@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.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,79 @@ 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
|
+
validation: import_zod9.z.object({
|
|
12176
|
+
min: import_zod9.z.number().optional(),
|
|
12177
|
+
max: import_zod9.z.number().optional()
|
|
12178
|
+
}).optional(),
|
|
12179
|
+
ui: import_zod9.z.object({
|
|
12180
|
+
suffix: import_zod9.z.string().optional()
|
|
12181
|
+
}).optional()
|
|
12182
|
+
});
|
|
12183
|
+
var SelectOptionSchema = import_zod9.z.object({
|
|
12184
|
+
label: import_zod9.z.string().min(1),
|
|
12185
|
+
value: import_zod9.z.string().min(1)
|
|
12186
|
+
});
|
|
12187
|
+
var SelectCharacteristicSchema = import_zod9.z.object({
|
|
12188
|
+
key: import_zod9.z.string().min(1),
|
|
12189
|
+
label: import_zod9.z.string().min(1),
|
|
12190
|
+
type: import_zod9.z.literal("select"),
|
|
12191
|
+
required: import_zod9.z.boolean().default(false),
|
|
12192
|
+
options: import_zod9.z.array(SelectOptionSchema).min(1)
|
|
12193
|
+
});
|
|
12194
|
+
var CharacteristicSchema = import_zod9.z.discriminatedUnion("type", [
|
|
12195
|
+
NumberCharacteristicSchema,
|
|
12196
|
+
SelectCharacteristicSchema
|
|
12197
|
+
]);
|
|
12198
|
+
var CharacteristicsSchemeSchema = import_zod9.z.array(CharacteristicSchema);
|
|
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
|
+
}
|
|
12209
|
+
var ProductTypeBaseSchema = import_zod9.z.object({
|
|
12210
|
+
name: import_zod9.z.string().min(1),
|
|
12211
|
+
defaultWriteoffStrategy: import_zod9.z.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]).default("FIFO"),
|
|
12212
|
+
skuMode: import_zod9.z.enum(["GLOBAL", "CUSTOM"]).default("GLOBAL"),
|
|
12213
|
+
skuTemplate: import_zod9.z.string().regex(SKU_TEMPLATE_REGEX, "Invalid SKU template format").optional().nullable(),
|
|
12214
|
+
characteristicsScheme: CharacteristicsSchemeSchema.optional().nullable()
|
|
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(validateSkuTemplate, {
|
|
12220
|
+
message: "All characteristic keys in skuTemplate must be required characteristics",
|
|
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(validateSkuTemplate, {
|
|
12227
|
+
message: "All characteristic keys in skuTemplate must be required characteristics",
|
|
12228
|
+
path: ["skuTemplate"]
|
|
12229
|
+
});
|
|
12230
|
+
var ProductTypeSchema = import_zod9.z.object({
|
|
12231
|
+
id: import_zod9.z.number(),
|
|
12232
|
+
name: import_zod9.z.string(),
|
|
12233
|
+
defaultWriteoffStrategy: import_zod9.z.enum(["FIFO", "LIFO", "FEFO", "MANUAL"]),
|
|
12234
|
+
skuMode: import_zod9.z.enum(["GLOBAL", "CUSTOM"]),
|
|
12235
|
+
skuTemplate: import_zod9.z.string().nullable(),
|
|
12236
|
+
skuCounter: import_zod9.z.number(),
|
|
12237
|
+
characteristicsScheme: CharacteristicsSchemeSchema.nullable(),
|
|
12238
|
+
updatedAt: import_zod9.z.string()
|
|
12239
|
+
});
|
|
12159
12240
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12160
12241
|
0 && (module.exports = {
|
|
12161
12242
|
ALL_PERMISSIONS,
|
|
@@ -12165,6 +12246,8 @@ var UpdateRoleSchema = import_zod8.z.object({
|
|
|
12165
12246
|
BoolFilterObjectZodSchema,
|
|
12166
12247
|
BoolWithAggregatesFilterObjectSchema,
|
|
12167
12248
|
BoolWithAggregatesFilterObjectZodSchema,
|
|
12249
|
+
CharacteristicSchema,
|
|
12250
|
+
CharacteristicsSchemeSchema,
|
|
12168
12251
|
CountryAggregateResultSchema,
|
|
12169
12252
|
CountryAggregateSchema,
|
|
12170
12253
|
CountryAggregateZodSchema,
|
|
@@ -12302,6 +12385,7 @@ var UpdateRoleSchema = import_zod8.z.object({
|
|
|
12302
12385
|
CreateEmployeeSchema,
|
|
12303
12386
|
CreateLocalitySchema,
|
|
12304
12387
|
CreateOrganizationSchema,
|
|
12388
|
+
CreateProductTypeSchema,
|
|
12305
12389
|
CreateRoleSchema,
|
|
12306
12390
|
CreateWarehouseSchema,
|
|
12307
12391
|
DateTimeFieldUpdateOperationsInputObjectSchema,
|
|
@@ -13480,6 +13564,7 @@ var UpdateRoleSchema = import_zod8.z.object({
|
|
|
13480
13564
|
OrganizationWhereUniqueInputObjectSchema,
|
|
13481
13565
|
OrganizationWhereUniqueInputObjectZodSchema,
|
|
13482
13566
|
PaginationQuerySchema,
|
|
13567
|
+
ProductTypeSchema,
|
|
13483
13568
|
QueryModeSchema,
|
|
13484
13569
|
RolePermissionItemSchema,
|
|
13485
13570
|
RoleSchema,
|
|
@@ -13607,6 +13692,7 @@ var UpdateRoleSchema = import_zod8.z.object({
|
|
|
13607
13692
|
UpdateOrganizationSchema,
|
|
13608
13693
|
UpdateOwnPasswordSchema,
|
|
13609
13694
|
UpdateOwnProfileSchema,
|
|
13695
|
+
UpdateProductTypeSchema,
|
|
13610
13696
|
UpdateRoleSchema,
|
|
13611
13697
|
UpdateWarehouseSchema,
|
|
13612
13698
|
UuidFilterObjectSchema,
|