@api-client/core 0.18.62 → 0.18.63

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 (47) 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/helpers/Intelisense.d.ts.map +1 -1
  14. package/build/src/modeling/helpers/Intelisense.js +2 -2
  15. package/build/src/modeling/helpers/Intelisense.js.map +1 -1
  16. package/build/src/modeling/importers/JsonSchemaImporter.js +1 -1
  17. package/build/src/modeling/importers/JsonSchemaImporter.js.map +1 -1
  18. package/build/src/modeling/types.d.ts +0 -14
  19. package/build/src/modeling/types.d.ts.map +1 -1
  20. package/build/src/modeling/types.js.map +1 -1
  21. package/build/tsconfig.tsbuildinfo +1 -1
  22. package/data/models/example-generator-api.json +15 -15
  23. package/package.json +4 -4
  24. package/src/modeling/DataDomain.ts +6 -6
  25. package/src/modeling/DomainAssociation.ts +1 -1
  26. package/src/modeling/DomainEntity.ts +36 -18
  27. package/src/modeling/helpers/Intelisense.ts +8 -14
  28. package/src/modeling/importers/JsonSchemaImporter.ts +1 -1
  29. package/src/modeling/types.ts +0 -15
  30. package/tests/unit/modeling/amf/shape_generator.spec.ts +4 -4
  31. package/tests/unit/modeling/api_model_expose_entity.spec.ts +11 -11
  32. package/tests/unit/modeling/api_model_remove_entity.spec.ts +1 -1
  33. package/tests/unit/modeling/data_domain_associations.spec.ts +6 -6
  34. package/tests/unit/modeling/data_domain_foreign.spec.ts +2 -2
  35. package/tests/unit/modeling/data_domain_namespaces.spec.ts +1 -1
  36. package/tests/unit/modeling/data_domain_serialization.spec.ts +15 -15
  37. package/tests/unit/modeling/domain_asociation.spec.ts +15 -15
  38. package/tests/unit/modeling/domain_entity.spec.ts +3 -3
  39. package/tests/unit/modeling/domain_entity_associations.spec.ts +4 -4
  40. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +16 -16
  41. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +14 -14
  42. package/tests/unit/modeling/domain_property.spec.ts +1 -1
  43. package/tests/unit/modeling/domain_validation.spec.ts +3 -3
  44. package/tests/unit/modeling/domain_versioning.spec.ts +5 -5
  45. package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
  46. package/tests/unit/modeling/validation/association_validation.spec.ts +40 -56
  47. package/tests/unit/modeling/validation/entity_validation.spec.ts +2 -2
@@ -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' } })