@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
@@ -1 +1 @@
1
- {"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGxD,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AA+BnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;IACU,WAAW;sBAAS,aAAa;;;;;;;iBAAjC,WAAY,SAAQ,WAAa;;;gCAM3C,cAAc,EAAE;sCAShB,QAAQ,EAAE;YATO,iKAAS,IAAI,6BAAJ,IAAI,mFAAO;YAS1B,mLAAS,UAAU,6BAAV,UAAU,+FAAqB;;;QAd3C,IAAI,CAAwB;QAKnB,6EAAoB;QAHtC;;WAEG;QACe,IAAS,IAAI,0CAAO;QAApB,IAAS,IAAI,gDAAO;QAKtC,4EAAmC;QAHnC;;WAEG;QACH,IAAS,MAAM,4CAAoB;QAAnC,IAAS,MAAM,kDAAoB;QAIvB,yFAAwC;QAHpD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;;;;;;;;WAUG;QACH,SAAS;YACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QAC/B,CAAC;QAEO,WAAW,CAAC,GAAW;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QAC9D,CAAC;QAED;;;;;;WAMG;QACH,SAAS,CAAC,GAAW;YACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SAxVU,WAAW","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainEntityKind, DomainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const dataNamespace = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = dataNamespace.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n this.fields.push({\n type: 'entity',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
1
+ {"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGxD,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AA+BnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;IACU,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ainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const ns = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = ns.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n this.fields.push({\n type: 'entity',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
@@ -7,7 +7,8 @@ import type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './B
7
7
  import type { ModelValidationOptions } from '../models/types.js';
8
8
  import type { DomainEntity } from './DomainEntity.js';
9
9
  import type { IApiPropertyShape } from '../amf/definitions/Shapes.js';
10
- import { PropertySchema } from './types.js';
10
+ import type { PropertySchema } from './types.js';
11
+ import { type SemanticType, type AppliedDataSemantic } from './Semantics.js';
11
12
  export interface DomainPropertySchema extends DomainElementSchema {
12
13
  kind: typeof DomainPropertyKind;
13
14
  /**
@@ -47,11 +48,11 @@ export interface DomainPropertySchema extends DomainElementSchema {
47
48
  */
48
49
  tags?: string[];
49
50
  /**
50
- * For future use.
51
- *
52
- * The keys of the taxonomy items associated with the property.
51
+ * The semantics applied to this property.
52
+ * This is a list of applied semantics that can be used to
53
+ * describe the property in more detail.
53
54
  */
54
- taxonomy?: string[];
55
+ semantics?: AppliedDataSemantic[];
55
56
  /**
56
57
  * The data type for this property.
57
58
  * Note, not all schemas support the same type. For example, defining `sint32`
@@ -90,21 +91,21 @@ export interface DomainPropertySchema extends DomainElementSchema {
90
91
  * - **Bindings:** Allows defining how the property is
91
92
  * represented in different formats (e.g., web APIs,
92
93
  * protocol buffers).
93
- * - **Metadata:** Supports metadata such as tags, taxonomy,
94
+ * - **Metadata:** Supports metadata such as tags, semantics,
94
95
  * read-only/write-only status, and deprecation.
95
96
  * - **Schema:** Allows defining a general schema for the
96
97
  * property, which is propagated to all bindings.
97
98
  *
98
99
  * **Usage:**
99
100
  *
100
- * Use the `DataEntity.addProperty` method to add a new property to an
101
+ * Use the `DomainEntity.addProperty` method to add a new property to an
101
102
  * entity. The property can be created using the constructor, but it
102
103
  * won't be added to the graph until you call the `addProperty` method.
103
104
  *
104
105
  * **Example:**
105
106
  *
106
107
  * ```typescript
107
- * const entity = dataModel.addEntity({ key: 'user' });
108
+ * const entity = domainModel.addEntity({ key: 'user' });
108
109
  * const property = entity.addProperty({
109
110
  * key: 'name',
110
111
  * type: 'string',
@@ -159,11 +160,9 @@ export declare class DomainProperty extends DomainElement {
159
160
  */
160
161
  accessor tags: string[];
161
162
  /**
162
- * Reserved for future use.
163
- *
164
- * The keys of the taxonomy items associated with the property.
163
+ * Semantics applied to this property.
165
164
  */
166
- accessor taxonomy: string[];
165
+ accessor semantics: AppliedDataSemantic[];
167
166
  /**
168
167
  * The data type for this property.
169
168
  * Note, not all schemas support the same type. For example, defining `sint32`
@@ -277,5 +276,22 @@ export declare class DomainProperty extends DomainElement {
277
276
  * @returns AMF property shape definition.
278
277
  */
279
278
  toApiShape(): IApiPropertyShape;
279
+ /**
280
+ * Adds or updates a semantic to the property.
281
+ * @param semantic The semantic to add to the property.
282
+ * @throws Error if the semantic is not an property semantic.
283
+ */
284
+ addSemantic(semantic: AppliedDataSemantic): void;
285
+ /**
286
+ * Removes a semantic from the property.
287
+ * @param semanticId The ID of the semantic to remove.
288
+ */
289
+ removeSemantic(semanticId: SemanticType): void;
290
+ /**
291
+ * Checks if the property has a specific semantic.
292
+ * @param semanticId The ID of the semantic to check.
293
+ * @returns True if the semantic is present, false otherwise.
294
+ */
295
+ hasSemantic(semanticId: SemanticType): boolean;
280
296
  }
281
297
  //# sourceMappingURL=DomainProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomainProperty.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAGL,KAAK,uBAAuB,EAE5B,KAAK,oBAAoB,EAEzB,KAAK,kBAAkB,EAIxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAC3F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AA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a,IAAI,mBAAmB;IASpC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS;IAKnE;;;;;;;;;;;;OAYG;IACH,UAAU,IAAI,iBAAiB;IAK/B;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAchD;;;OAGG;IACH,cAAc,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI;IAQ9C;;;;OAIG;IACH,WAAW,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO;CAG/C"}
@@ -6,6 +6,7 @@ import { Thing } from '../models/Thing.js';
6
6
  import { observed, retargetChange, toRaw } from './observed.js';
7
7
  import { BinaryFormats, DomainPropertyAttributes, DomainPropertyList, DomainPropertyTypes, NumberFormats, } from './DataFormat.js';
8
8
  import { ShapeGenerator } from './amf/ShapeGenerator.js';
9
+ import { DataSemantics, isPropertySemantic } from './Semantics.js';
9
10
  /**
10
11
  * Represents a property within a data domain entity.
11
12
  *
@@ -22,21 +23,21 @@ import { ShapeGenerator } from './amf/ShapeGenerator.js';
22
23
  * - **Bindings:** Allows defining how the property is
23
24
  * represented in different formats (e.g., web APIs,
24
25
  * protocol buffers).
25
- * - **Metadata:** Supports metadata such as tags, taxonomy,
26
+ * - **Metadata:** Supports metadata such as tags, semantics,
26
27
  * read-only/write-only status, and deprecation.
27
28
  * - **Schema:** Allows defining a general schema for the
28
29
  * property, which is propagated to all bindings.
29
30
  *
30
31
  * **Usage:**
31
32
  *
32
- * Use the `DataEntity.addProperty` method to add a new property to an
33
+ * Use the `DomainEntity.addProperty` method to add a new property to an
33
34
  * entity. The property can be created using the constructor, but it
34
35
  * won't be added to the graph until you call the `addProperty` method.
35
36
  *
36
37
  * **Example:**
37
38
  *
38
39
  * ```typescript
39
- * const entity = dataModel.addEntity({ key: 'user' });
40
+ * const entity = domainModel.addEntity({ key: 'user' });
40
41
  * const property = entity.addProperty({
41
42
  * key: 'name',
42
43
  * type: 'string',
@@ -77,9 +78,9 @@ let DomainProperty = (() => {
77
78
  let _tags_decorators;
78
79
  let _tags_initializers = [];
79
80
  let _tags_extraInitializers = [];
80
- let _taxonomy_decorators;
81
- let _taxonomy_initializers = [];
82
- let _taxonomy_extraInitializers = [];
81
+ let _semantics_decorators;
82
+ let _semantics_initializers = [];
83
+ let _semantics_extraInitializers = [];
83
84
  let _type_decorators;
84
85
  let _type_initializers = [];
85
86
  let _type_extraInitializers = [];
@@ -101,7 +102,7 @@ let DomainProperty = (() => {
101
102
  _writeOnly_decorators = [observed()];
102
103
  _deprecated_decorators = [observed()];
103
104
  _tags_decorators = [observed({ deep: true })];
104
- _taxonomy_decorators = [observed({ deep: true })];
105
+ _semantics_decorators = [observed({ deep: true })];
105
106
  _type_decorators = [observed()];
106
107
  _schema_decorators = [observed({ deep: true })];
107
108
  _bindings_decorators = [observed({ deep: true })];
@@ -114,7 +115,7 @@ let DomainProperty = (() => {
114
115
  __esDecorate(this, null, _writeOnly_decorators, { kind: "accessor", name: "writeOnly", static: false, private: false, access: { has: obj => "writeOnly" in obj, get: obj => obj.writeOnly, set: (obj, value) => { obj.writeOnly = value; } }, metadata: _metadata }, _writeOnly_initializers, _writeOnly_extraInitializers);
115
116
  __esDecorate(this, null, _deprecated_decorators, { kind: "accessor", name: "deprecated", static: false, private: false, access: { has: obj => "deprecated" in obj, get: obj => obj.deprecated, set: (obj, value) => { obj.deprecated = value; } }, metadata: _metadata }, _deprecated_initializers, _deprecated_extraInitializers);
116
117
  __esDecorate(this, null, _tags_decorators, { kind: "accessor", name: "tags", static: false, private: false, access: { has: obj => "tags" in obj, get: obj => obj.tags, set: (obj, value) => { obj.tags = value; } }, metadata: _metadata }, _tags_initializers, _tags_extraInitializers);
117
- __esDecorate(this, null, _taxonomy_decorators, { kind: "accessor", name: "taxonomy", static: false, private: false, access: { has: obj => "taxonomy" in obj, get: obj => obj.taxonomy, set: (obj, value) => { obj.taxonomy = value; } }, metadata: _metadata }, _taxonomy_initializers, _taxonomy_extraInitializers);
118
+ __esDecorate(this, null, _semantics_decorators, { kind: "accessor", name: "semantics", static: false, private: false, access: { has: obj => "semantics" in obj, get: obj => obj.semantics, set: (obj, value) => { obj.semantics = value; } }, metadata: _metadata }, _semantics_initializers, _semantics_extraInitializers);
118
119
  __esDecorate(this, null, _type_decorators, { kind: "accessor", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
119
120
  __esDecorate(this, null, _schema_decorators, { kind: "accessor", name: "schema", static: false, private: false, access: { has: obj => "schema" in obj, get: obj => obj.schema, set: (obj, value) => { obj.schema = value; } }, metadata: _metadata }, _schema_initializers, _schema_extraInitializers);
120
121
  __esDecorate(this, null, _bindings_decorators, { kind: "accessor", name: "bindings", static: false, private: false, access: { has: obj => "bindings" in obj, get: obj => obj.bindings, set: (obj, value) => { obj.bindings = value; } }, metadata: _metadata }, _bindings_initializers, _bindings_extraInitializers);
@@ -171,9 +172,7 @@ let DomainProperty = (() => {
171
172
  set deprecated(value) { this.#deprecated_accessor_storage = value; }
172
173
  #tags_accessor_storage = (__runInitializers(this, _deprecated_extraInitializers), __runInitializers(this, _tags_initializers, []
173
174
  /**
174
- * Reserved for future use.
175
- *
176
- * The keys of the taxonomy items associated with the property.
175
+ * Semantics applied to this property.
177
176
  */
178
177
  ));
179
178
  /**
@@ -185,7 +184,7 @@ let DomainProperty = (() => {
185
184
  */
186
185
  get tags() { return this.#tags_accessor_storage; }
187
186
  set tags(value) { this.#tags_accessor_storage = value; }
188
- #taxonomy_accessor_storage = (__runInitializers(this, _tags_extraInitializers), __runInitializers(this, _taxonomy_initializers, []
187
+ #semantics_accessor_storage = (__runInitializers(this, _tags_extraInitializers), __runInitializers(this, _semantics_initializers, []
189
188
  /**
190
189
  * The data type for this property.
191
190
  * Note, not all schemas support the same type. For example, defining `sint32`
@@ -195,13 +194,11 @@ let DomainProperty = (() => {
195
194
  */
196
195
  ));
197
196
  /**
198
- * Reserved for future use.
199
- *
200
- * The keys of the taxonomy items associated with the property.
197
+ * Semantics applied to this property.
201
198
  */
202
- get taxonomy() { return this.#taxonomy_accessor_storage; }
203
- set taxonomy(value) { this.#taxonomy_accessor_storage = value; }
204
- #type_accessor_storage = (__runInitializers(this, _taxonomy_extraInitializers), __runInitializers(this, _type_initializers, 'string'
199
+ get semantics() { return this.#semantics_accessor_storage; }
200
+ set semantics(value) { this.#semantics_accessor_storage = value; }
201
+ #type_accessor_storage = (__runInitializers(this, _semantics_extraInitializers), __runInitializers(this, _type_initializers, 'string'
205
202
  /**
206
203
  * The general schema definition of this property.
207
204
  * This is propagated to all bindings (when they support these properties).
@@ -247,7 +244,7 @@ let DomainProperty = (() => {
247
244
  * @returns The data model schema.
248
245
  */
249
246
  static createSchema(input = {}) {
250
- const { key = nanoid(), multiple, required, type = DomainPropertyList.string, index, primary, readOnly, writeOnly, tags, taxonomy, deprecated, schema, bindings, } = input;
247
+ const { key = nanoid(), multiple, required, type = DomainPropertyList.string, index, primary, readOnly, writeOnly, tags, semantics, deprecated, schema, bindings, } = input;
251
248
  if (typeof type === 'string') {
252
249
  if (!DomainPropertyTypes.includes(type)) {
253
250
  throw new Error(`Invalid data property type ${type}`);
@@ -284,8 +281,8 @@ let DomainProperty = (() => {
284
281
  if (Array.isArray(tags)) {
285
282
  result.tags = [...tags];
286
283
  }
287
- if (Array.isArray(taxonomy)) {
288
- result.taxonomy = [...taxonomy];
284
+ if (Array.isArray(semantics)) {
285
+ result.semantics = [...semantics];
289
286
  }
290
287
  if (schema) {
291
288
  result.schema = structuredClone(schema);
@@ -370,11 +367,11 @@ let DomainProperty = (() => {
370
367
  else {
371
368
  this.tags = [];
372
369
  }
373
- if (Array.isArray(init.taxonomy)) {
374
- this.taxonomy = [...init.taxonomy];
370
+ if (Array.isArray(init.semantics)) {
371
+ this.semantics = [...init.semantics];
375
372
  }
376
373
  else {
377
- this.taxonomy = [];
374
+ this.semantics = [];
378
375
  }
379
376
  if (init.schema) {
380
377
  this.schema = structuredClone(init.schema);
@@ -437,8 +434,8 @@ let DomainProperty = (() => {
437
434
  if (Array.isArray(this.tags) && this.tags.length) {
438
435
  result.tags = [...this.tags];
439
436
  }
440
- if (Array.isArray(this.taxonomy) && this.taxonomy.length) {
441
- result.taxonomy = [...this.taxonomy];
437
+ if (Array.isArray(this.semantics) && this.semantics.length) {
438
+ result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i));
442
439
  }
443
440
  if (this.schema) {
444
441
  result.schema = structuredClone(toRaw(this, this.schema));
@@ -554,6 +551,44 @@ let DomainProperty = (() => {
554
551
  const serializer = new ShapeGenerator();
555
552
  return serializer.property(this);
556
553
  }
554
+ /**
555
+ * Adds or updates a semantic to the property.
556
+ * @param semantic The semantic to add to the property.
557
+ * @throws Error if the semantic is not an property semantic.
558
+ */
559
+ addSemantic(semantic) {
560
+ const sem = DataSemantics[semantic.id];
561
+ if (!isPropertySemantic(sem)) {
562
+ throw new Error(`Invalid semantic type: ${semantic.id}. Expected a property semantic.`);
563
+ }
564
+ const index = this.semantics.findIndex((s) => s.id === semantic.id);
565
+ if (index >= 0) {
566
+ this.semantics[index] = semantic;
567
+ }
568
+ else {
569
+ this.semantics.push(semantic);
570
+ }
571
+ this.domain.notifyChange();
572
+ }
573
+ /**
574
+ * Removes a semantic from the property.
575
+ * @param semanticId The ID of the semantic to remove.
576
+ */
577
+ removeSemantic(semanticId) {
578
+ const index = this.semantics.findIndex((s) => s.id === semanticId);
579
+ if (index >= 0) {
580
+ this.semantics.splice(index, 1);
581
+ this.domain.notifyChange();
582
+ }
583
+ }
584
+ /**
585
+ * Checks if the property has a specific semantic.
586
+ * @param semanticId The ID of the semantic to check.
587
+ * @returns True if the semantic is present, false otherwise.
588
+ */
589
+ hasSemantic(semanticId) {
590
+ return this.semantics.some((s) => s.id === semanticId);
591
+ }
557
592
  };
558
593
  })();
559
594
  export { DomainProperty };
@@ -1 +1 @@
1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I,CAAC,CAAA;QAClC,CAAC;;;SA5ZU,cAAc","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainPropertyKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from './observed.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DomainPropertyAttribute,\n DomainPropertyAttributes,\n type DomainPropertyFormat,\n DomainPropertyList,\n type DomainPropertyType,\n DomainPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from './DataFormat.js'\nimport type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './Bindings.js'\nimport type { ModelValidationOptions } from '../models/types.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport { PropertySchema } from './types.js'\n\nexport interface DomainPropertySchema extends DomainElementSchema {\n kind: typeof DomainPropertyKind\n /**\n * The domain property description.\n */\n info: IThing\n /**\n * Wether the data property is required.\n */\n required?: boolean\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n taxonomy?: string[]\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers, but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DomainPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: PropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: PropertyBinding[]\n}\n\n/**\n * Represents a property within a data domain entity.\n *\n * A `DomainProperty` defines a single data element within a\n * `DomainEntity`. It specifies the data type, constraints,\n * and other metadata for a specific piece of information.\n *\n * **Key Features:**\n *\n * - **Data Type:** Defines the type of data the property\n * holds (e.g., string, number, boolean, date).\n * - **Constraints:** Supports defining constraints such as\n * minimum/maximum values, enum values, and default values.\n * - **Bindings:** Allows defining how the property is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Metadata:** Supports metadata such as tags, taxonomy,\n * read-only/write-only status, and deprecation.\n * - **Schema:** Allows defining a general schema for the\n * property, which is propagated to all bindings.\n *\n * **Usage:**\n *\n * Use the `DataEntity.addProperty` method to add a new property to an\n * entity. The property can be created using the constructor, but it\n * won't be added to the graph until you call the `addProperty` method.\n *\n * **Example:**\n *\n * ```typescript\n * const entity = dataModel.addEntity({ key: 'user' });\n * const property = entity.addProperty({\n * key: 'name',\n * type: 'string',\n * required: true,\n * schema: {\n * minimum: 3,\n * maximum: 50,\n * },\n * });\n * ```\n */\nexport class DomainProperty extends DomainElement {\n override kind: typeof DomainPropertyKind\n\n /**\n * The description of the domain property.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data property is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data property allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n @observed() accessor primary: boolean | undefined\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n @observed() accessor index: boolean | undefined\n\n /**\n * Whether the property is read only in the schema.\n */\n @observed() accessor readOnly: boolean | undefined\n\n /**\n * Whether the property is write only in the schema.\n */\n @observed() accessor writeOnly: boolean | undefined\n\n /**\n * Whether this property is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Optional general purpose tags for the UI.\n *\n * Note to implementations, use the `addTag()` method as it propagates the \"tag\" value in the namespace.\n * Also, the tags property is excluded from the observer properties.\n * Changes to this property will not notify the observers.\n */\n @observed({ deep: true }) accessor tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n @observed({ deep: true }) accessor taxonomy: string[] = []\n\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n @observed() accessor type: DomainPropertyType = 'string'\n\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n @observed({ deep: true }) accessor schema: PropertySchema | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: PropertyBinding[] = []\n\n /**\n * Creates a full data model schema with defaults.\n *\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainPropertySchema> = {}): DomainPropertySchema {\n const {\n key = nanoid(),\n multiple,\n required,\n type = DomainPropertyList.string,\n index,\n primary,\n readOnly,\n writeOnly,\n tags,\n taxonomy,\n deprecated,\n schema,\n bindings,\n } = input\n if (typeof type === 'string') {\n if (!DomainPropertyTypes.includes(type as DomainPropertyType)) {\n throw new Error(`Invalid data property type ${type}`)\n }\n }\n const info = Thing.fromJSON(input.info, { name: 'new_property' }).toJSON()\n const result: DomainPropertySchema = {\n kind: DomainPropertyKind,\n key,\n info,\n type,\n }\n if (typeof multiple === 'boolean') {\n result.multiple = multiple\n }\n if (typeof required === 'boolean') {\n result.required = required\n }\n if (typeof index === 'boolean') {\n result.index = index\n }\n if (typeof primary === 'boolean') {\n result.primary = primary\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n if (Array.isArray(tags)) {\n result.tags = [...tags]\n }\n if (Array.isArray(taxonomy)) {\n result.taxonomy = [...taxonomy]\n }\n if (schema) {\n result.schema = structuredClone(schema)\n }\n if (Array.isArray(bindings)) {\n result.bindings = bindings.map((i) => structuredClone(i))\n } else {\n result.bindings = []\n }\n return result\n }\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * Creates a new domain property instance.\n * It does not add it to the graph.\n * You need to call the `addProperty` method of the graph or a data model to add it.\n *\n * Domain objects constructors shouldn't be used directly. Use methods\n * provided on the DataDomain class to create new objects.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial domain property schema.\n * @returns Created domain property instance.\n */\n constructor(root: DataDomain, parent: string, input: Partial<DomainPropertySchema> = {}) {\n const init = DomainProperty.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainPropertyKind\n this.info = new Thing(init.info)\n this.type = init.type\n\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n } else {\n this.multiple = undefined\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n } else {\n this.required = undefined\n }\n if (typeof init.index === 'boolean') {\n this.index = init.index\n } else {\n this.index = undefined\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof init.primary === 'boolean') {\n this.primary = init.primary\n } else {\n this.primary = undefined\n }\n if (typeof init.readOnly === 'boolean') {\n this.readOnly = init.readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof init.writeOnly === 'boolean') {\n this.writeOnly = init.writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(init.tags)) {\n this.tags = [...init.tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(init.taxonomy)) {\n this.taxonomy = [...init.taxonomy]\n } else {\n this.taxonomy = []\n }\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n /**\n * Checks whether the input is a valid definition of a domain property.\n *\n * @param input The input to validate.\n * @param options Validation options.\n * @returns true when the passed input is a valid definition of a domain property.\n */\n static validate(input: unknown, options: ModelValidationOptions = {}): boolean {\n if (!input || (typeof input !== 'object' && input !== null)) {\n return false\n }\n const typed = input as DomainPropertySchema\n if (options.strict && typed.kind !== DomainPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): DomainPropertySchema {\n const result: DomainPropertySchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n type: this.type || DomainPropertyList.string,\n }\n if (typeof this.index === 'boolean') {\n result.index = this.index\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n if (typeof this.primary === 'boolean') {\n result.primary = this.primary\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (typeof this.readOnly === 'boolean') {\n result.readOnly = this.readOnly\n }\n if (typeof this.writeOnly === 'boolean') {\n result.writeOnly = this.writeOnly\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes this property from the parent entity.\n * It calls the `removeProperty()` method of the parent entity.\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeProperty(this.key)\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Checks whether the passed value is one of the supported data types.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data types.\n */\n static isValidType(value: unknown): value is DomainPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyTypes.includes(value as DomainPropertyType)\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyAttributes.includes(value as DomainPropertyAttribute)\n }\n\n /**\n * Checks whether the passed value of one of the supported `format` values.\n *\n * @param value The value to test\n * @returns `true` when the value is one of the supported `format` values.\n */\n static isValidFormat(value: unknown): value is DomainPropertyFormat {\n if (value === undefined) {\n // It is the valid value.\n return true\n }\n if (typeof value !== 'string') {\n return false\n }\n if (NumberFormats.includes(value as NumberFormat)) {\n return true\n }\n if (BinaryFormats.includes(value as BinaryFormat)) {\n return true\n }\n return false\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): PropertySchema {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): PropertyWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as PropertyBinding\n this.bindings.push(object)\n }\n return object.schema as PropertyWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): PropertyBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as PropertyBinding\n return item?.schema || undefined\n }\n\n /**\n * Creates a Property Shape of AMF.\n *\n * The property itself is auto-generated. If the `schema` is\n * defined then it is used as the `range` of the property.\n * Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this\n * synchronizes changed data properties with the shape\n * definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.property(this)\n }\n}\n"]}
1
+ {"version":3,"file":"DomainProperty.js","sourceRoot":"","sources":["../../../src/modeling/DomainProperty.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,aAAa,EAA4B,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAEL,aAAa,EAEb,wBAAwB,EAExB,kBAAkB,EAElB,mBAAmB,EAEnB,aAAa,GACd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAMxD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAA+C,MAAM,gBAAgB,CAAA;AAqE/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;IACU,cAAc;sBAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAApC,cAAe,SAAQ,WAAa;;;gCAM9C,cAAc,EAAE;oCAKhB,QAAQ,EAAE;oCAKV,QAAQ,EAAE;mCAKV,QAAQ,EAAE;iCAKV,QAAQ,EAAE;oCAKV,QAAQ,EAAE;qCAKV,QAAQ,EAAE;sCAKV,QAAQ,EAAE;gCASV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;qCAKxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gCASxB,QAAQ,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AC;gBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;gBAC/B,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;YAC5B,CAAC;QACH,CAAC;QAED;;;;WAIG;QACH,WAAW,CAAC,UAAwB;YAClC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAA;QACxD,CAAC;;;SAlcU,cAAc","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainPropertyKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from './observed.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DomainPropertyAttribute,\n DomainPropertyAttributes,\n type DomainPropertyFormat,\n DomainPropertyList,\n type DomainPropertyType,\n DomainPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from './DataFormat.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './Bindings.js'\nimport type { ModelValidationOptions } from '../models/types.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { PropertySchema } from './types.js'\nimport { DataSemantics, isPropertySemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\n\nexport interface DomainPropertySchema extends DomainElementSchema {\n kind: typeof DomainPropertyKind\n /**\n * The domain property description.\n */\n info: IThing\n /**\n * Wether the data property is required.\n */\n required?: boolean\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n /**\n * The semantics applied to this property.\n * This is a list of applied semantics that can be used to\n * describe the property in more detail.\n */\n semantics?: AppliedDataSemantic[]\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers, but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DomainPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: PropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: PropertyBinding[]\n}\n\n/**\n * Represents a property within a data domain entity.\n *\n * A `DomainProperty` defines a single data element within a\n * `DomainEntity`. It specifies the data type, constraints,\n * and other metadata for a specific piece of information.\n *\n * **Key Features:**\n *\n * - **Data Type:** Defines the type of data the property\n * holds (e.g., string, number, boolean, date).\n * - **Constraints:** Supports defining constraints such as\n * minimum/maximum values, enum values, and default values.\n * - **Bindings:** Allows defining how the property is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Metadata:** Supports metadata such as tags, semantics,\n * read-only/write-only status, and deprecation.\n * - **Schema:** Allows defining a general schema for the\n * property, which is propagated to all bindings.\n *\n * **Usage:**\n *\n * Use the `DomainEntity.addProperty` method to add a new property to an\n * entity. The property can be created using the constructor, but it\n * won't be added to the graph until you call the `addProperty` method.\n *\n * **Example:**\n *\n * ```typescript\n * const entity = domainModel.addEntity({ key: 'user' });\n * const property = entity.addProperty({\n * key: 'name',\n * type: 'string',\n * required: true,\n * schema: {\n * minimum: 3,\n * maximum: 50,\n * },\n * });\n * ```\n */\nexport class DomainProperty extends DomainElement {\n override kind: typeof DomainPropertyKind\n\n /**\n * The description of the domain property.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data property is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data property allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n @observed() accessor primary: boolean | undefined\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n @observed() accessor index: boolean | undefined\n\n /**\n * Whether the property is read only in the schema.\n */\n @observed() accessor readOnly: boolean | undefined\n\n /**\n * Whether the property is write only in the schema.\n */\n @observed() accessor writeOnly: boolean | undefined\n\n /**\n * Whether this property is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Optional general purpose tags for the UI.\n *\n * Note to implementations, use the `addTag()` method as it propagates the \"tag\" value in the namespace.\n * Also, the tags property is excluded from the observer properties.\n * Changes to this property will not notify the observers.\n */\n @observed({ deep: true }) accessor tags: string[] = []\n\n /**\n * Semantics applied to this property.\n */\n @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []\n\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n @observed() accessor type: DomainPropertyType = 'string'\n\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n @observed({ deep: true }) accessor schema: PropertySchema | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: PropertyBinding[] = []\n\n /**\n * Creates a full data model schema with defaults.\n *\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainPropertySchema> = {}): DomainPropertySchema {\n const {\n key = nanoid(),\n multiple,\n required,\n type = DomainPropertyList.string,\n index,\n primary,\n readOnly,\n writeOnly,\n tags,\n semantics,\n deprecated,\n schema,\n bindings,\n } = input\n if (typeof type === 'string') {\n if (!DomainPropertyTypes.includes(type as DomainPropertyType)) {\n throw new Error(`Invalid data property type ${type}`)\n }\n }\n const info = Thing.fromJSON(input.info, { name: 'new_property' }).toJSON()\n const result: DomainPropertySchema = {\n kind: DomainPropertyKind,\n key,\n info,\n type,\n }\n if (typeof multiple === 'boolean') {\n result.multiple = multiple\n }\n if (typeof required === 'boolean') {\n result.required = required\n }\n if (typeof index === 'boolean') {\n result.index = index\n }\n if (typeof primary === 'boolean') {\n result.primary = primary\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n if (Array.isArray(tags)) {\n result.tags = [...tags]\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\n }\n if (schema) {\n result.schema = structuredClone(schema)\n }\n if (Array.isArray(bindings)) {\n result.bindings = bindings.map((i) => structuredClone(i))\n } else {\n result.bindings = []\n }\n return result\n }\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * Creates a new domain property instance.\n * It does not add it to the graph.\n * You need to call the `addProperty` method of the graph or a data model to add it.\n *\n * Domain objects constructors shouldn't be used directly. Use methods\n * provided on the DataDomain class to create new objects.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial domain property schema.\n * @returns Created domain property instance.\n */\n constructor(root: DataDomain, parent: string, input: Partial<DomainPropertySchema> = {}) {\n const init = DomainProperty.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainPropertyKind\n this.info = new Thing(init.info)\n this.type = init.type\n\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n } else {\n this.multiple = undefined\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n } else {\n this.required = undefined\n }\n if (typeof init.index === 'boolean') {\n this.index = init.index\n } else {\n this.index = undefined\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof init.primary === 'boolean') {\n this.primary = init.primary\n } else {\n this.primary = undefined\n }\n if (typeof init.readOnly === 'boolean') {\n this.readOnly = init.readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof init.writeOnly === 'boolean') {\n this.writeOnly = init.writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(init.tags)) {\n this.tags = [...init.tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(init.semantics)) {\n this.semantics = [...init.semantics]\n } else {\n this.semantics = []\n }\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n /**\n * Checks whether the input is a valid definition of a domain property.\n *\n * @param input The input to validate.\n * @param options Validation options.\n * @returns true when the passed input is a valid definition of a domain property.\n */\n static validate(input: unknown, options: ModelValidationOptions = {}): boolean {\n if (!input || (typeof input !== 'object' && input !== null)) {\n return false\n }\n const typed = input as DomainPropertySchema\n if (options.strict && typed.kind !== DomainPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): DomainPropertySchema {\n const result: DomainPropertySchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n type: this.type || DomainPropertyList.string,\n }\n if (typeof this.index === 'boolean') {\n result.index = this.index\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n if (typeof this.primary === 'boolean') {\n result.primary = this.primary\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (typeof this.readOnly === 'boolean') {\n result.readOnly = this.readOnly\n }\n if (typeof this.writeOnly === 'boolean') {\n result.writeOnly = this.writeOnly\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.semantics) && this.semantics.length) {\n result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes this property from the parent entity.\n * It calls the `removeProperty()` method of the parent entity.\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeProperty(this.key)\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Checks whether the passed value is one of the supported data types.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data types.\n */\n static isValidType(value: unknown): value is DomainPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyTypes.includes(value as DomainPropertyType)\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyAttributes.includes(value as DomainPropertyAttribute)\n }\n\n /**\n * Checks whether the passed value of one of the supported `format` values.\n *\n * @param value The value to test\n * @returns `true` when the value is one of the supported `format` values.\n */\n static isValidFormat(value: unknown): value is DomainPropertyFormat {\n if (value === undefined) {\n // It is the valid value.\n return true\n }\n if (typeof value !== 'string') {\n return false\n }\n if (NumberFormats.includes(value as NumberFormat)) {\n return true\n }\n if (BinaryFormats.includes(value as BinaryFormat)) {\n return true\n }\n return false\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): PropertySchema {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): PropertyWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as PropertyBinding\n this.bindings.push(object)\n }\n return object.schema as PropertyWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): PropertyBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as PropertyBinding\n return item?.schema || undefined\n }\n\n /**\n * Creates a Property Shape of AMF.\n *\n * The property itself is auto-generated. If the `schema` is\n * defined then it is used as the `range` of the property.\n * Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this\n * synchronizes changed data properties with the shape\n * definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.property(this)\n }\n\n /**\n * Adds or updates a semantic to the property.\n * @param semantic The semantic to add to the property.\n * @throws Error if the semantic is not an property semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isPropertySemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected a property semantic.`)\n }\n const index = this.semantics.findIndex((s) => s.id === semantic.id)\n if (index >= 0) {\n this.semantics[index] = semantic\n } else {\n this.semantics.push(semantic)\n }\n this.domain.notifyChange()\n }\n\n /**\n * Removes a semantic from the property.\n * @param semanticId The ID of the semantic to remove.\n */\n removeSemantic(semanticId: SemanticType): void {\n const index = this.semantics.findIndex((s) => s.id === semanticId)\n if (index >= 0) {\n this.semantics.splice(index, 1)\n this.domain.notifyChange()\n }\n }\n\n /**\n * Checks if the property has a specific semantic.\n * @param semanticId The ID of the semantic to check.\n * @returns True if the semantic is present, false otherwise.\n */\n hasSemantic(semanticId: SemanticType): boolean {\n return this.semantics.some((s) => s.id === semanticId)\n }\n}\n"]}