@aws-amplify/data-schema 0.14.3 → 0.14.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.
@@ -23,6 +23,7 @@ function internalCombine(schemas) {
23
23
  },
24
24
  models: schemas.reduce((prev, schema) => ({ ...prev, ...schema.models }), {}),
25
25
  transform() {
26
+ validateDuplicateTypeNames(schemas);
26
27
  const baseDefinition = {
27
28
  functionSlots: [],
28
29
  jsFunctions: [],
@@ -53,3 +54,19 @@ function internalCombine(schemas) {
53
54
  ...exports.combinedSchemaBrand,
54
55
  };
55
56
  }
57
+ function validateDuplicateTypeNames(schemas) {
58
+ const allSchemaKeys = schemas.flatMap((s) => Object.keys(s.data.types));
59
+ const keySet = new Set();
60
+ const duplicateKeySet = new Set();
61
+ allSchemaKeys.forEach((key) => {
62
+ if (keySet.has(key)) {
63
+ duplicateKeySet.add(key);
64
+ }
65
+ else {
66
+ keySet.add(key);
67
+ }
68
+ });
69
+ if (duplicateKeySet.size > 0) {
70
+ throw new Error(`The schemas you are attempting to combine have a name collision. Please remove or rename ${Array.from(duplicateKeySet).join(', ')}.`);
71
+ }
72
+ }
@@ -25,16 +25,21 @@ type BackendSecret = {
25
25
  resolvePath: (backendIdentifier: any) => any;
26
26
  };
27
27
  export type DatasourceEngine = 'mysql' | 'postgresql' | 'dynamodb';
28
+ type SubnetAZ = {
29
+ subnetId: string;
30
+ availabilityZone: string;
31
+ };
32
+ type VpcConfig = {
33
+ vpcId: string;
34
+ securityGroupIds: string[];
35
+ subnetAvailabilityZones: SubnetAZ[];
36
+ };
28
37
  type DatasourceConfig<DE extends DatasourceEngine> = DE extends 'dynamodb' ? {
29
38
  engine: DE;
30
39
  } : {
31
40
  engine: DE;
32
- hostname: BackendSecret;
33
- username: BackendSecret;
34
- password: BackendSecret;
35
- port: BackendSecret;
36
- databaseName: BackendSecret;
37
- vpcConfig?: Record<string, never>;
41
+ connectionUri: BackendSecret;
42
+ vpcConfig?: VpcConfig;
38
43
  };
39
44
  export type SchemaConfig<DE extends DatasourceEngine, DC extends DatasourceConfig<DE>> = {
40
45
  database: DC;