sinfactura-types 1.10.439 → 1.10.441

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.
@@ -88,19 +88,12 @@ exports.WEBHOOK_DELIVERY_LOG_RETENTION_DAYS = 30;
88
88
  /**
89
89
  * Where an `order.created` event was minted.
90
90
  *
91
- * ⚠️ A CLOSED union, and rule 1 above applies to it with full force: a fifth
92
- * order-minting path cannot be added here without breaking every subscriber
93
- * that switches exhaustively — it mints `order.created.v2` instead. The four
94
- * members are the paths that EMIT — which is no longer the same thing as the
95
- * paths that WRITE an ORDER row.
96
- *
97
- * ⚠️ Converting an approved presupuesto (`convertPresupuestoToOrder`) mints an
98
- * ordinary order through the same `createOrder` every member above uses, and
99
- * emits nothing here — precisely BECAUSE adding a fifth member is the breaking
100
- * change the paragraph above forbids. The gap is known and deliberate, not an
101
- * oversight to be tidied: do not close it by quietly widening this tuple. The
102
- * rest of that path's fan-out (stock webhooks, notifications, the ML push) does
103
- * run; it is only this event that waits on the v2 decision.
91
+ * ⚠️ A CLOSED union: adding a source member breaks exhaustive subscribers and
92
+ * requires `order.created.v2` under rule 1. A new emit seam need not be a new
93
+ * source: `pos` means a counter sale, from `POST /orders` or a converted
94
+ * presupuesto. `presupuestoId` discriminates quote origin on the latter.
95
+ * Only POS, storefront and quote conversion use the shared `createOrder`;
96
+ * service delivery and MercadoLibre mint their rows through other calls.
104
97
  *
105
98
  * `service_delivery` is the repair-shop handover: a `ready` → `delivered`
106
99
  * transition mints an ordinary sale out of the counter lines the operator
@@ -57,25 +57,28 @@ declare global {
57
57
  * balance, cannot receive a transfer and is not addressable. A consumer that
58
58
  * treats the two as interchangeable will attribute stock to a string.
59
59
  *
60
- * ⚠️ **Until a store is cut over, the per-location book does not converge on
61
- * the store-wide one.** `Product.stock` is the store-wide scalar the order,
62
- * sale and marketplace paths bump, alongside the store-wide income and sale
63
- * ledgers those same paths append to. A store's `InventoryLevel` rows start at
64
- * ZERO and, today, move only for the explicit inventory operations an operator
65
- * runs — receipts, adjustments, write-offs, transfers, reservations and
66
- * releases — so `Σ InventoryLevel.onHand` is not `Product.stock` and nothing
67
- * reconciles the two. The api's ADR-0001 (`docs/DECISIONS.md`) makes the level
68
- * the stock truth: behind the per-store `Store.stockAuthority` switch, each
69
- * trading path moves over to updating the level in the same transaction as
70
- * `Product.stock`, and a one-off seed at cutover puts the gap in the primary
71
- * depósito. From then on `Product.stock = Σ onHand + units on open transfers`.
72
- * Before it, the gap is expected and is not drift.
60
+ * ⚠️ **On a store not cut over (`Store.stockAuthority` absent or `'store'`),
61
+ * the per-location book does not converge on the store-wide one.**
62
+ * `Product.stock` is the store-wide scalar the order, sale and marketplace
63
+ * paths bump, alongside the store-wide income and sale ledgers those same
64
+ * paths append to. On such a store the `InventoryLevel` rows start at ZERO and
65
+ * move only for the explicit inventory operations an operator runs —
66
+ * receipts, adjustments, write-offs, transfers, reservations and releases — so
67
+ * `Σ InventoryLevel.onHand` is not `Product.stock`, nothing reconciles the
68
+ * two, and the gap is expected and is not drift. The api's ADR-0001
69
+ * (`docs/DECISIONS.md`) makes the level the stock truth: on a store cut over
70
+ * (`stockAuthority: 'depositos'`), the trading and ingress paths write the
71
+ * level in the same transaction as `Product.stock`, a one-off seed at cutover
72
+ * put the gap in the primary depósito, and the nightly stock reconciliation
73
+ * checks `Product.stock = Σ onHand + units on open transfers`.
73
74
  *
74
75
  * ⚠️ A consumer must not present a per-warehouse figure it cannot compute from
75
- * the level rows themselves, and — more important now, not less — must not
76
- * read an absent or zero level as "no stock". An absent cell is the NORMAL,
76
+ * the level rows themselves, and — on a store NOT cut over — must not read an
77
+ * absent or zero level as "no stock". There an absent cell is the NORMAL,
77
78
  * indefinite state for a product no operator has received into that location,
78
- * while the store may be holding plenty of it. A screen that totals the levels
79
+ * while the store may be holding plenty of it. On a cut-over store every unit
80
+ * that moves writes its level, so an absent row IS zero units there — the
81
+ * storefront reads it that way. A screen that totals the levels
79
82
  * and captions the total "stock", or that subtracts that total from
80
83
  * `Product.stock` and captions the difference "missing", shows an operator a
81
84
  * shortfall with no cause and sends them hunting units nobody lost.
package/dist/webhook.d.ts CHANGED
@@ -238,19 +238,12 @@ export interface ProductStockOutPayload {
238
238
  /**
239
239
  * Where an `order.created` event was minted.
240
240
  *
241
- * ⚠️ A CLOSED union, and rule 1 above applies to it with full force: a fifth
242
- * order-minting path cannot be added here without breaking every subscriber
243
- * that switches exhaustively — it mints `order.created.v2` instead. The four
244
- * members are the paths that EMIT — which is no longer the same thing as the
245
- * paths that WRITE an ORDER row.
246
- *
247
- * ⚠️ Converting an approved presupuesto (`convertPresupuestoToOrder`) mints an
248
- * ordinary order through the same `createOrder` every member above uses, and
249
- * emits nothing here — precisely BECAUSE adding a fifth member is the breaking
250
- * change the paragraph above forbids. The gap is known and deliberate, not an
251
- * oversight to be tidied: do not close it by quietly widening this tuple. The
252
- * rest of that path's fan-out (stock webhooks, notifications, the ML push) does
253
- * run; it is only this event that waits on the v2 decision.
241
+ * ⚠️ A CLOSED union: adding a source member breaks exhaustive subscribers and
242
+ * requires `order.created.v2` under rule 1. A new emit seam need not be a new
243
+ * source: `pos` means a counter sale, from `POST /orders` or a converted
244
+ * presupuesto. `presupuestoId` discriminates quote origin on the latter.
245
+ * Only POS, storefront and quote conversion use the shared `createOrder`;
246
+ * service delivery and MercadoLibre mint their rows through other calls.
254
247
  *
255
248
  * `service_delivery` is the repair-shop handover: a `ready` → `delivered`
256
249
  * transition mints an ordinary sale out of the counter lines the operator
@@ -262,14 +255,14 @@ export declare const ORDER_CREATED_SOURCES: readonly ["pos", "storefront", "serv
262
255
  export type OrderCreatedSource = (typeof ORDER_CREATED_SOURCES)[number];
263
256
  /**
264
257
  * Payload for `order.created` — an ORDER row is durable, emitted from the
265
- * post-commit fan-out of each of the four paths that mint one.
258
+ * best-effort post-commit fan-out of each minting path.
266
259
  *
267
260
  * ── WHY THERE IS NO `total` AND NO `currency` ────────────────────────────
268
261
  *
269
262
  * Both were considered and both are deliberately ABSENT, and this is the
270
263
  * decision most likely to be "fixed" by someone who finds the figure sitting
271
264
  * in scope at a seam. It is not an availability problem — a total is reachable
272
- * at all four. It is a DENOMINATION problem:
265
+ * at every seam. It is a DENOMINATION problem:
273
266
  *
274
267
  * - `Order.currency` is a catalogId (lowercase, e.g. `'ars'`, an FK to
275
268
  * `PlatformCurrency`), while {@link PaymentReceivedWebhookPayload}'s
@@ -295,9 +288,12 @@ export type OrderCreatedSource = (typeof ORDER_CREATED_SOURCES)[number];
295
288
  * consumer's `outcome: 'created'` branch, so a record that commits the order
296
289
  * and then dies before the fan-out is redelivered as `outcome: 'updated'` and
297
290
  * emits nothing. The store users' new-order notification carries exactly the
298
- * same exposure on exactly the same branch. The other three legs are
299
- * exactly-once: each sits past a committed transaction inside the request that
300
- * made it.
291
+ * same exposure on exactly the same branch. The synchronous tails, including
292
+ * quote conversion, are also best-effort: a process can stop between commit
293
+ * and emit, and subscription-read/enqueue failures are warned and swallowed.
294
+ * A converted quote is not re-announced on replay. Delivery transport retries
295
+ * can duplicate a delivered event; there is no exactly-once external delivery
296
+ * or durable recovery guarantee.
301
297
  *
302
298
  * ⚠️ **No order EDIT emits.** This fires on the write that creates the row and
303
299
  * never again — not on a line change, a discount, a tender, a fulfilment move
@@ -306,6 +302,8 @@ export type OrderCreatedSource = (typeof ORDER_CREATED_SOURCES)[number];
306
302
  export interface OrderCreatedPayload {
307
303
  orderId: string;
308
304
  source: OrderCreatedSource;
305
+ /** Quote origin on converted counter sales only; omitted on every other path. */
306
+ presupuestoId?: string;
309
307
  /**
310
308
  * Server-stamped Unix milliseconds, taken at the post-commit emit.
311
309
  *
@@ -323,7 +321,7 @@ export interface OrderCreatedPayload {
323
321
  /**
324
322
  * The order's customer.
325
323
  *
326
- * Present on the three synchronous legs without exception — a POS walk-in
324
+ * Present on the synchronous legs without exception — a POS walk-in
327
325
  * has no NAMED customer but is minted against the store's system customer
328
326
  * row, so `Order.customerId` is never empty. Absent only on the
329
327
  * MercadoLibre leg when the post-write order re-read came back empty: that
package/dist/webhook.js CHANGED
@@ -85,19 +85,12 @@ export const WEBHOOK_DELIVERY_LOG_RETENTION_DAYS = 30;
85
85
  /**
86
86
  * Where an `order.created` event was minted.
87
87
  *
88
- * ⚠️ A CLOSED union, and rule 1 above applies to it with full force: a fifth
89
- * order-minting path cannot be added here without breaking every subscriber
90
- * that switches exhaustively — it mints `order.created.v2` instead. The four
91
- * members are the paths that EMIT — which is no longer the same thing as the
92
- * paths that WRITE an ORDER row.
93
- *
94
- * ⚠️ Converting an approved presupuesto (`convertPresupuestoToOrder`) mints an
95
- * ordinary order through the same `createOrder` every member above uses, and
96
- * emits nothing here — precisely BECAUSE adding a fifth member is the breaking
97
- * change the paragraph above forbids. The gap is known and deliberate, not an
98
- * oversight to be tidied: do not close it by quietly widening this tuple. The
99
- * rest of that path's fan-out (stock webhooks, notifications, the ML push) does
100
- * run; it is only this event that waits on the v2 decision.
88
+ * ⚠️ A CLOSED union: adding a source member breaks exhaustive subscribers and
89
+ * requires `order.created.v2` under rule 1. A new emit seam need not be a new
90
+ * source: `pos` means a counter sale, from `POST /orders` or a converted
91
+ * presupuesto. `presupuestoId` discriminates quote origin on the latter.
92
+ * Only POS, storefront and quote conversion use the shared `createOrder`;
93
+ * service delivery and MercadoLibre mint their rows through other calls.
101
94
  *
102
95
  * `service_delivery` is the repair-shop handover: a `ready` → `delivered`
103
96
  * transition mints an ordinary sale out of the counter lines the operator
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.439",
3
+ "version": "1.10.441",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",