@api-client/core 0.14.1 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/browser.d.ts +1 -1
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +2 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/ApiFile.d.ts +23 -0
- package/build/src/modeling/ApiFile.d.ts.map +1 -0
- package/build/src/modeling/ApiFile.js +44 -0
- package/build/src/modeling/ApiFile.js.map +1 -0
- package/build/src/modeling/ApiModel.d.ts +159 -0
- package/build/src/modeling/ApiModel.d.ts.map +1 -0
- package/build/src/modeling/ApiModel.js +237 -0
- package/build/src/modeling/ApiModel.js.map +1 -0
- package/build/src/modeling/DataDomain.d.ts +1 -1
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js +1 -3
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +35 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js +42 -5
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.js +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +1 -2
- package/build/src/modeling/DomainFile.d.ts.map +1 -1
- package/build/src/modeling/DomainFile.js +3 -41
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +62 -7
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +76 -7
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
- package/build/src/modeling/types.d.ts +491 -0
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/models/kinds.d.ts +2 -0
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +2 -0
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/File.d.ts +19 -2
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +100 -13
- package/build/src/models/store/File.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/APIC-187.json +3 -3
- package/data/models/APIC-188.json +3 -3
- package/data/models/APIC-233.json +1 -1
- package/data/models/APIC-391.json +2 -2
- package/data/models/APIC-483.json +1 -1
- package/data/models/APIC-487.json +1 -1
- package/data/models/APIC-655.json +1 -1
- package/data/models/APIC-689.json +1 -1
- package/data/models/APIC-690.json +5 -5
- package/data/models/SE-10469.json +1 -1
- package/data/models/SE-13092.json +5 -5
- package/data/models/SE-22063.json +12 -2
- package/data/models/amf-helper-api.json +154 -14
- package/data/models/arc-demo-api.json +95 -15
- package/data/models/async-api.json +1 -1
- package/data/models/example-generator-api.json +361 -21
- package/data/models/expanded-api.json +1 -1
- package/data/models/flattened-api.json +1 -1
- package/data/models/multiple-servers.json +1 -1
- package/data/models/oas-3-api.json +1 -1
- package/data/models/oas-date.json +1 -1
- package/data/models/oas-types.json +1 -1
- package/data/models/oas-unions.json +1 -1
- package/data/models/petstore.json +1 -1
- package/data/models/raml-date.json +1 -1
- package/data/models/recursive.json +1 -1
- package/data/models/schema-api.json +62 -2
- package/data/models/secured-api.json +16 -16
- package/data/models/tracked-to-linked.json +4 -4
- package/package.json +3 -4
- package/src/modeling/ApiFile.ts +53 -0
- package/src/modeling/ApiModel.ts +327 -0
- package/src/modeling/DataDomain.ts +1 -1
- package/src/modeling/DomainAssociation.ts +56 -0
- package/src/modeling/DomainEntity.ts +1 -1
- package/src/modeling/DomainFile.ts +3 -40
- package/src/modeling/Semantics.ts +79 -7
- package/src/modeling/amf/ShapeGenerator.ts +1 -1
- package/src/modeling/types.ts +545 -0
- package/src/models/kinds.ts +2 -0
- package/src/models/store/File.ts +100 -13
- package/tests/unit/modeling/api_model.spec.ts +291 -0
- package/tests/unit/modeling/domain_asociation.spec.ts +92 -2
- package/tests/unit/modeling/domain_entity.spec.ts +15 -15
- package/tests/unit/modeling/domain_file.spec.ts +1 -11
- package/tests/unit/modeling/domain_model_entities.spec.ts +2 -2
- package/tests/unit/modeling/semantics.spec.ts +146 -0
- package/tests/unit/models/File/constructor.spec.ts +3 -2
- package/tests/unit/models/File/shortcutTo.spec.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataDomain.js","sourceRoot":"","sources":["../../../src/modeling/DataDomain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAQ3B,OAAO,EAA8B,eAAe,EAA6B,MAAM,sBAAsB,CAAA;AAC7G,OAAO,EAA0B,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAItE,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAgBjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC;;OAEG;IACH,IAAI,CAAuB;IAC3B;;OAEG;IACH,GAAG,CAAQ;IAEX;;OAEG;IACH,KAAK,CAAsD;IAE3D;;;;OAIG;IACH,YAAY,GAA4B,IAAI,GAAG,EAAsB,CAAA;IAErE;;OAEG;IACH,cAAc,GAA8B,EA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QACpD,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,UAAU,GAAG,GAAG,SAAS,IAAI,SAAS,EAAE,CAAA;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACxC,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC3C,OAAO,IAAoB,CAAA;QAC7B,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,mBAAmB,CAAC,GAAW,EAAE,IAAY;QAC3C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,mBAAmB;gBACtB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;gBACzB,MAAK;YACP,KAAK,eAAe;gBAClB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;gBACrB,MAAK;YACP,KAAK,gBAAgB;gBACnB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;gBACtB,MAAK;YACP,KAAK,kBAAkB;gBACrB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;gBACxB,MAAK;YACP,KAAK,qBAAqB;gBACxB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;gBAC3B,MAAK;YACP;gBACE,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,mBAAmB,GAAG,EAAE,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;CACF","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { Graph } from '@api-client/graph/graph/Graph.js'\nimport {\n DomainAssociationKind,\n DataDomainKind,\n DomainEntityKind,\n DomainModelKind,\n DomainNamespaceKind,\n DomainPropertyKind,\n} from '../models/kinds.js'\nimport type {\n AssociationAddOptions,\n DomainGraphEdge,\n DomainGraphNodeType,\n ForeignDomainDependency,\n SerializedGraph,\n} from './types.js'\nimport { type DomainNamespaceSchema, DomainNamespace, type NamespaceOrderedItem } from './DomainNamespace.js'\nimport { type DomainModelSchema, DomainModel } from './DomainModel.js'\nimport { type DomainEntitySchema, DomainEntity } from './DomainEntity.js'\nimport { DomainAssociation } from './DomainAssociation.js'\nimport { DomainProperty, DomainPropertySchema } from './DomainProperty.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { serialize, deserialize, mergeGraph, removeForeignGraph } from './DomainSerialization.js'\n\nexport interface DataDomainSchema {\n info: IThing\n kind: typeof DataDomainKind\n key: string\n graph?: SerializedGraph\n dependencyList?: ForeignDomainDependency[]\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/**\n * Represents the root of a data domain model.\n *\n * The `DataDomain` class serves as the top-level container\n * for a collection of data models, namespaces, entities,\n * properties, and associations. It provides methods for\n * managing and manipulating these data elements, enabling\n * the creation of complex and interconnected data\n * structures.\n *\n * **Key Features:**\n *\n * - **Root Container:** Holds all data elements within a domain.\n * - **Graph-Based Structure:** Uses a graph to represent relationships between data elements.\n * - **Namespace Management:** Supports creating and managing namespaces to organize data models.\n * - **Data Model Management:** Supports creating and managing data models to group entities.\n * - **Entity Management:** Supports creating and managing entities, which define the structure of data.\n * - **Property Management:** Supports creating and managing properties, which define the data elements\n * within entities.\n * - **Association Management:** Supports creating and managing associations, which define relationships\n * between entities.\n * - **Foreign Domain Support:** Allows registering and integrating data from external domains.\n * - **Change Notification:** Notifies listeners when changes occur within the data domain.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `DataDomain`.\n * 2. Use methods like `addNamespace()`, `addModel()`,\n * `addEntity()`, `addProperty()`, and `addAssociation()`\n * to build the data domain structure.\n * 3. Use methods like `findNamespace()`, `findModel()`,\n * `findEntity()`, `findProperty()`, and\n * `findAssociation()` to retrieve data elements.\n * 4. Use methods like `listNamespaces()`, `listGraphNamespaces()`, `listModels()`,\n * and `listEntities()` to iterate over collections of\n * data elements.\n * 5. Use `registerForeignDomain()` to integrate data from\n * external domains.\n * 6. Listen for the `change` event to be notified of\n * changes within the data domain.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userNamespace = dataDomain.addNamespace({\n * key: 'userNamespace',\n * });\n * const userModel = userNamespace.addModel({\n * key: 'userModel',\n * });\n * const userEntity = userModel.addEntity({\n * key: 'user',\n * });\n * const nameProperty = userEntity.addProperty({\n * key: 'name',\n * type: 'string',\n * });\n * ```\n *\n * @fires DataDomain#change {Event} - Fired when the data\n * domain changes.\n *\n * @todo: Implement a mechanism to move an entity to a new\n * parent model.\n */\nexport class DataDomain extends EventTarget {\n /**\n * The kind of the domain element.\n */\n kind: typeof DataDomainKind\n /**\n * The unique key of the domain element.\n */\n key: string\n\n /**\n * The graph used to store the data domain structure.\n */\n graph: Graph<unknown, DomainGraphNodeType, DomainGraphEdge>\n\n /**\n * A map of foreign data domains.\n * Key: The unique identifier of the foreign domain.\n * Value: The foreign DataDomain instance.\n */\n dependencies: Map<string, DataDomain> = new Map<string, DataDomain>()\n\n /**\n * The list of foreign domain dependencies.\n */\n dependencyList: ForeignDomainDependency[] = []\n\n /**\n * The description of the domain property.\n */\n accessor info: Thing\n\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n\n /**\n * This is to keep it consistent with the domain elements.\n */\n get domain(): DataDomain {\n return this\n }\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 static createSchema(input: Partial<DataDomainSchema> = {}): DataDomainSchema {\n const { key = nanoid(), fields } = input\n const info = Thing.fromJSON(input.info, { name: 'Unnamed domain' }).toJSON()\n const result: DataDomainSchema = {\n kind: DataDomainKind,\n key,\n info,\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.graph) {\n result.graph = input.graph\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n return result\n }\n\n /**\n * Creates a new instance of the `DataDomain` class.\n *\n * When creating a new Data Domain arguments should not be set.\n * When restoring a Data Domain from a previous state, you should provide\n * the serialized graph state as well as the same list of dependencies\n * used when the graph was deserialized. Edges to missing dependency nodes\n * will be ignored.\n *\n * @param state The previously serialized state of the graph.\n * @param dependencies An array of foreign data domains to register with this domain.\n */\n constructor(state?: Partial<DataDomainSchema>, dependencies?: DataDomain[]) {\n super()\n const init = DataDomain.createSchema(state)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.graph = deserialize(this, init.graph, dependencies)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (Array.isArray(init.dependencyList)) {\n this.dependencyList = [...init.dependencyList]\n } else {\n this.dependencyList = []\n }\n this.#initializing = false\n this.info.addEventListener('change', () => {\n this.notifyChange()\n })\n }\n\n /**\n * Serializes the DataDomain instance to a JSON object.\n * It does not serialize the foreign domain dependencies. The serialized nodes\n * are the ones that are local to this data domain.\n * @returns The serialized data domain ready for storage or transport.\n */\n toJSON(): DataDomainSchema {\n const result: DataDomainSchema = {\n info: this.info.toJSON(),\n kind: this.kind,\n key: this.key,\n graph: serialize(this.graph, this.key),\n }\n if (this.dependencyList.length > 0) {\n result.dependencyList = structuredClone(this.dependencyList)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n return result\n }\n\n /**\n * This function is used internally by all domain elements to notify that something has changed.\n * Since we want to notify listeners after the operation commits, we use microtask\n * to ensure that the event is dispatched after the current operation.\n */\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n })\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks if this data domain has any fields (namespace and models).\n *\n * @returns True if the data domain has fields.\n * @example\n * ```typescript\n * if (domain.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\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.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 * Adds a new data domain instance to the graph.\n *\n * @param value The partial namespace schema. All missing\n * values will be filled with default values.\n * @param parent The parent namespace key. If not provided,\n * the new namespace will be added to the root of the\n * graph.\n * @returns The created namespace instance.\n * @throws Error When the parent does not exist or is not\n * a namespace.\n * @example\n * ```typescript\n * const newNamespace = dataDomain.addNamespace({\n * key: 'newNamespace',\n * });\n * ```\n */\n addNamespace(value?: Partial<DomainNamespaceSchema>, parent?: string): DomainNamespace {\n if (parent) {\n if (!this.graph.hasNode(parent)) {\n throw new Error(`Parent namespace ${parent} does not exist`)\n }\n const instance = this.graph.node(parent) as DomainNamespace\n if (!instance || instance.kind !== DomainNamespaceKind) {\n throw new Error(`Parent namespace ${parent} is not a valid namespace`)\n }\n if (instance.domain.key !== this.key) {\n throw new Error(`Cannot add a namespace to a foreign domain`)\n }\n return instance.addNamespace(value)\n }\n const item = new DomainNamespace(this, value)\n this.graph.setNode(item.key, item)\n this.fields.push({\n type: 'namespace',\n key: item.key,\n })\n this.notifyChange()\n return item\n }\n\n /**\n * Removes a namespace from the graph.\n *\n * @param key The key of the namespace to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the namespace does not exist.\n * @example\n * ```typescript\n * dataDomain.removeNamespace('userNamespace');\n * ```\n */\n removeNamespace(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Namespace ${key} does not exist`)\n }\n const ns = this.graph.node(key) as DomainNamespace\n if (!ns || ns.kind !== DomainNamespaceKind) {\n throw new Error(`Namespace ${key} not found`)\n }\n if (ns.domain.key !== this.key) {\n throw new Error(`Cannot remove a namespace from a foreign domain`)\n }\n const parent = ns.getParentInstance()\n if (parent === this) {\n removeGraphNode(this.graph, key)\n this.removeField(key)\n this.notifyChange()\n } else {\n parent.removeNamespace(key)\n }\n return this\n }\n\n /**\n * Lists all namespaces of this data domain that are direct children of it.\n *\n * Note, it accounts for the order of the namespaces as defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainNamespace`.\n * @example\n * ```typescript\n * for (const ns of domain.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.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this data domain has any namespaces.\n *\n * @returns True if the data domain has namespaces.\n * @example\n * ```typescript\n * if (domain.hasNamespaces()) {\n * // ...\n * }\n * ```\n */\n hasNamespaces(): boolean {\n return this.fields.some((item) => item.type === 'namespace')\n }\n\n /**\n * Lists all namespaces in the graph.\n *\n * @param parent The key of the parent namespace. If not\n * provided, all root namespaces will be listed.\n * @returns A generator that yields each `DomainNamespace`.\n * @example\n * ```typescript\n * for (const ns of dataDomain.listGraphNamespaces()) {\n * console.log(ns.key);\n * }\n * ```\n */\n *listGraphNamespaces(parent?: string): Generator<DomainNamespace> {\n for (const node of this.graph.children(parent)) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainNamespaceKind && value.domain.key === this.key) {\n yield value\n }\n }\n }\n\n /**\n * Finds a namespace by its key.\n *\n * @param key The key of the namespace to find.\n * @returns The namespace instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const ns = dataDomain.findNamespace('userNamespace');\n * if (ns) {\n * console.log(ns.key);\n * }\n * ```\n */\n findNamespace(key: string): DomainNamespace | undefined {\n const result = this.graph.node(key) as DomainNamespace | undefined\n if (result && result.kind === DomainNamespaceKind) {\n return result\n }\n }\n\n /**\n * Moves a namespace to a new parent.\n *\n * @param key The key of the namespace to move.\n * @param parent The new parent namespace key. If\n * undefined, the namespace will be moved to the root.\n * @returns The current DataDomain instance.\n * @throws Error When the namespace or parent does not\n * exist, or when a namespace is moved to itself or\n * its own child.\n * @example\n * ```typescript\n * dataDomain.moveNamespace('userNamespace', 'root');\n * ```\n */\n moveNamespace(key: string, parent?: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Namespace ${key} does not exist`)\n }\n\n const namespace = this.findNamespace(key)\n if (!namespace) {\n throw new Error(`Namespace ${key} not found in the graph`)\n }\n\n if (parent) {\n const instance = this.findNamespace(parent)\n if (instance && instance.domain.key !== this.key) {\n throw new Error(`Cannot move a namespace to a foreign domain`)\n }\n if (!instance) {\n throw new Error(`Parent namespace ${parent} does not exist`)\n }\n }\n\n if (key === parent) {\n throw new Error(`Cannot move a namespace to itself`)\n }\n\n if (namespace.domain.key !== this.key) {\n throw new Error(`Cannot move a namespace from a foreign domain`)\n }\n let parentNamespace: DomainNamespace | undefined\n if (parent) {\n parentNamespace = this.findNamespace(parent)\n if (!parentNamespace) {\n throw new Error(`Parent namespace ${parent} not found`)\n }\n if (this.isChildOf(parent, key)) {\n throw new Error(`Cannot move a namespace to its own child`)\n }\n }\n\n // namespaces can only have one parent\n const currentParentKey = this.graph.parent(key)\n if (currentParentKey && !parent) {\n // The new parent namespace will detach the namespace when attaching to self.\n const currentParent = this.graph.node(currentParentKey) as DomainNamespace\n currentParent.detachNamespace(key)\n } else if (!currentParentKey) {\n // The namespace is a root namespace.\n this.removeField(key)\n }\n // Add to new parent\n if (parent && parentNamespace) {\n parentNamespace.attachNamespace(key)\n } else {\n // The namespace is a root namespace.\n this.fields.push({\n type: 'namespace',\n key,\n })\n }\n this.notifyChange()\n return this\n }\n\n /**\n * Checks if a namespace is a child of another namespace.\n * @param parentKey The key of the parent namespace.\n * @param childKey The key of the child namespace.\n * @returns True if the namespace is a child of another namespace.\n */\n private isChildOf(parentKey: string, childKey: string): boolean {\n const children = this.graph.children(childKey)\n for (const child of children) {\n if (child === parentKey) {\n return true\n }\n if (this.isChildOf(parentKey, child)) {\n return true\n }\n }\n return false\n }\n\n /**\n * Adds a data model to the graph.\n *\n * @param input The partial data model schema.\n * @param parent The parent namespace key. If not\n * provided, the new data model will be added to the\n * root of the graph.\n * @returns The created data model instance.\n * @throws Error When the parent does not exist or is not\n * a namespace.\n * @example\n * ```typescript\n * const newModel = dataDomain.addModel({\n * key: 'newModel',\n * });\n * ```\n */\n addModel(input?: Partial<DomainModelSchema>, parent?: string): DomainModel {\n if (parent) {\n if (!this.graph.hasNode(parent)) {\n throw new Error(`Parent ${parent} does not exist`)\n }\n const instance = this.findNamespace(parent)\n if (!instance) {\n throw new Error(`Parent namespace ${parent} is not a valid namespace`)\n }\n if (instance.domain.key !== this.key) {\n throw new Error(`Cannot add a model to a foreign domain`)\n }\n return instance.addModel(input)\n }\n const item = new DomainModel(this, input)\n this.graph.setNode(item.key, item)\n this.fields.push({\n type: 'model',\n key: item.key,\n })\n return item\n }\n\n /**\n * Removes a data model from the graph.\n *\n * @param key The key of the data model to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the data model does not exist.\n * @example\n * ```typescript\n * dataDomain.removeModel('userModel');\n * ```\n */\n removeModel(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Data model ${key} does not exist`)\n }\n const model = this.graph.node(key) as DomainModel\n if (!model || model.kind !== DomainModelKind) {\n throw new Error(`Data model ${key} not found`)\n }\n if (model.domain.key !== this.key) {\n throw new Error(`Cannot remove a model from a foreign domain`)\n }\n const parent = model.getParentInstance()\n if (parent === this) {\n removeGraphNode(this.graph, key)\n this.removeField(key)\n this.notifyChange()\n } else {\n parent.removeModel(key)\n }\n return this\n }\n\n /**\n * Lists all models of this data domain that are direct children of it.\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.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this data domain has any direct models.\n *\n * @returns True if the data domain has models.\n * @example\n * ```typescript\n * if (domain.hasModels()) {\n * // ...\n * }\n * ```\n */\n hasModels(): boolean {\n return this.fields.some((item) => item.type === 'model')\n }\n\n /**\n * Lists all data models in the graph.\n *\n * @param parent The key of the parent namespace. If not\n * provided, all root data models will be listed.\n * @returns A generator that yields each `DomainModel`.\n * @example\n * ```typescript\n * for (const model of dataDomain.listGraphModels()) {\n * console.log(model.key);\n * }\n * ```\n */\n *listGraphModels(parent?: string): Generator<DomainModel> {\n for (const node of this.graph.children(parent)) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainModelKind && value.domain.key === this.key) {\n yield value\n }\n }\n }\n\n /**\n * Finds a data model by its key.\n *\n * @param key The key of the data model to find.\n * @returns The data model instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const model = dataDomain.findModel('userModel');\n * if (model) {\n * console.log(model.key);\n * }\n * ```\n */\n findModel(key: string): DomainModel | undefined {\n const value = this.graph.node(key) as DomainModel | undefined\n if (value && value.kind === DomainModelKind) {\n return value\n }\n return undefined\n }\n\n /**\n * Moves a data model to a new parent.\n *\n * @param key The key of the data model to move.\n * @param parent The new parent namespace key. If\n * undefined, the data model will be moved to the root.\n * @returns The current DataDomain instance.\n * @throws Error When the data model or parent does not\n * exist, or when a data model is moved to a foreign\n * domain.\n * @example\n * ```typescript\n * dataDomain.moveModel('userModel', 'newNamespace');\n * ```\n */\n moveModel(key: string, parent?: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Data model ${key} does not exist`)\n }\n\n const model = this.findModel(key)\n if (!model) {\n throw new Error(`Data model ${key} not found in the graph`)\n }\n\n if (parent) {\n const instance = this.findNamespace(parent)\n if (instance && instance.domain.key !== this.key) {\n throw new Error(`Cannot move a model to a foreign domain`)\n }\n if (!instance) {\n throw new Error(`Parent namespace ${parent} does not exist`)\n }\n }\n\n if (model.domain.key !== this.key) {\n throw new Error(`Cannot move a data model to a foreign domain`)\n }\n\n // namespaces can only have one parent\n const currentParentKey = this.graph.parent(key)\n // Remove from current parent\n if (currentParentKey && !parent) {\n // The new parent namespace will detach the model when attaching to self.\n const currentParent = this.findNamespace(currentParentKey)\n if (!currentParent) {\n throw new Error(`The parent namespace ${currentParentKey} not found`)\n }\n currentParent.detachModel(key)\n } else if (!currentParentKey) {\n // The model is a root model.\n this.removeField(key)\n }\n\n // Add to new parent\n if (parent) {\n const parentNamespace = this.findNamespace(parent) as DomainNamespace\n parentNamespace.attachModel(key)\n } else {\n // The model is becoming a root model.\n this.fields.push({\n type: 'model',\n key,\n })\n }\n\n this.notifyChange()\n return this\n }\n\n /**\n * Adds an entity to a data model.\n *\n * @param input The partial entity schema.\n * @param parent The key of the parent data model.\n * @returns The created entity instance.\n * @throws {Error} When the parent does not exist or is not a data model.\n * @example\n * ```typescript\n * const userEntity = dataDomain.addEntity({\n * key: 'user',\n * }, 'userModel');\n * ```\n */\n addEntity(parent: string, input?: Partial<DomainEntitySchema>): DomainEntity {\n if (!parent) {\n throw new Error(`An entity expects a DomainModel parent`)\n }\n if (!this.graph.hasNode(parent)) {\n throw new Error(`The parent ${parent} does not exist`)\n }\n const instance = this.findModel(parent)\n if (!instance) {\n throw new Error(`Parent model ${parent} is not a valid model`)\n }\n if (instance.domain.key !== this.key) {\n throw new Error(`Cannot add an entity to a foreign domain`)\n }\n return instance.addEntity(input)\n }\n\n /**\n * Removes an entity from the graph.\n *\n * @param key The key of the entity to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the entity does not exist.\n * @example\n * ```typescript\n * dataDomain.removeEntity('user');\n * ```\n */\n removeEntity(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Entity ${key} does not exist`)\n }\n const parentKey = this.graph.parent(key)\n if (!parentKey) {\n throw new Error(`Parent model not found for entity ${key}`)\n }\n const parent = this.findModel(parentKey)\n if (!parent) {\n throw new Error(`Parent model ${parentKey} not found`)\n }\n if (parent.domain.key !== this.key) {\n throw new Error(`Cannot remove an entity from a foreign domain`)\n }\n parent.removeEntity(key)\n return this\n }\n\n /**\n * Lists all entities in a data model, or, if the model key is not provided,\n * all entities in the domain.\n *\n * @param parent The key of the parent data model.\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of dataDomain.listEntities('userModel')) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(parent?: string): Generator<DomainEntity> {\n const iterator = parent ? this.graph.children(parent) : this.graph.nodes()\n for (const node of iterator) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainEntityKind && value.domain.key === this.key) {\n yield value\n }\n }\n }\n\n /**\n * Lists all entities in the graph that are not part of this domain.\n */\n *listForeignEntities(): Generator<DomainEntity> {\n for (const node of this.graph.nodes()) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainEntityKind && value.domain.key !== this.key) {\n yield value\n }\n }\n }\n\n /**\n * Finds an entity by its key.\n *\n * @param key The key of the entity to find.\n * @returns The entity instance or undefined if not found.\n * @example\n * ```typescript\n * const entity = dataDomain.findEntity('user');\n * if (entity) {\n * console.log(entity.key);\n * }\n * ```\n */\n findEntity(key: string): DomainEntity | undefined {\n const node = this.graph.node(key) as DomainEntity | undefined\n if (node && node.kind === DomainEntityKind) {\n return node\n }\n return undefined\n }\n\n /**\n * Moves an entity from one model to another.\n *\n * @param entityKey The key of the entity to move.\n * @param sourceModelKey The key of the source model.\n * @param targetModelKey The key of the target model.\n * @throws Error When the entity, source model, or target model does not exist.\n * @throws Error When the entity is not in the same domain.\n * @throws Error When the source and target models are the same.\n * @throws Error When moving to an unsupported object.\n */\n moveEntity(entityKey: string, sourceModelKey: string, targetModelKey: string): void {\n if (sourceModelKey === targetModelKey) {\n throw new Error(`Cannot move an entity to the same model`)\n }\n if (!this.graph.hasNode(entityKey)) {\n throw new Error(`Entity ${entityKey} does not exist`)\n }\n if (!this.graph.hasNode(sourceModelKey)) {\n throw new Error(`Source model ${sourceModelKey} does not exist`)\n }\n if (!this.graph.hasNode(targetModelKey)) {\n throw new Error(`Target model ${targetModelKey} does not exist`)\n }\n\n const entity = this.findEntity(entityKey)\n const sourceModel = this.findModel(sourceModelKey)\n const targetModel = this.findModel(targetModelKey)\n\n if (!entity || !sourceModel || !targetModel) {\n throw new Error(`Entity or models not found in the graph`)\n }\n\n if (entity.domain.key !== this.key) {\n // this also applied to the parent model.\n throw new Error(`Cannot move an entity from a foreign domain`)\n }\n if (targetModel.domain.key !== this.key) {\n throw new Error(`Cannot move an entity to a foreign domain`)\n }\n // The target model detaches the entity when attaching to self.\n targetModel.attachEntity(entityKey)\n this.notifyChange()\n }\n\n /**\n * Adds an association between two entities.\n *\n * This function is a shortcut that finds the entity and\n * calls the `addAssociation` method on it.\n *\n * @param source The key of the source entity.\n * @param init The association options.\n * @returns The created association.\n * @throws Error When the source entity does not exist.\n * @example\n * ```typescript\n * const addressAssociation = dataDomain.addAssociation(\n * 'user', { key: 'address' }\n * );\n * ```\n */\n addAssociation(source: string, init?: AssociationAddOptions): DomainAssociation {\n if (!this.graph.hasNode(source)) {\n throw new Error(`Source entity ${source} not found`)\n }\n const entity = this.findEntity(source)\n if (!entity) {\n throw new Error(`Source entity ${source} not found`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot add an association to a foreign domain`)\n }\n return entity.addAssociation(init)\n }\n\n /**\n * Removes an association from the graph.\n *\n * @param key The key of the association to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the association does not exist or\n * when the parent entity is not found.\n * @example\n * ```typescript\n * dataDomain.removeAssociation('address');\n * ```\n */\n removeAssociation(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Association ${key} does not exist`)\n }\n const instance = this.graph.node(key) as DomainAssociation\n if (!instance || instance.kind !== DomainAssociationKind) {\n throw new Error(`Association ${key} not found`)\n }\n const entity = instance.getParentInstance()\n if (!entity) {\n throw new Error(`Parent entity not found for association ${key}`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot remove an association from a foreign domain`)\n }\n entity.removeAssociation(key)\n return this\n }\n\n /**\n * Finds an association by its key.\n *\n * @param key The key of the association to find.\n * @returns The association instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const assoc = dataDomain.findAssociation('address');\n * if (assoc) {\n * console.log(assoc.key);\n * }\n * ```\n */\n findAssociation(key: string): DomainAssociation | undefined {\n const node = this.graph.node(key) as DomainAssociation | undefined\n if (node && node.kind === DomainAssociationKind) {\n return node\n }\n return undefined\n }\n\n /**\n * Adds a property to an entity.\n *\n * @param parent The key of the parent entity.\n * @param property The partial property schema.\n * @returns The created property instance.\n * @throws Error When the parent does not exist or is not\n * an entity.\n * @example\n * ```typescript\n * const nameProperty = dataDomain.addProperty(\n * 'user', { key: 'name', type: 'string' }\n * );\n * ```\n */\n addProperty(parent: string, property?: Partial<DomainPropertySchema>): DomainProperty {\n if (!parent) {\n throw new Error(`A property expects a DomainEntity parent`)\n }\n if (!this.graph.hasNode(parent)) {\n throw new Error(`Parent entity ${parent} does not exist`)\n }\n const entity = this.findEntity(parent)\n if (!entity) {\n throw new Error(`Parent entity ${parent} not found`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot add a property to a foreign domain`)\n }\n return entity.addProperty(property)\n }\n\n /**\n * Removes a property from the graph.\n *\n * @param key The key of the property to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the property does not exist or when\n * the parent entity is not found.\n * @example\n * ```typescript\n * dataDomain.removeProperty('name');\n * ```\n */\n removeProperty(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Property ${key} does not exist`)\n }\n const instance = this.graph.node(key) as DomainProperty\n if (!instance || instance.kind !== DomainPropertyKind) {\n throw new Error(`Property ${key} not found`)\n }\n const entity = instance.getParentInstance()\n if (!entity) {\n throw new Error(`Parent entity not found for property ${key}`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot remove a property from a foreign domain`)\n }\n entity.removeProperty(key)\n return this\n }\n\n /**\n * Finds a property by its key.\n *\n * @param key The key of the property to find.\n * @returns The property instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const prop = dataDomain.findProperty('name');\n * if (prop) {\n * console.log(prop.key);\n * }\n * ```\n */\n findProperty(key: string): DomainProperty | undefined {\n const node = this.graph.node(key) as DomainProperty | undefined\n if (node && node.kind === DomainPropertyKind) {\n return node\n }\n return undefined\n }\n\n /**\n * Registers a foreign DataDomain.\n *\n * @param domain The foreign DataDomain instance.\n * @param key The unique identifier for the foreign\n * domain.\n * @param version The version of the foreign domain.\n * @throws Error When a foreign domain with the same key is already registered.\n * @example\n * ```typescript\n * dataDomain.registerForeignDomain(\n * foreignDomain, 'foreignDomain', '1.0.0'\n * );\n * ```\n */\n registerForeignDomain(domain: DataDomain): void {\n const { info, key } = domain\n if (!info.version) {\n // @TODO: make the data domain immutable after a version is set.\n // This will prevent the user from changing the version\n // after the domain is registered.\n throw new Error(`Foreign domain ${key} does not have a version set`)\n }\n if (this.dependencies.has(key)) {\n throw new Error(`Foreign domain with key ${key} already registered`)\n }\n this.dependencies.set(key, domain)\n this.dependencyList.push({ key, version: info.version })\n // Copy the relevant parts of the foreign domain's graph into the local graph.\n // this.copyForeignDomainGraph(domain)\n mergeGraph(this.graph, domain.graph, domain.key)\n this.notifyChange()\n }\n\n /**\n * Un-registers a foreign DataDomain. It removes all defined by the foreign domain\n * information from the graph.\n * @param key The key of the foreign domain to unregister.\n */\n unregisterForeignDomain(key: string): void {\n const foreignDomain = this.dependencies.get(key)\n if (!foreignDomain) {\n throw new Error(`Foreign domain with key ${key} not found`)\n }\n this.dependencies.delete(key)\n this.dependencyList = this.dependencyList.filter((dependency) => dependency.key !== key)\n // Remove the foreign domain's nodes from the local graph.\n removeForeignGraph(this.graph, foreignDomain.key)\n this.notifyChange()\n }\n\n /**\n * Finds an entity in a foreign domain.\n *\n * @param entityKey The key of the entity to find.\n * @param domainKey The key of the foreign domain.\n * @returns The entity instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const foreignUser = dataDomain.findForeignEntity(\n * 'user', 'foreignDomain'\n * );\n * if (foreignUser) {\n * console.log(foreignUser.key);\n * }\n * ```\n */\n findForeignEntity(entityKey: string, domainKey: string): DomainEntity | undefined {\n const foreignDomain = this.dependencies.get(domainKey)\n if (!foreignDomain) {\n return undefined\n }\n const foreignKey = `${domainKey}:${entityKey}`\n const node = this.graph.node(foreignKey)\n if (node && node.kind === DomainEntityKind) {\n return node as DomainEntity\n }\n return undefined\n }\n\n /**\n * A convenience function to remove an object from the\n * namespace.\n *\n * @param key The key of the object to remove.\n * @param kind The kind of the object to remove.\n * @throws Error when the kind is not known.\n * @example\n * ```typescript\n * dataDomain.removeDomainElement('user', DomainEntityKind);\n * ```\n */\n removeDomainElement(key: string, kind: string): void {\n switch (kind) {\n case DomainNamespaceKind:\n this.removeNamespace(key)\n break\n case DomainModelKind:\n this.removeModel(key)\n break\n case DomainEntityKind:\n this.removeEntity(key)\n break\n case DomainPropertyKind:\n this.removeProperty(key)\n break\n case DomainAssociationKind:\n this.removeAssociation(key)\n break\n default:\n throw new Error(`Unknown kind ${kind} for the object ${key}`)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataDomain.js","sourceRoot":"","sources":["../../../src/modeling/DataDomain.ts"],"names":[],"m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3C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,mBAAmB;gBACtB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;gBACzB,MAAK;YACP,KAAK,eAAe;gBAClB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;gBACrB,MAAK;YACP,KAAK,gBAAgB;gBACnB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;gBACtB,MAAK;YACP,KAAK,kBAAkB;gBACrB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;gBACxB,MAAK;YACP,KAAK,qBAAqB;gBACxB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;gBAC3B,MAAK;YACP;gBACE,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,mBAAmB,GAAG,EAAE,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;CACF","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { Graph } from '@api-client/graph/graph/Graph.js'\nimport {\n DomainAssociationKind,\n DataDomainKind,\n DomainEntityKind,\n DomainModelKind,\n DomainNamespaceKind,\n DomainPropertyKind,\n} from '../models/kinds.js'\nimport type {\n AssociationAddOptions,\n DomainGraphEdge,\n DomainGraphNodeType,\n ForeignDomainDependency,\n SerializedGraph,\n} from './types.js'\nimport { type DomainNamespaceSchema, DomainNamespace, type NamespaceOrderedItem } from './DomainNamespace.js'\nimport { type DomainModelSchema, DomainModel } from './DomainModel.js'\nimport { type DomainEntitySchema, DomainEntity } from './DomainEntity.js'\nimport { DomainAssociation } from './DomainAssociation.js'\nimport { DomainProperty, DomainPropertySchema } from './DomainProperty.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { removeGraphNode } from './GraphUtils.js'\nimport { serialize, deserialize, mergeGraph, removeForeignGraph } from './DomainSerialization.js'\n\nexport interface DataDomainSchema {\n info: IThing\n kind: typeof DataDomainKind\n key: string\n graph?: SerializedGraph\n dependencyList?: ForeignDomainDependency[]\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/**\n * Represents the root of a data domain model.\n *\n * The `DataDomain` class serves as the top-level container\n * for a collection of data models, namespaces, entities,\n * properties, and associations. It provides methods for\n * managing and manipulating these data elements, enabling\n * the creation of complex and interconnected data\n * structures.\n *\n * **Key Features:**\n *\n * - **Root Container:** Holds all data elements within a domain.\n * - **Graph-Based Structure:** Uses a graph to represent relationships between data elements.\n * - **Namespace Management:** Supports creating and managing namespaces to organize data models.\n * - **Data Model Management:** Supports creating and managing data models to group entities.\n * - **Entity Management:** Supports creating and managing entities, which define the structure of data.\n * - **Property Management:** Supports creating and managing properties, which define the data elements\n * within entities.\n * - **Association Management:** Supports creating and managing associations, which define relationships\n * between entities.\n * - **Foreign Domain Support:** Allows registering and integrating data from external domains.\n * - **Change Notification:** Notifies listeners when changes occur within the data domain.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `DataDomain`.\n * 2. Use methods like `addNamespace()`, `addModel()`,\n * `addEntity()`, `addProperty()`, and `addAssociation()`\n * to build the data domain structure.\n * 3. Use methods like `findNamespace()`, `findModel()`,\n * `findEntity()`, `findProperty()`, and\n * `findAssociation()` to retrieve data elements.\n * 4. Use methods like `listNamespaces()`, `listGraphNamespaces()`, `listModels()`,\n * and `listEntities()` to iterate over collections of\n * data elements.\n * 5. Use `registerForeignDomain()` to integrate data from\n * external domains.\n * 6. Listen for the `change` event to be notified of\n * changes within the data domain.\n *\n * **Example:**\n *\n * ```typescript\n * const dataDomain = new DataDomain();\n * const userNamespace = dataDomain.addNamespace({\n * key: 'userNamespace',\n * });\n * const userModel = userNamespace.addModel({\n * key: 'userModel',\n * });\n * const userEntity = userModel.addEntity({\n * key: 'user',\n * });\n * const nameProperty = userEntity.addProperty({\n * key: 'name',\n * type: 'string',\n * });\n * ```\n *\n * @fires DataDomain#change {Event} - Fired when the data\n * domain changes.\n *\n * @todo: Implement a mechanism to move an entity to a new\n * parent model.\n */\nexport class DataDomain extends EventTarget {\n /**\n * The kind of the domain element.\n */\n kind: typeof DataDomainKind\n /**\n * The unique key of the domain element.\n */\n key: string\n\n /**\n * The graph used to store the data domain structure.\n */\n graph: Graph<unknown, DomainGraphNodeType, DomainGraphEdge>\n\n /**\n * A map of foreign data domains.\n * Key: The unique identifier of the foreign domain.\n * Value: The foreign DataDomain instance.\n */\n dependencies: Map<string, DataDomain> = new Map<string, DataDomain>()\n\n /**\n * The list of foreign domain dependencies.\n */\n dependencyList: ForeignDomainDependency[] = []\n\n /**\n * The description of the domain property.\n */\n info: Thing\n\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n\n /**\n * This is to keep it consistent with the domain elements.\n */\n get domain(): DataDomain {\n return this\n }\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 static createSchema(input: Partial<DataDomainSchema> = {}): DataDomainSchema {\n const { key = nanoid(), fields } = input\n const info = Thing.fromJSON(input.info, { name: 'Unnamed domain' }).toJSON()\n const result: DataDomainSchema = {\n kind: DataDomainKind,\n key,\n info,\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.graph) {\n result.graph = input.graph\n }\n if (Array.isArray(fields)) {\n result.fields = [...fields]\n }\n return result\n }\n\n /**\n * Creates a new instance of the `DataDomain` class.\n *\n * When creating a new Data Domain arguments should not be set.\n * When restoring a Data Domain from a previous state, you should provide\n * the serialized graph state as well as the same list of dependencies\n * used when the graph was deserialized. Edges to missing dependency nodes\n * will be ignored.\n *\n * @param state The previously serialized state of the graph.\n * @param dependencies An array of foreign data domains to register with this domain.\n */\n constructor(state?: Partial<DataDomainSchema>, dependencies?: DataDomain[]) {\n super()\n const init = DataDomain.createSchema(state)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.graph = deserialize(this, init.graph, dependencies)\n if (Array.isArray(init.fields)) {\n this.fields = [...init.fields]\n } else {\n this.fields = []\n }\n if (Array.isArray(init.dependencyList)) {\n this.dependencyList = [...init.dependencyList]\n } else {\n this.dependencyList = []\n }\n this.#initializing = false\n this.info.addEventListener('change', () => {\n this.notifyChange()\n })\n }\n\n /**\n * Serializes the DataDomain instance to a JSON object.\n * It does not serialize the foreign domain dependencies. The serialized nodes\n * are the ones that are local to this data domain.\n * @returns The serialized data domain ready for storage or transport.\n */\n toJSON(): DataDomainSchema {\n const result: DataDomainSchema = {\n info: this.info.toJSON(),\n kind: this.kind,\n key: this.key,\n graph: serialize(this.graph, this.key),\n }\n if (this.dependencyList.length > 0) {\n result.dependencyList = structuredClone(this.dependencyList)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n return result\n }\n\n /**\n * This function is used internally by all domain elements to notify that something has changed.\n * Since we want to notify listeners after the operation commits, we use microtask\n * to ensure that the event is dispatched after the current operation.\n */\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n })\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Checks if this data domain has any fields (namespace and models).\n *\n * @returns True if the data domain has fields.\n * @example\n * ```typescript\n * if (domain.hasFields()) {\n * // ...\n * }\n * ```\n */\n hasFields(): boolean {\n return this.fields.length > 0\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.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 * Adds a new data domain instance to the graph.\n *\n * @param value The partial namespace schema. All missing\n * values will be filled with default values.\n * @param parent The parent namespace key. If not provided,\n * the new namespace will be added to the root of the\n * graph.\n * @returns The created namespace instance.\n * @throws Error When the parent does not exist or is not\n * a namespace.\n * @example\n * ```typescript\n * const newNamespace = dataDomain.addNamespace({\n * key: 'newNamespace',\n * });\n * ```\n */\n addNamespace(value?: Partial<DomainNamespaceSchema>, parent?: string): DomainNamespace {\n if (parent) {\n if (!this.graph.hasNode(parent)) {\n throw new Error(`Parent namespace ${parent} does not exist`)\n }\n const instance = this.graph.node(parent) as DomainNamespace\n if (!instance || instance.kind !== DomainNamespaceKind) {\n throw new Error(`Parent namespace ${parent} is not a valid namespace`)\n }\n if (instance.domain.key !== this.key) {\n throw new Error(`Cannot add a namespace to a foreign domain`)\n }\n return instance.addNamespace(value)\n }\n const item = new DomainNamespace(this, value)\n this.graph.setNode(item.key, item)\n this.fields.push({\n type: 'namespace',\n key: item.key,\n })\n this.notifyChange()\n return item\n }\n\n /**\n * Removes a namespace from the graph.\n *\n * @param key The key of the namespace to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the namespace does not exist.\n * @example\n * ```typescript\n * dataDomain.removeNamespace('userNamespace');\n * ```\n */\n removeNamespace(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Namespace ${key} does not exist`)\n }\n const ns = this.graph.node(key) as DomainNamespace\n if (!ns || ns.kind !== DomainNamespaceKind) {\n throw new Error(`Namespace ${key} not found`)\n }\n if (ns.domain.key !== this.key) {\n throw new Error(`Cannot remove a namespace from a foreign domain`)\n }\n const parent = ns.getParentInstance()\n if (parent === this) {\n removeGraphNode(this.graph, key)\n this.removeField(key)\n this.notifyChange()\n } else {\n parent.removeNamespace(key)\n }\n return this\n }\n\n /**\n * Lists all namespaces of this data domain that are direct children of it.\n *\n * Note, it accounts for the order of the namespaces as defined in the `fields` array.\n *\n * @returns A generator that yields each `DomainNamespace`.\n * @example\n * ```typescript\n * for (const ns of domain.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.graph.node(key)\n if (!node || node.kind !== DomainNamespaceKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this data domain has any namespaces.\n *\n * @returns True if the data domain has namespaces.\n * @example\n * ```typescript\n * if (domain.hasNamespaces()) {\n * // ...\n * }\n * ```\n */\n hasNamespaces(): boolean {\n return this.fields.some((item) => item.type === 'namespace')\n }\n\n /**\n * Lists all namespaces in the graph.\n *\n * @param parent The key of the parent namespace. If not\n * provided, all root namespaces will be listed.\n * @returns A generator that yields each `DomainNamespace`.\n * @example\n * ```typescript\n * for (const ns of dataDomain.listGraphNamespaces()) {\n * console.log(ns.key);\n * }\n * ```\n */\n *listGraphNamespaces(parent?: string): Generator<DomainNamespace> {\n for (const node of this.graph.children(parent)) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainNamespaceKind && value.domain.key === this.key) {\n yield value\n }\n }\n }\n\n /**\n * Finds a namespace by its key.\n *\n * @param key The key of the namespace to find.\n * @returns The namespace instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const ns = dataDomain.findNamespace('userNamespace');\n * if (ns) {\n * console.log(ns.key);\n * }\n * ```\n */\n findNamespace(key: string): DomainNamespace | undefined {\n const result = this.graph.node(key) as DomainNamespace | undefined\n if (result && result.kind === DomainNamespaceKind) {\n return result\n }\n }\n\n /**\n * Moves a namespace to a new parent.\n *\n * @param key The key of the namespace to move.\n * @param parent The new parent namespace key. If\n * undefined, the namespace will be moved to the root.\n * @returns The current DataDomain instance.\n * @throws Error When the namespace or parent does not\n * exist, or when a namespace is moved to itself or\n * its own child.\n * @example\n * ```typescript\n * dataDomain.moveNamespace('userNamespace', 'root');\n * ```\n */\n moveNamespace(key: string, parent?: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Namespace ${key} does not exist`)\n }\n\n const namespace = this.findNamespace(key)\n if (!namespace) {\n throw new Error(`Namespace ${key} not found in the graph`)\n }\n\n if (parent) {\n const instance = this.findNamespace(parent)\n if (instance && instance.domain.key !== this.key) {\n throw new Error(`Cannot move a namespace to a foreign domain`)\n }\n if (!instance) {\n throw new Error(`Parent namespace ${parent} does not exist`)\n }\n }\n\n if (key === parent) {\n throw new Error(`Cannot move a namespace to itself`)\n }\n\n if (namespace.domain.key !== this.key) {\n throw new Error(`Cannot move a namespace from a foreign domain`)\n }\n let parentNamespace: DomainNamespace | undefined\n if (parent) {\n parentNamespace = this.findNamespace(parent)\n if (!parentNamespace) {\n throw new Error(`Parent namespace ${parent} not found`)\n }\n if (this.isChildOf(parent, key)) {\n throw new Error(`Cannot move a namespace to its own child`)\n }\n }\n\n // namespaces can only have one parent\n const currentParentKey = this.graph.parent(key)\n if (currentParentKey && !parent) {\n // The new parent namespace will detach the namespace when attaching to self.\n const currentParent = this.graph.node(currentParentKey) as DomainNamespace\n currentParent.detachNamespace(key)\n } else if (!currentParentKey) {\n // The namespace is a root namespace.\n this.removeField(key)\n }\n // Add to new parent\n if (parent && parentNamespace) {\n parentNamespace.attachNamespace(key)\n } else {\n // The namespace is a root namespace.\n this.fields.push({\n type: 'namespace',\n key,\n })\n }\n this.notifyChange()\n return this\n }\n\n /**\n * Checks if a namespace is a child of another namespace.\n * @param parentKey The key of the parent namespace.\n * @param childKey The key of the child namespace.\n * @returns True if the namespace is a child of another namespace.\n */\n private isChildOf(parentKey: string, childKey: string): boolean {\n const children = this.graph.children(childKey)\n for (const child of children) {\n if (child === parentKey) {\n return true\n }\n if (this.isChildOf(parentKey, child)) {\n return true\n }\n }\n return false\n }\n\n /**\n * Adds a data model to the graph.\n *\n * @param input The partial data model schema.\n * @param parent The parent namespace key. If not\n * provided, the new data model will be added to the\n * root of the graph.\n * @returns The created data model instance.\n * @throws Error When the parent does not exist or is not\n * a namespace.\n * @example\n * ```typescript\n * const newModel = dataDomain.addModel({\n * key: 'newModel',\n * });\n * ```\n */\n addModel(input?: Partial<DomainModelSchema>, parent?: string): DomainModel {\n if (parent) {\n if (!this.graph.hasNode(parent)) {\n throw new Error(`Parent ${parent} does not exist`)\n }\n const instance = this.findNamespace(parent)\n if (!instance) {\n throw new Error(`Parent namespace ${parent} is not a valid namespace`)\n }\n if (instance.domain.key !== this.key) {\n throw new Error(`Cannot add a model to a foreign domain`)\n }\n return instance.addModel(input)\n }\n const item = new DomainModel(this, input)\n this.graph.setNode(item.key, item)\n this.fields.push({\n type: 'model',\n key: item.key,\n })\n return item\n }\n\n /**\n * Removes a data model from the graph.\n *\n * @param key The key of the data model to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the data model does not exist.\n * @example\n * ```typescript\n * dataDomain.removeModel('userModel');\n * ```\n */\n removeModel(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Data model ${key} does not exist`)\n }\n const model = this.graph.node(key) as DomainModel\n if (!model || model.kind !== DomainModelKind) {\n throw new Error(`Data model ${key} not found`)\n }\n if (model.domain.key !== this.key) {\n throw new Error(`Cannot remove a model from a foreign domain`)\n }\n const parent = model.getParentInstance()\n if (parent === this) {\n removeGraphNode(this.graph, key)\n this.removeField(key)\n this.notifyChange()\n } else {\n parent.removeModel(key)\n }\n return this\n }\n\n /**\n * Lists all models of this data domain that are direct children of it.\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.graph.node(key)\n if (!node || node.kind !== DomainModelKind) {\n continue\n }\n yield node\n }\n }\n\n /**\n * Checks if this data domain has any direct models.\n *\n * @returns True if the data domain has models.\n * @example\n * ```typescript\n * if (domain.hasModels()) {\n * // ...\n * }\n * ```\n */\n hasModels(): boolean {\n return this.fields.some((item) => item.type === 'model')\n }\n\n /**\n * Lists all data models in the graph.\n *\n * @param parent The key of the parent namespace. If not\n * provided, all root data models will be listed.\n * @returns A generator that yields each `DomainModel`.\n * @example\n * ```typescript\n * for (const model of dataDomain.listGraphModels()) {\n * console.log(model.key);\n * }\n * ```\n */\n *listGraphModels(parent?: string): Generator<DomainModel> {\n for (const node of this.graph.children(parent)) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainModelKind && value.domain.key === this.key) {\n yield value\n }\n }\n }\n\n /**\n * Finds a data model by its key.\n *\n * @param key The key of the data model to find.\n * @returns The data model instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const model = dataDomain.findModel('userModel');\n * if (model) {\n * console.log(model.key);\n * }\n * ```\n */\n findModel(key: string): DomainModel | undefined {\n const value = this.graph.node(key) as DomainModel | undefined\n if (value && value.kind === DomainModelKind) {\n return value\n }\n return undefined\n }\n\n /**\n * Moves a data model to a new parent.\n *\n * @param key The key of the data model to move.\n * @param parent The new parent namespace key. If\n * undefined, the data model will be moved to the root.\n * @returns The current DataDomain instance.\n * @throws Error When the data model or parent does not\n * exist, or when a data model is moved to a foreign\n * domain.\n * @example\n * ```typescript\n * dataDomain.moveModel('userModel', 'newNamespace');\n * ```\n */\n moveModel(key: string, parent?: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Data model ${key} does not exist`)\n }\n\n const model = this.findModel(key)\n if (!model) {\n throw new Error(`Data model ${key} not found in the graph`)\n }\n\n if (parent) {\n const instance = this.findNamespace(parent)\n if (instance && instance.domain.key !== this.key) {\n throw new Error(`Cannot move a model to a foreign domain`)\n }\n if (!instance) {\n throw new Error(`Parent namespace ${parent} does not exist`)\n }\n }\n\n if (model.domain.key !== this.key) {\n throw new Error(`Cannot move a data model to a foreign domain`)\n }\n\n // namespaces can only have one parent\n const currentParentKey = this.graph.parent(key)\n // Remove from current parent\n if (currentParentKey && !parent) {\n // The new parent namespace will detach the model when attaching to self.\n const currentParent = this.findNamespace(currentParentKey)\n if (!currentParent) {\n throw new Error(`The parent namespace ${currentParentKey} not found`)\n }\n currentParent.detachModel(key)\n } else if (!currentParentKey) {\n // The model is a root model.\n this.removeField(key)\n }\n\n // Add to new parent\n if (parent) {\n const parentNamespace = this.findNamespace(parent) as DomainNamespace\n parentNamespace.attachModel(key)\n } else {\n // The model is becoming a root model.\n this.fields.push({\n type: 'model',\n key,\n })\n }\n\n this.notifyChange()\n return this\n }\n\n /**\n * Adds an entity to a data model.\n *\n * @param input The partial entity schema.\n * @param parent The key of the parent data model.\n * @returns The created entity instance.\n * @throws {Error} When the parent does not exist or is not a data model.\n * @example\n * ```typescript\n * const userEntity = dataDomain.addEntity({\n * key: 'user',\n * }, 'userModel');\n * ```\n */\n addEntity(parent: string, input?: Partial<DomainEntitySchema>): DomainEntity {\n if (!parent) {\n throw new Error(`An entity expects a DomainModel parent`)\n }\n if (!this.graph.hasNode(parent)) {\n throw new Error(`The parent ${parent} does not exist`)\n }\n const instance = this.findModel(parent)\n if (!instance) {\n throw new Error(`Parent model ${parent} is not a valid model`)\n }\n if (instance.domain.key !== this.key) {\n throw new Error(`Cannot add an entity to a foreign domain`)\n }\n return instance.addEntity(input)\n }\n\n /**\n * Removes an entity from the graph.\n *\n * @param key The key of the entity to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the entity does not exist.\n * @example\n * ```typescript\n * dataDomain.removeEntity('user');\n * ```\n */\n removeEntity(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Entity ${key} does not exist`)\n }\n const parentKey = this.graph.parent(key)\n if (!parentKey) {\n throw new Error(`Parent model not found for entity ${key}`)\n }\n const parent = this.findModel(parentKey)\n if (!parent) {\n throw new Error(`Parent model ${parentKey} not found`)\n }\n if (parent.domain.key !== this.key) {\n throw new Error(`Cannot remove an entity from a foreign domain`)\n }\n parent.removeEntity(key)\n return this\n }\n\n /**\n * Lists all entities in a data model, or, if the model key is not provided,\n * all entities in the domain.\n *\n * @param parent The key of the parent data model.\n * @returns A generator that yields each `DomainEntity`.\n * @example\n * ```typescript\n * for (const entity of dataDomain.listEntities('userModel')) {\n * console.log(entity.key);\n * }\n * ```\n */\n *listEntities(parent?: string): Generator<DomainEntity> {\n const iterator = parent ? this.graph.children(parent) : this.graph.nodes()\n for (const node of iterator) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainEntityKind && value.domain.key === this.key) {\n yield value\n }\n }\n }\n\n /**\n * Lists all entities in the graph that are not part of this domain.\n */\n *listForeignEntities(): Generator<DomainEntity> {\n for (const node of this.graph.nodes()) {\n const value = this.graph.node(node) as DomainGraphNodeType\n if (value.kind === DomainEntityKind && value.domain.key !== this.key) {\n yield value\n }\n }\n }\n\n /**\n * Finds an entity by its key.\n *\n * @param key The key of the entity to find.\n * @returns The entity instance or undefined if not found.\n * @example\n * ```typescript\n * const entity = dataDomain.findEntity('user');\n * if (entity) {\n * console.log(entity.key);\n * }\n * ```\n */\n findEntity(key: string): DomainEntity | undefined {\n const node = this.graph.node(key) as DomainEntity | undefined\n if (node && node.kind === DomainEntityKind) {\n return node\n }\n return undefined\n }\n\n /**\n * Moves an entity from one model to another.\n *\n * @param entityKey The key of the entity to move.\n * @param sourceModelKey The key of the source model.\n * @param targetModelKey The key of the target model.\n * @throws Error When the entity, source model, or target model does not exist.\n * @throws Error When the entity is not in the same domain.\n * @throws Error When the source and target models are the same.\n * @throws Error When moving to an unsupported object.\n */\n moveEntity(entityKey: string, sourceModelKey: string, targetModelKey: string): void {\n if (sourceModelKey === targetModelKey) {\n throw new Error(`Cannot move an entity to the same model`)\n }\n if (!this.graph.hasNode(entityKey)) {\n throw new Error(`Entity ${entityKey} does not exist`)\n }\n if (!this.graph.hasNode(sourceModelKey)) {\n throw new Error(`Source model ${sourceModelKey} does not exist`)\n }\n if (!this.graph.hasNode(targetModelKey)) {\n throw new Error(`Target model ${targetModelKey} does not exist`)\n }\n\n const entity = this.findEntity(entityKey)\n const sourceModel = this.findModel(sourceModelKey)\n const targetModel = this.findModel(targetModelKey)\n\n if (!entity || !sourceModel || !targetModel) {\n throw new Error(`Entity or models not found in the graph`)\n }\n\n if (entity.domain.key !== this.key) {\n // this also applied to the parent model.\n throw new Error(`Cannot move an entity from a foreign domain`)\n }\n if (targetModel.domain.key !== this.key) {\n throw new Error(`Cannot move an entity to a foreign domain`)\n }\n // The target model detaches the entity when attaching to self.\n targetModel.attachEntity(entityKey)\n this.notifyChange()\n }\n\n /**\n * Adds an association between two entities.\n *\n * This function is a shortcut that finds the entity and\n * calls the `addAssociation` method on it.\n *\n * @param source The key of the source entity.\n * @param init The association options.\n * @returns The created association.\n * @throws Error When the source entity does not exist.\n * @example\n * ```typescript\n * const addressAssociation = dataDomain.addAssociation(\n * 'user', { key: 'address' }\n * );\n * ```\n */\n addAssociation(source: string, init?: AssociationAddOptions): DomainAssociation {\n if (!this.graph.hasNode(source)) {\n throw new Error(`Source entity ${source} not found`)\n }\n const entity = this.findEntity(source)\n if (!entity) {\n throw new Error(`Source entity ${source} not found`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot add an association to a foreign domain`)\n }\n return entity.addAssociation(init)\n }\n\n /**\n * Removes an association from the graph.\n *\n * @param key The key of the association to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the association does not exist or\n * when the parent entity is not found.\n * @example\n * ```typescript\n * dataDomain.removeAssociation('address');\n * ```\n */\n removeAssociation(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Association ${key} does not exist`)\n }\n const instance = this.graph.node(key) as DomainAssociation\n if (!instance || instance.kind !== DomainAssociationKind) {\n throw new Error(`Association ${key} not found`)\n }\n const entity = instance.getParentInstance()\n if (!entity) {\n throw new Error(`Parent entity not found for association ${key}`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot remove an association from a foreign domain`)\n }\n entity.removeAssociation(key)\n return this\n }\n\n /**\n * Finds an association by its key.\n *\n * @param key The key of the association to find.\n * @returns The association instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const assoc = dataDomain.findAssociation('address');\n * if (assoc) {\n * console.log(assoc.key);\n * }\n * ```\n */\n findAssociation(key: string): DomainAssociation | undefined {\n const node = this.graph.node(key) as DomainAssociation | undefined\n if (node && node.kind === DomainAssociationKind) {\n return node\n }\n return undefined\n }\n\n /**\n * Adds a property to an entity.\n *\n * @param parent The key of the parent entity.\n * @param property The partial property schema.\n * @returns The created property instance.\n * @throws Error When the parent does not exist or is not\n * an entity.\n * @example\n * ```typescript\n * const nameProperty = dataDomain.addProperty(\n * 'user', { key: 'name', type: 'string' }\n * );\n * ```\n */\n addProperty(parent: string, property?: Partial<DomainPropertySchema>): DomainProperty {\n if (!parent) {\n throw new Error(`A property expects a DomainEntity parent`)\n }\n if (!this.graph.hasNode(parent)) {\n throw new Error(`Parent entity ${parent} does not exist`)\n }\n const entity = this.findEntity(parent)\n if (!entity) {\n throw new Error(`Parent entity ${parent} not found`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot add a property to a foreign domain`)\n }\n return entity.addProperty(property)\n }\n\n /**\n * Removes a property from the graph.\n *\n * @param key The key of the property to remove.\n * @returns The current DataDomain instance.\n * @throws Error When the property does not exist or when\n * the parent entity is not found.\n * @example\n * ```typescript\n * dataDomain.removeProperty('name');\n * ```\n */\n removeProperty(key: string): this {\n if (!this.graph.hasNode(key)) {\n throw new Error(`Property ${key} does not exist`)\n }\n const instance = this.graph.node(key) as DomainProperty\n if (!instance || instance.kind !== DomainPropertyKind) {\n throw new Error(`Property ${key} not found`)\n }\n const entity = instance.getParentInstance()\n if (!entity) {\n throw new Error(`Parent entity not found for property ${key}`)\n }\n if (entity.domain.key !== this.key) {\n throw new Error(`Cannot remove a property from a foreign domain`)\n }\n entity.removeProperty(key)\n return this\n }\n\n /**\n * Finds a property by its key.\n *\n * @param key The key of the property to find.\n * @returns The property instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const prop = dataDomain.findProperty('name');\n * if (prop) {\n * console.log(prop.key);\n * }\n * ```\n */\n findProperty(key: string): DomainProperty | undefined {\n const node = this.graph.node(key) as DomainProperty | undefined\n if (node && node.kind === DomainPropertyKind) {\n return node\n }\n return undefined\n }\n\n /**\n * Registers a foreign DataDomain.\n *\n * @param domain The foreign DataDomain instance.\n * @param key The unique identifier for the foreign\n * domain.\n * @param version The version of the foreign domain.\n * @throws Error When a foreign domain with the same key is already registered.\n * @example\n * ```typescript\n * dataDomain.registerForeignDomain(\n * foreignDomain, 'foreignDomain', '1.0.0'\n * );\n * ```\n */\n registerForeignDomain(domain: DataDomain): void {\n const { info, key } = domain\n if (!info.version) {\n // @TODO: make the data domain immutable after a version is set.\n // This will prevent the user from changing the version\n // after the domain is registered.\n throw new Error(`Foreign domain ${key} does not have a version set`)\n }\n if (this.dependencies.has(key)) {\n throw new Error(`Foreign domain with key ${key} already registered`)\n }\n this.dependencies.set(key, domain)\n this.dependencyList.push({ key, version: info.version })\n // Copy the relevant parts of the foreign domain's graph into the local graph.\n // this.copyForeignDomainGraph(domain)\n mergeGraph(this.graph, domain.graph, domain.key)\n this.notifyChange()\n }\n\n /**\n * Un-registers a foreign DataDomain. It removes all defined by the foreign domain\n * information from the graph.\n * @param key The key of the foreign domain to unregister.\n */\n unregisterForeignDomain(key: string): void {\n const foreignDomain = this.dependencies.get(key)\n if (!foreignDomain) {\n throw new Error(`Foreign domain with key ${key} not found`)\n }\n this.dependencies.delete(key)\n this.dependencyList = this.dependencyList.filter((dependency) => dependency.key !== key)\n // Remove the foreign domain's nodes from the local graph.\n removeForeignGraph(this.graph, foreignDomain.key)\n this.notifyChange()\n }\n\n /**\n * Finds an entity in a foreign domain.\n *\n * @param entityKey The key of the entity to find.\n * @param domainKey The key of the foreign domain.\n * @returns The entity instance or undefined if not\n * found.\n * @example\n * ```typescript\n * const foreignUser = dataDomain.findForeignEntity(\n * 'user', 'foreignDomain'\n * );\n * if (foreignUser) {\n * console.log(foreignUser.key);\n * }\n * ```\n */\n findForeignEntity(entityKey: string, domainKey: string): DomainEntity | undefined {\n const foreignDomain = this.dependencies.get(domainKey)\n if (!foreignDomain) {\n return undefined\n }\n const foreignKey = `${domainKey}:${entityKey}`\n const node = this.graph.node(foreignKey)\n if (node && node.kind === DomainEntityKind) {\n return node as DomainEntity\n }\n return undefined\n }\n\n /**\n * A convenience function to remove an object from the\n * namespace.\n *\n * @param key The key of the object to remove.\n * @param kind The kind of the object to remove.\n * @throws Error when the kind is not known.\n * @example\n * ```typescript\n * dataDomain.removeDomainElement('user', DomainEntityKind);\n * ```\n */\n removeDomainElement(key: string, kind: string): void {\n switch (kind) {\n case DomainNamespaceKind:\n this.removeNamespace(key)\n break\n case DomainModelKind:\n this.removeModel(key)\n break\n case DomainEntityKind:\n this.removeEntity(key)\n break\n case DomainPropertyKind:\n this.removeProperty(key)\n break\n case DomainAssociationKind:\n this.removeAssociation(key)\n break\n default:\n throw new Error(`Unknown kind ${kind} for the object ${key}`)\n }\n }\n}\n"]}
|
|
@@ -8,6 +8,25 @@ import type { AssociationBinding, AssociationBindings, AssociationWebBindings }
|
|
|
8
8
|
import { DomainAttributeAttribute } from './DataFormat.js';
|
|
9
9
|
import type { AssociationTarget } from './types.js';
|
|
10
10
|
import { type SemanticType, type AppliedDataSemantic } from './Semantics.js';
|
|
11
|
+
/**
|
|
12
|
+
* Defines the behavior when a parent entity in an association is deleted.
|
|
13
|
+
*
|
|
14
|
+
* - `restrict`: Prevents the deletion of a parent entity if it has any associated child entities.
|
|
15
|
+
* The generated API should return a clear and specific error message (e.g., 409 Conflict).
|
|
16
|
+
* - _Example_: Do not allow a Department to be deleted if it still has Employees.
|
|
17
|
+
* - `cascade`: Automatically deletes all associated child entities when the parent entity is deleted.
|
|
18
|
+
* - _Example_: Deleting a User will also delete all their associated Posts and Comments.
|
|
19
|
+
* - `setNull`: Sets the foreign key of the associated child entities to NULL. This is only valid if the
|
|
20
|
+
* association property on the child entity is nullable.
|
|
21
|
+
* - _Example_: When a `Project` is deleted, the `project_id` on associated `Tasks` is set to NULL,
|
|
22
|
+
* making them unassigned but not deleting them.
|
|
23
|
+
* - `doNothing`: No action is taken on the associated child entities when the parent entity is deleted.
|
|
24
|
+
* - _Example_: Deleting a `Category` does not affect associated `Products`, which remain in the database
|
|
25
|
+
* but may become orphaned.
|
|
26
|
+
* This is useful when the association is optional or when child entities should not be deleted
|
|
27
|
+
* or modified upon the deletion of a parent entity.
|
|
28
|
+
*/
|
|
29
|
+
export type OnDeleteRule = 'restrict' | 'cascade' | 'setNull' | 'doNothing';
|
|
11
30
|
export interface DomainAssociationSchema extends DomainElementSchema {
|
|
12
31
|
kind: typeof DomainAssociationKind;
|
|
13
32
|
/**
|
|
@@ -50,6 +69,14 @@ export interface DomainAssociationSchema extends DomainElementSchema {
|
|
|
50
69
|
* describe the association in more detail.
|
|
51
70
|
*/
|
|
52
71
|
semantics?: AppliedDataSemantic[];
|
|
72
|
+
/**
|
|
73
|
+
* Defines the behavior when a parent entity in an association is deleted.
|
|
74
|
+
*/
|
|
75
|
+
onDelete?: OnDeleteRule;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the association is read-only.
|
|
78
|
+
*/
|
|
79
|
+
readOnly?: boolean;
|
|
53
80
|
}
|
|
54
81
|
/**
|
|
55
82
|
* Represents an association between entities in a data domain.
|
|
@@ -139,6 +166,14 @@ export declare class DomainAssociation extends DomainElement {
|
|
|
139
166
|
* Semantics applied to this association.
|
|
140
167
|
*/
|
|
141
168
|
accessor semantics: AppliedDataSemantic[];
|
|
169
|
+
/**
|
|
170
|
+
* Defines the behavior when a parent entity in an association is deleted.
|
|
171
|
+
*/
|
|
172
|
+
accessor onDelete: OnDeleteRule | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* Whether the association is read-only.
|
|
175
|
+
*/
|
|
176
|
+
accessor readOnly: boolean | undefined;
|
|
142
177
|
/**
|
|
143
178
|
* Creates a full data association schema with defaults.
|
|
144
179
|
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B,CAAC;IAsCtF;;;;OAIG;IACH,MAAM,IAAI,uBAAuB;IAiCjC;;;;OAIG;IACH,iBAAiB,IAAI,YAAY,GAAG,SAAS;IAI7C;;;;;;;;;;OAUG;IACH,MAAM,IAAI,IAAI;IAKd;;;;;;;;OAQG;IACH,YAAY,IAAI,oBAAoB;IAOpC;;;;;;;OAOG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,wBAAwB;IAO1E;;;;;;;;;;OAUG;IACH,aAAa,IAAI,sBAAsB;IAUvC;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,mBAAmB,GAAG,SAAS;IAKtE;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAErC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAiDnD;;;;;;;;;OASG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAe/C;;;;;;;;;;;OAWG;IACF,WAAW,IAAI,SAAS,CAAC,YAAY,CAAC;IAWvC;;;;;;;;;OASG;IACH,UAAU,IAAI,iBAAiB;IAK/B;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAchD;;;OAGG;IACH,cAAc,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI;IAQ9C;;;;OAIG;IACH,WAAW,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO;CAG/C"}
|
|
@@ -74,6 +74,12 @@ let DomainAssociation = (() => {
|
|
|
74
74
|
let _semantics_decorators;
|
|
75
75
|
let _semantics_initializers = [];
|
|
76
76
|
let _semantics_extraInitializers = [];
|
|
77
|
+
let _onDelete_decorators;
|
|
78
|
+
let _onDelete_initializers = [];
|
|
79
|
+
let _onDelete_extraInitializers = [];
|
|
80
|
+
let _readOnly_decorators;
|
|
81
|
+
let _readOnly_initializers = [];
|
|
82
|
+
let _readOnly_extraInitializers = [];
|
|
77
83
|
return class DomainAssociation extends _classSuper {
|
|
78
84
|
static {
|
|
79
85
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
@@ -84,6 +90,8 @@ let DomainAssociation = (() => {
|
|
|
84
90
|
_bindings_decorators = [observed({ deep: true })];
|
|
85
91
|
_targets_decorators = [observed({ deep: true })];
|
|
86
92
|
_semantics_decorators = [observed({ deep: true })];
|
|
93
|
+
_onDelete_decorators = [observed()];
|
|
94
|
+
_readOnly_decorators = [observed()];
|
|
87
95
|
__esDecorate(this, null, _info_decorators, { kind: "accessor", name: "info", static: false, private: false, access: { has: obj => "info" in obj, get: obj => obj.info, set: (obj, value) => { obj.info = value; } }, metadata: _metadata }, _info_initializers, _info_extraInitializers);
|
|
88
96
|
__esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
|
|
89
97
|
__esDecorate(this, null, _multiple_decorators, { kind: "accessor", name: "multiple", static: false, private: false, access: { has: obj => "multiple" in obj, get: obj => obj.multiple, set: (obj, value) => { obj.multiple = value; } }, metadata: _metadata }, _multiple_initializers, _multiple_extraInitializers);
|
|
@@ -91,6 +99,8 @@ let DomainAssociation = (() => {
|
|
|
91
99
|
__esDecorate(this, null, _bindings_decorators, { kind: "accessor", name: "bindings", static: false, private: false, access: { has: obj => "bindings" in obj, get: obj => obj.bindings, set: (obj, value) => { obj.bindings = value; } }, metadata: _metadata }, _bindings_initializers, _bindings_extraInitializers);
|
|
92
100
|
__esDecorate(this, null, _targets_decorators, { kind: "accessor", name: "targets", static: false, private: false, access: { has: obj => "targets" in obj, get: obj => obj.targets, set: (obj, value) => { obj.targets = value; } }, metadata: _metadata }, _targets_initializers, _targets_extraInitializers);
|
|
93
101
|
__esDecorate(this, null, _semantics_decorators, { kind: "accessor", name: "semantics", static: false, private: false, access: { has: obj => "semantics" in obj, get: obj => obj.semantics, set: (obj, value) => { obj.semantics = value; } }, metadata: _metadata }, _semantics_initializers, _semantics_extraInitializers);
|
|
102
|
+
__esDecorate(this, null, _onDelete_decorators, { kind: "accessor", name: "onDelete", static: false, private: false, access: { has: obj => "onDelete" in obj, get: obj => obj.onDelete, set: (obj, value) => { obj.onDelete = value; } }, metadata: _metadata }, _onDelete_initializers, _onDelete_extraInitializers);
|
|
103
|
+
__esDecorate(this, null, _readOnly_decorators, { kind: "accessor", name: "readOnly", static: false, private: false, access: { has: obj => "readOnly" in obj, get: obj => obj.readOnly, set: (obj, value) => { obj.readOnly = value; } }, metadata: _metadata }, _readOnly_initializers, _readOnly_extraInitializers);
|
|
94
104
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
95
105
|
}
|
|
96
106
|
/**
|
|
@@ -146,10 +156,7 @@ let DomainAssociation = (() => {
|
|
|
146
156
|
set targets(value) { this.#targets_accessor_storage = value; }
|
|
147
157
|
#semantics_accessor_storage = (__runInitializers(this, _targets_extraInitializers), __runInitializers(this, _semantics_initializers, []
|
|
148
158
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @param input The partial data association schema.
|
|
152
|
-
* @returns The data association schema.
|
|
159
|
+
* Defines the behavior when a parent entity in an association is deleted.
|
|
153
160
|
*/
|
|
154
161
|
));
|
|
155
162
|
/**
|
|
@@ -157,6 +164,18 @@ let DomainAssociation = (() => {
|
|
|
157
164
|
*/
|
|
158
165
|
get semantics() { return this.#semantics_accessor_storage; }
|
|
159
166
|
set semantics(value) { this.#semantics_accessor_storage = value; }
|
|
167
|
+
#onDelete_accessor_storage = (__runInitializers(this, _semantics_extraInitializers), __runInitializers(this, _onDelete_initializers, void 0));
|
|
168
|
+
/**
|
|
169
|
+
* Defines the behavior when a parent entity in an association is deleted.
|
|
170
|
+
*/
|
|
171
|
+
get onDelete() { return this.#onDelete_accessor_storage; }
|
|
172
|
+
set onDelete(value) { this.#onDelete_accessor_storage = value; }
|
|
173
|
+
#readOnly_accessor_storage = (__runInitializers(this, _onDelete_extraInitializers), __runInitializers(this, _readOnly_initializers, void 0));
|
|
174
|
+
/**
|
|
175
|
+
* Whether the association is read-only.
|
|
176
|
+
*/
|
|
177
|
+
get readOnly() { return this.#readOnly_accessor_storage; }
|
|
178
|
+
set readOnly(value) { this.#readOnly_accessor_storage = value; }
|
|
160
179
|
/**
|
|
161
180
|
* Creates a full data association schema with defaults.
|
|
162
181
|
*
|
|
@@ -174,6 +193,12 @@ let DomainAssociation = (() => {
|
|
|
174
193
|
if (Array.isArray(semantics)) {
|
|
175
194
|
result.semantics = [...semantics];
|
|
176
195
|
}
|
|
196
|
+
if (input.onDelete) {
|
|
197
|
+
result.onDelete = input.onDelete;
|
|
198
|
+
}
|
|
199
|
+
if (typeof input.readOnly === 'boolean') {
|
|
200
|
+
result.readOnly = input.readOnly;
|
|
201
|
+
}
|
|
177
202
|
if (input.schema) {
|
|
178
203
|
result.schema = structuredClone(input.schema);
|
|
179
204
|
}
|
|
@@ -203,7 +228,7 @@ let DomainAssociation = (() => {
|
|
|
203
228
|
constructor(root, parent, input) {
|
|
204
229
|
const init = DomainAssociation.createSchema(input);
|
|
205
230
|
super(root, init.key);
|
|
206
|
-
__runInitializers(this,
|
|
231
|
+
__runInitializers(this, _readOnly_extraInitializers);
|
|
207
232
|
this.parent = parent;
|
|
208
233
|
this.kind = DomainAssociationKind;
|
|
209
234
|
this.info = new Thing(init.info);
|
|
@@ -234,6 +259,12 @@ let DomainAssociation = (() => {
|
|
|
234
259
|
else {
|
|
235
260
|
this.semantics = [];
|
|
236
261
|
}
|
|
262
|
+
if (init.onDelete) {
|
|
263
|
+
this.onDelete = init.onDelete;
|
|
264
|
+
}
|
|
265
|
+
if (typeof init.readOnly === 'boolean') {
|
|
266
|
+
this.readOnly = init.readOnly;
|
|
267
|
+
}
|
|
237
268
|
}
|
|
238
269
|
/**
|
|
239
270
|
* Generates a JSON representation of the association.
|
|
@@ -264,6 +295,12 @@ let DomainAssociation = (() => {
|
|
|
264
295
|
if (Array.isArray(this.semantics) && this.semantics.length) {
|
|
265
296
|
result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i));
|
|
266
297
|
}
|
|
298
|
+
if (this.onDelete) {
|
|
299
|
+
result.onDelete = this.onDelete;
|
|
300
|
+
}
|
|
301
|
+
if (typeof this.readOnly === 'boolean' && this.readOnly) {
|
|
302
|
+
result.readOnly = this.readOnly;
|
|
303
|
+
}
|
|
267
304
|
return result;
|
|
268
305
|
}
|
|
269
306
|
/**
|