@api-client/core 0.14.0 → 0.14.1

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 (140) hide show
  1. package/build/src/amf/AmfTypes.d.ts +1 -1
  2. package/build/src/amf/AmfTypes.js +1 -1
  3. package/build/src/amf/AmfTypes.js.map +1 -1
  4. package/build/src/amf/Utils.d.ts +0 -6
  5. package/build/src/amf/Utils.d.ts.map +1 -1
  6. package/build/src/amf/Utils.js +0 -14
  7. package/build/src/amf/Utils.js.map +1 -1
  8. package/build/src/browser.d.ts +1 -0
  9. package/build/src/browser.d.ts.map +1 -1
  10. package/build/src/browser.js +1 -0
  11. package/build/src/browser.js.map +1 -1
  12. package/build/src/index.d.ts +1 -0
  13. package/build/src/index.d.ts.map +1 -1
  14. package/build/src/index.js +1 -0
  15. package/build/src/index.js.map +1 -1
  16. package/build/src/legacy.d.ts +0 -8
  17. package/build/src/legacy.d.ts.map +1 -1
  18. package/build/src/legacy.js +0 -9
  19. package/build/src/legacy.js.map +1 -1
  20. package/build/src/modeling/Bindings.d.ts +1 -1
  21. package/build/src/modeling/Bindings.js.map +1 -1
  22. package/build/src/modeling/DataDomain.js +2 -2
  23. package/build/src/modeling/DataDomain.js.map +1 -1
  24. package/build/src/modeling/DataFormat.d.ts +0 -40
  25. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  26. package/build/src/modeling/DataFormat.js +0 -27
  27. package/build/src/modeling/DataFormat.js.map +1 -1
  28. package/build/src/modeling/DomainAssociation.d.ts +28 -0
  29. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  30. package/build/src/modeling/DomainAssociation.js +73 -4
  31. package/build/src/modeling/DomainAssociation.js.map +1 -1
  32. package/build/src/modeling/DomainEntity.d.ts +25 -9
  33. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  34. package/build/src/modeling/DomainEntity.js +65 -21
  35. package/build/src/modeling/DomainEntity.js.map +1 -1
  36. package/build/src/modeling/DomainFile.d.ts +1 -1
  37. package/build/src/modeling/DomainFile.js +1 -1
  38. package/build/src/modeling/DomainFile.js.map +1 -1
  39. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  42. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  43. package/build/src/modeling/DomainModel.d.ts +2 -2
  44. package/build/src/modeling/DomainModel.js +2 -2
  45. package/build/src/modeling/DomainModel.js.map +1 -1
  46. package/build/src/modeling/DomainProperty.d.ts +28 -12
  47. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  48. package/build/src/modeling/DomainProperty.js +61 -26
  49. package/build/src/modeling/DomainProperty.js.map +1 -1
  50. package/build/src/modeling/Semantics.d.ts +109 -0
  51. package/build/src/modeling/Semantics.d.ts.map +1 -0
  52. package/build/src/modeling/Semantics.js +97 -0
  53. package/build/src/modeling/Semantics.js.map +1 -0
  54. package/build/src/models/kinds.d.ts +0 -24
  55. package/build/src/models/kinds.d.ts.map +1 -1
  56. package/build/src/models/kinds.js +0 -24
  57. package/build/src/models/kinds.js.map +1 -1
  58. package/build/src/models/store/data_catalog.d.ts +1 -1
  59. package/build/src/models/store/data_catalog.js.map +1 -1
  60. package/build/tsconfig.tsbuildinfo +1 -1
  61. package/data/models/example-generator-api.json +11 -11
  62. package/package.json +1 -1
  63. package/src/amf/AmfTypes.ts +1 -1
  64. package/src/amf/Utils.ts +0 -15
  65. package/src/modeling/Bindings.ts +1 -1
  66. package/src/modeling/DataDomain.ts +2 -2
  67. package/src/modeling/DataFormat.ts +0 -48
  68. package/src/modeling/DomainAssociation.ts +66 -3
  69. package/src/modeling/DomainEntity.ts +56 -17
  70. package/src/modeling/DomainFile.ts +1 -1
  71. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  72. package/src/modeling/DomainModel.ts +2 -2
  73. package/src/modeling/DomainProperty.ts +60 -21
  74. package/src/modeling/Semantics.ts +178 -0
  75. package/src/modeling/graph.md +14 -14
  76. package/src/modeling/readme.md +29 -29
  77. package/src/models/kinds.ts +0 -25
  78. package/src/models/store/data_catalog.ts +1 -1
  79. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  80. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  81. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  82. package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
  83. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  84. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  85. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  86. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  87. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  88. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  89. package/build/src/amf/AmfShapeGenerator.js +0 -416
  90. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  91. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  92. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  93. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  94. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  95. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  96. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  97. package/build/src/modeling/legacy/DataEntity.js +0 -855
  98. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  99. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  100. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  101. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  102. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  103. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  104. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  105. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  106. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  107. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  108. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  109. package/build/src/modeling/legacy/DataModel.js +0 -237
  110. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  111. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  112. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  113. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  114. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  115. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  116. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  117. package/build/src/modeling/legacy/DataProperty.js +0 -415
  118. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  119. package/build/src/models/store/DataFile.d.ts +0 -29
  120. package/build/src/models/store/DataFile.d.ts.map +0 -1
  121. package/build/src/models/store/DataFile.js +0 -87
  122. package/build/src/models/store/DataFile.js.map +0 -1
  123. package/src/amf/AmfShapeGenerator.ts +0 -477
  124. package/src/modeling/legacy/DataAssociation.ts +0 -554
  125. package/src/modeling/legacy/DataEntity.ts +0 -1019
  126. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  127. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  128. package/src/modeling/legacy/DataModel.ts +0 -276
  129. package/src/modeling/legacy/DataNamespace.ts +0 -929
  130. package/src/modeling/legacy/DataProperty.ts +0 -630
  131. package/src/models/store/DataFile.ts +0 -95
  132. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  133. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  134. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  135. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  136. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  137. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  138. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  139. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  140. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -41728,16 +41728,16 @@
41728
41728
  "@id": "#194"
41729
41729
  },
41730
41730
  {
41731
- "@id": "#197"
41731
+ "@id": "#200"
41732
41732
  },
41733
41733
  {
41734
- "@id": "#206"
41734
+ "@id": "#197"
41735
41735
  },
41736
41736
  {
41737
- "@id": "#200"
41737
+ "@id": "#203"
41738
41738
  },
41739
41739
  {
41740
- "@id": "#203"
41740
+ "@id": "#206"
41741
41741
  },
41742
41742
  {
41743
41743
  "@id": "#209"
@@ -43138,7 +43138,7 @@
43138
43138
  "doc:ExternalDomainElement",
43139
43139
  "doc:DomainElement"
43140
43140
  ],
43141
- "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43141
+ "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43142
43142
  "core:mediaType": "application/yaml",
43143
43143
  "sourcemaps:sources": [
43144
43144
  {
@@ -43159,7 +43159,7 @@
43159
43159
  "doc:ExternalDomainElement",
43160
43160
  "doc:DomainElement"
43161
43161
  ],
43162
- "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43162
+ "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43163
43163
  "core:mediaType": "application/yaml",
43164
43164
  "sourcemaps:sources": [
43165
43165
  {
@@ -43180,7 +43180,7 @@
43180
43180
  "doc:ExternalDomainElement",
43181
43181
  "doc:DomainElement"
43182
43182
  ],
43183
- "doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
43183
+ "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43184
43184
  "core:mediaType": "application/yaml",
43185
43185
  "sourcemaps:sources": [
43186
43186
  {
@@ -43201,7 +43201,7 @@
43201
43201
  "doc:ExternalDomainElement",
43202
43202
  "doc:DomainElement"
43203
43203
  ],
43204
- "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43204
+ "doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
43205
43205
  "core:mediaType": "application/yaml",
43206
43206
  "sourcemaps:sources": [
43207
43207
  {
@@ -44426,7 +44426,7 @@
44426
44426
  {
44427
44427
  "@id": "#199/source-map/lexical/element_0",
44428
44428
  "sourcemaps:element": "amf://id#199",
44429
- "sourcemaps:value": "[(1,0)-(3,0)]"
44429
+ "sourcemaps:value": "[(1,0)-(5,0)]"
44430
44430
  },
44431
44431
  {
44432
44432
  "@id": "#202/source-map/lexical/element_0",
@@ -44436,12 +44436,12 @@
44436
44436
  {
44437
44437
  "@id": "#205/source-map/lexical/element_0",
44438
44438
  "sourcemaps:element": "amf://id#205",
44439
- "sourcemaps:value": "[(1,0)-(6,0)]"
44439
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44440
44440
  },
44441
44441
  {
44442
44442
  "@id": "#208/source-map/lexical/element_0",
44443
44443
  "sourcemaps:element": "amf://id#208",
44444
- "sourcemaps:value": "[(1,0)-(5,0)]"
44444
+ "sourcemaps:value": "[(1,0)-(6,0)]"
44445
44445
  },
44446
44446
  {
44447
44447
  "@id": "#223/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.14.0",
4
+ "version": "0.14.1",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -103,7 +103,7 @@ export const IAmfExampleTypes = [
103
103
  ]
104
104
 
105
105
  /**
106
- * Translates the DataProperty type to an AMF data type.
106
+ * Translates the DomainProperty type to an AMF data type.
107
107
  * @param type The property data type
108
108
  * @returns AMF shape dataType
109
109
  */
package/src/amf/Utils.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { UrlEncoder } from '../lib/parsers/UrlEncoder.js'
2
1
  import { AmfNamespace } from './definitions/Namespace.js'
3
2
  import { IApiNodeShape, IApiPropertyShape, IShapeUnion, IApiUnionShape } from './definitions/Shapes.js'
4
3
 
@@ -45,20 +44,6 @@ export function formatXmlValue(fill: string, value: unknown): string {
45
44
  return formatted
46
45
  }
47
46
 
48
- /**
49
- * @param str A key or value to encode as x-www-form-urlencoded.
50
- * @param replacePlus When set it replaces `%20` with `+`.
51
- * @deprecated Use `UrlEncoder.encodeQueryString()` instead.
52
- */
53
- export function wwwFormUrlEncode(str: string, replacePlus?: boolean): string {
54
- // Spec says to normalize newlines to \r\n and replace %20 spaces with +.
55
- // jQuery does this as well, so this is likely to be widely compatible.
56
- if (str === undefined) {
57
- return ''
58
- }
59
- return UrlEncoder.encodeQueryString(String(str), replacePlus)
60
- }
61
-
62
47
  /**
63
48
  * Processes a value that should be a number.
64
49
  */
@@ -139,7 +139,7 @@ export type PropertyBindings = PropertyWebBindings | PropertyProtobufBindings
139
139
  export interface PropertyBinding extends Binding {
140
140
  /**
141
141
  * The definition of the bindings.
142
- * The bindings tells how to translated the DataProperty to a specific format.
142
+ * The bindings tells how to translated the DomainProperty to a specific format.
143
143
  * For example, it allows to define the `dataType` and `format` for RAML / OAS (via the AMF shapes)
144
144
  * or the field number for protocol buffer.
145
145
  */
@@ -800,7 +800,7 @@ export class DataDomain extends EventTarget {
800
800
  */
801
801
  addEntity(parent: string, input?: Partial<DomainEntitySchema>): DomainEntity {
802
802
  if (!parent) {
803
- throw new Error(`An entity expects a DataModel parent`)
803
+ throw new Error(`An entity expects a DomainModel parent`)
804
804
  }
805
805
  if (!this.graph.hasNode(parent)) {
806
806
  throw new Error(`The parent ${parent} does not exist`)
@@ -1047,7 +1047,7 @@ export class DataDomain extends EventTarget {
1047
1047
  */
1048
1048
  addProperty(parent: string, property?: Partial<DomainPropertySchema>): DomainProperty {
1049
1049
  if (!parent) {
1050
- throw new Error(`A property expects a DataEntity parent`)
1050
+ throw new Error(`A property expects a DomainEntity parent`)
1051
1051
  }
1052
1052
  if (!this.graph.hasNode(parent)) {
1053
1053
  throw new Error(`Parent entity ${parent} does not exist`)
@@ -9,11 +9,6 @@ export type DomainPropertyType =
9
9
  // | 'any'
10
10
  | 'binary'
11
11
 
12
- /**
13
- * @deprecated Use the {@link DomainPropertyType} instead.
14
- */
15
- export type DataPropertyType = DomainPropertyType
16
-
17
12
  export const DomainPropertyTypes: DomainPropertyType[] = [
18
13
  'string',
19
14
  'number',
@@ -36,11 +31,6 @@ export const DomainPropertyTypes: DomainPropertyType[] = [
36
31
  'binary',
37
32
  ]
38
33
 
39
- /**
40
- * @deprecated Use the {@link DomainPropertyTypes} instead.
41
- */
42
- export const DataPropertyTypes: DataPropertyType[] = DomainPropertyTypes
43
-
44
34
  export enum DomainPropertyList {
45
35
  string = 'string',
46
36
  number = 'number',
@@ -53,21 +43,6 @@ export enum DomainPropertyList {
53
43
  file = 'binary',
54
44
  }
55
45
 
56
- /**
57
- * @deprecated Use the {@link DomainPropertyList} instead.
58
- */
59
- export enum DataPropertyList {
60
- string = 'string',
61
- number = 'number',
62
- // nil = 'nil',
63
- boolean = 'boolean',
64
- date = 'date',
65
- datetime = 'datetime',
66
- time = 'time',
67
- // any = 'any',
68
- file = 'binary',
69
- }
70
-
71
46
  /**
72
47
  * The data property "attributes".
73
48
  */
@@ -80,11 +55,6 @@ export type DomainPropertyAttribute =
80
55
  | 'writeOnly'
81
56
  | 'deprecated'
82
57
 
83
- /**
84
- * @deprecated Use the {@link DomainPropertyAttribute} instead.
85
- */
86
- export type DataPropertyAttribute = DomainPropertyAttribute
87
-
88
58
  export const DomainPropertyAttributes: DomainPropertyAttribute[] = [
89
59
  'required',
90
60
  'multiple',
@@ -95,26 +65,12 @@ export const DomainPropertyAttributes: DomainPropertyAttribute[] = [
95
65
  'deprecated',
96
66
  ]
97
67
 
98
- /**
99
- * @deprecated Use the {@link DomainPropertyAttributes} instead.
100
- */
101
- export const DataPropertyAttributes: DataPropertyAttribute[] = DomainPropertyAttributes
102
-
103
68
  /**
104
69
  * The data attribute "attributes".
105
70
  */
106
71
  export type DomainAttributeAttribute = 'required' | 'multiple'
107
72
 
108
- /**
109
- * @deprecated Use the {@link DomainAttributeAttribute} instead.
110
- */
111
- export type DataAttributeAttribute = DomainAttributeAttribute
112
-
113
73
  export const DomainAttributeAttributes: DomainAttributeAttribute[] = ['required', 'multiple']
114
- /**
115
- * @deprecated Use the {@link DomainAttributeAttributes} instead.
116
- */
117
- export const DataAttributeAttributes: DataAttributeAttribute[] = DomainAttributeAttributes
118
74
 
119
75
  /**
120
76
  * Note, OAS supports the `integer` data type and not format.
@@ -138,7 +94,3 @@ export type BinaryFormat = 'hex' | 'base64'
138
94
  export const BinaryFormats: BinaryFormat[] = ['hex', 'base64']
139
95
 
140
96
  export type DomainPropertyFormat = NumberFormat | BinaryFormat
141
- /**
142
- * @deprecated Use the {@link DomainPropertyFormat} instead.
143
- */
144
- export type DataPropertyFormat = NumberFormat | BinaryFormat
@@ -10,6 +10,7 @@ import type { AssociationBinding, AssociationBindings, AssociationWebBindings }
10
10
  import { DomainAttributeAttribute, DomainAttributeAttributes } from './DataFormat.js'
11
11
  import type { AssociationTarget, DomainGraphEdge } from './types.js'
12
12
  import { ShapeGenerator } from './amf/ShapeGenerator.js'
13
+ import { DataSemantics, isAssociationSemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'
13
14
 
14
15
  export interface DomainAssociationSchema extends DomainElementSchema {
15
16
  kind: typeof DomainAssociationKind
@@ -47,6 +48,12 @@ export interface DomainAssociationSchema extends DomainElementSchema {
47
48
  * When multiple associations are set then we are dealing with an union.
48
49
  */
49
50
  targets?: AssociationTarget[]
51
+ /**
52
+ * The semantics applied to this association.
53
+ * This is a list of applied semantics that can be used to
54
+ * describe the association in more detail.
55
+ */
56
+ semantics?: AppliedDataSemantic[]
50
57
  }
51
58
 
52
59
  /**
@@ -141,6 +148,11 @@ export class DomainAssociation extends DomainElement {
141
148
  */
142
149
  @observed({ deep: true }) accessor targets: AssociationTarget[]
143
150
 
151
+ /**
152
+ * Semantics applied to this association.
153
+ */
154
+ @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []
155
+
144
156
  /**
145
157
  * Creates a full data association schema with defaults.
146
158
  *
@@ -148,13 +160,16 @@ export class DomainAssociation extends DomainElement {
148
160
  * @returns The data association schema.
149
161
  */
150
162
  static createSchema(input: Partial<DomainAssociationSchema> = {}): DomainAssociationSchema {
151
- const { key = nanoid() } = input
163
+ const { key = nanoid(), semantics = [] } = input
152
164
  const info = Thing.fromJSON(input.info, { name: 'new_association' }).toJSON()
153
165
  const result: DomainAssociationSchema = {
154
166
  kind: DomainAssociationKind,
155
167
  key,
156
168
  info,
157
169
  }
170
+ if (Array.isArray(semantics)) {
171
+ result.semantics = [...semantics]
172
+ }
158
173
  if (input.schema) {
159
174
  result.schema = structuredClone(input.schema)
160
175
  }
@@ -207,6 +222,11 @@ export class DomainAssociation extends DomainElement {
207
222
  } else {
208
223
  this.targets = []
209
224
  }
225
+ if (Array.isArray(init.semantics)) {
226
+ this.semantics = init.semantics.map((item) => structuredClone(item))
227
+ } else {
228
+ this.semantics = []
229
+ }
210
230
  }
211
231
 
212
232
  /**
@@ -230,10 +250,13 @@ export class DomainAssociation extends DomainElement {
230
250
  result.required = this.required
231
251
  }
232
252
  if (Array.isArray(this.bindings) && this.bindings.length) {
233
- result.bindings = (toRaw(this, this.bindings) as AssociationBinding[]).map((i) => structuredClone(i))
253
+ result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))
234
254
  }
235
255
  if (Array.isArray(this.targets) && this.targets.length) {
236
- result.targets = (toRaw(this, this.targets) as AssociationTarget[]).map((i) => ({ ...i }))
256
+ result.targets = toRaw(this, this.targets)?.map((i) => ({ ...i }))
257
+ }
258
+ if (Array.isArray(this.semantics) && this.semantics.length) {
259
+ result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))
237
260
  }
238
261
  return result
239
262
  }
@@ -472,4 +495,44 @@ export class DomainAssociation extends DomainElement {
472
495
  const serializer = new ShapeGenerator()
473
496
  return serializer.associationProperty(this)
474
497
  }
498
+
499
+ /**
500
+ * Adds or updates a semantic to the association.
501
+ * @param semantic The semantic to add to the association.
502
+ * @throws Error if the semantic is not an association semantic.
503
+ */
504
+ addSemantic(semantic: AppliedDataSemantic): void {
505
+ const sem = DataSemantics[semantic.id]
506
+ if (!isAssociationSemantic(sem)) {
507
+ throw new Error(`Invalid semantic type: ${semantic.id}. Expected an association semantic.`)
508
+ }
509
+ const index = this.semantics.findIndex((s) => s.id === semantic.id)
510
+ if (index >= 0) {
511
+ this.semantics[index] = semantic
512
+ } else {
513
+ this.semantics.push(semantic)
514
+ }
515
+ this.domain.notifyChange()
516
+ }
517
+
518
+ /**
519
+ * Removes a semantic from the association.
520
+ * @param semanticId The ID of the semantic to remove.
521
+ */
522
+ removeSemantic(semanticId: SemanticType): void {
523
+ const index = this.semantics.findIndex((s) => s.id === semanticId)
524
+ if (index >= 0) {
525
+ this.semantics.splice(index, 1)
526
+ this.domain.notifyChange()
527
+ }
528
+ }
529
+
530
+ /**
531
+ * Checks if the association has a specific semantic.
532
+ * @param semanticId The ID of the semantic to check.
533
+ * @returns True if the semantic is present, false otherwise.
534
+ */
535
+ hasSemantic(semanticId: SemanticType): boolean {
536
+ return this.semantics.some((s) => s.id === semanticId)
537
+ }
475
538
  }
@@ -17,6 +17,7 @@ import { ShapeGenerator } from './amf/ShapeGenerator.js'
17
17
  import type { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'
18
18
  import { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'
19
19
  import { removeGraphNode } from './GraphUtils.js'
20
+ import { DataSemantics, isEntitySemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'
20
21
 
21
22
  export interface EntityOrderedItem {
22
23
  /**
@@ -43,11 +44,11 @@ export interface DomainEntitySchema extends DomainElementSchema {
43
44
  tags?: string[]
44
45
 
45
46
  /**
46
- * For future use.
47
- *
48
- * The keys of the taxonomy items associated with the entity.
47
+ * The semantics applied to this entity.
48
+ * This is a list of applied semantics that can be used to
49
+ * describe the entity in more detail.
49
50
  */
50
- taxonomy?: string[]
51
+ semantics?: AppliedDataSemantic[]
51
52
 
52
53
  /**
53
54
  * The ordered list of fields (properties and associations) in the schema.
@@ -76,7 +77,7 @@ export interface DomainEntitySchema extends DomainElementSchema {
76
77
  * - **Properties:** Defines the data elements (fields) within the entity.
77
78
  * - **Associations:** Defines relationships to other entities.
78
79
  * - **Inheritance:** Supports inheriting properties and associations from parent entities.
79
- * - **Metadata:** Supports tags, taxonomy, and deprecation status.
80
+ * - **Metadata:** Supports tags, semantics, and deprecation status.
80
81
  * - **AMF Shape Generation:** Can be serialized to an AMF (API Modeling Framework) shape.
81
82
  * - **Example Generation:** Can generate example databased on its schema.
82
83
  *
@@ -139,11 +140,9 @@ export class DomainEntity extends DomainElement {
139
140
  @observed({ deep: true }) accessor tags: string[]
140
141
 
141
142
  /**
142
- * Reserved for future use.
143
- *
144
- * The keys of the taxonomy items associated with the entity.
143
+ * Semantics applied to this property.
145
144
  */
146
- @observed({ deep: true }) accessor taxonomy: string[]
145
+ @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []
147
146
 
148
147
  /**
149
148
  * The ordered list of fields (properties and associations) in the schema.
@@ -165,7 +164,7 @@ export class DomainEntity extends DomainElement {
165
164
  * @returns The data entity schema.
166
165
  */
167
166
  static createSchema(input: Partial<DomainEntitySchema> = {}): DomainEntitySchema {
168
- const { key = nanoid(), tags, taxonomy, fields, deprecated } = input
167
+ const { key = nanoid(), tags, semantics, fields, deprecated } = input
169
168
  const info = Thing.fromJSON(input.info, { name: 'New entity' }).toJSON()
170
169
  const result: DomainEntitySchema = {
171
170
  kind: DomainEntityKind,
@@ -175,8 +174,8 @@ export class DomainEntity extends DomainElement {
175
174
  if (Array.isArray(tags)) {
176
175
  result.tags = [...tags]
177
176
  }
178
- if (Array.isArray(taxonomy)) {
179
- result.taxonomy = [...taxonomy]
177
+ if (Array.isArray(semantics)) {
178
+ result.semantics = [...semantics]
180
179
  }
181
180
  if (Array.isArray(fields)) {
182
181
  result.fields = [...fields]
@@ -206,10 +205,10 @@ export class DomainEntity extends DomainElement {
206
205
  } else {
207
206
  this.tags = []
208
207
  }
209
- if (Array.isArray(init.taxonomy)) {
210
- this.taxonomy = [...init.taxonomy]
208
+ if (Array.isArray(init.semantics)) {
209
+ this.semantics = init.semantics.map((item) => structuredClone(item))
211
210
  } else {
212
- this.taxonomy = []
211
+ this.semantics = []
213
212
  }
214
213
  if (Array.isArray(init.fields)) {
215
214
  this.fields = [...init.fields]
@@ -235,8 +234,8 @@ export class DomainEntity extends DomainElement {
235
234
  if (Array.isArray(this.fields) && this.fields.length) {
236
235
  result.fields = [...this.fields]
237
236
  }
238
- if (Array.isArray(this.taxonomy) && this.taxonomy.length) {
239
- result.taxonomy = [...(toRaw(this, this.taxonomy) as string[])]
237
+ if (Array.isArray(this.semantics) && this.semantics.length) {
238
+ result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))
240
239
  }
241
240
  if (Array.isArray(this.tags) && this.tags.length) {
242
241
  result.tags = [...(toRaw(this, this.tags) as string[])]
@@ -841,4 +840,44 @@ export class DomainEntity extends DomainElement {
841
840
  }
842
841
  return property
843
842
  }
843
+
844
+ /**
845
+ * Adds or updates a semantic to the entity.
846
+ * @param semantic The semantic to add to the entity.
847
+ * @throws Error if the semantic is not an entity semantic.
848
+ */
849
+ addSemantic(semantic: AppliedDataSemantic): void {
850
+ const sem = DataSemantics[semantic.id]
851
+ if (!isEntitySemantic(sem)) {
852
+ throw new Error(`Invalid semantic type: ${semantic.id}. Expected an entity semantic.`)
853
+ }
854
+ const index = this.semantics.findIndex((s) => s.id === semantic.id)
855
+ if (index >= 0) {
856
+ this.semantics[index] = semantic
857
+ } else {
858
+ this.semantics.push(semantic)
859
+ }
860
+ this.domain.notifyChange()
861
+ }
862
+
863
+ /**
864
+ * Removes a semantic from the entity.
865
+ * @param semanticId The ID of the semantic to remove.
866
+ */
867
+ removeSemantic(semanticId: SemanticType): void {
868
+ const index = this.semantics.findIndex((s) => s.id === semanticId)
869
+ if (index >= 0) {
870
+ this.semantics.splice(index, 1)
871
+ this.domain.notifyChange()
872
+ }
873
+ }
874
+
875
+ /**
876
+ * Checks if the entity has a specific semantic.
877
+ * @param semanticId The ID of the semantic to check.
878
+ * @returns True if the semantic is present, false otherwise.
879
+ */
880
+ hasSemantic(semanticId: SemanticType): boolean {
881
+ return this.semantics.some((s) => s.id === semanticId)
882
+ }
844
883
  }
@@ -19,7 +19,7 @@ export class DomainFile extends File {
19
19
  }
20
20
 
21
21
  /**
22
- * Creates the file definition for a DataNamespace contents.
22
+ * Creates the file definition for a DomainNamespace contents.
23
23
  *
24
24
  * @param input The data namespace instance or schema.
25
25
  */
@@ -436,7 +436,7 @@ export class DomainImpactAnalysis {
436
436
  this.deleteNamespaceAnalysis(key, rootKey)
437
437
  break
438
438
  case DomainModelKind:
439
- this.deleteDataModelAnalysis(key, rootKey)
439
+ this.deleteModelAnalysis(key, rootKey)
440
440
  break
441
441
  case DomainEntityKind:
442
442
  this.deleteEntityAnalysis(key, rootKey)
@@ -469,11 +469,11 @@ export class DomainImpactAnalysis {
469
469
  this.deleteNamespaceAnalysis(child.key, rootKey)
470
470
  }
471
471
  for (const child of ns.listModels()) {
472
- this.deleteDataModelAnalysis(child.key, rootKey)
472
+ this.deleteModelAnalysis(child.key, rootKey)
473
473
  }
474
474
  }
475
475
 
476
- protected deleteDataModelAnalysis(key: string, rootKey: string): void {
476
+ protected deleteModelAnalysis(key: string, rootKey: string): void {
477
477
  const model = this.root.findModel(key)
478
478
  if (!model) {
479
479
  return
@@ -64,10 +64,10 @@ export interface DomainModelSchema extends DomainElementSchema {
64
64
  *
65
65
  * ```typescript
66
66
  * const dataDomain = new DataDomain();
67
- * const dataNamespace = dataDomain.addNamespace({
67
+ * const ns = dataDomain.addNamespace({
68
68
  * key: 'myNamespace',
69
69
  * });
70
- * const userModel = dataNamespace.addModel({
70
+ * const userModel = ns.addModel({
71
71
  * key: 'userModel',
72
72
  * info: { name: 'User Model' },
73
73
  * });