@pksep/zod-shared 0.0.562 → 0.0.563

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.
@@ -1,110 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ErpSpecificationItemRemoveInputZod = exports.ErpSpecificationItemMoveInputZod = exports.ErpSpecificationItemUpdateInputZod = exports.ErpSpecificationItemAddInputZod = exports.ErpSpecificationItemRemoveInputShape = exports.ErpSpecificationItemMoveInputShape = exports.ErpSpecificationItemUpdateInputShape = exports.ErpSpecificationItemAddInputShape = void 0;
37
- const z = __importStar(require("zod/v4"));
38
- const mutate_specification_dto_1 = require("../../specification/dto/mutate-specification.dto");
39
- const utils_1 = require("../../utils");
40
- /** MCP SDK использует Zod v4; итоговая команда дополнительно проверяется общим DTO ERP на Zod v3. */
41
- const SpecificationParentTypeMcpZod = z.enum([
42
- utils_1.IzdType.product,
43
- utils_1.IzdType.cbed,
44
- utils_1.IzdType.detal
45
- ]);
46
- const SpecificationSectionMcpZod = z.nativeEnum(utils_1.SpetificationEntityKeys);
47
- const idempotencyKeyZod = z
48
- .string()
49
- .trim()
50
- .min(8)
51
- .max(128)
52
- .regex(/^[a-zA-Z0-9._:-]+$/);
53
- const entityReferenceShape = {
54
- parentType: SpecificationParentTypeMcpZod,
55
- parentName: z.string().trim().min(1).max(255).optional(),
56
- parentDesignation: z.string().trim().min(1).max(255).optional(),
57
- section: SpecificationSectionMcpZod,
58
- itemName: z.string().trim().min(1).max(255).optional(),
59
- itemDesignation: z.string().trim().min(1).max(255).optional(),
60
- idempotencyKey: idempotencyKeyZod
61
- };
62
- /** Требует человекочитаемые ссылки на родителя и позицию без внутренних ID. */
63
- const validateReferences = (input, context) => {
64
- if (!input.parentName && !input.parentDesignation) {
65
- context.addIssue({
66
- code: z.ZodIssueCode.custom,
67
- path: ['parentName'],
68
- message: 'Укажите название или обозначение родительской сущности'
69
- });
70
- }
71
- if (!input.itemName && !input.itemDesignation) {
72
- context.addIssue({
73
- code: z.ZodIssueCode.custom,
74
- path: ['itemName'],
75
- message: 'Укажите название или обозначение позиции спецификации'
76
- });
77
- }
78
- };
79
- exports.ErpSpecificationItemAddInputShape = Object.assign(Object.assign({}, entityReferenceShape), { quantity: z
80
- .number()
81
- .min(mutate_specification_dto_1.SPECIFICATION_QUANTITY_MIN)
82
- .max(mutate_specification_dto_1.SPECIFICATION_QUANTITY_MAX), measureId: z.number().int().min(1).optional(), position: z.number().int().min(mutate_specification_dto_1.SPECIFICATION_POSITION_MIN).optional() });
83
- exports.ErpSpecificationItemUpdateInputShape = Object.assign(Object.assign({}, entityReferenceShape), { quantity: z
84
- .number()
85
- .min(mutate_specification_dto_1.SPECIFICATION_QUANTITY_MIN)
86
- .max(mutate_specification_dto_1.SPECIFICATION_QUANTITY_MAX)
87
- .optional(), measureId: z.number().int().min(1).optional() });
88
- exports.ErpSpecificationItemMoveInputShape = Object.assign(Object.assign({}, entityReferenceShape), { position: z.number().int().min(mutate_specification_dto_1.SPECIFICATION_POSITION_MIN) });
89
- exports.ErpSpecificationItemRemoveInputShape = entityReferenceShape;
90
- exports.ErpSpecificationItemAddInputZod = z
91
- .object(exports.ErpSpecificationItemAddInputShape)
92
- .superRefine(validateReferences);
93
- exports.ErpSpecificationItemUpdateInputZod = z
94
- .object(exports.ErpSpecificationItemUpdateInputShape)
95
- .superRefine((input, context) => {
96
- validateReferences(input, context);
97
- if (input.quantity === undefined && input.measureId === undefined) {
98
- context.addIssue({
99
- code: z.ZodIssueCode.custom,
100
- path: ['quantity'],
101
- message: 'Укажите новое количество или единицу измерения'
102
- });
103
- }
104
- });
105
- exports.ErpSpecificationItemMoveInputZod = z
106
- .object(exports.ErpSpecificationItemMoveInputShape)
107
- .superRefine(validateReferences);
108
- exports.ErpSpecificationItemRemoveInputZod = z
109
- .object(exports.ErpSpecificationItemRemoveInputShape)
110
- .superRefine(validateReferences);