@api-client/core 0.18.18 → 0.18.20

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 (43) hide show
  1. package/build/src/modeling/DataDomain.d.ts +35 -1
  2. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  3. package/build/src/modeling/DataDomain.js +120 -0
  4. package/build/src/modeling/DataDomain.js.map +1 -1
  5. package/build/src/modeling/DomainProperty.d.ts +10 -0
  6. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  7. package/build/src/modeling/DomainProperty.js +26 -2
  8. package/build/src/modeling/DomainProperty.js.map +1 -1
  9. package/build/src/modeling/definitions/SKU.d.ts.map +1 -1
  10. package/build/src/modeling/definitions/SKU.js +2 -0
  11. package/build/src/modeling/definitions/SKU.js.map +1 -1
  12. package/build/src/modeling/helpers/Intelisense.d.ts +472 -0
  13. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -0
  14. package/build/src/modeling/helpers/Intelisense.js +1201 -0
  15. package/build/src/modeling/helpers/Intelisense.js.map +1 -0
  16. package/build/src/modeling/templates/blog-domain.d.ts +40 -0
  17. package/build/src/modeling/templates/blog-domain.d.ts.map +1 -0
  18. package/build/src/modeling/templates/blog-domain.js +621 -0
  19. package/build/src/modeling/templates/blog-domain.js.map +1 -0
  20. package/build/src/modeling/templates/ecommerce-domain.d.ts +39 -0
  21. package/build/src/modeling/templates/ecommerce-domain.d.ts.map +1 -0
  22. package/build/src/modeling/templates/ecommerce-domain.js +662 -0
  23. package/build/src/modeling/templates/ecommerce-domain.js.map +1 -0
  24. package/build/src/modeling/templates/types.d.ts +9 -0
  25. package/build/src/modeling/templates/types.d.ts.map +1 -0
  26. package/build/src/modeling/templates/types.js +2 -0
  27. package/build/src/modeling/templates/types.js.map +1 -0
  28. package/build/src/modeling/types.d.ts +49 -0
  29. package/build/src/modeling/types.d.ts.map +1 -1
  30. package/build/src/modeling/types.js.map +1 -1
  31. package/build/tsconfig.tsbuildinfo +1 -1
  32. package/data/models/example-generator-api.json +6 -6
  33. package/package.json +1 -1
  34. package/src/modeling/DataDomain.ts +144 -0
  35. package/src/modeling/DomainProperty.ts +23 -0
  36. package/src/modeling/definitions/SKU.ts +2 -0
  37. package/src/modeling/helpers/Intelisense.ts +1346 -0
  38. package/src/modeling/templates/blog-domain.ts +788 -0
  39. package/src/modeling/templates/ecommerce-domain.ts +834 -0
  40. package/src/modeling/templates/types.ts +9 -0
  41. package/src/modeling/types.ts +63 -0
  42. package/tests/unit/modeling/DataDomain.search.spec.ts +188 -0
  43. package/tests/unit/modeling/helpers/intellisense.spec.ts +971 -0
@@ -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
  }
@@ -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,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,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;;;SA3gBU,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 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 /**\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
+ {"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;IACU,cAAc;sBAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAApC,cAAe,SAAQ,WAAa;;;gCAM9C,cAAc,EAAE;oCAKhB,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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":"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,E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AAO,MAAM,iBAAiB,GAAI,SAAQ,SAAc,KAAG,kBAe1D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAOhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;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.
@@ -1 +1 @@
1
- {"version":3,"file":"SKU.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/SKU.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqG9C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAA6B,EAAkC,EAAE;IAC7F,OAAO,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,GAAG,CAAA;AACzC,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,SAAoB,EAAE,EAAsB,EAAE;IAC9E,MAAM,YAAY,GAAG;QACnB,GAAG,kBAAkB;QACrB,GAAG,MAAM;KACV,CAAA;IAED,4BAA4B;IAC5B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAChD,CAAC;IAED,OAA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,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,EAAE,CAAC;YAC/F,MAAM,CAAC,IAAI,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,IAAI,YAAY,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,IAAI,CAAC,wEAAwE,CAAC,CAAA;QACvF,CAAC;IACH,CAAC;SAAM,IAAI,YAAY,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACrD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;SAAM,IAAI,YAAY,CAAC,cAAc,KAAK,QAAQ,IAAI,YAAY,CAAC,aAAa,EAAE,CAAC;QAClF,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;YACpD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAA;YACxD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Supported SKU validation modes.\n */\nexport type SKUValidationMode = 'strict' | 'lenient' | 'custom'\n\n/**\n * Supported SKU case transformation modes.\n */\nexport type SKUCaseMode = 'uppercase' | 'lowercase' | 'preserve'\n\n/**\n * Configuration options for the SKU semantic.\n * Controls SKU validation, formatting, uniqueness enforcement, and pattern matching.\n */\nexport interface SKUConfig {\n /**\n * The validation mode for SKU format.\n *\n * - 'strict': Enforces alphanumeric characters with optional hyphens/underscores\n * - 'lenient': Allows more special characters but still validates basic format\n * - 'custom': Uses custom regex pattern defined in `customPattern`\n */\n validationMode?: SKUValidationMode\n\n /**\n * Custom regex pattern for SKU validation when using 'custom' validation mode.\n * Only used when validationMode is 'custom'.\n */\n customPattern?: string\n\n /**\n * Case transformation to apply to SKUs.\n * - 'uppercase': Convert to uppercase (recommended for consistency)\n * - 'lowercase': Convert to lowercase\n * - 'preserve': Keep original case\n */\n caseMode?: SKUCaseMode\n\n /**\n * Prefix to automatically add to SKUs if not present.\n * Useful for organizing SKUs by category (e.g., 'PROD-', 'SKU-').\n */\n prefix?: string\n\n /**\n * Whether to enforce global uniqueness across all entities.\n * When true, creates unique database constraints.\n * Default: true\n */\n enforceUniqueness?: boolean\n\n /**\n * Whether to auto-generate SKUs when not provided.\n * When true, generates SKUs based on other fields or random values.\n * Default: false\n */\n autoGenerate?: boolean\n\n /**\n * Field key to use as source for auto-generation.\n * Only used when autoGenerate is true.\n * If not specified, uses random generation.\n *\n * The kay can be any field that provides a meaningful value for the SKU. It can also be a key of\n * a property in one of the parent entities.\n */\n autoGenerateSource?: string\n\n /**\n * Whether to validate that SKU doesn't conflict with reserved words or patterns.\n * Default: true\n */\n validateReservedWords?: boolean\n\n /**\n * List of reserved SKU values that cannot be used.\n * Common examples: 'ADMIN', 'TEST', 'NULL', 'DEFAULT'\n */\n reservedValues?: string[]\n\n /**\n * Custom metadata for the SKU field.\n */\n metadata?: Record<string, unknown>\n\n /**\n * Index signature to allow additional properties.\n */\n [key: string]: unknown\n}\n\n/**\n * Type-safe configuration for SKU semantic.\n */\nexport interface AppliedSKUSemantic extends AppliedDataSemantic {\n id: SemanticType.SKU\n config?: SKUConfig\n}\n\n/**\n * Type guard to check if a semantic is a SKU semantic.\n */\nexport const isSKUSemantic = (semantic: AppliedDataSemantic): semantic is AppliedSKUSemantic => {\n return semantic.id === SemanticType.SKU\n}\n\n/**\n * Helper function to create a SKU semantic with configuration.\n */\nexport const createSKUSemantic = (config: SKUConfig = {}): AppliedSKUSemantic => {\n const mergedConfig = {\n ...DEFAULT_SKU_CONFIG,\n ...config,\n }\n\n // Merge metadata separately\n if (config.metadata) {\n mergedConfig.metadata = { ...config.metadata }\n }\n\n return {\n id: SemanticType.SKU,\n config: mergedConfig,\n }\n}\n\n/**\n * Default configuration for SKU semantic.\n * Optimized for common product catalog use cases.\n */\nexport const DEFAULT_SKU_CONFIG: SKUConfig = {\n validationMode: 'strict',\n caseMode: 'uppercase',\n enforceUniqueness: true,\n autoGenerate: false,\n validateReservedWords: true,\n reservedValues: ['ADMIN', 'TEST', 'NULL', 'DEFAULT', 'UNDEFINED', 'SAMPLE', 'DEMO'],\n}\n\n/**\n * Predefined configurations for common use cases.\n */\nexport const SKU_PRESETS = {\n /**\n * Standard product SKU with strict validation and uppercase formatting.\n */\n PRODUCT_STANDARD: createSKUSemantic({\n validationMode: 'strict',\n caseMode: 'uppercase',\n prefix: 'PROD-',\n enforceUniqueness: true,\n }),\n\n /**\n * Simple SKU configuration for basic catalogs.\n */\n SIMPLE: createSKUSemantic({\n validationMode: 'lenient',\n caseMode: 'preserve',\n enforceUniqueness: true,\n }),\n\n /**\n * Auto-generating SKU from product name.\n */\n AUTO_GENERATE: createSKUSemantic({\n validationMode: 'strict',\n caseMode: 'uppercase',\n autoGenerate: true,\n autoGenerateSource: 'name',\n enforceUniqueness: true,\n }),\n\n /**\n * Flexible SKU for variable product types.\n */\n FLEXIBLE: createSKUSemantic({\n validationMode: 'lenient',\n caseMode: 'preserve',\n enforceUniqueness: true,\n validateReservedWords: false,\n }),\n} as const\n\n/**\n * Helper function to validate a SKU configuration.\n */\nexport const validateSKUConfig = (config: SKUConfig): string[] => {\n const errors: string[] = []\n\n if (config.validationMode === 'custom' && !config.customPattern) {\n errors.push('customPattern is required when validationMode is custom')\n }\n\n if (config.customPattern) {\n try {\n new RegExp(config.customPattern)\n } catch {\n errors.push('customPattern must be a valid regular expression')\n }\n }\n\n if (config.prefix && config.prefix.length === 0) {\n errors.push('prefix cannot be empty string')\n }\n\n if (config.autoGenerateSource && !config.autoGenerate) {\n errors.push('autoGenerate must be true when autoGenerateSource is specified')\n }\n\n return errors\n}\n\n/**\n * Helper function to validate SKU value against configuration.\n */\nexport const validateSKUValue = (value: string, config: SKUConfig = DEFAULT_SKU_CONFIG): string[] => {\n const errors: string[] = []\n const mergedConfig = { ...DEFAULT_SKU_CONFIG, ...config }\n\n if (!value || typeof value !== 'string') {\n errors.push('SKU value must be a non-empty string')\n return errors\n }\n\n if (mergedConfig.validateReservedWords && mergedConfig.reservedValues) {\n const normalizedValue = value.toUpperCase()\n if (mergedConfig.reservedValues.some((reserved) => reserved.toUpperCase() === normalizedValue)) {\n errors.push(`SKU cannot use reserved value: ${value}`)\n }\n }\n\n // Validation pattern checks\n if (mergedConfig.validationMode === 'strict') {\n if (!/^[A-Za-z0-9_-]+$/.test(value)) {\n errors.push('SKU can only contain alphanumeric characters, hyphens, and underscores')\n }\n } else if (mergedConfig.validationMode === 'lenient') {\n if (!/^[A-Za-z0-9_.-]+$/.test(value)) {\n errors.push('SKU contains invalid characters')\n }\n } else if (mergedConfig.validationMode === 'custom' && mergedConfig.customPattern) {\n try {\n const regex = new RegExp(mergedConfig.customPattern)\n if (!regex.test(value)) {\n errors.push('SKU does not match the required pattern')\n }\n } catch {\n errors.push('Invalid custom pattern configuration')\n }\n }\n\n return errors\n}\n"]}
1
+ {"version":3,"file":"SKU.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/SKU.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqG9C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAA6B,EAAkC,EAAE;IAC7F,OAAO,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,GAAG,CAAA;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,CAAC,yCAAyC,CAAC,CAAA;YACxD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Supported SKU validation modes.\n */\nexport type SKUValidationMode = 'strict' | 'lenient' | 'custom'\n\n/**\n * Supported SKU case transformation modes.\n */\nexport type SKUCaseMode = 'uppercase' | 'lowercase' | 'preserve'\n\n/**\n * Configuration options for the SKU semantic.\n * Controls SKU validation, formatting, uniqueness enforcement, and pattern matching.\n */\nexport interface SKUConfig {\n /**\n * The validation mode for SKU format.\n *\n * - 'strict': Enforces alphanumeric characters with optional hyphens/underscores\n * - 'lenient': Allows more special characters but still validates basic format\n * - 'custom': Uses custom regex pattern defined in `customPattern`\n */\n validationMode?: SKUValidationMode\n\n /**\n * Custom regex pattern for SKU validation when using 'custom' validation mode.\n * Only used when validationMode is 'custom'.\n */\n customPattern?: string\n\n /**\n * Case transformation to apply to SKUs.\n * - 'uppercase': Convert to uppercase (recommended for consistency)\n * - 'lowercase': Convert to lowercase\n * - 'preserve': Keep original case\n */\n caseMode?: SKUCaseMode\n\n /**\n * Prefix to automatically add to SKUs if not present.\n * Useful for organizing SKUs by category (e.g., 'PROD-', 'SKU-').\n */\n prefix?: string\n\n /**\n * Whether to enforce global uniqueness across all entities.\n * When true, creates unique database constraints.\n * Default: true\n */\n enforceUniqueness?: boolean\n\n /**\n * Whether to auto-generate SKUs when not provided.\n * When true, generates SKUs based on other fields or random values.\n * Default: false\n */\n autoGenerate?: boolean\n\n /**\n * Field key to use as source for auto-generation.\n * Only used when autoGenerate is true.\n * If not specified, uses random generation.\n *\n * The kay can be any field that provides a meaningful value for the SKU. It can also be a key of\n * a property in one of the parent entities.\n */\n autoGenerateSource?: string\n\n /**\n * Whether to validate that SKU doesn't conflict with reserved words or patterns.\n * Default: true\n */\n validateReservedWords?: boolean\n\n /**\n * List of reserved SKU values that cannot be used.\n * Common examples: 'ADMIN', 'TEST', 'NULL', 'DEFAULT'\n */\n reservedValues?: string[]\n\n /**\n * Custom metadata for the SKU field.\n */\n metadata?: Record<string, unknown>\n\n /**\n * Index signature to allow additional properties.\n */\n [key: string]: unknown\n}\n\n/**\n * Type-safe configuration for SKU semantic.\n */\nexport interface AppliedSKUSemantic extends AppliedDataSemantic {\n id: SemanticType.SKU\n config?: SKUConfig\n}\n\n/**\n * Type guard to check if a semantic is a SKU semantic.\n */\nexport const isSKUSemantic = (semantic: AppliedDataSemantic): semantic is AppliedSKUSemantic => {\n return semantic.id === SemanticType.SKU\n}\n\n/**\n * Helper function to create a SKU semantic with configuration.\n */\nexport const createSKUSemantic = (config: SKUConfig = {}): AppliedSKUSemantic => {\n const mergedConfig = {\n ...DEFAULT_SKU_CONFIG,\n ...config,\n }\n\n // Merge metadata separately\n if (config.metadata) {\n mergedConfig.metadata = { ...config.metadata }\n }\n\n return {\n id: SemanticType.SKU,\n config: mergedConfig,\n }\n}\n\n/**\n * Default configuration for SKU semantic.\n * Optimized for common product catalog use cases.\n */\nexport const DEFAULT_SKU_CONFIG: SKUConfig = {\n validationMode: 'strict',\n caseMode: 'uppercase',\n enforceUniqueness: true,\n autoGenerate: false,\n validateReservedWords: true,\n reservedValues: ['ADMIN', 'TEST', 'NULL', 'DEFAULT', 'UNDEFINED', 'SAMPLE', 'DEMO'],\n}\n\n/**\n * Predefined configurations for common use cases.\n */\nexport const SKU_PRESETS = {\n /**\n * Standard product SKU with strict validation and uppercase formatting.\n */\n PRODUCT_STANDARD: createSKUSemantic({\n validationMode: 'strict',\n caseMode: 'uppercase',\n prefix: 'PROD-',\n enforceUniqueness: true,\n validateReservedWords: true,\n reservedValues: ['ADMIN', 'TEST', 'NULL', 'DEFAULT'],\n }),\n\n /**\n * Simple SKU configuration for basic catalogs.\n */\n SIMPLE: createSKUSemantic({\n validationMode: 'lenient',\n caseMode: 'preserve',\n enforceUniqueness: true,\n }),\n\n /**\n * Auto-generating SKU from product name.\n */\n AUTO_GENERATE: createSKUSemantic({\n validationMode: 'strict',\n caseMode: 'uppercase',\n autoGenerate: true,\n autoGenerateSource: 'name',\n enforceUniqueness: true,\n }),\n\n /**\n * Flexible SKU for variable product types.\n */\n FLEXIBLE: createSKUSemantic({\n validationMode: 'lenient',\n caseMode: 'preserve',\n enforceUniqueness: true,\n validateReservedWords: false,\n }),\n} as const\n\n/**\n * Helper function to validate a SKU configuration.\n */\nexport const validateSKUConfig = (config: SKUConfig): string[] => {\n const errors: string[] = []\n\n if (config.validationMode === 'custom' && !config.customPattern) {\n errors.push('customPattern is required when validationMode is custom')\n }\n\n if (config.customPattern) {\n try {\n new RegExp(config.customPattern)\n } catch {\n errors.push('customPattern must be a valid regular expression')\n }\n }\n\n if (config.prefix && config.prefix.length === 0) {\n errors.push('prefix cannot be empty string')\n }\n\n if (config.autoGenerateSource && !config.autoGenerate) {\n errors.push('autoGenerate must be true when autoGenerateSource is specified')\n }\n\n return errors\n}\n\n/**\n * Helper function to validate SKU value against configuration.\n */\nexport const validateSKUValue = (value: string, config: SKUConfig = DEFAULT_SKU_CONFIG): string[] => {\n const errors: string[] = []\n const mergedConfig = { ...DEFAULT_SKU_CONFIG, ...config }\n\n if (!value || typeof value !== 'string') {\n errors.push('SKU value must be a non-empty string')\n return errors\n }\n\n if (mergedConfig.validateReservedWords && mergedConfig.reservedValues) {\n const normalizedValue = value.toUpperCase()\n if (mergedConfig.reservedValues.some((reserved) => reserved.toUpperCase() === normalizedValue)) {\n errors.push(`SKU cannot use reserved value: ${value}`)\n }\n }\n\n // Validation pattern checks\n if (mergedConfig.validationMode === 'strict') {\n if (!/^[A-Za-z0-9_-]+$/.test(value)) {\n errors.push('SKU can only contain alphanumeric characters, hyphens, and underscores')\n }\n } else if (mergedConfig.validationMode === 'lenient') {\n if (!/^[A-Za-z0-9_.-]+$/.test(value)) {\n errors.push('SKU contains invalid characters')\n }\n } else if (mergedConfig.validationMode === 'custom' && mergedConfig.customPattern) {\n try {\n const regex = new RegExp(mergedConfig.customPattern)\n if (!regex.test(value)) {\n errors.push('SKU does not match the required pattern')\n }\n } catch {\n errors.push('Invalid custom pattern configuration')\n }\n }\n\n return errors\n}\n"]}