@api-client/core 0.15.1 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TESTING_READY.md +114 -0
- package/TESTING_SETUP.md +198 -0
- package/build/src/modeling/Semantics.d.ts +126 -2
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +281 -13
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/src/modeling/definitions/Calculated.d.ts +54 -0
- package/build/src/modeling/definitions/Calculated.d.ts.map +1 -0
- package/build/src/modeling/definitions/Calculated.js +31 -0
- package/build/src/modeling/definitions/Calculated.js.map +1 -0
- package/build/src/modeling/definitions/Categories.d.ts +60 -0
- package/build/src/modeling/definitions/Categories.d.ts.map +1 -0
- package/build/src/modeling/definitions/Categories.js +33 -0
- package/build/src/modeling/definitions/Categories.js.map +1 -0
- package/build/src/modeling/definitions/Derived.d.ts +54 -0
- package/build/src/modeling/definitions/Derived.d.ts.map +1 -0
- package/build/src/modeling/definitions/Derived.js +31 -0
- package/build/src/modeling/definitions/Derived.js.map +1 -0
- package/build/src/modeling/definitions/Description.d.ts +36 -0
- package/build/src/modeling/definitions/Description.d.ts.map +1 -0
- package/build/src/modeling/definitions/Description.js +28 -0
- package/build/src/modeling/definitions/Description.js.map +1 -0
- package/build/src/modeling/definitions/Email.d.ts +66 -0
- package/build/src/modeling/definitions/Email.d.ts.map +1 -0
- package/build/src/modeling/definitions/Email.js +33 -0
- package/build/src/modeling/definitions/Email.js.map +1 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.d.ts +212 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.d.ts.map +1 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.js +129 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.js.map +1 -0
- package/build/src/modeling/definitions/HTML.d.ts +88 -0
- package/build/src/modeling/definitions/HTML.d.ts.map +1 -0
- package/build/src/modeling/definitions/HTML.js +42 -0
- package/build/src/modeling/definitions/HTML.js.map +1 -0
- package/build/src/modeling/definitions/Markdown.d.ts +84 -0
- package/build/src/modeling/definitions/Markdown.d.ts.map +1 -0
- package/build/src/modeling/definitions/Markdown.js +41 -0
- package/build/src/modeling/definitions/Markdown.js.map +1 -0
- package/build/src/modeling/definitions/Password.d.ts +112 -0
- package/build/src/modeling/definitions/Password.d.ts.map +1 -0
- package/build/src/modeling/definitions/Password.js +57 -0
- package/build/src/modeling/definitions/Password.js.map +1 -0
- package/build/src/modeling/definitions/Phone.d.ts +83 -0
- package/build/src/modeling/definitions/Phone.d.ts.map +1 -0
- package/build/src/modeling/definitions/Phone.js +39 -0
- package/build/src/modeling/definitions/Phone.js.map +1 -0
- package/build/src/modeling/definitions/Price.d.ts +102 -0
- package/build/src/modeling/definitions/Price.d.ts.map +1 -0
- package/build/src/modeling/definitions/Price.js +99 -0
- package/build/src/modeling/definitions/Price.js.map +1 -0
- package/build/src/modeling/definitions/PublicUniqueName.d.ts +69 -0
- package/build/src/modeling/definitions/PublicUniqueName.d.ts.map +1 -0
- package/build/src/modeling/definitions/PublicUniqueName.js +34 -0
- package/build/src/modeling/definitions/PublicUniqueName.js.map +1 -0
- package/build/src/modeling/definitions/SKU.d.ts +127 -0
- package/build/src/modeling/definitions/SKU.d.ts.map +1 -0
- package/build/src/modeling/definitions/SKU.js +142 -0
- package/build/src/modeling/definitions/SKU.js.map +1 -0
- package/build/src/modeling/definitions/Status.d.ts +150 -0
- package/build/src/modeling/definitions/Status.d.ts.map +1 -0
- package/build/src/modeling/definitions/Status.js +60 -0
- package/build/src/modeling/definitions/Status.js.map +1 -0
- package/build/src/modeling/definitions/Summary.d.ts +53 -0
- package/build/src/modeling/definitions/Summary.d.ts.map +1 -0
- package/build/src/modeling/definitions/Summary.js +50 -0
- package/build/src/modeling/definitions/Summary.js.map +1 -0
- package/build/src/modeling/definitions/Tags.d.ts +52 -0
- package/build/src/modeling/definitions/Tags.d.ts.map +1 -0
- package/build/src/modeling/definitions/Tags.js +32 -0
- package/build/src/modeling/definitions/Tags.js.map +1 -0
- package/build/src/modeling/definitions/URL.d.ts +68 -0
- package/build/src/modeling/definitions/URL.d.ts.map +1 -0
- package/build/src/modeling/definitions/URL.js +37 -0
- package/build/src/modeling/definitions/URL.js.map +1 -0
- package/build/src/modeling/validation/semantic_validation.d.ts +4 -0
- package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/semantic_validation.js +32 -1
- package/build/src/modeling/validation/semantic_validation.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modeling/Semantics.ts +297 -14
- package/src/modeling/definitions/Calculated.ts +76 -0
- package/src/modeling/definitions/Categories.ts +84 -0
- package/src/modeling/definitions/Derived.ts +76 -0
- package/src/modeling/definitions/Description.ts +55 -0
- package/src/modeling/definitions/Email.ts +90 -0
- package/src/modeling/definitions/GeospatialCoordinates.ts +274 -0
- package/src/modeling/definitions/HTML.ts +121 -0
- package/src/modeling/definitions/Markdown.ts +116 -0
- package/src/modeling/definitions/Password.ts +156 -0
- package/src/modeling/definitions/Phone.ts +116 -0
- package/src/modeling/definitions/Price.examples.md +158 -0
- package/src/modeling/definitions/Price.ts +180 -0
- package/src/modeling/definitions/PublicUniqueName.ts +98 -0
- package/src/modeling/definitions/SKU.examples.md +230 -0
- package/src/modeling/definitions/SKU.ts +254 -0
- package/src/modeling/definitions/Status.ts +227 -0
- package/src/modeling/definitions/Summary.ts +73 -0
- package/src/modeling/definitions/Tags.ts +75 -0
- package/src/modeling/definitions/URL.ts +96 -0
- package/src/modeling/validation/semantic_validation.ts +35 -1
- package/tests/example-test-setup.ts +133 -0
- package/tests/template-node.spec.ts +75 -0
- package/tests/test-utils.ts +293 -0
- package/tests/unit/modeling/definitions/calculated.spec.ts +33 -0
- package/tests/unit/modeling/definitions/categories.spec.ts +38 -0
- package/tests/unit/modeling/definitions/derived.spec.ts +34 -0
- package/tests/unit/modeling/definitions/description.spec.ts +38 -0
- package/tests/unit/modeling/definitions/email.spec.ts +38 -0
- package/tests/unit/modeling/definitions/geospatial-coordinates.spec.ts +41 -0
- package/tests/unit/modeling/definitions/html.spec.ts +38 -0
- package/tests/unit/modeling/definitions/markdown.spec.ts +38 -0
- package/tests/unit/modeling/definitions/password.spec.ts +347 -0
- package/tests/unit/modeling/definitions/phone.spec.ts +38 -0
- package/tests/unit/modeling/definitions/price.spec.ts +465 -0
- package/tests/unit/modeling/definitions/public-unique-name.spec.ts +38 -0
- package/tests/unit/modeling/definitions/sku.spec.ts +240 -0
- package/tests/unit/modeling/definitions/status.spec.ts +37 -0
- package/tests/unit/modeling/definitions/summary.spec.ts +36 -0
- package/tests/unit/modeling/definitions/tags.spec.ts +38 -0
- package/tests/unit/modeling/definitions/url.spec.ts +38 -0
- package/tests/unit/modeling/domain_property.spec.ts +106 -0
- package/tests/unit/modeling/domain_validation.spec.ts +5 -5
- package/tests/unit/modeling/semantic-configs.spec.ts +569 -0
- package/tests/unit/modeling/semantics.spec.ts +52 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { SemanticType } from '../Semantics.js';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a semantic is a SKU semantic.
|
|
4
|
+
*/
|
|
5
|
+
export const isSKUSemantic = (semantic) => {
|
|
6
|
+
return semantic.id === SemanticType.SKU;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to create a SKU semantic with configuration.
|
|
10
|
+
*/
|
|
11
|
+
export const createSKUSemantic = (config = {}) => {
|
|
12
|
+
const mergedConfig = {
|
|
13
|
+
...DEFAULT_SKU_CONFIG,
|
|
14
|
+
...config,
|
|
15
|
+
};
|
|
16
|
+
// Merge metadata separately
|
|
17
|
+
if (config.metadata) {
|
|
18
|
+
mergedConfig.metadata = { ...config.metadata };
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
id: SemanticType.SKU,
|
|
22
|
+
config: mergedConfig,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Default configuration for SKU semantic.
|
|
27
|
+
* Optimized for common product catalog use cases.
|
|
28
|
+
*/
|
|
29
|
+
export const DEFAULT_SKU_CONFIG = {
|
|
30
|
+
validationMode: 'strict',
|
|
31
|
+
caseMode: 'uppercase',
|
|
32
|
+
enforceUniqueness: true,
|
|
33
|
+
autoGenerate: false,
|
|
34
|
+
validateReservedWords: true,
|
|
35
|
+
reservedValues: ['ADMIN', 'TEST', 'NULL', 'DEFAULT', 'UNDEFINED', 'SAMPLE', 'DEMO'],
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Predefined configurations for common use cases.
|
|
39
|
+
*/
|
|
40
|
+
export const SKU_PRESETS = {
|
|
41
|
+
/**
|
|
42
|
+
* Standard product SKU with strict validation and uppercase formatting.
|
|
43
|
+
*/
|
|
44
|
+
PRODUCT_STANDARD: createSKUSemantic({
|
|
45
|
+
validationMode: 'strict',
|
|
46
|
+
caseMode: 'uppercase',
|
|
47
|
+
prefix: 'PROD-',
|
|
48
|
+
enforceUniqueness: true,
|
|
49
|
+
}),
|
|
50
|
+
/**
|
|
51
|
+
* Simple SKU configuration for basic catalogs.
|
|
52
|
+
*/
|
|
53
|
+
SIMPLE: createSKUSemantic({
|
|
54
|
+
validationMode: 'lenient',
|
|
55
|
+
caseMode: 'preserve',
|
|
56
|
+
enforceUniqueness: true,
|
|
57
|
+
}),
|
|
58
|
+
/**
|
|
59
|
+
* Auto-generating SKU from product name.
|
|
60
|
+
*/
|
|
61
|
+
AUTO_GENERATE: createSKUSemantic({
|
|
62
|
+
validationMode: 'strict',
|
|
63
|
+
caseMode: 'uppercase',
|
|
64
|
+
autoGenerate: true,
|
|
65
|
+
autoGenerateSource: 'name',
|
|
66
|
+
enforceUniqueness: true,
|
|
67
|
+
}),
|
|
68
|
+
/**
|
|
69
|
+
* Flexible SKU for variable product types.
|
|
70
|
+
*/
|
|
71
|
+
FLEXIBLE: createSKUSemantic({
|
|
72
|
+
validationMode: 'lenient',
|
|
73
|
+
caseMode: 'preserve',
|
|
74
|
+
enforceUniqueness: true,
|
|
75
|
+
validateReservedWords: false,
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Helper function to validate a SKU configuration.
|
|
80
|
+
*/
|
|
81
|
+
export const validateSKUConfig = (config) => {
|
|
82
|
+
const errors = [];
|
|
83
|
+
if (config.validationMode === 'custom' && !config.customPattern) {
|
|
84
|
+
errors.push('customPattern is required when validationMode is custom');
|
|
85
|
+
}
|
|
86
|
+
if (config.customPattern) {
|
|
87
|
+
try {
|
|
88
|
+
new RegExp(config.customPattern);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
errors.push('customPattern must be a valid regular expression');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (config.prefix && config.prefix.length === 0) {
|
|
95
|
+
errors.push('prefix cannot be empty string');
|
|
96
|
+
}
|
|
97
|
+
if (config.autoGenerateSource && !config.autoGenerate) {
|
|
98
|
+
errors.push('autoGenerate must be true when autoGenerateSource is specified');
|
|
99
|
+
}
|
|
100
|
+
return errors;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Helper function to validate SKU value against configuration.
|
|
104
|
+
*/
|
|
105
|
+
export const validateSKUValue = (value, config = DEFAULT_SKU_CONFIG) => {
|
|
106
|
+
const errors = [];
|
|
107
|
+
const mergedConfig = { ...DEFAULT_SKU_CONFIG, ...config };
|
|
108
|
+
if (!value || typeof value !== 'string') {
|
|
109
|
+
errors.push('SKU value must be a non-empty string');
|
|
110
|
+
return errors;
|
|
111
|
+
}
|
|
112
|
+
if (mergedConfig.validateReservedWords && mergedConfig.reservedValues) {
|
|
113
|
+
const normalizedValue = value.toUpperCase();
|
|
114
|
+
if (mergedConfig.reservedValues.some((reserved) => reserved.toUpperCase() === normalizedValue)) {
|
|
115
|
+
errors.push(`SKU cannot use reserved value: ${value}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Validation pattern checks
|
|
119
|
+
if (mergedConfig.validationMode === 'strict') {
|
|
120
|
+
if (!/^[A-Za-z0-9_-]+$/.test(value)) {
|
|
121
|
+
errors.push('SKU can only contain alphanumeric characters, hyphens, and underscores');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (mergedConfig.validationMode === 'lenient') {
|
|
125
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(value)) {
|
|
126
|
+
errors.push('SKU contains invalid characters');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (mergedConfig.validationMode === 'custom' && mergedConfig.customPattern) {
|
|
130
|
+
try {
|
|
131
|
+
const regex = new RegExp(mergedConfig.customPattern);
|
|
132
|
+
if (!regex.test(value)) {
|
|
133
|
+
errors.push('SKU does not match the required pattern');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
errors.push('Invalid custom pattern configuration');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return errors;
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=SKU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SKU.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/SKU.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAkG9C;;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,OAAO;QACL,EAAE,EAAE,YAAY,CAAC,GAAG;QACpB,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,cAAc,EAAE,QAAQ;IACxB,QAAQ,EAAE,WAAW;IACrB,iBAAiB,EAAE,IAAI;IACvB,YAAY,EAAE,KAAK;IACnB,qBAAqB,EAAE,IAAI;IAC3B,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC;CACpF,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB;;OAEG;IACH,gBAAgB,EAAE,iBAAiB,CAAC;QAClC,cAAc,EAAE,QAAQ;QACxB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,OAAO;QACf,iBAAiB,EAAE,IAAI;KACxB,CAAC;IAEF;;OAEG;IACH,MAAM,EAAE,iBAAiB,CAAC;QACxB,cAAc,EAAE,SAAS;QACzB,QAAQ,EAAE,UAAU;QACpB,iBAAiB,EAAE,IAAI;KACxB,CAAC;IAEF;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;QAC/B,cAAc,EAAE,QAAQ;QACxB,QAAQ,EAAE,WAAW;QACrB,YAAY,EAAE,IAAI;QAClB,kBAAkB,EAAE,MAAM;QAC1B,iBAAiB,EAAE,IAAI;KACxB,CAAC;IAEF;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAC;QAC1B,cAAc,EAAE,SAAS;QACzB,QAAQ,EAAE,UAAU;QACpB,iBAAiB,EAAE,IAAI;QACvB,qBAAqB,EAAE,KAAK;KAC7B,CAAC;CACM,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAiB,EAAY,EAAE;IAC/D,MAAM,MAAM,GAAa,EAAE,CAAA;IAE3B,IAAI,MAAM,CAAC,cAAc,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;QAChE,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAA;IACxE,CAAC;IAED,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,MAAM,CAAC,kBAAkB,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACtD,MAAM,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAA;IAC/E,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAE,SAAoB,kBAAkB,EAAY,EAAE;IAClG,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,MAAM,YAAY,GAAG,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAAA;IAEzD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;QACnD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAAI,YAAY,CAAC,qBAAqB,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC;QACtE,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;QAC3C,IAAI,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,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 name to use as source for auto-generation.\n * Only used when autoGenerate is true.\n * If not specified, uses random generation.\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"]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { AppliedDataSemantic } from '../Semantics.js';
|
|
2
|
+
import { SemanticType } from '../Semantics.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the Status semantic.
|
|
5
|
+
* These options control state management and workflow behavior.
|
|
6
|
+
*/
|
|
7
|
+
export interface StatusConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Allowed states for this status field.
|
|
10
|
+
* Only required when the field doesn't have enum values defined in the schema.
|
|
11
|
+
* If enum values are defined in DomainProperty > Schema, those values will be used instead.
|
|
12
|
+
*/
|
|
13
|
+
allowedStates?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Default state when creating new records.
|
|
16
|
+
* Must be one of the allowedStates (if specified) or enum values from the schema.
|
|
17
|
+
*/
|
|
18
|
+
defaultState: string;
|
|
19
|
+
/**
|
|
20
|
+
* State transitions configuration.
|
|
21
|
+
* Maps from current state to array of allowed next states.
|
|
22
|
+
*/
|
|
23
|
+
transitions?: Record<string, string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* State-specific behaviors and permissions.
|
|
26
|
+
*/
|
|
27
|
+
stateBehaviors?: Record<string, {
|
|
28
|
+
/**
|
|
29
|
+
* Whether records in this state are publicly visible.
|
|
30
|
+
* Defaults to true if not specified.
|
|
31
|
+
*/
|
|
32
|
+
isPublic?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether records in this state can be edited.
|
|
35
|
+
* Defaults to true if not specified.
|
|
36
|
+
*/
|
|
37
|
+
isEditable?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether records in this state can be deleted.
|
|
40
|
+
* Defaults to false if not specified.
|
|
41
|
+
*/
|
|
42
|
+
isDeletable?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether this state requires approval before transition.
|
|
45
|
+
* Defaults to false if not specified.
|
|
46
|
+
*/
|
|
47
|
+
requiresApproval?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Custom display name for this state.
|
|
50
|
+
*/
|
|
51
|
+
displayName?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Custom description for this state.
|
|
54
|
+
*/
|
|
55
|
+
description?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Color or visual indicator for this state.
|
|
58
|
+
*/
|
|
59
|
+
color?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Icon for this state.
|
|
62
|
+
*/
|
|
63
|
+
icon?: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Workflow configuration for status management.
|
|
67
|
+
*/
|
|
68
|
+
workflow?: {
|
|
69
|
+
/**
|
|
70
|
+
* Whether status changes require approval.
|
|
71
|
+
* Defaults to false if not specified.
|
|
72
|
+
*/
|
|
73
|
+
requiresApproval?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Roles that can approve status changes.
|
|
76
|
+
* Required if requiresApproval is true.
|
|
77
|
+
*/
|
|
78
|
+
approvalRoles?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Whether to send notifications on status changes.
|
|
81
|
+
* Defaults to false if not specified.
|
|
82
|
+
*/
|
|
83
|
+
sendNotifications?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Notification channels to use.
|
|
86
|
+
*/
|
|
87
|
+
notificationChannels?: ('email' | 'sms' | 'push' | 'webhook')[];
|
|
88
|
+
/**
|
|
89
|
+
* Whether to log status change history.
|
|
90
|
+
* Defaults to true if not specified.
|
|
91
|
+
*/
|
|
92
|
+
logHistory?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether to allow bulk status changes.
|
|
95
|
+
* Defaults to false if not specified.
|
|
96
|
+
*/
|
|
97
|
+
allowBulkChanges?: boolean;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Auto-transitions based on conditions.
|
|
101
|
+
*/
|
|
102
|
+
autoTransitions?: {
|
|
103
|
+
/**
|
|
104
|
+
* Current state that triggers the auto-transition.
|
|
105
|
+
*/
|
|
106
|
+
from: string;
|
|
107
|
+
/**
|
|
108
|
+
* Target state to transition to.
|
|
109
|
+
*/
|
|
110
|
+
to: string;
|
|
111
|
+
/**
|
|
112
|
+
* Condition that triggers the transition.
|
|
113
|
+
* Examples: "after 24 hours", "when approved", "when payment received"
|
|
114
|
+
*/
|
|
115
|
+
condition: string;
|
|
116
|
+
/**
|
|
117
|
+
* Whether this auto-transition requires approval.
|
|
118
|
+
* Defaults to false if not specified.
|
|
119
|
+
*/
|
|
120
|
+
requiresApproval?: boolean;
|
|
121
|
+
}[];
|
|
122
|
+
/**
|
|
123
|
+
* Custom metadata for the status field.
|
|
124
|
+
*/
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
126
|
+
/**
|
|
127
|
+
* Index signature to allow additional properties.
|
|
128
|
+
*/
|
|
129
|
+
[key: string]: unknown;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Type-safe configuration for Status semantic.
|
|
133
|
+
*/
|
|
134
|
+
export interface AppliedStatusSemantic extends AppliedDataSemantic {
|
|
135
|
+
id: SemanticType.Status;
|
|
136
|
+
config?: StatusConfig;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Type guard to check if a semantic is a Status semantic.
|
|
140
|
+
*/
|
|
141
|
+
export declare const isStatusSemantic: (semantic: AppliedDataSemantic) => semantic is AppliedStatusSemantic;
|
|
142
|
+
/**
|
|
143
|
+
* Helper function to create a Status semantic with configuration.
|
|
144
|
+
*/
|
|
145
|
+
export declare const createStatusSemantic: (config?: Partial<StatusConfig>) => AppliedStatusSemantic;
|
|
146
|
+
/**
|
|
147
|
+
* Default configuration for Status semantic.
|
|
148
|
+
*/
|
|
149
|
+
export declare const DEFAULT_STATUS_CONFIG: StatusConfig;
|
|
150
|
+
//# sourceMappingURL=Status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/Status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IAExB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAEtC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CACrB,MAAM,EACN;QACE;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAA;QAElB;;;WAGG;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;QAEpB;;;WAGG;QACH,WAAW,CAAC,EAAE,OAAO,CAAA;QAErB;;;WAGG;QACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;QAE1B;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAA;QAEpB;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAA;QAEpB;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,CAAA;QAEd;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CACF,CAAA;IAED;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;;WAGG;QACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;QAE1B;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;QAExB;;;WAGG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAE3B;;WAEG;QACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAA;QAE/D;;;WAGG;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;QAEpB;;;WAGG;QACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,CAAA;IAED;;OAEG;IACH,eAAe,CAAC,EAAE;QAChB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAA;QAEZ;;WAEG;QACH,EAAE,EAAE,MAAM,CAAA;QAEV;;;WAGG;QACH,SAAS,EAAE,MAAM,CAAA;QAEjB;;;WAGG;QACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,EAAE,CAAA;IAEH;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,EAAE,EAAE,YAAY,CAAC,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,mBAAmB,KAAG,QAAQ,IAAI,qBAE5E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAQ,OAAO,CAAC,YAAY,CAAM,KAAG,qBAqBzE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAyBnC,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SemanticType } from '../Semantics.js';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a semantic is a Status semantic.
|
|
4
|
+
*/
|
|
5
|
+
export const isStatusSemantic = (semantic) => {
|
|
6
|
+
return semantic.id === SemanticType.Status;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to create a Status semantic with configuration.
|
|
10
|
+
*/
|
|
11
|
+
export const createStatusSemantic = (config = {}) => {
|
|
12
|
+
const mergedConfig = {
|
|
13
|
+
...DEFAULT_STATUS_CONFIG,
|
|
14
|
+
...config,
|
|
15
|
+
// Deep merge nested objects
|
|
16
|
+
stateBehaviors: config.stateBehaviors
|
|
17
|
+
? { ...DEFAULT_STATUS_CONFIG.stateBehaviors, ...config.stateBehaviors }
|
|
18
|
+
: DEFAULT_STATUS_CONFIG.stateBehaviors,
|
|
19
|
+
workflow: config.workflow
|
|
20
|
+
? { ...DEFAULT_STATUS_CONFIG.workflow, ...config.workflow }
|
|
21
|
+
: DEFAULT_STATUS_CONFIG.workflow,
|
|
22
|
+
};
|
|
23
|
+
if (config.metadata) {
|
|
24
|
+
mergedConfig.metadata = { ...config.metadata };
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
id: SemanticType.Status,
|
|
28
|
+
config: mergedConfig,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Default configuration for Status semantic.
|
|
33
|
+
*/
|
|
34
|
+
export const DEFAULT_STATUS_CONFIG = {
|
|
35
|
+
defaultState: 'draft',
|
|
36
|
+
stateBehaviors: {
|
|
37
|
+
draft: {
|
|
38
|
+
isPublic: false,
|
|
39
|
+
isEditable: true,
|
|
40
|
+
isDeletable: true,
|
|
41
|
+
},
|
|
42
|
+
published: {
|
|
43
|
+
isPublic: true,
|
|
44
|
+
isEditable: true,
|
|
45
|
+
isDeletable: false,
|
|
46
|
+
},
|
|
47
|
+
archived: {
|
|
48
|
+
isPublic: false,
|
|
49
|
+
isEditable: false,
|
|
50
|
+
isDeletable: false,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
workflow: {
|
|
54
|
+
requiresApproval: false,
|
|
55
|
+
sendNotifications: false,
|
|
56
|
+
logHistory: true,
|
|
57
|
+
allowBulkChanges: false,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=Status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/Status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAoK9C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAA6B,EAAqC,EAAE;IACnG,OAAO,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,MAAM,CAAA;AAC5C,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAgC,EAAE,EAAyB,EAAE;IAChG,MAAM,YAAY,GAAG;QACnB,GAAG,qBAAqB;QACxB,GAAG,MAAM;QACT,4BAA4B;QAC5B,cAAc,EAAE,MAAM,CAAC,cAAc;YACnC,CAAC,CAAC,EAAE,GAAG,qBAAqB,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,cAAc,EAAE;YACvE,CAAC,CAAC,qBAAqB,CAAC,cAAc;QACxC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACvB,CAAC,CAAC,EAAE,GAAG,qBAAqB,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;YAC3D,CAAC,CAAC,qBAAqB,CAAC,QAAQ;KACnC,CAAA;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAChD,CAAC;IAED,OAAO;QACL,EAAE,EAAE,YAAY,CAAC,MAAM;QACvB,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,YAAY,EAAE,OAAO;IACrB,cAAc,EAAE;QACd,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;SAClB;QACD,SAAS,EAAE;YACT,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,KAAK;SACnB;KACF;IACD,QAAQ,EAAE;QACR,gBAAgB,EAAE,KAAK;QACvB,iBAAiB,EAAE,KAAK;QACxB,UAAU,EAAE,IAAI;QAChB,gBAAgB,EAAE,KAAK;KACxB;CACF,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Configuration options for the Status semantic.\n * These options control state management and workflow behavior.\n */\nexport interface StatusConfig {\n /**\n * Allowed states for this status field.\n * Only required when the field doesn't have enum values defined in the schema.\n * If enum values are defined in DomainProperty > Schema, those values will be used instead.\n */\n allowedStates?: string[]\n\n /**\n * Default state when creating new records.\n * Must be one of the allowedStates (if specified) or enum values from the schema.\n */\n defaultState: string\n\n /**\n * State transitions configuration.\n * Maps from current state to array of allowed next states.\n */\n transitions?: Record<string, string[]>\n\n /**\n * State-specific behaviors and permissions.\n */\n stateBehaviors?: Record<\n string,\n {\n /**\n * Whether records in this state are publicly visible.\n * Defaults to true if not specified.\n */\n isPublic?: boolean\n\n /**\n * Whether records in this state can be edited.\n * Defaults to true if not specified.\n */\n isEditable?: boolean\n\n /**\n * Whether records in this state can be deleted.\n * Defaults to false if not specified.\n */\n isDeletable?: boolean\n\n /**\n * Whether this state requires approval before transition.\n * Defaults to false if not specified.\n */\n requiresApproval?: boolean\n\n /**\n * Custom display name for this state.\n */\n displayName?: string\n\n /**\n * Custom description for this state.\n */\n description?: string\n\n /**\n * Color or visual indicator for this state.\n */\n color?: string\n\n /**\n * Icon for this state.\n */\n icon?: string\n }\n >\n\n /**\n * Workflow configuration for status management.\n */\n workflow?: {\n /**\n * Whether status changes require approval.\n * Defaults to false if not specified.\n */\n requiresApproval?: boolean\n\n /**\n * Roles that can approve status changes.\n * Required if requiresApproval is true.\n */\n approvalRoles?: string[]\n\n /**\n * Whether to send notifications on status changes.\n * Defaults to false if not specified.\n */\n sendNotifications?: boolean\n\n /**\n * Notification channels to use.\n */\n notificationChannels?: ('email' | 'sms' | 'push' | 'webhook')[]\n\n /**\n * Whether to log status change history.\n * Defaults to true if not specified.\n */\n logHistory?: boolean\n\n /**\n * Whether to allow bulk status changes.\n * Defaults to false if not specified.\n */\n allowBulkChanges?: boolean\n }\n\n /**\n * Auto-transitions based on conditions.\n */\n autoTransitions?: {\n /**\n * Current state that triggers the auto-transition.\n */\n from: string\n\n /**\n * Target state to transition to.\n */\n to: string\n\n /**\n * Condition that triggers the transition.\n * Examples: \"after 24 hours\", \"when approved\", \"when payment received\"\n */\n condition: string\n\n /**\n * Whether this auto-transition requires approval.\n * Defaults to false if not specified.\n */\n requiresApproval?: boolean\n }[]\n\n /**\n * Custom metadata for the status 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 Status semantic.\n */\nexport interface AppliedStatusSemantic extends AppliedDataSemantic {\n id: SemanticType.Status\n config?: StatusConfig\n}\n\n/**\n * Type guard to check if a semantic is a Status semantic.\n */\nexport const isStatusSemantic = (semantic: AppliedDataSemantic): semantic is AppliedStatusSemantic => {\n return semantic.id === SemanticType.Status\n}\n\n/**\n * Helper function to create a Status semantic with configuration.\n */\nexport const createStatusSemantic = (config: Partial<StatusConfig> = {}): AppliedStatusSemantic => {\n const mergedConfig = {\n ...DEFAULT_STATUS_CONFIG,\n ...config,\n // Deep merge nested objects\n stateBehaviors: config.stateBehaviors\n ? { ...DEFAULT_STATUS_CONFIG.stateBehaviors, ...config.stateBehaviors }\n : DEFAULT_STATUS_CONFIG.stateBehaviors,\n workflow: config.workflow\n ? { ...DEFAULT_STATUS_CONFIG.workflow, ...config.workflow }\n : DEFAULT_STATUS_CONFIG.workflow,\n }\n\n if (config.metadata) {\n mergedConfig.metadata = { ...config.metadata }\n }\n\n return {\n id: SemanticType.Status,\n config: mergedConfig,\n }\n}\n\n/**\n * Default configuration for Status semantic.\n */\nexport const DEFAULT_STATUS_CONFIG: StatusConfig = {\n defaultState: 'draft',\n stateBehaviors: {\n draft: {\n isPublic: false,\n isEditable: true,\n isDeletable: true,\n },\n published: {\n isPublic: true,\n isEditable: true,\n isDeletable: false,\n },\n archived: {\n isPublic: false,\n isEditable: false,\n isDeletable: false,\n },\n },\n workflow: {\n requiresApproval: false,\n sendNotifications: false,\n logHistory: true,\n allowBulkChanges: false,\n },\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AppliedDataSemantic } from '../Semantics.js';
|
|
2
|
+
import { SemanticType } from '../Semantics.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the Summary semantic.
|
|
5
|
+
* Summary is a simple semantic without configuration options.
|
|
6
|
+
*/
|
|
7
|
+
export interface SummaryConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Custom metadata for the summary field.
|
|
10
|
+
*/
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Index signature to allow additional properties.
|
|
14
|
+
*/
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Default configuration for the Summary semantic.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_SUMMARY_CONFIG: SummaryConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a Summary semantic application.
|
|
23
|
+
* @param config - Optional configuration (not used for simple semantic)
|
|
24
|
+
* @returns AppliedDataSemantic for Summary
|
|
25
|
+
*/
|
|
26
|
+
export declare const createSummarySemantic: (config?: SummaryConfig) => AppliedDataSemantic;
|
|
27
|
+
/**
|
|
28
|
+
* Type guard to check if a semantic is a Summary semantic.
|
|
29
|
+
* @param semantic - The semantic to check
|
|
30
|
+
* @returns True if the semantic is a Summary semantic
|
|
31
|
+
*/
|
|
32
|
+
export declare const isSummarySemantic: (semantic: AppliedDataSemantic) => semantic is AppliedDataSemantic & {
|
|
33
|
+
id: SemanticType.Summary;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Extracts the configuration from a Summary semantic application.
|
|
37
|
+
* @param semantic - The semantic application
|
|
38
|
+
* @returns The Summary configuration or undefined if not a Summary semantic
|
|
39
|
+
*/
|
|
40
|
+
export declare const getSummaryConfig: (semantic: AppliedDataSemantic) => SummaryConfig | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Validates Summary semantic configuration.
|
|
43
|
+
* @returns True if the configuration is valid
|
|
44
|
+
*/
|
|
45
|
+
export declare const validateSummaryConfig: () => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Merges Summary configurations, with the second config taking precedence.
|
|
48
|
+
* @param base - The base configuration
|
|
49
|
+
* @param override - The configuration to merge on top
|
|
50
|
+
* @returns Merged configuration
|
|
51
|
+
*/
|
|
52
|
+
export declare const mergeSummaryConfig: (base: SummaryConfig, override: SummaryConfig) => SummaryConfig;
|
|
53
|
+
//# sourceMappingURL=Summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Summary.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/Summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAAkB,CAAA;AAEvD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,aAAa,KAAG,mBAG7D,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,mBAAmB,KAC5B,QAAQ,IAAI,mBAAmB,GAAG;IAAE,EAAE,EAAE,YAAY,CAAC,OAAO,CAAA;CAA0C,CAAA;AAEzG;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,mBAAmB,KAAG,aAAa,GAAG,SAKhF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,OAGxC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,aAAa,EAAE,UAAU,aAAa,KAAG,aAGjF,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SemanticType } from '../Semantics.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration for the Summary semantic.
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULT_SUMMARY_CONFIG = {};
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Summary semantic application.
|
|
8
|
+
* @param config - Optional configuration (not used for simple semantic)
|
|
9
|
+
* @returns AppliedDataSemantic for Summary
|
|
10
|
+
*/
|
|
11
|
+
export const createSummarySemantic = (config) => ({
|
|
12
|
+
id: SemanticType.Summary,
|
|
13
|
+
config: config ? { ...DEFAULT_SUMMARY_CONFIG, ...config } : { ...DEFAULT_SUMMARY_CONFIG },
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a semantic is a Summary semantic.
|
|
17
|
+
* @param semantic - The semantic to check
|
|
18
|
+
* @returns True if the semantic is a Summary semantic
|
|
19
|
+
*/
|
|
20
|
+
export const isSummarySemantic = (semantic) => semantic.id === SemanticType.Summary;
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the configuration from a Summary semantic application.
|
|
23
|
+
* @param semantic - The semantic application
|
|
24
|
+
* @returns The Summary configuration or undefined if not a Summary semantic
|
|
25
|
+
*/
|
|
26
|
+
export const getSummaryConfig = (semantic) => {
|
|
27
|
+
if (!isSummarySemantic(semantic)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return semantic.config;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Validates Summary semantic configuration.
|
|
34
|
+
* @returns True if the configuration is valid
|
|
35
|
+
*/
|
|
36
|
+
export const validateSummaryConfig = () => {
|
|
37
|
+
// No validation needed for simple semantic
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Merges Summary configurations, with the second config taking precedence.
|
|
42
|
+
* @param base - The base configuration
|
|
43
|
+
* @param override - The configuration to merge on top
|
|
44
|
+
* @returns Merged configuration
|
|
45
|
+
*/
|
|
46
|
+
export const mergeSummaryConfig = (base, override) => {
|
|
47
|
+
// No merging needed for simple semantic
|
|
48
|
+
return { ...base, ...override };
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=Summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Summary.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/Summary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAiB9C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB,EAAE,CAAA;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAsB,EAAuB,EAAE,CAAC,CAAC;IACrF,EAAE,EAAE,YAAY,CAAC,OAAO;IACxB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,EAAE;CAC1F,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,QAA6B,EACmC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,OAAO,CAAA;AAEzG;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAA6B,EAA6B,EAAE;IAC3F,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,QAAQ,CAAC,MAAmC,CAAA;AACrD,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAY,EAAE;IACjD,2CAA2C;IAC3C,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAmB,EAAE,QAAuB,EAAiB,EAAE;IAChG,wCAAwC;IACxC,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAA;AACjC,CAAC,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Configuration for the Summary semantic.\n * Summary is a simple semantic without configuration options.\n */\nexport interface SummaryConfig {\n /**\n * Custom metadata for the summary field.\n */\n metadata?: Record<string, unknown>\n /**\n * Index signature to allow additional properties.\n */\n [key: string]: unknown\n}\n\n/**\n * Default configuration for the Summary semantic.\n */\nexport const DEFAULT_SUMMARY_CONFIG: SummaryConfig = {}\n\n/**\n * Creates a Summary semantic application.\n * @param config - Optional configuration (not used for simple semantic)\n * @returns AppliedDataSemantic for Summary\n */\nexport const createSummarySemantic = (config?: SummaryConfig): AppliedDataSemantic => ({\n id: SemanticType.Summary,\n config: config ? { ...DEFAULT_SUMMARY_CONFIG, ...config } : { ...DEFAULT_SUMMARY_CONFIG },\n})\n\n/**\n * Type guard to check if a semantic is a Summary semantic.\n * @param semantic - The semantic to check\n * @returns True if the semantic is a Summary semantic\n */\nexport const isSummarySemantic = (\n semantic: AppliedDataSemantic\n): semantic is AppliedDataSemantic & { id: SemanticType.Summary } => semantic.id === SemanticType.Summary\n\n/**\n * Extracts the configuration from a Summary semantic application.\n * @param semantic - The semantic application\n * @returns The Summary configuration or undefined if not a Summary semantic\n */\nexport const getSummaryConfig = (semantic: AppliedDataSemantic): SummaryConfig | undefined => {\n if (!isSummarySemantic(semantic)) {\n return undefined\n }\n return semantic.config as SummaryConfig | undefined\n}\n\n/**\n * Validates Summary semantic configuration.\n * @returns True if the configuration is valid\n */\nexport const validateSummaryConfig = (): boolean => {\n // No validation needed for simple semantic\n return true\n}\n\n/**\n * Merges Summary configurations, with the second config taking precedence.\n * @param base - The base configuration\n * @param override - The configuration to merge on top\n * @returns Merged configuration\n */\nexport const mergeSummaryConfig = (base: SummaryConfig, override: SummaryConfig): SummaryConfig => {\n // No merging needed for simple semantic\n return { ...base, ...override }\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AppliedDataSemantic } from '../Semantics.js';
|
|
2
|
+
import { SemanticType } from '../Semantics.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the Tags semantic.
|
|
5
|
+
* Controls allowed tags, validation, and formatting for associations.
|
|
6
|
+
*/
|
|
7
|
+
export interface TagsConfig {
|
|
8
|
+
/**
|
|
9
|
+
* List of allowed tags.
|
|
10
|
+
*/
|
|
11
|
+
allowedTags?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Whether to allow custom tags not in the allowedTags list.
|
|
14
|
+
*/
|
|
15
|
+
allowCustomTags?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether tags are case sensitive.
|
|
18
|
+
*/
|
|
19
|
+
caseSensitive?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to allow Unicode characters in tags.
|
|
22
|
+
*/
|
|
23
|
+
allowUnicode?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Custom metadata for the tags association.
|
|
26
|
+
*/
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Index signature to allow additional properties.
|
|
30
|
+
*/
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Type-safe configuration for Tags semantic.
|
|
35
|
+
*/
|
|
36
|
+
export interface AppliedTagsSemantic extends AppliedDataSemantic {
|
|
37
|
+
id: SemanticType.Tags;
|
|
38
|
+
config?: TagsConfig;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Type guard to check if a semantic is a Tags semantic.
|
|
42
|
+
*/
|
|
43
|
+
export declare const isTagsSemantic: (semantic: AppliedDataSemantic) => semantic is AppliedTagsSemantic;
|
|
44
|
+
/**
|
|
45
|
+
* Helper function to create a Tags semantic with configuration.
|
|
46
|
+
*/
|
|
47
|
+
export declare const createTagsSemantic: (config?: TagsConfig) => AppliedTagsSemantic;
|
|
48
|
+
/**
|
|
49
|
+
* Default configuration for Tags semantic.
|
|
50
|
+
*/
|
|
51
|
+
export declare const DEFAULT_TAGS_CONFIG: TagsConfig;
|
|
52
|
+
//# sourceMappingURL=Tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/Tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,EAAE,EAAE,YAAY,CAAC,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,mBAAmB,KAAG,QAAQ,IAAI,mBAE1E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAQ,UAAe,KAAG,mBAa5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAIjC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SemanticType } from '../Semantics.js';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a semantic is a Tags semantic.
|
|
4
|
+
*/
|
|
5
|
+
export const isTagsSemantic = (semantic) => {
|
|
6
|
+
return semantic.id === SemanticType.Tags;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to create a Tags semantic with configuration.
|
|
10
|
+
*/
|
|
11
|
+
export const createTagsSemantic = (config = {}) => {
|
|
12
|
+
const mergedConfig = {
|
|
13
|
+
...DEFAULT_TAGS_CONFIG,
|
|
14
|
+
...config,
|
|
15
|
+
};
|
|
16
|
+
if (config.metadata) {
|
|
17
|
+
mergedConfig.metadata = { ...config.metadata };
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
id: SemanticType.Tags,
|
|
21
|
+
config: mergedConfig,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Default configuration for Tags semantic.
|
|
26
|
+
*/
|
|
27
|
+
export const DEFAULT_TAGS_CONFIG = {
|
|
28
|
+
allowCustomTags: true,
|
|
29
|
+
caseSensitive: false,
|
|
30
|
+
allowUnicode: false,
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=Tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tags.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/Tags.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAyC9C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAA6B,EAAmC,EAAE;IAC/F,OAAO,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,IAAI,CAAA;AAC1C,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAqB,EAAE,EAAuB,EAAE;IACjF,MAAM,YAAY,GAAG;QACnB,GAAG,mBAAmB;QACtB,GAAG,MAAM;KACV,CAAA;IACD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAChD,CAAC;IAED,OAAO;QACL,EAAE,EAAE,YAAY,CAAC,IAAI;QACrB,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAe;IAC7C,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,KAAK;IACpB,YAAY,EAAE,KAAK;CACpB,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Configuration options for the Tags semantic.\n * Controls allowed tags, validation, and formatting for associations.\n */\nexport interface TagsConfig {\n /**\n * List of allowed tags.\n */\n allowedTags?: string[]\n /**\n * Whether to allow custom tags not in the allowedTags list.\n */\n allowCustomTags?: boolean\n /**\n * Whether tags are case sensitive.\n */\n caseSensitive?: boolean\n /**\n * Whether to allow Unicode characters in tags.\n */\n allowUnicode?: boolean\n /**\n * Custom metadata for the tags association.\n */\n metadata?: Record<string, unknown>\n /**\n * Index signature to allow additional properties.\n */\n [key: string]: unknown\n}\n\n/**\n * Type-safe configuration for Tags semantic.\n */\nexport interface AppliedTagsSemantic extends AppliedDataSemantic {\n id: SemanticType.Tags\n config?: TagsConfig\n}\n\n/**\n * Type guard to check if a semantic is a Tags semantic.\n */\nexport const isTagsSemantic = (semantic: AppliedDataSemantic): semantic is AppliedTagsSemantic => {\n return semantic.id === SemanticType.Tags\n}\n\n/**\n * Helper function to create a Tags semantic with configuration.\n */\nexport const createTagsSemantic = (config: TagsConfig = {}): AppliedTagsSemantic => {\n const mergedConfig = {\n ...DEFAULT_TAGS_CONFIG,\n ...config,\n }\n if (config.metadata) {\n mergedConfig.metadata = { ...config.metadata }\n }\n\n return {\n id: SemanticType.Tags,\n config: mergedConfig,\n }\n}\n\n/**\n * Default configuration for Tags semantic.\n */\nexport const DEFAULT_TAGS_CONFIG: TagsConfig = {\n allowCustomTags: true,\n caseSensitive: false,\n allowUnicode: false,\n}\n"]}
|