@meerkapp/wms-contracts 0.3.0-beta.1 → 0.3.0-beta.2
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 +15 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -89
- package/dist/index.d.ts +14 -89
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12172,7 +12172,6 @@ var NumberCharacteristicSchema = import_zod9.z.object({
|
|
|
12172
12172
|
label: import_zod9.z.string().min(1),
|
|
12173
12173
|
type: import_zod9.z.literal("number"),
|
|
12174
12174
|
required: import_zod9.z.boolean().default(false),
|
|
12175
|
-
sku_dependent: import_zod9.z.boolean().default(false),
|
|
12176
12175
|
validation: import_zod9.z.object({
|
|
12177
12176
|
min: import_zod9.z.number().optional(),
|
|
12178
12177
|
max: import_zod9.z.number().optional()
|
|
@@ -12190,7 +12189,6 @@ var SelectCharacteristicSchema = import_zod9.z.object({
|
|
|
12190
12189
|
label: import_zod9.z.string().min(1),
|
|
12191
12190
|
type: import_zod9.z.literal("select"),
|
|
12192
12191
|
required: import_zod9.z.boolean().default(false),
|
|
12193
|
-
sku_dependent: import_zod9.z.boolean().default(false),
|
|
12194
12192
|
options: import_zod9.z.array(SelectOptionSchema).min(1)
|
|
12195
12193
|
});
|
|
12196
12194
|
var CharacteristicSchema = import_zod9.z.discriminatedUnion("type", [
|
|
@@ -12198,39 +12196,40 @@ var CharacteristicSchema = import_zod9.z.discriminatedUnion("type", [
|
|
|
12198
12196
|
SelectCharacteristicSchema
|
|
12199
12197
|
]);
|
|
12200
12198
|
var CharacteristicsSchemeSchema = import_zod9.z.array(CharacteristicSchema);
|
|
12201
|
-
var SKU_TEMPLATE_REGEX = /^(\{(brand|
|
|
12199
|
+
var SKU_TEMPLATE_REGEX = /^(\{(brand|counter)(?::\d+)?\}|\{[a-z_]+(?::\d+)?\}|[^{}]+)+$/;
|
|
12200
|
+
var RESERVED_SKU_KEYS = /* @__PURE__ */ new Set(["brand", "counter"]);
|
|
12201
|
+
function validateSkuTemplate(data) {
|
|
12202
|
+
if (data.skuMode !== "CUSTOM" || !data.skuTemplate || !data.characteristicsScheme) return true;
|
|
12203
|
+
const requiredKeys = new Set(
|
|
12204
|
+
data.characteristicsScheme.filter((c) => c.required).map((c) => c.key)
|
|
12205
|
+
);
|
|
12206
|
+
const templateKeys = [...data.skuTemplate.matchAll(/\{([a-z_]+)(?::\d+)?\}/g)].map(([, key]) => key).filter((key) => !RESERVED_SKU_KEYS.has(key));
|
|
12207
|
+
return templateKeys.every((key) => requiredKeys.has(key));
|
|
12208
|
+
}
|
|
12202
12209
|
var ProductTypeBaseSchema = import_zod9.z.object({
|
|
12203
12210
|
name: import_zod9.z.string().min(1),
|
|
12204
|
-
code: import_zod9.z.string().min(1).max(10).regex(/^[A-ZА-ЯЁ0-9]+$/, "Code must be uppercase letters and digits"),
|
|
12205
12211
|
defaultWriteoffStrategy: import_zod9.z.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]).default("FIFO"),
|
|
12206
12212
|
skuMode: import_zod9.z.enum(["GLOBAL", "CUSTOM"]).default("GLOBAL"),
|
|
12207
|
-
skuTemplate: import_zod9.z.string().regex(SKU_TEMPLATE_REGEX).optional().nullable(),
|
|
12213
|
+
skuTemplate: import_zod9.z.string().regex(SKU_TEMPLATE_REGEX, "Invalid SKU template format").optional().nullable(),
|
|
12208
12214
|
characteristicsScheme: CharacteristicsSchemeSchema.optional().nullable()
|
|
12209
12215
|
});
|
|
12210
|
-
function refineCustomSkuTemplate(data) {
|
|
12211
|
-
if (data.skuMode !== "CUSTOM" || !data.skuTemplate || !data.characteristicsScheme) return true;
|
|
12212
|
-
const schemeKeys = new Set(data.characteristicsScheme.map((c) => c.key));
|
|
12213
|
-
const templateKeys = [...data.skuTemplate.matchAll(/\{([a-z_]+)(?::\d+)?\}/g)].map(([, key]) => key).filter((key) => !["brand", "type", "counter"].includes(key));
|
|
12214
|
-
return templateKeys.every((key) => schemeKeys.has(key));
|
|
12215
|
-
}
|
|
12216
12216
|
var CreateProductTypeSchema = ProductTypeBaseSchema.refine(
|
|
12217
12217
|
(data) => !(data.skuMode === "CUSTOM" && !data.skuTemplate),
|
|
12218
12218
|
{ message: "skuTemplate is required for CUSTOM sku mode", path: ["skuTemplate"] }
|
|
12219
|
-
).refine(
|
|
12220
|
-
message: "All characteristic keys in skuTemplate must
|
|
12219
|
+
).refine(validateSkuTemplate, {
|
|
12220
|
+
message: "All characteristic keys in skuTemplate must be required characteristics",
|
|
12221
12221
|
path: ["skuTemplate"]
|
|
12222
12222
|
});
|
|
12223
12223
|
var UpdateProductTypeSchema = ProductTypeBaseSchema.partial().refine(
|
|
12224
12224
|
(data) => !(data.skuMode === "CUSTOM" && data.skuTemplate === null),
|
|
12225
12225
|
{ message: "skuTemplate cannot be null for CUSTOM sku mode", path: ["skuTemplate"] }
|
|
12226
|
-
).refine(
|
|
12227
|
-
message: "All characteristic keys in skuTemplate must
|
|
12226
|
+
).refine(validateSkuTemplate, {
|
|
12227
|
+
message: "All characteristic keys in skuTemplate must be required characteristics",
|
|
12228
12228
|
path: ["skuTemplate"]
|
|
12229
12229
|
});
|
|
12230
12230
|
var ProductTypeSchema = import_zod9.z.object({
|
|
12231
12231
|
id: import_zod9.z.number(),
|
|
12232
12232
|
name: import_zod9.z.string(),
|
|
12233
|
-
code: import_zod9.z.string(),
|
|
12234
12233
|
defaultWriteoffStrategy: import_zod9.z.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]),
|
|
12235
12234
|
skuMode: import_zod9.z.enum(["GLOBAL", "CUSTOM"]),
|
|
12236
12235
|
skuTemplate: import_zod9.z.string().nullable(),
|