@api-client/core 0.18.17 → 0.18.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/build/src/{modeling → decorators}/observed.d.ts +3 -3
  2. package/build/src/decorators/observed.d.ts.map +1 -0
  3. package/build/src/{modeling → decorators}/observed.js +4 -4
  4. package/build/src/decorators/observed.js.map +1 -0
  5. package/build/src/modeling/ApiModel.js +1 -1
  6. package/build/src/modeling/ApiModel.js.map +1 -1
  7. package/build/src/modeling/DataDomain.d.ts +35 -1
  8. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  9. package/build/src/modeling/DataDomain.js +120 -0
  10. package/build/src/modeling/DataDomain.js.map +1 -1
  11. package/build/src/modeling/DomainAssociation.d.ts +7 -0
  12. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  13. package/build/src/modeling/DomainAssociation.js +44 -1
  14. package/build/src/modeling/DomainAssociation.js.map +1 -1
  15. package/build/src/modeling/DomainEntity.d.ts +6 -0
  16. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  17. package/build/src/modeling/DomainEntity.js +21 -1
  18. package/build/src/modeling/DomainEntity.js.map +1 -1
  19. package/build/src/modeling/DomainModel.js +1 -1
  20. package/build/src/modeling/DomainModel.js.map +1 -1
  21. package/build/src/modeling/DomainNamespace.js +1 -1
  22. package/build/src/modeling/DomainNamespace.js.map +1 -1
  23. package/build/src/modeling/DomainProperty.d.ts +15 -0
  24. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  25. package/build/src/modeling/DomainProperty.js +64 -3
  26. package/build/src/modeling/DomainProperty.js.map +1 -1
  27. package/build/src/modeling/DomainSerialization.d.ts.map +1 -1
  28. package/build/src/modeling/DomainSerialization.js +2 -2
  29. package/build/src/modeling/DomainSerialization.js.map +1 -1
  30. package/build/src/modeling/definitions/SKU.d.ts.map +1 -1
  31. package/build/src/modeling/definitions/SKU.js +2 -0
  32. package/build/src/modeling/definitions/SKU.js.map +1 -1
  33. package/build/src/modeling/helpers/Intelisense.d.ts +472 -0
  34. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -0
  35. package/build/src/modeling/helpers/Intelisense.js +1200 -0
  36. package/build/src/modeling/helpers/Intelisense.js.map +1 -0
  37. package/build/src/modeling/templates/blog-domain.d.ts +40 -0
  38. package/build/src/modeling/templates/blog-domain.d.ts.map +1 -0
  39. package/build/src/modeling/templates/blog-domain.js +621 -0
  40. package/build/src/modeling/templates/blog-domain.js.map +1 -0
  41. package/build/src/modeling/templates/ecommerce-domain.d.ts +39 -0
  42. package/build/src/modeling/templates/ecommerce-domain.d.ts.map +1 -0
  43. package/build/src/modeling/templates/ecommerce-domain.js +663 -0
  44. package/build/src/modeling/templates/ecommerce-domain.js.map +1 -0
  45. package/build/src/modeling/types.d.ts +49 -0
  46. package/build/src/modeling/types.d.ts.map +1 -1
  47. package/build/src/modeling/types.js.map +1 -1
  48. package/build/src/models/Thing.js +1 -1
  49. package/build/src/models/Thing.js.map +1 -1
  50. package/build/tsconfig.tsbuildinfo +1 -1
  51. package/data/models/example-generator-api.json +6 -6
  52. package/package.json +2 -1
  53. package/src/{modeling → decorators}/observed.ts +5 -5
  54. package/src/modeling/ApiModel.ts +1 -1
  55. package/src/modeling/DataDomain.ts +144 -0
  56. package/src/modeling/DomainAssociation.ts +51 -1
  57. package/src/modeling/DomainEntity.ts +24 -1
  58. package/src/modeling/DomainModel.ts +1 -1
  59. package/src/modeling/DomainNamespace.ts +1 -1
  60. package/src/modeling/DomainProperty.ts +66 -1
  61. package/src/modeling/DomainSerialization.ts +2 -4
  62. package/src/modeling/definitions/SKU.ts +2 -0
  63. package/src/modeling/helpers/Intelisense.ts +1345 -0
  64. package/src/modeling/templates/blog-domain.ts +787 -0
  65. package/src/modeling/templates/ecommerce-domain.ts +834 -0
  66. package/src/modeling/types.ts +63 -0
  67. package/src/models/Thing.ts +1 -1
  68. package/tests/unit/decorators/observed.spec.ts +527 -0
  69. package/tests/unit/modeling/DataDomain.search.spec.ts +188 -0
  70. package/tests/unit/modeling/data_domain_serialization.spec.ts +6 -2
  71. package/tests/unit/modeling/domain_asociation.spec.ts +376 -0
  72. package/tests/unit/modeling/domain_entity.spec.ts +147 -0
  73. package/tests/unit/modeling/domain_property.spec.ts +273 -0
  74. package/build/src/modeling/observed.d.ts.map +0 -1
  75. package/build/src/modeling/observed.js.map +0 -1
@@ -3,7 +3,7 @@ import { DomainPropertyKind } from '../models/kinds.js';
3
3
  import { DomainElement } from './DomainElement.js';
4
4
  import { nanoid } from '../nanoid.js';
5
5
  import { Thing } from '../models/Thing.js';
6
- import { observed, retargetChange, toRaw } from './observed.js';
6
+ import { observed, retargetChange, toRaw } from '../decorators/observed.js';
7
7
  import { BinaryFormats, DomainPropertyAttributes, DomainPropertyList, DomainPropertyTypes, NumberFormats, } from './DataFormat.js';
8
8
  import { ShapeGenerator } from './amf/ShapeGenerator.js';
9
9
  import { DataSemantics, isPropertySemantic } from './Semantics.js';
@@ -64,6 +64,9 @@ let DomainProperty = (() => {
64
64
  let _primary_decorators;
65
65
  let _primary_initializers = [];
66
66
  let _primary_extraInitializers = [];
67
+ let _unique_decorators;
68
+ let _unique_initializers = [];
69
+ let _unique_extraInitializers = [];
67
70
  let _index_decorators;
68
71
  let _index_initializers = [];
69
72
  let _index_extraInitializers = [];
@@ -98,6 +101,7 @@ let DomainProperty = (() => {
98
101
  _required_decorators = [observed()];
99
102
  _multiple_decorators = [observed()];
100
103
  _primary_decorators = [observed()];
104
+ _unique_decorators = [observed()];
101
105
  _index_decorators = [observed()];
102
106
  _readOnly_decorators = [observed()];
103
107
  _writeOnly_decorators = [observed()];
@@ -111,6 +115,7 @@ let DomainProperty = (() => {
111
115
  __esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
112
116
  __esDecorate(this, null, _multiple_decorators, { kind: "accessor", name: "multiple", static: false, private: false, access: { has: obj => "multiple" in obj, get: obj => obj.multiple, set: (obj, value) => { obj.multiple = value; } }, metadata: _metadata }, _multiple_initializers, _multiple_extraInitializers);
113
117
  __esDecorate(this, null, _primary_decorators, { kind: "accessor", name: "primary", static: false, private: false, access: { has: obj => "primary" in obj, get: obj => obj.primary, set: (obj, value) => { obj.primary = value; } }, metadata: _metadata }, _primary_initializers, _primary_extraInitializers);
118
+ __esDecorate(this, null, _unique_decorators, { kind: "accessor", name: "unique", static: false, private: false, access: { has: obj => "unique" in obj, get: obj => obj.unique, set: (obj, value) => { obj.unique = value; } }, metadata: _metadata }, _unique_initializers, _unique_extraInitializers);
114
119
  __esDecorate(this, null, _index_decorators, { kind: "accessor", name: "index", static: false, private: false, access: { has: obj => "index" in obj, get: obj => obj.index, set: (obj, value) => { obj.index = value; } }, metadata: _metadata }, _index_initializers, _index_extraInitializers);
115
120
  __esDecorate(this, null, _readOnly_decorators, { kind: "accessor", name: "readOnly", static: false, private: false, access: { has: obj => "readOnly" in obj, get: obj => obj.readOnly, set: (obj, value) => { obj.readOnly = value; } }, metadata: _metadata }, _readOnly_initializers, _readOnly_extraInitializers);
116
121
  __esDecorate(this, null, _writeOnly_decorators, { kind: "accessor", name: "writeOnly", static: false, private: false, access: { has: obj => "writeOnly" in obj, get: obj => obj.writeOnly, set: (obj, value) => { obj.writeOnly = value; } }, metadata: _metadata }, _writeOnly_initializers, _writeOnly_extraInitializers);
@@ -147,7 +152,14 @@ let DomainProperty = (() => {
147
152
  */
148
153
  get primary() { return this.#primary_accessor_storage; }
149
154
  set primary(value) { this.#primary_accessor_storage = value; }
150
- #index_accessor_storage = (__runInitializers(this, _primary_extraInitializers), __runInitializers(this, _index_initializers, void 0));
155
+ #unique_accessor_storage = (__runInitializers(this, _primary_extraInitializers), __runInitializers(this, _unique_initializers, void 0));
156
+ /**
157
+ * Whether this property describes a unique property of the entity.
158
+ * This is used to generate unique constraints in the database.
159
+ */
160
+ get unique() { return this.#unique_accessor_storage; }
161
+ set unique(value) { this.#unique_accessor_storage = value; }
162
+ #index_accessor_storage = (__runInitializers(this, _unique_extraInitializers), __runInitializers(this, _index_initializers, void 0));
151
163
  /**
152
164
  * Whether this property describes an indexed property of the entity.
153
165
  */
@@ -245,7 +257,7 @@ let DomainProperty = (() => {
245
257
  * @returns The data model schema.
246
258
  */
247
259
  static createSchema(input = {}) {
248
- const { key = nanoid(), multiple, required, type = DomainPropertyList.string, index, primary, readOnly, writeOnly, tags, semantics, deprecated, schema, bindings, } = input;
260
+ const { key = nanoid(), multiple, required, type = DomainPropertyList.string, index, primary, unique, readOnly, writeOnly, tags, semantics, deprecated, schema, bindings, } = input;
249
261
  if (typeof type === 'string') {
250
262
  if (!DomainPropertyTypes.includes(type)) {
251
263
  throw new Error(`Invalid data property type ${type}`);
@@ -270,6 +282,9 @@ let DomainProperty = (() => {
270
282
  if (typeof primary === 'boolean') {
271
283
  result.primary = primary;
272
284
  }
285
+ if (typeof unique === 'boolean') {
286
+ result.unique = unique;
287
+ }
273
288
  if (typeof readOnly === 'boolean') {
274
289
  result.readOnly = readOnly;
275
290
  }
@@ -350,6 +365,12 @@ let DomainProperty = (() => {
350
365
  else {
351
366
  this.primary = undefined;
352
367
  }
368
+ if (typeof init.unique === 'boolean') {
369
+ this.unique = init.unique;
370
+ }
371
+ else {
372
+ this.unique = undefined;
373
+ }
353
374
  if (typeof init.readOnly === 'boolean') {
354
375
  this.readOnly = init.readOnly;
355
376
  }
@@ -420,6 +441,9 @@ let DomainProperty = (() => {
420
441
  if (typeof this.primary === 'boolean') {
421
442
  result.primary = this.primary;
422
443
  }
444
+ if (typeof this.unique === 'boolean') {
445
+ result.unique = this.unique;
446
+ }
423
447
  if (typeof this.multiple === 'boolean') {
424
448
  result.multiple = this.multiple;
425
449
  }
@@ -620,6 +644,43 @@ let DomainProperty = (() => {
620
644
  hasSemantic(semanticId) {
621
645
  return this.semantics.some((s) => s.id === semanticId);
622
646
  }
647
+ /**
648
+ * Creates a duplicate of this domain property on the parent entity.
649
+ * It places the duplicate on the parent entity right after the original property.
650
+ */
651
+ duplicate() {
652
+ const parent = this.getParentInstance();
653
+ if (!parent) {
654
+ throw new Error(`Cannot duplicate property ${this.key} as it has no parent entity.`);
655
+ }
656
+ const originalIndex = parent.fields.findIndex((f) => f.key === this.key);
657
+ if (originalIndex === -1) {
658
+ throw new Error(`Cannot duplicate property ${this.key} as it does not exist on the parent entity fields list.`);
659
+ }
660
+ const baseName = this.info.name || 'field';
661
+ const newName = parent.generateUniqueName(baseName);
662
+ // Making a copy and restoring it through the `addProperty()` method
663
+ // scales better than copying it manually.
664
+ const copy = this.toJSON();
665
+ // Delete properties that should not be copied
666
+ delete copy.key;
667
+ delete copy.primary; // Don't duplicate the primary key
668
+ // Set the new name for the duplicated property
669
+ if (copy.info) {
670
+ copy.info.name = newName;
671
+ }
672
+ else {
673
+ copy.info = { name: newName };
674
+ }
675
+ const result = parent.addProperty(copy);
676
+ // Move the duplicate to be right after the original
677
+ const fromIndex = parent.fields.length - 1;
678
+ const duplicateField = parent.fields[fromIndex];
679
+ parent.fields.splice(fromIndex, 1);
680
+ parent.fields.splice(originalIndex + 1, 0, duplicateField);
681
+ this.domain.notifyChange();
682
+ return result;
683
+ }
623
684
  };
624
685
  })();
625
686
  export { DomainProperty };
@@ -1 +1 @@
1
- {"version":3,"file":"DomainProperty.js","sourceRoot":"","sources":["../../../src/modeling/DomainProperty.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,aAAa,EAA4B,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAEL,aAAa,EAEb,wBA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,IAAI,CAAC,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;gBAC/B,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;YAC5B,CAAC;QACH,CAAC;QAED;;;;WAIG;QACH,WAAW,CAAC,UAAwB;YAClC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAA;QACxD,CAAC;;;SAjeU,cAAc","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainPropertyKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from './observed.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DomainPropertyAttribute,\n DomainPropertyAttributes,\n type DomainPropertyFormat,\n DomainPropertyList,\n type DomainPropertyType,\n DomainPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from './DataFormat.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './Bindings.js'\nimport type { ModelValidationOptions } from '../models/types.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { PropertySchema } from './types.js'\nimport { DataSemantics, isPropertySemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport type { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\n\nexport interface DomainPropertySchema extends DomainElementSchema {\n kind: typeof DomainPropertyKind\n /**\n * The domain property description.\n */\n info: IThing\n /**\n * Wether the data property is required.\n */\n required?: boolean\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n /**\n * The semantics applied to this property.\n * This is a list of applied semantics that can be used to\n * describe the property in more detail.\n */\n semantics?: AppliedDataSemantic[]\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers, but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DomainPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: PropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: PropertyBinding[]\n}\n\n/**\n * Represents a property within a data domain entity.\n *\n * A `DomainProperty` defines a single data element within a\n * `DomainEntity`. It specifies the data type, constraints,\n * and other metadata for a specific piece of information.\n *\n * **Key Features:**\n *\n * - **Data Type:** Defines the type of data the property\n * holds (e.g., string, number, boolean, date).\n * - **Constraints:** Supports defining constraints such as\n * minimum/maximum values, enum values, and default values.\n * - **Bindings:** Allows defining how the property is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Metadata:** Supports metadata such as tags, semantics,\n * read-only/write-only status, and deprecation.\n * - **Schema:** Allows defining a general schema for the\n * property, which is propagated to all bindings.\n *\n * **Usage:**\n *\n * Use the `DomainEntity.addProperty` method to add a new property to an\n * entity. The property can be created using the constructor, but it\n * won't be added to the graph until you call the `addProperty` method.\n *\n * **Example:**\n *\n * ```typescript\n * const entity = domainModel.addEntity({ key: 'user' });\n * const property = entity.addProperty({\n * key: 'name',\n * type: 'string',\n * required: true,\n * schema: {\n * minimum: 3,\n * maximum: 50,\n * },\n * });\n * ```\n */\nexport class DomainProperty extends DomainElement {\n override kind: typeof DomainPropertyKind\n\n /**\n * The description of the domain property.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data property is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data property allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n @observed() accessor primary: boolean | undefined\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n @observed() accessor index: boolean | undefined\n\n /**\n * Whether the property is read only in the schema.\n */\n @observed() accessor readOnly: boolean | undefined\n\n /**\n * Whether the property is write only in the schema.\n */\n @observed() accessor writeOnly: boolean | undefined\n\n /**\n * Whether this property is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Optional general purpose tags for the UI.\n *\n * Note to implementations, use the `addTag()` method as it propagates the \"tag\" value in the namespace.\n * Also, the tags property is excluded from the observer properties.\n * Changes to this property will not notify the observers.\n */\n @observed({ deep: true }) accessor tags: string[] = []\n\n /**\n * Semantics applied to this property.\n */\n @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []\n\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n @observed() accessor type: DomainPropertyType = 'string'\n\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n @observed({ deep: true }) accessor schema: PropertySchema | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: PropertyBinding[] = []\n\n /**\n * Creates a full data model schema with defaults.\n *\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainPropertySchema> = {}): DomainPropertySchema {\n const {\n key = nanoid(),\n multiple,\n required,\n type = DomainPropertyList.string,\n index,\n primary,\n readOnly,\n writeOnly,\n tags,\n semantics,\n deprecated,\n schema,\n bindings,\n } = input\n if (typeof type === 'string') {\n if (!DomainPropertyTypes.includes(type as DomainPropertyType)) {\n throw new Error(`Invalid data property type ${type}`)\n }\n }\n const info = Thing.fromJSON(input.info, { name: 'new_property' }).toJSON()\n const result: DomainPropertySchema = {\n kind: DomainPropertyKind,\n key,\n info,\n type,\n }\n if (typeof multiple === 'boolean') {\n result.multiple = multiple\n }\n if (typeof required === 'boolean') {\n result.required = required\n }\n if (typeof index === 'boolean') {\n result.index = index\n }\n if (typeof primary === 'boolean') {\n result.primary = primary\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n if (Array.isArray(tags)) {\n result.tags = [...tags]\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\n }\n if (schema) {\n result.schema = structuredClone(schema)\n }\n if (Array.isArray(bindings)) {\n result.bindings = bindings.map((i) => structuredClone(i))\n } else {\n result.bindings = []\n }\n return result\n }\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * Creates a new domain property instance.\n * It does not add it to the graph.\n * You need to call the `addProperty` method of the graph or a data model to add it.\n *\n * Domain objects constructors shouldn't be used directly. Use methods\n * provided on the DataDomain class to create new objects.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial domain property schema.\n * @returns Created domain property instance.\n */\n constructor(root: DataDomain, parent: string, input: Partial<DomainPropertySchema> = {}) {\n const init = DomainProperty.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainPropertyKind\n this.info = new Thing(init.info)\n this.type = init.type\n\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n } else {\n this.multiple = undefined\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n } else {\n this.required = undefined\n }\n if (typeof init.index === 'boolean') {\n this.index = init.index\n } else {\n this.index = undefined\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof init.primary === 'boolean') {\n this.primary = init.primary\n } else {\n this.primary = undefined\n }\n if (typeof init.readOnly === 'boolean') {\n this.readOnly = init.readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof init.writeOnly === 'boolean') {\n this.writeOnly = init.writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(init.tags)) {\n this.tags = [...init.tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(init.semantics)) {\n this.semantics = [...init.semantics]\n } else {\n this.semantics = []\n }\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n /**\n * Checks whether the input is a valid definition of a domain property.\n *\n * @param input The input to validate.\n * @param options Validation options.\n * @returns true when the passed input is a valid definition of a domain property.\n */\n static validate(input: unknown, options: ModelValidationOptions = {}): boolean {\n if (!input || (typeof input !== 'object' && input !== null)) {\n return false\n }\n const typed = input as DomainPropertySchema\n if (options.strict && typed.kind !== DomainPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): DomainPropertySchema {\n const result: DomainPropertySchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n type: this.type || DomainPropertyList.string,\n }\n if (typeof this.index === 'boolean') {\n result.index = this.index\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n if (typeof this.primary === 'boolean') {\n result.primary = this.primary\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (typeof this.readOnly === 'boolean') {\n result.readOnly = this.readOnly\n }\n if (typeof this.writeOnly === 'boolean') {\n result.writeOnly = this.writeOnly\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.semantics) && this.semantics.length) {\n result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes this property from the parent entity.\n * It calls the `removeProperty()` method of the parent entity.\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeProperty(this.key)\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Checks whether the passed value is one of the supported data types.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data types.\n */\n static isValidType(value: unknown): value is DomainPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyTypes.includes(value as DomainPropertyType)\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyAttributes.includes(value as DomainPropertyAttribute)\n }\n\n /**\n * Checks whether the passed value of one of the supported `format` values.\n *\n * @param value The value to test\n * @returns `true` when the value is one of the supported `format` values.\n */\n static isValidFormat(value: unknown): value is DomainPropertyFormat {\n if (value === undefined) {\n // It is the valid value.\n return true\n }\n if (typeof value !== 'string') {\n return false\n }\n if (NumberFormats.includes(value as NumberFormat)) {\n return true\n }\n if (BinaryFormats.includes(value as BinaryFormat)) {\n return true\n }\n return false\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): PropertySchema {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): PropertyWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as PropertyBinding\n this.bindings.push(object)\n }\n return object.schema as PropertyWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): PropertyBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as PropertyBinding\n return item?.schema || undefined\n }\n\n /**\n * Creates a Property Shape of AMF.\n *\n * The property itself is auto-generated. If the `schema` is\n * defined then it is used as the `range` of the property.\n * Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this\n * synchronizes changed data properties with the shape\n * definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.property(this)\n }\n\n /**\n * Generates an example value for this property based on its schema and type.\n *\n * This method converts the property to an AMF shape and then generates\n * an example value using the ApiSchemaGenerator. The generated example\n * respects the property's type, constraints, and any defined schema.\n *\n * @param mime The mime type of the example (e.g., 'application/json', 'application/xml').\n * @param opts Optional configuration for example generation.\n * @returns The generated example value.\n * @example\n * ```typescript\n * const example = property.toExample('application/json');\n * console.log(example);\n * ```\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n // TODO: add support for semantic extensions and generate example values based on them.\n const shape = this.toApiShape()\n if (!shape.range) {\n return undefined\n }\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: opts.renderExamples ?? true,\n renderMocked: opts.renderMocked ?? true,\n renderOptional: opts.renderOptional ?? true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n /**\n * Adds or updates a semantic to the property.\n * @param semantic The semantic to add to the property.\n * @throws Error if the semantic is not an property semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isPropertySemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected a property semantic.`)\n }\n const index = this.semantics.findIndex((s) => s.id === semantic.id)\n if (index >= 0) {\n this.semantics[index] = semantic\n } else {\n this.semantics.push(semantic)\n }\n this.domain.notifyChange()\n }\n\n /**\n * Removes a semantic from the property.\n * @param semanticId The ID of the semantic to remove.\n */\n removeSemantic(semanticId: SemanticType): void {\n const index = this.semantics.findIndex((s) => s.id === semanticId)\n if (index >= 0) {\n this.semantics.splice(index, 1)\n this.domain.notifyChange()\n }\n }\n\n /**\n * Checks if the property has a specific semantic.\n * @param semanticId The ID of the semantic to check.\n * @returns True if the semantic is present, false otherwise.\n */\n hasSemantic(semanticId: SemanticType): boolean {\n return this.semantics.some((s) => s.id === semanticId)\n }\n}\n"]}
1
+ {"version":3,"file":"DomainProperty.js","sourceRoot":"","sources":["../../../src/modeling/DomainProperty.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,aAAa,EAA4B,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EAEL,aAAa,EAEb,wBAAwB,EAExB,kBAAkB,EAElB,mBAAmB,EAEnB,aAAa,GACd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAMxD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAA+C,MAAM,gBAAgB,CAAA;AAC/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AA2EjE;;;;;;;;;;;;;;;;;;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GAAG,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;YAEnD,oEAAoE;YACpE,0CAA0C;YAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAmC,CAAA;YAE3D,8CAA8C;YAC9C,OAAO,IAAI,CAAC,GAAG,CAAA;YACf,OAAO,IAAI,CAAC,OAAO,CAAA,CAAC,kCAAkC;YAEtD,+CAA+C;YAC/C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAA;YAC1B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;YAC/B,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;YAEvC,oDAAoD;YACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;YAC1C,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAC/C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;YAClC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,CAAA;YAE1D,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;YAC1B,OAAO,MAAM,CAAA;QACf,CAAC;;;SA7hBU,cAAc","sourcesContent":["import type { DataDomain } from './DataDomain.js'\nimport { DomainPropertyKind } from '../models/kinds.js'\nimport { DomainElement, type DomainElementSchema } from './DomainElement.js'\nimport { nanoid } from '../nanoid.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport { observed, retargetChange, toRaw } from '../decorators/observed.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DomainPropertyAttribute,\n DomainPropertyAttributes,\n type DomainPropertyFormat,\n DomainPropertyList,\n type DomainPropertyType,\n DomainPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from './DataFormat.js'\nimport { ShapeGenerator } from './amf/ShapeGenerator.js'\nimport type { PropertyBinding, PropertyBindings, PropertyWebBindings } from './Bindings.js'\nimport type { ModelValidationOptions } from '../models/types.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport type { PropertySchema } from './types.js'\nimport { DataSemantics, isPropertySemantic, type SemanticType, type AppliedDataSemantic } from './Semantics.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport type { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\n\nexport interface DomainPropertySchema extends DomainElementSchema {\n kind: typeof DomainPropertyKind\n /**\n * The domain property description.\n */\n info: IThing\n /**\n * Wether the data property is required.\n */\n required?: boolean\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n /**\n * Whether this property describes a unique property of the entity.\n * This is used to generate unique constraints in the database.\n */\n unique?: boolean\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n /**\n * The semantics applied to this property.\n * This is a list of applied semantics that can be used to\n * describe the property in more detail.\n */\n semantics?: AppliedDataSemantic[]\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers, but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DomainPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: PropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: PropertyBinding[]\n}\n\n/**\n * Represents a property within a data domain entity.\n *\n * A `DomainProperty` defines a single data element within a\n * `DomainEntity`. It specifies the data type, constraints,\n * and other metadata for a specific piece of information.\n *\n * **Key Features:**\n *\n * - **Data Type:** Defines the type of data the property\n * holds (e.g., string, number, boolean, date).\n * - **Constraints:** Supports defining constraints such as\n * minimum/maximum values, enum values, and default values.\n * - **Bindings:** Allows defining how the property is\n * represented in different formats (e.g., web APIs,\n * protocol buffers).\n * - **Metadata:** Supports metadata such as tags, semantics,\n * read-only/write-only status, and deprecation.\n * - **Schema:** Allows defining a general schema for the\n * property, which is propagated to all bindings.\n *\n * **Usage:**\n *\n * Use the `DomainEntity.addProperty` method to add a new property to an\n * entity. The property can be created using the constructor, but it\n * won't be added to the graph until you call the `addProperty` method.\n *\n * **Example:**\n *\n * ```typescript\n * const entity = domainModel.addEntity({ key: 'user' });\n * const property = entity.addProperty({\n * key: 'name',\n * type: 'string',\n * required: true,\n * schema: {\n * minimum: 3,\n * maximum: 50,\n * },\n * });\n * ```\n */\nexport class DomainProperty extends DomainElement {\n override kind: typeof DomainPropertyKind\n\n /**\n * The description of the domain property.\n */\n @retargetChange() accessor info: Thing\n\n /**\n * Wether the data property is required.\n */\n @observed() accessor required: boolean | undefined\n\n /**\n * Whether the data property allows multiple items.\n */\n @observed() accessor multiple: boolean | undefined\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n @observed() accessor primary: boolean | undefined\n\n /**\n * Whether this property describes a unique property of the entity.\n * This is used to generate unique constraints in the database.\n */\n @observed() accessor unique: boolean | undefined\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n @observed() accessor index: boolean | undefined\n\n /**\n * Whether the property is read only in the schema.\n */\n @observed() accessor readOnly: boolean | undefined\n\n /**\n * Whether the property is write only in the schema.\n */\n @observed() accessor writeOnly: boolean | undefined\n\n /**\n * Whether this property is deprecated.\n */\n @observed() accessor deprecated: boolean | undefined\n\n /**\n * Optional general purpose tags for the UI.\n *\n * Note to implementations, use the `addTag()` method as it propagates the \"tag\" value in the namespace.\n * Also, the tags property is excluded from the observer properties.\n * Changes to this property will not notify the observers.\n */\n @observed({ deep: true }) accessor tags: string[] = []\n\n /**\n * Semantics applied to this property.\n */\n @observed({ deep: true }) accessor semantics: AppliedDataSemantic[] = []\n\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n @observed() accessor type: DomainPropertyType = 'string'\n\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n @observed({ deep: true }) accessor schema: PropertySchema | undefined\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n @observed({ deep: true }) accessor bindings: PropertyBinding[] = []\n\n /**\n * Creates a full data model schema with defaults.\n *\n * @param input The partial data model schema.\n * @returns The data model schema.\n */\n static createSchema(input: Partial<DomainPropertySchema> = {}): DomainPropertySchema {\n const {\n key = nanoid(),\n multiple,\n required,\n type = DomainPropertyList.string,\n index,\n primary,\n unique,\n readOnly,\n writeOnly,\n tags,\n semantics,\n deprecated,\n schema,\n bindings,\n } = input\n if (typeof type === 'string') {\n if (!DomainPropertyTypes.includes(type as DomainPropertyType)) {\n throw new Error(`Invalid data property type ${type}`)\n }\n }\n const info = Thing.fromJSON(input.info, { name: 'new_property' }).toJSON()\n const result: DomainPropertySchema = {\n kind: DomainPropertyKind,\n key,\n info,\n type,\n }\n if (typeof multiple === 'boolean') {\n result.multiple = multiple\n }\n if (typeof required === 'boolean') {\n result.required = required\n }\n if (typeof index === 'boolean') {\n result.index = index\n }\n if (typeof primary === 'boolean') {\n result.primary = primary\n }\n if (typeof unique === 'boolean') {\n result.unique = unique\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n if (typeof deprecated === 'boolean') {\n result.deprecated = deprecated\n }\n if (Array.isArray(tags)) {\n result.tags = [...tags]\n }\n if (Array.isArray(semantics)) {\n result.semantics = [...semantics]\n }\n if (schema) {\n result.schema = structuredClone(schema)\n }\n if (Array.isArray(bindings)) {\n result.bindings = bindings.map((i) => structuredClone(i))\n } else {\n result.bindings = []\n }\n return result\n }\n\n /**\n * The key of the parent entity.\n */\n protected parent: string\n\n /**\n * Creates a new domain property instance.\n * It does not add it to the graph.\n * You need to call the `addProperty` method of the graph or a data model to add it.\n *\n * Domain objects constructors shouldn't be used directly. Use methods\n * provided on the DataDomain class to create new objects.\n *\n * @param root A reference to the root DataDomain instance.\n * @param parent The key of the parent entity.\n * @param input The partial domain property schema.\n * @returns Created domain property instance.\n */\n constructor(root: DataDomain, parent: string, input: Partial<DomainPropertySchema> = {}) {\n const init = DomainProperty.createSchema(input)\n super(root, init.key)\n this.parent = parent\n this.kind = DomainPropertyKind\n this.info = new Thing(init.info)\n this.type = init.type\n\n if (typeof init.multiple === 'boolean') {\n this.multiple = init.multiple\n } else {\n this.multiple = undefined\n }\n if (typeof init.required === 'boolean') {\n this.required = init.required\n } else {\n this.required = undefined\n }\n if (typeof init.index === 'boolean') {\n this.index = init.index\n } else {\n this.index = undefined\n }\n if (typeof init.deprecated === 'boolean') {\n this.deprecated = init.deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof init.primary === 'boolean') {\n this.primary = init.primary\n } else {\n this.primary = undefined\n }\n if (typeof init.unique === 'boolean') {\n this.unique = init.unique\n } else {\n this.unique = undefined\n }\n if (typeof init.readOnly === 'boolean') {\n this.readOnly = init.readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof init.writeOnly === 'boolean') {\n this.writeOnly = init.writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(init.tags)) {\n this.tags = [...init.tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(init.semantics)) {\n this.semantics = [...init.semantics]\n } else {\n this.semantics = []\n }\n if (init.schema) {\n this.schema = structuredClone(init.schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(init.bindings)) {\n this.bindings = init.bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n /**\n * Checks whether the input is a valid definition of a domain property.\n *\n * @param input The input to validate.\n * @param options Validation options.\n * @returns true when the passed input is a valid definition of a domain property.\n */\n static validate(input: unknown, options: ModelValidationOptions = {}): boolean {\n if (!input || (typeof input !== 'object' && input !== null)) {\n return false\n }\n const typed = input as DomainPropertySchema\n if (options.strict && typed.kind !== DomainPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): DomainPropertySchema {\n const result: DomainPropertySchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n type: this.type || DomainPropertyList.string,\n }\n if (typeof this.index === 'boolean') {\n result.index = this.index\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n if (typeof this.primary === 'boolean') {\n result.primary = this.primary\n }\n if (typeof this.unique === 'boolean') {\n result.unique = this.unique\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (typeof this.readOnly === 'boolean') {\n result.readOnly = this.readOnly\n }\n if (typeof this.writeOnly === 'boolean') {\n result.writeOnly = this.writeOnly\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.semantics) && this.semantics.length) {\n result.semantics = toRaw(this, this.semantics)?.map((i) => structuredClone(i))\n }\n if (this.schema) {\n result.schema = structuredClone(toRaw(this, this.schema))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = toRaw(this, this.bindings)?.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes this property from the parent entity.\n * It calls the `removeProperty()` method of the parent entity.\n */\n remove(): void {\n const parent = this.getParentInstance()\n parent?.removeProperty(this.key)\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DomainEntity | undefined {\n return this.root.graph.node(this.parent) as DomainEntity | undefined\n }\n\n /**\n * Checks whether the passed value is one of the supported data types.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data types.\n */\n static isValidType(value: unknown): value is DomainPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyTypes.includes(value as DomainPropertyType)\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DomainPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DomainPropertyAttributes.includes(value as DomainPropertyAttribute)\n }\n\n /**\n * Checks whether the passed value of one of the supported `format` values.\n *\n * @param value The value to test\n * @returns `true` when the value is one of the supported `format` values.\n */\n static isValidFormat(value: unknown): value is DomainPropertyFormat {\n if (value === undefined) {\n // It is the valid value.\n return true\n }\n if (typeof value !== 'string') {\n return false\n }\n if (NumberFormats.includes(value as NumberFormat)) {\n return true\n }\n if (BinaryFormats.includes(value as BinaryFormat)) {\n return true\n }\n return false\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): PropertySchema {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): PropertyWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as PropertyBinding\n this.bindings.push(object)\n }\n return object.schema as PropertyWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): PropertyBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as PropertyBinding\n return item?.schema || undefined\n }\n\n /**\n * Creates a Property Shape of AMF.\n *\n * The property itself is auto-generated. If the `schema` is\n * defined then it is used as the `range` of the property.\n * Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this\n * synchronizes changed data properties with the shape\n * definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new ShapeGenerator()\n return serializer.property(this)\n }\n\n /**\n * Generates an example value for this property based on its schema and type.\n *\n * This method converts the property to an AMF shape and then generates\n * an example value using the ApiSchemaGenerator. The generated example\n * respects the property's type, constraints, and any defined schema.\n *\n * @param mime The mime type of the example (e.g., 'application/json', 'application/xml').\n * @param opts Optional configuration for example generation.\n * @returns The generated example value.\n * @example\n * ```typescript\n * const example = property.toExample('application/json');\n * console.log(example);\n * ```\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n // TODO: add support for semantic extensions and generate example values based on them.\n const shape = this.toApiShape()\n if (!shape.range) {\n return undefined\n }\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: opts.renderExamples ?? true,\n renderMocked: opts.renderMocked ?? true,\n renderOptional: opts.renderOptional ?? true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n /**\n * Adds or updates a semantic to the property.\n * @param semantic The semantic to add to the property.\n * @throws Error if the semantic is not an property semantic.\n */\n addSemantic(semantic: AppliedDataSemantic): void {\n const sem = DataSemantics[semantic.id]\n if (!isPropertySemantic(sem)) {\n throw new Error(`Invalid semantic type: ${semantic.id}. Expected a property semantic.`)\n }\n const index = this.semantics.findIndex((s) => s.id === semantic.id)\n if (index >= 0) {\n this.semantics[index] = semantic\n } else {\n this.semantics.push(semantic)\n }\n this.domain.notifyChange()\n }\n\n /**\n * Removes a semantic from the property.\n * @param semanticId The ID of the semantic to remove.\n */\n removeSemantic(semanticId: SemanticType): void {\n const index = this.semantics.findIndex((s) => s.id === semanticId)\n if (index >= 0) {\n this.semantics.splice(index, 1)\n this.domain.notifyChange()\n }\n }\n\n /**\n * Checks if the property has a specific semantic.\n * @param semanticId The ID of the semantic to check.\n * @returns True if the semantic is present, false otherwise.\n */\n hasSemantic(semanticId: SemanticType): boolean {\n return this.semantics.some((s) => s.id === semanticId)\n }\n\n /**\n * Creates a duplicate of this domain property on the parent entity.\n * It places the duplicate on the parent entity right after the original property.\n */\n duplicate(): DomainProperty {\n const parent = this.getParentInstance()\n if (!parent) {\n throw new Error(`Cannot duplicate property ${this.key} as it has no parent entity.`)\n }\n const originalIndex = parent.fields.findIndex((f) => f.key === this.key)\n if (originalIndex === -1) {\n throw new Error(`Cannot duplicate property ${this.key} as it does not exist on the parent entity fields list.`)\n }\n const baseName = this.info.name || 'field'\n const newName = parent.generateUniqueName(baseName)\n\n // Making a copy and restoring it through the `addProperty()` method\n // scales better than copying it manually.\n const copy = this.toJSON() as Partial<DomainPropertySchema>\n\n // Delete properties that should not be copied\n delete copy.key\n delete copy.primary // Don't duplicate the primary key\n\n // Set the new name for the duplicated property\n if (copy.info) {\n copy.info.name = newName\n } else {\n copy.info = { name: newName }\n }\n const result = parent.addProperty(copy)\n\n // Move the duplicate to be right after the original\n const fromIndex = parent.fields.length - 1\n const duplicateField = parent.fields[fromIndex]\n parent.fields.splice(fromIndex, 1)\n parent.fields.splice(originalIndex + 1, 0, duplicateField)\n\n this.domain.notifyChange()\n return result\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DomainSerialization.d.ts","sourceRoot":"","sources":["../../../src/modeling/DomainSerialization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAGf,eAAe,EAEf,qBAAqB,EAErB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AASnB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAMjD,UAAU,gBAAgB;IACxB;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAA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;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,kBAAuB,GAAG,qBAAqB,CAsNrG"}
@@ -150,8 +150,8 @@ function validateGraphConsistency(g, domainKey) {
150
150
  return edgeData && edgeData.type === 'association';
151
151
  });
152
152
  if (targetEdges.length === 0) {
153
- validationErrors.push(`Association "${association.info.name}" (${nodeId}) has no target entities. ` +
154
- `Associations must reference at least one target entity.`);
153
+ // This is general warning message, do not an error.
154
+ // We can serialize and deserialize associations without targets.
155
155
  }
156
156
  // Validate that all target entities exist
157
157
  for (const targetEdge of targetEdges) {
@@ -1 +1 @@
1
- {"version":3,"file":"DomainSerialization.js","sourceRoot":"","sources":["../../../src/modeling/DomainSerialization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAWxD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAA;AAElF,OAAO,EAAE,WAAW,EAA0B,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,YAAY,EAAsB,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAA;AAanF,SAAS,UAAU,CAAC,CAAkB,EAAE,SAAiB;IACvD,MAAM,MAAM,GAAmB,EAAE,CAAA;IACjC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC3B,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACrD,2BAA2B;YAC3B,SAA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CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;gBAC3H,MAAM,KAAK,GAAyB;oBAClC,IAAI,EAAE,iBAAiB;oBACvB,QAAQ,EAAE,SAAS;oBACnB,OAAO;oBACP,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE;oBACrD,UAAU,EAAE,sBAAsB;iBACnC,CAAA;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA;IAEpE,OAAO;QACL,KAAK,EAAE,CAAC;QACR,MAAM;QACN,OAAO,EAAE,CAAC,SAAS;KACpB,CAAA;AACH,CAAC","sourcesContent":["import type { JsonEdge, Node } from '@api-client/graph/graph/types.js'\nimport { Graph } from '@api-client/graph/graph/Graph.js'\nimport type {\n DataDomainGraph,\n DomainGraphEdge,\n DomainGraphNodeType,\n SerializedGraph,\n DeserializationMode,\n DeserializationResult,\n DeserializationIssue,\n DeserializeOptions,\n} from './types.js'\nimport {\n DomainAssociationKind,\n DomainEntityKind,\n DomainModelKind,\n DomainNamespaceKind,\n DomainPropertyKind,\n} from '../models/kinds.js'\nimport { DomainNamespace, type DomainNamespaceSchema } from './DomainNamespace.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { DomainModel, type DomainModelSchema } from './DomainModel.js'\nimport { DomainEntity, DomainEntitySchema } from './DomainEntity.js'\nimport { DomainProperty, DomainPropertySchema } from './DomainProperty.js'\nimport { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'\n\ninterface GraphMergeResult {\n /**\n * The set of node ids generated for the foreign nodes.\n */\n nodes: Set<string>\n /**\n * The set of edge ids generated for the foreign edges.\n */\n edges: Set<string>\n}\n\nfunction writeNodes(g: DataDomainGraph, domainKey: string): Node<object>[] {\n const result: Node<object>[] = []\n for (const v of g.nodes()) {\n const nodeValue = g.node(v)\n if (!nodeValue || nodeValue.domain.key !== domainKey) {\n // Filter out foreign nodes\n continue\n }\n // We do only use single parent for the graph. Potentially this could be\n // replaced with the `g.parent(v)` method.\n const parents = [...g.parents(v)]\n const node: Node<object> = { v }\n node.value = nodeValue.toJSON()\n if (parents.length) {\n node.parents = parents\n }\n result.push(node)\n }\n return result\n}\n\nfunction writeEdges(g: DataDomainGraph, domainKey: string): JsonEdge<DomainGraphEdge>[] {\n const result: JsonEdge<DomainGraphEdge>[] = []\n for (const e of g.edges()) {\n const edgeValue = g.edge(e)\n if (!edgeValue) {\n continue\n }\n const sourceNode = g.node(e.v)\n const targetNode = g.node(e.w)\n if (!sourceNode || !targetNode) {\n continue\n }\n if (sourceNode.domain.key !== domainKey) {\n // Filter out edges starting from foreign nodes. These are foreign associations\n // that have nothing to do with the current domain.\n continue\n }\n if (targetNode.domain.key !== domainKey && edgeValue.type !== 'association' && edgeValue.type !== 'parent') {\n // Filter out edges to foreign nodes except for associations and parent-child relations\n continue\n }\n const edge: JsonEdge<DomainGraphEdge> = { v: e.v, w: e.w }\n if (e.name) {\n edge.name = e.name\n }\n edge.value = structuredClone(edgeValue)\n result.push(edge)\n }\n return result\n}\n\n/**\n * Validates the graph consistency before serialization.\n * Ensures that all required edges exist for properties and associations.\n * @param g The graph to validate\n * @param domainKey The domain key to validate\n * @throws Error if the graph is inconsistent\n */\nfunction validateGraphConsistency(g: DataDomainGraph, domainKey: string): void {\n const validationErrors: string[] = []\n\n // Get all nodes that belong to this domain\n const domainNodes = new Set<string>()\n for (const nodeId of g.nodes()) {\n const node = g.node(nodeId)\n if (node && node.domain.key === domainKey) {\n domainNodes.add(nodeId)\n }\n }\n\n // Validate that properties and associations have parent edges\n for (const nodeId of domainNodes) {\n const node = g.node(nodeId)\n if (!node) continue\n\n if (node.kind === DomainPropertyKind || node.kind === DomainAssociationKind) {\n // These nodes must have exactly one incoming edge from their parent entity\n const incomingEdges = [...g.inEdges(nodeId)]\n const parentEdges = incomingEdges.filter((edge) => {\n const sourceNode = g.node(edge.v)\n return sourceNode && sourceNode.domain.key === domainKey\n })\n\n if (parentEdges.length === 0) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has no parent entity edge. ` +\n `This will cause deserialization to fail.`\n )\n } else if (parentEdges.length > 1) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n const parentIds = parentEdges.map((e) => e.v).join(', ')\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has multiple parent edges: ${parentIds}. ` +\n `This may cause deserialization issues.`\n )\n } else {\n // Validate that the parent is actually an entity\n const parentEdge = parentEdges[0]\n const parentNode = g.node(parentEdge.v)\n if (!parentNode || parentNode.kind !== DomainEntityKind) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has a parent that is not an entity. ` +\n `Parent: ${parentNode?.kind || 'unknown'} (${parentEdge.v})`\n )\n }\n }\n }\n\n // Validate that entities have model parents\n if (node.kind === DomainEntityKind) {\n const parents = [...g.parents(nodeId)]\n const hasModelParent = parents.some((parentId) => {\n const parent = g.node(parentId)\n return parent && parent.kind === DomainModelKind\n })\n\n if (!hasModelParent) {\n validationErrors.push(\n `Entity \"${node.info.name}\" (${nodeId}) has no model parent. ` + `Entities must belong to a model.`\n )\n }\n }\n\n // Validate that models have either namespace parents or are at root level\n if (node.kind === DomainModelKind) {\n const parents = [...g.parents(nodeId)]\n const hasNamespaceParent = parents.some((parentId) => {\n const parent = g.node(parentId)\n return parent && parent.kind === DomainNamespaceKind\n })\n\n // Models can either be at root level (no parents) or have a namespace parent\n // They should not have other types of parents\n if (parents.length > 0 && !hasNamespaceParent) {\n const invalidParents = parents\n .map((parentId) => {\n const parent = g.node(parentId)\n return `${parent?.kind || 'unknown'} (${parentId})`\n })\n .join(', ')\n validationErrors.push(\n `Model \"${node.info.name}\" (${nodeId}) has invalid parent types: ${invalidParents}. ` +\n `Models can only belong to namespaces or be at root level.`\n )\n }\n }\n }\n\n // Validate association targets exist\n for (const nodeId of domainNodes) {\n const node = g.node(nodeId)\n if (node && node.kind === DomainAssociationKind) {\n const association = node as DomainAssociation\n const outgoingEdges = [...g.outEdges(nodeId)]\n\n // Check that association has target edges\n const targetEdges = outgoingEdges.filter((edge) => {\n const edgeData = g.edge(edge)\n return edgeData && edgeData.type === 'association'\n })\n\n if (targetEdges.length === 0) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) has no target entities. ` +\n `Associations must reference at least one target entity.`\n )\n }\n\n // Validate that all target entities exist\n for (const targetEdge of targetEdges) {\n const targetNode = g.node(targetEdge.w)\n if (!targetNode) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) references non-existent target: ${targetEdge.w}`\n )\n } else if (targetNode.kind !== DomainEntityKind) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) references non-entity target: ` +\n `${targetNode.kind} (${targetEdge.w})`\n )\n }\n }\n }\n }\n\n if (validationErrors.length > 0) {\n throw new Error(\n `Graph consistency validation failed for domain \"${domainKey}\":\\n` +\n validationErrors.map((error) => ` - ${error}`).join('\\n')\n )\n }\n}\n\nexport function serialize(g: DataDomainGraph, domainKey: string): SerializedGraph {\n // Validate graph consistency before serialization\n validateGraphConsistency(g, domainKey)\n\n const json: SerializedGraph = {\n options: {\n directed: g.isDirected(),\n multigraph: g.isMultigraph(),\n compound: g.isCompound(),\n },\n nodes: writeNodes(g, domainKey),\n edges: writeEdges(g, domainKey),\n }\n return json\n}\n\n/**\n * Removes all foreign nodes, edges, and parents from the graph.\n * @param g The graph to remove the foreign nodes from\n * @param domainKey The key of the domain to remove\n */\nexport function removeForeignGraph(g: DataDomainGraph, domainKey: string): void {\n for (const node of g.nodes()) {\n const nodeValue = g.node(node)\n if (!nodeValue) {\n continue\n }\n if (nodeValue.domain.key === domainKey) {\n // This is a foreign node, remove it from the graph.\n g.removeNode(node)\n // When a node is removed, all edges and parents are removed as well.\n // No need to iterate over them.\n }\n }\n}\n\n/**\n * Merges a foreign domain graph into the current domain graph.\n * @param own Our domain graph\n * @param foreign The foreign domain graph\n * @param domain The key of the foreign domain\n */\nexport function mergeGraph(own: DataDomainGraph, foreign: DataDomainGraph, domain: string): GraphMergeResult {\n const nodes = new Set<string>()\n const edges = new Set<string>()\n // Copy nodes\n for (const node of foreign.nodes()) {\n const foreignNode = foreign.node(node)\n if (!foreignNode) {\n continue\n }\n const foreignKey = `${domain}:${node}`\n own.setNode(foreignKey, foreignNode)\n nodes.add(foreignKey)\n }\n // Copy edges\n for (const edge of foreign.edges()) {\n const label = foreign.edge(edge)\n if (!label) {\n continue\n }\n const foreignSource = `${domain}:${edge.v}`\n const foreignTarget = `${domain}:${edge.w}`\n // const foreignEdge = foreign.edge(edge)\n own.setEdge(foreignSource, foreignTarget, {\n foreign: true,\n domain,\n ...label,\n })\n edges.add(`${foreignSource}|${foreignTarget}`)\n }\n const notRootEntities = new Set<string>()\n // Copy parent-child relationships\n for (const node of foreign.nodes()) {\n const foreignNodeKey = `${domain}:${node}`\n for (const parent of foreign.parents(node)) {\n const foreignParentKey = `${domain}:${parent}`\n const srcNode = own.node(foreignNodeKey) as DomainGraphNodeType\n const targetNode = own.node(foreignParentKey) as DomainGraphNodeType\n if (srcNode.kind === DomainEntityKind && targetNode.kind === DomainEntityKind) {\n // entities can have multiple parents between them. We need to respect that.\n if (!notRootEntities.has(foreignNodeKey)) {\n // We use `setParent` in the first run to remove the entity from the root\n // of the graph.\n notRootEntities.add(foreignNodeKey)\n own.setParent(foreignNodeKey, foreignParentKey)\n } else {\n own.addParent(foreignNodeKey, foreignParentKey)\n }\n } else {\n // other nodes can only have a single parent.\n own.setParent(foreignNodeKey, foreignParentKey)\n }\n }\n }\n return {\n nodes,\n edges,\n }\n}\n\n/**\n * Properties and associations are stored as nodes with edges to the parent entity in the graph.\n * At the time of restoring these nodes, the graph has no edges yet.\n * This function finds the parent of the child node in the edges list.\n * @param child The DomainProperty or DomainAssociation key\n * @param edges The list of serialized graph edges\n * @returns The parent key of the child or undefined if not found\n */\nfunction findEdgeParent(child: string, edges: JsonEdge<DomainGraphEdge>[]): string | undefined {\n for (const edge of edges) {\n if (edge.w === child) {\n return edge.v\n }\n }\n return undefined\n}\n\n/**\n * Restores the previously serialized node entry.\n * @param root The DataDomain instance to use as the root for the graph\n * @param entry The node entry to restore\n * @param edges The list of serialized graph edges\n * @param mode The deserialization mode\n * @param issues Array to collect issues in lenient mode\n * @returns The restored node instance or undefined if failed in lenient mode\n * @throws Error if the entry is malformed or the kind is unknown in strict mode\n */\nfunction prepareNode(\n root: DataDomain,\n entry: unknown,\n edges: JsonEdge<DomainGraphEdge>[],\n mode: DeserializationMode,\n issues: DeserializationIssue[]\n): DomainGraphNodeType | undefined {\n if (!entry) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: 'Unable to restore data domain graph. Malformed node entry',\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(issue.message)\n }\n return undefined\n }\n\n const domainElement = entry as { kind?: string; key?: string }\n if (!domainElement.kind) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: 'Unable to restore data domain graph. Node entry missing kind property',\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(issue.message)\n }\n return undefined\n }\n\n try {\n if (domainElement.kind === DomainNamespaceKind) {\n return new DomainNamespace(root, domainElement as DomainNamespaceSchema)\n }\n if (domainElement.kind === DomainModelKind) {\n return new DomainModel(root, domainElement as DomainModelSchema)\n }\n if (domainElement.kind === DomainEntityKind) {\n return new DomainEntity(root, domainElement as DomainEntitySchema)\n }\n if (domainElement.kind === DomainPropertyKind) {\n const typed = domainElement as DomainPropertySchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n const issue: DeserializationIssue = {\n type: 'missing_edge',\n severity: 'error',\n message: `Property \"${typed.info?.name || typed.key}\" has no parent entity edge`,\n affectedKey: typed.key,\n resolution: mode === 'lenient' ? 'Property will be skipped' : undefined,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return undefined\n }\n return new DomainProperty(root, parent, typed)\n }\n if (domainElement.kind === DomainAssociationKind) {\n const typed = domainElement as DomainAssociationSchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n const issue: DeserializationIssue = {\n type: 'missing_edge',\n severity: 'error',\n message: `Association \"${typed.info?.name || typed.key}\" has no parent entity edge`,\n affectedKey: typed.key,\n resolution: mode === 'lenient' ? 'Association will be skipped' : undefined,\n }\n issues.push(issue)\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return undefined\n }\n return new DomainAssociation(root, parent, typed)\n }\n\n const issue: DeserializationIssue = {\n type: 'unknown_kind',\n severity: 'error',\n message: `Unknown node kind: ${domainElement.kind}`,\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Unknown node kind ${domainElement.kind}`)\n }\n return undefined\n } catch (error) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: `Failed to create node: ${error instanceof Error ? error.message : String(error)}`,\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw error\n }\n return undefined\n }\n}\n\n/**\n * To deserialize a graph:\n *\n * - Create a new DataDomain instance\n * - Restore all foreign nodes and edges\n * - Call the deserialize function\n *\n * @param root The DataDomain instance to use as the root for the graph\n * @param json The previously serialized graph\n * @param dependencies An array of foreign data domains to register with this domain\n * @param mode The deserialization mode - 'strict' throws errors, 'lenient' collects issues\n * @returns DeserializationResult with graph, issues, and success status\n * @throws Error in strict mode when any issue is encountered\n */\nexport function deserialize(root: DataDomain, options: DeserializeOptions = {}): DeserializationResult {\n const { json, dependencies, mode = 'strict' } = options\n const g = new Graph<unknown, DomainGraphNodeType, DomainGraphEdge>({\n compound: true,\n multigraph: true,\n directed: true,\n })\n const issues: DeserializationIssue[] = []\n let foreignNodes = new Set<string>()\n let foreignEdges = new Set<string>()\n\n // Process dependencies\n if (dependencies) {\n for (const dependency of dependencies) {\n try {\n const result = mergeGraph(g, dependency.graph, dependency.key)\n if (result.edges.size) {\n foreignEdges = new Set([...foreignEdges, ...result.edges])\n }\n if (result.nodes.size) {\n foreignNodes = new Set([...foreignNodes, ...result.nodes])\n }\n root.dependencies.set(dependency.key, dependency)\n } catch (error) {\n const message = `Failed to merge dependency \"${dependency.key}\": ${error instanceof Error ? error.message : String(error)}`\n\n if (mode === 'strict') {\n throw new Error(message)\n }\n\n const issue: DeserializationIssue = {\n type: 'missing_dependency',\n severity: 'error',\n message,\n affectedKey: dependency.key,\n resolution: 'Dependency will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n\n if (!json) {\n return {\n graph: g,\n issues,\n success: true,\n }\n }\n\n // Process nodes\n if (Array.isArray(json.nodes)) {\n // 1st pass - set up nodes\n const parentInfo = new Map<string, string[]>()\n for (const entry of json.nodes) {\n const node = prepareNode(root, entry.value, json.edges, mode, issues)\n if (node) {\n g.setNode(entry.v, node)\n if (entry.parents) {\n parentInfo.set(entry.v, entry.parents)\n }\n }\n // Note: prepareNode throws in strict mode, so we won't reach here if there's an error\n }\n\n // 2nd pass - set up parents\n for (const [key, parents] of parentInfo) {\n // Verify the node still exists (might have been skipped in lenient mode)\n if (!g.hasNode(key)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Cannot set parents for missing node: ${key}`,\n affectedKey: key,\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n for (const parent of parents) {\n // Verify parent exists\n if (!g.hasNode(parent)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Parent node \"${parent}\" not found for child \"${key}\"`,\n affectedKey: key,\n context: { parentKey: parent },\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n try {\n g.setParent(key, parent)\n } catch (error) {\n const message = `Failed to set parent \"${parent}\" for child \"${key}\": ${error instanceof Error ? error.message : String(error)}`\n const issue: DeserializationIssue = {\n type: 'invalid_parent',\n severity: 'warning',\n message,\n affectedKey: key,\n context: { parentKey: parent },\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n }\n\n // Process edges\n if (Array.isArray(json.edges)) {\n for (const entry of json.edges) {\n if (!entry.value) {\n const message = 'Edge entry missing value'\n\n if (mode === 'strict') {\n throw new Error(message)\n }\n\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message,\n context: { edge: entry },\n }\n issues.push(issue)\n continue\n }\n\n // Handle foreign edges\n if (entry.value.foreign) {\n // The `v` has to be local to the graph. The `w` must be foreign.\n if (!foreignNodes.has(entry.w)) {\n // Note, we don't consider this an error, just a warning.\n // Because of that, we don't throw an error here.\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Missing foreign node: ${entry.w}`,\n affectedKey: entry.w,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n }\n\n // Check if nodes exist for the edge\n if (foreignNodes.has(entry.v) || foreignNodes.has(entry.w)) {\n if (!g.hasNode(entry.v) || !g.hasNode(entry.w)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Missing foreign node for edge: ${entry.v} -> ${entry.w}`,\n context: { sourceNode: entry.v, targetNode: entry.w },\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n } else {\n // Both nodes should be local - verify they exist\n if (!g.hasNode(entry.v)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Source node not found for edge: ${entry.v}`,\n affectedKey: entry.v,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n if (!g.hasNode(entry.w)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Target node not found for edge: ${entry.w}`,\n affectedKey: entry.w,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n }\n\n try {\n g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value)\n } catch (error) {\n const message = `Failed to create edge ${entry.v} -> ${entry.w}: ${error instanceof Error ? error.message : String(error)}`\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'warning',\n message,\n context: { sourceNode: entry.v, targetNode: entry.w },\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n\n const hasErrors = issues.some((issue) => issue.severity === 'error')\n\n return {\n graph: g,\n issues,\n success: !hasErrors,\n }\n}\n"]}
1
+ {"version":3,"file":"DomainSerialization.js","sourceRoot":"","sources":["../../../src/modeling/DomainSerialization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAWxD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAA;AAElF,OAAO,EAAE,WAAW,EAA0B,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,YAAY,EAAsB,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAA;AAanF,SAAS,UAAU,CAAC,CAAkB,EAAE,SAAiB;IACvD,MAAM,MAAM,GAAmB,EAAE,CAAA;IACjC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,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K,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;gBAC3H,MAAM,KAAK,GAAyB;oBAClC,IAAI,EAAE,iBAAiB;oBACvB,QAAQ,EAAE,SAAS;oBACnB,OAAO;oBACP,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE;oBACrD,UAAU,EAAE,sBAAsB;iBACnC,CAAA;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA;IAEpE,OAAO;QACL,KAAK,EAAE,CAAC;QACR,MAAM;QACN,OAAO,EAAE,CAAC,SAAS;KACpB,CAAA;AACH,CAAC","sourcesContent":["import type { JsonEdge, Node } from '@api-client/graph/graph/types.js'\nimport { Graph } from '@api-client/graph/graph/Graph.js'\nimport type {\n DataDomainGraph,\n DomainGraphEdge,\n DomainGraphNodeType,\n SerializedGraph,\n DeserializationMode,\n DeserializationResult,\n DeserializationIssue,\n DeserializeOptions,\n} from './types.js'\nimport {\n DomainAssociationKind,\n DomainEntityKind,\n DomainModelKind,\n DomainNamespaceKind,\n DomainPropertyKind,\n} from '../models/kinds.js'\nimport { DomainNamespace, type DomainNamespaceSchema } from './DomainNamespace.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { DomainModel, type DomainModelSchema } from './DomainModel.js'\nimport { DomainEntity, DomainEntitySchema } from './DomainEntity.js'\nimport { DomainProperty, DomainPropertySchema } from './DomainProperty.js'\nimport { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'\n\ninterface GraphMergeResult {\n /**\n * The set of node ids generated for the foreign nodes.\n */\n nodes: Set<string>\n /**\n * The set of edge ids generated for the foreign edges.\n */\n edges: Set<string>\n}\n\nfunction writeNodes(g: DataDomainGraph, domainKey: string): Node<object>[] {\n const result: Node<object>[] = []\n for (const v of g.nodes()) {\n const nodeValue = g.node(v)\n if (!nodeValue || nodeValue.domain.key !== domainKey) {\n // Filter out foreign nodes\n continue\n }\n // We do only use single parent for the graph. Potentially this could be\n // replaced with the `g.parent(v)` method.\n const parents = [...g.parents(v)]\n const node: Node<object> = { v }\n node.value = nodeValue.toJSON()\n if (parents.length) {\n node.parents = parents\n }\n result.push(node)\n }\n return result\n}\n\nfunction writeEdges(g: DataDomainGraph, domainKey: string): JsonEdge<DomainGraphEdge>[] {\n const result: JsonEdge<DomainGraphEdge>[] = []\n for (const e of g.edges()) {\n const edgeValue = g.edge(e)\n if (!edgeValue) {\n continue\n }\n const sourceNode = g.node(e.v)\n const targetNode = g.node(e.w)\n if (!sourceNode || !targetNode) {\n continue\n }\n if (sourceNode.domain.key !== domainKey) {\n // Filter out edges starting from foreign nodes. These are foreign associations\n // that have nothing to do with the current domain.\n continue\n }\n if (targetNode.domain.key !== domainKey && edgeValue.type !== 'association' && edgeValue.type !== 'parent') {\n // Filter out edges to foreign nodes except for associations and parent-child relations\n continue\n }\n const edge: JsonEdge<DomainGraphEdge> = { v: e.v, w: e.w }\n if (e.name) {\n edge.name = e.name\n }\n edge.value = structuredClone(edgeValue)\n result.push(edge)\n }\n return result\n}\n\n/**\n * Validates the graph consistency before serialization.\n * Ensures that all required edges exist for properties and associations.\n * @param g The graph to validate\n * @param domainKey The domain key to validate\n * @throws Error if the graph is inconsistent\n */\nfunction validateGraphConsistency(g: DataDomainGraph, domainKey: string): void {\n const validationErrors: string[] = []\n\n // Get all nodes that belong to this domain\n const domainNodes = new Set<string>()\n for (const nodeId of g.nodes()) {\n const node = g.node(nodeId)\n if (node && node.domain.key === domainKey) {\n domainNodes.add(nodeId)\n }\n }\n\n // Validate that properties and associations have parent edges\n for (const nodeId of domainNodes) {\n const node = g.node(nodeId)\n if (!node) continue\n\n if (node.kind === DomainPropertyKind || node.kind === DomainAssociationKind) {\n // These nodes must have exactly one incoming edge from their parent entity\n const incomingEdges = [...g.inEdges(nodeId)]\n const parentEdges = incomingEdges.filter((edge) => {\n const sourceNode = g.node(edge.v)\n return sourceNode && sourceNode.domain.key === domainKey\n })\n\n if (parentEdges.length === 0) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has no parent entity edge. ` +\n `This will cause deserialization to fail.`\n )\n } else if (parentEdges.length > 1) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n const parentIds = parentEdges.map((e) => e.v).join(', ')\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has multiple parent edges: ${parentIds}. ` +\n `This may cause deserialization issues.`\n )\n } else {\n // Validate that the parent is actually an entity\n const parentEdge = parentEdges[0]\n const parentNode = g.node(parentEdge.v)\n if (!parentNode || parentNode.kind !== DomainEntityKind) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has a parent that is not an entity. ` +\n `Parent: ${parentNode?.kind || 'unknown'} (${parentEdge.v})`\n )\n }\n }\n }\n\n // Validate that entities have model parents\n if (node.kind === DomainEntityKind) {\n const parents = [...g.parents(nodeId)]\n const hasModelParent = parents.some((parentId) => {\n const parent = g.node(parentId)\n return parent && parent.kind === DomainModelKind\n })\n\n if (!hasModelParent) {\n validationErrors.push(\n `Entity \"${node.info.name}\" (${nodeId}) has no model parent. ` + `Entities must belong to a model.`\n )\n }\n }\n\n // Validate that models have either namespace parents or are at root level\n if (node.kind === DomainModelKind) {\n const parents = [...g.parents(nodeId)]\n const hasNamespaceParent = parents.some((parentId) => {\n const parent = g.node(parentId)\n return parent && parent.kind === DomainNamespaceKind\n })\n\n // Models can either be at root level (no parents) or have a namespace parent\n // They should not have other types of parents\n if (parents.length > 0 && !hasNamespaceParent) {\n const invalidParents = parents\n .map((parentId) => {\n const parent = g.node(parentId)\n return `${parent?.kind || 'unknown'} (${parentId})`\n })\n .join(', ')\n validationErrors.push(\n `Model \"${node.info.name}\" (${nodeId}) has invalid parent types: ${invalidParents}. ` +\n `Models can only belong to namespaces or be at root level.`\n )\n }\n }\n }\n\n // Validate association targets exist\n for (const nodeId of domainNodes) {\n const node = g.node(nodeId)\n if (node && node.kind === DomainAssociationKind) {\n const association = node as DomainAssociation\n const outgoingEdges = [...g.outEdges(nodeId)]\n\n // Check that association has target edges\n const targetEdges = outgoingEdges.filter((edge) => {\n const edgeData = g.edge(edge)\n return edgeData && edgeData.type === 'association'\n })\n\n if (targetEdges.length === 0) {\n // This is general warning message, do not an error.\n // We can serialize and deserialize associations without targets.\n }\n\n // Validate that all target entities exist\n for (const targetEdge of targetEdges) {\n const targetNode = g.node(targetEdge.w)\n if (!targetNode) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) references non-existent target: ${targetEdge.w}`\n )\n } else if (targetNode.kind !== DomainEntityKind) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) references non-entity target: ` +\n `${targetNode.kind} (${targetEdge.w})`\n )\n }\n }\n }\n }\n\n if (validationErrors.length > 0) {\n throw new Error(\n `Graph consistency validation failed for domain \"${domainKey}\":\\n` +\n validationErrors.map((error) => ` - ${error}`).join('\\n')\n )\n }\n}\n\nexport function serialize(g: DataDomainGraph, domainKey: string): SerializedGraph {\n // Validate graph consistency before serialization\n validateGraphConsistency(g, domainKey)\n\n const json: SerializedGraph = {\n options: {\n directed: g.isDirected(),\n multigraph: g.isMultigraph(),\n compound: g.isCompound(),\n },\n nodes: writeNodes(g, domainKey),\n edges: writeEdges(g, domainKey),\n }\n return json\n}\n\n/**\n * Removes all foreign nodes, edges, and parents from the graph.\n * @param g The graph to remove the foreign nodes from\n * @param domainKey The key of the domain to remove\n */\nexport function removeForeignGraph(g: DataDomainGraph, domainKey: string): void {\n for (const node of g.nodes()) {\n const nodeValue = g.node(node)\n if (!nodeValue) {\n continue\n }\n if (nodeValue.domain.key === domainKey) {\n // This is a foreign node, remove it from the graph.\n g.removeNode(node)\n // When a node is removed, all edges and parents are removed as well.\n // No need to iterate over them.\n }\n }\n}\n\n/**\n * Merges a foreign domain graph into the current domain graph.\n * @param own Our domain graph\n * @param foreign The foreign domain graph\n * @param domain The key of the foreign domain\n */\nexport function mergeGraph(own: DataDomainGraph, foreign: DataDomainGraph, domain: string): GraphMergeResult {\n const nodes = new Set<string>()\n const edges = new Set<string>()\n // Copy nodes\n for (const node of foreign.nodes()) {\n const foreignNode = foreign.node(node)\n if (!foreignNode) {\n continue\n }\n const foreignKey = `${domain}:${node}`\n own.setNode(foreignKey, foreignNode)\n nodes.add(foreignKey)\n }\n // Copy edges\n for (const edge of foreign.edges()) {\n const label = foreign.edge(edge)\n if (!label) {\n continue\n }\n const foreignSource = `${domain}:${edge.v}`\n const foreignTarget = `${domain}:${edge.w}`\n // const foreignEdge = foreign.edge(edge)\n own.setEdge(foreignSource, foreignTarget, {\n foreign: true,\n domain,\n ...label,\n })\n edges.add(`${foreignSource}|${foreignTarget}`)\n }\n const notRootEntities = new Set<string>()\n // Copy parent-child relationships\n for (const node of foreign.nodes()) {\n const foreignNodeKey = `${domain}:${node}`\n for (const parent of foreign.parents(node)) {\n const foreignParentKey = `${domain}:${parent}`\n const srcNode = own.node(foreignNodeKey) as DomainGraphNodeType\n const targetNode = own.node(foreignParentKey) as DomainGraphNodeType\n if (srcNode.kind === DomainEntityKind && targetNode.kind === DomainEntityKind) {\n // entities can have multiple parents between them. We need to respect that.\n if (!notRootEntities.has(foreignNodeKey)) {\n // We use `setParent` in the first run to remove the entity from the root\n // of the graph.\n notRootEntities.add(foreignNodeKey)\n own.setParent(foreignNodeKey, foreignParentKey)\n } else {\n own.addParent(foreignNodeKey, foreignParentKey)\n }\n } else {\n // other nodes can only have a single parent.\n own.setParent(foreignNodeKey, foreignParentKey)\n }\n }\n }\n return {\n nodes,\n edges,\n }\n}\n\n/**\n * Properties and associations are stored as nodes with edges to the parent entity in the graph.\n * At the time of restoring these nodes, the graph has no edges yet.\n * This function finds the parent of the child node in the edges list.\n * @param child The DomainProperty or DomainAssociation key\n * @param edges The list of serialized graph edges\n * @returns The parent key of the child or undefined if not found\n */\nfunction findEdgeParent(child: string, edges: JsonEdge<DomainGraphEdge>[]): string | undefined {\n for (const edge of edges) {\n if (edge.w === child) {\n return edge.v\n }\n }\n return undefined\n}\n\n/**\n * Restores the previously serialized node entry.\n * @param root The DataDomain instance to use as the root for the graph\n * @param entry The node entry to restore\n * @param edges The list of serialized graph edges\n * @param mode The deserialization mode\n * @param issues Array to collect issues in lenient mode\n * @returns The restored node instance or undefined if failed in lenient mode\n * @throws Error if the entry is malformed or the kind is unknown in strict mode\n */\nfunction prepareNode(\n root: DataDomain,\n entry: unknown,\n edges: JsonEdge<DomainGraphEdge>[],\n mode: DeserializationMode,\n issues: DeserializationIssue[]\n): DomainGraphNodeType | undefined {\n if (!entry) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: 'Unable to restore data domain graph. Malformed node entry',\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(issue.message)\n }\n return undefined\n }\n\n const domainElement = entry as { kind?: string; key?: string }\n if (!domainElement.kind) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: 'Unable to restore data domain graph. Node entry missing kind property',\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(issue.message)\n }\n return undefined\n }\n\n try {\n if (domainElement.kind === DomainNamespaceKind) {\n return new DomainNamespace(root, domainElement as DomainNamespaceSchema)\n }\n if (domainElement.kind === DomainModelKind) {\n return new DomainModel(root, domainElement as DomainModelSchema)\n }\n if (domainElement.kind === DomainEntityKind) {\n return new DomainEntity(root, domainElement as DomainEntitySchema)\n }\n if (domainElement.kind === DomainPropertyKind) {\n const typed = domainElement as DomainPropertySchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n const issue: DeserializationIssue = {\n type: 'missing_edge',\n severity: 'error',\n message: `Property \"${typed.info?.name || typed.key}\" has no parent entity edge`,\n affectedKey: typed.key,\n resolution: mode === 'lenient' ? 'Property will be skipped' : undefined,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return undefined\n }\n return new DomainProperty(root, parent, typed)\n }\n if (domainElement.kind === DomainAssociationKind) {\n const typed = domainElement as DomainAssociationSchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n const issue: DeserializationIssue = {\n type: 'missing_edge',\n severity: 'error',\n message: `Association \"${typed.info?.name || typed.key}\" has no parent entity edge`,\n affectedKey: typed.key,\n resolution: mode === 'lenient' ? 'Association will be skipped' : undefined,\n }\n issues.push(issue)\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return undefined\n }\n return new DomainAssociation(root, parent, typed)\n }\n\n const issue: DeserializationIssue = {\n type: 'unknown_kind',\n severity: 'error',\n message: `Unknown node kind: ${domainElement.kind}`,\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Unknown node kind ${domainElement.kind}`)\n }\n return undefined\n } catch (error) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: `Failed to create node: ${error instanceof Error ? error.message : String(error)}`,\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw error\n }\n return undefined\n }\n}\n\n/**\n * To deserialize a graph:\n *\n * - Create a new DataDomain instance\n * - Restore all foreign nodes and edges\n * - Call the deserialize function\n *\n * @param root The DataDomain instance to use as the root for the graph\n * @param json The previously serialized graph\n * @param dependencies An array of foreign data domains to register with this domain\n * @param mode The deserialization mode - 'strict' throws errors, 'lenient' collects issues\n * @returns DeserializationResult with graph, issues, and success status\n * @throws Error in strict mode when any issue is encountered\n */\nexport function deserialize(root: DataDomain, options: DeserializeOptions = {}): DeserializationResult {\n const { json, dependencies, mode = 'strict' } = options\n const g = new Graph<unknown, DomainGraphNodeType, DomainGraphEdge>({\n compound: true,\n multigraph: true,\n directed: true,\n })\n const issues: DeserializationIssue[] = []\n let foreignNodes = new Set<string>()\n let foreignEdges = new Set<string>()\n\n // Process dependencies\n if (dependencies) {\n for (const dependency of dependencies) {\n try {\n const result = mergeGraph(g, dependency.graph, dependency.key)\n if (result.edges.size) {\n foreignEdges = new Set([...foreignEdges, ...result.edges])\n }\n if (result.nodes.size) {\n foreignNodes = new Set([...foreignNodes, ...result.nodes])\n }\n root.dependencies.set(dependency.key, dependency)\n } catch (error) {\n const message = `Failed to merge dependency \"${dependency.key}\": ${error instanceof Error ? error.message : String(error)}`\n\n if (mode === 'strict') {\n throw new Error(message)\n }\n\n const issue: DeserializationIssue = {\n type: 'missing_dependency',\n severity: 'error',\n message,\n affectedKey: dependency.key,\n resolution: 'Dependency will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n\n if (!json) {\n return {\n graph: g,\n issues,\n success: true,\n }\n }\n\n // Process nodes\n if (Array.isArray(json.nodes)) {\n // 1st pass - set up nodes\n const parentInfo = new Map<string, string[]>()\n for (const entry of json.nodes) {\n const node = prepareNode(root, entry.value, json.edges, mode, issues)\n if (node) {\n g.setNode(entry.v, node)\n if (entry.parents) {\n parentInfo.set(entry.v, entry.parents)\n }\n }\n // Note: prepareNode throws in strict mode, so we won't reach here if there's an error\n }\n\n // 2nd pass - set up parents\n for (const [key, parents] of parentInfo) {\n // Verify the node still exists (might have been skipped in lenient mode)\n if (!g.hasNode(key)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Cannot set parents for missing node: ${key}`,\n affectedKey: key,\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n for (const parent of parents) {\n // Verify parent exists\n if (!g.hasNode(parent)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Parent node \"${parent}\" not found for child \"${key}\"`,\n affectedKey: key,\n context: { parentKey: parent },\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n try {\n g.setParent(key, parent)\n } catch (error) {\n const message = `Failed to set parent \"${parent}\" for child \"${key}\": ${error instanceof Error ? error.message : String(error)}`\n const issue: DeserializationIssue = {\n type: 'invalid_parent',\n severity: 'warning',\n message,\n affectedKey: key,\n context: { parentKey: parent },\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n }\n\n // Process edges\n if (Array.isArray(json.edges)) {\n for (const entry of json.edges) {\n if (!entry.value) {\n const message = 'Edge entry missing value'\n\n if (mode === 'strict') {\n throw new Error(message)\n }\n\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message,\n context: { edge: entry },\n }\n issues.push(issue)\n continue\n }\n\n // Handle foreign edges\n if (entry.value.foreign) {\n // The `v` has to be local to the graph. The `w` must be foreign.\n if (!foreignNodes.has(entry.w)) {\n // Note, we don't consider this an error, just a warning.\n // Because of that, we don't throw an error here.\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Missing foreign node: ${entry.w}`,\n affectedKey: entry.w,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n }\n\n // Check if nodes exist for the edge\n if (foreignNodes.has(entry.v) || foreignNodes.has(entry.w)) {\n if (!g.hasNode(entry.v) || !g.hasNode(entry.w)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Missing foreign node for edge: ${entry.v} -> ${entry.w}`,\n context: { sourceNode: entry.v, targetNode: entry.w },\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n } else {\n // Both nodes should be local - verify they exist\n if (!g.hasNode(entry.v)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Source node not found for edge: ${entry.v}`,\n affectedKey: entry.v,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n if (!g.hasNode(entry.w)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Target node not found for edge: ${entry.w}`,\n affectedKey: entry.w,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n }\n\n try {\n g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value)\n } catch (error) {\n const message = `Failed to create edge ${entry.v} -> ${entry.w}: ${error instanceof Error ? error.message : String(error)}`\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'warning',\n message,\n context: { sourceNode: entry.v, targetNode: entry.w },\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n\n const hasErrors = issues.some((issue) => issue.severity === 'error')\n\n return {\n graph: g,\n issues,\n success: !hasErrors,\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SKU.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/SKU.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAA;AAEhE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAA;IAElC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAA;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;OAIG;IACH,iBAAiB,C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IACtB;;OAEG;;IAUH;;OAEG;;IAOH;;OAEG;;IASH;;OAEG;;CAOK,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,SAAS,KAAG,MAAM,EAwB3D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,SAAQ,SAA8B,KAAG,MAAM,EAqC9F,CAAA"}
@@ -46,6 +46,8 @@ export const SKU_PRESETS = {
46
46
  caseMode: 'uppercase',
47
47
  prefix: 'PROD-',
48
48
  enforceUniqueness: true,
49
+ validateReservedWords: true,
50
+ reservedValues: ['ADMIN', 'TEST', 'NULL', 'DEFAULT'],
49
51
  }),
50
52
  /**
51
53
  * Simple SKU configuration for basic catalogs.