@api-client/core 0.13.6 → 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 (174) 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 +3 -4
  37. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  38. package/build/src/modeling/DomainFile.js +5 -9
  39. package/build/src/modeling/DomainFile.js.map +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  42. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  43. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  44. package/build/src/modeling/DomainModel.d.ts +2 -2
  45. package/build/src/modeling/DomainModel.js +2 -2
  46. package/build/src/modeling/DomainModel.js.map +1 -1
  47. package/build/src/modeling/DomainProperty.d.ts +28 -12
  48. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  49. package/build/src/modeling/DomainProperty.js +61 -26
  50. package/build/src/modeling/DomainProperty.js.map +1 -1
  51. package/build/src/modeling/Semantics.d.ts +109 -0
  52. package/build/src/modeling/Semantics.d.ts.map +1 -0
  53. package/build/src/modeling/Semantics.js +97 -0
  54. package/build/src/modeling/Semantics.js.map +1 -0
  55. package/build/src/models/CertificateFile.d.ts +2 -3
  56. package/build/src/models/CertificateFile.d.ts.map +1 -1
  57. package/build/src/models/CertificateFile.js +4 -8
  58. package/build/src/models/CertificateFile.js.map +1 -1
  59. package/build/src/models/Folder.d.ts +1 -2
  60. package/build/src/models/Folder.d.ts.map +1 -1
  61. package/build/src/models/Folder.js +2 -4
  62. package/build/src/models/Folder.js.map +1 -1
  63. package/build/src/models/Project.d.ts +2 -3
  64. package/build/src/models/Project.d.ts.map +1 -1
  65. package/build/src/models/Project.js +4 -8
  66. package/build/src/models/Project.js.map +1 -1
  67. package/build/src/models/kinds.d.ts +0 -24
  68. package/build/src/models/kinds.d.ts.map +1 -1
  69. package/build/src/models/kinds.js +0 -24
  70. package/build/src/models/kinds.js.map +1 -1
  71. package/build/src/models/store/File.d.ts +1 -21
  72. package/build/src/models/store/File.d.ts.map +1 -1
  73. package/build/src/models/store/File.js +3 -23
  74. package/build/src/models/store/File.js.map +1 -1
  75. package/build/src/models/store/data_catalog.d.ts +1 -1
  76. package/build/src/models/store/data_catalog.js.map +1 -1
  77. package/build/src/sdk/FilesSdk.js +1 -1
  78. package/build/src/sdk/FilesSdk.js.map +1 -1
  79. package/build/tsconfig.tsbuildinfo +1 -1
  80. package/data/models/example-generator-api.json +22 -22
  81. package/eslint.config.js +1 -0
  82. package/package.json +5 -5
  83. package/src/amf/AmfTypes.ts +1 -1
  84. package/src/amf/Utils.ts +0 -15
  85. package/src/modeling/Bindings.ts +1 -1
  86. package/src/modeling/DataDomain.ts +2 -2
  87. package/src/modeling/DataFormat.ts +0 -48
  88. package/src/modeling/DomainAssociation.ts +66 -3
  89. package/src/modeling/DomainEntity.ts +56 -17
  90. package/src/modeling/DomainFile.ts +5 -9
  91. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  92. package/src/modeling/DomainModel.ts +2 -2
  93. package/src/modeling/DomainProperty.ts +60 -21
  94. package/src/modeling/Semantics.ts +178 -0
  95. package/src/modeling/graph.md +14 -14
  96. package/src/modeling/readme.md +29 -29
  97. package/src/models/CertificateFile.ts +4 -12
  98. package/src/models/Folder.ts +2 -4
  99. package/src/models/Project.ts +4 -8
  100. package/src/models/kinds.ts +0 -25
  101. package/src/models/store/File.ts +4 -35
  102. package/src/models/store/data_catalog.ts +1 -1
  103. package/src/sdk/FilesSdk.ts +1 -1
  104. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  105. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  106. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  107. package/tests/unit/modeling/domain_asociation.spec.ts +177 -0
  108. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  109. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  110. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  111. package/tests/unit/modeling/domain_file.spec.ts +4 -27
  112. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  113. package/tests/unit/models/Certificate/from_name.spec.ts +3 -15
  114. package/tests/unit/models/File/constructor.spec.ts +0 -1
  115. package/tests/unit/models/File/new.spec.ts +0 -13
  116. package/tests/unit/models/File/shortcutTo.spec.ts +1 -2
  117. package/tests/unit/models/File/toJSON.spec.ts +0 -13
  118. package/tests/unit/models/File/updateByMeMeta.spec.ts +4 -6
  119. package/tests/unit/models/Folder/create.spec.ts +2 -23
  120. package/tests/unit/models/Project/create.spec.ts +6 -32
  121. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  122. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  123. package/build/src/amf/AmfShapeGenerator.js +0 -416
  124. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  125. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  126. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  127. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  128. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  129. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  130. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  131. package/build/src/modeling/legacy/DataEntity.js +0 -855
  132. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  133. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  134. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  135. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  136. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  137. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  138. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  139. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  140. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  141. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  142. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  143. package/build/src/modeling/legacy/DataModel.js +0 -237
  144. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  145. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  146. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  147. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  148. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  149. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  150. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  151. package/build/src/modeling/legacy/DataProperty.js +0 -415
  152. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  153. package/build/src/models/store/DataFile.d.ts +0 -31
  154. package/build/src/models/store/DataFile.d.ts.map +0 -1
  155. package/build/src/models/store/DataFile.js +0 -92
  156. package/build/src/models/store/DataFile.js.map +0 -1
  157. package/src/amf/AmfShapeGenerator.ts +0 -477
  158. package/src/modeling/legacy/DataAssociation.ts +0 -554
  159. package/src/modeling/legacy/DataEntity.ts +0 -1019
  160. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  161. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  162. package/src/modeling/legacy/DataModel.ts +0 -276
  163. package/src/modeling/legacy/DataNamespace.ts +0 -929
  164. package/src/modeling/legacy/DataProperty.ts +0 -630
  165. package/src/models/store/DataFile.ts +0 -100
  166. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  167. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  168. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  169. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  170. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  171. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  172. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  173. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  174. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -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
  * });
@@ -16,12 +16,13 @@ import {
16
16
  type NumberFormat,
17
17
  NumberFormats,
18
18
  } from './DataFormat.js'
19
+ import { ShapeGenerator } from './amf/ShapeGenerator.js'
19
20
  import type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './Bindings.js'
20
21
  import type { ModelValidationOptions } from '../models/types.js'
21
22
  import type { DomainEntity } from './DomainEntity.js'
22
23
  import type { IApiPropertyShape } from '../amf/definitions/Shapes.js'
23
- import { ShapeGenerator } from './amf/ShapeGenerator.js'
24
- import { PropertySchema } from './types.js'
24
+ import type { PropertySchema } from './types.js'
25
+ import { DataSemantics, isPropertySemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'
25
26
 
26
27
  export interface DomainPropertySchema extends DomainElementSchema {
27
28
  kind: typeof DomainPropertyKind
@@ -62,11 +63,11 @@ export interface DomainPropertySchema extends DomainElementSchema {
62
63
  */
63
64
  tags?: string[]
64
65
  /**
65
- * For future use.
66
- *
67
- * The keys of the taxonomy items associated with the property.
66
+ * The semantics applied to this property.
67
+ * This is a list of applied semantics that can be used to
68
+ * describe the property in more detail.
68
69
  */
69
- taxonomy?: string[]
70
+ semantics?: AppliedDataSemantic[]
70
71
  /**
71
72
  * The data type for this property.
72
73
  * Note, not all schemas support the same type. For example, defining `sint32`
@@ -106,21 +107,21 @@ export interface DomainPropertySchema extends DomainElementSchema {
106
107
  * - **Bindings:** Allows defining how the property is
107
108
  * represented in different formats (e.g., web APIs,
108
109
  * protocol buffers).
109
- * - **Metadata:** Supports metadata such as tags, taxonomy,
110
+ * - **Metadata:** Supports metadata such as tags, semantics,
110
111
  * read-only/write-only status, and deprecation.
111
112
  * - **Schema:** Allows defining a general schema for the
112
113
  * property, which is propagated to all bindings.
113
114
  *
114
115
  * **Usage:**
115
116
  *
116
- * Use the `DataEntity.addProperty` method to add a new property to an
117
+ * Use the `DomainEntity.addProperty` method to add a new property to an
117
118
  * entity. The property can be created using the constructor, but it
118
119
  * won't be added to the graph until you call the `addProperty` method.
119
120
  *
120
121
  * **Example:**
121
122
  *
122
123
  * ```typescript
123
- * const entity = dataModel.addEntity({ key: 'user' });
124
+ * const entity = domainModel.addEntity({ key: 'user' });
124
125
  * const property = entity.addProperty({
125
126
  * key: 'name',
126
127
  * type: 'string',
@@ -185,11 +186,9 @@ export class DomainProperty extends DomainElement {
185
186
  @observed({ deep: true }) accessor tags: string[] = []
186
187
 
187
188
  /**
188
- * Reserved for future use.
189
- *
190
- * The keys of the taxonomy items associated with the property.
189
+ * Semantics applied to this property.
191
190
  */
192
- @observed({ deep: true }) accessor taxonomy: string[] = []
191
+ @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []
193
192
 
194
193
  /**
195
194
  * The data type for this property.
@@ -232,7 +231,7 @@ export class DomainProperty extends DomainElement {
232
231
  readOnly,
233
232
  writeOnly,
234
233
  tags,
235
- taxonomy,
234
+ semantics,
236
235
  deprecated,
237
236
  schema,
238
237
  bindings,
@@ -273,8 +272,8 @@ export class DomainProperty extends DomainElement {
273
272
  if (Array.isArray(tags)) {
274
273
  result.tags = [...tags]
275
274
  }
276
- if (Array.isArray(taxonomy)) {
277
- result.taxonomy = [...taxonomy]
275
+ if (Array.isArray(semantics)) {
276
+ result.semantics = [...semantics]
278
277
  }
279
278
  if (schema) {
280
279
  result.schema = structuredClone(schema)
@@ -353,10 +352,10 @@ export class DomainProperty extends DomainElement {
353
352
  } else {
354
353
  this.tags = []
355
354
  }
356
- if (Array.isArray(init.taxonomy)) {
357
- this.taxonomy = [...init.taxonomy]
355
+ if (Array.isArray(init.semantics)) {
356
+ this.semantics = [...init.semantics]
358
357
  } else {
359
- this.taxonomy = []
358
+ this.semantics = []
360
359
  }
361
360
  if (init.schema) {
362
361
  this.schema = structuredClone(init.schema)
@@ -419,8 +418,8 @@ export class DomainProperty extends DomainElement {
419
418
  if (Array.isArray(this.tags) && this.tags.length) {
420
419
  result.tags = [...this.tags]
421
420
  }
422
- if (Array.isArray(this.taxonomy) && this.taxonomy.length) {
423
- result.taxonomy = [...this.taxonomy]
421
+ if (Array.isArray(this.semantics) && this.semantics.length) {
422
+ result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))
424
423
  }
425
424
  if (this.schema) {
426
425
  result.schema = structuredClone(toRaw(this, this.schema))
@@ -545,4 +544,44 @@ export class DomainProperty extends DomainElement {
545
544
  const serializer = new ShapeGenerator()
546
545
  return serializer.property(this)
547
546
  }
547
+
548
+ /**
549
+ * Adds or updates a semantic to the property.
550
+ * @param semantic The semantic to add to the property.
551
+ * @throws Error if the semantic is not an property semantic.
552
+ */
553
+ addSemantic(semantic: AppliedDataSemantic): void {
554
+ const sem = DataSemantics[semantic.id]
555
+ if (!isPropertySemantic(sem)) {
556
+ throw new Error(`Invalid semantic type: ${semantic.id}. Expected a property semantic.`)
557
+ }
558
+ const index = this.semantics.findIndex((s) => s.id === semantic.id)
559
+ if (index >= 0) {
560
+ this.semantics[index] = semantic
561
+ } else {
562
+ this.semantics.push(semantic)
563
+ }
564
+ this.domain.notifyChange()
565
+ }
566
+
567
+ /**
568
+ * Removes a semantic from the property.
569
+ * @param semanticId The ID of the semantic to remove.
570
+ */
571
+ removeSemantic(semanticId: SemanticType): void {
572
+ const index = this.semantics.findIndex((s) => s.id === semanticId)
573
+ if (index >= 0) {
574
+ this.semantics.splice(index, 1)
575
+ this.domain.notifyChange()
576
+ }
577
+ }
578
+
579
+ /**
580
+ * Checks if the property has a specific semantic.
581
+ * @param semanticId The ID of the semantic to check.
582
+ * @returns True if the semantic is present, false otherwise.
583
+ */
584
+ hasSemantic(semanticId: SemanticType): boolean {
585
+ return this.semantics.some((s) => s.id === semanticId)
586
+ }
548
587
  }
@@ -0,0 +1,178 @@
1
+ import type { DomainPropertyType } from './DataFormat.js'
2
+
3
+ /**
4
+ * Defines the names for all available data semantics.
5
+ * Using a string enum makes it easy to add or remove semantics in a single place.
6
+ */
7
+ export enum SemanticType {
8
+ // Entity-Level Semantics
9
+ /**
10
+ * Designates a Data Entity that represents users of the system.
11
+ */
12
+ User = 'https://apinow.app/semantics/entities/#User',
13
+
14
+ // Property-Level Semantics
15
+ CreatedTimestamp = 'https://apinow.app/semantics/properties/#CreatedTimestamp',
16
+ UpdatedTimestamp = 'https://apinow.app/semantics/properties/#UpdatedTimestamp',
17
+ DeletedTimestamp = 'https://apinow.app/semantics/properties/#DeletedTimestamp',
18
+ DeletedFlag = 'https://apinow.app/semantics/properties/#DeletedFlag',
19
+ PublicUniqueName = 'https://apinow.app/semantics/properties/#PublicUniqueName',
20
+ // Association-Level Semantics
21
+ ResourceOwnerIdentifier = 'https://apinow.app/semantics/associations/#ResourceOwnerIdentifier',
22
+ }
23
+
24
+ /**
25
+ * Defines the scope at which a semantic can be applied.
26
+ */
27
+ export enum SemanticScope {
28
+ Entity = 'Entity',
29
+ Property = 'Property',
30
+ Association = 'Association',
31
+ }
32
+
33
+ /**
34
+ * A base interface for all Data Semantics, containing common properties.
35
+ * A semantic is an annotation applied to a Data Entity, Property, or Association
36
+ * to provide additional context or constraints.
37
+ * This interface is extended by more specific semantic types.
38
+ */
39
+ interface BaseDataSemantic {
40
+ /**
41
+ * A unique identifier for the semantic definition.
42
+ */
43
+ id: SemanticType
44
+ /**
45
+ * A human-readable name for the semantic.
46
+ */
47
+ displayName: string
48
+ /**
49
+ * A description of the semantic's purpose and impact.
50
+ */
51
+ description: string
52
+ /**
53
+ * Specifies whether the semantic applies to an Entity, Property, or Association.
54
+ */
55
+ scope: SemanticScope
56
+ }
57
+
58
+ /**
59
+ * Represents a semantic that can be applied to an entire Data Entity.
60
+ */
61
+ export interface EntitySemantic extends BaseDataSemantic {
62
+ scope: SemanticScope.Entity
63
+ }
64
+
65
+ /**
66
+ * Represents a semantic that can be applied to a single property.
67
+ */
68
+ export interface PropertySemantic extends BaseDataSemantic {
69
+ scope: SemanticScope.Property
70
+ /**
71
+ * Optional array of data types this semantic can be applied to.
72
+ * Enforces constraints, e.g., DeletedTimestamp on a DateTime property.
73
+ */
74
+ applicableDataTypes?: DomainPropertyType[]
75
+ }
76
+
77
+ /**
78
+ * Represents a semantic that can be applied to an association between entities.
79
+ */
80
+ export interface AssociationSemantic extends BaseDataSemantic {
81
+ scope: SemanticScope.Association
82
+ }
83
+
84
+ /**
85
+ * A type guard to check if a semantic is an EntitySemantic.
86
+ */
87
+ export const isEntitySemantic = (semantic: DataSemantic): semantic is EntitySemantic =>
88
+ semantic.scope === SemanticScope.Entity
89
+
90
+ /**
91
+ * A type guard to check if a semantic is a PropertySemantic.
92
+ */
93
+ export const isPropertySemantic = (semantic: DataSemantic): semantic is PropertySemantic =>
94
+ semantic.scope === SemanticScope.Property
95
+
96
+ /**
97
+ * A type guard to check if a semantic is a AssociationSemantic.
98
+ */
99
+ export const isAssociationSemantic = (semantic: DataSemantic): semantic is AssociationSemantic =>
100
+ semantic.scope === SemanticScope.Association
101
+
102
+ /**
103
+ * Union type for any kind of data semantic
104
+ */
105
+ export type DataSemantic = EntitySemantic | PropertySemantic | AssociationSemantic
106
+
107
+ /**
108
+ * A map to store the definitions of all available data semantics.
109
+ * This acts as a central registry for the application.
110
+ */
111
+ export const DataSemantics: Record<SemanticType, DataSemantic> = {
112
+ // Entity-Level Definitions
113
+ [SemanticType.User]: {
114
+ id: SemanticType.User,
115
+ displayName: 'User Entity',
116
+ scope: SemanticScope.Entity,
117
+ description: 'Designates an entity that represents system users, crucial for authentication and authorization.',
118
+ },
119
+
120
+ // Property-Level Definitions
121
+ [SemanticType.CreatedTimestamp]: {
122
+ id: SemanticType.CreatedTimestamp,
123
+ displayName: 'Creation Timestamp',
124
+ scope: SemanticScope.Property,
125
+ description: "Marks a field as the one that contains the object's creation timestamp.",
126
+ applicableDataTypes: ['datetime'],
127
+ },
128
+ [SemanticType.UpdatedTimestamp]: {
129
+ id: SemanticType.UpdatedTimestamp,
130
+ displayName: 'Update Timestamp',
131
+ scope: SemanticScope.Property,
132
+ description: "Marks a field as the field that contains object's last modification timestamp.",
133
+ applicableDataTypes: ['datetime'],
134
+ },
135
+ [SemanticType.DeletedTimestamp]: {
136
+ id: SemanticType.DeletedTimestamp,
137
+ displayName: 'Soft Delete Timestamp',
138
+ scope: SemanticScope.Property,
139
+ description: "Marks a field as the field that contains object's deletion timestamp.",
140
+ applicableDataTypes: ['datetime'],
141
+ },
142
+ [SemanticType.DeletedFlag]: {
143
+ id: SemanticType.DeletedFlag,
144
+ displayName: 'Soft Delete Flag',
145
+ scope: SemanticScope.Property,
146
+ description: 'A boolean property that marks the object as deleted without physically removing it.',
147
+ applicableDataTypes: ['boolean'],
148
+ },
149
+ [SemanticType.ResourceOwnerIdentifier]: {
150
+ id: SemanticType.ResourceOwnerIdentifier,
151
+ displayName: 'Resource Owner Identifier',
152
+ scope: SemanticScope.Association,
153
+ description: 'Links a resource to a "User" entity instance, indicating ownership for access control.',
154
+ },
155
+ [SemanticType.PublicUniqueName]: {
156
+ id: SemanticType.PublicUniqueName,
157
+ displayName: 'Public Unique Name (Slug)',
158
+ scope: SemanticScope.Property,
159
+ description: 'A user-friendly, unique public identifier for a resource, often used in URLs.',
160
+ applicableDataTypes: ['string'],
161
+ },
162
+ }
163
+
164
+ /**
165
+ * Represents the application of a data semantic to a specific
166
+ * entity or property within a user's data model.
167
+ */
168
+ export interface AppliedDataSemantic {
169
+ /**
170
+ * The unique identifier of the semantic being applied.
171
+ */
172
+ id: SemanticType
173
+
174
+ /**
175
+ * Optional configuration or values specific to this application.
176
+ */
177
+ config?: Record<string, unknown>
178
+ }
@@ -4,20 +4,20 @@
4
4
 
5
5
  ```plain
6
6
  DataDomain (Root container)
7
- ├── DataNamespace (logical grouping)
8
- │ └── DataModel
9
- │ └── DataEntity
7
+ ├── DomainNamespace (logical grouping)
8
+ │ └── DomainModel
9
+ │ └── DomainEntity
10
10
  │ ├── Property (name, type, ...)
11
11
  │ ├── Association (name, cardinality, target Entity)
12
- │ └── ParentEntity (reference to another DataEntity)
13
- ├── DataModel
14
- │ └── DataEntity
12
+ │ └── ParentEntity (reference to another DomainEntity)
13
+ ├── DomainModel
14
+ │ └── DomainEntity
15
15
  │ ├── Property
16
16
  │ ├── Association
17
17
  │ └── ParentEntity
18
- └── ForeignDataNamespace (immutable, imported from another DataDomain)
19
- └── DataModel
20
- └── DataEntity
18
+ └── ForeignDomainNamespace (immutable, imported from another DataDomain)
19
+ └── DomainModel
20
+ └── DomainEntity
21
21
  ├── Property
22
22
  ├── Association
23
23
  └── ParentEntity
@@ -31,11 +31,11 @@ Here's a breakdown of how each element is represented in the graph:
31
31
 
32
32
  **Nodes:**
33
33
 
34
- * **Namespace:** Represents a `DataNamespace`. It's a container for models and other namespaces.
35
- * **Model:** Represents a `DataModel`. It's a container for entities.
36
- * **Entity:** Represents a `DataEntity`. It's the fundamental building block, defining a specific type of data.
37
- * **Property:** Represents a `DataProperty`. It's an attribute of an entity.
38
- * **Association:** Represents a `DataAssociation`. It defines a relationship between entities.
34
+ * **Namespace:** Represents a `DomainNamespace`. It's a container for models and other namespaces.
35
+ * **Model:** Represents a `DomainModel`. It's a container for entities.
36
+ * **Entity:** Represents a `DomainEntity`. It's the fundamental building block, defining a specific type of data.
37
+ * **Property:** Represents a `DomainProperty`. It's an attribute of an entity.
38
+ * **Association:** Represents a `DomainAssociation`. It defines a relationship between entities.
39
39
 
40
40
  **Edges:**
41
41
 
@@ -4,53 +4,53 @@
4
4
 
5
5
  At the heart of this data modeling system are the following fundamental concepts.
6
6
 
7
- ### DataNamespace
7
+ ### DomainNamespace
8
8
 
9
9
  This is the top-level container, representing a logical grouping of data. Think of it as a "domain" or a "schema" in a database. It can contain:
10
10
 
11
- - `DataModels`: Logical groupings of entities.
11
+ - `DomainModels`: Logical groupings of entities.
12
12
  - `DataEntities`: The basic building blocks, representing individual data structures.
13
13
  - `DataProperties`: Attributes of entities (e.g., name, age, address).
14
- - `DataAssociations`: Relationships between entities (e.g., a user has an address).
14
+ - `DomainAssociations`: Relationships between entities (e.g., a user has an address).
15
15
  - `Sub-namespaces`: Namespaces can be nested within each other, creating a hierarchical structure.
16
16
  - `Foreign Namespaces`: References to external namespaces, enabling the use of entities defined elsewhere.
17
17
  - `Tags`: Common tags for the entire namespace.
18
18
 
19
- ### DataModel
19
+ ### DomainModel
20
20
 
21
- A logical grouping of `DataEntity` instances. It represents a specific data structure, like a "Product" or "User" model. A `DataModel` can contain multiple `DataEntity` instances.
21
+ A logical grouping of `DomainEntity` instances. It represents a specific data structure, like a "Product" or "User" model. A `DomainModel` can contain multiple `DomainEntity` instances.
22
22
 
23
- ### DataEntity
23
+ ### DomainEntity
24
24
 
25
25
  The fundamental building block of the data model. It represents a specific type of data, like a "User," "Product," or "Address."
26
26
 
27
- - `Properties`: DataProperty instances that describe the attributes of the entity.
28
- - `Associations`: DataAssociation instances that define relationships to other entities.
27
+ - `Properties`: DomainProperty instances that describe the attributes of the entity.
28
+ - `Associations`: DomainAssociation instances that define relationships to other entities.
29
29
  - `Parents`: An entity can inherit from other entities, creating a hierarchy.
30
30
  - `Fields`: Ordered list of properties and associations.
31
31
  - `Tags`: Optional tags for the UI.
32
- - `Taxonomy`: Reserved for future use.
32
+ - `Semantics`: A system of predefined, meaningful labels or classifications that can be applied to Data Entities or their individual properties.
33
33
  - `Deprecated`: Whether the entity is deprecated.
34
34
  - `Schema`: The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)
35
35
 
36
- ### DataProperty
36
+ ### DomainProperty
37
37
 
38
- Represents an attribute of a `DataEntity`. It has a name, a data type (e.g., string, number, boolean), and optional constraints (e.g., required, multiple, min/max values).
38
+ Represents an attribute of a `DomainEntity`. It has a name, a data type (e.g., string, number, boolean), and optional constraints (e.g., required, multiple, min/max values).
39
39
 
40
40
  - `Type`: The data type of the property.
41
41
  - `Schema`: The general schema definition of this property.
42
42
  - `Bindings`: The list of bindings for this property.
43
43
  - `Tags`: Optional tags for the UI.
44
- - `Taxonomy`: Reserved for future use.
44
+ - `Semantics`: A system of predefined, meaningful labels or classifications that can be applied to Data Entities or their individual properties.
45
45
  - `Deprecated`: Whether the property is deprecated.
46
46
  - `Primary`: Whether this property describes a primary key of the entity.
47
47
  - `Index`: Whether this property describes an indexed property of the entity.
48
48
  - `ReadOnly`: Whether the property is read only in the schema.
49
49
  - `WriteOnly`: Whether the property is write only in the schema.
50
50
 
51
- ### DataAssociation
51
+ ### DomainAssociation
52
52
 
53
- Defines a relationship between `DataEntity` instances. It specifies the target entities and the nature of the relationship (e.g., one-to-one, one-to-many).
53
+ Defines a relationship between `DomainEntity` instances. It specifies the target entities and the nature of the relationship (e.g., one-to-one, one-to-many).
54
54
 
55
55
  - `Targets`: The list of target entities.
56
56
  - `Multiple`: Whether the association allows multiple target entities.
@@ -67,24 +67,24 @@ Defines a translation from a data model to a specific format (like JSON, RAML, X
67
67
 
68
68
  Here's how these components work together to structure a data domain:
69
69
 
70
- 1. **Root Namespace**: You start with a `DataNamespace`, which acts as the root of your data domain. This namespace is the top-level container for all other elements.
70
+ 1. **Root Namespace**: You start with a `DomainNamespace`, which acts as the root of your data domain. This namespace is the top-level container for all other elements.
71
71
 
72
72
  1. **Sub-namespaces (Optional)**: You can create sub-namespaces within the root namespace to further organize your data. This is useful for large domains with many entities and relationships.
73
73
 
74
- 1. **Data Models**: Within a namespace (or sub-namespace), you define `DataModel` instances. Each `DataModel` represents a specific area of your domain. For example, you might have a "User Management" `DataModel`, a "Product Catalog" `DataModel`, and an "Order Processing" `DataModel`.
74
+ 1. **Data Models**: Within a namespace (or sub-namespace), you define `DomainModel` instances. Each `DomainModel` represents a specific area of your domain. For example, you might have a "User Management" `DomainModel`, a "Product Catalog" `DomainModel`, and an "Order Processing" `DomainModel`.
75
75
 
76
- 1. **Data Entities**: Inside each `DataModel`, you define `DataEntity` instances. These are the core data structures. For example, in the "User Management" `DataModel`, you might have `DataEntity` instances for "User," "Role," and "Permission."
76
+ 1. **Data Entities**: Inside each `DomainModel`, you define `DomainEntity` instances. These are the core data structures. For example, in the "User Management" `DomainModel`, you might have `DomainEntity` instances for "User," "Role," and "Permission."
77
77
 
78
- 1. **Data Properties**: Each `DataEntity` has `DataProperty` instances that describe its attributes. For example, the "User" `DataEntity` might have `DataProperty` instances for "firstName" (string), "lastName" (string), "email" (string), "age" (number), etc.
78
+ 1. **Data Properties**: Each `DomainEntity` has `DomainProperty` instances that describe its attributes. For example, the "User" `DomainEntity` might have `DomainProperty` instances for "firstName" (string), "lastName" (string), "email" (string), "age" (number), etc.
79
79
 
80
- 1. **Data Associations**: You use `DataAssociation` instances to define relationships between `DataEntity` instances. For example:
80
+ 1. **Data Associations**: You use `DomainAssociation` instances to define relationships between `DomainEntity` instances. For example:
81
81
 
82
82
  - A "User" has an "Address" (one-to-one).
83
83
  - A "User" has multiple "Roles" (one-to-many).
84
84
  - A "Product" belongs to a "Category" (many-to-one).
85
85
  - An "Order" contains multiple "Order Items" (one-to-many).
86
86
 
87
- 1. **Inheritance**: `DataEntity` instances can inherit from other `DataEntity` instances using the parents property. This allows you to create a hierarchy of entities and reuse common properties and associations.
87
+ 1. **Inheritance**: `DomainEntity` instances can inherit from other `DomainEntity` instances using the parents property. This allows you to create a hierarchy of entities and reuse common properties and associations.
88
88
 
89
89
  1. **Foreign Namespaces**: You can reference entities from other namespaces using the foreign property of the root namespace. This allows you to reuse data structures defined elsewhere.
90
90
 
@@ -109,18 +109,18 @@ Let's imagine a simple e-commerce domain:
109
109
  - **Data Association**: `address` (references `Address` entity)
110
110
  - **Data Entity**: `Address`
111
111
  - **Data Properties**: `street` (string), `city` (string), `zipCode` (string), `country` (string)
112
- - **Foreign Namespace**: `Taxonomy` (defined elsewhere)
113
- - **Data Model**: `Taxonomy`
114
- - **Data Entity**: `TaxonomyItem`
112
+ - **Foreign Namespace**: `Semantics` (defined elsewhere)
113
+ - **Data Model**: `Semantics`
114
+ - **Data Entity**: `SemanticsItem`
115
115
 
116
116
  ### Key Relationships
117
117
 
118
- - **Namespace-Model**: A `DataNamespace` contains `DataModel` instances.
119
- - **Model-Entity**: A `DataModel` contains `DataEntity` instances.
120
- - **Entity-Property**: A `DataEntity` has `DataProperty` instances.
121
- - **Entity-Association**: A `DataEntity` has `DataAssociation` instances.
122
- - **Entity-Parent**: A `DataEntity` can have `DataEntity` instances as parents.
123
- - **Namespace-Foreign**: A `DataNamespace` can have references to `DataNamespace` instances.
118
+ - **Namespace-Model**: A `DomainNamespace` contains `DomainModel` instances.
119
+ - **Model-Entity**: A `DomainModel` contains `DomainEntity` instances.
120
+ - **Entity-Property**: A `DomainEntity` has `DomainProperty` instances.
121
+ - **Entity-Association**: A `DomainEntity` has `DomainAssociation` instances.
122
+ - **Entity-Parent**: A `DomainEntity` can have `DomainEntity` instances as parents.
123
+ - **Namespace-Foreign**: A `DomainNamespace` can have references to `DomainNamespace` instances.
124
124
 
125
125
  ## Summary
126
126
 
@@ -11,18 +11,12 @@ export interface ICertificateFile extends IFile {
11
11
  export class CertificateFile extends File {
12
12
  override kind = CertificateFileKind
13
13
 
14
- static fromCertificate(
15
- certificate: ICertificate | Certificate,
16
- organization: string,
17
- owner?: string
18
- ): CertificateFile {
14
+ static fromCertificate(certificate: ICertificate | Certificate): CertificateFile {
19
15
  const init: ICertificateFile = {
20
16
  kind: CertificateFileKind,
21
17
  key: certificate.key,
22
- organization,
23
18
  info: Thing.fromName(certificate.name).toJSON(),
24
- lastModified: { user: owner || '', time: 0, byMe: false },
25
- owner,
19
+ lastModified: { user: '', time: 0, byMe: false },
26
20
  parents: [],
27
21
  permissionIds: [],
28
22
  permissions: [],
@@ -32,10 +26,9 @@ export class CertificateFile extends File {
32
26
 
33
27
  /**
34
28
  * @param name The name to set.
35
- * @param owner The user id that is the owner of the file.
36
29
  */
37
- static override fromName(name: string, organization: string, owner?: string): CertificateFile {
38
- return super.fromName(name, organization, owner, CertificateFileKind) as CertificateFile
30
+ static override fromName(name: string): CertificateFile {
31
+ return super.fromName(name, CertificateFileKind) as CertificateFile
39
32
  }
40
33
 
41
34
  constructor(input?: string | ICertificateFile) {
@@ -49,7 +42,6 @@ export class CertificateFile extends File {
49
42
  init = {
50
43
  kind: CertificateFileKind,
51
44
  key: nanoid(),
52
- organization: '',
53
45
  info: Thing.fromName('').toJSON(),
54
46
  parents: [],
55
47
  permissionIds: [],
@@ -20,10 +20,9 @@ export class Folder extends File {
20
20
  * Creates a new Folder object from a name.
21
21
  *
22
22
  * @param name The name to set.
23
- * @param owner The user id that is the owner of the folder.
24
23
  */
25
- static override fromName(name: string, organization: string, owner?: string): Folder {
26
- return super.fromName(name, organization, owner, FolderKind) as Folder
24
+ static override fromName(name: string): Folder {
25
+ return super.fromName(name, FolderKind) as Folder
27
26
  }
28
27
 
29
28
  /**
@@ -40,7 +39,6 @@ export class Folder extends File {
40
39
  init = {
41
40
  kind: FolderKind,
42
41
  key: nanoid(),
43
- organization: '',
44
42
  info: Thing.fromName('').toJSON(),
45
43
  parents: [],
46
44
  permissionIds: [],
@@ -19,7 +19,7 @@ export interface IProject extends IFile {
19
19
  export class Project extends File {
20
20
  override kind = ProjectKind
21
21
 
22
- static fromProject(project: HttpProject | IHttpProject, organization: string, owner?: string): Project {
22
+ static fromProject(project: HttpProject | IHttpProject): Project {
23
23
  let final: IHttpProject
24
24
  if (typeof (project as HttpProject).toJSON === 'function') {
25
25
  final = (project as HttpProject).toJSON()
@@ -29,10 +29,8 @@ export class Project extends File {
29
29
  const init: IProject = {
30
30
  kind: ProjectKind,
31
31
  key: project.key,
32
- organization,
33
32
  info: { ...final.info },
34
- lastModified: { user: owner || '', time: 0, byMe: false },
35
- owner,
33
+ lastModified: { user: '', time: 0, byMe: false },
36
34
  parents: [],
37
35
  permissionIds: [],
38
36
  permissions: [],
@@ -42,10 +40,9 @@ export class Project extends File {
42
40
 
43
41
  /**
44
42
  * @param name The name to set.
45
- * @param owner The user id that is the owner of the file.
46
43
  */
47
- static override fromName(name: string, organization: string, owner?: string): Project {
48
- return super.fromName(name, organization, owner, ProjectKind) as Project
44
+ static override fromName(name: string): Project {
45
+ return super.fromName(name, ProjectKind) as Project
49
46
  }
50
47
 
51
48
  constructor(input?: string | IProject) {
@@ -59,7 +56,6 @@ export class Project extends File {
59
56
  init = {
60
57
  kind: ProjectKind,
61
58
  key: nanoid(),
62
- organization: '',
63
59
  info: Thing.fromName('').toJSON(),
64
60
  parents: [],
65
61
  permissionIds: [],