sinfactura-types 1.10.480 → 1.10.481

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/audit.d.ts CHANGED
@@ -122,6 +122,13 @@ declare global {
122
122
  * would leave every historical row outside the type.
123
123
  */
124
124
  | 'mercadopago.dynamicQr.create' | 'rma_requested' | 'rma_authorized' | 'rma_rejected' | 'rma_received' | 'rma_settled' | 'rma_tracking_updated'
125
+ /**
126
+ * A partial or completing shipment was recorded (`POST /orders { mode:
127
+ * 'shipment' }`); the completing one also writes `order_delivered`.
128
+ */
129
+ | 'order_shipment_created'
130
+ /** A shipment was voided; when the order was delivered, this un-delivered it. */
131
+ | 'order_shipment_voided'
125
132
  /** A customer rated the order. `after`: `surveyId`, `rating`, `comment` presence. */
126
133
  | 'survey_submitted'
127
134
  /** An operator changed `Order.comments`. Presence-only, both sides. */
package/dist/cjs/order.js CHANGED
@@ -167,11 +167,13 @@ exports.orderFulfilmentProgress = orderFulfilmentProgress;
167
167
  * `POST /invoices`, and the payment starts that carry no route tuple of their
168
168
  * own (Stripe `POST /stripe`, the MercadoPago Preference and Point intent) —
169
169
  * this is their catalogue. Nothing was written and no provider was contacted.
170
- * - `ORDER_HAS_SHIPMENTS` · 409 — the order carries at least one shipment, so
171
- * edit, disable, whole-order delivery (either direction) and a `readyAt`
172
- * change are refused. Nothing was written.
170
+ * - `ORDER_HAS_SHIPMENTS` · 409 — the order carries at least one live
171
+ * (un-voided) shipment, so edit, disable, whole-order delivery (either
172
+ * direction) and a `readyAt` change are refused. Voiding every shipment lifts
173
+ * it. Nothing was written.
173
174
  * - `ORDER_HAS_RETURNS` · 409 — the order carries at least one return and can no
174
- * longer be edited. Nothing was written.
175
+ * longer be edited, and none of its shipments can be voided. Nothing was
176
+ * written.
175
177
  * - `ORDER_CANCELLATION_NOT_PROTECTED` · 409 — `mode: 'cancel'` on an order with
176
178
  * no cancel guard of the current generation, or with the switch off; `disable`
177
179
  * is the escape. Nothing was written.
@@ -181,6 +183,25 @@ exports.orderFulfilmentProgress = orderFulfilmentProgress;
181
183
  * `OrderLockReason` rides in `message` as `reason: <r>` and, from
182
184
  * `mode: 'cancel'`, also as a `reason` key. Nothing was written.
183
185
  *
186
+ * Shipment refusals (`mode: 'shipment' | 'shipment-void'`), nothing written on
187
+ * any of them:
188
+ * - `SHIPMENT_QUANTITY_EXCEEDED` · 409 — a line would exceed its ordered
189
+ * quantity; `data.lines[{ index, requested, remaining }]`.
190
+ * - `SHIPMENT_LINE_MISMATCH` · 409 — an `index` out of range, a `productId`
191
+ * that is not the one at that position, a line with nothing ordered, or an
192
+ * integer quantity against a weighed (fractional) line, which ships only
193
+ * whole; `data.index`. A FRACTIONAL quantity that is not exactly a weighed
194
+ * line's whole ordered quantity is `400 VALIDATION_FAILED` instead.
195
+ * - `SHIPMENT_NOT_FOUND` · 404 · `SHIPMENT_LIMIT_REACHED` · 409 (50 live
196
+ * shipments per order; a void frees its slot)
197
+ * - `SHIPMENT_TOO_LARGE` · 409 — the shipment's DynamoDB condition would pass
198
+ * the 4 KB expression cap; only an order past 49 lines can reach it. Split
199
+ * the shipment into smaller ones.
200
+ * - `ORDER_FULFILMENT_EXTERNAL` · 409 — a MercadoLibre order; its fulfilment
201
+ * axis belongs to the marketplace sync.
202
+ * - `SHIPMENT_FAILED` · 502 — an unclassified write failure, logged.
203
+ * - `IDEMPOTENCY_KEY_REQUIRED` · 400 — both shipment modes require the header.
204
+ *
184
205
  * Idempotency refusals, all six from `withIdempotency`:
185
206
  * - `INVALID_IDEMPOTENCY_KEY` · 400 · `IDEMPOTENCY_KEY_REUSE` · 409
186
207
  * - `IDEMPOTENCY_IN_PROGRESS` · 409 · `IDEMPOTENCY_LOCK_CONTENTION` · 409
@@ -212,6 +233,14 @@ exports.ORDER_ERROR_CODES = [
212
233
  'ORDER_CANCELLED',
213
234
  'ORDER_HAS_SHIPMENTS',
214
235
  'ORDER_HAS_RETURNS',
236
+ 'SHIPMENT_QUANTITY_EXCEEDED',
237
+ 'SHIPMENT_LINE_MISMATCH',
238
+ 'SHIPMENT_NOT_FOUND',
239
+ 'SHIPMENT_LIMIT_REACHED',
240
+ 'SHIPMENT_TOO_LARGE',
241
+ 'ORDER_FULFILMENT_EXTERNAL',
242
+ 'SHIPMENT_FAILED',
243
+ 'IDEMPOTENCY_KEY_REQUIRED',
215
244
  'INVALID_IDEMPOTENCY_KEY',
216
245
  'IDEMPOTENCY_KEY_REUSE',
217
246
  'IDEMPOTENCY_IN_PROGRESS',
@@ -671,7 +671,9 @@ declare global {
671
671
  *
672
672
  * Answered by `POST /account` (a movement), `DELETE /account`, `POST` and
673
673
  * `DELETE /payments/{source}/{paymentId}/link` (link with credit, unlink),
674
- * and `POST /orders` (create, `mode: 'delivery'`, `mode: 'return'`).
674
+ * and `POST /orders` (create, `mode: 'delivery'`, `mode: 'return'`, and the
675
+ * `mode: 'shipment'` that completes an order or `mode: 'shipment-void'` that
676
+ * un-delivers one).
675
677
  *
676
678
  * HOW it is decided differs by writer, and only the first kind covers a merge
677
679
  * that lands after the handler's read:
package/dist/order.d.ts CHANGED
@@ -194,7 +194,11 @@ declare global {
194
194
  */
195
195
  fulfilledQuantity?: number;
196
196
  }
197
- /** A shipment's lifecycle: `voided` shipments stay listed but hand over nothing. */
197
+ /**
198
+ * A shipment's lifecycle. A void marks the SHIPMENT row `voided` (kept as
199
+ * history, listed by `GET /orders?mode=shipments`) and removes its summary
200
+ * from `Order.shipments`, so a summary on the order is always `active`.
201
+ */
198
202
  type OrderShipmentState = 'active' | 'voided';
199
203
  /** Carrier tracking an operator attaches to a shipment — every field optional. */
200
204
  interface OrderShipmentTracking {
@@ -203,9 +207,10 @@ declare global {
203
207
  trackingUrl?: string;
204
208
  }
205
209
  /**
206
- * Bounded, embedded projection of one shipment on its order row. The
210
+ * Bounded, embedded projection of one LIVE shipment on its order row. The
207
211
  * canonical shipment row lives in its own partition; this summary is what
208
- * the order-row locks read.
212
+ * the order-row locks read. A void removes it (`shipmentState` is therefore
213
+ * always `active` here); the voided row stays in the shipment partition.
209
214
  */
210
215
  interface OrderShipmentSummary {
211
216
  shipmentId: string;
@@ -216,6 +221,82 @@ declare global {
216
221
  units: number;
217
222
  tracking?: OrderShipmentTracking;
218
223
  }
224
+ /**
225
+ * One line of a shipment. `index` is the line's position in `Order.items`
226
+ * (the identity returns use too); `productId` pins that position to the
227
+ * product it held when the shipment was recorded.
228
+ */
229
+ interface OrderShipmentLine {
230
+ index: number;
231
+ productId: string;
232
+ /**
233
+ * Units handed over. A positive integer, except that a line whose ordered
234
+ * `quantity` is fractional (a weighed product) ships whole, in one
235
+ * shipment, with exactly its ordered quantity.
236
+ */
237
+ quantity: number;
238
+ }
239
+ /**
240
+ * The canonical shipment row, as `GET /orders?mode=shipments` returns it —
241
+ * operator-only. The customer sees only the `OrderShipmentSummary` on the
242
+ * order row and `items[].fulfilledQuantity`; `note`, `createdBy` and the void
243
+ * fields never leave this row.
244
+ */
245
+ interface OrderShipment {
246
+ shipmentId: string;
247
+ orderId: string;
248
+ storeId: string;
249
+ lines: OrderShipmentLine[];
250
+ tracking?: OrderShipmentTracking;
251
+ /** Operator-only free text. */
252
+ note?: string;
253
+ shipmentState: OrderShipmentState;
254
+ createdAt: number;
255
+ /** The operator's `userId`. */
256
+ createdBy: string;
257
+ voidedAt?: number;
258
+ voidedBy?: string;
259
+ voidReason?: string;
260
+ }
261
+ /**
262
+ * `POST /orders { mode: 'shipment' }` — record a (partial) hand-over.
263
+ * `Idempotency-Key` header REQUIRED. The shipment that brings every line to
264
+ * its ordered quantity IS the order's delivery: it stamps `deliveredAt` and
265
+ * moves the whole-order receivable, once. A shipment moves no stock and is
266
+ * not a sale or an invoice.
267
+ */
268
+ interface OrderShipmentRequest {
269
+ mode: 'shipment';
270
+ orderId: string;
271
+ /** 1..`MAX_ORDER_PRODUCT_LINES`, each `index` at most once. */
272
+ lines: OrderShipmentLine[];
273
+ tracking?: OrderShipmentTracking;
274
+ /** ≤ 500 chars, operator-only. */
275
+ note?: string;
276
+ /** SMS the customer when THIS shipment completes the order. */
277
+ sendSms?: boolean;
278
+ }
279
+ /**
280
+ * `POST /orders { mode: 'shipment-void' }` — the only reversal. ADMIN or
281
+ * MANAGER; `Idempotency-Key` header REQUIRED. Restores the shipment's lines,
282
+ * marks its row `voided` and REMOVES its summary from `Order.shipments`, so
283
+ * an order whose every shipment was voided carries an empty list and is no
284
+ * longer shipment-locked. Voiding a shipment of a completed order un-delivers
285
+ * it (same calendar day only).
286
+ */
287
+ interface OrderShipmentVoidRequest {
288
+ mode: 'shipment-void';
289
+ orderId: string;
290
+ shipmentId: string;
291
+ /** Trimmed, 1..500 chars. */
292
+ reason: string;
293
+ }
294
+ /** `200` body `data` of both shipment modes. */
295
+ interface OrderShipmentResult {
296
+ shipment: OrderShipment;
297
+ /** The order as re-read after the commit; absent only if that re-read failed. */
298
+ order?: Order;
299
+ }
219
300
  interface Order extends CurrencyRateProvenance, CurrencyRateFreshness {
220
301
  storeId: string;
221
302
  orderId: string;
@@ -811,8 +892,11 @@ declare global {
811
892
  */
812
893
  returns?: ReturnSummary[];
813
894
  /**
814
- * Bounded, embedded projections of this order's shipments (partial
815
- * fulfilment). Server-owned — stripped from every client body.
895
+ * Bounded, embedded projections of this order's LIVE shipments (partial
896
+ * fulfilment), at most 50. Server-owned — stripped from every client body.
897
+ * A void removes its shipment's entry, so the list never carries a voided
898
+ * shipment; the full history, voided rows included, is
899
+ * `GET /orders?mode=shipments`.
816
900
  *
817
901
  * ⚠️ **A NON-EMPTY list LOCKS the order**: edit, disable, whole-order
818
902
  * delivery (both directions), a `readyAt` change and the customer's own
@@ -1681,11 +1765,13 @@ export declare const orderFulfilmentProgress: (order: OrderFulfilmentProgressInp
1681
1765
  * `POST /invoices`, and the payment starts that carry no route tuple of their
1682
1766
  * own (Stripe `POST /stripe`, the MercadoPago Preference and Point intent) —
1683
1767
  * this is their catalogue. Nothing was written and no provider was contacted.
1684
- * - `ORDER_HAS_SHIPMENTS` · 409 — the order carries at least one shipment, so
1685
- * edit, disable, whole-order delivery (either direction) and a `readyAt`
1686
- * change are refused. Nothing was written.
1768
+ * - `ORDER_HAS_SHIPMENTS` · 409 — the order carries at least one live
1769
+ * (un-voided) shipment, so edit, disable, whole-order delivery (either
1770
+ * direction) and a `readyAt` change are refused. Voiding every shipment lifts
1771
+ * it. Nothing was written.
1687
1772
  * - `ORDER_HAS_RETURNS` · 409 — the order carries at least one return and can no
1688
- * longer be edited. Nothing was written.
1773
+ * longer be edited, and none of its shipments can be voided. Nothing was
1774
+ * written.
1689
1775
  * - `ORDER_CANCELLATION_NOT_PROTECTED` · 409 — `mode: 'cancel'` on an order with
1690
1776
  * no cancel guard of the current generation, or with the switch off; `disable`
1691
1777
  * is the escape. Nothing was written.
@@ -1695,6 +1781,25 @@ export declare const orderFulfilmentProgress: (order: OrderFulfilmentProgressInp
1695
1781
  * `OrderLockReason` rides in `message` as `reason: <r>` and, from
1696
1782
  * `mode: 'cancel'`, also as a `reason` key. Nothing was written.
1697
1783
  *
1784
+ * Shipment refusals (`mode: 'shipment' | 'shipment-void'`), nothing written on
1785
+ * any of them:
1786
+ * - `SHIPMENT_QUANTITY_EXCEEDED` · 409 — a line would exceed its ordered
1787
+ * quantity; `data.lines[{ index, requested, remaining }]`.
1788
+ * - `SHIPMENT_LINE_MISMATCH` · 409 — an `index` out of range, a `productId`
1789
+ * that is not the one at that position, a line with nothing ordered, or an
1790
+ * integer quantity against a weighed (fractional) line, which ships only
1791
+ * whole; `data.index`. A FRACTIONAL quantity that is not exactly a weighed
1792
+ * line's whole ordered quantity is `400 VALIDATION_FAILED` instead.
1793
+ * - `SHIPMENT_NOT_FOUND` · 404 · `SHIPMENT_LIMIT_REACHED` · 409 (50 live
1794
+ * shipments per order; a void frees its slot)
1795
+ * - `SHIPMENT_TOO_LARGE` · 409 — the shipment's DynamoDB condition would pass
1796
+ * the 4 KB expression cap; only an order past 49 lines can reach it. Split
1797
+ * the shipment into smaller ones.
1798
+ * - `ORDER_FULFILMENT_EXTERNAL` · 409 — a MercadoLibre order; its fulfilment
1799
+ * axis belongs to the marketplace sync.
1800
+ * - `SHIPMENT_FAILED` · 502 — an unclassified write failure, logged.
1801
+ * - `IDEMPOTENCY_KEY_REQUIRED` · 400 — both shipment modes require the header.
1802
+ *
1698
1803
  * Idempotency refusals, all six from `withIdempotency`:
1699
1804
  * - `INVALID_IDEMPOTENCY_KEY` · 400 · `IDEMPOTENCY_KEY_REUSE` · 409
1700
1805
  * - `IDEMPOTENCY_IN_PROGRESS` · 409 · `IDEMPOTENCY_LOCK_CONTENTION` · 409
@@ -1710,6 +1815,6 @@ export declare const orderFulfilmentProgress: (order: OrderFulfilmentProgressInp
1710
1815
  * `SUBSCRIPTION_READONLY`) sit on the order CREATE leg only: an edit is not a new
1711
1816
  * order, so `bareOrderPostHandler` routes past `requireMetered` entirely.
1712
1817
  */
1713
- export declare const ORDER_ERROR_CODES: readonly ["ORDER_NOT_FOUND", "ORDER_LOCKED", "ORDER_NOT_READY", "ORDER_DELIVERED_ANOTHER_DAY", "ORDER_DELIVERY_STATE_UNCHANGED", "ORDER_ILLEGAL_TRANSITION", "ORDER_VERSION_CONFLICT", "CUSTOMER_NOT_FOUND", "CUSTOMER_MERGED", "ORDER_HAS_NO_CUSTOMER", "FX_CONVERSION_UNAVAILABLE", "ROLE_FORBIDDEN", "ORDER_CANCELLED", "ORDER_HAS_SHIPMENTS", "ORDER_HAS_RETURNS", "INVALID_IDEMPOTENCY_KEY", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_IN_PROGRESS", "IDEMPOTENCY_LOCK_CONTENTION", "IDEMPOTENCY_KEY_FAILED", "IDEMPOTENT_RESPONSE_NOT_CACHED", "ORDER_CANCELLATION_NOT_PROTECTED", "ORDER_CANCELLATION_COMMITTED", "ORDER_CANCELLATION_LOCKED"];
1818
+ export declare const ORDER_ERROR_CODES: readonly ["ORDER_NOT_FOUND", "ORDER_LOCKED", "ORDER_NOT_READY", "ORDER_DELIVERED_ANOTHER_DAY", "ORDER_DELIVERY_STATE_UNCHANGED", "ORDER_ILLEGAL_TRANSITION", "ORDER_VERSION_CONFLICT", "CUSTOMER_NOT_FOUND", "CUSTOMER_MERGED", "ORDER_HAS_NO_CUSTOMER", "FX_CONVERSION_UNAVAILABLE", "ROLE_FORBIDDEN", "ORDER_CANCELLED", "ORDER_HAS_SHIPMENTS", "ORDER_HAS_RETURNS", "SHIPMENT_QUANTITY_EXCEEDED", "SHIPMENT_LINE_MISMATCH", "SHIPMENT_NOT_FOUND", "SHIPMENT_LIMIT_REACHED", "SHIPMENT_TOO_LARGE", "ORDER_FULFILMENT_EXTERNAL", "SHIPMENT_FAILED", "IDEMPOTENCY_KEY_REQUIRED", "INVALID_IDEMPOTENCY_KEY", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_IN_PROGRESS", "IDEMPOTENCY_LOCK_CONTENTION", "IDEMPOTENCY_KEY_FAILED", "IDEMPOTENT_RESPONSE_NOT_CACHED", "ORDER_CANCELLATION_NOT_PROTECTED", "ORDER_CANCELLATION_COMMITTED", "ORDER_CANCELLATION_LOCKED"];
1714
1819
  export type OrderErrorCode = (typeof ORDER_ERROR_CODES)[number];
1715
1820
  export {};
package/dist/order.js CHANGED
@@ -160,11 +160,13 @@ export const orderFulfilmentProgress = (order) => {
160
160
  * `POST /invoices`, and the payment starts that carry no route tuple of their
161
161
  * own (Stripe `POST /stripe`, the MercadoPago Preference and Point intent) —
162
162
  * this is their catalogue. Nothing was written and no provider was contacted.
163
- * - `ORDER_HAS_SHIPMENTS` · 409 — the order carries at least one shipment, so
164
- * edit, disable, whole-order delivery (either direction) and a `readyAt`
165
- * change are refused. Nothing was written.
163
+ * - `ORDER_HAS_SHIPMENTS` · 409 — the order carries at least one live
164
+ * (un-voided) shipment, so edit, disable, whole-order delivery (either
165
+ * direction) and a `readyAt` change are refused. Voiding every shipment lifts
166
+ * it. Nothing was written.
166
167
  * - `ORDER_HAS_RETURNS` · 409 — the order carries at least one return and can no
167
- * longer be edited. Nothing was written.
168
+ * longer be edited, and none of its shipments can be voided. Nothing was
169
+ * written.
168
170
  * - `ORDER_CANCELLATION_NOT_PROTECTED` · 409 — `mode: 'cancel'` on an order with
169
171
  * no cancel guard of the current generation, or with the switch off; `disable`
170
172
  * is the escape. Nothing was written.
@@ -174,6 +176,25 @@ export const orderFulfilmentProgress = (order) => {
174
176
  * `OrderLockReason` rides in `message` as `reason: <r>` and, from
175
177
  * `mode: 'cancel'`, also as a `reason` key. Nothing was written.
176
178
  *
179
+ * Shipment refusals (`mode: 'shipment' | 'shipment-void'`), nothing written on
180
+ * any of them:
181
+ * - `SHIPMENT_QUANTITY_EXCEEDED` · 409 — a line would exceed its ordered
182
+ * quantity; `data.lines[{ index, requested, remaining }]`.
183
+ * - `SHIPMENT_LINE_MISMATCH` · 409 — an `index` out of range, a `productId`
184
+ * that is not the one at that position, a line with nothing ordered, or an
185
+ * integer quantity against a weighed (fractional) line, which ships only
186
+ * whole; `data.index`. A FRACTIONAL quantity that is not exactly a weighed
187
+ * line's whole ordered quantity is `400 VALIDATION_FAILED` instead.
188
+ * - `SHIPMENT_NOT_FOUND` · 404 · `SHIPMENT_LIMIT_REACHED` · 409 (50 live
189
+ * shipments per order; a void frees its slot)
190
+ * - `SHIPMENT_TOO_LARGE` · 409 — the shipment's DynamoDB condition would pass
191
+ * the 4 KB expression cap; only an order past 49 lines can reach it. Split
192
+ * the shipment into smaller ones.
193
+ * - `ORDER_FULFILMENT_EXTERNAL` · 409 — a MercadoLibre order; its fulfilment
194
+ * axis belongs to the marketplace sync.
195
+ * - `SHIPMENT_FAILED` · 502 — an unclassified write failure, logged.
196
+ * - `IDEMPOTENCY_KEY_REQUIRED` · 400 — both shipment modes require the header.
197
+ *
177
198
  * Idempotency refusals, all six from `withIdempotency`:
178
199
  * - `INVALID_IDEMPOTENCY_KEY` · 400 · `IDEMPOTENCY_KEY_REUSE` · 409
179
200
  * - `IDEMPOTENCY_IN_PROGRESS` · 409 · `IDEMPOTENCY_LOCK_CONTENTION` · 409
@@ -205,6 +226,14 @@ export const ORDER_ERROR_CODES = [
205
226
  'ORDER_CANCELLED',
206
227
  'ORDER_HAS_SHIPMENTS',
207
228
  'ORDER_HAS_RETURNS',
229
+ 'SHIPMENT_QUANTITY_EXCEEDED',
230
+ 'SHIPMENT_LINE_MISMATCH',
231
+ 'SHIPMENT_NOT_FOUND',
232
+ 'SHIPMENT_LIMIT_REACHED',
233
+ 'SHIPMENT_TOO_LARGE',
234
+ 'ORDER_FULFILMENT_EXTERNAL',
235
+ 'SHIPMENT_FAILED',
236
+ 'IDEMPOTENCY_KEY_REQUIRED',
208
237
  'INVALID_IDEMPOTENCY_KEY',
209
238
  'IDEMPOTENCY_KEY_REUSE',
210
239
  'IDEMPOTENCY_IN_PROGRESS',
package/dist/webhook.d.ts CHANGED
@@ -469,8 +469,10 @@ export interface OrderCreatedPayload {
469
469
  *
470
470
  * ── WHICH MOVES REACH THE WIRE ───────────────────────────────────────────
471
471
  *
472
- * REAL moves only, from the two single-order fulfilment seams: the operator
473
- * delivery/un-delivery toggle, and the MercadoLibre shipment sync. Three writers
472
+ * REAL moves only, from the single-order fulfilment seams: the operator
473
+ * delivery/un-delivery toggle, the shipment that completes an order and the
474
+ * shipment void that un-delivers one (`POST /orders { mode: 'shipment' |
475
+ * 'shipment-void' }`), and the MercadoLibre shipment sync. Three writers
474
476
  * touch `fulfilmentStatus` and are deliberately SILENT, because none is a
475
477
  * transition:
476
478
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.480",
3
+ "version": "1.10.481",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",