@meerkapp/wms-contracts 0.2.0 → 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 +87 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +813 -2
- package/dist/index.d.ts +813 -2
- package/dist/index.js +82 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10353,7 +10353,10 @@ var ALL_PERMISSIONS = [
|
|
|
10353
10353
|
"employee:update:own:avatar",
|
|
10354
10354
|
// role management
|
|
10355
10355
|
"role:create",
|
|
10356
|
-
"role:update"
|
|
10356
|
+
"role:update",
|
|
10357
|
+
// product type management
|
|
10358
|
+
"product_type:create",
|
|
10359
|
+
"product_type:update"
|
|
10357
10360
|
];
|
|
10358
10361
|
var LoginSchema = z875.object({
|
|
10359
10362
|
email: z875.string().email(),
|
|
@@ -10466,6 +10469,79 @@ var UpdateRoleSchema = z881.object({
|
|
|
10466
10469
|
color: z881.string().optional(),
|
|
10467
10470
|
permissionIds: z881.array(z881.number().int()).optional()
|
|
10468
10471
|
});
|
|
10472
|
+
|
|
10473
|
+
// src/modules/product-type/index.ts
|
|
10474
|
+
import { z as z882 } from "zod";
|
|
10475
|
+
var NumberCharacteristicSchema = z882.object({
|
|
10476
|
+
key: z882.string().min(1),
|
|
10477
|
+
label: z882.string().min(1),
|
|
10478
|
+
type: z882.literal("number"),
|
|
10479
|
+
required: z882.boolean().default(false),
|
|
10480
|
+
validation: z882.object({
|
|
10481
|
+
min: z882.number().optional(),
|
|
10482
|
+
max: z882.number().optional()
|
|
10483
|
+
}).optional(),
|
|
10484
|
+
ui: z882.object({
|
|
10485
|
+
suffix: z882.string().optional()
|
|
10486
|
+
}).optional()
|
|
10487
|
+
});
|
|
10488
|
+
var SelectOptionSchema = z882.object({
|
|
10489
|
+
label: z882.string().min(1),
|
|
10490
|
+
value: z882.string().min(1)
|
|
10491
|
+
});
|
|
10492
|
+
var SelectCharacteristicSchema = z882.object({
|
|
10493
|
+
key: z882.string().min(1),
|
|
10494
|
+
label: z882.string().min(1),
|
|
10495
|
+
type: z882.literal("select"),
|
|
10496
|
+
required: z882.boolean().default(false),
|
|
10497
|
+
options: z882.array(SelectOptionSchema).min(1)
|
|
10498
|
+
});
|
|
10499
|
+
var CharacteristicSchema = z882.discriminatedUnion("type", [
|
|
10500
|
+
NumberCharacteristicSchema,
|
|
10501
|
+
SelectCharacteristicSchema
|
|
10502
|
+
]);
|
|
10503
|
+
var CharacteristicsSchemeSchema = z882.array(CharacteristicSchema);
|
|
10504
|
+
var SKU_TEMPLATE_REGEX = /^(\{(brand|counter)(?::\d+)?\}|\{[a-z_]+(?::\d+)?\}|[^{}]+)+$/;
|
|
10505
|
+
var RESERVED_SKU_KEYS = /* @__PURE__ */ new Set(["brand", "counter"]);
|
|
10506
|
+
function validateSkuTemplate(data) {
|
|
10507
|
+
if (data.skuMode !== "CUSTOM" || !data.skuTemplate || !data.characteristicsScheme) return true;
|
|
10508
|
+
const requiredKeys = new Set(
|
|
10509
|
+
data.characteristicsScheme.filter((c) => c.required).map((c) => c.key)
|
|
10510
|
+
);
|
|
10511
|
+
const templateKeys = [...data.skuTemplate.matchAll(/\{([a-z_]+)(?::\d+)?\}/g)].map(([, key]) => key).filter((key) => !RESERVED_SKU_KEYS.has(key));
|
|
10512
|
+
return templateKeys.every((key) => requiredKeys.has(key));
|
|
10513
|
+
}
|
|
10514
|
+
var ProductTypeBaseSchema = z882.object({
|
|
10515
|
+
name: z882.string().min(1),
|
|
10516
|
+
defaultWriteoffStrategy: z882.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]).default("FIFO"),
|
|
10517
|
+
skuMode: z882.enum(["GLOBAL", "CUSTOM"]).default("GLOBAL"),
|
|
10518
|
+
skuTemplate: z882.string().regex(SKU_TEMPLATE_REGEX, "Invalid SKU template format").optional().nullable(),
|
|
10519
|
+
characteristicsScheme: CharacteristicsSchemeSchema.optional().nullable()
|
|
10520
|
+
});
|
|
10521
|
+
var CreateProductTypeSchema = ProductTypeBaseSchema.refine(
|
|
10522
|
+
(data) => !(data.skuMode === "CUSTOM" && !data.skuTemplate),
|
|
10523
|
+
{ message: "skuTemplate is required for CUSTOM sku mode", path: ["skuTemplate"] }
|
|
10524
|
+
).refine(validateSkuTemplate, {
|
|
10525
|
+
message: "All characteristic keys in skuTemplate must be required characteristics",
|
|
10526
|
+
path: ["skuTemplate"]
|
|
10527
|
+
});
|
|
10528
|
+
var UpdateProductTypeSchema = ProductTypeBaseSchema.partial().refine(
|
|
10529
|
+
(data) => !(data.skuMode === "CUSTOM" && data.skuTemplate === null),
|
|
10530
|
+
{ message: "skuTemplate cannot be null for CUSTOM sku mode", path: ["skuTemplate"] }
|
|
10531
|
+
).refine(validateSkuTemplate, {
|
|
10532
|
+
message: "All characteristic keys in skuTemplate must be required characteristics",
|
|
10533
|
+
path: ["skuTemplate"]
|
|
10534
|
+
});
|
|
10535
|
+
var ProductTypeSchema = z882.object({
|
|
10536
|
+
id: z882.number(),
|
|
10537
|
+
name: z882.string(),
|
|
10538
|
+
defaultWriteoffStrategy: z882.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]),
|
|
10539
|
+
skuMode: z882.enum(["GLOBAL", "CUSTOM"]),
|
|
10540
|
+
skuTemplate: z882.string().nullable(),
|
|
10541
|
+
skuCounter: z882.number(),
|
|
10542
|
+
characteristicsScheme: CharacteristicsSchemeSchema.nullable(),
|
|
10543
|
+
updatedAt: z882.string()
|
|
10544
|
+
});
|
|
10469
10545
|
export {
|
|
10470
10546
|
ALL_PERMISSIONS,
|
|
10471
10547
|
BoolFieldUpdateOperationsInputObjectSchema,
|
|
@@ -10474,6 +10550,8 @@ export {
|
|
|
10474
10550
|
BoolFilterObjectZodSchema,
|
|
10475
10551
|
BoolWithAggregatesFilterObjectSchema,
|
|
10476
10552
|
BoolWithAggregatesFilterObjectZodSchema,
|
|
10553
|
+
CharacteristicSchema,
|
|
10554
|
+
CharacteristicsSchemeSchema,
|
|
10477
10555
|
CountryAggregateResultSchema,
|
|
10478
10556
|
CountryAggregateSchema,
|
|
10479
10557
|
CountryAggregateZodSchema,
|
|
@@ -10611,6 +10689,7 @@ export {
|
|
|
10611
10689
|
CreateEmployeeSchema,
|
|
10612
10690
|
CreateLocalitySchema,
|
|
10613
10691
|
CreateOrganizationSchema,
|
|
10692
|
+
CreateProductTypeSchema,
|
|
10614
10693
|
CreateRoleSchema,
|
|
10615
10694
|
CreateWarehouseSchema,
|
|
10616
10695
|
DateTimeFieldUpdateOperationsInputObjectSchema,
|
|
@@ -11789,6 +11868,7 @@ export {
|
|
|
11789
11868
|
OrganizationWhereUniqueInputObjectSchema,
|
|
11790
11869
|
OrganizationWhereUniqueInputObjectZodSchema,
|
|
11791
11870
|
PaginationQuerySchema,
|
|
11871
|
+
ProductTypeSchema,
|
|
11792
11872
|
QueryModeSchema,
|
|
11793
11873
|
RolePermissionItemSchema,
|
|
11794
11874
|
RoleSchema,
|
|
@@ -11916,6 +11996,7 @@ export {
|
|
|
11916
11996
|
UpdateOrganizationSchema,
|
|
11917
11997
|
UpdateOwnPasswordSchema,
|
|
11918
11998
|
UpdateOwnProfileSchema,
|
|
11999
|
+
UpdateProductTypeSchema,
|
|
11919
12000
|
UpdateRoleSchema,
|
|
11920
12001
|
UpdateWarehouseSchema,
|
|
11921
12002
|
UuidFilterObjectSchema,
|