@api-client/core 0.17.1 → 0.17.3
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.
- package/build/src/modeling/Semantics.d.ts +4 -5
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +8 -2
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +12 -12
- package/package.json +1 -1
- package/src/modeling/Semantics.ts +15 -1
- package/tests/unit/modeling/semantics.spec.ts +77 -0
|
@@ -42062,10 +42062,10 @@
|
|
|
42062
42062
|
"@id": "#209"
|
|
42063
42063
|
},
|
|
42064
42064
|
{
|
|
42065
|
-
"@id": "#
|
|
42065
|
+
"@id": "#191"
|
|
42066
42066
|
},
|
|
42067
42067
|
{
|
|
42068
|
-
"@id": "#
|
|
42068
|
+
"@id": "#194"
|
|
42069
42069
|
},
|
|
42070
42070
|
{
|
|
42071
42071
|
"@id": "#197"
|
|
@@ -42816,10 +42816,10 @@
|
|
|
42816
42816
|
"@id": "#213"
|
|
42817
42817
|
},
|
|
42818
42818
|
{
|
|
42819
|
-
"@id": "#
|
|
42819
|
+
"@id": "#216"
|
|
42820
42820
|
},
|
|
42821
42821
|
{
|
|
42822
|
-
"@id": "#
|
|
42822
|
+
"@id": "#219"
|
|
42823
42823
|
}
|
|
42824
42824
|
],
|
|
42825
42825
|
"doc:root": false,
|
|
@@ -43436,7 +43436,7 @@
|
|
|
43436
43436
|
"doc:ExternalDomainElement",
|
|
43437
43437
|
"doc:DomainElement"
|
|
43438
43438
|
],
|
|
43439
|
-
"doc:raw": "
|
|
43439
|
+
"doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
|
|
43440
43440
|
"core:mediaType": "application/yaml",
|
|
43441
43441
|
"sourcemaps:sources": [
|
|
43442
43442
|
{
|
|
@@ -43457,7 +43457,7 @@
|
|
|
43457
43457
|
"doc:ExternalDomainElement",
|
|
43458
43458
|
"doc:DomainElement"
|
|
43459
43459
|
],
|
|
43460
|
-
"doc:raw": "
|
|
43460
|
+
"doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
|
|
43461
43461
|
"core:mediaType": "application/yaml",
|
|
43462
43462
|
"sourcemaps:sources": [
|
|
43463
43463
|
{
|
|
@@ -44274,7 +44274,7 @@
|
|
|
44274
44274
|
"doc:ExternalDomainElement",
|
|
44275
44275
|
"doc:DomainElement"
|
|
44276
44276
|
],
|
|
44277
|
-
"doc:raw": "type:
|
|
44277
|
+
"doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\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": "
|
|
44298
|
+
"doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
|
|
44299
44299
|
"core:mediaType": "application/yaml",
|
|
44300
44300
|
"sourcemaps:sources": [
|
|
44301
44301
|
{
|
|
@@ -44756,12 +44756,12 @@
|
|
|
44756
44756
|
{
|
|
44757
44757
|
"@id": "#193/source-map/lexical/element_0",
|
|
44758
44758
|
"sourcemaps:element": "amf://id#193",
|
|
44759
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44759
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
44760
44760
|
},
|
|
44761
44761
|
{
|
|
44762
44762
|
"@id": "#196/source-map/lexical/element_0",
|
|
44763
44763
|
"sourcemaps:element": "amf://id#196",
|
|
44764
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44764
|
+
"sourcemaps:value": "[(1,0)-(10,0)]"
|
|
44765
44765
|
},
|
|
44766
44766
|
{
|
|
44767
44767
|
"@id": "#199/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)-(
|
|
45129
|
+
"sourcemaps:value": "[(1,0)-(7,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)-(
|
|
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,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-redeclare */
|
|
1
2
|
/* eslint-disable max-len */
|
|
2
3
|
import type { DomainPropertyType } from './DataFormat.js'
|
|
3
4
|
|
|
@@ -609,11 +610,20 @@ export const DataSemantics: Record<SemanticType, DataSemantic> = {
|
|
|
609
610
|
},
|
|
610
611
|
}
|
|
611
612
|
|
|
613
|
+
export function getSemanticsByCategory(): Record<SemanticCategory, DataSemantic[]>
|
|
614
|
+
export function getSemanticsByCategory(scope: SemanticScope.Entity): Record<SemanticCategory, EntitySemantic[]>
|
|
615
|
+
export function getSemanticsByCategory(scope: SemanticScope.Property): Record<SemanticCategory, PropertySemantic[]>
|
|
616
|
+
export function getSemanticsByCategory(
|
|
617
|
+
scope: SemanticScope.Association
|
|
618
|
+
): Record<SemanticCategory, AssociationSemantic[]>
|
|
619
|
+
|
|
612
620
|
/**
|
|
613
621
|
* Helper function to get all semantics grouped by category.
|
|
614
622
|
* Useful for organizing semantics in UI dropdowns and forms.
|
|
623
|
+
*
|
|
624
|
+
* @param scope Optional scope to filter semantics by (Entity, Property, Association)
|
|
615
625
|
*/
|
|
616
|
-
export
|
|
626
|
+
export function getSemanticsByCategory(scope?: SemanticScope): Record<SemanticCategory, DataSemantic[]> {
|
|
617
627
|
const result: Record<SemanticCategory, DataSemantic[]> = {
|
|
618
628
|
[SemanticCategory.Identity]: [],
|
|
619
629
|
[SemanticCategory.Lifecycle]: [],
|
|
@@ -626,6 +636,10 @@ export const getSemanticsByCategory = (): Record<SemanticCategory, DataSemantic[
|
|
|
626
636
|
}
|
|
627
637
|
|
|
628
638
|
Object.values(DataSemantics).forEach((semantic) => {
|
|
639
|
+
// If a scope is provided, filter semantics by that scope
|
|
640
|
+
if (scope && semantic.scope !== scope) {
|
|
641
|
+
return
|
|
642
|
+
}
|
|
629
643
|
result[semantic.category].push(semantic)
|
|
630
644
|
})
|
|
631
645
|
|
|
@@ -247,6 +247,83 @@ test.group('Semantics', () => {
|
|
|
247
247
|
assert.equal(totalSemantics, allSemantics, 'All semantics should be categorized')
|
|
248
248
|
})
|
|
249
249
|
|
|
250
|
+
test('getSemanticsByCategory should filter by Entity scope', ({ assert }) => {
|
|
251
|
+
const semanticsByCategory = getSemanticsByCategory(SemanticScope.Entity)
|
|
252
|
+
const allEntitySemantics = Object.values(DataSemantics).filter((s) => s.scope === SemanticScope.Entity)
|
|
253
|
+
|
|
254
|
+
// Ensure only Entity scope semantics are present
|
|
255
|
+
Object.values(semanticsByCategory).forEach((categorySemantics) => {
|
|
256
|
+
categorySemantics.forEach((semantic) => {
|
|
257
|
+
assert.equal(semantic.scope, SemanticScope.Entity, 'Only Entity semantics should be returned')
|
|
258
|
+
})
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
// Ensure all Entity scope semantics are returned
|
|
262
|
+
const returnedEntitySemantics = Object.values(semanticsByCategory).flat()
|
|
263
|
+
assert.equal(returnedEntitySemantics.length, allEntitySemantics.length, 'All Entity semantics should be returned')
|
|
264
|
+
allEntitySemantics.forEach((expectedSemantic) => {
|
|
265
|
+
assert.include(
|
|
266
|
+
returnedEntitySemantics,
|
|
267
|
+
expectedSemantic,
|
|
268
|
+
`Expected Entity semantic ${expectedSemantic.id} not found`
|
|
269
|
+
)
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
test('getSemanticsByCategory should filter by Property scope', ({ assert }) => {
|
|
274
|
+
const semanticsByCategory = getSemanticsByCategory(SemanticScope.Property)
|
|
275
|
+
const allPropertySemantics = Object.values(DataSemantics).filter((s) => s.scope === SemanticScope.Property)
|
|
276
|
+
|
|
277
|
+
// Ensure only Property scope semantics are present
|
|
278
|
+
Object.values(semanticsByCategory).forEach((categorySemantics) => {
|
|
279
|
+
categorySemantics.forEach((semantic) => {
|
|
280
|
+
assert.equal(semantic.scope, SemanticScope.Property, 'Only Property semantics should be returned')
|
|
281
|
+
})
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
// Ensure all Property scope semantics are returned
|
|
285
|
+
const returnedPropertySemantics = Object.values(semanticsByCategory).flat()
|
|
286
|
+
assert.equal(
|
|
287
|
+
returnedPropertySemantics.length,
|
|
288
|
+
allPropertySemantics.length,
|
|
289
|
+
'All Property semantics should be returned'
|
|
290
|
+
)
|
|
291
|
+
allPropertySemantics.forEach((expectedSemantic) => {
|
|
292
|
+
assert.include(
|
|
293
|
+
returnedPropertySemantics,
|
|
294
|
+
expectedSemantic,
|
|
295
|
+
`Expected Property semantic ${expectedSemantic.id} not found`
|
|
296
|
+
)
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
test('getSemanticsByCategory should filter by Association scope', ({ assert }) => {
|
|
301
|
+
const semanticsByCategory = getSemanticsByCategory(SemanticScope.Association)
|
|
302
|
+
const allAssociationSemantics = Object.values(DataSemantics).filter((s) => s.scope === SemanticScope.Association)
|
|
303
|
+
|
|
304
|
+
// Ensure only Association scope semantics are present
|
|
305
|
+
Object.values(semanticsByCategory).forEach((categorySemantics) => {
|
|
306
|
+
categorySemantics.forEach((semantic) => {
|
|
307
|
+
assert.equal(semantic.scope, SemanticScope.Association, 'Only Association semantics should be returned')
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
// Ensure all Association scope semantics are returned
|
|
312
|
+
const returnedAssociationSemantics = Object.values(semanticsByCategory).flat()
|
|
313
|
+
assert.equal(
|
|
314
|
+
returnedAssociationSemantics.length,
|
|
315
|
+
allAssociationSemantics.length,
|
|
316
|
+
'All Association semantics should be returned'
|
|
317
|
+
)
|
|
318
|
+
allAssociationSemantics.forEach((expectedSemantic) => {
|
|
319
|
+
assert.include(
|
|
320
|
+
returnedAssociationSemantics,
|
|
321
|
+
expectedSemantic,
|
|
322
|
+
`Expected Association semantic ${expectedSemantic.id} not found`
|
|
323
|
+
)
|
|
324
|
+
})
|
|
325
|
+
})
|
|
326
|
+
|
|
250
327
|
test('getSemanticsByCategoryType should filter semantics by category', ({ assert }) => {
|
|
251
328
|
const identitySemantics = getSemanticsByCategoryType(SemanticCategory.Identity)
|
|
252
329
|
|