@floristcloud/api-lib 1.2.204 → 1.2.205

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.
@@ -129,6 +129,12 @@ exports.ERRORS = {
129
129
  // 409, а не 403: фильтр исключений маскирует текст любого 403 общим «Access denied», а здесь
130
130
  // клиенту важно получить причину — заказы отключены временно, доступ ни при чём.
131
131
  ORDERS_DISABLED_BY_SETTINGS: { code: 'S007', message: 'Ordering is temporarily disabled by the company', httpCode: 409 },
132
+ // Самовывоз и доставка выключаются по отдельности, но хотя бы один способ получения должен остаться.
133
+ SETTINGS_FULFILLMENT_METHOD_REQUIRED: {
134
+ code: 'S008',
135
+ message: 'At least one of pickup or delivery must stay enabled',
136
+ httpCode: 400,
137
+ },
132
138
  FORBIDDEN_API: { code: 'A011', message: 'Access denied', httpCode: 403 },
133
139
  RESOURCE_ACCESS_DENIED: { code: 'A022', message: 'Resource does not belong to your company', httpCode: 400 },
134
140
  RESOURCE_NOT_FOUND: { code: 'A023', message: 'Resource not found', httpCode: 404 },
@@ -659,6 +665,10 @@ exports.ERRORS = {
659
665
  ORDER_DELIVERY_NOT_DELETED: { code: 'OD009', message: 'Failed to delete order delivery', httpCode: 500 },
660
666
  ORDER_DELIVERY_NOT_EXIST: { code: 'OD010', message: 'Order delivery not exist', httpCode: 400 },
661
667
  ORDER_DELIVERY_FETCH_FAILED: { code: 'OD011', message: 'Order delivery fetch failed', httpCode: 500 },
668
+ ORDER_DELIVERY_DISABLED_BY_SETTINGS: { code: 'OD012', message: 'The company does not deliver orders', httpCode: 409 },
669
+ ORDER_PICKUP_DISABLED_BY_SETTINGS: { code: 'OD013', message: 'The company does not offer pickup', httpCode: 409 },
670
+ // Пока не отдаётся: время вне слотов принимается, пока не обновятся старые версии мобилки.
671
+ ORDER_DELIVERY_TIME_SLOT_INVALID: { code: 'OD014', message: 'Delivery time is not one of the company time slots', httpCode: 400 },
662
672
  //ORDER PRODUCT
663
673
  ORDER_PRODUCT_NOT_CREATED: { code: 'OP001', message: 'Failed to create product in order', httpCode: 500 },
664
674
  ORDER_PRODUCT_FETCH_FAILED: { code: 'OP002', message: 'Error when retrieving a product in order', httpCode: 500 },
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DISABLE_ORDERS_MESSAGE_MAX_LENGTH = void 0;
3
+ 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;
7
+ // Слотов доставки — не больше, чем часов в сутках: витрина и мобилка показывают их одним списком.
8
+ exports.DELIVERY_TIME_SLOTS_MAX_LENGTH = 24;
9
+ // Время суток в слотах доставки — `HH:mm` по часам компании (её `timeZone`), 00:00–23:59.
10
+ exports.TIME_OF_DAY_PATTERN = /^([01]\d|2[0-3]):[0-5]\d$/;
@@ -40,4 +40,7 @@ exports.ValidationI18nKey = {
40
40
  standingOrderQuantityRequired: 'validation.standingOrderQuantityRequired',
41
41
  contactMessengerUrlRequired: 'validation.contactMessengerUrlRequired',
42
42
  contactMessengerDuplicate: 'validation.contactMessengerDuplicate',
43
+ timeOfDayFormat: 'validation.timeOfDayFormat',
44
+ deliveryTimeSlotRange: 'validation.deliveryTimeSlotRange',
45
+ deliveryTimeSlotDuplicate: 'validation.deliveryTimeSlotDuplicate',
43
46
  };
@@ -43,6 +43,9 @@ exports.VALIDATION_I18N_MESSAGE = {
43
43
  [validation_i18n_key_1.ValidationI18nKey.standingOrderQuantityRequired]: 'Quantity is required',
44
44
  [validation_i18n_key_1.ValidationI18nKey.contactMessengerUrlRequired]: 'This messenger cannot be reached by phone number, provide a link',
45
45
  [validation_i18n_key_1.ValidationI18nKey.contactMessengerDuplicate]: 'The same messenger is listed twice for this contact',
46
+ [validation_i18n_key_1.ValidationI18nKey.timeOfDayFormat]: 'Time must be in HH:mm format',
47
+ [validation_i18n_key_1.ValidationI18nKey.deliveryTimeSlotRange]: 'Delivery time slot must end after it starts',
48
+ [validation_i18n_key_1.ValidationI18nKey.deliveryTimeSlotDuplicate]: 'The same delivery time slot is listed twice',
46
49
  };
47
50
  /**
48
51
  * A validation `message` is a stable i18n token when it matches this pattern (e.g. `validation.dateRange`).
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDeliveryTimeSlot = formatDeliveryTimeSlot;
4
+ /**
5
+ * Подпись слота доставки — ровно та строка, что клиент отправляет в `delivery.time` при оформлении
6
+ * и что хранится в `OrderDelivery.time`. Сервер сверяет время заказа со слотами компании по этой
7
+ * подписи, поэтому витрина и мобилка строят её только этой функцией.
8
+ */
9
+ function formatDeliveryTimeSlot(slot) {
10
+ return `${slot.from}-${slot.to}`;
11
+ }
@@ -18,3 +18,4 @@ __exportStar(require("./date.helper"), exports);
18
18
  __exportStar(require("./pagination.helper"), exports);
19
19
  __exportStar(require("./query-boolean.helper"), exports);
20
20
  __exportStar(require("./resolve-localized-name.helper"), exports);
21
+ __exportStar(require("./format-delivery-time-slot.helper"), exports);
@@ -7,5 +7,6 @@ exports.UpdateClientForClientRequestSchema = zod_1.z.object({
7
7
  contactName: zod_1.z.string().nullable(),
8
8
  phone: zod_1.z.string(),
9
9
  email: zod_1.z.email().toLowerCase(),
10
- alwaysRequiresDelivery: zod_1.z.boolean(),
10
+ // `alwaysRequiresDelivery` клиент больше не меняет — его ведут сотрудники в панели. Поле от
11
+ // необновлённых витрины и мобилки z.object отбрасывает молча, запрос при этом проходит.
11
12
  });
@@ -128,6 +128,9 @@ __exportStar(require("./service/service.schema"), exports);
128
128
  __exportStar(require("./settings/city-delivery-pricing-rule.schema"), exports);
129
129
  __exportStar(require("./settings/default-delivery-pricing-rule.schema"), exports);
130
130
  __exportStar(require("./settings/delivery-pricing-tiers.schema"), exports);
131
+ __exportStar(require("./settings/delivery-time-slot.schema"), exports);
132
+ __exportStar(require("./settings/delivery-time-slots.schema"), exports);
133
+ __exportStar(require("./settings/time-of-day.schema"), exports);
131
134
  __exportStar(require("./settings/group-delivery-pricing-rule.schema"), exports);
132
135
  __exportStar(require("./settings/settings-private-response.schema"), exports);
133
136
  __exportStar(require("./settings/settings-private.schema"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeliveryTimeSlotSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const validation_i18n_key_1 = require("../../constant/validation-i18n-key");
6
+ const time_of_day_schema_1 = require("./time-of-day.schema");
7
+ // Промежуток доставки, который клиент выбирает при оформлении: «с 10:00 до 14:00» по часам компании.
8
+ exports.DeliveryTimeSlotSchema = zod_1.z
9
+ .object({
10
+ from: time_of_day_schema_1.TimeOfDaySchema,
11
+ to: time_of_day_schema_1.TimeOfDaySchema,
12
+ })
13
+ .refine(({ from, to }) => from < to, { path: ['to'], message: validation_i18n_key_1.ValidationI18nKey.deliveryTimeSlotRange });
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeliveryTimeSlotsSchema = 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 format_delivery_time_slot_helper_1 = require("../../helpers/format-delivery-time-slot.helper");
8
+ const delivery_time_slot_schema_1 = require("./delivery-time-slot.schema");
9
+ /**
10
+ * Слоты доставки компании в порядке показа клиенту.
11
+ * `null` в настройках — слотов нет, время выбирается по часу внутри рабочих часов (прежнее поведение);
12
+ * пустой список — время доставки клиент не выбирает.
13
+ */
14
+ exports.DeliveryTimeSlotsSchema = zod_1.z
15
+ .array(delivery_time_slot_schema_1.DeliveryTimeSlotSchema)
16
+ .max(settings_constant_1.DELIVERY_TIME_SLOTS_MAX_LENGTH)
17
+ .superRefine((slots, ctx) => {
18
+ const seen = new Set();
19
+ slots.forEach((slot, index) => {
20
+ const label = (0, format_delivery_time_slot_helper_1.formatDeliveryTimeSlot)(slot);
21
+ if (seen.has(label)) {
22
+ ctx.addIssue({ code: 'custom', path: [index], message: validation_i18n_key_1.ValidationI18nKey.deliveryTimeSlotDuplicate });
23
+ }
24
+ seen.add(label);
25
+ });
26
+ });
@@ -12,6 +12,7 @@ const menu_items_url_enum_1 = require("../../enum/menu-items-url.enum");
12
12
  const delivery_pricing_in_transit_mode_enum_1 = require("../../enum/delivery-pricing-in-transit-mode.enum");
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
+ const delivery_time_slots_schema_1 = require("./delivery-time-slots.schema");
15
16
  // Preserve existing direct imports and contracts package exports.
16
17
  var delivery_pricing_rule_schema_1 = require("./delivery-pricing-rule.schema");
17
18
  Object.defineProperty(exports, "DeliveryPricingRuleSchema", { enumerable: true, get: function () { return delivery_pricing_rule_schema_1.DeliveryPricingRuleSchema; } });
@@ -135,6 +136,10 @@ exports.SettingsSchema = zod_1.z.object({
135
136
  importantMessage: exports.ImportantMessageSchema.nullable(),
136
137
  deliveryPricingEnabled: zod_1.z.boolean(),
137
138
  deliveryPricingTiers: zod_1.z.array(delivery_pricing_tier_schema_1.DeliveryPricingTierSchema).nullable(),
139
+ // Способы получения на витрине и в мобилке. Сервер отклоняет оформление выключенным способом.
140
+ isPickupEnabled: zod_1.z.boolean(),
141
+ isDeliveryEnabled: zod_1.z.boolean(),
142
+ deliveryTimeSlots: delivery_time_slots_schema_1.DeliveryTimeSlotsSchema.nullable(),
138
143
  employeeClientScopeEnabled: zod_1.z.boolean(),
139
144
  telegramStaffBotName: zod_1.z.string().nullable().optional(),
140
145
  });
@@ -166,13 +171,13 @@ exports.CreateSettingsSchema = zod_1.z.object(Object.assign(Object.assign({}, Re
166
171
  opensAt: zod_1.z.coerce.date().optional(),
167
172
  closesAt: zod_1.z.coerce.date().optional(),
168
173
  isClosed: zod_1.z.coerce.boolean(),
169
- })), 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(), loginImageKeyList: zod_1.z.array(zod_1.z.string()).optional(), chatHasManagerMode: zod_1.z.nativeEnum(enum_1.ChatHasManagerModeEnum).default(enum_1.ChatHasManagerModeEnum.ALL_RW), chatNoManagerMode: zod_1.z.nativeEnum(enum_1.ChatNoManagerModeEnum).default(enum_1.ChatNoManagerModeEnum.ANY_MANAGER), 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() }));
174
+ })), 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(), loginImageKeyList: zod_1.z.array(zod_1.z.string()).optional(), chatHasManagerMode: zod_1.z.nativeEnum(enum_1.ChatHasManagerModeEnum).default(enum_1.ChatHasManagerModeEnum.ALL_RW), chatNoManagerMode: zod_1.z.nativeEnum(enum_1.ChatNoManagerModeEnum).default(enum_1.ChatNoManagerModeEnum.ANY_MANAGER), 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() }));
170
175
  exports.UpdateSettingsRequestSchema = zod_1.z.object(Object.assign(Object.assign({}, RemovedSellerDocumentSettings), { language: zod_1.z.nativeEnum(enum_1.LanguageEnum), additionalLanguage: zod_1.z.nativeEnum(enum_1.LanguageEnum).nullable().optional(), currency: zod_1.z.string().optional(), timeZone: zod_1.z.string().optional(), isImageTemplateSync: zod_1.z.coerce.boolean().optional(), phoneFormat: zod_1.z.string().optional(), webShopLegalName: zod_1.z.string().nullable().optional(), webShopName: zod_1.z.string().optional(), address: zod_1.z.string().optional(), phone: zod_1.z.string().optional(), instagram: zod_1.z.string().optional().nullable(), mapUrl: zod_1.z.string().optional().nullable(), logoKey: zod_1.z.string().optional().nullable(), iconKey: zod_1.z.string().optional().nullable(), invoiceProductFields: zod_1.z.array(zod_1.z.nativeEnum(enum_1.InvoiceProductFieldEnum)).optional().nullable(), isShowPriceAnonymous: zod_1.z.coerce.boolean().optional(), orderExpirationWarningMin: zod_1.z.coerce.number().nullable().optional(), orderExpirationMin: zod_1.z.coerce.number().nullable().optional(), paymentGraceDaysAfterCompletion: zod_1.z.coerce.number().nullable().optional(), writeOffAllowedHoursAfterCompletion: zod_1.z.coerce.number().nullable().optional(), discountPriceRounding: zod_1.z.nativeEnum(enum_1.DiscountPriceRoundingEnum).optional(), webshopMainDisplayMode: zod_1.z.nativeEnum(webshop_main_display_mode_enum_1.WebshopMainDisplayModeEnum).nullable().optional(), webshopMode: zod_1.z.nativeEnum(enum_1.WebshopModeEnum).nullable().optional(), workingHours: zod_1.z.array(zod_1.z.object({
171
176
  dayOfWeek: zod_1.z.coerce.number(),
172
177
  opensAt: zod_1.z.coerce.date().optional(),
173
178
  closesAt: zod_1.z.coerce.date().optional(),
174
179
  isClosed: zod_1.z.coerce.boolean(),
175
- })), 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(), employeeClientScopeEnabled: zod_1.z.coerce.boolean().optional(),
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(),
176
181
  // post terminal settings
177
182
  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(),
178
183
  // whatsapp settings
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimeOfDaySchema = 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
+ // Время суток `HH:mm` по часам компании. Строка, а не Date: у времени без дня нет таймзоны,
8
+ // и сравнивать такие строки можно лексикографически.
9
+ exports.TimeOfDaySchema = zod_1.z.string().regex(settings_constant_1.TIME_OF_DAY_PATTERN, { message: validation_i18n_key_1.ValidationI18nKey.timeOfDayFormat });
package/constant/error.ts CHANGED
@@ -131,6 +131,12 @@ export const ERRORS = {
131
131
  // 409, а не 403: фильтр исключений маскирует текст любого 403 общим «Access denied», а здесь
132
132
  // клиенту важно получить причину — заказы отключены временно, доступ ни при чём.
133
133
  ORDERS_DISABLED_BY_SETTINGS: { code: 'S007', message: 'Ordering is temporarily disabled by the company', httpCode: 409 },
134
+ // Самовывоз и доставка выключаются по отдельности, но хотя бы один способ получения должен остаться.
135
+ SETTINGS_FULFILLMENT_METHOD_REQUIRED: {
136
+ code: 'S008',
137
+ message: 'At least one of pickup or delivery must stay enabled',
138
+ httpCode: 400,
139
+ },
134
140
 
135
141
  FORBIDDEN_API: { code: 'A011', message: 'Access denied', httpCode: 403 },
136
142
  RESOURCE_ACCESS_DENIED: { code: 'A022', message: 'Resource does not belong to your company', httpCode: 400 },
@@ -680,6 +686,10 @@ export const ERRORS = {
680
686
  ORDER_DELIVERY_NOT_DELETED: { code: 'OD009', message: 'Failed to delete order delivery', httpCode: 500 },
681
687
  ORDER_DELIVERY_NOT_EXIST: { code: 'OD010', message: 'Order delivery not exist', httpCode: 400 },
682
688
  ORDER_DELIVERY_FETCH_FAILED: { code: 'OD011', message: 'Order delivery fetch failed', httpCode: 500 },
689
+ ORDER_DELIVERY_DISABLED_BY_SETTINGS: { code: 'OD012', message: 'The company does not deliver orders', httpCode: 409 },
690
+ ORDER_PICKUP_DISABLED_BY_SETTINGS: { code: 'OD013', message: 'The company does not offer pickup', httpCode: 409 },
691
+ // Пока не отдаётся: время вне слотов принимается, пока не обновятся старые версии мобилки.
692
+ ORDER_DELIVERY_TIME_SLOT_INVALID: { code: 'OD014', message: 'Delivery time is not one of the company time slots', httpCode: 400 },
683
693
 
684
694
  //ORDER PRODUCT
685
695
  ORDER_PRODUCT_NOT_CREATED: { code: 'OP001', message: 'Failed to create product in order', httpCode: 500 },
@@ -1,3 +1,9 @@
1
1
  // Текст режима «запрет заказов» («Возобновим работу в 16.00 после инвентаризации»). Витрина рисует
2
2
  // его баннером вместо каталога, поэтому это короткое объявление, а не страница: 300 символов.
3
3
  export const DISABLE_ORDERS_MESSAGE_MAX_LENGTH = 300;
4
+
5
+ // Слотов доставки — не больше, чем часов в сутках: витрина и мобилка показывают их одним списком.
6
+ export const DELIVERY_TIME_SLOTS_MAX_LENGTH = 24;
7
+
8
+ // Время суток в слотах доставки — `HH:mm` по часам компании (её `timeZone`), 00:00–23:59.
9
+ export const TIME_OF_DAY_PATTERN = /^([01]\d|2[0-3]):[0-5]\d$/;
@@ -37,6 +37,9 @@ export const ValidationI18nKey = {
37
37
  standingOrderQuantityRequired: 'validation.standingOrderQuantityRequired',
38
38
  contactMessengerUrlRequired: 'validation.contactMessengerUrlRequired',
39
39
  contactMessengerDuplicate: 'validation.contactMessengerDuplicate',
40
+ timeOfDayFormat: 'validation.timeOfDayFormat',
41
+ deliveryTimeSlotRange: 'validation.deliveryTimeSlotRange',
42
+ deliveryTimeSlotDuplicate: 'validation.deliveryTimeSlotDuplicate',
40
43
  } as const;
41
44
 
42
45
  export type ValidationI18nKeyType = (typeof ValidationI18nKey)[keyof typeof ValidationI18nKey];
@@ -41,6 +41,9 @@ export const VALIDATION_I18N_MESSAGE: Record<ValidationI18nKeyType, string> = {
41
41
  [ValidationI18nKey.standingOrderQuantityRequired]: 'Quantity is required',
42
42
  [ValidationI18nKey.contactMessengerUrlRequired]: 'This messenger cannot be reached by phone number, provide a link',
43
43
  [ValidationI18nKey.contactMessengerDuplicate]: 'The same messenger is listed twice for this contact',
44
+ [ValidationI18nKey.timeOfDayFormat]: 'Time must be in HH:mm format',
45
+ [ValidationI18nKey.deliveryTimeSlotRange]: 'Delivery time slot must end after it starts',
46
+ [ValidationI18nKey.deliveryTimeSlotDuplicate]: 'The same delivery time slot is listed twice',
44
47
  };
45
48
 
46
49
  /**
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Подпись слота доставки — ровно та строка, что клиент отправляет в `delivery.time` при оформлении
3
+ * и что хранится в `OrderDelivery.time`. Сервер сверяет время заказа со слотами компании по этой
4
+ * подписи, поэтому витрина и мобилка строят её только этой функцией.
5
+ */
6
+ export function formatDeliveryTimeSlot(slot: { from: string; to: string }): string {
7
+ return `${slot.from}-${slot.to}`;
8
+ }
package/helpers/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from './date.helper';
2
2
  export * from './pagination.helper';
3
3
  export * from './query-boolean.helper';
4
4
  export * from './resolve-localized-name.helper';
5
+ export * from './format-delivery-time-slot.helper';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floristcloud/api-lib",
3
- "version": "1.2.204",
3
+ "version": "1.2.205",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -5,5 +5,6 @@ export const UpdateClientForClientRequestSchema = z.object({
5
5
  contactName: z.string().nullable(),
6
6
  phone: z.string(),
7
7
  email: z.email().toLowerCase(),
8
- alwaysRequiresDelivery: z.boolean(),
8
+ // `alwaysRequiresDelivery` клиент больше не меняет — его ведут сотрудники в панели. Поле от
9
+ // необновлённых витрины и мобилки z.object отбрасывает молча, запрос при этом проходит.
9
10
  });
package/schemas/index.ts CHANGED
@@ -112,6 +112,9 @@ export * from './service/service.schema';
112
112
  export * from './settings/city-delivery-pricing-rule.schema';
113
113
  export * from './settings/default-delivery-pricing-rule.schema';
114
114
  export * from './settings/delivery-pricing-tiers.schema';
115
+ export * from './settings/delivery-time-slot.schema';
116
+ export * from './settings/delivery-time-slots.schema';
117
+ export * from './settings/time-of-day.schema';
115
118
  export * from './settings/group-delivery-pricing-rule.schema';
116
119
  export * from './settings/settings-private-response.schema';
117
120
  export * from './settings/settings-private.schema';
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { ValidationI18nKey } from '../../constant/validation-i18n-key';
3
+ import { TimeOfDaySchema } from './time-of-day.schema';
4
+
5
+ // Промежуток доставки, который клиент выбирает при оформлении: «с 10:00 до 14:00» по часам компании.
6
+ export const DeliveryTimeSlotSchema = z
7
+ .object({
8
+ from: TimeOfDaySchema,
9
+ to: TimeOfDaySchema,
10
+ })
11
+ .refine(({ from, to }) => from < to, { path: ['to'], message: ValidationI18nKey.deliveryTimeSlotRange });
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { DELIVERY_TIME_SLOTS_MAX_LENGTH } from '../../constant/settings.constant';
3
+ import { ValidationI18nKey } from '../../constant/validation-i18n-key';
4
+ import { formatDeliveryTimeSlot } from '../../helpers/format-delivery-time-slot.helper';
5
+ import { DeliveryTimeSlotSchema } from './delivery-time-slot.schema';
6
+
7
+ /**
8
+ * Слоты доставки компании в порядке показа клиенту.
9
+ * `null` в настройках — слотов нет, время выбирается по часу внутри рабочих часов (прежнее поведение);
10
+ * пустой список — время доставки клиент не выбирает.
11
+ */
12
+ export const DeliveryTimeSlotsSchema = z
13
+ .array(DeliveryTimeSlotSchema)
14
+ .max(DELIVERY_TIME_SLOTS_MAX_LENGTH)
15
+ .superRefine((slots, ctx) => {
16
+ const seen = new Set<string>();
17
+ slots.forEach((slot, index) => {
18
+ const label = formatDeliveryTimeSlot(slot);
19
+ if (seen.has(label)) {
20
+ ctx.addIssue({ code: 'custom', path: [index], message: ValidationI18nKey.deliveryTimeSlotDuplicate });
21
+ }
22
+ seen.add(label);
23
+ });
24
+ });
@@ -23,6 +23,7 @@ import { MenuItemsUrlEnum } from '../../enum/menu-items-url.enum';
23
23
  import { DeliveryPricingInTransitModeEnum } from '../../enum/delivery-pricing-in-transit-mode.enum';
24
24
  import { DeliveryPricingRulesSchema } from './delivery-pricing-rules.schema';
25
25
  import { DeliveryPricingTierSchema } from './delivery-pricing-tier.schema';
26
+ import { DeliveryTimeSlotsSchema } from './delivery-time-slots.schema';
26
27
 
27
28
  // Preserve existing direct imports and contracts package exports.
28
29
  export { DeliveryPricingRuleSchema } from './delivery-pricing-rule.schema';
@@ -153,6 +154,10 @@ export const SettingsSchema = z.object({
153
154
  importantMessage: ImportantMessageSchema.nullable(),
154
155
  deliveryPricingEnabled: z.boolean(),
155
156
  deliveryPricingTiers: z.array(DeliveryPricingTierSchema).nullable(),
157
+ // Способы получения на витрине и в мобилке. Сервер отклоняет оформление выключенным способом.
158
+ isPickupEnabled: z.boolean(),
159
+ isDeliveryEnabled: z.boolean(),
160
+ deliveryTimeSlots: DeliveryTimeSlotsSchema.nullable(),
156
161
  employeeClientScopeEnabled: z.boolean(),
157
162
  telegramStaffBotName: z.string().nullable().optional(),
158
163
  });
@@ -248,6 +253,9 @@ export const CreateSettingsSchema = z.object({
248
253
  deliveryPricingEnabled: z.coerce.boolean().optional(),
249
254
  deliveryPricingRules: DeliveryPricingRulesSchema.nullable().optional(),
250
255
  deliveryPricingInTransitMode: z.nativeEnum(DeliveryPricingInTransitModeEnum).optional(),
256
+ isPickupEnabled: z.boolean().optional(),
257
+ isDeliveryEnabled: z.boolean().optional(),
258
+ deliveryTimeSlots: DeliveryTimeSlotsSchema.nullable().optional(),
251
259
  });
252
260
 
253
261
  export const UpdateSettingsRequestSchema = z.object({
@@ -312,6 +320,9 @@ export const UpdateSettingsRequestSchema = z.object({
312
320
  deliveryPricingEnabled: z.coerce.boolean().optional(),
313
321
  deliveryPricingRules: DeliveryPricingRulesSchema.nullable().optional(),
314
322
  deliveryPricingInTransitMode: z.nativeEnum(DeliveryPricingInTransitModeEnum).optional(),
323
+ isPickupEnabled: z.boolean().optional(),
324
+ isDeliveryEnabled: z.boolean().optional(),
325
+ deliveryTimeSlots: DeliveryTimeSlotsSchema.nullable().optional(),
315
326
  employeeClientScopeEnabled: z.coerce.boolean().optional(),
316
327
  // post terminal settings
317
328
  vatTag: z.string().nullable().optional(),
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import { TIME_OF_DAY_PATTERN } from '../../constant/settings.constant';
3
+ import { ValidationI18nKey } from '../../constant/validation-i18n-key';
4
+
5
+ // Время суток `HH:mm` по часам компании. Строка, а не Date: у времени без дня нет таймзоны,
6
+ // и сравнивать такие строки можно лексикографически.
7
+ export const TimeOfDaySchema = z.string().regex(TIME_OF_DAY_PATTERN, { message: ValidationI18nKey.timeOfDayFormat });