sinfactura-types 1.10.299 → 1.10.301
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/cjs/index.js +1 -0
- package/dist/cjs/presupuesto.js +89 -0
- package/dist/cjs/socket.js +16 -0
- package/dist/cjs/webhook.js +19 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/presupuesto.d.ts +159 -0
- package/dist/presupuesto.js +86 -0
- package/dist/socket.d.ts +1 -1
- package/dist/socket.js +16 -0
- package/dist/store.d.ts +1 -0
- package/dist/webhook.d.ts +192 -1
- package/dist/webhook.js +18 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -60,6 +60,7 @@ __exportStar(require("./notification.js"), exports);
|
|
|
60
60
|
__exportStar(require("./order.js"), exports);
|
|
61
61
|
__exportStar(require("./payment.js"), exports);
|
|
62
62
|
__exportStar(require("./platform.js"), exports);
|
|
63
|
+
__exportStar(require("./presupuesto.js"), exports);
|
|
63
64
|
__exportStar(require("./pricing.js"), exports);
|
|
64
65
|
__exportStar(require("./print.js"), exports);
|
|
65
66
|
__exportStar(require("./product.js"), exports);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRESUPUESTO_ERROR_CODES = exports.PRESUPUESTO_STATUSES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A Presupuesto — a sales quote/estimate, its own entity (decision: Option B —
|
|
6
|
+
* own partition, own atomic sequence, never the order counter).
|
|
7
|
+
*
|
|
8
|
+
* ⚠️ **Not a fiscal document.** No `CbteTipo` maps to a quote, it is never sent
|
|
9
|
+
* to ARCA, it never mints a CAE, and it never calls `recordFiscalAudit`. It is
|
|
10
|
+
* a commercial document a store hands a prospective buyer before a sale
|
|
11
|
+
* happens — `tests/unit/presupuestoNeverFiscal.test.ts` asserts this at the
|
|
12
|
+
* source level (no writer under this entity's own files imports the fiscal
|
|
13
|
+
* machinery), so a later reader cannot mistake it for one.
|
|
14
|
+
*
|
|
15
|
+
* Its own partition, `PRESUPUESTO#{storeId}`, and its own atomic sequence
|
|
16
|
+
* (`COUNTER#{storeId}` / `SK='PRESUPUESTO'`) — the same pattern
|
|
17
|
+
* `PurchaseOrder`, `CycleCount` and `ServiceOrder` each already use for their
|
|
18
|
+
* own entity's numbering. Deliberately NOT the order id: sequencing off the
|
|
19
|
+
* `ORDER` counter would let a customer holding two presupuesto numbers infer
|
|
20
|
+
* roughly how many orders the store has written between them, which a number
|
|
21
|
+
* that exists only to number quotes has no business leaking.
|
|
22
|
+
*
|
|
23
|
+
* The shape mirrors `ServiceQuote` (`serviceOrder.ts`) for the
|
|
24
|
+
* version/status/approval/rejection/supersession semantics — that vocabulary
|
|
25
|
+
* was already argued out once for the service side and is not re-derived here
|
|
26
|
+
* — and `Order` (`order.ts`) for `items`/`currency*`/`amount`, so a converted
|
|
27
|
+
* order INHERITS these fields untouched rather than having them re-typed.
|
|
28
|
+
*
|
|
29
|
+
* `items`/`amount`/`currency*` intentionally reuse `Order`'s own shapes rather
|
|
30
|
+
* than inventing parallel ones: conversion is a COPY of the presupuesto's
|
|
31
|
+
* already-priced items onto a new `Order` row plus the counter allocation
|
|
32
|
+
* `Order` already has, never a re-price. `priceListId` is carried explicitly
|
|
33
|
+
* because it is the one field a re-key would silently source from the
|
|
34
|
+
* customer's *current* default price list rather than the one the quote was
|
|
35
|
+
* actually priced against.
|
|
36
|
+
*/
|
|
37
|
+
exports.PRESUPUESTO_STATUSES = [
|
|
38
|
+
'draft',
|
|
39
|
+
'sent',
|
|
40
|
+
'approved',
|
|
41
|
+
'rejected',
|
|
42
|
+
'expired',
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Refusals from the presupuesto read/write/convert legs
|
|
46
|
+
* (`stacks/lambdas/presupuestos/*.ts`).
|
|
47
|
+
*
|
|
48
|
+
* - `PRESUPUESTO_NOT_FOUND` · 404 · `VALIDATION_FAILED` · 400
|
|
49
|
+
* - `PRESUPUESTO_NOT_MUTABLE` · 409 — the row is superseded, converted,
|
|
50
|
+
* rejected or expired.
|
|
51
|
+
* - `PRESUPUESTO_ILLEGAL_TRANSITION` · 409 — the requested status change is
|
|
52
|
+
* not on the published state machine.
|
|
53
|
+
* - `PRESUPUESTO_ALREADY_CONVERTED` · 409 — `convertedOrderId` is already set.
|
|
54
|
+
* - `PRESUPUESTO_NOT_APPROVED` · 409 — conversion attempted on a row that is
|
|
55
|
+
* not `approved`.
|
|
56
|
+
* - `PRESUPUESTO_TOO_MANY_PRODUCTS` · 400 — a create or revise naming more
|
|
57
|
+
* DISTINCT products than one conversion transaction could ever carry. Bounded
|
|
58
|
+
* at the raise so that every quote which can be approved can also be
|
|
59
|
+
* converted.
|
|
60
|
+
*
|
|
61
|
+
* Conversion also commits stock, so it can refuse for the same two reasons a
|
|
62
|
+
* checkout can, rendering the SAME bodies those refusals already have:
|
|
63
|
+
*
|
|
64
|
+
* - `STOCK INSUFICIENTE` · 409 — one or more quoted products are short. Carries
|
|
65
|
+
* `insufficientStock: StockShortfall[]`. ⚠️ Only raised when the store runs
|
|
66
|
+
* with stock control on (`config.stock`).
|
|
67
|
+
* - `PRODUCT_NOT_FOUND` · 409 — a quoted product is no longer on the catalogue.
|
|
68
|
+
* Carries `missingProducts: string[]`.
|
|
69
|
+
* - `TRANSACTION_ITEMS_LIMIT_REACHED` · 400 — the assembled conversion
|
|
70
|
+
* transaction would exceed DynamoDB's item ceiling. Reachable only for a row
|
|
71
|
+
* quoted before `PRESUPUESTO_TOO_MANY_PRODUCTS` existed, since nothing is
|
|
72
|
+
* backfilled.
|
|
73
|
+
*/
|
|
74
|
+
exports.PRESUPUESTO_ERROR_CODES = [
|
|
75
|
+
'PRESUPUESTO_NOT_FOUND',
|
|
76
|
+
'VALIDATION_FAILED',
|
|
77
|
+
'PRESUPUESTO_NOT_MUTABLE',
|
|
78
|
+
'PRESUPUESTO_ILLEGAL_TRANSITION',
|
|
79
|
+
'PRESUPUESTO_ALREADY_CONVERTED',
|
|
80
|
+
'PRESUPUESTO_NOT_APPROVED',
|
|
81
|
+
'PRESUPUESTO_TOO_MANY_PRODUCTS',
|
|
82
|
+
'TRANSACTION_ITEMS_LIMIT_REACHED',
|
|
83
|
+
'PRODUCT_NOT_FOUND',
|
|
84
|
+
// ⚠️ Not SCREAMING_SNAKE, and deliberately so: this is the literal
|
|
85
|
+
// `STOCK_INSUFFICIENT_ERROR` every stock-guarded write in this repo already
|
|
86
|
+
// puts on the wire. Spelling a second, tidier code for the same refusal would
|
|
87
|
+
// make one client branch answer two ways depending on which surface refused.
|
|
88
|
+
'STOCK INSUFICIENTE',
|
|
89
|
+
];
|
package/dist/cjs/socket.js
CHANGED
|
@@ -160,6 +160,22 @@ exports.SOCKET_ACTIONS = [
|
|
|
160
160
|
*/
|
|
161
161
|
'loyalty',
|
|
162
162
|
'orders',
|
|
163
|
+
/**
|
|
164
|
+
* BE → all store users, plus the payload's own customer, on every
|
|
165
|
+
* presupuesto write: create, revise (a new version), a status transition
|
|
166
|
+
* (send/approve/reject/expire), and conversion to an order. Carries the
|
|
167
|
+
* full `Presupuesto` row, mirroring how `'orders'` carries the order —
|
|
168
|
+
* INCLUDING `items[].cost`, since `dynamoUpdate`'s default
|
|
169
|
+
* `'operator-and-customer'` audience is the same one `'orders'` uses and
|
|
170
|
+
* `scrubForCustomer`/`stripBasketCost` already strip `items[].cost`
|
|
171
|
+
* structurally (by shape, not by `action` name) before the customer's copy
|
|
172
|
+
* goes out.
|
|
173
|
+
*
|
|
174
|
+
* ⚠️ Never a fiscal frame — a `Presupuesto` is never sent to ARCA and never
|
|
175
|
+
* carries an `Invoice`. See the contract's own doc comment
|
|
176
|
+
* (`presupuesto.ts`).
|
|
177
|
+
*/
|
|
178
|
+
'presupuestos',
|
|
163
179
|
/**
|
|
164
180
|
* A product row changed. Sent in TWO shapes, and a consumer must handle both
|
|
165
181
|
* — see {@link ProductStockFrameData}.
|
package/dist/cjs/webhook.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
// BREAKING change to every subscriber that exhaustively switches on it, even
|
|
44
44
|
// though it adds rather than removes.
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.PRINT_JOB_SETTLED_OUTCOMES = exports.WEBHOOK_EVENT_TYPES = void 0;
|
|
46
|
+
exports.ORDER_CREATED_SOURCES = exports.PRINT_JOB_SETTLED_OUTCOMES = exports.WEBHOOK_EVENT_TYPES = void 0;
|
|
47
47
|
/**
|
|
48
48
|
* Every event an integrator can subscribe to — print-state transitions and
|
|
49
49
|
* business events alike.
|
|
@@ -69,6 +69,24 @@ exports.WEBHOOK_EVENT_TYPES = [
|
|
|
69
69
|
'payment.received',
|
|
70
70
|
'product.stock_low',
|
|
71
71
|
'product.stock_out',
|
|
72
|
+
'order.created',
|
|
73
|
+
'invoice.generated',
|
|
72
74
|
];
|
|
73
75
|
/** Terminal outcomes for a print job. Closed union — a job printed, or it failed. */
|
|
74
76
|
exports.PRINT_JOB_SETTLED_OUTCOMES = ['printed', 'failed'];
|
|
77
|
+
/**
|
|
78
|
+
* Where an `order.created` event was minted.
|
|
79
|
+
*
|
|
80
|
+
* ⚠️ A CLOSED union, and rule 1 above applies to it with full force: a fifth
|
|
81
|
+
* order-minting path cannot be added here without breaking every subscriber
|
|
82
|
+
* that switches exhaustively — it mints `order.created.v2` instead. The four
|
|
83
|
+
* members are the complete set of paths that write an ORDER row today, each
|
|
84
|
+
* verified at its own post-commit fan-out, not a sample.
|
|
85
|
+
*
|
|
86
|
+
* `service_delivery` is the repair-shop handover: a `ready` → `delivered`
|
|
87
|
+
* transition mints an ordinary sale out of the counter lines the operator
|
|
88
|
+
* named. It is a real order, indistinguishable downstream from a till sale,
|
|
89
|
+
* and it is the one path whose existence an integrator would otherwise never
|
|
90
|
+
* learn about.
|
|
91
|
+
*/
|
|
92
|
+
exports.ORDER_CREATED_SOURCES = ['pos', 'storefront', 'service_delivery', 'mercadolibre'];
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export * from './notification.ts';
|
|
|
36
36
|
export * from './order.ts';
|
|
37
37
|
export * from './payment.ts';
|
|
38
38
|
export * from './platform.ts';
|
|
39
|
+
export * from './presupuesto.ts';
|
|
39
40
|
export * from './pricing.ts';
|
|
40
41
|
export * from './print.ts';
|
|
41
42
|
export * from './product.ts';
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,7 @@ export * from "./notification.js";
|
|
|
44
44
|
export * from "./order.js";
|
|
45
45
|
export * from "./payment.js";
|
|
46
46
|
export * from "./platform.js";
|
|
47
|
+
export * from "./presupuesto.js";
|
|
47
48
|
export * from "./pricing.js";
|
|
48
49
|
export * from "./print.js";
|
|
49
50
|
export * from "./product.js";
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Presupuesto — a sales quote/estimate, its own entity (decision: Option B —
|
|
3
|
+
* own partition, own atomic sequence, never the order counter).
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ **Not a fiscal document.** No `CbteTipo` maps to a quote, it is never sent
|
|
6
|
+
* to ARCA, it never mints a CAE, and it never calls `recordFiscalAudit`. It is
|
|
7
|
+
* a commercial document a store hands a prospective buyer before a sale
|
|
8
|
+
* happens — `tests/unit/presupuestoNeverFiscal.test.ts` asserts this at the
|
|
9
|
+
* source level (no writer under this entity's own files imports the fiscal
|
|
10
|
+
* machinery), so a later reader cannot mistake it for one.
|
|
11
|
+
*
|
|
12
|
+
* Its own partition, `PRESUPUESTO#{storeId}`, and its own atomic sequence
|
|
13
|
+
* (`COUNTER#{storeId}` / `SK='PRESUPUESTO'`) — the same pattern
|
|
14
|
+
* `PurchaseOrder`, `CycleCount` and `ServiceOrder` each already use for their
|
|
15
|
+
* own entity's numbering. Deliberately NOT the order id: sequencing off the
|
|
16
|
+
* `ORDER` counter would let a customer holding two presupuesto numbers infer
|
|
17
|
+
* roughly how many orders the store has written between them, which a number
|
|
18
|
+
* that exists only to number quotes has no business leaking.
|
|
19
|
+
*
|
|
20
|
+
* The shape mirrors `ServiceQuote` (`serviceOrder.ts`) for the
|
|
21
|
+
* version/status/approval/rejection/supersession semantics — that vocabulary
|
|
22
|
+
* was already argued out once for the service side and is not re-derived here
|
|
23
|
+
* — and `Order` (`order.ts`) for `items`/`currency*`/`amount`, so a converted
|
|
24
|
+
* order INHERITS these fields untouched rather than having them re-typed.
|
|
25
|
+
*
|
|
26
|
+
* `items`/`amount`/`currency*` intentionally reuse `Order`'s own shapes rather
|
|
27
|
+
* than inventing parallel ones: conversion is a COPY of the presupuesto's
|
|
28
|
+
* already-priced items onto a new `Order` row plus the counter allocation
|
|
29
|
+
* `Order` already has, never a re-price. `priceListId` is carried explicitly
|
|
30
|
+
* because it is the one field a re-key would silently source from the
|
|
31
|
+
* customer's *current* default price list rather than the one the quote was
|
|
32
|
+
* actually priced against.
|
|
33
|
+
*/
|
|
34
|
+
export declare const PRESUPUESTO_STATUSES: readonly ["draft", "sent", "approved", "rejected", "expired"];
|
|
35
|
+
declare global {
|
|
36
|
+
/**
|
|
37
|
+
* - `draft` — being composed; the customer has not seen it.
|
|
38
|
+
* - `sent` — handed to the customer; awaiting their decision.
|
|
39
|
+
* - `approved` — the customer accepted it. Convertible to an order exactly
|
|
40
|
+
* once — `convertedOrderId` presence is the guard.
|
|
41
|
+
* - `rejected` — the customer declined it. Terminal.
|
|
42
|
+
* - `expired` — the acceptance window (`expiresAt`) lapsed unaccepted.
|
|
43
|
+
* Terminal.
|
|
44
|
+
*
|
|
45
|
+
* ⚠️ There is deliberately no `superseded` member here, unlike
|
|
46
|
+
* `ServiceQuoteStatus`. A superseded row's OWN `status` stays whatever it
|
|
47
|
+
* was the instant the revision minted — `supersededBy`'s presence is what
|
|
48
|
+
* marks it superseded, exactly as the contract's own field doc states. A
|
|
49
|
+
* reader checking "is this row live" must check `supersededBy` AND
|
|
50
|
+
* `convertedOrderId`, never `status` alone.
|
|
51
|
+
*/
|
|
52
|
+
type PresupuestoStatus = 'draft' | 'sent' | 'approved' | 'rejected' | 'expired';
|
|
53
|
+
/** Recorded once `status` moves to `approved`. */
|
|
54
|
+
interface PresupuestoApproval {
|
|
55
|
+
approvedAt: number;
|
|
56
|
+
/** userId of the operator who recorded it, or the customerId who self-served. */
|
|
57
|
+
approvedBy: string;
|
|
58
|
+
}
|
|
59
|
+
/** Recorded once `status` moves to `rejected`. */
|
|
60
|
+
interface PresupuestoRejection {
|
|
61
|
+
rejectedAt: number;
|
|
62
|
+
/** Bounded free text. Never PII by contract — an operator/customer note, same posture as `Order.cancellationReason`. */
|
|
63
|
+
reason?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A sales quote/estimate for a prospective sale.
|
|
67
|
+
*
|
|
68
|
+
* `PK: PRESUPUESTO#{storeId}` / `SK: {presupuestoId}` — its own partition,
|
|
69
|
+
* its own `COUNTER#{storeId}` / `SK='PRESUPUESTO'` sequence.
|
|
70
|
+
*/
|
|
71
|
+
interface Presupuesto {
|
|
72
|
+
storeId: string;
|
|
73
|
+
/** Minted by the entity's own `COUNTER#{storeId}` / `SK='PRESUPUESTO'` sequence — never the order counter. */
|
|
74
|
+
presupuestoId: string;
|
|
75
|
+
/** 1-based, monotonic across this presupuesto's revision chain. Mirrors `ServiceQuote.version`. */
|
|
76
|
+
version: number;
|
|
77
|
+
status: PresupuestoStatus;
|
|
78
|
+
/**
|
|
79
|
+
* `presupuestoId` of the revision that replaced this one. A revision
|
|
80
|
+
* MINTS A NEW VERSION — its own row, its own `presupuestoId` — and sets
|
|
81
|
+
* this on the row it replaces; it never mutates the old row's other
|
|
82
|
+
* fields. Presence marks this row superseded regardless of `status`.
|
|
83
|
+
*/
|
|
84
|
+
supersededBy?: string;
|
|
85
|
+
customerId: string;
|
|
86
|
+
/**
|
|
87
|
+
* The customer's price list at ISSUE time. Carried explicitly so a
|
|
88
|
+
* conversion never re-keys from whatever the customer's price list
|
|
89
|
+
* happens to be at CONVERSION time — the one field a human retyping the
|
|
90
|
+
* quote would silently get from the wrong source.
|
|
91
|
+
*/
|
|
92
|
+
priceListId?: string;
|
|
93
|
+
/** Same shape `Order.items` already uses — not a parallel line type kept in sync by hand. */
|
|
94
|
+
items: Partial<CartLine>[];
|
|
95
|
+
/** Self-describing currency stamp (ADR-0013), same posture as `ServiceQuote`. */
|
|
96
|
+
currency: string;
|
|
97
|
+
currencyValue: number;
|
|
98
|
+
currencyValueAt: number;
|
|
99
|
+
/** The quoted total, in this row's currency. */
|
|
100
|
+
amount: number;
|
|
101
|
+
/** Unix ms this version was raised. */
|
|
102
|
+
issuedAt: number;
|
|
103
|
+
/**
|
|
104
|
+
* Unix ms the offer lapses. ⚠️ Readable on THIS row, and therefore on the
|
|
105
|
+
* list read — not only inside the rendered PDF. An operator deciding on
|
|
106
|
+
* expiry from a grid needs a field the grid can read; one only the PDF
|
|
107
|
+
* carries cannot drive a column or a chip.
|
|
108
|
+
*/
|
|
109
|
+
expiresAt?: number;
|
|
110
|
+
/** Unix ms the quote was handed to the customer — the `draft` -> `sent` transition. */
|
|
111
|
+
sentAt?: number;
|
|
112
|
+
approval?: PresupuestoApproval;
|
|
113
|
+
rejection?: PresupuestoRejection;
|
|
114
|
+
/**
|
|
115
|
+
* The `orderId` this presupuesto became. Set ONCE, atomically with the
|
|
116
|
+
* order's own create — presence IS the "already converted" guard a
|
|
117
|
+
* terminal quote needs, so a second conversion attempt fails at the
|
|
118
|
+
* write rather than minting a duplicate order.
|
|
119
|
+
*/
|
|
120
|
+
convertedOrderId?: string;
|
|
121
|
+
createdAt: number;
|
|
122
|
+
updatedAt?: number;
|
|
123
|
+
/** Lowercase '#'-joined write-side index. Internal; not part of the read contract. */
|
|
124
|
+
search?: string;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Refusals from the presupuesto read/write/convert legs
|
|
129
|
+
* (`stacks/lambdas/presupuestos/*.ts`).
|
|
130
|
+
*
|
|
131
|
+
* - `PRESUPUESTO_NOT_FOUND` · 404 · `VALIDATION_FAILED` · 400
|
|
132
|
+
* - `PRESUPUESTO_NOT_MUTABLE` · 409 — the row is superseded, converted,
|
|
133
|
+
* rejected or expired.
|
|
134
|
+
* - `PRESUPUESTO_ILLEGAL_TRANSITION` · 409 — the requested status change is
|
|
135
|
+
* not on the published state machine.
|
|
136
|
+
* - `PRESUPUESTO_ALREADY_CONVERTED` · 409 — `convertedOrderId` is already set.
|
|
137
|
+
* - `PRESUPUESTO_NOT_APPROVED` · 409 — conversion attempted on a row that is
|
|
138
|
+
* not `approved`.
|
|
139
|
+
* - `PRESUPUESTO_TOO_MANY_PRODUCTS` · 400 — a create or revise naming more
|
|
140
|
+
* DISTINCT products than one conversion transaction could ever carry. Bounded
|
|
141
|
+
* at the raise so that every quote which can be approved can also be
|
|
142
|
+
* converted.
|
|
143
|
+
*
|
|
144
|
+
* Conversion also commits stock, so it can refuse for the same two reasons a
|
|
145
|
+
* checkout can, rendering the SAME bodies those refusals already have:
|
|
146
|
+
*
|
|
147
|
+
* - `STOCK INSUFICIENTE` · 409 — one or more quoted products are short. Carries
|
|
148
|
+
* `insufficientStock: StockShortfall[]`. ⚠️ Only raised when the store runs
|
|
149
|
+
* with stock control on (`config.stock`).
|
|
150
|
+
* - `PRODUCT_NOT_FOUND` · 409 — a quoted product is no longer on the catalogue.
|
|
151
|
+
* Carries `missingProducts: string[]`.
|
|
152
|
+
* - `TRANSACTION_ITEMS_LIMIT_REACHED` · 400 — the assembled conversion
|
|
153
|
+
* transaction would exceed DynamoDB's item ceiling. Reachable only for a row
|
|
154
|
+
* quoted before `PRESUPUESTO_TOO_MANY_PRODUCTS` existed, since nothing is
|
|
155
|
+
* backfilled.
|
|
156
|
+
*/
|
|
157
|
+
export declare const PRESUPUESTO_ERROR_CODES: readonly ["PRESUPUESTO_NOT_FOUND", "VALIDATION_FAILED", "PRESUPUESTO_NOT_MUTABLE", "PRESUPUESTO_ILLEGAL_TRANSITION", "PRESUPUESTO_ALREADY_CONVERTED", "PRESUPUESTO_NOT_APPROVED", "PRESUPUESTO_TOO_MANY_PRODUCTS", "TRANSACTION_ITEMS_LIMIT_REACHED", "PRODUCT_NOT_FOUND", "STOCK INSUFICIENTE"];
|
|
158
|
+
export type PresupuestoErrorCode = (typeof PRESUPUESTO_ERROR_CODES)[number];
|
|
159
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Presupuesto — a sales quote/estimate, its own entity (decision: Option B —
|
|
3
|
+
* own partition, own atomic sequence, never the order counter).
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ **Not a fiscal document.** No `CbteTipo` maps to a quote, it is never sent
|
|
6
|
+
* to ARCA, it never mints a CAE, and it never calls `recordFiscalAudit`. It is
|
|
7
|
+
* a commercial document a store hands a prospective buyer before a sale
|
|
8
|
+
* happens — `tests/unit/presupuestoNeverFiscal.test.ts` asserts this at the
|
|
9
|
+
* source level (no writer under this entity's own files imports the fiscal
|
|
10
|
+
* machinery), so a later reader cannot mistake it for one.
|
|
11
|
+
*
|
|
12
|
+
* Its own partition, `PRESUPUESTO#{storeId}`, and its own atomic sequence
|
|
13
|
+
* (`COUNTER#{storeId}` / `SK='PRESUPUESTO'`) — the same pattern
|
|
14
|
+
* `PurchaseOrder`, `CycleCount` and `ServiceOrder` each already use for their
|
|
15
|
+
* own entity's numbering. Deliberately NOT the order id: sequencing off the
|
|
16
|
+
* `ORDER` counter would let a customer holding two presupuesto numbers infer
|
|
17
|
+
* roughly how many orders the store has written between them, which a number
|
|
18
|
+
* that exists only to number quotes has no business leaking.
|
|
19
|
+
*
|
|
20
|
+
* The shape mirrors `ServiceQuote` (`serviceOrder.ts`) for the
|
|
21
|
+
* version/status/approval/rejection/supersession semantics — that vocabulary
|
|
22
|
+
* was already argued out once for the service side and is not re-derived here
|
|
23
|
+
* — and `Order` (`order.ts`) for `items`/`currency*`/`amount`, so a converted
|
|
24
|
+
* order INHERITS these fields untouched rather than having them re-typed.
|
|
25
|
+
*
|
|
26
|
+
* `items`/`amount`/`currency*` intentionally reuse `Order`'s own shapes rather
|
|
27
|
+
* than inventing parallel ones: conversion is a COPY of the presupuesto's
|
|
28
|
+
* already-priced items onto a new `Order` row plus the counter allocation
|
|
29
|
+
* `Order` already has, never a re-price. `priceListId` is carried explicitly
|
|
30
|
+
* because it is the one field a re-key would silently source from the
|
|
31
|
+
* customer's *current* default price list rather than the one the quote was
|
|
32
|
+
* actually priced against.
|
|
33
|
+
*/
|
|
34
|
+
export const PRESUPUESTO_STATUSES = [
|
|
35
|
+
'draft',
|
|
36
|
+
'sent',
|
|
37
|
+
'approved',
|
|
38
|
+
'rejected',
|
|
39
|
+
'expired',
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Refusals from the presupuesto read/write/convert legs
|
|
43
|
+
* (`stacks/lambdas/presupuestos/*.ts`).
|
|
44
|
+
*
|
|
45
|
+
* - `PRESUPUESTO_NOT_FOUND` · 404 · `VALIDATION_FAILED` · 400
|
|
46
|
+
* - `PRESUPUESTO_NOT_MUTABLE` · 409 — the row is superseded, converted,
|
|
47
|
+
* rejected or expired.
|
|
48
|
+
* - `PRESUPUESTO_ILLEGAL_TRANSITION` · 409 — the requested status change is
|
|
49
|
+
* not on the published state machine.
|
|
50
|
+
* - `PRESUPUESTO_ALREADY_CONVERTED` · 409 — `convertedOrderId` is already set.
|
|
51
|
+
* - `PRESUPUESTO_NOT_APPROVED` · 409 — conversion attempted on a row that is
|
|
52
|
+
* not `approved`.
|
|
53
|
+
* - `PRESUPUESTO_TOO_MANY_PRODUCTS` · 400 — a create or revise naming more
|
|
54
|
+
* DISTINCT products than one conversion transaction could ever carry. Bounded
|
|
55
|
+
* at the raise so that every quote which can be approved can also be
|
|
56
|
+
* converted.
|
|
57
|
+
*
|
|
58
|
+
* Conversion also commits stock, so it can refuse for the same two reasons a
|
|
59
|
+
* checkout can, rendering the SAME bodies those refusals already have:
|
|
60
|
+
*
|
|
61
|
+
* - `STOCK INSUFICIENTE` · 409 — one or more quoted products are short. Carries
|
|
62
|
+
* `insufficientStock: StockShortfall[]`. ⚠️ Only raised when the store runs
|
|
63
|
+
* with stock control on (`config.stock`).
|
|
64
|
+
* - `PRODUCT_NOT_FOUND` · 409 — a quoted product is no longer on the catalogue.
|
|
65
|
+
* Carries `missingProducts: string[]`.
|
|
66
|
+
* - `TRANSACTION_ITEMS_LIMIT_REACHED` · 400 — the assembled conversion
|
|
67
|
+
* transaction would exceed DynamoDB's item ceiling. Reachable only for a row
|
|
68
|
+
* quoted before `PRESUPUESTO_TOO_MANY_PRODUCTS` existed, since nothing is
|
|
69
|
+
* backfilled.
|
|
70
|
+
*/
|
|
71
|
+
export const PRESUPUESTO_ERROR_CODES = [
|
|
72
|
+
'PRESUPUESTO_NOT_FOUND',
|
|
73
|
+
'VALIDATION_FAILED',
|
|
74
|
+
'PRESUPUESTO_NOT_MUTABLE',
|
|
75
|
+
'PRESUPUESTO_ILLEGAL_TRANSITION',
|
|
76
|
+
'PRESUPUESTO_ALREADY_CONVERTED',
|
|
77
|
+
'PRESUPUESTO_NOT_APPROVED',
|
|
78
|
+
'PRESUPUESTO_TOO_MANY_PRODUCTS',
|
|
79
|
+
'TRANSACTION_ITEMS_LIMIT_REACHED',
|
|
80
|
+
'PRODUCT_NOT_FOUND',
|
|
81
|
+
// ⚠️ Not SCREAMING_SNAKE, and deliberately so: this is the literal
|
|
82
|
+
// `STOCK_INSUFFICIENT_ERROR` every stock-guarded write in this repo already
|
|
83
|
+
// puts on the wire. Spelling a second, tidier code for the same refusal would
|
|
84
|
+
// make one client branch answer two ways depending on which surface refused.
|
|
85
|
+
'STOCK INSUFICIENTE',
|
|
86
|
+
];
|
package/dist/socket.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* A client must ignore actions it does not own rather than assume it
|
|
27
27
|
* receives all of them.
|
|
28
28
|
*/
|
|
29
|
-
export declare const SOCKET_ACTIONS: readonly ["account", "appointments", "appointmentWaitlist", "attendance", "automation-rules", "baskets", "cart", "brands", "cash", "categories", "campaigns", "customers", "deliveries", "globals", "invoices", "literals", "loyalty", "orders", "products", "promotions", "segments", "returns", "rma", "templates", "services", "service-templates", "shifts", "stores", "suppliers", "supplier-invoice", "support", "surveys", "users", "warehouses", "favorites", "webhooks", "account-delete", "baskets-delete", "cart-delete", "log-delete", "notifications", "support-message", "whatsapp-message", "payment_received", "payment_linked", "payment_unlinked", "mercadopago", "mercadopago_dynamic_qr_created", "mercadopago_static_qr_created", "mp_hook_log_appended", "mp_ipn_log_appended", "stripe", "subscription", "caea", "print", "print-order", "print-invoice", "print-product", "print-tag", "print_job_failed", "request_printers", "printers_changed", "agent_status_changed", "print_rules_changed", "printers_active", "agent_command", "maintenance", "currency_auto_updated", "drain_progress", "integration_event_appended", "userActivityRecorded", "mercadolibre_settlement_period", "customDomain", "purchaseOrders", "cycleCounts"];
|
|
29
|
+
export declare const SOCKET_ACTIONS: readonly ["account", "appointments", "appointmentWaitlist", "attendance", "automation-rules", "baskets", "cart", "brands", "cash", "categories", "campaigns", "customers", "deliveries", "globals", "invoices", "literals", "loyalty", "orders", "presupuestos", "products", "promotions", "segments", "returns", "rma", "templates", "services", "service-templates", "shifts", "stores", "suppliers", "supplier-invoice", "support", "surveys", "users", "warehouses", "favorites", "webhooks", "account-delete", "baskets-delete", "cart-delete", "log-delete", "notifications", "support-message", "whatsapp-message", "payment_received", "payment_linked", "payment_unlinked", "mercadopago", "mercadopago_dynamic_qr_created", "mercadopago_static_qr_created", "mp_hook_log_appended", "mp_ipn_log_appended", "stripe", "subscription", "caea", "print", "print-order", "print-invoice", "print-product", "print-tag", "print_job_failed", "request_printers", "printers_changed", "agent_status_changed", "print_rules_changed", "printers_active", "agent_command", "maintenance", "currency_auto_updated", "drain_progress", "integration_event_appended", "userActivityRecorded", "mercadolibre_settlement_period", "customDomain", "purchaseOrders", "cycleCounts"];
|
|
30
30
|
/** Union of every server→client data-frame action. */
|
|
31
31
|
export type SocketAction = (typeof SOCKET_ACTIONS)[number];
|
|
32
32
|
/**
|
package/dist/socket.js
CHANGED
|
@@ -157,6 +157,22 @@ export const SOCKET_ACTIONS = [
|
|
|
157
157
|
*/
|
|
158
158
|
'loyalty',
|
|
159
159
|
'orders',
|
|
160
|
+
/**
|
|
161
|
+
* BE → all store users, plus the payload's own customer, on every
|
|
162
|
+
* presupuesto write: create, revise (a new version), a status transition
|
|
163
|
+
* (send/approve/reject/expire), and conversion to an order. Carries the
|
|
164
|
+
* full `Presupuesto` row, mirroring how `'orders'` carries the order —
|
|
165
|
+
* INCLUDING `items[].cost`, since `dynamoUpdate`'s default
|
|
166
|
+
* `'operator-and-customer'` audience is the same one `'orders'` uses and
|
|
167
|
+
* `scrubForCustomer`/`stripBasketCost` already strip `items[].cost`
|
|
168
|
+
* structurally (by shape, not by `action` name) before the customer's copy
|
|
169
|
+
* goes out.
|
|
170
|
+
*
|
|
171
|
+
* ⚠️ Never a fiscal frame — a `Presupuesto` is never sent to ARCA and never
|
|
172
|
+
* carries an `Invoice`. See the contract's own doc comment
|
|
173
|
+
* (`presupuesto.ts`).
|
|
174
|
+
*/
|
|
175
|
+
'presupuestos',
|
|
160
176
|
/**
|
|
161
177
|
* A product row changed. Sent in TWO shapes, and a consumer must handle both
|
|
162
178
|
* — see {@link ProductStockFrameData}.
|
package/dist/store.d.ts
CHANGED
package/dist/webhook.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* immediately subscribable — and a store that subscribes to an event with no
|
|
11
11
|
* emit site gets silence it cannot distinguish from "nothing happened".
|
|
12
12
|
*/
|
|
13
|
-
export declare const WEBHOOK_EVENT_TYPES: readonly ["print.queued", "print.received", "print.printed", "print.failed", "print.agent.connected", "print.agent.disconnected", "print.printer.online", "print.printer.offline", "print.job.settled", "payment.received", "product.stock_low", "product.stock_out"];
|
|
13
|
+
export declare const WEBHOOK_EVENT_TYPES: readonly ["print.queued", "print.received", "print.printed", "print.failed", "print.agent.connected", "print.agent.disconnected", "print.printer.online", "print.printer.offline", "print.job.settled", "payment.received", "product.stock_low", "product.stock_out", "order.created", "invoice.generated"];
|
|
14
14
|
export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
|
|
15
15
|
/** Terminal outcomes for a print job. Closed union — a job printed, or it failed. */
|
|
16
16
|
export declare const PRINT_JOB_SETTLED_OUTCOMES: readonly ["printed", "failed"];
|
|
@@ -188,3 +188,194 @@ export interface ProductStockOutPayload {
|
|
|
188
188
|
/** Server-stamped Unix milliseconds. */
|
|
189
189
|
crossedAt: number;
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Where an `order.created` event was minted.
|
|
193
|
+
*
|
|
194
|
+
* ⚠️ A CLOSED union, and rule 1 above applies to it with full force: a fifth
|
|
195
|
+
* order-minting path cannot be added here without breaking every subscriber
|
|
196
|
+
* that switches exhaustively — it mints `order.created.v2` instead. The four
|
|
197
|
+
* members are the complete set of paths that write an ORDER row today, each
|
|
198
|
+
* verified at its own post-commit fan-out, not a sample.
|
|
199
|
+
*
|
|
200
|
+
* `service_delivery` is the repair-shop handover: a `ready` → `delivered`
|
|
201
|
+
* transition mints an ordinary sale out of the counter lines the operator
|
|
202
|
+
* named. It is a real order, indistinguishable downstream from a till sale,
|
|
203
|
+
* and it is the one path whose existence an integrator would otherwise never
|
|
204
|
+
* learn about.
|
|
205
|
+
*/
|
|
206
|
+
export declare const ORDER_CREATED_SOURCES: readonly ["pos", "storefront", "service_delivery", "mercadolibre"];
|
|
207
|
+
export type OrderCreatedSource = (typeof ORDER_CREATED_SOURCES)[number];
|
|
208
|
+
/**
|
|
209
|
+
* Payload for `order.created` — an ORDER row is durable, emitted from the
|
|
210
|
+
* post-commit fan-out of each of the four paths that mint one.
|
|
211
|
+
*
|
|
212
|
+
* ── WHY THERE IS NO `total` AND NO `currency` ────────────────────────────
|
|
213
|
+
*
|
|
214
|
+
* Both were considered and both are deliberately ABSENT, and this is the
|
|
215
|
+
* decision most likely to be "fixed" by someone who finds the figure sitting
|
|
216
|
+
* in scope at a seam. It is not an availability problem — a total is reachable
|
|
217
|
+
* at all four. It is a DENOMINATION problem:
|
|
218
|
+
*
|
|
219
|
+
* - `Order.currency` is a catalogId (lowercase, e.g. `'ars'`, an FK to
|
|
220
|
+
* `PlatformCurrency`), while {@link PaymentReceivedWebhookPayload}'s
|
|
221
|
+
* `currency` is ISO 4217 (`'ARS'`). The MercadoLibre leg holds ML's own
|
|
222
|
+
* `currency_id` instead, a third vocabulary again. One field name spelling
|
|
223
|
+
* three things across two sibling events is worse for a reconciler than no
|
|
224
|
+
* field at all.
|
|
225
|
+
* - A money figure with no trustworthy denomination beside it is a number an
|
|
226
|
+
* integrator would reconcile against and be wrong about — and a
|
|
227
|
+
* present-but-wrong amount is strictly worse than an absent one, because
|
|
228
|
+
* nothing about it looks broken.
|
|
229
|
+
*
|
|
230
|
+
* So money lives on `payment.received`, where the denomination is ISO and
|
|
231
|
+
* provider-authoritative, and this event says only that an order exists. An
|
|
232
|
+
* integrator that needs the figures reads `GET /orders` under its own token,
|
|
233
|
+
* where the capability gate already lives.
|
|
234
|
+
*
|
|
235
|
+
* ⚠️ Rule 1 makes this reversible in the safe direction only: adding `total`
|
|
236
|
+
* and `currency` LATER, as optionals with a stated vocabulary, is additive.
|
|
237
|
+
* Shipping them now and discovering the mismatch would not be.
|
|
238
|
+
*
|
|
239
|
+
* ⚠️ **The MercadoLibre leg is AT-MOST-ONCE.** It rides the `orders_v2` SQS
|
|
240
|
+
* consumer's `outcome: 'created'` branch, so a record that commits the order
|
|
241
|
+
* and then dies before the fan-out is redelivered as `outcome: 'updated'` and
|
|
242
|
+
* emits nothing. The store users' new-order notification carries exactly the
|
|
243
|
+
* same exposure on exactly the same branch. The other three legs are
|
|
244
|
+
* exactly-once: each sits past a committed transaction inside the request that
|
|
245
|
+
* made it.
|
|
246
|
+
*
|
|
247
|
+
* ⚠️ **No order EDIT emits.** This fires on the write that creates the row and
|
|
248
|
+
* never again — not on a line change, a discount, a tender, a fulfilment move
|
|
249
|
+
* or a cancellation.
|
|
250
|
+
*/
|
|
251
|
+
export interface OrderCreatedPayload {
|
|
252
|
+
orderId: string;
|
|
253
|
+
source: OrderCreatedSource;
|
|
254
|
+
/**
|
|
255
|
+
* Server-stamped Unix milliseconds, taken at the post-commit emit.
|
|
256
|
+
*
|
|
257
|
+
* ⚠️ **NOT `Order.createdAt`.** It is within milliseconds of it (the emit
|
|
258
|
+
* sits on the commit's own tail, in the same invocation), but it is the
|
|
259
|
+
* moment the api ANNOUNCED the order, not the stamp the row carries. Same
|
|
260
|
+
* convention, and same reason, as `crossedAt` on the stock payloads: it is
|
|
261
|
+
* uniformly in scope at every seam, so it can be REQUIRED and can never be
|
|
262
|
+
* subtly wrong at one of them.
|
|
263
|
+
*
|
|
264
|
+
* ⚠️ A subscriber that falls back to RECEIPT time gets this wrong under
|
|
265
|
+
* delivery retry, and retry is live (5 attempts with backoff).
|
|
266
|
+
*/
|
|
267
|
+
occurredAt: number;
|
|
268
|
+
/**
|
|
269
|
+
* The order's customer.
|
|
270
|
+
*
|
|
271
|
+
* Present on the three synchronous legs without exception — a POS walk-in
|
|
272
|
+
* has no NAMED customer but is minted against the store's system customer
|
|
273
|
+
* row, so `Order.customerId` is never empty. Absent only on the
|
|
274
|
+
* MercadoLibre leg when the post-write order re-read came back empty: that
|
|
275
|
+
* is the same read that gates the operator broadcast beside it, and when it
|
|
276
|
+
* vanishes the api genuinely does not know the buyer at that instant.
|
|
277
|
+
*/
|
|
278
|
+
customerId?: string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Payload for `invoice.generated` — ARCA authorised a fiscal voucher and its
|
|
282
|
+
* `INVOICE#{storeId}` row is durable.
|
|
283
|
+
*
|
|
284
|
+
* ── WHAT COUNTS AS "GENERATED" ───────────────────────────────────────────
|
|
285
|
+
*
|
|
286
|
+
* Exactly the statuses `isFiscalStatusDeliverable` admits: `authorized_cae`,
|
|
287
|
+
* `authorized_caea` and `caea_reported`. A `pending_cae` row (written when
|
|
288
|
+
* ARCA was unreachable) and a `rejected` one are NOT events here — the first
|
|
289
|
+
* fires later, from the outage drain, once a real CAE lands; the second never
|
|
290
|
+
* fires at all.
|
|
291
|
+
*
|
|
292
|
+
* ⚠️ **Never gate an emit on `cae !== ''`.** `authorized_caea` carries a
|
|
293
|
+
* `caea` and an empty `cae`, so that test silently drops every CAEA voucher —
|
|
294
|
+
* which is precisely the contingency path a store is on when ARCA is down and
|
|
295
|
+
* an integrator most needs to hear from us.
|
|
296
|
+
*
|
|
297
|
+
* ── CREDIT AND DEBIT NOTES ARE THIS EVENT ────────────────────────────────
|
|
298
|
+
*
|
|
299
|
+
* An NC/ND reaches the same authorisation chokepoint as a Factura, is archived
|
|
300
|
+
* the same way, is broadcast the same way, and the outage drain settles it the
|
|
301
|
+
* same way. It is discriminated by `invoiceType` (the ARCA CbteTipo), which is
|
|
302
|
+
* a NUMBER rather than a union precisely so a new voucher type is not a
|
|
303
|
+
* union-widening breaking change under rule 1. Excluding notes would leave an
|
|
304
|
+
* integrator reconciling fiscal documents short by every reversal — a silence
|
|
305
|
+
* it could not distinguish from "no note was issued".
|
|
306
|
+
*
|
|
307
|
+
* ⚠️ **There is no `pdfUrl`, and one cannot be added by populating a field.**
|
|
308
|
+
* No stable or presigned invoice-PDF URL exists anywhere in this system: the
|
|
309
|
+
* PDF is rendered on demand and returned as a base64 data URI through the
|
|
310
|
+
* authenticated `GET /invoices` route, the S3 cold archive holds JSON, and the
|
|
311
|
+
* email path attaches bytes. A URL would be a new design decision about
|
|
312
|
+
* lifetime and authentication, not a field to fill in.
|
|
313
|
+
*
|
|
314
|
+
* ⚠️ **No receptor identity, ever.** `razonSocial`, `cuit`, `cuitType`,
|
|
315
|
+
* `address` and `location` all sit on the row this payload is built beside and
|
|
316
|
+
* are all personal data under Ley 25.326 leaving our network to a
|
|
317
|
+
* tenant-registered URL. `cae`, `caea`, `invoiceNumber` and `pointOfSale` are
|
|
318
|
+
* fiscal codes, not personal data, and are safe. This is why the payload is
|
|
319
|
+
* ENUMERATED: a spread of the invoice row ships the receptor's identity.
|
|
320
|
+
*
|
|
321
|
+
* ⚠️ **No `total` and no `currency`**, for the same denomination reason as
|
|
322
|
+
* {@link OrderCreatedPayload}, plus one specific to this row: on the WSFEX
|
|
323
|
+
* export path `Invoice.total` is the ARS peso base while the voucher itself is
|
|
324
|
+
* denominated in a foreign currency, so the stored figure is not the amount the
|
|
325
|
+
* voucher declares.
|
|
326
|
+
*/
|
|
327
|
+
export interface InvoiceGeneratedPayload {
|
|
328
|
+
invoiceId: string;
|
|
329
|
+
orderId: string;
|
|
330
|
+
customerId: string;
|
|
331
|
+
/**
|
|
332
|
+
* ARCA CbteTipo — 1/6 Factura A/B, 3/8 NC, 2/7 ND, 19 Factura E (export), …
|
|
333
|
+
*
|
|
334
|
+
* A `number`, deliberately: the ARCA codeset grows, and under rule 1 a
|
|
335
|
+
* widened union would break every exhaustive subscriber while a wider number
|
|
336
|
+
* range does not.
|
|
337
|
+
*/
|
|
338
|
+
invoiceType: number;
|
|
339
|
+
pointOfSale: number;
|
|
340
|
+
invoiceNumber: number;
|
|
341
|
+
/**
|
|
342
|
+
* The deliverable subset of `FiscalStatus`, never the full union.
|
|
343
|
+
*
|
|
344
|
+
* ⚠️ Widening this to a fourth member is a BREAKING change under rule 1 and
|
|
345
|
+
* mints a new event string.
|
|
346
|
+
*
|
|
347
|
+
* ⚠️ `caea_reported` is admitted by the gate but emitted by NO seam today —
|
|
348
|
+
* it is the post-Inform status of a voucher that was already announced as
|
|
349
|
+
* `authorized_caea`, and re-announcing the same voucher on its Inform would
|
|
350
|
+
* be a duplicate, not a new fiscal document. It is in the union because the
|
|
351
|
+
* gate (`isFiscalStatusDeliverable`) admits it and narrowing the union later
|
|
352
|
+
* would be the breaking direction; a subscriber should treat it as reserved.
|
|
353
|
+
*/
|
|
354
|
+
fiscalStatus: 'authorized_cae' | 'authorized_caea' | 'caea_reported';
|
|
355
|
+
/** ARCA CAE. Present iff `fiscalStatus === 'authorized_cae'`. */
|
|
356
|
+
cae?: string;
|
|
357
|
+
/** ARCA CAEA. Present iff `fiscalStatus` is `authorized_caea` or `caea_reported`. */
|
|
358
|
+
caea?: string;
|
|
359
|
+
/**
|
|
360
|
+
* Expiry as ARCA returned it, `YYYYMMDD`.
|
|
361
|
+
*
|
|
362
|
+
* ⚠️ It does NOT mean the same thing on both branches. Under
|
|
363
|
+
* `authorized_cae` it is the CAE's own `FchVto`. Under `authorized_caea` it
|
|
364
|
+
* is the CAEA PERIOD's `validTo` — a CAEA has no per-voucher expiry, so the
|
|
365
|
+
* field carries the fortnight's end and is shared by every voucher stamped
|
|
366
|
+
* in that period. Read it together with `fiscalStatus`, never alone.
|
|
367
|
+
*
|
|
368
|
+
* Optional because the value is omitted when empty rather than sent blank.
|
|
369
|
+
*/
|
|
370
|
+
caeExpiration?: string;
|
|
371
|
+
/**
|
|
372
|
+
* Server-stamped Unix milliseconds at the post-commit emit — the moment
|
|
373
|
+
* authorisation became durable here, NOT the voucher's `dated` (its fiscal
|
|
374
|
+
* date) and NOT `Invoice.createdAt`. Same convention and same reason as
|
|
375
|
+
* {@link OrderCreatedPayload.occurredAt}.
|
|
376
|
+
*
|
|
377
|
+
* ⚠️ On the ARCA-outage drain this is the DRAIN's clock, hours or days after
|
|
378
|
+
* the sale — which is the honest answer to "when was this authorised".
|
|
379
|
+
*/
|
|
380
|
+
occurredAt: number;
|
|
381
|
+
}
|
package/dist/webhook.js
CHANGED
|
@@ -66,6 +66,24 @@ export const WEBHOOK_EVENT_TYPES = [
|
|
|
66
66
|
'payment.received',
|
|
67
67
|
'product.stock_low',
|
|
68
68
|
'product.stock_out',
|
|
69
|
+
'order.created',
|
|
70
|
+
'invoice.generated',
|
|
69
71
|
];
|
|
70
72
|
/** Terminal outcomes for a print job. Closed union — a job printed, or it failed. */
|
|
71
73
|
export const PRINT_JOB_SETTLED_OUTCOMES = ['printed', 'failed'];
|
|
74
|
+
/**
|
|
75
|
+
* Where an `order.created` event was minted.
|
|
76
|
+
*
|
|
77
|
+
* ⚠️ A CLOSED union, and rule 1 above applies to it with full force: a fifth
|
|
78
|
+
* order-minting path cannot be added here without breaking every subscriber
|
|
79
|
+
* that switches exhaustively — it mints `order.created.v2` instead. The four
|
|
80
|
+
* members are the complete set of paths that write an ORDER row today, each
|
|
81
|
+
* verified at its own post-commit fan-out, not a sample.
|
|
82
|
+
*
|
|
83
|
+
* `service_delivery` is the repair-shop handover: a `ready` → `delivered`
|
|
84
|
+
* transition mints an ordinary sale out of the counter lines the operator
|
|
85
|
+
* named. It is a real order, indistinguishable downstream from a till sale,
|
|
86
|
+
* and it is the one path whose existence an integrator would otherwise never
|
|
87
|
+
* learn about.
|
|
88
|
+
*/
|
|
89
|
+
export const ORDER_CREATED_SOURCES = ['pos', 'storefront', 'service_delivery', 'mercadolibre'];
|