sinfactura-types 1.6.43 → 1.6.45

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/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export * from "./imports";
15
15
  export * from "./invoice";
16
16
  export * from "./log";
17
17
  export * from "./maintenance";
18
+ export * from "./mercadolibre";
18
19
  export * from "./mercadopago";
19
20
  export * from "./notification";
20
21
  export * from "./order";
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ export * from "./imports";
15
15
  export * from "./invoice";
16
16
  export * from "./log";
17
17
  export * from "./maintenance";
18
+ export * from "./mercadolibre";
18
19
  export * from "./mercadopago";
19
20
  export * from "./notification";
20
21
  export * from "./order";
@@ -0,0 +1,118 @@
1
+ declare global {
2
+ interface MlOauthTokenResponse {
3
+ access_token: string;
4
+ token_type?: string;
5
+ expires_in: number;
6
+ scope?: string;
7
+ user_id: number;
8
+ refresh_token: string;
9
+ }
10
+ interface MlOauthInitiateResponse {
11
+ authorizationUrl: string;
12
+ }
13
+ interface MlOauthCallbackResponse {
14
+ connected: true;
15
+ storeId: string;
16
+ mercadolibreUserId: string;
17
+ expiresAt: number;
18
+ connectedAt: number;
19
+ }
20
+ 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";
21
+ interface MercadolibreStatus {
22
+ connected: boolean;
23
+ status: MercadolibreConnectionStatus;
24
+ userId?: string;
25
+ nickname?: string;
26
+ connectedAt?: number;
27
+ expiresAt?: number;
28
+ autoInvoice?: boolean;
29
+ defaultPosId?: number;
30
+ syncPolicy?: Mercadolibre["syncPolicy"];
31
+ }
32
+ interface MlWebhookEvent {
33
+ _id: string;
34
+ resource: string;
35
+ user_id: number;
36
+ topic: string;
37
+ application_id: number;
38
+ attempts: number;
39
+ sent: string;
40
+ received: string;
41
+ }
42
+ type MlMatchGrade = "vinculada" | "para-revisar" | "sin-vincular";
43
+ type MlMatchBasis = "seller_sku" | "gtin" | "title";
44
+ interface MlMatchSuggestion {
45
+ productId: string;
46
+ sku?: string;
47
+ mlItemId: string;
48
+ mlTitle?: string;
49
+ userProductId?: string;
50
+ familyId?: string;
51
+ variationId?: string;
52
+ grade: MlMatchGrade;
53
+ basis?: MlMatchBasis;
54
+ }
55
+ interface MercadolibreOrderWsPayload {
56
+ orderId: string;
57
+ mlOrderId: string;
58
+ packId?: string;
59
+ buyerNickname?: string;
60
+ total: number;
61
+ currency: string;
62
+ paidAt?: number;
63
+ }
64
+ type GtinRequirementTag = "not_required" | "conditional_required" | "new_required";
65
+ interface MlAttribute {
66
+ id: string;
67
+ name?: string;
68
+ value_id?: string;
69
+ value_name?: string;
70
+ attribute_group_id?: string;
71
+ attribute_group_name?: string;
72
+ }
73
+ interface MlRequiredAttribute {
74
+ id: string;
75
+ name?: string;
76
+ required: boolean;
77
+ tags?: string[];
78
+ }
79
+ interface MlCategoryPrediction {
80
+ domainName: string;
81
+ categoryId: string;
82
+ categoryName: string;
83
+ attributes: MlAttribute[];
84
+ requiredAttributes: MlRequiredAttribute[];
85
+ immediatePayment?: "required" | "optional";
86
+ maxTitleLength?: number;
87
+ gtinRequirement: GtinRequirementTag;
88
+ }
89
+ interface PublishPrediction extends MlCategoryPrediction {
90
+ isUpMigrated: boolean;
91
+ }
92
+ interface MlPublishRequest {
93
+ productId: string;
94
+ categoryId: string;
95
+ attributes: MlAttribute[];
96
+ listingTypeId: string;
97
+ saleTerms?: Record<string, unknown>[];
98
+ pictures?: {
99
+ url: string;
100
+ }[];
101
+ description?: string;
102
+ }
103
+ interface MlPublishResponse {
104
+ productId: string;
105
+ itemId: string;
106
+ userProductId?: string;
107
+ isUpMigrated: boolean;
108
+ status: "linked";
109
+ }
110
+ interface MlFieldError {
111
+ field: string;
112
+ code?: string;
113
+ message: string;
114
+ type?: "warning" | "error";
115
+ causeId?: number;
116
+ }
117
+ }
118
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -6,7 +6,8 @@ export declare enum NotificationTypeEnum {
6
6
  DOLARINFORMAL = "DOLARINFORMAL",
7
7
  DOLARBNA = "DOLARBNA",
8
8
  ERROR = "ERROR",
9
- AFIP_CERT_EXPIRY = "AFIP_CERT_EXPIRY"
9
+ AFIP_CERT_EXPIRY = "AFIP_CERT_EXPIRY",
10
+ MERCADOLIBRE = "MERCADOLIBRE"
10
11
  }
11
12
  declare global {
12
13
  interface NotificationInterface {
@@ -17,4 +17,7 @@ export var NotificationTypeEnum;
17
17
  NotificationTypeEnum["DOLARBNA"] = "DOLARBNA";
18
18
  NotificationTypeEnum["ERROR"] = "ERROR";
19
19
  NotificationTypeEnum["AFIP_CERT_EXPIRY"] = "AFIP_CERT_EXPIRY";
20
+ // ML order-ingestion fanout (app#797 / api#1574) — User-row read path
21
+ // added by the orders_v2 worker.
22
+ NotificationTypeEnum["MERCADOLIBRE"] = "MERCADOLIBRE";
20
23
  })(NotificationTypeEnum || (NotificationTypeEnum = {}));
package/dist/order.d.ts CHANGED
@@ -56,6 +56,42 @@ declare global {
56
56
  };
57
57
  };
58
58
  linkedPayments?: Record<string, LinkedPaymentEntry>;
59
+ channel?: OrderChannel;
60
+ mercadolibre?: OrderMercadolibre;
61
+ }
62
+ type OrderChannel = 'meli';
63
+ interface OrderMercadolibre {
64
+ mlOrderId: string;
65
+ packId?: string;
66
+ buyerNickname?: string;
67
+ shipmentId?: string;
68
+ logisticType?: string;
69
+ items?: OrderMercadolibreItem[];
70
+ fees?: {
71
+ saleFee?: number;
72
+ shippingCostSeller?: number;
73
+ currency: string;
74
+ currencyValue?: number;
75
+ currencyValueAt?: number;
76
+ };
77
+ billingInfo?: {
78
+ docType?: string;
79
+ docNumber?: string;
80
+ custType?: 'CO' | 'BU';
81
+ taxpayerType?: string;
82
+ iibbNumber?: string;
83
+ };
84
+ }
85
+ interface OrderMercadolibreItem {
86
+ mlItemId: string;
87
+ variationId?: string;
88
+ userProductId?: string;
89
+ sellerSku?: string;
90
+ quantity: number;
91
+ stock?: {
92
+ mlStoreId?: string;
93
+ networkNodeId?: string;
94
+ }[];
59
95
  }
60
96
  interface LinkedPaymentEntry {
61
97
  source: 'mp' | 'stripe' | 'mp_movement';
package/dist/product.d.ts CHANGED
@@ -44,6 +44,19 @@ declare global {
44
44
  isService: boolean;
45
45
  cost: number;
46
46
  prices?: PriceSlot[];
47
+ channels?: Record<string, ProductChannelMapping>;
48
+ }
49
+ type ProductChannelStatus = 'linked' | 'pending' | 'paused' | 'rejected' | 'unlinked';
50
+ interface ProductChannelMapping {
51
+ externalId?: string;
52
+ userProductId?: string;
53
+ familyId?: string;
54
+ variationId?: string;
55
+ status: ProductChannelStatus;
56
+ linkedAt?: number;
57
+ lastSyncedAt?: number;
58
+ basis?: MlMatchBasis | 'manual';
59
+ syncErrors?: string[];
47
60
  }
48
61
  }
49
62
  export {};
package/dist/store.d.ts CHANGED
@@ -150,6 +150,7 @@ declare global {
150
150
  newPhotoURL?: string;
151
151
  removePhotoURL?: string;
152
152
  mercadopagoUserId?: string;
153
+ mercadolibreUserId?: string;
153
154
  currencies: StoreCurrencySubscription[];
154
155
  cashInMethods: Method[];
155
156
  cashOutMethods: Method[];
@@ -194,6 +195,7 @@ declare global {
194
195
  whatsapp?: WhatsAppConfig;
195
196
  sms?: SmsIntegration;
196
197
  gmail?: Gmail;
198
+ mercadolibre?: Mercadolibre;
197
199
  }
198
200
  interface SmsIntegration {
199
201
  /** When true, the store may send SMS through the shared platform account. */
@@ -265,6 +267,39 @@ declare global {
265
267
  code?: string;
266
268
  }
267
269
  type MercadopagoConnectionStatus = "connected" | "expired" | "disconnected" | "error" | "never";
270
+ type MercadolibreConnectionStatus = "connected" | "expired" | "disconnected" | "error" | "needs-reauth" | "never";
271
+ interface Mercadolibre {
272
+ userId?: string;
273
+ nickname?: string;
274
+ /** KMS-encrypted (`alias/ml-oauth-tokens`) — never returned in API responses. */
275
+ accessTokenEncrypted?: string;
276
+ /** KMS-encrypted. SINGLE-USE rotated by ML (last-only-valid) — never returned. */
277
+ refreshTokenEncrypted?: string;
278
+ expiresAt?: number;
279
+ connectedAt?: number;
280
+ tokenType?: string;
281
+ scope?: string;
282
+ status?: MercadolibreConnectionStatus;
283
+ disconnectedAt?: number;
284
+ lastTokenRefreshAt?: number;
285
+ /** Transient (network/5xx) failures only — a hard `invalid_grant` is
286
+ * terminal on FIRST occurrence (→ `needs-reauth`), never counted. */
287
+ tokenRefreshFailures?: number;
288
+ /** Write-ahead refresh-attempt marker (ADR-0018 Amendment B): unix ms
289
+ * persisted BEFORE calling ML's token endpoint. A dangling marker found
290
+ * by the next lock-acquirer means the previous winner may have burned
291
+ * the single-use refresh token → go straight to `needs-reauth`. */
292
+ refreshAttemptAt?: number;
293
+ /** Per-channel auto-invoice toggle — default OFF; enabling requires
294
+ * `defaultPosId` (dedicated PdV) + the Facturador-collision check. */
295
+ autoInvoice?: boolean;
296
+ defaultPosId?: number;
297
+ syncPolicy?: {
298
+ stockBuffer?: number;
299
+ stockLimit?: number;
300
+ paused?: boolean;
301
+ };
302
+ }
268
303
  interface Afip {
269
304
  production: boolean;
270
305
  address?: string;
@@ -278,7 +313,7 @@ declare global {
278
313
  pointOfSale?: number;
279
314
  activitiesStartedAt?: number;
280
315
  invoiceNote?: string;
281
- showInvoiceLogo?: string;
316
+ showInvoiceLogo?: boolean;
282
317
  currency: CatalogId;
283
318
  cert?: string;
284
319
  csr?: string;
@@ -63,7 +63,7 @@ declare global {
63
63
  * every existing plan in `FEATURE_MATRIX` must then declare the new key
64
64
  * (TypeScript enforces this via `Record<FeatureKey, Entitlement>`).
65
65
  */
66
- type FeatureKey = 'maxOrdersMonth' | 'maxInvoicesMonth' | 'maxProducts' | 'maxUsers' | 'maxCustomers' | 'maxStores' | 'priceListsMax' | 'afipInvoicing' | 'paymentIntegrations' | 'suppliers' | 'cashManagement' | 'multiStore' | 'importExport' | 'advancedReports' | 'customBranding' | 'apiAccess' | 'prioritySupport' | 'whatsappCommerce' | 'aiFeatures' | 'mobileApp' | 'customDomain' | 'advancedPricing';
66
+ type FeatureKey = 'maxOrdersMonth' | 'maxInvoicesMonth' | 'maxProducts' | 'maxUsers' | 'maxCustomers' | 'maxStores' | 'priceListsMax' | 'afipInvoicing' | 'paymentIntegrations' | 'suppliers' | 'cashManagement' | 'multiStore' | 'importExport' | 'advancedReports' | 'customBranding' | 'apiAccess' | 'prioritySupport' | 'whatsappCommerce' | 'aiFeatures' | 'mobileApp' | 'customDomain' | 'advancedPricing' | 'marketplaceChannels';
67
67
  /** Full feature matrix — every tier declares every feature. */
68
68
  type FeatureMatrix = Record<PlanTier, Record<FeatureKey, Entitlement>>;
69
69
  /** Resolved entitlements for a specific tenant (matrix + overrides applied). */
@@ -392,7 +392,7 @@ declare global {
392
392
  }
393
393
  interface IntegrationTokenRefreshedEvent extends UserActivityEventBase {
394
394
  event: 'Integration Token Refreshed';
395
- provider: 'mercadopago' | 'gmail';
395
+ provider: 'mercadopago' | 'gmail' | 'mercadolibre';
396
396
  outcome: 'refreshed' | 'disconnected' | 'skipped' | 'error';
397
397
  trigger: 'operator-single' | 'operator-global';
398
398
  detail?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.6.43",
3
+ "version": "1.6.45",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",