sinfactura-types 1.10.366 → 1.10.368

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.
@@ -7,7 +7,7 @@ exports.NotificationTypeEnum = void 0;
7
7
  // Stripe hook, propagate-fx). Exported as a real enum so `api`
8
8
  // (stacks/helpers/notificationType.ts) and `app`
9
9
  // (src/domain/notificationType.ts) can drop their hand-mirrored copies
10
- // in follow-ups. DOLARBNA / ERROR / ML_FACTURADOR_COLLISION have no
10
+ // in follow-ups. DOLARBNA / ERROR / ML_FACTURADOR_COLLISION / ML_SELLER_SWITCHED have no
11
11
  // User-row read path — enum members only. AFIP_CERT_EXPIRY (the
12
12
  // cert-expiry alert type) was in that list and no longer belongs to it:
13
13
  // `createStore` seeds it on the founding user and `afipCertMonitor`
@@ -49,6 +49,19 @@ var NotificationTypeEnum;
49
49
  * The producer therefore fans out to every ADMIN of the store.
50
50
  */
51
51
  NotificationTypeEnum["ML_FACTURADOR_COLLISION"] = "ML_FACTURADOR_COLLISION";
52
+ /**
53
+ * The store's linked Mercado Libre seller was REPLACED by a different ML
54
+ * account (a confirmed seller switch). Names who switched it, from which
55
+ * account to which, and when.
56
+ *
57
+ * ⚠️ No User-row read path, same category and same two reasons as
58
+ * `ML_FACTURADOR_COLLISION`: a silent seller switch drops every
59
+ * notification for the real seller, which no tenant should be able to
60
+ * opt out of hearing about; and a new key is seeded nowhere, so an opt-in
61
+ * read would deliver it to nobody. The producer fans out to every
62
+ * non-disabled ADMIN of the store. Additive — no consumer migration owed.
63
+ */
64
+ NotificationTypeEnum["ML_SELLER_SWITCHED"] = "ML_SELLER_SWITCHED";
52
65
  // Stock alerts — fired when a sale crosses a product's stock
53
66
  // threshold. LOW_STOCK at stock <= `Product.minStock`; OUT_OF_STOCK at
54
67
  // stock <= 0. Both have User-row opt-in read paths.
@@ -2,7 +2,27 @@ declare global {
2
2
  interface MlOauthInitiateResponse {
3
3
  authorizationUrl: string;
4
4
  }
5
- type MlOauthErrorCode = 'OAUTH_USER_DENIED' | 'OAUTH_STATE_MISMATCH' | 'OAUTH_EXCHANGE_FAILED' | 'ML_OAUTH_NOT_CONFIGURED' | 'ML_REDIRECT_URI_MISMATCH' | 'ML_OFFLINE_ACCESS_NOT_GRANTED' | 'ML_OPERATOR_SUB_ACCOUNT' | 'ML_SELLER_ALREADY_LINKED';
5
+ interface MlOauthInitiateRequest {
6
+ switchToUserId?: string;
7
+ }
8
+ interface MlSellerAccountRef {
9
+ userId: string;
10
+ nickname?: string;
11
+ }
12
+ interface MlSellerSwitchRefusal {
13
+ code: MlSellerSwitchRefusalCode;
14
+ current: MlSellerAccountRef;
15
+ attempted: MlSellerAccountRef;
16
+ }
17
+ interface MlSellerSwitchRefusalQuery {
18
+ error: MlSellerSwitchRefusalCode;
19
+ currentUserId: string;
20
+ currentNickname?: string;
21
+ attemptedUserId: string;
22
+ attemptedNickname?: string;
23
+ }
24
+ type MlSellerSwitchRefusalCode = 'ML_SELLER_SWITCH_UNCONFIRMED' | 'ML_SELLER_SWITCH_MISMATCH' | 'ML_SELLER_SWITCH_STALE';
25
+ type MlOauthErrorCode = 'OAUTH_USER_DENIED' | 'OAUTH_STATE_MISMATCH' | 'OAUTH_EXCHANGE_FAILED' | 'ML_OAUTH_NOT_CONFIGURED' | 'ML_REDIRECT_URI_MISMATCH' | 'ML_OFFLINE_ACCESS_NOT_GRANTED' | 'ML_OPERATOR_SUB_ACCOUNT' | 'ML_SELLER_ALREADY_LINKED' | MlSellerSwitchRefusalCode;
6
26
  type MlMatchGrade = 'vinculada' | 'para-revisar' | 'sin-vincular' | 'rechazada';
7
27
  type MlMatchBasis = 'seller_sku' | 'gtin' | 'title';
8
28
  interface MlFieldError {
@@ -78,6 +98,93 @@ declare global {
78
98
  data: MercadolibreSettlementPeriod[];
79
99
  LastEvaluatedKey?: Record<string, unknown>;
80
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';
81
188
  interface MlOauthDisconnectResponse {
82
189
  disconnected: true;
83
190
  storeId: string;
@@ -29,6 +29,19 @@ export declare enum NotificationTypeEnum {
29
29
  * The producer therefore fans out to every ADMIN of the store.
30
30
  */
31
31
  ML_FACTURADOR_COLLISION = "ML_FACTURADOR_COLLISION",
32
+ /**
33
+ * The store's linked Mercado Libre seller was REPLACED by a different ML
34
+ * account (a confirmed seller switch). Names who switched it, from which
35
+ * account to which, and when.
36
+ *
37
+ * ⚠️ No User-row read path, same category and same two reasons as
38
+ * `ML_FACTURADOR_COLLISION`: a silent seller switch drops every
39
+ * notification for the real seller, which no tenant should be able to
40
+ * opt out of hearing about; and a new key is seeded nowhere, so an opt-in
41
+ * read would deliver it to nobody. The producer fans out to every
42
+ * non-disabled ADMIN of the store. Additive — no consumer migration owed.
43
+ */
44
+ ML_SELLER_SWITCHED = "ML_SELLER_SWITCHED",
32
45
  LOW_STOCK = "LOW_STOCK",
33
46
  OUT_OF_STOCK = "OUT_OF_STOCK",
34
47
  SUPPORT = "SUPPORT",
@@ -4,7 +4,7 @@
4
4
  // Stripe hook, propagate-fx). Exported as a real enum so `api`
5
5
  // (stacks/helpers/notificationType.ts) and `app`
6
6
  // (src/domain/notificationType.ts) can drop their hand-mirrored copies
7
- // in follow-ups. DOLARBNA / ERROR / ML_FACTURADOR_COLLISION have no
7
+ // in follow-ups. DOLARBNA / ERROR / ML_FACTURADOR_COLLISION / ML_SELLER_SWITCHED have no
8
8
  // User-row read path — enum members only. AFIP_CERT_EXPIRY (the
9
9
  // cert-expiry alert type) was in that list and no longer belongs to it:
10
10
  // `createStore` seeds it on the founding user and `afipCertMonitor`
@@ -46,6 +46,19 @@ export var NotificationTypeEnum;
46
46
  * The producer therefore fans out to every ADMIN of the store.
47
47
  */
48
48
  NotificationTypeEnum["ML_FACTURADOR_COLLISION"] = "ML_FACTURADOR_COLLISION";
49
+ /**
50
+ * The store's linked Mercado Libre seller was REPLACED by a different ML
51
+ * account (a confirmed seller switch). Names who switched it, from which
52
+ * account to which, and when.
53
+ *
54
+ * ⚠️ No User-row read path, same category and same two reasons as
55
+ * `ML_FACTURADOR_COLLISION`: a silent seller switch drops every
56
+ * notification for the real seller, which no tenant should be able to
57
+ * opt out of hearing about; and a new key is seeded nowhere, so an opt-in
58
+ * read would deliver it to nobody. The producer fans out to every
59
+ * non-disabled ADMIN of the store. Additive — no consumer migration owed.
60
+ */
61
+ NotificationTypeEnum["ML_SELLER_SWITCHED"] = "ML_SELLER_SWITCHED";
49
62
  // Stock alerts — fired when a sale crosses a product's stock
50
63
  // threshold. LOW_STOCK at stock <= `Product.minStock`; OUT_OF_STOCK at
51
64
  // stock <= 0. Both have User-row opt-in read paths.
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;
@@ -918,6 +918,15 @@ declare global {
918
918
  before: string | number | boolean;
919
919
  after: string | number | boolean;
920
920
  }
921
+ interface IntegrationConnectionChangedEvent extends UserActivityEventBase {
922
+ event: 'Integration Connection Changed';
923
+ provider: 'mercadolibre';
924
+ action: 'connect' | 'reconnect' | 'switch' | 'disconnect';
925
+ from_ml_user_id?: string;
926
+ from_nickname?: string;
927
+ to_ml_user_id?: string;
928
+ to_nickname?: string;
929
+ }
921
930
  interface MlChannelStatusChangedEvent extends UserActivityEventBase {
922
931
  event: 'ML Channel Status Changed';
923
932
  provider: 'mercadolibre';
@@ -1074,7 +1083,7 @@ declare global {
1074
1083
  carrier?: string;
1075
1084
  tracking_set: boolean;
1076
1085
  }
1077
- type UserActivityEvent = CustomerConsentImportedEvent | CustomerConsentImportCompletedEvent | UserLoggedInEvent | UserLoggedOutEvent | UserPasswordChangedEvent | UserSuspendedEvent | TwoFactorEnrolledEvent | TwoFactorDisabledEvent | TwoFactorResetEvent | TwoFactorRecoveryCodesGeneratedEvent | StoreSettingsUpdatedEvent | PlanChangedEvent | InvoiceCreatedEvent | OrderCreatedEvent | OrderCancelledEvent | OrderEditedEvent | OrderReturnedEvent | ProductPriceChangedEvent | CustomerCreatedEvent | CustomerEditedEvent | CustomerRecordServedEvent | CustomersMergedEvent | CashDrawerOpenedEvent | CashDrawerClosedEvent | TenantImpersonatedEvent | SecretRotatedEvent | UserCreatedEvent | UserUpdatedEvent | ProductCreatedEvent | ProductUpdatedEvent | StockIncomeCreatedEvent | StockAdjustedEvent | CategoryCreatedEvent | CategoryUpdatedEvent | BrandCreatedEvent | BrandUpdatedEvent | SupplierCreatedEvent | SupplierUpdatedEvent | SupplierInvoiceCreatedEvent | SupplierAccountCreatedEvent | SupplierAccountUpdatedEvent | AccountCreatedEvent | AccountDeletedEvent | BasketUpdatedEvent | BasketDiscountGrantedEvent | BasketDeletedEvent | CashDrawerMovementEvent | PaymentCreatedEvent | PaymentLinkedEvent | PaymentUnlinkedEvent | PaymentLinkageUpdatedEvent | CreditLimitOverriddenEvent | NotificationReadEvent | LogDeletedEvent | PlanCreatedEvent | StoreMaintenanceToggledEvent | PlatformMaintenanceToggledEvent | MaintenanceBroadcastSentEvent | TenantCreatedEvent | LiteralUpdatedEvent | SupportTicketCreatedEvent | SupportTicketUpdatedEvent | AuditTrailViewedEvent | ReportViewedEvent | CustomerPiiViewedEvent | CashDrawerUiOpenedEvent | CashDrawerUiClosedEvent | ExportInitiatedEvent | ImpersonationUiStartedEvent | ImpersonationUiEndedEvent | PaymentViewedEvent | InvoiceViewedEvent | CustomerDetailViewedEvent | SupplierAccountViewedEvent | SearchPerformedEvent | ActionDeniedEvent | TwoFactorChallengeShownEvent | TwoFactorCodeValidationFailedEvent | TwoFactorEnrollmentStartedEvent | TwoFactorRecoveryCodesRevealedEvent | TwoFactorResetInitiatedEvent | IntegrationTokenRefreshedEvent | WaitlistConvertedEvent | PlatformConfigUpdatedEvent | MlChannelStatusChangedEvent | PrintRuleCreatedEvent | PrintRuleEditedEvent | PrintRuleDeletedEvent | WebhookCreatedEvent | WebhookUpdatedEvent | WebhookDeletedEvent | PrinterActiveToggledEvent | PrinterRawFormatsUpdatedEvent | PrinterProfileUpdatedEvent | PlanTemplateUpdatedEvent | SupplierAccountDeletedEvent | CustomerPasswordResetInitiatedEvent | UserSessionsRevokedEvent | UserAnonymizedEvent | UserPasswordResetInitiatedByOperatorEvent | AgentCommandDispatchedEvent | RmaRequestedEvent | RmaTransitionedEvent | RmaTrackingUpdatedEvent | ClockedInEvent | ClockedOutEvent | AttendanceCorrectedEvent;
1086
+ type UserActivityEvent = CustomerConsentImportedEvent | CustomerConsentImportCompletedEvent | UserLoggedInEvent | UserLoggedOutEvent | UserPasswordChangedEvent | UserSuspendedEvent | TwoFactorEnrolledEvent | TwoFactorDisabledEvent | TwoFactorResetEvent | TwoFactorRecoveryCodesGeneratedEvent | StoreSettingsUpdatedEvent | PlanChangedEvent | InvoiceCreatedEvent | OrderCreatedEvent | OrderCancelledEvent | OrderEditedEvent | OrderReturnedEvent | ProductPriceChangedEvent | CustomerCreatedEvent | CustomerEditedEvent | CustomerRecordServedEvent | CustomersMergedEvent | CashDrawerOpenedEvent | CashDrawerClosedEvent | TenantImpersonatedEvent | SecretRotatedEvent | UserCreatedEvent | UserUpdatedEvent | ProductCreatedEvent | ProductUpdatedEvent | StockIncomeCreatedEvent | StockAdjustedEvent | CategoryCreatedEvent | CategoryUpdatedEvent | BrandCreatedEvent | BrandUpdatedEvent | SupplierCreatedEvent | SupplierUpdatedEvent | SupplierInvoiceCreatedEvent | SupplierAccountCreatedEvent | SupplierAccountUpdatedEvent | AccountCreatedEvent | AccountDeletedEvent | BasketUpdatedEvent | BasketDiscountGrantedEvent | BasketDeletedEvent | CashDrawerMovementEvent | PaymentCreatedEvent | PaymentLinkedEvent | PaymentUnlinkedEvent | PaymentLinkageUpdatedEvent | CreditLimitOverriddenEvent | NotificationReadEvent | LogDeletedEvent | PlanCreatedEvent | StoreMaintenanceToggledEvent | PlatformMaintenanceToggledEvent | MaintenanceBroadcastSentEvent | TenantCreatedEvent | LiteralUpdatedEvent | SupportTicketCreatedEvent | SupportTicketUpdatedEvent | AuditTrailViewedEvent | ReportViewedEvent | CustomerPiiViewedEvent | CashDrawerUiOpenedEvent | CashDrawerUiClosedEvent | ExportInitiatedEvent | ImpersonationUiStartedEvent | ImpersonationUiEndedEvent | PaymentViewedEvent | InvoiceViewedEvent | CustomerDetailViewedEvent | SupplierAccountViewedEvent | SearchPerformedEvent | ActionDeniedEvent | TwoFactorChallengeShownEvent | TwoFactorCodeValidationFailedEvent | TwoFactorEnrollmentStartedEvent | TwoFactorRecoveryCodesRevealedEvent | TwoFactorResetInitiatedEvent | IntegrationTokenRefreshedEvent | WaitlistConvertedEvent | PlatformConfigUpdatedEvent | MlChannelStatusChangedEvent | IntegrationConnectionChangedEvent | PrintRuleCreatedEvent | PrintRuleEditedEvent | PrintRuleDeletedEvent | WebhookCreatedEvent | WebhookUpdatedEvent | WebhookDeletedEvent | PrinterActiveToggledEvent | PrinterRawFormatsUpdatedEvent | PrinterProfileUpdatedEvent | PlanTemplateUpdatedEvent | SupplierAccountDeletedEvent | CustomerPasswordResetInitiatedEvent | UserSessionsRevokedEvent | UserAnonymizedEvent | UserPasswordResetInitiatedByOperatorEvent | AgentCommandDispatchedEvent | RmaRequestedEvent | RmaTransitionedEvent | RmaTrackingUpdatedEvent | ClockedInEvent | ClockedOutEvent | AttendanceCorrectedEvent;
1078
1087
  }
1079
1088
  /**
1080
1089
  * Canonical whitelist of UI-only `UserActivityEvent` variant names. Imported by
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.366",
3
+ "version": "1.10.368",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",