@aws-amplify/data-schema 1.20.4 → 1.20.5

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.4",
3
+ "version": "1.20.5",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -897,6 +897,7 @@ function mapToNativeAppSyncAuthDirectives(
897
897
  const rules = new Set<string>();
898
898
 
899
899
  const groupProvider: Map<string, Set<string>> = new Map();
900
+ const generalProviderUsed = new Set<string>();
900
901
 
901
902
  for (const entry of authorization) {
902
903
  const rule = accessData(entry);
@@ -911,17 +912,20 @@ function mapToNativeAppSyncAuthDirectives(
911
912
  };
912
913
  rule.groups.forEach((group) => groupProvider.get(provider)?.add(group));
913
914
  } else {
915
+ generalProviderUsed.add(provider);
914
916
  rules.add(provider);
915
917
  }
916
918
  }
917
919
 
918
920
  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"])
921
+ if(!generalProviderUsed.has(provider)) {
922
+ rules.add(
923
+ `${provider}(cognito_groups: [${Array.from(groups).reduce((acc, group) =>
924
+ acc == "" ? `"${group}"` : `${acc}, "${group}"`
925
+ , "")}])`
926
+ );
927
+ // example: (cognito_groups: ["Bloggers", "Readers"])
928
+ }
925
929
  })
926
930
 
927
931
  const authString = [...rules].join(' ');