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