@api-client/core 0.18.10 → 0.18.11

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.
@@ -42071,10 +42071,10 @@
42071
42071
  "@id": "#197"
42072
42072
  },
42073
42073
  {
42074
- "@id": "#200"
42074
+ "@id": "#203"
42075
42075
  },
42076
42076
  {
42077
- "@id": "#203"
42077
+ "@id": "#200"
42078
42078
  },
42079
42079
  {
42080
42080
  "@id": "#206"
@@ -42810,16 +42810,16 @@
42810
42810
  "@id": "#219"
42811
42811
  },
42812
42812
  {
42813
- "@id": "#210"
42813
+ "@id": "#216"
42814
42814
  },
42815
42815
  {
42816
- "@id": "#213"
42816
+ "@id": "#219"
42817
42817
  },
42818
42818
  {
42819
- "@id": "#216"
42819
+ "@id": "#210"
42820
42820
  },
42821
42821
  {
42822
- "@id": "#219"
42822
+ "@id": "#213"
42823
42823
  }
42824
42824
  ],
42825
42825
  "doc:root": false,
@@ -43499,7 +43499,7 @@
43499
43499
  "doc:ExternalDomainElement",
43500
43500
  "doc:DomainElement"
43501
43501
  ],
43502
- "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43502
+ "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43503
43503
  "core:mediaType": "application/yaml",
43504
43504
  "sourcemaps:sources": [
43505
43505
  {
@@ -43520,7 +43520,7 @@
43520
43520
  "doc:ExternalDomainElement",
43521
43521
  "doc:DomainElement"
43522
43522
  ],
43523
- "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43523
+ "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43524
43524
  "core:mediaType": "application/yaml",
43525
43525
  "sourcemaps:sources": [
43526
43526
  {
@@ -44232,7 +44232,7 @@
44232
44232
  "doc:ExternalDomainElement",
44233
44233
  "doc:DomainElement"
44234
44234
  ],
44235
- "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '22'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)22 000000'\n",
44235
+ "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
44236
44236
  "core:mediaType": "application/yaml",
44237
44237
  "sourcemaps:sources": [
44238
44238
  {
@@ -44253,7 +44253,7 @@
44253
44253
  "doc:ExternalDomainElement",
44254
44254
  "doc:DomainElement"
44255
44255
  ],
44256
- "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
44256
+ "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
44257
44257
  "core:mediaType": "application/yaml",
44258
44258
  "sourcemaps:sources": [
44259
44259
  {
@@ -44274,7 +44274,7 @@
44274
44274
  "doc:ExternalDomainElement",
44275
44275
  "doc:DomainElement"
44276
44276
  ],
44277
- "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
44277
+ "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '22'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)22 000000'\n",
44278
44278
  "core:mediaType": "application/yaml",
44279
44279
  "sourcemaps:sources": [
44280
44280
  {
@@ -44295,7 +44295,7 @@
44295
44295
  "doc:ExternalDomainElement",
44296
44296
  "doc:DomainElement"
44297
44297
  ],
44298
- "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
44298
+ "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
44299
44299
  "core:mediaType": "application/yaml",
44300
44300
  "sourcemaps:sources": [
44301
44301
  {
@@ -44771,12 +44771,12 @@
44771
44771
  {
44772
44772
  "@id": "#202/source-map/lexical/element_0",
44773
44773
  "sourcemaps:element": "amf://id#202",
44774
- "sourcemaps:value": "[(1,0)-(5,0)]"
44774
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44775
44775
  },
44776
44776
  {
44777
44777
  "@id": "#205/source-map/lexical/element_0",
44778
44778
  "sourcemaps:element": "amf://id#205",
44779
- "sourcemaps:value": "[(1,0)-(3,0)]"
44779
+ "sourcemaps:value": "[(1,0)-(5,0)]"
44780
44780
  },
44781
44781
  {
44782
44782
  "@id": "#208/source-map/lexical/element_0",
@@ -45116,22 +45116,22 @@
45116
45116
  {
45117
45117
  "@id": "#212/source-map/lexical/element_0",
45118
45118
  "sourcemaps:element": "amf://id#212",
45119
- "sourcemaps:value": "[(1,0)-(6,0)]"
45119
+ "sourcemaps:value": "[(1,0)-(7,0)]"
45120
45120
  },
45121
45121
  {
45122
45122
  "@id": "#215/source-map/lexical/element_0",
45123
45123
  "sourcemaps:element": "amf://id#215",
45124
- "sourcemaps:value": "[(1,0)-(6,0)]"
45124
+ "sourcemaps:value": "[(1,0)-(3,0)]"
45125
45125
  },
45126
45126
  {
45127
45127
  "@id": "#218/source-map/lexical/element_0",
45128
45128
  "sourcemaps:element": "amf://id#218",
45129
- "sourcemaps:value": "[(1,0)-(7,0)]"
45129
+ "sourcemaps:value": "[(1,0)-(6,0)]"
45130
45130
  },
45131
45131
  {
45132
45132
  "@id": "#221/source-map/lexical/element_0",
45133
45133
  "sourcemaps:element": "amf://id#221",
45134
- "sourcemaps:value": "[(1,0)-(3,0)]"
45134
+ "sourcemaps:value": "[(1,0)-(6,0)]"
45135
45135
  },
45136
45136
  {
45137
45137
  "@id": "#338/source-map/synthesized-field/element_1",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.18.10",
4
+ "version": "0.18.11",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -272,19 +272,25 @@ export function deserialize(root: DataDomain, json?: SerializedGraph, dependenci
272
272
  return g
273
273
  }
274
274
  if (Array.isArray(json.nodes)) {
275
+ // 1st pass - set up nodes
276
+ const parentInfo = new Map<string, string[]>()
275
277
  for (const entry of json.nodes) {
276
278
  g.setNode(entry.v, prepareNode(root, entry.value, json.edges))
277
279
  if (entry.parents) {
278
- for (const parent of entry.parents) {
279
- // In data domain graph, all nodes that can have parents can only have a single parent.
280
- // It's the business logic of the library.
281
- // Parent-child relationships:
282
- // - Namespace -> Namespace
283
- // - Namespace -> Model
284
- // - Model -> Entity
285
- // Entities and Association are associated with the parent entity through edges.
286
- g.setParent(entry.v, parent)
287
- }
280
+ parentInfo.set(entry.v, entry.parents)
281
+ }
282
+ }
283
+ // 2nd pass - set up parents
284
+ for (const [key, parents] of parentInfo) {
285
+ // In data domain graph, all nodes that can have parents can only have a single parent.
286
+ // It's the business logic of the library.
287
+ // Parent-child relationships:
288
+ // - Namespace -> Namespace
289
+ // - Namespace -> Model
290
+ // - Model -> Entity
291
+ // Entities and Association are associated with the parent entity through edges.
292
+ for (const parent of parents) {
293
+ g.setParent(key, parent)
288
294
  }
289
295
  }
290
296
  }
File without changes
@@ -291,4 +291,104 @@ test.group('DataDomain Serialization and Deserialization', () => {
291
291
  assert.isTrue(restored.graph.hasEdge(e1.key, a1.key), 'has edge from e1 to a1')
292
292
  assert.isFalse(restored.graph.hasEdge(a1.key, `${fd.key}:${fe1.key}`), 'has no edge from a1 to fe1')
293
293
  }).tags(['@modeling', '@serialization'])
294
+
295
+ test('should serialize and deserialize parent-child relationships in the graph', ({ assert }) => {
296
+ const domain = new DataDomain()
297
+
298
+ // Create hierarchical structure: root > ns1 > ns2 > m1 > e1, e2 (e2 inherits from e1)
299
+ const ns1 = domain.addNamespace({ key: 'ns1' })
300
+ const ns2 = ns1.addNamespace({ key: 'ns2' })
301
+ const m1 = ns2.addModel({ key: 'm1' })
302
+ const m2 = domain.addModel({ key: 'm2' }) // root level model
303
+ const e1 = m1.addEntity({ key: 'e1' })
304
+ const e2 = m1.addEntity({ key: 'e2' })
305
+ const e3 = m2.addEntity({ key: 'e3' })
306
+
307
+ // Add entity inheritance relationships
308
+ e2.addParent(e1.key) // e2 inherits from e1
309
+ e3.addParent(e2.key) // e3 inherits from e2 (multi-level inheritance)
310
+
311
+ // Add properties and associations
312
+ const p1 = e1.addProperty({ type: 'string', key: 'p1' })
313
+ const p2 = e2.addProperty({ type: 'number', key: 'p2' })
314
+ const a1 = e1.addAssociation({ key: e3.key }, { key: 'a1' })
315
+
316
+ const serialized = domain.toJSON()
317
+ const restored = new DataDomain(serialized)
318
+
319
+ // Verify basic domain properties
320
+ assert.equal(restored.key, domain.key)
321
+ assert.equal(restored.kind, domain.kind)
322
+ assert.deepEqual(restored.info.toJSON(), domain.info.toJSON())
323
+
324
+ // Verify all nodes are restored
325
+ assert.equal([...restored.graph.nodes()].length, 10) // 2 ns + 2 models + 3 entities + 2 properties + 1 association
326
+
327
+ // Verify namespace hierarchy: ns1 (root) -> ns2 (child of ns1)
328
+ const rns1 = restored.findNamespace(ns1.key)
329
+ const rns2 = restored.findNamespace(ns2.key)
330
+ assert.isDefined(rns1)
331
+ assert.isDefined(rns2)
332
+ assert.isUndefined(restored.graph.parent(ns1.key), 'ns1 should be at root level')
333
+ assert.equal(restored.graph.parent(ns2.key), ns1.key, 'ns2 should be child of ns1')
334
+
335
+ // Verify model hierarchy: m1 (child of ns2), m2 (root level)
336
+ const rm1 = restored.findModel(m1.key)
337
+ const rm2 = restored.findModel(m2.key)
338
+ assert.isDefined(rm1)
339
+ assert.isDefined(rm2)
340
+ assert.equal(restored.graph.parent(m1.key), ns2.key, 'm1 should be child of ns2')
341
+ assert.isUndefined(restored.graph.parent(m2.key), 'm2 should be at root level')
342
+
343
+ // Verify entity hierarchy: e1, e2 (children of m1), e3 (child of m2)
344
+ const re1 = restored.findEntity(e1.key)
345
+ const re2 = restored.findEntity(e2.key)
346
+ const re3 = restored.findEntity(e3.key)
347
+ assert.isDefined(re1)
348
+ assert.isDefined(re2)
349
+ assert.isDefined(re3)
350
+ assert.equal(restored.graph.parent(e1.key), m1.key, 'e1 should be child of m1')
351
+ assert.equal(restored.graph.parent(e2.key), m1.key, 'e2 should be child of m1')
352
+ assert.equal(restored.graph.parent(e3.key), m2.key, 'e3 should be child of m2')
353
+
354
+ // Verify entity inheritance relationships (via edges, not parent-child)
355
+ assert.isTrue(restored.graph.hasEdge(e2.key, e1.key), 'e2 should inherit from e1')
356
+ assert.equal(restored.graph.edge(e2.key, e1.key)?.type, 'parent', 'inheritance edge should have type parent')
357
+ assert.isTrue(restored.graph.hasEdge(e3.key, e2.key), 'e3 should inherit from e2')
358
+ assert.equal(restored.graph.edge(e3.key, e2.key)?.type, 'parent', 'inheritance edge should have type parent')
359
+
360
+ // Verify entity inheritance works functionally
361
+ const restoredParentsE2 = [...re2!.listParents()]
362
+ const restoredParentsE3 = [...re3!.listParents()]
363
+ assert.equal(restoredParentsE2.length, 1, 'e2 should have 1 parent')
364
+ assert.equal(restoredParentsE2[0].key, e1.key, 'e2 parent should be e1')
365
+ assert.equal(restoredParentsE3.length, 1, 'e3 should have 1 parent')
366
+ assert.equal(restoredParentsE3[0].key, e2.key, 'e3 parent should be e2')
367
+
368
+ // Verify property hierarchy: p1 (child of e1), p2 (child of e2)
369
+ const rp1 = restored.findProperty(p1.key)
370
+ const rp2 = restored.findProperty(p2.key)
371
+ assert.isDefined(rp1)
372
+ assert.isDefined(rp2)
373
+ assert.isTrue(restored.graph.hasEdge(e1.key, p1.key), 'e1 should have edge to p1')
374
+ assert.equal(restored.graph.edge(e1.key, p1.key)?.type, 'property', 'property edge should have type property')
375
+ assert.isTrue(restored.graph.hasEdge(e2.key, p2.key), 'e2 should have edge to p2')
376
+ assert.equal(restored.graph.edge(e2.key, p2.key)?.type, 'property', 'property edge should have type property')
377
+
378
+ // Verify association hierarchy: a1 (child of e1) -> e3
379
+ const ra1 = restored.findAssociation(a1.key)
380
+ assert.isDefined(ra1)
381
+ assert.isTrue(restored.graph.hasEdge(e1.key, a1.key), 'e1 should have edge to a1')
382
+ assert.equal(
383
+ restored.graph.edge(e1.key, a1.key)?.type,
384
+ 'association',
385
+ 'association edge should have type association'
386
+ )
387
+ assert.isTrue(restored.graph.hasEdge(a1.key, e3.key), 'a1 should have edge to e3')
388
+ assert.equal(
389
+ restored.graph.edge(a1.key, e3.key)?.type,
390
+ 'association',
391
+ 'association target edge should have type association'
392
+ )
393
+ }).tags(['@modeling', '@serialization'])
294
394
  })