platform-types 1.10.722 → 1.10.724
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/dist/account.d.ts +6 -0
- package/dist/appointment.d.ts +1 -1
- package/dist/appointment.js +2 -0
- package/dist/cjs/appointment.js +2 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/store.js +63 -1
- package/dist/cjs/systemCustomer.js +31 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/store.d.ts +91 -0
- package/dist/store.js +60 -0
- package/dist/systemCustomer.d.ts +27 -0
- package/dist/systemCustomer.js +27 -0
- package/package.json +1 -1
package/dist/account.d.ts
CHANGED
|
@@ -198,6 +198,12 @@ declare global {
|
|
|
198
198
|
* and attach the token here. The approval binds the raw body minus the token,
|
|
199
199
|
* which is why the keys marked accepted and IGNORED below are declared at all.
|
|
200
200
|
*
|
|
201
|
+
* A `customerId` equal to `SYSTEM_CUSTOMER_ID` (the walk-in, see
|
|
202
|
+
* `isSystemCustomer`) is refused `403 SYSTEM_CUSTOMER_PROTECTED`, credit and
|
|
203
|
+
* debit alike, with no business row read or written: the walk-in has no cuenta
|
|
204
|
+
* corriente. Collect a walk-in order's cash through
|
|
205
|
+
* `POST /orders { mode: 'tender' }` instead.
|
|
206
|
+
*
|
|
201
207
|
* Held to its schema by `AssertAccountPostRequestMatchesSchema`.
|
|
202
208
|
*/
|
|
203
209
|
interface AccountPostRequest extends TerminalElevationAuthorization {
|
package/dist/appointment.d.ts
CHANGED
|
@@ -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 —
|
package/dist/appointment.js
CHANGED
|
@@ -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 —
|
package/dist/cjs/appointment.js
CHANGED
|
@@ -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/index.js
CHANGED
|
@@ -114,6 +114,7 @@ __exportStar(require("./terminal.js"), exports);
|
|
|
114
114
|
__exportStar(require("./supplier.js"), exports);
|
|
115
115
|
__exportStar(require("./supplierClaim.js"), exports);
|
|
116
116
|
__exportStar(require("./survey.js"), exports);
|
|
117
|
+
__exportStar(require("./systemCustomer.js"), exports);
|
|
117
118
|
__exportStar(require("./user.js"), exports);
|
|
118
119
|
__exportStar(require("./userActivity.js"), exports);
|
|
119
120
|
__exportStar(require("./valuation.js"), exports);
|
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
|
+
];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSystemCustomer = exports.SYSTEM_CUSTOMER_ID = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The walk-in ("Consumidor Final") system customer — the ONE definition.
|
|
6
|
+
*
|
|
7
|
+
* Every store mints a single CUSTOMER row under this fixed id the first time it
|
|
8
|
+
* records a walk-in POS sale, so a walk-in order still carries a non-null
|
|
9
|
+
* `Order.customerId`. It carries no real identity and has no cuenta corriente.
|
|
10
|
+
* Operator writes that refuse it with `403 SYSTEM_CUSTOMER_PROTECTED` include
|
|
11
|
+
* `POST /customers` and its merge mode, the address book, contacts and notes
|
|
12
|
+
* (create and edit), a movement or a balance reprojection on `POST /account`,
|
|
13
|
+
* a payment link whose target is the customer, and the customer data-rights
|
|
14
|
+
* modes (data export, anonymize). Map the code wherever it appears; this is
|
|
15
|
+
* not a closed list.
|
|
16
|
+
*
|
|
17
|
+
* A client routes on it instead of hard-coding the literal: collecting cash on a
|
|
18
|
+
* delivered walk-in order is `POST /orders { mode: 'tender' }`, never a
|
|
19
|
+
* cuenta-corriente movement.
|
|
20
|
+
*
|
|
21
|
+
* ⚠️ Zero imports, deliberately: the server re-exports it from the leaf
|
|
22
|
+
* `stacks/helpers/protectSystemCustomer.ts` (imported by services and crons),
|
|
23
|
+
* and a client bundles it without any other contract module.
|
|
24
|
+
*
|
|
25
|
+
* The id sits outside the mintable range: the customer counter starts at 1 and
|
|
26
|
+
* a store's seeded placeholder rows hold `CUST000001`–`CUST000006`.
|
|
27
|
+
*/
|
|
28
|
+
exports.SYSTEM_CUSTOMER_ID = 'CUST000000';
|
|
29
|
+
/** `true` exactly when `customerId` is the walk-in system customer. */
|
|
30
|
+
const isSystemCustomer = (customerId) => customerId === exports.SYSTEM_CUSTOMER_ID;
|
|
31
|
+
exports.isSystemCustomer = isSystemCustomer;
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ export * from './terminal.ts';
|
|
|
90
90
|
export * from './supplier.ts';
|
|
91
91
|
export * from './supplierClaim.ts';
|
|
92
92
|
export * from './survey.ts';
|
|
93
|
+
export * from './systemCustomer.ts';
|
|
93
94
|
export * from './user.ts';
|
|
94
95
|
export * from './userActivity.ts';
|
|
95
96
|
export * from './valuation.ts';
|
package/dist/index.js
CHANGED
|
@@ -98,6 +98,7 @@ export * from "./terminal.js";
|
|
|
98
98
|
export * from "./supplier.js";
|
|
99
99
|
export * from "./supplierClaim.js";
|
|
100
100
|
export * from "./survey.js";
|
|
101
|
+
export * from "./systemCustomer.js";
|
|
101
102
|
export * from "./user.js";
|
|
102
103
|
export * from "./userActivity.js";
|
|
103
104
|
export * from "./valuation.js";
|
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
|
+
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The walk-in ("Consumidor Final") system customer — the ONE definition.
|
|
3
|
+
*
|
|
4
|
+
* Every store mints a single CUSTOMER row under this fixed id the first time it
|
|
5
|
+
* records a walk-in POS sale, so a walk-in order still carries a non-null
|
|
6
|
+
* `Order.customerId`. It carries no real identity and has no cuenta corriente.
|
|
7
|
+
* Operator writes that refuse it with `403 SYSTEM_CUSTOMER_PROTECTED` include
|
|
8
|
+
* `POST /customers` and its merge mode, the address book, contacts and notes
|
|
9
|
+
* (create and edit), a movement or a balance reprojection on `POST /account`,
|
|
10
|
+
* a payment link whose target is the customer, and the customer data-rights
|
|
11
|
+
* modes (data export, anonymize). Map the code wherever it appears; this is
|
|
12
|
+
* not a closed list.
|
|
13
|
+
*
|
|
14
|
+
* A client routes on it instead of hard-coding the literal: collecting cash on a
|
|
15
|
+
* delivered walk-in order is `POST /orders { mode: 'tender' }`, never a
|
|
16
|
+
* cuenta-corriente movement.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ Zero imports, deliberately: the server re-exports it from the leaf
|
|
19
|
+
* `stacks/helpers/protectSystemCustomer.ts` (imported by services and crons),
|
|
20
|
+
* and a client bundles it without any other contract module.
|
|
21
|
+
*
|
|
22
|
+
* The id sits outside the mintable range: the customer counter starts at 1 and
|
|
23
|
+
* a store's seeded placeholder rows hold `CUST000001`–`CUST000006`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SYSTEM_CUSTOMER_ID: "CUST000000";
|
|
26
|
+
/** `true` exactly when `customerId` is the walk-in system customer. */
|
|
27
|
+
export declare const isSystemCustomer: (customerId: string | undefined | null) => customerId is typeof SYSTEM_CUSTOMER_ID;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The walk-in ("Consumidor Final") system customer — the ONE definition.
|
|
3
|
+
*
|
|
4
|
+
* Every store mints a single CUSTOMER row under this fixed id the first time it
|
|
5
|
+
* records a walk-in POS sale, so a walk-in order still carries a non-null
|
|
6
|
+
* `Order.customerId`. It carries no real identity and has no cuenta corriente.
|
|
7
|
+
* Operator writes that refuse it with `403 SYSTEM_CUSTOMER_PROTECTED` include
|
|
8
|
+
* `POST /customers` and its merge mode, the address book, contacts and notes
|
|
9
|
+
* (create and edit), a movement or a balance reprojection on `POST /account`,
|
|
10
|
+
* a payment link whose target is the customer, and the customer data-rights
|
|
11
|
+
* modes (data export, anonymize). Map the code wherever it appears; this is
|
|
12
|
+
* not a closed list.
|
|
13
|
+
*
|
|
14
|
+
* A client routes on it instead of hard-coding the literal: collecting cash on a
|
|
15
|
+
* delivered walk-in order is `POST /orders { mode: 'tender' }`, never a
|
|
16
|
+
* cuenta-corriente movement.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ Zero imports, deliberately: the server re-exports it from the leaf
|
|
19
|
+
* `stacks/helpers/protectSystemCustomer.ts` (imported by services and crons),
|
|
20
|
+
* and a client bundles it without any other contract module.
|
|
21
|
+
*
|
|
22
|
+
* The id sits outside the mintable range: the customer counter starts at 1 and
|
|
23
|
+
* a store's seeded placeholder rows hold `CUST000001`–`CUST000006`.
|
|
24
|
+
*/
|
|
25
|
+
export const SYSTEM_CUSTOMER_ID = 'CUST000000';
|
|
26
|
+
/** `true` exactly when `customerId` is the walk-in system customer. */
|
|
27
|
+
export const isSystemCustomer = (customerId) => customerId === SYSTEM_CUSTOMER_ID;
|