@api-client/core 0.11.7 → 0.11.9

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 (54) hide show
  1. package/build/src/browser.d.ts +2 -0
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +2 -0
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/index.d.ts +2 -0
  6. package/build/src/index.d.ts.map +1 -1
  7. package/build/src/index.js +2 -0
  8. package/build/src/index.js.map +1 -1
  9. package/build/src/modeling/DataAssociation.d.ts +8 -0
  10. package/build/src/modeling/DataAssociation.d.ts.map +1 -1
  11. package/build/src/modeling/DataAssociation.js +20 -0
  12. package/build/src/modeling/DataAssociation.js.map +1 -1
  13. package/build/src/modeling/DataEntity.d.ts +17 -1
  14. package/build/src/modeling/DataEntity.d.ts.map +1 -1
  15. package/build/src/modeling/DataEntity.js +48 -6
  16. package/build/src/modeling/DataEntity.js.map +1 -1
  17. package/build/src/modeling/DataModel.d.ts +10 -1
  18. package/build/src/modeling/DataModel.d.ts.map +1 -1
  19. package/build/src/modeling/DataModel.js +22 -2
  20. package/build/src/modeling/DataModel.js.map +1 -1
  21. package/build/src/modeling/DataNamespace.d.ts +60 -55
  22. package/build/src/modeling/DataNamespace.d.ts.map +1 -1
  23. package/build/src/modeling/DataNamespace.js +133 -116
  24. package/build/src/modeling/DataNamespace.js.map +1 -1
  25. package/build/src/modeling/DataProperty.d.ts +16 -3
  26. package/build/src/modeling/DataProperty.d.ts.map +1 -1
  27. package/build/src/modeling/DataProperty.js +28 -2
  28. package/build/src/modeling/DataProperty.js.map +1 -1
  29. package/build/src/modeling/DomainImpactAnalysis.d.ts +289 -0
  30. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -0
  31. package/build/src/modeling/DomainImpactAnalysis.js +437 -0
  32. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -0
  33. package/build/src/modeling/types.d.ts +14 -0
  34. package/build/src/modeling/types.d.ts.map +1 -0
  35. package/build/src/modeling/types.js +2 -0
  36. package/build/src/modeling/types.js.map +1 -0
  37. package/data/models/example-generator-api.json +14 -14
  38. package/package.json +6 -6
  39. package/src/modeling/DataAssociation.ts +21 -0
  40. package/src/modeling/DataEntity.ts +59 -10
  41. package/src/modeling/DataModel.ts +24 -2
  42. package/src/modeling/DataNamespace.ts +150 -137
  43. package/src/modeling/DataProperty.ts +32 -3
  44. package/src/modeling/DomainImpactAnalysis.ts +519 -0
  45. package/src/modeling/types.ts +13 -0
  46. package/tests/servers/ExpressServer.ts +1 -0
  47. package/tests/servers/express-routes/BaseApi.ts +1 -1
  48. package/tests/servers/express-routes/TestsApi.ts +1 -1
  49. package/tests/unit/modeling/data_association.spec.ts +73 -0
  50. package/tests/unit/modeling/data_entity.spec.ts +111 -1
  51. package/tests/unit/modeling/data_model.spec.ts +54 -0
  52. package/tests/unit/modeling/data_namespace.spec.ts +46 -1
  53. package/tests/unit/modeling/data_property.spec.ts +73 -0
  54. package/tests/unit/modeling/impact_analysis.spec.ts +373 -0
@@ -4,6 +4,7 @@ import { IDataEntity, DataEntity } from './DataEntity.js';
4
4
  import { IDataModel, DataModel } from './DataModel.js';
5
5
  import { IDataProperty, DataProperty } from './DataProperty.js';
6
6
  import { DataNamespaceKind, DataModelKind } from '../models/kinds.js';
7
+ import type { DataDomainRemoveOptions } from './types.js';
7
8
  type ItemKind = typeof DataNamespaceKind | typeof DataModelKind;
8
9
  export interface DataItemAdaptingOptions {
9
10
  /**
@@ -49,7 +50,10 @@ interface ForeignNamespace {
49
50
  key: string;
50
51
  version: string;
51
52
  }
52
- interface IDataNamespaceParent {
53
+ /**
54
+ * Data namespace is a logical description of the hierarchy in the data.
55
+ */
56
+ export interface IDataNamespace {
53
57
  kind: typeof DataNamespaceKind;
54
58
  /**
55
59
  * The key of the namespace.
@@ -63,11 +67,6 @@ interface IDataNamespaceParent {
63
67
  * The data namespace description.
64
68
  */
65
69
  info: IThing;
66
- }
67
- /**
68
- * Data namespace is a logical description of the hierarchy in the data.
69
- */
70
- export interface IDataNamespace extends IDataNamespaceParent {
71
70
  /**
72
71
  * The list of definitions used in the namespace.
73
72
  */
@@ -87,54 +86,6 @@ export interface IDataItem {
87
86
  */
88
87
  key: string;
89
88
  }
90
- declare class DataNamespaceParent {
91
- kind: string;
92
- key: string;
93
- /**
94
- * The ordered list of items in this namespace.
95
- */
96
- items: DataItem[];
97
- /**
98
- * The description of the data namespace.
99
- */
100
- info: Thing;
101
- /**
102
- * When a namespace is a sub-namespace this is the reference to the
103
- * root namespace with all definitions.
104
- */
105
- root?: DataNamespace;
106
- constructor(root?: DataNamespace);
107
- /**
108
- * @deprecated Use the `getParentInstance()` method instead.
109
- */
110
- getParent(): DataNamespace | undefined;
111
- /**
112
- * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
113
- */
114
- getParentInstance(): DataNamespace | undefined;
115
- /**
116
- * Adds a data namespace to the structure.
117
- * @param init The name of the namespace to add, namespace's schema, or instance.
118
- */
119
- addNamespace(init: string | IDataNamespace | DataNamespace): DataNamespace;
120
- /**
121
- * Lists namespaces that are in this namespace items.
122
- */
123
- listNamespaces(): DataNamespace[];
124
- /**
125
- * Lists namespaces that are in this namespace items.
126
- */
127
- listDataModels(): DataModel[];
128
- /**
129
- * @returns The root of the namespaces tree. It might be the same object.
130
- */
131
- getRoot(): DataNamespace;
132
- /**
133
- * Removes self from the parent namespace with all data models.
134
- * This does noting for the root namespace.
135
- */
136
- remove(): void;
137
- }
138
89
  export declare class DataItem implements IDataItem {
139
90
  kind: ItemKind;
140
91
  key: string;
@@ -157,7 +108,25 @@ export declare class DataItem implements IDataItem {
157
108
  /**
158
109
  * Data namespace is a logical description of the hierarchy in the data.
159
110
  */
160
- export declare class DataNamespace extends DataNamespaceParent {
111
+ export declare class DataNamespace {
112
+ kind: string;
113
+ key: string;
114
+ /**
115
+ * The ordered list of items in this namespace.
116
+ */
117
+ items: DataItem[];
118
+ /**
119
+ * The description of the data namespace.
120
+ */
121
+ info: Thing;
122
+ /**
123
+ * When a namespace is a sub-namespace this is the reference to the
124
+ * root namespace with all definitions.
125
+ */
126
+ root?: DataNamespace;
127
+ /**
128
+ * The list of definitions used in the namespace.
129
+ */
161
130
  definitions: DataDefinitions;
162
131
  /**
163
132
  * The list of foreign namespaces.
@@ -173,10 +142,38 @@ export declare class DataNamespace extends DataNamespaceParent {
173
142
  * @param name The name to set.
174
143
  */
175
144
  static fromName(name: string, root?: DataNamespace): DataNamespace;
145
+ /**
146
+ * @deprecated
147
+ */
176
148
  static definitions(): DataDefinitions;
177
149
  constructor(input?: string | IDataNamespace, root?: DataNamespace);
178
150
  new(init: IDataNamespace): void;
179
151
  toJSON(): IDataNamespace;
152
+ /**
153
+ * @deprecated Use the `getParentInstance()` method instead.
154
+ */
155
+ getParent(): DataNamespace | undefined;
156
+ /**
157
+ * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
158
+ */
159
+ getParentInstance(): DataNamespace | undefined;
160
+ /**
161
+ * Lists namespaces that are in this namespace items.
162
+ */
163
+ listNamespaces(): DataNamespace[];
164
+ /**
165
+ * Lists namespaces that are in this namespace items.
166
+ */
167
+ listDataModels(): DataModel[];
168
+ /**
169
+ * @returns The root of the namespaces tree. It might be the same object.
170
+ */
171
+ getRoot(): DataNamespace;
172
+ /**
173
+ * Removes self from the parent namespace with all data models.
174
+ * This does noting for the root namespace.
175
+ */
176
+ remove(opts?: DataDomainRemoveOptions): void;
180
177
  /**
181
178
  * Checks if this is the root namespace.
182
179
  * @returns True if this is the root namespace.
@@ -303,6 +300,14 @@ export declare class DataNamespace extends DataNamespaceParent {
303
300
  addForeign(ns: DataNamespace): void;
304
301
  removeForeign(ns: DataNamespace): void;
305
302
  hasForeignNamespace(key: string): boolean;
303
+ /**
304
+ * Checks whether the namespace is a child of the given namespace.
305
+ * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.
306
+ *
307
+ * @param key The key of the parent namespace to check.
308
+ * @returns True if this namespace is a child of the given namespace.
309
+ */
310
+ isChildOf(key: string): boolean;
306
311
  }
307
312
  export {};
308
313
  //# sourceMappingURL=DataNamespace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataNamespace.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,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,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGrE,KAAK,QAAQ,GAAG,OAAO,iBAAiB,GAAG,OAAO,aAAa,CAAA;AAE/D,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAA;IACrB,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAA;IAC5B,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAA;IACjC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAC7B;AAED,UAAU,eAAe;IACvB,MAAM,EAAE,SAAS,EAAE,CAAA;IAEnB,QAAQ,EAAE,UAAU,EAAE,CAAA;IAEtB,UAAU,EAAE,YAAY,EAAE,CAAA;IAE1B,YAAY,EAAE,eAAe,E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YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAKnD;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAKzD;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE;IAuBhF;;;;;;;;;OASG;IACH,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAa7E,UAAU,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAQnC,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAOtC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzC;;;;;;OAMG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAahC"}
@@ -6,119 +6,6 @@ import { DataModel } from './DataModel.js';
6
6
  import { DataProperty } from './DataProperty.js';
7
7
  import { DataNamespaceKind, DataModelKind } from '../models/kinds.js';
8
8
  import v4 from '../lib/uuid.js';
9
- class DataNamespaceParent {
10
- kind = DataNamespaceKind;
11
- key = '';
12
- /**
13
- * The ordered list of items in this namespace.
14
- */
15
- items = [];
16
- /**
17
- * The description of the data namespace.
18
- */
19
- info = Thing.fromName('');
20
- /**
21
- * When a namespace is a sub-namespace this is the reference to the
22
- * root namespace with all definitions.
23
- */
24
- root;
25
- constructor(root) {
26
- this.root = root;
27
- }
28
- /**
29
- * @deprecated Use the `getParentInstance()` method instead.
30
- */
31
- getParent() {
32
- return this.getParentInstance();
33
- }
34
- /**
35
- * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
36
- */
37
- getParentInstance() {
38
- const { root, key } = this;
39
- if (root) {
40
- const result = root.findParent(key);
41
- if (result === this.root) {
42
- return undefined;
43
- }
44
- return result;
45
- }
46
- // we are the root namespace.
47
- return undefined;
48
- }
49
- /**
50
- * Adds a data namespace to the structure.
51
- * @param init The name of the namespace to add, namespace's schema, or instance.
52
- */
53
- addNamespace(init) {
54
- return this.root.addNamespace(init, this.key);
55
- }
56
- /**
57
- * Lists namespaces that are in this namespace items.
58
- */
59
- listNamespaces() {
60
- const result = [];
61
- const { items } = this;
62
- const root = this.getRoot();
63
- const { namespaces } = root.definitions;
64
- items.forEach((i) => {
65
- if (i.kind !== DataNamespaceKind) {
66
- return;
67
- }
68
- const def = namespaces.find((j) => j.key === i.key);
69
- if (def) {
70
- result.push(def);
71
- }
72
- });
73
- return result;
74
- }
75
- /**
76
- * Lists namespaces that are in this namespace items.
77
- */
78
- listDataModels() {
79
- const result = [];
80
- const { items } = this;
81
- const root = this.getRoot();
82
- const { models } = root.definitions;
83
- items.forEach((i) => {
84
- if (i.kind !== DataModelKind) {
85
- return;
86
- }
87
- const def = models.find((j) => j.key === i.key);
88
- if (def) {
89
- result.push(def);
90
- }
91
- });
92
- return result;
93
- }
94
- /**
95
- * @returns The root of the namespaces tree. It might be the same object.
96
- */
97
- getRoot() {
98
- if (this.root) {
99
- return this.root;
100
- }
101
- return this;
102
- }
103
- /**
104
- * Removes self from the parent namespace with all data models.
105
- * This does noting for the root namespace.
106
- */
107
- remove() {
108
- const { root } = this;
109
- if (!root) {
110
- throw new Error(`Unable to remove the root namespace this way.`);
111
- }
112
- const models = this.listDataModels();
113
- const children = this.listNamespaces();
114
- models.forEach((m) => m.remove());
115
- children.forEach((c) => c.remove());
116
- const index = root.definitions.namespaces.findIndex((i) => i.key === this.key);
117
- if (index >= 0) {
118
- root.definitions.namespaces.splice(index, 1);
119
- }
120
- }
121
- }
122
9
  export class DataItem {
123
10
  kind = DataModelKind;
124
11
  key = '';
@@ -194,7 +81,25 @@ export class DataItem {
194
81
  /**
195
82
  * Data namespace is a logical description of the hierarchy in the data.
196
83
  */
197
- export class DataNamespace extends DataNamespaceParent {
84
+ export class DataNamespace {
85
+ kind = DataNamespaceKind;
86
+ key = '';
87
+ /**
88
+ * The ordered list of items in this namespace.
89
+ */
90
+ items = [];
91
+ /**
92
+ * The description of the data namespace.
93
+ */
94
+ info = Thing.fromName('');
95
+ /**
96
+ * When a namespace is a sub-namespace this is the reference to the
97
+ * root namespace with all definitions.
98
+ */
99
+ root;
100
+ /**
101
+ * The list of definitions used in the namespace.
102
+ */
198
103
  definitions;
199
104
  /**
200
105
  * The list of foreign namespaces.
@@ -215,6 +120,9 @@ export class DataNamespace extends DataNamespaceParent {
215
120
  ns.info = info;
216
121
  return ns;
217
122
  }
123
+ /**
124
+ * @deprecated
125
+ */
218
126
  static definitions() {
219
127
  return {
220
128
  models: [],
@@ -226,8 +134,15 @@ export class DataNamespace extends DataNamespaceParent {
226
134
  };
227
135
  }
228
136
  constructor(input, root) {
229
- super(root);
230
- this.definitions = DataNamespace.definitions();
137
+ this.root = root;
138
+ this.definitions = {
139
+ models: [],
140
+ associations: [],
141
+ entities: [],
142
+ properties: [],
143
+ namespaces: [],
144
+ tags: [],
145
+ };
231
146
  let init;
232
147
  if (typeof input === 'string') {
233
148
  init = JSON.parse(input);
@@ -335,6 +250,88 @@ export class DataNamespace extends DataNamespaceParent {
335
250
  }
336
251
  return result;
337
252
  }
253
+ /**
254
+ * @deprecated Use the `getParentInstance()` method instead.
255
+ */
256
+ getParent() {
257
+ return this.getParentInstance();
258
+ }
259
+ /**
260
+ * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.
261
+ */
262
+ getParentInstance() {
263
+ const { root, key } = this;
264
+ if (root) {
265
+ return root.findParent(key);
266
+ }
267
+ // we are the root namespace.
268
+ return undefined;
269
+ }
270
+ /**
271
+ * Lists namespaces that are in this namespace items.
272
+ */
273
+ listNamespaces() {
274
+ const result = [];
275
+ const { items } = this;
276
+ const root = this.getRoot();
277
+ const { namespaces } = root.definitions;
278
+ items.forEach((i) => {
279
+ if (i.kind !== DataNamespaceKind) {
280
+ return;
281
+ }
282
+ const def = namespaces.find((j) => j.key === i.key);
283
+ if (def) {
284
+ result.push(def);
285
+ }
286
+ });
287
+ return result;
288
+ }
289
+ /**
290
+ * Lists namespaces that are in this namespace items.
291
+ */
292
+ listDataModels() {
293
+ const result = [];
294
+ const { items } = this;
295
+ const root = this.getRoot();
296
+ const { models } = root.definitions;
297
+ items.forEach((i) => {
298
+ if (i.kind !== DataModelKind) {
299
+ return;
300
+ }
301
+ const def = models.find((j) => j.key === i.key);
302
+ if (def) {
303
+ result.push(def);
304
+ }
305
+ });
306
+ return result;
307
+ }
308
+ /**
309
+ * @returns The root of the namespaces tree. It might be the same object.
310
+ */
311
+ getRoot() {
312
+ if (this.root) {
313
+ return this.root;
314
+ }
315
+ return this;
316
+ }
317
+ /**
318
+ * Removes self from the parent namespace with all data models.
319
+ * This does noting for the root namespace.
320
+ */
321
+ remove(opts) {
322
+ const { root } = this;
323
+ if (!root) {
324
+ throw new Error(`Unable to remove the root namespace this way.`);
325
+ }
326
+ const models = this.listDataModels();
327
+ const children = this.listNamespaces();
328
+ models.forEach((m) => m.remove(opts));
329
+ children.forEach((c) => c.remove(opts));
330
+ const index = root.definitions.namespaces.findIndex((i) => i.key === this.key);
331
+ if (index >= 0) {
332
+ root.definitions.namespaces.splice(index, 1);
333
+ }
334
+ }
338
335
  /**
339
336
  * Checks if this is the root namespace.
340
337
  * @returns True if this is the root namespace.
@@ -731,5 +728,25 @@ export class DataNamespace extends DataNamespaceParent {
731
728
  hasForeignNamespace(key) {
732
729
  return this.foreign.some((i) => i.key === key);
733
730
  }
731
+ /**
732
+ * Checks whether the namespace is a child of the given namespace.
733
+ * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.
734
+ *
735
+ * @param key The key of the parent namespace to check.
736
+ * @returns True if this namespace is a child of the given namespace.
737
+ */
738
+ isChildOf(key) {
739
+ if (this.key === key) {
740
+ return false;
741
+ }
742
+ const parent = this.getParentInstance();
743
+ if (!parent) {
744
+ return false;
745
+ }
746
+ if (parent.key === key) {
747
+ return true;
748
+ }
749
+ return parent.isChildOf(key);
750
+ }
734
751
  }
735
752
  //# sourceMappingURL=DataNamespace.js.map