diff --git a/.github/workflows/component-ci.yml b/.github/workflows/component-ci.yml new file mode 100644 index 0000000..7f0e84f --- /dev/null +++ b/.github/workflows/component-ci.yml @@ -0,0 +1,14 @@ +name: Iconica Standard Component CI Workflow +# Workflow Caller version: 2.0.0 + +on: + pull_request: + workflow_dispatch: + +jobs: + call-global-iconica-workflow: + uses: Iconica-Development/.github/.github/workflows/component-ci.yml@master + secrets: inherit + permissions: write-all + with: + subfolder: '.' # add optional subfolder to run workflow in \ No newline at end of file diff --git a/.github/workflows/component-documentation.yml b/.github/workflows/component-documentation.yml new file mode 100644 index 0000000..c12e46a --- /dev/null +++ b/.github/workflows/component-documentation.yml @@ -0,0 +1,14 @@ +name: Iconica Standard Component Documentation Workflow +# Workflow Caller version: 1.0.0 + +on: + release: + types: [published] + + workflow_dispatch: + +jobs: + call-iconica-component-documentation-workflow: + uses: Iconica-Development/.github/.github/workflows/component-documentation.yml@master + secrets: inherit + permissions: write-all diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1702e56 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,15 @@ +name: Iconica Standard Component Release Workflow +# Workflow Caller version: 1.0.0 + +on: + release: + types: [published] + + workflow_dispatch: + +jobs: + call-global-iconica-workflow: + uses: Iconica-Development/.github/.github/workflows/component-release.yml@master + secrets: inherit + permissions: write-all + diff --git a/lib/src/dart_frog_utils.dart b/lib/src/dart_frog_utils.dart index 924bdf6..b622fec 100644 --- a/lib/src/dart_frog_utils.dart +++ b/lib/src/dart_frog_utils.dart @@ -1,4 +1,3 @@ -export "dart_utils/select_map.dart"; export "exception_handling/exception_handler.dart"; export "exceptions/exceptions.dart"; export "extensions/method.dart"; diff --git a/lib/src/dart_utils/select_map.dart b/lib/src/dart_utils/select_map.dart deleted file mode 100644 index ce8385b..0000000 --- a/lib/src/dart_utils/select_map.dart +++ /dev/null @@ -1,146 +0,0 @@ -extension SelectFields on Map { - /// Selects values in a map, if any match the given [paths]. - /// - /// [paths] needs to be a list of strings with a . delimiter. The delimiter - /// can be changed, if the keys also contain the delimiter. - /// - /// Selecting a child value from an inner map will automatically include the - /// property that contains the full map, but only the inner map. - /// - /// Even for lists, you can select the objects internally if those objects - /// are included. If the selector results in an empty list or empty map, it - /// will automatically remove those from the returned value. - /// - Map select( - List paths, { - String delimiter = ".", - Map>? preCalculatedSeperated, - }) { - Map> seperateCurrent(List paths) { - final splitPaths = paths.map((item) => item.split(delimiter)); - return splitPaths.fold(>{}, (map, split) { - if (split.isEmpty) return map; - final current = split.first; - - final remaining = split.sublist(1).join(delimiter); - final currentMap = map[current] ??= []; - if (remaining.isNotEmpty) { - currentMap.add(remaining); - } - return map; - }); - } - - final propertyJoinedPaths = - preCalculatedSeperated ?? seperateCurrent(paths); - - dynamic handleChildren(String key, List remainingPaths) { - final value = this[key]; - - if (remainingPaths.isEmpty) { - return value; - } - - if (value is Map) { - final selected = value.select( - remainingPaths, - ); - if (selected.isEmpty) { - return null; - } - - return selected; - } - - if (value is List) { - final preCalculatedSeperated = seperateCurrent(remainingPaths); - return value - .whereType>() - .map( - (item) => item.select( - remainingPaths, - preCalculatedSeperated: preCalculatedSeperated, - ), - ) - .where((item) => item.isNotEmpty) - .toList(); - } - - return value; - } - - final createdMap = { - for (final entry in propertyJoinedPaths.entries) - if (this[entry.key] != null) - entry.key: handleChildren(entry.key, entry.value), - }; - - return createdMap; - } -} - -extension OmitFields on Map { - Map omit( - List paths, { - String delimiter = ".", - Map>? preCalculatedSeperated, - }) { - Map> seperateCurrent(List paths) { - final splitPaths = paths.map((item) => item.split(delimiter)); - return splitPaths.fold(>{}, (map, split) { - if (split.isEmpty) return map; - final current = split.first; - - final remaining = split.sublist(1).join(delimiter); - final currentMap = map[current] ??= []; - if (remaining.isNotEmpty) { - currentMap.add(remaining); - } - return map; - }); - } - - final separated = preCalculatedSeperated ?? seperateCurrent(paths); - - bool isOmitted(MapEntry entry) { - final paths = separated[entry.key]; - - if (paths == null) return false; - if (paths.isNotEmpty) return false; - return true; - } - - dynamic handleChildren(MapEntry entry) { - final paths = separated[entry.key]; - final value = entry.value; - - if (paths == null || paths.isEmpty) { - return entry.value; - } - - if (value is Map) { - return value.omit(paths); - } - - if (value is List) { - final preCalculatedSeperated = seperateCurrent(paths); - return value - .whereType>() - .map( - (item) => item.omit( - paths, - preCalculatedSeperated: preCalculatedSeperated, - ), - ) - .where((item) => item.isNotEmpty) - .toList(); - } - return value; - } - - return { - for (final entry in entries) - if (!isOmitted(entry)) entry.key: handleChildren(entry), - }; - } -} diff --git a/lib/src/serializers/base_serializer.dart b/lib/src/serializers/base_serializer.dart index ac2b1a2..68f6fca 100644 --- a/lib/src/serializers/base_serializer.dart +++ b/lib/src/serializers/base_serializer.dart @@ -1,5 +1,6 @@ import "package:dart_frog/dart_frog.dart"; import "package:dart_frog_utils/dart_frog_utils.dart"; +import "package:dart_iconica_utilities/dart_iconica_utilities.dart"; /// class Serializer { diff --git a/lib/src/views/base_view.dart b/lib/src/views/base_view.dart index aaccbe8..9f3762b 100644 --- a/lib/src/views/base_view.dart +++ b/lib/src/views/base_view.dart @@ -80,6 +80,7 @@ mixin PostMixin on BaseView { /// mixin GetMixin on BaseView { + /// FutureOr get(RequestContext context); @override