@api-client/core 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Local.session.sql +0 -0
- package/build/src/modeling/DataModel.d.ts +10 -1
- package/build/src/modeling/DataModel.d.ts.map +1 -1
- package/build/src/modeling/DataModel.js +39 -0
- package/build/src/modeling/DataModel.js.map +1 -1
- package/build/src/modeling/DataNamespace.d.ts +14 -0
- package/build/src/modeling/DataNamespace.d.ts.map +1 -1
- package/build/src/modeling/DataNamespace.js +49 -0
- package/build/src/modeling/DataNamespace.js.map +1 -1
- package/data/models/example-generator-api.json +24 -24
- package/data/models/multiple-servers.json +16 -0
- package/data/models/petstore.json +92 -7
- package/package.json +1 -1
- package/src/modeling/DataModel.ts +40 -1
- package/src/modeling/DataNamespace.ts +56 -0
- package/tests/unit/modeling/data_model.spec.ts +54 -0
- package/tests/unit/modeling/data_namespace.spec.ts +138 -1
- package/build/oauth-popup.html +0 -33
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IThing, Thing } from '../models/Thing.js';
|
|
2
2
|
import { DataEntity, IDataEntity } from './DataEntity.js';
|
|
3
|
-
import { DataNamespace } from './DataNamespace.js';
|
|
3
|
+
import type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js';
|
|
4
4
|
import { FileBreadcrumb } from '../models/store/File.js';
|
|
5
5
|
import { DataModelKind } from '../models/kinds.js';
|
|
6
6
|
/**
|
|
@@ -56,6 +56,15 @@ export declare class DataModel {
|
|
|
56
56
|
* Removes self from the namespace with all entities.
|
|
57
57
|
*/
|
|
58
58
|
remove(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Adapts an entity to this data model.
|
|
61
|
+
* The entity must already be added to another data model within this namespace for it to be
|
|
62
|
+
* adapted to this data model.
|
|
63
|
+
* This method is used to change the data model of an entity.
|
|
64
|
+
* It will remove the entity from the previous data model and add it to this one.
|
|
65
|
+
* @param entity The entity to adapt.
|
|
66
|
+
*/
|
|
67
|
+
adaptEntity(entity: DataEntity, opts?: DataItemAdaptingOptions): void;
|
|
59
68
|
/**
|
|
60
69
|
* Adds an entity to this data model.
|
|
61
70
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"DataModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,aAAa,CAAA;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IA0BX,IAAI,EAAE,aAAa;IAzB5B,IAAI,SAAgB;IAEpB,GAAG,SAAK;IAER;;OAEG;IACH,IAAI,EAAE,KAAK,CAAqB;IAEhC;;OAEG;IACH,QAAQ,EAAE,UAAU,EAAE,CAAK;IAE3B,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;IAM7D;;;OAGG;gBAEM,IAAI,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU;IAkB7B,GAAG,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAwB3B,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQ3C,MAAM,IAAI,UAAU;IAYpB,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI1D;;OAEG;IACH,MAAM,IAAI,IAAI;IAoBd;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,GAAE,uBAA4B,GAAG,IAAI;IA+BzE;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU;IAc9D;;OAEG;IACH,SAAS,IAAI,aAAa,GAAG,SAAS;IAOtC;;OAEG;IACH,WAAW,IAAI,cAAc,EAAE;CAuBhC"}
|
|
@@ -113,6 +113,45 @@ export class DataModel {
|
|
|
113
113
|
root.definitions.models.splice(index, 1);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Adapts an entity to this data model.
|
|
118
|
+
* The entity must already be added to another data model within this namespace for it to be
|
|
119
|
+
* adapted to this data model.
|
|
120
|
+
* This method is used to change the data model of an entity.
|
|
121
|
+
* It will remove the entity from the previous data model and add it to this one.
|
|
122
|
+
* @param entity The entity to adapt.
|
|
123
|
+
*/
|
|
124
|
+
adaptEntity(entity, opts = {}) {
|
|
125
|
+
if (opts.index !== undefined) {
|
|
126
|
+
if (opts.index < 0) {
|
|
127
|
+
throw new Error(`The index ${opts.index} cannot be below 0.`);
|
|
128
|
+
}
|
|
129
|
+
if (opts.index >= this.entities.length) {
|
|
130
|
+
throw new Error(`The index ${opts.index} is not valid.`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (entity.root !== this.root) {
|
|
134
|
+
throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`);
|
|
135
|
+
}
|
|
136
|
+
if (entity.getParent() === this) {
|
|
137
|
+
throw new Error(`The entity ${entity.key} is already adapted by this data model.`);
|
|
138
|
+
}
|
|
139
|
+
const parent = entity.getParent();
|
|
140
|
+
if (!parent) {
|
|
141
|
+
throw new Error(`The entity ${entity.key} has no parent.`);
|
|
142
|
+
}
|
|
143
|
+
const index = parent.entities.findIndex((i) => i.key === entity.key);
|
|
144
|
+
if (index < 0) {
|
|
145
|
+
throw new Error(`The entity ${entity.key} is not in the parent data model.`);
|
|
146
|
+
}
|
|
147
|
+
parent.entities.splice(index, 1);
|
|
148
|
+
if (opts.index !== undefined) {
|
|
149
|
+
this.entities.splice(opts.index, 0, entity);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.entities.push(entity);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
116
155
|
/**
|
|
117
156
|
* Adds an entity to this data model.
|
|
118
157
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../../src/modeling/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAA;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAwBlD;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IA0BX;IAzBT,IAAI,GAAG,aAAa,CAAA;IAEpB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,GAAiB,EAAE,CAAA;IAE3B,MAAM,CAAC,QAAQ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,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;aAC9C,CAAC,CAAA;YACF,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;QAC7B,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;YAChD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;SACrB,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataModelKind } from '../models/kinds.js'\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport interface IDataModel {\n kind: typeof DataModelKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The list of keys of entities that this data model contain.\n */\n entities?: string[]\n}\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport class DataModel {\n kind = DataModelKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * The list of entities that this data model has.\n */\n entities: DataEntity[] = []\n\n static fromName(root: DataNamespace, name: string): DataModel {\n const entity = new DataModel(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param root the root namespace.\n * @param input The data model definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataModel\n ) {\n let init: IDataModel\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataModelKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n entities: [],\n }\n }\n this.new(init)\n }\n\n new(init: IDataModel): void {\n if (!DataModel.isDataModel(init)) {\n throw new Error(`Not a data model.`)\n }\n const { info, key = v4(), kind = DataModelKind, entities } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n\n this.entities = []\n if (Array.isArray(entities)) {\n entities.forEach((key) => {\n const value = this._readEntity(key)\n if (value) {\n this.entities.push(value)\n }\n })\n }\n }\n\n static isDataModel(input: unknown): boolean {\n const typed = input as IDataModel\n if (!input || typed.kind !== DataModelKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataModel {\n const result: IDataModel = {\n kind: DataModelKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.entities) && this.entities.length) {\n result.entities = this.entities.map((i) => i.key)\n }\n return result\n }\n\n protected _readEntity(key: string): DataEntity | undefined {\n return this.root.definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Removes self from the namespace with all entities.\n */\n remove(): void {\n const { key, entities, root } = this\n // remove children\n entities.forEach((e) => e.remove())\n\n // remove self from the parent\n const parent = this.getParent()\n if (parent) {\n const itemIndex = parent.items.findIndex((i) => i.key === key)\n if (itemIndex >= 0) {\n parent.items.splice(itemIndex, 1)\n }\n }\n // remove self from definitions\n const index = root.definitions.models.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.models.splice(index, 1)\n }\n }\n\n /**\n * Adds an entity to this data model.\n *\n * @param init The name of the entity to create, the instance of the entity or its schema\n * @returns A reference to the created entity.\n */\n addEntity(init: string | DataEntity | IDataEntity): DataEntity {\n let definition: DataEntity\n if (typeof init === 'string') {\n definition = DataEntity.fromName(this.root, init)\n } else if (init instanceof DataEntity) {\n definition = init\n } else {\n definition = new DataEntity(this.root, init)\n }\n this.root.definitions.entities.push(definition)\n this.entities.push(definition)\n return definition\n }\n\n /**\n * Returns the parent namespace where this data model exist.\n */\n getParent(): DataNamespace | undefined {\n if (this.root.items.some((e) => e.key === this.key)) {\n return this.root\n }\n return this.root.definitions.namespaces.find((n) => n.items.some((e) => e.key === this.key))\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.name || 'Unnamed data model',\n kind: DataModelKind,\n })\n let parent = this.getParent()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParent()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.name || 'Unnamed namespace',\n kind: this.root.kind,\n })\n return result.reverse()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../../src/modeling/DataModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAA;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAwBlD;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IA0BX;IAzBT,IAAI,GAAG,aAAa,CAAA;IAEpB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,GAAiB,EAAE,CAAA;IAE3B,MAAM,CAAC,QAAQ,CAAC,IAAmB,EAAE,IAAY;QAC/C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,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I,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;aAC9C,CAAC,CAAA;YACF,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;QAC7B,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB;YAChD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;SACrB,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataModelKind } from '../models/kinds.js'\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport interface IDataModel {\n kind: typeof DataModelKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data model description.\n */\n info: IThing\n /**\n * The list of keys of entities that this data model contain.\n */\n entities?: string[]\n}\n\n/**\n * Data model creates a logical structure around data entities.\n * It groups entities that represents a whole schema, like a Product data model\n * can have entities that describe: the product entity, price history entity,\n * product location, etc.\n */\nexport class DataModel {\n kind = DataModelKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * The list of entities that this data model has.\n */\n entities: DataEntity[] = []\n\n static fromName(root: DataNamespace, name: string): DataModel {\n const entity = new DataModel(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param root the root namespace.\n * @param input The data model definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataModel\n ) {\n let init: IDataModel\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataModelKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n entities: [],\n }\n }\n this.new(init)\n }\n\n new(init: IDataModel): void {\n if (!DataModel.isDataModel(init)) {\n throw new Error(`Not a data model.`)\n }\n const { info, key = v4(), kind = DataModelKind, entities } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n\n this.entities = []\n if (Array.isArray(entities)) {\n entities.forEach((key) => {\n const value = this._readEntity(key)\n if (value) {\n this.entities.push(value)\n }\n })\n }\n }\n\n static isDataModel(input: unknown): boolean {\n const typed = input as IDataModel\n if (!input || typed.kind !== DataModelKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataModel {\n const result: IDataModel = {\n kind: DataModelKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.entities) && this.entities.length) {\n result.entities = this.entities.map((i) => i.key)\n }\n return result\n }\n\n protected _readEntity(key: string): DataEntity | undefined {\n return this.root.definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Removes self from the namespace with all entities.\n */\n remove(): void {\n const { key, entities, root } = this\n // remove children\n entities.forEach((e) => e.remove())\n\n // remove self from the parent\n const parent = this.getParent()\n if (parent) {\n const itemIndex = parent.items.findIndex((i) => i.key === key)\n if (itemIndex >= 0) {\n parent.items.splice(itemIndex, 1)\n }\n }\n // remove self from definitions\n const index = root.definitions.models.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.models.splice(index, 1)\n }\n }\n\n /**\n * Adapts an entity to this data model.\n * The entity must already be added to another data model within this namespace for it to be\n * adapted to this data model.\n * This method is used to change the data model of an entity.\n * It will remove the entity from the previous data model and add it to this one.\n * @param entity The entity to adapt.\n */\n adaptEntity(entity: DataEntity, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.entities.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (entity.root !== this.root) {\n throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`)\n }\n if (entity.getParent() === this) {\n throw new Error(`The entity ${entity.key} is already adapted by this data model.`)\n }\n const parent = entity.getParent()\n if (!parent) {\n throw new Error(`The entity ${entity.key} has no parent.`)\n }\n const index = parent.entities.findIndex((i) => i.key === entity.key)\n if (index < 0) {\n throw new Error(`The entity ${entity.key} is not in the parent data model.`)\n }\n parent.entities.splice(index, 1)\n if (opts.index !== undefined) {\n this.entities.splice(opts.index, 0, entity)\n } else {\n this.entities.push(entity)\n }\n }\n\n /**\n * Adds an entity to this data model.\n *\n * @param init The name of the entity to create, the instance of the entity or its schema\n * @returns A reference to the created entity.\n */\n addEntity(init: string | DataEntity | IDataEntity): DataEntity {\n let definition: DataEntity\n if (typeof init === 'string') {\n definition = DataEntity.fromName(this.root, init)\n } else if (init instanceof DataEntity) {\n definition = init\n } else {\n definition = new DataEntity(this.root, init)\n }\n this.root.definitions.entities.push(definition)\n this.entities.push(definition)\n return definition\n }\n\n /**\n * Returns the parent namespace where this data model exist.\n */\n getParent(): DataNamespace | undefined {\n if (this.root.items.some((e) => e.key === this.key)) {\n return this.root\n }\n return this.root.definitions.namespaces.find((n) => n.items.some((e) => e.key === this.key))\n }\n\n /**\n * Creates breadcrumbs from this data model to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.name || 'Unnamed data model',\n kind: DataModelKind,\n })\n let parent = this.getParent()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParent()\n }\n result.push({\n key: this.root.key,\n name: this.root.info.name || 'Unnamed namespace',\n kind: this.root.kind,\n })\n return result.reverse()\n }\n}\n"]}
|
|
@@ -5,6 +5,12 @@ import { IDataModel, DataModel } from './DataModel.js';
|
|
|
5
5
|
import { IDataProperty, DataProperty } from './DataProperty.js';
|
|
6
6
|
import { DataNamespaceKind, DataModelKind } from '../models/kinds.js';
|
|
7
7
|
type ItemKind = typeof DataNamespaceKind | typeof DataModelKind;
|
|
8
|
+
export interface DataItemAdaptingOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The index at which to adapt the item.
|
|
11
|
+
*/
|
|
12
|
+
index?: number;
|
|
13
|
+
}
|
|
8
14
|
interface IDataDefinitions {
|
|
9
15
|
models?: IDataModel[];
|
|
10
16
|
entities?: IDataEntity[];
|
|
@@ -184,6 +190,14 @@ export declare class DataNamespace extends DataNamespaceParent {
|
|
|
184
190
|
* @param parent The optional key of the parent namespace to add the new namespace to.
|
|
185
191
|
*/
|
|
186
192
|
addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace;
|
|
193
|
+
/**
|
|
194
|
+
* Adapts an existing namespace to this namespace.
|
|
195
|
+
* This will remove the namespace from the parent namespace and add it to this one.
|
|
196
|
+
*
|
|
197
|
+
* @param ns The namespace to adapt.
|
|
198
|
+
* @param opts Adapting options.
|
|
199
|
+
*/
|
|
200
|
+
adaptNamespace(ns: DataNamespace, opts?: DataItemAdaptingOptions): void;
|
|
187
201
|
/**
|
|
188
202
|
* Finds a namespace in the definitions.
|
|
189
203
|
* @param key The key of the namespace to find.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataNamespace.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,eAAe,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a,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAKjD;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQlC;;;OAGG;IACH,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAqB5C;;;;;;;;;OASG;IACF,eAAe,CACd,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAC3B,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,cAAoB,GAC1B,SAAS,CAAC,MAAM,EAAE,CAAC;IAsBtB;;;;;;;;;OASG;IACH,2BAA2B,IAAI,MAAM,EAAE;IAgBvC;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAK/C;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAKnD;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAKzD;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE;IAuBhF;;;;;;;;;OASG;IACH,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAa7E,UAAU,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAQnC,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAOtC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG1C"}
|
|
@@ -389,6 +389,55 @@ export class DataNamespace extends DataNamespaceParent {
|
|
|
389
389
|
root.items.push(item);
|
|
390
390
|
return definition;
|
|
391
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Adapts an existing namespace to this namespace.
|
|
394
|
+
* This will remove the namespace from the parent namespace and add it to this one.
|
|
395
|
+
*
|
|
396
|
+
* @param ns The namespace to adapt.
|
|
397
|
+
* @param opts Adapting options.
|
|
398
|
+
*/
|
|
399
|
+
adaptNamespace(ns, opts = {}) {
|
|
400
|
+
if (opts.index !== undefined) {
|
|
401
|
+
if (opts.index < 0) {
|
|
402
|
+
throw new Error(`The index ${opts.index} cannot be below 0.`);
|
|
403
|
+
}
|
|
404
|
+
if (opts.index >= this.items.length) {
|
|
405
|
+
throw new Error(`The index ${opts.index} is not valid.`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (ns === this) {
|
|
409
|
+
throw new Error(`Unable to adapt a namespace that is self.`);
|
|
410
|
+
}
|
|
411
|
+
if (ns.root !== this.root) {
|
|
412
|
+
throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`);
|
|
413
|
+
}
|
|
414
|
+
if (ns.getParent() === this) {
|
|
415
|
+
throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`);
|
|
416
|
+
}
|
|
417
|
+
// Check for circular dependency
|
|
418
|
+
let current = this;
|
|
419
|
+
while (current) {
|
|
420
|
+
if (current === ns) {
|
|
421
|
+
throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`);
|
|
422
|
+
}
|
|
423
|
+
current = current.getParent();
|
|
424
|
+
}
|
|
425
|
+
const parent = ns.getParent() || this.root;
|
|
426
|
+
if (!parent) {
|
|
427
|
+
throw new Error(`The namespace ${ns.key} has no parent.`);
|
|
428
|
+
}
|
|
429
|
+
const index = parent.items.findIndex((i) => i.key === ns.key);
|
|
430
|
+
if (index < 0) {
|
|
431
|
+
throw new Error(`The namespace ${ns.key} is not in the parent data namespace.`);
|
|
432
|
+
}
|
|
433
|
+
const [item] = parent.items.splice(index, 1);
|
|
434
|
+
if (opts.index !== undefined) {
|
|
435
|
+
this.items.splice(opts.index, 0, item);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
this.items.push(item);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
392
441
|
/**
|
|
393
442
|
* Finds a namespace in the definitions.
|
|
394
443
|
* @param key The key of the namespace to find.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataNamespace.js","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAoB,eAAe,EAAqB,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAc,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAiB,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAyF/B,MAAM,mBAAmB;IACvB,IAAI,GAAG,iBAAiB,CAAA;IAExB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,KAAK,GAAe,EAAE,CAAA;IAEtB;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;;OAGG;IACH,IAAI,CAAgB;IAEpB,YAAY,IAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;QAC1B,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,MAAM,GAAI,IAAsB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;YACtD,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAA;YAClB,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;QACD,6BAA6B;QAC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AAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,GAAW;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;IAChD,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport { IThing, Thing } from '../models/Thing.js'\nimport { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js'\nimport { IDataEntity, DataEntity } from './DataEntity.js'\nimport { IDataModel, DataModel } from './DataModel.js'\nimport { IDataProperty, DataProperty } from './DataProperty.js'\nimport { DataNamespaceKind, DataModelKind } from '../models/kinds.js'\nimport v4 from '../lib/uuid.js'\n\ntype ItemKind = typeof DataNamespaceKind | typeof DataModelKind\n\ninterface IDataDefinitions {\n models?: IDataModel[]\n entities?: IDataEntity[]\n properties?: IDataProperty[]\n associations?: IDataAssociation[]\n namespaces?: IDataNamespace[]\n tags?: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\ninterface DataDefinitions {\n models: DataModel[]\n // @todo: This should be a map of entities with a key of the entity key.\n entities: DataEntity[]\n // @todo: This should be a map of properties with a key of the property key.\n properties: DataProperty[]\n // @todo: This should be a map of associations with a key of the association key.\n associations: DataAssociation[]\n namespaces: DataNamespace[]\n /**\n * Common for the entire root namespace tags.\n * These are kept separately so the UI can generate autocomplete for tags.\n */\n tags: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * Data definition for a foreign namespace.\n * Each foreign namespace is resolved to a specific version.\n * This makes sure that the local data are always referencing an existing\n * entity as breaking changes should be resolved when upgrading a version.\n */\ninterface ForeignNamespace {\n key: string\n version: string\n}\n\ninterface IDataNamespaceParent {\n kind: typeof DataNamespaceKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The ordered list of items in this namespace.\n */\n items: IDataItem[]\n /**\n * The data namespace description.\n */\n info: IThing\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport interface IDataNamespace extends IDataNamespaceParent {\n /**\n * The list of definitions used in the namespace.\n */\n definitions: IDataDefinitions\n}\n\n/**\n * Data item is a reference to an object in the top namespace definitions\n * to the namespace items.\n */\nexport interface IDataItem {\n /**\n * The kind of the item.\n */\n kind: ItemKind\n /**\n * The identifier in the `definitions` array of the namespace.\n */\n key: string\n}\n\nclass DataNamespaceParent {\n kind = DataNamespaceKind\n\n key = ''\n\n /**\n * The ordered list of items in this namespace.\n */\n items: DataItem[] = []\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * When a namespace is a sub-namespace this is the reference to the\n * root namespace with all definitions.\n */\n root?: DataNamespace\n\n constructor(root?: DataNamespace) {\n this.root = root\n }\n\n /**\n * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.\n */\n getParent(): DataNamespace | undefined {\n const { root, key } = this\n if (root) {\n const result = (root as DataNamespace).findParent(key)\n if (result === this.root) {\n return undefined\n }\n return result\n }\n // we are the root namespace.\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n */\n addNamespace(init: string | IDataNamespace | DataNamespace): DataNamespace {\n return (this.root as DataNamespace).addNamespace(init, this.key)\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listNamespaces(): DataNamespace[] {\n const result: DataNamespace[] = []\n const { items } = this\n const root = this.getRoot()\n const { namespaces } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataNamespaceKind) {\n return\n }\n const def = namespaces.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listDataModels(): DataModel[] {\n const result: DataModel[] = []\n const { items } = this\n const root = this.getRoot()\n const { models } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataModelKind) {\n return\n }\n const def = models.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * @returns The root of the namespaces tree. It might be the same object.\n */\n getRoot(): DataNamespace {\n if (this.root) {\n return this.root\n }\n return this as unknown as DataNamespace\n }\n\n /**\n * Removes self from the parent namespace with all data models.\n * This does noting for the root namespace.\n */\n remove(): void {\n const { root } = this\n if (!root) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const models = this.listDataModels()\n const children = this.listNamespaces()\n models.forEach((m) => m.remove())\n children.forEach((c) => c.remove())\n const index = root.definitions.namespaces.findIndex((i) => i.key === this.key)\n if (index >= 0) {\n root.definitions.namespaces.splice(index, 1)\n }\n }\n}\n\nexport class DataItem implements IDataItem {\n kind: ItemKind = DataModelKind\n\n key = ''\n\n /**\n * A reference to the top level namespace.\n */\n private root: DataNamespace\n\n static isDataItem(input: unknown): boolean {\n const typed = input as IDataItem\n if (!input || ![DataModelKind, DataNamespaceKind].includes(typed.kind)) {\n return false\n }\n return true\n }\n\n static dataNamespace(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataNamespaceKind,\n key,\n })\n return item\n }\n\n static dataModel(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataModelKind,\n key,\n })\n return item\n }\n\n /**\n * @param root The top-most data namespace.\n * @param input The project item definition used to restore the state.\n */\n constructor(root: DataNamespace, input: string | IDataItem) {\n this.root = root\n let init: IDataItem\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n throw new Error('Specify the type of the item.')\n }\n this.new(init)\n }\n\n new(init: IDataItem): void {\n if (!DataItem.isDataItem(init)) {\n throw new Error(`Not a data item.`)\n }\n const { kind, key } = init\n this.kind = kind\n this.key = key\n }\n\n toJSON(): IDataItem {\n const result: IDataItem = {\n kind: this.kind,\n key: this.key,\n }\n return result\n }\n\n getItem(): DataNamespace | DataModel | undefined {\n const { root, key, kind } = this\n const { definitions } = root\n if (kind === DataModelKind) {\n return definitions.models.find((i) => i.key === key)\n }\n if (kind === kind) {\n return definitions.namespaces.find((i) => i.key === key)\n }\n }\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport class DataNamespace extends DataNamespaceParent {\n definitions: DataDefinitions\n\n /**\n * The list of foreign namespaces.\n * This is used to find entities from foreign namespaces.\n * Values here are treated as read only (objects can be frozen).\n *\n * This should be set by the application and the namespace will do\n * nothing to populate this value.\n */\n foreign: DataNamespace[] = []\n\n /**\n * Creates a new data namespace from a name.\n * @param name The name to set.\n */\n static fromName(name: string, root?: DataNamespace): DataNamespace {\n const ns = new DataNamespace(undefined, root)\n const info = Thing.fromName(name)\n ns.info = info\n return ns\n }\n\n static definitions(): DataDefinitions {\n return {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n }\n\n constructor(input?: string | IDataNamespace, root?: DataNamespace) {\n super(root)\n this.definitions = DataNamespace.definitions()\n\n let init: IDataNamespace\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n if (!init.kind) {\n init.kind = DataNamespaceKind\n }\n } else {\n init = {\n kind: DataNamespaceKind,\n key: v4(),\n definitions: {},\n items: [],\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataNamespace): void {\n if (!init || !init.definitions || !init.items) {\n throw new Error(`Not a data namespace.`)\n }\n const { key = v4(), definitions = {}, items, info } = init\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(items)) {\n this.items = items.map((i) => new DataItem(this, i))\n } else {\n this.items = []\n }\n if (Array.isArray(definitions.associations)) {\n this.definitions.associations = definitions.associations.map((i) => new DataAssociation(this, i))\n } else {\n this.definitions.associations = []\n }\n if (Array.isArray(definitions.properties)) {\n this.definitions.properties = definitions.properties.map((i) => new DataProperty(this, i))\n } else {\n this.definitions.properties = []\n }\n // note, entities must be restored after properties / associations\n if (Array.isArray(definitions.entities)) {\n this.definitions.entities = definitions.entities.map((i) => new DataEntity(this, i))\n } else {\n this.definitions.entities = []\n }\n // must be set after entities.\n if (Array.isArray(definitions.models)) {\n this.definitions.models = definitions.models.map((i) => new DataModel(this, i))\n } else {\n this.definitions.models = []\n }\n if (Array.isArray(definitions.namespaces)) {\n this.definitions.namespaces = definitions.namespaces.map((i) => new DataNamespace(i, this))\n } else {\n this.definitions.namespaces = []\n }\n if (Array.isArray(definitions.tags)) {\n this.definitions.tags = [...definitions.tags]\n } else {\n this.definitions.tags = []\n }\n }\n\n toJSON(): IDataNamespace {\n const result: IDataNamespace = {\n key: this.key,\n kind: DataNamespaceKind,\n info: this.info.toJSON(),\n items: this.items.map((i) => i.toJSON()),\n definitions: {},\n }\n const { associations, entities, models, namespaces, properties, tags } = this.definitions\n if (Array.isArray(associations) && associations.length) {\n result.definitions.associations = associations.map((i) => i.toJSON())\n }\n if (Array.isArray(entities) && entities.length) {\n result.definitions.entities = entities.map((i) => i.toJSON())\n }\n if (Array.isArray(models) && models.length) {\n result.definitions.models = models.map((i) => i.toJSON())\n }\n if (Array.isArray(namespaces) && namespaces.length) {\n result.definitions.namespaces = namespaces.map((i) => i.toJSON())\n }\n if (Array.isArray(properties) && properties.length) {\n result.definitions.properties = properties.map((i) => i.toJSON())\n }\n if (Array.isArray(tags) && tags.length) {\n result.definitions.tags = [...tags]\n }\n return result\n }\n\n /**\n * Checks if this is the root namespace.\n * @returns True if this is the root namespace.\n */\n isRoot(): boolean {\n return this.root === undefined\n }\n\n /**\n * Finds a parent namespace for the given namespace.\n * @param key The namespace key to find the parent for.\n * @returns The parent namespace or undefined when the namespace does not exist. It may return the root namespace.\n */\n findParent(key: string): DataNamespace | undefined {\n const { definitions, items = [] } = this\n const rootIndex = items.findIndex((i) => i.key === key)\n if (rootIndex >= 0) {\n return this\n }\n const definition = definitions.namespaces.find((i) => i.items.some((item) => item.key === key))\n if (definition) {\n return definition\n }\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n * @param parent The optional key of the parent namespace to add the new namespace to.\n */\n override addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findParent(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataNamespace\n if (typeof init === 'string') {\n definition = DataNamespace.fromName(init, this.root || this)\n } else if (init instanceof DataNamespace) {\n definition = init\n } else {\n definition = new DataNamespace(init, this.root || this)\n }\n ;(this.root || this).definitions.namespaces.push(definition)\n const item = DataItem.dataNamespace(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Finds a namespace in the definitions.\n * @param key The key of the namespace to find.\n * @returns The namespace definition or undefined when not found.\n */\n findNamespace(key: string): DataNamespace | undefined {\n const { definitions } = this.root || this\n return definitions.namespaces.find((i) => i.key === key)\n }\n\n /**\n * Finds a namespace and calls the `remove()` on it.\n * @param key The key of the namespace to find.\n */\n removeNamespace(key: string): void {\n const root = this.root || this\n if (root.key === key) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const { definitions } = root\n const ns = definitions.namespaces.find((i) => i.key === key)\n if (ns) {\n ns.remove()\n }\n }\n\n /**\n * Adds a data model to a namespace.\n * @param init The name of the data model to add, data model's schema, or its instance.\n * @param parent The optional key of the parent namespace to add the new data model to.\n */\n addDataModel(init: string | IDataModel | DataModel, parent?: string): DataModel {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataModel\n if (typeof init === 'string') {\n definition = DataModel.fromName(this.root || this, init)\n } else if (init instanceof DataModel) {\n definition = init\n } else {\n definition = new DataModel(this.root || this, init)\n }\n ;(this.root || this).definitions.models.push(definition)\n const item = DataItem.dataModel(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Finds a data model in the definitions.\n * @param key The key of the data model to find.\n * @returns The data model definition or undefined when not found.\n */\n findDataModel(key: string): DataModel | undefined {\n const { definitions } = this.root || this\n return definitions.models.find((i) => i.key === key)\n }\n\n /**\n * Finds a data model and calls the `remove()` on it.\n * @param key The key of the data model to find.\n */\n removeDataModel(key: string): void {\n const { definitions } = this.root || this\n const model = definitions.models.find((i) => i.key === key)\n if (model) {\n model.remove()\n }\n }\n\n /**\n * @returns The graph of associations where keys are the source\n * entities and the value is the list of all target entities.\n */\n associationGraph(): Record<string, string[]> {\n const graph: Record<string, string[]> = {}\n const { definitions } = this.root || this\n const { associations, entities } = definitions\n for (const assoc of associations) {\n if (!assoc.targets.length) {\n continue\n }\n const srcEntity = entities.find((i) => i.associations.some((a) => a === assoc))\n if (!srcEntity) {\n continue\n }\n if (!graph[srcEntity.key]) {\n graph[srcEntity.key] = []\n }\n const targetIds = assoc.targets.map((i) => i.key)\n graph[srcEntity.key].splice(0, 0, ...targetIds)\n }\n return graph\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n *\n * @param from The key of the from entity\n * @param to The key of the target entity\n * @param g The graph generated with `associationGraph()`\n * @param path The current list of entity ids. Do not set this, it is for the recursive processing of the graph.\n * @param visited The list of visited paths to avoid cycles.\n * Do not set this, it is for the recursive processing of the graph.\n */\n *associationPath(\n from: string,\n to: string,\n g: Record<string, string[]>,\n path: string[] = [],\n visited = new Set<string>()\n ): Generator<string[]> {\n if (from === to) {\n yield path.concat(to)\n return\n }\n if (visited.has(from)) {\n // it's a cycle\n return\n }\n if (g[from]) {\n visited.add(from)\n path.push(from)\n\n for (const neighbor of g[from]) {\n yield* this.associationPath(neighbor, to, g, path, visited)\n }\n\n visited.delete(from)\n path.pop()\n }\n }\n\n /**\n * Scans all associations for foreign namespaces and returns\n * the list of all namespaces used in the association graph.\n * This will never add this namespace's key.\n *\n * This function should be used to read keys for all related\n * namespaces through associations.\n *\n * @returns All keys of foreign namespaces.\n */\n computeForeignNamespaceKeys(): string[] {\n const result: string[] = []\n const { associations = [] } = this.definitions\n associations.forEach((association) => {\n const { targets = [] } = association\n targets.forEach((target) => {\n const { namespace } = target\n if (!namespace || namespace === this.key) {\n return\n }\n result.push(namespace)\n })\n })\n return result\n }\n\n /**\n * Finds an entity in this namespace.\n * @param key The key of the entity to find.\n */\n findEntity(key: string): DataEntity | undefined {\n const { definitions } = this.root || this\n return definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Finds a property by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findProperty(key: string): DataProperty | undefined {\n const { definitions } = this.root || this\n return definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Finds an association by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findAssociation(key: string): DataAssociation | undefined {\n const { definitions } = this.root || this\n return definitions.associations.find((i) => i.key === key)\n }\n\n /**\n * Searches for entities for association targets.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param targets The list of targets\n * @returns A list of entities. An `undefined` is put at the index where an entity cannot be found\n */\n findAssociatedEntities(targets: AssociationTarget[]): (DataEntity | undefined)[] {\n const result: (DataEntity | undefined)[] = []\n targets.forEach((target) => {\n let ns: DataNamespace | undefined\n if (target.namespace) {\n ns = this.foreign.find((i) => i.key === target.namespace)\n } else {\n ns = this\n }\n if (!ns) {\n result.push(undefined)\n return\n }\n const entity = ns.findEntity(target.key)\n if (entity) {\n result.push(entity)\n } else {\n result.push(undefined)\n }\n })\n return result\n }\n\n /**\n * Finds an associated entity in the current or foreign namespace.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param key The key of the entity to find.\n * @param namespace The optional namespace to search in.\n * If not set, the current namespace is used.\n * This is used to find entities in foreign namespaces.\n * @returns The entity or undefined if not found.\n */\n findAssociatedEntity(key: string, namespace?: string): DataEntity | undefined {\n let ns: DataNamespace | undefined\n if (namespace) {\n ns = this.foreign.find((i) => i.key === namespace)\n } else {\n ns = this\n }\n if (!ns) {\n return undefined\n }\n return ns.findEntity(key)\n }\n\n addForeign(ns: DataNamespace): void {\n const exists = this.foreign.some((i) => i.key === ns.key)\n if (exists) {\n return\n }\n this.foreign.push(ns)\n }\n\n removeForeign(ns: DataNamespace): void {\n const index = this.foreign.findIndex((i) => i === ns)\n if (index >= 0) {\n this.foreign.splice(index, 1)\n }\n }\n\n hasForeignNamespace(key: string): boolean {\n return this.foreign.some((i) => i.key === key)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataNamespace.js","sourceRoot":"","sources":["../../../src/modeling/DataNamespace.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAoB,eAAe,EAAqB,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAc,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAiB,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAgG/B,MAAM,mBAAmB;IACvB,IAAI,GAAG,iBAAiB,CAAA;IAExB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,KAAK,GAAe,EAAE,CAAA;IAEtB;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;;OAGG;IACH,IAAI,CAAgB;IAEpB,YAAY,IAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;I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,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;IAChD,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport { IThing, Thing } from '../models/Thing.js'\nimport { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js'\nimport { IDataEntity, DataEntity } from './DataEntity.js'\nimport { IDataModel, DataModel } from './DataModel.js'\nimport { IDataProperty, DataProperty } from './DataProperty.js'\nimport { DataNamespaceKind, DataModelKind } from '../models/kinds.js'\nimport v4 from '../lib/uuid.js'\n\ntype ItemKind = typeof DataNamespaceKind | typeof DataModelKind\n\nexport interface DataItemAdaptingOptions {\n /**\n * The index at which to adapt the item.\n */\n index?: number\n}\n\ninterface IDataDefinitions {\n models?: IDataModel[]\n entities?: IDataEntity[]\n properties?: IDataProperty[]\n associations?: IDataAssociation[]\n namespaces?: IDataNamespace[]\n tags?: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\ninterface DataDefinitions {\n models: DataModel[]\n // @todo: This should be a map of entities with a key of the entity key.\n entities: DataEntity[]\n // @todo: This should be a map of properties with a key of the property key.\n properties: DataProperty[]\n // @todo: This should be a map of associations with a key of the association key.\n associations: DataAssociation[]\n namespaces: DataNamespace[]\n /**\n * Common for the entire root namespace tags.\n * These are kept separately so the UI can generate autocomplete for tags.\n */\n tags: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * Data definition for a foreign namespace.\n * Each foreign namespace is resolved to a specific version.\n * This makes sure that the local data are always referencing an existing\n * entity as breaking changes should be resolved when upgrading a version.\n */\ninterface ForeignNamespace {\n key: string\n version: string\n}\n\ninterface IDataNamespaceParent {\n kind: typeof DataNamespaceKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The ordered list of items in this namespace.\n */\n items: IDataItem[]\n /**\n * The data namespace description.\n */\n info: IThing\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport interface IDataNamespace extends IDataNamespaceParent {\n /**\n * The list of definitions used in the namespace.\n */\n definitions: IDataDefinitions\n}\n\n/**\n * Data item is a reference to an object in the top namespace definitions\n * to the namespace items.\n */\nexport interface IDataItem {\n /**\n * The kind of the item.\n */\n kind: ItemKind\n /**\n * The identifier in the `definitions` array of the namespace.\n */\n key: string\n}\n\nclass DataNamespaceParent {\n kind = DataNamespaceKind\n\n key = ''\n\n /**\n * The ordered list of items in this namespace.\n */\n items: DataItem[] = []\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * When a namespace is a sub-namespace this is the reference to the\n * root namespace with all definitions.\n */\n root?: DataNamespace\n\n constructor(root?: DataNamespace) {\n this.root = root\n }\n\n /**\n * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.\n */\n getParent(): DataNamespace | undefined {\n const { root, key } = this\n if (root) {\n const result = (root as DataNamespace).findParent(key)\n if (result === this.root) {\n return undefined\n }\n return result\n }\n // we are the root namespace.\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n */\n addNamespace(init: string | IDataNamespace | DataNamespace): DataNamespace {\n return (this.root as DataNamespace).addNamespace(init, this.key)\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listNamespaces(): DataNamespace[] {\n const result: DataNamespace[] = []\n const { items } = this\n const root = this.getRoot()\n const { namespaces } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataNamespaceKind) {\n return\n }\n const def = namespaces.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listDataModels(): DataModel[] {\n const result: DataModel[] = []\n const { items } = this\n const root = this.getRoot()\n const { models } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataModelKind) {\n return\n }\n const def = models.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * @returns The root of the namespaces tree. It might be the same object.\n */\n getRoot(): DataNamespace {\n if (this.root) {\n return this.root\n }\n return this as unknown as DataNamespace\n }\n\n /**\n * Removes self from the parent namespace with all data models.\n * This does noting for the root namespace.\n */\n remove(): void {\n const { root } = this\n if (!root) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const models = this.listDataModels()\n const children = this.listNamespaces()\n models.forEach((m) => m.remove())\n children.forEach((c) => c.remove())\n const index = root.definitions.namespaces.findIndex((i) => i.key === this.key)\n if (index >= 0) {\n root.definitions.namespaces.splice(index, 1)\n }\n }\n}\n\nexport class DataItem implements IDataItem {\n kind: ItemKind = DataModelKind\n\n key = ''\n\n /**\n * A reference to the top level namespace.\n */\n private root: DataNamespace\n\n static isDataItem(input: unknown): boolean {\n const typed = input as IDataItem\n if (!input || ![DataModelKind, DataNamespaceKind].includes(typed.kind)) {\n return false\n }\n return true\n }\n\n static dataNamespace(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataNamespaceKind,\n key,\n })\n return item\n }\n\n static dataModel(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataModelKind,\n key,\n })\n return item\n }\n\n /**\n * @param root The top-most data namespace.\n * @param input The project item definition used to restore the state.\n */\n constructor(root: DataNamespace, input: string | IDataItem) {\n this.root = root\n let init: IDataItem\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n throw new Error('Specify the type of the item.')\n }\n this.new(init)\n }\n\n new(init: IDataItem): void {\n if (!DataItem.isDataItem(init)) {\n throw new Error(`Not a data item.`)\n }\n const { kind, key } = init\n this.kind = kind\n this.key = key\n }\n\n toJSON(): IDataItem {\n const result: IDataItem = {\n kind: this.kind,\n key: this.key,\n }\n return result\n }\n\n getItem(): DataNamespace | DataModel | undefined {\n const { root, key, kind } = this\n const { definitions } = root\n if (kind === DataModelKind) {\n return definitions.models.find((i) => i.key === key)\n }\n if (kind === kind) {\n return definitions.namespaces.find((i) => i.key === key)\n }\n }\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n */\nexport class DataNamespace extends DataNamespaceParent {\n definitions: DataDefinitions\n\n /**\n * The list of foreign namespaces.\n * This is used to find entities from foreign namespaces.\n * Values here are treated as read only (objects can be frozen).\n *\n * This should be set by the application and the namespace will do\n * nothing to populate this value.\n */\n foreign: DataNamespace[] = []\n\n /**\n * Creates a new data namespace from a name.\n * @param name The name to set.\n */\n static fromName(name: string, root?: DataNamespace): DataNamespace {\n const ns = new DataNamespace(undefined, root)\n const info = Thing.fromName(name)\n ns.info = info\n return ns\n }\n\n static definitions(): DataDefinitions {\n return {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n }\n\n constructor(input?: string | IDataNamespace, root?: DataNamespace) {\n super(root)\n this.definitions = DataNamespace.definitions()\n\n let init: IDataNamespace\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n if (!init.kind) {\n init.kind = DataNamespaceKind\n }\n } else {\n init = {\n kind: DataNamespaceKind,\n key: v4(),\n definitions: {},\n items: [],\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataNamespace): void {\n if (!init || !init.definitions || !init.items) {\n throw new Error(`Not a data namespace.`)\n }\n const { key = v4(), definitions = {}, items, info } = init\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(items)) {\n this.items = items.map((i) => new DataItem(this, i))\n } else {\n this.items = []\n }\n if (Array.isArray(definitions.associations)) {\n this.definitions.associations = definitions.associations.map((i) => new DataAssociation(this, i))\n } else {\n this.definitions.associations = []\n }\n if (Array.isArray(definitions.properties)) {\n this.definitions.properties = definitions.properties.map((i) => new DataProperty(this, i))\n } else {\n this.definitions.properties = []\n }\n // note, entities must be restored after properties / associations\n if (Array.isArray(definitions.entities)) {\n this.definitions.entities = definitions.entities.map((i) => new DataEntity(this, i))\n } else {\n this.definitions.entities = []\n }\n // must be set after entities.\n if (Array.isArray(definitions.models)) {\n this.definitions.models = definitions.models.map((i) => new DataModel(this, i))\n } else {\n this.definitions.models = []\n }\n if (Array.isArray(definitions.namespaces)) {\n this.definitions.namespaces = definitions.namespaces.map((i) => new DataNamespace(i, this))\n } else {\n this.definitions.namespaces = []\n }\n if (Array.isArray(definitions.tags)) {\n this.definitions.tags = [...definitions.tags]\n } else {\n this.definitions.tags = []\n }\n }\n\n toJSON(): IDataNamespace {\n const result: IDataNamespace = {\n key: this.key,\n kind: DataNamespaceKind,\n info: this.info.toJSON(),\n items: this.items.map((i) => i.toJSON()),\n definitions: {},\n }\n const { associations, entities, models, namespaces, properties, tags } = this.definitions\n if (Array.isArray(associations) && associations.length) {\n result.definitions.associations = associations.map((i) => i.toJSON())\n }\n if (Array.isArray(entities) && entities.length) {\n result.definitions.entities = entities.map((i) => i.toJSON())\n }\n if (Array.isArray(models) && models.length) {\n result.definitions.models = models.map((i) => i.toJSON())\n }\n if (Array.isArray(namespaces) && namespaces.length) {\n result.definitions.namespaces = namespaces.map((i) => i.toJSON())\n }\n if (Array.isArray(properties) && properties.length) {\n result.definitions.properties = properties.map((i) => i.toJSON())\n }\n if (Array.isArray(tags) && tags.length) {\n result.definitions.tags = [...tags]\n }\n return result\n }\n\n /**\n * Checks if this is the root namespace.\n * @returns True if this is the root namespace.\n */\n isRoot(): boolean {\n return this.root === undefined\n }\n\n /**\n * Finds a parent namespace for the given namespace.\n * @param key The namespace key to find the parent for.\n * @returns The parent namespace or undefined when the namespace does not exist. It may return the root namespace.\n */\n findParent(key: string): DataNamespace | undefined {\n const { definitions, items = [] } = this\n const rootIndex = items.findIndex((i) => i.key === key)\n if (rootIndex >= 0) {\n return this\n }\n const definition = definitions.namespaces.find((i) => i.items.some((item) => item.key === key))\n if (definition) {\n return definition\n }\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n * @param parent The optional key of the parent namespace to add the new namespace to.\n */\n override addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findParent(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataNamespace\n if (typeof init === 'string') {\n definition = DataNamespace.fromName(init, this.root || this)\n } else if (init instanceof DataNamespace) {\n definition = init\n } else {\n definition = new DataNamespace(init, this.root || this)\n }\n ;(this.root || this).definitions.namespaces.push(definition)\n const item = DataItem.dataNamespace(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Adapts an existing namespace to this namespace.\n * This will remove the namespace from the parent namespace and add it to this one.\n *\n * @param ns The namespace to adapt.\n * @param opts Adapting options.\n */\n adaptNamespace(ns: DataNamespace, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (ns === this) {\n throw new Error(`Unable to adapt a namespace that is self.`)\n }\n if (ns.root !== this.root) {\n throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`)\n }\n if (ns.getParent() === this) {\n throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`)\n }\n // Check for circular dependency\n let current: DataNamespace | undefined = this\n while (current) {\n if (current === ns) {\n throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`)\n }\n current = current.getParent()\n }\n const parent = ns.getParent() || this.root\n if (!parent) {\n throw new Error(`The namespace ${ns.key} has no parent.`)\n }\n const index = parent.items.findIndex((i) => i.key === ns.key)\n if (index < 0) {\n throw new Error(`The namespace ${ns.key} is not in the parent data namespace.`)\n }\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Finds a namespace in the definitions.\n * @param key The key of the namespace to find.\n * @returns The namespace definition or undefined when not found.\n */\n findNamespace(key: string): DataNamespace | undefined {\n const { definitions } = this.root || this\n return definitions.namespaces.find((i) => i.key === key)\n }\n\n /**\n * Finds a namespace and calls the `remove()` on it.\n * @param key The key of the namespace to find.\n */\n removeNamespace(key: string): void {\n const root = this.root || this\n if (root.key === key) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const { definitions } = root\n const ns = definitions.namespaces.find((i) => i.key === key)\n if (ns) {\n ns.remove()\n }\n }\n\n /**\n * Adds a data model to a namespace.\n * @param init The name of the data model to add, data model's schema, or its instance.\n * @param parent The optional key of the parent namespace to add the new data model to.\n */\n addDataModel(init: string | IDataModel | DataModel, parent?: string): DataModel {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataModel\n if (typeof init === 'string') {\n definition = DataModel.fromName(this.root || this, init)\n } else if (init instanceof DataModel) {\n definition = init\n } else {\n definition = new DataModel(this.root || this, init)\n }\n ;(this.root || this).definitions.models.push(definition)\n const item = DataItem.dataModel(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Finds a data model in the definitions.\n * @param key The key of the data model to find.\n * @returns The data model definition or undefined when not found.\n */\n findDataModel(key: string): DataModel | undefined {\n const { definitions } = this.root || this\n return definitions.models.find((i) => i.key === key)\n }\n\n /**\n * Finds a data model and calls the `remove()` on it.\n * @param key The key of the data model to find.\n */\n removeDataModel(key: string): void {\n const { definitions } = this.root || this\n const model = definitions.models.find((i) => i.key === key)\n if (model) {\n model.remove()\n }\n }\n\n /**\n * @returns The graph of associations where keys are the source\n * entities and the value is the list of all target entities.\n */\n associationGraph(): Record<string, string[]> {\n const graph: Record<string, string[]> = {}\n const { definitions } = this.root || this\n const { associations, entities } = definitions\n for (const assoc of associations) {\n if (!assoc.targets.length) {\n continue\n }\n const srcEntity = entities.find((i) => i.associations.some((a) => a === assoc))\n if (!srcEntity) {\n continue\n }\n if (!graph[srcEntity.key]) {\n graph[srcEntity.key] = []\n }\n const targetIds = assoc.targets.map((i) => i.key)\n graph[srcEntity.key].splice(0, 0, ...targetIds)\n }\n return graph\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n *\n * @param from The key of the from entity\n * @param to The key of the target entity\n * @param g The graph generated with `associationGraph()`\n * @param path The current list of entity ids. Do not set this, it is for the recursive processing of the graph.\n * @param visited The list of visited paths to avoid cycles.\n * Do not set this, it is for the recursive processing of the graph.\n */\n *associationPath(\n from: string,\n to: string,\n g: Record<string, string[]>,\n path: string[] = [],\n visited = new Set<string>()\n ): Generator<string[]> {\n if (from === to) {\n yield path.concat(to)\n return\n }\n if (visited.has(from)) {\n // it's a cycle\n return\n }\n if (g[from]) {\n visited.add(from)\n path.push(from)\n\n for (const neighbor of g[from]) {\n yield* this.associationPath(neighbor, to, g, path, visited)\n }\n\n visited.delete(from)\n path.pop()\n }\n }\n\n /**\n * Scans all associations for foreign namespaces and returns\n * the list of all namespaces used in the association graph.\n * This will never add this namespace's key.\n *\n * This function should be used to read keys for all related\n * namespaces through associations.\n *\n * @returns All keys of foreign namespaces.\n */\n computeForeignNamespaceKeys(): string[] {\n const result: string[] = []\n const { associations = [] } = this.definitions\n associations.forEach((association) => {\n const { targets = [] } = association\n targets.forEach((target) => {\n const { namespace } = target\n if (!namespace || namespace === this.key) {\n return\n }\n result.push(namespace)\n })\n })\n return result\n }\n\n /**\n * Finds an entity in this namespace.\n * @param key The key of the entity to find.\n */\n findEntity(key: string): DataEntity | undefined {\n const { definitions } = this.root || this\n return definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Finds a property by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findProperty(key: string): DataProperty | undefined {\n const { definitions } = this.root || this\n return definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Finds an association by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findAssociation(key: string): DataAssociation | undefined {\n const { definitions } = this.root || this\n return definitions.associations.find((i) => i.key === key)\n }\n\n /**\n * Searches for entities for association targets.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param targets The list of targets\n * @returns A list of entities. An `undefined` is put at the index where an entity cannot be found\n */\n findAssociatedEntities(targets: AssociationTarget[]): (DataEntity | undefined)[] {\n const result: (DataEntity | undefined)[] = []\n targets.forEach((target) => {\n let ns: DataNamespace | undefined\n if (target.namespace) {\n ns = this.foreign.find((i) => i.key === target.namespace)\n } else {\n ns = this\n }\n if (!ns) {\n result.push(undefined)\n return\n }\n const entity = ns.findEntity(target.key)\n if (entity) {\n result.push(entity)\n } else {\n result.push(undefined)\n }\n })\n return result\n }\n\n /**\n * Finds an associated entity in the current or foreign namespace.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param key The key of the entity to find.\n * @param namespace The optional namespace to search in.\n * If not set, the current namespace is used.\n * This is used to find entities in foreign namespaces.\n * @returns The entity or undefined if not found.\n */\n findAssociatedEntity(key: string, namespace?: string): DataEntity | undefined {\n let ns: DataNamespace | undefined\n if (namespace) {\n ns = this.foreign.find((i) => i.key === namespace)\n } else {\n ns = this\n }\n if (!ns) {\n return undefined\n }\n return ns.findEntity(key)\n }\n\n addForeign(ns: DataNamespace): void {\n const exists = this.foreign.some((i) => i.key === ns.key)\n if (exists) {\n return\n }\n this.foreign.push(ns)\n }\n\n removeForeign(ns: DataNamespace): void {\n const index = this.foreign.findIndex((i) => i === ns)\n if (index >= 0) {\n this.foreign.splice(index, 1)\n }\n }\n\n hasForeignNamespace(key: string): boolean {\n return this.foreign.some((i) => i.key === key)\n }\n}\n"]}
|
|
@@ -41722,22 +41722,22 @@
|
|
|
41722
41722
|
"@id": "#209"
|
|
41723
41723
|
},
|
|
41724
41724
|
{
|
|
41725
|
-
"@id": "#
|
|
41725
|
+
"@id": "#203"
|
|
41726
41726
|
},
|
|
41727
41727
|
{
|
|
41728
|
-
"@id": "#
|
|
41728
|
+
"@id": "#206"
|
|
41729
41729
|
},
|
|
41730
41730
|
{
|
|
41731
|
-
"@id": "#
|
|
41731
|
+
"@id": "#200"
|
|
41732
41732
|
},
|
|
41733
41733
|
{
|
|
41734
|
-
"@id": "#
|
|
41734
|
+
"@id": "#194"
|
|
41735
41735
|
},
|
|
41736
41736
|
{
|
|
41737
|
-
"@id": "#
|
|
41737
|
+
"@id": "#191"
|
|
41738
41738
|
},
|
|
41739
41739
|
{
|
|
41740
|
-
"@id": "#
|
|
41740
|
+
"@id": "#197"
|
|
41741
41741
|
},
|
|
41742
41742
|
{
|
|
41743
41743
|
"@id": "#209"
|
|
@@ -42476,10 +42476,10 @@
|
|
|
42476
42476
|
"@id": "#219"
|
|
42477
42477
|
},
|
|
42478
42478
|
{
|
|
42479
|
-
"@id": "#
|
|
42479
|
+
"@id": "#213"
|
|
42480
42480
|
},
|
|
42481
42481
|
{
|
|
42482
|
-
"@id": "#
|
|
42482
|
+
"@id": "#216"
|
|
42483
42483
|
}
|
|
42484
42484
|
],
|
|
42485
42485
|
"doc:root": false,
|
|
@@ -43096,7 +43096,7 @@
|
|
|
43096
43096
|
"doc:ExternalDomainElement",
|
|
43097
43097
|
"doc:DomainElement"
|
|
43098
43098
|
],
|
|
43099
|
-
"doc:raw": "
|
|
43099
|
+
"doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
|
|
43100
43100
|
"core:mediaType": "application/yaml",
|
|
43101
43101
|
"sourcemaps:sources": [
|
|
43102
43102
|
{
|
|
@@ -43117,7 +43117,7 @@
|
|
|
43117
43117
|
"doc:ExternalDomainElement",
|
|
43118
43118
|
"doc:DomainElement"
|
|
43119
43119
|
],
|
|
43120
|
-
"doc:raw": "
|
|
43120
|
+
"doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
|
|
43121
43121
|
"core:mediaType": "application/yaml",
|
|
43122
43122
|
"sourcemaps:sources": [
|
|
43123
43123
|
{
|
|
@@ -43138,7 +43138,7 @@
|
|
|
43138
43138
|
"doc:ExternalDomainElement",
|
|
43139
43139
|
"doc:DomainElement"
|
|
43140
43140
|
],
|
|
43141
|
-
"doc:raw": "code: '
|
|
43141
|
+
"doc:raw": "code: '7487'\ndescription: 'Financial and insurance activities'\ntype: \"PRIMARY\"\nclassificationCode: 'BE_NACEBEL2008'\nactivityGroupCode: 'ABCDE'\n",
|
|
43142
43142
|
"core:mediaType": "application/yaml",
|
|
43143
43143
|
"sourcemaps:sources": [
|
|
43144
43144
|
{
|
|
@@ -43159,7 +43159,7 @@
|
|
|
43159
43159
|
"doc:ExternalDomainElement",
|
|
43160
43160
|
"doc:DomainElement"
|
|
43161
43161
|
],
|
|
43162
|
-
"doc:raw": "
|
|
43162
|
+
"doc:raw": "code: '5'\ndescription: 'Limited company'\n",
|
|
43163
43163
|
"core:mediaType": "application/yaml",
|
|
43164
43164
|
"sourcemaps:sources": [
|
|
43165
43165
|
{
|
|
@@ -43180,7 +43180,7 @@
|
|
|
43180
43180
|
"doc:ExternalDomainElement",
|
|
43181
43181
|
"doc:DomainElement"
|
|
43182
43182
|
],
|
|
43183
|
-
"doc:raw": "
|
|
43183
|
+
"doc:raw": "countryCode: \"BE\"\ngraydonEnterpriseId: 1057155523\nregistrationId: \"0422319093\"\nvatNumber: \"BE0422319093\"\ngraydonCompanyId: \"0422319093\"\nisBranchOffice: false\n",
|
|
43184
43184
|
"core:mediaType": "application/yaml",
|
|
43185
43185
|
"sourcemaps:sources": [
|
|
43186
43186
|
{
|
|
@@ -43201,7 +43201,7 @@
|
|
|
43201
43201
|
"doc:ExternalDomainElement",
|
|
43202
43202
|
"doc:DomainElement"
|
|
43203
43203
|
],
|
|
43204
|
-
"doc:raw": "
|
|
43204
|
+
"doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
|
|
43205
43205
|
"core:mediaType": "application/yaml",
|
|
43206
43206
|
"sourcemaps:sources": [
|
|
43207
43207
|
{
|
|
@@ -43913,7 +43913,7 @@
|
|
|
43913
43913
|
"doc:ExternalDomainElement",
|
|
43914
43914
|
"doc:DomainElement"
|
|
43915
43915
|
],
|
|
43916
|
-
"doc:raw": "type:
|
|
43916
|
+
"doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
|
|
43917
43917
|
"core:mediaType": "application/yaml",
|
|
43918
43918
|
"sourcemaps:sources": [
|
|
43919
43919
|
{
|
|
@@ -43934,7 +43934,7 @@
|
|
|
43934
43934
|
"doc:ExternalDomainElement",
|
|
43935
43935
|
"doc:DomainElement"
|
|
43936
43936
|
],
|
|
43937
|
-
"doc:raw": "
|
|
43937
|
+
"doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
|
|
43938
43938
|
"core:mediaType": "application/yaml",
|
|
43939
43939
|
"sourcemaps:sources": [
|
|
43940
43940
|
{
|
|
@@ -44416,32 +44416,32 @@
|
|
|
44416
44416
|
{
|
|
44417
44417
|
"@id": "#193/source-map/lexical/element_0",
|
|
44418
44418
|
"sourcemaps:element": "amf://id#193",
|
|
44419
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44419
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44420
44420
|
},
|
|
44421
44421
|
{
|
|
44422
44422
|
"@id": "#196/source-map/lexical/element_0",
|
|
44423
44423
|
"sourcemaps:element": "amf://id#196",
|
|
44424
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44424
|
+
"sourcemaps:value": "[(1,0)-(5,0)]"
|
|
44425
44425
|
},
|
|
44426
44426
|
{
|
|
44427
44427
|
"@id": "#199/source-map/lexical/element_0",
|
|
44428
44428
|
"sourcemaps:element": "amf://id#199",
|
|
44429
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44429
|
+
"sourcemaps:value": "[(1,0)-(6,0)]"
|
|
44430
44430
|
},
|
|
44431
44431
|
{
|
|
44432
44432
|
"@id": "#202/source-map/lexical/element_0",
|
|
44433
44433
|
"sourcemaps:element": "amf://id#202",
|
|
44434
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44434
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44435
44435
|
},
|
|
44436
44436
|
{
|
|
44437
44437
|
"@id": "#205/source-map/lexical/element_0",
|
|
44438
44438
|
"sourcemaps:element": "amf://id#205",
|
|
44439
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44439
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
44440
44440
|
},
|
|
44441
44441
|
{
|
|
44442
44442
|
"@id": "#208/source-map/lexical/element_0",
|
|
44443
44443
|
"sourcemaps:element": "amf://id#208",
|
|
44444
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44444
|
+
"sourcemaps:value": "[(1,0)-(10,0)]"
|
|
44445
44445
|
},
|
|
44446
44446
|
{
|
|
44447
44447
|
"@id": "#223/source-map/lexical/element_0",
|
|
@@ -44781,12 +44781,12 @@
|
|
|
44781
44781
|
{
|
|
44782
44782
|
"@id": "#215/source-map/lexical/element_0",
|
|
44783
44783
|
"sourcemaps:element": "amf://id#215",
|
|
44784
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44784
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
44785
44785
|
},
|
|
44786
44786
|
{
|
|
44787
44787
|
"@id": "#218/source-map/lexical/element_0",
|
|
44788
44788
|
"sourcemaps:element": "amf://id#218",
|
|
44789
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44789
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44790
44790
|
},
|
|
44791
44791
|
{
|
|
44792
44792
|
"@id": "#221/source-map/lexical/element_0",
|
|
@@ -741,6 +741,9 @@
|
|
|
741
741
|
],
|
|
742
742
|
"sourcemaps:lexical": [
|
|
743
743
|
{
|
|
744
|
+
"@id": "#34/source-map/lexical/element_1"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
744
747
|
"@id": "#34/source-map/lexical/element_0"
|
|
745
748
|
}
|
|
746
749
|
]
|
|
@@ -1009,6 +1012,9 @@
|
|
|
1009
1012
|
],
|
|
1010
1013
|
"sourcemaps:lexical": [
|
|
1011
1014
|
{
|
|
1015
|
+
"@id": "#49/source-map/lexical/element_1"
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1012
1018
|
"@id": "#49/source-map/lexical/element_0"
|
|
1013
1019
|
}
|
|
1014
1020
|
]
|
|
@@ -1188,6 +1194,11 @@
|
|
|
1188
1194
|
]
|
|
1189
1195
|
},
|
|
1190
1196
|
{
|
|
1197
|
+
"@id": "#34/source-map/lexical/element_1",
|
|
1198
|
+
"sourcemaps:element": "amf://id#34",
|
|
1199
|
+
"sourcemaps:value": "[(17,6)-(25,0)]"
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1191
1202
|
"@id": "#34/source-map/lexical/element_0",
|
|
1192
1203
|
"sourcemaps:element": "apiContract:parameter",
|
|
1193
1204
|
"sourcemaps:value": "[(17,6)-(25,0)]"
|
|
@@ -1487,6 +1498,11 @@
|
|
|
1487
1498
|
]
|
|
1488
1499
|
},
|
|
1489
1500
|
{
|
|
1501
|
+
"@id": "#49/source-map/lexical/element_1",
|
|
1502
|
+
"sourcemaps:element": "amf://id#49",
|
|
1503
|
+
"sourcemaps:value": "[(63,6)-(70,0)]"
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1490
1506
|
"@id": "#49/source-map/lexical/element_0",
|
|
1491
1507
|
"sourcemaps:element": "apiContract:uriParameter",
|
|
1492
1508
|
"sourcemaps:value": "[(63,6)-(70,0)]"
|
|
@@ -4447,6 +4447,11 @@
|
|
|
4447
4447
|
{
|
|
4448
4448
|
"@id": "#547"
|
|
4449
4449
|
}
|
|
4450
|
+
],
|
|
4451
|
+
"sourcemaps:sources": [
|
|
4452
|
+
{
|
|
4453
|
+
"@id": "#546/source-map"
|
|
4454
|
+
}
|
|
4450
4455
|
]
|
|
4451
4456
|
},
|
|
4452
4457
|
{
|
|
@@ -5259,6 +5264,9 @@
|
|
|
5259
5264
|
],
|
|
5260
5265
|
"sourcemaps:lexical": [
|
|
5261
5266
|
{
|
|
5267
|
+
"@id": "#295/source-map/lexical/element_1"
|
|
5268
|
+
},
|
|
5269
|
+
{
|
|
5262
5270
|
"@id": "#295/source-map/lexical/element_0"
|
|
5263
5271
|
}
|
|
5264
5272
|
]
|
|
@@ -5442,6 +5450,9 @@
|
|
|
5442
5450
|
],
|
|
5443
5451
|
"sourcemaps:lexical": [
|
|
5444
5452
|
{
|
|
5453
|
+
"@id": "#319/source-map/lexical/element_1"
|
|
5454
|
+
},
|
|
5455
|
+
{
|
|
5445
5456
|
"@id": "#319/source-map/lexical/element_0"
|
|
5446
5457
|
}
|
|
5447
5458
|
]
|
|
@@ -5623,6 +5634,9 @@
|
|
|
5623
5634
|
],
|
|
5624
5635
|
"sourcemaps:lexical": [
|
|
5625
5636
|
{
|
|
5637
|
+
"@id": "#337/source-map/lexical/element_1"
|
|
5638
|
+
},
|
|
5639
|
+
{
|
|
5626
5640
|
"@id": "#337/source-map/lexical/element_0"
|
|
5627
5641
|
}
|
|
5628
5642
|
]
|
|
@@ -5948,13 +5962,16 @@
|
|
|
5948
5962
|
],
|
|
5949
5963
|
"sourcemaps:lexical": [
|
|
5950
5964
|
{
|
|
5951
|
-
"@id": "#351/source-map/lexical/
|
|
5965
|
+
"@id": "#351/source-map/lexical/element_3"
|
|
5966
|
+
},
|
|
5967
|
+
{
|
|
5968
|
+
"@id": "#351/source-map/lexical/element_1"
|
|
5952
5969
|
},
|
|
5953
5970
|
{
|
|
5954
5971
|
"@id": "#351/source-map/lexical/element_0"
|
|
5955
5972
|
},
|
|
5956
5973
|
{
|
|
5957
|
-
"@id": "#351/source-map/lexical/
|
|
5974
|
+
"@id": "#351/source-map/lexical/element_2"
|
|
5958
5975
|
}
|
|
5959
5976
|
]
|
|
5960
5977
|
},
|
|
@@ -6104,10 +6121,13 @@
|
|
|
6104
6121
|
],
|
|
6105
6122
|
"sourcemaps:lexical": [
|
|
6106
6123
|
{
|
|
6107
|
-
"@id": "#378/source-map/lexical/
|
|
6124
|
+
"@id": "#378/source-map/lexical/element_2"
|
|
6108
6125
|
},
|
|
6109
6126
|
{
|
|
6110
6127
|
"@id": "#378/source-map/lexical/element_0"
|
|
6128
|
+
},
|
|
6129
|
+
{
|
|
6130
|
+
"@id": "#378/source-map/lexical/element_1"
|
|
6111
6131
|
}
|
|
6112
6132
|
]
|
|
6113
6133
|
},
|
|
@@ -6921,6 +6941,9 @@
|
|
|
6921
6941
|
],
|
|
6922
6942
|
"sourcemaps:lexical": [
|
|
6923
6943
|
{
|
|
6944
|
+
"@id": "#456/source-map/lexical/element_1"
|
|
6945
|
+
},
|
|
6946
|
+
{
|
|
6924
6947
|
"@id": "#456/source-map/lexical/element_0"
|
|
6925
6948
|
}
|
|
6926
6949
|
]
|
|
@@ -7108,6 +7131,9 @@
|
|
|
7108
7131
|
],
|
|
7109
7132
|
"sourcemaps:lexical": [
|
|
7110
7133
|
{
|
|
7134
|
+
"@id": "#466/source-map/lexical/element_1"
|
|
7135
|
+
},
|
|
7136
|
+
{
|
|
7111
7137
|
"@id": "#466/source-map/lexical/element_0"
|
|
7112
7138
|
}
|
|
7113
7139
|
]
|
|
@@ -7655,6 +7681,9 @@
|
|
|
7655
7681
|
],
|
|
7656
7682
|
"sourcemaps:lexical": [
|
|
7657
7683
|
{
|
|
7684
|
+
"@id": "#509/source-map/lexical/element_1"
|
|
7685
|
+
},
|
|
7686
|
+
{
|
|
7658
7687
|
"@id": "#509/source-map/lexical/element_0"
|
|
7659
7688
|
}
|
|
7660
7689
|
]
|
|
@@ -8243,6 +8272,17 @@
|
|
|
8243
8272
|
]
|
|
8244
8273
|
},
|
|
8245
8274
|
{
|
|
8275
|
+
"@id": "#546/source-map",
|
|
8276
|
+
"@type": [
|
|
8277
|
+
"sourcemaps:SourceMap"
|
|
8278
|
+
],
|
|
8279
|
+
"sourcemaps:lexical": [
|
|
8280
|
+
{
|
|
8281
|
+
"@id": "#546/source-map/lexical/element_0"
|
|
8282
|
+
}
|
|
8283
|
+
]
|
|
8284
|
+
},
|
|
8285
|
+
{
|
|
8246
8286
|
"@id": "#544/source-map",
|
|
8247
8287
|
"@type": [
|
|
8248
8288
|
"sourcemaps:SourceMap"
|
|
@@ -9027,6 +9067,11 @@
|
|
|
9027
9067
|
]
|
|
9028
9068
|
},
|
|
9029
9069
|
{
|
|
9070
|
+
"@id": "#295/source-map/lexical/element_1",
|
|
9071
|
+
"sourcemaps:element": "amf://id#295",
|
|
9072
|
+
"sourcemaps:value": "[(121,6)-(135,0)]"
|
|
9073
|
+
},
|
|
9074
|
+
{
|
|
9030
9075
|
"@id": "#295/source-map/lexical/element_0",
|
|
9031
9076
|
"sourcemaps:element": "apiContract:parameter",
|
|
9032
9077
|
"sourcemaps:value": "[(121,6)-(135,0)]"
|
|
@@ -9234,6 +9279,11 @@
|
|
|
9234
9279
|
]
|
|
9235
9280
|
},
|
|
9236
9281
|
{
|
|
9282
|
+
"@id": "#319/source-map/lexical/element_1",
|
|
9283
|
+
"sourcemaps:element": "amf://id#319",
|
|
9284
|
+
"sourcemaps:value": "[(164,6)-(174,0)]"
|
|
9285
|
+
},
|
|
9286
|
+
{
|
|
9237
9287
|
"@id": "#319/source-map/lexical/element_0",
|
|
9238
9288
|
"sourcemaps:element": "apiContract:parameter",
|
|
9239
9289
|
"sourcemaps:value": "[(164,6)-(174,0)]"
|
|
@@ -9444,6 +9494,11 @@
|
|
|
9444
9494
|
]
|
|
9445
9495
|
},
|
|
9446
9496
|
{
|
|
9497
|
+
"@id": "#337/source-map/lexical/element_1",
|
|
9498
|
+
"sourcemaps:element": "amf://id#337",
|
|
9499
|
+
"sourcemaps:value": "[(201,6)-(209,0)]"
|
|
9500
|
+
},
|
|
9501
|
+
{
|
|
9447
9502
|
"@id": "#337/source-map/lexical/element_0",
|
|
9448
9503
|
"sourcemaps:element": "apiContract:uriParameter",
|
|
9449
9504
|
"sourcemaps:value": "[(201,6)-(209,0)]"
|
|
@@ -9901,18 +9956,23 @@
|
|
|
9901
9956
|
]
|
|
9902
9957
|
},
|
|
9903
9958
|
{
|
|
9904
|
-
"@id": "#351/source-map/lexical/
|
|
9959
|
+
"@id": "#351/source-map/lexical/element_3",
|
|
9905
9960
|
"sourcemaps:element": "apiContract:uriParameter",
|
|
9906
9961
|
"sourcemaps:value": "[(234,6)-(275,0)]"
|
|
9907
9962
|
},
|
|
9908
9963
|
{
|
|
9964
|
+
"@id": "#351/source-map/lexical/element_1",
|
|
9965
|
+
"sourcemaps:element": "apiContract:parameter",
|
|
9966
|
+
"sourcemaps:value": "[(234,6)-(275,0)]"
|
|
9967
|
+
},
|
|
9968
|
+
{
|
|
9909
9969
|
"@id": "#351/source-map/lexical/element_0",
|
|
9910
9970
|
"sourcemaps:element": "apiContract:cookieParameter",
|
|
9911
9971
|
"sourcemaps:value": "[(234,6)-(275,0)]"
|
|
9912
9972
|
},
|
|
9913
9973
|
{
|
|
9914
|
-
"@id": "#351/source-map/lexical/
|
|
9915
|
-
"sourcemaps:element": "
|
|
9974
|
+
"@id": "#351/source-map/lexical/element_2",
|
|
9975
|
+
"sourcemaps:element": "amf://id#351",
|
|
9916
9976
|
"sourcemaps:value": "[(234,6)-(275,0)]"
|
|
9917
9977
|
},
|
|
9918
9978
|
{
|
|
@@ -10087,7 +10147,7 @@
|
|
|
10087
10147
|
]
|
|
10088
10148
|
},
|
|
10089
10149
|
{
|
|
10090
|
-
"@id": "#378/source-map/lexical/
|
|
10150
|
+
"@id": "#378/source-map/lexical/element_2",
|
|
10091
10151
|
"sourcemaps:element": "apiContract:uriParameter",
|
|
10092
10152
|
"sourcemaps:value": "[(288,6)-(302,0)]"
|
|
10093
10153
|
},
|
|
@@ -10097,6 +10157,11 @@
|
|
|
10097
10157
|
"sourcemaps:value": "[(288,6)-(302,0)]"
|
|
10098
10158
|
},
|
|
10099
10159
|
{
|
|
10160
|
+
"@id": "#378/source-map/lexical/element_1",
|
|
10161
|
+
"sourcemaps:element": "amf://id#378",
|
|
10162
|
+
"sourcemaps:value": "[(288,6)-(302,0)]"
|
|
10163
|
+
},
|
|
10164
|
+
{
|
|
10100
10165
|
"@id": "#377/source-map/lexical/element_2",
|
|
10101
10166
|
"sourcemaps:element": "core:name",
|
|
10102
10167
|
"sourcemaps:value": "[(303,8)-(303,13)]"
|
|
@@ -10901,6 +10966,11 @@
|
|
|
10901
10966
|
]
|
|
10902
10967
|
},
|
|
10903
10968
|
{
|
|
10969
|
+
"@id": "#456/source-map/lexical/element_1",
|
|
10970
|
+
"sourcemaps:element": "amf://id#456",
|
|
10971
|
+
"sourcemaps:value": "[(443,6)-(451,0)]"
|
|
10972
|
+
},
|
|
10973
|
+
{
|
|
10904
10974
|
"@id": "#456/source-map/lexical/element_0",
|
|
10905
10975
|
"sourcemaps:element": "apiContract:uriParameter",
|
|
10906
10976
|
"sourcemaps:value": "[(443,6)-(451,0)]"
|
|
@@ -11069,6 +11139,11 @@
|
|
|
11069
11139
|
]
|
|
11070
11140
|
},
|
|
11071
11141
|
{
|
|
11142
|
+
"@id": "#466/source-map/lexical/element_1",
|
|
11143
|
+
"sourcemaps:element": "amf://id#466",
|
|
11144
|
+
"sourcemaps:value": "[(474,6)-(482,0)]"
|
|
11145
|
+
},
|
|
11146
|
+
{
|
|
11072
11147
|
"@id": "#466/source-map/lexical/element_0",
|
|
11073
11148
|
"sourcemaps:element": "apiContract:uriParameter",
|
|
11074
11149
|
"sourcemaps:value": "[(474,6)-(482,0)]"
|
|
@@ -11641,6 +11716,11 @@
|
|
|
11641
11716
|
]
|
|
11642
11717
|
},
|
|
11643
11718
|
{
|
|
11719
|
+
"@id": "#509/source-map/lexical/element_1",
|
|
11720
|
+
"sourcemaps:element": "amf://id#509",
|
|
11721
|
+
"sourcemaps:value": "[(564,6)-(577,0)]"
|
|
11722
|
+
},
|
|
11723
|
+
{
|
|
11644
11724
|
"@id": "#509/source-map/lexical/element_0",
|
|
11645
11725
|
"sourcemaps:element": "apiContract:parameter",
|
|
11646
11726
|
"sourcemaps:value": "[(564,6)-(577,0)]"
|
|
@@ -12256,6 +12336,11 @@
|
|
|
12256
12336
|
]
|
|
12257
12337
|
},
|
|
12258
12338
|
{
|
|
12339
|
+
"@id": "#546/source-map/lexical/element_0",
|
|
12340
|
+
"sourcemaps:element": "amf://id#546",
|
|
12341
|
+
"sourcemaps:value": "[(678,6)-(685,0)]"
|
|
12342
|
+
},
|
|
12343
|
+
{
|
|
12259
12344
|
"@id": "#544/source-map/lexical/element_2",
|
|
12260
12345
|
"sourcemaps:element": "core:name",
|
|
12261
12346
|
"sourcemaps:value": "[(686,8)-(686,13)]"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IThing, Thing } from '../models/Thing.js'
|
|
2
2
|
import v4 from '../lib/uuid.js'
|
|
3
3
|
import { DataEntity, IDataEntity } from './DataEntity.js'
|
|
4
|
-
import { DataNamespace } from './DataNamespace.js'
|
|
4
|
+
import type { DataItemAdaptingOptions, DataNamespace } from './DataNamespace.js'
|
|
5
5
|
import { FileBreadcrumb } from '../models/store/File.js'
|
|
6
6
|
import { DataModelKind } from '../models/kinds.js'
|
|
7
7
|
|
|
@@ -149,6 +149,45 @@ export class DataModel {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Adapts an entity to this data model.
|
|
154
|
+
* The entity must already be added to another data model within this namespace for it to be
|
|
155
|
+
* adapted to this data model.
|
|
156
|
+
* This method is used to change the data model of an entity.
|
|
157
|
+
* It will remove the entity from the previous data model and add it to this one.
|
|
158
|
+
* @param entity The entity to adapt.
|
|
159
|
+
*/
|
|
160
|
+
adaptEntity(entity: DataEntity, opts: DataItemAdaptingOptions = {}): void {
|
|
161
|
+
if (opts.index !== undefined) {
|
|
162
|
+
if (opts.index < 0) {
|
|
163
|
+
throw new Error(`The index ${opts.index} cannot be below 0.`)
|
|
164
|
+
}
|
|
165
|
+
if (opts.index >= this.entities.length) {
|
|
166
|
+
throw new Error(`The index ${opts.index} is not valid.`)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (entity.root !== this.root) {
|
|
170
|
+
throw new Error(`The entity ${entity.key} is not in the same namespace as this data model.`)
|
|
171
|
+
}
|
|
172
|
+
if (entity.getParent() === this) {
|
|
173
|
+
throw new Error(`The entity ${entity.key} is already adapted by this data model.`)
|
|
174
|
+
}
|
|
175
|
+
const parent = entity.getParent()
|
|
176
|
+
if (!parent) {
|
|
177
|
+
throw new Error(`The entity ${entity.key} has no parent.`)
|
|
178
|
+
}
|
|
179
|
+
const index = parent.entities.findIndex((i) => i.key === entity.key)
|
|
180
|
+
if (index < 0) {
|
|
181
|
+
throw new Error(`The entity ${entity.key} is not in the parent data model.`)
|
|
182
|
+
}
|
|
183
|
+
parent.entities.splice(index, 1)
|
|
184
|
+
if (opts.index !== undefined) {
|
|
185
|
+
this.entities.splice(opts.index, 0, entity)
|
|
186
|
+
} else {
|
|
187
|
+
this.entities.push(entity)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
152
191
|
/**
|
|
153
192
|
* Adds an entity to this data model.
|
|
154
193
|
*
|
|
@@ -9,6 +9,13 @@ import v4 from '../lib/uuid.js'
|
|
|
9
9
|
|
|
10
10
|
type ItemKind = typeof DataNamespaceKind | typeof DataModelKind
|
|
11
11
|
|
|
12
|
+
export interface DataItemAdaptingOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The index at which to adapt the item.
|
|
15
|
+
*/
|
|
16
|
+
index?: number
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
interface IDataDefinitions {
|
|
13
20
|
models?: IDataModel[]
|
|
14
21
|
entities?: IDataEntity[]
|
|
@@ -494,6 +501,55 @@ export class DataNamespace extends DataNamespaceParent {
|
|
|
494
501
|
return definition
|
|
495
502
|
}
|
|
496
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Adapts an existing namespace to this namespace.
|
|
506
|
+
* This will remove the namespace from the parent namespace and add it to this one.
|
|
507
|
+
*
|
|
508
|
+
* @param ns The namespace to adapt.
|
|
509
|
+
* @param opts Adapting options.
|
|
510
|
+
*/
|
|
511
|
+
adaptNamespace(ns: DataNamespace, opts: DataItemAdaptingOptions = {}): void {
|
|
512
|
+
if (opts.index !== undefined) {
|
|
513
|
+
if (opts.index < 0) {
|
|
514
|
+
throw new Error(`The index ${opts.index} cannot be below 0.`)
|
|
515
|
+
}
|
|
516
|
+
if (opts.index >= this.items.length) {
|
|
517
|
+
throw new Error(`The index ${opts.index} is not valid.`)
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (ns === this) {
|
|
521
|
+
throw new Error(`Unable to adapt a namespace that is self.`)
|
|
522
|
+
}
|
|
523
|
+
if (ns.root !== this.root) {
|
|
524
|
+
throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`)
|
|
525
|
+
}
|
|
526
|
+
if (ns.getParent() === this) {
|
|
527
|
+
throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`)
|
|
528
|
+
}
|
|
529
|
+
// Check for circular dependency
|
|
530
|
+
let current: DataNamespace | undefined = this
|
|
531
|
+
while (current) {
|
|
532
|
+
if (current === ns) {
|
|
533
|
+
throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`)
|
|
534
|
+
}
|
|
535
|
+
current = current.getParent()
|
|
536
|
+
}
|
|
537
|
+
const parent = ns.getParent() || this.root
|
|
538
|
+
if (!parent) {
|
|
539
|
+
throw new Error(`The namespace ${ns.key} has no parent.`)
|
|
540
|
+
}
|
|
541
|
+
const index = parent.items.findIndex((i) => i.key === ns.key)
|
|
542
|
+
if (index < 0) {
|
|
543
|
+
throw new Error(`The namespace ${ns.key} is not in the parent data namespace.`)
|
|
544
|
+
}
|
|
545
|
+
const [item] = parent.items.splice(index, 1)
|
|
546
|
+
if (opts.index !== undefined) {
|
|
547
|
+
this.items.splice(opts.index, 0, item)
|
|
548
|
+
} else {
|
|
549
|
+
this.items.push(item)
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
497
553
|
/**
|
|
498
554
|
* Finds a namespace in the definitions.
|
|
499
555
|
* @param key The key of the namespace to find.
|
|
@@ -285,3 +285,57 @@ test.group('breadcrumbs()', (group) => {
|
|
|
285
285
|
assert.equal(result[3].key, m1.key, 'has self last')
|
|
286
286
|
})
|
|
287
287
|
})
|
|
288
|
+
|
|
289
|
+
test.group('adaptEntity()', (group) => {
|
|
290
|
+
let root: DataNamespace
|
|
291
|
+
let dm1: DataModel
|
|
292
|
+
let dm2: DataModel
|
|
293
|
+
let e1: DataEntity
|
|
294
|
+
let e2: DataEntity
|
|
295
|
+
|
|
296
|
+
group.each.setup(() => {
|
|
297
|
+
root = new DataNamespace()
|
|
298
|
+
dm1 = root.addNamespace('dm1').addDataModel('Data Model 1')
|
|
299
|
+
dm2 = root.addNamespace('dm2').addDataModel('Data Model 2')
|
|
300
|
+
e1 = dm1.addEntity('Entity 1')
|
|
301
|
+
e2 = dm1.addEntity('Entity 2')
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
test('moves an entity to a new data model', ({ assert }) => {
|
|
305
|
+
dm2.adaptEntity(e1)
|
|
306
|
+
assert.deepEqual(dm1.entities, [e2], 'removes from the old data model')
|
|
307
|
+
assert.deepEqual(dm2.entities, [e1], 'adds to the new data model')
|
|
308
|
+
assert.deepEqual(root.definitions.entities, [e1, e2], 'keeps the entity in the root definitions')
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
test('moves an entity to a new index', ({ assert }) => {
|
|
312
|
+
const e3 = dm2.addEntity('Entity 3')
|
|
313
|
+
dm2.adaptEntity(e1, { index: 0 })
|
|
314
|
+
assert.deepEqual(dm1.entities, [e2], 'removes from the old data model')
|
|
315
|
+
assert.deepEqual(dm2.entities, [e1, e3], 'adds to the new data model')
|
|
316
|
+
assert.deepEqual(root.definitions.entities, [e1, e2, e3], 'keeps the entity in the root definitions')
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
test('throws when adapting an entity from another root', ({ assert }) => {
|
|
320
|
+
const otherRoot = new DataNamespace()
|
|
321
|
+
const otherDm = otherRoot.addNamespace('other').addDataModel('Other Data Model')
|
|
322
|
+
const otherEntity = otherDm.addEntity('Other Entity')
|
|
323
|
+
assert.throws(
|
|
324
|
+
() => dm1.adaptEntity(otherEntity),
|
|
325
|
+
`The entity ${otherEntity.key} is not in the same namespace as this data model.`
|
|
326
|
+
)
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
test('throws when adapting an entity that is already adapted', ({ assert }) => {
|
|
330
|
+
dm2.adaptEntity(e1)
|
|
331
|
+
assert.throws(() => dm2.adaptEntity(e1), `The entity ${e1.key} is already adapted by this data model.`)
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
test('throws when index is out of range (minimum)', ({ assert }) => {
|
|
335
|
+
assert.throws(() => dm2.adaptEntity(e1, { index: -1 }), `The index -1 cannot be below 0.`)
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
test('throws when index is out of range (maximum)', ({ assert }) => {
|
|
339
|
+
assert.throws(() => dm2.adaptEntity(e1, { index: 1 }), `The index 1 is not valid.`)
|
|
340
|
+
})
|
|
341
|
+
})
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { test } from '@japa/runner'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DataEntity,
|
|
4
|
+
DataItem,
|
|
5
|
+
DataModel,
|
|
6
|
+
DataNamespace,
|
|
7
|
+
DataNamespaceKind,
|
|
8
|
+
IDataNamespace,
|
|
9
|
+
Thing,
|
|
10
|
+
} from '../../../src/index.js'
|
|
3
11
|
|
|
4
12
|
test.group('constructor() defaults', () => {
|
|
5
13
|
test('sets the kind', ({ assert }) => {
|
|
@@ -1066,3 +1074,132 @@ test.group('isRoot()', (group) => {
|
|
|
1066
1074
|
assert.isFalse(result)
|
|
1067
1075
|
})
|
|
1068
1076
|
})
|
|
1077
|
+
|
|
1078
|
+
test.group('adaptNamespace()', (group) => {
|
|
1079
|
+
let root: DataNamespace
|
|
1080
|
+
let n1: DataNamespace
|
|
1081
|
+
let n2: DataNamespace
|
|
1082
|
+
|
|
1083
|
+
group.each.setup(() => {
|
|
1084
|
+
root = new DataNamespace()
|
|
1085
|
+
n1 = root.addNamespace('n1')
|
|
1086
|
+
n2 = root.addNamespace('n2')
|
|
1087
|
+
})
|
|
1088
|
+
|
|
1089
|
+
test('moves a namespace to a new parent', ({ assert }) => {
|
|
1090
|
+
const n3 = n1.addNamespace('n3')
|
|
1091
|
+
n2.adaptNamespace(n3)
|
|
1092
|
+
assert.deepEqual(n1.items, [], 'removes from the old parent')
|
|
1093
|
+
const item = DataItem.dataNamespace(root, n3.key)
|
|
1094
|
+
assert.deepEqual(n2.items, [item], 'adds to the new parent')
|
|
1095
|
+
assert.deepEqual(root.definitions.namespaces, [n1, n2, n3], 'keeps the namespace in the root definitions')
|
|
1096
|
+
})
|
|
1097
|
+
|
|
1098
|
+
test('moves a namespace to a new index', ({ assert }) => {
|
|
1099
|
+
const n3 = n1.addNamespace('n3')
|
|
1100
|
+
const n4 = n1.addNamespace('n4')
|
|
1101
|
+
const n5 = n2.addNamespace('n5')
|
|
1102
|
+
n2.adaptNamespace(n3, { index: 0 })
|
|
1103
|
+
const item3 = DataItem.dataNamespace(root, n3.key)
|
|
1104
|
+
const item4 = DataItem.dataNamespace(root, n4.key)
|
|
1105
|
+
const item5 = DataItem.dataNamespace(root, n5.key)
|
|
1106
|
+
assert.deepEqual(n1.items, [item4], 'removes from the old parent')
|
|
1107
|
+
assert.deepEqual(n2.items, [item3, item5], 'adds to the new parent')
|
|
1108
|
+
assert.deepEqual(root.definitions.namespaces, [n1, n2, n3, n4, n5], 'keeps the namespace in the root definitions')
|
|
1109
|
+
})
|
|
1110
|
+
|
|
1111
|
+
test('throws when adapting self', ({ assert }) => {
|
|
1112
|
+
assert.throws(() => n1.adaptNamespace(n1), 'Unable to adapt a namespace that is self.')
|
|
1113
|
+
})
|
|
1114
|
+
|
|
1115
|
+
test('throws when adapting a namespace from another root', ({ assert }) => {
|
|
1116
|
+
const otherRoot = new DataNamespace()
|
|
1117
|
+
const otherNs = otherRoot.addNamespace('other')
|
|
1118
|
+
assert.throws(
|
|
1119
|
+
() => n1.adaptNamespace(otherNs),
|
|
1120
|
+
`The namespace ${otherNs.key} is not in the same namespace as this data namespace.`
|
|
1121
|
+
)
|
|
1122
|
+
})
|
|
1123
|
+
|
|
1124
|
+
test('throws when adapting a namespace that is already adapted', ({ assert }) => {
|
|
1125
|
+
const n3 = n1.addNamespace('n3')
|
|
1126
|
+
n2.adaptNamespace(n3)
|
|
1127
|
+
assert.throws(() => n2.adaptNamespace(n3), `The namespace ${n3.key} is already adapted by this data namespace.`)
|
|
1128
|
+
})
|
|
1129
|
+
|
|
1130
|
+
test('throws when index is out of range (minimum)', ({ assert }) => {
|
|
1131
|
+
assert.throws(() => n1.adaptNamespace(n2, { index: -1 }), `The index -1 cannot be below 0.`)
|
|
1132
|
+
})
|
|
1133
|
+
|
|
1134
|
+
test('throws when index is out of range (maximum)', ({ assert }) => {
|
|
1135
|
+
assert.throws(() => n1.adaptNamespace(n2, { index: 1 }), `The index 1 is not valid.`)
|
|
1136
|
+
})
|
|
1137
|
+
})
|
|
1138
|
+
|
|
1139
|
+
test.group('adaptNamespace() - Circular Dependency', (group) => {
|
|
1140
|
+
let root: DataNamespace
|
|
1141
|
+
let n1: DataNamespace
|
|
1142
|
+
let n2: DataNamespace
|
|
1143
|
+
let n3: DataNamespace
|
|
1144
|
+
let n4: DataNamespace
|
|
1145
|
+
|
|
1146
|
+
// Root
|
|
1147
|
+
// ├── n1
|
|
1148
|
+
// │ ├── n3
|
|
1149
|
+
// │ │ └── n4
|
|
1150
|
+
// └── n2
|
|
1151
|
+
|
|
1152
|
+
group.each.setup(() => {
|
|
1153
|
+
root = new DataNamespace()
|
|
1154
|
+
n1 = root.addNamespace('n1')
|
|
1155
|
+
n2 = root.addNamespace('n2')
|
|
1156
|
+
n3 = n1.addNamespace('n3')
|
|
1157
|
+
n4 = n3.addNamespace('n4')
|
|
1158
|
+
})
|
|
1159
|
+
|
|
1160
|
+
test('throws when adapting a namespace under itself', ({ assert }) => {
|
|
1161
|
+
assert.throws(() => n1.adaptNamespace(n1), 'Unable to adapt a namespace that is self.')
|
|
1162
|
+
})
|
|
1163
|
+
|
|
1164
|
+
test('throws when adapting a namespace under its child', ({ assert }) => {
|
|
1165
|
+
assert.throws(
|
|
1166
|
+
() => n3.adaptNamespace(n1),
|
|
1167
|
+
`Unable to adapt namespace ${n1.key} under itself or one of its children.`
|
|
1168
|
+
)
|
|
1169
|
+
})
|
|
1170
|
+
|
|
1171
|
+
test('throws when adapting a namespace under its grandchild', ({ assert }) => {
|
|
1172
|
+
assert.throws(
|
|
1173
|
+
() => n4.adaptNamespace(n1),
|
|
1174
|
+
`Unable to adapt namespace ${n1.key} under itself or one of its children.`
|
|
1175
|
+
)
|
|
1176
|
+
})
|
|
1177
|
+
|
|
1178
|
+
test('does not throw when adapting a namespace under its sibling', ({ assert }) => {
|
|
1179
|
+
const n5 = n1.addNamespace('n5')
|
|
1180
|
+
assert.doesNotThrow(() => n2.adaptNamespace(n5))
|
|
1181
|
+
})
|
|
1182
|
+
|
|
1183
|
+
test("does not throw when adapting a namespace under its sibling's child", ({ assert }) => {
|
|
1184
|
+
const n5 = n1.addNamespace('n5')
|
|
1185
|
+
const n6 = n5.addNamespace('n6')
|
|
1186
|
+
assert.doesNotThrow(() => n2.adaptNamespace(n6))
|
|
1187
|
+
})
|
|
1188
|
+
|
|
1189
|
+
test("does not throw when adapting a namespace under its sibling's parent", ({ assert }) => {
|
|
1190
|
+
const n5 = n1.addNamespace('n5')
|
|
1191
|
+
// Root (before)
|
|
1192
|
+
// ├── n1
|
|
1193
|
+
// │ ├── n3
|
|
1194
|
+
// │ │ └── n4
|
|
1195
|
+
// │ └── n5
|
|
1196
|
+
// └── n2
|
|
1197
|
+
// Root (after)
|
|
1198
|
+
// └── n1
|
|
1199
|
+
// ├── n3
|
|
1200
|
+
// │ └── n4
|
|
1201
|
+
// └── n5
|
|
1202
|
+
// └── n2
|
|
1203
|
+
assert.doesNotThrow(() => n5.adaptNamespace(n2))
|
|
1204
|
+
})
|
|
1205
|
+
})
|
package/build/oauth-popup.html
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<title>Oauth2 callback window</title>
|
|
6
|
-
<style>
|
|
7
|
-
*[hidden] {
|
|
8
|
-
display: none;
|
|
9
|
-
}
|
|
10
|
-
</style>
|
|
11
|
-
</head>
|
|
12
|
-
<body>
|
|
13
|
-
<h1>Sending the authorization data to the application</h1>
|
|
14
|
-
<p id="general-error" hidden>
|
|
15
|
-
The window wasn't opened as a popup and therefore it can't pass the authorization information.<br />
|
|
16
|
-
This is an error.
|
|
17
|
-
</p>
|
|
18
|
-
<script>
|
|
19
|
-
const messageTarget = window.opener || window.parent || window.top
|
|
20
|
-
if (!messageTarget || messageTarget === window || !messageTarget.postMessage) {
|
|
21
|
-
const elm = document.getElementById('general-error')
|
|
22
|
-
elm.removeAttribute('hidden')
|
|
23
|
-
} else {
|
|
24
|
-
const search = window.location.search.substr(1)
|
|
25
|
-
if (search) {
|
|
26
|
-
messageTarget.postMessage(search, '*')
|
|
27
|
-
} else {
|
|
28
|
-
messageTarget.postMessage(window.location.hash.substr(1), '*')
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
</script>
|
|
32
|
-
</body>
|
|
33
|
-
</html>
|