@api-client/core 0.18.17 → 0.18.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/{modeling → decorators}/observed.d.ts +3 -3
- package/build/src/decorators/observed.d.ts.map +1 -0
- package/build/src/{modeling → decorators}/observed.js +4 -4
- package/build/src/decorators/observed.js.map +1 -0
- package/build/src/modeling/ApiModel.js +1 -1
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +7 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js +44 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +6 -0
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +21 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainModel.js +1 -1
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainNamespace.js +1 -1
- package/build/src/modeling/DomainNamespace.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +5 -0
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +38 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/DomainSerialization.d.ts.map +1 -1
- package/build/src/modeling/DomainSerialization.js +2 -2
- package/build/src/modeling/DomainSerialization.js.map +1 -1
- package/build/src/models/Thing.js +1 -1
- package/build/src/models/Thing.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/package.json +2 -1
- package/src/{modeling → decorators}/observed.ts +5 -5
- package/src/modeling/ApiModel.ts +1 -1
- package/src/modeling/DomainAssociation.ts +51 -1
- package/src/modeling/DomainEntity.ts +24 -1
- package/src/modeling/DomainModel.ts +1 -1
- package/src/modeling/DomainNamespace.ts +1 -1
- package/src/modeling/DomainProperty.ts +43 -1
- package/src/modeling/DomainSerialization.ts +2 -4
- package/src/models/Thing.ts +1 -1
- package/tests/unit/decorators/observed.spec.ts +527 -0
- package/tests/unit/modeling/data_domain_serialization.spec.ts +6 -2
- package/tests/unit/modeling/domain_asociation.spec.ts +376 -0
- package/tests/unit/modeling/domain_entity.spec.ts +147 -0
- package/tests/unit/modeling/domain_property.spec.ts +273 -0
- package/build/src/modeling/observed.d.ts.map +0 -1
- package/build/src/modeling/observed.js.map +0 -1
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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: opts.renderExamples ?? true,\n renderMocked: opts.renderMocked ?? true,\n renderOptional: 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,EAAE,MAAM,2BAA2B,CAAA;AAE3E,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,C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BACtC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACpB,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACpC,CAAC;YACH,CAAC;YAED,IAAI,OAAO,GAAG,CAAC,CAAA;YACf,IAAI,OAAO,GAAG,GAAG,QAAQ,OAAO,CAAA;YAChC,OAAO,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClC,OAAO,GAAG,GAAG,QAAQ,SAAS,OAAO,EAAE,CAAA;gBACvC,OAAO,EAAE,CAAA;YACX,CAAC;YAED,OAAO,OAAO,CAAA;QAChB,CAAC;;;SA3wBU,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 '../decorators/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: opts.renderExamples ?? true,\n renderMocked: opts.renderMocked ?? true,\n renderOptional: 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 /**\n * Generates a unique name by appending a number to the base name.\n * @param baseName The base name to make unique.\n * @returns A unique name within the current entity.\n */\n generateUniqueName(baseName: string): string {\n const existingNames = new Set<string>()\n for (const field of this.listFields()) {\n if (field.info.name) {\n existingNames.add(field.info.name)\n }\n }\n\n let counter = 2\n let newName = `${baseName}_copy`\n while (existingNames.has(newName)) {\n newName = `${baseName}_copy_${counter}`\n counter++\n }\n\n return newName\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { DomainEntityKind, DomainModelKind } from '../models/kinds.js';
|
|
|
3
3
|
import { DomainElement } from './DomainElement.js';
|
|
4
4
|
import { nanoid } from '../nanoid.js';
|
|
5
5
|
import { Thing } from '../models/Thing.js';
|
|
6
|
-
import { observed, retargetChange } from '
|
|
6
|
+
import { observed, retargetChange } from '../decorators/observed.js';
|
|
7
7
|
import { DomainEntity } from './DomainEntity.js';
|
|
8
8
|
import { RemoveEntityException } from '../exceptions/remove_entity_exception.js';
|
|
9
9
|
import { removeGraphNode } from './GraphUtils.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;A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AC/B,CAAC;QAEO,WAAW,CAAC,GAAW;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QAC9D,CAAC;QAED;;;;;;WAMG;QACH,SAAS,CAAC,GAAW;YACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SA/VU,WAAW","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainEntityKind, DomainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const ns = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = ns.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n if (!this.fields.some((item) => item.key === key)) {\n this.fields.push({\n type: 'entity',\n key: key,\n })\n }\n this.root.graph.setParent(key, this.key)\n // verify that the entity is moved to the current model\n const graphParent = this.root.graph.parent(key)\n if (graphParent !== this.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a child of this model`)\n }\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainModel.js","sourceRoot":"","sources":["../../../src/modeling/DomainModel.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAGpE,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AA+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D,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SA/VU,WAAW","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainEntityKind, DomainModelKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from '../decorators/observed.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { FileBreadcrumb } from '../models/store/File.js'\nimport { DomainEntity, type DomainEntitySchema } from './DomainEntity.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\n\nexport interface ModelOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'entity'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainModelSchema extends DomainElementSchema {\n kind: typeof DomainModelKind\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The ordered list of entities in the schema.\n */\n fields?: ModelOrderedItem[]\n\n /**\n * Whether this model is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * Represents a data model within a data domain.\n *\n * A `DomainModel` groups related `DomainEntity` instances, providing a logical structure for organizing\n * data. It acts as a container for entities that share a common purpose or context.\n *\n * **Key Features:**\n *\n * - **Entity Container:** Holds a collection of `DomainEntity` instances.\n * - **Logical Grouping:** Organizes entities into meaningful groups.\n * - **Metadata:** Supports a description for the data model.\n * - **Namespace Integration:** Belongs to a `DomainNamespace`, creating a hierarchical structure.\n *\n * **Usage:**\n *\n * The preferred way to create a `DomainModel` is through\n * the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const ns = dataDomain.addNamespace({\n * key: 'myNamespace',\n * });\n * const userModel = ns.addModel({\n * key: 'userModel',\n * info: { name: 'User Model' },\n * });\n * ```\n */\nexport class DomainModel extends DomainElement {\n override kind: typeof DomainModelKind\n\n /**\n * The description of the domain model.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of entities in the schema.\n */\n accessor fields: ModelOrderedItem[]\n /**\n * Whether this model is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full data model schema with defaults.\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainModelSchema> = {}): DomainModelSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New model' }).toJSON()\n const result: DomainModelSchema = {\n kind: DomainModelKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new model instance.\n *\n * You should use the `DomainNamespace.addModel()` or\n * `DataDomain.addModel()` method instead.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial model schema.\n */\n constructor(root: DataDomain, input?: Partial<DomainModelSchema>) {\n const init = DomainModel.createSchema(input)\n super(root, init.key)\n this.kind = DomainModelKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n /**\n * Generates a JSON representation of the data model.\n *\n * @returns A plain object representation of the\n * `DomainModel`.\n * @example\n * ```typescript\n * const json = userModel.toJSON();\n * console.log(json);\n * ```\n */\n toJSON(): DomainModelSchema {\n const result: DomainModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Returns the parent namespace where this data model\n * exists.\n *\n * @returns The parent `DomainNamespace`.\n * @throws Error When no parent is found.\n * @example\n * ```typescript\n * const parent = userModel.getParentInstance();\n * console.log(parent.key);\n * ```\n */\n getParentInstance(): DomainNamespace | DataDomain {\n const parentKey = this.root.graph.parent(this.key)\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Adds a child entity to the current model.\n *\n * @param value The partial entity schema.\n * @returns The created entity instance.\n * @example\n * ```typescript\n * const entity = model.addEntity({\n * key: 'address',\n * info: { name: 'Address' },\n * })\n * ```\n */\n addEntity(input?: Partial<DomainEntitySchema>): DomainEntity {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Entity with key ${input?.key} already exists`)\n }\n const item = new DomainEntity(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n key: item.key,\n type: 'entity',\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes an entity from the current model.\n *\n * @param key The key of the model to remove.\n * @throws {RemoveEntityException} If the model does not exist.\n * @example\n * ```typescript\n * model.removeEntity('address')\n * ```\n */\n removeEntity(key: string): void {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new RemoveEntityException(`Trying to remove the ${key} entity, but it is not a child of this model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n }\n\n /**\n * Attaches an entity to the current model. It changes the parent of the entity\n * to the current model in the graph.\n *\n * The attached entity must be already a child of another model. It detaches the entity\n * from the previous model.\n *\n * @param key The key of the entity to attach.\n * @throws {AttachException} If the entity does not exist.\n * @throws {AttachException} If passed key doesn't belong to an entity.\n * @throws {AttachException} When the entity is already a child of the current model.\n * @throws {AttachException} If the entity is not in the same domain.\n * @example\n * ```typescript\n * model.attachEntity('address')\n * ```\n */\n attachEntity(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a entity`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not in the same domain`)\n }\n const parent = node.getParentInstance() as DomainModel\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n parent.detachEntity(key)\n if (!this.fields.some((item) => item.key === key)) {\n this.fields.push({\n type: 'entity',\n key: key,\n })\n }\n this.root.graph.setParent(key, this.key)\n // verify that the entity is moved to the current model\n const graphParent = this.root.graph.parent(key)\n if (graphParent !== this.key) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is not a child of this model`)\n }\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches an entity from the current model. It changes the parent of the entity\n * to the root graph.\n * Unlike remove, it doesn't remove the entity from the graph nor notifies the change.\n * @param key The key of the entity to detach.\n * @throws {DetachException} If the entity does not exist.\n * @throws {DetachException} If passed key doesn't belong to an entity.\n * @throws {DetachException} When the entity is not a child of the current model.\n */\n detachEntity(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} entity, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not an entity`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} entity, but it is not a child of this model`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all entities.\n *\n * Note, it accounts for the order of the entities as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of model.listEntities()) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(): Generator<DomainEntity> {\n for (const { key, type } of this.fields) {\n if (type !== 'entity') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainEntityKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this model has any entities.\n *\n * @returns True if the model has entities.\n * @example\n * ```typescript\n * if (model.hasEntities()) {\n * // ...\n * }\n * ```\n */\n hasEntities(): boolean {\n return this.fields.some((item) => item.type === 'entity')\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.getLabel('Unnamed model'),\n kind: DomainModelKind,\n })\n let parent: DomainNamespace | DataDomain = this.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.getLabel('Unnamed namespace'),\n })\n const typed = parent as DomainNamespace\n parent = typed.getParentInstance()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.getLabel('Unnamed data domain'),\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Checks if this model has any fields (entities).\n *\n * @returns True if the model has fields.\n * @example\n * ```typescript\n * if (model.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the data model is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the data model is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this data model is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { DomainModelKind, DomainNamespaceKind } from '../models/kinds.js';
|
|
|
3
3
|
import { DomainElement } from './DomainElement.js';
|
|
4
4
|
import { nanoid } from '../nanoid.js';
|
|
5
5
|
import { Thing } from '../models/Thing.js';
|
|
6
|
-
import { observed, retargetChange } from '
|
|
6
|
+
import { observed, retargetChange } from '../decorators/observed.js';
|
|
7
7
|
import { DomainModel } from './DomainModel.js';
|
|
8
8
|
import { RemoveNamespaceException } from '../exceptions/remove_namespace_exception.js';
|
|
9
9
|
import { RemoveModelException } from '../exceptions/remove_model_exception.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainNamespace.js","sourceRoot":"","sources":["../../../src/modeling/DomainNamespace.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,WAAW,EAAqB,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAC9E,OAAO,EAAE,eA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EAAE,CAAC;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACtC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,SAAQ;gBACV,CAAC;gBACD,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;oBACvE,MAAM,IAAI,CAAA;gBACZ,CAAC;YACH,CAAC;QACH,CAAC;QAED;;;;;;;;;;WAUG;QACH,SAAS;YACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QAC/B,CAAC;QAEO,WAAW,CAAC,GAAW;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QAC9D,CAAC;QAED;;;;;;WAMG;QACH,SAAS,CAAC,GAAW;YACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SA/dU,eAAe","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainModelKind, DomainNamespaceKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from './observed.js'\nimport { DomainModel, DomainModelSchema } from './DomainModel.js'\nimport { RemoveNamespaceException } from '../exceptions/remove_namespace_exception.js'\nimport { RemoveModelException } from '../exceptions/remove_model_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\n\nexport interface NamespaceOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'namespace' | 'model'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainNamespaceSchema extends DomainElementSchema {\n kind: typeof DomainNamespaceKind\n /**\n * The data namespace description.\n */\n info: IThing\n /**\n * The ordered list of fields (namespace and models) in the schema.\n * These only keep references to define the order of these properties\n * in the schema as graph won't do it.\n */\n fields?: NamespaceOrderedItem[]\n\n /**\n * Whether this namespace is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * The domain namespace is a way to create a logical structure around data models.\n * It groups data models that represent a whole schema, like a Product data namespace\n * can have data models that describe: the product data model, price history data model,\n * product location, etc.\n *\n * It is optional to have a namespace, but it is recommended to have one for complex\n * data domains.\n *\n * A data domain can be a child of another data domain. It can also contain multiple\n * data domains and data models.\n */\nexport class DomainNamespace extends DomainElement {\n override kind: typeof DomainNamespaceKind\n\n /**\n * The description of the domain namespace.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of fields (namespace and models) in the schema.\n * These only keep references to define the order of these properties\n * in the schema as graph won't do it.\n */\n accessor fields: NamespaceOrderedItem[]\n\n /**\n * Whether this namespace is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full namespace schema with defaults.\n * @param input The partial namespace schema.\n * @returns The namespace schema.\n */\n static createSchema(input: Partial<DomainNamespaceSchema> = {}): DomainNamespaceSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New namespace' }).toJSON()\n const result: DomainNamespaceSchema = {\n kind: DomainNamespaceKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new namespace instance.\n * It does not add it to the graph.\n * You need to call the `addNamespace` method of the graph to add it.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial namespace schema.\n * @returns Created namespace instance.\n */\n constructor(root: DataDomain, input?: Partial<DomainNamespaceSchema>) {\n const init = DomainNamespace.createSchema(input)\n super(root, init.key)\n this.kind = DomainNamespaceKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n toJSON(): DomainNamespaceSchema {\n const result: DomainNamespaceSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Adds a child namespace to the current namespace.\n *\n * @param value The partial namespace schema.\n * @returns The created namespace instance.\n * @example\n * ```typescript\n * const property = namespace.addNamespace({\n * key: 'e-commerce'\n * })\n * ```\n */\n addNamespace(value?: Partial<DomainNamespaceSchema>): DomainNamespace {\n if (value && value.key && this.root.graph.hasNode(value.key)) {\n throw new Error(`Trying to add a namespace to ${this.key}, but it already exists`)\n }\n const instance = new DomainNamespace(this.root, value)\n this.root.graph.setNode(instance.key, instance)\n this.root.graph.setParent(instance.key, this.key)\n this.fields.push({\n type: 'namespace',\n key: instance.key,\n })\n this.root.notifyChange()\n return instance\n }\n\n /**\n * Removes a namespace from the current namespace.\n *\n * @param key The key of the namespace to remove.\n * @throws {RemoveNamespaceException} If the namespace does not exist.\n * @example\n * ```typescript\n * namespace.removeNamespace('e-commerce')\n * ```\n */\n removeNamespace(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveNamespaceException(`Trying to remove the ${key} namespace, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n throw new RemoveNamespaceException(`Trying to remove the ${key} namespace, but it is not a namespace`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Attaches a namespace to the current namespace. It changes the parent of the namespace\n * to the current namespace in the graph.\n *\n * The attached namespace must be already a child of another namespace.\n *\n * @param key The key of the namespace to attach.\n * @throws {Error} If the namespace does not exist.\n * @example\n * ```typescript\n * namespace.attachNamespace('e-commerce')\n * ```\n */\n attachNamespace(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new Error(`Trying to attach the ${key} namespace, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n throw new Error(`Trying to attach the ${key} namespace, but it is not a namespace`)\n }\n if (node.domain.key !== this.root.key) {\n throw new Error(`Trying to attach the ${key} namespace, but it is not in the same domain`)\n }\n const parent = node.getParentInstance()\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n if (this.root !== parent) {\n ;(parent as DomainNamespace).detachNamespace(key)\n }\n this.fields.push({\n type: 'namespace',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches a namespace from the current namespace. It changes the parent of the namespace\n * to the root graph.\n * Unlike remove, it doesn't remove the namespace from the graph nor notifies the change.\n * @param key The key of the namespace to detach.\n * @throws {RemoveNamespaceException} If the namespace does not exist.\n */\n detachNamespace(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new RemoveNamespaceException(`Trying to detach the ${key} namespace, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n throw new RemoveNamespaceException(`Trying to detach the ${key} namespace, but it is not a namespace`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all namespaces of this namespaces.\n *\n * Note, it accounts for the order of the namespaces as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainNamespace`.\n * @example\n * ```typescript\n * for (const ns of namespace.listNamespaces()) {\n * console.log(ns.key);\n * }\n * ```\n */\n *listNamespaces(): Generator<DomainNamespace> {\n for (const { key, type } of this.fields) {\n if (type !== 'namespace') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this namespace has any namespaces.\n *\n * @returns True if the namespace has namespaces.\n * @example\n * ```typescript\n * if (namespace.hasNamespaces()) {\n * // ...\n * }\n * ```\n */\n hasNamespaces(): boolean {\n return this.fields.some((item) => item.type === 'namespace')\n }\n\n /**\n * Adds a data model to the current namespace.\n * @param value The partial data model schema.\n * @returns The created data model instance.\n * @example\n * ```typescript\n * const property = namespace.addModel({\n * key: 'inventory'\n * })\n * ```\n */\n addModel(input?: Partial<DomainModelSchema>): DomainModel {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Trying to add a model to ${this.key}, but it already exists`)\n }\n const item = new DomainModel(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n type: 'model',\n key: item.key,\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes a data model from the current namespace.\n *\n * @param key The key of the data model to remove.\n * @throws {RemoveModelException} If the data model does not exist.\n * @example\n * ```typescript\n * namespace.removeModel('inventory')\n * ```\n */\n removeModel(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveModelException(`Trying to remove the ${key} model, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n throw new RemoveModelException(`Trying to remove the ${key} model, but it is not a model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Attaches a model to the current namespace and sets its parent to the current namespace.\n *\n * The attached model is already a child of another namespace.\n * This method only adds this model to its internal list of fields.\n *\n * Unlike `addModel`, it doesn't create a new model or add it to the graph.\n * It only adds the model to the list of fields.\n *\n * @param key The key of the model to attach.\n * @throws {AttachException} If the model does not exist.\n * @throws {AttachException} If the model is not a model.\n * @throws {AttachException} If the model is not in the same domain.\n * @throws {AttachException} If the model is already a child of this namespace.\n * @example\n * ```typescript\n * namespace.attachModel('inventory')\n * ```\n */\n attachModel(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} model, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n throw new AttachException(`Trying to attach the ${key} model, but it is not a model`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} model, but it is not in the same domain`)\n }\n const parent = node.getParentInstance()\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} model, but it is already a child of this namespace`)\n }\n if (this.root !== parent) {\n ;(parent as DomainNamespace).detachModel(key)\n }\n this.fields.push({\n type: 'model',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches a model from the current namespace and sets its parent to the root graph.\n * Unlike remove, it doesn't remove the model from the graph nor notifies the change.\n * @param key The key of the model to detach.\n * @throws {DetachException} If the model does not exist.\n * @throws {DetachException} If the model is not a model.\n * @throws {DetachException} If the model is not a child of this namespace.\n */\n detachModel(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} model, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n throw new DetachException(`Trying to detach the ${key} model, but it is not a model`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} model, but it is not a child of this namespace`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all models of this namespaces.\n *\n * Note, it accounts for the order of the models as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainModel`.\n * @example\n * ```typescript\n * for (const ns of namespace.listModels()) {\n * console.log(ns.key);\n * }\n * ```\n */\n *listModels(): Generator<DomainModel> {\n for (const { key, type } of this.fields) {\n if (type !== 'model') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this namespace has any models.\n *\n * @returns True if the namespace has models.\n * @example\n * ```typescript\n * if (namespace.hasModels()) {\n * // ...\n * }\n * ```\n */\n hasModels(): boolean {\n return this.fields.some((item) => item.type === 'model')\n }\n\n /**\n * Returns a parent data namespace or the data domain where this data namespace exist.\n */\n getParentInstance(): DomainNamespace | DataDomain {\n let parentKey: string | undefined\n for (const parent of this.root.graph.parents(this.key)) {\n parentKey = parent\n break\n }\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Lists all fields (namespace and models) of this namespace.\n *\n * @returns A generator that yields each `DomainAssociation` or `DomainProperty`.\n * @example\n * ```typescript\n * for (const field of namespace.listFields()) {\n * console.log(field.key);\n * }\n * ```\n */\n *listFields(): Generator<DomainNamespace | DomainModel> {\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 === DomainNamespaceKind || node.kind === DomainModelKind) {\n yield node\n }\n }\n }\n\n /**\n * Checks if this namespace has any fields (namespace and models).\n *\n * @returns True if the namespace has fields.\n * @example\n * ```typescript\n * if (namespace.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the namespace is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this namespace is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainNamespace.js","sourceRoot":"","sources":["../../../src/modeling/DomainNamespace.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAqB,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAiCnE;;;;;;;;;;;GAWG;IACU,eAAe;sBAAS,aAAa;;;;;;;iBAArC,eAAgB,SAAQ,WAAa;;;gCAM/C,cAAc,EAAE;sCAYhB,QAAQ,EAAE;YAZO,iKAAS,IAAI,6BAAJ,IAAI,mFAAO;YAY1B,mLAAS,UAAU,6BAAV,UAAU,+FAAqB;;;QAjB3C,IAAI,CAA4B;QAKvB,6EAAoB;QAHtC;;WAEG;QACe,IAAS,IAAI,0CA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AAC;QAEO,WAAW,CAAC,GAAW;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QAC9D,CAAC;QAED;;;;;;WAMG;QACH,SAAS,CAAC,GAAW;YACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAA;YACd,CAAC;YACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAQ,MAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;;;SA/dU,eAAe","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainModelKind, DomainNamespaceKind } from '../models/kinds.js'\nimport { DomainElement, DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange } from '../decorators/observed.js'\nimport { DomainModel, DomainModelSchema } from './DomainModel.js'\nimport { RemoveNamespaceException } from '../exceptions/remove_namespace_exception.js'\nimport { RemoveModelException } from '../exceptions/remove_model_exception.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { DetachException } from '../exceptions/detach_exception.js'\nimport { AttachException } from '../exceptions/attach_exception.js'\n\nexport interface NamespaceOrderedItem {\n /**\n * The type of the ordered item.\n */\n type: 'namespace' | 'model'\n\n /**\n * The key of the ordered item.\n */\n key: string\n}\n\nexport interface DomainNamespaceSchema extends DomainElementSchema {\n kind: typeof DomainNamespaceKind\n /**\n * The data namespace description.\n */\n info: IThing\n /**\n * The ordered list of fields (namespace and models) in the schema.\n * These only keep references to define the order of these properties\n * in the schema as graph won't do it.\n */\n fields?: NamespaceOrderedItem[]\n\n /**\n * Whether this namespace is deprecated.\n */\n deprecated?: boolean\n}\n\n/**\n * The domain namespace is a way to create a logical structure around data models.\n * It groups data models that represent a whole schema, like a Product data namespace\n * can have data models that describe: the product data model, price history data model,\n * product location, etc.\n *\n * It is optional to have a namespace, but it is recommended to have one for complex\n * data domains.\n *\n * A data domain can be a child of another data domain. It can also contain multiple\n * data domains and data models.\n */\nexport class DomainNamespace extends DomainElement {\n override kind: typeof DomainNamespaceKind\n\n /**\n * The description of the domain namespace.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * The ordered list of fields (namespace and models) in the schema.\n * These only keep references to define the order of these properties\n * in the schema as graph won't do it.\n */\n accessor fields: NamespaceOrderedItem[]\n\n /**\n * Whether this namespace is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Creates a full namespace schema with defaults.\n * @param input The partial namespace schema.\n * @returns The namespace schema.\n */\n static createSchema(input: Partial<DomainNamespaceSchema> = {}): DomainNamespaceSchema {\n const { key = nanoid(), fields, deprecated } = input\n const info = Thing.fromJSON(input.info, { name: 'New namespace' }).toJSON()\n const result: DomainNamespaceSchema = {\n kind: DomainNamespaceKind,\n key,\n info,\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n return result\n }\n\n /**\n * Creates a new namespace instance.\n * It does not add it to the graph.\n * You need to call the `addNamespace` method of the graph to add it.\n *\n * @param root A reference to the root DataDomain instance.\n * @param input The partial namespace schema.\n * @returns Created namespace instance.\n */\n constructor(root: DataDomain, input?: Partial<DomainNamespaceSchema>) {\n const init = DomainNamespace.createSchema(input)\n super(root, init.key)\n this.kind = DomainNamespaceKind\n this.info = new Thing(init.info)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n toJSON(): DomainNamespaceSchema {\n const result: DomainNamespaceSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n /**\n * Adds a child namespace to the current namespace.\n *\n * @param value The partial namespace schema.\n * @returns The created namespace instance.\n * @example\n * ```typescript\n * const property = namespace.addNamespace({\n * key: 'e-commerce'\n * })\n * ```\n */\n addNamespace(value?: Partial<DomainNamespaceSchema>): DomainNamespace {\n if (value && value.key && this.root.graph.hasNode(value.key)) {\n throw new Error(`Trying to add a namespace to ${this.key}, but it already exists`)\n }\n const instance = new DomainNamespace(this.root, value)\n this.root.graph.setNode(instance.key, instance)\n this.root.graph.setParent(instance.key, this.key)\n this.fields.push({\n type: 'namespace',\n key: instance.key,\n })\n this.root.notifyChange()\n return instance\n }\n\n /**\n * Removes a namespace from the current namespace.\n *\n * @param key The key of the namespace to remove.\n * @throws {RemoveNamespaceException} If the namespace does not exist.\n * @example\n * ```typescript\n * namespace.removeNamespace('e-commerce')\n * ```\n */\n removeNamespace(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveNamespaceException(`Trying to remove the ${key} namespace, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n throw new RemoveNamespaceException(`Trying to remove the ${key} namespace, but it is not a namespace`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Attaches a namespace to the current namespace. It changes the parent of the namespace\n * to the current namespace in the graph.\n *\n * The attached namespace must be already a child of another namespace.\n *\n * @param key The key of the namespace to attach.\n * @throws {Error} If the namespace does not exist.\n * @example\n * ```typescript\n * namespace.attachNamespace('e-commerce')\n * ```\n */\n attachNamespace(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new Error(`Trying to attach the ${key} namespace, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n throw new Error(`Trying to attach the ${key} namespace, but it is not a namespace`)\n }\n if (node.domain.key !== this.root.key) {\n throw new Error(`Trying to attach the ${key} namespace, but it is not in the same domain`)\n }\n const parent = node.getParentInstance()\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} entity, but it is already a child of this model`)\n }\n if (this.root !== parent) {\n ;(parent as DomainNamespace).detachNamespace(key)\n }\n this.fields.push({\n type: 'namespace',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches a namespace from the current namespace. It changes the parent of the namespace\n * to the root graph.\n * Unlike remove, it doesn't remove the namespace from the graph nor notifies the change.\n * @param key The key of the namespace to detach.\n * @throws {RemoveNamespaceException} If the namespace does not exist.\n */\n detachNamespace(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new RemoveNamespaceException(`Trying to detach the ${key} namespace, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n throw new RemoveNamespaceException(`Trying to detach the ${key} namespace, but it is not a namespace`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all namespaces of this namespaces.\n *\n * Note, it accounts for the order of the namespaces as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainNamespace`.\n * @example\n * ```typescript\n * for (const ns of namespace.listNamespaces()) {\n * console.log(ns.key);\n * }\n * ```\n */\n *listNamespaces(): Generator<DomainNamespace> {\n for (const { key, type } of this.fields) {\n if (type !== 'namespace') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this namespace has any namespaces.\n *\n * @returns True if the namespace has namespaces.\n * @example\n * ```typescript\n * if (namespace.hasNamespaces()) {\n * // ...\n * }\n * ```\n */\n hasNamespaces(): boolean {\n return this.fields.some((item) => item.type === 'namespace')\n }\n\n /**\n * Adds a data model to the current namespace.\n * @param value The partial data model schema.\n * @returns The created data model instance.\n * @example\n * ```typescript\n * const property = namespace.addModel({\n * key: 'inventory'\n * })\n * ```\n */\n addModel(input?: Partial<DomainModelSchema>): DomainModel {\n if (input && input.key && this.root.graph.hasNode(input.key)) {\n throw new Error(`Trying to add a model to ${this.key}, but it already exists`)\n }\n const item = new DomainModel(this.root, input)\n this.root.graph.setNode(item.key, item)\n this.root.graph.setParent(item.key, this.key)\n this.fields.push({\n type: 'model',\n key: item.key,\n })\n this.root.notifyChange()\n return item\n }\n\n /**\n * Removes a data model from the current namespace.\n *\n * @param key The key of the data model to remove.\n * @throws {RemoveModelException} If the data model does not exist.\n * @example\n * ```typescript\n * namespace.removeModel('inventory')\n * ```\n */\n removeModel(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new RemoveModelException(`Trying to remove the ${key} model, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n throw new RemoveModelException(`Trying to remove the ${key} model, but it is not a model`)\n }\n removeGraphNode(this.root.graph, key)\n this.removeField(key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Attaches a model to the current namespace and sets its parent to the current namespace.\n *\n * The attached model is already a child of another namespace.\n * This method only adds this model to its internal list of fields.\n *\n * Unlike `addModel`, it doesn't create a new model or add it to the graph.\n * It only adds the model to the list of fields.\n *\n * @param key The key of the model to attach.\n * @throws {AttachException} If the model does not exist.\n * @throws {AttachException} If the model is not a model.\n * @throws {AttachException} If the model is not in the same domain.\n * @throws {AttachException} If the model is already a child of this namespace.\n * @example\n * ```typescript\n * namespace.attachModel('inventory')\n * ```\n */\n attachModel(key: string): this {\n if (!this.root.graph.hasNode(key)) {\n throw new AttachException(`Trying to attach the ${key} model, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n throw new AttachException(`Trying to attach the ${key} model, but it is not a model`)\n }\n if (node.domain.key !== this.root.key) {\n throw new AttachException(`Trying to attach the ${key} model, but it is not in the same domain`)\n }\n const parent = node.getParentInstance()\n if (parent === this) {\n throw new AttachException(`Trying to attach the ${key} model, but it is already a child of this namespace`)\n }\n if (this.root !== parent) {\n ;(parent as DomainNamespace).detachModel(key)\n }\n this.fields.push({\n type: 'model',\n key: key,\n })\n this.root.graph.setParent(key, this.key)\n this.root.notifyChange()\n return this\n }\n\n /**\n * Detaches a model from the current namespace and sets its parent to the root graph.\n * Unlike remove, it doesn't remove the model from the graph nor notifies the change.\n * @param key The key of the model to detach.\n * @throws {DetachException} If the model does not exist.\n * @throws {DetachException} If the model is not a model.\n * @throws {DetachException} If the model is not a child of this namespace.\n */\n detachModel(key: string): this {\n const index = this.fields.findIndex((item) => item.key === key)\n if (index === -1) {\n throw new DetachException(`Trying to detach the ${key} model, but it doesn't exist`)\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n throw new DetachException(`Trying to detach the ${key} model, but it is not a model`)\n }\n if (node.getParentInstance() !== this) {\n throw new DetachException(`Trying to detach the ${key} model, but it is not a child of this namespace`)\n }\n this.fields.splice(index, 1)\n this.root.graph.setParent(key)\n return this\n }\n\n /**\n * Lists all models of this namespaces.\n *\n * Note, it accounts for the order of the models as\n * defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainModel`.\n * @example\n * ```typescript\n * for (const ns of namespace.listModels()) {\n * console.log(ns.key);\n * }\n * ```\n */\n *listModels(): Generator<DomainModel> {\n for (const { key, type } of this.fields) {\n if (type !== 'model') {\n continue\n }\n const node = this.root.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this namespace has any models.\n *\n * @returns True if the namespace has models.\n * @example\n * ```typescript\n * if (namespace.hasModels()) {\n * // ...\n * }\n * ```\n */\n hasModels(): boolean {\n return this.fields.some((item) => item.type === 'model')\n }\n\n /**\n * Returns a parent data namespace or the data domain where this data namespace exist.\n */\n getParentInstance(): DomainNamespace | DataDomain {\n let parentKey: string | undefined\n for (const parent of this.root.graph.parents(this.key)) {\n parentKey = parent\n break\n }\n if (!parentKey) {\n return this.root\n }\n return this.root.graph.node(parentKey) as DomainNamespace\n }\n\n /**\n * Lists all fields (namespace and models) of this namespace.\n *\n * @returns A generator that yields each `DomainAssociation` or `DomainProperty`.\n * @example\n * ```typescript\n * for (const field of namespace.listFields()) {\n * console.log(field.key);\n * }\n * ```\n */\n *listFields(): Generator<DomainNamespace | DomainModel> {\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 === DomainNamespaceKind || node.kind === DomainModelKind) {\n yield node\n }\n }\n }\n\n /**\n * Checks if this namespace has any fields (namespace and models).\n *\n * @returns True if the namespace has fields.\n * @example\n * ```typescript\n * if (namespace.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks whether the namespace is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this namespace is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n if (parent === this.root) {\n return false\n }\n return (parent as DomainNamespace).isChildOf(key)\n }\n}\n"]}
|
|
@@ -311,5 +311,10 @@ export declare class DomainProperty extends DomainElement {
|
|
|
311
311
|
* @returns True if the semantic is present, false otherwise.
|
|
312
312
|
*/
|
|
313
313
|
hasSemantic(semanticId: SemanticType): boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Creates a duplicate of this domain property on the parent entity.
|
|
316
|
+
* It places the duplicate on the parent entity right after the original property.
|
|
317
|
+
*/
|
|
318
|
+
duplicate(): DomainProperty;
|
|
314
319
|
}
|
|
315
320
|
//# sourceMappingURL=DomainProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainProperty.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAGL,KAAK,uBAAuB,EAE5B,KAAK,oBAAoB,EAEzB,KAAK,kBAAkB,EAIxB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAC3F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAqC,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAE/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAEpE,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,IAAI,EAAE,OAAO,kBAAkB,CAAA;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;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AO,GAAG,KAAK,IAAI,kBAAkB;IAO/D;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB;IAOzE;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB;IAiBnE;;;OAGG;IACH,YAAY,IAAI,cAAc;IAO9B;;;OAGG;IACH,aAAa,IAAI,mBAAmB;IASpC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS;IAKnE;;;;;;;;;;;;OAYG;IACH,UAAU,IAAI,iBAAiB;IAK/B;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IAerG;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAchD;;;OAGG;IACH,cAAc,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI;IAQ9C;;;;OAIG;IACH,WAAW,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO;IAI9C;;;OAGG;IACH,SAAS,IAAI,cAAc;CAqC5B"}
|
|
@@ -3,7 +3,7 @@ import { DomainPropertyKind } from '../models/kinds.js';
|
|
|
3
3
|
import { DomainElement } from './DomainElement.js';
|
|
4
4
|
import { nanoid } from '../nanoid.js';
|
|
5
5
|
import { Thing } from '../models/Thing.js';
|
|
6
|
-
import { observed, retargetChange, toRaw } from '
|
|
6
|
+
import { observed, retargetChange, toRaw } from '../decorators/observed.js';
|
|
7
7
|
import { BinaryFormats, DomainPropertyAttributes, DomainPropertyList, DomainPropertyTypes, NumberFormats, } from './DataFormat.js';
|
|
8
8
|
import { ShapeGenerator } from './amf/ShapeGenerator.js';
|
|
9
9
|
import { DataSemantics, isPropertySemantic } from './Semantics.js';
|
|
@@ -620,6 +620,43 @@ let DomainProperty = (() => {
|
|
|
620
620
|
hasSemantic(semanticId) {
|
|
621
621
|
return this.semantics.some((s) => s.id === semanticId);
|
|
622
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Creates a duplicate of this domain property on the parent entity.
|
|
625
|
+
* It places the duplicate on the parent entity right after the original property.
|
|
626
|
+
*/
|
|
627
|
+
duplicate() {
|
|
628
|
+
const parent = this.getParentInstance();
|
|
629
|
+
if (!parent) {
|
|
630
|
+
throw new Error(`Cannot duplicate property ${this.key} as it has no parent entity.`);
|
|
631
|
+
}
|
|
632
|
+
const originalIndex = parent.fields.findIndex((f) => f.key === this.key);
|
|
633
|
+
if (originalIndex === -1) {
|
|
634
|
+
throw new Error(`Cannot duplicate property ${this.key} as it does not exist on the parent entity fields list.`);
|
|
635
|
+
}
|
|
636
|
+
const baseName = this.info.name || 'field';
|
|
637
|
+
const newName = parent.generateUniqueName(baseName);
|
|
638
|
+
// Making a copy and restoring it through the `addProperty()` method
|
|
639
|
+
// scales better than copying it manually.
|
|
640
|
+
const copy = this.toJSON();
|
|
641
|
+
// Delete properties that should not be copied
|
|
642
|
+
delete copy.key;
|
|
643
|
+
delete copy.primary; // Don't duplicate the primary key
|
|
644
|
+
// Set the new name for the duplicated property
|
|
645
|
+
if (copy.info) {
|
|
646
|
+
copy.info.name = newName;
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
copy.info = { name: newName };
|
|
650
|
+
}
|
|
651
|
+
const result = parent.addProperty(copy);
|
|
652
|
+
// Move the duplicate to be right after the original
|
|
653
|
+
const fromIndex = parent.fields.length - 1;
|
|
654
|
+
const duplicateField = parent.fields[fromIndex];
|
|
655
|
+
parent.fields.splice(fromIndex, 1);
|
|
656
|
+
parent.fields.splice(originalIndex + 1, 0, duplicateField);
|
|
657
|
+
this.domain.notifyChange();
|
|
658
|
+
return result;
|
|
659
|
+
}
|
|
623
660
|
};
|
|
624
661
|
})();
|
|
625
662
|
export { DomainProperty };
|