@api-client/core 0.18.62 → 0.18.64

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.
Files changed (80) hide show
  1. package/API_MODELING_EXPLAINER.md +57 -0
  2. package/DATA_MODELING_EXPLAINER.md +74 -0
  3. package/build/src/modeling/DataDomain.d.ts +6 -5
  4. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  5. package/build/src/modeling/DataDomain.js +5 -4
  6. package/build/src/modeling/DataDomain.js.map +1 -1
  7. package/build/src/modeling/DomainAssociation.js +1 -1
  8. package/build/src/modeling/DomainAssociation.js.map +1 -1
  9. package/build/src/modeling/DomainEntity.d.ts +9 -6
  10. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  11. package/build/src/modeling/DomainEntity.js +34 -18
  12. package/build/src/modeling/DomainEntity.js.map +1 -1
  13. package/build/src/modeling/ai/Semantics.d.ts +7 -0
  14. package/build/src/modeling/ai/Semantics.d.ts.map +1 -0
  15. package/build/src/modeling/ai/Semantics.js +552 -0
  16. package/build/src/modeling/ai/Semantics.js.map +1 -0
  17. package/build/src/modeling/definitions/Calculated.d.ts +1 -1
  18. package/build/src/modeling/definitions/Calculated.js.map +1 -1
  19. package/build/src/modeling/definitions/Country.d.ts +1 -1
  20. package/build/src/modeling/definitions/Country.js.map +1 -1
  21. package/build/src/modeling/definitions/Derived.d.ts +1 -1
  22. package/build/src/modeling/definitions/Derived.js.map +1 -1
  23. package/build/src/modeling/definitions/Description.d.ts +0 -1
  24. package/build/src/modeling/definitions/Description.d.ts.map +1 -1
  25. package/build/src/modeling/definitions/Description.js.map +1 -1
  26. package/build/src/modeling/definitions/Email.d.ts +5 -1
  27. package/build/src/modeling/definitions/Email.d.ts.map +1 -1
  28. package/build/src/modeling/definitions/Email.js.map +1 -1
  29. package/build/src/modeling/definitions/HTML.d.ts +0 -22
  30. package/build/src/modeling/definitions/HTML.d.ts.map +1 -1
  31. package/build/src/modeling/definitions/HTML.js +0 -1
  32. package/build/src/modeling/definitions/HTML.js.map +1 -1
  33. package/build/src/modeling/definitions/Markdown.d.ts +0 -16
  34. package/build/src/modeling/definitions/Markdown.d.ts.map +1 -1
  35. package/build/src/modeling/definitions/Markdown.js +0 -1
  36. package/build/src/modeling/definitions/Markdown.js.map +1 -1
  37. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
  38. package/build/src/modeling/helpers/Intelisense.js +2 -2
  39. package/build/src/modeling/helpers/Intelisense.js.map +1 -1
  40. package/build/src/modeling/importers/JsonSchemaImporter.js +1 -1
  41. package/build/src/modeling/importers/JsonSchemaImporter.js.map +1 -1
  42. package/build/src/modeling/types.d.ts +0 -14
  43. package/build/src/modeling/types.d.ts.map +1 -1
  44. package/build/src/modeling/types.js.map +1 -1
  45. package/build/tsconfig.tsbuildinfo +1 -1
  46. package/data/models/example-generator-api.json +15 -15
  47. package/package.json +4 -4
  48. package/src/modeling/DataDomain.ts +6 -6
  49. package/src/modeling/DomainAssociation.ts +1 -1
  50. package/src/modeling/DomainEntity.ts +36 -18
  51. package/src/modeling/ai/Semantics.ts +597 -0
  52. package/src/modeling/ai/readme.md +7 -0
  53. package/src/modeling/definitions/Calculated.ts +1 -1
  54. package/src/modeling/definitions/Country.ts +1 -1
  55. package/src/modeling/definitions/Derived.ts +1 -1
  56. package/src/modeling/definitions/Description.ts +0 -1
  57. package/src/modeling/definitions/Email.ts +5 -1
  58. package/src/modeling/definitions/HTML.ts +0 -23
  59. package/src/modeling/definitions/Markdown.ts +0 -17
  60. package/src/modeling/helpers/Intelisense.ts +8 -14
  61. package/src/modeling/importers/JsonSchemaImporter.ts +1 -1
  62. package/src/modeling/types.ts +0 -15
  63. package/tests/unit/modeling/amf/shape_generator.spec.ts +4 -4
  64. package/tests/unit/modeling/api_model_expose_entity.spec.ts +11 -11
  65. package/tests/unit/modeling/api_model_remove_entity.spec.ts +1 -1
  66. package/tests/unit/modeling/data_domain_associations.spec.ts +6 -6
  67. package/tests/unit/modeling/data_domain_foreign.spec.ts +2 -2
  68. package/tests/unit/modeling/data_domain_namespaces.spec.ts +1 -1
  69. package/tests/unit/modeling/data_domain_serialization.spec.ts +15 -15
  70. package/tests/unit/modeling/domain_asociation.spec.ts +15 -15
  71. package/tests/unit/modeling/domain_entity.spec.ts +3 -3
  72. package/tests/unit/modeling/domain_entity_associations.spec.ts +4 -4
  73. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +16 -16
  74. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +14 -14
  75. package/tests/unit/modeling/domain_property.spec.ts +1 -1
  76. package/tests/unit/modeling/domain_validation.spec.ts +3 -3
  77. package/tests/unit/modeling/domain_versioning.spec.ts +5 -5
  78. package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
  79. package/tests/unit/modeling/validation/association_validation.spec.ts +40 -56
  80. package/tests/unit/modeling/validation/entity_validation.spec.ts +2 -2
@@ -16,7 +16,7 @@ test.group('DomainEntity.addAssociation()', () => {
16
16
  const model = dataDomain.addModel()
17
17
  const entity1 = model.addEntity({ key: 'entity1' })
18
18
  const entity2 = model.addEntity({ key: 'entity2' })
19
- const association = entity1.addAssociation({ key: entity2.key })
19
+ const association = entity1.addAssociation({ targets: [{ key: entity2.key }] })
20
20
  assert.instanceOf(association, DomainAssociation)
21
21
  assert.isTrue(dataDomain.graph.hasNode(association.key))
22
22
  assert.deepEqual(association.targets, [{ key: entity2.key }])
@@ -27,7 +27,7 @@ test.group('DomainEntity.addAssociation()', () => {
27
27
  const model = dataDomain.addModel()
28
28
  const entity = model.addEntity()
29
29
  assert.throws(() => {
30
- entity.addAssociation({ key: 'non-existent-entity' })
30
+ entity.addAssociation({ targets: [{ key: 'non-existent-entity' }] })
31
31
  }, 'Target entity non-existent-entity not found')
32
32
  })
33
33
 
@@ -84,7 +84,7 @@ test.group('DomainEntity.addAssociation()', () => {
84
84
  root2.info.version = '1.0.0'
85
85
  root1.registerForeignDomain(root2)
86
86
 
87
- const association = e1.addAssociation({ key: e2.key, domain: root2.key })
87
+ const association = e1.addAssociation({ targets: [{ key: e2.key, domain: root2.key }] })
88
88
  assert.instanceOf(association, DomainAssociation)
89
89
  assert.isTrue(root1.graph.hasNode(association.key))
90
90
  assert.deepEqual(association.targets, [{ key: e2.key, domain: root2.key }])
@@ -98,7 +98,7 @@ test.group('DomainEntity.addAssociation()', () => {
98
98
  root2.info.version = '1.0.0'
99
99
  root1.registerForeignDomain(root2)
100
100
  assert.throws(() => {
101
- entity.addAssociation({ key: 'non-existent-entity', domain: root2.key })
101
+ entity.addAssociation({ targets: [{ key: 'non-existent-entity', domain: root2.key }] })
102
102
  }, `Foreign entity ${root2.key}:non-existent-entity not found`)
103
103
  })
104
104
  })
@@ -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({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
733
+ e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
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({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
748
- e2.addAssociation({ key: e3.key }, { key: 'a2', info: { name: 'a2' } })
747
+ e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
748
+ e2.addAssociation({ targets: [{ key: e3.key }], key: 'a2', info: { name: 'a2' } })
749
749
 
750
750
  const result = e1.toExample(mime) as string
751
751
 
@@ -758,7 +758,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
758
758
  })
759
759
 
760
760
  test('does not make associations to self (recursive #1)', ({ assert }) => {
761
- e1.addAssociation({ key: e1.key }, { key: 'a1' })
761
+ e1.addAssociation({ targets: [{ key: e1.key }], key: 'a1' })
762
762
  const result = e1.toExample(mime) as string
763
763
  assert.equal(result, '{}')
764
764
  })
@@ -767,9 +767,9 @@ 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({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
771
- e2.addAssociation({ key: e3.key }, { key: 'a2', info: { name: 'a2' } })
772
- e3.addAssociation({ key: e1.key }, { key: 'a3', info: { name: 'a3' } })
770
+ e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
771
+ e2.addAssociation({ targets: [{ key: e3.key }], key: 'a2', info: { name: 'a2' } })
772
+ e3.addAssociation({ targets: [{ key: e1.key }], key: 'a3', info: { name: 'a3' } })
773
773
 
774
774
  const result = e1.toExample(mime) as string
775
775
 
@@ -786,7 +786,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
786
786
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
787
787
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
788
788
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
789
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
789
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
790
790
  a1.addTarget(e3.key)
791
791
 
792
792
  const result = e1.toExample(mime) as string
@@ -801,7 +801,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
801
801
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
802
802
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
803
803
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
804
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
804
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
805
805
  a1.addTarget(e3.key)
806
806
  a1.multiple = true
807
807
 
@@ -821,7 +821,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
821
821
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
822
822
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
823
823
 
824
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
824
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
825
825
  a1.addTarget(e3.key)
826
826
  a1.schema = { unionType: 'anyOf' }
827
827
 
@@ -838,7 +838,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
838
838
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
839
839
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
840
840
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
841
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
841
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
842
842
  a1.addTarget(e3.key)
843
843
  a1.schema = { unionType: 'allOf' }
844
844
 
@@ -857,7 +857,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
857
857
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
858
858
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
859
859
 
860
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
860
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
861
861
  a1.addTarget(e3.key)
862
862
 
863
863
  a1.schema = { unionType: 'oneOf' }
@@ -877,7 +877,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
877
877
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
878
878
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
879
879
 
880
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
880
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
881
881
  a1.addTarget(e3.key)
882
882
  a1.schema = { unionType: 'oneOf' }
883
883
 
@@ -897,7 +897,7 @@ test.group('JSON DomainEntity Generator: associations', (group) => {
897
897
  e3.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
898
898
  n2.info.version = '1.0.0'
899
899
  n1.registerForeignDomain(n2)
900
- e1.addAssociation({ key: e3.key, domain: n2.key }, { key: 'a3', info: { name: 'a3' } })
900
+ e1.addAssociation({ targets: [{ key: e3.key, domain: n2.key }], key: 'a3', info: { name: 'a3' } })
901
901
  const result = e1.toExample(mime) as string
902
902
  assert.typeOf(result, 'string', 'result is a string')
903
903
  const data = JSON.parse(result)
@@ -945,7 +945,7 @@ test.group('JSON DomainEntity Generator: parents', (group) => {
945
945
  e2.addParent(e1.key)
946
946
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
947
947
  e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
948
- e2.addAssociation({ key: e3.key }, { key: 'a1', info: { name: 'a1' } })
948
+ e2.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
949
949
 
950
950
  const result = e2.toExample(mime) as string
951
951
 
@@ -963,7 +963,7 @@ test.group('JSON DomainEntity Generator: parents', (group) => {
963
963
  e2.addParent(e1.key)
964
964
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
965
965
  e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
966
- e1.addAssociation({ key: e3.key }, { key: 'a1', info: { name: 'a1' } })
966
+ e1.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
967
967
 
968
968
  const result = e2.toExample(mime) as string
969
969
 
@@ -1108,7 +1108,7 @@ 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({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1111
+ e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1112
1112
 
1113
1113
  const result = e1.toExample(mime) as string
1114
1114
 
@@ -1131,8 +1131,8 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1131
1131
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
1132
1132
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
1133
1133
  e2.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
1134
- e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1135
- e2.addAssociation({ key: e3.key }, { key: 'a2', info: { name: 'a2' } })
1134
+ e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1135
+ e2.addAssociation({ targets: [{ key: e3.key }], key: 'a2', info: { name: 'a2' } })
1136
1136
 
1137
1137
  const result = e1.toExample(mime) as string
1138
1138
 
@@ -1160,7 +1160,7 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1160
1160
  })
1161
1161
 
1162
1162
  test('does not make associations to self (recursive #1)', ({ assert }) => {
1163
- e1.addAssociation({ key: e1.key }, { key: 'a1' })
1163
+ e1.addAssociation({ targets: [{ key: e1.key }], key: 'a1' })
1164
1164
  const result = e1.toExample(mime) as string
1165
1165
 
1166
1166
  const dom = new JSDOM(result, { contentType: mime })
@@ -1174,9 +1174,9 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1174
1174
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
1175
1175
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
1176
1176
  e2.addProperty({ type: 'number', key: 'n1', info: { name: 'n1' } })
1177
- e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1178
- e2.addAssociation({ key: e3.key }, { key: 'a2', info: { name: 'a2' } })
1179
- e3.addAssociation({ key: e1.key }, { key: 'a3', info: { name: 'a3' } })
1177
+ e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1178
+ e2.addAssociation({ targets: [{ key: e3.key }], key: 'a2', info: { name: 'a2' } })
1179
+ e3.addAssociation({ targets: [{ key: e1.key }], key: 'a3', info: { name: 'a3' } })
1180
1180
 
1181
1181
  const result = e1.toExample(mime) as string
1182
1182
  assert.typeOf(result, 'string', 'result is a string')
@@ -1192,7 +1192,7 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1192
1192
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
1193
1193
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
1194
1194
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
1195
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1195
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1196
1196
  a1.addTarget(e3.key)
1197
1197
 
1198
1198
  const result = e1.toExample(mime) as string
@@ -1233,7 +1233,7 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1233
1233
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
1234
1234
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
1235
1235
 
1236
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1236
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1237
1237
  a1.addTarget(e3.key)
1238
1238
 
1239
1239
  a1.schema = { unionType: 'anyOf' }
@@ -1255,7 +1255,7 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1255
1255
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
1256
1256
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
1257
1257
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
1258
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1258
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1259
1259
  a1.addTarget(e3.key)
1260
1260
 
1261
1261
  a1.schema = { unionType: 'allOf' }
@@ -1278,7 +1278,7 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1278
1278
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
1279
1279
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
1280
1280
 
1281
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1281
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1282
1282
  a1.addTarget(e3.key)
1283
1283
 
1284
1284
  a1.schema = { unionType: 'oneOf' }
@@ -1301,7 +1301,7 @@ test.group('XML DomainEntity Generator: associations', (group) => {
1301
1301
  e2.addProperty({ type: 'string', key: 's1', info: { name: 's1' } })
1302
1302
  e3.addProperty({ type: 'number', key: 'i1', info: { name: 'i1' } })
1303
1303
 
1304
- const a1 = e1.addAssociation({ key: e2.key }, { key: 'a1', info: { name: 'a1' } })
1304
+ const a1 = e1.addAssociation({ targets: [{ key: e2.key }], key: 'a1', info: { name: 'a1' } })
1305
1305
  a1.addTarget(e3.key)
1306
1306
 
1307
1307
  a1.schema = { unionType: 'oneOf' }
@@ -1374,7 +1374,7 @@ test.group('XML DomainEntity Generator: parents', (group) => {
1374
1374
  e2.addParent(e1.key)
1375
1375
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
1376
1376
  e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
1377
- e2.addAssociation({ key: e3.key }, { key: 'a1', info: { name: 'a1' } })
1377
+ e2.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
1378
1378
 
1379
1379
  const result = e2.toExample(mime) as string
1380
1380
  assert.typeOf(result, 'string', 'result is a string')
@@ -1406,7 +1406,7 @@ test.group('XML DomainEntity Generator: parents', (group) => {
1406
1406
  e2.addParent(e1.key)
1407
1407
  const e3 = d1.addEntity({ key: 'e3', info: { name: 'e3' } })
1408
1408
  e3.addProperty({ type: 'string', key: 'p3', info: { name: 'p3' } })
1409
- e1.addAssociation({ key: e3.key }, { key: 'a1', info: { name: 'a1' } })
1409
+ e1.addAssociation({ targets: [{ key: e3.key }], key: 'a1', info: { name: 'a1' } })
1410
1410
 
1411
1411
  const result = e2.toExample(mime) as string
1412
1412
  assert.typeOf(result, 'string', 'result is a string')
@@ -1623,7 +1623,7 @@ test.group('DomainProperty.duplicate()', () => {
1623
1623
  const targetEntity = model.addEntity()
1624
1624
 
1625
1625
  const property1 = entity.addProperty({ info: { name: 'prop1' } })
1626
- const association = entity.addAssociation({ key: targetEntity.key })
1626
+ const association = entity.addAssociation({ targets: [{ key: targetEntity.key }] })
1627
1627
  association.info.name = 'assoc1'
1628
1628
  const property2 = entity.addProperty({ info: { name: 'prop2' } })
1629
1629
 
@@ -45,7 +45,7 @@ test.group('DomainImpactAnalysis.validate()', (group) => {
45
45
  const model = domain.addModel({ key: 'model' })
46
46
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'entity1' } })
47
47
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'entity2' } })
48
- entity1.addAssociation({ key: entity2.key }, { info: { name: 'Invalid-Name' } })
48
+ entity1.addAssociation({ targets: [{ key: entity2.key }], info: { name: 'Invalid-Name' } })
49
49
 
50
50
  const report = analysis.validate()
51
51
  assert.lengthOf(report.impact, 12)
@@ -57,7 +57,7 @@ test.group('DomainImpactAnalysis.validate()', (group) => {
57
57
  const entity1 = model.addEntity({ key: 'invalid-entity', info: { name: 'Invalid-Entity' } })
58
58
  entity1.addProperty({ key: 'invalid-property', type: 'string', info: { name: 'Invalid-Property' } })
59
59
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'entity2' } })
60
- entity1.addAssociation({ key: entity2.key }, { info: { name: 'Invalid-Name' } })
60
+ entity1.addAssociation({ targets: [{ key: entity2.key }], info: { name: 'Invalid-Name' } })
61
61
 
62
62
  const report = analysis.validate()
63
63
  assert.lengthOf(report.impact, 16)
@@ -74,7 +74,7 @@ test.group('DomainImpactAnalysis.validate()', (group) => {
74
74
  entity2.addProperty({ key: 'p4', type: 'string', primary: true, info: { name: 'property4' } })
75
75
  const p5e2 = entity2.addProperty({ key: 'p5', type: 'datetime', info: { name: 'property5' } })
76
76
  const p6e2 = entity2.addProperty({ key: 'p6', type: 'datetime', info: { name: 'property6' } })
77
- entity1.addAssociation({ key: entity2.key }, { info: { name: 'name' } })
77
+ entity1.addAssociation({ targets: [{ key: entity2.key }], info: { name: 'name' } })
78
78
  const p3e1 = entity1.addProperty({ type: 'datetime', info: { name: 'p3e1' } })
79
79
  const p4e1 = entity1.addProperty({ type: 'datetime', info: { name: 'p4e1' } })
80
80
  const p5e1 = entity1.addProperty({ type: 'boolean', info: { name: 'p5e1' } })
@@ -26,7 +26,7 @@ test.group('DomainVersioning', () => {
26
26
  fd.info.version = '1.0.0'
27
27
  root.registerForeignDomain(fd)
28
28
 
29
- e1.addAssociation({ domain: fd.key, key: fe1.key }, { key: 'a1' })
29
+ e1.addAssociation({ targets: [{ domain: fd.key, key: fe1.key }], key: 'a1' })
30
30
 
31
31
  const serialized = DomainVersioning.serializeForVersionRelease(root)
32
32
 
@@ -65,11 +65,11 @@ test.group('DomainVersioning', () => {
65
65
  const fm1 = fd1.addModel({ key: 'fm1' })
66
66
  const fe1 = fm1.addEntity({ key: 'fe1' })
67
67
  const fe2 = fm1.addEntity({ key: 'fe2' }) // This should be included
68
- fe1.addAssociation({ key: fe2.key }, { key: 'a1' })
68
+ fe1.addAssociation({ targets: [{ key: fe2.key }], key: 'a1' })
69
69
  fd1.info.version = '1.0.0'
70
70
  root.registerForeignDomain(fd1)
71
71
 
72
- e1.addAssociation({ domain: fd1.key, key: fe1.key }, { key: 'a2' })
72
+ e1.addAssociation({ targets: [{ domain: fd1.key, key: fe1.key }], key: 'a2' })
73
73
 
74
74
  const serialized = DomainVersioning.serializeForVersionRelease(root)
75
75
 
@@ -99,11 +99,11 @@ test.group('DomainVersioning', () => {
99
99
  fd2.registerForeignDomain(fd1)
100
100
  const fm2 = fd2.addModel({ key: 'fm2' }) // not serialized
101
101
  const fe2 = fm2.addEntity({ key: 'fe2' }) // serialized
102
- const fa1 = fe2.addAssociation({ domain: fd1.key, key: fe1.key }, { key: 'a1' })
102
+ const fa1 = fe2.addAssociation({ targets: [{ domain: fd1.key, key: fe1.key }], key: 'a1' })
103
103
  fd2.info.version = '1.0.0'
104
104
  root.registerForeignDomain(fd2) // serialized
105
105
 
106
- const a2 = e1.addAssociation({ domain: fd2.key, key: fe2.key }, { key: 'a2' }) // serialized
106
+ const a2 = e1.addAssociation({ targets: [{ domain: fd2.key, key: fe2.key }], key: 'a2' }) // serialized
107
107
 
108
108
  const serialized = DomainVersioning.serializeForVersionRelease(root)
109
109
 
@@ -77,7 +77,7 @@ test.group('ExposedEntity Path Setter Validation', () => {
77
77
  const dm = domain.addModel()
78
78
  const eA = dm.addEntity({ info: { name: 'A' } })
79
79
  const eB = dm.addEntity({ info: { name: 'B' } })
80
- eA.addAssociation({ key: eB.key }, { info: { name: 'toB' } })
80
+ eA.addAssociation({ targets: [{ key: eB.key }], key: 'toB' })
81
81
 
82
82
  const model = new ApiModel()
83
83
  model.attachDataDomain(domain)
@@ -21,13 +21,11 @@ test.group('AssociationValidation', (group) => {
21
21
  const model = domain.addModel({ key: 'model' })
22
22
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
23
23
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'Entity2' } })
24
- const association = entity1.addAssociation(
25
- { key: entity2.key },
26
- {
27
- key: 'association',
28
- info: { name: 'Association' },
29
- }
30
- )
24
+ const association = entity1.addAssociation({
25
+ targets: [{ key: entity2.key }],
26
+ key: 'association',
27
+ info: { name: 'Association' },
28
+ })
31
29
  const validateNameSpy = sinon.spy(validation, 'validateName')
32
30
  const validateTargetsSpy = sinon.spy(validation, 'validateTargets')
33
31
 
@@ -42,13 +40,11 @@ test.group('AssociationValidation', (group) => {
42
40
  const model = domain.addModel({ key: 'model' })
43
41
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
44
42
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'Entity2' } })
45
- const association = entity1.addAssociation(
46
- { key: entity2.key },
47
- {
48
- key: 'association',
49
- info: { name: 'association' },
50
- }
51
- )
43
+ const association = entity1.addAssociation({
44
+ targets: [{ key: entity2.key }],
45
+ key: 'association',
46
+ info: { name: 'association' },
47
+ })
52
48
  association.info.name = undefined
53
49
  const results = validation.validateName(association)
54
50
  assert.lengthOf(results, 1)
@@ -60,13 +56,11 @@ test.group('AssociationValidation', (group) => {
60
56
  const model = domain.addModel({ key: 'model' })
61
57
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
62
58
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'Entity2' } })
63
- const association = entity1.addAssociation(
64
- { key: entity2.key },
65
- {
66
- key: '1association',
67
- info: { name: '1association' },
68
- }
69
- )
59
+ const association = entity1.addAssociation({
60
+ targets: [{ key: entity2.key }],
61
+ key: '1association',
62
+ info: { name: '1association' },
63
+ })
70
64
  const results = validation.validateName(association)
71
65
  assert.lengthOf(results, 1)
72
66
  assert.equal(results[0].rule, 'format')
@@ -77,13 +71,11 @@ test.group('AssociationValidation', (group) => {
77
71
  const model = domain.addModel({ key: 'model' })
78
72
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
79
73
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'Entity2' } })
80
- const association = entity1.addAssociation(
81
- { key: entity2.key },
82
- {
83
- key: 'invalid-association!',
84
- info: { name: 'invalid-association!' },
85
- }
86
- )
74
+ const association = entity1.addAssociation({
75
+ targets: [{ key: entity2.key }],
76
+ key: 'invalid-association!',
77
+ info: { name: 'invalid-association!' },
78
+ })
87
79
  const results = validation.validateName(association)
88
80
  assert.lengthOf(results, 1)
89
81
  assert.equal(results[0].rule, 'format')
@@ -94,13 +86,11 @@ test.group('AssociationValidation', (group) => {
94
86
  const model = domain.addModel({ key: 'model' })
95
87
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
96
88
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'Entity2' } })
97
- const association = entity1.addAssociation(
98
- { key: entity2.key },
99
- {
100
- key: 'a',
101
- info: { name: 'a' },
102
- }
103
- )
89
+ const association = entity1.addAssociation({
90
+ targets: [{ key: entity2.key }],
91
+ key: 'a',
92
+ info: { name: 'a' },
93
+ })
104
94
  const results = validation.validateName(association)
105
95
  assert.lengthOf(results, 1)
106
96
  assert.equal(results[0].rule, 'length')
@@ -111,13 +101,11 @@ test.group('AssociationValidation', (group) => {
111
101
  const model = domain.addModel({ key: 'model' })
112
102
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
113
103
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'Entity2' } })
114
- const association = entity1.addAssociation(
115
- { key: entity2.key },
116
- {
117
- key: 'a'.repeat(60),
118
- info: { name: 'a'.repeat(60) },
119
- }
120
- )
104
+ const association = entity1.addAssociation({
105
+ targets: [{ key: entity2.key }],
106
+ key: 'a'.repeat(60),
107
+ info: { name: 'a'.repeat(60) },
108
+ })
121
109
  const results = validation.validateName(association)
122
110
  assert.lengthOf(results, 1)
123
111
  assert.equal(results[0].rule, 'length')
@@ -128,13 +116,11 @@ test.group('AssociationValidation', (group) => {
128
116
  const model = domain.addModel({ key: 'model' })
129
117
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
130
118
  const entity2 = model.addEntity({ key: 'entity2', info: { name: 'Entity2' } })
131
- const association = entity1.addAssociation(
132
- { key: entity2.key },
133
- {
134
- key: 'valid_association123',
135
- info: { name: 'valid_association123' },
136
- }
137
- )
119
+ const association = entity1.addAssociation({
120
+ targets: [{ key: entity2.key }],
121
+ key: 'valid_association123',
122
+ info: { name: 'valid_association123' },
123
+ })
138
124
  const results = validation.validateName(association)
139
125
  assert.lengthOf(results, 0)
140
126
  })
@@ -142,13 +128,11 @@ test.group('AssociationValidation', (group) => {
142
128
  test('validateEntities() should return an error when the target entity does not exist', ({ assert }) => {
143
129
  const model = domain.addModel({ key: 'model' })
144
130
  const entity1 = model.addEntity({ key: 'entity1', info: { name: 'Entity1' } })
145
- const association = entity1.addAssociation(
146
- {},
147
- {
148
- key: 'association',
149
- info: { name: 'association' },
150
- }
151
- )
131
+ const association = entity1.addAssociation({
132
+ targets: [],
133
+ key: 'association',
134
+ info: { name: 'association' },
135
+ })
152
136
  const results = validation.validateTargets(association)
153
137
  assert.lengthOf(results, 1)
154
138
  assert.equal(results[0].rule, 'required')
@@ -97,7 +97,7 @@ test.group('EntityValidation', (group) => {
97
97
  const model = domain.addModel({ key: 'model' })
98
98
  const target = model.addEntity({ key: 'target', info: { name: 'Target' } })
99
99
  const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
100
- parent.addAssociation({ key: target.key })
100
+ parent.addAssociation({ targets: [{ key: target.key }] })
101
101
  const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })
102
102
  entity.addParent(parent.key)
103
103
  const results = validation.minimumRequiredProperties(entity)
@@ -130,7 +130,7 @@ test.group('EntityValidation', (group) => {
130
130
  key: 'grandparent',
131
131
  info: { name: 'Grandparent' },
132
132
  })
133
- grandparent.addAssociation({ key: target.key })
133
+ grandparent.addAssociation({ targets: [{ key: target.key }] })
134
134
  const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
135
135
  parent.addParent(grandparent.key)
136
136
  const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })