@api-client/core 0.14.1 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/build/src/browser.d.ts +1 -1
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js.map +1 -1
  4. package/build/src/index.d.ts +2 -1
  5. package/build/src/index.d.ts.map +1 -1
  6. package/build/src/index.js +1 -0
  7. package/build/src/index.js.map +1 -1
  8. package/build/src/modeling/ApiFile.d.ts +23 -0
  9. package/build/src/modeling/ApiFile.d.ts.map +1 -0
  10. package/build/src/modeling/ApiFile.js +44 -0
  11. package/build/src/modeling/ApiFile.js.map +1 -0
  12. package/build/src/modeling/ApiModel.d.ts +159 -0
  13. package/build/src/modeling/ApiModel.d.ts.map +1 -0
  14. package/build/src/modeling/ApiModel.js +237 -0
  15. package/build/src/modeling/ApiModel.js.map +1 -0
  16. package/build/src/modeling/DataDomain.d.ts +1 -1
  17. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  18. package/build/src/modeling/DataDomain.js +1 -3
  19. package/build/src/modeling/DataDomain.js.map +1 -1
  20. package/build/src/modeling/DomainAssociation.d.ts +35 -0
  21. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  22. package/build/src/modeling/DomainAssociation.js +42 -5
  23. package/build/src/modeling/DomainAssociation.js.map +1 -1
  24. package/build/src/modeling/DomainEntity.js +1 -1
  25. package/build/src/modeling/DomainEntity.js.map +1 -1
  26. package/build/src/modeling/DomainFile.d.ts +1 -2
  27. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  28. package/build/src/modeling/DomainFile.js +3 -41
  29. package/build/src/modeling/DomainFile.js.map +1 -1
  30. package/build/src/modeling/Semantics.d.ts +62 -7
  31. package/build/src/modeling/Semantics.d.ts.map +1 -1
  32. package/build/src/modeling/Semantics.js +76 -7
  33. package/build/src/modeling/Semantics.js.map +1 -1
  34. package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
  35. package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
  36. package/build/src/modeling/types.d.ts +491 -0
  37. package/build/src/modeling/types.d.ts.map +1 -1
  38. package/build/src/modeling/types.js.map +1 -1
  39. package/build/src/models/kinds.d.ts +2 -0
  40. package/build/src/models/kinds.d.ts.map +1 -1
  41. package/build/src/models/kinds.js +2 -0
  42. package/build/src/models/kinds.js.map +1 -1
  43. package/build/src/models/store/File.d.ts +19 -2
  44. package/build/src/models/store/File.d.ts.map +1 -1
  45. package/build/src/models/store/File.js +100 -13
  46. package/build/src/models/store/File.js.map +1 -1
  47. package/build/tsconfig.tsbuildinfo +1 -1
  48. package/data/models/APIC-187.json +3 -3
  49. package/data/models/APIC-188.json +3 -3
  50. package/data/models/APIC-233.json +1 -1
  51. package/data/models/APIC-391.json +2 -2
  52. package/data/models/APIC-483.json +1 -1
  53. package/data/models/APIC-487.json +1 -1
  54. package/data/models/APIC-655.json +1 -1
  55. package/data/models/APIC-689.json +1 -1
  56. package/data/models/APIC-690.json +5 -5
  57. package/data/models/SE-10469.json +1 -1
  58. package/data/models/SE-13092.json +5 -5
  59. package/data/models/SE-22063.json +12 -2
  60. package/data/models/amf-helper-api.json +154 -14
  61. package/data/models/arc-demo-api.json +95 -15
  62. package/data/models/async-api.json +1 -1
  63. package/data/models/example-generator-api.json +361 -21
  64. package/data/models/expanded-api.json +1 -1
  65. package/data/models/flattened-api.json +1 -1
  66. package/data/models/multiple-servers.json +1 -1
  67. package/data/models/oas-3-api.json +1 -1
  68. package/data/models/oas-date.json +1 -1
  69. package/data/models/oas-types.json +1 -1
  70. package/data/models/oas-unions.json +1 -1
  71. package/data/models/petstore.json +1 -1
  72. package/data/models/raml-date.json +1 -1
  73. package/data/models/recursive.json +1 -1
  74. package/data/models/schema-api.json +62 -2
  75. package/data/models/secured-api.json +16 -16
  76. package/data/models/tracked-to-linked.json +4 -4
  77. package/package.json +3 -4
  78. package/src/modeling/ApiFile.ts +53 -0
  79. package/src/modeling/ApiModel.ts +327 -0
  80. package/src/modeling/DataDomain.ts +1 -1
  81. package/src/modeling/DomainAssociation.ts +56 -0
  82. package/src/modeling/DomainEntity.ts +1 -1
  83. package/src/modeling/DomainFile.ts +3 -40
  84. package/src/modeling/Semantics.ts +79 -7
  85. package/src/modeling/amf/ShapeGenerator.ts +1 -1
  86. package/src/modeling/types.ts +545 -0
  87. package/src/models/kinds.ts +2 -0
  88. package/src/models/store/File.ts +100 -13
  89. package/tests/unit/modeling/api_model.spec.ts +291 -0
  90. package/tests/unit/modeling/domain_asociation.spec.ts +92 -2
  91. package/tests/unit/modeling/domain_entity.spec.ts +15 -15
  92. package/tests/unit/modeling/domain_file.spec.ts +1 -11
  93. package/tests/unit/modeling/domain_model_entities.spec.ts +2 -2
  94. package/tests/unit/modeling/semantics.spec.ts +146 -0
  95. package/tests/unit/models/File/constructor.spec.ts +3 -2
  96. package/tests/unit/models/File/shortcutTo.spec.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DomainAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DomainAssociation.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,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;AAI/D,OAAO,EAA4B,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAA+C,MAAM,gBAAgB,CAAA;AA8ClH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;IACU,iBAAiB;sBAAS,aAAa;;;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,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAA;QACxD,CAAC;;;SAlbU,iBAAiB","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainAssociationKind } 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 type { DomainEntity } from './DomainEntity.js'\nimport type { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DomainAttributeAttribute, DomainAttributeAttributes } from './DataFormat.js'\nimport type { AssociationTarget, DomainGraphEdge } from './types.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport { DataSemantics, isAssociationSemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\n\nexport interface DomainAssociationSchema extends DomainElementSchema {\n kind: typeof DomainAssociationKind\n /**\n * The data association description.\n */\n info: IThing\n /**\n * Wether the data association is required.\n */\n required?: boolean\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\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?: AssociationBinding[]\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets?: AssociationTarget[]\n /**\n * The semantics applied to this association.\n * This is a list of applied semantics that can be used to\n * describe the association in more detail.\n */\n semantics?: AppliedDataSemantic[]\n}\n\n/**\n * Represents an association between entities in a data domain.\n *\n * A `DomainAssociation` defines a relationship between a\n * `DomainEntity` and one or more other entities. It specifies\n * how entities are connected and can represent various types\n * of relationships, such as one-to-one, one-to-many, or\n * many-to-many.\n *\n * **Key Features:**\n *\n * - **Target Entities:** Specifies the entities that are\n * the target of the association.\n * - **Cardinality:** Defines whether the association is\n * single-valued or multi-valued (e.g., one-to-one vs.\n * one-to-many).\n * - **Required Status:** Indicates whether the association\n * is mandatory or optional.\n * - **Schema Customization:** Allows defining a custom\n * schema for the association, overriding the default\n * schema derived from the target entities.\n * - **Bindings:** Supports defining how the association is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Foreign Namespaces:** Can target entities in other\n * namespaces, enabling cross-namespace relationships.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainAssociation` is\n * through the `DomainEntity.addAssociation()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userModel = dataDomain.addModel({ key: 'userModel' });\n * const userEntity = userModel.addEntity({ key: 'user' });\n * const addressEntity = userModel.addEntity({ key: 'address' });\n * // Add an association from User to Address\n * const addressAssociation = userEntity.addAssociation();\n * addressAssociation.addTarget(addressEntity);\n * ```\n */\nexport class DomainAssociation extends DomainElement {\n /**\n * The kind of the domain element.\n */\n override kind: typeof DomainAssociationKind\n\n /**\n * The description of the association namespace.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data association is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data association allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * The schema allowing to translate the model into a\n * specific format (like JSON, RAML, XML, etc.)\n */\n @observed({ deep: true }) accessor schema: IApiAssociationShape | 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: AssociationBinding[]\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n @observed({ deep: true }) accessor targets: AssociationTarget[]\n\n /**\n * Semantics applied to this association.\n */\n @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []\n\n /**\n * Creates a full data association schema with defaults.\n *\n * @param input The partial data association schema.\n * @returns The data association schema.\n */\n static createSchema(input: Partial<DomainAssociationSchema> = {}): DomainAssociationSchema {\n const { key = nanoid(), semantics = [] } = input\n const info = Thing.fromJSON(input.info, { name: 'new_association' }).toJSON()\n const result: DomainAssociationSchema = {\n kind: DomainAssociationKind,\n key,\n info,\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\n }\n if (input.schema) {\n result.schema = structuredClone(input.schema)\n }\n if (typeof input.multiple === 'boolean') {\n result.multiple = input.multiple\n }\n if (typeof input.required === 'boolean') {\n result.required = input.required\n }\n if (Array.isArray(input.bindings)) {\n result.bindings = input.bindings.map((i) => structuredClone(i))\n }\n if (Array.isArray(input.targets)) {\n result.targets = input.targets.map((i) => ({ ...i }))\n }\n return result\n }\n\n /**\n * Creates a new data association instance.\n *\n * You probably want to use the `DomainEntity.addAssociation()` method instead.\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 data association schema.\n */\n constructor(root: DataDomain, parent: string, input?: Partial<DomainAssociationSchema>) {\n const init = DomainAssociation.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainAssociationKind\n this.info = new Thing(init.info)\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n }\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n if (Array.isArray(init.targets)) {\n this.targets = init.targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n if (Array.isArray(init.semantics)) {\n this.semantics = init.semantics.map((item) => structuredClone(item))\n } else {\n this.semantics = []\n }\n }\n\n /**\n * Generates a JSON representation of the association.\n *\n * @returns A plain object representation of the `DomainAssociation`.\n */\n toJSON(): DomainAssociationSchema {\n const result: DomainAssociationSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\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 (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n if (Array.isArray(this.targets) && this.targets.length) {\n result.targets = toRaw(this, this.targets)?.map((i) => ({ ...i }))\n }\n if (Array.isArray(this.semantics) && this.semantics.length) {\n result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n *\n * @returns The parent `DomainEntity` or undefined if not found.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Removes this property from the parent entity.\n *\n * This method removes the association from the parent\n * entity's list of associations.\n *\n * @example\n * ```typescript\n * association.remove();\n * ```\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeAssociation(this.key)\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n *\n * @returns The schema object.\n * @example\n * ```typescript\n * const schema = association.ensureSchema();\n * ```\n */\n ensureSchema(): IApiAssociationShape {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Checks whether the passed value is one of the supported\n * data property attributes.\n *\n * @param value The value to test\n * @returns True when the passed value is one of the\n * supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainAttributeAttributes.includes(value as DomainAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings\n * definition.\n *\n * @returns The web binding definition\n * @example\n * ```typescript\n * const webBindings = association.getWebBinding();\n * webBindings.hidden = true;\n * ```\n */\n getWebBinding(): AssociationWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as AssociationBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as AssociationBinding\n this.bindings.push(object)\n this.domain.notifyChange()\n }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was\n * created.\n *\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n * @example\n * ```typescript\n * const webBindings = association.readBinding('web');\n * if (webBindings) {\n * // ...\n * }\n * ```\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema || undefined\n }\n\n /**\n * Adds a target entity to the association.\n *\n * If the entity comes from another namespace then it is\n * set as a foreign entity.\n *\n * @param entity - The `DomainEntity` instance to add.\n * @example\n * ```typescript\n * association.addTarget(addressEntity);\n * ```\n */\n addTarget(entity: DomainEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `DomainEntity` definition or just\n * its key.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local\n * entities.\n * @example\n * ```typescript\n * association.addTarget('address', 'foreignNamespace');\n * ```\n */\n addTarget(entity: string, namespace?: string): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local entities.\n */\n addTarget(init: string | DomainEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n if (init.domain.key !== this.root.key) {\n namespace = init.domain.key\n }\n }\n if (this.targets.some((i) => i.key === key && i.domain === namespace)) {\n const message = `Target ${key} already exists.`\n throw new Error(message)\n }\n if (namespace && !this.root.dependencies.has(namespace)) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.domain = namespace\n }\n this.targets.push(info)\n const targetKey = namespace ? `${namespace}:${key}` : key\n const label: DomainGraphEdge = {\n type: 'association',\n }\n if (namespace) {\n label.domain = namespace\n label.foreign = true\n }\n // We need to associate the target with the association\n // in the graph. This way, when looking for associations\n // on a target entities we can easily locate the\n // association.\n this.root.graph.setEdge(this.key, targetKey, label)\n // this.root.notifyChange()\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or\n * schema.\n * @example\n * ```typescript\n * association.removeTarget(addressEntity);\n * ```\n */\n removeTarget(init: string | DomainEntity): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n }\n const index = this.targets.findIndex((i) => i.key === key)\n if (index >= 0) {\n this.targets.splice(index, 1)\n // this.root.notifyChange()\n }\n this.root.graph.removeEdge(this.key, key)\n }\n\n /**\n * Lists all target entities of this association.\n *\n * @returns A generator that yields each target\n * `DomainEntity`.\n * @example\n * ```typescript\n * for (const target of association.listTargets()) {\n * console.log(target.key);\n * }\n * ```\n */\n *listTargets(): Generator<DomainEntity> {\n for (const target of this.targets) {\n const { key, domain } = target\n const targetKey = domain ? `${domain}:${key}` : key\n const entity = this.root.graph.node(targetKey) as DomainEntity | undefined\n if (entity) {\n yield entity\n }\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.associationProperty(this)\n }\n\n /**\n * Adds or updates a semantic to the association.\n * @param semantic The semantic to add to the association.\n * @throws Error if the semantic is not an association semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isAssociationSemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected an association 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 association.\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 association 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"]}
1
+ {"version":3,"file":"DomainAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DomainAssociation.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,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;AAI/D,OAAO,EAA4B,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAA+C,MAAM,gBAAgB,CAAA;AA0ElH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;IACU,iBAAiB;sBAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAvC,iBAAkB,SAAQ,WAAa;;;gCASjD,cAAc,EAAE;oCAKhB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AAqB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,EAAE,qCAAqC,CAAC,CAAA;YAC7F,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAA;YACnE,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAA;YAClC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAC/B,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;QAC5B,CAAC;QAED;;;WAGG;QACH,cAAc,CAAC,UAAwB;YACrC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAA;YAClE,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;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;;;SA9cU,iBAAiB","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainAssociationKind } 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 type { DomainEntity } from './DomainEntity.js'\nimport type { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DomainAttributeAttribute, DomainAttributeAttributes } from './DataFormat.js'\nimport type { AssociationTarget, DomainGraphEdge } from './types.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport { DataSemantics, isAssociationSemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\n\n/**\n * Defines the behavior when a parent entity in an association is deleted.\n *\n * - `restrict`: Prevents the deletion of a parent entity if it has any associated child entities.\n * The generated API should return a clear and specific error message (e.g., 409 Conflict).\n * - _Example_: Do not allow a Department to be deleted if it still has Employees.\n * - `cascade`: Automatically deletes all associated child entities when the parent entity is deleted.\n * - _Example_: Deleting a User will also delete all their associated Posts and Comments.\n * - `setNull`: Sets the foreign key of the associated child entities to NULL. This is only valid if the\n * association property on the child entity is nullable.\n * - _Example_: When a `Project` is deleted, the `project_id` on associated `Tasks` is set to NULL,\n * making them unassigned but not deleting them.\n * - `doNothing`: No action is taken on the associated child entities when the parent entity is deleted.\n * - _Example_: Deleting a `Category` does not affect associated `Products`, which remain in the database\n * but may become orphaned.\n * This is useful when the association is optional or when child entities should not be deleted\n * or modified upon the deletion of a parent entity.\n */\nexport type OnDeleteRule = 'restrict' | 'cascade' | 'setNull' | 'doNothing'\n\nexport interface DomainAssociationSchema extends DomainElementSchema {\n kind: typeof DomainAssociationKind\n /**\n * The data association description.\n */\n info: IThing\n /**\n * Wether the data association is required.\n */\n required?: boolean\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\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?: AssociationBinding[]\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets?: AssociationTarget[]\n /**\n * The semantics applied to this association.\n * This is a list of applied semantics that can be used to\n * describe the association in more detail.\n */\n semantics?: AppliedDataSemantic[]\n /**\n * Defines the behavior when a parent entity in an association is deleted.\n */\n onDelete?: OnDeleteRule\n /**\n * Whether the association is read-only.\n */\n readOnly?: boolean\n}\n\n/**\n * Represents an association between entities in a data domain.\n *\n * A `DomainAssociation` defines a relationship between a\n * `DomainEntity` and one or more other entities. It specifies\n * how entities are connected and can represent various types\n * of relationships, such as one-to-one, one-to-many, or\n * many-to-many.\n *\n * **Key Features:**\n *\n * - **Target Entities:** Specifies the entities that are\n * the target of the association.\n * - **Cardinality:** Defines whether the association is\n * single-valued or multi-valued (e.g., one-to-one vs.\n * one-to-many).\n * - **Required Status:** Indicates whether the association\n * is mandatory or optional.\n * - **Schema Customization:** Allows defining a custom\n * schema for the association, overriding the default\n * schema derived from the target entities.\n * - **Bindings:** Supports defining how the association is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Foreign Namespaces:** Can target entities in other\n * namespaces, enabling cross-namespace relationships.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainAssociation` is\n * through the `DomainEntity.addAssociation()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userModel = dataDomain.addModel({ key: 'userModel' });\n * const userEntity = userModel.addEntity({ key: 'user' });\n * const addressEntity = userModel.addEntity({ key: 'address' });\n * // Add an association from User to Address\n * const addressAssociation = userEntity.addAssociation();\n * addressAssociation.addTarget(addressEntity);\n * ```\n */\nexport class DomainAssociation extends DomainElement {\n /**\n * The kind of the domain element.\n */\n override kind: typeof DomainAssociationKind\n\n /**\n * The description of the association namespace.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data association is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data association allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * The schema allowing to translate the model into a\n * specific format (like JSON, RAML, XML, etc.)\n */\n @observed({ deep: true }) accessor schema: IApiAssociationShape | 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: AssociationBinding[]\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n @observed({ deep: true }) accessor targets: AssociationTarget[]\n\n /**\n * Semantics applied to this association.\n */\n @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []\n\n /**\n * Defines the behavior when a parent entity in an association is deleted.\n */\n @observed() accessor onDelete: OnDeleteRule | undefined\n\n /**\n * Whether the association is read-only.\n */\n @observed() accessor readOnly: boolean | undefined\n\n /**\n * Creates a full data association schema with defaults.\n *\n * @param input The partial data association schema.\n * @returns The data association schema.\n */\n static createSchema(input: Partial<DomainAssociationSchema> = {}): DomainAssociationSchema {\n const { key = nanoid(), semantics = [] } = input\n const info = Thing.fromJSON(input.info, { name: 'new_association' }).toJSON()\n const result: DomainAssociationSchema = {\n kind: DomainAssociationKind,\n key,\n info,\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\n }\n if (input.onDelete) {\n result.onDelete = input.onDelete\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (input.schema) {\n result.schema = structuredClone(input.schema)\n }\n if (typeof input.multiple === 'boolean') {\n result.multiple = input.multiple\n }\n if (typeof input.required === 'boolean') {\n result.required = input.required\n }\n if (Array.isArray(input.bindings)) {\n result.bindings = input.bindings.map((i) => structuredClone(i))\n }\n if (Array.isArray(input.targets)) {\n result.targets = input.targets.map((i) => ({ ...i }))\n }\n return result\n }\n\n /**\n * Creates a new data association instance.\n *\n * You probably want to use the `DomainEntity.addAssociation()` method instead.\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 data association schema.\n */\n constructor(root: DataDomain, parent: string, input?: Partial<DomainAssociationSchema>) {\n const init = DomainAssociation.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainAssociationKind\n this.info = new Thing(init.info)\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n }\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n if (Array.isArray(init.targets)) {\n this.targets = init.targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n if (Array.isArray(init.semantics)) {\n this.semantics = init.semantics.map((item) => structuredClone(item))\n } else {\n this.semantics = []\n }\n if (init.onDelete) {\n this.onDelete = init.onDelete\n }\n if (typeof init.readOnly === 'boolean') {\n this.readOnly = init.readOnly\n }\n }\n\n /**\n * Generates a JSON representation of the association.\n *\n * @returns A plain object representation of the `DomainAssociation`.\n */\n toJSON(): DomainAssociationSchema {\n const result: DomainAssociationSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\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 (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n if (Array.isArray(this.targets) && this.targets.length) {\n result.targets = toRaw(this, this.targets)?.map((i) => ({ ...i }))\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.onDelete) {\n result.onDelete = this.onDelete\n }\n if (typeof this.readOnly === 'boolean' && this.readOnly) {\n result.readOnly = this.readOnly\n }\n return result\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n *\n * @returns The parent `DomainEntity` or undefined if not found.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Removes this property from the parent entity.\n *\n * This method removes the association from the parent\n * entity's list of associations.\n *\n * @example\n * ```typescript\n * association.remove();\n * ```\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeAssociation(this.key)\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n *\n * @returns The schema object.\n * @example\n * ```typescript\n * const schema = association.ensureSchema();\n * ```\n */\n ensureSchema(): IApiAssociationShape {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Checks whether the passed value is one of the supported\n * data property attributes.\n *\n * @param value The value to test\n * @returns True when the passed value is one of the\n * supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainAttributeAttributes.includes(value as DomainAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings\n * definition.\n *\n * @returns The web binding definition\n * @example\n * ```typescript\n * const webBindings = association.getWebBinding();\n * webBindings.hidden = true;\n * ```\n */\n getWebBinding(): AssociationWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as AssociationBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as AssociationBinding\n this.bindings.push(object)\n this.domain.notifyChange()\n }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was\n * created.\n *\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n * @example\n * ```typescript\n * const webBindings = association.readBinding('web');\n * if (webBindings) {\n * // ...\n * }\n * ```\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema || undefined\n }\n\n /**\n * Adds a target entity to the association.\n *\n * If the entity comes from another namespace then it is\n * set as a foreign entity.\n *\n * @param entity - The `DomainEntity` instance to add.\n * @example\n * ```typescript\n * association.addTarget(addressEntity);\n * ```\n */\n addTarget(entity: DomainEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `DomainEntity` definition or just\n * its key.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local\n * entities.\n * @example\n * ```typescript\n * association.addTarget('address', 'foreignNamespace');\n * ```\n */\n addTarget(entity: string, namespace?: string): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this\n * entity belongs to. Do not set this value for local entities.\n */\n addTarget(init: string | DomainEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n if (init.domain.key !== this.root.key) {\n namespace = init.domain.key\n }\n }\n if (this.targets.some((i) => i.key === key && i.domain === namespace)) {\n const message = `Target ${key} already exists.`\n throw new Error(message)\n }\n if (namespace && !this.root.dependencies.has(namespace)) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.domain = namespace\n }\n this.targets.push(info)\n const targetKey = namespace ? `${namespace}:${key}` : key\n const label: DomainGraphEdge = {\n type: 'association',\n }\n if (namespace) {\n label.domain = namespace\n label.foreign = true\n }\n // We need to associate the target with the association\n // in the graph. This way, when looking for associations\n // on a target entities we can easily locate the\n // association.\n this.root.graph.setEdge(this.key, targetKey, label)\n // this.root.notifyChange()\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or\n * schema.\n * @example\n * ```typescript\n * association.removeTarget(addressEntity);\n * ```\n */\n removeTarget(init: string | DomainEntity): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n }\n const index = this.targets.findIndex((i) => i.key === key)\n if (index >= 0) {\n this.targets.splice(index, 1)\n // this.root.notifyChange()\n }\n this.root.graph.removeEdge(this.key, key)\n }\n\n /**\n * Lists all target entities of this association.\n *\n * @returns A generator that yields each target\n * `DomainEntity`.\n * @example\n * ```typescript\n * for (const target of association.listTargets()) {\n * console.log(target.key);\n * }\n * ```\n */\n *listTargets(): Generator<DomainEntity> {\n for (const target of this.targets) {\n const { key, domain } = target\n const targetKey = domain ? `${domain}:${key}` : key\n const entity = this.root.graph.node(targetKey) as DomainEntity | undefined\n if (entity) {\n yield entity\n }\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.associationProperty(this)\n }\n\n /**\n * Adds or updates a semantic to the association.\n * @param semantic The semantic to add to the association.\n * @throws Error if the semantic is not an association semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isAssociationSemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected an association 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 association.\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 association 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"]}
@@ -150,7 +150,7 @@ let DomainEntity = (() => {
150
150
  */
151
151
  static createSchema(input = {}) {
152
152
  const { key = nanoid(), tags, semantics, fields, deprecated } = input;
153
- const info = Thing.fromJSON(input.info, { name: 'New entity' }).toJSON();
153
+ const info = Thing.fromJSON(input.info, { name: 'new_entity' }).toJSON();
154
154
  const result = {
155
155
  kind: DomainEntityKind,
156
156
  key,
@@ -1 +1 @@
1
- {"version":3,"file":"DomainEntity.js","sourceRoot":"","sources":["../../../src/modeling/DomainEntity.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAChG,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;AAE/D,OAAO,EAAE,cAAc,EAA6B,MAAM,qBAAqB,CAAA;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACpF,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAA;AAKnF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAA+C,MAAM,gBAAgB,CAAA;AA+C7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;IACU,YAAY;sBA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YACxF,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAC,CAAA;YACnE,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAA;YAClC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAC/B,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;QAC5B,CAAC;QAED;;;WAGG;QACH,cAAc,CAAC,UAAwB;YACrC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAA;YAClE,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;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;;;SApvBU,YAAY","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainAssociationKind, DomainEntityKind, 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 type { IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { DomainProperty, type DomainPropertySchema } from './DomainProperty.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'\nimport type { AssociationAddOptions } from './types.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport type { DomainModel } from './DomainModel.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport { ValidationError } from '../exceptions/validation_error.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport type { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { DataSemantics, isEntitySemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\n\nexport interface EntityOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'property' | 'association'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainEntitySchema extends DomainElementSchema {\n kind: typeof DomainEntityKind\n /**\n * The domain entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * The semantics applied to this entity.\n * This is a list of applied semantics that can be used to\n * describe the entity in more detail.\n */\n semantics?: AppliedDataSemantic[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: EntityOrderedItem[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents an entity within a data domain model.\n *\n * A `DomainEntity` defines a structured data type,\n * containing properties and associations. It's a\n * fundamental building block for modeling complex data\n * structures.\n *\n * **Key Features:**\n *\n * - **Properties:** Defines the data elements (fields) within the entity.\n * - **Associations:** Defines relationships to other entities.\n * - **Inheritance:** Supports inheriting properties and associations from parent entities.\n * - **Metadata:** Supports tags, semantics, and deprecation status.\n * - **AMF Shape Generation:** Can be serialized to an AMF (API Modeling Framework) shape.\n * - **Example Generation:** Can generate example databased on its schema.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainEntity` is through\n * the `DomainModel.addEntity()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userModel = dataDomain.addModel({ key: 'userModel' });\n * const userEntity = userModel.addEntity({ key: 'user' });\n * ```\n *\n * Entity Validation Rules:\n *\n * - **Primary Key:** An entity must have a primary key selected. This can come from a parent\n * entity or be defined in the current entity.\n * - **Parent Entity:** The parent entity must exist in the graph.\n * - **Circular Dependency:** Adding a parent entity that creates a circular dependency is not allowed.\n * - **Unique Parent:** An entity cannot have the same parent more than once.\n * - **Property Shadowing:** A property can shadow a parent property. This means that if a property\n * with the same key exists in both the parent and child entity, the child property will take precedence.\n * - **Association Shadowing:** An association can shadow a parent association. This means that if an\n * association with the same key exists in both the parent and child entity,\n * the child association will take precedence.\n * - **Property Resolution:** When the same property exists more than one parent and the child entity,\n * doesn't explicitly define the property, then:\n * - The last parent entity (iterating from the first entity to the last) that has the property\n * will be used as the source of the property.\n * - **Association Resolution:** When the same association exists more than one parent and the child entity,\n * doesn't explicitly define the association, then:\n * - The last parent entity (iterating from the first entity to the last) that has the association\n * will be used as the source of the association.\n * - **Minimum Required Properties:** An entity must have at least one property defined. Entities without properties\n * are ignored in the system.\n * - **Entity Name**:\n * - An entity must have a name defined.\n * - The name has to follow the same rules as the names in a SQL database. This means that the name must be unique\n * within the data domain and cannot contain special characters.\n * - **Association Targets:** An association must have a target entity defined.\n * This means that the association must point to at least one entity.\n */\nexport class DomainEntity extends DomainElement {\n /**\n * The kind of the domain element.\n */\n override kind: typeof DomainEntityKind\n\n /**\n * The description of the domain entity.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Optional general purpose tags for the UI.\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 ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n accessor fields: EntityOrderedItem[]\n\n /**\n * Whether this entity is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data entity schema with defaults.\n *\n * @param input The partial data entity schema.\n * @returns The data entity schema.\n */\n static createSchema(input: Partial<DomainEntitySchema> = {}): DomainEntitySchema {\n const { key = nanoid(), tags, semantics, fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New entity' }).toJSON()\n const result: DomainEntitySchema = {\n kind: DomainEntityKind,\n key,\n info,\n }\n if (Array.isArray(tags)) {\n result.tags = [...tags]\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\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 domain entity instance.\n *\n * You probably want to use the `DomainModel.addEntity()`\n * method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial domain entity schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainEntitySchema>) {\n const init = DomainEntity.createSchema(input)\n super(root, init.key)\n this.kind = DomainEntityKind\n this.info = new Thing(init.info)\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.map((item) => structuredClone(item))\n } else {\n this.semantics = []\n }\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 }\n }\n\n /**\n * Generates a JSON representation of the entity.\n *\n * @returns A plain object representation of the `DomainEntity`.\n */\n toJSON(): DomainEntitySchema {\n const result: DomainEntitySchema = {\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 (Array.isArray(this.semantics) && this.semantics.length) {\n result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...(toRaw(this, this.tags) as string[])]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns a parent data entity where this data property\n * exist.\n *\n * @returns The parent `DomainModel` or undefined if not found.\n * @example\n * ```typescript\n * const parent = entity.getParentInstance();\n * if (parent) {\n * console.log(parent.key);\n * }\n * ```\n */\n getParentInstance(): DomainModel | undefined {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return undefined\n }\n return this.root.graph.node(parentKey) as DomainModel | undefined\n }\n\n /**\n * Adds a property to this entity.\n *\n * @param property The partial property schema.\n * @returns The created `DomainProperty` instance.\n * @example\n * ```typescript\n * const property = entity.addProperty({\n * key: 'name',\n * type: 'string',\n * required: true,\n * })\n * ```\n */\n addProperty(property?: Partial<DomainPropertySchema>): DomainProperty {\n if (property && property.key && this.root.graph.hasNode(property.key)) {\n throw new Error(`Trying to add a property ${property.key}, but it already exists`)\n }\n const instance = new DomainProperty(this.root, this.key, property)\n this.root.graph.setNode(instance.key, instance)\n this.root.graph.setEdge(this.key, instance.key, { type: 'property' })\n this.fields.push({\n type: 'property',\n key: instance.key,\n })\n this.root.notifyChange()\n return instance\n }\n\n /**\n * Removes a property from this entity.\n *\n * @param key The key of the property to remove.\n * @throws {RemovePropertyException} When the property does not exist.\n * @example\n * ```typescript\n * entity.removeProperty('name')\n * ```\n */\n removeProperty(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist`)\n }\n const prop = this.root.graph.node(key) as DomainProperty\n if (prop.getParentInstance() !== this) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't belong to this entity`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * A shortcut to `listProperties()`.\n */\n get properties(): Generator<DomainProperty> {\n return this.listProperties()\n }\n\n /**\n * Lists all properties of this entity.\n *\n * Note, it accounts for the order of the properties as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainProperty`.\n * @example\n * ```typescript\n * for (const property of entity.listProperties()) {\n * console.log(property.key);\n * }\n * ```\n */\n *listProperties(): Generator<DomainProperty> {\n for (const { key, type } of this.fields) {\n if (type !== 'property') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainPropertyKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this entity has any properties.\n *\n * @returns True if the entity has properties.\n * @example\n * ```typescript\n * if (entity.hasProperties()) {\n * // ...\n * }\n * ```\n */\n hasProperties(): boolean {\n return this.fields.some((item) => item.type === 'property')\n }\n\n /**\n * A shortcut to `listParents()`.\n */\n get parents(): Generator<DomainEntity> {\n return this.listParents()\n }\n\n /**\n * Lists all parent entities of this entity.\n *\n * @returns A generator that yields each parent `DomainEntity`.\n * @example\n * ```typescript\n * for (const parent of entity.listParents()) {\n * console.log(parent.key);\n * }\n * ```\n */\n *listParents(): Generator<DomainEntity> {\n for (const edge of this.root.graph.outEdges(this.key)) {\n const value = this.root.graph.edge(edge)\n if (!value || value.type !== 'parent') {\n continue\n }\n const parent = this.root.graph.node(edge.w) as DomainEntity\n if (parent) {\n yield parent\n }\n }\n }\n\n /**\n * Adds a parent to this entity.\n *\n * @param key The key of the parent entity.\n * @param domain The key of the foreign domain the parent belongs to.\n * @returns `this` for chaining.\n * @throws ValidationError When the parent does not exist or a circular dependency is detected.\n * @example\n * ```typescript\n * entity.addParent('baseEntity');\n * ```\n */\n addParent(key: string, domain?: string): this {\n const effectiveKey = domain ? `${domain}:${key}` : key\n // Prevent adding self as parent\n if (effectiveKey === this.key) {\n const message = 'Entity cannot be a parent of itself'\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n const { graph } = this.root\n if (!graph.hasNode(effectiveKey)) {\n let message = `Entity with key \"${key}\" not found`\n if (domain) {\n message += ` in domain \"${domain}\"`\n }\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'required',\n },\n ],\n { message }\n )\n }\n // Check for circular inheritance\n if (this.hasCircularParent(effectiveKey)) {\n const message = `Circular inheritance detected. Cannot add ${key} as a parent`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n if (graph.outEdges(this.key, effectiveKey).next().value) {\n const message = `Parent ${key} already exists`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'unique',\n },\n ],\n { message }\n )\n }\n // Parents are associated through graph edges.\n // Otherwise it would collide with the parent model.\n if (domain) {\n graph.setEdge(this.key, effectiveKey, { type: 'parent', domain, foreign: true })\n } else {\n graph.setEdge(this.key, effectiveKey, { type: 'parent' })\n }\n this.root.notifyChange()\n return this\n }\n\n /**\n * Removes a parent from this entity.\n *\n * @param key The key of the parent entity to remove.\n * @returns `this` for chaining.\n * @throws Error When the parent does not exist.\n * @example\n * ```typescript\n * entity.removeParent('baseEntity');\n * ```\n */\n removeParent(key: string): this {\n const { graph } = this.root\n if (!graph.hasEdge(this.key, key)) {\n throw new Error(`Trying to remove a parent ${key} from ${this.key}, but it doesn't exist`)\n }\n graph.removeEdge(this.key, key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Checks if this entity has any parents.\n *\n * @returns True if the entity has parents.\n * @example\n * ```typescript\n * if (entity.hasParents()) {\n * // ...\n * }\n * ```\n */\n hasParents(): boolean {\n for (const edge of this.root.graph.outEdges(this.key)) {\n if (this.root.graph.edge(edge)?.type === 'parent') {\n return true\n }\n }\n return false\n }\n\n /**\n * Checks if the passed entity has a circular parent\n * relationship when attempting to add a new parent.\n *\n * @param key The key of the parent being added.\n * @returns True if adding this parent would create a\n * circular relationship.\n */\n hasCircularParent(key: string): boolean {\n const { graph } = this.root\n\n // Check if new parent is one of the children.\n for (const edge of graph.outEdges(key, this.key)) {\n if (graph.edge(edge)?.type === 'parent') {\n return true\n }\n }\n\n // check if this entity is in parents chain.\n let current: DomainEntity | undefined = graph.node(key) as DomainEntity | undefined\n while (current) {\n if (current.key === this.key) {\n return true\n }\n const parents = [...current.listParents()]\n if (parents.length === 0) {\n break\n }\n // Assuming single inheritance\n // TODO: Update this to check for multiple parents.\n current = parents[0]\n }\n\n return false\n }\n\n /**\n * Creates breadcrumbs from this entity to the root\n * namespace.\n *\n * @returns An array of `FileBreadcrumb` instances.\n * @example\n * ```typescript\n * const breadcrumbs = entity.breadcrumbs();\n * console.log(breadcrumbs);\n * ```\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed entity'),\n kind: DomainEntityKind,\n })\n const model = this.getParentInstance()\n if (model) {\n result.push({\n key: model.key,\n kind: model.kind,\n name: model.info.getLabel('Unnamed model'),\n })\n let parent: DataDomain | DomainNamespace = model.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 }\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 * Adds an association to this entity.\n *\n * @param init The association options.\n * @param input The partial association schema.\n * @returns The created `DomainAssociation` instance.\n * @throws Error When the target entity does not exist.\n * @example\n * ```typescript\n * const association = entity.addAssociation({\n * key: 'address',\n * });\n * ```\n */\n addAssociation(init: AssociationAddOptions = {}, input?: Partial<DomainAssociationSchema>): DomainAssociation {\n const { graph } = this.root\n if (init.domain && init.key) {\n // target is foreign\n const foreignKey = `${init.domain}:${init.key}`\n if (!graph.hasNode(foreignKey)) {\n throw new Error(`Foreign entity ${foreignKey} not found`)\n }\n } else if (init.key) {\n if (!graph.hasNode(init.key)) {\n throw new Error(`Target entity ${init.key} not found`)\n }\n }\n const item = new DomainAssociation(this.root, this.key, input)\n graph.setNode(item.key, item)\n graph.setEdge(this.key, item.key, { type: 'association' })\n if (init.key) {\n item.addTarget(init.key, init.domain)\n }\n this.fields.push({ type: 'association', key: item.key })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an association from this entity.\n *\n * @param key The key of the association to remove.\n * @throws Error When the association does not exist.\n * @example\n * ```typescript\n * entity.removeAssociation('address');\n * ```\n */\n removeAssociation(key: string): void {\n if (!this.root.graph.hasEdge(this.key, key)) {\n throw new Error(`Unable to find a connection between this entity and the ${key} association`)\n }\n const edge = this.root.graph.edge(this.key, key)\n if (!edge || edge.type !== 'association') {\n throw new Error(`Association ${key} does not exist`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * A shortcut to `listAssociations()`.\n */\n get associations(): Generator<DomainAssociation> {\n return this.listAssociations()\n }\n\n /**\n * Lists all associations of this entity.\n *\n * The order of the associations is defined in the `fields` array.\n *\n * @returns A generator that yields each\n * `DomainAssociation`.\n * @example\n * ```typescript\n * for (const association of entity.listAssociations()) {\n * console.log(association.key);\n * }\n * ```\n */\n *listAssociations(): Generator<DomainAssociation> {\n for (const { key, type } of this.fields) {\n if (type !== 'association') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainAssociationKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this entity has any associations.\n *\n * @returns True if the entity has associations.\n * @example\n * ```typescript\n * if (entity.hasAssociations()) {\n * // ...\n * }\n * ```\n */\n hasAssociations(): boolean {\n return this.fields.some((item) => item.type === 'association')\n }\n\n /**\n * Lists all fields (properties and associations) of this entity.\n *\n * @returns A generator that yields each `DomainAssociation` or `DomainProperty`.\n * @example\n * ```typescript\n * for (const field of entity.listFields()) {\n * console.log(field.key);\n * }\n * ```\n */\n *listFields(): Generator<DomainAssociation | DomainProperty> {\n for (const { key } of this.fields) {\n const node = this.root.graph.node(key)\n if (!node) {\n continue\n }\n if (node.kind === DomainAssociationKind || node.kind === DomainPropertyKind) {\n yield node\n }\n }\n }\n\n /**\n * Checks if this entity has any fields (properties or associations).\n *\n * @returns True if the entity has fields.\n * @example\n * ```typescript\n * if (entity.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 * Creates an AMF's data Shape.\n *\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IShapeUnion {\n const serializer = new ShapeGenerator()\n return serializer.entity(this)\n }\n\n /**\n * Reads the schema of the Entity and generates an example for it.\n *\n * @param mime The mime type of the example.\n * @param opts The example generation options.\n * @returns The generated example.\n * @example\n * ```typescript\n * const example = entity.toExample('application/json');\n * console.log(example);\n * ```\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n const shape = this.toApiShape()\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: typeof opts.renderExamples === 'boolean' ? opts.renderExamples : true,\n renderMocked: typeof opts.renderMocked === 'boolean' ? opts.renderMocked : true,\n renderOptional: typeof opts.renderOptional === 'boolean' ? opts.renderOptional : true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n /**\n * Checks whether the entity is a child of the given namespace or data model.\n * The relationship doesn't have to be direct, as long as the entity\n * is in the hierarchy it will return true.\n *\n * @param key The key of the parent to check.\n * @returns True if this entity is a child of the given namespace or data model.\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 return parent.isChildOf(key)\n }\n\n /**\n * Finds the primary key property of this entity.\n * @returns The primary key property of this entity or undefined if not found.\n */\n primaryKey(): DomainProperty | undefined {\n for (const property of this.properties) {\n if (property.primary) {\n return property\n }\n }\n let property: DomainProperty | undefined\n for (const parent of this.listParents()) {\n const prop = parent.primaryKey()\n if (prop) {\n // According to the validation rules, the last parent\n // that has the property will be used as the source of\n // the property.\n // In the future, we may add a schema definition to the entity that\n // will explicitly define which property to use.\n property = prop\n }\n }\n return property\n }\n\n /**\n * Adds or updates a semantic to the entity.\n * @param semantic The semantic to add to the entity.\n * @throws Error if the semantic is not an entity semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isEntitySemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected an entity 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 entity.\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 entity 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"]}
1
+ {"version":3,"file":"DomainEntity.js","sourceRoot":"","sources":["../../../src/modeling/DomainEntity.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAChG,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,EAA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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;;;SApvBU,YAAY","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainAssociationKind, DomainEntityKind, 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 type { IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { DomainProperty, type DomainPropertySchema } from './DomainProperty.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'\nimport type { AssociationAddOptions } from './types.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport type { DomainModel } from './DomainModel.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport { ValidationError } from '../exceptions/validation_error.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport type { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { DataSemantics, isEntitySemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\n\nexport interface EntityOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'property' | 'association'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainEntitySchema extends DomainElementSchema {\n kind: typeof DomainEntityKind\n /**\n * The domain entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * The semantics applied to this entity.\n * This is a list of applied semantics that can be used to\n * describe the entity in more detail.\n */\n semantics?: AppliedDataSemantic[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: EntityOrderedItem[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents an entity within a data domain model.\n *\n * A `DomainEntity` defines a structured data type,\n * containing properties and associations. It's a\n * fundamental building block for modeling complex data\n * structures.\n *\n * **Key Features:**\n *\n * - **Properties:** Defines the data elements (fields) within the entity.\n * - **Associations:** Defines relationships to other entities.\n * - **Inheritance:** Supports inheriting properties and associations from parent entities.\n * - **Metadata:** Supports tags, semantics, and deprecation status.\n * - **AMF Shape Generation:** Can be serialized to an AMF (API Modeling Framework) shape.\n * - **Example Generation:** Can generate example databased on its schema.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainEntity` is through\n * the `DomainModel.addEntity()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userModel = dataDomain.addModel({ key: 'userModel' });\n * const userEntity = userModel.addEntity({ key: 'user' });\n * ```\n *\n * Entity Validation Rules:\n *\n * - **Primary Key:** An entity must have a primary key selected. This can come from a parent\n * entity or be defined in the current entity.\n * - **Parent Entity:** The parent entity must exist in the graph.\n * - **Circular Dependency:** Adding a parent entity that creates a circular dependency is not allowed.\n * - **Unique Parent:** An entity cannot have the same parent more than once.\n * - **Property Shadowing:** A property can shadow a parent property. This means that if a property\n * with the same key exists in both the parent and child entity, the child property will take precedence.\n * - **Association Shadowing:** An association can shadow a parent association. This means that if an\n * association with the same key exists in both the parent and child entity,\n * the child association will take precedence.\n * - **Property Resolution:** When the same property exists more than one parent and the child entity,\n * doesn't explicitly define the property, then:\n * - The last parent entity (iterating from the first entity to the last) that has the property\n * will be used as the source of the property.\n * - **Association Resolution:** When the same association exists more than one parent and the child entity,\n * doesn't explicitly define the association, then:\n * - The last parent entity (iterating from the first entity to the last) that has the association\n * will be used as the source of the association.\n * - **Minimum Required Properties:** An entity must have at least one property defined. Entities without properties\n * are ignored in the system.\n * - **Entity Name**:\n * - An entity must have a name defined.\n * - The name has to follow the same rules as the names in a SQL database. This means that the name must be unique\n * within the data domain and cannot contain special characters.\n * - **Association Targets:** An association must have a target entity defined.\n * This means that the association must point to at least one entity.\n */\nexport class DomainEntity extends DomainElement {\n /**\n * The kind of the domain element.\n */\n override kind: typeof DomainEntityKind\n\n /**\n * The description of the domain entity.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Optional general purpose tags for the UI.\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 ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n accessor fields: EntityOrderedItem[]\n\n /**\n * Whether this entity is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data entity schema with defaults.\n *\n * @param input The partial data entity schema.\n * @returns The data entity schema.\n */\n static createSchema(input: Partial<DomainEntitySchema> = {}): DomainEntitySchema {\n const { key = nanoid(), tags, semantics, fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'new_entity' }).toJSON()\n const result: DomainEntitySchema = {\n kind: DomainEntityKind,\n key,\n info,\n }\n if (Array.isArray(tags)) {\n result.tags = [...tags]\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\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 domain entity instance.\n *\n * You probably want to use the `DomainModel.addEntity()`\n * method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial domain entity schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainEntitySchema>) {\n const init = DomainEntity.createSchema(input)\n super(root, init.key)\n this.kind = DomainEntityKind\n this.info = new Thing(init.info)\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.map((item) => structuredClone(item))\n } else {\n this.semantics = []\n }\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 }\n }\n\n /**\n * Generates a JSON representation of the entity.\n *\n * @returns A plain object representation of the `DomainEntity`.\n */\n toJSON(): DomainEntitySchema {\n const result: DomainEntitySchema = {\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 (Array.isArray(this.semantics) && this.semantics.length) {\n result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...(toRaw(this, this.tags) as string[])]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns a parent data entity where this data property\n * exist.\n *\n * @returns The parent `DomainModel` or undefined if not found.\n * @example\n * ```typescript\n * const parent = entity.getParentInstance();\n * if (parent) {\n * console.log(parent.key);\n * }\n * ```\n */\n getParentInstance(): DomainModel | undefined {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return undefined\n }\n return this.root.graph.node(parentKey) as DomainModel | undefined\n }\n\n /**\n * Adds a property to this entity.\n *\n * @param property The partial property schema.\n * @returns The created `DomainProperty` instance.\n * @example\n * ```typescript\n * const property = entity.addProperty({\n * key: 'name',\n * type: 'string',\n * required: true,\n * })\n * ```\n */\n addProperty(property?: Partial<DomainPropertySchema>): DomainProperty {\n if (property && property.key && this.root.graph.hasNode(property.key)) {\n throw new Error(`Trying to add a property ${property.key}, but it already exists`)\n }\n const instance = new DomainProperty(this.root, this.key, property)\n this.root.graph.setNode(instance.key, instance)\n this.root.graph.setEdge(this.key, instance.key, { type: 'property' })\n this.fields.push({\n type: 'property',\n key: instance.key,\n })\n this.root.notifyChange()\n return instance\n }\n\n /**\n * Removes a property from this entity.\n *\n * @param key The key of the property to remove.\n * @throws {RemovePropertyException} When the property does not exist.\n * @example\n * ```typescript\n * entity.removeProperty('name')\n * ```\n */\n removeProperty(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist`)\n }\n const prop = this.root.graph.node(key) as DomainProperty\n if (prop.getParentInstance() !== this) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't belong to this entity`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * A shortcut to `listProperties()`.\n */\n get properties(): Generator<DomainProperty> {\n return this.listProperties()\n }\n\n /**\n * Lists all properties of this entity.\n *\n * Note, it accounts for the order of the properties as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainProperty`.\n * @example\n * ```typescript\n * for (const property of entity.listProperties()) {\n * console.log(property.key);\n * }\n * ```\n */\n *listProperties(): Generator<DomainProperty> {\n for (const { key, type } of this.fields) {\n if (type !== 'property') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainPropertyKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this entity has any properties.\n *\n * @returns True if the entity has properties.\n * @example\n * ```typescript\n * if (entity.hasProperties()) {\n * // ...\n * }\n * ```\n */\n hasProperties(): boolean {\n return this.fields.some((item) => item.type === 'property')\n }\n\n /**\n * A shortcut to `listParents()`.\n */\n get parents(): Generator<DomainEntity> {\n return this.listParents()\n }\n\n /**\n * Lists all parent entities of this entity.\n *\n * @returns A generator that yields each parent `DomainEntity`.\n * @example\n * ```typescript\n * for (const parent of entity.listParents()) {\n * console.log(parent.key);\n * }\n * ```\n */\n *listParents(): Generator<DomainEntity> {\n for (const edge of this.root.graph.outEdges(this.key)) {\n const value = this.root.graph.edge(edge)\n if (!value || value.type !== 'parent') {\n continue\n }\n const parent = this.root.graph.node(edge.w) as DomainEntity\n if (parent) {\n yield parent\n }\n }\n }\n\n /**\n * Adds a parent to this entity.\n *\n * @param key The key of the parent entity.\n * @param domain The key of the foreign domain the parent belongs to.\n * @returns `this` for chaining.\n * @throws ValidationError When the parent does not exist or a circular dependency is detected.\n * @example\n * ```typescript\n * entity.addParent('baseEntity');\n * ```\n */\n addParent(key: string, domain?: string): this {\n const effectiveKey = domain ? `${domain}:${key}` : key\n // Prevent adding self as parent\n if (effectiveKey === this.key) {\n const message = 'Entity cannot be a parent of itself'\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n const { graph } = this.root\n if (!graph.hasNode(effectiveKey)) {\n let message = `Entity with key \"${key}\" not found`\n if (domain) {\n message += ` in domain \"${domain}\"`\n }\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'required',\n },\n ],\n { message }\n )\n }\n // Check for circular inheritance\n if (this.hasCircularParent(effectiveKey)) {\n const message = `Circular inheritance detected. Cannot add ${key} as a parent`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n if (graph.outEdges(this.key, effectiveKey).next().value) {\n const message = `Parent ${key} already exists`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'unique',\n },\n ],\n { message }\n )\n }\n // Parents are associated through graph edges.\n // Otherwise it would collide with the parent model.\n if (domain) {\n graph.setEdge(this.key, effectiveKey, { type: 'parent', domain, foreign: true })\n } else {\n graph.setEdge(this.key, effectiveKey, { type: 'parent' })\n }\n this.root.notifyChange()\n return this\n }\n\n /**\n * Removes a parent from this entity.\n *\n * @param key The key of the parent entity to remove.\n * @returns `this` for chaining.\n * @throws Error When the parent does not exist.\n * @example\n * ```typescript\n * entity.removeParent('baseEntity');\n * ```\n */\n removeParent(key: string): this {\n const { graph } = this.root\n if (!graph.hasEdge(this.key, key)) {\n throw new Error(`Trying to remove a parent ${key} from ${this.key}, but it doesn't exist`)\n }\n graph.removeEdge(this.key, key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Checks if this entity has any parents.\n *\n * @returns True if the entity has parents.\n * @example\n * ```typescript\n * if (entity.hasParents()) {\n * // ...\n * }\n * ```\n */\n hasParents(): boolean {\n for (const edge of this.root.graph.outEdges(this.key)) {\n if (this.root.graph.edge(edge)?.type === 'parent') {\n return true\n }\n }\n return false\n }\n\n /**\n * Checks if the passed entity has a circular parent\n * relationship when attempting to add a new parent.\n *\n * @param key The key of the parent being added.\n * @returns True if adding this parent would create a\n * circular relationship.\n */\n hasCircularParent(key: string): boolean {\n const { graph } = this.root\n\n // Check if new parent is one of the children.\n for (const edge of graph.outEdges(key, this.key)) {\n if (graph.edge(edge)?.type === 'parent') {\n return true\n }\n }\n\n // check if this entity is in parents chain.\n let current: DomainEntity | undefined = graph.node(key) as DomainEntity | undefined\n while (current) {\n if (current.key === this.key) {\n return true\n }\n const parents = [...current.listParents()]\n if (parents.length === 0) {\n break\n }\n // Assuming single inheritance\n // TODO: Update this to check for multiple parents.\n current = parents[0]\n }\n\n return false\n }\n\n /**\n * Creates breadcrumbs from this entity to the root\n * namespace.\n *\n * @returns An array of `FileBreadcrumb` instances.\n * @example\n * ```typescript\n * const breadcrumbs = entity.breadcrumbs();\n * console.log(breadcrumbs);\n * ```\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed entity'),\n kind: DomainEntityKind,\n })\n const model = this.getParentInstance()\n if (model) {\n result.push({\n key: model.key,\n kind: model.kind,\n name: model.info.getLabel('Unnamed model'),\n })\n let parent: DataDomain | DomainNamespace = model.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 }\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 * Adds an association to this entity.\n *\n * @param init The association options.\n * @param input The partial association schema.\n * @returns The created `DomainAssociation` instance.\n * @throws Error When the target entity does not exist.\n * @example\n * ```typescript\n * const association = entity.addAssociation({\n * key: 'address',\n * });\n * ```\n */\n addAssociation(init: AssociationAddOptions = {}, input?: Partial<DomainAssociationSchema>): DomainAssociation {\n const { graph } = this.root\n if (init.domain && init.key) {\n // target is foreign\n const foreignKey = `${init.domain}:${init.key}`\n if (!graph.hasNode(foreignKey)) {\n throw new Error(`Foreign entity ${foreignKey} not found`)\n }\n } else if (init.key) {\n if (!graph.hasNode(init.key)) {\n throw new Error(`Target entity ${init.key} not found`)\n }\n }\n const item = new DomainAssociation(this.root, this.key, input)\n graph.setNode(item.key, item)\n graph.setEdge(this.key, item.key, { type: 'association' })\n if (init.key) {\n item.addTarget(init.key, init.domain)\n }\n this.fields.push({ type: 'association', key: item.key })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an association from this entity.\n *\n * @param key The key of the association to remove.\n * @throws Error When the association does not exist.\n * @example\n * ```typescript\n * entity.removeAssociation('address');\n * ```\n */\n removeAssociation(key: string): void {\n if (!this.root.graph.hasEdge(this.key, key)) {\n throw new Error(`Unable to find a connection between this entity and the ${key} association`)\n }\n const edge = this.root.graph.edge(this.key, key)\n if (!edge || edge.type !== 'association') {\n throw new Error(`Association ${key} does not exist`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * A shortcut to `listAssociations()`.\n */\n get associations(): Generator<DomainAssociation> {\n return this.listAssociations()\n }\n\n /**\n * Lists all associations of this entity.\n *\n * The order of the associations is defined in the `fields` array.\n *\n * @returns A generator that yields each\n * `DomainAssociation`.\n * @example\n * ```typescript\n * for (const association of entity.listAssociations()) {\n * console.log(association.key);\n * }\n * ```\n */\n *listAssociations(): Generator<DomainAssociation> {\n for (const { key, type } of this.fields) {\n if (type !== 'association') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainAssociationKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this entity has any associations.\n *\n * @returns True if the entity has associations.\n * @example\n * ```typescript\n * if (entity.hasAssociations()) {\n * // ...\n * }\n * ```\n */\n hasAssociations(): boolean {\n return this.fields.some((item) => item.type === 'association')\n }\n\n /**\n * Lists all fields (properties and associations) of this entity.\n *\n * @returns A generator that yields each `DomainAssociation` or `DomainProperty`.\n * @example\n * ```typescript\n * for (const field of entity.listFields()) {\n * console.log(field.key);\n * }\n * ```\n */\n *listFields(): Generator<DomainAssociation | DomainProperty> {\n for (const { key } of this.fields) {\n const node = this.root.graph.node(key)\n if (!node) {\n continue\n }\n if (node.kind === DomainAssociationKind || node.kind === DomainPropertyKind) {\n yield node\n }\n }\n }\n\n /**\n * Checks if this entity has any fields (properties or associations).\n *\n * @returns True if the entity has fields.\n * @example\n * ```typescript\n * if (entity.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 * Creates an AMF's data Shape.\n *\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IShapeUnion {\n const serializer = new ShapeGenerator()\n return serializer.entity(this)\n }\n\n /**\n * Reads the schema of the Entity and generates an example for it.\n *\n * @param mime The mime type of the example.\n * @param opts The example generation options.\n * @returns The generated example.\n * @example\n * ```typescript\n * const example = entity.toExample('application/json');\n * console.log(example);\n * ```\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n const shape = this.toApiShape()\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: typeof opts.renderExamples === 'boolean' ? opts.renderExamples : true,\n renderMocked: typeof opts.renderMocked === 'boolean' ? opts.renderMocked : true,\n renderOptional: typeof opts.renderOptional === 'boolean' ? opts.renderOptional : true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n /**\n * Checks whether the entity is a child of the given namespace or data model.\n * The relationship doesn't have to be direct, as long as the entity\n * is in the hierarchy it will return true.\n *\n * @param key The key of the parent to check.\n * @returns True if this entity is a child of the given namespace or data model.\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 return parent.isChildOf(key)\n }\n\n /**\n * Finds the primary key property of this entity.\n * @returns The primary key property of this entity or undefined if not found.\n */\n primaryKey(): DomainProperty | undefined {\n for (const property of this.properties) {\n if (property.primary) {\n return property\n }\n }\n let property: DomainProperty | undefined\n for (const parent of this.listParents()) {\n const prop = parent.primaryKey()\n if (prop) {\n // According to the validation rules, the last parent\n // that has the property will be used as the source of\n // the property.\n // In the future, we may add a schema definition to the entity that\n // will explicitly define which property to use.\n property = prop\n }\n }\n return property\n }\n\n /**\n * Adds or updates a semantic to the entity.\n * @param semantic The semantic to add to the entity.\n * @throws Error if the semantic is not an entity semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isEntitySemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected an entity 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 entity.\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 entity 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"]}
@@ -16,8 +16,7 @@ export declare class DomainFile extends File {
16
16
  * @param input The data namespace instance or schema.
17
17
  */
18
18
  static fromDataDomain(input: DataDomain | DataDomainSchema): DomainFile;
19
- constructor(input?: string | IDomainFile);
20
- new(init: IDomainFile): this;
19
+ constructor(state?: Partial<IDomainFile>);
21
20
  static isDomainFile(input: unknown): boolean;
22
21
  toJSON(): IDomainFile;
23
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DomainFile.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,IAAI,EAAE,OAAO,cAAc,CAAA;CAC5B;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAiB;WAEd,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAIlD;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,gBAAgB,GAAG,UAAU;gBAmB3D,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW;IAqB/B,GAAG,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IASrC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQnC,MAAM,IAAI,WAAW;CAO/B"}
1
+ {"version":3,"file":"DomainFile.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,IAAI,EAAE,OAAO,cAAc,CAAA;CAC5B;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAiB;WAEd,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAIlD;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,gBAAgB,GAAG,UAAU;gBAU3D,KAAK,GAAE,OAAO,CAAC,WAAW,CAAM;IAI5C,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQnC,MAAM,IAAI,WAAW;CAO/B"}
@@ -1,6 +1,4 @@
1
- import { nanoid } from '../nanoid.js';
2
1
  import { File } from '../models/store/File.js';
3
- import { Thing } from '../models/Thing.js';
4
2
  import { DomainFileKind } from '../models/kinds.js';
5
3
  /**
6
4
  * Used by the store. A file definition for the DataDomain
@@ -23,46 +21,10 @@ export class DomainFile extends File {
23
21
  else {
24
22
  final = input;
25
23
  }
26
- const init = {
27
- kind: DomainFileKind,
28
- key: final.key,
29
- info: { ...final.info },
30
- lastModified: { user: '', time: 0, byMe: false },
31
- parents: [],
32
- permissionIds: [],
33
- permissions: [],
34
- };
35
- return new DomainFile(init);
36
- }
37
- constructor(input) {
38
- super();
39
- let init;
40
- if (typeof input === 'string') {
41
- init = JSON.parse(input);
42
- }
43
- else if (typeof input === 'object') {
44
- init = input;
45
- }
46
- else {
47
- init = {
48
- kind: DomainFileKind,
49
- key: nanoid(),
50
- info: Thing.fromName('').toJSON(),
51
- parents: [],
52
- permissionIds: [],
53
- permissions: [],
54
- lastModified: { user: '', time: 0, byMe: false },
55
- };
56
- }
57
- this.new(init);
24
+ return new DomainFile({ key: final.key, info: final.info });
58
25
  }
59
- new(init) {
60
- if (!DomainFile.isDomainFile(init)) {
61
- throw new Error(`Not a data file.`);
62
- }
63
- super.new(init);
64
- this.kind = DomainFileKind;
65
- return this;
26
+ constructor(state = {}) {
27
+ super({ ...state, kind: DomainFileKind });
66
28
  }
67
29
  static isDomainFile(input) {
68
30
  const typed = input;
@@ -1 +1 @@
1
- {"version":3,"file":"DomainFile.js","sourceRoot":"","sources":["../../../src/modeling/DomainFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,IAAI,EAAc,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAMnD;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAI;IACzB,IAAI,GAAG,cAAc,CAAA;IAE9B,MAAM,CAAU,QAAQ,CAAC,IAAY;QACnC,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAe,CAAA;IAC3D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,KAAoC;QACxD,IAAI,KAAuB,CAAA;QAC3B,IAAI,OAAQ,KAAoB,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACvD,KAAK,GAAI,KAAoB,CAAC,MAAM,EAAE,CAAA;QACxC,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,KAAyB,CAAA;QACnC,CAAC;QACD,MAAM,IAAI,GAAgB;YACxB,IAAI,EAAE,cAAc;YACpB,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE;YACvB,YAAY,EAAE,EAAE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M,KAAK,GAAG,KAAoB,CAAA;QAClC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEQ,MAAM;QACb,MAAM,MAAM,GAAgB;YAC1B,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,cAAc;SACrB,CAAA;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { File, type IFile } from '../models/store/File.js'\nimport { Thing } from '../models/Thing.js'\nimport type { DataDomain, DataDomainSchema } from './DataDomain.js'\nimport { DomainFileKind } from '../models/kinds.js'\n\nexport interface IDomainFile extends IFile {\n kind: typeof DomainFileKind\n}\n\n/**\n * Used by the store. A file definition for the DataDomain\n */\nexport class DomainFile extends File {\n override kind = DomainFileKind\n\n static override fromName(name: string): DomainFile {\n return super.fromName(name, DomainFileKind) as DomainFile\n }\n\n /**\n * Creates the file definition for a DomainNamespace contents.\n *\n * @param input The data namespace instance or schema.\n */\n static fromDataDomain(input: DataDomain | DataDomainSchema): DomainFile {\n let final: DataDomainSchema\n if (typeof (input as DataDomain).toJSON === 'function') {\n final = (input as DataDomain).toJSON()\n } else {\n final = input as DataDomainSchema\n }\n const init: IDomainFile = {\n kind: DomainFileKind,\n key: final.key,\n info: { ...final.info },\n lastModified: { user: '', time: 0, byMe: false },\n parents: [],\n permissionIds: [],\n permissions: [],\n }\n return new DomainFile(init)\n }\n\n constructor(input?: string | IDomainFile) {\n super()\n let init: IDomainFile\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DomainFileKind,\n key: nanoid(),\n info: Thing.fromName('').toJSON(),\n parents: [],\n permissionIds: [],\n permissions: [],\n lastModified: { user: '', time: 0, byMe: false },\n }\n }\n this.new(init)\n }\n\n override new(init: IDomainFile): this {\n if (!DomainFile.isDomainFile(init)) {\n throw new Error(`Not a data file.`)\n }\n super.new(init)\n this.kind = DomainFileKind\n return this\n }\n\n static isDomainFile(input: unknown): boolean {\n const typed = input as IDomainFile\n if (!input || typed.kind !== DomainFileKind) {\n return false\n }\n return true\n }\n\n override toJSON(): IDomainFile {\n const result: IDomainFile = {\n ...super.toJSON(),\n kind: DomainFileKind,\n }\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"DomainFile.js","sourceRoot":"","sources":["../../../src/modeling/DomainFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAMnD;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAI;IACzB,IAAI,GAAG,cAAc,CAAA;IAE9B,MAAM,CAAU,QAAQ,CAAC,IAAY;QACnC,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAe,CAAA;IAC3D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,KAAoC;QACxD,IAAI,KAAuB,CAAA;QAC3B,IAAI,OAAQ,KAAoB,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACvD,KAAK,GAAI,KAAoB,CAAC,MAAM,EAAE,CAAA;QACxC,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,KAAyB,CAAA;QACnC,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED,YAAY,QAA8B,EAAE;QAC1C,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,KAAc;QAChC,MAAM,KAAK,GAAG,KAAoB,CAAA;QAClC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEQ,MAAM;QACb,MAAM,MAAM,GAAgB;YAC1B,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,cAAc;SACrB,CAAA;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { File, type IFile } from '../models/store/File.js'\nimport type { DataDomain, DataDomainSchema } from './DataDomain.js'\nimport { DomainFileKind } from '../models/kinds.js'\n\nexport interface IDomainFile extends IFile {\n kind: typeof DomainFileKind\n}\n\n/**\n * Used by the store. A file definition for the DataDomain\n */\nexport class DomainFile extends File {\n override kind = DomainFileKind\n\n static override fromName(name: string): DomainFile {\n return super.fromName(name, DomainFileKind) as DomainFile\n }\n\n /**\n * Creates the file definition for a DomainNamespace contents.\n *\n * @param input The data namespace instance or schema.\n */\n static fromDataDomain(input: DataDomain | DataDomainSchema): DomainFile {\n let final: DataDomainSchema\n if (typeof (input as DataDomain).toJSON === 'function') {\n final = (input as DataDomain).toJSON()\n } else {\n final = input as DataDomainSchema\n }\n return new DomainFile({ key: final.key, info: final.info })\n }\n\n constructor(state: Partial<IDomainFile> = {}) {\n super({ ...state, kind: DomainFileKind })\n }\n\n static isDomainFile(input: unknown): boolean {\n const typed = input as IDomainFile\n if (!input || typed.kind !== DomainFileKind) {\n return false\n }\n return true\n }\n\n override toJSON(): IDomainFile {\n const result: IDomainFile = {\n ...super.toJSON(),\n kind: DomainFileKind,\n }\n return result\n }\n}\n"]}
@@ -7,20 +7,75 @@ export declare enum SemanticType {
7
7
  /**
8
8
  * Designates a Data Entity that represents users of the system.
9
9
  */
10
- User = "https://apinow.app/semantics/entities/#User",
11
- CreatedTimestamp = "https://apinow.app/semantics/properties/#CreatedTimestamp",
12
- UpdatedTimestamp = "https://apinow.app/semantics/properties/#UpdatedTimestamp",
13
- DeletedTimestamp = "https://apinow.app/semantics/properties/#DeletedTimestamp",
14
- DeletedFlag = "https://apinow.app/semantics/properties/#DeletedFlag",
15
- PublicUniqueName = "https://apinow.app/semantics/properties/#PublicUniqueName",
16
- ResourceOwnerIdentifier = "https://apinow.app/semantics/associations/#ResourceOwnerIdentifier"
10
+ User = "Semantic#User",
11
+ /**
12
+ * Annotates the field as the user password.
13
+ * The runtime should treat this field with special care,
14
+ * ensuring it is encrypted and not exposed in API responses.
15
+ */
16
+ Password = "Semantic#Password",
17
+ /**
18
+ * Designates a Data Property as the `createdAt` timestamp of an entity.
19
+ * This is used to track when the entity was first created.
20
+ */
21
+ CreatedTimestamp = "Semantic#CreatedTimestamp",
22
+ /**
23
+ * Designates a Data Property as the `updatedAt` timestamp of an entity.
24
+ * This is used to track when the entity was last modified.
25
+ */
26
+ UpdatedTimestamp = "Semantic#UpdatedTimestamp",
27
+ /**
28
+ * Designates a Data Property as the `deletedAt` timestamp of an entity.
29
+ * This is used to track when the entity was soft-deleted.
30
+ * Soft-deletion means the entity is not physically removed from the database,
31
+ * but marked as deleted for logical deletion purposes.
32
+ */
33
+ DeletedTimestamp = "Semantic#DeletedTimestamp",
34
+ /**
35
+ * Designates a Data Property as a boolean flag indicating whether the entity is deleted.
36
+ * This is used for soft-deletion, where the entity is not physically removed from the database,
37
+ * but marked as deleted.
38
+ */
39
+ DeletedFlag = "Semantic#DeletedFlag",
40
+ /**
41
+ * Designates a Data Property as a unique public identifier for a resource.
42
+ * This is often used in URLs to provide a user-friendly way to access the resource.
43
+ * For example, a blog post might have a public unique name like "my-first-post".
44
+ */
45
+ PublicUniqueName = "Semantic#PublicUniqueName",
46
+ /**
47
+ * Designates a Data Property as the `role` of a user within the system.
48
+ * This is used to define the user's permissions and access levels.
49
+ * For example, a user with the role of "admin" would have elevated permissions
50
+ * compared to a user with the role of "guest".
51
+ * Roles are defined on the entity as enums, or as a string property with a controlled vocabulary.
52
+ */
53
+ UserRole = "Semantic#UserRole",
54
+ /**
55
+ * Designates an association that links a resource to a "User" entity instance.
56
+ * This is used to indicate ownership of the resource for access control purposes.
57
+ * For example, a blog post might have a resource owner identifier that points to the user who created it.
58
+ */
59
+ ResourceOwnerIdentifier = "Semantic#ResourceOwnerIdentifier"
17
60
  }
18
61
  /**
19
62
  * Defines the scope at which a semantic can be applied.
20
63
  */
21
64
  export declare enum SemanticScope {
65
+ /**
66
+ * The semantic applies to an entire Data Entity.
67
+ * This is used for semantics that provide context or constraints at the entity level.
68
+ */
22
69
  Entity = "Entity",
70
+ /**
71
+ * The semantic applies to a single Data Property.
72
+ * This is used for semantics that provide context or constraints at the property level.
73
+ */
23
74
  Property = "Property",
75
+ /**
76
+ * The semantic applies to an Association between Data Entities.
77
+ * This is used for semantics that provide context or constraints at the association level.
78
+ */
24
79
  Association = "Association"
25
80
  }
26
81
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Semantics.d.ts","sourceRoot":"","sources":["../../../src/modeling/Semantics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD;;;GAGG;AACH,oBAAY,YAAY;IAEtB;;OAEG;IACH,IAAI,gDAAgD;IAGpD,gBAAgB,8DAA8D;IAC9E,gBAAgB,8DAA8D;IAC9E,gBAAgB,8DAA8D;IAC9E,WAAW,yDAAyD;IACpE,gBAAgB,8DAA8D;IAE9E,uBAAuB,uEAAuE;CAC/F;AAED;;GAEG;AACH,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;CAC5B;AAED;;;;;GAKG;AACH,UAAU,gBAAgB;IACxB;;OAEG;IACH,EAAE,EAAE,YAAY,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,KAAK,EAAE,aAAa,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,S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