@aws-amplify/data-schema 1.3.4 → 1.3.6
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/dist/cjs/SchemaProcessor.js +36 -6
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/runtime/internals/APIClient.js +1 -1
- package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
- package/dist/esm/SchemaProcessor.mjs +37 -7
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/runtime/internals/APIClient.mjs +1 -1
- package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/SchemaProcessor.ts +46 -8
- package/src/runtime/internals/APIClient.ts +1 -1
package/package.json
CHANGED
package/src/SchemaProcessor.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type InternalField,
|
|
5
5
|
string,
|
|
6
6
|
type BaseModelField,
|
|
7
|
+
ModelFieldType,
|
|
7
8
|
} from './ModelField';
|
|
8
9
|
import { type InternalRelationalField } from './ModelRelationalField';
|
|
9
10
|
import type { InternalModel } from './ModelType';
|
|
@@ -484,6 +485,34 @@ function escapeGraphQlString(str: string) {
|
|
|
484
485
|
return JSON.stringify(str);
|
|
485
486
|
}
|
|
486
487
|
|
|
488
|
+
/**
|
|
489
|
+
* AWS AppSync scalars that are stored as strings in the data source
|
|
490
|
+
*/
|
|
491
|
+
const stringFieldTypes = {
|
|
492
|
+
ID: true,
|
|
493
|
+
String: true,
|
|
494
|
+
AWSDate: true,
|
|
495
|
+
AWSTime: true,
|
|
496
|
+
AWSDateTime: true,
|
|
497
|
+
AWSEmail: true,
|
|
498
|
+
AWSPhone: true,
|
|
499
|
+
AWSURL: true,
|
|
500
|
+
AWSIPAddress: true,
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Normalize string-compatible field types for comparison
|
|
505
|
+
*/
|
|
506
|
+
const normalizeStringFieldTypes = (
|
|
507
|
+
fieldType: ModelFieldType,
|
|
508
|
+
): ModelFieldType => {
|
|
509
|
+
if (fieldType in stringFieldTypes) {
|
|
510
|
+
return ModelFieldType.String;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return fieldType;
|
|
514
|
+
};
|
|
515
|
+
|
|
487
516
|
/**
|
|
488
517
|
* Tests whether two ModelField definitions are in conflict.
|
|
489
518
|
*
|
|
@@ -496,15 +525,24 @@ function escapeGraphQlString(str: string) {
|
|
|
496
525
|
* @returns
|
|
497
526
|
*/
|
|
498
527
|
function areConflicting(left: BaseModelField, right: BaseModelField): boolean {
|
|
499
|
-
|
|
528
|
+
const leftData = (left as InternalField).data;
|
|
529
|
+
const rightData = (right as InternalField).data;
|
|
530
|
+
|
|
531
|
+
// `array` and `fieldType` are the only props we care about for this comparison, because the others
|
|
500
532
|
// (required, arrayRequired, etc) are not specified on auth or FK directives.
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
533
|
+
if (leftData.array !== rightData.array) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Convert "string-compatible" field types to `String` for the sake of this comparison
|
|
538
|
+
//
|
|
539
|
+
// E.g. if a customer has an explicit a.id() field that they're referencing in an allow.ownerDefinedIn rule
|
|
540
|
+
// we treat ID and String as equivalent/non-conflicting
|
|
541
|
+
if (
|
|
542
|
+
normalizeStringFieldTypes(leftData.fieldType) !==
|
|
543
|
+
normalizeStringFieldTypes(rightData.fieldType)
|
|
544
|
+
) {
|
|
545
|
+
return true;
|
|
508
546
|
}
|
|
509
547
|
|
|
510
548
|
return false;
|