@floristcloud/api-lib 1.2.206 → 1.2.207
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/build/commands/index.js +1 -0
- package/build/commands/product-image/get-product-image-list.query.js +3 -0
- package/build/commands/product-resolution/analyze-product-resolution.query.js +10 -0
- package/build/commands/product-resolution/execute-product-resolution.command.js +10 -0
- package/build/commands/product-resolution/index.js +7 -0
- package/build/constant/error.js +30 -0
- package/build/constant/index.js +1 -0
- package/build/constant/product-resolution.constant.js +18 -0
- package/build/enum/group-update-consignment-items-operation.enum.js +2 -0
- package/build/enum/index.js +8 -0
- package/build/enum/product-resolution-category-reason.enum.js +14 -0
- package/build/enum/product-resolution-decision-action.enum.js +8 -0
- package/build/enum/product-resolution-group-state.enum.js +12 -0
- package/build/enum/product-resolution-image-reason.enum.js +12 -0
- package/build/enum/product-resolution-issue.enum.js +13 -0
- package/build/enum/product-resolution-matched-attribute.enum.js +13 -0
- package/build/enum/product-resolution-source.enum.js +11 -0
- package/build/enum/product-resolution-write-mode.enum.js +10 -0
- package/build/helpers/index.js +1 -0
- package/build/helpers/optional-query-boolean.helper.js +17 -0
- package/build/schemas/index.js +19 -0
- package/build/schemas/product/get-product-list-request.schema.js +4 -0
- package/build/schemas/product-resolution/analyze-product-resolution-request.schema.js +18 -0
- package/build/schemas/product-resolution/analyze-product-resolution-response.schema.js +16 -0
- package/build/schemas/product-resolution/execute-product-resolution-request.schema.js +14 -0
- package/build/schemas/product-resolution/execute-product-resolution-response.schema.js +12 -0
- package/build/schemas/product-resolution/product-resolution-blocked-image.schema.js +10 -0
- package/build/schemas/product-resolution/product-resolution-candidate-alternative.schema.js +11 -0
- package/build/schemas/product-resolution/product-resolution-category-candidate.schema.js +10 -0
- package/build/schemas/product-resolution/product-resolution-current-field.schema.js +9 -0
- package/build/schemas/product-resolution/product-resolution-current.schema.js +12 -0
- package/build/schemas/product-resolution/product-resolution-decision-set.schema.js +13 -0
- package/build/schemas/product-resolution/product-resolution-decision.schema.js +15 -0
- package/build/schemas/product-resolution/product-resolution-group-key.schema.js +11 -0
- package/build/schemas/product-resolution/product-resolution-group-result.schema.js +14 -0
- package/build/schemas/product-resolution/product-resolution-group.schema.js +27 -0
- package/build/schemas/product-resolution/product-resolution-image-candidate.schema.js +17 -0
- package/build/schemas/product-resolution/product-resolution-item.schema.js +17 -0
- package/build/schemas/product-resolution/product-resolution-scope.schema.js +19 -0
- package/build/schemas/product-resolution/product-resolution-suggestions.schema.js +12 -0
- package/build/schemas/product-resolution/product-resolution-summary.schema.js +14 -0
- package/commands/index.ts +2 -0
- package/commands/product-image/get-product-image-list.query.ts +3 -0
- package/commands/product-resolution/analyze-product-resolution.query.ts +18 -0
- package/commands/product-resolution/execute-product-resolution.command.ts +16 -0
- package/commands/product-resolution/index.ts +2 -0
- package/constant/error.ts +30 -0
- package/constant/index.ts +1 -0
- package/constant/product-resolution.constant.ts +15 -0
- package/enum/group-update-consignment-items-operation.enum.ts +2 -0
- package/enum/index.ts +9 -0
- package/enum/product-resolution-category-reason.enum.ts +10 -0
- package/enum/product-resolution-decision-action.enum.ts +4 -0
- package/enum/product-resolution-group-state.enum.ts +8 -0
- package/enum/product-resolution-image-reason.enum.ts +8 -0
- package/enum/product-resolution-issue.enum.ts +9 -0
- package/enum/product-resolution-matched-attribute.enum.ts +9 -0
- package/enum/product-resolution-source.enum.ts +7 -0
- package/enum/product-resolution-write-mode.enum.ts +6 -0
- package/helpers/index.ts +1 -0
- package/helpers/optional-query-boolean.helper.ts +14 -0
- package/package.json +1 -1
- package/schemas/index.ts +20 -0
- package/schemas/product/get-product-list-request.schema.ts +4 -0
- package/schemas/product-resolution/analyze-product-resolution-request.schema.ts +16 -0
- package/schemas/product-resolution/analyze-product-resolution-response.schema.ts +14 -0
- package/schemas/product-resolution/execute-product-resolution-request.schema.ts +12 -0
- package/schemas/product-resolution/execute-product-resolution-response.schema.ts +10 -0
- package/schemas/product-resolution/product-resolution-blocked-image.schema.ts +8 -0
- package/schemas/product-resolution/product-resolution-candidate-alternative.schema.ts +9 -0
- package/schemas/product-resolution/product-resolution-category-candidate.schema.ts +8 -0
- package/schemas/product-resolution/product-resolution-current-field.schema.ts +7 -0
- package/schemas/product-resolution/product-resolution-current.schema.ts +10 -0
- package/schemas/product-resolution/product-resolution-decision-set.schema.ts +11 -0
- package/schemas/product-resolution/product-resolution-decision.schema.ts +13 -0
- package/schemas/product-resolution/product-resolution-group-key.schema.ts +9 -0
- package/schemas/product-resolution/product-resolution-group-result.schema.ts +12 -0
- package/schemas/product-resolution/product-resolution-group.schema.ts +25 -0
- package/schemas/product-resolution/product-resolution-image-candidate.schema.ts +15 -0
- package/schemas/product-resolution/product-resolution-item.schema.ts +15 -0
- package/schemas/product-resolution/product-resolution-scope.schema.ts +17 -0
- package/schemas/product-resolution/product-resolution-suggestions.schema.ts +10 -0
- package/schemas/product-resolution/product-resolution-summary.schema.ts +12 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductResolutionSummarySchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const product_resolution_issue_enum_1 = require("../../enum/product-resolution-issue.enum");
|
|
6
|
+
const product_resolution_source_enum_1 = require("../../enum/product-resolution-source.enum");
|
|
7
|
+
// Сводка по всей области без фильтра `issues`: чипы-счётчики показывают, сколько товаров с каждой
|
|
8
|
+
// проблемой, независимо от того, какая проблема сейчас выбрана. Всегда содержит все ключи перечислений.
|
|
9
|
+
exports.ProductResolutionSummarySchema = zod_1.z.object({
|
|
10
|
+
totalProducts: zod_1.z.number(),
|
|
11
|
+
totalGroups: zod_1.z.number(),
|
|
12
|
+
byIssue: zod_1.z.record(zod_1.z.nativeEnum(product_resolution_issue_enum_1.ProductResolutionIssueEnum), zod_1.z.number()),
|
|
13
|
+
bySource: zod_1.z.record(zod_1.z.nativeEnum(product_resolution_source_enum_1.ProductResolutionSourceEnum), zod_1.z.number()),
|
|
14
|
+
});
|
package/commands/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ProductImageExtendedSchema } from '../../schemas/product-image/product-image.schema';
|
|
3
3
|
import { ProductImageOrderByEnum } from '../../enum';
|
|
4
|
+
import { optionalQueryBooleanSchema } from '../../helpers/optional-query-boolean.helper';
|
|
4
5
|
|
|
5
6
|
const GetProductImageListRequestSchema = z.object({
|
|
6
7
|
page: z.string().transform(val => Number(val) || 1),
|
|
@@ -12,6 +13,8 @@ const GetProductImageListRequestSchema = z.object({
|
|
|
12
13
|
grower: z.string().optional(),
|
|
13
14
|
color: z.string().optional(),
|
|
14
15
|
country: z.string().optional(),
|
|
16
|
+
// Без параметра — все карточки, false — только карточки без категории (они выпадают из резолва).
|
|
17
|
+
hasCategory: optionalQueryBooleanSchema,
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
const GetProductImageListResponseSchema = z.object({
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { AnalyzeProductResolutionRequestSchema } from '../../schemas/product-resolution/analyze-product-resolution-request.schema';
|
|
3
|
+
import { AnalyzeProductResolutionResponseSchema } from '../../schemas/product-resolution/analyze-product-resolution-response.schema';
|
|
4
|
+
import { ProductResolutionGroupSchema } from '../../schemas/product-resolution/product-resolution-group.schema';
|
|
5
|
+
import { ProductResolutionScopeSchema } from '../../schemas/product-resolution/product-resolution-scope.schema';
|
|
6
|
+
import { ProductResolutionSummarySchema } from '../../schemas/product-resolution/product-resolution-summary.schema';
|
|
7
|
+
|
|
8
|
+
export namespace AnalyzeProductResolutionContractQuery {
|
|
9
|
+
export const RequestSchema = AnalyzeProductResolutionRequestSchema;
|
|
10
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
11
|
+
|
|
12
|
+
export const ResponseSchema = AnalyzeProductResolutionResponseSchema;
|
|
13
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
14
|
+
|
|
15
|
+
export type Scope = z.infer<typeof ProductResolutionScopeSchema>;
|
|
16
|
+
export type Group = z.infer<typeof ProductResolutionGroupSchema>;
|
|
17
|
+
export type Summary = z.infer<typeof ProductResolutionSummarySchema>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { ExecuteProductResolutionRequestSchema } from '../../schemas/product-resolution/execute-product-resolution-request.schema';
|
|
3
|
+
import { ExecuteProductResolutionResponseSchema } from '../../schemas/product-resolution/execute-product-resolution-response.schema';
|
|
4
|
+
import { ProductResolutionDecisionSchema } from '../../schemas/product-resolution/product-resolution-decision.schema';
|
|
5
|
+
import { ProductResolutionGroupResultSchema } from '../../schemas/product-resolution/product-resolution-group-result.schema';
|
|
6
|
+
|
|
7
|
+
export namespace ExecuteProductResolutionContractCommand {
|
|
8
|
+
export const RequestSchema = ExecuteProductResolutionRequestSchema;
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = ExecuteProductResolutionResponseSchema;
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
|
|
14
|
+
export type Decision = z.infer<typeof ProductResolutionDecisionSchema>;
|
|
15
|
+
export type GroupResult = z.infer<typeof ProductResolutionGroupResultSchema>;
|
|
16
|
+
}
|
package/constant/error.ts
CHANGED
|
@@ -2194,6 +2194,36 @@ export const ERRORS = {
|
|
|
2194
2194
|
message: 'Product image links changed concurrently, retry the operation',
|
|
2195
2195
|
httpCode: 409,
|
|
2196
2196
|
},
|
|
2197
|
+
PRODUCT_RESOLUTION_ANALYZE_FAILED: {
|
|
2198
|
+
code: 'PRES001',
|
|
2199
|
+
message: 'Failed to analyze product resolution',
|
|
2200
|
+
httpCode: 500,
|
|
2201
|
+
},
|
|
2202
|
+
PRODUCT_RESOLUTION_EXECUTE_FAILED: {
|
|
2203
|
+
code: 'PRES002',
|
|
2204
|
+
message: 'Failed to execute product resolution',
|
|
2205
|
+
httpCode: 500,
|
|
2206
|
+
},
|
|
2207
|
+
PRODUCT_RESOLUTION_GROUP_NOT_FOUND: {
|
|
2208
|
+
code: 'PRES003',
|
|
2209
|
+
message: 'Product group not found in the resolution scope',
|
|
2210
|
+
httpCode: 404,
|
|
2211
|
+
},
|
|
2212
|
+
PRODUCT_RESOLUTION_NO_SUGGESTION: {
|
|
2213
|
+
code: 'PRES004',
|
|
2214
|
+
message: 'Product group has no suggestion to accept',
|
|
2215
|
+
httpCode: 400,
|
|
2216
|
+
},
|
|
2217
|
+
PRODUCT_RESOLUTION_NOTHING_TO_SET: {
|
|
2218
|
+
code: 'PRES005',
|
|
2219
|
+
message: 'Decision does not set any field',
|
|
2220
|
+
httpCode: 400,
|
|
2221
|
+
},
|
|
2222
|
+
PRODUCT_RESOLUTION_TOO_MANY_PRODUCTS: {
|
|
2223
|
+
code: 'PRES006',
|
|
2224
|
+
message: 'Too many products match the decisions, narrow the scope',
|
|
2225
|
+
httpCode: 400,
|
|
2226
|
+
},
|
|
2197
2227
|
GROWER_SUGGESTIONS_FETCH_FAILED: {
|
|
2198
2228
|
code: 'ANORM004',
|
|
2199
2229
|
message: 'Error when retrieving grower suggestions',
|
package/constant/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Лимиты разбора ассортимента. Анализ отдаёт группы страницами: у компании тысячи товаров сворачиваются
|
|
2
|
+
// в сотни групп, но резолвер зовётся на каждую группу страницы, и страница не должна расти с каталогом.
|
|
3
|
+
export const PRODUCT_RESOLUTION_LIMITS = {
|
|
4
|
+
DEFAULT_PAGE_SIZE: 50,
|
|
5
|
+
MAX_PAGE_SIZE: 200,
|
|
6
|
+
MAX_DECISIONS: 200,
|
|
7
|
+
MAX_CONSIGNMENTS: 100,
|
|
8
|
+
MAX_SEARCH_LENGTH: 200,
|
|
9
|
+
MAX_ALTERNATIVES: 3,
|
|
10
|
+
// Товаров группы в ответе анализа: образец для раскрытия строки, полный размер — `itemCount`.
|
|
11
|
+
// Текущие значения и проблемы группы считаются в SQL по всем её товарам, а не по образцу.
|
|
12
|
+
MAX_ITEMS_PER_GROUP: 50,
|
|
13
|
+
// Товаров за одно применение: решения сверх этого отклоняются целиком, область надо сузить.
|
|
14
|
+
MAX_EXECUTE_PRODUCTS: 5000,
|
|
15
|
+
} as const;
|
package/enum/index.ts
CHANGED
|
@@ -187,3 +187,12 @@ export * from './security-code-purpose.enum';
|
|
|
187
187
|
export * from './client-statement-mode.enum';
|
|
188
188
|
|
|
189
189
|
export * from './order-balance-forbidden-status-list';
|
|
190
|
+
|
|
191
|
+
export * from './product-resolution-issue.enum';
|
|
192
|
+
export * from './product-resolution-source.enum';
|
|
193
|
+
export * from './product-resolution-group-state.enum';
|
|
194
|
+
export * from './product-resolution-category-reason.enum';
|
|
195
|
+
export * from './product-resolution-image-reason.enum';
|
|
196
|
+
export * from './product-resolution-matched-attribute.enum';
|
|
197
|
+
export * from './product-resolution-decision-action.enum';
|
|
198
|
+
export * from './product-resolution-write-mode.enum';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Почему резолвер предложил категорию. Порядок — от самого надёжного совпадения к самому слабому.
|
|
2
|
+
export enum ProductResolutionCategoryReasonEnum {
|
|
3
|
+
CATEGORY_NAME = 'CATEGORY_NAME',
|
|
4
|
+
CATEGORY_ALIAS = 'CATEGORY_ALIAS',
|
|
5
|
+
NAME_PREFIX = 'NAME_PREFIX',
|
|
6
|
+
NAME_PREFIX_ALIAS = 'NAME_PREFIX_ALIAS',
|
|
7
|
+
IMAGE_NAME = 'IMAGE_NAME',
|
|
8
|
+
FROM_IMAGE = 'FROM_IMAGE',
|
|
9
|
+
HISTORY = 'HISTORY',
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Состояние группы позиций по категории и карточке: всё есть / система предлагает / предложить нечего /
|
|
2
|
+
// внутри группы значения расходятся.
|
|
3
|
+
export enum ProductResolutionGroupStateEnum {
|
|
4
|
+
RESOLVED = 'RESOLVED',
|
|
5
|
+
SUGGESTED = 'SUGGESTED',
|
|
6
|
+
UNRESOLVED = 'UNRESOLVED',
|
|
7
|
+
MIXED = 'MIXED',
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Почему резолвер предложил карточку: по её имени, по алиасу, по той же позиции в прошлых поставках,
|
|
2
|
+
// по имени без префикса категории.
|
|
3
|
+
export enum ProductResolutionImageReasonEnum {
|
|
4
|
+
IMAGE_NAME = 'IMAGE_NAME',
|
|
5
|
+
IMAGE_ALIAS = 'IMAGE_ALIAS',
|
|
6
|
+
CATEGORY_STRIP = 'CATEGORY_STRIP',
|
|
7
|
+
HISTORY = 'HISTORY',
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Чего не хватает товару, чтобы считаться разобранным. NO_CATEGORY и NO_IMAGE определяют состояние группы;
|
|
2
|
+
// остальные — только фильтр и счётчики (цвет, страна и производитель заполняются отдельным шагом).
|
|
3
|
+
export enum ProductResolutionIssueEnum {
|
|
4
|
+
NO_CATEGORY = 'NO_CATEGORY',
|
|
5
|
+
NO_IMAGE = 'NO_IMAGE',
|
|
6
|
+
NO_COLOR = 'NO_COLOR',
|
|
7
|
+
NO_COUNTRY = 'NO_COUNTRY',
|
|
8
|
+
NO_GROWER = 'NO_GROWER',
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Какие атрибуты позиции совпали с кандидатом. Показывается рядом с подсказкой: «по имени и производителю»
|
|
2
|
+
// надёжнее, чем «только по имени».
|
|
3
|
+
export enum ProductResolutionMatchedAttributeEnum {
|
|
4
|
+
NAME = 'NAME',
|
|
5
|
+
CATEGORY = 'CATEGORY',
|
|
6
|
+
GROWER = 'GROWER',
|
|
7
|
+
COLOR = 'COLOR',
|
|
8
|
+
COUNTRY = 'COUNTRY',
|
|
9
|
+
}
|
package/helpers/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Трёхзначный boolean-флаг из query-строки: отсутствует — фильтра нет, `true`/`1` — да, иначе — нет.
|
|
5
|
+
* Отличается от `queryBooleanSchema` тем, что без параметра остаётся `undefined`, а не `false`:
|
|
6
|
+
* для фильтров «есть категория / есть карточка» оба значения — это фильтр, а его отсутствие — весь список.
|
|
7
|
+
*/
|
|
8
|
+
export const optionalQueryBooleanSchema = z
|
|
9
|
+
.union([z.boolean(), z.string()])
|
|
10
|
+
.optional()
|
|
11
|
+
.transform(value => {
|
|
12
|
+
if (value === undefined) return undefined;
|
|
13
|
+
return typeof value === 'boolean' ? value : value === 'true' || value === '1';
|
|
14
|
+
});
|
package/package.json
CHANGED
package/schemas/index.ts
CHANGED
|
@@ -194,3 +194,23 @@ export * from './action-log/balance-order-statuses-action-payload.schema';
|
|
|
194
194
|
export * from './action-log/action-log-balance-order-statuses.schema';
|
|
195
195
|
export * from './settings/balance-order-status-blocked-order.schema';
|
|
196
196
|
export * from './settings/balance-order-status-blocked-orders.schema';
|
|
197
|
+
|
|
198
|
+
export * from './product-resolution/product-resolution-scope.schema';
|
|
199
|
+
export * from './product-resolution/product-resolution-group-key.schema';
|
|
200
|
+
export * from './product-resolution/product-resolution-current-field.schema';
|
|
201
|
+
export * from './product-resolution/product-resolution-current.schema';
|
|
202
|
+
export * from './product-resolution/product-resolution-item.schema';
|
|
203
|
+
export * from './product-resolution/product-resolution-candidate-alternative.schema';
|
|
204
|
+
export * from './product-resolution/product-resolution-category-candidate.schema';
|
|
205
|
+
export * from './product-resolution/product-resolution-image-candidate.schema';
|
|
206
|
+
export * from './product-resolution/product-resolution-blocked-image.schema';
|
|
207
|
+
export * from './product-resolution/product-resolution-suggestions.schema';
|
|
208
|
+
export * from './product-resolution/product-resolution-group.schema';
|
|
209
|
+
export * from './product-resolution/product-resolution-summary.schema';
|
|
210
|
+
export * from './product-resolution/analyze-product-resolution-request.schema';
|
|
211
|
+
export * from './product-resolution/analyze-product-resolution-response.schema';
|
|
212
|
+
export * from './product-resolution/product-resolution-decision-set.schema';
|
|
213
|
+
export * from './product-resolution/product-resolution-decision.schema';
|
|
214
|
+
export * from './product-resolution/execute-product-resolution-request.schema';
|
|
215
|
+
export * from './product-resolution/product-resolution-group-result.schema';
|
|
216
|
+
export * from './product-resolution/execute-product-resolution-response.schema';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ProductMarkEnum } from '../../enum';
|
|
3
|
+
import { optionalQueryBooleanSchema } from '../../helpers/optional-query-boolean.helper';
|
|
3
4
|
|
|
4
5
|
export const GetProductListRequestSchema = z.object({
|
|
5
6
|
page: z.coerce.number().optional().default(1),
|
|
@@ -16,4 +17,7 @@ export const GetProductListRequestSchema = z.object({
|
|
|
16
17
|
size: z.string().optional(),
|
|
17
18
|
deliveryDates: z.array(z.coerce.date()).optional(),
|
|
18
19
|
marks: z.enum(ProductMarkEnum).array().optional(),
|
|
20
|
+
// Трёхзначные фильтры разбора: без параметра — весь список, false — только без категории / карточки.
|
|
21
|
+
hasCategory: optionalQueryBooleanSchema,
|
|
22
|
+
hasImage: optionalQueryBooleanSchema,
|
|
19
23
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PRODUCT_RESOLUTION_LIMITS } from '../../constant/product-resolution.constant';
|
|
3
|
+
import { ProductResolutionScopeSchema } from './product-resolution-scope.schema';
|
|
4
|
+
|
|
5
|
+
// POST, хотя анализ без побочных эффектов: область содержит списки UUID поставок, которые в query не помещаются.
|
|
6
|
+
export const AnalyzeProductResolutionRequestSchema = z.object({
|
|
7
|
+
scope: ProductResolutionScopeSchema,
|
|
8
|
+
page: z.number().int().min(1).optional().default(1),
|
|
9
|
+
count: z
|
|
10
|
+
.number()
|
|
11
|
+
.int()
|
|
12
|
+
.min(1)
|
|
13
|
+
.max(PRODUCT_RESOLUTION_LIMITS.MAX_PAGE_SIZE)
|
|
14
|
+
.optional()
|
|
15
|
+
.default(PRODUCT_RESOLUTION_LIMITS.DEFAULT_PAGE_SIZE),
|
|
16
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionGroupSchema } from './product-resolution-group.schema';
|
|
3
|
+
import { ProductResolutionSummarySchema } from './product-resolution-summary.schema';
|
|
4
|
+
|
|
5
|
+
export const AnalyzeProductResolutionResponseSchema = z.object({
|
|
6
|
+
data: z.object({
|
|
7
|
+
groups: z.array(ProductResolutionGroupSchema),
|
|
8
|
+
// Групп в области с учётом фильтра `issues` — для пагинации.
|
|
9
|
+
total: z.number(),
|
|
10
|
+
page: z.number(),
|
|
11
|
+
count: z.number(),
|
|
12
|
+
summary: ProductResolutionSummarySchema,
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PRODUCT_RESOLUTION_LIMITS } from '../../constant/product-resolution.constant';
|
|
3
|
+
import { ProductResolutionWriteModeEnum } from '../../enum/product-resolution-write-mode.enum';
|
|
4
|
+
import { ProductResolutionDecisionSchema } from './product-resolution-decision.schema';
|
|
5
|
+
import { ProductResolutionScopeSchema } from './product-resolution-scope.schema';
|
|
6
|
+
|
|
7
|
+
// Область та же, что в анализе: состав группы пересчитывается на сервере по ключу, а не присылается списком UUID.
|
|
8
|
+
export const ExecuteProductResolutionRequestSchema = z.object({
|
|
9
|
+
scope: ProductResolutionScopeSchema,
|
|
10
|
+
decisions: z.array(ProductResolutionDecisionSchema).min(1).max(PRODUCT_RESOLUTION_LIMITS.MAX_DECISIONS),
|
|
11
|
+
mode: z.nativeEnum(ProductResolutionWriteModeEnum).optional().default(ProductResolutionWriteModeEnum.FILL_ONLY),
|
|
12
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionGroupResultSchema } from './product-resolution-group-result.schema';
|
|
3
|
+
|
|
4
|
+
export const ExecuteProductResolutionResponseSchema = z.object({
|
|
5
|
+
data: z.object({
|
|
6
|
+
updatedProducts: z.number(),
|
|
7
|
+
aliasesCreated: z.number(),
|
|
8
|
+
groups: z.array(ProductResolutionGroupResultSchema),
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Карточка с таким же именем есть, но без категории — в резолв она не попадает (решение 2026-11-15:
|
|
4
|
+
// такие карточки правятся отдельно, здесь только показываем причину).
|
|
5
|
+
export const ProductResolutionBlockedImageSchema = z.object({
|
|
6
|
+
uuid: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionMatchedAttributeEnum } from '../../enum/product-resolution-matched-attribute.enum';
|
|
3
|
+
|
|
4
|
+
// Следующий по рангу кандидат: сотрудник выбирает сам, когда несколько карточек подходят почти одинаково.
|
|
5
|
+
export const ProductResolutionCandidateAlternativeSchema = z.object({
|
|
6
|
+
uuid: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
matched: z.array(z.nativeEnum(ProductResolutionMatchedAttributeEnum)),
|
|
9
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionCategoryReasonEnum } from '../../enum/product-resolution-category-reason.enum';
|
|
3
|
+
|
|
4
|
+
export const ProductResolutionCategoryCandidateSchema = z.object({
|
|
5
|
+
uuid: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
reason: z.nativeEnum(ProductResolutionCategoryReasonEnum),
|
|
8
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionCurrentFieldSchema } from './product-resolution-current-field.schema';
|
|
3
|
+
|
|
4
|
+
export const ProductResolutionCurrentSchema = z.object({
|
|
5
|
+
categoryUUID: ProductResolutionCurrentFieldSchema,
|
|
6
|
+
imageUUID: ProductResolutionCurrentFieldSchema,
|
|
7
|
+
color: ProductResolutionCurrentFieldSchema,
|
|
8
|
+
country: ProductResolutionCurrentFieldSchema,
|
|
9
|
+
grower: ProductResolutionCurrentFieldSchema,
|
|
10
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Что назначить группе руками. Отсутствие ключа — поле не трогаем. Карточка без категории тянет за собой
|
|
4
|
+
// категорию карточки, если у товара её нет.
|
|
5
|
+
export const ProductResolutionDecisionSetSchema = z.object({
|
|
6
|
+
categoryUUID: z.string().optional(),
|
|
7
|
+
imageUUID: z.string().optional(),
|
|
8
|
+
color: z.string().trim().min(1).optional(),
|
|
9
|
+
country: z.string().trim().min(1).optional(),
|
|
10
|
+
grower: z.string().trim().min(1).optional(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionDecisionActionEnum } from '../../enum/product-resolution-decision-action.enum';
|
|
3
|
+
import { ProductResolutionDecisionSetSchema } from './product-resolution-decision-set.schema';
|
|
4
|
+
import { ProductResolutionGroupKeySchema } from './product-resolution-group-key.schema';
|
|
5
|
+
|
|
6
|
+
// `learn` сохраняет решение в справочник: алиас карточки на ключ группы (или алиас категории, если
|
|
7
|
+
// назначена только категория), чтобы следующий импорт этой позиции прошёл без ручного разбора.
|
|
8
|
+
export const ProductResolutionDecisionSchema = z.object({
|
|
9
|
+
key: ProductResolutionGroupKeySchema,
|
|
10
|
+
action: z.nativeEnum(ProductResolutionDecisionActionEnum),
|
|
11
|
+
set: ProductResolutionDecisionSetSchema.optional(),
|
|
12
|
+
learn: z.boolean().optional().default(true),
|
|
13
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Ключ группы — нормализованное имя (нижний регистр, одиночные пробелы) и производитель в том же виде;
|
|
4
|
+
// пустой производитель — отдельная группа. Решение 2026-11-15: у одной позиции бывает несколько
|
|
5
|
+
// производителей, и карточка у них может быть разной.
|
|
6
|
+
export const ProductResolutionGroupKeySchema = z.object({
|
|
7
|
+
normalizedName: z.string().min(1),
|
|
8
|
+
grower: z.string().nullable(),
|
|
9
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ErrorMessageSchema } from '../error-message.schema';
|
|
3
|
+
import { ProductResolutionGroupKeySchema } from './product-resolution-group-key.schema';
|
|
4
|
+
|
|
5
|
+
export const ProductResolutionGroupResultSchema = z.object({
|
|
6
|
+
key: ProductResolutionGroupKeySchema,
|
|
7
|
+
// Товаров в группе на момент применения и сколько из них реально изменилось.
|
|
8
|
+
productCount: z.number(),
|
|
9
|
+
updatedCount: z.number(),
|
|
10
|
+
isAliasCreated: z.boolean(),
|
|
11
|
+
error: ErrorMessageSchema.optional(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionGroupStateEnum } from '../../enum/product-resolution-group-state.enum';
|
|
3
|
+
import { ProductResolutionIssueEnum } from '../../enum/product-resolution-issue.enum';
|
|
4
|
+
import { ProductResolutionSourceEnum } from '../../enum/product-resolution-source.enum';
|
|
5
|
+
import { ProductResolutionCurrentSchema } from './product-resolution-current.schema';
|
|
6
|
+
import { ProductResolutionGroupKeySchema } from './product-resolution-group-key.schema';
|
|
7
|
+
import { ProductResolutionItemSchema } from './product-resolution-item.schema';
|
|
8
|
+
import { ProductResolutionSuggestionsSchema } from './product-resolution-suggestions.schema';
|
|
9
|
+
|
|
10
|
+
export const ProductResolutionGroupSchema = z.object({
|
|
11
|
+
key: ProductResolutionGroupKeySchema,
|
|
12
|
+
sampleName: z.string(),
|
|
13
|
+
itemCount: z.number(),
|
|
14
|
+
totalBalance: z.number(),
|
|
15
|
+
sources: z.array(z.nativeEnum(ProductResolutionSourceEnum)),
|
|
16
|
+
// Образец товаров группы, не больше PRODUCT_RESOLUTION_LIMITS.MAX_ITEMS_PER_GROUP; полный размер — `itemCount`.
|
|
17
|
+
// `current`, `issues` и `sources` считаются по всем товарам группы.
|
|
18
|
+
items: z.array(ProductResolutionItemSchema),
|
|
19
|
+
current: ProductResolutionCurrentSchema,
|
|
20
|
+
categoryName: z.string().nullable(),
|
|
21
|
+
imageName: z.string().nullable(),
|
|
22
|
+
issues: z.array(z.nativeEnum(ProductResolutionIssueEnum)),
|
|
23
|
+
suggestions: ProductResolutionSuggestionsSchema,
|
|
24
|
+
state: z.nativeEnum(ProductResolutionGroupStateEnum),
|
|
25
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionImageReasonEnum } from '../../enum/product-resolution-image-reason.enum';
|
|
3
|
+
import { ProductResolutionMatchedAttributeEnum } from '../../enum/product-resolution-matched-attribute.enum';
|
|
4
|
+
import { ProductResolutionCandidateAlternativeSchema } from './product-resolution-candidate-alternative.schema';
|
|
5
|
+
|
|
6
|
+
export const ProductResolutionImageCandidateSchema = z.object({
|
|
7
|
+
uuid: z.string(),
|
|
8
|
+
name: z.string(),
|
|
9
|
+
imageUrl: z.string(),
|
|
10
|
+
categoryUUID: z.string().nullable(),
|
|
11
|
+
categoryName: z.string().nullable(),
|
|
12
|
+
reason: z.nativeEnum(ProductResolutionImageReasonEnum),
|
|
13
|
+
matched: z.array(z.nativeEnum(ProductResolutionMatchedAttributeEnum)),
|
|
14
|
+
alternatives: z.array(ProductResolutionCandidateAlternativeSchema),
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionSourceEnum } from '../../enum/product-resolution-source.enum';
|
|
3
|
+
|
|
4
|
+
export const ProductResolutionItemSchema = z.object({
|
|
5
|
+
productUUID: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
consignmentUUID: z.string(),
|
|
8
|
+
balance: z.number(),
|
|
9
|
+
source: z.nativeEnum(ProductResolutionSourceEnum),
|
|
10
|
+
categoryUUID: z.string().nullable(),
|
|
11
|
+
imageUUID: z.string().nullable(),
|
|
12
|
+
color: z.string().nullable(),
|
|
13
|
+
country: z.string().nullable(),
|
|
14
|
+
grower: z.string().nullable(),
|
|
15
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PRODUCT_RESOLUTION_LIMITS } from '../../constant/product-resolution.constant';
|
|
3
|
+
import { ProductResolutionIssueEnum } from '../../enum/product-resolution-issue.enum';
|
|
4
|
+
import { ProductResolutionSourceEnum } from '../../enum/product-resolution-source.enum';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Область разбора: какие товары попадают в анализ. Пустой список поставок — вся номенклатура компании.
|
|
8
|
+
* `issues` фильтрует товары (не группы): в группу входят только строки с запрошенной проблемой,
|
|
9
|
+
* поэтому без фильтра видно и уже разобранные позиции.
|
|
10
|
+
*/
|
|
11
|
+
export const ProductResolutionScopeSchema = z.object({
|
|
12
|
+
consignmentUUIDList: z.array(z.string()).max(PRODUCT_RESOLUTION_LIMITS.MAX_CONSIGNMENTS).optional(),
|
|
13
|
+
onlyInStock: z.boolean().optional().default(false),
|
|
14
|
+
issues: z.array(z.nativeEnum(ProductResolutionIssueEnum)).optional(),
|
|
15
|
+
sources: z.array(z.nativeEnum(ProductResolutionSourceEnum)).optional(),
|
|
16
|
+
search: z.string().trim().max(PRODUCT_RESOLUTION_LIMITS.MAX_SEARCH_LENGTH).optional(),
|
|
17
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionCategoryCandidateSchema } from './product-resolution-category-candidate.schema';
|
|
3
|
+
import { ProductResolutionImageCandidateSchema } from './product-resolution-image-candidate.schema';
|
|
4
|
+
import { ProductResolutionBlockedImageSchema } from './product-resolution-blocked-image.schema';
|
|
5
|
+
|
|
6
|
+
export const ProductResolutionSuggestionsSchema = z.object({
|
|
7
|
+
category: ProductResolutionCategoryCandidateSchema.nullable(),
|
|
8
|
+
image: ProductResolutionImageCandidateSchema.nullable(),
|
|
9
|
+
blockedImage: ProductResolutionBlockedImageSchema.nullable(),
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductResolutionIssueEnum } from '../../enum/product-resolution-issue.enum';
|
|
3
|
+
import { ProductResolutionSourceEnum } from '../../enum/product-resolution-source.enum';
|
|
4
|
+
|
|
5
|
+
// Сводка по всей области без фильтра `issues`: чипы-счётчики показывают, сколько товаров с каждой
|
|
6
|
+
// проблемой, независимо от того, какая проблема сейчас выбрана. Всегда содержит все ключи перечислений.
|
|
7
|
+
export const ProductResolutionSummarySchema = z.object({
|
|
8
|
+
totalProducts: z.number(),
|
|
9
|
+
totalGroups: z.number(),
|
|
10
|
+
byIssue: z.record(z.nativeEnum(ProductResolutionIssueEnum), z.number()),
|
|
11
|
+
bySource: z.record(z.nativeEnum(ProductResolutionSourceEnum), z.number()),
|
|
12
|
+
});
|