@aws-amplify/data-schema 1.20.0 → 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.
|
@@ -600,19 +600,26 @@ function getAppSyncAuthDirectiveFromRule(rule) {
|
|
|
600
600
|
}
|
|
601
601
|
function mapToNativeAppSyncAuthDirectives(authorization, isCustomHandler) {
|
|
602
602
|
const rules = new Set();
|
|
603
|
+
const groupProvider = new Map();
|
|
603
604
|
for (const entry of authorization) {
|
|
604
605
|
const rule = accessData(entry);
|
|
605
606
|
isCustomHandler && validateCustomHandlerAuthRule(rule);
|
|
606
607
|
const provider = getAppSyncAuthDirectiveFromRule(rule);
|
|
607
608
|
if (rule.groups) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
609
|
+
if (!groupProvider.has(provider)) {
|
|
610
|
+
groupProvider.set(provider, new Set());
|
|
611
|
+
}
|
|
612
|
+
rule.groups.forEach((group) => groupProvider.get(provider)?.add(group));
|
|
612
613
|
}
|
|
613
614
|
else {
|
|
614
615
|
rules.add(provider);
|
|
615
616
|
}
|
|
617
|
+
groupProvider.forEach((groups, provider) => {
|
|
618
|
+
rules.add(`${provider}(cognito_groups: [${Array.from(groups)
|
|
619
|
+
.map((group) => `"${group}"`)
|
|
620
|
+
.join(', ')}])`);
|
|
621
|
+
// example: (cognito_groups: ["Bloggers", "Readers"])
|
|
622
|
+
});
|
|
616
623
|
}
|
|
617
624
|
const authString = [...rules].join(' ');
|
|
618
625
|
return { authString };
|
|
@@ -947,8 +954,19 @@ function generateInputTypes(operationName, args, getRefType) {
|
|
|
947
954
|
if (isRefField(argDef)) {
|
|
948
955
|
const refType = getRefType(argDef.data.link, operationName);
|
|
949
956
|
if (refType.type === 'CustomType') {
|
|
957
|
+
const { valueRequired, array, arrayRequired } = argDef.data;
|
|
950
958
|
const inputTypeName = `${argDef.data.link}Input`;
|
|
951
|
-
|
|
959
|
+
let field = inputTypeName;
|
|
960
|
+
if (valueRequired === true) {
|
|
961
|
+
field += '!';
|
|
962
|
+
}
|
|
963
|
+
if (array) {
|
|
964
|
+
field = `[${field}]`;
|
|
965
|
+
if (arrayRequired === true) {
|
|
966
|
+
field += '!';
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
argDefinitions.push(`${argName}: ${field}`);
|
|
952
970
|
// Process the input type if it hasn't been processed yet
|
|
953
971
|
if (!processedTypes.has(inputTypeName)) {
|
|
954
972
|
processedTypes.add(inputTypeName);
|
|
@@ -960,7 +978,18 @@ function generateInputTypes(operationName, args, getRefType) {
|
|
|
960
978
|
}
|
|
961
979
|
}
|
|
962
980
|
else if (refType.type === 'Enum') {
|
|
963
|
-
|
|
981
|
+
const { valueRequired, array, arrayRequired } = argDef.data;
|
|
982
|
+
let field = argDef.data.link;
|
|
983
|
+
if (valueRequired === true) {
|
|
984
|
+
field += '!';
|
|
985
|
+
}
|
|
986
|
+
if (array) {
|
|
987
|
+
field = `[${field}]`;
|
|
988
|
+
if (arrayRequired === true) {
|
|
989
|
+
field += '!';
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
argDefinitions.push(`${argName}: ${field}`);
|
|
964
993
|
}
|
|
965
994
|
else {
|
|
966
995
|
throw new Error(`Unsupported reference type '${refType.type}' for argument '${argName}' in '${operationName}'. ` +
|