@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.cjs CHANGED
@@ -37,6 +37,8 @@ __export(index_exports, {
37
37
  BoolFilterObjectZodSchema: () => BoolFilterObjectZodSchema,
38
38
  BoolWithAggregatesFilterObjectSchema: () => BoolWithAggregatesFilterObjectSchema,
39
39
  BoolWithAggregatesFilterObjectZodSchema: () => BoolWithAggregatesFilterObjectZodSchema,
40
+ CharacteristicSchema: () => CharacteristicSchema,
41
+ CharacteristicsSchemeSchema: () => CharacteristicsSchemeSchema,
40
42
  CountryAggregateResultSchema: () => CountryAggregateResultSchema,
41
43
  CountryAggregateSchema: () => CountryAggregateSchema,
42
44
  CountryAggregateZodSchema: () => CountryAggregateZodSchema,
@@ -174,6 +176,7 @@ __export(index_exports, {
174
176
  CreateEmployeeSchema: () => CreateEmployeeSchema,
175
177
  CreateLocalitySchema: () => CreateLocalitySchema,
176
178
  CreateOrganizationSchema: () => CreateOrganizationSchema,
179
+ CreateProductTypeSchema: () => CreateProductTypeSchema,
177
180
  CreateRoleSchema: () => CreateRoleSchema,
178
181
  CreateWarehouseSchema: () => CreateWarehouseSchema,
179
182
  DateTimeFieldUpdateOperationsInputObjectSchema: () => DateTimeFieldUpdateOperationsInputObjectSchema,
@@ -1352,6 +1355,7 @@ __export(index_exports, {
1352
1355
  OrganizationWhereUniqueInputObjectSchema: () => OrganizationWhereUniqueInputObjectSchema,
1353
1356
  OrganizationWhereUniqueInputObjectZodSchema: () => OrganizationWhereUniqueInputObjectZodSchema,
1354
1357
  PaginationQuerySchema: () => PaginationQuerySchema,
1358
+ ProductTypeSchema: () => ProductTypeSchema,
1355
1359
  QueryModeSchema: () => QueryModeSchema,
1356
1360
  RolePermissionItemSchema: () => RolePermissionItemSchema,
1357
1361
  RoleSchema: () => RoleSchema,
@@ -1479,6 +1483,7 @@ __export(index_exports, {
1479
1483
  UpdateOrganizationSchema: () => UpdateOrganizationSchema,
1480
1484
  UpdateOwnPasswordSchema: () => UpdateOwnPasswordSchema,
1481
1485
  UpdateOwnProfileSchema: () => UpdateOwnProfileSchema,
1486
+ UpdateProductTypeSchema: () => UpdateProductTypeSchema,
1482
1487
  UpdateRoleSchema: () => UpdateRoleSchema,
1483
1488
  UpdateWarehouseSchema: () => UpdateWarehouseSchema,
1484
1489
  UuidFilterObjectSchema: () => UuidFilterObjectSchema,
@@ -12043,7 +12048,10 @@ var ALL_PERMISSIONS = [
12043
12048
  "employee:update:own:avatar",
12044
12049
  // role management
12045
12050
  "role:create",
12046
- "role:update"
12051
+ "role:update",
12052
+ // product type management
12053
+ "product_type:create",
12054
+ "product_type:update"
12047
12055
  ];
12048
12056
  var LoginSchema = import_zod2.z.object({
12049
12057
  email: import_zod2.z.string().email(),
@@ -12156,6 +12164,80 @@ var UpdateRoleSchema = import_zod8.z.object({
12156
12164
  color: import_zod8.z.string().optional(),
12157
12165
  permissionIds: import_zod8.z.array(import_zod8.z.number().int()).optional()
12158
12166
  });
12167
+
12168
+ // src/modules/product-type/index.ts
12169
+ var import_zod9 = require("zod");
12170
+ var NumberCharacteristicSchema = import_zod9.z.object({
12171
+ key: import_zod9.z.string().min(1),
12172
+ label: import_zod9.z.string().min(1),
12173
+ type: import_zod9.z.literal("number"),
12174
+ required: import_zod9.z.boolean().default(false),
12175
+ sku_dependent: import_zod9.z.boolean().default(false),
12176
+ validation: import_zod9.z.object({
12177
+ min: import_zod9.z.number().optional(),
12178
+ max: import_zod9.z.number().optional()
12179
+ }).optional(),
12180
+ ui: import_zod9.z.object({
12181
+ suffix: import_zod9.z.string().optional()
12182
+ }).optional()
12183
+ });
12184
+ var SelectOptionSchema = import_zod9.z.object({
12185
+ label: import_zod9.z.string().min(1),
12186
+ value: import_zod9.z.string().min(1)
12187
+ });
12188
+ var SelectCharacteristicSchema = import_zod9.z.object({
12189
+ key: import_zod9.z.string().min(1),
12190
+ label: import_zod9.z.string().min(1),
12191
+ type: import_zod9.z.literal("select"),
12192
+ required: import_zod9.z.boolean().default(false),
12193
+ sku_dependent: import_zod9.z.boolean().default(false),
12194
+ options: import_zod9.z.array(SelectOptionSchema).min(1)
12195
+ });
12196
+ var CharacteristicSchema = import_zod9.z.discriminatedUnion("type", [
12197
+ NumberCharacteristicSchema,
12198
+ SelectCharacteristicSchema
12199
+ ]);
12200
+ var CharacteristicsSchemeSchema = import_zod9.z.array(CharacteristicSchema);
12201
+ var SKU_TEMPLATE_REGEX = /^(\{(brand|type|counter)(?::\d+)?\}|\{[a-z_]+(?::\d+)?\}|[^{}]+)+$/;
12202
+ var ProductTypeBaseSchema = import_zod9.z.object({
12203
+ 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
+ defaultWriteoffStrategy: import_zod9.z.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]).default("FIFO"),
12206
+ skuMode: import_zod9.z.enum(["GLOBAL", "CUSTOM"]).default("GLOBAL"),
12207
+ skuTemplate: import_zod9.z.string().regex(SKU_TEMPLATE_REGEX).optional().nullable(),
12208
+ characteristicsScheme: CharacteristicsSchemeSchema.optional().nullable()
12209
+ });
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
+ var CreateProductTypeSchema = ProductTypeBaseSchema.refine(
12217
+ (data) => !(data.skuMode === "CUSTOM" && !data.skuTemplate),
12218
+ { message: "skuTemplate is required for CUSTOM sku mode", path: ["skuTemplate"] }
12219
+ ).refine(refineCustomSkuTemplate, {
12220
+ message: "All characteristic keys in skuTemplate must exist in characteristicsScheme",
12221
+ path: ["skuTemplate"]
12222
+ });
12223
+ var UpdateProductTypeSchema = ProductTypeBaseSchema.partial().refine(
12224
+ (data) => !(data.skuMode === "CUSTOM" && data.skuTemplate === null),
12225
+ { message: "skuTemplate cannot be null for CUSTOM sku mode", path: ["skuTemplate"] }
12226
+ ).refine(refineCustomSkuTemplate, {
12227
+ message: "All characteristic keys in skuTemplate must exist in characteristicsScheme",
12228
+ path: ["skuTemplate"]
12229
+ });
12230
+ var ProductTypeSchema = import_zod9.z.object({
12231
+ id: import_zod9.z.number(),
12232
+ name: import_zod9.z.string(),
12233
+ code: import_zod9.z.string(),
12234
+ defaultWriteoffStrategy: import_zod9.z.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]),
12235
+ skuMode: import_zod9.z.enum(["GLOBAL", "CUSTOM"]),
12236
+ skuTemplate: import_zod9.z.string().nullable(),
12237
+ skuCounter: import_zod9.z.number(),
12238
+ characteristicsScheme: CharacteristicsSchemeSchema.nullable(),
12239
+ updatedAt: import_zod9.z.string()
12240
+ });
12159
12241
  // Annotate the CommonJS export names for ESM import in node:
12160
12242
  0 && (module.exports = {
12161
12243
  ALL_PERMISSIONS,
@@ -12165,6 +12247,8 @@ var UpdateRoleSchema = import_zod8.z.object({
12165
12247
  BoolFilterObjectZodSchema,
12166
12248
  BoolWithAggregatesFilterObjectSchema,
12167
12249
  BoolWithAggregatesFilterObjectZodSchema,
12250
+ CharacteristicSchema,
12251
+ CharacteristicsSchemeSchema,
12168
12252
  CountryAggregateResultSchema,
12169
12253
  CountryAggregateSchema,
12170
12254
  CountryAggregateZodSchema,
@@ -12302,6 +12386,7 @@ var UpdateRoleSchema = import_zod8.z.object({
12302
12386
  CreateEmployeeSchema,
12303
12387
  CreateLocalitySchema,
12304
12388
  CreateOrganizationSchema,
12389
+ CreateProductTypeSchema,
12305
12390
  CreateRoleSchema,
12306
12391
  CreateWarehouseSchema,
12307
12392
  DateTimeFieldUpdateOperationsInputObjectSchema,
@@ -13480,6 +13565,7 @@ var UpdateRoleSchema = import_zod8.z.object({
13480
13565
  OrganizationWhereUniqueInputObjectSchema,
13481
13566
  OrganizationWhereUniqueInputObjectZodSchema,
13482
13567
  PaginationQuerySchema,
13568
+ ProductTypeSchema,
13483
13569
  QueryModeSchema,
13484
13570
  RolePermissionItemSchema,
13485
13571
  RoleSchema,
@@ -13607,6 +13693,7 @@ var UpdateRoleSchema = import_zod8.z.object({
13607
13693
  UpdateOrganizationSchema,
13608
13694
  UpdateOwnPasswordSchema,
13609
13695
  UpdateOwnProfileSchema,
13696
+ UpdateProductTypeSchema,
13610
13697
  UpdateRoleSchema,
13611
13698
  UpdateWarehouseSchema,
13612
13699
  UuidFilterObjectSchema,