@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.
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,25 @@ function mapToNativeAppSyncAuthDirectives(
|
|
|
904
906
|
const provider = getAppSyncAuthDirectiveFromRule(rule);
|
|
905
907
|
|
|
906
908
|
if (rule.groups) {
|
|
907
|
-
|
|
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: [${
|
|
919
|
+
`${provider}(cognito_groups: [${Array.from(groups)
|
|
910
920
|
.map((group) => `"${group}"`)
|
|
911
921
|
.join(', ')}])`,
|
|
912
922
|
);
|
|
913
|
-
|
|
914
|
-
|
|
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 };
|
|
@@ -1444,8 +1454,24 @@ function generateInputTypes(
|
|
|
1444
1454
|
if (isRefField(argDef)) {
|
|
1445
1455
|
const refType = getRefType(argDef.data.link, operationName);
|
|
1446
1456
|
if (refType.type === 'CustomType') {
|
|
1457
|
+
const { valueRequired, array, arrayRequired } = argDef.data;
|
|
1458
|
+
|
|
1447
1459
|
const inputTypeName = `${argDef.data.link}Input`;
|
|
1448
|
-
|
|
1460
|
+
let field = inputTypeName;
|
|
1461
|
+
|
|
1462
|
+
if (valueRequired === true) {
|
|
1463
|
+
field += '!';
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
if (array) {
|
|
1467
|
+
field = `[${field}]`;
|
|
1468
|
+
|
|
1469
|
+
if (arrayRequired === true) {
|
|
1470
|
+
field += '!';
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
argDefinitions.push(`${argName}: ${field}`);
|
|
1449
1475
|
|
|
1450
1476
|
// Process the input type if it hasn't been processed yet
|
|
1451
1477
|
if (!processedTypes.has(inputTypeName)) {
|
|
@@ -1462,7 +1488,23 @@ function generateInputTypes(
|
|
|
1462
1488
|
});
|
|
1463
1489
|
}
|
|
1464
1490
|
} else if (refType.type === 'Enum') {
|
|
1465
|
-
|
|
1491
|
+
const { valueRequired, array, arrayRequired } = argDef.data;
|
|
1492
|
+
|
|
1493
|
+
let field = argDef.data.link;
|
|
1494
|
+
|
|
1495
|
+
if (valueRequired === true) {
|
|
1496
|
+
field += '!';
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
if (array) {
|
|
1500
|
+
field = `[${field}]`;
|
|
1501
|
+
|
|
1502
|
+
if (arrayRequired === true) {
|
|
1503
|
+
field += '!';
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
argDefinitions.push(`${argName}: ${field}`);
|
|
1466
1508
|
} else {
|
|
1467
1509
|
throw new Error(
|
|
1468
1510
|
`Unsupported reference type '${refType.type}' for argument '${argName}' in '${operationName}'. ` +
|