@api-client/core 0.18.30 → 0.18.31

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.
@@ -42068,10 +42068,10 @@
42068
42068
  "@id": "#194"
42069
42069
  },
42070
42070
  {
42071
- "@id": "#197"
42071
+ "@id": "#200"
42072
42072
  },
42073
42073
  {
42074
- "@id": "#200"
42074
+ "@id": "#197"
42075
42075
  },
42076
42076
  {
42077
42077
  "@id": "#203"
@@ -43478,7 +43478,7 @@
43478
43478
  "doc:ExternalDomainElement",
43479
43479
  "doc:DomainElement"
43480
43480
  ],
43481
- "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43481
+ "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43482
43482
  "core:mediaType": "application/yaml",
43483
43483
  "sourcemaps:sources": [
43484
43484
  {
@@ -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: '5'\ndescription: 'Limited company'\n",
43503
43503
  "core:mediaType": "application/yaml",
43504
43504
  "sourcemaps:sources": [
43505
43505
  {
@@ -44766,12 +44766,12 @@
44766
44766
  {
44767
44767
  "@id": "#199/source-map/lexical/element_0",
44768
44768
  "sourcemaps:element": "amf://id#199",
44769
- "sourcemaps:value": "[(1,0)-(3,0)]"
44769
+ "sourcemaps:value": "[(1,0)-(5,0)]"
44770
44770
  },
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",
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.30",
4
+ "version": "0.18.31",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -401,12 +401,20 @@ export class ApiModel extends DependentModel {
401
401
  throw new Error(`Entity not found in domain: ${entity.key}`)
402
402
  }
403
403
  const name = domainEntity.info.name || ''
404
+ const segment = pluralize(name.toLocaleLowerCase())
405
+ const relativeCollectionPath = `/${segment}`
406
+ const relativeResourcePath = `/${segment}/{id}`
407
+ const absoluteCollectionPath = relativeCollectionPath
408
+ const absoluteResourcePath = relativeResourcePath
404
409
  const newEntity: ExposedEntity = {
405
410
  key: nanoid(),
406
411
  entity: { ...entity },
407
412
  actions: [],
408
413
  isRoot: true,
409
- path: pluralize(name.toLocaleLowerCase()),
414
+ relativeCollectionPath,
415
+ relativeResourcePath,
416
+ absoluteCollectionPath,
417
+ absoluteResourcePath,
410
418
  }
411
419
  if (options) {
412
420
  newEntity.exposeOptions = { ...options }
@@ -479,13 +487,24 @@ export class ApiModel extends DependentModel {
479
487
  if (!targetDomainEntity) continue
480
488
 
481
489
  const name = association.info.name || ''
490
+ const parentExposure = this.exposes.find((e) => e.key === parentKey)
491
+ const parentAbsResource = parentExposure?.absoluteResourcePath || ''
492
+ const segment = pluralize(name.toLocaleLowerCase())
493
+ const isCollection = association.multiple !== false
494
+ const relativeCollectionPath = isCollection ? `/${segment}` : undefined
495
+ const relativeResourcePath = isCollection ? `/${segment}/{id}` : `/${segment}`
496
+ const absoluteCollectionPath = isCollection ? `${parentAbsResource}${relativeCollectionPath}` : undefined
497
+ const absoluteResourcePath = `${parentAbsResource}${relativeResourcePath}`
482
498
  // Create nested exposure
483
499
  const nestedExposure: ExposedEntity = {
484
500
  key: nanoid(),
485
501
  entity: { ...target },
486
502
  actions: [],
487
503
  isRoot: false,
488
- path: pluralize(name.toLocaleLowerCase()),
504
+ relativeCollectionPath,
505
+ relativeResourcePath,
506
+ absoluteCollectionPath,
507
+ absoluteResourcePath,
489
508
  parent: {
490
509
  key: parentKey,
491
510
  association: {
@@ -449,9 +449,28 @@ export interface ExposedEntity {
449
449
  */
450
450
  entity: AssociationTarget
451
451
  /**
452
- * The path segment for this exposure.
452
+ * Relative path to the collection endpoint for this exposure.
453
+ * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.
453
454
  */
454
- path: string
455
+ relativeCollectionPath?: string
456
+
457
+ /**
458
+ * Relative path to the resource endpoint for this exposure.
459
+ * Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.
460
+ */
461
+ relativeResourcePath: string
462
+
463
+ /**
464
+ * Absolute path to the collection endpoint for this exposure (includes parent paths).
465
+ * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.
466
+ */
467
+ absoluteCollectionPath?: string
468
+
469
+ /**
470
+ * Absolute path to the resource endpoint for this exposure (includes parent paths).
471
+ * Starts with '/'.
472
+ */
473
+ absoluteResourcePath: string
455
474
 
456
475
  /**
457
476
  * Whether this exposure is a root exposure (top-level collection).
@@ -81,7 +81,8 @@ test.group('ApiModel.exposeEntity()', () => {
81
81
  const nestedB = model.exposes.find((e) => !e.isRoot && e.entity.key === eB.key)
82
82
  assert.isDefined(nestedB)
83
83
  assert.deepEqual(nestedB?.parent?.key, exposedA.key)
84
- assert.strictEqual(nestedB?.path, 'entitybs')
84
+ assert.strictEqual(nestedB?.relativeCollectionPath, '/entitybs')
85
+ assert.strictEqual(nestedB?.absoluteCollectionPath, '/as/{id}/entitybs')
85
86
  })
86
87
 
87
88
  test('does not infinitely expose circular associations', ({ assert }) => {