@meerkapp/wms-contracts 0.3.0-beta.2 → 0.3.0-beta.3
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/dist/index.cjs +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +348 -0
- package/dist/index.d.ts +348 -0
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12191,20 +12191,37 @@ var SelectCharacteristicSchema = import_zod9.z.object({
|
|
|
12191
12191
|
required: import_zod9.z.boolean().default(false),
|
|
12192
12192
|
options: import_zod9.z.array(SelectOptionSchema).min(1)
|
|
12193
12193
|
});
|
|
12194
|
+
var ToggleCharacteristicSchema = import_zod9.z.object({
|
|
12195
|
+
key: import_zod9.z.string().min(1),
|
|
12196
|
+
label: import_zod9.z.string().min(1),
|
|
12197
|
+
type: import_zod9.z.literal("toggle"),
|
|
12198
|
+
required: import_zod9.z.boolean().default(false),
|
|
12199
|
+
true_label: import_zod9.z.string().min(1),
|
|
12200
|
+
false_label: import_zod9.z.string().min(1)
|
|
12201
|
+
});
|
|
12202
|
+
var CheckboxCharacteristicSchema = import_zod9.z.object({
|
|
12203
|
+
key: import_zod9.z.string().min(1),
|
|
12204
|
+
label: import_zod9.z.string().min(1),
|
|
12205
|
+
type: import_zod9.z.literal("checkbox"),
|
|
12206
|
+
required: import_zod9.z.boolean().default(false)
|
|
12207
|
+
});
|
|
12194
12208
|
var CharacteristicSchema = import_zod9.z.discriminatedUnion("type", [
|
|
12195
12209
|
NumberCharacteristicSchema,
|
|
12196
|
-
SelectCharacteristicSchema
|
|
12210
|
+
SelectCharacteristicSchema,
|
|
12211
|
+
ToggleCharacteristicSchema,
|
|
12212
|
+
CheckboxCharacteristicSchema
|
|
12197
12213
|
]);
|
|
12198
12214
|
var CharacteristicsSchemeSchema = import_zod9.z.array(CharacteristicSchema);
|
|
12199
12215
|
var SKU_TEMPLATE_REGEX = /^(\{(brand|counter)(?::\d+)?\}|\{[a-z_]+(?::\d+)?\}|[^{}]+)+$/;
|
|
12200
12216
|
var RESERVED_SKU_KEYS = /* @__PURE__ */ new Set(["brand", "counter"]);
|
|
12217
|
+
var SKU_COMPATIBLE_TYPES = /* @__PURE__ */ new Set(["number", "select", "toggle"]);
|
|
12201
12218
|
function validateSkuTemplate(data) {
|
|
12202
12219
|
if (data.skuMode !== "CUSTOM" || !data.skuTemplate || !data.characteristicsScheme) return true;
|
|
12203
|
-
const
|
|
12204
|
-
data.characteristicsScheme.filter((c) => c.required).map((c) => c.key)
|
|
12220
|
+
const skuCompatibleKeys = new Set(
|
|
12221
|
+
data.characteristicsScheme.filter((c) => c.required && SKU_COMPATIBLE_TYPES.has(c.type)).map((c) => c.key)
|
|
12205
12222
|
);
|
|
12206
12223
|
const templateKeys = [...data.skuTemplate.matchAll(/\{([a-z_]+)(?::\d+)?\}/g)].map(([, key]) => key).filter((key) => !RESERVED_SKU_KEYS.has(key));
|
|
12207
|
-
return templateKeys.every((key) =>
|
|
12224
|
+
return templateKeys.every((key) => skuCompatibleKeys.has(key));
|
|
12208
12225
|
}
|
|
12209
12226
|
var ProductTypeBaseSchema = import_zod9.z.object({
|
|
12210
12227
|
name: import_zod9.z.string().min(1),
|
|
@@ -12217,14 +12234,14 @@ var CreateProductTypeSchema = ProductTypeBaseSchema.refine(
|
|
|
12217
12234
|
(data) => !(data.skuMode === "CUSTOM" && !data.skuTemplate),
|
|
12218
12235
|
{ message: "skuTemplate is required for CUSTOM sku mode", path: ["skuTemplate"] }
|
|
12219
12236
|
).refine(validateSkuTemplate, {
|
|
12220
|
-
message: "All
|
|
12237
|
+
message: "All keys in skuTemplate must be required characteristics of type number, select or toggle",
|
|
12221
12238
|
path: ["skuTemplate"]
|
|
12222
12239
|
});
|
|
12223
12240
|
var UpdateProductTypeSchema = ProductTypeBaseSchema.partial().refine(
|
|
12224
12241
|
(data) => !(data.skuMode === "CUSTOM" && data.skuTemplate === null),
|
|
12225
12242
|
{ message: "skuTemplate cannot be null for CUSTOM sku mode", path: ["skuTemplate"] }
|
|
12226
12243
|
).refine(validateSkuTemplate, {
|
|
12227
|
-
message: "All
|
|
12244
|
+
message: "All keys in skuTemplate must be required characteristics of type number, select or toggle",
|
|
12228
12245
|
path: ["skuTemplate"]
|
|
12229
12246
|
});
|
|
12230
12247
|
var ProductTypeSchema = import_zod9.z.object({
|