sinfactura-types 1.10.291 → 1.10.293

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/account.d.ts CHANGED
@@ -92,6 +92,23 @@ declare global {
92
92
  * id it was written under, so do not read it as a live pointer.
93
93
  */
94
94
  method?: number;
95
+ /**
96
+ * ⚠️ TWO meanings, on two different KINDS of row. They are not the same
97
+ * number and a consumer that reads them as one will type a checkpoint as
98
+ * a movement:
99
+ *
100
+ * - On a STORED `BALANCE-{customerId}-{date}` checkpoint this is the
101
+ * LEGACY pre-map scalar. No current writer emits it — both emit the
102
+ * per-currency map instead ({@link AccountBalanceCheckpoint}) — and
103
+ * `getLastBalanceByCustomerId` falls back to it ONLY when `balances` is
104
+ * absent, i.e. on a row written before the map existed.
105
+ * - On the WIRE this is the amount of the server-synthesised "Saldo
106
+ * anterior" opening row ({@link AccountStatementOpeningRow}), computed
107
+ * per request from the checkpoint plus the movements after it. That row
108
+ * is never stored, so its `balance` is not the legacy field coming back.
109
+ *
110
+ * An ordinary movement row carries NEITHER: its money is `debit`/`credit`.
111
+ */
95
112
  balance?: number;
96
113
  userId?: string;
97
114
  deleted?: boolean;
@@ -104,5 +121,88 @@ declare global {
104
121
  paymentRefSource?: PaymentReceivedSource;
105
122
  paymentRefId?: string;
106
123
  }
124
+ /**
125
+ * The STORED carried-forward checkpoint row, at `PK: ACCOUNT#{storeId}` /
126
+ * `SK: BALANCE-{customerId}-{date}`. It shares a partition with the movement
127
+ * rows above and is deliberately NOT an {@link Account}: every money field
128
+ * differs, and the two are told apart by the `BALANCE-` sort-key prefix.
129
+ *
130
+ * Written by exactly two producers — the operator and storefront
131
+ * `GET /account` twins — when a customer statement crosses
132
+ * `AUTO_BALANCE_SNAPSHOT_THRESHOLD` un-checkpointed rows, under
133
+ * `attribute_not_exists(PK)` so the loser of a concurrent pair no-ops. Read
134
+ * back by `getLastBalanceByCustomerId`, which trusts it verbatim — which is
135
+ * why a TRUNCATED recompute is never persisted as one.
136
+ */
137
+ interface AccountBalanceCheckpoint {
138
+ /**
139
+ * `` `BALANCE-${customerId}` `` — the synthetic `PK-customerId` index
140
+ * marker, NOT a real customer id and never matchable against a live
141
+ * SOCKET row. The movement rows in the same partition use
142
+ * `` `${customerId}#${createdAt}` `` instead ({@link Account.customerId}).
143
+ */
144
+ customerId: string;
145
+ /** `buenosAiresMidnightUtcMs(dated)` — the bound the next ledger walk starts from. */
146
+ createdAt: number;
147
+ /** The checkpoint's own day, `20260123`. */
148
+ dated: number;
149
+ /**
150
+ * Balance carried forward PER CURRENCY, keyed by catalogId (`'ars'`), each
151
+ * already rounded to 2 decimals. The `''` key is the "ledger default"
152
+ * bucket — rows that carried no `currency` of their own — which the
153
+ * reader resolves against `store.config.displayCurrency`.
154
+ *
155
+ * This map, not a scalar, is what both writers persist. The scalar
156
+ * {@link Account.balance} is the legacy shape the tolerant reader still
157
+ * accepts on rows written before the map existed.
158
+ */
159
+ balances: Record<string, number>;
160
+ /** Always `'Balance automatico'` — these rows are only ever server-minted. */
161
+ description: string;
162
+ }
163
+ /**
164
+ * Every way a caller can ask `GET /account` for a window it will not read.
165
+ *
166
+ * Published rather than kept beside `resolveAccountDateRange` because it
167
+ * REACHES THE WIRE — both `GET /account` twins return it as the `error` of a
168
+ * 400 — and a closed vocabulary the FEs must branch on is exactly the shape
169
+ * that cannot live under `stacks/`: from there their only options are to
170
+ * hand-copy it (and rot the day a member is added) or type it `string` and
171
+ * discard the exhaustiveness.
172
+ *
173
+ * ⚠️ Refusal ORDER is part of the contract, so a caller with two mistakes
174
+ * gets the stable one: structure (`DATE_AND_RANGE_EXCLUSIVE`,
175
+ * `DATE_RANGE_INCOMPLETE`) before format (`DATE_MALFORMED`) before semantics
176
+ * (`DATE_RANGE_INVERTED`, `DATE_RANGE_TOO_WIDE`).
177
+ *
178
+ * ⚠️ The storefront twin can only ever return `DATE_MALFORMED`: it reads no
179
+ * `from`/`to`, having no store-wide branch to window.
180
+ */
181
+ type AccountDateRangeError = 'DATE_AND_RANGE_EXCLUSIVE' | 'DATE_RANGE_INCOMPLETE' | 'DATE_MALFORMED' | 'DATE_RANGE_INVERTED' | 'DATE_RANGE_TOO_WIDE';
182
+ /**
183
+ * The server-SYNTHESISED "Saldo anterior" row both `GET /account` twins put
184
+ * at the head of a customer statement. One per currency present in the
185
+ * history; **never stored**, so it carries no `SK` and no real `accountId`.
186
+ *
187
+ * It is the reason {@link Account.balance} still exists on the wire after the
188
+ * stored checkpoint moved to a per-currency map.
189
+ */
190
+ interface AccountStatementOpeningRow {
191
+ /** `'ACC000001'` for the first, `` `ACC000001-${currency}` `` after that — a display id, not a key. */
192
+ accountId: string;
193
+ /** A fixed sentinel that sorts the row before every real movement. */
194
+ createdAt: number;
195
+ /**
196
+ * The LEDGER denomination (`store.config.displayCurrency`), never a
197
+ * movement row's own `currency`. OMITTED rather than guessed when the
198
+ * store read failed — a wrong denomination is worse than an absent one.
199
+ */
200
+ currency?: string;
201
+ /** The requested checkpoint day, as a NUMBER like every real row. */
202
+ dated: number;
203
+ details: string;
204
+ /** The carried-forward amount for this row's currency, rounded to 2 decimals. */
205
+ balance: number;
206
+ }
107
207
  }
108
208
  export {};
@@ -419,6 +419,16 @@ export interface PlatformOverrideRosterEntry {
419
419
  * override on that store carries an expiry.
420
420
  */
421
421
  earliestExpiresAt?: number;
422
+ /**
423
+ * Keys this store holds an override row under that the api no longer
424
+ * declares. Each is a valid `DELETE …/overrides/{featureKey}` target and
425
+ * nothing else — the resolver drops such a row, so it neither grants nor
426
+ * refuses anything.
427
+ *
428
+ * ⚠️ Absent — not `[]` — on a clean store AND on any roster row built before
429
+ * this field existed. Treat absent as "not measured", never as "none".
430
+ */
431
+ orphanKeys?: string[];
422
432
  }
423
433
  /**
424
434
  * Roster response. Built by a scheduled scan into a single `PLATFORM#OVERRIDES`
@@ -544,11 +544,48 @@ declare global {
544
544
  */
545
545
  missingProviderIds: string[];
546
546
  }
547
+ /** One store holding at least one `OVERRIDE#` row under a key the api no longer declares. */
548
+ interface OrphanOverrideStore {
549
+ storeId: string;
550
+ /** The undeclared keys, exactly as stored — each one is a valid `DELETE …/overrides/{featureKey}` target. */
551
+ keys: string[];
552
+ }
553
+ /**
554
+ * Per-store entitlement overrides written under a key that has since left the
555
+ * api's feature-key tuple.
556
+ *
557
+ * Such a row grants nothing and refuses nothing — the resolver drops it on
558
+ * every read — but it is still stored and still shown to the operator, so it
559
+ * is catalogue state awaiting cleanup rather than an entitlement.
560
+ *
561
+ * ⚠️ **The answer is as old as `rosterBuiltAt`, and that field is the whole
562
+ * point of its being present.** Finding these needs a full-table sweep of every
563
+ * per-tenant `SUBSCRIPTION#{storeId}` partition, which the drift report cannot
564
+ * do inside a request — it reads the roster the override-digest scan publishes.
565
+ * `rosterBuiltAt: null` means that scan has never completed on this stage, so
566
+ * an empty `stores` says NOTHING about whether orphans exist.
567
+ */
568
+ interface OrphanOverrideDrift {
569
+ /** Unix ms the roster this answer came from was built; `null` when no roster row exists yet. */
570
+ rosterBuiltAt: number | null;
571
+ stores: OrphanOverrideStore[];
572
+ /** Every distinct undeclared key across `stores`, sorted — the catalogue-level view of the same data. */
573
+ keys: string[];
574
+ }
547
575
  /** `data` shape of `report-plan-catalog-drift` — 200 when clean, 409 (`PLAN_CATALOG_DRIFT`) when `drift` is `true`. */
548
576
  interface PlanCatalogDriftReport {
549
- /** True when ANY tier lacks a template row, or a paid one is missing a provider identifier. */
577
+ /**
578
+ * True when ANY tier lacks a template row, a paid one is missing a provider
579
+ * identifier, or any store holds an override under an undeclared key.
580
+ *
581
+ * ⚠️ An UNBUILT roster (`orphanOverrides.rosterBuiltAt === null`) does not
582
+ * flip this. A stage whose scan has never completed would otherwise answer
583
+ * 409 forever over a question nobody has asked yet, which is the shape that
584
+ * gets a report ignored; the `null` is the tell.
585
+ */
550
586
  drift: boolean;
551
587
  tiers: TierCatalogDrift[];
588
+ orphanOverrides: OrphanOverrideDrift;
552
589
  }
553
590
  }
554
591
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.291",
3
+ "version": "1.10.293",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",