@api-client/core 0.13.6 → 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.
Files changed (174) hide show
  1. package/build/src/amf/AmfTypes.d.ts +1 -1
  2. package/build/src/amf/AmfTypes.js +1 -1
  3. package/build/src/amf/AmfTypes.js.map +1 -1
  4. package/build/src/amf/Utils.d.ts +0 -6
  5. package/build/src/amf/Utils.d.ts.map +1 -1
  6. package/build/src/amf/Utils.js +0 -14
  7. package/build/src/amf/Utils.js.map +1 -1
  8. package/build/src/browser.d.ts +1 -0
  9. package/build/src/browser.d.ts.map +1 -1
  10. package/build/src/browser.js +1 -0
  11. package/build/src/browser.js.map +1 -1
  12. package/build/src/index.d.ts +1 -0
  13. package/build/src/index.d.ts.map +1 -1
  14. package/build/src/index.js +1 -0
  15. package/build/src/index.js.map +1 -1
  16. package/build/src/legacy.d.ts +0 -8
  17. package/build/src/legacy.d.ts.map +1 -1
  18. package/build/src/legacy.js +0 -9
  19. package/build/src/legacy.js.map +1 -1
  20. package/build/src/modeling/Bindings.d.ts +1 -1
  21. package/build/src/modeling/Bindings.js.map +1 -1
  22. package/build/src/modeling/DataDomain.js +2 -2
  23. package/build/src/modeling/DataDomain.js.map +1 -1
  24. package/build/src/modeling/DataFormat.d.ts +0 -40
  25. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  26. package/build/src/modeling/DataFormat.js +0 -27
  27. package/build/src/modeling/DataFormat.js.map +1 -1
  28. package/build/src/modeling/DomainAssociation.d.ts +28 -0
  29. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  30. package/build/src/modeling/DomainAssociation.js +73 -4
  31. package/build/src/modeling/DomainAssociation.js.map +1 -1
  32. package/build/src/modeling/DomainEntity.d.ts +25 -9
  33. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  34. package/build/src/modeling/DomainEntity.js +65 -21
  35. package/build/src/modeling/DomainEntity.js.map +1 -1
  36. package/build/src/modeling/DomainFile.d.ts +3 -4
  37. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  38. package/build/src/modeling/DomainFile.js +5 -9
  39. package/build/src/modeling/DomainFile.js.map +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  42. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  43. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  44. package/build/src/modeling/DomainModel.d.ts +2 -2
  45. package/build/src/modeling/DomainModel.js +2 -2
  46. package/build/src/modeling/DomainModel.js.map +1 -1
  47. package/build/src/modeling/DomainProperty.d.ts +28 -12
  48. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  49. package/build/src/modeling/DomainProperty.js +61 -26
  50. package/build/src/modeling/DomainProperty.js.map +1 -1
  51. package/build/src/modeling/Semantics.d.ts +109 -0
  52. package/build/src/modeling/Semantics.d.ts.map +1 -0
  53. package/build/src/modeling/Semantics.js +97 -0
  54. package/build/src/modeling/Semantics.js.map +1 -0
  55. package/build/src/models/CertificateFile.d.ts +2 -3
  56. package/build/src/models/CertificateFile.d.ts.map +1 -1
  57. package/build/src/models/CertificateFile.js +4 -8
  58. package/build/src/models/CertificateFile.js.map +1 -1
  59. package/build/src/models/Folder.d.ts +1 -2
  60. package/build/src/models/Folder.d.ts.map +1 -1
  61. package/build/src/models/Folder.js +2 -4
  62. package/build/src/models/Folder.js.map +1 -1
  63. package/build/src/models/Project.d.ts +2 -3
  64. package/build/src/models/Project.d.ts.map +1 -1
  65. package/build/src/models/Project.js +4 -8
  66. package/build/src/models/Project.js.map +1 -1
  67. package/build/src/models/kinds.d.ts +0 -24
  68. package/build/src/models/kinds.d.ts.map +1 -1
  69. package/build/src/models/kinds.js +0 -24
  70. package/build/src/models/kinds.js.map +1 -1
  71. package/build/src/models/store/File.d.ts +1 -21
  72. package/build/src/models/store/File.d.ts.map +1 -1
  73. package/build/src/models/store/File.js +3 -23
  74. package/build/src/models/store/File.js.map +1 -1
  75. package/build/src/models/store/data_catalog.d.ts +1 -1
  76. package/build/src/models/store/data_catalog.js.map +1 -1
  77. package/build/src/sdk/FilesSdk.js +1 -1
  78. package/build/src/sdk/FilesSdk.js.map +1 -1
  79. package/build/tsconfig.tsbuildinfo +1 -1
  80. package/data/models/example-generator-api.json +22 -22
  81. package/eslint.config.js +1 -0
  82. package/package.json +5 -5
  83. package/src/amf/AmfTypes.ts +1 -1
  84. package/src/amf/Utils.ts +0 -15
  85. package/src/modeling/Bindings.ts +1 -1
  86. package/src/modeling/DataDomain.ts +2 -2
  87. package/src/modeling/DataFormat.ts +0 -48
  88. package/src/modeling/DomainAssociation.ts +66 -3
  89. package/src/modeling/DomainEntity.ts +56 -17
  90. package/src/modeling/DomainFile.ts +5 -9
  91. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  92. package/src/modeling/DomainModel.ts +2 -2
  93. package/src/modeling/DomainProperty.ts +60 -21
  94. package/src/modeling/Semantics.ts +178 -0
  95. package/src/modeling/graph.md +14 -14
  96. package/src/modeling/readme.md +29 -29
  97. package/src/models/CertificateFile.ts +4 -12
  98. package/src/models/Folder.ts +2 -4
  99. package/src/models/Project.ts +4 -8
  100. package/src/models/kinds.ts +0 -25
  101. package/src/models/store/File.ts +4 -35
  102. package/src/models/store/data_catalog.ts +1 -1
  103. package/src/sdk/FilesSdk.ts +1 -1
  104. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  105. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  106. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  107. package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
  108. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  109. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  110. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  111. package/tests/unit/modeling/domain_file.spec.ts +4 -27
  112. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  113. package/tests/unit/models/Certificate/from_name.spec.ts +3 -15
  114. package/tests/unit/models/File/constructor.spec.ts +0 -1
  115. package/tests/unit/models/File/new.spec.ts +0 -13
  116. package/tests/unit/models/File/shortcutTo.spec.ts +1 -2
  117. package/tests/unit/models/File/toJSON.spec.ts +0 -13
  118. package/tests/unit/models/File/updateByMeMeta.spec.ts +4 -6
  119. package/tests/unit/models/Folder/create.spec.ts +2 -23
  120. package/tests/unit/models/Project/create.spec.ts +6 -32
  121. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  122. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  123. package/build/src/amf/AmfShapeGenerator.js +0 -416
  124. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  125. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  126. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  127. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  128. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  129. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  130. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  131. package/build/src/modeling/legacy/DataEntity.js +0 -855
  132. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  133. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  134. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  135. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  136. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  137. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  138. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  139. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  140. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  141. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  142. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  143. package/build/src/modeling/legacy/DataModel.js +0 -237
  144. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  145. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  146. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  147. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  148. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  149. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  150. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  151. package/build/src/modeling/legacy/DataProperty.js +0 -415
  152. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  153. package/build/src/models/store/DataFile.d.ts +0 -31
  154. package/build/src/models/store/DataFile.d.ts.map +0 -1
  155. package/build/src/models/store/DataFile.js +0 -92
  156. package/build/src/models/store/DataFile.js.map +0 -1
  157. package/src/amf/AmfShapeGenerator.ts +0 -477
  158. package/src/modeling/legacy/DataAssociation.ts +0 -554
  159. package/src/modeling/legacy/DataEntity.ts +0 -1019
  160. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  161. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  162. package/src/modeling/legacy/DataModel.ts +0 -276
  163. package/src/modeling/legacy/DataNamespace.ts +0 -929
  164. package/src/modeling/legacy/DataProperty.ts +0 -630
  165. package/src/models/store/DataFile.ts +0 -100
  166. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  167. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  168. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  169. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  170. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  171. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  172. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  173. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  174. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -1,887 +0,0 @@
1
- import { test } from '@japa/runner'
2
- import { DataPropertyKind, Thing, type PropertyBinding, type PropertyWebBindings } from '../../../../src/index.js'
3
- import {
4
- DataEntity,
5
- DataModel,
6
- DataNamespace,
7
- DataProperty,
8
- type IDataProperty,
9
- type DataPropertySchema,
10
- } from '../../../../src/legacy.js'
11
-
12
- test.group('constructor() with defaults', (group) => {
13
- let root: DataNamespace
14
- group.each.setup(() => {
15
- root = new DataNamespace()
16
- })
17
-
18
- test('sets the kind', ({ assert }) => {
19
- const assoc = new DataProperty(root)
20
- assert.equal(assoc.kind, DataPropertyKind)
21
- })
22
-
23
- test('sets the key', ({ assert }) => {
24
- const assoc = new DataProperty(root)
25
- assert.typeOf(assoc.key, 'string')
26
- assert.isNotEmpty(assoc.key)
27
- })
28
-
29
- test('sets the default "info"', ({ assert }) => {
30
- const assoc = new DataProperty(root)
31
- assert.typeOf(assoc.info, 'EventTarget')
32
- assert.equal(assoc.info.name, '')
33
- })
34
-
35
- test('sets the default "type"', ({ assert }) => {
36
- const assoc = new DataProperty(root)
37
- assert.equal(assoc.type, 'string')
38
- })
39
-
40
- test('sets the default "tags"', ({ assert }) => {
41
- const assoc = new DataProperty(root)
42
- assert.deepEqual(assoc.tags, [])
43
- })
44
-
45
- test('sets the default "taxonomy"', ({ assert }) => {
46
- const assoc = new DataProperty(root)
47
- assert.deepEqual(assoc.taxonomy, [])
48
- })
49
-
50
- test('sets the default "schema"', ({ assert }) => {
51
- const assoc = new DataProperty(root)
52
- assert.isUndefined(assoc.schema)
53
- })
54
-
55
- test('does not set multiple', ({ assert }) => {
56
- const assoc = new DataProperty(root)
57
- assert.isUndefined(assoc.multiple)
58
- })
59
-
60
- test('does not set required', ({ assert }) => {
61
- const assoc = new DataProperty(root)
62
- assert.isUndefined(assoc.required)
63
- })
64
-
65
- test('does not set primary', ({ assert }) => {
66
- const assoc = new DataProperty(root)
67
- assert.isUndefined(assoc.primary)
68
- })
69
-
70
- test('does not set index', ({ assert }) => {
71
- const assoc = new DataProperty(root)
72
- assert.isUndefined(assoc.index)
73
- })
74
-
75
- test('does not set readOnly', ({ assert }) => {
76
- const assoc = new DataProperty(root)
77
- assert.isUndefined(assoc.readOnly)
78
- })
79
-
80
- test('does not set writeOnly', ({ assert }) => {
81
- const assoc = new DataProperty(root)
82
- assert.isUndefined(assoc.writeOnly)
83
- })
84
-
85
- test('does not set deprecated', ({ assert }) => {
86
- const assoc = new DataProperty(root)
87
- assert.isUndefined(assoc.deprecated)
88
- })
89
- })
90
-
91
- test.group('constructor() from schema initialization', (group) => {
92
- let root: DataNamespace
93
- group.each.setup(() => {
94
- root = new DataNamespace()
95
- })
96
-
97
- test('sets the key', ({ assert }) => {
98
- const orig = new DataProperty(root).toJSON()
99
- orig.key = 'test'
100
- const instance = new DataProperty(root, orig)
101
- assert.equal(instance.key, 'test')
102
- })
103
-
104
- test('sets the info', ({ assert }) => {
105
- const orig = new DataProperty(root).toJSON()
106
- orig.info.name = 'test'
107
- const instance = new DataProperty(root, orig)
108
- assert.equal(instance.info.name, 'test')
109
- })
110
-
111
- test('sets the multiple', ({ assert }) => {
112
- const orig = new DataProperty(root).toJSON()
113
- orig.multiple = true
114
- const instance = new DataProperty(root, orig)
115
- assert.isTrue(instance.multiple)
116
- })
117
-
118
- test('sets the required', ({ assert }) => {
119
- const orig = new DataProperty(root).toJSON()
120
- orig.required = true
121
- const instance = new DataProperty(root, orig)
122
- assert.isTrue(instance.required)
123
- })
124
-
125
- test('sets the "type"', ({ assert }) => {
126
- const orig = new DataProperty(root).toJSON()
127
- orig.type = 'date'
128
- const assoc = new DataProperty(root, orig)
129
- assert.equal(assoc.type, 'date')
130
- })
131
-
132
- test('sets the "tags"', ({ assert }) => {
133
- const orig = new DataProperty(root).toJSON()
134
- orig.tags = ['test']
135
- const assoc = new DataProperty(root, orig)
136
- assert.deepEqual(assoc.tags, ['test'])
137
- })
138
-
139
- test('sets the "taxonomy"', ({ assert }) => {
140
- const orig = new DataProperty(root).toJSON()
141
- orig.taxonomy = ['test']
142
- const assoc = new DataProperty(root, orig)
143
- assert.deepEqual(assoc.taxonomy, ['test'])
144
- })
145
-
146
- test('sets the "schema"', ({ assert }) => {
147
- const orig = new DataProperty(root).toJSON()
148
- orig.schema = {
149
- enum: ['1'],
150
- }
151
- const assoc = new DataProperty(root, orig)
152
- assert.deepEqual(assoc.schema, orig.schema)
153
- })
154
-
155
- test('sets the primary', ({ assert }) => {
156
- const orig = new DataProperty(root).toJSON()
157
- orig.primary = true
158
- const assoc = new DataProperty(root, orig)
159
- assert.isTrue(assoc.primary)
160
- })
161
-
162
- test('sets the index', ({ assert }) => {
163
- const orig = new DataProperty(root).toJSON()
164
- orig.index = true
165
- const assoc = new DataProperty(root, orig)
166
- assert.isTrue(assoc.index)
167
- })
168
-
169
- test('sets the readOnly', ({ assert }) => {
170
- const orig = new DataProperty(root).toJSON()
171
- orig.readOnly = true
172
- const assoc = new DataProperty(root, orig)
173
- assert.isTrue(assoc.readOnly)
174
- })
175
-
176
- test('sets the writeOnly', ({ assert }) => {
177
- const orig = new DataProperty(root).toJSON()
178
- orig.writeOnly = true
179
- const assoc = new DataProperty(root, orig)
180
- assert.isTrue(assoc.writeOnly)
181
- })
182
-
183
- test('sets the deprecated', ({ assert }) => {
184
- const orig = new DataProperty(root).toJSON()
185
- orig.deprecated = true
186
- const assoc = new DataProperty(root, orig)
187
- assert.isTrue(assoc.deprecated)
188
- })
189
-
190
- test('initializes from JSON schema ', ({ assert }) => {
191
- const orig = new DataProperty(root).toJSON()
192
- orig.required = true
193
- const instance = new DataProperty(root, JSON.stringify(orig))
194
- assert.isTrue(instance.required)
195
- })
196
- })
197
-
198
- test.group('fromName()', (group) => {
199
- let root: DataNamespace
200
- group.each.setup(() => {
201
- root = new DataNamespace()
202
- })
203
-
204
- test('sets the name', ({ assert }) => {
205
- const assoc = DataProperty.fromName(root, 'test')
206
- assert.equal(assoc.info.name, 'test')
207
- })
208
- })
209
-
210
- test.group('fromType()', (group) => {
211
- let root: DataNamespace
212
- group.each.setup(() => {
213
- root = new DataNamespace()
214
- })
215
-
216
- test('sets the type', ({ assert }) => {
217
- const assoc = DataProperty.fromType(root, 'number')
218
- assert.equal(assoc.type, 'number')
219
- })
220
- })
221
-
222
- test.group('new()', (group) => {
223
- let root: DataNamespace
224
- let base: IDataProperty
225
- group.each.setup(() => {
226
- root = new DataNamespace()
227
- base = {
228
- info: Thing.fromName('test name').toJSON(),
229
- key: 'test123',
230
- kind: DataPropertyKind,
231
- type: 'binary',
232
- }
233
- })
234
-
235
- test('sets the key', ({ assert }) => {
236
- const assoc = new DataProperty(root)
237
- assoc.new(base)
238
- assert.equal(assoc.key, 'test123')
239
- })
240
-
241
- test('sets the info', ({ assert }) => {
242
- const assoc = new DataProperty(root)
243
- assoc.new(base)
244
- assert.equal(assoc.info.name, 'test name')
245
- })
246
-
247
- test('sets the type', ({ assert }) => {
248
- const assoc = new DataProperty(root)
249
- assoc.new(base)
250
- assert.equal(assoc.type, 'binary')
251
- })
252
-
253
- test('sets default info', ({ assert }) => {
254
- const assoc = new DataProperty(root)
255
- // @ts-expect-error Used in testing
256
- delete base.info
257
- assoc.new(base)
258
- assert.equal(assoc.info.name, '')
259
- })
260
-
261
- test('sets the multiple', ({ assert }) => {
262
- const assoc = new DataProperty(root)
263
- assoc.new({ ...base, multiple: true })
264
- assert.isTrue(assoc.multiple)
265
- })
266
-
267
- test('does not set multiple when not in the input', ({ assert }) => {
268
- const assoc = new DataProperty(root)
269
- assoc.new(base)
270
- assert.isUndefined(assoc.multiple)
271
- })
272
-
273
- test('sets the required', ({ assert }) => {
274
- const assoc = new DataProperty(root)
275
- assoc.new({ ...base, required: true })
276
- assert.isTrue(assoc.required)
277
- })
278
-
279
- test('does not set required when not in the input', ({ assert }) => {
280
- const assoc = new DataProperty(root)
281
- assoc.new(base)
282
- assert.isUndefined(assoc.required)
283
- })
284
-
285
- test('sets the index', ({ assert }) => {
286
- const assoc = new DataProperty(root)
287
- assoc.new({ ...base, index: true })
288
- assert.isTrue(assoc.index)
289
- })
290
-
291
- test('does not set index when not in the input', ({ assert }) => {
292
- const assoc = new DataProperty(root)
293
- assoc.new(base)
294
- assert.isUndefined(assoc.index)
295
- })
296
-
297
- test('sets the readOnly', ({ assert }) => {
298
- const assoc = new DataProperty(root)
299
- assoc.new({ ...base, readOnly: true })
300
- assert.isTrue(assoc.readOnly)
301
- })
302
-
303
- test('does not set readOnly when not in the input', ({ assert }) => {
304
- const assoc = new DataProperty(root)
305
- assoc.new(base)
306
- assert.isUndefined(assoc.readOnly)
307
- })
308
-
309
- test('sets the writeOnly', ({ assert }) => {
310
- const assoc = new DataProperty(root)
311
- assoc.new({ ...base, writeOnly: true })
312
- assert.isTrue(assoc.writeOnly)
313
- })
314
-
315
- test('does not set writeOnly when not in the input', ({ assert }) => {
316
- const assoc = new DataProperty(root)
317
- assoc.new(base)
318
- assert.isUndefined(assoc.writeOnly)
319
- })
320
-
321
- test('sets the deprecated', ({ assert }) => {
322
- const assoc = new DataProperty(root)
323
- assoc.new({ ...base, deprecated: true })
324
- assert.isTrue(assoc.deprecated)
325
- })
326
-
327
- test('does not set deprecated when not in the input', ({ assert }) => {
328
- const assoc = new DataProperty(root)
329
- assoc.new(base)
330
- assert.isUndefined(assoc.deprecated)
331
- })
332
-
333
- test('sets the primary', ({ assert }) => {
334
- const assoc = new DataProperty(root)
335
- assoc.new({ ...base, primary: true })
336
- assert.isTrue(assoc.primary)
337
- })
338
-
339
- test('does not set primary when not in the input', ({ assert }) => {
340
- const assoc = new DataProperty(root)
341
- assoc.new(base)
342
- assert.isUndefined(assoc.primary)
343
- })
344
-
345
- test('sets the tags as a copy', ({ assert }) => {
346
- const assoc = new DataProperty(root)
347
- const init = { ...base, tags: ['a'] }
348
- assoc.new(init)
349
- assert.deepEqual(assoc.tags, ['a'])
350
- init.tags.push('b')
351
- assert.deepEqual(assoc.tags, ['a'])
352
- })
353
-
354
- test('resets tags when not in the input', ({ assert }) => {
355
- const assoc = new DataProperty(root)
356
- assoc.tags = ['a']
357
- assoc.new(base)
358
- assert.deepEqual(assoc.tags, [])
359
- })
360
-
361
- test('sets the taxonomy as a copy', ({ assert }) => {
362
- const assoc = new DataProperty(root)
363
- const init = { ...base, taxonomy: ['a'] }
364
- assoc.new(init)
365
- assert.deepEqual(assoc.taxonomy, ['a'])
366
- init.taxonomy.push('b')
367
- assert.deepEqual(assoc.taxonomy, ['a'])
368
- })
369
-
370
- test('resets taxonomy when not in the input', ({ assert }) => {
371
- const assoc = new DataProperty(root)
372
- assoc.taxonomy = ['a']
373
- assoc.new(base)
374
- assert.deepEqual(assoc.taxonomy, [])
375
- })
376
-
377
- test('sets the schemas as a copy', ({ assert }) => {
378
- const assoc = new DataProperty(root)
379
- const schema: DataPropertySchema = {
380
- enum: ['1'],
381
- }
382
- const init = { ...base, schema }
383
- assoc.new(init)
384
- assert.deepEqual(assoc.schema, schema)
385
- schema.enum!.push('other')
386
- assert.deepEqual(assoc.schema!.enum, ['1'])
387
- })
388
-
389
- test('resets schemas when not in the input', ({ assert }) => {
390
- const assoc = new DataProperty(root)
391
- const schema: DataPropertySchema = {
392
- enum: ['1'],
393
- }
394
- assoc.schema = schema
395
- assoc.new(base)
396
- assert.isUndefined(assoc.schema)
397
- })
398
-
399
- test('throws when unknown input', ({ assert }) => {
400
- const assoc = new DataProperty(root)
401
- assert.throws(() => {
402
- // @ts-expect-error Used in testing
403
- assoc.new({})
404
- }, 'Not a data property.')
405
- })
406
- })
407
-
408
- test.group('toJSON()', (group) => {
409
- let root: DataNamespace
410
- let base: DataProperty
411
- group.each.setup(() => {
412
- root = new DataNamespace()
413
- base = new DataProperty(root, {
414
- info: Thing.fromName('test name').toJSON(),
415
- key: 'test123',
416
- kind: DataPropertyKind,
417
- type: 'number',
418
- })
419
- })
420
-
421
- test('serializes the kind', ({ assert }) => {
422
- const result = base.toJSON()
423
- assert.equal(result.kind, DataPropertyKind)
424
- })
425
-
426
- test('serializes the key', ({ assert }) => {
427
- const result = base.toJSON()
428
- assert.equal(result.key, base.key)
429
- })
430
-
431
- test('serializes the info', ({ assert }) => {
432
- const result = base.toJSON()
433
- assert.equal(result.info.name, 'test name')
434
- })
435
-
436
- test('does not serialize the multiple by default', ({ assert }) => {
437
- const result = base.toJSON()
438
- assert.isUndefined(result.multiple)
439
- })
440
-
441
- test('does not serialize the required by default', ({ assert }) => {
442
- const result = base.toJSON()
443
- assert.isUndefined(result.required)
444
- })
445
-
446
- test('does not serialize the primary by default', ({ assert }) => {
447
- const result = base.toJSON()
448
- assert.isUndefined(result.primary)
449
- })
450
-
451
- test('does not serialize the index by default', ({ assert }) => {
452
- const result = base.toJSON()
453
- assert.isUndefined(result.index)
454
- })
455
-
456
- test('does not serialize the readOnly by default', ({ assert }) => {
457
- const result = base.toJSON()
458
- assert.isUndefined(result.readOnly)
459
- })
460
-
461
- test('does not serialize the writeOnly by default', ({ assert }) => {
462
- const result = base.toJSON()
463
- assert.isUndefined(result.writeOnly)
464
- })
465
-
466
- test('does not serialize the schema by default', ({ assert }) => {
467
- const result = base.toJSON()
468
- assert.isUndefined(result.schema)
469
- })
470
-
471
- test('serialize the set multiple', ({ assert }) => {
472
- base.multiple = false
473
- const result = base.toJSON()
474
- assert.isFalse(result.multiple)
475
- })
476
-
477
- test('serialize the set required', ({ assert }) => {
478
- base.required = false
479
- const result = base.toJSON()
480
- assert.isFalse(result.required)
481
- })
482
-
483
- test('serialize the set primary', ({ assert }) => {
484
- base.primary = false
485
- const result = base.toJSON()
486
- assert.isFalse(result.primary)
487
- })
488
-
489
- test('serialize the set index', ({ assert }) => {
490
- base.index = false
491
- const result = base.toJSON()
492
- assert.isFalse(result.index)
493
- })
494
-
495
- test('serialize the set readOnly', ({ assert }) => {
496
- base.readOnly = false
497
- const result = base.toJSON()
498
- assert.isFalse(result.readOnly)
499
- })
500
-
501
- test('serialize the set writeOnly', ({ assert }) => {
502
- base.writeOnly = false
503
- const result = base.toJSON()
504
- assert.isFalse(result.writeOnly)
505
- })
506
-
507
- test('does not serialize taxonomy by default', ({ assert }) => {
508
- const result = base.toJSON()
509
- assert.isUndefined(result.taxonomy)
510
- })
511
-
512
- test('does not serialize tags by default', ({ assert }) => {
513
- const result = base.toJSON()
514
- assert.isUndefined(result.tags)
515
- })
516
-
517
- test('serializes tags as a copy', ({ assert }) => {
518
- base.tags = ['a']
519
- const result = base.toJSON()
520
- assert.deepEqual(result.tags, ['a'])
521
- base.tags.push('b')
522
- assert.deepEqual(result.tags, ['a'])
523
- })
524
-
525
- test('serializes taxonomy as a copy', ({ assert }) => {
526
- base.taxonomy = ['a']
527
- const result = base.toJSON()
528
- assert.deepEqual(result.taxonomy, ['a'])
529
- base.taxonomy.push('b')
530
- assert.deepEqual(result.taxonomy, ['a'])
531
- })
532
- })
533
-
534
- test.group('remove()', (group) => {
535
- let root: DataNamespace
536
- let m1: DataModel
537
- let e1: DataEntity
538
- let p1: DataProperty
539
-
540
- group.each.setup(() => {
541
- root = new DataNamespace()
542
- m1 = root.addDataModel('m1')
543
- e1 = m1.addEntity('e1')
544
- p1 = e1.addNamedProperty('test prop')
545
- })
546
-
547
- test('removes self from the parent entity', ({ assert }) => {
548
- p1.remove()
549
- assert.deepEqual(e1.properties, [])
550
- })
551
-
552
- test('removes self from the root definitions', ({ assert }) => {
553
- p1.remove()
554
- assert.deepEqual(root.definitions.properties, [])
555
- })
556
-
557
- test('does not serialize properties', ({ assert }) => {
558
- p1.remove()
559
- const schema = root.toJSON()
560
- assert.isUndefined(schema.definitions.properties)
561
- assert.isUndefined(schema.definitions.entities![0].properties)
562
- })
563
-
564
- test('removes self only', ({ assert }) => {
565
- const p2 = e1.addNamedProperty('other')
566
- p1.remove()
567
- assert.deepEqual(e1.properties, [p2])
568
- assert.deepEqual(root.definitions.properties, [p2])
569
- })
570
- })
571
-
572
- test.group('addTag()', (group) => {
573
- let root: DataNamespace
574
- let m1: DataModel
575
- let e1: DataEntity
576
- let p1: DataProperty
577
-
578
- group.each.setup(() => {
579
- root = new DataNamespace()
580
- m1 = root.addDataModel('m1')
581
- e1 = m1.addEntity('e1')
582
- p1 = e1.addNamedProperty('test prop')
583
- })
584
-
585
- test('ignores when empty', ({ assert }) => {
586
- p1.addTag('')
587
- assert.deepEqual(p1.tags, [])
588
- })
589
-
590
- test('adds a tag to the property', ({ assert }) => {
591
- p1.addTag('Test')
592
- assert.deepEqual(p1.tags, ['Test'])
593
- })
594
-
595
- test('ignores a tag case insensitive', ({ assert }) => {
596
- p1.addTag('Test')
597
- p1.addTag('teSt')
598
- assert.deepEqual(p1.tags, ['Test'])
599
- })
600
-
601
- test('adds a tag the root definitions', ({ assert }) => {
602
- p1.addTag('Test')
603
- assert.deepEqual(root.definitions.tags, ['Test'])
604
- })
605
-
606
- test('ignores adding to root definitions when tag exists case insensitive', ({ assert }) => {
607
- p1.addTag('Test')
608
- p1.addTag('TeSt')
609
- assert.deepEqual(root.definitions.tags, ['Test'])
610
- })
611
- })
612
-
613
- test.group('removeTag()', (group) => {
614
- let root: DataNamespace
615
- let m1: DataModel
616
- let e1: DataEntity
617
- let p1: DataProperty
618
-
619
- group.each.setup(() => {
620
- root = new DataNamespace()
621
- m1 = root.addDataModel('m1')
622
- e1 = m1.addEntity('e1')
623
- p1 = e1.addNamedProperty('test prop')
624
- })
625
-
626
- test('ignores when empty', ({ assert }) => {
627
- p1.addTag('t1')
628
- p1.removeTag('')
629
- assert.deepEqual(p1.tags, ['t1'])
630
- })
631
-
632
- test('removes the tag from the property', ({ assert }) => {
633
- p1.addTag('t1')
634
- p1.removeTag('t1')
635
- assert.deepEqual(p1.tags, [])
636
- })
637
-
638
- test('removes only the selected tag', ({ assert }) => {
639
- p1.addTag('t1')
640
- p1.addTag('t2')
641
- p1.addTag('t3')
642
- p1.removeTag('t2')
643
- assert.deepEqual(p1.tags, ['t1', 't3'])
644
- })
645
-
646
- test('does not remove root tags', ({ assert }) => {
647
- p1.addTag('t1')
648
- p1.removeTag('t1')
649
- assert.deepEqual(root.definitions.tags, ['t1'])
650
- })
651
- })
652
-
653
- test.group('toApiShape()', (group) => {
654
- let root: DataNamespace
655
- let m1: DataModel
656
- let e1: DataEntity
657
- let p1: DataProperty
658
-
659
- group.each.setup(() => {
660
- root = new DataNamespace()
661
- m1 = root.addDataModel('m1')
662
- e1 = m1.addEntity('e1')
663
- p1 = e1.addNamedProperty('test prop')
664
- })
665
-
666
- // these tests only check whether the AmfShapeGenerator is called.
667
- // specific tests are performed elsewhere
668
-
669
- test('returns an object', ({ assert }) => {
670
- const result = p1.toApiShape()
671
-
672
- assert.typeOf(result, 'object')
673
- assert.typeOf(result.range, 'object')
674
- })
675
- })
676
-
677
- test.group('isValidType()', () => {
678
- test('returns true for valid types', ({ assert }) => {
679
- assert.isTrue(DataProperty.isValidType('string'))
680
- assert.isTrue(DataProperty.isValidType('number'))
681
- assert.isTrue(DataProperty.isValidType('boolean'))
682
- assert.isTrue(DataProperty.isValidType('date'))
683
- assert.isTrue(DataProperty.isValidType('datetime'))
684
- assert.isTrue(DataProperty.isValidType('time'))
685
- assert.isTrue(DataProperty.isValidType('binary'))
686
- })
687
-
688
- test('returns false for invalid types', ({ assert }) => {
689
- assert.isFalse(DataProperty.isValidType('invalid'))
690
- assert.isFalse(DataProperty.isValidType(123))
691
- assert.isFalse(DataProperty.isValidType(null))
692
- assert.isFalse(DataProperty.isValidType(undefined))
693
- })
694
- })
695
-
696
- test.group('isValidAttribute()', () => {
697
- test('returns true for valid attributes', ({ assert }) => {
698
- assert.isTrue(DataProperty.isValidAttribute('required'))
699
- assert.isTrue(DataProperty.isValidAttribute('multiple'))
700
- assert.isTrue(DataProperty.isValidAttribute('primary'))
701
- assert.isTrue(DataProperty.isValidAttribute('index'))
702
- assert.isTrue(DataProperty.isValidAttribute('readOnly'))
703
- assert.isTrue(DataProperty.isValidAttribute('writeOnly'))
704
- assert.isTrue(DataProperty.isValidAttribute('deprecated'))
705
- })
706
-
707
- test('returns false for invalid attributes', ({ assert }) => {
708
- assert.isFalse(DataProperty.isValidAttribute('invalid'))
709
- assert.isFalse(DataProperty.isValidAttribute(123))
710
- assert.isFalse(DataProperty.isValidAttribute(null))
711
- assert.isFalse(DataProperty.isValidAttribute(undefined))
712
- })
713
- })
714
-
715
- test.group('isValidFormat()', () => {
716
- test('returns true for valid formats', ({ assert }) => {
717
- assert.isTrue(DataProperty.isValidFormat('float'))
718
- assert.isTrue(DataProperty.isValidFormat('double'))
719
- assert.isTrue(DataProperty.isValidFormat('int32'))
720
- assert.isTrue(DataProperty.isValidFormat('int64'))
721
- assert.isTrue(DataProperty.isValidFormat('hex'))
722
- assert.isTrue(DataProperty.isValidFormat('base64'))
723
- assert.isTrue(DataProperty.isValidFormat(undefined))
724
- })
725
-
726
- test('returns false for invalid formats', ({ assert }) => {
727
- assert.isFalse(DataProperty.isValidFormat('invalid'))
728
- assert.isFalse(DataProperty.isValidFormat(123))
729
- assert.isFalse(DataProperty.isValidFormat(null))
730
- })
731
- })
732
-
733
- test.group('ensureSchema()', () => {
734
- test('creates a schema object if it does not exist', ({ assert }) => {
735
- const root = new DataNamespace()
736
- const property = new DataProperty(root)
737
- assert.isUndefined(property.schema)
738
- const schema = property.ensureSchema()
739
- assert.isObject(schema)
740
- assert.deepEqual(property.schema, schema)
741
- })
742
-
743
- test('returns the existing schema object', ({ assert }) => {
744
- const root = new DataNamespace()
745
- const property = new DataProperty(root)
746
- const existingSchema = { enum: ['a', 'b'] }
747
- property.schema = existingSchema
748
- const schema = property.ensureSchema()
749
- assert.deepEqual(schema, existingSchema)
750
- assert.deepEqual(property.schema, existingSchema)
751
- })
752
- })
753
-
754
- test.group('Bindings', () => {
755
- test('add a web binding', ({ assert }) => {
756
- const root = new DataNamespace()
757
- const property = new DataProperty(root)
758
- const webBinding = property.getWebBinding()
759
- webBinding.format = 'int32'
760
- assert.equal(property.bindings[0].type, 'web')
761
- const wb = property.bindings[0].schema as PropertyWebBindings
762
- assert.equal(wb.format, 'int32')
763
- })
764
- })
765
-
766
- test.group('getWebBinding()', () => {
767
- test('creates a web binding if it does not exist', ({ assert }) => {
768
- const root = new DataNamespace()
769
- const property = new DataProperty(root)
770
- assert.lengthOf(property.bindings, 0)
771
- const binding = property.getWebBinding()
772
- assert.isObject(binding)
773
- assert.lengthOf(property.bindings, 1)
774
- assert.equal(property.bindings[0].type, 'web')
775
- assert.deepEqual(property.bindings[0].schema, binding)
776
- })
777
-
778
- test('returns the existing web binding', ({ assert }) => {
779
- const root = new DataNamespace()
780
- const property = new DataProperty(root)
781
- const existingBinding: PropertyBinding = { type: 'web', schema: { hidden: true } }
782
- property.bindings.push(existingBinding)
783
- const binding = property.getWebBinding()
784
- assert.deepEqual(binding, existingBinding.schema)
785
- assert.deepEqual(property.bindings[0].schema, binding)
786
- })
787
- })
788
-
789
- test.group('readBinding()', () => {
790
- test('returns the existing web binding', ({ assert }) => {
791
- const root = new DataNamespace()
792
- const property = new DataProperty(root)
793
- const existingBinding: PropertyBinding = { type: 'web', schema: { hidden: true } }
794
- property.bindings.push(existingBinding)
795
- const binding = property.readBinding('web')
796
- assert.deepEqual(binding, existingBinding.schema)
797
- })
798
-
799
- test('returns the existing protobuf binding', ({ assert }) => {
800
- const root = new DataNamespace()
801
- const property = new DataProperty(root)
802
- const existingBinding: PropertyBinding = { type: 'protobuf', schema: { field: 1 } }
803
- property.bindings.push(existingBinding)
804
- const binding = property.readBinding('protobuf')
805
- assert.deepEqual(binding, existingBinding.schema)
806
- })
807
-
808
- test('returns undefined when binding does not exist', ({ assert }) => {
809
- const root = new DataNamespace()
810
- const property = new DataProperty(root)
811
- const binding = property.readBinding('web')
812
- assert.isUndefined(binding)
813
- })
814
- })
815
-
816
- test.group('DataProperty.isChildOf()', (group) => {
817
- let root: DataNamespace
818
- let n1: DataNamespace
819
- let n2: DataNamespace
820
- let m1: DataModel
821
- let m2: DataModel
822
- let e1: DataEntity
823
- let e2: DataEntity
824
- let p1: DataProperty
825
- let p2: DataProperty
826
- let p3: DataProperty
827
-
828
- group.each.setup(() => {
829
- root = new DataNamespace()
830
- n1 = root.addNamespace('n1')
831
- n2 = n1.addNamespace('n2')
832
- m1 = root.addDataModel('m1')
833
- m2 = n1.addDataModel('m2')
834
- e1 = m1.addEntity('e1')
835
- e2 = m2.addEntity('e2')
836
- p1 = e1.addNamedProperty('p1')
837
- p2 = e2.addNamedProperty('p2')
838
- p3 = n2.addDataModel('m3').addEntity('e3').addNamedProperty('p3')
839
- })
840
-
841
- test('returns false when called on a property not in an entity', ({ assert }) => {
842
- const p4 = new DataProperty(root)
843
- const result = p4.isChildOf('some-key')
844
- assert.isFalse(result)
845
- })
846
-
847
- test('returns false when called on self', ({ assert }) => {
848
- const result = p2.isChildOf(p2.key)
849
- assert.isFalse(result)
850
- })
851
-
852
- test('returns true when called on a direct parent', ({ assert }) => {
853
- const result = p2.isChildOf(e2.key)
854
- assert.isTrue(result)
855
- })
856
-
857
- test('returns true when called on a grandparent', ({ assert }) => {
858
- const result = p3.isChildOf(root.key)
859
- assert.isTrue(result)
860
- })
861
-
862
- test('returns false when called on a sibling', ({ assert }) => {
863
- const p4 = e1.addNamedProperty('p4')
864
- const result = p1.isChildOf(p4.key)
865
- assert.isFalse(result)
866
- })
867
-
868
- test('returns false when called on a child', ({ assert }) => {
869
- const result = e2.isChildOf(p2.key)
870
- assert.isFalse(result)
871
- })
872
-
873
- test('returns false when called on a non-existent namespace', ({ assert }) => {
874
- const result = p2.isChildOf('non-existent-key')
875
- assert.isFalse(result)
876
- })
877
-
878
- test('returns true when called on a grandparent', ({ assert }) => {
879
- const result = p3.isChildOf(n1.key)
880
- assert.isTrue(result)
881
- })
882
-
883
- test('returns true when called on a data model in the same namespace', ({ assert }) => {
884
- const result = p1.isChildOf(m1.key)
885
- assert.isTrue(result)
886
- })
887
- })