platform-types 1.10.728 → 1.10.730

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.
@@ -22,7 +22,7 @@
22
22
  * returned to the store's operators, and is never logged.
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.WORK_ITEM_TEXT_MAX = exports.WORK_ITEM_PAGE_MAX = exports.WORK_ITEM_HISTORY_KINDS = exports.WORK_ITEM_SOURCE_VERDICTS = exports.WORK_ITEM_AVAILABILITIES = exports.WORK_ITEM_STATUSES = exports.WORK_ITEM_FAMILIES = void 0;
25
+ exports.WORK_ITEM_ERROR_CODES = exports.WORK_ITEM_TEXT_MAX = exports.WORK_ITEM_PAGE_MAX = exports.WORK_ITEM_HISTORY_KINDS = exports.WORK_ITEM_SOURCE_VERDICTS = exports.WORK_ITEM_AVAILABILITIES = exports.WORK_ITEM_STATUSES = exports.WORK_ITEM_FAMILIES = void 0;
26
26
  exports.WORK_ITEM_FAMILIES = [
27
27
  'order-create',
28
28
  'collection',
@@ -41,3 +41,65 @@ exports.WORK_ITEM_HISTORY_KINDS = ['reported', 'handover-requested', 'accepted',
41
41
  exports.WORK_ITEM_PAGE_MAX = 100;
42
42
  /** Upper bound on `summary` and on a `correct` note, in characters. */
43
43
  exports.WORK_ITEM_TEXT_MAX = 500;
44
+ /**
45
+ * Refusals from `/work-items` — `stacks/lambdas/workItems/*.ts` (`_get`,
46
+ * `_post`). EVERYTHING those files can answer, not a selection.
47
+ *
48
+ * ⚠️ Completeness is asserted mechanically:
49
+ * `tests/unit/workItemPublishedContract.test.ts` reads those source files off
50
+ * disk and fails on any literal `error: '…'` code missing from this tuple, and
51
+ * on any member here that no source (or named shared helper) can answer.
52
+ *
53
+ * - `WORK_ITEM_NOT_FOUND` · 404 — no such item in this store. Payload-free.
54
+ * - `WORK_ITEM_NOT_OPEN` · 409 — a transition on a `resolved`/`corrected`
55
+ * item, by a caller with authority over it; `data` is
56
+ * {@link WorkItemStateConflictData}. Authority is checked BEFORE state, so a
57
+ * caller without it gets its mode's refusal instead (`handover`/`resolve`:
58
+ * `WORK_ITEM_NOT_RESPONSIBLE`; `accept`: `WORK_ITEM_NO_PENDING_HANDOVER`,
59
+ * since a close strips the handover) — never read either as "still open".
60
+ * - `WORK_ITEM_VERSION_CONFLICT` · 409 — `expectedVersion` is stale, or the
61
+ * write lost its compare-and-swap; `data` is {@link WorkItemStateConflictData}
62
+ * when the item could be re-read, else absent.
63
+ * - `WORK_ITEM_NOT_RESPONSIBLE` · 403 — `handover`/`resolve` by someone who is
64
+ * neither the responsible user nor ADMIN-tier.
65
+ * - `WORK_ITEM_HANDOVER_TO_SELF` · 400 — `toUserId` already holds the item.
66
+ * - `WORK_ITEM_TARGET_USER_NOT_FOUND` · 404 — `toUserId` is not a live operator
67
+ * of this store.
68
+ * - `WORK_ITEM_NO_PENDING_HANDOVER` · 409 — `accept` with no handover pending,
69
+ * including on an item that has since been closed. Payload-free.
70
+ * - `WORK_ITEM_NOT_HANDOVER_TARGET` · 403 — `accept` by anyone but the named
71
+ * receiver.
72
+ * - `WORK_ITEM_UNRESOLVED_AT_SOURCE` · 409 — `resolve` whose source read is not
73
+ * authoritative; `data` is {@link WorkItemUnresolvedAtSourceData}.
74
+ * - `WORK_ITEM_SOURCE_REF_INVALID` · 400 — an `order-create` report whose
75
+ * `attemptKey` was not minted for this store and caller.
76
+ * - `WORK_ITEM_CAPTURED_AT_AHEAD` · 400 — `capturedAt` beyond the server's
77
+ * skew allowance.
78
+ * - `ROLE_FORBIDDEN` · 403 — `GET ?scope=store` or `correct` by a non-ADMIN-tier
79
+ * caller.
80
+ * - `INVALID_CURSOR` · 400 — a `?startKey=` that does not decode, or decodes to
81
+ * a key outside this store's open-item range. Restart from the first page.
82
+ * Read path only.
83
+ * - `VALIDATION_FAILED` · 400 — `stacks/helpers/validateRequest.ts`, on every
84
+ * leg (including a family's missing required `sourceRef` field).
85
+ *
86
+ * ⚠️ `UNHANDLED_ERROR` is deliberately NOT here: it is `tryCatch`'s generic
87
+ * envelope for an unexpected throw and belongs to no endpoint. Cross-cutting
88
+ * refusals are NOT repeated here — check `GATING_ERROR_CODES` as well.
89
+ */
90
+ exports.WORK_ITEM_ERROR_CODES = [
91
+ 'WORK_ITEM_NOT_FOUND',
92
+ 'WORK_ITEM_NOT_OPEN',
93
+ 'WORK_ITEM_VERSION_CONFLICT',
94
+ 'WORK_ITEM_NOT_RESPONSIBLE',
95
+ 'WORK_ITEM_HANDOVER_TO_SELF',
96
+ 'WORK_ITEM_TARGET_USER_NOT_FOUND',
97
+ 'WORK_ITEM_NO_PENDING_HANDOVER',
98
+ 'WORK_ITEM_NOT_HANDOVER_TARGET',
99
+ 'WORK_ITEM_UNRESOLVED_AT_SOURCE',
100
+ 'WORK_ITEM_SOURCE_REF_INVALID',
101
+ 'WORK_ITEM_CAPTURED_AT_AHEAD',
102
+ 'ROLE_FORBIDDEN',
103
+ 'INVALID_CURSOR',
104
+ 'VALIDATION_FAILED',
105
+ ];
@@ -74,11 +74,16 @@ declare global {
74
74
  * `'queued'` — accepted for delivery, not yet handed to the transport.
75
75
  * `'sent'` — the transport ACCEPTED it; acceptance is never proof of inbox
76
76
  * placement. `'failed'` — the transport refused or errored. `'skipped'` — the
77
- * segment matched the recipient but the recipient was not eligible at send
78
- * time (no marketing consent for the channel, or a suppressed address).
77
+ * segment matched the recipient but the send was withheld at send time: the
78
+ * recipient was not eligible (no marketing consent for the channel, no
79
+ * address, a suppressed address, a customer that no longer exists), the
80
+ * campaign was cancelled, or the store had its Marketing module switched off
81
+ * (`reason: 'MODULE_OFF'`). `CampaignRecipient.reason` carries which.
79
82
  *
80
83
  * ⚠️ `'skipped'` is a REFUSAL that was honoured, not a delivery problem:
81
- * never retry it, and never roll it into a failure rate.
84
+ * never retry it, and never roll it into a failure rate. A `'MODULE_OFF'`
85
+ * skip is the STORE'S choice, not the customer's — group on `reason` before
86
+ * reading a skip as a consent refusal.
82
87
  */
83
88
  type CampaignRecipientStatus = 'queued' | 'sent' | 'failed' | 'skipped';
84
89
  /**
@@ -548,8 +553,9 @@ declare global {
548
553
  /**
549
554
  * `'queued'` — accepted, not yet handed to a transport. `'sent'` — handed
550
555
  * over. `'failed'` — the transport refused or errored. `'skipped'` — the rule
551
- * matched but the send was withheld, by the frequency cap or by a live
552
- * consent re-check.
556
+ * matched but the send was withheld, by the frequency cap, by a live
557
+ * consent re-check, or because the store had its Marketing module switched
558
+ * off (`reason: 'MODULE_OFF'`, a store choice rather than a customer's).
553
559
  *
554
560
  * Deliberately the same four values as {@link CampaignRecipientStatus}, and
555
561
  * deliberately a SEPARATE type rather than an alias: the two vocabularies
package/dist/store.d.ts CHANGED
@@ -917,7 +917,7 @@ declare global {
917
917
  * `409 STORE_MODULE_BALANCE_CHECK_INCOMPLETE` when the bounded read could
918
918
  * not finish).
919
919
  *
920
- * Enforced on the server for four modules only:
920
+ * Enforced on the server for six modules only:
921
921
  * - `promotions` — applying one is refused `PROMOTION_NOT_ACTIVE` (the
922
922
  * existing promotion refusal, not `STORE_MODULE_DISABLED`), a grant already
923
923
  * frozen on a cart stays on the row but derives no money (its
@@ -934,6 +934,11 @@ declare global {
934
934
  * - `multiWarehouse` — every sale resolves to the primary depósito (a
935
935
  * scoped operator's sale to their own home depósito when the primary is
936
936
  * outside their scope), and only the primary feeds MercadoLibre.
937
+ * - `loyalty` — the automatic earn credits nothing (the `loyalty-earn`
938
+ * worker skips it, including one queued before the switch). The
939
+ * operator's `POST /loyalty/earn` and every read stay reachable.
940
+ * - `marketing` — automation and campaign sends go out to nobody: each is
941
+ * settled `'skipped'` with reason `MODULE_OFF` at its send worker.
937
942
  * Every other module is hide-only: its endpoints stay reachable. Public
938
943
  * reads carry only `appointments`, `surveys`, `promotions` and
939
944
  * `customerAccounts`. `PUT /platform/stores/{storeId}` refuses the leaf.
@@ -169,6 +169,27 @@ declare global {
169
169
  openCount: number;
170
170
  availability: Record<WorkItemFamily, WorkItemAvailability>;
171
171
  }
172
+ /**
173
+ * `data` of a state-bearing `409` — `WORK_ITEM_NOT_OPEN` (always) and
174
+ * `WORK_ITEM_VERSION_CONFLICT` (when the item could be re-read; a lost
175
+ * compare-and-swap whose re-read finds nothing answers with no `data`).
176
+ * `current` is the item as the server holds it now. The pre-write refusals
177
+ * are answered only past the mode's authority gate. ⚠️ The post-commit
178
+ * conflict (a compare-and-swap lost after that gate passed) re-reads the item
179
+ * and returns it WITHOUT re-checking authority, so its `current` can reflect
180
+ * a responsibility or handover that moved in the race.
181
+ */
182
+ interface WorkItemStateConflictData {
183
+ current: WorkItem;
184
+ }
185
+ /**
186
+ * `data` of `409 WORK_ITEM_UNRESOLVED_AT_SOURCE` — the source read that did
187
+ * not decide the item. `verdict.verdict` is `pending` or `unknown`, never an
188
+ * authoritative one.
189
+ */
190
+ interface WorkItemUnresolvedAtSourceData {
191
+ verdict: WorkItemSourceVerdict;
192
+ }
172
193
  /** The `workItems` socket frame's `data` — refetch, never patch from it. */
173
194
  interface WorkItemFrameData {
174
195
  itemId: string;
@@ -186,3 +207,51 @@ export declare const WORK_ITEM_HISTORY_KINDS: readonly ["reported", "handover-re
186
207
  export declare const WORK_ITEM_PAGE_MAX = 100;
187
208
  /** Upper bound on `summary` and on a `correct` note, in characters. */
188
209
  export declare const WORK_ITEM_TEXT_MAX = 500;
210
+ /**
211
+ * Refusals from `/work-items` — `stacks/lambdas/workItems/*.ts` (`_get`,
212
+ * `_post`). EVERYTHING those files can answer, not a selection.
213
+ *
214
+ * ⚠️ Completeness is asserted mechanically:
215
+ * `tests/unit/workItemPublishedContract.test.ts` reads those source files off
216
+ * disk and fails on any literal `error: '…'` code missing from this tuple, and
217
+ * on any member here that no source (or named shared helper) can answer.
218
+ *
219
+ * - `WORK_ITEM_NOT_FOUND` · 404 — no such item in this store. Payload-free.
220
+ * - `WORK_ITEM_NOT_OPEN` · 409 — a transition on a `resolved`/`corrected`
221
+ * item, by a caller with authority over it; `data` is
222
+ * {@link WorkItemStateConflictData}. Authority is checked BEFORE state, so a
223
+ * caller without it gets its mode's refusal instead (`handover`/`resolve`:
224
+ * `WORK_ITEM_NOT_RESPONSIBLE`; `accept`: `WORK_ITEM_NO_PENDING_HANDOVER`,
225
+ * since a close strips the handover) — never read either as "still open".
226
+ * - `WORK_ITEM_VERSION_CONFLICT` · 409 — `expectedVersion` is stale, or the
227
+ * write lost its compare-and-swap; `data` is {@link WorkItemStateConflictData}
228
+ * when the item could be re-read, else absent.
229
+ * - `WORK_ITEM_NOT_RESPONSIBLE` · 403 — `handover`/`resolve` by someone who is
230
+ * neither the responsible user nor ADMIN-tier.
231
+ * - `WORK_ITEM_HANDOVER_TO_SELF` · 400 — `toUserId` already holds the item.
232
+ * - `WORK_ITEM_TARGET_USER_NOT_FOUND` · 404 — `toUserId` is not a live operator
233
+ * of this store.
234
+ * - `WORK_ITEM_NO_PENDING_HANDOVER` · 409 — `accept` with no handover pending,
235
+ * including on an item that has since been closed. Payload-free.
236
+ * - `WORK_ITEM_NOT_HANDOVER_TARGET` · 403 — `accept` by anyone but the named
237
+ * receiver.
238
+ * - `WORK_ITEM_UNRESOLVED_AT_SOURCE` · 409 — `resolve` whose source read is not
239
+ * authoritative; `data` is {@link WorkItemUnresolvedAtSourceData}.
240
+ * - `WORK_ITEM_SOURCE_REF_INVALID` · 400 — an `order-create` report whose
241
+ * `attemptKey` was not minted for this store and caller.
242
+ * - `WORK_ITEM_CAPTURED_AT_AHEAD` · 400 — `capturedAt` beyond the server's
243
+ * skew allowance.
244
+ * - `ROLE_FORBIDDEN` · 403 — `GET ?scope=store` or `correct` by a non-ADMIN-tier
245
+ * caller.
246
+ * - `INVALID_CURSOR` · 400 — a `?startKey=` that does not decode, or decodes to
247
+ * a key outside this store's open-item range. Restart from the first page.
248
+ * Read path only.
249
+ * - `VALIDATION_FAILED` · 400 — `stacks/helpers/validateRequest.ts`, on every
250
+ * leg (including a family's missing required `sourceRef` field).
251
+ *
252
+ * ⚠️ `UNHANDLED_ERROR` is deliberately NOT here: it is `tryCatch`'s generic
253
+ * envelope for an unexpected throw and belongs to no endpoint. Cross-cutting
254
+ * refusals are NOT repeated here — check `GATING_ERROR_CODES` as well.
255
+ */
256
+ export declare const WORK_ITEM_ERROR_CODES: readonly ["WORK_ITEM_NOT_FOUND", "WORK_ITEM_NOT_OPEN", "WORK_ITEM_VERSION_CONFLICT", "WORK_ITEM_NOT_RESPONSIBLE", "WORK_ITEM_HANDOVER_TO_SELF", "WORK_ITEM_TARGET_USER_NOT_FOUND", "WORK_ITEM_NO_PENDING_HANDOVER", "WORK_ITEM_NOT_HANDOVER_TARGET", "WORK_ITEM_UNRESOLVED_AT_SOURCE", "WORK_ITEM_SOURCE_REF_INVALID", "WORK_ITEM_CAPTURED_AT_AHEAD", "ROLE_FORBIDDEN", "INVALID_CURSOR", "VALIDATION_FAILED"];
257
+ export type WorkItemErrorCode = (typeof WORK_ITEM_ERROR_CODES)[number];
package/dist/workItem.js CHANGED
@@ -38,3 +38,65 @@ export const WORK_ITEM_HISTORY_KINDS = ['reported', 'handover-requested', 'accep
38
38
  export const WORK_ITEM_PAGE_MAX = 100;
39
39
  /** Upper bound on `summary` and on a `correct` note, in characters. */
40
40
  export const WORK_ITEM_TEXT_MAX = 500;
41
+ /**
42
+ * Refusals from `/work-items` — `stacks/lambdas/workItems/*.ts` (`_get`,
43
+ * `_post`). EVERYTHING those files can answer, not a selection.
44
+ *
45
+ * ⚠️ Completeness is asserted mechanically:
46
+ * `tests/unit/workItemPublishedContract.test.ts` reads those source files off
47
+ * disk and fails on any literal `error: '…'` code missing from this tuple, and
48
+ * on any member here that no source (or named shared helper) can answer.
49
+ *
50
+ * - `WORK_ITEM_NOT_FOUND` · 404 — no such item in this store. Payload-free.
51
+ * - `WORK_ITEM_NOT_OPEN` · 409 — a transition on a `resolved`/`corrected`
52
+ * item, by a caller with authority over it; `data` is
53
+ * {@link WorkItemStateConflictData}. Authority is checked BEFORE state, so a
54
+ * caller without it gets its mode's refusal instead (`handover`/`resolve`:
55
+ * `WORK_ITEM_NOT_RESPONSIBLE`; `accept`: `WORK_ITEM_NO_PENDING_HANDOVER`,
56
+ * since a close strips the handover) — never read either as "still open".
57
+ * - `WORK_ITEM_VERSION_CONFLICT` · 409 — `expectedVersion` is stale, or the
58
+ * write lost its compare-and-swap; `data` is {@link WorkItemStateConflictData}
59
+ * when the item could be re-read, else absent.
60
+ * - `WORK_ITEM_NOT_RESPONSIBLE` · 403 — `handover`/`resolve` by someone who is
61
+ * neither the responsible user nor ADMIN-tier.
62
+ * - `WORK_ITEM_HANDOVER_TO_SELF` · 400 — `toUserId` already holds the item.
63
+ * - `WORK_ITEM_TARGET_USER_NOT_FOUND` · 404 — `toUserId` is not a live operator
64
+ * of this store.
65
+ * - `WORK_ITEM_NO_PENDING_HANDOVER` · 409 — `accept` with no handover pending,
66
+ * including on an item that has since been closed. Payload-free.
67
+ * - `WORK_ITEM_NOT_HANDOVER_TARGET` · 403 — `accept` by anyone but the named
68
+ * receiver.
69
+ * - `WORK_ITEM_UNRESOLVED_AT_SOURCE` · 409 — `resolve` whose source read is not
70
+ * authoritative; `data` is {@link WorkItemUnresolvedAtSourceData}.
71
+ * - `WORK_ITEM_SOURCE_REF_INVALID` · 400 — an `order-create` report whose
72
+ * `attemptKey` was not minted for this store and caller.
73
+ * - `WORK_ITEM_CAPTURED_AT_AHEAD` · 400 — `capturedAt` beyond the server's
74
+ * skew allowance.
75
+ * - `ROLE_FORBIDDEN` · 403 — `GET ?scope=store` or `correct` by a non-ADMIN-tier
76
+ * caller.
77
+ * - `INVALID_CURSOR` · 400 — a `?startKey=` that does not decode, or decodes to
78
+ * a key outside this store's open-item range. Restart from the first page.
79
+ * Read path only.
80
+ * - `VALIDATION_FAILED` · 400 — `stacks/helpers/validateRequest.ts`, on every
81
+ * leg (including a family's missing required `sourceRef` field).
82
+ *
83
+ * ⚠️ `UNHANDLED_ERROR` is deliberately NOT here: it is `tryCatch`'s generic
84
+ * envelope for an unexpected throw and belongs to no endpoint. Cross-cutting
85
+ * refusals are NOT repeated here — check `GATING_ERROR_CODES` as well.
86
+ */
87
+ export const WORK_ITEM_ERROR_CODES = [
88
+ 'WORK_ITEM_NOT_FOUND',
89
+ 'WORK_ITEM_NOT_OPEN',
90
+ 'WORK_ITEM_VERSION_CONFLICT',
91
+ 'WORK_ITEM_NOT_RESPONSIBLE',
92
+ 'WORK_ITEM_HANDOVER_TO_SELF',
93
+ 'WORK_ITEM_TARGET_USER_NOT_FOUND',
94
+ 'WORK_ITEM_NO_PENDING_HANDOVER',
95
+ 'WORK_ITEM_NOT_HANDOVER_TARGET',
96
+ 'WORK_ITEM_UNRESOLVED_AT_SOURCE',
97
+ 'WORK_ITEM_SOURCE_REF_INVALID',
98
+ 'WORK_ITEM_CAPTURED_AT_AHEAD',
99
+ 'ROLE_FORBIDDEN',
100
+ 'INVALID_CURSOR',
101
+ 'VALIDATION_FAILED',
102
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.728",
3
+ "version": "1.10.730",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",