@aws-amplify/data-schema 1.20.1 → 1.20.3

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.3",
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,24 @@ function mapToNativeAppSyncAuthDirectives(
904
906
  const provider = getAppSyncAuthDirectiveFromRule(rule);
905
907
 
906
908
  if (rule.groups) {
907
- // example: (cognito_groups: ["Bloggers", "Readers"])
908
- rules.add(
909
- `${provider}(cognito_groups: [${rule.groups
910
- .map((group) => `"${group}"`)
911
- .join(', ')}])`,
912
- );
909
+ if(!groupProvider.has(provider)) {
910
+ groupProvider.set(provider, new Set());
911
+ };
912
+ rule.groups.forEach((group) => groupProvider.get(provider)?.add(group));
913
913
  } else {
914
914
  rules.add(provider);
915
915
  }
916
916
  }
917
917
 
918
+ groupProvider.forEach((groups, provider) => {
919
+ rules.add(
920
+ `${provider}(cognito_groups: [${Array.from(groups)
921
+ .map((group) => `"${group}"`)
922
+ .join(', ')}])`,
923
+ );
924
+ // example: (cognito_groups: ["Bloggers", "Readers"])
925
+ })
926
+
918
927
  const authString = [...rules].join(' ');
919
928
 
920
929
  return { authString };