sinfactura-types 1.10.283 → 1.10.285

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.
@@ -18,7 +18,7 @@
18
18
  * Nothing posts to a connection directly.
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.isSocketKeepAlive = exports.SOCKET_KEEPALIVE = exports.SOCKET_AUTH_FAIL_REASONS = exports.LIVE_CLIENT_SOCKET_ACTIONS = exports.CLIENT_SOCKET_ACTIONS = exports.DESTRUCTIVE_AGENT_COMMANDS = exports.isAgentCommand = exports.AGENT_COMMANDS = exports.isSocketAction = exports.SOCKET_ACTIONS = void 0;
21
+ exports.isSocketKeepAlive = exports.SOCKET_KEEPALIVE = exports.SOCKET_AUTH_FAIL_REASONS = exports.LIVE_CLIENT_SOCKET_ACTIONS = exports.CLIENT_SOCKET_ACTIONS = exports.DESTRUCTIVE_AGENT_COMMANDS = exports.isAgentCommand = exports.AGENT_COMMANDS = exports.PRODUCT_STOCK_FRAME_FIELDS = exports.isSocketAction = exports.SOCKET_ACTIONS = void 0;
22
22
  /* -------------------------------------------------------------------------- */
23
23
  /* Server → client data frames */
24
24
  /* -------------------------------------------------------------------------- */
@@ -138,6 +138,36 @@ exports.SOCKET_ACTIONS = [
138
138
  */
139
139
  'loyalty',
140
140
  'orders',
141
+ /**
142
+ * A product row changed. Sent in TWO shapes, and a consumer must handle both
143
+ * — see {@link ProductStockFrameData}.
144
+ *
145
+ * 1. **Full row** — the whole `Product`. Sent by the paths that create or
146
+ * re-state a row: `products/_post.ts` (create, edit, disable),
147
+ * `_postStock.ts`, `_postStockAdjust.ts` and
148
+ * `mercadolibre/_matchSuggestions.ts`. A session catalogue INSERTS on this
149
+ * shape. ⚠️ The product CSV import does NOT send it — announcing an import
150
+ * means one frame per row, which does not fit that handler's 29s ceiling
151
+ * until `wsPostStore` grows a batched fan-out; see `products/_import.ts`.
152
+ * 2. **Partial projection** — {@link ProductStockFrameData}, sent by the
153
+ * paths that only move stock: order create (operator and storefront),
154
+ * order edit, void and return, the web cancel, and MercadoLibre inbound
155
+ * stock apply/reverse. A session catalogue PATCHES on this shape and must
156
+ * not treat it as a whole row.
157
+ *
158
+ * ⚠️ The partial shape is a PATCH, and `productId` is the only field
159
+ * guaranteed to identify it. Merging it over a row the client does not hold
160
+ * yet would mint a product with no name or price; the correct handling is to
161
+ * ignore a patch for an unknown id and let the next full read supply it.
162
+ *
163
+ * ⚠️ Audience differs per path and is not derivable from the frame. The
164
+ * order edit, void, return and web-cancel paths reach customer sockets too
165
+ * (`wsPostStoreCustomers`, which suppresses a row by reading
166
+ * `hiddenFromStorefront` off the payload); order create and MercadoLibre
167
+ * stock are operator-only. A customer's copy is
168
+ * `scrubForCustomer`'d, so `cost` is absent there — never rely on its
169
+ * presence to tell the shapes apart.
170
+ */
141
171
  'products',
142
172
  /**
143
173
  * A promotion created, updated or retired. Operator-only —
@@ -353,6 +383,38 @@ exports.SOCKET_ACTIONS = [
353
383
  /** Runtime guard — narrows an untrusted string to a known action. */
354
384
  const isSocketAction = (value) => typeof value === 'string' && exports.SOCKET_ACTIONS.includes(value);
355
385
  exports.isSocketAction = isSocketAction;
386
+ /**
387
+ * The fields a stock-moving write announces, as a RUNTIME tuple.
388
+ *
389
+ * ⚠️ This is the single source of truth, and it is a tuple rather than a
390
+ * hand-kept list in two places for the reason `RESPONSE_STRIPPED_KEYS` is one:
391
+ * the api builds its `ProjectionExpression` by joining THIS array
392
+ * (`PRODUCT_STOCK_PROJECTION` in `@helpers/broadcastProductRows`) and
393
+ * {@link ProductStockFrameData} derives its keys from it, so the projection
394
+ * that reads the row and the type describing what the FEs receive cannot
395
+ * disagree. Two independently typed lists is exactly the drift this shape
396
+ * exists to prevent — a field added to one and not the other is invisible to
397
+ * `typecheck`, to lint and to any test that compares one against a literal.
398
+ *
399
+ * ⚠️ `updatedAt` and `lastMovementAt` are BOTH carried because a stock write
400
+ * only moves the second — `movementStamp` writes `lastMovementAt`, never
401
+ * `updatedAt`. A consumer ordering `products` frames by `updatedAt` will watch
402
+ * it stand still across a whole day of sales; order by `lastMovementAt`, or do
403
+ * not order these frames at all.
404
+ *
405
+ * ⚠️ Neither name is a DynamoDB reserved word, so the joined projection needs
406
+ * no `ExpressionAttributeNames` alias. Adding one that IS reserved (`status`,
407
+ * `size`, `name`, …) breaks every read at once — alias it at the join site.
408
+ */
409
+ exports.PRODUCT_STOCK_FRAME_FIELDS = [
410
+ 'stock',
411
+ 'prices',
412
+ 'cost',
413
+ 'currency',
414
+ 'hiddenFromStorefront',
415
+ 'updatedAt',
416
+ 'lastMovementAt',
417
+ ];
356
418
  /* -------------------------------------------------------------------------- */
357
419
  /* Agent diagnostic commands */
358
420
  /* -------------------------------------------------------------------------- */
package/dist/report.d.ts CHANGED
@@ -32,6 +32,27 @@ declare global {
32
32
  /** `cost - returnCost`. Forward-only — see `returns`. */
33
33
  netCost?: number;
34
34
  }
35
+ /**
36
+ * One IVA rate's slice of a `ReportInvoicesAmounts` bucket.
37
+ *
38
+ * ⚠️ The SIGN follows the bucket it sits in, exactly like the scalar
39
+ * `neto`/`iva` beside it: positive magnitudes inside `gross` and `credit`,
40
+ * and `gross - credit` inside `net` — so a rate whose credit notes outweigh
41
+ * its facturas (or that a day credited without invoicing) carries NEGATIVE
42
+ * figures in `net.rates` and only there.
43
+ */
44
+ interface ReportInvoicesRateAmount {
45
+ /**
46
+ * AFIP Iva Id — `3` (0,00 %), `4` (10,50 %), `5` (21,00 %), `6` (27,00 %),
47
+ * `8` (5,00 %), `9` (2,50 %). ARCA *Tablas del SISTEMA* §1 one-for-one; the
48
+ * same numbering `InvoiceAlicuota.id` uses, NOT a percentage.
49
+ */
50
+ id: number;
51
+ /** Neto gravado on this rate. */
52
+ neto: number;
53
+ /** Débito fiscal (IVA) on this rate. */
54
+ iva: number;
55
+ }
35
56
  /**
36
57
  * One FAC/NC/net bucket of the ventas IVA summary. Every amount is a POSITIVE
37
58
  * magnitude, including `credit` — netting is expressed by the `net` bucket only.
@@ -45,6 +66,29 @@ declare global {
45
66
  iva: number;
46
67
  /** `ImpTotal` sum. */
47
68
  total: number;
69
+ /**
70
+ * The per-rate decomposition of `neto`/`iva`, ascending by AFIP Iva Id.
71
+ * SPARSE — a rate absent from the bucket emits no entry, so an empty array
72
+ * means no declared alícuota at all (an export-only or Factura C-only day).
73
+ *
74
+ * ⚠️ **`net.rates` is the netted per-rate base**, and the only one in this
75
+ * payload. The legacy `neto10`/`neto21`/`iva10`/`iva21` columns on
76
+ * `ReportInvoicesResume` sum credit notes with a POSITIVE sign and cover
77
+ * only Iva Ids 4 and 5 — they are neither netted nor complete, and must not
78
+ * be presented as a «base imponible».
79
+ *
80
+ * ⚠️ `neto`/`iva` stay authoritative for the bucket total. Each entry is
81
+ * rounded to 2 decimals independently of the scalar beside it, so the two
82
+ * can disagree by a cent for sub-centavo alícuota bases — which the stored
83
+ * 2-decimal amounts do not produce today. Read the scalar for the total,
84
+ * `rates` for the split; do not re-derive one from the other.
85
+ *
86
+ * ⚠️ Rows whose voucher class declares no débito fiscal — exports
87
+ * (CbteTipo 19/20/21) and the Factura C family — contribute to `quantity`
88
+ * and `total` but to NO rate entry, matching `neto`/`iva`. Their internal
89
+ * `Invoice.alicuotas` breakdown is not declared IVA.
90
+ */
91
+ rates: ReportInvoicesRateAmount[];
48
92
  }
49
93
  /**
50
94
  * One day of the `GET /reports?mode=invoices&date=YYYYMM` ventas summary.
@@ -62,6 +106,11 @@ declare global {
62
106
  * Legacy roll-up columns summing EVERY deliverable voucher with a POSITIVE
63
107
  * sign (credit notes included), so `total` mixes debits and credits.
64
108
  * Retained for wire compatibility; prefer `gross`/`credit`/`net` below.
109
+ *
110
+ * ⚠️ `neto10`/`neto21`/`iva10`/`iva21` are NOT a taxable base. They add a
111
+ * Nota de Crédito to the figure it should reduce, and they cover only Iva
112
+ * Ids 4 and 5 — a voucher on any of the other four declarable rates is
113
+ * missing from them entirely. The netted per-rate base is `net.rates`.
65
114
  */
66
115
  neto10: number;
67
116
  neto21: number;
package/dist/socket.d.ts CHANGED
@@ -63,6 +63,45 @@ export interface SocketMessage<T = unknown> {
63
63
  action: SocketAction;
64
64
  data: T;
65
65
  }
66
+ /**
67
+ * The fields a stock-moving write announces, as a RUNTIME tuple.
68
+ *
69
+ * ⚠️ This is the single source of truth, and it is a tuple rather than a
70
+ * hand-kept list in two places for the reason `RESPONSE_STRIPPED_KEYS` is one:
71
+ * the api builds its `ProjectionExpression` by joining THIS array
72
+ * (`PRODUCT_STOCK_PROJECTION` in `@helpers/broadcastProductRows`) and
73
+ * {@link ProductStockFrameData} derives its keys from it, so the projection
74
+ * that reads the row and the type describing what the FEs receive cannot
75
+ * disagree. Two independently typed lists is exactly the drift this shape
76
+ * exists to prevent — a field added to one and not the other is invisible to
77
+ * `typecheck`, to lint and to any test that compares one against a literal.
78
+ *
79
+ * ⚠️ `updatedAt` and `lastMovementAt` are BOTH carried because a stock write
80
+ * only moves the second — `movementStamp` writes `lastMovementAt`, never
81
+ * `updatedAt`. A consumer ordering `products` frames by `updatedAt` will watch
82
+ * it stand still across a whole day of sales; order by `lastMovementAt`, or do
83
+ * not order these frames at all.
84
+ *
85
+ * ⚠️ Neither name is a DynamoDB reserved word, so the joined projection needs
86
+ * no `ExpressionAttributeNames` alias. Adding one that IS reserved (`status`,
87
+ * `size`, `name`, …) breaks every read at once — alias it at the join site.
88
+ */
89
+ export declare const PRODUCT_STOCK_FRAME_FIELDS: readonly ["stock", "prices", "cost", "currency", "hiddenFromStorefront", "updatedAt", "lastMovementAt"];
90
+ /**
91
+ * `data` of a **partial** `products` frame — the projection every stock-moving
92
+ * write announces, and the only `products` shape that is not a whole `Product`.
93
+ *
94
+ * ⚠️ `cost` is merchant margin. It is present on the operator copy and removed
95
+ * from the customer copy by `scrubForCustomer`, so it is optional HERE for that
96
+ * reason alone — not because the operator path ever omits it.
97
+ *
98
+ * ⚠️ Every projected field is optional except the two identity keys, because
99
+ * DynamoDB projects only the attributes a row actually carries: a product with
100
+ * no price list has no `prices`, and one that has never moved has no
101
+ * `lastMovementAt`. Absent means "not set on the row", never "unchanged".
102
+ */
103
+ export interface ProductStockFrameData extends Pick<Product, 'storeId' | 'productId'>, Partial<Pick<Product, (typeof PRODUCT_STOCK_FRAME_FIELDS)[number]>> {
104
+ }
66
105
  /**
67
106
  * The `/logs` read mode a `log-delete` frame can refer to.
68
107
  *
package/dist/socket.js CHANGED
@@ -135,6 +135,36 @@ export const SOCKET_ACTIONS = [
135
135
  */
136
136
  'loyalty',
137
137
  'orders',
138
+ /**
139
+ * A product row changed. Sent in TWO shapes, and a consumer must handle both
140
+ * — see {@link ProductStockFrameData}.
141
+ *
142
+ * 1. **Full row** — the whole `Product`. Sent by the paths that create or
143
+ * re-state a row: `products/_post.ts` (create, edit, disable),
144
+ * `_postStock.ts`, `_postStockAdjust.ts` and
145
+ * `mercadolibre/_matchSuggestions.ts`. A session catalogue INSERTS on this
146
+ * shape. ⚠️ The product CSV import does NOT send it — announcing an import
147
+ * means one frame per row, which does not fit that handler's 29s ceiling
148
+ * until `wsPostStore` grows a batched fan-out; see `products/_import.ts`.
149
+ * 2. **Partial projection** — {@link ProductStockFrameData}, sent by the
150
+ * paths that only move stock: order create (operator and storefront),
151
+ * order edit, void and return, the web cancel, and MercadoLibre inbound
152
+ * stock apply/reverse. A session catalogue PATCHES on this shape and must
153
+ * not treat it as a whole row.
154
+ *
155
+ * ⚠️ The partial shape is a PATCH, and `productId` is the only field
156
+ * guaranteed to identify it. Merging it over a row the client does not hold
157
+ * yet would mint a product with no name or price; the correct handling is to
158
+ * ignore a patch for an unknown id and let the next full read supply it.
159
+ *
160
+ * ⚠️ Audience differs per path and is not derivable from the frame. The
161
+ * order edit, void, return and web-cancel paths reach customer sockets too
162
+ * (`wsPostStoreCustomers`, which suppresses a row by reading
163
+ * `hiddenFromStorefront` off the payload); order create and MercadoLibre
164
+ * stock are operator-only. A customer's copy is
165
+ * `scrubForCustomer`'d, so `cost` is absent there — never rely on its
166
+ * presence to tell the shapes apart.
167
+ */
138
168
  'products',
139
169
  /**
140
170
  * A promotion created, updated or retired. Operator-only —
@@ -349,6 +379,38 @@ export const SOCKET_ACTIONS = [
349
379
  ];
350
380
  /** Runtime guard — narrows an untrusted string to a known action. */
351
381
  export const isSocketAction = (value) => typeof value === 'string' && SOCKET_ACTIONS.includes(value);
382
+ /**
383
+ * The fields a stock-moving write announces, as a RUNTIME tuple.
384
+ *
385
+ * ⚠️ This is the single source of truth, and it is a tuple rather than a
386
+ * hand-kept list in two places for the reason `RESPONSE_STRIPPED_KEYS` is one:
387
+ * the api builds its `ProjectionExpression` by joining THIS array
388
+ * (`PRODUCT_STOCK_PROJECTION` in `@helpers/broadcastProductRows`) and
389
+ * {@link ProductStockFrameData} derives its keys from it, so the projection
390
+ * that reads the row and the type describing what the FEs receive cannot
391
+ * disagree. Two independently typed lists is exactly the drift this shape
392
+ * exists to prevent — a field added to one and not the other is invisible to
393
+ * `typecheck`, to lint and to any test that compares one against a literal.
394
+ *
395
+ * ⚠️ `updatedAt` and `lastMovementAt` are BOTH carried because a stock write
396
+ * only moves the second — `movementStamp` writes `lastMovementAt`, never
397
+ * `updatedAt`. A consumer ordering `products` frames by `updatedAt` will watch
398
+ * it stand still across a whole day of sales; order by `lastMovementAt`, or do
399
+ * not order these frames at all.
400
+ *
401
+ * ⚠️ Neither name is a DynamoDB reserved word, so the joined projection needs
402
+ * no `ExpressionAttributeNames` alias. Adding one that IS reserved (`status`,
403
+ * `size`, `name`, …) breaks every read at once — alias it at the join site.
404
+ */
405
+ export const PRODUCT_STOCK_FRAME_FIELDS = [
406
+ 'stock',
407
+ 'prices',
408
+ 'cost',
409
+ 'currency',
410
+ 'hiddenFromStorefront',
411
+ 'updatedAt',
412
+ 'lastMovementAt',
413
+ ];
352
414
  /* -------------------------------------------------------------------------- */
353
415
  /* Agent diagnostic commands */
354
416
  /* -------------------------------------------------------------------------- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.283",
3
+ "version": "1.10.285",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",