platform-types 1.10.800 → 1.10.802

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 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";
@@ -10,6 +10,13 @@ declare global {
10
10
  interface ResolvedStorefrontLiterals {
11
11
  values: Record<string, string>;
12
12
  provenance: Record<string, 'default' | 'GLOBAL' | 'WEB' | `WEB#${string}`>;
13
+ /**
14
+ * The compiled storefront default of each key, before any layer is applied: what a
15
+ * revert restores, and the text whose `{tokens}` an override must keep. No stored
16
+ * layer changes it. A key the catalog generator excludes has no entry, so a missing
17
+ * entry means "default unknown"; the six blanked payment keys are `''`.
18
+ */
19
+ defaults: Record<string, string>;
13
20
  }
14
21
  /**
15
22
  * One scope's literals, unmerged.
@@ -227,9 +227,72 @@ export interface PlatformLiteralsBody extends PlatformOperatorReason {
227
227
  literals: Record<string, string | null>;
228
228
  /**
229
229
  * Must equal the store id inside a per-tenant scope; absent or wrong there is
230
- * `400 CONFIRMATION_MISMATCH`. Ignored on a global scope, which names no tenant.
230
+ * `400 CONFIRMATION_MISMATCH`. Ignored on a global scope, which names no tenant,
231
+ * and ignored on a dry run.
231
232
  */
232
233
  confirm?: string;
234
+ /**
235
+ * `true` judges each key on its own and writes nothing: no row, no activity
236
+ * row, no audit row. The answer is `PlatformLiteralsDryRunResult`. A bad
237
+ * scope, an empty map or a bad reason is still a request-level 400. The
238
+ * legacy `WEB#` write conflicts happen only at commit and are not predicted.
239
+ */
240
+ dryRun?: boolean;
241
+ }
242
+ /** Why a dry run says one key would be refused. */
243
+ export type PlatformLiteralDryRunError = 'RESERVED_KEY' | 'INVALID_KEY' | 'VALUE_TOO_LONG' | 'LITERAL_KEY_NOT_ALLOWED';
244
+ /**
245
+ * One key of a dry run: what the write would do (`set` a new value, `remove` a
246
+ * stored one, or leave it `unchanged`), or the code that would refuse it.
247
+ */
248
+ export type PlatformLiteralDryRunKeyResult = {
249
+ key: string;
250
+ verdict: 'set' | 'remove' | 'unchanged';
251
+ } | {
252
+ key: string;
253
+ error: PlatformLiteralDryRunError;
254
+ };
255
+ /** `POST /platform/literals { dryRun: true }` → `200 { message, data }`, one result per body key. */
256
+ export interface PlatformLiteralsDryRunResult {
257
+ results: PlatformLiteralDryRunKeyResult[];
258
+ }
259
+ /**
260
+ * One change on `GET /platform/literals/{scope}/{key}/history`. `before` and
261
+ * `after` are the stored values on each side of the change, `''` for a key the
262
+ * scope does not hold. `actorStoreId` is the acting manager's own store, since
263
+ * `actorId` is numbered per store. `actorName` is absent when the actor's
264
+ * activity row can no longer be read; `reason` is absent when none was sent.
265
+ */
266
+ export interface PlatformLiteralHistoryEntry {
267
+ at: string;
268
+ actorId: string;
269
+ actorStoreId?: string;
270
+ actorName?: string;
271
+ before: string;
272
+ after: string;
273
+ reason?: string;
274
+ }
275
+ /** `GET /platform/literals/{scope}/{key}/history`: newest first; send `cursor` back as `?cursor=`. */
276
+ export interface PlatformLiteralHistoryResponse {
277
+ data: PlatformLiteralHistoryEntry[];
278
+ cursor?: string;
279
+ }
280
+ /** One store's own value for a key, on its `APP#{storeId}` or `WEB#{storeId}` row. */
281
+ export interface PlatformLiteralOverride {
282
+ storeId: string;
283
+ /** Absent when the store row has no name, or can no longer be read. */
284
+ storeName?: string;
285
+ scope: `APP#${string}` | `WEB#${string}`;
286
+ value: string;
287
+ }
288
+ /**
289
+ * `GET /platform/literals/overrides?key=K`. `truncated` is `true` when the read
290
+ * stopped at its bound before reaching every tenant row, so the list may be
291
+ * incomplete.
292
+ */
293
+ export interface PlatformLiteralOverridesResponse {
294
+ data: PlatformLiteralOverride[];
295
+ truncated?: true;
233
296
  }
234
297
  /** `POST /platform/operations { mode: 'mp-recover-payment' }`. */
235
298
  /** Tracked non-money refresh returned inside the standard response data envelope. */
@@ -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';
@@ -1027,6 +1027,7 @@ declare global {
1027
1027
  key: string;
1028
1028
  before: string;
1029
1029
  after: string;
1030
+ reason?: string;
1030
1031
  }
1031
1032
  interface SupportTicketCreatedEvent extends UserActivityEventBase {
1032
1033
  event: 'Support Ticket Created';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.800",
3
+ "version": "1.10.802",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",