@api-client/core 0.19.30 → 0.19.32
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/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js +0 -8
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +4 -4
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/RuntimeApiModel.d.ts +16 -0
- package/build/src/modeling/RuntimeApiModel.d.ts.map +1 -1
- package/build/src/modeling/RuntimeApiModel.js +31 -0
- package/build/src/modeling/RuntimeApiModel.js.map +1 -1
- package/build/src/modeling/ai/domain_response_schema.d.ts +4 -2
- package/build/src/modeling/ai/domain_response_schema.d.ts.map +1 -1
- package/build/src/modeling/ai/domain_response_schema.js +1 -1
- package/build/src/modeling/ai/domain_response_schema.js.map +1 -1
- package/build/src/modeling/ai/types.d.ts +2 -3
- package/build/src/modeling/ai/types.d.ts.map +1 -1
- package/build/src/modeling/ai/types.js.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
- package/build/src/modeling/generators/oas_312/OasGenerator.js +1 -1
- package/build/src/modeling/generators/oas_312/OasGenerator.js.map +1 -1
- package/build/src/modeling/generators/oas_312/OasSchemaGenerator.js +3 -3
- package/build/src/modeling/generators/oas_312/OasSchemaGenerator.js.map +1 -1
- package/build/src/modeling/generators/oas_320/OasSchemaGenerator.js +3 -3
- package/build/src/modeling/generators/oas_320/OasSchemaGenerator.js.map +1 -1
- package/build/src/modeling/types.d.ts +55 -15
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -1
- package/build/src/modeling/validation/api_model_rules.js +49 -46
- package/build/src/modeling/validation/api_model_rules.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modeling/ApiModel.ts +0 -10
- package/src/modeling/DomainAssociation.ts +4 -4
- package/src/modeling/RuntimeApiModel.ts +46 -0
- package/src/modeling/ai/domain_response_schema.ts +1 -1
- package/src/modeling/ai/types.ts +2 -3
- package/src/modeling/amf/ShapeGenerator.ts +1 -1
- package/src/modeling/generators/oas_312/OasGenerator.ts +1 -1
- package/src/modeling/generators/oas_312/OasSchemaGenerator.ts +3 -3
- package/src/modeling/generators/oas_320/OasSchemaGenerator.ts +3 -3
- package/src/modeling/readme.md +2 -2
- package/src/modeling/types.ts +56 -15
- package/src/modeling/validation/api_model_rules.ts +50 -48
- package/src/modeling/validation/api_model_validation_rules.md +2 -2
- package/tests/unit/modeling/RuntimeApiModel.spec.ts +31 -0
- package/tests/unit/modeling/amf/shape_generator.spec.ts +32 -14
- package/tests/unit/modeling/api_model.spec.ts +6 -6
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +1 -1
- package/tests/unit/modeling/domain_asociation.spec.ts +18 -18
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +68 -23
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +32 -9
- package/tests/unit/modeling/generators/OasGenerator.spec.ts +3 -5
- package/tests/unit/modeling/validation/api_model_rules.spec.ts +12 -12
|
@@ -762,6 +762,9 @@ test.group('associationProperty()', (group) => {
|
|
|
762
762
|
})
|
|
763
763
|
|
|
764
764
|
test('returns basic shape definition', ({ assert }) => {
|
|
765
|
+
a1.schema = {
|
|
766
|
+
embedded: true,
|
|
767
|
+
}
|
|
765
768
|
const result = a1.toApiShape()
|
|
766
769
|
assert.typeOf(result, 'object')
|
|
767
770
|
|
|
@@ -812,8 +815,8 @@ test.group('associationProperty()', (group) => {
|
|
|
812
815
|
assert.equal(result.path, AmfNamespace.aml.vocabularies.data.key + 'a1', 'has the path')
|
|
813
816
|
})
|
|
814
817
|
|
|
815
|
-
test('returns a
|
|
816
|
-
a1.schema = {
|
|
818
|
+
test('returns a reference definition when not embedded', ({ assert }) => {
|
|
819
|
+
a1.schema = { embedded: false }
|
|
817
820
|
const result = a1.toApiShape()
|
|
818
821
|
const range = result.range as Shapes.IApiScalarShape
|
|
819
822
|
assert.equal(range.id, `link-${a1.key}`)
|
|
@@ -824,6 +827,9 @@ test.group('associationProperty()', (group) => {
|
|
|
824
827
|
test('returns a default union type', ({ assert }) => {
|
|
825
828
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
826
829
|
a1.addTarget(e3)
|
|
830
|
+
a1.schema = {
|
|
831
|
+
embedded: true,
|
|
832
|
+
}
|
|
827
833
|
const result = a1.toApiShape()
|
|
828
834
|
const range = result.range as Shapes.IApiUnionShape
|
|
829
835
|
|
|
@@ -841,12 +847,18 @@ test.group('associationProperty()', (group) => {
|
|
|
841
847
|
|
|
842
848
|
test('has no range when no associations', ({ assert }) => {
|
|
843
849
|
a1.removeTarget(e2)
|
|
850
|
+
a1.schema = {
|
|
851
|
+
embedded: true,
|
|
852
|
+
}
|
|
844
853
|
const result = a1.toApiShape()
|
|
845
854
|
assert.isUndefined(result.range)
|
|
846
855
|
})
|
|
847
856
|
|
|
848
857
|
test('returns an array shape when multiple', ({ assert }) => {
|
|
849
858
|
a1.multiple = true
|
|
859
|
+
a1.schema = {
|
|
860
|
+
embedded: true,
|
|
861
|
+
}
|
|
850
862
|
const result = a1.toApiShape()
|
|
851
863
|
const range = result.range as Shapes.IApiArrayShape
|
|
852
864
|
assert.deepEqual(range.types, AmfTypes.IAmfArrayTypes)
|
|
@@ -859,7 +871,7 @@ test.group('associationProperty()', (group) => {
|
|
|
859
871
|
})
|
|
860
872
|
|
|
861
873
|
test('creates the "anyOf" union', ({ assert }) => {
|
|
862
|
-
a1.schema = { unionType: 'anyOf' }
|
|
874
|
+
a1.schema = { unionType: 'anyOf', embedded: true }
|
|
863
875
|
|
|
864
876
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
865
877
|
a1.addTarget(e3)
|
|
@@ -879,7 +891,7 @@ test.group('associationProperty()', (group) => {
|
|
|
879
891
|
})
|
|
880
892
|
|
|
881
893
|
test('creates the "allOf" union', ({ assert }) => {
|
|
882
|
-
a1.schema = { unionType: 'allOf' }
|
|
894
|
+
a1.schema = { unionType: 'allOf', embedded: true }
|
|
883
895
|
|
|
884
896
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
885
897
|
a1.addTarget(e3)
|
|
@@ -899,7 +911,7 @@ test.group('associationProperty()', (group) => {
|
|
|
899
911
|
})
|
|
900
912
|
|
|
901
913
|
test('creates the "oneOf" union', ({ assert }) => {
|
|
902
|
-
a1.schema = { unionType: 'oneOf' }
|
|
914
|
+
a1.schema = { unionType: 'oneOf', embedded: true }
|
|
903
915
|
|
|
904
916
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
905
917
|
a1.addTarget(e3)
|
|
@@ -919,7 +931,7 @@ test.group('associationProperty()', (group) => {
|
|
|
919
931
|
})
|
|
920
932
|
|
|
921
933
|
test('creates the "not" union', ({ assert }) => {
|
|
922
|
-
a1.schema = { unionType: 'not' }
|
|
934
|
+
a1.schema = { unionType: 'not', embedded: true }
|
|
923
935
|
|
|
924
936
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
925
937
|
a1.addTarget(e3)
|
|
@@ -938,7 +950,7 @@ test.group('associationProperty()', (group) => {
|
|
|
938
950
|
})
|
|
939
951
|
|
|
940
952
|
test('creates the "not" shape', ({ assert }) => {
|
|
941
|
-
a1.schema = { unionType: 'not' }
|
|
953
|
+
a1.schema = { unionType: 'not', embedded: true }
|
|
942
954
|
|
|
943
955
|
const result = a1.toApiShape()
|
|
944
956
|
const range = result.range as Shapes.IApiUnionShape
|
|
@@ -956,7 +968,7 @@ test.group('associationProperty()', (group) => {
|
|
|
956
968
|
|
|
957
969
|
test('wraps the union in the array shape', ({ assert }) => {
|
|
958
970
|
a1.multiple = true
|
|
959
|
-
a1.schema = { unionType: 'anyOf' }
|
|
971
|
+
a1.schema = { unionType: 'anyOf', embedded: true }
|
|
960
972
|
|
|
961
973
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
962
974
|
a1.addTarget(e3)
|
|
@@ -978,8 +990,8 @@ test.group('associationProperty()', (group) => {
|
|
|
978
990
|
assert.lengthOf(p2.properties, 0, 'p2 has the properties')
|
|
979
991
|
})
|
|
980
992
|
|
|
981
|
-
test('handles
|
|
982
|
-
a1.schema = {
|
|
993
|
+
test('handles not embedded schema', ({ assert }) => {
|
|
994
|
+
a1.schema = { embedded: false }
|
|
983
995
|
const result = a1.toApiShape()
|
|
984
996
|
const range = result.range as Shapes.IApiScalarShape
|
|
985
997
|
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.string)
|
|
@@ -988,13 +1000,16 @@ test.group('associationProperty()', (group) => {
|
|
|
988
1000
|
test('handles multiple associations', ({ assert }) => {
|
|
989
1001
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
990
1002
|
a1.addTarget(e3)
|
|
1003
|
+
a1.schema = {
|
|
1004
|
+
embedded: true,
|
|
1005
|
+
}
|
|
991
1006
|
const result = a1.toApiShape()
|
|
992
1007
|
const range = result.range as Shapes.IApiUnionShape
|
|
993
1008
|
assert.lengthOf(range.anyOf, 2)
|
|
994
1009
|
})
|
|
995
1010
|
|
|
996
1011
|
test('handles unionType', ({ assert }) => {
|
|
997
|
-
a1.schema = { unionType: 'allOf' }
|
|
1012
|
+
a1.schema = { unionType: 'allOf', embedded: true }
|
|
998
1013
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
999
1014
|
a1.addTarget(e3)
|
|
1000
1015
|
const result = a1.toApiShape()
|
|
@@ -1004,7 +1019,7 @@ test.group('associationProperty()', (group) => {
|
|
|
1004
1019
|
|
|
1005
1020
|
test('handles multiple and unionType', ({ assert }) => {
|
|
1006
1021
|
a1.multiple = true
|
|
1007
|
-
a1.schema = { unionType: 'allOf' }
|
|
1022
|
+
a1.schema = { unionType: 'allOf', embedded: true }
|
|
1008
1023
|
const e3 = m1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
1009
1024
|
a1.addTarget(e3)
|
|
1010
1025
|
const result = a1.toApiShape()
|
|
@@ -1119,9 +1134,9 @@ test.group('AI Generated tests', (group) => {
|
|
|
1119
1134
|
assert.equal(items.format, AmfNamespace.w3.xmlSchema.integer)
|
|
1120
1135
|
})
|
|
1121
1136
|
|
|
1122
|
-
test('handles multiple associations
|
|
1137
|
+
test('handles multiple associations not embedded', ({ assert }) => {
|
|
1123
1138
|
a1.multiple = true
|
|
1124
|
-
a1.schema = {
|
|
1139
|
+
a1.schema = { embedded: true }
|
|
1125
1140
|
const result = a1.toApiShape()
|
|
1126
1141
|
const range = result.range as Shapes.IApiArrayShape
|
|
1127
1142
|
assert.include(range.types, AmfNamespace.aml.vocabularies.shapes.ArrayShape)
|
|
@@ -1139,6 +1154,9 @@ test.group('AI Generated tests', (group) => {
|
|
|
1139
1154
|
},
|
|
1140
1155
|
},
|
|
1141
1156
|
]
|
|
1157
|
+
a1.schema = {
|
|
1158
|
+
embedded: true,
|
|
1159
|
+
}
|
|
1142
1160
|
const result = a1.toApiShape()
|
|
1143
1161
|
const range = result.range as Shapes.IApiArrayShape
|
|
1144
1162
|
assert.include(range.types, AmfNamespace.aml.vocabularies.shapes.ArrayShape)
|
|
@@ -53,7 +53,7 @@ test.group('ApiModel.createSchema()', () => {
|
|
|
53
53
|
user: { key: 'user-entity' },
|
|
54
54
|
dependencyList: [{ key: 'domain1', version: '1.0.0' }],
|
|
55
55
|
authentication: { strategy: 'UsernamePassword' },
|
|
56
|
-
authorization: { strategy: 'RBAC'
|
|
56
|
+
authorization: { strategy: 'RBAC' } as RolesBasedAccessControl,
|
|
57
57
|
session: { secret: 'secret', properties: ['email'] },
|
|
58
58
|
accessRule: [{ type: 'public' }],
|
|
59
59
|
rateLimiting: { rules: [] },
|
|
@@ -72,7 +72,7 @@ test.group('ApiModel.createSchema()', () => {
|
|
|
72
72
|
assert.deepEqual(schema.user, { key: 'user-entity' })
|
|
73
73
|
assert.deepEqual(schema.dependencyList, [{ key: 'domain1', version: '1.0.0' }])
|
|
74
74
|
assert.deepEqual(schema.authentication, { strategy: 'UsernamePassword' })
|
|
75
|
-
assert.deepEqual(schema.authorization, { strategy: 'RBAC'
|
|
75
|
+
assert.deepEqual(schema.authorization, { strategy: 'RBAC' })
|
|
76
76
|
assert.deepEqual(schema.session, { secret: 'secret', properties: ['email'] })
|
|
77
77
|
assert.deepEqual(schema.accessRule, [{ type: 'public' }])
|
|
78
78
|
assert.deepEqual(schema.rateLimiting, { rules: [] })
|
|
@@ -132,7 +132,7 @@ test.group('ApiModel.constructor()', () => {
|
|
|
132
132
|
user: { key: 'user-entity' },
|
|
133
133
|
dependencyList: [{ key: 'domain1', version: '1.0.0' }],
|
|
134
134
|
authentication: { strategy: 'UsernamePassword' },
|
|
135
|
-
authorization: { strategy: 'RBAC'
|
|
135
|
+
authorization: { strategy: 'RBAC' } as RolesBasedAccessControl,
|
|
136
136
|
session: { secret: 'secret', properties: ['email'] },
|
|
137
137
|
accessRule: [{ type: 'allowPublic' }],
|
|
138
138
|
rateLimiting: { rules: [] },
|
|
@@ -150,7 +150,7 @@ test.group('ApiModel.constructor()', () => {
|
|
|
150
150
|
assert.deepEqual(model.user, { key: 'user-entity' })
|
|
151
151
|
assert.deepEqual(model.dependencyList, [{ key: 'domain1', version: '1.0.0' }])
|
|
152
152
|
assert.deepEqual(model.authentication, { strategy: 'UsernamePassword' })
|
|
153
|
-
assert.deepEqual(model.authorization, { strategy: 'RBAC'
|
|
153
|
+
assert.deepEqual(model.authorization, { strategy: 'RBAC' })
|
|
154
154
|
assert.deepEqual(model.session, { secret: 'secret', properties: ['email'] })
|
|
155
155
|
assert.deepEqual(model.accessRule, [new AllowPublicAccessRule(model)])
|
|
156
156
|
assert.deepEqual(model.rateLimiting, new RateLimitingConfiguration())
|
|
@@ -289,7 +289,7 @@ test.group('ApiModel.toJSON()', () => {
|
|
|
289
289
|
user: { key: 'user-entity' },
|
|
290
290
|
dependencyList: [{ key: 'domain1', version: '1.0.0' }],
|
|
291
291
|
authentication: { strategy: 'UsernamePassword' },
|
|
292
|
-
authorization: { strategy: 'RBAC'
|
|
292
|
+
authorization: { strategy: 'RBAC' } as RolesBasedAccessControl,
|
|
293
293
|
session: { secret: 'secret', properties: ['email'] },
|
|
294
294
|
accessRule: [{ type: 'allowPublic' }],
|
|
295
295
|
rateLimiting: { rules: [] },
|
|
@@ -308,7 +308,7 @@ test.group('ApiModel.toJSON()', () => {
|
|
|
308
308
|
assert.deepEqual(json.user, { key: 'user-entity' })
|
|
309
309
|
assert.deepEqual(json.dependencyList, [{ key: 'domain1', version: '1.0.0' }])
|
|
310
310
|
assert.deepEqual(json.authentication, { strategy: 'UsernamePassword' })
|
|
311
|
-
assert.deepEqual(json.authorization, { strategy: 'RBAC'
|
|
311
|
+
assert.deepEqual(json.authorization, { strategy: 'RBAC' })
|
|
312
312
|
assert.deepEqual(json.session, { secret: 'secret', properties: ['email'] })
|
|
313
313
|
assert.deepEqual(json.accessRule, [{ type: 'allowPublic' }])
|
|
314
314
|
assert.deepEqual(json.rateLimiting, { rules: [] })
|
|
@@ -664,7 +664,7 @@ test.group('DomainAssociation change observers', (g) => {
|
|
|
664
664
|
const e1 = m1.addEntity()
|
|
665
665
|
const a1 = e1.addAssociation()
|
|
666
666
|
await sleep(1)
|
|
667
|
-
a1.schema = {
|
|
667
|
+
a1.schema = { embedded: false }
|
|
668
668
|
await assert.dispatchCount(domain, 'change', 1, { timeout: 1 })
|
|
669
669
|
})
|
|
670
670
|
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
DataFormat,
|
|
9
9
|
SemanticType,
|
|
10
10
|
type OnDeleteRule,
|
|
11
|
+
type AssociationSchema,
|
|
11
12
|
} from '../../../src/index.js'
|
|
12
|
-
import { Shapes } from '@api-client/amf-core'
|
|
13
13
|
|
|
14
14
|
test.group('DomainAssociation.createSchema()', () => {
|
|
15
15
|
test('creates a valid schema with default values', ({ assert }) => {
|
|
@@ -58,7 +58,7 @@ test.group('DomainAssociation.createSchema()', () => {
|
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
test('creates a schema with provided schema', ({ assert }) => {
|
|
61
|
-
const schemaDefinition:
|
|
61
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
62
62
|
const schema = DomainAssociation.createSchema({ schema: schemaDefinition })
|
|
63
63
|
assert.deepEqual(schema.schema, schemaDefinition)
|
|
64
64
|
})
|
|
@@ -88,7 +88,7 @@ test.group('DomainAssociation.createSchema()', () => {
|
|
|
88
88
|
test('creates a schema with all properties', ({ assert }) => {
|
|
89
89
|
const key = 'test-key'
|
|
90
90
|
const info = { name: 'Test Association', description: 'Test description' }
|
|
91
|
-
const schemaDefinition:
|
|
91
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
92
92
|
const multiple = true
|
|
93
93
|
const required = true
|
|
94
94
|
const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
|
|
@@ -144,7 +144,7 @@ test.group('DomainAssociation.createSchema()', () => {
|
|
|
144
144
|
})
|
|
145
145
|
|
|
146
146
|
test('creates a schema with cloned schema', ({ assert }) => {
|
|
147
|
-
const schemaDefinition:
|
|
147
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
148
148
|
const schema = DomainAssociation.createSchema({ schema: schemaDefinition })
|
|
149
149
|
assert.deepEqual(schema.schema, schemaDefinition)
|
|
150
150
|
assert.notStrictEqual(schema.schema, schemaDefinition)
|
|
@@ -212,7 +212,7 @@ test.group('DomainAssociation.constructor()', () => {
|
|
|
212
212
|
test('creates an instance with provided schema', ({ assert }) => {
|
|
213
213
|
const dataDomain = new DataDomain()
|
|
214
214
|
const parentKey = 'test-parent'
|
|
215
|
-
const schemaDefinition:
|
|
215
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
216
216
|
const association = new DomainAssociation(dataDomain, parentKey, { schema: schemaDefinition })
|
|
217
217
|
assert.deepEqual(association.schema, schemaDefinition)
|
|
218
218
|
})
|
|
@@ -252,7 +252,7 @@ test.group('DomainAssociation.constructor()', () => {
|
|
|
252
252
|
const parentKey = 'test-parent'
|
|
253
253
|
const key = 'test-key'
|
|
254
254
|
const info = { name: 'Test Association', description: 'Test description' }
|
|
255
|
-
const schemaDefinition:
|
|
255
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
256
256
|
const multiple = true
|
|
257
257
|
const required = true
|
|
258
258
|
const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
|
|
@@ -316,7 +316,7 @@ test.group('DomainAssociation.constructor()', () => {
|
|
|
316
316
|
test('creates an instance with cloned schema', ({ assert }) => {
|
|
317
317
|
const dataDomain = new DataDomain()
|
|
318
318
|
const parentKey = 'test-parent'
|
|
319
|
-
const schemaDefinition:
|
|
319
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
320
320
|
const association = new DomainAssociation(dataDomain, parentKey, { schema: schemaDefinition })
|
|
321
321
|
assert.deepEqual(association.schema, schemaDefinition)
|
|
322
322
|
assert.notStrictEqual(association.schema, schemaDefinition)
|
|
@@ -390,7 +390,7 @@ test.group('DomainAssociation.toJSON()', () => {
|
|
|
390
390
|
test('returns a JSON representation with provided schema', ({ assert }) => {
|
|
391
391
|
const dataDomain = new DataDomain()
|
|
392
392
|
const parentKey = 'test-parent'
|
|
393
|
-
const schemaDefinition:
|
|
393
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
394
394
|
const association = new DomainAssociation(dataDomain, parentKey, { schema: schemaDefinition })
|
|
395
395
|
const json = association.toJSON()
|
|
396
396
|
assert.deepEqual(json.schema, schemaDefinition)
|
|
@@ -438,7 +438,7 @@ test.group('DomainAssociation.toJSON()', () => {
|
|
|
438
438
|
const parentKey = 'test-parent'
|
|
439
439
|
const key = 'test-key'
|
|
440
440
|
const info = { name: 'Test Association', description: 'Test description' }
|
|
441
|
-
const schemaDefinition:
|
|
441
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
442
442
|
const multiple = true
|
|
443
443
|
const required = true
|
|
444
444
|
const bindings: AssociationBinding[] = [{ type: 'web', schema: { hidden: false } }]
|
|
@@ -527,7 +527,7 @@ test.group('DomainAssociation.toJSON()', () => {
|
|
|
527
527
|
test('returns a JSON representation with cloned schema', ({ assert }) => {
|
|
528
528
|
const dataDomain = new DataDomain()
|
|
529
529
|
const parentKey = 'test-parent'
|
|
530
|
-
const schemaDefinition:
|
|
530
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
531
531
|
const association = new DomainAssociation(dataDomain, parentKey, { schema: schemaDefinition })
|
|
532
532
|
const json = association.toJSON()
|
|
533
533
|
assert.deepEqual(json.schema, schemaDefinition)
|
|
@@ -538,7 +538,7 @@ test.group('DomainAssociation.toJSON()', () => {
|
|
|
538
538
|
const dataDomain = new DataDomain()
|
|
539
539
|
const parentKey = 'test-parent'
|
|
540
540
|
const association = new DomainAssociation(dataDomain, parentKey)
|
|
541
|
-
const schemaDefinition:
|
|
541
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
542
542
|
association.schema = schemaDefinition
|
|
543
543
|
const json = association.toJSON()
|
|
544
544
|
assert.deepEqual(json.schema, schemaDefinition)
|
|
@@ -672,7 +672,7 @@ test.group('DomainAssociation.ensureSchema()', () => {
|
|
|
672
672
|
|
|
673
673
|
test('returns the existing schema object if it exists', ({ assert }) => {
|
|
674
674
|
const dataDomain = new DataDomain()
|
|
675
|
-
const schemaDefinition:
|
|
675
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
676
676
|
const association = new DomainAssociation(dataDomain, 'test-parent', { schema: schemaDefinition })
|
|
677
677
|
const originalSchema = association.schema
|
|
678
678
|
const schema = association.ensureSchema()
|
|
@@ -682,7 +682,7 @@ test.group('DomainAssociation.ensureSchema()', () => {
|
|
|
682
682
|
|
|
683
683
|
test('does not modify the existing schema object', ({ assert }) => {
|
|
684
684
|
const dataDomain = new DataDomain()
|
|
685
|
-
const schemaDefinition:
|
|
685
|
+
const schemaDefinition: AssociationSchema = { embedded: false }
|
|
686
686
|
const association = new DomainAssociation(dataDomain, 'test-parent', { schema: schemaDefinition })
|
|
687
687
|
const originalSchema = association.schema
|
|
688
688
|
association.ensureSchema()
|
|
@@ -1083,7 +1083,7 @@ test.group('DomainAssociation.duplicate()', () => {
|
|
|
1083
1083
|
association.readOnly = true
|
|
1084
1084
|
association.onDelete = 'cascade'
|
|
1085
1085
|
association.semantics = [{ id: SemanticType.ResourceOwnerIdentifier }]
|
|
1086
|
-
association.schema = {
|
|
1086
|
+
association.schema = { embedded: true, unionType: 'allOf' }
|
|
1087
1087
|
association.bindings = [{ type: 'web', schema: { hidden: true } }]
|
|
1088
1088
|
|
|
1089
1089
|
const duplicate = association.duplicate()
|
|
@@ -1095,7 +1095,7 @@ test.group('DomainAssociation.duplicate()', () => {
|
|
|
1095
1095
|
assert.equal(duplicate.readOnly, true)
|
|
1096
1096
|
assert.equal(duplicate.onDelete, 'cascade')
|
|
1097
1097
|
assert.deepEqual(duplicate.semantics, [{ id: SemanticType.ResourceOwnerIdentifier }])
|
|
1098
|
-
assert.deepEqual(duplicate.schema, {
|
|
1098
|
+
assert.deepEqual(duplicate.schema, { embedded: true, unionType: 'allOf' })
|
|
1099
1099
|
assert.deepEqual(duplicate.bindings, [{ type: 'web', schema: { hidden: true } }])
|
|
1100
1100
|
})
|
|
1101
1101
|
|
|
@@ -1107,17 +1107,17 @@ test.group('DomainAssociation.duplicate()', () => {
|
|
|
1107
1107
|
|
|
1108
1108
|
const association = entity.addAssociation({ targets: [{ key: targetEntity.key }] })
|
|
1109
1109
|
association.info.name = 'original'
|
|
1110
|
-
association.schema = {
|
|
1110
|
+
association.schema = { embedded: false, unionType: 'anyOf' }
|
|
1111
1111
|
association.bindings = [{ type: 'web', schema: { hidden: false } }]
|
|
1112
1112
|
|
|
1113
1113
|
const duplicate = association.duplicate()
|
|
1114
1114
|
|
|
1115
1115
|
// Modify original schema and bindings
|
|
1116
|
-
association.schema!.
|
|
1116
|
+
association.schema!.embedded = true
|
|
1117
1117
|
association.bindings[0].schema = { hidden: true }
|
|
1118
1118
|
|
|
1119
1119
|
// Duplicate should be unaffected
|
|
1120
|
-
assert.equal(duplicate.schema!.
|
|
1120
|
+
assert.equal(duplicate.schema!.embedded, false)
|
|
1121
1121
|
assert.deepEqual(duplicate.bindings[0].schema, { hidden: false })
|
|
1122
1122
|
})
|
|
1123
1123
|
|
|
@@ -730,7 +730,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
730
730
|
|
|
731
731
|
test('creates a property from an association', ({ assert }) => {
|
|
732
732
|
e2.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
|
|
733
|
-
e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
|
|
733
|
+
e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' }, schema: { embedded: true } })
|
|
734
734
|
|
|
735
735
|
const result = e1.toExample(mime) as string
|
|
736
736
|
|
|
@@ -744,8 +744,8 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
744
744
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
745
745
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
746
746
|
e2.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
|
|
747
|
-
e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
|
|
748
|
-
e2.addAssociation({ targets: [{ key: e3.key }], key: 'a2', info: { name: 'a2' } })
|
|
747
|
+
e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' }, schema: { embedded: true } })
|
|
748
|
+
e2.addAssociation({ targets: [{ key: e3.key }], key: 'a2', info: { name: 'a2' }, schema: { embedded: true } })
|
|
749
749
|
|
|
750
750
|
const result = e1.toExample(mime) as string
|
|
751
751
|
|
|
@@ -757,8 +757,8 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
757
757
|
assert.typeOf(data.a1.a2.i1, 'number', 'has a deep association property')
|
|
758
758
|
})
|
|
759
759
|
|
|
760
|
-
test('does not make associations to self (recursive #1)', ({ assert }) => {
|
|
761
|
-
e1.addAssociation({ targets: [{ key: e1.key }],
|
|
760
|
+
test('does not make associations to self with embedded shape (recursive #1)', ({ assert }) => {
|
|
761
|
+
e1.addAssociation({ targets: [{ key: e1.key }], schema: { embedded: true } })
|
|
762
762
|
const result = e1.toExample(mime) as string
|
|
763
763
|
assert.equal(result, '{}')
|
|
764
764
|
})
|
|
@@ -767,9 +767,24 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
767
767
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
768
768
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
769
769
|
e2.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
|
|
770
|
-
e1.addAssociation({
|
|
771
|
-
|
|
772
|
-
|
|
770
|
+
e1.addAssociation({
|
|
771
|
+
targets: [{ key: e2.key }],
|
|
772
|
+
key: 'a1',
|
|
773
|
+
info: { name: 'a1' },
|
|
774
|
+
schema: { embedded: true },
|
|
775
|
+
})
|
|
776
|
+
e2.addAssociation({
|
|
777
|
+
targets: [{ key: e3.key }],
|
|
778
|
+
key: 'a2',
|
|
779
|
+
info: { name: 'a2' },
|
|
780
|
+
schema: { embedded: true },
|
|
781
|
+
})
|
|
782
|
+
e3.addAssociation({
|
|
783
|
+
targets: [{ key: e1.key }],
|
|
784
|
+
key: 'a3',
|
|
785
|
+
info: { name: 'a3' },
|
|
786
|
+
schema: { embedded: true },
|
|
787
|
+
})
|
|
773
788
|
|
|
774
789
|
const result = e1.toExample(mime) as string
|
|
775
790
|
|
|
@@ -786,7 +801,12 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
786
801
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
787
802
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
788
803
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
789
|
-
const a1 = e1.addAssociation({
|
|
804
|
+
const a1 = e1.addAssociation({
|
|
805
|
+
targets: [{ key: e2.key }],
|
|
806
|
+
key: 'a1',
|
|
807
|
+
info: { name: 'a1' },
|
|
808
|
+
schema: { embedded: true },
|
|
809
|
+
})
|
|
790
810
|
a1.addTarget(e3.key)
|
|
791
811
|
|
|
792
812
|
const result = e1.toExample(mime) as string
|
|
@@ -801,9 +821,14 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
801
821
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
802
822
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
803
823
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
804
|
-
const a1 = e1.addAssociation({
|
|
824
|
+
const a1 = e1.addAssociation({
|
|
825
|
+
targets: [{ key: e2.key }],
|
|
826
|
+
key: 'a1',
|
|
827
|
+
info: { name: 'a1' },
|
|
828
|
+
multiple: true,
|
|
829
|
+
schema: { embedded: true },
|
|
830
|
+
})
|
|
805
831
|
a1.addTarget(e3.key)
|
|
806
|
-
a1.multiple = true
|
|
807
832
|
|
|
808
833
|
const result = e1.toExample(mime) as string
|
|
809
834
|
|
|
@@ -821,9 +846,13 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
821
846
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
822
847
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
823
848
|
|
|
824
|
-
const a1 = e1.addAssociation({
|
|
849
|
+
const a1 = e1.addAssociation({
|
|
850
|
+
targets: [{ key: e2.key }],
|
|
851
|
+
key: 'a1',
|
|
852
|
+
info: { name: 'a1' },
|
|
853
|
+
schema: { unionType: 'anyOf', embedded: true },
|
|
854
|
+
})
|
|
825
855
|
a1.addTarget(e3.key)
|
|
826
|
-
a1.schema = { unionType: 'anyOf' }
|
|
827
856
|
|
|
828
857
|
const result = e1.toExample(mime) as string
|
|
829
858
|
|
|
@@ -838,9 +867,13 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
838
867
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
839
868
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
840
869
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
841
|
-
const a1 = e1.addAssociation({
|
|
870
|
+
const a1 = e1.addAssociation({
|
|
871
|
+
targets: [{ key: e2.key }],
|
|
872
|
+
key: 'a1',
|
|
873
|
+
info: { name: 'a1' },
|
|
874
|
+
schema: { embedded: true, unionType: 'allOf' },
|
|
875
|
+
})
|
|
842
876
|
a1.addTarget(e3.key)
|
|
843
|
-
a1.schema = { unionType: 'allOf' }
|
|
844
877
|
|
|
845
878
|
const result = e1.toExample(mime) as string
|
|
846
879
|
|
|
@@ -857,11 +890,14 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
857
890
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
858
891
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
859
892
|
|
|
860
|
-
const a1 = e1.addAssociation({
|
|
893
|
+
const a1 = e1.addAssociation({
|
|
894
|
+
targets: [{ key: e2.key }],
|
|
895
|
+
key: 'a1',
|
|
896
|
+
info: { name: 'a1' },
|
|
897
|
+
schema: { embedded: true, unionType: 'oneOf' },
|
|
898
|
+
})
|
|
861
899
|
a1.addTarget(e3.key)
|
|
862
900
|
|
|
863
|
-
a1.schema = { unionType: 'oneOf' }
|
|
864
|
-
|
|
865
901
|
const result = e1.toExample(mime) as string
|
|
866
902
|
|
|
867
903
|
assert.typeOf(result, 'string', 'result is a string')
|
|
@@ -877,9 +913,13 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
877
913
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
878
914
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
879
915
|
|
|
880
|
-
const a1 = e1.addAssociation({
|
|
916
|
+
const a1 = e1.addAssociation({
|
|
917
|
+
targets: [{ key: e2.key }],
|
|
918
|
+
key: 'a1',
|
|
919
|
+
info: { name: 'a1' },
|
|
920
|
+
schema: { unionType: 'oneOf', embedded: true },
|
|
921
|
+
})
|
|
881
922
|
a1.addTarget(e3.key)
|
|
882
|
-
a1.schema = { unionType: 'oneOf' }
|
|
883
923
|
|
|
884
924
|
const result = e1.toExample(mime) as string
|
|
885
925
|
|
|
@@ -897,7 +937,12 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
|
|
|
897
937
|
e3.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
|
|
898
938
|
n2.info.version = '1.0.0'
|
|
899
939
|
n1.registerForeignDomain(n2)
|
|
900
|
-
e1.addAssociation({
|
|
940
|
+
e1.addAssociation({
|
|
941
|
+
targets: [{ key: e3.key, domain: n2.key }],
|
|
942
|
+
key: 'a3',
|
|
943
|
+
info: { name: 'a3' },
|
|
944
|
+
schema: { embedded: true },
|
|
945
|
+
})
|
|
901
946
|
const result = e1.toExample(mime) as string
|
|
902
947
|
assert.typeOf(result, 'string', 'result is a string')
|
|
903
948
|
const data = JSON.parse(result)
|
|
@@ -945,7 +990,7 @@ test.group('JSON DomainEntity Generator: parents', (group) => {
|
|
|
945
990
|
e2.addParent(e1.key)
|
|
946
991
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
947
992
|
e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
|
|
948
|
-
e2.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
|
|
993
|
+
e2.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' }, schema: { embedded: true } })
|
|
949
994
|
|
|
950
995
|
const result = e2.toExample(mime) as string
|
|
951
996
|
|
|
@@ -963,7 +1008,7 @@ test.group('JSON DomainEntity Generator: parents', (group) => {
|
|
|
963
1008
|
e2.addParent(e1.key)
|
|
964
1009
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
965
1010
|
e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
|
|
966
|
-
e1.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
|
|
1011
|
+
e1.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' }, schema: { embedded: true } })
|
|
967
1012
|
|
|
968
1013
|
const result = e2.toExample(mime) as string
|
|
969
1014
|
|
|
@@ -1108,7 +1108,12 @@ test.group('XML DomainEntity Generator: associations', (group) => {
|
|
|
1108
1108
|
|
|
1109
1109
|
test('creates a property from an association', ({ assert }) => {
|
|
1110
1110
|
e2.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
|
|
1111
|
-
e1.addAssociation({
|
|
1111
|
+
e1.addAssociation({
|
|
1112
|
+
targets: [{ key: e2.key }],
|
|
1113
|
+
key: 'a1',
|
|
1114
|
+
info: { name: 'a1' },
|
|
1115
|
+
schema: { embedded: true },
|
|
1116
|
+
})
|
|
1112
1117
|
|
|
1113
1118
|
const result = e1.toExample(mime) as string
|
|
1114
1119
|
|
|
@@ -1131,8 +1136,18 @@ test.group('XML DomainEntity Generator: associations', (group) => {
|
|
|
1131
1136
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
1132
1137
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
1133
1138
|
e2.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
|
|
1134
|
-
e1.addAssociation({
|
|
1135
|
-
|
|
1139
|
+
e1.addAssociation({
|
|
1140
|
+
targets: [{ key: e2.key }],
|
|
1141
|
+
key: 'a1',
|
|
1142
|
+
info: { name: 'a1' },
|
|
1143
|
+
schema: { embedded: true },
|
|
1144
|
+
})
|
|
1145
|
+
e2.addAssociation({
|
|
1146
|
+
targets: [{ key: e3.key }],
|
|
1147
|
+
key: 'a2',
|
|
1148
|
+
info: { name: 'a2' },
|
|
1149
|
+
schema: { embedded: true },
|
|
1150
|
+
})
|
|
1136
1151
|
|
|
1137
1152
|
const result = e1.toExample(mime) as string
|
|
1138
1153
|
|
|
@@ -1192,7 +1207,12 @@ test.group('XML DomainEntity Generator: associations', (group) => {
|
|
|
1192
1207
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
1193
1208
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
1194
1209
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
1195
|
-
const a1 = e1.addAssociation({
|
|
1210
|
+
const a1 = e1.addAssociation({
|
|
1211
|
+
targets: [{ key: e2.key }],
|
|
1212
|
+
key: 'a1',
|
|
1213
|
+
info: { name: 'a1' },
|
|
1214
|
+
schema: { embedded: true },
|
|
1215
|
+
})
|
|
1196
1216
|
a1.addTarget(e3.key)
|
|
1197
1217
|
|
|
1198
1218
|
const result = e1.toExample(mime) as string
|
|
@@ -1233,11 +1253,14 @@ test.group('XML DomainEntity Generator: associations', (group) => {
|
|
|
1233
1253
|
e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
|
|
1234
1254
|
e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
|
|
1235
1255
|
|
|
1236
|
-
const a1 = e1.addAssociation({
|
|
1256
|
+
const a1 = e1.addAssociation({
|
|
1257
|
+
targets: [{ key: e2.key }],
|
|
1258
|
+
key: 'a1',
|
|
1259
|
+
info: { name: 'a1' },
|
|
1260
|
+
schema: { embedded: true, unionType: 'anyOf' },
|
|
1261
|
+
})
|
|
1237
1262
|
a1.addTarget(e3.key)
|
|
1238
1263
|
|
|
1239
|
-
a1.schema = { unionType: 'anyOf' }
|
|
1240
|
-
|
|
1241
1264
|
const result = e1.toExample(mime) as string
|
|
1242
1265
|
assert.typeOf(result, 'string', 'result is a string')
|
|
1243
1266
|
|
|
@@ -1374,7 +1397,7 @@ test.group('XML DomainEntity Generator: parents', (group) => {
|
|
|
1374
1397
|
e2.addParent(e1.key)
|
|
1375
1398
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
1376
1399
|
e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
|
|
1377
|
-
e2.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
|
|
1400
|
+
e2.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' }, schema: { embedded: true } })
|
|
1378
1401
|
|
|
1379
1402
|
const result = e2.toExample(mime) as string
|
|
1380
1403
|
assert.typeOf(result, 'string', 'result is a string')
|
|
@@ -1406,7 +1429,7 @@ test.group('XML DomainEntity Generator: parents', (group) => {
|
|
|
1406
1429
|
e2.addParent(e1.key)
|
|
1407
1430
|
const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
|
|
1408
1431
|
e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
|
|
1409
|
-
e1.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
|
|
1432
|
+
e1.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' }, schema: { embedded: true } })
|
|
1410
1433
|
|
|
1411
1434
|
const result = e2.toExample(mime) as string
|
|
1412
1435
|
assert.typeOf(result, 'string', 'result is a string')
|