@aws-amplify/data-schema 1.20.1 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/data-schema",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -896,6 +896,8 @@ function mapToNativeAppSyncAuthDirectives(
896
896
  ) {
897
897
  const rules = new Set<string>();
898
898
 
899
+ const groupProvider: Map<string, Set<string>> = new Map();
900
+
899
901
  for (const entry of authorization) {
900
902
  const rule = accessData(entry);
901
903
 
@@ -904,17 +906,25 @@ function mapToNativeAppSyncAuthDirectives(
904
906
  const provider = getAppSyncAuthDirectiveFromRule(rule);
905
907
 
906
908
  if (rule.groups) {
907
- // example: (cognito_groups: ["Bloggers", "Readers"])
909
+ if(!groupProvider.has(provider)) {
910
+ groupProvider.set(provider, new Set());
911
+ };
912
+ rule.groups.forEach((group) => groupProvider.get(provider)?.add(group));
913
+ } else {
914
+ rules.add(provider);
915
+ }
916
+
917
+ groupProvider.forEach((groups, provider) => {
908
918
  rules.add(
909
- `${provider}(cognito_groups: [${rule.groups
919
+ `${provider}(cognito_groups: [${Array.from(groups)
910
920
  .map((group) => `"${group}"`)
911
921
  .join(', ')}])`,
912
922
  );
913
- } else {
914
- rules.add(provider);
915
- }
923
+ // example: (cognito_groups: ["Bloggers", "Readers"])
924
+ })
916
925
  }
917
926
 
927
+
918
928
  const authString = [...rules].join(' ');
919
929
 
920
930
  return { authString };