@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
package/src/SchemaProcessor.ts
CHANGED
|
@@ -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
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
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 };
|