@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.
Files changed (140) 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 +1 -1
  37. package/build/src/modeling/DomainFile.js +1 -1
  38. package/build/src/modeling/DomainFile.js.map +1 -1
  39. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  42. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  43. package/build/src/modeling/DomainModel.d.ts +2 -2
  44. package/build/src/modeling/DomainModel.js +2 -2
  45. package/build/src/modeling/DomainModel.js.map +1 -1
  46. package/build/src/modeling/DomainProperty.d.ts +28 -12
  47. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  48. package/build/src/modeling/DomainProperty.js +61 -26
  49. package/build/src/modeling/DomainProperty.js.map +1 -1
  50. package/build/src/modeling/Semantics.d.ts +109 -0
  51. package/build/src/modeling/Semantics.d.ts.map +1 -0
  52. package/build/src/modeling/Semantics.js +97 -0
  53. package/build/src/modeling/Semantics.js.map +1 -0
  54. package/build/src/models/kinds.d.ts +0 -24
  55. package/build/src/models/kinds.d.ts.map +1 -1
  56. package/build/src/models/kinds.js +0 -24
  57. package/build/src/models/kinds.js.map +1 -1
  58. package/build/src/models/store/data_catalog.d.ts +1 -1
  59. package/build/src/models/store/data_catalog.js.map +1 -1
  60. package/build/tsconfig.tsbuildinfo +1 -1
  61. package/data/models/example-generator-api.json +11 -11
  62. package/package.json +1 -1
  63. package/src/amf/AmfTypes.ts +1 -1
  64. package/src/amf/Utils.ts +0 -15
  65. package/src/modeling/Bindings.ts +1 -1
  66. package/src/modeling/DataDomain.ts +2 -2
  67. package/src/modeling/DataFormat.ts +0 -48
  68. package/src/modeling/DomainAssociation.ts +66 -3
  69. package/src/modeling/DomainEntity.ts +56 -17
  70. package/src/modeling/DomainFile.ts +1 -1
  71. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  72. package/src/modeling/DomainModel.ts +2 -2
  73. package/src/modeling/DomainProperty.ts +60 -21
  74. package/src/modeling/Semantics.ts +178 -0
  75. package/src/modeling/graph.md +14 -14
  76. package/src/modeling/readme.md +29 -29
  77. package/src/models/kinds.ts +0 -25
  78. package/src/models/store/data_catalog.ts +1 -1
  79. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  80. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  81. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  82. package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
  83. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  84. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  85. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  86. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  87. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  88. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  89. package/build/src/amf/AmfShapeGenerator.js +0 -416
  90. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  91. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  92. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  93. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  94. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  95. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  96. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  97. package/build/src/modeling/legacy/DataEntity.js +0 -855
  98. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  99. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  100. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  101. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  102. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  103. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  104. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  105. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  106. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  107. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  108. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  109. package/build/src/modeling/legacy/DataModel.js +0 -237
  110. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  111. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  112. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  113. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  114. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  115. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  116. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  117. package/build/src/modeling/legacy/DataProperty.js +0 -415
  118. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  119. package/build/src/models/store/DataFile.d.ts +0 -29
  120. package/build/src/models/store/DataFile.d.ts.map +0 -1
  121. package/build/src/models/store/DataFile.js +0 -87
  122. package/build/src/models/store/DataFile.js.map +0 -1
  123. package/src/amf/AmfShapeGenerator.ts +0 -477
  124. package/src/modeling/legacy/DataAssociation.ts +0 -554
  125. package/src/modeling/legacy/DataEntity.ts +0 -1019
  126. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  127. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  128. package/src/modeling/legacy/DataModel.ts +0 -276
  129. package/src/modeling/legacy/DataNamespace.ts +0 -929
  130. package/src/modeling/legacy/DataProperty.ts +0 -630
  131. package/src/models/store/DataFile.ts +0 -95
  132. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  133. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  134. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  135. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  136. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  137. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  138. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  139. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  140. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -1,237 +0,0 @@
1
- import { Thing } from '../../models/Thing.js';
2
- import { nanoid } from '../../nanoid.js';
3
- import { DataEntity } from './DataEntity.js';
4
- import { DataModelKind } from '../../models/kinds.js';
5
- /**
6
- * Data model creates a logical structure around data entities.
7
- * It groups entities that represents a whole schema, like a Product data model
8
- * can have entities that describe: the product entity, price history entity,
9
- * product location, etc.
10
- * @deprecated
11
- */
12
- export class DataModel {
13
- root;
14
- kind = DataModelKind;
15
- key = '';
16
- /**
17
- * The description of the data namespace.
18
- */
19
- info = Thing.fromName('');
20
- /**
21
- * The list of entities that this data model has.
22
- */
23
- entities = [];
24
- static fromName(root, name) {
25
- const entity = new DataModel(root);
26
- entity.info = Thing.fromName(name);
27
- return entity;
28
- }
29
- /**
30
- * @param root the root namespace.
31
- * @param input The data model definition to restore.
32
- */
33
- constructor(root, input) {
34
- this.root = root;
35
- let init;
36
- if (typeof input === 'string') {
37
- init = JSON.parse(input);
38
- }
39
- else if (typeof input === 'object') {
40
- init = input;
41
- }
42
- else {
43
- init = {
44
- kind: DataModelKind,
45
- key: nanoid(),
46
- info: Thing.fromName('').toJSON(),
47
- entities: [],
48
- };
49
- }
50
- this.new(init);
51
- }
52
- new(init) {
53
- if (!DataModel.isDataModel(init)) {
54
- throw new Error(`Not a data model.`);
55
- }
56
- const { info, key = nanoid(), kind = DataModelKind, entities } = init;
57
- this.kind = kind;
58
- this.key = key;
59
- if (info) {
60
- this.info = new Thing(info);
61
- }
62
- else {
63
- this.info = Thing.fromName('');
64
- }
65
- this.entities = [];
66
- if (Array.isArray(entities)) {
67
- entities.forEach((key) => {
68
- const value = this._readEntity(key);
69
- if (value) {
70
- this.entities.push(value);
71
- }
72
- });
73
- }
74
- }
75
- static isDataModel(input) {
76
- const typed = input;
77
- if (!input || typed.kind !== DataModelKind) {
78
- return false;
79
- }
80
- return true;
81
- }
82
- toJSON() {
83
- const result = {
84
- kind: DataModelKind,
85
- key: this.key,
86
- info: this.info.toJSON(),
87
- };
88
- if (Array.isArray(this.entities) && this.entities.length) {
89
- result.entities = this.entities.map((i) => i.key);
90
- }
91
- return result;
92
- }
93
- _readEntity(key) {
94
- return this.root.definitions.entities.find((i) => i.key === key);
95
- }
96
- /**
97
- * Removes self from the namespace with all entities.
98
- */
99
- remove(opts) {
100
- const { key, entities, root } = this;
101
- // remove children
102
- entities.forEach((e) => e.remove(opts));
103
- // remove self from the parent
104
- const parent = this.getParentInstance();
105
- if (parent) {
106
- const itemIndex = parent.items.findIndex((i) => i.key === key);
107
- if (itemIndex >= 0) {
108
- parent.items.splice(itemIndex, 1);
109
- }
110
- }
111
- // remove self from definitions
112
- const index = root.definitions.models.findIndex((i) => i.key === key);
113
- if (index >= 0) {
114
- root.definitions.models.splice(index, 1);
115
- }
116
- }
117
- /**
118
- * Adapts an entity to this data model.
119
- * The entity must already be added to another data model within this namespace for it to be
120
- * adapted to this data model.
121
- * This method is used to change the data model of an entity.
122
- * It will remove the entity from the previous data model and add it to this one.
123
- * @param entity The entity to adapt.
124
- */
125
- adaptEntity(entity, opts = {}) {
126
- if (opts.index !== undefined) {
127
- if (opts.index < 0) {
128
- throw new Error(`The index ${opts.index} cannot be below 0.`);
129
- }
130
- if (opts.index >= this.entities.length) {
131
- throw new Error(`The index ${opts.index} is not valid.`);
132
- }
133
- }
134
- if (entity.root !== this.root) {
135
- throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`);
136
- }
137
- const parent = entity.getParentInstance();
138
- if (!parent) {
139
- throw new Error(`The entity ${entity.key} has no parent.`);
140
- }
141
- if (parent.key === this.key) {
142
- throw new Error(`The entity ${entity.key} is already adapted by this data model.`);
143
- }
144
- // it has a parent (above check) so it has the index.
145
- const index = parent.entities.findIndex((i) => i.key === entity.key);
146
- parent.entities.splice(index, 1);
147
- if (opts.index !== undefined) {
148
- this.entities.splice(opts.index, 0, entity);
149
- }
150
- else {
151
- this.entities.push(entity);
152
- }
153
- }
154
- /**
155
- * Adds an entity to this data model.
156
- *
157
- * @param init The name of the entity to create, the instance of the entity or its schema
158
- * @returns A reference to the created entity.
159
- */
160
- addEntity(init) {
161
- let definition;
162
- if (typeof init === 'string') {
163
- definition = DataEntity.fromName(this.root, init);
164
- }
165
- else if (init instanceof DataEntity) {
166
- definition = init;
167
- }
168
- else {
169
- definition = new DataEntity(this.root, init);
170
- }
171
- this.root.definitions.entities.push(definition);
172
- this.entities.push(definition);
173
- return definition;
174
- }
175
- /**
176
- * @deprecated Use the `getParentInstance()` method instead.
177
- */
178
- getParent() {
179
- return this.getParentInstance();
180
- }
181
- /**
182
- * Returns the parent namespace where this data model exist.
183
- */
184
- getParentInstance() {
185
- if (this.root.items.some((e) => e.key === this.key)) {
186
- return this.root;
187
- }
188
- return this.root.definitions.namespaces.find((n) => n.items.some((e) => e.key === this.key));
189
- }
190
- /**
191
- * Creates breadcrumbs from this data model to the root namespace.
192
- */
193
- breadcrumbs() {
194
- const result = [];
195
- result.push({
196
- key: this.key,
197
- name: this.info.getLabel('Unnamed data model'),
198
- kind: DataModelKind,
199
- });
200
- let parent = this.getParentInstance();
201
- while (parent && parent !== this.root) {
202
- result.push({
203
- key: parent.key,
204
- kind: parent.kind,
205
- name: parent.info.getLabel('Unnamed namespace'),
206
- });
207
- parent = parent.getParentInstance();
208
- }
209
- result.push({
210
- key: this.root.key,
211
- name: this.root.info.getLabel('Unnamed data domain'),
212
- kind: this.root.kind,
213
- });
214
- return result.reverse();
215
- }
216
- /**
217
- * Checks whether the data model is a child of the given namespace.
218
- * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.
219
- *
220
- * @param key The key of the parent namespace to check.
221
- * @returns True if this data model is a child of the given namespace.
222
- */
223
- isChildOf(key) {
224
- if (this.key === key) {
225
- return false;
226
- }
227
- const parent = this.getParentInstance();
228
- if (!parent) {
229
- return false;
230
- }
231
- if (parent.key === key) {
232
- return true;
233
- }
234
- return parent.isChildOf(key);
235
- }
236
- }
237
- //# sourceMappingURL=DataModel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../../../src/modeling/legacy/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAA;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AA0BrD;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IA0BX;IAzBT,IAAI,GAAG,aAAa,CAAA;IAEpB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,GAAiB,EAAE,CAAA;IAE3B,MAAM,CAAC,QAAQ,CAAC,IAAmB,EAAE,IAAY;QAC/C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClC,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;OAGG;IACH,YACS,IAAmB,EAC1B,KAA2B;QADpB,SAAI,GAAJ,IAAI,CAAe;QAG1B,IAAI,IAAgB,CAAA;QACpB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,CAAA;QACd,CAAC;aAAM,CAAC;YACN,IAAI,G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AG;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC;YACpD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;SACrB,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../../models/Thing.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js'\nimport { FileBreadcrumb } from '../../models/store/File.js'\nimport { DataModelKind } from '../../models/kinds.js'\nimport type { DataDomainRemoveOptions } from '../types.js'\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n * @deprecated\n */\nexport interface IDataModel {\n kind: typeof DataModelKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The list of keys of entities that this data model contain.\n */\n entities?: string[]\n}\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n * @deprecated\n */\nexport class DataModel {\n kind = DataModelKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * The list of entities that this data model has.\n */\n entities: DataEntity[] = []\n\n static fromName(root: DataNamespace, name: string): DataModel {\n const entity = new DataModel(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param root the root namespace.\n * @param input The data model definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataModel\n ) {\n let init: IDataModel\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataModelKind,\n key: nanoid(),\n info: Thing.fromName('').toJSON(),\n entities: [],\n }\n }\n this.new(init)\n }\n\n new(init: IDataModel): void {\n if (!DataModel.isDataModel(init)) {\n throw new Error(`Not a data model.`)\n }\n const { info, key = nanoid(), kind = DataModelKind, entities } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n\n this.entities = []\n if (Array.isArray(entities)) {\n entities.forEach((key) => {\n const value = this._readEntity(key)\n if (value) {\n this.entities.push(value)\n }\n })\n }\n }\n\n static isDataModel(input: unknown): boolean {\n const typed = input as IDataModel\n if (!input || typed.kind !== DataModelKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataModel {\n const result: IDataModel = {\n kind: DataModelKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.entities) && this.entities.length) {\n result.entities = this.entities.map((i) => i.key)\n }\n return result\n }\n\n protected _readEntity(key: string): DataEntity | undefined {\n return this.root.definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Removes self from the namespace with all entities.\n */\n remove(opts?: DataDomainRemoveOptions): void {\n const { key, entities, root } = this\n // remove children\n entities.forEach((e) => e.remove(opts))\n\n // remove self from the parent\n const parent = this.getParentInstance()\n if (parent) {\n const itemIndex = parent.items.findIndex((i) => i.key === key)\n if (itemIndex >= 0) {\n parent.items.splice(itemIndex, 1)\n }\n }\n // remove self from definitions\n const index = root.definitions.models.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.models.splice(index, 1)\n }\n }\n\n /**\n * Adapts an entity to this data model.\n * The entity must already be added to another data model within this namespace for it to be\n * adapted to this data model.\n * This method is used to change the data model of an entity.\n * It will remove the entity from the previous data model and add it to this one.\n * @param entity The entity to adapt.\n */\n adaptEntity(entity: DataEntity, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.entities.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (entity.root !== this.root) {\n throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`)\n }\n const parent = entity.getParentInstance()\n if (!parent) {\n throw new Error(`The entity ${entity.key} has no parent.`)\n }\n if (parent.key === this.key) {\n throw new Error(`The entity ${entity.key} is already adapted by this data model.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.entities.findIndex((i) => i.key === entity.key)\n parent.entities.splice(index, 1)\n if (opts.index !== undefined) {\n this.entities.splice(opts.index, 0, entity)\n } else {\n this.entities.push(entity)\n }\n }\n\n /**\n * Adds an entity to this data model.\n *\n * @param init The name of the entity to create, the instance of the entity or its schema\n * @returns A reference to the created entity.\n */\n addEntity(init: string | DataEntity | IDataEntity): DataEntity {\n let definition: DataEntity\n if (typeof init === 'string') {\n definition = DataEntity.fromName(this.root, init)\n } else if (init instanceof DataEntity) {\n definition = init\n } else {\n definition = new DataEntity(this.root, init)\n }\n this.root.definitions.entities.push(definition)\n this.entities.push(definition)\n return definition\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataNamespace | undefined {\n return this.getParentInstance()\n }\n\n /**\n * Returns the parent namespace where this data model exist.\n */\n getParentInstance(): DataNamespace | undefined {\n if (this.root.items.some((e) => e.key === this.key)) {\n return this.root\n }\n return this.root.definitions.namespaces.find((n) => n.items.some((e) => e.key === this.key))\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed data model'),\n kind: DataModelKind,\n })\n let parent = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n parent = parent.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
@@ -1,340 +0,0 @@
1
- import { IThing, Thing } from '../../models/Thing.js';
2
- import { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js';
3
- import { IDataEntity, DataEntity } from './DataEntity.js';
4
- import { IDataModel, DataModel } from './DataModel.js';
5
- import { IDataProperty, DataProperty } from './DataProperty.js';
6
- import { DataNamespaceKind, DataModelKind } from '../../models/kinds.js';
7
- import type { DataDomainRemoveOptions } from '../types.js';
8
- /**
9
- * @deprecated
10
- */
11
- type ItemKind = typeof DataNamespaceKind | typeof DataModelKind;
12
- /**
13
- * @deprecated
14
- */
15
- export interface DataItemAdaptingOptions {
16
- /**
17
- * The index at which to adapt the item.
18
- */
19
- index?: number;
20
- }
21
- /**
22
- * @deprecated
23
- */
24
- interface IDataDefinitions {
25
- models?: IDataModel[];
26
- entities?: IDataEntity[];
27
- properties?: IDataProperty[];
28
- associations?: IDataAssociation[];
29
- namespaces?: IDataNamespace[];
30
- tags?: string[];
31
- /**
32
- * The list of foreign namespaces associated with this namespace.
33
- */
34
- foreign?: ForeignNamespace[];
35
- }
36
- /**
37
- * @deprecated
38
- */
39
- interface DataDefinitions {
40
- models: DataModel[];
41
- entities: DataEntity[];
42
- properties: DataProperty[];
43
- associations: DataAssociation[];
44
- namespaces: DataNamespace[];
45
- /**
46
- * Common for the entire root namespace tags.
47
- * These are kept separately so the UI can generate autocomplete for tags.
48
- */
49
- tags: string[];
50
- /**
51
- * The list of foreign namespaces associated with this namespace.
52
- */
53
- foreign?: ForeignNamespace[];
54
- }
55
- /**
56
- * Data definition for a foreign namespace.
57
- * Each foreign namespace is resolved to a specific version.
58
- * This makes sure that the local data are always referencing an existing
59
- * entity as breaking changes should be resolved when upgrading a version.
60
- * @deprecated
61
- */
62
- interface ForeignNamespace {
63
- key: string;
64
- version: string;
65
- }
66
- /**
67
- * Data namespace is a logical description of the hierarchy in the data.
68
- * @deprecated
69
- */
70
- export interface IDataNamespace {
71
- kind: typeof DataNamespaceKind;
72
- /**
73
- * The key of the namespace.
74
- */
75
- key: string;
76
- /**
77
- * The ordered list of items in this namespace.
78
- */
79
- items: IDataItem[];
80
- /**
81
- * The data namespace description.
82
- */
83
- info: IThing;
84
- /**
85
- * The list of definitions used in the namespace.
86
- */
87
- definitions: IDataDefinitions;
88
- }
89
- /**
90
- * Data item is a reference to an object in the top namespace definitions
91
- * to the namespace items.
92
- * @deprecated
93
- */
94
- export interface IDataItem {
95
- /**
96
- * The kind of the item.
97
- */
98
- kind: ItemKind;
99
- /**
100
- * The identifier in the `definitions` array of the namespace.
101
- */
102
- key: string;
103
- }
104
- /**
105
- * @deprecated
106
- */
107
- export declare class DataItem implements IDataItem {
108
- kind: ItemKind;
109
- key: string;
110
- /**
111
- * A reference to the top level namespace.
112
- */
113
- private root;
114
- static isDataItem(input: unknown): boolean;
115
- static dataNamespace(root: DataNamespace, key: string): DataItem;
116
- static dataModel(root: DataNamespace, key: string): DataItem;
117
- /**
118
- * @param root The top-most data namespace.
119
- * @param input The project item definition used to restore the state.
120
- */
121
- constructor(root: DataNamespace, input: string | IDataItem);
122
- new(init: IDataItem): void;
123
- toJSON(): IDataItem;
124
- getItem(): DataNamespace | DataModel | undefined;
125
- }
126
- /**
127
- * Data namespace is a logical description of the hierarchy in the data.
128
- * @deprecated
129
- */
130
- export declare class DataNamespace {
131
- kind: string;
132
- key: string;
133
- /**
134
- * The ordered list of items in this namespace.
135
- */
136
- items: DataItem[];
137
- /**
138
- * The description of the data namespace.
139
- */
140
- info: Thing;
141
- /**
142
- * When a namespace is a sub-namespace this is the reference to the
143
- * root namespace with all definitions.
144
- */
145
- root?: DataNamespace;
146
- /**
147
- * The list of definitions used in the namespace.
148
- */
149
- definitions: DataDefinitions;
150
- /**
151
- * The list of foreign namespaces.
152
- * This is used to find entities from foreign namespaces.
153
- * Values here are treated as read only (objects can be frozen).
154
- *
155
- * This should be set by the application and the namespace will do
156
- * nothing to populate this value.
157
- */
158
- foreign: DataNamespace[];
159
- /**
160
- * Creates a new data namespace from a name.
161
- * @param name The name to set.
162
- */
163
- static fromName(name: string, root?: DataNamespace): DataNamespace;
164
- /**
165
- * @deprecated
166
- */
167
- static definitions(): DataDefinitions;
168
- constructor(input?: string | IDataNamespace, root?: DataNamespace);
169
- new(init: IDataNamespace): void;
170
- toJSON(): IDataNamespace;
171
- /**
172
- * @deprecated Use the `getParentInstance()` method instead.
173
- */
174
- getParent(): DataNamespace | undefined;
175
- /**
176
- * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
177
- */
178
- getParentInstance(): DataNamespace | undefined;
179
- /**
180
- * Lists namespaces that are in this namespace items.
181
- */
182
- listNamespaces(): DataNamespace[];
183
- /**
184
- * Lists namespaces that are in this namespace items.
185
- */
186
- listDataModels(): DataModel[];
187
- /**
188
- * @returns The root of the namespaces tree. It might be the same object.
189
- */
190
- getRoot(): DataNamespace;
191
- /**
192
- * Removes self from the parent namespace with all data models.
193
- * This does noting for the root namespace.
194
- */
195
- remove(opts?: DataDomainRemoveOptions): void;
196
- /**
197
- * Checks if this is the root namespace.
198
- * @returns True if this is the root namespace.
199
- */
200
- isRoot(): boolean;
201
- /**
202
- * Finds a parent namespace for the given namespace.
203
- * @param key The namespace key to find the parent for.
204
- * @returns The parent namespace or undefined when the namespace does not exist. It may return the root namespace.
205
- */
206
- findParent(key: string): DataNamespace | undefined;
207
- /**
208
- * Adds a data namespace to the structure.
209
- * @param init The name of the namespace to add, namespace's schema, or instance.
210
- * @param parent The optional key of the parent namespace to add the new namespace to.
211
- */
212
- addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace;
213
- /**
214
- * Adapts an existing namespace to this namespace.
215
- * This will remove the namespace from the parent namespace and add it to this one.
216
- *
217
- * @param ns The namespace to adapt.
218
- * @param opts Adapting options.
219
- */
220
- adaptNamespace(ns: DataNamespace, opts?: DataItemAdaptingOptions): void;
221
- /**
222
- * Adapts an existing data model to this namespace.
223
- * This will remove the data model from the parent namespace and add it to this one.
224
- * @param model The data model to adapt.
225
- * @param opts The adapting options.
226
- */
227
- adaptDataModel(model: DataModel, opts?: DataItemAdaptingOptions): void;
228
- /**
229
- * Finds a namespace in the definitions.
230
- * @param key The key of the namespace to find.
231
- * @returns The namespace definition or undefined when not found.
232
- */
233
- findNamespace(key: string): DataNamespace | undefined;
234
- /**
235
- * Finds a namespace and calls the `remove()` on it.
236
- * @param key The key of the namespace to find.
237
- */
238
- removeNamespace(key: string, opts?: DataDomainRemoveOptions): void;
239
- /**
240
- * Adds a data model to a namespace.
241
- * @param init The name of the data model to add, data model's schema, or its instance.
242
- * @param parent The optional key of the parent namespace to add the new data model to.
243
- */
244
- addDataModel(init: string | IDataModel | DataModel, parent?: string): DataModel;
245
- /**
246
- * Finds a data model in the definitions.
247
- * @param key The key of the data model to find.
248
- * @returns The data model definition or undefined when not found.
249
- */
250
- findDataModel(key: string): DataModel | undefined;
251
- /**
252
- * A convenience function to remove an object from the namespace.
253
- * @param key The key of the object to remove.
254
- * @param kind The kind of the object to remove.
255
- * @param opts The options for the removal.
256
- * @throws Error when the kind is not known.
257
- */
258
- removeObject(key: string, kind: string, opts?: DataDomainRemoveOptions): void;
259
- /**
260
- * Finds a data model and calls the `remove()` on it.
261
- * @param key The key of the data model to find.
262
- */
263
- removeDataModel(key: string, opts?: DataDomainRemoveOptions): void;
264
- /**
265
- * @returns The graph of associations where keys are the source
266
- * entities and the value is the list of all target entities.
267
- */
268
- associationGraph(): Record<string, string[]>;
269
- /**
270
- * Prints out all associations from one entity to another through all entities that may be in between.
271
- *
272
- * @param from The key of the from entity
273
- * @param to The key of the target entity
274
- * @param g The graph generated with `associationGraph()`
275
- * @param path The current list of entity ids. Do not set this, it is for the recursive processing of the graph.
276
- * @param visited The list of visited paths to avoid cycles.
277
- * Do not set this, it is for the recursive processing of the graph.
278
- */
279
- associationPath(from: string, to: string, g: Record<string, string[]>, path?: string[], visited?: Set<string>): Generator<string[]>;
280
- /**
281
- * Scans all associations for foreign namespaces and returns
282
- * the list of all namespaces used in the association graph.
283
- * This will never add this namespace's key.
284
- *
285
- * This function should be used to read keys for all related
286
- * namespaces through associations.
287
- *
288
- * @returns All keys of foreign namespaces.
289
- */
290
- computeForeignNamespaceKeys(): string[];
291
- /**
292
- * Finds an entity in this namespace.
293
- * @param key The key of the entity to find.
294
- */
295
- findEntity(key: string): DataEntity | undefined;
296
- /**
297
- * Finds a property by its key.
298
- * @param key The key of the property to find
299
- * @returns The property or undefined if not found.
300
- */
301
- findProperty(key: string): DataProperty | undefined;
302
- /**
303
- * Finds an association by its key.
304
- * @param key The key of the property to find
305
- * @returns The property or undefined if not found.
306
- */
307
- findAssociation(key: string): DataAssociation | undefined;
308
- /**
309
- * Searches for entities for association targets.
310
- * This is a helper function to discover entities in the current and foreign namespaces.
311
- *
312
- * @param targets The list of targets
313
- * @returns A list of entities. An `undefined` is put at the index where an entity cannot be found
314
- */
315
- findAssociatedEntities(targets: AssociationTarget[]): (DataEntity | undefined)[];
316
- /**
317
- * Finds an associated entity in the current or foreign namespace.
318
- * This is a helper function to discover entities in the current and foreign namespaces.
319
- *
320
- * @param key The key of the entity to find.
321
- * @param namespace The optional namespace to search in.
322
- * If not set, the current namespace is used.
323
- * This is used to find entities in foreign namespaces.
324
- * @returns The entity or undefined if not found.
325
- */
326
- findAssociatedEntity(key: string, namespace?: string): DataEntity | undefined;
327
- addForeign(ns: DataNamespace): void;
328
- removeForeign(ns: DataNamespace): void;
329
- hasForeignNamespace(key: string): boolean;
330
- /**
331
- * Checks whether the namespace is a child of the given namespace.
332
- * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.
333
- *
334
- * @param key The key of the parent namespace to check.
335
- * @returns True if this namespace is a child of the given namespace.
336
- */
337
- isChildOf(key: string): boolean;
338
- }
339
- export {};
340
- //# sourceMappingURL=DataNamespace.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataNamespace.d.ts","sourceRoot":"","sources":["../../../../src/modeling/legacy/DataNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EACL,iBAAiB,EACjB,aAAa,EAId,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAE1D;;GAEG;AACH,KAAK,QAAQ,GAAG,OAAO,iBAAiB,GAAG,OAAO,aAAa,CAAA;AAE/D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AACD;;GAEG;AACH,UAAU,gBAA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