platform-types 1.10.800 → 1.10.801
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/refundObligation.js +65 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/refundObligation.d.ts +127 -0
- package/dist/refundObligation.js +62 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -93,6 +93,7 @@ __exportStar(require("./productGroup.js"), exports);
|
|
|
93
93
|
__exportStar(require("./purchaseOrder.js"), exports);
|
|
94
94
|
__exportStar(require("./purchaseReceipt.js"), exports);
|
|
95
95
|
__exportStar(require("./pushDevice.js"), exports);
|
|
96
|
+
__exportStar(require("./refundObligation.js"), exports);
|
|
96
97
|
__exportStar(require("./reminder.js"), exports);
|
|
97
98
|
__exportStar(require("./report.js"), exports);
|
|
98
99
|
__exportStar(require("./return.js"), exports);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Refund obligations — money the store owes a customer back, tracked until it is
|
|
4
|
+
* proven returned.
|
|
5
|
+
*
|
|
6
|
+
* An obligation is created inside the transaction of whatever made the money owed
|
|
7
|
+
* (a purchase withdrawal's cancellation, a return, a late capture on a withdrawn
|
|
8
|
+
* order) and closes on its own when Mercado Pago reports the refund, when an
|
|
9
|
+
* operator closes a payment attempt's resolution as `refunded`, or when a
|
|
10
|
+
* chargeback settled the money back. An open dispute holds it; a lifted dispute
|
|
11
|
+
* reopens it. Nothing here moves money or writes a ledger row: closure records a
|
|
12
|
+
* fact.
|
|
13
|
+
*
|
|
14
|
+
* ⚠️ The stored row carries none of the main table's index-key attributes
|
|
15
|
+
* (`status`, `customerId`, `dated`, `updatedAt`, `terminalId`, `inboxKey`), so it
|
|
16
|
+
* joins no GSI: `state` replaces `status`, `revisedAt` replaces `updatedAt`.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.REFUND_OBLIGATION_DUE_SOURCE = exports.REFUND_OBLIGATION_CLOSED_BY = exports.REFUND_OBLIGATION_HOLD_REASONS = exports.REFUND_OBLIGATION_STATES = exports.REFUND_OBLIGATION_KINDS = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* - `provider` — paid through Mercado Pago; closes when the provider reports the
|
|
22
|
+
* refund (`paymentId` is set).
|
|
23
|
+
* - `offline` — paid by other means (cash, transfer); has no `paymentId` and
|
|
24
|
+
* closes only by an operator.
|
|
25
|
+
* - `late-capture` — an approval that arrived after the order no longer wanted
|
|
26
|
+
* it; closes when the provider reports the refund or when the attempt's
|
|
27
|
+
* resolution is closed `refunded` after it was created — never because the
|
|
28
|
+
* attempt reached `refunded`.
|
|
29
|
+
*/
|
|
30
|
+
exports.REFUND_OBLIGATION_KINDS = ['provider', 'offline', 'late-capture'];
|
|
31
|
+
/**
|
|
32
|
+
* - `awaiting-goods` — owed once the goods are back; no due date yet.
|
|
33
|
+
* - `open` — owed, with a `refundDueAt`.
|
|
34
|
+
* - `overdue` — past `refundDueAt` and still owed.
|
|
35
|
+
* - `held` — a dispute on the payment holds it (`holdReason`); no due pointer.
|
|
36
|
+
* - `closed` — settled; `closure` says how. Terminal.
|
|
37
|
+
*/
|
|
38
|
+
exports.REFUND_OBLIGATION_STATES = ['awaiting-goods', 'open', 'overdue', 'held', 'closed'];
|
|
39
|
+
/**
|
|
40
|
+
* Why an obligation is `held`. `dispute-open` reopens on its own once the
|
|
41
|
+
* dispute is lifted; `reimbursed` (Mercado Pago covered the seller) never does —
|
|
42
|
+
* only an operator's decision moves it. A stored row with no `holdReason` reads
|
|
43
|
+
* as `dispute-open`.
|
|
44
|
+
*/
|
|
45
|
+
exports.REFUND_OBLIGATION_HOLD_REASONS = ['dispute-open', 'reimbursed'];
|
|
46
|
+
/**
|
|
47
|
+
* What closed an obligation.
|
|
48
|
+
*
|
|
49
|
+
* - `detected-refund` — Mercado Pago's cumulative refunded amount, net of what
|
|
50
|
+
* was refunded before the obligation existed, covers it.
|
|
51
|
+
* - `resolution-refunded` — an operator closed the payment attempt's resolution
|
|
52
|
+
* as `refunded` after the obligation was created.
|
|
53
|
+
* - `operator` — an operator closed it by hand.
|
|
54
|
+
* - `chargeback` — a settled chargeback took the money back.
|
|
55
|
+
* - `api-refund` — a refund the api itself made (reserved; no writer yet).
|
|
56
|
+
*/
|
|
57
|
+
exports.REFUND_OBLIGATION_CLOSED_BY = [
|
|
58
|
+
'detected-refund',
|
|
59
|
+
'resolution-refunded',
|
|
60
|
+
'operator',
|
|
61
|
+
'chargeback',
|
|
62
|
+
'api-refund',
|
|
63
|
+
];
|
|
64
|
+
/** Where a {@link StatutoryInstant} came from: the platform global it was computed with. */
|
|
65
|
+
exports.REFUND_OBLIGATION_DUE_SOURCE = 'global:refundObligationDueDays';
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ export * from './productGroup.ts';
|
|
|
69
69
|
export * from './purchaseOrder.ts';
|
|
70
70
|
export * from './purchaseReceipt.ts';
|
|
71
71
|
export * from './pushDevice.ts';
|
|
72
|
+
export * from './refundObligation.ts';
|
|
72
73
|
export * from './reminder.ts';
|
|
73
74
|
export * from './report.ts';
|
|
74
75
|
export * from './return.ts';
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ export * from "./productGroup.js";
|
|
|
77
77
|
export * from "./purchaseOrder.js";
|
|
78
78
|
export * from "./purchaseReceipt.js";
|
|
79
79
|
export * from "./pushDevice.js";
|
|
80
|
+
export * from "./refundObligation.js";
|
|
80
81
|
export * from "./reminder.js";
|
|
81
82
|
export * from "./report.js";
|
|
82
83
|
export * from "./return.js";
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refund obligations — money the store owes a customer back, tracked until it is
|
|
3
|
+
* proven returned.
|
|
4
|
+
*
|
|
5
|
+
* An obligation is created inside the transaction of whatever made the money owed
|
|
6
|
+
* (a purchase withdrawal's cancellation, a return, a late capture on a withdrawn
|
|
7
|
+
* order) and closes on its own when Mercado Pago reports the refund, when an
|
|
8
|
+
* operator closes a payment attempt's resolution as `refunded`, or when a
|
|
9
|
+
* chargeback settled the money back. An open dispute holds it; a lifted dispute
|
|
10
|
+
* reopens it. Nothing here moves money or writes a ledger row: closure records a
|
|
11
|
+
* fact.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ The stored row carries none of the main table's index-key attributes
|
|
14
|
+
* (`status`, `customerId`, `dated`, `updatedAt`, `terminalId`, `inboxKey`), so it
|
|
15
|
+
* joins no GSI: `state` replaces `status`, `revisedAt` replaces `updatedAt`.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* - `provider` — paid through Mercado Pago; closes when the provider reports the
|
|
19
|
+
* refund (`paymentId` is set).
|
|
20
|
+
* - `offline` — paid by other means (cash, transfer); has no `paymentId` and
|
|
21
|
+
* closes only by an operator.
|
|
22
|
+
* - `late-capture` — an approval that arrived after the order no longer wanted
|
|
23
|
+
* it; closes when the provider reports the refund or when the attempt's
|
|
24
|
+
* resolution is closed `refunded` after it was created — never because the
|
|
25
|
+
* attempt reached `refunded`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const REFUND_OBLIGATION_KINDS: readonly ["provider", "offline", "late-capture"];
|
|
28
|
+
/**
|
|
29
|
+
* - `awaiting-goods` — owed once the goods are back; no due date yet.
|
|
30
|
+
* - `open` — owed, with a `refundDueAt`.
|
|
31
|
+
* - `overdue` — past `refundDueAt` and still owed.
|
|
32
|
+
* - `held` — a dispute on the payment holds it (`holdReason`); no due pointer.
|
|
33
|
+
* - `closed` — settled; `closure` says how. Terminal.
|
|
34
|
+
*/
|
|
35
|
+
export declare const REFUND_OBLIGATION_STATES: readonly ["awaiting-goods", "open", "overdue", "held", "closed"];
|
|
36
|
+
/**
|
|
37
|
+
* Why an obligation is `held`. `dispute-open` reopens on its own once the
|
|
38
|
+
* dispute is lifted; `reimbursed` (Mercado Pago covered the seller) never does —
|
|
39
|
+
* only an operator's decision moves it. A stored row with no `holdReason` reads
|
|
40
|
+
* as `dispute-open`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const REFUND_OBLIGATION_HOLD_REASONS: readonly ["dispute-open", "reimbursed"];
|
|
43
|
+
/**
|
|
44
|
+
* What closed an obligation.
|
|
45
|
+
*
|
|
46
|
+
* - `detected-refund` — Mercado Pago's cumulative refunded amount, net of what
|
|
47
|
+
* was refunded before the obligation existed, covers it.
|
|
48
|
+
* - `resolution-refunded` — an operator closed the payment attempt's resolution
|
|
49
|
+
* as `refunded` after the obligation was created.
|
|
50
|
+
* - `operator` — an operator closed it by hand.
|
|
51
|
+
* - `chargeback` — a settled chargeback took the money back.
|
|
52
|
+
* - `api-refund` — a refund the api itself made (reserved; no writer yet).
|
|
53
|
+
*/
|
|
54
|
+
export declare const REFUND_OBLIGATION_CLOSED_BY: readonly ["detected-refund", "resolution-refunded", "operator", "chargeback", "api-refund"];
|
|
55
|
+
/** Where a {@link StatutoryInstant} came from: the platform global it was computed with. */
|
|
56
|
+
export declare const REFUND_OBLIGATION_DUE_SOURCE = "global:refundObligationDueDays";
|
|
57
|
+
declare global {
|
|
58
|
+
type RefundObligationKind = (typeof REFUND_OBLIGATION_KINDS)[number];
|
|
59
|
+
type RefundObligationState = (typeof REFUND_OBLIGATION_STATES)[number];
|
|
60
|
+
type RefundObligationHoldReason = (typeof REFUND_OBLIGATION_HOLD_REASONS)[number];
|
|
61
|
+
type RefundObligationClosedBy = (typeof REFUND_OBLIGATION_CLOSED_BY)[number];
|
|
62
|
+
/** A deadline and the rule that set it. */
|
|
63
|
+
interface StatutoryInstant {
|
|
64
|
+
/** Unix ms. */
|
|
65
|
+
at: number;
|
|
66
|
+
/** The rule it was computed from, e.g. `global:refundObligationDueDays`. */
|
|
67
|
+
source: string;
|
|
68
|
+
}
|
|
69
|
+
/** The link credit an obligation's money was booked to, when there is one. */
|
|
70
|
+
interface RefundObligationLedgerCredit {
|
|
71
|
+
/** The `ACCOUNT#{storeId}` row's SK. */
|
|
72
|
+
accountId: string;
|
|
73
|
+
/** The customer whose balance the credit moved. */
|
|
74
|
+
customerId: string;
|
|
75
|
+
}
|
|
76
|
+
/** How an obligation was closed. */
|
|
77
|
+
interface RefundObligationClosure {
|
|
78
|
+
by: RefundObligationClosedBy;
|
|
79
|
+
/** Unix ms. */
|
|
80
|
+
at: number;
|
|
81
|
+
/** The store user who closed it, for `operator`. */
|
|
82
|
+
actor?: string;
|
|
83
|
+
/** The operator's own words, for `operator`. */
|
|
84
|
+
reason?: string;
|
|
85
|
+
/** For `detected-refund`: the ids of the payment's `refunds[]` dated at or after `createdAt`. */
|
|
86
|
+
providerRefundIds?: string[];
|
|
87
|
+
}
|
|
88
|
+
interface RefundObligation {
|
|
89
|
+
/** The row's sort key: `{orderId}#{parentId}#{kind}#{paymentId | 'till'}`. */
|
|
90
|
+
obligationId: string;
|
|
91
|
+
orderId: string;
|
|
92
|
+
/** The withdrawal or RMA that made the money owed. */
|
|
93
|
+
parentId: string;
|
|
94
|
+
kind: RefundObligationKind;
|
|
95
|
+
/** The Mercado Pago payment the money came in on. Absent for `offline`. */
|
|
96
|
+
paymentId?: string;
|
|
97
|
+
/** Decimal, in `currency`. */
|
|
98
|
+
amount: number;
|
|
99
|
+
/** The payment's own currency: creation refuses another one the payment's observation names. */
|
|
100
|
+
currency: string;
|
|
101
|
+
/** The payment's refunded amount when the obligation was created, so an earlier refund never closes it. */
|
|
102
|
+
refundedAtCreation?: number;
|
|
103
|
+
/**
|
|
104
|
+
* The payment had no observation when the obligation was created: its baseline
|
|
105
|
+
* is then the payment's `approved` refunds dated before `createdAt`.
|
|
106
|
+
*/
|
|
107
|
+
observationAbsentAtCreation?: boolean;
|
|
108
|
+
ledgerCredit?: RefundObligationLedgerCredit;
|
|
109
|
+
state: RefundObligationState;
|
|
110
|
+
/** Set while `held`. */
|
|
111
|
+
holdReason?: RefundObligationHoldReason;
|
|
112
|
+
/** The state a hold came from; a reopen returns to it (`overdue` returns to `open`). */
|
|
113
|
+
heldFrom?: Exclude<RefundObligationState, 'held' | 'closed'>;
|
|
114
|
+
/** Bumped by every move, for a compare-and-set. */
|
|
115
|
+
revision: number;
|
|
116
|
+
/** When the refund is due. Set by the move to `open`; removed by a hold. */
|
|
117
|
+
refundDueAt?: StatutoryInstant;
|
|
118
|
+
/** The SK of the obligation's due pointer, while it has one. */
|
|
119
|
+
duePointerSK?: string;
|
|
120
|
+
closure?: RefundObligationClosure;
|
|
121
|
+
/** Unix ms. */
|
|
122
|
+
createdAt: number;
|
|
123
|
+
/** Unix ms of the last move. */
|
|
124
|
+
revisedAt: number;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refund obligations — money the store owes a customer back, tracked until it is
|
|
3
|
+
* proven returned.
|
|
4
|
+
*
|
|
5
|
+
* An obligation is created inside the transaction of whatever made the money owed
|
|
6
|
+
* (a purchase withdrawal's cancellation, a return, a late capture on a withdrawn
|
|
7
|
+
* order) and closes on its own when Mercado Pago reports the refund, when an
|
|
8
|
+
* operator closes a payment attempt's resolution as `refunded`, or when a
|
|
9
|
+
* chargeback settled the money back. An open dispute holds it; a lifted dispute
|
|
10
|
+
* reopens it. Nothing here moves money or writes a ledger row: closure records a
|
|
11
|
+
* fact.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ The stored row carries none of the main table's index-key attributes
|
|
14
|
+
* (`status`, `customerId`, `dated`, `updatedAt`, `terminalId`, `inboxKey`), so it
|
|
15
|
+
* joins no GSI: `state` replaces `status`, `revisedAt` replaces `updatedAt`.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* - `provider` — paid through Mercado Pago; closes when the provider reports the
|
|
19
|
+
* refund (`paymentId` is set).
|
|
20
|
+
* - `offline` — paid by other means (cash, transfer); has no `paymentId` and
|
|
21
|
+
* closes only by an operator.
|
|
22
|
+
* - `late-capture` — an approval that arrived after the order no longer wanted
|
|
23
|
+
* it; closes when the provider reports the refund or when the attempt's
|
|
24
|
+
* resolution is closed `refunded` after it was created — never because the
|
|
25
|
+
* attempt reached `refunded`.
|
|
26
|
+
*/
|
|
27
|
+
export const REFUND_OBLIGATION_KINDS = ['provider', 'offline', 'late-capture'];
|
|
28
|
+
/**
|
|
29
|
+
* - `awaiting-goods` — owed once the goods are back; no due date yet.
|
|
30
|
+
* - `open` — owed, with a `refundDueAt`.
|
|
31
|
+
* - `overdue` — past `refundDueAt` and still owed.
|
|
32
|
+
* - `held` — a dispute on the payment holds it (`holdReason`); no due pointer.
|
|
33
|
+
* - `closed` — settled; `closure` says how. Terminal.
|
|
34
|
+
*/
|
|
35
|
+
export const REFUND_OBLIGATION_STATES = ['awaiting-goods', 'open', 'overdue', 'held', 'closed'];
|
|
36
|
+
/**
|
|
37
|
+
* Why an obligation is `held`. `dispute-open` reopens on its own once the
|
|
38
|
+
* dispute is lifted; `reimbursed` (Mercado Pago covered the seller) never does —
|
|
39
|
+
* only an operator's decision moves it. A stored row with no `holdReason` reads
|
|
40
|
+
* as `dispute-open`.
|
|
41
|
+
*/
|
|
42
|
+
export const REFUND_OBLIGATION_HOLD_REASONS = ['dispute-open', 'reimbursed'];
|
|
43
|
+
/**
|
|
44
|
+
* What closed an obligation.
|
|
45
|
+
*
|
|
46
|
+
* - `detected-refund` — Mercado Pago's cumulative refunded amount, net of what
|
|
47
|
+
* was refunded before the obligation existed, covers it.
|
|
48
|
+
* - `resolution-refunded` — an operator closed the payment attempt's resolution
|
|
49
|
+
* as `refunded` after the obligation was created.
|
|
50
|
+
* - `operator` — an operator closed it by hand.
|
|
51
|
+
* - `chargeback` — a settled chargeback took the money back.
|
|
52
|
+
* - `api-refund` — a refund the api itself made (reserved; no writer yet).
|
|
53
|
+
*/
|
|
54
|
+
export const REFUND_OBLIGATION_CLOSED_BY = [
|
|
55
|
+
'detected-refund',
|
|
56
|
+
'resolution-refunded',
|
|
57
|
+
'operator',
|
|
58
|
+
'chargeback',
|
|
59
|
+
'api-refund',
|
|
60
|
+
];
|
|
61
|
+
/** Where a {@link StatutoryInstant} came from: the platform global it was computed with. */
|
|
62
|
+
export const REFUND_OBLIGATION_DUE_SOURCE = 'global:refundObligationDueDays';
|