@api-client/core 0.18.52 → 0.18.54

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": "#200"
42071
+ "@id": "#197"
42072
42072
  },
42073
42073
  {
42074
- "@id": "#197"
42074
+ "@id": "#200"
42075
42075
  },
42076
42076
  {
42077
42077
  "@id": "#203"
@@ -42810,16 +42810,16 @@
42810
42810
  "@id": "#219"
42811
42811
  },
42812
42812
  {
42813
- "@id": "#219"
42813
+ "@id": "#210"
42814
42814
  },
42815
42815
  {
42816
- "@id": "#210"
42816
+ "@id": "#216"
42817
42817
  },
42818
42818
  {
42819
42819
  "@id": "#213"
42820
42820
  },
42821
42821
  {
42822
- "@id": "#216"
42822
+ "@id": "#219"
42823
42823
  }
42824
42824
  ],
42825
42825
  "doc:root": false,
@@ -43478,7 +43478,7 @@
43478
43478
  "doc:ExternalDomainElement",
43479
43479
  "doc:DomainElement"
43480
43480
  ],
43481
- "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43481
+ "doc:raw": "code: '5'\ndescription: 'Limited company'\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": "code: '5'\ndescription: 'Limited company'\n",
43502
+ "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43503
43503
  "core:mediaType": "application/yaml",
43504
43504
  "sourcemaps:sources": [
43505
43505
  {
@@ -44232,7 +44232,7 @@
44232
44232
  "doc:ExternalDomainElement",
44233
44233
  "doc:DomainElement"
44234
44234
  ],
44235
- "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
44235
+ "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '22'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)22 000000'\n",
44236
44236
  "core:mediaType": "application/yaml",
44237
44237
  "sourcemaps:sources": [
44238
44238
  {
@@ -44274,7 +44274,7 @@
44274
44274
  "doc:ExternalDomainElement",
44275
44275
  "doc:DomainElement"
44276
44276
  ],
44277
- "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
44277
+ "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\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'\ncountryDialCode : '+32'\nareaCode : '22'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)22 000000'\n",
44298
+ "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
44299
44299
  "core:mediaType": "application/yaml",
44300
44300
  "sourcemaps:sources": [
44301
44301
  {
@@ -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)-(5,0)]"
44769
+ "sourcemaps:value": "[(1,0)-(3,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)-(3,0)]"
44774
+ "sourcemaps:value": "[(1,0)-(5,0)]"
44775
44775
  },
44776
44776
  {
44777
44777
  "@id": "#205/source-map/lexical/element_0",
@@ -45126,12 +45126,12 @@
45126
45126
  {
45127
45127
  "@id": "#218/source-map/lexical/element_0",
45128
45128
  "sourcemaps:element": "amf://id#218",
45129
- "sourcemaps:value": "[(1,0)-(3,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)-(6,0)]"
45134
+ "sourcemaps:value": "[(1,0)-(3,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.52",
4
+ "version": "0.18.54",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -26,7 +26,7 @@ export type IShapeUnion =
26
26
 
27
27
  export interface IApiAssociationShape {
28
28
  /**
29
- * This is custom property not available in AMF and used with data associations.
29
+ * This is a custom property that not available in the AMF library and is used with data associations.
30
30
  *
31
31
  * Whether the target entity should be embedded under the property name.
32
32
  * When false, this association is just an information that one entity depend on another.
@@ -71,6 +71,12 @@ export enum SemanticType {
71
71
  * we may add more automation related to the `title` property in the future.
72
72
  */
73
73
  Title = 'Semantic#Title',
74
+ /**
75
+ * A semantic that describes a name of a person or pet. This semantic is used with
76
+ * the `PublicUniqueName` to determine which field is responsible for the slug generation. However,
77
+ * we may add more automation related to the `name` property in the future.
78
+ */
79
+ Name = 'Semantic#Name',
74
80
  /**
75
81
  * Designates a Data Property as the `role` of a user within the system.
76
82
  * This is used to define the user's permissions and access levels.
@@ -314,9 +320,13 @@ export enum SemanticOperation {
314
320
  Update = 'Update',
315
321
  Delete = 'Delete',
316
322
  /**
317
- * Special operation for list/query operations
323
+ * Special operation for list operations
318
324
  */
319
325
  List = 'List',
326
+ /**
327
+ * Special operation for search operations
328
+ */
329
+ Search = 'Search',
320
330
  }
321
331
 
322
332
  /**
@@ -814,6 +824,19 @@ export const DataSemantics: Record<SemanticType, DataSemantic> = {
814
824
  operations: [],
815
825
  },
816
826
  },
827
+ [SemanticType.Name]: {
828
+ id: SemanticType.Name,
829
+ displayName: 'Name',
830
+ scope: SemanticScope.Property,
831
+ description: 'A person or pet name',
832
+ category: SemanticCategory.Content,
833
+ applicableDataTypes: ['string'],
834
+ hasConfig: false,
835
+ runtime: {
836
+ timing: SemanticTiming.None,
837
+ operations: [],
838
+ },
839
+ },
817
840
  [SemanticType.Description]: {
818
841
  id: SemanticType.Description,
819
842
  displayName: 'Description',
@@ -29,6 +29,8 @@ export function addAutoField(entity: DomainEntity, autoField: string): DomainEle
29
29
  return addEmailField(entity)
30
30
  case 'name':
31
31
  return addNameField(entity)
32
+ case 'display-name':
33
+ return addDisplayNameField(entity)
32
34
  case 'description':
33
35
  return addDescriptionField(entity)
34
36
  case 'status':
@@ -49,6 +51,8 @@ export function addAutoField(entity: DomainEntity, autoField: string): DomainEle
49
51
  return addIsDeletedField(entity)
50
52
  case 'deleted':
51
53
  return addDeletedAtField(entity)
54
+ case 'role':
55
+ return addRoleField(entity)
52
56
  case 'first-name':
53
57
  return addFirstNameField(entity)
54
58
  case 'last-name':
@@ -70,8 +74,12 @@ export function addAutoField(entity: DomainEntity, autoField: string): DomainEle
70
74
  case 'images':
71
75
  return addImagesField(entity)
72
76
  case 'session-id':
77
+ // This was removed from the UI. We will not support session id configuration
78
+ // as the platform will handle it to separate the business logic from the transport layer.
73
79
  return addSessionIdField(entity)
74
80
  case 'expires-at':
81
+ // This was removed from the UI. We will not support expires at configuration
82
+ // as the platform will handle it to separate the business logic from the transport layer.
75
83
  return addExpiresAtField(entity)
76
84
  case 'unit-price':
77
85
  return addUnitPriceField(entity)
@@ -198,6 +206,21 @@ export function addNameField(entity: DomainEntity, info: Partial<IThing> = {}):
198
206
  return prop
199
207
  }
200
208
 
209
+ export function addDisplayNameField(entity: DomainEntity, info: Partial<IThing> = {}): DomainProperty {
210
+ const existing = findDisplayNameField(entity, true)
211
+ if (existing) {
212
+ return existing
213
+ }
214
+ const prop = entity.addProperty({
215
+ info: { name: 'display-name', displayName: 'Display Name', ...info },
216
+ type: 'string',
217
+ })
218
+ prop.addSemantic({
219
+ id: SemanticType.Name,
220
+ })
221
+ return prop
222
+ }
223
+
201
224
  /**
202
225
  * Adds a description field to the specified entity.
203
226
  * If a description field already exists, it returns the existing field.
@@ -472,6 +495,24 @@ export function addDeletedAtField(entity: DomainEntity, info: Partial<IThing> =
472
495
  return prop
473
496
  }
474
497
 
498
+ export function addRoleField(entity: DomainEntity, info: Partial<IThing> = {}): DomainProperty {
499
+ const existing = findRoleField(entity, true)
500
+ if (existing) {
501
+ return existing
502
+ }
503
+ const prop = entity.addProperty({
504
+ info: { name: 'role', displayName: 'Role', ...info },
505
+ type: 'string',
506
+ required: true,
507
+ index: true,
508
+ schema: { defaultValue: { type: 'literal', value: 'user' }, enum: ['user', 'admin'] },
509
+ })
510
+ prop.addSemantic({
511
+ id: SemanticType.UserRole,
512
+ })
513
+ return prop
514
+ }
515
+
475
516
  /**
476
517
  * Adds an is_deleted field to the specified entity.
477
518
  * If an is_deleted field already exists, it returns the existing field.
@@ -1134,6 +1175,10 @@ function findNameField(entity: DomainEntity, direct = false): DomainProperty | u
1134
1175
  return findPropertyField(entity, (property) => property.hasSemantic(SemanticType.Title), direct)
1135
1176
  }
1136
1177
 
1178
+ function findDisplayNameField(entity: DomainEntity, direct = false): DomainProperty | undefined {
1179
+ return findPropertyField(entity, (property) => property.hasSemantic(SemanticType.Name), direct)
1180
+ }
1181
+
1137
1182
  function findDescriptionField(entity: DomainEntity, direct = false): DomainProperty | undefined {
1138
1183
  return findPropertyField(entity, (property) => property.hasSemantic(SemanticType.Description), direct)
1139
1184
  }
@@ -1196,6 +1241,10 @@ function findDeletedAtField(entity: DomainEntity, direct = false): DomainPropert
1196
1241
  )
1197
1242
  }
1198
1243
 
1244
+ function findRoleField(entity: DomainEntity, direct = false): DomainProperty | undefined {
1245
+ return findPropertyField(entity, (property) => property.hasSemantic(SemanticType.UserRole), direct)
1246
+ }
1247
+
1199
1248
  function findIsDeletedField(entity: DomainEntity, direct = false): DomainProperty | undefined {
1200
1249
  return findPropertyField(entity, (property) => property.hasSemantic(SemanticType.DeletedFlag), direct)
1201
1250
  }
@@ -32,6 +32,8 @@ import {
32
32
  addUnitPriceField,
33
33
  addCurrencyAmountField,
34
34
  addRecommendedFields,
35
+ addDisplayNameField,
36
+ addRoleField,
35
37
  } from '../../../../src/modeling/helpers/Intelisense.js'
36
38
  import { SemanticType } from '../../../../src/modeling/Semantics.js'
37
39
 
@@ -402,6 +404,33 @@ test.group('addNameField()', () => {
402
404
  })
403
405
  })
404
406
 
407
+ test.group('addDisplayNameField()', () => {
408
+ test('creates new display name field when none exists', ({ assert }) => {
409
+ const entity = createTestEntity()
410
+ const field = addDisplayNameField(entity) as DomainProperty
411
+ assert.instanceOf(field, DomainProperty)
412
+ assert.equal(field.info.name, 'display-name')
413
+ assert.equal(field.info.displayName, 'Display Name')
414
+ assert.equal(field.type, 'string')
415
+ assert.isTrue(field.semantics.length > 0)
416
+ })
417
+
418
+ test('returns existing display name field when one exists', ({ assert }) => {
419
+ const entity = createTestEntity()
420
+ const firstField = addDisplayNameField(entity) as DomainProperty
421
+ const secondField = addDisplayNameField(entity) as DomainProperty
422
+ assert.equal(firstField, secondField)
423
+ assert.lengthOf([...entity.properties], 1)
424
+ })
425
+
426
+ test('adds semantic annotation', ({ assert }) => {
427
+ const entity = createTestEntity()
428
+ const field = addDisplayNameField(entity) as DomainProperty
429
+ const hasSemantic = field.hasSemantic(SemanticType.Name)
430
+ assert.isTrue(hasSemantic)
431
+ })
432
+ })
433
+
405
434
  test.group('addDescriptionField()', () => {
406
435
  test('creates new description field when none exists', ({ assert }) => {
407
436
  const entity = createTestEntity()
@@ -568,6 +597,36 @@ test.group('addDeletedAtField()', () => {
568
597
  })
569
598
  })
570
599
 
600
+ test.group('addRoleField()', () => {
601
+ test('creates new role field when none exists', ({ assert }) => {
602
+ const entity = createTestEntity()
603
+ const field = addRoleField(entity)
604
+ assert.instanceOf(field, DomainProperty)
605
+ assert.equal(field.info.name, 'role')
606
+ assert.equal(field.info.displayName, 'Role')
607
+ assert.equal(field.type, 'string')
608
+ assert.isTrue(field.index)
609
+ assert.deepEqual(field.schema?.defaultValue, { type: 'literal', value: 'user' })
610
+ assert.deepEqual(field.schema?.enum, ['user', 'admin'])
611
+ assert.isTrue(field.hasSemantic(SemanticType.UserRole))
612
+ })
613
+
614
+ test('returns existing role field when one exists', ({ assert }) => {
615
+ const entity = createTestEntity()
616
+ const firstField = addRoleField(entity)
617
+ const secondField = addRoleField(entity)
618
+ assert.equal(firstField, secondField)
619
+ assert.lengthOf([...entity.properties], 1)
620
+ })
621
+
622
+ test('merges custom info with defaults', ({ assert }) => {
623
+ const entity = createTestEntity()
624
+ const field = addRoleField(entity, { description: 'User role' })
625
+ assert.equal(field.info.name, 'role')
626
+ assert.equal(field.info.description, 'User role')
627
+ })
628
+ })
629
+
571
630
  test.group('addIsDeletedField()', () => {
572
631
  test('creates new is deleted field when none exists', ({ assert }) => {
573
632
  const entity = createTestEntity()