sinfactura-types 1.10.367 → 1.10.369
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/customerTimeline.js +14 -0
- package/dist/cjs/index.js +1 -0
- package/dist/customerTimeline.d.ts +110 -0
- package/dist/customerTimeline.js +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mercadolibre.d.ts +87 -0
- package/dist/store.d.ts +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// `GET /customers/timeline?customerId=` — one read answering "what has happened
|
|
3
|
+
// with this customer": orders, invoices, current-account movements, operator
|
|
4
|
+
// notes and marketing-consent stamps, newest first, in ONE ordered stream.
|
|
5
|
+
//
|
|
6
|
+
// READ-ONLY. A projection over rows that already exist; there is no timeline
|
|
7
|
+
// table and no write path. Staff only (`staffToken` + the `customers`
|
|
8
|
+
// capability); the store is always the token's, never the query's or the
|
|
9
|
+
// cursor's.
|
|
10
|
+
//
|
|
11
|
+
// ⚠️ Every item is a MINIMAL projection — an allow-list of summary fields, never
|
|
12
|
+
// the row. No staff identity ever rides on an item (no note author, no editor,
|
|
13
|
+
// no consent actor), and no consent `ip`.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/cjs/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __exportStar(require("./customer.js"), exports);
|
|
|
42
42
|
__exportStar(require("./customerAddress.js"), exports);
|
|
43
43
|
__exportStar(require("./customerContact.js"), exports);
|
|
44
44
|
__exportStar(require("./customerNote.js"), exports);
|
|
45
|
+
__exportStar(require("./customerTimeline.js"), exports);
|
|
45
46
|
__exportStar(require("./cycleCount.js"), exports);
|
|
46
47
|
__exportStar(require("./delivery.js"), exports);
|
|
47
48
|
__exportStar(require("./gating.js"), exports);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
/** The five sources, in tie-break rank order (lower rank first at equal `at`). */
|
|
3
|
+
type CustomerTimelineSource = 'order' | 'invoice' | 'account' | 'note' | 'consent';
|
|
4
|
+
/**
|
|
5
|
+
* Fields every item carries. `id` is the source's own id (`orderId`,
|
|
6
|
+
* `invoiceId`, the ledger row's `accountId`, `noteId`, the consent channel);
|
|
7
|
+
* it is unique only WITHIN its `type`, so a client keys items by `type`+`id`.
|
|
8
|
+
*
|
|
9
|
+
* `at` is the ms epoch the item is ORDERED by:
|
|
10
|
+
* - order / invoice — the row's `createdAt`;
|
|
11
|
+
* - account — the movement's `createdAt` as embedded in its index key; a
|
|
12
|
+
* legacy row without that key falls back to its own `createdAt`;
|
|
13
|
+
* - note — the `noteId` millisecond, which is the creation time EXCEPT for a
|
|
14
|
+
* note moved by a customer merge onto a taken millisecond (re-keyed to the
|
|
15
|
+
* move's time);
|
|
16
|
+
* - consent — the channel's current stamp `ts`.
|
|
17
|
+
*/
|
|
18
|
+
interface CustomerTimelineItemBase {
|
|
19
|
+
id: string;
|
|
20
|
+
at: number;
|
|
21
|
+
}
|
|
22
|
+
interface CustomerTimelineOrderItem extends CustomerTimelineItemBase {
|
|
23
|
+
type: 'order';
|
|
24
|
+
total?: number;
|
|
25
|
+
currency?: string;
|
|
26
|
+
fulfilmentStatus?: OrderFulfilmentStatus;
|
|
27
|
+
financialStatus?: OrderFinancialStatus;
|
|
28
|
+
}
|
|
29
|
+
interface CustomerTimelineInvoiceItem extends CustomerTimelineItemBase {
|
|
30
|
+
type: 'invoice';
|
|
31
|
+
invoiceType?: number;
|
|
32
|
+
pointOfSale?: number;
|
|
33
|
+
invoiceNumber?: number;
|
|
34
|
+
total?: number;
|
|
35
|
+
currency?: string;
|
|
36
|
+
fiscalStatus?: FiscalStatus;
|
|
37
|
+
}
|
|
38
|
+
/** One current-account movement (a debit or a payment/credit). Checkpoints never appear. */
|
|
39
|
+
interface CustomerTimelineAccountItem extends CustomerTimelineItemBase {
|
|
40
|
+
type: 'account';
|
|
41
|
+
debit?: number;
|
|
42
|
+
credit?: number;
|
|
43
|
+
currency?: string;
|
|
44
|
+
orderId?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One operator note. `body` is present ONLY for an admin-tier caller (ADMIN,
|
|
48
|
+
* SUPERVISOR, MANAGER); every other caller — a USER with the `customers`
|
|
49
|
+
* flag included — gets the ids-only item and reads the body, if at all,
|
|
50
|
+
* through `GET /customers/notes`. Never an author or editor.
|
|
51
|
+
*/
|
|
52
|
+
interface CustomerTimelineNoteItem extends CustomerTimelineItemBase {
|
|
53
|
+
type: 'note';
|
|
54
|
+
body?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The CURRENT consent stamp of one marketing channel — its latest grant or
|
|
58
|
+
* withdrawal. ⚠️ NOT a history: the customer row keeps one stamp per channel
|
|
59
|
+
* and overwrites it, so an earlier change of the same channel is not on the
|
|
60
|
+
* timeline. `granted` defaults to `false` when the channel flag is absent
|
|
61
|
+
* (absence never means consent). Never the `ip`, never who recorded it.
|
|
62
|
+
*/
|
|
63
|
+
interface CustomerTimelineConsentItem extends CustomerTimelineItemBase {
|
|
64
|
+
type: 'consent';
|
|
65
|
+
/** The channel IS the id. */
|
|
66
|
+
id: 'adds' | 'email' | 'phone' | 'sms' | 'whatsapp';
|
|
67
|
+
granted: boolean;
|
|
68
|
+
source?: ChannelConsentStamp['source'];
|
|
69
|
+
}
|
|
70
|
+
type CustomerTimelineItem = CustomerTimelineOrderItem | CustomerTimelineInvoiceItem | CustomerTimelineAccountItem | CustomerTimelineNoteItem | CustomerTimelineConsentItem;
|
|
71
|
+
/**
|
|
72
|
+
* One page, ordered by `at` DESCENDING; ties broken by source rank
|
|
73
|
+
* (`order`, `invoice`, `account`, `note`, `consent`) then `id` ascending, so a
|
|
74
|
+
* page boundary is stable and no item is skipped or repeated across pages.
|
|
75
|
+
*
|
|
76
|
+
* - `nextCursor` — opaque; pass back as `?cursor=`. Present while a further
|
|
77
|
+
* page exists. A page may be SHORTER than `limit` and still carry one (the
|
|
78
|
+
* per-request read budget ended it early); keep paging.
|
|
79
|
+
* - `truncated` — `true` whenever the timeline is not complete as of this
|
|
80
|
+
* page: more pages exist (`nextCursor`), OR `partialSources` is non-empty.
|
|
81
|
+
* ⚠️ `truncated: true` WITHOUT a `nextCursor` is a legal final state — it
|
|
82
|
+
* means rows exist that no page can reach, never a silent prefix.
|
|
83
|
+
* - `partialSources` — sources whose rows could not all be read within the
|
|
84
|
+
* per-source read bound. Orders, invoices and legacy ledger rows are not
|
|
85
|
+
* stored in time order per customer, so a customer past that bound has some
|
|
86
|
+
* of them missing from EVERY page, in no particular order. Absent when every
|
|
87
|
+
* source was read whole.
|
|
88
|
+
*/
|
|
89
|
+
interface CustomerTimelinePage {
|
|
90
|
+
items: CustomerTimelineItem[];
|
|
91
|
+
nextCursor?: string;
|
|
92
|
+
truncated: boolean;
|
|
93
|
+
partialSources?: ('order' | 'invoice' | 'account')[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Every DOMAIN refusal on `/customers/timeline`, one bare code each (the
|
|
97
|
+
* generic `VALIDATION_FAILED`, `CAPABILITY_REQUIRED` and `INVALID_CURSOR` —
|
|
98
|
+
* 400 on a cursor that does not decode — are not listed here).
|
|
99
|
+
*
|
|
100
|
+
* - `CUSTOMER_TIMELINE_CUSTOMER_NOT_FOUND` (404) — the customer is not in the
|
|
101
|
+
* caller's store. Covers «no such id» too, so the route is not a
|
|
102
|
+
* cross-tenant existence oracle.
|
|
103
|
+
* - `CUSTOMER_TIMELINE_CUSTOMER_MERGED` (409) — the customer was folded into
|
|
104
|
+
* another; `data.mergedInto` is the survivor, whose timeline carries the
|
|
105
|
+
* moved history. An ERASED customer is not refused: its timeline shows what
|
|
106
|
+
* the erasure left.
|
|
107
|
+
*/
|
|
108
|
+
type CustomerTimelineErrorCode = 'CUSTOMER_TIMELINE_CUSTOMER_NOT_FOUND' | 'CUSTOMER_TIMELINE_CUSTOMER_MERGED';
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// `GET /customers/timeline?customerId=` — one read answering "what has happened
|
|
2
|
+
// with this customer": orders, invoices, current-account movements, operator
|
|
3
|
+
// notes and marketing-consent stamps, newest first, in ONE ordered stream.
|
|
4
|
+
//
|
|
5
|
+
// READ-ONLY. A projection over rows that already exist; there is no timeline
|
|
6
|
+
// table and no write path. Staff only (`staffToken` + the `customers`
|
|
7
|
+
// capability); the store is always the token's, never the query's or the
|
|
8
|
+
// cursor's.
|
|
9
|
+
//
|
|
10
|
+
// ⚠️ Every item is a MINIMAL projection — an allow-list of summary fields, never
|
|
11
|
+
// the row. No staff identity ever rides on an item (no note author, no editor,
|
|
12
|
+
// no consent actor), and no consent `ip`.
|
|
13
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './customer.ts';
|
|
|
18
18
|
export * from './customerAddress.ts';
|
|
19
19
|
export * from './customerContact.ts';
|
|
20
20
|
export * from './customerNote.ts';
|
|
21
|
+
export * from './customerTimeline.ts';
|
|
21
22
|
export * from './cycleCount.ts';
|
|
22
23
|
export * from './delivery.ts';
|
|
23
24
|
export * from './gating.ts';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./customer.js";
|
|
|
26
26
|
export * from "./customerAddress.js";
|
|
27
27
|
export * from "./customerContact.js";
|
|
28
28
|
export * from "./customerNote.js";
|
|
29
|
+
export * from "./customerTimeline.js";
|
|
29
30
|
export * from "./cycleCount.js";
|
|
30
31
|
export * from "./delivery.js";
|
|
31
32
|
export * from "./gating.js";
|
package/dist/mercadolibre.d.ts
CHANGED
|
@@ -98,6 +98,93 @@ declare global {
|
|
|
98
98
|
data: MercadolibreSettlementPeriod[];
|
|
99
99
|
LastEvaluatedKey?: Record<string, unknown>;
|
|
100
100
|
}
|
|
101
|
+
/** What started a reconciliation run. */
|
|
102
|
+
type MlOrderReconcileTrigger = 'reconnect' | 'daily' | 'manual';
|
|
103
|
+
/** A reconciliation window on `date_created`, unix ms, `from` inclusive, `to` inclusive. */
|
|
104
|
+
interface MlOrderReconcileWindow {
|
|
105
|
+
from: number;
|
|
106
|
+
to: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* FE → BE body of `POST /mercadolibre/orders/sync` (ADMIN). Both bounds are
|
|
110
|
+
* unix ms and optional: `to` defaults to now, `from` to `to − 72h`. A `to`
|
|
111
|
+
* in the future is clamped to now. The window may span at most 60 days.
|
|
112
|
+
*/
|
|
113
|
+
interface MlOrdersSyncRequest {
|
|
114
|
+
from?: number;
|
|
115
|
+
to?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* BE → FE `202` of `POST /mercadolibre/orders/sync`. The run is ASYNC (a
|
|
119
|
+
* multi-page `orders/search` walk with 429 back-off does not fit the API's
|
|
120
|
+
* 29 s cap); its outcome lands as one `MlOrderReconcileSummary` row in the
|
|
121
|
+
* store's integration events log, tagged with this `jobId`.
|
|
122
|
+
*/
|
|
123
|
+
interface MlOrdersSyncResponse {
|
|
124
|
+
jobId: string;
|
|
125
|
+
window: MlOrderReconcileWindow;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Refusals of `POST /mercadolibre/orders/sync` — each writes nothing.
|
|
129
|
+
* `ML_SYNC_WINDOW_INVALID` (400) — a bound is not a finite unix-ms number,
|
|
130
|
+
* or `from` is not before `to`.
|
|
131
|
+
* `ML_SYNC_WINDOW_TOO_LARGE` (400) — the window spans more than 60 days.
|
|
132
|
+
* `ML_SYNC_RATE_LIMITED` (429) — a manual run for this store started less
|
|
133
|
+
* than 10 minutes ago.
|
|
134
|
+
* `ML_NOT_CONNECTED` (409) — the store has no connected MercadoLibre seller.
|
|
135
|
+
*/
|
|
136
|
+
type MlOrdersSyncErrorCode = 'ML_SYNC_WINDOW_INVALID' | 'ML_SYNC_WINDOW_TOO_LARGE' | 'ML_SYNC_RATE_LIMITED' | 'ML_NOT_CONNECTED';
|
|
137
|
+
/**
|
|
138
|
+
* The one integration-events row a reconciliation run writes
|
|
139
|
+
* (`type: 'reconcile-sweep'`, `storeId` set). `scanned` counts orders ML listed;
|
|
140
|
+
* `created` those with no local pointer (each one is a lost notification);
|
|
141
|
+
* `updated` those whose ML `last_updated` is newer than ours;
|
|
142
|
+
* `skippedPreConnect` those created before the store's `connectedAt`,
|
|
143
|
+
* which the order worker refuses — never enqueued and never counted as
|
|
144
|
+
* recovered (absent on rows written before it existed). `truncated`
|
|
145
|
+
* means the run stopped at its page/time budget and resumes from its
|
|
146
|
+
* checkpoint next time — the counts cover only what was walked.
|
|
147
|
+
*/
|
|
148
|
+
interface MlOrderReconcileSummary {
|
|
149
|
+
trigger: MlOrderReconcileTrigger;
|
|
150
|
+
window: MlOrderReconcileWindow;
|
|
151
|
+
scanned: number;
|
|
152
|
+
created: number;
|
|
153
|
+
updated: number;
|
|
154
|
+
skippedPreConnect?: number;
|
|
155
|
+
truncated?: boolean;
|
|
156
|
+
jobId?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* `errorCode` of the row written for each notification re-enqueued by the
|
|
160
|
+
* reconnect replay (`storeId` set, so the tenant log shows what was
|
|
161
|
+
* recovered). `retry:manual` is the tenant retry; `retry:platform` the
|
|
162
|
+
* MANAGER retry of a row that carries no `storeId`.
|
|
163
|
+
*/
|
|
164
|
+
type MlEventRetryCode = 'retry:manual' | 'retry:reconnect' | 'retry:platform';
|
|
165
|
+
/**
|
|
166
|
+
* MANAGER body of the platform retry of an ML event row that has no
|
|
167
|
+
* `storeId` (an `unknown-seller` drop). The target store is named
|
|
168
|
+
* explicitly and must currently be linked to the row's `mlUserId`.
|
|
169
|
+
*/
|
|
170
|
+
interface MlPlatformEventRetryRequest {
|
|
171
|
+
mode: 'retry';
|
|
172
|
+
ts: number;
|
|
173
|
+
id: string;
|
|
174
|
+
storeId: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Refusals of the MANAGER platform retry — each writes nothing and
|
|
178
|
+
* enqueues nothing.
|
|
179
|
+
* `ML_EVENT_NOT_FOUND` (404) — no such row.
|
|
180
|
+
* `ML_EVENT_NOT_RETRYABLE` (422) — the row lacks the notification fields.
|
|
181
|
+
* `ML_EVENT_ALREADY_SCOPED` (409) — the row already carries a `storeId`;
|
|
182
|
+
* the tenant retry owns it.
|
|
183
|
+
* `ML_EVENT_STORE_NOT_CONNECTED` (409) — the named store has no linked seller.
|
|
184
|
+
* `ML_EVENT_SELLER_MISMATCH` (409) — the named store's linked seller is not
|
|
185
|
+
* the row's `mlUserId`.
|
|
186
|
+
*/
|
|
187
|
+
type MlPlatformEventRetryErrorCode = 'ML_EVENT_NOT_FOUND' | 'ML_EVENT_NOT_RETRYABLE' | 'ML_EVENT_ALREADY_SCOPED' | 'ML_EVENT_STORE_NOT_CONNECTED' | 'ML_EVENT_SELLER_MISMATCH' | 'ML_EVENT_RETRY_ENQUEUE_FAILED' | 'PROVIDER_NOT_SUPPORTED';
|
|
101
188
|
interface MlOauthDisconnectResponse {
|
|
102
189
|
disconnected: true;
|
|
103
190
|
storeId: string;
|
package/dist/store.d.ts
CHANGED
|
@@ -916,7 +916,28 @@ declare global {
|
|
|
916
916
|
* unpublished) carries them — so this expiry travels alone.
|
|
917
917
|
*/
|
|
918
918
|
expiresAt?: number;
|
|
919
|
+
/**
|
|
920
|
+
* unix ms of the FIRST link of this store to the currently linked seller —
|
|
921
|
+
* the date the pre-connect order guard compares against. A reconnect of
|
|
922
|
+
* the same seller keeps it. A first connect or a confirmed switch takes
|
|
923
|
+
* that seller's `sellerHistory[userId].firstLinkedAt` when the store was
|
|
924
|
+
* linked to it before, else the link time.
|
|
925
|
+
*/
|
|
919
926
|
connectedAt?: number;
|
|
927
|
+
/** unix ms of the latest same-seller reconnect; absent until one happens, cleared by a switch. */
|
|
928
|
+
reconnectedAt?: number;
|
|
929
|
+
/**
|
|
930
|
+
* Every ML seller this store has been linked to, keyed by seller
|
|
931
|
+
* `user_id`. `firstLinkedAt` (unix ms) is written once per seller, on the
|
|
932
|
+
* first successful link recorded for it, and never moved after that.
|
|
933
|
+
* A confirmed switch also records the seller being left, from its
|
|
934
|
+
* `connectedAt`. Survives a disconnect and a switch, so switching back to
|
|
935
|
+
* a seller restores its original `connectedAt`. Forward-only: a store
|
|
936
|
+
* starts recording at its next link after this field shipped.
|
|
937
|
+
*/
|
|
938
|
+
sellerHistory?: Record<string, {
|
|
939
|
+
firstLinkedAt: number;
|
|
940
|
+
}>;
|
|
920
941
|
tokenType?: string;
|
|
921
942
|
scope?: string;
|
|
922
943
|
status?: MercadolibreConnectionStatus;
|