@pksep/zod-shared 0.0.532 → 0.0.534

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.
Files changed (50) hide show
  1. package/dist/action/schemas/actions.schema.d.ts +2 -2
  2. package/dist/assemble/dto/assembly-paginate.dto.d.ts +18 -0
  3. package/dist/assemble/dto/assembly-paginate.dto.js +2 -1
  4. package/dist/assemble/dto/create-assemble-kit.dto.d.ts +14 -8
  5. package/dist/assemble/dto/create-assemble-kit.dto.js +7 -3
  6. package/dist/assemble/dto/get-assemble-operation-count.dto.d.ts +6 -6
  7. package/dist/assemble/dto/get-assemble-pagination-sclad.dto.d.ts +18 -0
  8. package/dist/assemble/dto/get-assemble-pagination-sclad.dto.js +2 -1
  9. package/dist/assemble/dto/get-assemble-pagination.dto.d.ts +18 -0
  10. package/dist/assemble/dto/get-assemble-pagination.dto.js +2 -1
  11. package/dist/assemble/interfaces/interfaces.d.ts +12 -0
  12. package/dist/assemble/schemas/assemble-coming.schema.d.ts +4 -4
  13. package/dist/assemble/schemas/assemble.schema.d.ts +4 -4
  14. package/dist/assemble-kit/interfaces/interface.d.ts +7 -0
  15. package/dist/assemble-kit/schemas/assemble-kit.schema.d.ts +2 -2
  16. package/dist/cbed/dto/get-deficit.dto.d.ts +18 -0
  17. package/dist/cbed/dto/get-deficit.dto.js +2 -1
  18. package/dist/deliveries/schemas/deliveries.schema.d.ts +2 -2
  19. package/dist/detal/dto/get-deficit.dto.d.ts +18 -0
  20. package/dist/detal/dto/get-deficit.dto.js +2 -1
  21. package/dist/equipment/schemas/equipment.schema.d.ts +8 -8
  22. package/dist/exclusion/dto/create-exclusion.dto.js +1 -1
  23. package/dist/expenditure/schema/expenditure-consumption.schema.d.ts +2 -2
  24. package/dist/expenditure/schema/expenditure.schema.d.ts +2 -2
  25. package/dist/material/dto/get-deficit.dto.d.ts +18 -0
  26. package/dist/material/dto/get-deficit.dto.js +2 -1
  27. package/dist/metaloworking/dto/get-metallworking-pagination.dto.d.ts +18 -0
  28. package/dist/metaloworking/dto/get-metallworking-pagination.dto.js +3 -1
  29. package/dist/metaloworking/schemas/metaloworking-by-operation.schema.d.ts +2 -2
  30. package/dist/moving/schemas/moving.schema.d.ts +11 -6
  31. package/dist/product/dto/get-deficit.dto.d.ts +18 -0
  32. package/dist/product/dto/get-deficit.dto.js +2 -1
  33. package/dist/production-tasks/dto/get-deficits-detal-by-production-task.dto.d.ts +18 -0
  34. package/dist/production-tasks/dto/get-deficits-detal-by-production-task.dto.js +3 -1
  35. package/dist/production-tasks/dto/online-board-working.dto.d.ts +18 -0
  36. package/dist/production-tasks/dto/online-board-working.dto.js +2 -1
  37. package/dist/production-tasks/schemas/production-operation-pos.schema.d.ts +2 -2
  38. package/dist/role/schemas/role.schema.d.ts +11 -6
  39. package/dist/sclad/schemas/remain.schema.d.ts +2 -2
  40. package/dist/shipments/dto/shipments-paginate.dto.d.ts +18 -0
  41. package/dist/shipments/dto/shipments-paginate.dto.js +2 -1
  42. package/dist/user/schemas/user.schema.d.ts +7 -4
  43. package/dist/user/schemas/user.schema.js +1 -0
  44. package/dist/utils/index.d.ts +1 -0
  45. package/dist/utils/index.js +1 -0
  46. package/dist/utils/methods.d.ts +0 -4
  47. package/dist/utils/methods.js +3 -22
  48. package/dist/utils/sorting.d.ts +25 -0
  49. package/dist/utils/sorting.js +56 -0
  50. package/package.json +1 -1
@@ -32,6 +32,7 @@ export declare const UserSchema: z.ZodObject<{
32
32
  image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
33
  session_id: z.ZodNullable<z.ZodNumber>;
34
34
  last_online: z.ZodNullable<z.ZodNumber>;
35
+ createdAt: z.ZodOptional<z.ZodString>;
35
36
  rolesId: z.ZodNumber;
36
37
  role: z.ZodAny;
37
38
  documents: z.ZodArray<z.ZodObject<{
@@ -309,6 +310,7 @@ export declare const UserSchema: z.ZodObject<{
309
310
  action: import("../..").IActionText[];
310
311
  type_object: string;
311
312
  id?: number | null | undefined;
313
+ createdAt?: string | Date | undefined;
312
314
  responsible_id?: number | null | undefined;
313
315
  equipment_id?: number | null | undefined;
314
316
  user_id?: number | null | undefined;
@@ -338,13 +340,13 @@ export declare const UserSchema: z.ZodObject<{
338
340
  role_id?: number | null | undefined;
339
341
  parent_action_idL?: number | null | undefined;
340
342
  production_task_id?: number | null | undefined;
341
- createdAt?: string | Date | undefined;
342
343
  revision_id?: number | null | undefined;
343
344
  }, {
344
345
  action: import("../..").IActionText[];
345
346
  type_object: string;
346
347
  ban?: boolean | undefined;
347
348
  id?: number | null | undefined;
349
+ createdAt?: string | Date | undefined;
348
350
  responsible_id?: number | null | undefined;
349
351
  equipment_id?: number | null | undefined;
350
352
  user_id?: number | null | undefined;
@@ -374,7 +376,6 @@ export declare const UserSchema: z.ZodObject<{
374
376
  role_id?: number | null | undefined;
375
377
  parent_action_idL?: number | null | undefined;
376
378
  production_task_id?: number | null | undefined;
377
- createdAt?: string | Date | undefined;
378
379
  revision_id?: number | null | undefined;
379
380
  }>, "many">;
380
381
  responsibleForProduct: z.ZodArray<z.ZodObject<{
@@ -658,6 +659,7 @@ export declare const UserSchema: z.ZodObject<{
658
659
  action: import("../..").IActionText[];
659
660
  type_object: string;
660
661
  id?: number | null | undefined;
662
+ createdAt?: string | Date | undefined;
661
663
  responsible_id?: number | null | undefined;
662
664
  equipment_id?: number | null | undefined;
663
665
  user_id?: number | null | undefined;
@@ -687,7 +689,6 @@ export declare const UserSchema: z.ZodObject<{
687
689
  role_id?: number | null | undefined;
688
690
  parent_action_idL?: number | null | undefined;
689
691
  production_task_id?: number | null | undefined;
690
- createdAt?: string | Date | undefined;
691
692
  revision_id?: number | null | undefined;
692
693
  }[];
693
694
  responsibleForProduct: {
@@ -751,6 +752,7 @@ export declare const UserSchema: z.ZodObject<{
751
752
  }[];
752
753
  role?: any;
753
754
  image?: string | null | undefined;
755
+ createdAt?: string | undefined;
754
756
  subdivision?: import("../enums").EnumSubdivision | undefined;
755
757
  }, {
756
758
  banReason: string | null;
@@ -852,6 +854,7 @@ export declare const UserSchema: z.ZodObject<{
852
854
  type_object: string;
853
855
  ban?: boolean | undefined;
854
856
  id?: number | null | undefined;
857
+ createdAt?: string | Date | undefined;
855
858
  responsible_id?: number | null | undefined;
856
859
  equipment_id?: number | null | undefined;
857
860
  user_id?: number | null | undefined;
@@ -881,7 +884,6 @@ export declare const UserSchema: z.ZodObject<{
881
884
  role_id?: number | null | undefined;
882
885
  parent_action_idL?: number | null | undefined;
883
886
  production_task_id?: number | null | undefined;
884
- createdAt?: string | Date | undefined;
885
887
  revision_id?: number | null | undefined;
886
888
  }[];
887
889
  responsibleForProduct: {
@@ -954,6 +956,7 @@ export declare const UserSchema: z.ZodObject<{
954
956
  };
955
957
  }[] | undefined;
956
958
  image?: string | null | undefined;
959
+ createdAt?: string | undefined;
957
960
  subdivision?: import("../enums").EnumSubdivision | undefined;
958
961
  }>;
959
962
  export type ModelUser = z.infer<typeof UserSchema> & {
@@ -29,6 +29,7 @@ exports.UserSchema = zod_1.z.object({
29
29
  image: zod_1.z.string().nullish(),
30
30
  session_id: zod_1.z.number().int().nullable(),
31
31
  last_online: zod_1.z.number().int().nullable(),
32
+ createdAt: zod_1.z.string().optional(),
32
33
  rolesId: zod_1.z.number().int(),
33
34
  role: zod_1.z.any(),
34
35
  documents: zod_1.z.array(document_1.DocumentsSchema),
@@ -27,3 +27,4 @@ export * from './default-value/default-value';
27
27
  export * from './tables-config/enum';
28
28
  export * from './tables-config/methods';
29
29
  export * from './tables-config/tables-array';
30
+ export * from './sorting';
@@ -43,3 +43,4 @@ __exportStar(require("./default-value/default-value"), exports);
43
43
  __exportStar(require("./tables-config/enum"), exports);
44
44
  __exportStar(require("./tables-config/methods"), exports);
45
45
  __exportStar(require("./tables-config/tables-array"), exports);
46
+ __exportStar(require("./sorting"), exports);
@@ -22,10 +22,6 @@ export declare function moreMinusNum(num: number): number;
22
22
  */
23
23
  export declare function getFieldsSpetification(list: EntityCommonSpecification[], subKey: keyof EntityCommonSpecification): (string | number | boolean | undefined)[] | null;
24
24
  export declare const calculateByMeasurementRate: (units_measurement: IUnitsMeasurement[], ezId: number) => number;
25
- /**
26
- * Функция проверяет, является ли введенное обозначение исключением
27
- */
28
- export declare function isThisExclusionDesignation(designation: string, isProduct?: boolean): boolean;
29
25
  /**
30
26
  *
31
27
  * @param marks
@@ -23,7 +23,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.intersect = exports.shipmentsNullOne = exports.differencesShipments = exports.dateDifference = exports.toFormatString = exports.comparison = exports.comparisonTimestamp = exports.parseDate = exports.dataFormat = exports.dateToTimestampFormat = exports.convertStringValuesToNumbers = exports.dateToFormat = exports.photoPreloadUrl = exports.isImage = exports.getReversDate = exports.isValidNumber = exports.returnTypePosition = exports.checkMissingEntity = exports.countChildrensRelative = exports.concatedLists = exports.countUniqueValueChildren = exports.removeArrDublicateByAttr = exports.getOnCommonListChildrens = exports.sleep = exports.parseBoolean = exports.strIsBoolean = exports.useWorkpieceCharacterizationItems = exports.getFileType = exports.calculateStartDate = exports.calculateEndDate = exports.WORK_DAY_END_MINUTE = exports.WORK_DAY_END_HOUR = exports.WORK_DAY_START_HOUR = exports.leftToDoByProductionTask = exports.calculateByMeasurementRate = void 0;
24
24
  exports.moreMinusNum = moreMinusNum;
25
25
  exports.getFieldsSpetification = getFieldsSpetification;
26
- exports.isThisExclusionDesignation = isThisExclusionDesignation;
27
26
  exports.organiseListCbedDetal = organiseListCbedDetal;
28
27
  exports.getFieldBySpetificationList = getFieldBySpetificationList;
29
28
  exports.lessPlusNum = lessPlusNum;
@@ -80,24 +79,6 @@ const calculateByMeasurementRate = (units_measurement, ezId) => {
80
79
  return convertRate;
81
80
  };
82
81
  exports.calculateByMeasurementRate = calculateByMeasurementRate;
83
- /**
84
- * Функция проверяет, является ли введенное обозначение исключением
85
- */
86
- function isThisExclusionDesignation(designation, isProduct = false) {
87
- let exclusions = ['-', '', '?', '- архив'];
88
- const productExclusions = [
89
- 'покупной',
90
- '',
91
- 'ремонт',
92
- 'документ',
93
- 'оснастка',
94
- 'опция'
95
- ];
96
- if (isProduct)
97
- exclusions = exclusions.concat(productExclusions);
98
- const lowerDesignation = `${designation}`.toLowerCase();
99
- return exclusions.includes(lowerDesignation);
100
- }
101
82
  /**
102
83
  *
103
84
  * @param marks
@@ -784,7 +765,7 @@ const countChildrensRelative = (data) => {
784
765
  const foundedCbed = cbeds.find(cbed => listCbedItem.id === cbed.id);
785
766
  return Object.assign(Object.assign(Object.assign({}, foundedCbed), (0, sequelize_1.addFieldByCondition)(data.isNeedsTypes, {
786
767
  entity_type: enums_1.IzdType.cbed
787
- })), { count_to_obj: listCbedItem.quantity, count_to_needs: relativeNeeds * listCbedItem.quantity, needs: relativeNeeds * listCbedItem.quantity, parent_id: relative.id, parent_type: relativeType, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
768
+ })), { count_to_obj: listCbedItem.quantity, count_to_needs: relativeNeeds * listCbedItem.quantity, needs: relativeNeeds * listCbedItem.quantity, parent_id: relative.id, parent_type: relativeType, parent_ava: relative === null || relative === void 0 ? void 0 : relative.ava_path, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
788
769
  })) || [];
789
770
  relative.cbedGraph = [...relative.cbeds];
790
771
  }
@@ -794,7 +775,7 @@ const countChildrensRelative = (data) => {
794
775
  const foundedDetal = detals.find(detal => listDetalItem.id === detal.id);
795
776
  return Object.assign(Object.assign(Object.assign({}, foundedDetal), (0, sequelize_1.addFieldByCondition)(data.isNeedsTypes, {
796
777
  entity_type: enums_1.IzdType.detal
797
- })), { count_to_obj: listDetalItem.quantity, count_to_needs: relativeNeeds * listDetalItem.quantity, needs: relativeNeeds * listDetalItem.quantity, parent_id: relative.id, parent_type: relativeType, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
778
+ })), { count_to_obj: listDetalItem.quantity, count_to_needs: relativeNeeds * listDetalItem.quantity, needs: relativeNeeds * listDetalItem.quantity, parent_id: relative.id, parent_type: relativeType, parent_ava: relative === null || relative === void 0 ? void 0 : relative.ava_path, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
798
779
  })) || [];
799
780
  relative.detalsGraph = [...relative.detals];
800
781
  }
@@ -837,7 +818,7 @@ const countChildrensRelative = (data) => {
837
818
  : 0;
838
819
  return Object.assign(Object.assign(Object.assign({}, foundedMaterials), (0, sequelize_1.addFieldByCondition)(data.isNeedsTypes, {
839
820
  entity_type: enums_1.IzdType.material
840
- })), { measure_id: listMaterialItem.measureId, count_to_obj_not_converted: listMaterialItem.quantity, count_to_needs_not_converted: relativeNeeds * listMaterialItem.quantity, count_to_obj: specificationConvertedQuantity, count_to_needs: relativeNeeds * specificationConvertedQuantity, needs: relativeNeeds * specificationConvertedQuantity, parent_id: relative.id, parent_type: relativeType, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
821
+ })), { measure_id: listMaterialItem.measureId, count_to_obj_not_converted: listMaterialItem.quantity, count_to_needs_not_converted: relativeNeeds * listMaterialItem.quantity, count_to_obj: specificationConvertedQuantity, count_to_needs: relativeNeeds * specificationConvertedQuantity, needs: relativeNeeds * specificationConvertedQuantity, parent_id: relative.id, parent_type: relativeType, parent_ava: relative === null || relative === void 0 ? void 0 : relative.ava_path, parent_designation: (relative === null || relative === void 0 ? void 0 : relative.designation) || '-', parent_name: (relative === null || relative === void 0 ? void 0 : relative.name) || '-' });
841
822
  });
842
823
  materialsArray.forEach((currentMaterial) => {
843
824
  const materialKey = `${currentMaterial.parent_id}_${currentMaterial.parent_type}_${currentMaterial.id}`;
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ type SortValue = Date | number | string | boolean | null | undefined;
3
+ type SortSelector<T> = (item: T) => SortValue;
4
+ export declare enum ProductionPlanSortField {
5
+ calculateNeedsTime = "calculateNeedsTime",
6
+ calculatedCreateTime = "calculatedCreateTime",
7
+ warehouseReadinessDate = "warehouseReadinessDate",
8
+ orderedByProduction = "orderedByProduction"
9
+ }
10
+ export type ProductionPlanSortRule = {
11
+ sortField?: ProductionPlanSortField | null;
12
+ sortDesc?: boolean;
13
+ };
14
+ export declare const ProductionPlanSortRuleSchema: z.ZodObject<{
15
+ sortField: z.ZodOptional<z.ZodNullable<z.ZodNativeEnum<typeof ProductionPlanSortField>>>;
16
+ sortDesc: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ sortDesc: boolean;
19
+ sortField?: ProductionPlanSortField | null | undefined;
20
+ }, {
21
+ sortField?: ProductionPlanSortField | null | undefined;
22
+ sortDesc?: boolean | undefined;
23
+ }>;
24
+ export declare const sortByRules: <T>(items: T[], rules: ProductionPlanSortRule[] | null | undefined, selectors: Partial<Record<ProductionPlanSortField, SortSelector<T>>>) => T[];
25
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortByRules = exports.ProductionPlanSortRuleSchema = exports.ProductionPlanSortField = void 0;
4
+ const zod_1 = require("zod");
5
+ var ProductionPlanSortField;
6
+ (function (ProductionPlanSortField) {
7
+ ProductionPlanSortField["calculateNeedsTime"] = "calculateNeedsTime";
8
+ ProductionPlanSortField["calculatedCreateTime"] = "calculatedCreateTime";
9
+ ProductionPlanSortField["warehouseReadinessDate"] = "warehouseReadinessDate";
10
+ ProductionPlanSortField["orderedByProduction"] = "orderedByProduction";
11
+ })(ProductionPlanSortField || (exports.ProductionPlanSortField = ProductionPlanSortField = {}));
12
+ exports.ProductionPlanSortRuleSchema = zod_1.z.object({
13
+ sortField: zod_1.z.nativeEnum(ProductionPlanSortField).nullable().optional(),
14
+ sortDesc: zod_1.z.boolean().optional().default(false)
15
+ });
16
+ const normalizeSortValue = (value) => {
17
+ if (value instanceof Date)
18
+ return value.getTime();
19
+ if (typeof value === 'string') {
20
+ const dateTime = Date.parse(value);
21
+ return Number.isNaN(dateTime) ? value.toLocaleLowerCase() : dateTime;
22
+ }
23
+ return value;
24
+ };
25
+ const compareValues = (firstValue, secondValue, desc = false) => {
26
+ const isFirstNull = firstValue === null || firstValue === undefined;
27
+ const isSecondNull = secondValue === null || secondValue === undefined;
28
+ if (isFirstNull || isSecondNull) {
29
+ if (isFirstNull && isSecondNull)
30
+ return 0;
31
+ return isFirstNull ? (desc ? -1 : 1) : desc ? 1 : -1;
32
+ }
33
+ const normalizedFirstValue = normalizeSortValue(firstValue);
34
+ const normalizedSecondValue = normalizeSortValue(secondValue);
35
+ if (normalizedFirstValue < normalizedSecondValue)
36
+ return desc ? 1 : -1;
37
+ if (normalizedFirstValue > normalizedSecondValue)
38
+ return desc ? -1 : 1;
39
+ return 0;
40
+ };
41
+ const sortByRules = (items, rules, selectors) => {
42
+ const activeRules = (rules !== null && rules !== void 0 ? rules : []).filter(rule => rule.sortField && selectors[rule.sortField]);
43
+ if (!activeRules.length)
44
+ return items;
45
+ return [...items].sort((firstItem, secondItem) => {
46
+ var _a;
47
+ for (const rule of activeRules) {
48
+ const selector = selectors[rule.sortField];
49
+ const result = compareValues(selector(firstItem), selector(secondItem), (_a = rule.sortDesc) !== null && _a !== void 0 ? _a : false);
50
+ if (result !== 0)
51
+ return result;
52
+ }
53
+ return 0;
54
+ });
55
+ };
56
+ exports.sortByRules = sortByRules;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pksep/zod-shared",
3
- "version": "0.0.532",
3
+ "version": "0.0.534",
4
4
  "description": "Zod package for erp project. Contains dto, interfaces, schems, types, enum",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",