@floristcloud/api-lib 1.2.226 → 1.2.228
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/constant/error.js +7 -0
- package/build/constant/settings.constant.js +6 -1
- package/build/constant/validation-i18n-key.js +1 -0
- package/build/constant/validation-i18n-message.js +1 -0
- package/build/enum/index.js +2 -0
- package/build/enum/webshop-menu-item-color.enum.js +12 -0
- package/build/enum/webshop-menu-item-target.enum.js +9 -0
- package/build/schemas/index.js +5 -0
- package/build/schemas/settings/settings.schema.js +6 -1
- package/build/schemas/settings/webshop-featured-menu-item-badge-translations.schema.js +8 -0
- package/build/schemas/settings/webshop-featured-menu-item-name-translations.schema.js +9 -0
- package/build/schemas/settings/webshop-featured-menu-item-target.schema.js +16 -0
- package/build/schemas/settings/webshop-featured-menu-item.schema.js +36 -0
- package/build/schemas/settings/webshop-featured-menu-items.schema.js +23 -0
- package/constant/error.ts +7 -0
- package/constant/settings.constant.ts +7 -0
- package/constant/validation-i18n-key.ts +1 -0
- package/constant/validation-i18n-message.ts +1 -0
- package/enum/index.ts +2 -0
- package/enum/webshop-menu-item-color.enum.ts +8 -0
- package/enum/webshop-menu-item-target.enum.ts +5 -0
- package/package.json +1 -1
- package/schemas/index.ts +5 -0
- package/schemas/settings/settings.schema.ts +6 -0
- package/schemas/settings/webshop-featured-menu-item-badge-translations.schema.ts +9 -0
- package/schemas/settings/webshop-featured-menu-item-name-translations.schema.ts +10 -0
- package/schemas/settings/webshop-featured-menu-item-target.schema.ts +14 -0
- package/schemas/settings/webshop-featured-menu-item.schema.ts +34 -0
- package/schemas/settings/webshop-featured-menu-items.schema.ts +21 -0
package/build/constant/error.js
CHANGED
|
@@ -140,6 +140,13 @@ exports.ERRORS = {
|
|
|
140
140
|
message: 'At least one of pickup or delivery must stay enabled',
|
|
141
141
|
httpCode: 400,
|
|
142
142
|
},
|
|
143
|
+
// Пункт меню витрины ведёт на категорию или коллекцию, которой у компании нет (чужая, удалена,
|
|
144
|
+
// каталог постоянных заказов).
|
|
145
|
+
SETTINGS_FEATURED_MENU_ITEM_TARGET_NOT_FOUND: {
|
|
146
|
+
code: 'S009',
|
|
147
|
+
message: 'Webshop featured menu item target does not belong to the company',
|
|
148
|
+
httpCode: 400,
|
|
149
|
+
},
|
|
143
150
|
FORBIDDEN_API: { code: 'A011', message: 'Access denied', httpCode: 403 },
|
|
144
151
|
RESOURCE_ACCESS_DENIED: { code: 'A022', message: 'Resource does not belong to your company', httpCode: 400 },
|
|
145
152
|
RESOURCE_NOT_FOUND: { code: 'A023', message: 'Resource not found', httpCode: 404 },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TIME_OF_DAY_PATTERN = exports.DELIVERY_TIME_SLOTS_MAX_LENGTH = exports.DISABLE_ORDERS_MESSAGE_MAX_LENGTH = void 0;
|
|
3
|
+
exports.WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH = exports.WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH = exports.WEBSHOP_FEATURED_MENU_ITEMS_MAX_LENGTH = exports.TIME_OF_DAY_PATTERN = exports.DELIVERY_TIME_SLOTS_MAX_LENGTH = exports.DISABLE_ORDERS_MESSAGE_MAX_LENGTH = void 0;
|
|
4
4
|
// Текст режима «запрет заказов» («Возобновим работу в 16.00 после инвентаризации»). Витрина рисует
|
|
5
5
|
// его баннером вместо каталога, поэтому это короткое объявление, а не страница: 300 символов.
|
|
6
6
|
exports.DISABLE_ORDERS_MESSAGE_MAX_LENGTH = 300;
|
|
@@ -8,3 +8,8 @@ exports.DISABLE_ORDERS_MESSAGE_MAX_LENGTH = 300;
|
|
|
8
8
|
exports.DELIVERY_TIME_SLOTS_MAX_LENGTH = 24;
|
|
9
9
|
// Время суток в слотах доставки — `HH:mm` по часам компании (её `timeZone`), 00:00–23:59.
|
|
10
10
|
exports.TIME_OF_DAY_PATTERN = /^([01]\d|2[0-3]):[0-5]\d$/;
|
|
11
|
+
// Выделенных пунктов меню витрины — не больше пяти: блок стоит над каталогом и не должен его вытеснять.
|
|
12
|
+
exports.WEBSHOP_FEATURED_MENU_ITEMS_MAX_LENGTH = 5;
|
|
13
|
+
// Подпись пункта и бейдж рисуются в одну строку сайдбара.
|
|
14
|
+
exports.WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH = 60;
|
|
15
|
+
exports.WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH = 20;
|
|
@@ -44,4 +44,5 @@ exports.ValidationI18nKey = {
|
|
|
44
44
|
timeOfDayFormat: 'validation.timeOfDayFormat',
|
|
45
45
|
deliveryTimeSlotRange: 'validation.deliveryTimeSlotRange',
|
|
46
46
|
deliveryTimeSlotDuplicate: 'validation.deliveryTimeSlotDuplicate',
|
|
47
|
+
featuredMenuItemDuplicate: 'validation.featuredMenuItemDuplicate',
|
|
47
48
|
};
|
|
@@ -47,6 +47,7 @@ exports.VALIDATION_I18N_MESSAGE = {
|
|
|
47
47
|
[validation_i18n_key_1.ValidationI18nKey.timeOfDayFormat]: 'Time must be in HH:mm format',
|
|
48
48
|
[validation_i18n_key_1.ValidationI18nKey.deliveryTimeSlotRange]: 'Delivery time slot must end after it starts',
|
|
49
49
|
[validation_i18n_key_1.ValidationI18nKey.deliveryTimeSlotDuplicate]: 'The same delivery time slot is listed twice',
|
|
50
|
+
[validation_i18n_key_1.ValidationI18nKey.featuredMenuItemDuplicate]: 'The same webshop menu item is listed twice',
|
|
50
51
|
};
|
|
51
52
|
/**
|
|
52
53
|
* A validation `message` is a stable i18n token when it matches this pattern (e.g. `validation.dateRange`).
|
package/build/enum/index.js
CHANGED
|
@@ -174,6 +174,8 @@ __exportStar(require("./user-type.enum"), exports);
|
|
|
174
174
|
__exportStar(require("./userRole.enum"), exports);
|
|
175
175
|
__exportStar(require("./userStatus.enum"), exports);
|
|
176
176
|
__exportStar(require("./webshop-main-display-mode.enum"), exports);
|
|
177
|
+
__exportStar(require("./webshop-menu-item-color.enum"), exports);
|
|
178
|
+
__exportStar(require("./webshop-menu-item-target.enum"), exports);
|
|
177
179
|
__exportStar(require("./webshop-mode.enum"), exports);
|
|
178
180
|
__exportStar(require("./write-off-breakdown-group-by.enum"), exports);
|
|
179
181
|
__exportStar(require("./write-off-report-date-basis.enum"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebshopMenuItemColorEnum = void 0;
|
|
4
|
+
// Палитра выделенного пункта меню витрины. Цвета фиксированные, а не hex: контраст с текстом
|
|
5
|
+
// подбирает витрина, произвольный цвет дал бы нечитаемый пункт.
|
|
6
|
+
var WebshopMenuItemColorEnum;
|
|
7
|
+
(function (WebshopMenuItemColorEnum) {
|
|
8
|
+
WebshopMenuItemColorEnum["ACCENT"] = "ACCENT";
|
|
9
|
+
WebshopMenuItemColorEnum["RED"] = "RED";
|
|
10
|
+
WebshopMenuItemColorEnum["GREEN"] = "GREEN";
|
|
11
|
+
WebshopMenuItemColorEnum["GOLD"] = "GOLD";
|
|
12
|
+
})(WebshopMenuItemColorEnum || (exports.WebshopMenuItemColorEnum = WebshopMenuItemColorEnum = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebshopMenuItemTargetEnum = void 0;
|
|
4
|
+
// На что ведёт выделенный пункт меню витрины.
|
|
5
|
+
var WebshopMenuItemTargetEnum;
|
|
6
|
+
(function (WebshopMenuItemTargetEnum) {
|
|
7
|
+
WebshopMenuItemTargetEnum["CATEGORY"] = "CATEGORY";
|
|
8
|
+
WebshopMenuItemTargetEnum["PRE_ORDER_COLLECTION"] = "PRE_ORDER_COLLECTION";
|
|
9
|
+
})(WebshopMenuItemTargetEnum || (exports.WebshopMenuItemTargetEnum = WebshopMenuItemTargetEnum = {}));
|
package/build/schemas/index.js
CHANGED
|
@@ -130,6 +130,11 @@ __exportStar(require("./settings/delivery-pricing-tiers.schema"), exports);
|
|
|
130
130
|
__exportStar(require("./settings/delivery-time-slot.schema"), exports);
|
|
131
131
|
__exportStar(require("./settings/delivery-time-slots.schema"), exports);
|
|
132
132
|
__exportStar(require("./settings/time-of-day.schema"), exports);
|
|
133
|
+
__exportStar(require("./settings/webshop-featured-menu-item.schema"), exports);
|
|
134
|
+
__exportStar(require("./settings/webshop-featured-menu-item-badge-translations.schema"), exports);
|
|
135
|
+
__exportStar(require("./settings/webshop-featured-menu-item-name-translations.schema"), exports);
|
|
136
|
+
__exportStar(require("./settings/webshop-featured-menu-item-target.schema"), exports);
|
|
137
|
+
__exportStar(require("./settings/webshop-featured-menu-items.schema"), exports);
|
|
133
138
|
__exportStar(require("./settings/group-delivery-pricing-rule.schema"), exports);
|
|
134
139
|
__exportStar(require("./settings/settings-private-response.schema"), exports);
|
|
135
140
|
__exportStar(require("./settings/settings-private.schema"), exports);
|
|
@@ -13,6 +13,8 @@ const delivery_pricing_in_transit_mode_enum_1 = require("../../enum/delivery-pri
|
|
|
13
13
|
const delivery_pricing_rules_schema_1 = require("./delivery-pricing-rules.schema");
|
|
14
14
|
const delivery_pricing_tier_schema_1 = require("./delivery-pricing-tier.schema");
|
|
15
15
|
const delivery_time_slots_schema_1 = require("./delivery-time-slots.schema");
|
|
16
|
+
const webshop_featured_menu_item_target_schema_1 = require("./webshop-featured-menu-item-target.schema");
|
|
17
|
+
const webshop_featured_menu_items_schema_1 = require("./webshop-featured-menu-items.schema");
|
|
16
18
|
// Preserve existing direct imports and contracts package exports.
|
|
17
19
|
var delivery_pricing_rule_schema_1 = require("./delivery-pricing-rule.schema");
|
|
18
20
|
Object.defineProperty(exports, "DeliveryPricingRuleSchema", { enumerable: true, get: function () { return delivery_pricing_rule_schema_1.DeliveryPricingRuleSchema; } });
|
|
@@ -141,11 +143,14 @@ exports.SettingsSchema = zod_1.z.object({
|
|
|
141
143
|
isDeliveryEnabled: zod_1.z.boolean(),
|
|
142
144
|
deliveryTimeSlots: delivery_time_slots_schema_1.DeliveryTimeSlotsSchema.nullable(),
|
|
143
145
|
employeeClientScopeEnabled: zod_1.z.boolean(),
|
|
146
|
+
webshopFeaturedMenuItems: webshop_featured_menu_items_schema_1.WebshopFeaturedMenuItemsSchema.nullable(),
|
|
144
147
|
telegramStaffBotName: zod_1.z.string().nullable().optional(),
|
|
145
148
|
});
|
|
146
149
|
exports.SettingsForAdminSchema = exports.SettingsSchema.extend({
|
|
147
150
|
deliveryPricingRules: delivery_pricing_rules_schema_1.DeliveryPricingRulesSchema.nullable(),
|
|
148
151
|
deliveryPricingInTransitMode: zod_1.z.nativeEnum(delivery_pricing_in_transit_mode_enum_1.DeliveryPricingInTransitModeEnum),
|
|
152
|
+
// Цели выделенных пунктов меню витрины: имя и доступность, по одной на пункт.
|
|
153
|
+
webshopFeaturedMenuItemTargets: zod_1.z.array(webshop_featured_menu_item_target_schema_1.WebshopFeaturedMenuItemTargetSchema),
|
|
149
154
|
// post terminal settings
|
|
150
155
|
vatTag: zod_1.z.string().nullable(),
|
|
151
156
|
taxMode: zod_1.z.string().nullable(),
|
|
@@ -177,7 +182,7 @@ exports.UpdateSettingsRequestSchema = zod_1.z.object(Object.assign(Object.assign
|
|
|
177
182
|
opensAt: zod_1.z.coerce.date().optional(),
|
|
178
183
|
closesAt: zod_1.z.coerce.date().optional(),
|
|
179
184
|
isClosed: zod_1.z.coerce.boolean(),
|
|
180
|
-
})), phoneSales: zod_1.z.string().nullable().optional(), phoneWhatsappSales: zod_1.z.string().nullable().optional(), telegramChannel: zod_1.z.string().nullable().optional(), maxChannel: zod_1.z.string().nullable().optional(), contactPhoneList: exports.ContactPhoneListSchema.nullable().optional(), menuItemsSort: zod_1.z.array(zod_1.z.nativeEnum(menu_items_url_enum_1.MenuItemsUrlEnum)).nullable().optional(), phoneCountryCode: zod_1.z.array(zod_1.z.string()).optional(), aboutCompany: zod_1.z.string().nullable().optional(), companyRequisites: zod_1.z.string().nullable().optional(), offerAgreement: zod_1.z.string().nullable().optional(), privacyPolicy: zod_1.z.string().nullable().optional(), personalDataPolicy: zod_1.z.string().nullable().optional(), deliveryPolicy: zod_1.z.string().nullable().optional(), writeOffPolicy: zod_1.z.string().nullable().optional(), disableOrders: zod_1.z.boolean().optional(), disableOrdersMessage: exports.DisableOrdersMessageSchema.nullable().optional(), isMessengerEnabled: zod_1.z.coerce.boolean().optional(), isWriteOffAcceptanceEnabled: zod_1.z.coerce.boolean().optional(), isInvoiceDownloadEnabled: zod_1.z.coerce.boolean().optional(), isBalanceVisible: zod_1.z.coerce.boolean().optional(), bankHookEnabled: zod_1.z.coerce.boolean().optional(), bankHookToken: zod_1.z.string().nullable().optional(), loginImageKeyList: zod_1.z.array(zod_1.z.string()).optional(), chatHasManagerMode: zod_1.z.nativeEnum(enum_1.ChatHasManagerModeEnum).default(enum_1.ChatHasManagerModeEnum.ALL_RW).optional(), chatNoManagerMode: zod_1.z.nativeEnum(enum_1.ChatNoManagerModeEnum).default(enum_1.ChatNoManagerModeEnum.ANY_MANAGER).optional(), importantMessage: exports.ImportantMessageSchema.nullable().optional(), deliveryPricingEnabled: zod_1.z.coerce.boolean().optional(), deliveryPricingRules: delivery_pricing_rules_schema_1.DeliveryPricingRulesSchema.nullable().optional(), deliveryPricingInTransitMode: zod_1.z.nativeEnum(delivery_pricing_in_transit_mode_enum_1.DeliveryPricingInTransitModeEnum).optional(), isPickupEnabled: zod_1.z.boolean().optional(), isDeliveryEnabled: zod_1.z.boolean().optional(), deliveryTimeSlots: delivery_time_slots_schema_1.DeliveryTimeSlotsSchema.nullable().optional(), employeeClientScopeEnabled: zod_1.z.coerce.boolean().optional(),
|
|
185
|
+
})), phoneSales: zod_1.z.string().nullable().optional(), phoneWhatsappSales: zod_1.z.string().nullable().optional(), telegramChannel: zod_1.z.string().nullable().optional(), maxChannel: zod_1.z.string().nullable().optional(), contactPhoneList: exports.ContactPhoneListSchema.nullable().optional(), menuItemsSort: zod_1.z.array(zod_1.z.nativeEnum(menu_items_url_enum_1.MenuItemsUrlEnum)).nullable().optional(), phoneCountryCode: zod_1.z.array(zod_1.z.string()).optional(), aboutCompany: zod_1.z.string().nullable().optional(), companyRequisites: zod_1.z.string().nullable().optional(), offerAgreement: zod_1.z.string().nullable().optional(), privacyPolicy: zod_1.z.string().nullable().optional(), personalDataPolicy: zod_1.z.string().nullable().optional(), deliveryPolicy: zod_1.z.string().nullable().optional(), writeOffPolicy: zod_1.z.string().nullable().optional(), disableOrders: zod_1.z.boolean().optional(), disableOrdersMessage: exports.DisableOrdersMessageSchema.nullable().optional(), isMessengerEnabled: zod_1.z.coerce.boolean().optional(), isWriteOffAcceptanceEnabled: zod_1.z.coerce.boolean().optional(), isInvoiceDownloadEnabled: zod_1.z.coerce.boolean().optional(), isBalanceVisible: zod_1.z.coerce.boolean().optional(), bankHookEnabled: zod_1.z.coerce.boolean().optional(), bankHookToken: zod_1.z.string().nullable().optional(), loginImageKeyList: zod_1.z.array(zod_1.z.string()).optional(), chatHasManagerMode: zod_1.z.nativeEnum(enum_1.ChatHasManagerModeEnum).default(enum_1.ChatHasManagerModeEnum.ALL_RW).optional(), chatNoManagerMode: zod_1.z.nativeEnum(enum_1.ChatNoManagerModeEnum).default(enum_1.ChatNoManagerModeEnum.ANY_MANAGER).optional(), importantMessage: exports.ImportantMessageSchema.nullable().optional(), deliveryPricingEnabled: zod_1.z.coerce.boolean().optional(), deliveryPricingRules: delivery_pricing_rules_schema_1.DeliveryPricingRulesSchema.nullable().optional(), deliveryPricingInTransitMode: zod_1.z.nativeEnum(delivery_pricing_in_transit_mode_enum_1.DeliveryPricingInTransitModeEnum).optional(), isPickupEnabled: zod_1.z.boolean().optional(), isDeliveryEnabled: zod_1.z.boolean().optional(), deliveryTimeSlots: delivery_time_slots_schema_1.DeliveryTimeSlotsSchema.nullable().optional(), employeeClientScopeEnabled: zod_1.z.coerce.boolean().optional(), webshopFeaturedMenuItems: webshop_featured_menu_items_schema_1.WebshopFeaturedMenuItemsSchema.nullable().optional(),
|
|
181
186
|
// post terminal settings
|
|
182
187
|
vatTag: zod_1.z.string().nullable().optional(), taxMode: zod_1.z.string().nullable().optional(), integrationUrl: zod_1.z.string().nullable().optional(), receiptLogin: zod_1.z.string().nullable().optional(), receiptPassword: zod_1.z.string().nullable().optional(), retailPointUuid: zod_1.z.string().nullable().optional(),
|
|
183
188
|
// whatsapp settings
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebshopFeaturedMenuItemBadgeTranslationsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const settings_constant_1 = require("../../constant/settings.constant");
|
|
6
|
+
const language_enum_1 = require("../../enum/language.enum");
|
|
7
|
+
// Переводы бейджа пункта меню витрины — с тем же потолком длины, что и сам бейдж.
|
|
8
|
+
exports.WebshopFeaturedMenuItemBadgeTranslationsSchema = zod_1.z.partialRecord(zod_1.z.enum(language_enum_1.LanguageEnum), zod_1.z.string().trim().max(settings_constant_1.WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebshopFeaturedMenuItemNameTranslationsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const settings_constant_1 = require("../../constant/settings.constant");
|
|
6
|
+
const language_enum_1 = require("../../enum/language.enum");
|
|
7
|
+
// Переводы подписи пункта меню витрины — с тем же потолком длины, что и сама подпись: общий
|
|
8
|
+
// `LocalizedNameSchema` допускает 255 символов, а пункт рисуется в одну строку сайдбара.
|
|
9
|
+
exports.WebshopFeaturedMenuItemNameTranslationsSchema = zod_1.z.partialRecord(zod_1.z.enum(language_enum_1.LanguageEnum), zod_1.z.string().trim().max(settings_constant_1.WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebshopFeaturedMenuItemTargetSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const webshop_menu_item_target_enum_1 = require("../../enum/webshop-menu-item-target.enum");
|
|
6
|
+
/**
|
|
7
|
+
* Цель выделенного пункта глазами панели: имя для автокомплита и признак, увидит ли её витрина.
|
|
8
|
+
* `name: null` — цели больше нет (удалена). `isAvailable: false` — категория в архиве или удалена,
|
|
9
|
+
* коллекция закрыта, удалена или её срок приёма заказов истёк.
|
|
10
|
+
*/
|
|
11
|
+
exports.WebshopFeaturedMenuItemTargetSchema = zod_1.z.object({
|
|
12
|
+
targetType: zod_1.z.nativeEnum(webshop_menu_item_target_enum_1.WebshopMenuItemTargetEnum),
|
|
13
|
+
targetUUID: zod_1.z.string().uuid(),
|
|
14
|
+
name: zod_1.z.string().nullable(),
|
|
15
|
+
isAvailable: zod_1.z.boolean(),
|
|
16
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebshopFeaturedMenuItemSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const settings_constant_1 = require("../../constant/settings.constant");
|
|
6
|
+
const validation_i18n_key_1 = require("../../constant/validation-i18n-key");
|
|
7
|
+
const webshop_menu_item_color_enum_1 = require("../../enum/webshop-menu-item-color.enum");
|
|
8
|
+
const webshop_menu_item_target_enum_1 = require("../../enum/webshop-menu-item-target.enum");
|
|
9
|
+
const webshop_featured_menu_item_badge_translations_schema_1 = require("./webshop-featured-menu-item-badge-translations.schema");
|
|
10
|
+
const webshop_featured_menu_item_name_translations_schema_1 = require("./webshop-featured-menu-item-name-translations.schema");
|
|
11
|
+
/**
|
|
12
|
+
* Выделенный пункт меню витрины: ссылка на категорию или коллекцию предзаказа над каталогом.
|
|
13
|
+
*
|
|
14
|
+
* `uuid` генерирует панель — это ключ строки для перетаскивания, сервер его не назначает.
|
|
15
|
+
* Пустое `name` — витрина подписывает пункт именем цели. Показывать ли пункт конкретному клиенту,
|
|
16
|
+
* решает витрина: пункт виден, только если его цель есть в списках категорий и коллекций, которые
|
|
17
|
+
* она загружает для этого клиента. Окно `activeFrom`–`activeTo` — моменты времени ISO 8601.
|
|
18
|
+
*/
|
|
19
|
+
exports.WebshopFeaturedMenuItemSchema = zod_1.z
|
|
20
|
+
.object({
|
|
21
|
+
uuid: zod_1.z.string().uuid(),
|
|
22
|
+
targetType: zod_1.z.nativeEnum(webshop_menu_item_target_enum_1.WebshopMenuItemTargetEnum),
|
|
23
|
+
targetUUID: zod_1.z.string().uuid(),
|
|
24
|
+
name: zod_1.z.string().trim().max(settings_constant_1.WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH).nullable().optional(),
|
|
25
|
+
nameTranslations: webshop_featured_menu_item_name_translations_schema_1.WebshopFeaturedMenuItemNameTranslationsSchema.nullable().optional(),
|
|
26
|
+
badge: zod_1.z.string().trim().max(settings_constant_1.WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH).nullable().optional(),
|
|
27
|
+
badgeTranslations: webshop_featured_menu_item_badge_translations_schema_1.WebshopFeaturedMenuItemBadgeTranslationsSchema.nullable().optional(),
|
|
28
|
+
color: zod_1.z.nativeEnum(webshop_menu_item_color_enum_1.WebshopMenuItemColorEnum),
|
|
29
|
+
isActive: zod_1.z.boolean(),
|
|
30
|
+
activeFrom: zod_1.z.string().datetime({ offset: true }).nullable().optional(),
|
|
31
|
+
activeTo: zod_1.z.string().datetime({ offset: true }).nullable().optional(),
|
|
32
|
+
})
|
|
33
|
+
.refine(({ activeFrom, activeTo }) => !activeFrom || !activeTo || Date.parse(activeFrom) < Date.parse(activeTo), {
|
|
34
|
+
path: ['activeTo'],
|
|
35
|
+
message: validation_i18n_key_1.ValidationI18nKey.dateRange,
|
|
36
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebshopFeaturedMenuItemsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const settings_constant_1 = require("../../constant/settings.constant");
|
|
6
|
+
const validation_i18n_key_1 = require("../../constant/validation-i18n-key");
|
|
7
|
+
const webshop_featured_menu_item_schema_1 = require("./webshop-featured-menu-item.schema");
|
|
8
|
+
/**
|
|
9
|
+
* Выделенные пункты меню витрины в порядке показа. `null` в настройках — блока нет.
|
|
10
|
+
* Повтор `uuid` отклоняем: по нему панель различает строки при перетаскивании.
|
|
11
|
+
*/
|
|
12
|
+
exports.WebshopFeaturedMenuItemsSchema = zod_1.z
|
|
13
|
+
.array(webshop_featured_menu_item_schema_1.WebshopFeaturedMenuItemSchema)
|
|
14
|
+
.max(settings_constant_1.WEBSHOP_FEATURED_MENU_ITEMS_MAX_LENGTH)
|
|
15
|
+
.superRefine((items, ctx) => {
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
items.forEach((item, index) => {
|
|
18
|
+
if (seen.has(item.uuid)) {
|
|
19
|
+
ctx.addIssue({ code: 'custom', path: [index, 'uuid'], message: validation_i18n_key_1.ValidationI18nKey.featuredMenuItemDuplicate });
|
|
20
|
+
}
|
|
21
|
+
seen.add(item.uuid);
|
|
22
|
+
});
|
|
23
|
+
});
|
package/constant/error.ts
CHANGED
|
@@ -142,6 +142,13 @@ export const ERRORS = {
|
|
|
142
142
|
message: 'At least one of pickup or delivery must stay enabled',
|
|
143
143
|
httpCode: 400,
|
|
144
144
|
},
|
|
145
|
+
// Пункт меню витрины ведёт на категорию или коллекцию, которой у компании нет (чужая, удалена,
|
|
146
|
+
// каталог постоянных заказов).
|
|
147
|
+
SETTINGS_FEATURED_MENU_ITEM_TARGET_NOT_FOUND: {
|
|
148
|
+
code: 'S009',
|
|
149
|
+
message: 'Webshop featured menu item target does not belong to the company',
|
|
150
|
+
httpCode: 400,
|
|
151
|
+
},
|
|
145
152
|
|
|
146
153
|
FORBIDDEN_API: { code: 'A011', message: 'Access denied', httpCode: 403 },
|
|
147
154
|
RESOURCE_ACCESS_DENIED: { code: 'A022', message: 'Resource does not belong to your company', httpCode: 400 },
|
|
@@ -7,3 +7,10 @@ export const DELIVERY_TIME_SLOTS_MAX_LENGTH = 24;
|
|
|
7
7
|
|
|
8
8
|
// Время суток в слотах доставки — `HH:mm` по часам компании (её `timeZone`), 00:00–23:59.
|
|
9
9
|
export const TIME_OF_DAY_PATTERN = /^([01]\d|2[0-3]):[0-5]\d$/;
|
|
10
|
+
|
|
11
|
+
// Выделенных пунктов меню витрины — не больше пяти: блок стоит над каталогом и не должен его вытеснять.
|
|
12
|
+
export const WEBSHOP_FEATURED_MENU_ITEMS_MAX_LENGTH = 5;
|
|
13
|
+
|
|
14
|
+
// Подпись пункта и бейдж рисуются в одну строку сайдбара.
|
|
15
|
+
export const WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH = 60;
|
|
16
|
+
export const WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH = 20;
|
|
@@ -41,6 +41,7 @@ export const ValidationI18nKey = {
|
|
|
41
41
|
timeOfDayFormat: 'validation.timeOfDayFormat',
|
|
42
42
|
deliveryTimeSlotRange: 'validation.deliveryTimeSlotRange',
|
|
43
43
|
deliveryTimeSlotDuplicate: 'validation.deliveryTimeSlotDuplicate',
|
|
44
|
+
featuredMenuItemDuplicate: 'validation.featuredMenuItemDuplicate',
|
|
44
45
|
} as const;
|
|
45
46
|
|
|
46
47
|
export type ValidationI18nKeyType = (typeof ValidationI18nKey)[keyof typeof ValidationI18nKey];
|
|
@@ -45,6 +45,7 @@ export const VALIDATION_I18N_MESSAGE: Record<ValidationI18nKeyType, string> = {
|
|
|
45
45
|
[ValidationI18nKey.timeOfDayFormat]: 'Time must be in HH:mm format',
|
|
46
46
|
[ValidationI18nKey.deliveryTimeSlotRange]: 'Delivery time slot must end after it starts',
|
|
47
47
|
[ValidationI18nKey.deliveryTimeSlotDuplicate]: 'The same delivery time slot is listed twice',
|
|
48
|
+
[ValidationI18nKey.featuredMenuItemDuplicate]: 'The same webshop menu item is listed twice',
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
/**
|
package/enum/index.ts
CHANGED
|
@@ -158,6 +158,8 @@ export * from './user-type.enum';
|
|
|
158
158
|
export * from './userRole.enum';
|
|
159
159
|
export * from './userStatus.enum';
|
|
160
160
|
export * from './webshop-main-display-mode.enum';
|
|
161
|
+
export * from './webshop-menu-item-color.enum';
|
|
162
|
+
export * from './webshop-menu-item-target.enum';
|
|
161
163
|
export * from './webshop-mode.enum';
|
|
162
164
|
export * from './write-off-breakdown-group-by.enum';
|
|
163
165
|
export * from './write-off-report-date-basis.enum';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Палитра выделенного пункта меню витрины. Цвета фиксированные, а не hex: контраст с текстом
|
|
2
|
+
// подбирает витрина, произвольный цвет дал бы нечитаемый пункт.
|
|
3
|
+
export enum WebshopMenuItemColorEnum {
|
|
4
|
+
ACCENT = 'ACCENT',
|
|
5
|
+
RED = 'RED',
|
|
6
|
+
GREEN = 'GREEN',
|
|
7
|
+
GOLD = 'GOLD',
|
|
8
|
+
}
|
package/package.json
CHANGED
package/schemas/index.ts
CHANGED
|
@@ -114,6 +114,11 @@ export * from './settings/delivery-pricing-tiers.schema';
|
|
|
114
114
|
export * from './settings/delivery-time-slot.schema';
|
|
115
115
|
export * from './settings/delivery-time-slots.schema';
|
|
116
116
|
export * from './settings/time-of-day.schema';
|
|
117
|
+
export * from './settings/webshop-featured-menu-item.schema';
|
|
118
|
+
export * from './settings/webshop-featured-menu-item-badge-translations.schema';
|
|
119
|
+
export * from './settings/webshop-featured-menu-item-name-translations.schema';
|
|
120
|
+
export * from './settings/webshop-featured-menu-item-target.schema';
|
|
121
|
+
export * from './settings/webshop-featured-menu-items.schema';
|
|
117
122
|
export * from './settings/group-delivery-pricing-rule.schema';
|
|
118
123
|
export * from './settings/settings-private-response.schema';
|
|
119
124
|
export * from './settings/settings-private.schema';
|
|
@@ -24,6 +24,8 @@ import { DeliveryPricingInTransitModeEnum } from '../../enum/delivery-pricing-in
|
|
|
24
24
|
import { DeliveryPricingRulesSchema } from './delivery-pricing-rules.schema';
|
|
25
25
|
import { DeliveryPricingTierSchema } from './delivery-pricing-tier.schema';
|
|
26
26
|
import { DeliveryTimeSlotsSchema } from './delivery-time-slots.schema';
|
|
27
|
+
import { WebshopFeaturedMenuItemTargetSchema } from './webshop-featured-menu-item-target.schema';
|
|
28
|
+
import { WebshopFeaturedMenuItemsSchema } from './webshop-featured-menu-items.schema';
|
|
27
29
|
|
|
28
30
|
// Preserve existing direct imports and contracts package exports.
|
|
29
31
|
export { DeliveryPricingRuleSchema } from './delivery-pricing-rule.schema';
|
|
@@ -159,12 +161,15 @@ export const SettingsSchema = z.object({
|
|
|
159
161
|
isDeliveryEnabled: z.boolean(),
|
|
160
162
|
deliveryTimeSlots: DeliveryTimeSlotsSchema.nullable(),
|
|
161
163
|
employeeClientScopeEnabled: z.boolean(),
|
|
164
|
+
webshopFeaturedMenuItems: WebshopFeaturedMenuItemsSchema.nullable(),
|
|
162
165
|
telegramStaffBotName: z.string().nullable().optional(),
|
|
163
166
|
});
|
|
164
167
|
|
|
165
168
|
export const SettingsForAdminSchema = SettingsSchema.extend({
|
|
166
169
|
deliveryPricingRules: DeliveryPricingRulesSchema.nullable(),
|
|
167
170
|
deliveryPricingInTransitMode: z.nativeEnum(DeliveryPricingInTransitModeEnum),
|
|
171
|
+
// Цели выделенных пунктов меню витрины: имя и доступность, по одной на пункт.
|
|
172
|
+
webshopFeaturedMenuItemTargets: z.array(WebshopFeaturedMenuItemTargetSchema),
|
|
168
173
|
// post terminal settings
|
|
169
174
|
vatTag: z.string().nullable(),
|
|
170
175
|
taxMode: z.string().nullable(),
|
|
@@ -324,6 +329,7 @@ export const UpdateSettingsRequestSchema = z.object({
|
|
|
324
329
|
isDeliveryEnabled: z.boolean().optional(),
|
|
325
330
|
deliveryTimeSlots: DeliveryTimeSlotsSchema.nullable().optional(),
|
|
326
331
|
employeeClientScopeEnabled: z.coerce.boolean().optional(),
|
|
332
|
+
webshopFeaturedMenuItems: WebshopFeaturedMenuItemsSchema.nullable().optional(),
|
|
327
333
|
// post terminal settings
|
|
328
334
|
vatTag: z.string().nullable().optional(),
|
|
329
335
|
taxMode: z.string().nullable().optional(),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH } from '../../constant/settings.constant';
|
|
3
|
+
import { LanguageEnum } from '../../enum/language.enum';
|
|
4
|
+
|
|
5
|
+
// Переводы бейджа пункта меню витрины — с тем же потолком длины, что и сам бейдж.
|
|
6
|
+
export const WebshopFeaturedMenuItemBadgeTranslationsSchema = z.partialRecord(
|
|
7
|
+
z.enum(LanguageEnum),
|
|
8
|
+
z.string().trim().max(WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH),
|
|
9
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH } from '../../constant/settings.constant';
|
|
3
|
+
import { LanguageEnum } from '../../enum/language.enum';
|
|
4
|
+
|
|
5
|
+
// Переводы подписи пункта меню витрины — с тем же потолком длины, что и сама подпись: общий
|
|
6
|
+
// `LocalizedNameSchema` допускает 255 символов, а пункт рисуется в одну строку сайдбара.
|
|
7
|
+
export const WebshopFeaturedMenuItemNameTranslationsSchema = z.partialRecord(
|
|
8
|
+
z.enum(LanguageEnum),
|
|
9
|
+
z.string().trim().max(WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH),
|
|
10
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WebshopMenuItemTargetEnum } from '../../enum/webshop-menu-item-target.enum';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Цель выделенного пункта глазами панели: имя для автокомплита и признак, увидит ли её витрина.
|
|
6
|
+
* `name: null` — цели больше нет (удалена). `isAvailable: false` — категория в архиве или удалена,
|
|
7
|
+
* коллекция закрыта, удалена или её срок приёма заказов истёк.
|
|
8
|
+
*/
|
|
9
|
+
export const WebshopFeaturedMenuItemTargetSchema = z.object({
|
|
10
|
+
targetType: z.nativeEnum(WebshopMenuItemTargetEnum),
|
|
11
|
+
targetUUID: z.string().uuid(),
|
|
12
|
+
name: z.string().nullable(),
|
|
13
|
+
isAvailable: z.boolean(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH, WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH } from '../../constant/settings.constant';
|
|
3
|
+
import { ValidationI18nKey } from '../../constant/validation-i18n-key';
|
|
4
|
+
import { WebshopMenuItemColorEnum } from '../../enum/webshop-menu-item-color.enum';
|
|
5
|
+
import { WebshopMenuItemTargetEnum } from '../../enum/webshop-menu-item-target.enum';
|
|
6
|
+
import { WebshopFeaturedMenuItemBadgeTranslationsSchema } from './webshop-featured-menu-item-badge-translations.schema';
|
|
7
|
+
import { WebshopFeaturedMenuItemNameTranslationsSchema } from './webshop-featured-menu-item-name-translations.schema';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Выделенный пункт меню витрины: ссылка на категорию или коллекцию предзаказа над каталогом.
|
|
11
|
+
*
|
|
12
|
+
* `uuid` генерирует панель — это ключ строки для перетаскивания, сервер его не назначает.
|
|
13
|
+
* Пустое `name` — витрина подписывает пункт именем цели. Показывать ли пункт конкретному клиенту,
|
|
14
|
+
* решает витрина: пункт виден, только если его цель есть в списках категорий и коллекций, которые
|
|
15
|
+
* она загружает для этого клиента. Окно `activeFrom`–`activeTo` — моменты времени ISO 8601.
|
|
16
|
+
*/
|
|
17
|
+
export const WebshopFeaturedMenuItemSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
uuid: z.string().uuid(),
|
|
20
|
+
targetType: z.nativeEnum(WebshopMenuItemTargetEnum),
|
|
21
|
+
targetUUID: z.string().uuid(),
|
|
22
|
+
name: z.string().trim().max(WEBSHOP_FEATURED_MENU_ITEM_NAME_MAX_LENGTH).nullable().optional(),
|
|
23
|
+
nameTranslations: WebshopFeaturedMenuItemNameTranslationsSchema.nullable().optional(),
|
|
24
|
+
badge: z.string().trim().max(WEBSHOP_FEATURED_MENU_ITEM_BADGE_MAX_LENGTH).nullable().optional(),
|
|
25
|
+
badgeTranslations: WebshopFeaturedMenuItemBadgeTranslationsSchema.nullable().optional(),
|
|
26
|
+
color: z.nativeEnum(WebshopMenuItemColorEnum),
|
|
27
|
+
isActive: z.boolean(),
|
|
28
|
+
activeFrom: z.string().datetime({ offset: true }).nullable().optional(),
|
|
29
|
+
activeTo: z.string().datetime({ offset: true }).nullable().optional(),
|
|
30
|
+
})
|
|
31
|
+
.refine(({ activeFrom, activeTo }) => !activeFrom || !activeTo || Date.parse(activeFrom) < Date.parse(activeTo), {
|
|
32
|
+
path: ['activeTo'],
|
|
33
|
+
message: ValidationI18nKey.dateRange,
|
|
34
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WEBSHOP_FEATURED_MENU_ITEMS_MAX_LENGTH } from '../../constant/settings.constant';
|
|
3
|
+
import { ValidationI18nKey } from '../../constant/validation-i18n-key';
|
|
4
|
+
import { WebshopFeaturedMenuItemSchema } from './webshop-featured-menu-item.schema';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Выделенные пункты меню витрины в порядке показа. `null` в настройках — блока нет.
|
|
8
|
+
* Повтор `uuid` отклоняем: по нему панель различает строки при перетаскивании.
|
|
9
|
+
*/
|
|
10
|
+
export const WebshopFeaturedMenuItemsSchema = z
|
|
11
|
+
.array(WebshopFeaturedMenuItemSchema)
|
|
12
|
+
.max(WEBSHOP_FEATURED_MENU_ITEMS_MAX_LENGTH)
|
|
13
|
+
.superRefine((items, ctx) => {
|
|
14
|
+
const seen = new Set<string>();
|
|
15
|
+
items.forEach((item, index) => {
|
|
16
|
+
if (seen.has(item.uuid)) {
|
|
17
|
+
ctx.addIssue({ code: 'custom', path: [index, 'uuid'], message: ValidationI18nKey.featuredMenuItemDuplicate });
|
|
18
|
+
}
|
|
19
|
+
seen.add(item.uuid);
|
|
20
|
+
});
|
|
21
|
+
});
|