platform-types 1.10.729 → 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.
- package/dist/cjs/workItem.js +63 -1
- package/dist/workItem.d.ts +69 -0
- package/dist/workItem.js +62 -0
- package/package.json +1 -1
package/dist/cjs/workItem.js
CHANGED
|
@@ -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
|
+
];
|
package/dist/workItem.d.ts
CHANGED
|
@@ -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
|
+
];
|