platform-types 1.10.716 → 1.10.717

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/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.717",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",