@api-client/core 0.18.13 → 0.18.15
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/DomainValidation.d.ts +78 -0
- package/build/src/modeling/DomainValidation.d.ts.map +1 -1
- package/build/src/modeling/DomainValidation.js +78 -0
- package/build/src/modeling/DomainValidation.js.map +1 -1
- package/build/src/modeling/importers/FilteringJsonSchemaImporter.d.ts +84 -0
- package/build/src/modeling/importers/FilteringJsonSchemaImporter.d.ts.map +1 -0
- package/build/src/modeling/importers/FilteringJsonSchemaImporter.js +254 -0
- package/build/src/modeling/importers/FilteringJsonSchemaImporter.js.map +1 -0
- package/build/src/modeling/importers/SchemaFilteringStrategy.d.ts +72 -0
- package/build/src/modeling/importers/SchemaFilteringStrategy.d.ts.map +1 -0
- package/build/src/modeling/importers/SchemaFilteringStrategy.js +140 -0
- package/build/src/modeling/importers/SchemaFilteringStrategy.js.map +1 -0
- package/build/src/modeling/validation/entity_validation.d.ts +17 -3
- package/build/src/modeling/validation/entity_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/entity_validation.js +51 -10
- package/build/src/modeling/validation/entity_validation.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +15 -15
- package/package.json +1 -1
- package/src/modeling/DomainValidation.ts +78 -0
- package/src/modeling/importers/FilteringJsonSchemaImporter.ts +324 -0
- package/src/modeling/importers/SchemaFilteringStrategy.ts +201 -0
- package/src/modeling/validation/entity_validation.ts +59 -10
- package/tests/unit/modeling/importers/schema_filtering.spec.ts +764 -0
- package/tests/unit/modeling/validation/entity_validation.spec.ts +95 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
1
2
|
import { test } from '@japa/runner'
|
|
2
3
|
import { DataDomain, EntityValidation } from '../../../../src/index.js'
|
|
3
4
|
|
|
@@ -78,6 +79,100 @@ test.group('EntityValidation', (group) => {
|
|
|
78
79
|
assert.lengthOf(results, 0)
|
|
79
80
|
})
|
|
80
81
|
|
|
82
|
+
test('minimumRequiredProperties() should return no errors when the entity inherits properties from parent', ({
|
|
83
|
+
assert,
|
|
84
|
+
}) => {
|
|
85
|
+
const model = domain.addModel({ key: 'model' })
|
|
86
|
+
const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
|
|
87
|
+
parent.addProperty({ key: 'name', type: 'string' })
|
|
88
|
+
const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })
|
|
89
|
+
entity.addParent(parent.key)
|
|
90
|
+
const results = validation.minimumRequiredProperties(entity)
|
|
91
|
+
assert.lengthOf(results, 0)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('minimumRequiredProperties() should return no errors when the entity inherits associations from parent', ({
|
|
95
|
+
assert,
|
|
96
|
+
}) => {
|
|
97
|
+
const model = domain.addModel({ key: 'model' })
|
|
98
|
+
const target = model.addEntity({ key: 'target', info: { name: 'Target' } })
|
|
99
|
+
const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
|
|
100
|
+
parent.addAssociation({ key: target.key })
|
|
101
|
+
const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })
|
|
102
|
+
entity.addParent(parent.key)
|
|
103
|
+
const results = validation.minimumRequiredProperties(entity)
|
|
104
|
+
assert.lengthOf(results, 0)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('minimumRequiredProperties() should return no errors when the entity inherits properties from grandparent', ({
|
|
108
|
+
assert,
|
|
109
|
+
}) => {
|
|
110
|
+
const model = domain.addModel({ key: 'model' })
|
|
111
|
+
const grandparent = model.addEntity({
|
|
112
|
+
key: 'grandparent',
|
|
113
|
+
info: { name: 'Grandparent' },
|
|
114
|
+
})
|
|
115
|
+
grandparent.addProperty({ key: 'name', type: 'string' })
|
|
116
|
+
const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
|
|
117
|
+
parent.addParent(grandparent.key)
|
|
118
|
+
const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })
|
|
119
|
+
entity.addParent(parent.key)
|
|
120
|
+
const results = validation.minimumRequiredProperties(entity)
|
|
121
|
+
assert.lengthOf(results, 0)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test('minimumRequiredProperties() should return no errors when the entity inherits associations from grandparent', ({
|
|
125
|
+
assert,
|
|
126
|
+
}) => {
|
|
127
|
+
const model = domain.addModel({ key: 'model' })
|
|
128
|
+
const target = model.addEntity({ key: 'target', info: { name: 'Target' } })
|
|
129
|
+
const grandparent = model.addEntity({
|
|
130
|
+
key: 'grandparent',
|
|
131
|
+
info: { name: 'Grandparent' },
|
|
132
|
+
})
|
|
133
|
+
grandparent.addAssociation({ key: target.key })
|
|
134
|
+
const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
|
|
135
|
+
parent.addParent(grandparent.key)
|
|
136
|
+
const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })
|
|
137
|
+
entity.addParent(parent.key)
|
|
138
|
+
const results = validation.minimumRequiredProperties(entity)
|
|
139
|
+
assert.lengthOf(results, 0)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
test('minimumRequiredProperties() should return no errors when the entity inherits properties from great-grandparent', ({
|
|
143
|
+
assert,
|
|
144
|
+
}) => {
|
|
145
|
+
const model = domain.addModel({ key: 'model' })
|
|
146
|
+
const greatGrandparent = model.addEntity({
|
|
147
|
+
key: 'great_grandparent',
|
|
148
|
+
info: { name: 'GreatGrandparent' },
|
|
149
|
+
})
|
|
150
|
+
greatGrandparent.addProperty({ key: 'name', type: 'string' })
|
|
151
|
+
const grandparent = model.addEntity({ key: 'grandparent', info: { name: 'Grandparent' } })
|
|
152
|
+
grandparent.addParent(greatGrandparent.key)
|
|
153
|
+
const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
|
|
154
|
+
parent.addParent(grandparent.key)
|
|
155
|
+
const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })
|
|
156
|
+
entity.addParent(parent.key)
|
|
157
|
+
const results = validation.minimumRequiredProperties(entity)
|
|
158
|
+
assert.lengthOf(results, 0)
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
test('minimumRequiredProperties() should return warning when the entity has no properties in entire inheritance chain', ({
|
|
162
|
+
assert,
|
|
163
|
+
}) => {
|
|
164
|
+
const model = domain.addModel({ key: 'model' })
|
|
165
|
+
const grandparent = model.addEntity({ key: 'grandparent', info: { name: 'Grandparent' } })
|
|
166
|
+
const parent = model.addEntity({ key: 'parent', info: { name: 'Parent' } })
|
|
167
|
+
parent.addParent(grandparent.key)
|
|
168
|
+
const entity = model.addEntity({ key: 'entity', info: { name: 'Entity' } })
|
|
169
|
+
entity.addParent(parent.key)
|
|
170
|
+
const results = validation.minimumRequiredProperties(entity)
|
|
171
|
+
assert.lengthOf(results, 1)
|
|
172
|
+
assert.equal(results[0].severity, 'warning')
|
|
173
|
+
assert.equal(results[0].rule, 'required')
|
|
174
|
+
})
|
|
175
|
+
|
|
81
176
|
test('validateName() should return an error when the entity has no name', ({ assert }) => {
|
|
82
177
|
const model = domain.addModel({ key: 'model' })
|
|
83
178
|
const entity = model.addEntity({ key: 'entity', info: {} })
|