@api-client/core 0.14.9 → 0.14.10

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.
@@ -211,6 +211,20 @@ export declare class DataDomain extends DependentModel {
211
211
  * ```
212
212
  */
213
213
  listNamespaces(): Generator<DomainNamespace>;
214
+ /**
215
+ * Lists all namespaces in the graph that are part of specified domain.
216
+ *
217
+ * @param namespace The foreign namespace to search in. When not found, it throws an error.
218
+ * @returns A generator that yields each `DomainNamespace`.
219
+ * @throws Error When the foreign domain is not found.
220
+ * @example
221
+ * ```typescript
222
+ * for (const ns of dataDomain.listForeignNamespaces('foreignDomainKey')) {
223
+ * console.log(ns.key);
224
+ * }
225
+ * ```
226
+ */
227
+ listForeignNamespaces(namespace: string): Generator<DomainNamespace>;
214
228
  /**
215
229
  * Checks if this data domain has any namespaces.
216
230
  *
@@ -332,12 +346,26 @@ export declare class DataDomain extends DependentModel {
332
346
  * @returns A generator that yields each `DomainModel`.
333
347
  * @example
334
348
  * ```typescript
335
- * for (const ns of namespace.listModels()) {
336
- * console.log(ns.key);
349
+ * for (const model of namespace.listModels()) {
350
+ * console.log(model.key);
337
351
  * }
338
352
  * ```
339
353
  */
340
354
  listModels(): Generator<DomainModel>;
355
+ /**
356
+ * Lists all models in the graph that are part of specified domain.
357
+ *
358
+ * @param namespace The foreign namespace to search in. When not found, it throws an error.
359
+ * @returns A generator that yields each `DomainModel`.
360
+ * @throws Error When the foreign domain is not found.
361
+ * @example
362
+ * ```typescript
363
+ * for (const model of dataDomain.listForeignModels('foreignDomainKey')) {
364
+ * console.log(model.key);
365
+ * }
366
+ * ```
367
+ */
368
+ listForeignModels(namespace: string): Generator<DomainModel>;
341
369
  /**
342
370
  * Checks if this data domain has any direct models.
343
371
  *
@@ -437,10 +465,24 @@ export declare class DataDomain extends DependentModel {
437
465
  * ```
438
466
  */
439
467
  listEntities(parent?: string): Generator<DomainEntity>;
468
+ /**
469
+ * Lists all entities in the graph that are part of specified domain.
470
+ *
471
+ * @param namespace The foreign namespace to search in. When not found, it throws an error.
472
+ * @returns A generator that yields each `DomainEntity`.
473
+ * @throws Error When the foreign domain is not found.
474
+ * @example
475
+ * ```typescript
476
+ * for (const model of dataDomain.listForeignEntities('foreignDomainKey')) {
477
+ * console.log(model.key);
478
+ * }
479
+ * ```
480
+ */
481
+ listForeignEntities(namespace: string): Generator<DomainEntity>;
440
482
  /**
441
483
  * Lists all entities in the graph that are not part of this domain.
442
484
  */
443
- listForeignEntities(): Generator<DomainEntity>;
485
+ listAllForeignEntities(): Generator<DomainEntity>;
444
486
  /**
445
487
  * Finds an entity by its key.
446
488
  *
@@ -1 +1 @@
1
- {"version":3,"file":"DataDomain.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataDomain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AACxD,OAAO,EAEL,cAAc,EAKf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC9G,OAAO,EAAE,KAAK,qBAAqB,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC7G,OAAO,EAAE,KAAK,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,KAAK,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAGvD,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtG,MAAM,WAAW,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AAS,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAQ/E;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,cAAc;IAiBrF;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAmBjC;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAQzE;;;;;;;;;;;;;;OAcG;IACH,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAmB/C;;;;OAIG;IACH,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAY1C;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAajF;;;;;;;;;;;OAWG;IACH,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAqBrD"}
@@ -358,6 +358,32 @@ export class DataDomain extends DependentModel {
358
358
  yield node;
359
359
  }
360
360
  }
361
+ /**
362
+ * Lists all namespaces in the graph that are part of specified domain.
363
+ *
364
+ * @param namespace The foreign namespace to search in. When not found, it throws an error.
365
+ * @returns A generator that yields each `DomainNamespace`.
366
+ * @throws Error When the foreign domain is not found.
367
+ * @example
368
+ * ```typescript
369
+ * for (const ns of dataDomain.listForeignNamespaces('foreignDomainKey')) {
370
+ * console.log(ns.key);
371
+ * }
372
+ * ```
373
+ */
374
+ *listForeignNamespaces(namespace) {
375
+ const foreignDomain = this.dependencies.get(namespace);
376
+ if (!foreignDomain) {
377
+ throw new Error(`Foreign domain ${namespace} not found`);
378
+ }
379
+ for (const node of foreignDomain.listNamespaces()) {
380
+ const key = `${namespace}:${node.key}`;
381
+ const value = this.graph.node(key);
382
+ if (value) {
383
+ yield node;
384
+ }
385
+ }
386
+ }
361
387
  /**
362
388
  * Checks if this data domain has any namespaces.
363
389
  *
@@ -615,8 +641,8 @@ export class DataDomain extends DependentModel {
615
641
  * @returns A generator that yields each `DomainModel`.
616
642
  * @example
617
643
  * ```typescript
618
- * for (const ns of namespace.listModels()) {
619
- * console.log(ns.key);
644
+ * for (const model of namespace.listModels()) {
645
+ * console.log(model.key);
620
646
  * }
621
647
  * ```
622
648
  */
@@ -632,6 +658,32 @@ export class DataDomain extends DependentModel {
632
658
  yield node;
633
659
  }
634
660
  }
661
+ /**
662
+ * Lists all models in the graph that are part of specified domain.
663
+ *
664
+ * @param namespace The foreign namespace to search in. When not found, it throws an error.
665
+ * @returns A generator that yields each `DomainModel`.
666
+ * @throws Error When the foreign domain is not found.
667
+ * @example
668
+ * ```typescript
669
+ * for (const model of dataDomain.listForeignModels('foreignDomainKey')) {
670
+ * console.log(model.key);
671
+ * }
672
+ * ```
673
+ */
674
+ *listForeignModels(namespace) {
675
+ const foreignDomain = this.dependencies.get(namespace);
676
+ if (!foreignDomain) {
677
+ throw new Error(`Foreign domain ${namespace} not found`);
678
+ }
679
+ for (const node of foreignDomain.listModels()) {
680
+ const key = `${namespace}:${node.key}`;
681
+ const value = this.graph.node(key);
682
+ if (value) {
683
+ yield node;
684
+ }
685
+ }
686
+ }
635
687
  /**
636
688
  * Checks if this data domain has any direct models.
637
689
  *
@@ -835,10 +887,36 @@ export class DataDomain extends DependentModel {
835
887
  }
836
888
  }
837
889
  }
890
+ /**
891
+ * Lists all entities in the graph that are part of specified domain.
892
+ *
893
+ * @param namespace The foreign namespace to search in. When not found, it throws an error.
894
+ * @returns A generator that yields each `DomainEntity`.
895
+ * @throws Error When the foreign domain is not found.
896
+ * @example
897
+ * ```typescript
898
+ * for (const model of dataDomain.listForeignEntities('foreignDomainKey')) {
899
+ * console.log(model.key);
900
+ * }
901
+ * ```
902
+ */
903
+ *listForeignEntities(namespace) {
904
+ const foreignDomain = this.dependencies.get(namespace);
905
+ if (!foreignDomain) {
906
+ throw new Error(`Foreign domain ${namespace} not found`);
907
+ }
908
+ for (const node of foreignDomain.listEntities()) {
909
+ const key = `${namespace}:${node.key}`;
910
+ const value = this.graph.node(key);
911
+ if (value) {
912
+ yield node;
913
+ }
914
+ }
915
+ }
838
916
  /**
839
917
  * Lists all entities in the graph that are not part of this domain.
840
918
  */
841
- *listForeignEntities() {
919
+ *listAllForeignEntities() {
842
920
  for (const node of this.graph.nodes()) {
843
921
  const value = this.graph.node(node);
844
922
  if (value.kind === DomainEntityKind && value.domain.key !== this.key) {
@@ -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;AAE3B,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;AACjG,OAAO,EAAE,cAAc,EAAoD,MAAM,qBAAqB,CAAA;AAetG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,OAAO,UAAW,SAAQ,cAAc;IAC5C;;OAEG;IACH,IAAI,CAAuB;IAC3B;;OAEG;IACH,GAAG,CAAQ;IAEX;;OAEG;IACH,KAAK,CA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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 { AssociationAddOptions, DomainGraphEdge, DomainGraphNodeType, SerializedGraph } 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'\nimport { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'\n\nexport interface DataDomainSchema extends DependentModelSchema {\n info: IThing\n kind: typeof DataDomainKind\n key: string\n graph?: SerializedGraph\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 DependentModel {\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 * 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: DomainDependency[] = []) {\n const init = DataDomain.createSchema(state)\n const instances: DataDomain[] = []\n for (const dep of dependencies) {\n if (dep instanceof DataDomain) {\n instances.push(dep)\n } else if (typeof dep === 'object' && dep.kind === DataDomainKind && dep.key) {\n const domain = new DataDomain(dep)\n instances.push(domain)\n } else {\n throw new Error(`Invalid foreign domain dependency: ${dep}`)\n }\n }\n super(init.dependencyList, instances)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.graph = deserialize(this, init.graph, instances)\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 * Builds a reference key for a domain object.\n *\n * If the namespace is provided and it is different from the domain key,\n * it will return the key in the format `namespace:key`. The foreign namespace\n * must be registered in the domain's dependencies otherwise an error will be thrown.\n *\n * @param key The key of the namespace or model.\n * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign namespace.\n * @returns The reference key in the format `namespace:key` or just `key` if no namespace is provided.\n * @throws Error When the foreign domain is not found.\n * @example\n * ```typescript\n * const refKey = dataDomain.buildReferenceKey('userModel', 'domainKey');\n * ```\n */\n buildReferenceKey(key: string, namespace?: string): string {\n if (namespace && namespace !== this.key) {\n if (typeof namespace !== 'string' || namespace.length === 0) {\n throw new Error(`Invalid namespace key. Expected a string, got ${typeof namespace}`)\n }\n const foreignDomain = this.dependencies.get(namespace)\n if (!foreignDomain) {\n throw new Error(`Foreign domain ${namespace} not found`)\n }\n return `${namespace}:${key}`\n }\n return key\n }\n\n /**\n * Finds a namespace by its key.\n *\n * @param key The key of the namespace to find.\n * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign namespace.\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, namespace?: string): DomainNamespace | undefined {\n const result = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign entity.\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, namespace?: string): DomainModel | undefined {\n const value = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign entity.\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, namespace?: string): DomainEntity | undefined {\n const node = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign association\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, namespace?: string): DomainAssociation | undefined {\n const node = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign property\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, namespace?: string): DomainProperty | undefined {\n const node = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @deprecated Use `findEntity` with the `namespace` parameter instead.\n * This method is kept for backward compatibility but will be removed in the future.\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":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EACL,qBA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B,EAAE,SAAiB;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 { AssociationAddOptions, DomainGraphEdge, DomainGraphNodeType, SerializedGraph } 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'\nimport { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'\n\nexport interface DataDomainSchema extends DependentModelSchema {\n info: IThing\n kind: typeof DataDomainKind\n key: string\n graph?: SerializedGraph\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 DependentModel {\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 * 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: DomainDependency[] = []) {\n const init = DataDomain.createSchema(state)\n const instances: DataDomain[] = []\n for (const dep of dependencies) {\n if (dep instanceof DataDomain) {\n instances.push(dep)\n } else if (typeof dep === 'object' && dep.kind === DataDomainKind && dep.key) {\n const domain = new DataDomain(dep)\n instances.push(domain)\n } else {\n throw new Error(`Invalid foreign domain dependency: ${dep}`)\n }\n }\n super(init.dependencyList, instances)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.graph = deserialize(this, init.graph, instances)\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 * Lists all namespaces in the graph that are part of specified domain.\n *\n * @param namespace The foreign namespace to search in. When not found, it throws an error.\n * @returns A generator that yields each `DomainNamespace`.\n * @throws Error When the foreign domain is not found.\n * @example\n * ```typescript\n * for (const ns of dataDomain.listForeignNamespaces('foreignDomainKey')) {\n * console.log(ns.key);\n * }\n * ```\n */\n *listForeignNamespaces(namespace: string): Generator<DomainNamespace> {\n const foreignDomain = this.dependencies.get(namespace)\n if (!foreignDomain) {\n throw new Error(`Foreign domain ${namespace} not found`)\n }\n for (const node of foreignDomain.listNamespaces()) {\n const key = `${namespace}:${node.key}`\n const value = this.graph.node(key)\n if (value) {\n yield node\n }\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 * Builds a reference key for a domain object.\n *\n * If the namespace is provided and it is different from the domain key,\n * it will return the key in the format `namespace:key`. The foreign namespace\n * must be registered in the domain's dependencies otherwise an error will be thrown.\n *\n * @param key The key of the namespace or model.\n * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign namespace.\n * @returns The reference key in the format `namespace:key` or just `key` if no namespace is provided.\n * @throws Error When the foreign domain is not found.\n * @example\n * ```typescript\n * const refKey = dataDomain.buildReferenceKey('userModel', 'domainKey');\n * ```\n */\n buildReferenceKey(key: string, namespace?: string): string {\n if (namespace && namespace !== this.key) {\n if (typeof namespace !== 'string' || namespace.length === 0) {\n throw new Error(`Invalid namespace key. Expected a string, got ${typeof namespace}`)\n }\n const foreignDomain = this.dependencies.get(namespace)\n if (!foreignDomain) {\n throw new Error(`Foreign domain ${namespace} not found`)\n }\n return `${namespace}:${key}`\n }\n return key\n }\n\n /**\n * Finds a namespace by its key.\n *\n * @param key The key of the namespace to find.\n * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign namespace.\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, namespace?: string): DomainNamespace | undefined {\n const result = this.graph.node(this.buildReferenceKey(key, namespace)) 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 model of namespace.listModels()) {\n * console.log(model.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 * Lists all models in the graph that are part of specified domain.\n *\n * @param namespace The foreign namespace to search in. When not found, it throws an error.\n * @returns A generator that yields each `DomainModel`.\n * @throws Error When the foreign domain is not found.\n * @example\n * ```typescript\n * for (const model of dataDomain.listForeignModels('foreignDomainKey')) {\n * console.log(model.key);\n * }\n * ```\n */\n *listForeignModels(namespace: string): Generator<DomainModel> {\n const foreignDomain = this.dependencies.get(namespace)\n if (!foreignDomain) {\n throw new Error(`Foreign domain ${namespace} not found`)\n }\n for (const node of foreignDomain.listModels()) {\n const key = `${namespace}:${node.key}`\n const value = this.graph.node(key)\n if (value) {\n yield node\n }\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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign entity.\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, namespace?: string): DomainModel | undefined {\n const value = this.graph.node(this.buildReferenceKey(key, namespace)) 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 part of specified domain.\n *\n * @param namespace The foreign namespace to search in. When not found, it throws an error.\n * @returns A generator that yields each `DomainEntity`.\n * @throws Error When the foreign domain is not found.\n * @example\n * ```typescript\n * for (const model of dataDomain.listForeignEntities('foreignDomainKey')) {\n * console.log(model.key);\n * }\n * ```\n */\n *listForeignEntities(namespace: string): Generator<DomainEntity> {\n const foreignDomain = this.dependencies.get(namespace)\n if (!foreignDomain) {\n throw new Error(`Foreign domain ${namespace} not found`)\n }\n for (const node of foreignDomain.listEntities()) {\n const key = `${namespace}:${node.key}`\n const value = this.graph.node(key)\n if (value) {\n yield node\n }\n }\n }\n\n /**\n * Lists all entities in the graph that are not part of this domain.\n */\n *listAllForeignEntities(): 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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign entity.\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, namespace?: string): DomainEntity | undefined {\n const node = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign association\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, namespace?: string): DomainAssociation | undefined {\n const node = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @param namespace The namespace to search in. When different from the domain key, it looks for a foreign property\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, namespace?: string): DomainProperty | undefined {\n const node = this.graph.node(this.buildReferenceKey(key, namespace)) 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 * @deprecated Use `findEntity` with the `namespace` parameter instead.\n * This method is kept for backward compatibility but will be removed in the future.\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"]}
@@ -24,6 +24,13 @@ export declare abstract class DomainElement implements DomainElementSchema {
24
24
  * The unique key of the domain element.
25
25
  */
26
26
  get key(): string;
27
+ /**
28
+ * The key of the DataDomain this element belongs to.
29
+ * In a data domain that has foreign namespaces, this is the key of the namespace this element originally belongs to.
30
+ *
31
+ * It might be different from the `domain.key` if the element is a foreign object.
32
+ */
33
+ get namespace(): string;
27
34
  /**
28
35
  * @param root The root DataDomain instance.
29
36
  * @param key The unique key of the domain element.
@@ -1 +1 @@
1
- {"version":3,"file":"DomainElement.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,8BAAsB,aAAc,YAAW,mBAAmB;;IAChE;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,UAAU,CAAA;IAE1B;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAQ9B;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;;OAGG;gBACS,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM;CAI1C"}
1
+ {"version":3,"file":"DomainElement.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,8BAAsB,aAAc,YAAW,mBAAmB;;IAChE;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,UAAU,CAAA;IAE1B;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAQ9B;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAID;;;;;OAKG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;OAGG;gBACS,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM;CAQ1C"}
@@ -20,6 +20,16 @@ export class DomainElement {
20
20
  get key() {
21
21
  return this.#key;
22
22
  }
23
+ #namespace;
24
+ /**
25
+ * The key of the DataDomain this element belongs to.
26
+ * In a data domain that has foreign namespaces, this is the key of the namespace this element originally belongs to.
27
+ *
28
+ * It might be different from the `domain.key` if the element is a foreign object.
29
+ */
30
+ get namespace() {
31
+ return this.#namespace;
32
+ }
23
33
  /**
24
34
  * @param root The root DataDomain instance.
25
35
  * @param key The unique key of the domain element.
@@ -27,6 +37,10 @@ export class DomainElement {
27
37
  constructor(root, key) {
28
38
  this.root = root;
29
39
  this.#key = key;
40
+ // When dependencies are loaded, they all first belong to the root domain.
41
+ // When the foreign domain is merged, the object is transferred to the other domain,
42
+ // but the namespace is still the root domain key.
43
+ this.#namespace = root.key;
30
44
  }
31
45
  }
32
46
  //# sourceMappingURL=DomainElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomainElement.js","sourceRoot":"","sources":["../../../src/modeling/DomainElement.ts"],"names":[],"mappings":"AAaA,MAAM,OAAgB,aAAa;IACjC;;OAEG;IACO,IAAI,CAAY;IAE1B;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAID;;;OAGG;IACH,IAAI,CAAQ;IAEZ;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,YAAY,IAAgB,EAAE,GAAW;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;IACjB,CAAC;CACF","sourcesContent":["import type { DataDomain } from './DataDomain.js'\n\nexport interface DomainElementSchema {\n /**\n * The kind of the domain element.\n */\n kind: string\n /**\n * The unique key of the domain element.\n */\n key: string\n}\n\nexport abstract class DomainElement implements DomainElementSchema {\n /**\n * A reference to the root DataDomain instance.\n */\n protected root: DataDomain\n\n /**\n * The root DataDomain instance.\n */\n get domain(): DataDomain {\n return this.root\n }\n\n abstract accessor kind: string\n\n /**\n * The unique key of the domain element.\n * Since keys are immutable, we use a private field to store the key.\n */\n #key: string\n\n /**\n * The unique key of the domain element.\n */\n get key(): string {\n return this.#key\n }\n\n /**\n * @param root The root DataDomain instance.\n * @param key The unique key of the domain element.\n */\n constructor(root: DataDomain, key: string) {\n this.root = root\n this.#key = key\n }\n}\n"]}
1
+ {"version":3,"file":"DomainElement.js","sourceRoot":"","sources":["../../../src/modeling/DomainElement.ts"],"names":[],"mappings":"AAaA,MAAM,OAAgB,aAAa;IACjC;;OAEG;IACO,IAAI,CAAY;IAE1B;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAID;;;OAGG;IACH,IAAI,CAAQ;IAEZ;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,UAAU,CAAQ;IAElB;;;;;OAKG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED;;;OAGG;IACH,YAAY,IAAgB,EAAE,GAAW;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACf,0EAA0E;QAC1E,oFAAoF;QACpF,kDAAkD;QAClD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { DataDomain } from './DataDomain.js'\n\nexport interface DomainElementSchema {\n /**\n * The kind of the domain element.\n */\n kind: string\n /**\n * The unique key of the domain element.\n */\n key: string\n}\n\nexport abstract class DomainElement implements DomainElementSchema {\n /**\n * A reference to the root DataDomain instance.\n */\n protected root: DataDomain\n\n /**\n * The root DataDomain instance.\n */\n get domain(): DataDomain {\n return this.root\n }\n\n abstract accessor kind: string\n\n /**\n * The unique key of the domain element.\n * Since keys are immutable, we use a private field to store the key.\n */\n #key: string\n\n /**\n * The unique key of the domain element.\n */\n get key(): string {\n return this.#key\n }\n\n #namespace: string\n\n /**\n * The key of the DataDomain this element belongs to.\n * In a data domain that has foreign namespaces, this is the key of the namespace this element originally belongs to.\n *\n * It might be different from the `domain.key` if the element is a foreign object.\n */\n get namespace(): string {\n return this.#namespace\n }\n\n /**\n * @param root The root DataDomain instance.\n * @param key The unique key of the domain element.\n */\n constructor(root: DataDomain, key: string) {\n this.root = root\n this.#key = key\n // When dependencies are loaded, they all first belong to the root domain.\n // When the foreign domain is merged, the object is transferred to the other domain,\n // but the namespace is still the root domain key.\n this.#namespace = root.key\n }\n}\n"]}
@@ -219,7 +219,7 @@ export class EntityValidation {
219
219
  });
220
220
  }
221
221
  }
222
- for (const other of this.domain.listForeignEntities()) {
222
+ for (const other of this.domain.listAllForeignEntities()) {
223
223
  if (other.info.name?.toLowerCase() === name && other.key !== entity.key) {
224
224
  const message = `The "${name}" entity name is already used in the foreign data domain.`;
225
225
  const help = `The name must be unique. This includes references to other data domains.`;