@yoryoboy/bi-mcp 1.14.3 → 1.16.0

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.
Files changed (29) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/index.js +12 -1
  3. package/dist/index.js.map +2 -2
  4. package/dist/mcp-use.json +2 -2
  5. package/dist/src/services/mercadolibre/mercadolibre-billing.js +99 -1
  6. package/dist/src/services/mercadolibre/mercadolibre-billing.js.map +2 -2
  7. package/dist/src/tools/mercadolibre/get-billing-provisions-summary.js +391 -0
  8. package/dist/src/tools/mercadolibre/get-billing-provisions-summary.js.map +7 -0
  9. package/dist/src/tools/mercadolibre/get-order-details.js +18 -4
  10. package/dist/src/tools/mercadolibre/get-order-details.js.map +2 -2
  11. package/dist/src/tools/mercadolibre/get-orders-summary.js +6 -2
  12. package/dist/src/tools/mercadolibre/get-orders-summary.js.map +2 -2
  13. package/dist/src/tools/mercadolibre/get-shipping-summary.js +50 -14
  14. package/dist/src/tools/mercadolibre/get-shipping-summary.js.map +2 -2
  15. package/dist/src/tools/mercadolibre/index.js +1 -0
  16. package/dist/src/tools/mercadolibre/index.js.map +2 -2
  17. package/dist/tests/meli/mercadolibre-billing-provisions.test.js +940 -0
  18. package/dist/tests/meli/mercadolibre-billing-provisions.test.js.map +7 -0
  19. package/dist/tests/meli/mercadolibre-tool-handlers-medium-batch4.test.js +16 -4
  20. package/dist/tests/meli/mercadolibre-tool-handlers-medium-batch4.test.js.map +2 -2
  21. package/dist/tests/meli/mercadolibre-tool-handlers-monster-batch5.test.js +25 -3
  22. package/dist/tests/meli/mercadolibre-tool-handlers-monster-batch5.test.js.map +2 -2
  23. package/dist/tests/meli/mercadolibre-tool-handlers-monster-batch6.test.js +141 -5
  24. package/dist/tests/meli/mercadolibre-tool-handlers-monster-batch6.test.js.map +2 -2
  25. package/dist/tests/meli/mercadolibre-tool-handlers-monster-batch7.test.js +3 -2
  26. package/dist/tests/meli/mercadolibre-tool-handlers-monster-batch7.test.js.map +2 -2
  27. package/dist/vitest.config.js +3 -1
  28. package/dist/vitest.config.js.map +2 -2
  29. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/services/mercadolibre/mercadolibre-billing.ts"],
4
- "sourcesContent": ["import { getMercadoLibreApiContext, formatMercadoLibreError } from \"./mercadolibre-api.js\";\n\nexport interface MercadoLibreBillingDetailsParams {\n periodKey: string;\n documentType?: \"BILL\" | \"CREDIT_NOTE\";\n group?: \"ML\" | \"MP\" | \"flex\";\n limit?: number;\n offset?: number;\n}\n\nexport interface MercadoLibreBillingPage {\n offset: number;\n limit: number;\n total: number;\n results: Record<string, unknown>[];\n}\n\nexport interface MercadoLibreBillingFetchResult {\n period_key: string;\n group: string;\n document_type: string;\n pages_requested: number;\n pages_succeeded: number;\n pages_failed: number;\n total_reported: number;\n rows: Record<string, unknown>[];\n failures: Array<{\n offset: number;\n limit: number;\n message: string;\n }>;\n}\n\nexport async function getMercadoLibreBillingDetailsPage(\n profileId: string,\n params: MercadoLibreBillingDetailsParams\n): Promise<MercadoLibreBillingPage> {\n const { api } = await getMercadoLibreApiContext(profileId);\n const documentType = params.documentType ?? \"BILL\";\n const group = params.group ?? \"ML\";\n const limit = Math.min(150, Math.max(1, Math.floor(params.limit ?? 150)));\n const offset = Math.max(0, Math.floor(params.offset ?? 0));\n\n const response = await api.get<Record<string, unknown>>(\n `/billing/integration/periods/key/${params.periodKey}/group/${group}/details`,\n {\n params: {\n document_type: documentType,\n limit,\n offset,\n },\n }\n );\n\n return {\n offset: Number(response.data.offset ?? offset),\n limit: Number(response.data.limit ?? limit),\n total: Number(response.data.total ?? 0),\n results: Array.isArray(response.data.results)\n ? (response.data.results as Record<string, unknown>[])\n : [],\n };\n}\n\nexport async function getMercadoLibreBillingDetails(\n profileId: string,\n params: Omit<MercadoLibreBillingDetailsParams, \"offset\"> & { maxPages?: number }\n): Promise<MercadoLibreBillingFetchResult> {\n const limit = Math.min(150, Math.max(1, Math.floor(params.limit ?? 150)));\n const maxPages = Math.max(1, Math.floor(params.maxPages ?? 20));\n const documentType = params.documentType ?? \"BILL\";\n const group = params.group ?? \"ML\";\n const rows: Record<string, unknown>[] = [];\n const failures: MercadoLibreBillingFetchResult[\"failures\"] = [];\n\n let totalReported = 0;\n let pagesRequested = 0;\n let pagesSucceeded = 0;\n\n for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {\n const offset = pageIndex * limit;\n pagesRequested += 1;\n\n try {\n const page = await getMercadoLibreBillingDetailsPage(profileId, {\n ...params,\n group,\n documentType,\n limit,\n offset,\n });\n pagesSucceeded += 1;\n totalReported = Math.max(totalReported, page.total);\n rows.push(...page.results);\n\n if (offset + page.results.length >= page.total || page.results.length === 0) {\n break;\n }\n } catch (error) {\n failures.push({\n offset,\n limit,\n message: formatMercadoLibreError(error, \"Failed to fetch MercadoLibre billing details\"),\n });\n break;\n }\n }\n\n return {\n period_key: params.periodKey,\n group,\n document_type: documentType,\n pages_requested: pagesRequested,\n pages_succeeded: pagesSucceeded,\n pages_failed: failures.length,\n total_reported: totalReported,\n rows,\n failures,\n };\n}\n"],
5
- "mappings": "AAAA,SAAS,2BAA2B,+BAA+B;AAiCnE,eAAsB,kCACpB,WACA,QACkC;AAClC,QAAM,EAAE,IAAI,IAAI,MAAM,0BAA0B,SAAS;AACzD,QAAM,eAAe,OAAO,gBAAgB;AAC5C,QAAM,QAAQ,OAAO,SAAS;AAC9B,QAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,SAAS,GAAG,CAAC,CAAC;AACxE,QAAM,SAAS,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,UAAU,CAAC,CAAC;AAEzD,QAAM,WAAW,MAAM,IAAI;AAAA,IACzB,oCAAoC,OAAO,SAAS,UAAU,KAAK;AAAA,IACnE;AAAA,MACE,QAAQ;AAAA,QACN,eAAe;AAAA,QACf;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EA,SAAO;AAAA,IACL,YAAY,OAAO;AAAA,IACnB;AAAA,IACA,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB,cAAc,SAAS;AAAA,IACvB,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { getMercadoLibreApiContext, formatMercadoLibreError } from \"./mercadolibre-api.js\";\n\nexport interface MercadoLibreBillingDetailsParams {\n periodKey: string;\n documentType?: \"BILL\" | \"CREDIT_NOTE\";\n group?: \"ML\" | \"MP\" | \"flex\";\n limit?: number;\n offset?: number;\n}\n\nexport interface MercadoLibreBillingPage {\n offset: number;\n limit: number;\n total: number;\n results: Record<string, unknown>[];\n}\n\nexport interface MercadoLibreBillingFetchResult {\n period_key: string;\n group: string;\n document_type: string;\n pages_requested: number;\n pages_succeeded: number;\n pages_failed: number;\n total_reported: number;\n rows: Record<string, unknown>[];\n failures: Array<{\n offset: number;\n limit: number;\n message: string;\n }>;\n}\n\n// \u2500\u2500 Provisions (from_id cursor) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type BillingProvisionScope = \"ml\" | \"mp\" | \"flex\" | \"full\";\n\nexport interface BillingProvisionPage {\n results: Record<string, unknown>[];\n last_id: string | null;\n total: number;\n limit: number;\n}\n\nexport interface BillingProvisionFetchResult {\n scope: BillingProvisionScope;\n period_key: string;\n document_type: string;\n pages_requested: number;\n pages_succeeded: number;\n pages_failed: number;\n detail_count_total: number;\n last_id_seen: string | null;\n coverage_complete: boolean;\n rows: Record<string, unknown>[];\n failures: Array<{ page: number; from_id: string | null; message: string }>;\n}\n\n/**\n * Resolves the URL path segment for a given scope.\n * ml \u2192 group/ML/details\n * mp \u2192 group/MP/details\n * flex \u2192 group/ML/flex/details\n * full \u2192 group/ML/full/details\n */\nexport function scopeToGroupPath(scope: BillingProvisionScope): string {\n if (scope === \"flex\") return \"ML/flex\";\n if (scope === \"full\") return \"ML/full\";\n return scope.toUpperCase(); // \"ml\" \u2192 \"ML\", \"mp\" \u2192 \"MP\"\n}\n\n/**\n * Fetch one page of billing provisions using from_id cursor.\n */\nexport async function getMercadoLibreBillingProvisionPage(\n profileId: string,\n params: {\n periodKey: string;\n scope: BillingProvisionScope;\n documentType: \"BILL\" | \"CREDIT_NOTE\";\n limit: number;\n fromId?: string | null;\n detailType?: string;\n detailSubTypes?: string[];\n excludeDetailSubTypes?: string[];\n marketplaceType?: string;\n orderIds?: string[];\n itemIds?: string[];\n }\n): Promise<BillingProvisionPage> {\n const { api } = await getMercadoLibreApiContext(profileId);\n\n const queryParams: Record<string, unknown> = {\n document_type: params.documentType,\n limit: params.limit,\n };\n if (params.fromId) queryParams.from_id = params.fromId;\n if (params.detailType) queryParams.detail_type = params.detailType;\n if (params.detailSubTypes?.length) queryParams.detail_sub_types = params.detailSubTypes.join(\",\");\n if (params.excludeDetailSubTypes?.length) queryParams.exclude_detail_sub_types = params.excludeDetailSubTypes.join(\",\");\n if (params.marketplaceType) queryParams.marketplace_type = params.marketplaceType;\n if (params.orderIds?.length) queryParams.order_ids = params.orderIds.join(\",\");\n if (params.itemIds?.length) queryParams.item_ids = params.itemIds.join(\",\");\n\n const groupPath = scopeToGroupPath(params.scope);\n const response = await api.get<Record<string, unknown>>(\n `/billing/integration/periods/key/${params.periodKey}/group/${groupPath}/details`,\n { params: queryParams }\n );\n\n const data = response.data;\n const results = Array.isArray(data.results) ? (data.results as Record<string, unknown>[]) : [];\n const lastId = typeof data.last_id === \"string\" && data.last_id ? data.last_id : null;\n const pageTotal = Number(data.total ?? 0);\n const pageLimit = Number(data.limit ?? params.limit);\n\n return {\n results,\n last_id: lastId,\n total: isFinite(pageTotal) ? Math.max(0, pageTotal) : 0,\n limit: isFinite(pageLimit) ? Math.max(0, pageLimit) : params.limit,\n };\n}\n\nconst PROVISIONS_PAGE_LIMIT = 1000;\nconst PROVISIONS_MAX_PAGES = 200;\n\n/**\n * Fetch all billing provisions for one scope by walking from_id cursor.\n * Deduplicates by detail_id. Stops if last_id doesn't advance.\n * Returns partial coverage when pages fail.\n */\nexport async function getMercadoLibreBillingProvisions(\n profileId: string,\n params: {\n periodKey: string;\n scope: BillingProvisionScope;\n documentType: \"BILL\" | \"CREDIT_NOTE\";\n detailType?: string;\n detailSubTypes?: string[];\n excludeDetailSubTypes?: string[];\n marketplaceType?: string;\n orderIds?: string[];\n itemIds?: string[];\n /** Resume cursor: start fetching from this from_id instead of the first page. */\n fromId?: string | null;\n }\n): Promise<BillingProvisionFetchResult> {\n const seen = new Set<string>();\n const rows: Record<string, unknown>[] = [];\n const failures: BillingProvisionFetchResult[\"failures\"] = [];\n let lastId: string | null = params.fromId ?? null;\n let pagesRequested = 0;\n let pagesSucceeded = 0;\n let lastIdSeen: string | null = null;\n\n for (let page = 0; page < PROVISIONS_MAX_PAGES; page++) {\n pagesRequested += 1;\n let pageResult: BillingProvisionPage;\n\n try {\n pageResult = await getMercadoLibreBillingProvisionPage(profileId, {\n ...params,\n documentType: params.documentType,\n limit: PROVISIONS_PAGE_LIMIT,\n fromId: lastId,\n });\n pagesSucceeded += 1;\n } catch (error) {\n failures.push({\n page: page + 1,\n from_id: lastId,\n message: formatMercadoLibreError(error, \"Failed to fetch billing provisions page\"),\n });\n break;\n }\n\n const newRows: Record<string, unknown>[] = [];\n for (const row of pageResult.results) {\n // Real MELI payload nests detail fields under charge_info\n const chargeInfo = (row.charge_info as Record<string, unknown>) ?? row;\n const detailId = typeof chargeInfo.detail_id === \"string\"\n ? chargeInfo.detail_id\n : String(chargeInfo.detail_id ?? \"\");\n if (!detailId || seen.has(detailId)) continue;\n seen.add(detailId);\n newRows.push(row);\n }\n rows.push(...newRows);\n lastIdSeen = pageResult.last_id;\n\n // Stop conditions\n if (!pageResult.last_id) break;\n if (pageResult.last_id === lastId) break; // cursor not advancing\n if (pageResult.results.length === 0) break;\n\n lastId = pageResult.last_id;\n }\n\n const pagesFailed = pagesRequested - pagesSucceeded;\n const coverageComplete = pagesFailed === 0 && lastIdSeen === null;\n\n return {\n scope: params.scope,\n period_key: params.periodKey,\n document_type: params.documentType,\n pages_requested: pagesRequested,\n pages_succeeded: pagesSucceeded,\n pages_failed: pagesFailed,\n detail_count_total: rows.length,\n last_id_seen: lastIdSeen,\n coverage_complete: coverageComplete,\n rows,\n failures,\n };\n}\n\n// \u2500\u2500 Existing offset-based billing (preserved for backward compat) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport async function getMercadoLibreBillingDetailsPage(\n profileId: string,\n params: MercadoLibreBillingDetailsParams\n): Promise<MercadoLibreBillingPage> {\n const { api } = await getMercadoLibreApiContext(profileId);\n const documentType = params.documentType ?? \"BILL\";\n const group = params.group ?? \"ML\";\n const limit = Math.min(150, Math.max(1, Math.floor(params.limit ?? 150)));\n const offset = Math.max(0, Math.floor(params.offset ?? 0));\n\n const response = await api.get<Record<string, unknown>>(\n `/billing/integration/periods/key/${params.periodKey}/group/${group}/details`,\n {\n params: {\n document_type: documentType,\n limit,\n offset,\n },\n }\n );\n\n return {\n offset: Number(response.data.offset ?? offset),\n limit: Number(response.data.limit ?? limit),\n total: Number(response.data.total ?? 0),\n results: Array.isArray(response.data.results)\n ? (response.data.results as Record<string, unknown>[])\n : [],\n };\n}\n\nexport async function getMercadoLibreBillingDetails(\n profileId: string,\n params: Omit<MercadoLibreBillingDetailsParams, \"offset\"> & { maxPages?: number }\n): Promise<MercadoLibreBillingFetchResult> {\n const limit = Math.min(150, Math.max(1, Math.floor(params.limit ?? 150)));\n const maxPages = Math.max(1, Math.floor(params.maxPages ?? 20));\n const documentType = params.documentType ?? \"BILL\";\n const group = params.group ?? \"ML\";\n const rows: Record<string, unknown>[] = [];\n const failures: MercadoLibreBillingFetchResult[\"failures\"] = [];\n\n let totalReported = 0;\n let pagesRequested = 0;\n let pagesSucceeded = 0;\n\n for (let pageIndex = 0; pageIndex < maxPages; pageIndex += 1) {\n const offset = pageIndex * limit;\n pagesRequested += 1;\n\n try {\n const page = await getMercadoLibreBillingDetailsPage(profileId, {\n ...params,\n group,\n documentType,\n limit,\n offset,\n });\n pagesSucceeded += 1;\n totalReported = Math.max(totalReported, page.total);\n rows.push(...page.results);\n\n if (offset + page.results.length >= page.total || page.results.length === 0) {\n break;\n }\n } catch (error) {\n failures.push({\n offset,\n limit,\n message: formatMercadoLibreError(error, \"Failed to fetch MercadoLibre billing details\"),\n });\n break;\n }\n }\n\n return {\n period_key: params.periodKey,\n group,\n document_type: documentType,\n pages_requested: pagesRequested,\n pages_succeeded: pagesSucceeded,\n pages_failed: failures.length,\n total_reported: totalReported,\n rows,\n failures,\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,2BAA2B,+BAA+B;AAiE5D,SAAS,iBAAiB,OAAsC;AACrE,MAAI,UAAU,OAAQ,QAAO;AAC7B,MAAI,UAAU,OAAQ,QAAO;AAC7B,SAAO,MAAM,YAAY;AAC3B;AAKA,eAAsB,oCACpB,WACA,QAa+B;AAC/B,QAAM,EAAE,IAAI,IAAI,MAAM,0BAA0B,SAAS;AAEzD,QAAM,cAAuC;AAAA,IAC3C,eAAe,OAAO;AAAA,IACtB,OAAO,OAAO;AAAA,EAChB;AACA,MAAI,OAAO,OAAQ,aAAY,UAAU,OAAO;AAChD,MAAI,OAAO,WAAY,aAAY,cAAc,OAAO;AACxD,MAAI,OAAO,gBAAgB,OAAQ,aAAY,mBAAmB,OAAO,eAAe,KAAK,GAAG;AAChG,MAAI,OAAO,uBAAuB,OAAQ,aAAY,2BAA2B,OAAO,sBAAsB,KAAK,GAAG;AACtH,MAAI,OAAO,gBAAiB,aAAY,mBAAmB,OAAO;AAClE,MAAI,OAAO,UA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AAAA,QACZ;AAAA,QACA;AAAA,QACA,SAAS,wBAAwB,OAAO,8CAA8C;AAAA,MACxF,CAAC;AACD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,YAAY,OAAO;AAAA,IACnB;AAAA,IACA,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB,cAAc,SAAS;AAAA,IACvB,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,391 @@
1
+ import { error, object } from "mcp-use/server";
2
+ import { z } from "zod";
3
+ import {
4
+ getMercadoLibreBillingProvisions
5
+ } from "../../services/mercadolibre/mercadolibre-billing.js";
6
+ import {
7
+ formatMercadoLibreError
8
+ } from "../../services/mercadolibre/mercadolibre-api.js";
9
+ import { stripNulls } from "../../utils/strip-payload.js";
10
+ import { normalizeString, roundMoney, toNumber, asArray } from "./helpers.js";
11
+ import { resolveMercadoLibreProfileOrSelection } from "./profile-resolution.js";
12
+ import { mercadolibreProfileIdSchemaField } from "./write-helpers.js";
13
+ const meliGetBillingProvisionsSummarySchema = z.object({
14
+ profileId: mercadolibreProfileIdSchemaField,
15
+ periodKey: z.string().regex(/^\d{4}-\d{2}-01$/).describe("Billing period key in YYYY-MM-01 format (month start only)."),
16
+ scope: z.enum(["ml", "mp", "flex", "full", "all"]).describe(
17
+ "Provision scope: ml (MercadoLibre), mp (MercadoPago), flex (Meli Flex), full (Meli Full), or all (all scopes merged)."
18
+ ),
19
+ documentType: z.enum(["BILL", "CREDIT_NOTE"]).default("BILL").optional().describe("Document type: BILL or CREDIT_NOTE. Defaults to BILL."),
20
+ detailType: z.string().trim().min(1).optional().describe("Optional detail type filter."),
21
+ detailSubTypes: z.array(z.string().trim().min(1)).optional().describe("Optional detail sub-type filters."),
22
+ excludeDetailSubTypes: z.array(z.string().trim().min(1)).optional().describe("Optional detail sub-types to exclude."),
23
+ marketplaceType: z.string().trim().min(1).optional().describe("Optional marketplace type filter."),
24
+ orderIds: z.array(z.string().trim().min(1)).optional().describe("Optional order ID filters."),
25
+ itemIds: z.array(z.string().trim().min(1)).optional().describe("Optional item ID filters."),
26
+ fromIdByScope: z.object({
27
+ ml: z.string().trim().min(1).optional(),
28
+ mp: z.string().trim().min(1).optional(),
29
+ flex: z.string().trim().min(1).optional(),
30
+ full: z.string().trim().min(1).optional()
31
+ }).optional().describe(
32
+ 'Optional map from scope to from_id cursor for resuming a partial fetch. Use the same scope keys as the response continuation_by_scope block. Example: { "ml": "abc-123" } resumes the ml scope from cursor abc-123.'
33
+ )
34
+ });
35
+ const detailsSchema = [
36
+ "detail_id",
37
+ "detail_type",
38
+ "detail_sub_type",
39
+ "transaction_detail",
40
+ "detail_amount",
41
+ "currency_id",
42
+ "marketplace",
43
+ "concept_type",
44
+ "order_id",
45
+ "operation_id",
46
+ "item_id",
47
+ "item_title",
48
+ "shipping_id",
49
+ "pack_id",
50
+ "document_id",
51
+ "creation_date_time",
52
+ "sales_info_count",
53
+ "items_info_count"
54
+ ];
55
+ function projectCompactRow(row) {
56
+ const chargeInfo = row.charge_info ?? {};
57
+ const currencyInfo = row.currency_info ?? {};
58
+ const marketplaceInfo = row.marketplace_info ?? {};
59
+ const salesInfo = asArray(row.sales_info);
60
+ const itemsInfo = asArray(row.items_info);
61
+ const firstSale = salesInfo[0];
62
+ const firstItem = itemsInfo[0];
63
+ return [
64
+ normalizeString(chargeInfo.detail_id) || null,
65
+ // 0: detail_id
66
+ normalizeString(chargeInfo.detail_type) || null,
67
+ // 1: detail_type
68
+ normalizeString(chargeInfo.detail_sub_type) || null,
69
+ // 2: detail_sub_type
70
+ normalizeString(chargeInfo.transaction_detail) || null,
71
+ // 3: transaction_detail
72
+ toNumber(chargeInfo.detail_amount),
73
+ // 4: detail_amount
74
+ normalizeString(currencyInfo.currency_id) || null,
75
+ // 5: currency_id
76
+ normalizeString(marketplaceInfo.marketplace) || null,
77
+ // 6: marketplace
78
+ normalizeString(chargeInfo.concept_type) || null,
79
+ // 7: concept_type
80
+ firstSale ? normalizeString(firstSale.order_id) || null : null,
81
+ // 8: order_id
82
+ firstSale ? normalizeString(firstSale.operation_id) || null : null,
83
+ // 9: operation_id
84
+ firstItem ? normalizeString(firstItem.item_id) || null : null,
85
+ // 10: item_id
86
+ firstItem ? normalizeString(firstItem.item_title) || null : null,
87
+ // 11: item_title
88
+ firstSale ? normalizeString(firstSale.shipping_id) || null : null,
89
+ // 12: shipping_id
90
+ firstSale ? normalizeString(firstSale.pack_id) || null : null,
91
+ // 13: pack_id
92
+ normalizeString(row.document_id) || null,
93
+ // 14: document_id
94
+ normalizeString(chargeInfo.creation_date_time ?? row.creation_date_time) || null,
95
+ // 15: creation_date_time
96
+ salesInfo.length,
97
+ // 16: sales_info_count
98
+ itemsInfo.length
99
+ // 17: items_info_count
100
+ ];
101
+ }
102
+ const detailsSalesSchema = [
103
+ "detail_id",
104
+ "order_id",
105
+ "operation_id",
106
+ "sale_date_time",
107
+ "payer_nickname",
108
+ "transaction_amount"
109
+ ];
110
+ function projectSalesRow(detailId, sale) {
111
+ return [
112
+ detailId,
113
+ // 0: detail_id
114
+ normalizeString(sale.order_id) || null,
115
+ // 1: order_id
116
+ normalizeString(sale.operation_id) || null,
117
+ // 2: operation_id
118
+ normalizeString(sale.sale_date_time) || null,
119
+ // 3: sale_date_time
120
+ normalizeString(sale.payer_nickname) || null,
121
+ // 4: payer_nickname
122
+ toNumber(sale.transaction_amount)
123
+ // 5: transaction_amount
124
+ ];
125
+ }
126
+ const detailsItemsSchema = [
127
+ "detail_id",
128
+ "item_id",
129
+ "item_title",
130
+ "item_amount",
131
+ "item_price",
132
+ "order_id"
133
+ ];
134
+ function projectItemsRow(detailId, item) {
135
+ return [
136
+ detailId,
137
+ // 0: detail_id
138
+ normalizeString(item.item_id) || null,
139
+ // 1: item_id
140
+ normalizeString(item.item_title) || null,
141
+ // 2: item_title
142
+ toNumber(item.item_amount),
143
+ // 3: item_amount
144
+ toNumber(item.item_price),
145
+ // 4: item_price
146
+ normalizeString(item.order_id) || null
147
+ // 5: order_id
148
+ ];
149
+ }
150
+ function emptyCurrencyBucket() {
151
+ return {
152
+ charge_amount_total: 0,
153
+ bonus_amount_total: 0,
154
+ discount_amount_total: 0,
155
+ net_effect_total: 0
156
+ };
157
+ }
158
+ function classifyChargeType(row) {
159
+ const chargeInfo = row.charge_info ?? {};
160
+ const detailSubType = normalizeString(chargeInfo.detail_sub_type, "").trim().toUpperCase();
161
+ const transactionDetail = normalizeString(chargeInfo.transaction_detail, "").toLowerCase().trim();
162
+ const conceptType = normalizeString(chargeInfo.concept_type, "").toLowerCase().trim();
163
+ if (detailSubType.startsWith("B") || detailSubType.toLowerCase().includes("bonus") || detailSubType.toLowerCase().includes("bonificacion") || detailSubType.toLowerCase().includes("bonificaci\xF3n") || transactionDetail.includes("anulaci\xF3n") || transactionDetail.includes("anulacion") || transactionDetail.includes("bonus") || transactionDetail.includes("bonificaci\xF3n") || conceptType.includes("bonus") || conceptType.includes("bonificaci\xF3n")) {
164
+ return "bonus";
165
+ }
166
+ if (detailSubType.startsWith("D") || detailSubType.toLowerCase().includes("discount") || detailSubType.toLowerCase().includes("descuento") || detailSubType.toLowerCase().includes("adjustment") || transactionDetail.includes("descuento") || transactionDetail.includes("discount") || transactionDetail.includes("ajuste") || conceptType.includes("discount") || conceptType.includes("descuento")) {
167
+ return "discount";
168
+ }
169
+ return "charge";
170
+ }
171
+ function aggregateRows(rows) {
172
+ const currencyTotals = {};
173
+ const orderIds = /* @__PURE__ */ new Set();
174
+ const itemIds = /* @__PURE__ */ new Set();
175
+ const compactRows = [];
176
+ const detailSubTypesObserved = /* @__PURE__ */ new Set();
177
+ const marketplacesObserved = /* @__PURE__ */ new Set();
178
+ const conceptTypesObserved = /* @__PURE__ */ new Set();
179
+ for (const row of rows) {
180
+ compactRows.push(projectCompactRow(row));
181
+ const currencyInfo = row.currency_info;
182
+ const currency = normalizeString(
183
+ currencyInfo?.currency_id ?? row.currency_id ?? row.currency,
184
+ "UNKNOWN"
185
+ ).toUpperCase();
186
+ const bucket = currencyTotals[currency] ?? emptyCurrencyBucket();
187
+ currencyTotals[currency] = bucket;
188
+ const chargeInfo = row.charge_info ?? {};
189
+ const amount = toNumber(chargeInfo.detail_amount ?? chargeInfo.amount ?? 0);
190
+ const chargeType = classifyChargeType(row);
191
+ if (chargeType === "bonus") {
192
+ bucket.bonus_amount_total += amount;
193
+ } else if (chargeType === "discount") {
194
+ bucket.discount_amount_total += amount;
195
+ } else {
196
+ bucket.charge_amount_total += amount;
197
+ }
198
+ const detailSubType = normalizeString(chargeInfo.detail_sub_type, "").trim();
199
+ if (detailSubType) detailSubTypesObserved.add(detailSubType);
200
+ const marketplaceInfo = row.marketplace_info;
201
+ const marketplace = normalizeString(marketplaceInfo?.marketplace, "").trim();
202
+ if (marketplace) marketplacesObserved.add(marketplace);
203
+ const conceptType = normalizeString(chargeInfo.concept_type, "").trim();
204
+ if (conceptType) conceptTypesObserved.add(conceptType);
205
+ const salesInfo = asArray(row.sales_info);
206
+ for (const si of salesInfo) {
207
+ const oid = normalizeString(si.order_id);
208
+ if (oid) orderIds.add(oid);
209
+ }
210
+ const itemsInfo = asArray(row.items_info);
211
+ for (const ii of itemsInfo) {
212
+ const iid = normalizeString(ii.item_id);
213
+ if (iid) itemIds.add(iid);
214
+ }
215
+ }
216
+ for (const bucket of Object.values(currencyTotals)) {
217
+ bucket.net_effect_total = bucket.charge_amount_total + bucket.bonus_amount_total + bucket.discount_amount_total;
218
+ }
219
+ for (const bucket of Object.values(currencyTotals)) {
220
+ bucket.charge_amount_total = roundMoney(bucket.charge_amount_total);
221
+ bucket.bonus_amount_total = roundMoney(bucket.bonus_amount_total);
222
+ bucket.discount_amount_total = roundMoney(bucket.discount_amount_total);
223
+ bucket.net_effect_total = roundMoney(bucket.net_effect_total);
224
+ }
225
+ return {
226
+ compactRows,
227
+ currencyTotals,
228
+ detailCount: rows.length,
229
+ orderCountDetected: orderIds.size,
230
+ itemCountDetected: itemIds.size,
231
+ detailSubTypesObserved,
232
+ marketplacesObserved,
233
+ conceptTypesObserved
234
+ };
235
+ }
236
+ const ALL_SCOPES = ["ml", "mp", "flex", "full"];
237
+ async function fetchScope(profileId, scope, params, fromId) {
238
+ return getMercadoLibreBillingProvisions(profileId, { scope, ...params, fromId });
239
+ }
240
+ async function meliGetBillingProvisionsSummaryHandler(params) {
241
+ try {
242
+ const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);
243
+ if (!profileResolution.ok) {
244
+ return profileResolution.response;
245
+ }
246
+ const profileId = profileResolution.value.profileId;
247
+ const documentType = params.documentType ?? "BILL";
248
+ const fetchParams = {
249
+ periodKey: params.periodKey,
250
+ documentType,
251
+ detailType: params.detailType,
252
+ detailSubTypes: params.detailSubTypes,
253
+ excludeDetailSubTypes: params.excludeDetailSubTypes,
254
+ marketplaceType: params.marketplaceType,
255
+ orderIds: params.orderIds,
256
+ itemIds: params.itemIds
257
+ };
258
+ const scopes = params.scope === "all" ? ALL_SCOPES : [params.scope];
259
+ const fromIdByScope = params.fromIdByScope ?? {};
260
+ const scopeResults = await Promise.all(
261
+ scopes.map((scope) => fetchScope(profileId, scope, fetchParams, fromIdByScope[scope] ?? null))
262
+ );
263
+ let totalRows = 0;
264
+ const globalOrderIds = /* @__PURE__ */ new Set();
265
+ const globalItemIds = /* @__PURE__ */ new Set();
266
+ const globalCompactRows = [];
267
+ const globalCurrencyTotals = {};
268
+ const globalDetailSubTypes = /* @__PURE__ */ new Set();
269
+ const globalMarketplaces = /* @__PURE__ */ new Set();
270
+ const globalConceptTypes = /* @__PURE__ */ new Set();
271
+ const globalSalesRows = [];
272
+ const globalItemsRows = [];
273
+ const coverageByScope = {};
274
+ const continuationByScope = {};
275
+ let totalSourcesCalled = 0;
276
+ let totalPagesRequested = 0;
277
+ let totalPagesSucceeded = 0;
278
+ let totalPagesFailed = 0;
279
+ let globalCoverageComplete = true;
280
+ let allFailures = [];
281
+ for (const result of scopeResults) {
282
+ const agg = aggregateRows(result.rows);
283
+ for (const [currency, bucket] of Object.entries(agg.currencyTotals)) {
284
+ const global = globalCurrencyTotals[currency] ?? emptyCurrencyBucket();
285
+ globalCurrencyTotals[currency] = global;
286
+ global.charge_amount_total = roundMoney(global.charge_amount_total + bucket.charge_amount_total);
287
+ global.bonus_amount_total = roundMoney(global.bonus_amount_total + bucket.bonus_amount_total);
288
+ global.discount_amount_total = roundMoney(global.discount_amount_total + bucket.discount_amount_total);
289
+ global.net_effect_total = roundMoney(global.net_effect_total + bucket.net_effect_total);
290
+ }
291
+ globalCompactRows.push(...agg.compactRows);
292
+ totalRows += agg.detailCount;
293
+ for (const row of result.rows) {
294
+ const chargeInfo = row.charge_info ?? {};
295
+ const detailId = normalizeString(chargeInfo.detail_id) || null;
296
+ const salesInfo = asArray(row.sales_info);
297
+ for (const si of salesInfo) {
298
+ const oid = normalizeString(si.order_id);
299
+ if (oid) globalOrderIds.add(oid);
300
+ globalSalesRows.push(projectSalesRow(detailId, si));
301
+ }
302
+ const itemsInfo = asArray(row.items_info);
303
+ for (const ii of itemsInfo) {
304
+ const iid = normalizeString(ii.item_id);
305
+ if (iid) globalItemIds.add(iid);
306
+ globalItemsRows.push(projectItemsRow(detailId, ii));
307
+ }
308
+ }
309
+ for (const s of agg.detailSubTypesObserved) globalDetailSubTypes.add(s);
310
+ for (const m of agg.marketplacesObserved) globalMarketplaces.add(m);
311
+ for (const c of agg.conceptTypesObserved) globalConceptTypes.add(c);
312
+ coverageByScope[result.scope] = {
313
+ coverage_complete: result.coverage_complete,
314
+ last_id_seen: result.last_id_seen,
315
+ pages_requested: result.pages_requested,
316
+ pages_succeeded: result.pages_succeeded,
317
+ pages_failed: result.pages_failed,
318
+ detail_count: agg.detailCount
319
+ };
320
+ if (!result.coverage_complete && result.last_id_seen) {
321
+ continuationByScope[result.scope] = {
322
+ last_id: result.last_id_seen,
323
+ hint: `Resume ${result.scope} scope with fromIdByScope: { "${result.scope}": "${result.last_id_seen}" }. ${result.pages_failed} page(s) failed.`
324
+ };
325
+ }
326
+ totalSourcesCalled += 1;
327
+ totalPagesRequested += result.pages_requested;
328
+ totalPagesSucceeded += result.pages_succeeded;
329
+ totalPagesFailed += result.pages_failed;
330
+ if (!result.coverage_complete) globalCoverageComplete = false;
331
+ for (const f of result.failures) {
332
+ allFailures.push({ scope: result.scope, ...f });
333
+ }
334
+ }
335
+ const metadata = {
336
+ sources_called: totalSourcesCalled,
337
+ pages_requested: totalPagesRequested,
338
+ pages_succeeded: totalPagesSucceeded,
339
+ pages_failed: totalPagesFailed,
340
+ detail_count_total: totalRows,
341
+ coverage_complete: globalCoverageComplete,
342
+ coverage_by_scope: coverageByScope
343
+ };
344
+ if (Object.keys(continuationByScope).length > 0) {
345
+ metadata.continuation_by_scope = continuationByScope;
346
+ }
347
+ if (allFailures.length > 0) {
348
+ metadata.failures = allFailures;
349
+ }
350
+ const diagnostics = {
351
+ detail_sub_types_observed: [...globalDetailSubTypes].sort(),
352
+ marketplaces_observed: [...globalMarketplaces].sort(),
353
+ concept_types_observed: [...globalConceptTypes].sort()
354
+ };
355
+ const stripped = stripNulls({
356
+ profile_id: profileId,
357
+ period_key: params.periodKey,
358
+ scope: params.scope,
359
+ document_type: documentType,
360
+ metadata,
361
+ summary: {
362
+ detail_count: totalRows,
363
+ order_count_detected: globalOrderIds.size,
364
+ item_count_detected: globalItemIds.size,
365
+ currency_totals: globalCurrencyTotals
366
+ }
367
+ });
368
+ stripped.details_schema = detailsSchema;
369
+ stripped.details = globalCompactRows;
370
+ stripped.diagnostics = diagnostics;
371
+ stripped.details_sales_schema = detailsSalesSchema;
372
+ stripped.details_sales = globalSalesRows;
373
+ stripped.details_items_schema = detailsItemsSchema;
374
+ stripped.details_items = globalItemsRows;
375
+ const summary = stripped.summary;
376
+ summary.currency_totals = globalCurrencyTotals;
377
+ return object(stripped);
378
+ } catch (err) {
379
+ return error(
380
+ formatMercadoLibreError(err, "Failed to get MercadoLibre billing provisions summary")
381
+ );
382
+ }
383
+ }
384
+ export {
385
+ detailsItemsSchema,
386
+ detailsSalesSchema,
387
+ detailsSchema,
388
+ meliGetBillingProvisionsSummaryHandler,
389
+ meliGetBillingProvisionsSummarySchema
390
+ };
391
+ //# sourceMappingURL=get-billing-provisions-summary.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/tools/mercadolibre/get-billing-provisions-summary.ts"],
4
+ "sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport {\n type BillingProvisionFetchResult,\n type BillingProvisionScope,\n getMercadoLibreBillingProvisions,\n} from \"../../services/mercadolibre/mercadolibre-billing.js\";\nimport {\n formatMercadoLibreError,\n} from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { normalizeString, roundMoney, toNumber, asArray } from \"./helpers.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\n\n// \u2500\u2500 Schema \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const meliGetBillingProvisionsSummarySchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n periodKey: z\n .string()\n .regex(/^\\d{4}-\\d{2}-01$/)\n .describe(\"Billing period key in YYYY-MM-01 format (month start only).\"),\n scope: z.enum([\"ml\", \"mp\", \"flex\", \"full\", \"all\"]).describe(\n \"Provision scope: ml (MercadoLibre), mp (MercadoPago), flex (Meli Flex), full (Meli Full), or all (all scopes merged).\"\n ),\n documentType: z\n .enum([\"BILL\", \"CREDIT_NOTE\"])\n .default(\"BILL\")\n .optional()\n .describe(\"Document type: BILL or CREDIT_NOTE. Defaults to BILL.\"),\n detailType: z.string().trim().min(1).optional().describe(\"Optional detail type filter.\"),\n detailSubTypes: z\n .array(z.string().trim().min(1))\n .optional()\n .describe(\"Optional detail sub-type filters.\"),\n excludeDetailSubTypes: z\n .array(z.string().trim().min(1))\n .optional()\n .describe(\"Optional detail sub-types to exclude.\"),\n marketplaceType: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\"Optional marketplace type filter.\"),\n orderIds: z\n .array(z.string().trim().min(1))\n .optional()\n .describe(\"Optional order ID filters.\"),\n itemIds: z\n .array(z.string().trim().min(1))\n .optional()\n .describe(\"Optional item ID filters.\"),\n fromIdByScope: z\n .object({\n ml: z.string().trim().min(1).optional(),\n mp: z.string().trim().min(1).optional(),\n flex: z.string().trim().min(1).optional(),\n full: z.string().trim().min(1).optional(),\n })\n .optional()\n .describe(\n \"Optional map from scope to from_id cursor for resuming a partial fetch. \" +\n \"Use the same scope keys as the response continuation_by_scope block. \" +\n 'Example: { \"ml\": \"abc-123\" } resumes the ml scope from cursor abc-123.'\n ),\n});\n\n// \u2500\u2500 Compact schemas (faithful to real MELI payload, flattened) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const detailsSchema = [\n \"detail_id\",\n \"detail_type\",\n \"detail_sub_type\",\n \"transaction_detail\",\n \"detail_amount\",\n \"currency_id\",\n \"marketplace\",\n \"concept_type\",\n \"order_id\",\n \"operation_id\",\n \"item_id\",\n \"item_title\",\n \"shipping_id\",\n \"pack_id\",\n \"document_id\",\n \"creation_date_time\",\n \"sales_info_count\",\n \"items_info_count\",\n] as const;\n\ntype DetailRow = (string | number | null)[];\n\n/**\n * Project a raw MELI billing detail row into a positional compact array.\n * The order matches `detailsSchema`. Fields come from the nested MELI payload shape:\n * charge_info, currency_info, marketplace_info, sales_info[], items_info[]\n *\n * Positions 16-17 carry multiplicity signals so consumers know to check\n * details_sales/details_items secondary blocks when counts > 1.\n */\nfunction projectCompactRow(row: Record<string, unknown>): DetailRow {\n const chargeInfo = (row.charge_info as Record<string, unknown>) ?? {};\n const currencyInfo = (row.currency_info as Record<string, unknown>) ?? {};\n const marketplaceInfo = (row.marketplace_info as Record<string, unknown>) ?? {};\n const salesInfo = asArray<Record<string, unknown>>(row.sales_info);\n const itemsInfo = asArray<Record<string, unknown>>(row.items_info);\n\n const firstSale = salesInfo[0];\n const firstItem = itemsInfo[0];\n\n return [\n normalizeString(chargeInfo.detail_id) || null, // 0: detail_id\n normalizeString(chargeInfo.detail_type) || null, // 1: detail_type\n normalizeString(chargeInfo.detail_sub_type) || null, // 2: detail_sub_type\n normalizeString(chargeInfo.transaction_detail) || null, // 3: transaction_detail\n toNumber(chargeInfo.detail_amount), // 4: detail_amount\n normalizeString(currencyInfo.currency_id) || null, // 5: currency_id\n normalizeString(marketplaceInfo.marketplace) || null, // 6: marketplace\n normalizeString(chargeInfo.concept_type) || null, // 7: concept_type\n firstSale ? normalizeString(firstSale.order_id) || null : null, // 8: order_id\n firstSale ? normalizeString(firstSale.operation_id) || null : null, // 9: operation_id\n firstItem ? normalizeString(firstItem.item_id) || null : null, // 10: item_id\n firstItem ? normalizeString(firstItem.item_title) || null : null, // 11: item_title\n firstSale ? normalizeString(firstSale.shipping_id) || null : null, // 12: shipping_id\n firstSale ? normalizeString(firstSale.pack_id) || null : null, // 13: pack_id\n normalizeString(row.document_id) || null, // 14: document_id\n normalizeString(chargeInfo.creation_date_time ?? row.creation_date_time) || null, // 15: creation_date_time\n salesInfo.length, // 16: sales_info_count\n itemsInfo.length, // 17: items_info_count\n ];\n}\n\n// \u2500\u2500 Secondary compact schemas for sales_info / items_info multiplicity \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Secondary compact block for sales_info entries.\n * Each row references `detail_id` so consumers can reconstruct the relationship.\n * Populated even when sales_info_count === 1 so the contract is stable.\n */\nexport const detailsSalesSchema = [\n \"detail_id\",\n \"order_id\",\n \"operation_id\",\n \"sale_date_time\",\n \"payer_nickname\",\n \"transaction_amount\",\n] as const;\n\ntype SalesRow = (string | number | null)[];\n\nfunction projectSalesRow(detailId: string | null, sale: Record<string, unknown>): SalesRow {\n return [\n detailId, // 0: detail_id\n normalizeString(sale.order_id) || null, // 1: order_id\n normalizeString(sale.operation_id) || null, // 2: operation_id\n normalizeString(sale.sale_date_time) || null, // 3: sale_date_time\n normalizeString(sale.payer_nickname) || null, // 4: payer_nickname\n toNumber(sale.transaction_amount), // 5: transaction_amount\n ];\n}\n\n/**\n * Secondary compact block for items_info entries.\n * Each row references `detail_id` so consumers can reconstruct the relationship.\n */\nexport const detailsItemsSchema = [\n \"detail_id\",\n \"item_id\",\n \"item_title\",\n \"item_amount\",\n \"item_price\",\n \"order_id\",\n] as const;\n\ntype ItemsRow = (string | number | null)[];\n\nfunction projectItemsRow(detailId: string | null, item: Record<string, unknown>): ItemsRow {\n return [\n detailId, // 0: detail_id\n normalizeString(item.item_id) || null, // 1: item_id\n normalizeString(item.item_title) || null, // 2: item_title\n toNumber(item.item_amount), // 3: item_amount\n toNumber(item.item_price), // 4: item_price\n normalizeString(item.order_id) || null, // 5: order_id\n ];\n}\n\n// \u2500\u2500 Aggregation helpers (internal \u2014 compute summary + diagnostics) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ninterface CurrencyBucket {\n charge_amount_total: number;\n bonus_amount_total: number;\n discount_amount_total: number;\n net_effect_total: number;\n}\n\nfunction emptyCurrencyBucket(): CurrencyBucket {\n return {\n charge_amount_total: 0,\n bonus_amount_total: 0,\n discount_amount_total: 0,\n net_effect_total: 0,\n };\n}\n\n/**\n * Determine if a billing detail is a charge, bonus, or discount based on\n * detail_sub_type prefix and text heuristics (same logic as before, internal only).\n */\nfunction classifyChargeType(row: Record<string, unknown>): \"charge\" | \"bonus\" | \"discount\" {\n const chargeInfo = (row.charge_info as Record<string, unknown>) ?? {};\n const detailSubType = normalizeString(chargeInfo.detail_sub_type, \"\").trim().toUpperCase();\n const transactionDetail = normalizeString(chargeInfo.transaction_detail, \"\").toLowerCase().trim();\n const conceptType = normalizeString(chargeInfo.concept_type, \"\").toLowerCase().trim();\n\n // B* codes are bonuses/annulments\n if (detailSubType.startsWith(\"B\") ||\n detailSubType.toLowerCase().includes(\"bonus\") ||\n detailSubType.toLowerCase().includes(\"bonificacion\") ||\n detailSubType.toLowerCase().includes(\"bonificaci\u00F3n\") ||\n transactionDetail.includes(\"anulaci\u00F3n\") ||\n transactionDetail.includes(\"anulacion\") ||\n transactionDetail.includes(\"bonus\") ||\n transactionDetail.includes(\"bonificaci\u00F3n\") ||\n conceptType.includes(\"bonus\") ||\n conceptType.includes(\"bonificaci\u00F3n\")) {\n return \"bonus\";\n }\n\n // D* codes are discounts\n if (detailSubType.startsWith(\"D\") ||\n detailSubType.toLowerCase().includes(\"discount\") ||\n detailSubType.toLowerCase().includes(\"descuento\") ||\n detailSubType.toLowerCase().includes(\"adjustment\") ||\n transactionDetail.includes(\"descuento\") ||\n transactionDetail.includes(\"discount\") ||\n transactionDetail.includes(\"ajuste\") ||\n conceptType.includes(\"discount\") ||\n conceptType.includes(\"descuento\")) {\n return \"discount\";\n }\n\n return \"charge\";\n}\n\ninterface AggregatedResult {\n compactRows: DetailRow[];\n currencyTotals: Record<string, CurrencyBucket>;\n detailCount: number;\n orderCountDetected: number;\n itemCountDetected: number;\n detailSubTypesObserved: Set<string>;\n marketplacesObserved: Set<string>;\n conceptTypesObserved: Set<string>;\n}\n\nfunction aggregateRows(rows: Record<string, unknown>[]): AggregatedResult {\n const currencyTotals: Record<string, CurrencyBucket> = {};\n const orderIds = new Set<string>();\n const itemIds = new Set<string>();\n const compactRows: DetailRow[] = [];\n const detailSubTypesObserved = new Set<string>();\n const marketplacesObserved = new Set<string>();\n const conceptTypesObserved = new Set<string>();\n\n for (const row of rows) {\n // Project compact row\n compactRows.push(projectCompactRow(row));\n\n // Real MELI payout: currency lives under currency_info.currency_id\n const currencyInfo = row.currency_info as Record<string, unknown> | undefined;\n const currency = normalizeString(\n currencyInfo?.currency_id ?? row.currency_id ?? row.currency,\n \"UNKNOWN\"\n ).toUpperCase();\n const bucket = currencyTotals[currency] ?? emptyCurrencyBucket();\n currencyTotals[currency] = bucket;\n\n const chargeInfo = (row.charge_info as Record<string, unknown>) ?? {};\n const amount = toNumber(chargeInfo.detail_amount ?? chargeInfo.amount ?? 0);\n const chargeType = classifyChargeType(row);\n\n if (chargeType === \"bonus\") {\n bucket.bonus_amount_total += amount;\n } else if (chargeType === \"discount\") {\n bucket.discount_amount_total += amount;\n } else {\n bucket.charge_amount_total += amount;\n }\n\n // \u2500\u2500 Diagnostics accumulation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const detailSubType = normalizeString(chargeInfo.detail_sub_type, \"\").trim();\n if (detailSubType) detailSubTypesObserved.add(detailSubType);\n\n const marketplaceInfo = row.marketplace_info as Record<string, unknown> | undefined;\n const marketplace = normalizeString(marketplaceInfo?.marketplace, \"\").trim();\n if (marketplace) marketplacesObserved.add(marketplace);\n\n const conceptType = normalizeString(chargeInfo.concept_type, \"\").trim();\n if (conceptType) conceptTypesObserved.add(conceptType);\n\n // Detect order IDs from sales_info\n const salesInfo = asArray<Record<string, unknown>>(row.sales_info);\n for (const si of salesInfo) {\n const oid = normalizeString(si.order_id);\n if (oid) orderIds.add(oid);\n }\n\n // Detect item IDs from items_info\n const itemsInfo = asArray<Record<string, unknown>>(row.items_info);\n for (const ii of itemsInfo) {\n const iid = normalizeString(ii.item_id);\n if (iid) itemIds.add(iid);\n }\n }\n\n // net_effect = charge + bonus + discount (algebraic sum of signed amounts)\n for (const bucket of Object.values(currencyTotals)) {\n bucket.net_effect_total = bucket.charge_amount_total + bucket.bonus_amount_total + bucket.discount_amount_total;\n }\n\n // Round all money values\n for (const bucket of Object.values(currencyTotals)) {\n bucket.charge_amount_total = roundMoney(bucket.charge_amount_total);\n bucket.bonus_amount_total = roundMoney(bucket.bonus_amount_total);\n bucket.discount_amount_total = roundMoney(bucket.discount_amount_total);\n bucket.net_effect_total = roundMoney(bucket.net_effect_total);\n }\n\n return {\n compactRows,\n currencyTotals,\n detailCount: rows.length,\n orderCountDetected: orderIds.size,\n itemCountDetected: itemIds.size,\n detailSubTypesObserved,\n marketplacesObserved,\n conceptTypesObserved,\n };\n}\n\n// \u2500\u2500 Scope resolution for \"all\" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst ALL_SCOPES: BillingProvisionScope[] = [\"ml\", \"mp\", \"flex\", \"full\"];\n\ninterface FetchParams {\n periodKey: string;\n documentType: \"BILL\" | \"CREDIT_NOTE\";\n detailType?: string;\n detailSubTypes?: string[];\n excludeDetailSubTypes?: string[];\n marketplaceType?: string;\n orderIds?: string[];\n itemIds?: string[];\n}\n\nasync function fetchScope(\n profileId: string,\n scope: BillingProvisionScope,\n params: FetchParams,\n fromId?: string | null\n): Promise<BillingProvisionFetchResult> {\n return getMercadoLibreBillingProvisions(profileId, { scope, ...params, fromId });\n}\n\n// \u2500\u2500 Handler \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport async function meliGetBillingProvisionsSummaryHandler(\n params: z.infer<typeof meliGetBillingProvisionsSummarySchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const documentType = params.documentType ?? \"BILL\";\n\n const fetchParams: FetchParams = {\n periodKey: params.periodKey,\n documentType,\n detailType: params.detailType,\n detailSubTypes: params.detailSubTypes,\n excludeDetailSubTypes: params.excludeDetailSubTypes,\n marketplaceType: params.marketplaceType,\n orderIds: params.orderIds,\n itemIds: params.itemIds,\n };\n\n // Determine scopes to fetch\n const scopes: BillingProvisionScope[] =\n params.scope === \"all\" ? ALL_SCOPES : [params.scope];\n\n const fromIdByScope = params.fromIdByScope ?? {};\n\n // Fetch all scopes in parallel\n const scopeResults = await Promise.all(\n scopes.map((scope) => fetchScope(profileId, scope, fetchParams, fromIdByScope[scope] ?? null))\n );\n\n // Aggregate across scopes\n let totalRows = 0;\n const globalOrderIds = new Set<string>();\n const globalItemIds = new Set<string>();\n const globalCompactRows: DetailRow[] = [];\n const globalCurrencyTotals: Record<string, CurrencyBucket> = {};\n const globalDetailSubTypes = new Set<string>();\n const globalMarketplaces = new Set<string>();\n const globalConceptTypes = new Set<string>();\n const globalSalesRows: SalesRow[] = [];\n const globalItemsRows: ItemsRow[] = [];\n\n const coverageByScope: Record<string, unknown> = {};\n const continuationByScope: Record<string, unknown> = {};\n let totalSourcesCalled = 0;\n let totalPagesRequested = 0;\n let totalPagesSucceeded = 0;\n let totalPagesFailed = 0;\n let globalCoverageComplete = true;\n let allFailures: Array<{ scope: string; page: number; from_id: string | null; message: string }> = [];\n\n for (const result of scopeResults) {\n const agg = aggregateRows(result.rows);\n\n // Merge currency totals across scopes\n for (const [currency, bucket] of Object.entries(agg.currencyTotals)) {\n const global = globalCurrencyTotals[currency] ?? emptyCurrencyBucket();\n globalCurrencyTotals[currency] = global;\n global.charge_amount_total = roundMoney(global.charge_amount_total + bucket.charge_amount_total);\n global.bonus_amount_total = roundMoney(global.bonus_amount_total + bucket.bonus_amount_total);\n global.discount_amount_total = roundMoney(global.discount_amount_total + bucket.discount_amount_total);\n global.net_effect_total = roundMoney(global.net_effect_total + bucket.net_effect_total);\n }\n\n globalCompactRows.push(...agg.compactRows);\n totalRows += agg.detailCount;\n\n // Global unique order/item counts + secondary multiplicity rows\n for (const row of result.rows) {\n const chargeInfo = (row.charge_info as Record<string, unknown>) ?? {};\n const detailId = normalizeString(chargeInfo.detail_id) || null;\n\n const salesInfo = asArray<Record<string, unknown>>(row.sales_info);\n for (const si of salesInfo) {\n const oid = normalizeString(si.order_id);\n if (oid) globalOrderIds.add(oid);\n globalSalesRows.push(projectSalesRow(detailId, si));\n }\n const itemsInfo = asArray<Record<string, unknown>>(row.items_info);\n for (const ii of itemsInfo) {\n const iid = normalizeString(ii.item_id);\n if (iid) globalItemIds.add(iid);\n globalItemsRows.push(projectItemsRow(detailId, ii));\n }\n }\n\n // Merge diagnostics\n for (const s of agg.detailSubTypesObserved) globalDetailSubTypes.add(s);\n for (const m of agg.marketplacesObserved) globalMarketplaces.add(m);\n for (const c of agg.conceptTypesObserved) globalConceptTypes.add(c);\n\n // Per-scope coverage metadata\n coverageByScope[result.scope] = {\n coverage_complete: result.coverage_complete,\n last_id_seen: result.last_id_seen,\n pages_requested: result.pages_requested,\n pages_succeeded: result.pages_succeeded,\n pages_failed: result.pages_failed,\n detail_count: agg.detailCount,\n };\n\n if (!result.coverage_complete && result.last_id_seen) {\n continuationByScope[result.scope] = {\n last_id: result.last_id_seen,\n hint:\n `Resume ${result.scope} scope with fromIdByScope: ` +\n `{ \"${result.scope}\": \"${result.last_id_seen}\" }. ` +\n `${result.pages_failed} page(s) failed.`,\n };\n }\n\n // Metadata accumulation\n totalSourcesCalled += 1;\n totalPagesRequested += result.pages_requested;\n totalPagesSucceeded += result.pages_succeeded;\n totalPagesFailed += result.pages_failed;\n if (!result.coverage_complete) globalCoverageComplete = false;\n\n for (const f of result.failures) {\n allFailures.push({ scope: result.scope, ...f });\n }\n }\n\n // Build metadata block\n const metadata: Record<string, unknown> = {\n sources_called: totalSourcesCalled,\n pages_requested: totalPagesRequested,\n pages_succeeded: totalPagesSucceeded,\n pages_failed: totalPagesFailed,\n detail_count_total: totalRows,\n coverage_complete: globalCoverageComplete,\n coverage_by_scope: coverageByScope,\n };\n\n if (Object.keys(continuationByScope).length > 0) {\n metadata.continuation_by_scope = continuationByScope;\n }\n if (allFailures.length > 0) {\n metadata.failures = allFailures;\n }\n\n // Build diagnostics (simplified \u2014 observations only)\n const diagnostics = {\n detail_sub_types_observed: [...globalDetailSubTypes].sort(),\n marketplaces_observed: [...globalMarketplaces].sort(),\n concept_types_observed: [...globalConceptTypes].sort(),\n };\n\n // Build response in two phases: stripNulls for objects, then add back\n // compact arrays and diagnostics intact (nulls/diagnostics are positional/always-visible).\n const stripped = stripNulls({\n profile_id: profileId,\n period_key: params.periodKey,\n scope: params.scope,\n document_type: documentType,\n metadata,\n summary: {\n detail_count: totalRows,\n order_count_detected: globalOrderIds.size,\n item_count_detected: globalItemIds.size,\n currency_totals: globalCurrencyTotals,\n },\n }) as Record<string, unknown>;\n\n // Always include details, details_schema, diagnostics, and secondary blocks.\n // stripNulls would remove nulls from compact rows (breaking positional contract),\n // empty diagnostic arrays, empty currency_totals, and empty secondary blocks\n // (which must remain visible).\n stripped.details_schema = detailsSchema;\n stripped.details = globalCompactRows;\n stripped.diagnostics = diagnostics;\n\n // \u2500\u2500 Secondary multiplicity blocks (always present for contract stability) \u2500\u2500\n stripped.details_sales_schema = detailsSalesSchema;\n stripped.details_sales = globalSalesRows;\n stripped.details_items_schema = detailsItemsSchema;\n stripped.details_items = globalItemsRows;\n\n // \u2500\u2500 Guarantee currency_totals survives stripNulls (empty {} gets stripped) \u2500\u2500\n const summary = stripped.summary as Record<string, unknown>;\n summary.currency_totals = globalCurrencyTotals;\n\n return object(stripped);\n } catch (err) {\n return error(\n formatMercadoLibreError(err, \"Failed to get MercadoLibre billing provisions summary\")\n );\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB;AAAA,EAGE;AAAA,OACK;AACP;AAAA,EACE;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB,YAAY,UAAU,eAAe;AAC/D,SAAS,6CAA6C;AACtD,SAAS,wCAAwC;AAI1C,MAAM,wCAAwC,EAAE,OAAO;AAAA,EAC5D,WAAW;AAAA,EACX,WAAW,EACR,OAAO,EACP,MAAM,kBAAkB,EACxB,SAAS,6DAA6D;AAAA,EACzE,OAAO,EAAE,KAAK,CAAC,MAAM,MAAM,QAAQ,QAAQ,KAAK,CAAC,EAAE;AAAA,IACjD;AAAA,EACF;AAAA,EACA,cAAc,EACX,KAAK,CAAC,QAAQ,aAAa,CAAC,EAC5B,QAAQ,MAAM,EACd,SAAS,EACT,SAAS,uDAAuD;AAAA,EACnE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,8BAA8B;AAAA,EACvF,gBAAgB,EACb,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,EAC9B,SAAS,EACT,SAAS,mCAAmC;AAAA,EAC/C,uBAAuB,EACpB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,EAC9B,SAAS,EACT,SAAS,uCAAuC;AAAA,EACnD,iBAAiB,EACd,OAAO,EACP,KAAK,E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;AACzB,YAAQ,kBAAkB;AAE1B,WAAO,OAAO,QAAQ;AAAA,EACxB,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,wBAAwB,KAAK,uDAAuD;AAAA,IACtF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -3,7 +3,14 @@ import { z } from "zod";
3
3
  import { formatMercadoLibreError } from "../../services/mercadolibre/mercadolibre-api.js";
4
4
  import { getMercadoLibreOrder, getMercadoLibreOrderDetailsBatch } from "../../services/mercadolibre/mercadolibre-orders.js";
5
5
  import { stripNulls } from "../../utils/strip-payload.js";
6
- import { asArray, asRecord, compactDateTime, normalizeString, toNumber } from "./helpers.js";
6
+ import {
7
+ asArray,
8
+ asRecord,
9
+ compactDateTime,
10
+ normalizeScalarString,
11
+ normalizeString,
12
+ toNumber
13
+ } from "./helpers.js";
7
14
  import { resolveMercadoLibreProfileOrSelection } from "./profile-resolution.js";
8
15
  import { mercadolibreProfileIdSchemaField } from "./write-helpers.js";
9
16
  const MAX_ORDER_IDS = 50;
@@ -12,6 +19,7 @@ const meliGetOrderDetailsSchema = z.object({
12
19
  orderIds: z.array(z.string().trim().min(1).describe("MercadoLibre order id.")).min(1).max(MAX_ORDER_IDS).describe("One or more MercadoLibre order ids (up to 50).")
13
20
  });
14
21
  function formatOrder(order) {
22
+ const optionalMoney = (value) => value == null || value === "" ? void 0 : toNumber(value);
15
23
  return stripNulls({
16
24
  order_id: normalizeString(order.id),
17
25
  status: normalizeString(order.status),
@@ -22,7 +30,7 @@ function formatOrder(order) {
22
30
  total_amount: toNumber(order.total_amount),
23
31
  paid_amount: toNumber(order.paid_amount),
24
32
  shipping: stripNulls({
25
- id: normalizeString(asRecord(order.shipping).id),
33
+ id: normalizeScalarString(asRecord(order.shipping).id),
26
34
  status: normalizeString(asRecord(order.shipping).status),
27
35
  substatus: normalizeString(asRecord(order.shipping).substatus),
28
36
  mode: normalizeString(asRecord(order.shipping).mode),
@@ -49,11 +57,17 @@ function formatOrder(order) {
49
57
  }),
50
58
  payments: asArray(order.payments).map(
51
59
  (payment) => stripNulls({
52
- id: normalizeString(payment.id),
60
+ id: normalizeScalarString(payment.id),
53
61
  status: normalizeString(payment.status),
62
+ status_detail: normalizeString(payment.status_detail) || void 0,
63
+ payment_method_id: normalizeString(payment.payment_method_id) || void 0,
54
64
  payment_type: normalizeString(payment.payment_type),
55
65
  installments: toNumber(payment.installments),
56
- total_paid_amount: toNumber(payment.total_paid_amount)
66
+ total_paid_amount: toNumber(payment.total_paid_amount),
67
+ transaction_amount: optionalMoney(payment.transaction_amount),
68
+ transaction_amount_refunded: optionalMoney(payment.transaction_amount_refunded),
69
+ shipping_cost: optionalMoney(payment.shipping_cost),
70
+ coupon_amount: optionalMoney(payment.coupon_amount)
57
71
  })
58
72
  ),
59
73
  tags: Array.isArray(order.tags) ? order.tags : void 0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/tools/mercadolibre/get-order-details.ts"],
4
- "sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatMercadoLibreError } from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport { getMercadoLibreOrder, getMercadoLibreOrderDetailsBatch } from \"../../services/mercadolibre/mercadolibre-orders.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { asArray, asRecord, compactDateTime, normalizeString, toNumber } from \"./helpers.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\n\nconst MAX_ORDER_IDS = 50;\n\nexport const meliGetOrderDetailsSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n orderIds: z\n .array(z.string().trim().min(1).describe(\"MercadoLibre order id.\"))\n .min(1)\n .max(MAX_ORDER_IDS)\n .describe(\"One or more MercadoLibre order ids (up to 50).\"),\n});\n\nfunction formatOrder(order: Record<string, unknown>) {\n return stripNulls({\n order_id: normalizeString(order.id),\n status: normalizeString(order.status),\n status_detail: normalizeString(order.status_detail),\n date_created: compactDateTime(order.date_created),\n date_closed: compactDateTime(order.date_closed),\n currency_id: normalizeString(order.currency_id, \"UNKNOWN\"),\n total_amount: toNumber(order.total_amount),\n paid_amount: toNumber(order.paid_amount),\n shipping: stripNulls({\n id: normalizeString(asRecord(order.shipping).id),\n status: normalizeString(asRecord(order.shipping).status),\n substatus: normalizeString(asRecord(order.shipping).substatus),\n mode: normalizeString(asRecord(order.shipping).mode),\n logistic_type: normalizeString(asRecord(order.shipping).logistic_type),\n }),\n buyer: stripNulls({\n id: normalizeString(asRecord(order.buyer).id),\n nickname: normalizeString(asRecord(order.buyer).nickname),\n }),\n seller: stripNulls({\n id: normalizeString(asRecord(order.seller).id),\n nickname: normalizeString(asRecord(order.seller).nickname),\n }),\n items: asArray<Record<string, unknown>>(order.order_items).map((entry) => {\n const item = asRecord(entry.item);\n return stripNulls({\n item_id: normalizeString(item.id),\n title: normalizeString(item.title),\n variation_id: normalizeString(item.variation_id),\n quantity: toNumber(entry.quantity),\n unit_price: toNumber(entry.unit_price),\n full_unit_price: toNumber(entry.full_unit_price),\n });\n }),\n payments: asArray<Record<string, unknown>>(order.payments).map((payment) =>\n stripNulls({\n id: normalizeString(payment.id),\n status: normalizeString(payment.status),\n payment_type: normalizeString(payment.payment_type),\n installments: toNumber(payment.installments),\n total_paid_amount: toNumber(payment.total_paid_amount),\n })\n ),\n tags: Array.isArray(order.tags) ? order.tags : undefined,\n });\n}\n\nexport async function meliGetOrderDetailsHandler(\n params: z.infer<typeof meliGetOrderDetailsSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const uniqueOrderIds = Array.from(new Set(params.orderIds));\n\n if (uniqueOrderIds.length === 1) {\n const order = await getMercadoLibreOrder(profileId, uniqueOrderIds[0]);\n return object(\n stripNulls({\n metadata: {\n profile_id: profileId,\n requested: 1,\n successful: 1,\n failed: 0,\n },\n orders: [formatOrder(order)],\n })\n );\n }\n\n const batch = await getMercadoLibreOrderDetailsBatch(profileId, uniqueOrderIds, {\n maxConcurrency: 10,\n maxRetries: 2,\n });\n\n return object(\n stripNulls({\n metadata: {\n profile_id: profileId,\n requested: uniqueOrderIds.length,\n successful: batch.successful.length,\n failed: batch.failed.length,\n has_failures: batch.failed.length > 0,\n },\n orders: batch.successful.map((entry) => formatOrder(entry.document)),\n failures: batch.failed.map((failure) => ({\n order_id: failure.id,\n message: failure.message,\n status_code: failure.statusCode,\n attempts: failure.attempts,\n retryable: failure.retryable,\n })),\n })\n );\n } catch (err) {\n return error(formatMercadoLibreError(err, \"Failed to fetch MercadoLibre order details\"));\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,+BAA+B;AACxC,SAAS,sBAAsB,wCAAwC;AACvE,SAAS,kBAAkB;AAC3B,SAAS,SAAS,UAAU,iBAAiB,iBAAiB,gBAAgB;AAC9E,SAAS,6CAA6C;AACtD,SAAS,wCAAwC;AAEjD,MAAM,gBAAgB;AAEf,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,WAAW;AAAA,EACX,UAAU,EACP,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,wBAAwB,CAAC,EACjE,IAAI,CAAC,EACL,IAAI,aAAa,EACjB,SAAS,gDAAgD;AAC9D,CAAC;AAED,SAAS,YAAY,OAAgC;AACnD,SAAO,WAAW;AAAA,IAChB,UAAU,gBAAgB,MAAM,EAAE;AAAA,IAClC,QAAQ,gBAAgB,MAAM,MAAM;AAAA,IACpC,eAAe,gBAAgB,MAAM,aAAa;AAAA,IAClD,cAAc,gBAAgB,MAAM,YAAY;AAAA,IAChD,aAAa,gBAAgB,MAAM,WAAW;AAAA,IAC9C,aAAa,gBAAgB,MAAM,aAAa,SAAS;AAAA,IACzD,cAAc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;AAAA,UAClB,SAAS,QAAQ;AAAA,UACjB,aAAa,QAAQ;AAAA,UACrB,UAAU,QAAQ;AAAA,UAClB,WAAW,QAAQ;AAAA,QACrB,EAAE;AAAA,MACJ,CAAC;AAAA,IACH;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,MAAM,wBAAwB,KAAK,4CAA4C,CAAC;AAAA,EACzF;AACF;",
4
+ "sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatMercadoLibreError } from \"../../services/mercadolibre/mercadolibre-api.js\";\nimport { getMercadoLibreOrder, getMercadoLibreOrderDetailsBatch } from \"../../services/mercadolibre/mercadolibre-orders.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport {\n asArray,\n asRecord,\n compactDateTime,\n normalizeScalarString,\n normalizeString,\n toNumber,\n} from \"./helpers.js\";\nimport { resolveMercadoLibreProfileOrSelection } from \"./profile-resolution.js\";\nimport { mercadolibreProfileIdSchemaField } from \"./write-helpers.js\";\n\nconst MAX_ORDER_IDS = 50;\n\nexport const meliGetOrderDetailsSchema = z.object({\n profileId: mercadolibreProfileIdSchemaField,\n orderIds: z\n .array(z.string().trim().min(1).describe(\"MercadoLibre order id.\"))\n .min(1)\n .max(MAX_ORDER_IDS)\n .describe(\"One or more MercadoLibre order ids (up to 50).\"),\n});\n\nfunction formatOrder(order: Record<string, unknown>) {\n const optionalMoney = (value: unknown) => (value == null || value === \"\" ? undefined : toNumber(value));\n\n return stripNulls({\n order_id: normalizeString(order.id),\n status: normalizeString(order.status),\n status_detail: normalizeString(order.status_detail),\n date_created: compactDateTime(order.date_created),\n date_closed: compactDateTime(order.date_closed),\n currency_id: normalizeString(order.currency_id, \"UNKNOWN\"),\n total_amount: toNumber(order.total_amount),\n paid_amount: toNumber(order.paid_amount),\n shipping: stripNulls({\n id: normalizeScalarString(asRecord(order.shipping).id),\n status: normalizeString(asRecord(order.shipping).status),\n substatus: normalizeString(asRecord(order.shipping).substatus),\n mode: normalizeString(asRecord(order.shipping).mode),\n logistic_type: normalizeString(asRecord(order.shipping).logistic_type),\n }),\n buyer: stripNulls({\n id: normalizeString(asRecord(order.buyer).id),\n nickname: normalizeString(asRecord(order.buyer).nickname),\n }),\n seller: stripNulls({\n id: normalizeString(asRecord(order.seller).id),\n nickname: normalizeString(asRecord(order.seller).nickname),\n }),\n items: asArray<Record<string, unknown>>(order.order_items).map((entry) => {\n const item = asRecord(entry.item);\n return stripNulls({\n item_id: normalizeString(item.id),\n title: normalizeString(item.title),\n variation_id: normalizeString(item.variation_id),\n quantity: toNumber(entry.quantity),\n unit_price: toNumber(entry.unit_price),\n full_unit_price: toNumber(entry.full_unit_price),\n });\n }),\n payments: asArray<Record<string, unknown>>(order.payments).map((payment) =>\n stripNulls({\n id: normalizeScalarString(payment.id),\n status: normalizeString(payment.status),\n status_detail: normalizeString(payment.status_detail) || undefined,\n payment_method_id: normalizeString(payment.payment_method_id) || undefined,\n payment_type: normalizeString(payment.payment_type),\n installments: toNumber(payment.installments),\n total_paid_amount: toNumber(payment.total_paid_amount),\n transaction_amount: optionalMoney(payment.transaction_amount),\n transaction_amount_refunded: optionalMoney(payment.transaction_amount_refunded),\n shipping_cost: optionalMoney(payment.shipping_cost),\n coupon_amount: optionalMoney(payment.coupon_amount),\n })\n ),\n tags: Array.isArray(order.tags) ? order.tags : undefined,\n });\n}\n\nexport async function meliGetOrderDetailsHandler(\n params: z.infer<typeof meliGetOrderDetailsSchema>\n) {\n try {\n const profileResolution = await resolveMercadoLibreProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const uniqueOrderIds = Array.from(new Set(params.orderIds));\n\n if (uniqueOrderIds.length === 1) {\n const order = await getMercadoLibreOrder(profileId, uniqueOrderIds[0]);\n return object(\n stripNulls({\n metadata: {\n profile_id: profileId,\n requested: 1,\n successful: 1,\n failed: 0,\n },\n orders: [formatOrder(order)],\n })\n );\n }\n\n const batch = await getMercadoLibreOrderDetailsBatch(profileId, uniqueOrderIds, {\n maxConcurrency: 10,\n maxRetries: 2,\n });\n\n return object(\n stripNulls({\n metadata: {\n profile_id: profileId,\n requested: uniqueOrderIds.length,\n successful: batch.successful.length,\n failed: batch.failed.length,\n has_failures: batch.failed.length > 0,\n },\n orders: batch.successful.map((entry) => formatOrder(entry.document)),\n failures: batch.failed.map((failure) => ({\n order_id: failure.id,\n message: failure.message,\n status_code: failure.statusCode,\n attempts: failure.attempts,\n retryable: failure.retryable,\n })),\n })\n );\n } catch (err) {\n return error(formatMercadoLibreError(err, \"Failed to fetch MercadoLibre order details\"));\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,+BAA+B;AACxC,SAAS,sBAAsB,wCAAwC;AACvE,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6CAA6C;AACtD,SAAS,wCAAwC;AAEjD,MAAM,gBAAgB;AAEf,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,WAAW;AAAA,EACX,UAAU,EACP,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,wBAAwB,CAAC,EACjE,IAAI,CAAC,EACL,IAAI,aAAa,EACjB,SAAS,gDAAgD;AAC9D,CAAC;AAED,SAAS,YAAY,OAAgC;AACnD,QAAM,gBAAgB,CAAC,UAAoB,SAAS,QAAQ,UAAU,KAAK,SAAY,SAAS,KAAK;AAErG,SAAO,WAAW;AAAA,IAChB,UAAU,gBAAgB,MAAM,EAAE;AAAA,IAClC,QAAQ,gBAAgB,MAAM,MAAM;AAAA,IACpC,eAAe,gBAAgB,MAAM,aAAa;AAAA,IAClD,cAAc,gBAAgB,MAAM,YAAY;AAAA,IAChD,aAAa,gBAAgB,MAAM,WAAW;AAAA,IAC9C,aAAa,gBAAgB,MA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