platform-types 1.10.722 → 1.10.723

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.
@@ -959,7 +959,7 @@ declare global {
959
959
  * `GET /availability`, an operator queuing a party against a full slot rather
960
960
  * than configuring the schedule — so its five refusals are listed above.
961
961
  */
962
- export declare const APPOINTMENT_ERROR_CODES: readonly ["APPOINTMENT_NOT_FOUND", "APPOINTMENT_ID_REQUIRED", "APPOINTMENT_TYPE_DISABLED", "APPOINTMENT_SLOT_UNAVAILABLE", "APPOINTMENT_LEAD_TIME_NOT_MET", "APPOINTMENT_SELF_BOOKING_BLOCKED", "APPOINTMENT_CANCEL_CUTOFF_PASSED", "APPOINTMENT_OUTSIDE_WORKING_HOURS", "APPOINTMENT_TOO_FAR_AHEAD", "APPOINTMENT_ORDER_NOT_FOUND", "APPOINTMENT_ORDER_NOT_SCHEDULABLE", "APPOINTMENT_ORDER_ALREADY_SCHEDULED", "APPOINTMENT_STATUS_TRANSITION_ILLEGAL", "APPOINTMENT_VERSION_CONFLICT", "APPOINTMENT_NOT_CANCELLABLE", "APPOINTMENT_RESCHEDULE_NOOP", "APPOINTMENT_WAITLIST_PARTY_REQUIRED", "APPOINTMENT_WAITLIST_SLOT_AVAILABLE", "APPOINTMENT_WAITLIST_ALREADY_JOINED", "APPOINTMENT_WAITLIST_FULL", "APPOINTMENT_WAITLIST_ENTRY_NOT_FOUND", "INVALID_CURSOR", "RECURRENCE_RULE_MALFORMED", "RECURRENCE_RULE_UNSUPPORTED", "RECURRENCE_UNBOUNDED", "RECURRENCE_TOO_MANY", "APPOINTMENT_NOT_IN_SERIES", "RECURRENCE_SCOPE_REQUIRES_RULE_EDIT", "APPOINTMENT_STATUS_NOT_SCOPEABLE", "RECURRENCE_EXCEPTIONS_UNSUPPORTED", "RECURRENCE_EXCEPTIONS_SCOPE_REQUIRED", "VALIDATION_FAILED", "ROLE_FORBIDDEN", "APPOINTMENT_FEED_SECRET_NOT_CONFIGURED", "APPOINTMENT_FEED_IDENTITY_INVALID"];
962
+ export declare const APPOINTMENT_ERROR_CODES: readonly ["APPOINTMENT_NOT_FOUND", "APPOINTMENT_ID_REQUIRED", "APPOINTMENT_TYPE_DISABLED", "APPOINTMENT_SLOT_UNAVAILABLE", "APPOINTMENT_LEAD_TIME_NOT_MET", "APPOINTMENT_SELF_BOOKING_BLOCKED", "APPOINTMENT_CANCEL_CUTOFF_PASSED", "APPOINTMENT_OUTSIDE_WORKING_HOURS", "APPOINTMENT_TOO_FAR_AHEAD", "APPOINTMENT_ORDER_NOT_FOUND", "APPOINTMENT_ORDER_NOT_SCHEDULABLE", "APPOINTMENT_ORDER_ALREADY_SCHEDULED", "APPOINTMENT_STATUS_TRANSITION_ILLEGAL", "APPOINTMENT_VERSION_CONFLICT", "APPOINTMENT_NOT_CANCELLABLE", "APPOINTMENT_RESCHEDULE_NOOP", "APPOINTMENT_WAITLIST_PARTY_REQUIRED", "APPOINTMENT_WAITLIST_SLOT_AVAILABLE", "APPOINTMENT_WAITLIST_ALREADY_JOINED", "APPOINTMENT_WAITLIST_FULL", "APPOINTMENT_WAITLIST_ENTRY_NOT_FOUND", "INVALID_CURSOR", "RECURRENCE_RULE_MALFORMED", "RECURRENCE_RULE_UNSUPPORTED", "RECURRENCE_UNBOUNDED", "RECURRENCE_TOO_MANY", "APPOINTMENT_NOT_IN_SERIES", "RECURRENCE_SCOPE_REQUIRES_RULE_EDIT", "APPOINTMENT_STATUS_NOT_SCOPEABLE", "RECURRENCE_EXCEPTIONS_UNSUPPORTED", "RECURRENCE_EXCEPTIONS_SCOPE_REQUIRED", "VALIDATION_FAILED", "ROLE_FORBIDDEN", "APPOINTMENT_FEED_SECRET_NOT_CONFIGURED", "APPOINTMENT_FEED_IDENTITY_INVALID", "STORE_MODULE_DISABLED"];
963
963
  export type AppointmentErrorCode = (typeof APPOINTMENT_ERROR_CODES)[number];
964
964
  /**
965
965
  * Which occurrences of a recurring booking an edit applies to —
@@ -141,6 +141,8 @@ export const APPOINTMENT_ERROR_CODES = [
141
141
  'ROLE_FORBIDDEN',
142
142
  'APPOINTMENT_FEED_SECRET_NOT_CONFIGURED',
143
143
  'APPOINTMENT_FEED_IDENTITY_INVALID',
144
+ // The storefront's self-booking surface, while the store has `modules.appointments` off.
145
+ 'STORE_MODULE_DISABLED',
144
146
  ];
145
147
  /**
146
148
  * Which occurrences of a recurring booking an edit applies to —
@@ -144,6 +144,8 @@ exports.APPOINTMENT_ERROR_CODES = [
144
144
  'ROLE_FORBIDDEN',
145
145
  'APPOINTMENT_FEED_SECRET_NOT_CONFIGURED',
146
146
  'APPOINTMENT_FEED_IDENTITY_INVALID',
147
+ // The storefront's self-booking surface, while the store has `modules.appointments` off.
148
+ 'STORE_MODULE_DISABLED',
147
149
  ];
148
150
  /**
149
151
  * Which occurrences of a recurring booking an edit applies to —
package/dist/cjs/store.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CUSTOM_DOMAIN_ROW_LIMIT = exports.CUSTOM_DOMAIN_SLOT_LIMIT = void 0;
3
+ exports.STORE_MODULE_ERROR_CODES = exports.isStoreModuleOn = exports.isStoreModuleKey = exports.STORE_MODULE_KEYS = exports.CUSTOM_DOMAIN_ROW_LIMIT = exports.CUSTOM_DOMAIN_SLOT_LIMIT = void 0;
4
4
  /**
5
5
  * How many custom-domain rows a store may hold that count: one active domain
6
6
  * and one spare, so a replacement can be verified and provisioned before the
@@ -18,3 +18,65 @@ exports.CUSTOM_DOMAIN_SLOT_LIMIT = 2;
18
18
  * `409 DOMAIN_ROW_LIMIT` with this value as `limit`.
19
19
  */
20
20
  exports.CUSTOM_DOMAIN_ROW_LIMIT = 10;
21
+ /**
22
+ * Every `StoreModuleKey`, in catalogue order — the ONE list. The type is derived
23
+ * from it, so the `PATCH /store` validator and every client enumerate exactly
24
+ * the modules the type allows, and a module is added in one place.
25
+ */
26
+ exports.STORE_MODULE_KEYS = [
27
+ 'attendance',
28
+ 'lots',
29
+ 'stocktake',
30
+ 'purchases',
31
+ 'loyalty',
32
+ 'surveys',
33
+ 'customerZones',
34
+ 'workshop',
35
+ 'appointments',
36
+ 'cash',
37
+ 'multiWarehouse',
38
+ 'quotes',
39
+ 'promotions',
40
+ 'marketing',
41
+ 'fiscalInvoicing',
42
+ 'customerAccounts',
43
+ ];
44
+ /** Whether `value` names a module — narrows an untyped key (a request body, a stored row). */
45
+ const isStoreModuleKey = (value) => typeof value === 'string' && exports.STORE_MODULE_KEYS.includes(value);
46
+ exports.isStoreModuleKey = isStoreModuleKey;
47
+ /**
48
+ * Whether `module` is on for a store whose `config.modules` is `modules`.
49
+ * ⚠️ Absent is ON: only an explicit `false` turns a module off, so a missing
50
+ * map, a missing key and `true` all answer `true`.
51
+ */
52
+ const isStoreModuleOn = (modules, module) => modules?.[module] !== false;
53
+ exports.isStoreModuleOn = isStoreModuleOn;
54
+ /**
55
+ * Every refusal code the store-module switches put on the wire, beyond the
56
+ * platform-wide set (`VALIDATION_FAILED`, and `STORE_CONFIG_FORBIDDEN` for a
57
+ * plain USER writing the privileged leaf):
58
+ *
59
+ * - `STORE_MODULE_UNKNOWN` (400) — `PATCH /store` named a key outside
60
+ * `STORE_MODULE_KEYS`; `data.module` carries it.
61
+ * - `STORE_MODULE_NOT_BOOLEAN` (400) — a module's value was not `true`/`false`.
62
+ * - `STORE_MODULE_WAREHOUSES_ACTIVE` (409) — `multiWarehouse` off while more
63
+ * than one depósito is active; `data.activeWarehouses` carries the count.
64
+ * - `STORE_MODULE_TRANSFER_IN_FLIGHT` (409) — `multiWarehouse` off while a stock
65
+ * transfer is in transit or partially received; `data.transferId` names one.
66
+ * - `STORE_MODULE_CUSTOMER_BALANCES` (409) — `customerAccounts` off while a
67
+ * customer carries a non-zero balance; `data.customerId` names one.
68
+ * - `STORE_MODULE_BALANCE_CHECK_INCOMPLETE` (409) — the bounded balance read
69
+ * stopped before it could prove every balance is zero. Retrying is harmless but
70
+ * walks the same rows, so a very large customer book keeps answering it.
71
+ * - `STORE_MODULE_DISABLED` (403) — a server-enforced module is off (storefront
72
+ * self-booking, storefront survey); `data.module` names it.
73
+ */
74
+ exports.STORE_MODULE_ERROR_CODES = [
75
+ 'STORE_MODULE_UNKNOWN',
76
+ 'STORE_MODULE_NOT_BOOLEAN',
77
+ 'STORE_MODULE_WAREHOUSES_ACTIVE',
78
+ 'STORE_MODULE_TRANSFER_IN_FLIGHT',
79
+ 'STORE_MODULE_CUSTOMER_BALANCES',
80
+ 'STORE_MODULE_BALANCE_CHECK_INCOMPLETE',
81
+ 'STORE_MODULE_DISABLED',
82
+ ];
package/dist/store.d.ts CHANGED
@@ -85,6 +85,19 @@ declare global {
85
85
  /** MercadoLibre orders. */
86
86
  mercadolibre?: string;
87
87
  }
88
+ /**
89
+ * One store-wide module a store can switch off for every user — the
90
+ * catalogue is the shared `domain/STORE_MODULES.md`. Enumerable at runtime as
91
+ * `STORE_MODULE_KEYS`; read a switch through `isStoreModuleOn`.
92
+ */
93
+ type StoreModuleKey = (typeof STORE_MODULE_KEYS)[number];
94
+ /**
95
+ * `Store.config.modules`. ⚠️ An ABSENT key is ON — only an explicit `false`
96
+ * turns a module off, so a store that never wrote the map (every store that
97
+ * predates it) has every module on. Off HIDES; it never deletes, and the
98
+ * module's existing records stay readable.
99
+ */
100
+ type StoreModules = Partial<Record<StoreModuleKey, boolean>>;
88
101
  interface Ecommerce {
89
102
  /**
90
103
  * The tenant's «Activar tienda online» switch. Written only by the api's
@@ -880,8 +893,50 @@ declare global {
880
893
  * Written through `PATCH /store` `config` (admin tier), merged per channel;
881
894
  * a channel sent as `null` clears it. Absent, or a channel absent inside
882
895
  * it, means that channel's sales use the primary depósito.
896
+ *
897
+ * ⚠️ Ignored while `modules.multiWarehouse` is `false`: sales and the
898
+ * MercadoLibre feed then resolve to the primary depósito (see `modules`),
899
+ * whatever this holds.
883
900
  */
884
901
  channelWarehouses?: StoreChannelWarehouses;
902
+ /**
903
+ * Store-wide module switches — see `StoreModules`. Written through
904
+ * `PATCH /store` `config` at the PRIVILEGED tier (ADMIN/SUPERVISOR/MANAGER;
905
+ * a plain USER is refused `STORE_CONFIG_FORBIDDEN`), merged per key. An
906
+ * unknown key is refused `400 STORE_MODULE_UNKNOWN`, a non-boolean value
907
+ * `400 STORE_MODULE_NOT_BOOLEAN`.
908
+ *
909
+ * Turning a module OFF is refused while it still carries state:
910
+ * `multiWarehouse` while more than one depósito is active
911
+ * (`409 STORE_MODULE_WAREHOUSES_ACTIVE`) or a transfer is in transit or
912
+ * partially received (`409 STORE_MODULE_TRANSFER_IN_FLIGHT`);
913
+ * `customerAccounts` while any customer carries a non-zero balance
914
+ * (`409 STORE_MODULE_CUSTOMER_BALANCES`, or
915
+ * `409 STORE_MODULE_BALANCE_CHECK_INCOMPLETE` when the bounded read could
916
+ * not finish).
917
+ *
918
+ * Enforced on the server for four modules only:
919
+ * - `promotions` — applying one is refused `PROMOTION_NOT_ACTIVE` (the
920
+ * existing promotion refusal, not `STORE_MODULE_DISABLED`), a grant already
921
+ * frozen on a cart stays on the row but derives no money (its
922
+ * `promotionEffect` is removed), the storefront checkout and a service
923
+ * delivery refuse it `409 CART_PROMOTION_UNAVAILABLE` with
924
+ * `data.reason: 'PROMOTION_NOT_ACTIVE'` (removing the grant), and the
925
+ * applicable list is empty. A till ticket last written while promotions
926
+ * were on (it still carries its `promotionEffect`) converts at the price
927
+ * it was sold at.
928
+ * - `appointments` — storefront availability, booking and rescheduling are
929
+ * refused `403 STORE_MODULE_DISABLED`; the shopper's list and cancel stay.
930
+ * - `surveys` — a storefront survey is refused `403 STORE_MODULE_DISABLED`,
931
+ * so none is recorded, broadcast or mailed.
932
+ * - `multiWarehouse` — every sale resolves to the primary depósito (a
933
+ * scoped operator's sale to their own home depósito when the primary is
934
+ * outside their scope), and only the primary feeds MercadoLibre.
935
+ * Every other module is hide-only: its endpoints stay reachable. Public
936
+ * reads carry only `appointments`, `surveys`, `promotions` and
937
+ * `customerAccounts`. `PUT /platform/stores/{storeId}` refuses the leaf.
938
+ */
939
+ modules?: StoreModules;
885
940
  };
886
941
  ecommerce?: Ecommerce;
887
942
  /**
@@ -1947,3 +2002,39 @@ export declare const CUSTOM_DOMAIN_SLOT_LIMIT = 2;
1947
2002
  * `409 DOMAIN_ROW_LIMIT` with this value as `limit`.
1948
2003
  */
1949
2004
  export declare const CUSTOM_DOMAIN_ROW_LIMIT = 10;
2005
+ /**
2006
+ * Every `StoreModuleKey`, in catalogue order — the ONE list. The type is derived
2007
+ * from it, so the `PATCH /store` validator and every client enumerate exactly
2008
+ * the modules the type allows, and a module is added in one place.
2009
+ */
2010
+ export declare const STORE_MODULE_KEYS: readonly ["attendance", "lots", "stocktake", "purchases", "loyalty", "surveys", "customerZones", "workshop", "appointments", "cash", "multiWarehouse", "quotes", "promotions", "marketing", "fiscalInvoicing", "customerAccounts"];
2011
+ /** Whether `value` names a module — narrows an untyped key (a request body, a stored row). */
2012
+ export declare const isStoreModuleKey: (value: unknown) => value is StoreModuleKey;
2013
+ /**
2014
+ * Whether `module` is on for a store whose `config.modules` is `modules`.
2015
+ * ⚠️ Absent is ON: only an explicit `false` turns a module off, so a missing
2016
+ * map, a missing key and `true` all answer `true`.
2017
+ */
2018
+ export declare const isStoreModuleOn: (modules: StoreModules | null | undefined, module: StoreModuleKey) => boolean;
2019
+ /**
2020
+ * Every refusal code the store-module switches put on the wire, beyond the
2021
+ * platform-wide set (`VALIDATION_FAILED`, and `STORE_CONFIG_FORBIDDEN` for a
2022
+ * plain USER writing the privileged leaf):
2023
+ *
2024
+ * - `STORE_MODULE_UNKNOWN` (400) — `PATCH /store` named a key outside
2025
+ * `STORE_MODULE_KEYS`; `data.module` carries it.
2026
+ * - `STORE_MODULE_NOT_BOOLEAN` (400) — a module's value was not `true`/`false`.
2027
+ * - `STORE_MODULE_WAREHOUSES_ACTIVE` (409) — `multiWarehouse` off while more
2028
+ * than one depósito is active; `data.activeWarehouses` carries the count.
2029
+ * - `STORE_MODULE_TRANSFER_IN_FLIGHT` (409) — `multiWarehouse` off while a stock
2030
+ * transfer is in transit or partially received; `data.transferId` names one.
2031
+ * - `STORE_MODULE_CUSTOMER_BALANCES` (409) — `customerAccounts` off while a
2032
+ * customer carries a non-zero balance; `data.customerId` names one.
2033
+ * - `STORE_MODULE_BALANCE_CHECK_INCOMPLETE` (409) — the bounded balance read
2034
+ * stopped before it could prove every balance is zero. Retrying is harmless but
2035
+ * walks the same rows, so a very large customer book keeps answering it.
2036
+ * - `STORE_MODULE_DISABLED` (403) — a server-enforced module is off (storefront
2037
+ * self-booking, storefront survey); `data.module` names it.
2038
+ */
2039
+ export declare const STORE_MODULE_ERROR_CODES: readonly ["STORE_MODULE_UNKNOWN", "STORE_MODULE_NOT_BOOLEAN", "STORE_MODULE_WAREHOUSES_ACTIVE", "STORE_MODULE_TRANSFER_IN_FLIGHT", "STORE_MODULE_CUSTOMER_BALANCES", "STORE_MODULE_BALANCE_CHECK_INCOMPLETE", "STORE_MODULE_DISABLED"];
2040
+ export type StoreModuleErrorCode = (typeof STORE_MODULE_ERROR_CODES)[number];
package/dist/store.js CHANGED
@@ -15,3 +15,63 @@ export const CUSTOM_DOMAIN_SLOT_LIMIT = 2;
15
15
  * `409 DOMAIN_ROW_LIMIT` with this value as `limit`.
16
16
  */
17
17
  export const CUSTOM_DOMAIN_ROW_LIMIT = 10;
18
+ /**
19
+ * Every `StoreModuleKey`, in catalogue order — the ONE list. The type is derived
20
+ * from it, so the `PATCH /store` validator and every client enumerate exactly
21
+ * the modules the type allows, and a module is added in one place.
22
+ */
23
+ export const STORE_MODULE_KEYS = [
24
+ 'attendance',
25
+ 'lots',
26
+ 'stocktake',
27
+ 'purchases',
28
+ 'loyalty',
29
+ 'surveys',
30
+ 'customerZones',
31
+ 'workshop',
32
+ 'appointments',
33
+ 'cash',
34
+ 'multiWarehouse',
35
+ 'quotes',
36
+ 'promotions',
37
+ 'marketing',
38
+ 'fiscalInvoicing',
39
+ 'customerAccounts',
40
+ ];
41
+ /** Whether `value` names a module — narrows an untyped key (a request body, a stored row). */
42
+ export const isStoreModuleKey = (value) => typeof value === 'string' && STORE_MODULE_KEYS.includes(value);
43
+ /**
44
+ * Whether `module` is on for a store whose `config.modules` is `modules`.
45
+ * ⚠️ Absent is ON: only an explicit `false` turns a module off, so a missing
46
+ * map, a missing key and `true` all answer `true`.
47
+ */
48
+ export const isStoreModuleOn = (modules, module) => modules?.[module] !== false;
49
+ /**
50
+ * Every refusal code the store-module switches put on the wire, beyond the
51
+ * platform-wide set (`VALIDATION_FAILED`, and `STORE_CONFIG_FORBIDDEN` for a
52
+ * plain USER writing the privileged leaf):
53
+ *
54
+ * - `STORE_MODULE_UNKNOWN` (400) — `PATCH /store` named a key outside
55
+ * `STORE_MODULE_KEYS`; `data.module` carries it.
56
+ * - `STORE_MODULE_NOT_BOOLEAN` (400) — a module's value was not `true`/`false`.
57
+ * - `STORE_MODULE_WAREHOUSES_ACTIVE` (409) — `multiWarehouse` off while more
58
+ * than one depósito is active; `data.activeWarehouses` carries the count.
59
+ * - `STORE_MODULE_TRANSFER_IN_FLIGHT` (409) — `multiWarehouse` off while a stock
60
+ * transfer is in transit or partially received; `data.transferId` names one.
61
+ * - `STORE_MODULE_CUSTOMER_BALANCES` (409) — `customerAccounts` off while a
62
+ * customer carries a non-zero balance; `data.customerId` names one.
63
+ * - `STORE_MODULE_BALANCE_CHECK_INCOMPLETE` (409) — the bounded balance read
64
+ * stopped before it could prove every balance is zero. Retrying is harmless but
65
+ * walks the same rows, so a very large customer book keeps answering it.
66
+ * - `STORE_MODULE_DISABLED` (403) — a server-enforced module is off (storefront
67
+ * self-booking, storefront survey); `data.module` names it.
68
+ */
69
+ export const STORE_MODULE_ERROR_CODES = [
70
+ 'STORE_MODULE_UNKNOWN',
71
+ 'STORE_MODULE_NOT_BOOLEAN',
72
+ 'STORE_MODULE_WAREHOUSES_ACTIVE',
73
+ 'STORE_MODULE_TRANSFER_IN_FLIGHT',
74
+ 'STORE_MODULE_CUSTOMER_BALANCES',
75
+ 'STORE_MODULE_BALANCE_CHECK_INCOMPLETE',
76
+ 'STORE_MODULE_DISABLED',
77
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.722",
3
+ "version": "1.10.723",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",