platform-types 1.10.747 → 1.10.749
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/print.js +37 -1
- package/dist/order.d.ts +12 -15
- package/dist/payment.d.ts +35 -0
- package/dist/print.d.ts +116 -4
- package/dist/print.js +36 -0
- package/package.json +1 -1
package/dist/cjs/print.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LABEL_TEMPLATE_IDS = void 0;
|
|
3
|
+
exports.PRINT_DISPATCH_SKIP_REASONS = exports.LABEL_TEMPLATE_IDS = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* The five label footprints the app's `LABEL_TEMPLATES` ships; `^PW`/`^LL`
|
|
6
6
|
* presets on the api's ZPL producer.
|
|
@@ -19,3 +19,39 @@ exports.LABEL_TEMPLATE_IDS = void 0;
|
|
|
19
19
|
* consumer; treat it as a set. `producto` is the default template.
|
|
20
20
|
*/
|
|
21
21
|
exports.LABEL_TEMPLATE_IDS = ['producto', 'precio', 'estante', 'envio', 'inventario'];
|
|
22
|
+
/**
|
|
23
|
+
* Why the BE dispatch did not hand a print job to a connection — the four codes
|
|
24
|
+
* `wsPostPrinter` writes as `PrintJobSummary.errorCode` and reports per job in
|
|
25
|
+
* {@link PrintDispatchOutcome}.
|
|
26
|
+
*
|
|
27
|
+
* - `AGENT_OFFLINE` — the connection exists but its agent stopped heartbeating;
|
|
28
|
+
* or the agent has no connection at all although the job named it (a targeted
|
|
29
|
+
* agent's socket vanished before dispatch, or none of the agents a job was
|
|
30
|
+
* narrowed to is connected — one entry per named agent).
|
|
31
|
+
* - `PRINTER_INACTIVE` — the resolved rule names a printer the operator paused, the
|
|
32
|
+
* registry no longer holds, or the agent's latest printer report left out
|
|
33
|
+
* (unplugged or renamed).
|
|
34
|
+
* - `PRINTER_RAW_UNSUPPORTED` — a raw job (ESC/POS, ZPL) resolved to a printer
|
|
35
|
+
* that never declared that dialect, or resolved no rule at all; routing fails
|
|
36
|
+
* CLOSED rather than send a control stream to an unknown printer. The two
|
|
37
|
+
* causes are told apart by `printerId` — see {@link PrintDispatchOutcome}.
|
|
38
|
+
* - `NO_PRINTER_CONNECTED` — emitted only when the job reached nobody and skipped
|
|
39
|
+
* nobody without naming an agent: the store has no printer connection at all
|
|
40
|
+
* (or the job was narrowed to an empty agent list). A job that named its agents
|
|
41
|
+
* and found none of them connected is `AGENT_OFFLINE` instead.
|
|
42
|
+
*
|
|
43
|
+
* A runtime value, not `declare global`, for the same reason as
|
|
44
|
+
* `LABEL_TEMPLATE_IDS`: a client switches on these codes and may need to
|
|
45
|
+
* enumerate them. The api's `printRouting.ts` constants are checked against this
|
|
46
|
+
* tuple with `satisfies`, so a code cannot be spelled two ways.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { PRINT_DISPATCH_SKIP_REASONS, type PrintDispatchSkipReason } from 'platform-types';
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
exports.PRINT_DISPATCH_SKIP_REASONS = [
|
|
53
|
+
'AGENT_OFFLINE',
|
|
54
|
+
'PRINTER_INACTIVE',
|
|
55
|
+
'PRINTER_RAW_UNSUPPORTED',
|
|
56
|
+
'NO_PRINTER_CONNECTED',
|
|
57
|
+
];
|
package/dist/order.d.ts
CHANGED
|
@@ -1641,24 +1641,21 @@ declare global {
|
|
|
1641
1641
|
interface LinkedPaymentEntry {
|
|
1642
1642
|
source: 'mp' | 'stripe' | 'mp_movement';
|
|
1643
1643
|
/**
|
|
1644
|
-
* The amount this
|
|
1645
|
-
* — **not** the amount originally settled. It is what
|
|
1644
|
+
* The amount this payment counts toward the order. It is what
|
|
1646
1645
|
* `deriveOrderFinancialAxis` sums, so it has to mean money the order can
|
|
1647
1646
|
* still count.
|
|
1648
1647
|
*
|
|
1649
|
-
* ⚠️
|
|
1650
|
-
*
|
|
1651
|
-
*
|
|
1652
|
-
*
|
|
1653
|
-
*
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
*
|
|
1659
|
-
*
|
|
1660
|
-
* A consumer reconciling against provider refund history will find those
|
|
1661
|
-
* rows disagree, and the disagreement is the back catalogue, not a bug.
|
|
1648
|
+
* ⚠️ **No writer shrinks it on a refund.** A refund or settled chargeback
|
|
1649
|
+
* MercadoPago reports later is detected and recorded on the payment's
|
|
1650
|
+
* status observation, never here: the entry keeps its linked figure until
|
|
1651
|
+
* the operator mirrors the refund by hand (an unlink removes the entry).
|
|
1652
|
+
* Entries on HISTORICAL orders may carry a smaller figure (or be gone):
|
|
1653
|
+
* the removed outbound MercadoPago refund lowered a partially refunded
|
|
1654
|
+
* entry to its un-refunded remainder and removed an exhausted one, and
|
|
1655
|
+
* those rows keep what it wrote. Entries written before that refund
|
|
1656
|
+
* existed carry their pre-refund figure; nothing is backfilled either way,
|
|
1657
|
+
* so a consumer reconciling against provider refund history will find
|
|
1658
|
+
* rows that disagree, and the disagreement is the back catalogue, not a bug.
|
|
1662
1659
|
*
|
|
1663
1660
|
* ⚠️ Denominated in `currency` below — the PAYMENT's denomination, not the
|
|
1664
1661
|
* order's. Never sum this field across entries without converting.
|
package/dist/payment.d.ts
CHANGED
|
@@ -35,6 +35,41 @@ declare global {
|
|
|
35
35
|
source: PaymentReceivedSource;
|
|
36
36
|
paidAt: number;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* MercadoPago's CUMULATIVE refunded amount for this payment, in its own currency
|
|
40
|
+
* (`transaction_amount_refunded`, else the sum of `refunds[]` with status
|
|
41
|
+
* `approved`; never less than the full `amount` on `providerStatus: 'refunded'`). Written by
|
|
42
|
+
* the payment status service (`mercadopagoPaymentStatus.ts`) on every observation
|
|
43
|
+
* — the webhook and the poller's re-check alike. Absent means none observed, never
|
|
44
|
+
* an unknown. Present ⇒ a link refuses the payment (`LINK_LOCKED` `refunded-payment`).
|
|
45
|
+
*/
|
|
46
|
+
refundedAmount?: number;
|
|
47
|
+
/**
|
|
48
|
+
* MercadoPago's `refunds[]` as last observed, same writer: `id` is MercadoPago's
|
|
49
|
+
* numeric refund id as a string, `amount` in the payment's currency, `status` as
|
|
50
|
+
* MercadoPago states it (`approved` once the money moved, `in_process` before), and
|
|
51
|
+
* `at` its `date_created` in epoch ms. Absent when MercadoPago listed none.
|
|
52
|
+
*/
|
|
53
|
+
refunds?: {
|
|
54
|
+
id: string;
|
|
55
|
+
amount: number;
|
|
56
|
+
status: string;
|
|
57
|
+
at: number;
|
|
58
|
+
}[];
|
|
59
|
+
/**
|
|
60
|
+
* A dispute on the payment, same writer: present while `providerStatus` is
|
|
61
|
+
* `charged_back` or `in_mediation`. A later observation that shows neither clears it,
|
|
62
|
+
* except a SETTLED chargeback, which is kept through a later `approved`. On
|
|
63
|
+
* `charged_back`, `statusDetail` says what happened to the money: `settled` (taken for
|
|
64
|
+
* the full amount — reported for the operator to mirror by hand; the books are not
|
|
65
|
+
* changed), `reimbursed` (MercadoPago covered the seller) or `in_process` (still
|
|
66
|
+
* open). Any other detail, and a mediation, reads as still open. Present ⇒ a link
|
|
67
|
+
* refuses the payment.
|
|
68
|
+
*/
|
|
69
|
+
chargeback?: {
|
|
70
|
+
status: string;
|
|
71
|
+
statusDetail?: string;
|
|
72
|
+
};
|
|
38
73
|
}
|
|
39
74
|
/** GET /payments/pending returns this page inside the standard data envelope. */
|
|
40
75
|
interface MpPaymentObservationPage {
|
package/dist/print.d.ts
CHANGED
|
@@ -17,6 +17,113 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const LABEL_TEMPLATE_IDS: readonly ["producto", "precio", "estante", "envio", "inventario"];
|
|
19
19
|
export type LabelTemplateId = (typeof LABEL_TEMPLATE_IDS)[number];
|
|
20
|
+
/**
|
|
21
|
+
* Why the BE dispatch did not hand a print job to a connection — the four codes
|
|
22
|
+
* `wsPostPrinter` writes as `PrintJobSummary.errorCode` and reports per job in
|
|
23
|
+
* {@link PrintDispatchOutcome}.
|
|
24
|
+
*
|
|
25
|
+
* - `AGENT_OFFLINE` — the connection exists but its agent stopped heartbeating;
|
|
26
|
+
* or the agent has no connection at all although the job named it (a targeted
|
|
27
|
+
* agent's socket vanished before dispatch, or none of the agents a job was
|
|
28
|
+
* narrowed to is connected — one entry per named agent).
|
|
29
|
+
* - `PRINTER_INACTIVE` — the resolved rule names a printer the operator paused, the
|
|
30
|
+
* registry no longer holds, or the agent's latest printer report left out
|
|
31
|
+
* (unplugged or renamed).
|
|
32
|
+
* - `PRINTER_RAW_UNSUPPORTED` — a raw job (ESC/POS, ZPL) resolved to a printer
|
|
33
|
+
* that never declared that dialect, or resolved no rule at all; routing fails
|
|
34
|
+
* CLOSED rather than send a control stream to an unknown printer. The two
|
|
35
|
+
* causes are told apart by `printerId` — see {@link PrintDispatchOutcome}.
|
|
36
|
+
* - `NO_PRINTER_CONNECTED` — emitted only when the job reached nobody and skipped
|
|
37
|
+
* nobody without naming an agent: the store has no printer connection at all
|
|
38
|
+
* (or the job was narrowed to an empty agent list). A job that named its agents
|
|
39
|
+
* and found none of them connected is `AGENT_OFFLINE` instead.
|
|
40
|
+
*
|
|
41
|
+
* A runtime value, not `declare global`, for the same reason as
|
|
42
|
+
* `LABEL_TEMPLATE_IDS`: a client switches on these codes and may need to
|
|
43
|
+
* enumerate them. The api's `printRouting.ts` constants are checked against this
|
|
44
|
+
* tuple with `satisfies`, so a code cannot be spelled two ways.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { PRINT_DISPATCH_SKIP_REASONS, type PrintDispatchSkipReason } from 'platform-types';
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const PRINT_DISPATCH_SKIP_REASONS: readonly ["AGENT_OFFLINE", "PRINTER_INACTIVE", "PRINTER_RAW_UNSUPPORTED", "NO_PRINTER_CONNECTED"];
|
|
51
|
+
export type PrintDispatchSkipReason = (typeof PRINT_DISPATCH_SKIP_REASONS)[number];
|
|
52
|
+
/**
|
|
53
|
+
* What the BE dispatch of ONE print job did, as of the moment the handler
|
|
54
|
+
* answered. Written by `wsPostPrinter` and returned by the handlers that queue
|
|
55
|
+
* jobs: `POST /orders {mode:'receipt'}` and `POST /products {mode:'tag'}`.
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ `reached > 0` means the frame was queued to that many live agent
|
|
58
|
+
* connections — NOT that paper came out. The agent's ack settles the job
|
|
59
|
+
* (`printed`/`error`) later, on the job's state timeline.
|
|
60
|
+
*
|
|
61
|
+
* `reached === 0` always comes with at least one `skipped` entry. A job narrowed
|
|
62
|
+
* to agents none of which is connected carries one `{ reason: 'AGENT_OFFLINE', agentId }`
|
|
63
|
+
* per named agent; any other job that reached nobody and skipped nobody carries
|
|
64
|
+
* one `{ reason: 'NO_PRINTER_CONNECTED' }`. Either way it is the same code the
|
|
65
|
+
* job's terminal `error` row records. A job can also be mixed — reached some
|
|
66
|
+
* connections and skipped others.
|
|
67
|
+
*/
|
|
68
|
+
export interface PrintDispatchOutcome {
|
|
69
|
+
jobId: string;
|
|
70
|
+
/** How many printer connections the frame was queued to. */
|
|
71
|
+
reached: number;
|
|
72
|
+
/**
|
|
73
|
+
* One entry per connection the dispatch deliberately left out (or per named
|
|
74
|
+
* agent that had no connection), each with ONE reason (never the `+`-joined
|
|
75
|
+
* form `PrintJobSummary.errorCode` can carry). `agentId`/`printerId` are
|
|
76
|
+
* present when known: `printerId` is the printer the rule resolved to, and
|
|
77
|
+
* both are absent on `NO_PRINTER_CONNECTED`.
|
|
78
|
+
*
|
|
79
|
+
* `PRINTER_RAW_UNSUPPORTED` WITHOUT `printerId`: no rule could be resolved for
|
|
80
|
+
* the job's use case on that agent — no `PrintRule` for it, a connection with
|
|
81
|
+
* no `agentId` yet, or a job sent with no use case — so no printer could be
|
|
82
|
+
* verified (fix: add a rule). WITH `printerId`: a rule routed the job to that
|
|
83
|
+
* printer, which does not declare the raw format (fix: declare the format on
|
|
84
|
+
* the printer).
|
|
85
|
+
*/
|
|
86
|
+
skipped: {
|
|
87
|
+
reason: PrintDispatchSkipReason;
|
|
88
|
+
agentId?: string;
|
|
89
|
+
printerId?: string;
|
|
90
|
+
}[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The `data` shape of the handlers that report each queued print job's dispatch
|
|
94
|
+
* outcome: the order receipt, the invoice ESC/POS receipt and the product tag.
|
|
95
|
+
* Other print endpoints (`POST /print`, the invoice PDF print, the test page)
|
|
96
|
+
* still answer `{ jobId }` without `outcomes`. `OrderReceiptPrintData`,
|
|
97
|
+
* `InvoiceReceiptPrintData` and `ProductTagPrintData` are this shape under the name
|
|
98
|
+
* of the endpoint that returns it — aliases rather than empty `extends`, which
|
|
99
|
+
* `@typescript-eslint/no-empty-object-type` refuses.
|
|
100
|
+
*/
|
|
101
|
+
export interface PrintJobsQueuedData {
|
|
102
|
+
/** `jobIds[0]` — kept for clients that read a single id. */
|
|
103
|
+
jobId: string;
|
|
104
|
+
jobIds: string[];
|
|
105
|
+
/** One per job, index-aligned with `jobIds`. */
|
|
106
|
+
outcomes: PrintDispatchOutcome[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `data` of `POST /orders {mode:'receipt'}`, written by `orders/_receipt.ts`.
|
|
110
|
+
* One job per distinct printer render profile, so a store whose printers
|
|
111
|
+
* disagree on `columns`/`drawerKick` gets several.
|
|
112
|
+
*/
|
|
113
|
+
export type OrderReceiptPrintData = PrintJobsQueuedData;
|
|
114
|
+
/**
|
|
115
|
+
* `data` of the invoice ESC/POS receipt (`POST /invoices {mode:'printEscpos'}`),
|
|
116
|
+
* written by `invoices/_printEscpos.ts` — one job per printer render profile, as
|
|
117
|
+
* for the order receipt.
|
|
118
|
+
*/
|
|
119
|
+
export type InvoiceReceiptPrintData = PrintJobsQueuedData;
|
|
120
|
+
/**
|
|
121
|
+
* `data` of `POST /products {mode:'tag', notifyCloudPrint: true}`, written by
|
|
122
|
+
* `products/_tag.ts`: the ZPL job (when the store has a `zpl` agent) first, then
|
|
123
|
+
* one PDF job per requested item — unless the store has `zpl` agents and no PDF
|
|
124
|
+
* agent, when there is no PDF job at all.
|
|
125
|
+
*/
|
|
126
|
+
export type ProductTagPrintData = PrintJobsQueuedData;
|
|
20
127
|
declare global {
|
|
21
128
|
type PrintJobState = 'queued' | 'sent' | 'printed' | 'error' | 'cancelled';
|
|
22
129
|
type PrintContentType = 'pdf_uri' | 'pdf_base64' | 'raw_uri' | 'raw_base64';
|
|
@@ -83,8 +190,11 @@ declare global {
|
|
|
83
190
|
interface PrintAgentSummary {
|
|
84
191
|
/**
|
|
85
192
|
* Stable per-install id the agent mints on first run and reuses. The right
|
|
86
|
-
* handle for list keys and future per-agent actions.
|
|
87
|
-
*
|
|
193
|
+
* handle for list keys and future per-agent actions. Resolved the way
|
|
194
|
+
* dispatch resolves it: a connection whose listing copy carries none gets a
|
|
195
|
+
* consistent read of its own SOCKET row. Absent only when that leaves it
|
|
196
|
+
* unresolved — a pre-heartbeat build that never reported one, or a failed
|
|
197
|
+
* read — so a UI still needs a fallback label.
|
|
88
198
|
*/
|
|
89
199
|
agentId?: string;
|
|
90
200
|
/** This connection's own liveness — NOT the store-wide aggregate. */
|
|
@@ -444,8 +554,10 @@ declare global {
|
|
|
444
554
|
detail?: string;
|
|
445
555
|
/**
|
|
446
556
|
* Machine-readable failure classification, when one is recognised. BE-side
|
|
447
|
-
* dispatch
|
|
448
|
-
*
|
|
557
|
+
* dispatch (`wsPostPrinter`) writes one of `PrintDispatchSkipReason` —
|
|
558
|
+
* `AGENT_OFFLINE` / `PRINTER_INACTIVE` / `PRINTER_RAW_UNSUPPORTED` /
|
|
559
|
+
* `NO_PRINTER_CONNECTED` — or, when skips disagree, the distinct codes
|
|
560
|
+
* sorted and joined by `+`; an agent `ACK_FAILED` can classify to `PRINTER_PAUSED` /
|
|
449
561
|
* `NO_PRINTER_ASSIGNED` / `PRINTER_NOT_FOUND`. Unrecognised agent
|
|
450
562
|
* text stays in `detail` only, so absence of a code does NOT mean success.
|
|
451
563
|
*/
|
package/dist/print.js
CHANGED
|
@@ -16,3 +16,39 @@
|
|
|
16
16
|
* consumer; treat it as a set. `producto` is the default template.
|
|
17
17
|
*/
|
|
18
18
|
export const LABEL_TEMPLATE_IDS = ['producto', 'precio', 'estante', 'envio', 'inventario'];
|
|
19
|
+
/**
|
|
20
|
+
* Why the BE dispatch did not hand a print job to a connection — the four codes
|
|
21
|
+
* `wsPostPrinter` writes as `PrintJobSummary.errorCode` and reports per job in
|
|
22
|
+
* {@link PrintDispatchOutcome}.
|
|
23
|
+
*
|
|
24
|
+
* - `AGENT_OFFLINE` — the connection exists but its agent stopped heartbeating;
|
|
25
|
+
* or the agent has no connection at all although the job named it (a targeted
|
|
26
|
+
* agent's socket vanished before dispatch, or none of the agents a job was
|
|
27
|
+
* narrowed to is connected — one entry per named agent).
|
|
28
|
+
* - `PRINTER_INACTIVE` — the resolved rule names a printer the operator paused, the
|
|
29
|
+
* registry no longer holds, or the agent's latest printer report left out
|
|
30
|
+
* (unplugged or renamed).
|
|
31
|
+
* - `PRINTER_RAW_UNSUPPORTED` — a raw job (ESC/POS, ZPL) resolved to a printer
|
|
32
|
+
* that never declared that dialect, or resolved no rule at all; routing fails
|
|
33
|
+
* CLOSED rather than send a control stream to an unknown printer. The two
|
|
34
|
+
* causes are told apart by `printerId` — see {@link PrintDispatchOutcome}.
|
|
35
|
+
* - `NO_PRINTER_CONNECTED` — emitted only when the job reached nobody and skipped
|
|
36
|
+
* nobody without naming an agent: the store has no printer connection at all
|
|
37
|
+
* (or the job was narrowed to an empty agent list). A job that named its agents
|
|
38
|
+
* and found none of them connected is `AGENT_OFFLINE` instead.
|
|
39
|
+
*
|
|
40
|
+
* A runtime value, not `declare global`, for the same reason as
|
|
41
|
+
* `LABEL_TEMPLATE_IDS`: a client switches on these codes and may need to
|
|
42
|
+
* enumerate them. The api's `printRouting.ts` constants are checked against this
|
|
43
|
+
* tuple with `satisfies`, so a code cannot be spelled two ways.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { PRINT_DISPATCH_SKIP_REASONS, type PrintDispatchSkipReason } from 'platform-types';
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export const PRINT_DISPATCH_SKIP_REASONS = [
|
|
50
|
+
'AGENT_OFFLINE',
|
|
51
|
+
'PRINTER_INACTIVE',
|
|
52
|
+
'PRINTER_RAW_UNSUPPORTED',
|
|
53
|
+
'NO_PRINTER_CONNECTED',
|
|
54
|
+
];
|