@api-client/core 0.20.4 → 0.20.6

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 (33) hide show
  1. package/build/src/modeling/ApiModel.d.ts.map +1 -1
  2. package/build/src/modeling/ApiModel.js +9 -2
  3. package/build/src/modeling/ApiModel.js.map +1 -1
  4. package/build/src/modeling/DataDomain.d.ts +9 -3
  5. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  6. package/build/src/modeling/DataDomain.js +25 -6
  7. package/build/src/modeling/DataDomain.js.map +1 -1
  8. package/build/src/modeling/DependentModel.d.ts +4 -0
  9. package/build/src/modeling/DependentModel.d.ts.map +1 -1
  10. package/build/src/modeling/DependentModel.js.map +1 -1
  11. package/build/src/modeling/DomainEntity.d.ts +20 -0
  12. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  13. package/build/src/modeling/DomainEntity.js +93 -0
  14. package/build/src/modeling/DomainEntity.js.map +1 -1
  15. package/build/src/modeling/RuntimeApiModel.d.ts +22 -0
  16. package/build/src/modeling/RuntimeApiModel.d.ts.map +1 -1
  17. package/build/src/modeling/RuntimeApiModel.js +102 -1
  18. package/build/src/modeling/RuntimeApiModel.js.map +1 -1
  19. package/build/src/modeling/types.d.ts +20 -20
  20. package/build/src/modeling/types.d.ts.map +1 -1
  21. package/build/src/modeling/types.js.map +1 -1
  22. package/build/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +1 -1
  24. package/src/modeling/ApiModel.ts +8 -2
  25. package/src/modeling/DataDomain.ts +27 -7
  26. package/src/modeling/DependentModel.ts +4 -0
  27. package/src/modeling/DomainEntity.ts +100 -0
  28. package/src/modeling/RuntimeApiModel.ts +124 -2
  29. package/src/modeling/types.ts +21 -20
  30. package/tests/unit/modeling/RuntimeApiModel.spec.ts +91 -0
  31. package/tests/unit/modeling/data_domain_entities.spec.ts +56 -0
  32. package/tests/unit/modeling/data_domain_serialization.spec.ts +11 -11
  33. package/tests/unit/modeling/domain_entity_associations.spec.ts +63 -0
@@ -583,7 +583,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
583
583
  }
584
584
 
585
585
  // Should not throw in lenient mode
586
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
586
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
587
587
 
588
588
  // Should have issues recorded
589
589
  assert.isAbove(restored.issues.length, 0)
@@ -611,7 +611,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
611
611
  }
612
612
 
613
613
  // Should not throw in lenient mode
614
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
614
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
615
615
 
616
616
  // Should have issues recorded
617
617
  assert.isAbove(restored.issues.length, 0)
@@ -641,7 +641,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
641
641
  }
642
642
 
643
643
  // Should not throw in lenient mode
644
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
644
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
645
645
 
646
646
  // Should have issues recorded
647
647
  assert.isAbove(restored.issues.length, 0)
@@ -680,7 +680,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
680
680
  }
681
681
 
682
682
  // Should not throw in lenient mode
683
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
683
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
684
684
 
685
685
  // Should have issues recorded about missing parent node
686
686
  assert.isAbove(restored.issues.length, 0)
@@ -706,7 +706,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
706
706
  const serialized = domain.toJSON()
707
707
 
708
708
  // Deserialize without providing the foreign dependency
709
- const restored = new DataDomain(serialized, [], 'lenient')
709
+ const restored = new DataDomain(serialized, [], { mode: 'lenient' })
710
710
 
711
711
  // Should have issues recorded about missing dependency
712
712
  assert.isAbove(restored.issues.length, 0)
@@ -742,7 +742,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
742
742
  }
743
743
 
744
744
  // Should not throw in lenient mode
745
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
745
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
746
746
 
747
747
  // Should have issues recorded
748
748
  assert.isAbove(restored.issues.length, 0)
@@ -797,7 +797,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
797
797
  }
798
798
 
799
799
  // Should not throw in lenient mode
800
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
800
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
801
801
 
802
802
  // Should have multiple issues recorded
803
803
  assert.isAtLeast(restored.issues.length, 3)
@@ -823,7 +823,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
823
823
  e1.addProperty({ type: 'string' })
824
824
 
825
825
  const serialized = domain.toJSON()
826
- const restored = new DataDomain(serialized, [], 'strict')
826
+ const restored = new DataDomain(serialized, [], { mode: 'strict' })
827
827
 
828
828
  // Should have no issues in strict mode for valid data
829
829
  assert.equal(restored.issues.length, 0)
@@ -855,11 +855,11 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
855
855
 
856
856
  // Should throw in strict mode
857
857
  assert.throws(() => {
858
- new DataDomain(corruptedSerialized, [], 'strict')
858
+ new DataDomain(corruptedSerialized, [], { mode: 'strict' })
859
859
  })
860
860
 
861
861
  // Should not throw in lenient mode
862
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
862
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
863
863
  assert.isAbove(restored.issues.length, 0)
864
864
  }).tags(['@modeling', '@serialization', '@lenient', '@strict'])
865
865
 
@@ -879,7 +879,7 @@ test.group('DataDomain Lenient Mode Deserialization', () => {
879
879
  )
880
880
  }
881
881
 
882
- const restored = new DataDomain(corruptedSerialized, [], 'lenient')
882
+ const restored = new DataDomain(corruptedSerialized, [], { mode: 'lenient' })
883
883
 
884
884
  // Should have detailed issue information
885
885
  assert.isAbove(restored.issues.length, 0)
@@ -328,3 +328,66 @@ test.group('DomainEntity.hasAssociations()', () => {
328
328
  assert.isFalse(entity.hasAssociations())
329
329
  })
330
330
  })
331
+
332
+ test.group('DomainEntity.withInheritedAssociations()', () => {
333
+ test('returns associations from entity and its parents', ({ assert }) => {
334
+ const dataDomain = new DataDomain()
335
+ const model = dataDomain.addModel()
336
+ const parentEntity = model.addEntity({ key: 'parent' })
337
+ const childEntity = model.addEntity({ key: 'child' })
338
+
339
+ const parentAssoc = parentEntity.addAssociation()
340
+ parentAssoc.info.name = 'parentAssoc'
341
+
342
+ const childAssoc = childEntity.addAssociation()
343
+ childAssoc.info.name = 'childAssoc'
344
+
345
+ childEntity.addParent(parentEntity.key)
346
+
347
+ const inherited = Array.from(childEntity.withInheritedAssociations())
348
+ assert.lengthOf(inherited, 2)
349
+ assert.deepEqual(inherited.map((a) => a.info.name).sort(), ['childAssoc', 'parentAssoc'])
350
+ })
351
+
352
+ test('overrides parent association with the same name', ({ assert }) => {
353
+ const dataDomain = new DataDomain()
354
+ const model = dataDomain.addModel()
355
+ const parentEntity = model.addEntity({ key: 'parent' })
356
+ const childEntity = model.addEntity({ key: 'child' })
357
+
358
+ const parentAssoc = parentEntity.addAssociation()
359
+ parentAssoc.info.name = 'assoc'
360
+
361
+ const childAssoc = childEntity.addAssociation()
362
+ childAssoc.info.name = 'assoc'
363
+
364
+ childEntity.addParent(parentEntity.key)
365
+
366
+ const inherited = Array.from(childEntity.withInheritedAssociations())
367
+ assert.lengthOf(inherited, 1)
368
+ assert.equal(inherited[0].key, childAssoc.key)
369
+ })
370
+
371
+ test('uses cached inherited associations when domain is readOnly', ({ assert }) => {
372
+ const dataDomain = new DataDomain(undefined, [], { readOnly: true })
373
+ const model = dataDomain.addModel()
374
+ const parentEntity = model.addEntity({ key: 'parent' })
375
+ const childEntity = model.addEntity({ key: 'child' })
376
+
377
+ const parentAssoc = parentEntity.addAssociation()
378
+ parentAssoc.info.name = 'parentAssoc'
379
+
380
+ childEntity.addParent(parentEntity.key)
381
+
382
+ const inherited1 = Array.from(childEntity.withInheritedAssociations())
383
+ assert.lengthOf(inherited1, 1)
384
+
385
+ // Add another association bypassing normal immutability rules for test
386
+ const anotherAssoc = parentEntity.addAssociation()
387
+ anotherAssoc.info.name = 'anotherAssoc'
388
+
389
+ const inherited2 = Array.from(childEntity.withInheritedAssociations())
390
+ // Should still be length 1 because of the readOnly cache
391
+ assert.lengthOf(inherited2, 1)
392
+ })
393
+ })