sinfactura-types 1.10.408 → 1.10.409

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/auth.d.ts CHANGED
@@ -851,6 +851,55 @@ declare global {
851
851
  * rendered as a complete one reads as "nothing happened before this".
852
852
  */
853
853
  type OperatorLoginHistoryResponse = CustomerLoginHistoryResponse;
854
+ /**
855
+ * `POST /auth/2fa/enroll` `data` — starts an enrolment; nothing is enabled
856
+ * until `/verify-enrollment` proves possession.
857
+ *
858
+ * ⚠️ `secret` is the PLAINTEXT base32 seed, for authenticator apps that cannot
859
+ * scan. This response is the only time it crosses the wire: never log it,
860
+ * never persist it client-side, and drop it from memory once the user has
861
+ * confirmed a code.
862
+ */
863
+ interface TwoFactorEnrollResponse {
864
+ /** An `otpauth://totp/…` URI — render it as a QR code. */
865
+ qrCodeUrl: string;
866
+ /** The same seed, base32, for manual entry. */
867
+ secret: string;
868
+ }
869
+ /**
870
+ * `POST /auth/2fa/verify-enrollment` `data` — the pending seed is now the
871
+ * active second factor.
872
+ *
873
+ * ⚠️ `recoveryCodes` is the one-time PLAINTEXT set — the api keeps only
874
+ * hashes, so it can never be shown again. Show it once and make the user save
875
+ * it; a client that navigates away before rendering it leaves the account
876
+ * with codes nobody holds. It is NOT the stored `{ hash, usedAt }` form.
877
+ */
878
+ interface TwoFactorVerifyEnrollmentResponse {
879
+ enabled: true;
880
+ /** unix ms */
881
+ enrolledAt: number;
882
+ recoveryCodes: string[];
883
+ }
884
+ /**
885
+ * `POST /auth/2fa/disable` `data`. The seed and the recovery codes are gone.
886
+ * The user's remembered devices are revoked too, best-effort: a failed revoke
887
+ * does not fail this response.
888
+ */
889
+ interface TwoFactorDisableResponse {
890
+ enabled: false;
891
+ }
892
+ /**
893
+ * `POST /auth/2fa/recovery-codes` `data` — a fresh set that REPLACES the old
894
+ * one wholesale; every previous code stops working.
895
+ *
896
+ * ⚠️ Same one-time plaintext as {@link TwoFactorVerifyEnrollmentResponse.recoveryCodes}.
897
+ */
898
+ interface TwoFactorRecoveryCodesResponse {
899
+ recoveryCodes: string[];
900
+ /** unix ms */
901
+ recoveryCodesGeneratedAt: number;
902
+ }
854
903
  }
855
904
  /**
856
905
  * `body.error` codes the sign-in-method paths can refuse with.
@@ -1074,7 +1123,8 @@ export declare const LOGIN_ERROR_CODES: readonly ["WRONG_CREDENTIALS", "ACCOUNT_
1074
1123
  * changing their own 2FA settings.
1075
1124
  * - `2FA_LOCKED` · 429 — the factor is locked for ~15 minutes after repeated
1076
1125
  * failures. Back off; a retry loop cannot shorten it. Reached from the login
1077
- * step-up AND from the disable / recovery-codes management routes.
1126
+ * step-up AND from all four management routes — see
1127
+ * {@link TWO_FACTOR_MANAGEMENT_ERROR_CODES}.
1078
1128
  *
1079
1129
  * ⚠️ `ENROLLMENT_REQUIRED` is not here: it belongs to `STEP_UP_ERROR_CODES`,
1080
1130
  * because the second factor did not FAIL — there is no factor to fail yet. See
@@ -1083,6 +1133,44 @@ export declare const LOGIN_ERROR_CODES: readonly ["WRONG_CREDENTIALS", "ACCOUNT_
1083
1133
  */
1084
1134
  export declare const LOGIN_2FA_ERROR_CODES: readonly ["INVALID_2FA_CODE", "2FA_LOCKED"];
1085
1135
  export type Login2faErrorCode = (typeof LOGIN_2FA_ERROR_CODES)[number];
1136
+ /**
1137
+ * `body.error` codes the four self-service TOTP routes refuse with —
1138
+ * `POST /auth/2fa/enroll`, `/verify-enrollment`, `/disable` and
1139
+ * `/recovery-codes`. Complete for those routes: every refusal their handlers
1140
+ * answer is here, including the two they share with
1141
+ * {@link LOGIN_2FA_ERROR_CODES}, so a management screen can key one exhaustive
1142
+ * `Record` off this tuple alone.
1143
+ *
1144
+ * ⚠️ The user IS authenticated on every one of these routes, so no member here
1145
+ * is a reason to drop the session — `USER_NOT_FOUND` included.
1146
+ *
1147
+ * - `VALIDATION_FAILED` · 400 — the body failed the schema, which accepts a
1148
+ * 6–12 character `code` and no other key. Not on `/enroll`, which reads no
1149
+ * body.
1150
+ * - `INVALID_2FA_CODE` · 400 — ⚠️ 400 HERE, 401 on the login step-up. Wrong,
1151
+ * malformed or already-used code; re-prompt on the same screen. Not on
1152
+ * `/enroll`.
1153
+ * - `2FA_LOCKED` · 429 — the shared lockout across every door that takes a
1154
+ * code. Answered by all four routes, `/enroll` included: minting a fresh seed
1155
+ * must not reset the counter. Back off; retrying cannot shorten it.
1156
+ * - `USER_NOT_FOUND` · 404 — the token's user row is gone.
1157
+ * - `ALREADY_ENROLLED` · 409 — `/enroll` and `/verify-enrollment`. 2FA is on;
1158
+ * disabling it (which needs the current code) comes first.
1159
+ * - `NO_PENDING_ENROLLMENT` · 400 — `/verify-enrollment` with no `/enroll`
1160
+ * before it. Start over at `/enroll`.
1161
+ * - `ENROLLMENT_EXPIRED` · 400 — `/verify-enrollment` after the pending seed
1162
+ * lapsed (15 minutes). Start over at `/enroll` for a new QR.
1163
+ * - `ENROLLMENT_SUPERSEDED` · 409 — `/verify-enrollment` lost a race: another
1164
+ * `/enroll` replaced the pending seed, or a parallel verify promoted it first.
1165
+ * Rescan the CURRENT QR; the code just typed was checked against a seed that
1166
+ * no longer exists.
1167
+ * - `NOT_ENROLLED` · 400 — `/disable` and `/recovery-codes` with 2FA off.
1168
+ *
1169
+ * ⚠️ The cross-cutting wrapper refusals are NOT repeated here — check
1170
+ * `GATING_ERROR_CODES` in addition.
1171
+ */
1172
+ export declare const TWO_FACTOR_MANAGEMENT_ERROR_CODES: readonly ["VALIDATION_FAILED", "INVALID_2FA_CODE", "2FA_LOCKED", "USER_NOT_FOUND", "ALREADY_ENROLLED", "NO_PENDING_ENROLLMENT", "ENROLLMENT_EXPIRED", "ENROLLMENT_SUPERSEDED", "NOT_ENROLLED"];
1173
+ export type TwoFactorManagementErrorCode = (typeof TWO_FACTOR_MANAGEMENT_ERROR_CODES)[number];
1086
1174
  /**
1087
1175
  * Refusals from the session-management legs — `stacks/lambdas/auth/_revokeSession.ts`
1088
1176
  * and `_revokeOthers.ts`. Shared by the operator and customer hosts, which run
package/dist/auth.js CHANGED
@@ -251,7 +251,8 @@ export const LOGIN_ERROR_CODES = [
251
251
  * changing their own 2FA settings.
252
252
  * - `2FA_LOCKED` · 429 — the factor is locked for ~15 minutes after repeated
253
253
  * failures. Back off; a retry loop cannot shorten it. Reached from the login
254
- * step-up AND from the disable / recovery-codes management routes.
254
+ * step-up AND from all four management routes — see
255
+ * {@link TWO_FACTOR_MANAGEMENT_ERROR_CODES}.
255
256
  *
256
257
  * ⚠️ `ENROLLMENT_REQUIRED` is not here: it belongs to `STEP_UP_ERROR_CODES`,
257
258
  * because the second factor did not FAIL — there is no factor to fail yet. See
@@ -259,6 +260,53 @@ export const LOGIN_ERROR_CODES = [
259
260
  * it may be spelled.
260
261
  */
261
262
  export const LOGIN_2FA_ERROR_CODES = ['INVALID_2FA_CODE', '2FA_LOCKED'];
263
+ /**
264
+ * `body.error` codes the four self-service TOTP routes refuse with —
265
+ * `POST /auth/2fa/enroll`, `/verify-enrollment`, `/disable` and
266
+ * `/recovery-codes`. Complete for those routes: every refusal their handlers
267
+ * answer is here, including the two they share with
268
+ * {@link LOGIN_2FA_ERROR_CODES}, so a management screen can key one exhaustive
269
+ * `Record` off this tuple alone.
270
+ *
271
+ * ⚠️ The user IS authenticated on every one of these routes, so no member here
272
+ * is a reason to drop the session — `USER_NOT_FOUND` included.
273
+ *
274
+ * - `VALIDATION_FAILED` · 400 — the body failed the schema, which accepts a
275
+ * 6–12 character `code` and no other key. Not on `/enroll`, which reads no
276
+ * body.
277
+ * - `INVALID_2FA_CODE` · 400 — ⚠️ 400 HERE, 401 on the login step-up. Wrong,
278
+ * malformed or already-used code; re-prompt on the same screen. Not on
279
+ * `/enroll`.
280
+ * - `2FA_LOCKED` · 429 — the shared lockout across every door that takes a
281
+ * code. Answered by all four routes, `/enroll` included: minting a fresh seed
282
+ * must not reset the counter. Back off; retrying cannot shorten it.
283
+ * - `USER_NOT_FOUND` · 404 — the token's user row is gone.
284
+ * - `ALREADY_ENROLLED` · 409 — `/enroll` and `/verify-enrollment`. 2FA is on;
285
+ * disabling it (which needs the current code) comes first.
286
+ * - `NO_PENDING_ENROLLMENT` · 400 — `/verify-enrollment` with no `/enroll`
287
+ * before it. Start over at `/enroll`.
288
+ * - `ENROLLMENT_EXPIRED` · 400 — `/verify-enrollment` after the pending seed
289
+ * lapsed (15 minutes). Start over at `/enroll` for a new QR.
290
+ * - `ENROLLMENT_SUPERSEDED` · 409 — `/verify-enrollment` lost a race: another
291
+ * `/enroll` replaced the pending seed, or a parallel verify promoted it first.
292
+ * Rescan the CURRENT QR; the code just typed was checked against a seed that
293
+ * no longer exists.
294
+ * - `NOT_ENROLLED` · 400 — `/disable` and `/recovery-codes` with 2FA off.
295
+ *
296
+ * ⚠️ The cross-cutting wrapper refusals are NOT repeated here — check
297
+ * `GATING_ERROR_CODES` in addition.
298
+ */
299
+ export const TWO_FACTOR_MANAGEMENT_ERROR_CODES = [
300
+ 'VALIDATION_FAILED',
301
+ 'INVALID_2FA_CODE',
302
+ '2FA_LOCKED',
303
+ 'USER_NOT_FOUND',
304
+ 'ALREADY_ENROLLED',
305
+ 'NO_PENDING_ENROLLMENT',
306
+ 'ENROLLMENT_EXPIRED',
307
+ 'ENROLLMENT_SUPERSEDED',
308
+ 'NOT_ENROLLED',
309
+ ];
262
310
  /**
263
311
  * Refusals from the session-management legs — `stacks/lambdas/auth/_revokeSession.ts`
264
312
  * and `_revokeOthers.ts`. Shared by the operator and customer hosts, which run
@@ -73,3 +73,30 @@ export declare const MAX_CART_LINES = 31;
73
73
  * derivations happen to land on the same figure today and are free to diverge.
74
74
  */
75
75
  export declare const MAX_PRESUPUESTO_DISTINCT_PRODUCTS = 32;
76
+ /**
77
+ * The largest ORIGINAL image one upload may carry, in bytes — 4 MiB.
78
+ *
79
+ * Uploads travel as base64 inside the JSON body, against Lambda's ~6 MB request
80
+ * payload ceiling, and base64 inflates by ~33%. A client should downscale
81
+ * before this, not after a refusal.
82
+ *
83
+ * ⚠️ Unlike the three caps above this one is NOT a mirror: the api imports it
84
+ * from here. Uploads are bounded by the string length derived from it
85
+ * (`MAX_IMAGE_BASE64_CHARS`, below), not by measuring decoded bytes, so a payload
86
+ * a few bytes over this value can still pass — a client pre-checking against it
87
+ * is never refused.
88
+ */
89
+ export declare const MAX_IMAGE_BYTES: number;
90
+ /**
91
+ * The longest base64 string an image field accepts — `photoData`, and every
92
+ * `pictures[].base64` — measured in characters BEFORE decode. A longer string
93
+ * is `400 VALIDATION_FAILED`.
94
+ *
95
+ * {@link MAX_IMAGE_BYTES} in base64 characters, plus 64 for a
96
+ * `data:image/…;base64,` prefix, so a genuine 4 MiB image sent as a data URI is
97
+ * not refused for its prefix. Checking the STRING is deliberate: a bound applied
98
+ * after decode has already paid the memory it exists to protect.
99
+ *
100
+ * ⚠️ Not a mirror either — the api's schemas import this value.
101
+ */
102
+ export declare const MAX_IMAGE_BASE64_CHARS: number;
package/dist/capacity.js CHANGED
@@ -73,3 +73,30 @@ export const MAX_CART_LINES = 31;
73
73
  * derivations happen to land on the same figure today and are free to diverge.
74
74
  */
75
75
  export const MAX_PRESUPUESTO_DISTINCT_PRODUCTS = 32;
76
+ /**
77
+ * The largest ORIGINAL image one upload may carry, in bytes — 4 MiB.
78
+ *
79
+ * Uploads travel as base64 inside the JSON body, against Lambda's ~6 MB request
80
+ * payload ceiling, and base64 inflates by ~33%. A client should downscale
81
+ * before this, not after a refusal.
82
+ *
83
+ * ⚠️ Unlike the three caps above this one is NOT a mirror: the api imports it
84
+ * from here. Uploads are bounded by the string length derived from it
85
+ * (`MAX_IMAGE_BASE64_CHARS`, below), not by measuring decoded bytes, so a payload
86
+ * a few bytes over this value can still pass — a client pre-checking against it
87
+ * is never refused.
88
+ */
89
+ export const MAX_IMAGE_BYTES = 4 * 1024 * 1024;
90
+ /**
91
+ * The longest base64 string an image field accepts — `photoData`, and every
92
+ * `pictures[].base64` — measured in characters BEFORE decode. A longer string
93
+ * is `400 VALIDATION_FAILED`.
94
+ *
95
+ * {@link MAX_IMAGE_BYTES} in base64 characters, plus 64 for a
96
+ * `data:image/…;base64,` prefix, so a genuine 4 MiB image sent as a data URI is
97
+ * not refused for its prefix. Checking the STRING is deliberate: a bound applied
98
+ * after decode has already paid the memory it exists to protect.
99
+ *
100
+ * ⚠️ Not a mirror either — the api's schemas import this value.
101
+ */
102
+ export const MAX_IMAGE_BASE64_CHARS = Math.ceil(MAX_IMAGE_BYTES / 3) * 4 + 64;
package/dist/cjs/auth.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SESSION_ACTION_ERROR_CODES = exports.LOGIN_2FA_ERROR_CODES = exports.LOGIN_ERROR_CODES = exports.STEP_UP_ERROR_CODES = exports.REFRESH_ERROR_CODES = exports.SIGN_IN_METHOD_ERROR_CODES = void 0;
3
+ exports.SESSION_ACTION_ERROR_CODES = exports.TWO_FACTOR_MANAGEMENT_ERROR_CODES = exports.LOGIN_2FA_ERROR_CODES = exports.LOGIN_ERROR_CODES = exports.STEP_UP_ERROR_CODES = exports.REFRESH_ERROR_CODES = exports.SIGN_IN_METHOD_ERROR_CODES = void 0;
4
4
  /**
5
5
  * `body.error` codes the sign-in-method paths can refuse with.
6
6
  *
@@ -254,7 +254,8 @@ exports.LOGIN_ERROR_CODES = [
254
254
  * changing their own 2FA settings.
255
255
  * - `2FA_LOCKED` · 429 — the factor is locked for ~15 minutes after repeated
256
256
  * failures. Back off; a retry loop cannot shorten it. Reached from the login
257
- * step-up AND from the disable / recovery-codes management routes.
257
+ * step-up AND from all four management routes — see
258
+ * {@link TWO_FACTOR_MANAGEMENT_ERROR_CODES}.
258
259
  *
259
260
  * ⚠️ `ENROLLMENT_REQUIRED` is not here: it belongs to `STEP_UP_ERROR_CODES`,
260
261
  * because the second factor did not FAIL — there is no factor to fail yet. See
@@ -262,6 +263,53 @@ exports.LOGIN_ERROR_CODES = [
262
263
  * it may be spelled.
263
264
  */
264
265
  exports.LOGIN_2FA_ERROR_CODES = ['INVALID_2FA_CODE', '2FA_LOCKED'];
266
+ /**
267
+ * `body.error` codes the four self-service TOTP routes refuse with —
268
+ * `POST /auth/2fa/enroll`, `/verify-enrollment`, `/disable` and
269
+ * `/recovery-codes`. Complete for those routes: every refusal their handlers
270
+ * answer is here, including the two they share with
271
+ * {@link LOGIN_2FA_ERROR_CODES}, so a management screen can key one exhaustive
272
+ * `Record` off this tuple alone.
273
+ *
274
+ * ⚠️ The user IS authenticated on every one of these routes, so no member here
275
+ * is a reason to drop the session — `USER_NOT_FOUND` included.
276
+ *
277
+ * - `VALIDATION_FAILED` · 400 — the body failed the schema, which accepts a
278
+ * 6–12 character `code` and no other key. Not on `/enroll`, which reads no
279
+ * body.
280
+ * - `INVALID_2FA_CODE` · 400 — ⚠️ 400 HERE, 401 on the login step-up. Wrong,
281
+ * malformed or already-used code; re-prompt on the same screen. Not on
282
+ * `/enroll`.
283
+ * - `2FA_LOCKED` · 429 — the shared lockout across every door that takes a
284
+ * code. Answered by all four routes, `/enroll` included: minting a fresh seed
285
+ * must not reset the counter. Back off; retrying cannot shorten it.
286
+ * - `USER_NOT_FOUND` · 404 — the token's user row is gone.
287
+ * - `ALREADY_ENROLLED` · 409 — `/enroll` and `/verify-enrollment`. 2FA is on;
288
+ * disabling it (which needs the current code) comes first.
289
+ * - `NO_PENDING_ENROLLMENT` · 400 — `/verify-enrollment` with no `/enroll`
290
+ * before it. Start over at `/enroll`.
291
+ * - `ENROLLMENT_EXPIRED` · 400 — `/verify-enrollment` after the pending seed
292
+ * lapsed (15 minutes). Start over at `/enroll` for a new QR.
293
+ * - `ENROLLMENT_SUPERSEDED` · 409 — `/verify-enrollment` lost a race: another
294
+ * `/enroll` replaced the pending seed, or a parallel verify promoted it first.
295
+ * Rescan the CURRENT QR; the code just typed was checked against a seed that
296
+ * no longer exists.
297
+ * - `NOT_ENROLLED` · 400 — `/disable` and `/recovery-codes` with 2FA off.
298
+ *
299
+ * ⚠️ The cross-cutting wrapper refusals are NOT repeated here — check
300
+ * `GATING_ERROR_CODES` in addition.
301
+ */
302
+ exports.TWO_FACTOR_MANAGEMENT_ERROR_CODES = [
303
+ 'VALIDATION_FAILED',
304
+ 'INVALID_2FA_CODE',
305
+ '2FA_LOCKED',
306
+ 'USER_NOT_FOUND',
307
+ 'ALREADY_ENROLLED',
308
+ 'NO_PENDING_ENROLLMENT',
309
+ 'ENROLLMENT_EXPIRED',
310
+ 'ENROLLMENT_SUPERSEDED',
311
+ 'NOT_ENROLLED',
312
+ ];
265
313
  /**
266
314
  * Refusals from the session-management legs — `stacks/lambdas/auth/_revokeSession.ts`
267
315
  * and `_revokeOthers.ts`. Shared by the operator and customer hosts, which run
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_PRESUPUESTO_DISTINCT_PRODUCTS = exports.MAX_CART_LINES = exports.MAX_ORDER_PRODUCT_LINES = void 0;
3
+ exports.MAX_IMAGE_BASE64_CHARS = exports.MAX_IMAGE_BYTES = exports.MAX_PRESUPUESTO_DISTINCT_PRODUCTS = exports.MAX_CART_LINES = exports.MAX_ORDER_PRODUCT_LINES = void 0;
4
4
  /**
5
5
  * How many distinct PRODUCT LINES one ORDER can carry — what a checkout accepts.
6
6
  *
@@ -76,3 +76,30 @@ exports.MAX_CART_LINES = 31;
76
76
  * derivations happen to land on the same figure today and are free to diverge.
77
77
  */
78
78
  exports.MAX_PRESUPUESTO_DISTINCT_PRODUCTS = 32;
79
+ /**
80
+ * The largest ORIGINAL image one upload may carry, in bytes — 4 MiB.
81
+ *
82
+ * Uploads travel as base64 inside the JSON body, against Lambda's ~6 MB request
83
+ * payload ceiling, and base64 inflates by ~33%. A client should downscale
84
+ * before this, not after a refusal.
85
+ *
86
+ * ⚠️ Unlike the three caps above this one is NOT a mirror: the api imports it
87
+ * from here. Uploads are bounded by the string length derived from it
88
+ * (`MAX_IMAGE_BASE64_CHARS`, below), not by measuring decoded bytes, so a payload
89
+ * a few bytes over this value can still pass — a client pre-checking against it
90
+ * is never refused.
91
+ */
92
+ exports.MAX_IMAGE_BYTES = 4 * 1024 * 1024;
93
+ /**
94
+ * The longest base64 string an image field accepts — `photoData`, and every
95
+ * `pictures[].base64` — measured in characters BEFORE decode. A longer string
96
+ * is `400 VALIDATION_FAILED`.
97
+ *
98
+ * {@link MAX_IMAGE_BYTES} in base64 characters, plus 64 for a
99
+ * `data:image/…;base64,` prefix, so a genuine 4 MiB image sent as a data URI is
100
+ * not refused for its prefix. Checking the STRING is deliberate: a bound applied
101
+ * after decode has already paid the memory it exists to protect.
102
+ *
103
+ * ⚠️ Not a mirror either — the api's schemas import this value.
104
+ */
105
+ exports.MAX_IMAGE_BASE64_CHARS = Math.ceil(exports.MAX_IMAGE_BYTES / 3) * 4 + 64;
@@ -34,7 +34,7 @@
34
34
  * A cancelled order can still have the device on the shelf.
35
35
  */
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.SERVICE_CUSTODIES = exports.SERVICE_CUSTODY_TRANSITIONS = exports.SERVICE_TERMINAL_STATUSES = exports.SERVICE_STATUSES = exports.SERVICE_TRANSITIONS = void 0;
37
+ exports.SERVICE_ORDER_ERROR_CODES = exports.MAX_SERVICE_PICTURES = exports.SERVICE_CUSTODIES = exports.SERVICE_CUSTODY_TRANSITIONS = exports.SERVICE_TERMINAL_STATUSES = exports.SERVICE_STATUSES = exports.SERVICE_TRANSITIONS = void 0;
38
38
  /**
39
39
  * The legal moves on a service order. Exhaustive over `ServiceStatus` by
40
40
  * construction — adding a status to the union without a row here is a typecheck
@@ -142,3 +142,151 @@ exports.SERVICE_CUSTODY_TRANSITIONS = {
142
142
  * validator built on the array silently 400s it.
143
143
  */
144
144
  exports.SERVICE_CUSTODIES = Object.keys(exports.SERVICE_CUSTODY_TRANSITIONS);
145
+ /**
146
+ * How many photos one service order may carry in `pictures`, across BOTH
147
+ * stages (`intake` and `delivery`) together. `POST /services` `mode: 'create'`
148
+ * and `mode: 'edit'` refuse a longer array with `400 VALIDATION_FAILED`; the
149
+ * same number bounds `removePictures` on `mode: 'edit'`.
150
+ *
151
+ * Lower than a product's 50 on purpose: a repair wants a handful of photos per
152
+ * end of the job, not a catalogue, and the array rides the row on every read of
153
+ * the board.
154
+ *
155
+ * The api validates against THIS constant, so it cannot drift from what a
156
+ * client enforces while picking photos. Each entry's `base64` is bounded
157
+ * separately by {@link MAX_IMAGE_BASE64_CHARS}.
158
+ */
159
+ exports.MAX_SERVICE_PICTURES = 20;
160
+ /**
161
+ * `body.error` codes `/services` refuses with — every mode of `POST /services`
162
+ * and every `GET /services` read (list, `?mode=unclaimed`, by id, `?mode=pdf`).
163
+ * The api keeps this tuple complete against its handlers with a unit test, so a
164
+ * code missing here is a defect, not a design choice.
165
+ *
166
+ * ⚠️ MATCH ON `body.error`, never on the status alone: most of these are `409`
167
+ * or `400`, each with a different remedy. The families, and the members whose
168
+ * remedy is not obvious from the name:
169
+ *
170
+ * - `*_CHANGED` · 409 — `SERVICE_ORDER_STATUS_CHANGED`, `_EDIT_CHANGED`,
171
+ * `_DEPOSIT_CHANGED`, `_PARTS_CHANGED`, `_QUOTE_CHANGED`, `_WORKLOG_CHANGED`:
172
+ * someone else wrote the ticket between your read and your write, and nothing
173
+ * of yours was written. Refetch and let the operator retry against the new
174
+ * state — the body that lost was built on the old one.
175
+ * - `SERVICE_ORDER_ILLEGAL_TRANSITION` · 409 — the body is
176
+ * {@link ServiceOrderIllegalTransitionRefusal}; its `allowed[]` is the menu to
177
+ * offer instead.
178
+ * - `CUSTODY_ILLEGAL_TRANSITION` / `SERVICE_ORDER_CUSTODY_NOT_RECEIVED` · 409 —
179
+ * the body is {@link ServiceOrderCustodyRefusal}, with `allowed[]`.
180
+ * - `SERVICE_ORDER_TERMINAL` · 409 — the ticket is in a
181
+ * {@link SERVICE_TERMINAL_STATUSES} member and the mode only applies to an
182
+ * open one. Not retryable.
183
+ * - `SERVICE_DELIVERY_BASKET_DECISION_REQUIRED` · 400 — the `ready → delivered`
184
+ * handover found goods in the customer's cart. Ask the operator whether they
185
+ * are charged in this delivery and resend with the decision; nothing was
186
+ * written.
187
+ * - `SERVICE_RENOTIFY_*` — `mode: 'renotify'`. `_TOO_SOON` (429) carries
188
+ * `lastNotifiedAt` and `retryAfterMs`; `_IMPERSONATED` (403) means a support
189
+ * session cannot message the customer — the store must resend it itself;
190
+ * `_NOT_RECORDED` (500) and `_NOT_DISPATCHED` (409) mean nothing was sent;
191
+ * `_CONFLICT` (409) means re-read the order before sending again;
192
+ * `_LEDGER_UNREADABLE` (409) is a damaged row — escalate, do not retry.
193
+ * - `INVALID_IMAGE_REFERENCE` · 400 — a `pictures[]` / `removePictures[]`
194
+ * entry the ticket cannot take: a url outside the store or not already on
195
+ * this ticket, a resend that changes a stored photo's `stage`, or a
196
+ * bytes-less entry on create. Nothing was written. `MISSING_STORE_CONTEXT`
197
+ * (401) is the same guard refusing a session with no usable store.
198
+ * - `WARRANTY_BELOW_LEGAL_MINIMUM` · 400 — an explicit `warrantyDays` above 0 and below 30
199
+ * (Ley 24.240 art. 23 sets 30). `0` means "not stated" and is accepted. The
200
+ * same refusal, from the same rule, is answered by `/service-templates`
201
+ * create and edit.
202
+ * - `VALIDATION_FAILED` · 400 — the body or query failed its schema.
203
+ *
204
+ * ⚠️ `ROLE_FORBIDDEN` here is the router's own role check (a print agent, or a
205
+ * role no mode admits); the cross-cutting wrapper refusals are NOT repeated —
206
+ * check `GATING_ERROR_CODES` in addition.
207
+ */
208
+ exports.SERVICE_ORDER_ERROR_CODES = [
209
+ // Router and reads
210
+ 'ROLE_FORBIDDEN',
211
+ 'PARENT_FILTER_CONFLICT',
212
+ 'VALIDATION_FAILED',
213
+ 'INVALID_CURSOR',
214
+ 'INVALID_FROM_DATE',
215
+ 'INVALID_TO_DATE',
216
+ 'INVALID_DATE_RANGE',
217
+ 'REWORK_INDEX_UNAVAILABLE',
218
+ 'STORE_NOT_FOUND',
219
+ 'SERVICE_ORDER_NOT_FOUND',
220
+ // Intake and edit
221
+ 'CUSTOMER_NOT_FOUND',
222
+ 'PARENT_SERVICE_ORDER_NOT_FOUND',
223
+ 'SERVICE_TEMPLATE_NOT_FOUND',
224
+ 'SERVICE_TYPE_REQUIRED',
225
+ 'INVALID_IMAGE_REFERENCE',
226
+ 'MISSING_STORE_CONTEXT',
227
+ 'WARRANTY_BELOW_LEGAL_MINIMUM',
228
+ 'TECHNICIAN_NOT_FOUND',
229
+ 'TECHNICIAN_NOT_ELIGIBLE',
230
+ 'CUSTODY_ILLEGAL_TRANSITION',
231
+ 'SERVICE_ORDER_BILLABLE_FROZEN',
232
+ 'SERVICE_ORDER_EDIT_CHANGED',
233
+ 'SERVICE_ORDER_DISABLED_STATE_UNCHANGED',
234
+ // Lifecycle
235
+ 'SERVICE_ORDER_TERMINAL',
236
+ 'SERVICE_ORDER_DISABLED',
237
+ 'SERVICE_ORDER_ILLEGAL_TRANSITION',
238
+ 'SERVICE_ORDER_STATUS_CHANGED',
239
+ 'SERVICE_ORDER_OUTCOME_REQUIRED',
240
+ 'SERVICE_ORDER_OUTCOME_NOT_ALLOWED',
241
+ 'SERVICE_ORDER_CUSTODY_NOT_RECEIVED',
242
+ 'SERVICE_ORDER_BILLABLE_NOT_AT_THIS_TRANSITION',
243
+ // Deposit
244
+ 'PAYMENT_METHODS_NOT_CONFIGURED',
245
+ 'PAYMENT_METHOD_NOT_FOUND',
246
+ 'SERVICE_ORDER_DEPOSIT_CHANGED',
247
+ // Delivery handover (`mode: 'status'` → `delivered`)
248
+ 'SERVICE_BILLING_PRODUCTS_UNAVAILABLE',
249
+ 'SERVICE_BILLING_PRODUCT_IN_BASKET',
250
+ 'SERVICE_DELIVERY_BASKET_DECISION_REQUIRED',
251
+ 'PRODUCT_NOT_AVAILABLE',
252
+ 'FX_CONVERSION_UNAVAILABLE',
253
+ 'TRANSACT_ITEMS_LIMIT_EXCEEDED',
254
+ // Parts
255
+ 'SERVICE_PARTS_RESTORE_EXCEEDS_CONSUMED',
256
+ 'SERVICE_PARTS_RESTORE_EXCEEDS_AMOUNT',
257
+ 'SERVICE_PARTS_STOCK_INSUFFICIENT',
258
+ 'SERVICE_PARTS_PRODUCT_NOT_FOUND',
259
+ 'SERVICE_PARTS_LEDGER_FULL',
260
+ 'SERVICE_PARTS_TOO_MANY',
261
+ 'SERVICE_ORDER_PARTS_CHANGED',
262
+ // Quotes
263
+ 'SERVICE_QUOTE_NOT_FOUND',
264
+ 'SERVICE_QUOTE_NOT_OFFERABLE',
265
+ 'SERVICE_QUOTE_HOLDS_TOO_MANY',
266
+ 'SERVICE_QUOTE_SUPERSEDED',
267
+ 'SERVICE_QUOTE_ALREADY_RESOLVED',
268
+ 'SERVICE_QUOTE_LAPSED',
269
+ 'SERVICE_QUOTE_CHANNEL_RESERVED',
270
+ 'SERVICE_QUOTE_CHANNEL_NOT_APPLICABLE',
271
+ 'SERVICE_QUOTE_REASON_NOT_APPLICABLE',
272
+ 'SERVICE_ORDER_QUOTE_CHANGED',
273
+ // Renotify
274
+ 'SERVICE_ORDER_NOT_READY',
275
+ 'SERVICE_RENOTIFY_IMPERSONATED',
276
+ 'SERVICE_RENOTIFY_TOO_SOON',
277
+ 'SERVICE_RENOTIFY_CONFLICT',
278
+ 'SERVICE_RENOTIFY_NOT_RECORDED',
279
+ 'SERVICE_RENOTIFY_LEDGER_UNREADABLE',
280
+ 'SERVICE_RENOTIFY_NOT_DISPATCHED',
281
+ // Technician timer
282
+ 'SERVICE_TIMER_ALREADY_RUNNING',
283
+ 'SERVICE_TIMER_NOT_RUNNING',
284
+ 'SERVICE_TIMER_STOP_CONFLICT',
285
+ 'TECHNICIAN_NOT_CLOCKED_IN',
286
+ 'SERVICE_ORDER_GONE',
287
+ // Work log
288
+ 'SERVICE_WORKLOG_NOT_FOUND',
289
+ 'SERVICE_WORKLOG_NOT_REVERSIBLE',
290
+ 'SERVICE_WORKLOG_ALREADY_REVERSED',
291
+ 'SERVICE_ORDER_WORKLOG_CHANGED',
292
+ ];
@@ -185,5 +185,39 @@ declare global {
185
185
  type NotificationQueueInput = Omit<NotificationInterface, 'notificationId' | 'createdAt' | 'TableName'> & {
186
186
  TableName: string;
187
187
  };
188
+ /**
189
+ * `GET /notifications` body on the operator host — the caller's own
190
+ * notifications, newest first, projected through an allow-list.
191
+ *
192
+ * ⚠️ There is no `hasMore` on this leg: the ABSENCE of `LastEvaluatedKey` is
193
+ * the end of the list. A client that waits for a `hasMore: false` never stops
194
+ * paging.
195
+ *
196
+ * ⚠️ `LastEvaluatedKey` carries `PK`/`SK`, and that is correct. The api's
197
+ * storage-key strip runs over `data` only, never over the envelope beside it;
198
+ * send `LastEvaluatedKey.SK` back as `?offSet=` to resume.
199
+ */
200
+ interface GetNotificationsResponse {
201
+ /** Absent — not `[]` — when the read returned no items at all. */
202
+ data?: NotificationInterface[];
203
+ LastEvaluatedKey?: {
204
+ PK: string;
205
+ SK: string;
206
+ };
207
+ }
208
+ /**
209
+ * `POST /notifications` mode `mark-all-read` body.
210
+ *
211
+ * ⚠️ `hasMore: true` means the sweep hit its batch or time budget, not that it
212
+ * failed — call again. `updatedCount: 0` WITH `hasMore: true` is legal and
213
+ * happens when the head of the partition was already read; it is progress, not
214
+ * a stall, because the next call resumes past it.
215
+ */
216
+ interface MarkAllNotificationsReadResponse {
217
+ data: {
218
+ updatedCount: number;
219
+ hasMore: boolean;
220
+ };
221
+ }
188
222
  }
189
223
  export {};
@@ -1042,6 +1042,36 @@ declare global {
1042
1042
  /** Unix ms the timer started — the sole input to the stopped entry's `hours`. */
1043
1043
  startedAt: number;
1044
1044
  }
1045
+ /**
1046
+ * The `409` body of `POST /services` `mode: 'status'` when the requested
1047
+ * status is not an edge of {@link SERVICE_TRANSITIONS} from where the order
1048
+ * is now.
1049
+ *
1050
+ * `allowed` is `SERVICE_TRANSITIONS[current]`, read at refusal time. Prefer it
1051
+ * to the published table when rebuilding the action menu after a refusal: it
1052
+ * is what the api enforced, on the row it actually read.
1053
+ */
1054
+ interface ServiceOrderIllegalTransitionRefusal {
1055
+ error: 'SERVICE_ORDER_ILLEGAL_TRANSITION';
1056
+ message: string;
1057
+ allowed: readonly ServiceStatus[];
1058
+ }
1059
+ /**
1060
+ * The `409` body of a refused CUSTODY move, with the custody states that ARE
1061
+ * reachable — `SERVICE_CUSTODY_TRANSITIONS[current]`.
1062
+ *
1063
+ * - `CUSTODY_ILLEGAL_TRANSITION` — `mode: 'edit'` sent a `custody` the
1064
+ * current one cannot move to.
1065
+ * - `SERVICE_ORDER_CUSTODY_NOT_RECEIVED` — `mode: 'status'` asked for
1066
+ * `delivered` or `abandoned_disposed`, which move the customer's property,
1067
+ * while the equipment was never received (`pending_receipt`). Receive it
1068
+ * first; the status itself was not the problem.
1069
+ */
1070
+ interface ServiceOrderCustodyRefusal {
1071
+ error: 'CUSTODY_ILLEGAL_TRANSITION' | 'SERVICE_ORDER_CUSTODY_NOT_RECEIVED';
1072
+ message: string;
1073
+ allowed: readonly ServiceCustody[];
1074
+ }
1045
1075
  }
1046
1076
  /**
1047
1077
  * The legal moves on a service order. Exhaustive over `ServiceStatus` by
@@ -1129,4 +1159,69 @@ export declare const SERVICE_CUSTODY_TRANSITIONS: Readonly<Record<ServiceCustody
1129
1159
  * validator built on the array silently 400s it.
1130
1160
  */
1131
1161
  export declare const SERVICE_CUSTODIES: [ServiceCustody, ...ServiceCustody[]];
1162
+ /**
1163
+ * How many photos one service order may carry in `pictures`, across BOTH
1164
+ * stages (`intake` and `delivery`) together. `POST /services` `mode: 'create'`
1165
+ * and `mode: 'edit'` refuse a longer array with `400 VALIDATION_FAILED`; the
1166
+ * same number bounds `removePictures` on `mode: 'edit'`.
1167
+ *
1168
+ * Lower than a product's 50 on purpose: a repair wants a handful of photos per
1169
+ * end of the job, not a catalogue, and the array rides the row on every read of
1170
+ * the board.
1171
+ *
1172
+ * The api validates against THIS constant, so it cannot drift from what a
1173
+ * client enforces while picking photos. Each entry's `base64` is bounded
1174
+ * separately by {@link MAX_IMAGE_BASE64_CHARS}.
1175
+ */
1176
+ export declare const MAX_SERVICE_PICTURES = 20;
1177
+ /**
1178
+ * `body.error` codes `/services` refuses with — every mode of `POST /services`
1179
+ * and every `GET /services` read (list, `?mode=unclaimed`, by id, `?mode=pdf`).
1180
+ * The api keeps this tuple complete against its handlers with a unit test, so a
1181
+ * code missing here is a defect, not a design choice.
1182
+ *
1183
+ * ⚠️ MATCH ON `body.error`, never on the status alone: most of these are `409`
1184
+ * or `400`, each with a different remedy. The families, and the members whose
1185
+ * remedy is not obvious from the name:
1186
+ *
1187
+ * - `*_CHANGED` · 409 — `SERVICE_ORDER_STATUS_CHANGED`, `_EDIT_CHANGED`,
1188
+ * `_DEPOSIT_CHANGED`, `_PARTS_CHANGED`, `_QUOTE_CHANGED`, `_WORKLOG_CHANGED`:
1189
+ * someone else wrote the ticket between your read and your write, and nothing
1190
+ * of yours was written. Refetch and let the operator retry against the new
1191
+ * state — the body that lost was built on the old one.
1192
+ * - `SERVICE_ORDER_ILLEGAL_TRANSITION` · 409 — the body is
1193
+ * {@link ServiceOrderIllegalTransitionRefusal}; its `allowed[]` is the menu to
1194
+ * offer instead.
1195
+ * - `CUSTODY_ILLEGAL_TRANSITION` / `SERVICE_ORDER_CUSTODY_NOT_RECEIVED` · 409 —
1196
+ * the body is {@link ServiceOrderCustodyRefusal}, with `allowed[]`.
1197
+ * - `SERVICE_ORDER_TERMINAL` · 409 — the ticket is in a
1198
+ * {@link SERVICE_TERMINAL_STATUSES} member and the mode only applies to an
1199
+ * open one. Not retryable.
1200
+ * - `SERVICE_DELIVERY_BASKET_DECISION_REQUIRED` · 400 — the `ready → delivered`
1201
+ * handover found goods in the customer's cart. Ask the operator whether they
1202
+ * are charged in this delivery and resend with the decision; nothing was
1203
+ * written.
1204
+ * - `SERVICE_RENOTIFY_*` — `mode: 'renotify'`. `_TOO_SOON` (429) carries
1205
+ * `lastNotifiedAt` and `retryAfterMs`; `_IMPERSONATED` (403) means a support
1206
+ * session cannot message the customer — the store must resend it itself;
1207
+ * `_NOT_RECORDED` (500) and `_NOT_DISPATCHED` (409) mean nothing was sent;
1208
+ * `_CONFLICT` (409) means re-read the order before sending again;
1209
+ * `_LEDGER_UNREADABLE` (409) is a damaged row — escalate, do not retry.
1210
+ * - `INVALID_IMAGE_REFERENCE` · 400 — a `pictures[]` / `removePictures[]`
1211
+ * entry the ticket cannot take: a url outside the store or not already on
1212
+ * this ticket, a resend that changes a stored photo's `stage`, or a
1213
+ * bytes-less entry on create. Nothing was written. `MISSING_STORE_CONTEXT`
1214
+ * (401) is the same guard refusing a session with no usable store.
1215
+ * - `WARRANTY_BELOW_LEGAL_MINIMUM` · 400 — an explicit `warrantyDays` above 0 and below 30
1216
+ * (Ley 24.240 art. 23 sets 30). `0` means "not stated" and is accepted. The
1217
+ * same refusal, from the same rule, is answered by `/service-templates`
1218
+ * create and edit.
1219
+ * - `VALIDATION_FAILED` · 400 — the body or query failed its schema.
1220
+ *
1221
+ * ⚠️ `ROLE_FORBIDDEN` here is the router's own role check (a print agent, or a
1222
+ * role no mode admits); the cross-cutting wrapper refusals are NOT repeated —
1223
+ * check `GATING_ERROR_CODES` in addition.
1224
+ */
1225
+ export declare const SERVICE_ORDER_ERROR_CODES: readonly ["ROLE_FORBIDDEN", "PARENT_FILTER_CONFLICT", "VALIDATION_FAILED", "INVALID_CURSOR", "INVALID_FROM_DATE", "INVALID_TO_DATE", "INVALID_DATE_RANGE", "REWORK_INDEX_UNAVAILABLE", "STORE_NOT_FOUND", "SERVICE_ORDER_NOT_FOUND", "CUSTOMER_NOT_FOUND", "PARENT_SERVICE_ORDER_NOT_FOUND", "SERVICE_TEMPLATE_NOT_FOUND", "SERVICE_TYPE_REQUIRED", "INVALID_IMAGE_REFERENCE", "MISSING_STORE_CONTEXT", "WARRANTY_BELOW_LEGAL_MINIMUM", "TECHNICIAN_NOT_FOUND", "TECHNICIAN_NOT_ELIGIBLE", "CUSTODY_ILLEGAL_TRANSITION", "SERVICE_ORDER_BILLABLE_FROZEN", "SERVICE_ORDER_EDIT_CHANGED", "SERVICE_ORDER_DISABLED_STATE_UNCHANGED", "SERVICE_ORDER_TERMINAL", "SERVICE_ORDER_DISABLED", "SERVICE_ORDER_ILLEGAL_TRANSITION", "SERVICE_ORDER_STATUS_CHANGED", "SERVICE_ORDER_OUTCOME_REQUIRED", "SERVICE_ORDER_OUTCOME_NOT_ALLOWED", "SERVICE_ORDER_CUSTODY_NOT_RECEIVED", "SERVICE_ORDER_BILLABLE_NOT_AT_THIS_TRANSITION", "PAYMENT_METHODS_NOT_CONFIGURED", "PAYMENT_METHOD_NOT_FOUND", "SERVICE_ORDER_DEPOSIT_CHANGED", "SERVICE_BILLING_PRODUCTS_UNAVAILABLE", "SERVICE_BILLING_PRODUCT_IN_BASKET", "SERVICE_DELIVERY_BASKET_DECISION_REQUIRED", "PRODUCT_NOT_AVAILABLE", "FX_CONVERSION_UNAVAILABLE", "TRANSACT_ITEMS_LIMIT_EXCEEDED", "SERVICE_PARTS_RESTORE_EXCEEDS_CONSUMED", "SERVICE_PARTS_RESTORE_EXCEEDS_AMOUNT", "SERVICE_PARTS_STOCK_INSUFFICIENT", "SERVICE_PARTS_PRODUCT_NOT_FOUND", "SERVICE_PARTS_LEDGER_FULL", "SERVICE_PARTS_TOO_MANY", "SERVICE_ORDER_PARTS_CHANGED", "SERVICE_QUOTE_NOT_FOUND", "SERVICE_QUOTE_NOT_OFFERABLE", "SERVICE_QUOTE_HOLDS_TOO_MANY", "SERVICE_QUOTE_SUPERSEDED", "SERVICE_QUOTE_ALREADY_RESOLVED", "SERVICE_QUOTE_LAPSED", "SERVICE_QUOTE_CHANNEL_RESERVED", "SERVICE_QUOTE_CHANNEL_NOT_APPLICABLE", "SERVICE_QUOTE_REASON_NOT_APPLICABLE", "SERVICE_ORDER_QUOTE_CHANGED", "SERVICE_ORDER_NOT_READY", "SERVICE_RENOTIFY_IMPERSONATED", "SERVICE_RENOTIFY_TOO_SOON", "SERVICE_RENOTIFY_CONFLICT", "SERVICE_RENOTIFY_NOT_RECORDED", "SERVICE_RENOTIFY_LEDGER_UNREADABLE", "SERVICE_RENOTIFY_NOT_DISPATCHED", "SERVICE_TIMER_ALREADY_RUNNING", "SERVICE_TIMER_NOT_RUNNING", "SERVICE_TIMER_STOP_CONFLICT", "TECHNICIAN_NOT_CLOCKED_IN", "SERVICE_ORDER_GONE", "SERVICE_WORKLOG_NOT_FOUND", "SERVICE_WORKLOG_NOT_REVERSIBLE", "SERVICE_WORKLOG_ALREADY_REVERSED", "SERVICE_ORDER_WORKLOG_CHANGED"];
1226
+ export type ServiceOrderErrorCode = (typeof SERVICE_ORDER_ERROR_CODES)[number];
1132
1227
  export {};
@@ -139,3 +139,151 @@ export const SERVICE_CUSTODY_TRANSITIONS = {
139
139
  * validator built on the array silently 400s it.
140
140
  */
141
141
  export const SERVICE_CUSTODIES = Object.keys(SERVICE_CUSTODY_TRANSITIONS);
142
+ /**
143
+ * How many photos one service order may carry in `pictures`, across BOTH
144
+ * stages (`intake` and `delivery`) together. `POST /services` `mode: 'create'`
145
+ * and `mode: 'edit'` refuse a longer array with `400 VALIDATION_FAILED`; the
146
+ * same number bounds `removePictures` on `mode: 'edit'`.
147
+ *
148
+ * Lower than a product's 50 on purpose: a repair wants a handful of photos per
149
+ * end of the job, not a catalogue, and the array rides the row on every read of
150
+ * the board.
151
+ *
152
+ * The api validates against THIS constant, so it cannot drift from what a
153
+ * client enforces while picking photos. Each entry's `base64` is bounded
154
+ * separately by {@link MAX_IMAGE_BASE64_CHARS}.
155
+ */
156
+ export const MAX_SERVICE_PICTURES = 20;
157
+ /**
158
+ * `body.error` codes `/services` refuses with — every mode of `POST /services`
159
+ * and every `GET /services` read (list, `?mode=unclaimed`, by id, `?mode=pdf`).
160
+ * The api keeps this tuple complete against its handlers with a unit test, so a
161
+ * code missing here is a defect, not a design choice.
162
+ *
163
+ * ⚠️ MATCH ON `body.error`, never on the status alone: most of these are `409`
164
+ * or `400`, each with a different remedy. The families, and the members whose
165
+ * remedy is not obvious from the name:
166
+ *
167
+ * - `*_CHANGED` · 409 — `SERVICE_ORDER_STATUS_CHANGED`, `_EDIT_CHANGED`,
168
+ * `_DEPOSIT_CHANGED`, `_PARTS_CHANGED`, `_QUOTE_CHANGED`, `_WORKLOG_CHANGED`:
169
+ * someone else wrote the ticket between your read and your write, and nothing
170
+ * of yours was written. Refetch and let the operator retry against the new
171
+ * state — the body that lost was built on the old one.
172
+ * - `SERVICE_ORDER_ILLEGAL_TRANSITION` · 409 — the body is
173
+ * {@link ServiceOrderIllegalTransitionRefusal}; its `allowed[]` is the menu to
174
+ * offer instead.
175
+ * - `CUSTODY_ILLEGAL_TRANSITION` / `SERVICE_ORDER_CUSTODY_NOT_RECEIVED` · 409 —
176
+ * the body is {@link ServiceOrderCustodyRefusal}, with `allowed[]`.
177
+ * - `SERVICE_ORDER_TERMINAL` · 409 — the ticket is in a
178
+ * {@link SERVICE_TERMINAL_STATUSES} member and the mode only applies to an
179
+ * open one. Not retryable.
180
+ * - `SERVICE_DELIVERY_BASKET_DECISION_REQUIRED` · 400 — the `ready → delivered`
181
+ * handover found goods in the customer's cart. Ask the operator whether they
182
+ * are charged in this delivery and resend with the decision; nothing was
183
+ * written.
184
+ * - `SERVICE_RENOTIFY_*` — `mode: 'renotify'`. `_TOO_SOON` (429) carries
185
+ * `lastNotifiedAt` and `retryAfterMs`; `_IMPERSONATED` (403) means a support
186
+ * session cannot message the customer — the store must resend it itself;
187
+ * `_NOT_RECORDED` (500) and `_NOT_DISPATCHED` (409) mean nothing was sent;
188
+ * `_CONFLICT` (409) means re-read the order before sending again;
189
+ * `_LEDGER_UNREADABLE` (409) is a damaged row — escalate, do not retry.
190
+ * - `INVALID_IMAGE_REFERENCE` · 400 — a `pictures[]` / `removePictures[]`
191
+ * entry the ticket cannot take: a url outside the store or not already on
192
+ * this ticket, a resend that changes a stored photo's `stage`, or a
193
+ * bytes-less entry on create. Nothing was written. `MISSING_STORE_CONTEXT`
194
+ * (401) is the same guard refusing a session with no usable store.
195
+ * - `WARRANTY_BELOW_LEGAL_MINIMUM` · 400 — an explicit `warrantyDays` above 0 and below 30
196
+ * (Ley 24.240 art. 23 sets 30). `0` means "not stated" and is accepted. The
197
+ * same refusal, from the same rule, is answered by `/service-templates`
198
+ * create and edit.
199
+ * - `VALIDATION_FAILED` · 400 — the body or query failed its schema.
200
+ *
201
+ * ⚠️ `ROLE_FORBIDDEN` here is the router's own role check (a print agent, or a
202
+ * role no mode admits); the cross-cutting wrapper refusals are NOT repeated —
203
+ * check `GATING_ERROR_CODES` in addition.
204
+ */
205
+ export const SERVICE_ORDER_ERROR_CODES = [
206
+ // Router and reads
207
+ 'ROLE_FORBIDDEN',
208
+ 'PARENT_FILTER_CONFLICT',
209
+ 'VALIDATION_FAILED',
210
+ 'INVALID_CURSOR',
211
+ 'INVALID_FROM_DATE',
212
+ 'INVALID_TO_DATE',
213
+ 'INVALID_DATE_RANGE',
214
+ 'REWORK_INDEX_UNAVAILABLE',
215
+ 'STORE_NOT_FOUND',
216
+ 'SERVICE_ORDER_NOT_FOUND',
217
+ // Intake and edit
218
+ 'CUSTOMER_NOT_FOUND',
219
+ 'PARENT_SERVICE_ORDER_NOT_FOUND',
220
+ 'SERVICE_TEMPLATE_NOT_FOUND',
221
+ 'SERVICE_TYPE_REQUIRED',
222
+ 'INVALID_IMAGE_REFERENCE',
223
+ 'MISSING_STORE_CONTEXT',
224
+ 'WARRANTY_BELOW_LEGAL_MINIMUM',
225
+ 'TECHNICIAN_NOT_FOUND',
226
+ 'TECHNICIAN_NOT_ELIGIBLE',
227
+ 'CUSTODY_ILLEGAL_TRANSITION',
228
+ 'SERVICE_ORDER_BILLABLE_FROZEN',
229
+ 'SERVICE_ORDER_EDIT_CHANGED',
230
+ 'SERVICE_ORDER_DISABLED_STATE_UNCHANGED',
231
+ // Lifecycle
232
+ 'SERVICE_ORDER_TERMINAL',
233
+ 'SERVICE_ORDER_DISABLED',
234
+ 'SERVICE_ORDER_ILLEGAL_TRANSITION',
235
+ 'SERVICE_ORDER_STATUS_CHANGED',
236
+ 'SERVICE_ORDER_OUTCOME_REQUIRED',
237
+ 'SERVICE_ORDER_OUTCOME_NOT_ALLOWED',
238
+ 'SERVICE_ORDER_CUSTODY_NOT_RECEIVED',
239
+ 'SERVICE_ORDER_BILLABLE_NOT_AT_THIS_TRANSITION',
240
+ // Deposit
241
+ 'PAYMENT_METHODS_NOT_CONFIGURED',
242
+ 'PAYMENT_METHOD_NOT_FOUND',
243
+ 'SERVICE_ORDER_DEPOSIT_CHANGED',
244
+ // Delivery handover (`mode: 'status'` → `delivered`)
245
+ 'SERVICE_BILLING_PRODUCTS_UNAVAILABLE',
246
+ 'SERVICE_BILLING_PRODUCT_IN_BASKET',
247
+ 'SERVICE_DELIVERY_BASKET_DECISION_REQUIRED',
248
+ 'PRODUCT_NOT_AVAILABLE',
249
+ 'FX_CONVERSION_UNAVAILABLE',
250
+ 'TRANSACT_ITEMS_LIMIT_EXCEEDED',
251
+ // Parts
252
+ 'SERVICE_PARTS_RESTORE_EXCEEDS_CONSUMED',
253
+ 'SERVICE_PARTS_RESTORE_EXCEEDS_AMOUNT',
254
+ 'SERVICE_PARTS_STOCK_INSUFFICIENT',
255
+ 'SERVICE_PARTS_PRODUCT_NOT_FOUND',
256
+ 'SERVICE_PARTS_LEDGER_FULL',
257
+ 'SERVICE_PARTS_TOO_MANY',
258
+ 'SERVICE_ORDER_PARTS_CHANGED',
259
+ // Quotes
260
+ 'SERVICE_QUOTE_NOT_FOUND',
261
+ 'SERVICE_QUOTE_NOT_OFFERABLE',
262
+ 'SERVICE_QUOTE_HOLDS_TOO_MANY',
263
+ 'SERVICE_QUOTE_SUPERSEDED',
264
+ 'SERVICE_QUOTE_ALREADY_RESOLVED',
265
+ 'SERVICE_QUOTE_LAPSED',
266
+ 'SERVICE_QUOTE_CHANNEL_RESERVED',
267
+ 'SERVICE_QUOTE_CHANNEL_NOT_APPLICABLE',
268
+ 'SERVICE_QUOTE_REASON_NOT_APPLICABLE',
269
+ 'SERVICE_ORDER_QUOTE_CHANGED',
270
+ // Renotify
271
+ 'SERVICE_ORDER_NOT_READY',
272
+ 'SERVICE_RENOTIFY_IMPERSONATED',
273
+ 'SERVICE_RENOTIFY_TOO_SOON',
274
+ 'SERVICE_RENOTIFY_CONFLICT',
275
+ 'SERVICE_RENOTIFY_NOT_RECORDED',
276
+ 'SERVICE_RENOTIFY_LEDGER_UNREADABLE',
277
+ 'SERVICE_RENOTIFY_NOT_DISPATCHED',
278
+ // Technician timer
279
+ 'SERVICE_TIMER_ALREADY_RUNNING',
280
+ 'SERVICE_TIMER_NOT_RUNNING',
281
+ 'SERVICE_TIMER_STOP_CONFLICT',
282
+ 'TECHNICIAN_NOT_CLOCKED_IN',
283
+ 'SERVICE_ORDER_GONE',
284
+ // Work log
285
+ 'SERVICE_WORKLOG_NOT_FOUND',
286
+ 'SERVICE_WORKLOG_NOT_REVERSIBLE',
287
+ 'SERVICE_WORKLOG_ALREADY_REVERSED',
288
+ 'SERVICE_ORDER_WORKLOG_CHANGED',
289
+ ];
package/dist/user.d.ts CHANGED
@@ -44,6 +44,28 @@ declare global {
44
44
  * picker leaves out a print-agent account.
45
45
  */
46
46
  type UserDirectoryEntry = Pick<User, Exclude<UserDirectoryKey, 'fullName'>> & Partial<Pick<User, 'fullName'>>;
47
+ /**
48
+ * One staff row as `GET /users` returns it in full — the ADMIN-TIER answer
49
+ * (ADMIN, SUPERVISOR, MANAGER), plus the caller's OWN row at any tier.
50
+ *
51
+ * ⚠️ A below-admin caller receives THIS shape for its own row only; every
52
+ * colleague arrives as a {@link UserDirectoryEntry}. One response to such a
53
+ * caller is therefore a MIX of the two shapes, told apart by `userId`. Type
54
+ * the array as `(PublicUserRow | UserDirectoryEntry)[]` unless the caller is
55
+ * known to be admin tier.
56
+ *
57
+ * The read path drops the legacy singular `role` write-alias, the write-side
58
+ * `search` index and the `login` brute-force counters; `accessToken` is minted
59
+ * per auth response and never stored, so it does not reach this read either.
60
+ * `storeId` and `userId` are re-attached by the handler, so both are present
61
+ * on every row.
62
+ *
63
+ * ⚠️ `totp` SURVIVES, reduced to {@link UserTotp} — it is not omitted. A
64
+ * consumer that models the row as `Omit<User, 'totp'>` throws away the only
65
+ * signal that 2FA is enrolled. Unlike an auth body's `AuthUserTotp`, it
66
+ * carries no `recoveryCodesRemaining`.
67
+ */
68
+ type PublicUserRow = Omit<User, 'accessToken' | 'search' | 'login' | 'photoData' | 'removePhotoURL' | 'warnings'>;
47
69
  /**
48
70
  * Write shape for user create/update — carries the transient photo controls
49
71
  * and the plaintext password.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.408",
3
+ "version": "1.10.409",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",