@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,276 +0,0 @@
1
- import { IThing, Thing } from '../../models/Thing.js'
2
- import { nanoid } from '../../nanoid.js'
3
- import { DataEntity, IDataEntity } from './DataEntity.js'
4
- import type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js'
5
- import { FileBreadcrumb } from '../../models/store/File.js'
6
- import { DataModelKind } from '../../models/kinds.js'
7
- import type { DataDomainRemoveOptions } from '../types.js'
8
-
9
- /**
10
- * Data model creates a logical structure around data entities.
11
- * It groups entities that represents a whole schema, like a Product data model
12
- * can have entities that describe: the product entity, price history entity,
13
- * product location, etc.
14
- * @deprecated
15
- */
16
- export interface IDataModel {
17
- kind: typeof DataModelKind
18
- /**
19
- * The key of the namespace.
20
- */
21
- key: string
22
- /**
23
- * The data model description.
24
- */
25
- info: IThing
26
- /**
27
- * The list of keys of entities that this data model contain.
28
- */
29
- entities?: string[]
30
- }
31
-
32
- /**
33
- * Data model creates a logical structure around data entities.
34
- * It groups entities that represents a whole schema, like a Product data model
35
- * can have entities that describe: the product entity, price history entity,
36
- * product location, etc.
37
- * @deprecated
38
- */
39
- export class DataModel {
40
- kind = DataModelKind
41
-
42
- key = ''
43
-
44
- /**
45
- * The description of the data namespace.
46
- */
47
- info: Thing = Thing.fromName('')
48
-
49
- /**
50
- * The list of entities that this data model has.
51
- */
52
- entities: DataEntity[] = []
53
-
54
- static fromName(root: DataNamespace, name: string): DataModel {
55
- const entity = new DataModel(root)
56
- entity.info = Thing.fromName(name)
57
- return entity
58
- }
59
-
60
- /**
61
- * @param root the root namespace.
62
- * @param input The data model definition to restore.
63
- */
64
- constructor(
65
- public root: DataNamespace,
66
- input?: string | IDataModel
67
- ) {
68
- let init: IDataModel
69
- if (typeof input === 'string') {
70
- init = JSON.parse(input)
71
- } else if (typeof input === 'object') {
72
- init = input
73
- } else {
74
- init = {
75
- kind: DataModelKind,
76
- key: nanoid(),
77
- info: Thing.fromName('').toJSON(),
78
- entities: [],
79
- }
80
- }
81
- this.new(init)
82
- }
83
-
84
- new(init: IDataModel): void {
85
- if (!DataModel.isDataModel(init)) {
86
- throw new Error(`Not a data model.`)
87
- }
88
- const { info, key = nanoid(), kind = DataModelKind, entities } = init
89
- this.kind = kind
90
- this.key = key
91
- if (info) {
92
- this.info = new Thing(info)
93
- } else {
94
- this.info = Thing.fromName('')
95
- }
96
-
97
- this.entities = []
98
- if (Array.isArray(entities)) {
99
- entities.forEach((key) => {
100
- const value = this._readEntity(key)
101
- if (value) {
102
- this.entities.push(value)
103
- }
104
- })
105
- }
106
- }
107
-
108
- static isDataModel(input: unknown): boolean {
109
- const typed = input as IDataModel
110
- if (!input || typed.kind !== DataModelKind) {
111
- return false
112
- }
113
- return true
114
- }
115
-
116
- toJSON(): IDataModel {
117
- const result: IDataModel = {
118
- kind: DataModelKind,
119
- key: this.key,
120
- info: this.info.toJSON(),
121
- }
122
- if (Array.isArray(this.entities) && this.entities.length) {
123
- result.entities = this.entities.map((i) => i.key)
124
- }
125
- return result
126
- }
127
-
128
- protected _readEntity(key: string): DataEntity | undefined {
129
- return this.root.definitions.entities.find((i) => i.key === key)
130
- }
131
-
132
- /**
133
- * Removes self from the namespace with all entities.
134
- */
135
- remove(opts?: DataDomainRemoveOptions): void {
136
- const { key, entities, root } = this
137
- // remove children
138
- entities.forEach((e) => e.remove(opts))
139
-
140
- // remove self from the parent
141
- const parent = this.getParentInstance()
142
- if (parent) {
143
- const itemIndex = parent.items.findIndex((i) => i.key === key)
144
- if (itemIndex >= 0) {
145
- parent.items.splice(itemIndex, 1)
146
- }
147
- }
148
- // remove self from definitions
149
- const index = root.definitions.models.findIndex((i) => i.key === key)
150
- if (index >= 0) {
151
- root.definitions.models.splice(index, 1)
152
- }
153
- }
154
-
155
- /**
156
- * Adapts an entity to this data model.
157
- * The entity must already be added to another data model within this namespace for it to be
158
- * adapted to this data model.
159
- * This method is used to change the data model of an entity.
160
- * It will remove the entity from the previous data model and add it to this one.
161
- * @param entity The entity to adapt.
162
- */
163
- adaptEntity(entity: DataEntity, opts: DataItemAdaptingOptions = {}): void {
164
- if (opts.index !== undefined) {
165
- if (opts.index < 0) {
166
- throw new Error(`The index ${opts.index} cannot be below 0.`)
167
- }
168
- if (opts.index >= this.entities.length) {
169
- throw new Error(`The index ${opts.index} is not valid.`)
170
- }
171
- }
172
- if (entity.root !== this.root) {
173
- throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`)
174
- }
175
- const parent = entity.getParentInstance()
176
- if (!parent) {
177
- throw new Error(`The entity ${entity.key} has no parent.`)
178
- }
179
- if (parent.key === this.key) {
180
- throw new Error(`The entity ${entity.key} is already adapted by this data model.`)
181
- }
182
- // it has a parent (above check) so it has the index.
183
- const index = parent.entities.findIndex((i) => i.key === entity.key)
184
- parent.entities.splice(index, 1)
185
- if (opts.index !== undefined) {
186
- this.entities.splice(opts.index, 0, entity)
187
- } else {
188
- this.entities.push(entity)
189
- }
190
- }
191
-
192
- /**
193
- * Adds an entity to this data model.
194
- *
195
- * @param init The name of the entity to create, the instance of the entity or its schema
196
- * @returns A reference to the created entity.
197
- */
198
- addEntity(init: string | DataEntity | IDataEntity): DataEntity {
199
- let definition: DataEntity
200
- if (typeof init === 'string') {
201
- definition = DataEntity.fromName(this.root, init)
202
- } else if (init instanceof DataEntity) {
203
- definition = init
204
- } else {
205
- definition = new DataEntity(this.root, init)
206
- }
207
- this.root.definitions.entities.push(definition)
208
- this.entities.push(definition)
209
- return definition
210
- }
211
-
212
- /**
213
- * @deprecated Use the `getParentInstance()` method instead.
214
- */
215
- getParent(): DataNamespace | undefined {
216
- return this.getParentInstance()
217
- }
218
-
219
- /**
220
- * Returns the parent namespace where this data model exist.
221
- */
222
- getParentInstance(): DataNamespace | undefined {
223
- if (this.root.items.some((e) => e.key === this.key)) {
224
- return this.root
225
- }
226
- return this.root.definitions.namespaces.find((n) => n.items.some((e) => e.key === this.key))
227
- }
228
-
229
- /**
230
- * Creates breadcrumbs from this data model to the root namespace.
231
- */
232
- breadcrumbs(): FileBreadcrumb[] {
233
- const result: FileBreadcrumb[] = []
234
- result.push({
235
- key: this.key,
236
- name: this.info.getLabel('Unnamed data model'),
237
- kind: DataModelKind,
238
- })
239
- let parent = this.getParentInstance()
240
- while (parent && parent !== this.root) {
241
- result.push({
242
- key: parent.key,
243
- kind: parent.kind,
244
- name: parent.info.getLabel('Unnamed namespace'),
245
- })
246
- parent = parent.getParentInstance()
247
- }
248
- result.push({
249
- key: this.root.key,
250
- name: this.root.info.getLabel('Unnamed data domain'),
251
- kind: this.root.kind,
252
- })
253
- return result.reverse()
254
- }
255
-
256
- /**
257
- * Checks whether the data model is a child of the given namespace.
258
- * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.
259
- *
260
- * @param key The key of the parent namespace to check.
261
- * @returns True if this data model is a child of the given namespace.
262
- */
263
- isChildOf(key: string): boolean {
264
- if (this.key === key) {
265
- return false
266
- }
267
- const parent = this.getParentInstance()
268
- if (!parent) {
269
- return false
270
- }
271
- if (parent.key === key) {
272
- return true
273
- }
274
- return parent.isChildOf(key)
275
- }
276
- }