@meerkapp/wms-contracts 0.2.0 → 0.3.0-beta.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/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,80 @@ 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
+ sku_dependent: z882.boolean().default(false),
10481
+ validation: z882.object({
10482
+ min: z882.number().optional(),
10483
+ max: z882.number().optional()
10484
+ }).optional(),
10485
+ ui: z882.object({
10486
+ suffix: z882.string().optional()
10487
+ }).optional()
10488
+ });
10489
+ var SelectOptionSchema = z882.object({
10490
+ label: z882.string().min(1),
10491
+ value: z882.string().min(1)
10492
+ });
10493
+ var SelectCharacteristicSchema = z882.object({
10494
+ key: z882.string().min(1),
10495
+ label: z882.string().min(1),
10496
+ type: z882.literal("select"),
10497
+ required: z882.boolean().default(false),
10498
+ sku_dependent: z882.boolean().default(false),
10499
+ options: z882.array(SelectOptionSchema).min(1)
10500
+ });
10501
+ var CharacteristicSchema = z882.discriminatedUnion("type", [
10502
+ NumberCharacteristicSchema,
10503
+ SelectCharacteristicSchema
10504
+ ]);
10505
+ var CharacteristicsSchemeSchema = z882.array(CharacteristicSchema);
10506
+ var SKU_TEMPLATE_REGEX = /^(\{(brand|type|counter)(?::\d+)?\}|\{[a-z_]+(?::\d+)?\}|[^{}]+)+$/;
10507
+ var ProductTypeBaseSchema = z882.object({
10508
+ name: z882.string().min(1),
10509
+ code: z882.string().min(1).max(10).regex(/^[A-ZА-ЯЁ0-9]+$/, "Code must be uppercase letters and digits"),
10510
+ defaultWriteoffStrategy: z882.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]).default("FIFO"),
10511
+ skuMode: z882.enum(["GLOBAL", "CUSTOM"]).default("GLOBAL"),
10512
+ skuTemplate: z882.string().regex(SKU_TEMPLATE_REGEX).optional().nullable(),
10513
+ characteristicsScheme: CharacteristicsSchemeSchema.optional().nullable()
10514
+ });
10515
+ function refineCustomSkuTemplate(data) {
10516
+ if (data.skuMode !== "CUSTOM" || !data.skuTemplate || !data.characteristicsScheme) return true;
10517
+ const schemeKeys = new Set(data.characteristicsScheme.map((c) => c.key));
10518
+ const templateKeys = [...data.skuTemplate.matchAll(/\{([a-z_]+)(?::\d+)?\}/g)].map(([, key]) => key).filter((key) => !["brand", "type", "counter"].includes(key));
10519
+ return templateKeys.every((key) => schemeKeys.has(key));
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(refineCustomSkuTemplate, {
10525
+ message: "All characteristic keys in skuTemplate must exist in characteristicsScheme",
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(refineCustomSkuTemplate, {
10532
+ message: "All characteristic keys in skuTemplate must exist in characteristicsScheme",
10533
+ path: ["skuTemplate"]
10534
+ });
10535
+ var ProductTypeSchema = z882.object({
10536
+ id: z882.number(),
10537
+ name: z882.string(),
10538
+ code: z882.string(),
10539
+ defaultWriteoffStrategy: z882.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]),
10540
+ skuMode: z882.enum(["GLOBAL", "CUSTOM"]),
10541
+ skuTemplate: z882.string().nullable(),
10542
+ skuCounter: z882.number(),
10543
+ characteristicsScheme: CharacteristicsSchemeSchema.nullable(),
10544
+ updatedAt: z882.string()
10545
+ });
10469
10546
  export {
10470
10547
  ALL_PERMISSIONS,
10471
10548
  BoolFieldUpdateOperationsInputObjectSchema,
@@ -10474,6 +10551,8 @@ export {
10474
10551
  BoolFilterObjectZodSchema,
10475
10552
  BoolWithAggregatesFilterObjectSchema,
10476
10553
  BoolWithAggregatesFilterObjectZodSchema,
10554
+ CharacteristicSchema,
10555
+ CharacteristicsSchemeSchema,
10477
10556
  CountryAggregateResultSchema,
10478
10557
  CountryAggregateSchema,
10479
10558
  CountryAggregateZodSchema,
@@ -10611,6 +10690,7 @@ export {
10611
10690
  CreateEmployeeSchema,
10612
10691
  CreateLocalitySchema,
10613
10692
  CreateOrganizationSchema,
10693
+ CreateProductTypeSchema,
10614
10694
  CreateRoleSchema,
10615
10695
  CreateWarehouseSchema,
10616
10696
  DateTimeFieldUpdateOperationsInputObjectSchema,
@@ -11789,6 +11869,7 @@ export {
11789
11869
  OrganizationWhereUniqueInputObjectSchema,
11790
11870
  OrganizationWhereUniqueInputObjectZodSchema,
11791
11871
  PaginationQuerySchema,
11872
+ ProductTypeSchema,
11792
11873
  QueryModeSchema,
11793
11874
  RolePermissionItemSchema,
11794
11875
  RoleSchema,
@@ -11916,6 +11997,7 @@ export {
11916
11997
  UpdateOrganizationSchema,
11917
11998
  UpdateOwnPasswordSchema,
11918
11999
  UpdateOwnProfileSchema,
12000
+ UpdateProductTypeSchema,
11919
12001
  UpdateRoleSchema,
11920
12002
  UpdateWarehouseSchema,
11921
12003
  UuidFilterObjectSchema,