@api-client/core 0.14.0 → 0.14.1
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/amf/AmfTypes.d.ts +1 -1
- package/build/src/amf/AmfTypes.js +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/Utils.d.ts +0 -6
- package/build/src/amf/Utils.d.ts.map +1 -1
- package/build/src/amf/Utils.js +0 -14
- package/build/src/amf/Utils.js.map +1 -1
- package/build/src/browser.d.ts +1 -0
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +1 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +0 -8
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +0 -9
- package/build/src/legacy.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.js +2 -2
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DataFormat.d.ts +0 -40
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +0 -27
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +28 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js +73 -4
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +25 -9
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +65 -21
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +1 -1
- package/build/src/modeling/DomainFile.js +1 -1
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +3 -3
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +2 -2
- package/build/src/modeling/DomainModel.js +2 -2
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +28 -12
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +61 -26
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +109 -0
- package/build/src/modeling/Semantics.d.ts.map +1 -0
- package/build/src/modeling/Semantics.js +97 -0
- package/build/src/modeling/Semantics.js.map +1 -0
- package/build/src/models/kinds.d.ts +0 -24
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +0 -24
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/data_catalog.d.ts +1 -1
- package/build/src/models/store/data_catalog.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +11 -11
- package/package.json +1 -1
- package/src/amf/AmfTypes.ts +1 -1
- package/src/amf/Utils.ts +0 -15
- package/src/modeling/Bindings.ts +1 -1
- package/src/modeling/DataDomain.ts +2 -2
- package/src/modeling/DataFormat.ts +0 -48
- package/src/modeling/DomainAssociation.ts +66 -3
- package/src/modeling/DomainEntity.ts +56 -17
- package/src/modeling/DomainFile.ts +1 -1
- package/src/modeling/DomainImpactAnalysis.ts +3 -3
- package/src/modeling/DomainModel.ts +2 -2
- package/src/modeling/DomainProperty.ts +60 -21
- package/src/modeling/Semantics.ts +178 -0
- package/src/modeling/graph.md +14 -14
- package/src/modeling/readme.md +29 -29
- package/src/models/kinds.ts +0 -25
- package/src/models/store/data_catalog.ts +1 -1
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
- package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
- package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
- package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
- package/tests/unit/modeling/domain_entity.spec.ts +27 -26
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
- package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
- package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
- package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
- package/build/src/amf/AmfShapeGenerator.js +0 -416
- package/build/src/amf/AmfShapeGenerator.js.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataAssociation.js +0 -443
- package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
- package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
- package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntity.js +0 -855
- package/build/src/modeling/legacy/DataEntity.js.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
- package/build/src/modeling/legacy/DataModel.d.ts +0 -99
- package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataModel.js +0 -237
- package/build/src/modeling/legacy/DataModel.js.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataNamespace.js +0 -784
- package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
- package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
- package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/legacy/DataProperty.js +0 -415
- package/build/src/modeling/legacy/DataProperty.js.map +0 -1
- package/build/src/models/store/DataFile.d.ts +0 -29
- package/build/src/models/store/DataFile.d.ts.map +0 -1
- package/build/src/models/store/DataFile.js +0 -87
- package/build/src/models/store/DataFile.js.map +0 -1
- package/src/amf/AmfShapeGenerator.ts +0 -477
- package/src/modeling/legacy/DataAssociation.ts +0 -554
- package/src/modeling/legacy/DataEntity.ts +0 -1019
- package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
- package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
- package/src/modeling/legacy/DataModel.ts +0 -276
- package/src/modeling/legacy/DataNamespace.ts +0 -929
- package/src/modeling/legacy/DataProperty.ts +0 -630
- package/src/models/store/DataFile.ts +0 -95
- package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
- package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
- package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
- package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
- package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
- package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
- package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
- package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
- package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
|
@@ -1,1041 +0,0 @@
|
|
|
1
|
-
import { test } from '@japa/runner'
|
|
2
|
-
import { DataProperty } from '../../../../src/modeling/legacy/DataProperty.js'
|
|
3
|
-
import { DataEntity } from '../../../../src/modeling/legacy/DataEntity.js'
|
|
4
|
-
import { DataNamespace } from '../../../../src/modeling/legacy/DataNamespace.js'
|
|
5
|
-
import { DataModel } from '../../../../src/modeling/legacy/DataModel.js'
|
|
6
|
-
import {
|
|
7
|
-
IApiArrayShape,
|
|
8
|
-
IApiDataExample,
|
|
9
|
-
IApiFileShape,
|
|
10
|
-
IApiNodeShape,
|
|
11
|
-
IApiScalarNode,
|
|
12
|
-
IApiScalarShape,
|
|
13
|
-
IApiUnionShape,
|
|
14
|
-
IApiXmlSerializer,
|
|
15
|
-
IShapeUnion,
|
|
16
|
-
} from '../../../../src/amf/definitions/Shapes.js'
|
|
17
|
-
import {
|
|
18
|
-
IAmfAnyTypes,
|
|
19
|
-
IAmfArrayTypes,
|
|
20
|
-
IAmfExampleTypes,
|
|
21
|
-
IAmfFileTypes,
|
|
22
|
-
IAmfNodeTypes,
|
|
23
|
-
IAmfPropertyTypes,
|
|
24
|
-
IAmfScalarTypes,
|
|
25
|
-
IAmfUnionTypes,
|
|
26
|
-
} from '../../../../src/amf/AmfTypes.js'
|
|
27
|
-
import { AmfNamespace } from '../../../../src/amf/definitions/Namespace.js'
|
|
28
|
-
import { AmfShapeGenerator } from '../../../../src/amf/AmfShapeGenerator.js'
|
|
29
|
-
import { DataAssociation } from '../../../../src/modeling/legacy/DataAssociation.js'
|
|
30
|
-
import type { PropertyWebBindings } from '../../../../src/index.js'
|
|
31
|
-
|
|
32
|
-
test.group('entity()', (group) => {
|
|
33
|
-
let root: DataNamespace
|
|
34
|
-
let m1: DataModel
|
|
35
|
-
let e1: DataEntity
|
|
36
|
-
|
|
37
|
-
group.each.setup(() => {
|
|
38
|
-
root = new DataNamespace()
|
|
39
|
-
m1 = root.addDataModel('m1')
|
|
40
|
-
e1 = m1.addEntity('e1')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('returns the basic shape', ({ assert }) => {
|
|
44
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
45
|
-
|
|
46
|
-
assert.equal(result.id, e1.key, 'has the id')
|
|
47
|
-
assert.deepEqual(result.types, IAmfNodeTypes, 'has the types')
|
|
48
|
-
assert.deepEqual(result.values, [], 'has the values')
|
|
49
|
-
assert.deepEqual(result.inherits, [], 'has the inherits')
|
|
50
|
-
assert.deepEqual(result.or, [], 'has the or')
|
|
51
|
-
assert.deepEqual(result.and, [], 'has the and')
|
|
52
|
-
assert.deepEqual(result.xone, [], 'has the xone')
|
|
53
|
-
assert.deepEqual(result.examples, [], 'has the examples')
|
|
54
|
-
assert.deepEqual(result.properties, [], 'has the properties')
|
|
55
|
-
assert.typeOf(result.xmlSerialization, 'object', 'has the xmlSerialization')
|
|
56
|
-
assert.equal(result.name, 'e1', 'has the name')
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test('returns the display name', ({ assert }) => {
|
|
60
|
-
e1.info.displayName = 'e 1 name'
|
|
61
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
62
|
-
|
|
63
|
-
assert.equal(result.displayName, 'e 1 name')
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test('returns the description', ({ assert }) => {
|
|
67
|
-
e1.info.description = 'e 1 description'
|
|
68
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
69
|
-
|
|
70
|
-
assert.equal(result.description, 'e 1 description')
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test('returns the deprecated', ({ assert }) => {
|
|
74
|
-
e1.deprecated = true
|
|
75
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
76
|
-
|
|
77
|
-
assert.isTrue(result.deprecated)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test('returns empty properties', ({ assert }) => {
|
|
81
|
-
e1.info.description = 'e 1 description'
|
|
82
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
83
|
-
|
|
84
|
-
assert.deepEqual(result.properties, [])
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
test('returns defined properties', ({ assert }) => {
|
|
88
|
-
e1.addNamedProperty('test')
|
|
89
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
90
|
-
|
|
91
|
-
assert.lengthOf(result.properties, 1)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
test('adds associations to the properties', ({ assert }) => {
|
|
95
|
-
e1.addNamedProperty('test')
|
|
96
|
-
e1.addNamedAssociation('test association')
|
|
97
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
98
|
-
|
|
99
|
-
assert.lengthOf(result.properties, 2)
|
|
100
|
-
assert.equal(result.properties[1].name, 'test association')
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('adds parents to the inherits', ({ assert }) => {
|
|
104
|
-
const e2 = m1.addEntity('e2')
|
|
105
|
-
e1.parents = [e2.key]
|
|
106
|
-
const result = e1.toApiShape() as IApiNodeShape
|
|
107
|
-
|
|
108
|
-
assert.lengthOf(result.inherits, 1)
|
|
109
|
-
assert.equal(result.inherits[0].name, 'e2')
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
test.group('property() / just data model', (group) => {
|
|
114
|
-
let root: DataNamespace
|
|
115
|
-
let m1: DataModel
|
|
116
|
-
let e1: DataEntity
|
|
117
|
-
let p1: DataProperty
|
|
118
|
-
|
|
119
|
-
group.each.setup(() => {
|
|
120
|
-
root = new DataNamespace()
|
|
121
|
-
m1 = root.addDataModel('m1')
|
|
122
|
-
e1 = m1.addEntity('e1')
|
|
123
|
-
p1 = e1.addNamedProperty('p1')
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test('returns the basic shape', ({ assert }) => {
|
|
127
|
-
const result = p1.toApiShape()
|
|
128
|
-
assert.equal(result.id, p1.key, 'has the id')
|
|
129
|
-
assert.deepEqual(result.types, IAmfPropertyTypes, 'has the types')
|
|
130
|
-
assert.deepEqual(result.values, [], 'has the values')
|
|
131
|
-
assert.deepEqual(result.inherits, [], 'has the inherits')
|
|
132
|
-
assert.deepEqual(result.or, [], 'has the or')
|
|
133
|
-
assert.deepEqual(result.and, [], 'has the and')
|
|
134
|
-
assert.deepEqual(result.xone, [], 'has the xone')
|
|
135
|
-
assert.equal(result.path, AmfNamespace.aml.vocabularies.data.key + 'p1', 'has the path')
|
|
136
|
-
assert.equal(result.name, 'p1', 'has the name')
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test('sets the minCount', ({ assert }) => {
|
|
140
|
-
p1.required = true
|
|
141
|
-
const result = p1.toApiShape()
|
|
142
|
-
|
|
143
|
-
assert.equal(result.minCount, 1)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
test('has the default range for a string', ({ assert }) => {
|
|
147
|
-
p1.info.displayName = 'string dn'
|
|
148
|
-
p1.info.description = 'string desc'
|
|
149
|
-
const result = p1.toApiShape()
|
|
150
|
-
const range = result.range as IApiScalarShape
|
|
151
|
-
|
|
152
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
153
|
-
assert.equal(range.id, `scalar-shape-${p1.key}`, 'has the id')
|
|
154
|
-
assert.deepEqual(range.types, IAmfScalarTypes, 'has the types')
|
|
155
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.string, 'has the dataType')
|
|
156
|
-
assert.equal(range.name, 'p1', 'has the name')
|
|
157
|
-
assert.equal(range.displayName, 'string dn', 'has the displayName')
|
|
158
|
-
assert.equal(range.description, 'string desc', 'has the description')
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
test('handles examples', ({ assert }) => {
|
|
162
|
-
p1.schema = { examples: ['example1', 'example2'] }
|
|
163
|
-
const result = p1.toApiShape()
|
|
164
|
-
const range = result.range as IApiScalarShape
|
|
165
|
-
assert.lengthOf(range.examples, 2)
|
|
166
|
-
assert.property(range.examples[0], 'structuredValue')
|
|
167
|
-
assert.property(range.examples[1], 'structuredValue')
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
test('handles defaultValue', ({ assert }) => {
|
|
171
|
-
p1.schema = { defaultValue: { value: 'defaultValue', type: 'literal' } }
|
|
172
|
-
const result = p1.toApiShape()
|
|
173
|
-
const range = result.range as IApiScalarShape
|
|
174
|
-
assert.property(range, 'defaultValue')
|
|
175
|
-
assert.containsSubset(range.defaultValue, {
|
|
176
|
-
value: 'defaultValue',
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
test('handles enum', ({ assert }) => {
|
|
181
|
-
p1.schema = { enum: ['enum1', 'enum2'] }
|
|
182
|
-
const result = p1.toApiShape()
|
|
183
|
-
const range = result.range as IApiScalarShape
|
|
184
|
-
assert.lengthOf(range.values, 2)
|
|
185
|
-
assert.containsSubset(range.values[0], {
|
|
186
|
-
dataType: AmfNamespace.w3.xmlSchema.string,
|
|
187
|
-
value: `enum1`,
|
|
188
|
-
})
|
|
189
|
-
assert.containsSubset(range.values[1], {
|
|
190
|
-
dataType: AmfNamespace.w3.xmlSchema.string,
|
|
191
|
-
value: `enum2`,
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
test('has the default range for a number', ({ assert }) => {
|
|
196
|
-
p1.type = 'number'
|
|
197
|
-
const result = p1.toApiShape()
|
|
198
|
-
const range = result.range as IApiScalarShape
|
|
199
|
-
|
|
200
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
201
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.number, 'has the dataType')
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
test('handles readOnly and writeOnly', ({ assert }) => {
|
|
205
|
-
p1.readOnly = true
|
|
206
|
-
p1.writeOnly = true
|
|
207
|
-
const result = p1.toApiShape()
|
|
208
|
-
assert.isTrue(result.range?.readOnly)
|
|
209
|
-
assert.isTrue(result.range?.writeOnly)
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
test('handles deprecated', ({ assert }) => {
|
|
213
|
-
p1.deprecated = true
|
|
214
|
-
const result = p1.toApiShape()
|
|
215
|
-
assert.isTrue(result.deprecated)
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
test('handles multiple properties', ({ assert }) => {
|
|
219
|
-
p1.multiple = true
|
|
220
|
-
const result = p1.toApiShape()
|
|
221
|
-
const range = result.range as IApiArrayShape
|
|
222
|
-
assert.property(range, 'items')
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
test('handles binary base64 format', ({ assert }) => {
|
|
226
|
-
p1.type = 'binary'
|
|
227
|
-
const bindings = p1.getWebBinding() as PropertyWebBindings
|
|
228
|
-
bindings.format = 'base64'
|
|
229
|
-
const result = p1.toApiShape()
|
|
230
|
-
const range = result.range as IApiFileShape
|
|
231
|
-
assert.equal(range.format, AmfNamespace.w3.xmlSchema.base64Binary)
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
test('has the default range for an int32 format', ({ assert }) => {
|
|
235
|
-
p1.type = 'number'
|
|
236
|
-
const bindings = p1.getWebBinding()
|
|
237
|
-
bindings.format = 'int32'
|
|
238
|
-
const result = p1.toApiShape()
|
|
239
|
-
const range = result.range as IApiScalarShape
|
|
240
|
-
|
|
241
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
242
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.integer, 'has the dataType')
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
test('has the default range for an int64 format', ({ assert }) => {
|
|
246
|
-
p1.type = 'number'
|
|
247
|
-
const bindings = p1.getWebBinding()
|
|
248
|
-
bindings.format = 'int64'
|
|
249
|
-
const result = p1.toApiShape()
|
|
250
|
-
const range = result.range as IApiScalarShape
|
|
251
|
-
|
|
252
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
253
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.integer, 'has the dataType')
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
test('has the default range for a date', ({ assert }) => {
|
|
257
|
-
p1.type = 'date'
|
|
258
|
-
const result = p1.toApiShape()
|
|
259
|
-
const range = result.range as IApiScalarShape
|
|
260
|
-
|
|
261
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
262
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.date, 'has the dataType')
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
test('has the default range for a datetime', ({ assert }) => {
|
|
266
|
-
p1.type = 'datetime'
|
|
267
|
-
const result = p1.toApiShape()
|
|
268
|
-
const range = result.range as IApiScalarShape
|
|
269
|
-
|
|
270
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
271
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.dateTime, 'has the dataType')
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
test('has the default range for a time', ({ assert }) => {
|
|
275
|
-
p1.type = 'time'
|
|
276
|
-
const result = p1.toApiShape()
|
|
277
|
-
const range = result.range as IApiScalarShape
|
|
278
|
-
|
|
279
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
280
|
-
assert.equal(range.dataType, AmfNamespace.aml.vocabularies.shapes.dateTimeOnly, 'has the dataType')
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
// test('has the default range for a nil', ({ assert }) => {
|
|
284
|
-
// p1.type = 'nil'
|
|
285
|
-
// const result = p1.toApiShape()
|
|
286
|
-
// const range = result.range as IApiScalarShape
|
|
287
|
-
|
|
288
|
-
// assert.typeOf(range, 'object', 'has the range')
|
|
289
|
-
// assert.equal(range.dataType, AmfNamespace.aml.vocabularies.shapes.nil, 'has the dataType')
|
|
290
|
-
// })
|
|
291
|
-
|
|
292
|
-
test('has the default range for a boolean', ({ assert }) => {
|
|
293
|
-
p1.type = 'boolean'
|
|
294
|
-
const result = p1.toApiShape()
|
|
295
|
-
const range = result.range as IApiScalarShape
|
|
296
|
-
|
|
297
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
298
|
-
assert.equal(range.dataType, AmfNamespace.aml.vocabularies.shapes.boolean, 'has the dataType')
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
// test('has the default range for an any', ({ assert }) => {
|
|
302
|
-
// p1.type = 'any'
|
|
303
|
-
// const result = p1.toApiShape()
|
|
304
|
-
// const range = result.range as IApiScalarShape
|
|
305
|
-
|
|
306
|
-
// assert.typeOf(range, 'object', 'has the range')
|
|
307
|
-
// assert.equal(range.dataType, AmfNamespace.aml.vocabularies.shapes.AnyShape, 'has the dataType')
|
|
308
|
-
// })
|
|
309
|
-
|
|
310
|
-
test('has the default range for a file', ({ assert }) => {
|
|
311
|
-
p1.type = 'binary'
|
|
312
|
-
p1.info.displayName = 'string dn'
|
|
313
|
-
p1.info.description = 'string desc'
|
|
314
|
-
const result = p1.toApiShape()
|
|
315
|
-
const range = result.range as IApiFileShape
|
|
316
|
-
|
|
317
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
318
|
-
assert.equal(range.id, `file-shape-${p1.key}`, 'has the id')
|
|
319
|
-
assert.deepEqual(range.types, IAmfFileTypes, 'has the types')
|
|
320
|
-
assert.equal(range.name, 'p1', 'has the name')
|
|
321
|
-
assert.equal(range.displayName, 'string dn', 'has the displayName')
|
|
322
|
-
assert.equal(range.description, 'string desc', 'has the description')
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
test('has the default range for a string when a multiple', ({ assert }) => {
|
|
326
|
-
p1.multiple = true
|
|
327
|
-
p1.info.displayName = 'string dn'
|
|
328
|
-
p1.info.description = 'string desc'
|
|
329
|
-
const result = p1.toApiShape()
|
|
330
|
-
const range = result.range as IApiArrayShape
|
|
331
|
-
|
|
332
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
333
|
-
assert.equal(range.id, `array-shape-${p1.key}`, 'has the id')
|
|
334
|
-
assert.deepEqual(range.types, IAmfArrayTypes, 'has the types')
|
|
335
|
-
|
|
336
|
-
const items = range.items as IApiScalarShape
|
|
337
|
-
|
|
338
|
-
assert.typeOf(items, 'object', 'has the items')
|
|
339
|
-
assert.equal(items.id, `scalar-shape-${p1.key}`, 'has the id')
|
|
340
|
-
assert.deepEqual(items.types, IAmfScalarTypes, 'has the types')
|
|
341
|
-
|
|
342
|
-
assert.equal(items.name, 'p1', 'has the name')
|
|
343
|
-
assert.equal(items.displayName, 'string dn', 'has the displayName')
|
|
344
|
-
assert.equal(items.description, 'string desc', 'has the description')
|
|
345
|
-
})
|
|
346
|
-
|
|
347
|
-
test('has the default range for a file when a multiple', ({ assert }) => {
|
|
348
|
-
p1.multiple = true
|
|
349
|
-
p1.type = 'binary'
|
|
350
|
-
p1.info.displayName = 'string dn'
|
|
351
|
-
p1.info.description = 'string desc'
|
|
352
|
-
const result = p1.toApiShape()
|
|
353
|
-
const range = result.range as IApiArrayShape
|
|
354
|
-
|
|
355
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
356
|
-
assert.equal(range.id, `array-shape-${p1.key}`, 'has the id')
|
|
357
|
-
assert.deepEqual(range.types, IAmfArrayTypes, 'has the types')
|
|
358
|
-
|
|
359
|
-
const items = range.items as IApiFileShape
|
|
360
|
-
|
|
361
|
-
assert.typeOf(items, 'object', 'has the items')
|
|
362
|
-
assert.equal(items.id, `file-shape-${p1.key}`, 'has the id')
|
|
363
|
-
assert.deepEqual(items.types, IAmfFileTypes, 'has the types')
|
|
364
|
-
|
|
365
|
-
assert.equal(items.name, 'p1', 'has the name')
|
|
366
|
-
assert.equal(items.displayName, 'string dn', 'has the displayName')
|
|
367
|
-
assert.equal(items.description, 'string desc', 'has the description')
|
|
368
|
-
})
|
|
369
|
-
})
|
|
370
|
-
|
|
371
|
-
test.group('property() / with web bindings', (group) => {
|
|
372
|
-
let root: DataNamespace
|
|
373
|
-
let m1: DataModel
|
|
374
|
-
let e1: DataEntity
|
|
375
|
-
|
|
376
|
-
group.each.setup(() => {
|
|
377
|
-
root = new DataNamespace()
|
|
378
|
-
m1 = root.addDataModel('m1')
|
|
379
|
-
e1 = m1.addEntity('e1')
|
|
380
|
-
})
|
|
381
|
-
|
|
382
|
-
test('updates the name when changed', ({ assert }) => {
|
|
383
|
-
const p1 = e1.addTypedProperty('string', 'p1')
|
|
384
|
-
p1.bindings = [
|
|
385
|
-
{
|
|
386
|
-
type: 'web',
|
|
387
|
-
schema: {
|
|
388
|
-
name: 'other',
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
]
|
|
392
|
-
const result = p1.toApiShape()
|
|
393
|
-
const string = result.range as IApiScalarShape
|
|
394
|
-
|
|
395
|
-
assert.equal(string.name, 'other', 'the range has the changed name')
|
|
396
|
-
assert.equal(result.name, 'other', 'the property has the changed name')
|
|
397
|
-
})
|
|
398
|
-
|
|
399
|
-
// test('sets the dataType', ({ assert }) => {
|
|
400
|
-
// const p1 = e1.addTypedProperty('string', 'p1')
|
|
401
|
-
// p1.bindings = [
|
|
402
|
-
// {
|
|
403
|
-
// type: 'web',
|
|
404
|
-
// schema: {
|
|
405
|
-
// // dataType: AmfNamespace.w3.xmlSchema.date,
|
|
406
|
-
// },
|
|
407
|
-
// },
|
|
408
|
-
// ]
|
|
409
|
-
// const result = p1.toApiShape()
|
|
410
|
-
// const string = result.range as IApiScalarShape
|
|
411
|
-
// assert.equal(string.dataType, AmfNamespace.w3.xmlSchema.date)
|
|
412
|
-
// })
|
|
413
|
-
|
|
414
|
-
test('sets the xml serialization', ({ assert }) => {
|
|
415
|
-
const p1 = e1.addTypedProperty('string', 'p1')
|
|
416
|
-
const value: IApiXmlSerializer = {
|
|
417
|
-
id: '',
|
|
418
|
-
types: [],
|
|
419
|
-
customDomainProperties: [],
|
|
420
|
-
name: 'test',
|
|
421
|
-
}
|
|
422
|
-
p1.bindings = [
|
|
423
|
-
{
|
|
424
|
-
type: 'web',
|
|
425
|
-
schema: {
|
|
426
|
-
xml: value,
|
|
427
|
-
},
|
|
428
|
-
},
|
|
429
|
-
]
|
|
430
|
-
const result = p1.toApiShape()
|
|
431
|
-
const string = result.range as IApiScalarShape
|
|
432
|
-
assert.deepEqual(string.xmlSerialization, value)
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
test('sets the file types', ({ assert }) => {
|
|
436
|
-
const p1 = e1.addTypedProperty('binary', 'p1')
|
|
437
|
-
const value: string[] = ['a']
|
|
438
|
-
p1.bindings = [
|
|
439
|
-
{
|
|
440
|
-
type: 'web',
|
|
441
|
-
schema: {
|
|
442
|
-
fileTypes: value,
|
|
443
|
-
},
|
|
444
|
-
},
|
|
445
|
-
]
|
|
446
|
-
const result = p1.toApiShape()
|
|
447
|
-
const file = result.range as IApiFileShape
|
|
448
|
-
assert.deepEqual(file.fileTypes, value)
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
test('sets the pattern', ({ assert }) => {
|
|
452
|
-
const p1 = e1.addTypedProperty('string', 'p1')
|
|
453
|
-
p1.bindings = [
|
|
454
|
-
{
|
|
455
|
-
type: 'web',
|
|
456
|
-
schema: {
|
|
457
|
-
pattern: 'a-z',
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
]
|
|
461
|
-
const result = p1.toApiShape()
|
|
462
|
-
const string = result.range as IApiScalarShape
|
|
463
|
-
assert.equal(string.pattern, 'a-z')
|
|
464
|
-
})
|
|
465
|
-
|
|
466
|
-
test('sets the minLength', ({ assert }) => {
|
|
467
|
-
const p1 = e1.addTypedProperty('string', 'p1')
|
|
468
|
-
p1.schema = {
|
|
469
|
-
minimum: 1,
|
|
470
|
-
}
|
|
471
|
-
const result = p1.toApiShape()
|
|
472
|
-
const string = result.range as IApiScalarShape
|
|
473
|
-
assert.equal(string.minLength, 1)
|
|
474
|
-
})
|
|
475
|
-
|
|
476
|
-
test('sets the maxLength', ({ assert }) => {
|
|
477
|
-
const p1 = e1.addTypedProperty('string', 'p1')
|
|
478
|
-
p1.schema = {
|
|
479
|
-
maximum: 1,
|
|
480
|
-
}
|
|
481
|
-
const result = p1.toApiShape()
|
|
482
|
-
const string = result.range as IApiScalarShape
|
|
483
|
-
assert.equal(string.maxLength, 1)
|
|
484
|
-
})
|
|
485
|
-
|
|
486
|
-
test('sets the minimum', ({ assert }) => {
|
|
487
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
488
|
-
p1.schema = {
|
|
489
|
-
minimum: 1,
|
|
490
|
-
}
|
|
491
|
-
const result = p1.toApiShape()
|
|
492
|
-
const string = result.range as IApiScalarShape
|
|
493
|
-
assert.equal(string.minimum, 1)
|
|
494
|
-
})
|
|
495
|
-
|
|
496
|
-
test('sets the maximum', ({ assert }) => {
|
|
497
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
498
|
-
p1.schema = {
|
|
499
|
-
maximum: 1,
|
|
500
|
-
}
|
|
501
|
-
const result = p1.toApiShape()
|
|
502
|
-
const string = result.range as IApiScalarShape
|
|
503
|
-
assert.equal(string.maximum, 1)
|
|
504
|
-
})
|
|
505
|
-
|
|
506
|
-
test('sets the multipleOf', ({ assert }) => {
|
|
507
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
508
|
-
p1.schema = {
|
|
509
|
-
multipleOf: 1,
|
|
510
|
-
}
|
|
511
|
-
const result = p1.toApiShape()
|
|
512
|
-
const string = result.range as IApiScalarShape
|
|
513
|
-
assert.equal(string.multipleOf, 1)
|
|
514
|
-
})
|
|
515
|
-
|
|
516
|
-
test('sets the exclusiveMinimum', ({ assert }) => {
|
|
517
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
518
|
-
p1.schema = {
|
|
519
|
-
exclusiveMinimum: true,
|
|
520
|
-
}
|
|
521
|
-
const result = p1.toApiShape()
|
|
522
|
-
const string = result.range as IApiScalarShape
|
|
523
|
-
assert.isTrue(string.exclusiveMinimum)
|
|
524
|
-
})
|
|
525
|
-
|
|
526
|
-
test('sets the exclusiveMaximum to false', ({ assert }) => {
|
|
527
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
528
|
-
p1.schema = {
|
|
529
|
-
exclusiveMaximum: false,
|
|
530
|
-
}
|
|
531
|
-
const result = p1.toApiShape()
|
|
532
|
-
const string = result.range as IApiScalarShape
|
|
533
|
-
assert.isFalse(string.exclusiveMaximum)
|
|
534
|
-
})
|
|
535
|
-
|
|
536
|
-
test('sets the exclusiveMaximum to true', ({ assert }) => {
|
|
537
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
538
|
-
p1.schema = {
|
|
539
|
-
exclusiveMaximum: true,
|
|
540
|
-
}
|
|
541
|
-
const result = p1.toApiShape()
|
|
542
|
-
const string = result.range as IApiScalarShape
|
|
543
|
-
assert.isTrue(string.exclusiveMaximum)
|
|
544
|
-
})
|
|
545
|
-
|
|
546
|
-
test('sets the format', ({ assert }) => {
|
|
547
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
548
|
-
p1.bindings = [
|
|
549
|
-
{
|
|
550
|
-
type: 'web',
|
|
551
|
-
schema: {
|
|
552
|
-
format: 'float',
|
|
553
|
-
},
|
|
554
|
-
},
|
|
555
|
-
]
|
|
556
|
-
const result = p1.toApiShape()
|
|
557
|
-
const string = result.range as IApiScalarShape
|
|
558
|
-
assert.equal(string.format, AmfNamespace.w3.xmlSchema.float)
|
|
559
|
-
})
|
|
560
|
-
})
|
|
561
|
-
|
|
562
|
-
test.group('property() / with schema', (group) => {
|
|
563
|
-
let root: DataNamespace
|
|
564
|
-
let m1: DataModel
|
|
565
|
-
let e1: DataEntity
|
|
566
|
-
|
|
567
|
-
group.each.setup(() => {
|
|
568
|
-
root = new DataNamespace()
|
|
569
|
-
m1 = root.addDataModel('m1')
|
|
570
|
-
e1 = m1.addEntity('e1')
|
|
571
|
-
})
|
|
572
|
-
|
|
573
|
-
test('sets the default value', ({ assert }) => {
|
|
574
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
575
|
-
p1.schema = {
|
|
576
|
-
defaultValue: { value: '123', type: 'literal' },
|
|
577
|
-
}
|
|
578
|
-
const result = p1.toApiShape()
|
|
579
|
-
const range = result.range as IApiScalarShape
|
|
580
|
-
assert.typeOf(range.defaultValue, 'object', 'has the defaultValue')
|
|
581
|
-
const value = range.defaultValue as IApiScalarNode
|
|
582
|
-
assert.strictEqual(value.value, '123', 'has the value')
|
|
583
|
-
assert.equal(value.dataType, AmfNamespace.w3.xmlSchema.number, 'has the range data type')
|
|
584
|
-
})
|
|
585
|
-
|
|
586
|
-
test('sets the enum value', ({ assert }) => {
|
|
587
|
-
const p1 = e1.addTypedProperty('number', 'p1')
|
|
588
|
-
p1.schema = {
|
|
589
|
-
enum: ['123'],
|
|
590
|
-
}
|
|
591
|
-
const result = p1.toApiShape()
|
|
592
|
-
const range = result.range as IApiScalarShape
|
|
593
|
-
assert.typeOf(range.values, 'array', 'has the values')
|
|
594
|
-
const value = range.values[0] as IApiScalarNode
|
|
595
|
-
assert.strictEqual(value.value, '123', 'has the value')
|
|
596
|
-
assert.equal(value.dataType, AmfNamespace.w3.xmlSchema.number, 'has the range data type')
|
|
597
|
-
})
|
|
598
|
-
|
|
599
|
-
test('sets the examples value', ({ assert }) => {
|
|
600
|
-
const p1 = e1.addTypedProperty('string', 'p1')
|
|
601
|
-
p1.schema = {
|
|
602
|
-
examples: ['123'],
|
|
603
|
-
}
|
|
604
|
-
const result = p1.toApiShape()
|
|
605
|
-
const range = result.range as IApiScalarShape
|
|
606
|
-
assert.typeOf(range.examples, 'array', 'has the examples')
|
|
607
|
-
const example = range.examples[0] as IApiDataExample
|
|
608
|
-
|
|
609
|
-
assert.typeOf(example.id, 'string', 'has the example.id')
|
|
610
|
-
assert.isNotEmpty(example.id, 'the example.id is not empty')
|
|
611
|
-
assert.deepEqual(example.types, IAmfExampleTypes, 'the example.types')
|
|
612
|
-
assert.typeOf(example.structuredValue, 'object', 'has the example.structuredValue')
|
|
613
|
-
|
|
614
|
-
const value = example.structuredValue as IApiScalarNode
|
|
615
|
-
assert.strictEqual(value.value, '123', 'has the value')
|
|
616
|
-
assert.equal(value.dataType, AmfNamespace.w3.xmlSchema.string, 'has the range data type')
|
|
617
|
-
})
|
|
618
|
-
})
|
|
619
|
-
|
|
620
|
-
test.group('property() / default value functions', (group) => {
|
|
621
|
-
let root: DataNamespace
|
|
622
|
-
let m1: DataModel
|
|
623
|
-
let e1: DataEntity
|
|
624
|
-
let p1: DataProperty
|
|
625
|
-
|
|
626
|
-
group.each.setup(() => {
|
|
627
|
-
root = new DataNamespace()
|
|
628
|
-
m1 = root.addDataModel('m1')
|
|
629
|
-
e1 = m1.addEntity('e1')
|
|
630
|
-
p1 = e1.addNamedProperty('p1')
|
|
631
|
-
})
|
|
632
|
-
|
|
633
|
-
test('generates random string for "random" function', ({ assert }) => {
|
|
634
|
-
p1.schema = { defaultValue: { value: 'random', type: 'function' } }
|
|
635
|
-
const generator = new AmfShapeGenerator()
|
|
636
|
-
const result = generator.property(p1)
|
|
637
|
-
const range = result.range as IApiScalarShape
|
|
638
|
-
assert.typeOf(range.defaultValue, 'object')
|
|
639
|
-
const value = range.defaultValue as IApiScalarNode
|
|
640
|
-
assert.typeOf(value.value, 'string')
|
|
641
|
-
assert.lengthOf(value.value as string, 8)
|
|
642
|
-
})
|
|
643
|
-
|
|
644
|
-
test('generates uuid for "uuid-v4" function', ({ assert }) => {
|
|
645
|
-
p1.schema = { defaultValue: { value: 'uuid-v4', type: 'function' } }
|
|
646
|
-
const generator = new AmfShapeGenerator()
|
|
647
|
-
const result = generator.property(p1)
|
|
648
|
-
const range = result.range as IApiScalarShape
|
|
649
|
-
assert.typeOf(range.defaultValue, 'object')
|
|
650
|
-
const value = range.defaultValue as IApiScalarNode
|
|
651
|
-
assert.typeOf(value.value, 'string')
|
|
652
|
-
assert.lengthOf(value.value as string, 36)
|
|
653
|
-
assert.match(value.value as string, /^[0-9a-f-]+$/)
|
|
654
|
-
})
|
|
655
|
-
|
|
656
|
-
test('generates incremental number for "incremental" function', ({ assert }) => {
|
|
657
|
-
p1.type = 'number'
|
|
658
|
-
p1.schema = { defaultValue: { value: 'incremental', type: 'function' } }
|
|
659
|
-
const generator = new AmfShapeGenerator()
|
|
660
|
-
const result1 = generator.property(p1)
|
|
661
|
-
const range1 = result1.range as IApiScalarShape
|
|
662
|
-
assert.typeOf(range1.defaultValue, 'object')
|
|
663
|
-
const value1 = range1.defaultValue as IApiScalarNode
|
|
664
|
-
assert.typeOf(value1.value, 'string')
|
|
665
|
-
assert.equal(parseInt(value1.value as string), 0)
|
|
666
|
-
|
|
667
|
-
const result2 = generator.property(p1)
|
|
668
|
-
const range2 = result2.range as IApiScalarShape
|
|
669
|
-
assert.typeOf(range2.defaultValue, 'object')
|
|
670
|
-
const value2 = range2.defaultValue as IApiScalarNode
|
|
671
|
-
assert.typeOf(value2.value, 'string')
|
|
672
|
-
assert.equal(parseInt(value2.value as string), 1)
|
|
673
|
-
})
|
|
674
|
-
|
|
675
|
-
test('generates current date for "now" function (date type)', ({ assert }) => {
|
|
676
|
-
p1.type = 'date'
|
|
677
|
-
p1.schema = { defaultValue: { value: 'now', type: 'function' } }
|
|
678
|
-
const generator = new AmfShapeGenerator()
|
|
679
|
-
const result = generator.property(p1)
|
|
680
|
-
const range = result.range as IApiScalarShape
|
|
681
|
-
assert.typeOf(range.defaultValue, 'object')
|
|
682
|
-
const value = range.defaultValue as IApiScalarNode
|
|
683
|
-
assert.typeOf(value.value, 'string')
|
|
684
|
-
assert.match(value.value as string, /^\d{4}-\d{2}-\d{2}$/)
|
|
685
|
-
})
|
|
686
|
-
|
|
687
|
-
test('generates current time for "now" function (time type)', ({ assert }) => {
|
|
688
|
-
p1.type = 'time'
|
|
689
|
-
p1.schema = { defaultValue: { value: 'now', type: 'function' } }
|
|
690
|
-
const generator = new AmfShapeGenerator()
|
|
691
|
-
const result = generator.property(p1)
|
|
692
|
-
const range = result.range as IApiScalarShape
|
|
693
|
-
assert.typeOf(range.defaultValue, 'object')
|
|
694
|
-
const value = range.defaultValue as IApiScalarNode
|
|
695
|
-
assert.typeOf(value.value, 'string')
|
|
696
|
-
assert.match(value.value as string, /^\d{2}:\d{2}:\d{2}$/)
|
|
697
|
-
})
|
|
698
|
-
|
|
699
|
-
test('generates current datetime for "now" function (datetime type)', ({ assert }) => {
|
|
700
|
-
p1.type = 'datetime'
|
|
701
|
-
p1.schema = { defaultValue: { value: 'now', type: 'function' } }
|
|
702
|
-
const generator = new AmfShapeGenerator()
|
|
703
|
-
const result = generator.property(p1)
|
|
704
|
-
const range = result.range as IApiScalarShape
|
|
705
|
-
assert.typeOf(range.defaultValue, 'object')
|
|
706
|
-
const value = range.defaultValue as IApiScalarNode
|
|
707
|
-
assert.typeOf(value.value, 'string')
|
|
708
|
-
assert.match(value.value as string, /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/)
|
|
709
|
-
})
|
|
710
|
-
|
|
711
|
-
test('returns noValue for unsupported function', ({ assert }) => {
|
|
712
|
-
p1.schema = { defaultValue: { value: 'unsupported', type: 'function' } }
|
|
713
|
-
const generator = new AmfShapeGenerator()
|
|
714
|
-
const result = generator.property(p1)
|
|
715
|
-
const range = result.range as IApiScalarShape
|
|
716
|
-
assert.isUndefined(range.defaultValue)
|
|
717
|
-
})
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
test.group('refactorArrayToShape()', (group) => {
|
|
721
|
-
let root: DataNamespace
|
|
722
|
-
let m1: DataModel
|
|
723
|
-
let e1: DataEntity
|
|
724
|
-
let p1: DataProperty
|
|
725
|
-
|
|
726
|
-
group.each.setup(() => {
|
|
727
|
-
root = new DataNamespace()
|
|
728
|
-
m1 = root.addDataModel('m1')
|
|
729
|
-
e1 = m1.addEntity('e1')
|
|
730
|
-
p1 = e1.addNamedProperty('p1')
|
|
731
|
-
})
|
|
732
|
-
|
|
733
|
-
test('returns the array items', ({ assert }) => {
|
|
734
|
-
p1.multiple = true
|
|
735
|
-
const parameter = p1.toApiShape()
|
|
736
|
-
const range = parameter.range as IApiArrayShape
|
|
737
|
-
const shape = range.items as IApiScalarShape
|
|
738
|
-
const generator = new AmfShapeGenerator()
|
|
739
|
-
const result = generator.refactorArrayToShape(range)
|
|
740
|
-
assert.deepEqual(result, shape)
|
|
741
|
-
})
|
|
742
|
-
})
|
|
743
|
-
|
|
744
|
-
test.group('refactorShapeToArray()', (group) => {
|
|
745
|
-
let root: DataNamespace
|
|
746
|
-
let m1: DataModel
|
|
747
|
-
let e1: DataEntity
|
|
748
|
-
let p1: DataProperty
|
|
749
|
-
|
|
750
|
-
group.each.setup(() => {
|
|
751
|
-
root = new DataNamespace()
|
|
752
|
-
m1 = root.addDataModel('m1')
|
|
753
|
-
e1 = m1.addEntity('e1')
|
|
754
|
-
p1 = e1.addNamedProperty('p1')
|
|
755
|
-
})
|
|
756
|
-
|
|
757
|
-
test('returns the array items', ({ assert }) => {
|
|
758
|
-
const parameter = p1.toApiShape()
|
|
759
|
-
const range = parameter.range as IApiScalarShape
|
|
760
|
-
const generator = new AmfShapeGenerator()
|
|
761
|
-
const result = generator.refactorShapeToArray(p1.key, range)
|
|
762
|
-
|
|
763
|
-
assert.typeOf(result, 'object', 'has the range')
|
|
764
|
-
assert.equal(result.id, `array-shape-${p1.key}`, 'has the id')
|
|
765
|
-
assert.deepEqual(result.types, IAmfArrayTypes, 'has the types')
|
|
766
|
-
|
|
767
|
-
const items = result.items as IApiScalarShape
|
|
768
|
-
assert.deepEqual(items, range)
|
|
769
|
-
})
|
|
770
|
-
})
|
|
771
|
-
|
|
772
|
-
test.group('associationProperty()', (group) => {
|
|
773
|
-
let root: DataNamespace
|
|
774
|
-
let m1: DataModel
|
|
775
|
-
let e1: DataEntity
|
|
776
|
-
let e2: DataEntity
|
|
777
|
-
let a1: DataAssociation
|
|
778
|
-
let p2: DataProperty
|
|
779
|
-
|
|
780
|
-
group.each.setup(() => {
|
|
781
|
-
root = new DataNamespace()
|
|
782
|
-
m1 = root.addDataModel('m1')
|
|
783
|
-
e1 = m1.addEntity('e1')
|
|
784
|
-
e2 = m1.addEntity('e2')
|
|
785
|
-
a1 = e1.addTargetAssociation(e2.key, 'a1')
|
|
786
|
-
e1.addTypedProperty('boolean', 'p1')
|
|
787
|
-
p2 = e2.addTypedProperty('number', 'p2')
|
|
788
|
-
})
|
|
789
|
-
|
|
790
|
-
test('returns basic shape definition', ({ assert }) => {
|
|
791
|
-
const result = a1.toApiShape()
|
|
792
|
-
assert.typeOf(result, 'object')
|
|
793
|
-
|
|
794
|
-
assert.equal(result.id, a1.key, 'has the id')
|
|
795
|
-
assert.deepEqual(result.types, IAmfPropertyTypes, 'has the types')
|
|
796
|
-
assert.deepEqual(result.values, [], 'has the values')
|
|
797
|
-
assert.deepEqual(result.inherits, [], 'has the inherits')
|
|
798
|
-
assert.deepEqual(result.or, [], 'has the or')
|
|
799
|
-
assert.deepEqual(result.and, [], 'has the and')
|
|
800
|
-
assert.deepEqual(result.xone, [], 'has the xone')
|
|
801
|
-
assert.equal(result.path, AmfNamespace.aml.vocabularies.data.key + 'a1', 'has the path')
|
|
802
|
-
|
|
803
|
-
const range = result.range as IApiNodeShape
|
|
804
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
805
|
-
assert.deepEqual(range.types, IAmfNodeTypes, 'range has the types')
|
|
806
|
-
assert.equal(range.name, 'e2', 'range has the name')
|
|
807
|
-
assert.lengthOf(range.properties, 1, 'range has the properties')
|
|
808
|
-
|
|
809
|
-
const [prop] = range.properties
|
|
810
|
-
assert.equal(prop.id, p2.key, 'property has the id')
|
|
811
|
-
assert.deepEqual(prop.types, IAmfPropertyTypes, 'property has the types')
|
|
812
|
-
|
|
813
|
-
const pRange = prop.range as IApiScalarShape
|
|
814
|
-
assert.typeOf(pRange, 'object', 'property range is an object')
|
|
815
|
-
assert.deepEqual(pRange.types, IAmfScalarTypes, 'property range has the types')
|
|
816
|
-
assert.equal(pRange.name, 'p2', 'property range has the name')
|
|
817
|
-
assert.equal(pRange.dataType, AmfNamespace.w3.xmlSchema.number, 'property range has the dataType')
|
|
818
|
-
})
|
|
819
|
-
|
|
820
|
-
test('sets property description', ({ assert }) => {
|
|
821
|
-
a1.info.displayName = 'dn a1'
|
|
822
|
-
a1.info.description = 'desc a1'
|
|
823
|
-
const result = a1.toApiShape()
|
|
824
|
-
assert.equal(result.name, 'a1')
|
|
825
|
-
assert.equal(result.displayName, 'dn a1')
|
|
826
|
-
assert.equal(result.description, 'desc a1')
|
|
827
|
-
})
|
|
828
|
-
|
|
829
|
-
test('sets the minCount', ({ assert }) => {
|
|
830
|
-
a1.required = true
|
|
831
|
-
const result = a1.toApiShape()
|
|
832
|
-
assert.equal(result.minCount, 1)
|
|
833
|
-
})
|
|
834
|
-
|
|
835
|
-
test('sets the path', ({ assert }) => {
|
|
836
|
-
a1.required = true
|
|
837
|
-
const result = a1.toApiShape()
|
|
838
|
-
assert.equal(result.path, AmfNamespace.aml.vocabularies.data.key + 'a1', 'has the path')
|
|
839
|
-
})
|
|
840
|
-
|
|
841
|
-
test('returns a link definition when created on the schema', ({ assert }) => {
|
|
842
|
-
a1.schema = { linked: true }
|
|
843
|
-
const result = a1.toApiShape()
|
|
844
|
-
const range = result.range as IApiScalarShape
|
|
845
|
-
assert.equal(range.id, `link-${a1.key}`)
|
|
846
|
-
assert.deepEqual(range.types, IAmfScalarTypes)
|
|
847
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.string)
|
|
848
|
-
})
|
|
849
|
-
|
|
850
|
-
test('returns a default union type', ({ assert }) => {
|
|
851
|
-
const e3 = m1.addEntity('e3')
|
|
852
|
-
a1.addTarget(e3)
|
|
853
|
-
const result = a1.toApiShape()
|
|
854
|
-
const range = result.range as IApiUnionShape
|
|
855
|
-
|
|
856
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
857
|
-
assert.equal(range.id, `union-shape-${a1.key}`, 'the range has the id')
|
|
858
|
-
assert.deepEqual(range.types, IAmfUnionTypes, 'the range has the types')
|
|
859
|
-
assert.lengthOf(range.anyOf, 2, 'has the anyOf array')
|
|
860
|
-
const [p1, p2] = range.anyOf as IApiNodeShape[]
|
|
861
|
-
|
|
862
|
-
assert.deepEqual(p1.types, IAmfNodeTypes, 'p1 has the types')
|
|
863
|
-
assert.deepEqual(p2.types, IAmfNodeTypes, 'p2 has the types')
|
|
864
|
-
assert.lengthOf(p1.properties, 1, 'p1 has the properties')
|
|
865
|
-
assert.lengthOf(p2.properties, 0, 'p2 has the properties')
|
|
866
|
-
})
|
|
867
|
-
|
|
868
|
-
test('has no range when no associations', ({ assert }) => {
|
|
869
|
-
a1.removeTarget(e2)
|
|
870
|
-
const result = a1.toApiShape()
|
|
871
|
-
assert.isUndefined(result.range)
|
|
872
|
-
})
|
|
873
|
-
|
|
874
|
-
test('returns an array shape when multiple', ({ assert }) => {
|
|
875
|
-
a1.multiple = true
|
|
876
|
-
const result = a1.toApiShape()
|
|
877
|
-
const range = result.range as IApiArrayShape
|
|
878
|
-
assert.deepEqual(range.types, IAmfArrayTypes)
|
|
879
|
-
|
|
880
|
-
const arrayRange = range.items as IApiNodeShape
|
|
881
|
-
assert.typeOf(arrayRange, 'object', 'has the range')
|
|
882
|
-
assert.deepEqual(arrayRange.types, IAmfNodeTypes, 'range has the types')
|
|
883
|
-
assert.equal(arrayRange.name, 'e2', 'range has the name')
|
|
884
|
-
assert.lengthOf(arrayRange.properties, 1, 'range has the properties')
|
|
885
|
-
})
|
|
886
|
-
|
|
887
|
-
test('creates the "anyOf" union', ({ assert }) => {
|
|
888
|
-
a1.schema = { unionType: 'anyOf' }
|
|
889
|
-
|
|
890
|
-
const e3 = m1.addEntity('e3')
|
|
891
|
-
a1.addTarget(e3)
|
|
892
|
-
const result = a1.toApiShape()
|
|
893
|
-
const range = result.range as IApiUnionShape
|
|
894
|
-
|
|
895
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
896
|
-
assert.equal(range.id, `union-shape-${a1.key}`, 'the range has the id')
|
|
897
|
-
assert.deepEqual(range.types, IAmfUnionTypes, 'the range has the types')
|
|
898
|
-
assert.lengthOf(range.anyOf, 2, 'has the anyOf array')
|
|
899
|
-
const [p1, p2] = range.anyOf as IApiNodeShape[]
|
|
900
|
-
|
|
901
|
-
assert.deepEqual(p1.types, IAmfNodeTypes, 'p1 has the types')
|
|
902
|
-
assert.deepEqual(p2.types, IAmfNodeTypes, 'p2 has the types')
|
|
903
|
-
assert.lengthOf(p1.properties, 1, 'p1 has the properties')
|
|
904
|
-
assert.lengthOf(p2.properties, 0, 'p2 has the properties')
|
|
905
|
-
})
|
|
906
|
-
|
|
907
|
-
test('creates the "allOf" union', ({ assert }) => {
|
|
908
|
-
a1.schema = { unionType: 'allOf' }
|
|
909
|
-
|
|
910
|
-
const e3 = m1.addEntity('e3')
|
|
911
|
-
a1.addTarget(e3)
|
|
912
|
-
const result = a1.toApiShape()
|
|
913
|
-
const range = result.range as IApiUnionShape
|
|
914
|
-
|
|
915
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
916
|
-
assert.equal(range.id, `union-shape-${a1.key}`, 'the range has the id')
|
|
917
|
-
assert.deepEqual(range.types, IAmfUnionTypes, 'the range has the types')
|
|
918
|
-
assert.lengthOf(range.and, 2, 'has the anyOf array')
|
|
919
|
-
const [p1, p2] = range.and as IApiNodeShape[]
|
|
920
|
-
|
|
921
|
-
assert.deepEqual(p1.types, IAmfNodeTypes, 'p1 has the types')
|
|
922
|
-
assert.deepEqual(p2.types, IAmfNodeTypes, 'p2 has the types')
|
|
923
|
-
assert.lengthOf(p1.properties, 1, 'p1 has the properties')
|
|
924
|
-
assert.lengthOf(p2.properties, 0, 'p2 has the properties')
|
|
925
|
-
})
|
|
926
|
-
|
|
927
|
-
test('creates the "oneOf" union', ({ assert }) => {
|
|
928
|
-
a1.schema = { unionType: 'oneOf' }
|
|
929
|
-
|
|
930
|
-
const e3 = m1.addEntity('e3')
|
|
931
|
-
a1.addTarget(e3)
|
|
932
|
-
const result = a1.toApiShape()
|
|
933
|
-
const range = result.range as IApiUnionShape
|
|
934
|
-
|
|
935
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
936
|
-
assert.equal(range.id, `union-shape-${a1.key}`, 'the range has the id')
|
|
937
|
-
assert.deepEqual(range.types, IAmfUnionTypes, 'the range has the types')
|
|
938
|
-
assert.lengthOf(range.xone, 2, 'has the oneOf array')
|
|
939
|
-
const [p1, p2] = range.xone as IApiNodeShape[]
|
|
940
|
-
|
|
941
|
-
assert.deepEqual(p1.types, IAmfNodeTypes, 'p1 has the types')
|
|
942
|
-
assert.deepEqual(p2.types, IAmfNodeTypes, 'p2 has the types')
|
|
943
|
-
assert.lengthOf(p1.properties, 1, 'p1 has the properties')
|
|
944
|
-
assert.lengthOf(p2.properties, 0, 'p2 has the properties')
|
|
945
|
-
})
|
|
946
|
-
|
|
947
|
-
test('creates the "not" union', ({ assert }) => {
|
|
948
|
-
a1.schema = { unionType: 'not' }
|
|
949
|
-
|
|
950
|
-
const e3 = m1.addEntity('e3')
|
|
951
|
-
a1.addTarget(e3)
|
|
952
|
-
const result = a1.toApiShape()
|
|
953
|
-
const range = result.range as IApiUnionShape
|
|
954
|
-
|
|
955
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
956
|
-
assert.equal(range.id, `union-shape-${a1.key}`, 'the range has the id')
|
|
957
|
-
assert.deepEqual(range.types, IAmfUnionTypes, 'the range has the types')
|
|
958
|
-
assert.typeOf(range.not, 'object', 'has the not object')
|
|
959
|
-
|
|
960
|
-
const not = range.not as IApiNodeShape
|
|
961
|
-
assert.deepEqual(not.types, IAmfNodeTypes, 'p1 has the types')
|
|
962
|
-
assert.deepEqual(not.types, IAmfNodeTypes, 'p2 has the types')
|
|
963
|
-
assert.lengthOf(not.properties, 1, 'p1 has the properties')
|
|
964
|
-
})
|
|
965
|
-
|
|
966
|
-
test('creates the "not" shape', ({ assert }) => {
|
|
967
|
-
a1.schema = { unionType: 'not' }
|
|
968
|
-
|
|
969
|
-
const result = a1.toApiShape()
|
|
970
|
-
const range = result.range as IApiUnionShape
|
|
971
|
-
|
|
972
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
973
|
-
assert.equal(range.id, `not-shape-${a1.key}`, 'the range has the id')
|
|
974
|
-
assert.deepEqual(range.types, IAmfAnyTypes, 'the range has the types')
|
|
975
|
-
assert.typeOf(range.not, 'object', 'has the not object')
|
|
976
|
-
|
|
977
|
-
const not = range.not as IApiNodeShape
|
|
978
|
-
assert.deepEqual(not.types, IAmfNodeTypes, 'p1 has the types')
|
|
979
|
-
assert.deepEqual(not.types, IAmfNodeTypes, 'p2 has the types')
|
|
980
|
-
assert.lengthOf(not.properties, 1, 'p1 has the properties')
|
|
981
|
-
})
|
|
982
|
-
|
|
983
|
-
test('wraps the union in the array shape', ({ assert }) => {
|
|
984
|
-
a1.multiple = true
|
|
985
|
-
a1.schema = { unionType: 'anyOf' }
|
|
986
|
-
|
|
987
|
-
const e3 = m1.addEntity('e3')
|
|
988
|
-
a1.addTarget(e3)
|
|
989
|
-
const result = a1.toApiShape()
|
|
990
|
-
const range = result.range as IApiArrayShape
|
|
991
|
-
|
|
992
|
-
assert.typeOf(range, 'object', 'has the range')
|
|
993
|
-
assert.equal(range.id, `array-shape-${a1.key}`, 'the range has the id')
|
|
994
|
-
assert.deepEqual(range.types, IAmfArrayTypes, 'the range has the types')
|
|
995
|
-
|
|
996
|
-
const items = range.items as IApiUnionShape
|
|
997
|
-
|
|
998
|
-
assert.lengthOf(items.anyOf, 2, 'has the anyOf array')
|
|
999
|
-
const [p1, p2] = items.anyOf as IApiNodeShape[]
|
|
1000
|
-
|
|
1001
|
-
assert.deepEqual(p1.types, IAmfNodeTypes, 'p1 has the types')
|
|
1002
|
-
assert.deepEqual(p2.types, IAmfNodeTypes, 'p2 has the types')
|
|
1003
|
-
assert.lengthOf(p1.properties, 1, 'p1 has the properties')
|
|
1004
|
-
assert.lengthOf(p2.properties, 0, 'p2 has the properties')
|
|
1005
|
-
})
|
|
1006
|
-
|
|
1007
|
-
test('handles linked schema', ({ assert }) => {
|
|
1008
|
-
a1.schema = { linked: true }
|
|
1009
|
-
const result = a1.toApiShape()
|
|
1010
|
-
const range = result.range as IApiScalarShape
|
|
1011
|
-
assert.equal(range.dataType, AmfNamespace.w3.xmlSchema.string)
|
|
1012
|
-
})
|
|
1013
|
-
|
|
1014
|
-
test('handles multiple associations', ({ assert }) => {
|
|
1015
|
-
const e3 = m1.addEntity('e3')
|
|
1016
|
-
a1.addTarget(e3)
|
|
1017
|
-
const result = a1.toApiShape()
|
|
1018
|
-
const range = result.range as IApiUnionShape
|
|
1019
|
-
assert.lengthOf(range.anyOf, 2)
|
|
1020
|
-
})
|
|
1021
|
-
|
|
1022
|
-
test('handles unionType', ({ assert }) => {
|
|
1023
|
-
a1.schema = { unionType: 'allOf' }
|
|
1024
|
-
const e3 = m1.addEntity('e3')
|
|
1025
|
-
a1.addTarget(e3)
|
|
1026
|
-
const result = a1.toApiShape()
|
|
1027
|
-
const range = result.range as IApiUnionShape
|
|
1028
|
-
assert.lengthOf(range.and, 2)
|
|
1029
|
-
})
|
|
1030
|
-
|
|
1031
|
-
test('handles multiple and unionType', ({ assert }) => {
|
|
1032
|
-
a1.multiple = true
|
|
1033
|
-
a1.schema = { unionType: 'allOf' }
|
|
1034
|
-
const e3 = m1.addEntity('e3')
|
|
1035
|
-
a1.addTarget(e3)
|
|
1036
|
-
const result = a1.toApiShape()
|
|
1037
|
-
const range = result.range as IApiArrayShape
|
|
1038
|
-
const items = range.items as IShapeUnion
|
|
1039
|
-
assert.lengthOf(items.and, 2)
|
|
1040
|
-
})
|
|
1041
|
-
})
|