platform-types 1.10.716 → 1.10.718

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
@@ -326,6 +326,8 @@ declare global {
326
326
  accessToken: string;
327
327
  /** Transport-conditional exactly as `AuthUser.refreshToken` — absent on the default cookie path. */
328
328
  refreshToken?: string;
329
+ /** As `AuthUser.effectiveCapabilities` — the gate's own answer for the session just issued. */
330
+ effectiveCapabilities: UserCapability[];
329
331
  }
330
332
  /**
331
333
  * One row of `GET /auth?mode=sessions` — a storefront customer's own
package/dist/cash.d.ts CHANGED
@@ -468,7 +468,11 @@ declare global {
468
468
  }
469
469
  /**
470
470
  * Refusals from the cash-shift surface — `stacks/lambdas/shifts/*.ts`
471
- * (`_get`, `_post`, `_patchClose`, `_postMovement`, `_patchReconcile`).
471
+ * (`_get`, `_post`, `_patchClose`, `_postMovement`, `_patchReconcile`) — plus
472
+ * the shared drawer write's own `CASH_DRAWER_BUSY`, which `POST /cash`,
473
+ * `POST`/`DELETE /account` and a cash return answer. A tender or seña does
474
+ * not: a tender's drawer collision is `SHIFT_NOT_OPEN` or `422 CURRENCY_MISMATCH`,
475
+ * a seña's `SHIFT_NOT_OPEN` or `409 DEPOSIT_CURRENCY_MISMATCH`.
472
476
  *
473
477
  * - `INVALID_SHIFT_ID` · 400 · `SHIFT_NOT_FOUND` · 404
474
478
  * - `SHIFT_ALREADY_OPEN` · 409 — one open shift per cashier.
@@ -489,15 +493,24 @@ declare global {
489
493
  * - `SHIFT_EVENTS_TRUNCATED` · 503 — the event log could not be read in full, so
490
494
  * the totals behind a close or a reconcile would be computed from a partial
491
495
  * ledger.
496
+ * - `CASH_DRAWER_BUSY` · 409 — emitted by the shared drawer write
497
+ * (`drawerWriteRefusal`, `stacks/services/shifts.ts`), not by a `/shifts`
498
+ * route: `POST /account` and `POST /cash` answer it when their transaction is
499
+ * cancelled by a pure conflict on any item it writes (most often the drawer
500
+ * row), as do `DELETE /account` and `POST /orders { mode: 'return' }` on a
501
+ * cash leg. Nothing was written; retry the same request.
492
502
  * - `SELF_APPROVAL_FORBIDDEN` · 403 — segregation of duties: the cashier who
493
503
  * closed a shift cannot reconcile it.
494
504
  * - `INVALID_DENOMINATION` · 400 · `INVALID_CURSOR` · 400
505
+ * - `WAREHOUSE_NOT_FOUND` · 404 — `GET /shifts?warehouseId=` naming a depósito
506
+ * the store does not have (`resolveReportWarehouseFilter`).
495
507
  * - `ROLE_FORBIDDEN` · 403 · `VALIDATION_FAILED` · 400
496
508
  *
497
509
  * ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
498
- * as well.
510
+ * as well, and `TERMINAL_ELEVATION_ERROR_CODES` for a money-out movement's PIN
511
+ * elevation.
499
512
  */
500
- export declare const SHIFT_ERROR_CODES: readonly ["INVALID_SHIFT_ID", "SHIFT_NOT_FOUND", "SHIFT_ALREADY_OPEN", "SHIFT_NOT_OPEN", "SHIFT_NOT_CLOSED", "SHIFT_OWNER_MISMATCH", "CURRENCY_MISMATCH", "BUCKET_COUNTS_INVALID", "BUCKET_REVIEW_INVALID", "BUCKET_COUNT_MISSING", "SHIFT_CHANGED", "SHIFT_EVENTS_TRUNCATED", "SELF_APPROVAL_FORBIDDEN", "INVALID_DENOMINATION", "INVALID_CURSOR", "ROLE_FORBIDDEN", "VALIDATION_FAILED"];
513
+ export declare const SHIFT_ERROR_CODES: readonly ["INVALID_SHIFT_ID", "SHIFT_NOT_FOUND", "SHIFT_ALREADY_OPEN", "SHIFT_NOT_OPEN", "SHIFT_NOT_CLOSED", "SHIFT_OWNER_MISMATCH", "CURRENCY_MISMATCH", "BUCKET_COUNTS_INVALID", "BUCKET_REVIEW_INVALID", "BUCKET_COUNT_MISSING", "SHIFT_CHANGED", "SHIFT_EVENTS_TRUNCATED", "CASH_DRAWER_BUSY", "SELF_APPROVAL_FORBIDDEN", "INVALID_DENOMINATION", "INVALID_CURSOR", "WAREHOUSE_NOT_FOUND", "ROLE_FORBIDDEN", "VALIDATION_FAILED"];
501
514
  export type ShiftErrorCode = (typeof SHIFT_ERROR_CODES)[number];
502
515
  /**
503
516
  * Where a {@link ShiftMethodTotal}'s `label` came from.
package/dist/cash.js CHANGED
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * Refusals from the cash-shift surface — `stacks/lambdas/shifts/*.ts`
3
- * (`_get`, `_post`, `_patchClose`, `_postMovement`, `_patchReconcile`).
3
+ * (`_get`, `_post`, `_patchClose`, `_postMovement`, `_patchReconcile`) — plus
4
+ * the shared drawer write's own `CASH_DRAWER_BUSY`, which `POST /cash`,
5
+ * `POST`/`DELETE /account` and a cash return answer. A tender or seña does
6
+ * not: a tender's drawer collision is `SHIFT_NOT_OPEN` or `422 CURRENCY_MISMATCH`,
7
+ * a seña's `SHIFT_NOT_OPEN` or `409 DEPOSIT_CURRENCY_MISMATCH`.
4
8
  *
5
9
  * - `INVALID_SHIFT_ID` · 400 · `SHIFT_NOT_FOUND` · 404
6
10
  * - `SHIFT_ALREADY_OPEN` · 409 — one open shift per cashier.
@@ -21,13 +25,22 @@
21
25
  * - `SHIFT_EVENTS_TRUNCATED` · 503 — the event log could not be read in full, so
22
26
  * the totals behind a close or a reconcile would be computed from a partial
23
27
  * ledger.
28
+ * - `CASH_DRAWER_BUSY` · 409 — emitted by the shared drawer write
29
+ * (`drawerWriteRefusal`, `stacks/services/shifts.ts`), not by a `/shifts`
30
+ * route: `POST /account` and `POST /cash` answer it when their transaction is
31
+ * cancelled by a pure conflict on any item it writes (most often the drawer
32
+ * row), as do `DELETE /account` and `POST /orders { mode: 'return' }` on a
33
+ * cash leg. Nothing was written; retry the same request.
24
34
  * - `SELF_APPROVAL_FORBIDDEN` · 403 — segregation of duties: the cashier who
25
35
  * closed a shift cannot reconcile it.
26
36
  * - `INVALID_DENOMINATION` · 400 · `INVALID_CURSOR` · 400
37
+ * - `WAREHOUSE_NOT_FOUND` · 404 — `GET /shifts?warehouseId=` naming a depósito
38
+ * the store does not have (`resolveReportWarehouseFilter`).
27
39
  * - `ROLE_FORBIDDEN` · 403 · `VALIDATION_FAILED` · 400
28
40
  *
29
41
  * ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
30
- * as well.
42
+ * as well, and `TERMINAL_ELEVATION_ERROR_CODES` for a money-out movement's PIN
43
+ * elevation.
31
44
  */
32
45
  export const SHIFT_ERROR_CODES = [
33
46
  'INVALID_SHIFT_ID',
@@ -42,9 +55,11 @@ export const SHIFT_ERROR_CODES = [
42
55
  'BUCKET_COUNT_MISSING',
43
56
  'SHIFT_CHANGED',
44
57
  'SHIFT_EVENTS_TRUNCATED',
58
+ 'CASH_DRAWER_BUSY',
45
59
  'SELF_APPROVAL_FORBIDDEN',
46
60
  'INVALID_DENOMINATION',
47
61
  'INVALID_CURSOR',
62
+ 'WAREHOUSE_NOT_FOUND',
48
63
  'ROLE_FORBIDDEN',
49
64
  'VALIDATION_FAILED',
50
65
  ];
package/dist/cjs/cash.js CHANGED
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.METHOD_LABEL_SOURCES = exports.SHIFT_ERROR_CODES = void 0;
4
4
  /**
5
5
  * Refusals from the cash-shift surface — `stacks/lambdas/shifts/*.ts`
6
- * (`_get`, `_post`, `_patchClose`, `_postMovement`, `_patchReconcile`).
6
+ * (`_get`, `_post`, `_patchClose`, `_postMovement`, `_patchReconcile`) — plus
7
+ * the shared drawer write's own `CASH_DRAWER_BUSY`, which `POST /cash`,
8
+ * `POST`/`DELETE /account` and a cash return answer. A tender or seña does
9
+ * not: a tender's drawer collision is `SHIFT_NOT_OPEN` or `422 CURRENCY_MISMATCH`,
10
+ * a seña's `SHIFT_NOT_OPEN` or `409 DEPOSIT_CURRENCY_MISMATCH`.
7
11
  *
8
12
  * - `INVALID_SHIFT_ID` · 400 · `SHIFT_NOT_FOUND` · 404
9
13
  * - `SHIFT_ALREADY_OPEN` · 409 — one open shift per cashier.
@@ -24,13 +28,22 @@ exports.METHOD_LABEL_SOURCES = exports.SHIFT_ERROR_CODES = void 0;
24
28
  * - `SHIFT_EVENTS_TRUNCATED` · 503 — the event log could not be read in full, so
25
29
  * the totals behind a close or a reconcile would be computed from a partial
26
30
  * ledger.
31
+ * - `CASH_DRAWER_BUSY` · 409 — emitted by the shared drawer write
32
+ * (`drawerWriteRefusal`, `stacks/services/shifts.ts`), not by a `/shifts`
33
+ * route: `POST /account` and `POST /cash` answer it when their transaction is
34
+ * cancelled by a pure conflict on any item it writes (most often the drawer
35
+ * row), as do `DELETE /account` and `POST /orders { mode: 'return' }` on a
36
+ * cash leg. Nothing was written; retry the same request.
27
37
  * - `SELF_APPROVAL_FORBIDDEN` · 403 — segregation of duties: the cashier who
28
38
  * closed a shift cannot reconcile it.
29
39
  * - `INVALID_DENOMINATION` · 400 · `INVALID_CURSOR` · 400
40
+ * - `WAREHOUSE_NOT_FOUND` · 404 — `GET /shifts?warehouseId=` naming a depósito
41
+ * the store does not have (`resolveReportWarehouseFilter`).
30
42
  * - `ROLE_FORBIDDEN` · 403 · `VALIDATION_FAILED` · 400
31
43
  *
32
44
  * ⚠️ Cross-cutting refusals are NOT repeated here — check `GATING_ERROR_CODES`
33
- * as well.
45
+ * as well, and `TERMINAL_ELEVATION_ERROR_CODES` for a money-out movement's PIN
46
+ * elevation.
34
47
  */
35
48
  exports.SHIFT_ERROR_CODES = [
36
49
  'INVALID_SHIFT_ID',
@@ -45,9 +58,11 @@ exports.SHIFT_ERROR_CODES = [
45
58
  'BUCKET_COUNT_MISSING',
46
59
  'SHIFT_CHANGED',
47
60
  'SHIFT_EVENTS_TRUNCATED',
61
+ 'CASH_DRAWER_BUSY',
48
62
  'SELF_APPROVAL_FORBIDDEN',
49
63
  'INVALID_DENOMINATION',
50
64
  'INVALID_CURSOR',
65
+ 'WAREHOUSE_NOT_FOUND',
51
66
  'ROLE_FORBIDDEN',
52
67
  'VALIDATION_FAILED',
53
68
  ];
package/dist/order.d.ts CHANGED
@@ -1867,6 +1867,39 @@ declare global {
1867
1867
  */
1868
1868
  cancellation?: OrderCancellability;
1869
1869
  }
1870
+ /**
1871
+ * `POST /orders { mode: 'tender' }` — ring one or more tender legs against an
1872
+ * EXISTING order (the append counterpart of the create leg's
1873
+ * {@link CreateOrderRequest.tenders}). Any operator but PRINTER or ACCOUNTANT
1874
+ * (`403 ROLE_FORBIDDEN`).
1875
+ *
1876
+ * `shiftId` attributes the legs to a drawer. An EXPLICIT value must be the
1877
+ * caller's own OPEN shift — anything else is `409 SHIFT_NOT_AVAILABLE`, never
1878
+ * a silent drop. OMITTED resolves the caller's own open drawer; with none, a
1879
+ * cash leg lands on the store's default drawer. At commit the drawer is
1880
+ * re-asserted: one that closed mid-request is `409 SHIFT_NOT_OPEN`, one that
1881
+ * did not declare the order's currency `422 CURRENCY_MISMATCH`.
1882
+ *
1883
+ * The opt-in `Idempotency-Key` and the lost-reply recovery through
1884
+ * `mode: 'collection-attempt'` follow the money-write rule documented on
1885
+ * {@link ORDER_ERROR_CODES} (and {@link OrderCollectionAttemptLookupRequest});
1886
+ * it is not restated here. Every refusal specific to this mode is in that
1887
+ * tuple; a body the schema rejects is `400 VALIDATION_FAILED`, and the
1888
+ * cross-cutting refusals (`ROLE_FORBIDDEN`, `IMPERSONATION_READONLY`, …) are
1889
+ * in `GATING_ERROR_CODES`.
1890
+ *
1891
+ * Tied to its validator (`tenderModeSchema`, `stacks/lambdas/orders/_tender.ts`)
1892
+ * by `AssertOrderTenderRequestMatchesSchema` — `mode` is the router's key.
1893
+ */
1894
+ interface OrderTenderRequest {
1895
+ mode: 'tender';
1896
+ /** `ORD` followed by 6–10 digits. */
1897
+ orderId: string;
1898
+ /** RAW legs — see {@link TenderLegInput}. */
1899
+ tenders: TenderLegInput[];
1900
+ /** 1–100 chars; the caller's own OPEN shift. Omit to use the caller's open drawer. */
1901
+ shiftId?: string;
1902
+ }
1870
1903
  /**
1871
1904
  * `POST /orders { mode: 'deposit' }` — record a SEÑA (a sales deposit) on an
1872
1905
  * existing, undelivered order, as one {@link OrderTender} leg carrying
@@ -1925,7 +1958,7 @@ declare global {
1925
1958
  change?: number;
1926
1959
  /** Required, never defaulted. `true` needs an authorized factura on the order first. */
1927
1960
  freezesPrice: boolean;
1928
- /** Same semantics as `mode: 'tender'`'s. */
1961
+ /** Same semantics as {@link OrderTenderRequest.shiftId}. */
1929
1962
  shiftId?: string;
1930
1963
  }
1931
1964
  /**
package/dist/user.d.ts CHANGED
@@ -66,8 +66,16 @@ declare global {
66
66
  * consumer that models the row as `Omit<User, 'totp'>` throws away the only
67
67
  * signal that 2FA is enrolled. Unlike an auth body's `AuthUserTotp`, it
68
68
  * carries no `recoveryCodesRemaining`.
69
+ *
70
+ * `effectiveCapabilities` is present on the caller's OWN row only — the same
71
+ * answer as {@link AuthUser.effectiveCapabilities}, resolved from this
72
+ * request's token roles — and absent on every colleague's row, on the
73
+ * `POST /users` echo and on the `users` socket frame. A client keeps the list
74
+ * from its auth body or its own row here; a frame that omits it changes nothing.
69
75
  */
70
- type PublicUserRow = Omit<User, 'accessToken' | 'search' | 'login' | 'photoData' | 'removePhotoURL' | 'warnings'>;
76
+ type PublicUserRow = Omit<User, 'accessToken' | 'search' | 'login' | 'photoData' | 'removePhotoURL' | 'warnings'> & {
77
+ effectiveCapabilities?: UserCapability[];
78
+ };
71
79
  /**
72
80
  * Write shape for user create/update — carries the transient photo controls
73
81
  * and the plaintext password.
@@ -345,7 +353,31 @@ declare global {
345
353
  * Absent/false means no, for a plain USER only.
346
354
  */
347
355
  percepciones?: boolean;
356
+ /**
357
+ * May issue a nota de crédito — `POST /invoices` with `cbte_numero`, and
358
+ * the retry of a return's credit note (`POST /orders {mode:'return-credit-note'}`).
359
+ *
360
+ * ⚠️ **Role-implied** (ADMIN, SUPERVISOR, MANAGER hold it without the flag),
361
+ * for the reason `percepciones` gives: every elevated operator already issues
362
+ * NCs, and the granted class would withdraw that on deploy. A plain USER needs
363
+ * `creditNote: true` on their STORED row together with the server-stamped
364
+ * grant marker an admin's `POST /users` writes when it turns the flag on; a
365
+ * flag stored without that marker grants nothing, and nothing in a request
366
+ * grants it.
367
+ * Routine factura issuance is NOT gated by it.
368
+ *
369
+ * A client never derives this from `roles` — it reads
370
+ * `AuthUser.effectiveCapabilities`. Absent/false means no, for a plain USER only.
371
+ */
372
+ creditNote?: boolean;
348
373
  };
374
+ /**
375
+ * A key the server's capability gate decides — every `UserPermissions` key
376
+ * but the reserved, unread `accountant`. A refusal names one in
377
+ * `403 CAPABILITY_REQUIRED`'s `data.capability`, and
378
+ * `AuthUser.effectiveCapabilities` lists the ones a session holds.
379
+ */
380
+ type UserCapability = Exclude<keyof UserPermissions, 'accountant'>;
349
381
  /**
350
382
  * Wire error codes for the paths that create or update a USER row:
351
383
  * `POST /users` (create AND update — one handler serves both) and
@@ -389,6 +421,24 @@ declare global {
389
421
  * absent `totp` means the user never enrolled.
390
422
  */
391
423
  totp?: AuthUserTotp;
424
+ /**
425
+ * The capabilities this session holds, resolved by the SAME server function
426
+ * that gates each request (`@helpers/capabilityGate`), from the minted
427
+ * token's roles and the stored `permissions`. Clients read it —
428
+ * `effectiveCapabilities.includes('creditNote')` — and never compute it
429
+ * from `roles`, so the role-implied/granted split stays a server decision.
430
+ *
431
+ * ⚠️ A snapshot at token issue: a grant changed afterwards is enforced on
432
+ * the next request at once, but shows here only on the next refresh. A
433
+ * `403 CAPABILITY_REQUIRED` is the authoritative answer.
434
+ *
435
+ * PRINTER and ACCOUNTANT claims carry `[]`: neither is an operator acting on
436
+ * the store's authority, and the credit-note routes (`POST /invoices` with
437
+ * `cbte_numero`, the return credit-note retry) refuse them by role before
438
+ * consulting it. Not every capability-gated route does: `POST /cash` reads a
439
+ * PRINTER's stored flag.
440
+ */
441
+ effectiveCapabilities: UserCapability[];
392
442
  /**
393
443
  * ⚠️ Delivered in the body ONLY under the body refresh transport — the
394
444
  * native-mobile opt-in. The DEFAULT is cookie transport, where the token
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.716",
3
+ "version": "1.10.718",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",