@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.
- package/API_MODELING_EXPLAINER.md +57 -0
- package/DATA_MODELING_EXPLAINER.md +74 -0
- package/build/src/modeling/DataDomain.d.ts +6 -5
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js +5 -4
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainAssociation.js +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +9 -6
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +34 -18
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
- package/build/src/modeling/helpers/Intelisense.js +2 -2
- package/build/src/modeling/helpers/Intelisense.js.map +1 -1
- package/build/src/modeling/importers/JsonSchemaImporter.js +1 -1
- package/build/src/modeling/importers/JsonSchemaImporter.js.map +1 -1
- package/build/src/modeling/types.d.ts +0 -14
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +15 -15
- package/package.json +4 -4
- package/src/modeling/DataDomain.ts +6 -6
- package/src/modeling/DomainAssociation.ts +1 -1
- package/src/modeling/DomainEntity.ts +36 -18
- package/src/modeling/helpers/Intelisense.ts +8 -14
- package/src/modeling/importers/JsonSchemaImporter.ts +1 -1
- package/src/modeling/types.ts +0 -15
- package/tests/unit/modeling/amf/shape_generator.spec.ts +4 -4
- package/tests/unit/modeling/api_model_expose_entity.spec.ts +11 -11
- package/tests/unit/modeling/api_model_remove_entity.spec.ts +1 -1
- package/tests/unit/modeling/data_domain_associations.spec.ts +6 -6
- package/tests/unit/modeling/data_domain_foreign.spec.ts +2 -2
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +1 -1
- package/tests/unit/modeling/data_domain_serialization.spec.ts +15 -15
- package/tests/unit/modeling/domain_asociation.spec.ts +15 -15
- package/tests/unit/modeling/domain_entity.spec.ts +3 -3
- package/tests/unit/modeling/domain_entity_associations.spec.ts +4 -4
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +16 -16
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +14 -14
- package/tests/unit/modeling/domain_property.spec.ts +1 -1
- package/tests/unit/modeling/domain_validation.spec.ts +3 -3
- package/tests/unit/modeling/domain_versioning.spec.ts +5 -5
- package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
- package/tests/unit/modeling/validation/association_validation.spec.ts +40 -56
- 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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
84
|
-
|
|
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
|
-
|
|
101
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
-
|
|
135
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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' } })
|