@yoryoboy/bi-mcp 1.5.2 → 1.6.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.
- package/README.md +87 -87
- package/bin/bi-mcp.js +9 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-use.json +2 -2
- package/dist/public/icon.svg +6 -6
- package/dist/scripts/_helpers.js.map +1 -1
- package/dist/scripts/admin-profile-delete.js.map +1 -1
- package/dist/scripts/admin-profile-list.js.map +1 -1
- package/dist/scripts/admin-profile-upsert.js.map +1 -1
- package/dist/scripts/admin-vtex-list.js.map +1 -1
- package/dist/scripts/admin-vtex-upsert.js.map +1 -1
- package/dist/scripts/admin-vtex-validate.js.map +1 -1
- package/dist/scripts/decrypt-secret.js +36 -0
- package/dist/scripts/decrypt-secret.js.map +7 -0
- package/dist/scripts/run-migrations.js.map +1 -1
- package/dist/scripts/test-db-connection.js.map +1 -1
- package/dist/src/analytics/ga4-channel-groups.js.map +1 -1
- package/dist/src/analytics/ga4-report-utils.js.map +1 -1
- package/dist/src/config/benchmarks.js.map +1 -1
- package/dist/src/config/google-store.js.map +1 -1
- package/dist/src/config/google.js.map +1 -1
- package/dist/src/config/mercadolibre-profile-store.js.map +1 -1
- package/dist/src/config/mercadolibre.js.map +1 -1
- package/dist/src/config/meta.js.map +1 -1
- package/dist/src/config/profile-store.js.map +1 -1
- package/dist/src/config/vtex-crypto.js.map +1 -1
- package/dist/src/config/vtex-profile-store.js.map +1 -1
- package/dist/src/config/vtex.js.map +1 -1
- package/dist/src/db/client.js.map +1 -1
- package/dist/src/meta/meta-utils.js.map +1 -1
- package/dist/src/prompts/reporte-ventas.js.map +1 -1
- package/dist/src/services/analytics/ga4-client.js.map +1 -1
- package/dist/src/services/analytics/oauth.js.map +1 -1
- package/dist/src/services/google-ads/google-ads-client.js.map +1 -1
- package/dist/src/services/mercadolibre/mercadolibre-api.js.map +1 -1
- package/dist/src/services/mercadolibre/mercadolibre-items.js.map +1 -1
- package/dist/src/services/mercadolibre/mercadolibre-orders.js +19 -5
- package/dist/src/services/mercadolibre/mercadolibre-orders.js.map +2 -2
- package/dist/src/services/mercadolibre/mercadolibre-questions.js.map +1 -1
- package/dist/src/services/meta/meta-ads.js.map +1 -1
- package/dist/src/services/meta/meta-api.js.map +1 -1
- package/dist/src/services/search-console/search-console-client.js.map +1 -1
- package/dist/src/services/search-console/search-console-utils.js.map +1 -1
- package/dist/src/services/vtex/vtex-api.js.map +1 -1
- package/dist/src/services/vtex/vtex-catalog-write.js.map +1 -1
- package/dist/src/services/vtex/vtex-catalog.js.map +1 -1
- package/dist/src/services/vtex/vtex-logistics.js.map +1 -1
- package/dist/src/services/vtex/vtex-orders-write.js.map +1 -1
- package/dist/src/services/vtex/vtex-orders.js.map +1 -1
- package/dist/src/services/vtex/vtex-pricing-write.js.map +1 -1
- package/dist/src/services/vtex/vtex-pricing.js.map +1 -1
- package/dist/src/services/vtex/vtex-write.js.map +1 -1
- package/dist/src/tools/analytics/attribution-gaps.js.map +1 -1
- package/dist/src/tools/analytics/channel-mix.js.map +1 -1
- package/dist/src/tools/analytics/ecommerce-tracking-health.js.map +1 -1
- package/dist/src/tools/analytics/engagement-overview.js.map +1 -1
- package/dist/src/tools/analytics/index.js.map +1 -1
- package/dist/src/tools/analytics/list-accessible-properties.js.map +1 -1
- package/dist/src/tools/analytics/property-info.js.map +1 -1
- package/dist/src/tools/analytics/revenue-by-channel.js.map +1 -1
- package/dist/src/tools/analytics/revenue-overview.js.map +1 -1
- package/dist/src/tools/analytics/revenue-trend.js.map +1 -1
- package/dist/src/tools/analytics/source-medium-breakdown.js.map +1 -1
- package/dist/src/tools/analytics/top-landing-pages.js.map +1 -1
- package/dist/src/tools/config/check-database-connection.js.map +1 -1
- package/dist/src/tools/config/index.js.map +1 -1
- package/dist/src/tools/config/list-profiles.js.map +1 -1
- package/dist/src/tools/google-ads/account-overview.js.map +1 -1
- package/dist/src/tools/google-ads/account-risks.js.map +1 -1
- package/dist/src/tools/google-ads/break-even-analysis.js.map +1 -1
- package/dist/src/tools/google-ads/campaign-performance.js.map +1 -1
- package/dist/src/tools/google-ads/channel-mix.js.map +1 -1
- package/dist/src/tools/google-ads/compare-accounts.js.map +1 -1
- package/dist/src/tools/google-ads/customer-clients.js.map +1 -1
- package/dist/src/tools/google-ads/customer-info.js.map +1 -1
- package/dist/src/tools/google-ads/index.js.map +1 -1
- package/dist/src/tools/google-ads/scaling-health.js.map +1 -1
- package/dist/src/tools/google-ads/search-terms-summary.js.map +1 -1
- package/dist/src/tools/google-ads/time-series.js.map +1 -1
- package/dist/src/tools/index.js.map +1 -1
- package/dist/src/tools/mercadolibre/answer-question.js.map +1 -1
- package/dist/src/tools/mercadolibre/create-item.js.map +1 -1
- package/dist/src/tools/mercadolibre/estimate-listing-fee.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-account-context.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-category-requirements.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-item-details.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-item-visits.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-listing-quality.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-order-details.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-orders-summary.js +670 -38
- package/dist/src/tools/mercadolibre/get-orders-summary.js.map +2 -2
- package/dist/src/tools/mercadolibre/get-sales-by-item.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-sales-trend.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-shipping-summary.js.map +1 -1
- package/dist/src/tools/mercadolibre/get-store-performance.js.map +1 -1
- package/dist/src/tools/mercadolibre/helpers.js +13 -0
- package/dist/src/tools/mercadolibre/helpers.js.map +2 -2
- package/dist/src/tools/mercadolibre/index.js.map +1 -1
- package/dist/src/tools/mercadolibre/pause-or-reactivate-item.js.map +1 -1
- package/dist/src/tools/mercadolibre/predict-category.js.map +1 -1
- package/dist/src/tools/mercadolibre/profile-resolution.js.map +1 -1
- package/dist/src/tools/mercadolibre/search-items.js.map +1 -1
- package/dist/src/tools/mercadolibre/search-questions.js.map +1 -1
- package/dist/src/tools/mercadolibre/update-item-basic-fields.js.map +1 -1
- package/dist/src/tools/mercadolibre/update-item-description.js.map +1 -1
- package/dist/src/tools/mercadolibre/update-item-pictures.js.map +1 -1
- package/dist/src/tools/mercadolibre/validate-connection.js.map +1 -1
- package/dist/src/tools/mercadolibre/write-helpers.js.map +1 -1
- package/dist/src/tools/meta/account-overview.js.map +1 -1
- package/dist/src/tools/meta/ad-account-info.js.map +1 -1
- package/dist/src/tools/meta/ads-performance.js.map +1 -1
- package/dist/src/tools/meta/campaign-performance.js.map +1 -1
- package/dist/src/tools/meta/index.js.map +1 -1
- package/dist/src/tools/meta/list-accessible-ad-accounts.js.map +1 -1
- package/dist/src/tools/meta/list-accessible-businesses.js.map +1 -1
- package/dist/src/tools/meta/placement-mix.js.map +1 -1
- package/dist/src/tools/meta/time-series.js.map +1 -1
- package/dist/src/tools/search-console/country-breakdown.js.map +1 -1
- package/dist/src/tools/search-console/device-breakdown.js.map +1 -1
- package/dist/src/tools/search-console/high-impression-low-click-queries.js.map +1 -1
- package/dist/src/tools/search-console/index.js.map +1 -1
- package/dist/src/tools/search-console/list-accessible-sites.js.map +1 -1
- package/dist/src/tools/search-console/low-ctr-opportunities.js.map +1 -1
- package/dist/src/tools/search-console/page-performance.js.map +1 -1
- package/dist/src/tools/search-console/product-demand-low-capture-queries.js.map +1 -1
- package/dist/src/tools/search-console/query-page-matrix.js.map +1 -1
- package/dist/src/tools/search-console/query-performance.js.map +1 -1
- package/dist/src/tools/search-console/quick-win-opportunities.js.map +1 -1
- package/dist/src/tools/search-console/rising-non-brand-queries.js.map +1 -1
- package/dist/src/tools/search-console/search-performance.js.map +1 -1
- package/dist/src/tools/search-console/site-context.js.map +1 -1
- package/dist/src/tools/search-console/visibility-declines.js.map +1 -1
- package/dist/src/tools/vtex/activate-sku.js.map +1 -1
- package/dist/src/tools/vtex/add-order-tracking.js.map +1 -1
- package/dist/src/tools/vtex/associate-specification.js.map +1 -1
- package/dist/src/tools/vtex/attach-catalog-image.js.map +1 -1
- package/dist/src/tools/vtex/cancel-order.js.map +1 -1
- package/dist/src/tools/vtex/computed-price.js.map +1 -1
- package/dist/src/tools/vtex/create-brand.js.map +1 -1
- package/dist/src/tools/vtex/create-category.js.map +1 -1
- package/dist/src/tools/vtex/create-product-with-sku.js.map +1 -1
- package/dist/src/tools/vtex/create-product.js.map +1 -1
- package/dist/src/tools/vtex/create-sku.js.map +1 -1
- package/dist/src/tools/vtex/create-specification-value.js.map +1 -1
- package/dist/src/tools/vtex/create-specification.js.map +1 -1
- package/dist/src/tools/vtex/deactivate-sku.js.map +1 -1
- package/dist/src/tools/vtex/delete-fixed-price.js.map +1 -1
- package/dist/src/tools/vtex/index.js.map +1 -1
- package/dist/src/tools/vtex/inventory-check.js.map +1 -1
- package/dist/src/tools/vtex/invoice-order.js.map +1 -1
- package/dist/src/tools/vtex/order-details.js.map +1 -1
- package/dist/src/tools/vtex/orders-summary.js.map +1 -1
- package/dist/src/tools/vtex/product-offers.js.map +1 -1
- package/dist/src/tools/vtex/profile-resolution.js.map +1 -1
- package/dist/src/tools/vtex/sku-offers.js.map +1 -1
- package/dist/src/tools/vtex/sku-price.js.map +1 -1
- package/dist/src/tools/vtex/toggle-unlimited-quantity.js.map +1 -1
- package/dist/src/tools/vtex/update-inventory.js.map +1 -1
- package/dist/src/tools/vtex/update-lead-time.js.map +1 -1
- package/dist/src/tools/vtex/update-product-basic-fields.js.map +1 -1
- package/dist/src/tools/vtex/update-sku-basic-fields.js.map +1 -1
- package/dist/src/tools/vtex/update-sku-price.js.map +1 -1
- package/dist/src/tools/vtex/upsert-fixed-price.js.map +1 -1
- package/dist/src/tools/vtex/warehouse-inventory.js.map +1 -1
- package/dist/src/tools/vtex/write-helpers.js.map +1 -1
- package/dist/src/utils/case-conversion.js.map +1 -1
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/format-order-details.js.map +1 -1
- package/dist/src/utils/google-ads.js.map +1 -1
- package/dist/src/utils/money.js.map +1 -1
- package/dist/src/utils/order-status.js.map +1 -1
- package/dist/src/utils/pagination.js.map +1 -1
- package/dist/src/utils/strip-payload.js.map +1 -1
- package/dist/src/utils/type-guards.js.map +1 -1
- package/package.json +4 -3
- package/public/icon.svg +6 -6
- package/dist/src/google-ads/report-utils.js +0 -78
- package/dist/src/google-ads/report-utils.js.map +0 -7
- package/dist/src/search-console/search-console-utils.js +0 -275
- package/dist/src/search-console/search-console-utils.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/create-specification.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport { createSpecification } from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const createSpecificationSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n fieldTypeId: z\n .enum([\"1\", \"2\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"])\n .transform((value) => Number(value))\n .describe(\"Specification field type ID.\"),\n fieldGroupId: z.number().int().positive().describe(\"Specification group ID.\"),\n name: z.string().min(1).describe(\"Specification name.\"),\n categoryId: z.number().int().positive().optional().describe(\"Optional category ID.\"),\n description: z.string().optional().describe(\"Specification description.\"),\n position: z.number().int().nonnegative().optional().describe(\"Display position.\"),\n isFilter: z.boolean().optional().describe(\"Whether the specification should act as a filter.\"),\n isRequired: z.boolean().optional().describe(\"Whether the specification is required.\"),\n isOnProductDetails: z.boolean().optional().describe(\"Whether the specification should appear on product details.\"),\n isStockKeepingUnit: z.boolean().optional().describe(\"Whether this is an SKU specification.\"),\n isWizard: z.boolean().optional().describe(\"Wizard flag from VTEX.\"),\n isActive: z.boolean().optional().describe(\"Whether the specification is active.\"),\n isTopMenuLinkActive: z.boolean().optional().describe(\"Top menu link flag.\"),\n isSideMenuLinkActive: z.boolean().optional().describe(\"Side menu link flag.\"),\n defaultValue: z.string().optional().describe(\"Default value.\"),\n});\n\nexport async function createSpecificationHandler({\n profileId,\n fieldTypeId,\n fieldGroupId,\n name,\n categoryId,\n description,\n position,\n isFilter,\n isRequired,\n isOnProductDetails,\n isStockKeepingUnit,\n isWizard,\n isActive,\n isTopMenuLinkActive,\n isSideMenuLinkActive,\n defaultValue,\n}: z.infer<typeof createSpecificationSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const createdSpecification = await createSpecification(resolvedProfileId, {\n FieldTypeId: fieldTypeId,\n FieldGroupId: fieldGroupId,\n Name: name,\n CategoryId: categoryId,\n Description: description ?? null,\n Position: position ?? 0,\n IsFilter: isFilter ?? false,\n IsRequired: isRequired ?? false,\n IsOnProductDetails: isOnProductDetails ?? true,\n IsStockKeepingUnit: isStockKeepingUnit ?? false,\n IsWizard: isWizard ?? false,\n IsActive: isActive ?? true,\n IsTopMenuLinkActive: isTopMenuLinkActive ?? false,\n IsSideMenuLinkActive: isSideMenuLinkActive ?? false,\n DefaultValue: defaultValue ?? \"\",\n });\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"create_specification\",\n resourceId: String(createdSpecification.Id ?? \"\"),\n riskLevel: \"low\",\n message: \"Specification created successfully.\",\n before: null,\n after: createdSpecification,\n });\n } catch (err) {\n return handleVtexWriteError(err, \"Failed to create specification in VTEX\");\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport { createSpecification } from \"../../services/vtex/vtex-catalog-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const createSpecificationSchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n fieldTypeId: z\r\n .enum([\"1\", \"2\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"])\r\n .transform((value) => Number(value))\r\n .describe(\"Specification field type ID.\"),\r\n fieldGroupId: z.number().int().positive().describe(\"Specification group ID.\"),\r\n name: z.string().min(1).describe(\"Specification name.\"),\r\n categoryId: z.number().int().positive().optional().describe(\"Optional category ID.\"),\r\n description: z.string().optional().describe(\"Specification description.\"),\r\n position: z.number().int().nonnegative().optional().describe(\"Display position.\"),\r\n isFilter: z.boolean().optional().describe(\"Whether the specification should act as a filter.\"),\r\n isRequired: z.boolean().optional().describe(\"Whether the specification is required.\"),\r\n isOnProductDetails: z.boolean().optional().describe(\"Whether the specification should appear on product details.\"),\r\n isStockKeepingUnit: z.boolean().optional().describe(\"Whether this is an SKU specification.\"),\r\n isWizard: z.boolean().optional().describe(\"Wizard flag from VTEX.\"),\r\n isActive: z.boolean().optional().describe(\"Whether the specification is active.\"),\r\n isTopMenuLinkActive: z.boolean().optional().describe(\"Top menu link flag.\"),\r\n isSideMenuLinkActive: z.boolean().optional().describe(\"Side menu link flag.\"),\r\n defaultValue: z.string().optional().describe(\"Default value.\"),\r\n});\r\n\r\nexport async function createSpecificationHandler({\r\n profileId,\r\n fieldTypeId,\r\n fieldGroupId,\r\n name,\r\n categoryId,\r\n description,\r\n position,\r\n isFilter,\r\n isRequired,\r\n isOnProductDetails,\r\n isStockKeepingUnit,\r\n isWizard,\r\n isActive,\r\n isTopMenuLinkActive,\r\n isSideMenuLinkActive,\r\n defaultValue,\r\n}: z.infer<typeof createSpecificationSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const createdSpecification = await createSpecification(resolvedProfileId, {\r\n FieldTypeId: fieldTypeId,\r\n FieldGroupId: fieldGroupId,\r\n Name: name,\r\n CategoryId: categoryId,\r\n Description: description ?? null,\r\n Position: position ?? 0,\r\n IsFilter: isFilter ?? false,\r\n IsRequired: isRequired ?? false,\r\n IsOnProductDetails: isOnProductDetails ?? true,\r\n IsStockKeepingUnit: isStockKeepingUnit ?? false,\r\n IsWizard: isWizard ?? false,\r\n IsActive: isActive ?? true,\r\n IsTopMenuLinkActive: isTopMenuLinkActive ?? false,\r\n IsSideMenuLinkActive: isSideMenuLinkActive ?? false,\r\n DefaultValue: defaultValue ?? \"\",\r\n });\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"create_specification\",\r\n resourceId: String(createdSpecification.Id ?? \"\"),\r\n riskLevel: \"low\",\r\n message: \"Specification created successfully.\",\r\n before: null,\r\n after: createdSpecification,\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(err, \"Failed to create specification in VTEX\");\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,WAAW;AAAA,EACX,aAAa,EACV,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG,CAAC,EAC7C,UAAU,CAAC,UAAU,OAAO,KAAK,CAAC,EAClC,SAAS,8BAA8B;AAAA,EAC1C,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,yBAAyB;AAAA,EAC5E,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,qBAAqB;AAAA,EACtD,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,uBAAuB;AAAA,EACnF,aAAa,EAAE,OAAO,EAAE,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AAY;AAAA,MACtB,UAAU,YAAY;AAAA,MACtB,YAAY,cAAc;AAAA,MAC1B,oBAAoB,sBAAsB;AAAA,MAC1C,oBAAoB,sBAAsB;AAAA,MAC1C,UAAU,YAAY;AAAA,MACtB,UAAU,YAAY;AAAA,MACtB,qBAAqB,uBAAuB;AAAA,MAC5C,sBAAsB,wBAAwB;AAAA,MAC9C,cAAc,gBAAgB;AAAA,IAChC,CAAC;AAED,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY,OAAO,qBAAqB,MAAM,EAAE;AAAA,MAChD,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,IACT,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,wCAAwC;AAAA,EAC3E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/deactivate-sku.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n buildSkuUpdatePayload,\n getSku,\n updateSku,\n} from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const deactivateSkuSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"VTEX SKU identifier to deactivate.\"),\n});\n\nexport async function deactivateSkuHandler({\n profileId,\n skuId,\n}: z.infer<typeof deactivateSkuSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeSku = await getSku(resolvedProfileId, skuId);\n const afterSku = await updateSku(\n resolvedProfileId,\n skuId,\n buildSkuUpdatePayload(beforeSku, { isActive: false })\n );\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"deactivate_sku\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"SKU deactivated successfully.\",\n before: beforeSku,\n after: afterSku,\n details: {\n sku_id: skuId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to deactivate SKU ${skuId}`);\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport {\r\n buildSkuUpdatePayload,\r\n getSku,\r\n updateSku,\r\n} from \"../../services/vtex/vtex-catalog-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const deactivateSkuSchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"VTEX SKU identifier to deactivate.\"),\r\n});\r\n\r\nexport async function deactivateSkuHandler({\r\n profileId,\r\n skuId,\r\n}: z.infer<typeof deactivateSkuSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforeSku = await getSku(resolvedProfileId, skuId);\r\n const afterSku = await updateSku(\r\n resolvedProfileId,\r\n skuId,\r\n buildSkuUpdatePayload(beforeSku, { isActive: false })\r\n );\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"deactivate_sku\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"SKU deactivated successfully.\",\r\n before: beforeSku,\r\n after: afterSku,\r\n details: {\r\n sku_id: skuId,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(err, `Failed to deactivate SKU ${skuId}`);\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oCAAoC;AACxE,CAAC;AAED,eAAsB,qBAAqB;AAAA,EACzC;AAAA,EACA;AACF,GAAwC;AACtC,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,YAAY,MAAM,OAAO,mBAAmB,KAAK;AACvD,UAAM,WAAW,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA,sBAAsB,WAAW,EAAE,UAAU,MAAM,CAAC;AAAA,IACtD;AAEA,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,4BAA4B,KAAK,EAAE;AAAA,EACtE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/delete-fixed-price.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\nimport { deleteFixedPricesForPriceTable } from \"../../services/vtex/vtex-pricing-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const deleteFixedPriceSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU item identifier used by VTEX Pricing.\"),\n priceTableId: z.string().min(1).describe(\"Trade policy or price table identifier to clear.\"),\n});\n\nexport async function deleteFixedPriceHandler({\n profileId,\n skuId,\n priceTableId,\n}: z.infer<typeof deleteFixedPriceSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforePrice = await getSkuPrice(resolvedProfileId, skuId);\n\n await deleteFixedPricesForPriceTable(resolvedProfileId, skuId, priceTableId);\n\n const afterPrice = await getSkuPrice(resolvedProfileId, skuId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"delete_fixed_price\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Fixed prices deleted successfully for the selected price table.\",\n before: beforePrice as unknown as Record<string, unknown>,\n after: afterPrice as unknown as Record<string, unknown>,\n details: {\n sku_id: skuId,\n price_table_id: priceTableId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(\n err,\n `Failed to delete fixed prices for SKU ${skuId} on price table ${priceTableId}`\n );\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\r\nimport { deleteFixedPricesForPriceTable } from \"../../services/vtex/vtex-pricing-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const deleteFixedPriceSchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"SKU item identifier used by VTEX Pricing.\"),\r\n priceTableId: z.string().min(1).describe(\"Trade policy or price table identifier to clear.\"),\r\n});\r\n\r\nexport async function deleteFixedPriceHandler({\r\n profileId,\r\n skuId,\r\n priceTableId,\r\n}: z.infer<typeof deleteFixedPriceSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforePrice = await getSkuPrice(resolvedProfileId, skuId);\r\n\r\n await deleteFixedPricesForPriceTable(resolvedProfileId, skuId, priceTableId);\r\n\r\n const afterPrice = await getSkuPrice(resolvedProfileId, skuId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"delete_fixed_price\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"Fixed prices deleted successfully for the selected price table.\",\r\n before: beforePrice as unknown as Record<string, unknown>,\r\n after: afterPrice as unknown as Record<string, unknown>,\r\n details: {\r\n sku_id: skuId,\r\n price_table_id: priceTableId,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(\r\n err,\r\n `Failed to delete fixed prices for SKU ${skuId} on price table ${priceTableId}`\r\n );\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAC5B,SAAS,sCAAsC;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,2CAA2C;AAAA,EAC7E,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,kDAAkD;AAC7F,CAAC;AAED,eAAsB,wBAAwB;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AACF,GAA2C;AACzC,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,cAAc,MAAM,YAAY,mBAAmB,KAAK;AAE9D,UAAM,+BAA+B,mBAAmB,OAAO,YAAY;AAE3E,UAAM,aAAa,MAAM,YAAY,mBAAmB,KAAK;AAE7D,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,gBAAgB;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,MACA,yCAAyC,KAAK,mBAAmB,YAAY;AAAA,IAC/E;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./orders-summary.js\";\nexport * from \"./order-details.js\";\nexport * from \"./inventory-check.js\";\nexport * from \"./warehouse-inventory.js\";\nexport * from \"./update-inventory.js\";\nexport * from \"./update-lead-time.js\";\nexport * from \"./toggle-unlimited-quantity.js\";\nexport * from \"./sku-price.js\";\nexport * from \"./computed-price.js\";\nexport * from \"./product-offers.js\";\nexport * from \"./sku-offers.js\";\nexport * from \"./update-sku-price.js\";\nexport * from \"./upsert-fixed-price.js\";\nexport * from \"./delete-fixed-price.js\";\nexport * from \"./activate-sku.js\";\nexport * from \"./deactivate-sku.js\";\nexport * from \"./update-product-basic-fields.js\";\nexport * from \"./update-sku-basic-fields.js\";\nexport * from \"./create-product.js\";\nexport * from \"./create-sku.js\";\nexport * from \"./create-product-with-sku.js\";\nexport * from \"./create-brand.js\";\nexport * from \"./create-category.js\";\nexport * from \"./create-specification.js\";\nexport * from \"./create-specification-value.js\";\nexport * from \"./associate-specification.js\";\nexport * from \"./attach-catalog-image.js\";\nexport * from \"./cancel-order.js\";\nexport * from \"./invoice-order.js\";\nexport * from \"./add-order-tracking.js\";\nexport * from \"./profile-resolution.js\";\n"],
|
|
4
|
+
"sourcesContent": ["export * from \"./orders-summary.js\";\r\nexport * from \"./order-details.js\";\r\nexport * from \"./inventory-check.js\";\r\nexport * from \"./warehouse-inventory.js\";\r\nexport * from \"./update-inventory.js\";\r\nexport * from \"./update-lead-time.js\";\r\nexport * from \"./toggle-unlimited-quantity.js\";\r\nexport * from \"./sku-price.js\";\r\nexport * from \"./computed-price.js\";\r\nexport * from \"./product-offers.js\";\r\nexport * from \"./sku-offers.js\";\r\nexport * from \"./update-sku-price.js\";\r\nexport * from \"./upsert-fixed-price.js\";\r\nexport * from \"./delete-fixed-price.js\";\r\nexport * from \"./activate-sku.js\";\r\nexport * from \"./deactivate-sku.js\";\r\nexport * from \"./update-product-basic-fields.js\";\r\nexport * from \"./update-sku-basic-fields.js\";\r\nexport * from \"./create-product.js\";\r\nexport * from \"./create-sku.js\";\r\nexport * from \"./create-product-with-sku.js\";\r\nexport * from \"./create-brand.js\";\r\nexport * from \"./create-category.js\";\r\nexport * from \"./create-specification.js\";\r\nexport * from \"./create-specification-value.js\";\r\nexport * from \"./associate-specification.js\";\r\nexport * from \"./attach-catalog-image.js\";\r\nexport * from \"./cancel-order.js\";\r\nexport * from \"./invoice-order.js\";\r\nexport * from \"./add-order-tracking.js\";\r\nexport * from \"./profile-resolution.js\";\r\n"],
|
|
5
5
|
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/inventory-check.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { getInventoryBySkuBatch } from \"../../services/vtex/vtex-logistics.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\ntype HealthStatus = \"HEALTHY\" | \"LOW_STOCK\" | \"CRITICAL_LOW_STOCK\" | \"OUT_OF_STOCK\";\ntype SkuInventoryRow = [string, number, HealthStatus];\ntype WarehouseBalanceBaseRow = [string, number, number, boolean];\ntype WarehouseBalanceWithRefillRow = [...WarehouseBalanceBaseRow, string];\ntype WarehouseBalanceWithDateRow = [...WarehouseBalanceBaseRow, string];\ntype WarehouseBalanceFullRow = [...WarehouseBalanceBaseRow, string, string];\ntype WarehouseBalanceRow =\n | WarehouseBalanceBaseRow\n | WarehouseBalanceWithRefillRow\n | WarehouseBalanceWithDateRow\n | WarehouseBalanceFullRow;\n\nconst MAX_SKU_IDS = 50;\nconst MAX_CONCURRENT_REQUESTS = 10;\nconst MAX_RETRIES_PER_SKU = 2;\n\nfunction inferHealthStatus(globalAvailableQuantity: number, hasUnlimitedQuantity: boolean): HealthStatus {\n if (hasUnlimitedQuantity) {\n return \"HEALTHY\";\n }\n\n if (globalAvailableQuantity <= 0) {\n return \"OUT_OF_STOCK\";\n }\n\n if (globalAvailableQuantity < 5) {\n return \"CRITICAL_LOW_STOCK\";\n }\n\n if (globalAvailableQuantity < 20) {\n return \"LOW_STOCK\";\n }\n\n return \"HEALTHY\";\n}\n\nfunction toNumber(value: unknown): number {\n const parsedValue = Number(value);\n return Number.isFinite(parsedValue) ? parsedValue : 0;\n}\n\nfunction formatCompactUtcDate(dateTime?: string): string {\n if (!dateTime) {\n return \"\";\n }\n\n const match = dateTime.match(/^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}:\\d{2})/);\n if (!match) {\n return dateTime;\n }\n\n return `${match[1]} ${match[2]}`;\n}\n\nexport const inventoryCheckSchema = z.object({\n profileId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n ),\n skuIds: z\n .array(z.string().trim().min(1).describe(\"SKU identifier\"))\n .min(1)\n .max(MAX_SKU_IDS)\n .describe(\"List of SKU identifiers to fetch (up to 50 IDs)\"),\n});\n\nexport async function inventoryCheckHandler({\n profileId,\n skuIds,\n}: z.infer<typeof inventoryCheckSchema>) {\n try {\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const uniqueSkuIds = Array.from(new Set(skuIds));\n const batchResult = await getInventoryBySkuBatch(resolvedProfileId, uniqueSkuIds, {\n maxConcurrency: MAX_CONCURRENT_REQUESTS,\n maxRetries: MAX_RETRIES_PER_SKU,\n });\n\n const hasAnyTimeToRefill = batchResult.successful.some(({ document }) =>\n (Array.isArray(document.balance) ? document.balance : []).some(\n (balance) => typeof balance.timeToRefill === \"string\" && balance.timeToRefill.trim().length > 0\n )\n );\n const hasAnyDateOfSupplyUtc = batchResult.successful.some(({ document }) =>\n (Array.isArray(document.balance) ? document.balance : []).some(\n (balance) =>\n typeof balance.dateOfSupplyUtc === \"string\" && balance.dateOfSupplyUtc.trim().length > 0\n )\n );\n\n const warehouseBalanceSchema = [\"warehouseName\", \"totalQuantity\", \"reservedQuantity\", \"hasUnlimitedQuantity\"];\n if (hasAnyTimeToRefill) {\n warehouseBalanceSchema.push(\"timeToRefill\");\n }\n if (hasAnyDateOfSupplyUtc) {\n warehouseBalanceSchema.push(\"dateOfSupplyUtc\");\n }\n\n const inventory = batchResult.successful.map(({ skuId, document }) => {\n const balances = Array.isArray(document.balance) ? document.balance : [];\n const warehouses: WarehouseBalanceRow[] = balances.map((balance) => {\n const totalQuantity = toNumber(balance.totalQuantity);\n const reservedQuantity = toNumber(balance.reservedQuantity);\n const availableQuantityRaw = balance.availableQuantity;\n const availableQuantity =\n availableQuantityRaw === undefined\n ? Math.max(0, totalQuantity - reservedQuantity)\n : toNumber(availableQuantityRaw);\n const hasUnlimitedQuantity = Boolean(\n balance.hasUnlimitedQuantity ?? balance.isUnlimited ?? false\n );\n\n const warehouseBase: WarehouseBalanceBaseRow = [\n balance.warehouseName ?? balance.warehouseId ?? \"unknown\",\n totalQuantity,\n reservedQuantity,\n hasUnlimitedQuantity,\n ];\n\n if (hasAnyTimeToRefill && hasAnyDateOfSupplyUtc) {\n return [\n ...warehouseBase,\n balance.timeToRefill ?? \"\",\n formatCompactUtcDate(balance.dateOfSupplyUtc),\n ];\n }\n\n if (hasAnyTimeToRefill) {\n return [...warehouseBase, balance.timeToRefill ?? \"\"];\n }\n\n if (hasAnyDateOfSupplyUtc) {\n return [...warehouseBase, formatCompactUtcDate(balance.dateOfSupplyUtc)];\n }\n\n return warehouseBase;\n });\n\n const globalAvailableQuantity = balances.reduce((accumulator, balance) => {\n const totalQuantity = toNumber(balance.totalQuantity);\n const reservedQuantity = toNumber(balance.reservedQuantity);\n const availableQuantityRaw = balance.availableQuantity;\n const availableQuantity =\n availableQuantityRaw === undefined\n ? Math.max(0, totalQuantity - reservedQuantity)\n : toNumber(availableQuantityRaw);\n return accumulator + availableQuantity;\n }, 0);\n const hasUnlimitedQuantity = balances.some((balance) =>\n Boolean(balance.hasUnlimitedQuantity ?? balance.isUnlimited ?? false)\n );\n const skuRow: SkuInventoryRow = [\n document.skuId ?? skuId,\n globalAvailableQuantity,\n inferHealthStatus(globalAvailableQuantity, hasUnlimitedQuantity),\n ];\n\n return {\n sku: skuRow,\n warehouses,\n };\n });\n\n return object(\n stripNulls({\n metadata: {\n profile_id: resolvedProfileId,\n requested_ids: skuIds.length,\n unique_ids: uniqueSkuIds.length,\n max_parallel_requests: MAX_CONCURRENT_REQUESTS,\n successful_items: batchResult.successful.length,\n failed_items: batchResult.failed.length,\n has_failures: batchResult.failed.length > 0,\n },\n inventory_schema: {\n sku: [\"sku_id\", \"global_available_quantity\", \"health_status\"],\n warehouse_balance: warehouseBalanceSchema,\n },\n inventory,\n failures: batchResult.failed.map((failure) => ({\n sku_id: failure.skuId,\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(formatVtexError(err, \"Failed to check inventory batch\"));\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\r\nimport { getInventoryBySkuBatch } from \"../../services/vtex/vtex-logistics.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\r\n\r\ntype HealthStatus = \"HEALTHY\" | \"LOW_STOCK\" | \"CRITICAL_LOW_STOCK\" | \"OUT_OF_STOCK\";\r\ntype SkuInventoryRow = [string, number, HealthStatus];\r\ntype WarehouseBalanceBaseRow = [string, number, number, boolean];\r\ntype WarehouseBalanceWithRefillRow = [...WarehouseBalanceBaseRow, string];\r\ntype WarehouseBalanceWithDateRow = [...WarehouseBalanceBaseRow, string];\r\ntype WarehouseBalanceFullRow = [...WarehouseBalanceBaseRow, string, string];\r\ntype WarehouseBalanceRow =\r\n | WarehouseBalanceBaseRow\r\n | WarehouseBalanceWithRefillRow\r\n | WarehouseBalanceWithDateRow\r\n | WarehouseBalanceFullRow;\r\n\r\nconst MAX_SKU_IDS = 50;\r\nconst MAX_CONCURRENT_REQUESTS = 10;\r\nconst MAX_RETRIES_PER_SKU = 2;\r\n\r\nfunction inferHealthStatus(globalAvailableQuantity: number, hasUnlimitedQuantity: boolean): HealthStatus {\r\n if (hasUnlimitedQuantity) {\r\n return \"HEALTHY\";\r\n }\r\n\r\n if (globalAvailableQuantity <= 0) {\r\n return \"OUT_OF_STOCK\";\r\n }\r\n\r\n if (globalAvailableQuantity < 5) {\r\n return \"CRITICAL_LOW_STOCK\";\r\n }\r\n\r\n if (globalAvailableQuantity < 20) {\r\n return \"LOW_STOCK\";\r\n }\r\n\r\n return \"HEALTHY\";\r\n}\r\n\r\nfunction toNumber(value: unknown): number {\r\n const parsedValue = Number(value);\r\n return Number.isFinite(parsedValue) ? parsedValue : 0;\r\n}\r\n\r\nfunction formatCompactUtcDate(dateTime?: string): string {\r\n if (!dateTime) {\r\n return \"\";\r\n }\r\n\r\n const match = dateTime.match(/^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}:\\d{2})/);\r\n if (!match) {\r\n return dateTime;\r\n }\r\n\r\n return `${match[1]} ${match[2]}`;\r\n}\r\n\r\nexport const inventoryCheckSchema = z.object({\r\n profileId: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\r\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\r\n ),\r\n skuIds: z\r\n .array(z.string().trim().min(1).describe(\"SKU identifier\"))\r\n .min(1)\r\n .max(MAX_SKU_IDS)\r\n .describe(\"List of SKU identifiers to fetch (up to 50 IDs)\"),\r\n});\r\n\r\nexport async function inventoryCheckHandler({\r\n profileId,\r\n skuIds,\r\n}: z.infer<typeof inventoryCheckSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const uniqueSkuIds = Array.from(new Set(skuIds));\r\n const batchResult = await getInventoryBySkuBatch(resolvedProfileId, uniqueSkuIds, {\r\n maxConcurrency: MAX_CONCURRENT_REQUESTS,\r\n maxRetries: MAX_RETRIES_PER_SKU,\r\n });\r\n\r\n const hasAnyTimeToRefill = batchResult.successful.some(({ document }) =>\r\n (Array.isArray(document.balance) ? document.balance : []).some(\r\n (balance) => typeof balance.timeToRefill === \"string\" && balance.timeToRefill.trim().length > 0\r\n )\r\n );\r\n const hasAnyDateOfSupplyUtc = batchResult.successful.some(({ document }) =>\r\n (Array.isArray(document.balance) ? document.balance : []).some(\r\n (balance) =>\r\n typeof balance.dateOfSupplyUtc === \"string\" && balance.dateOfSupplyUtc.trim().length > 0\r\n )\r\n );\r\n\r\n const warehouseBalanceSchema = [\"warehouseName\", \"totalQuantity\", \"reservedQuantity\", \"hasUnlimitedQuantity\"];\r\n if (hasAnyTimeToRefill) {\r\n warehouseBalanceSchema.push(\"timeToRefill\");\r\n }\r\n if (hasAnyDateOfSupplyUtc) {\r\n warehouseBalanceSchema.push(\"dateOfSupplyUtc\");\r\n }\r\n\r\n const inventory = batchResult.successful.map(({ skuId, document }) => {\r\n const balances = Array.isArray(document.balance) ? document.balance : [];\r\n const warehouses: WarehouseBalanceRow[] = balances.map((balance) => {\r\n const totalQuantity = toNumber(balance.totalQuantity);\r\n const reservedQuantity = toNumber(balance.reservedQuantity);\r\n const availableQuantityRaw = balance.availableQuantity;\r\n const availableQuantity =\r\n availableQuantityRaw === undefined\r\n ? Math.max(0, totalQuantity - reservedQuantity)\r\n : toNumber(availableQuantityRaw);\r\n const hasUnlimitedQuantity = Boolean(\r\n balance.hasUnlimitedQuantity ?? balance.isUnlimited ?? false\r\n );\r\n\r\n const warehouseBase: WarehouseBalanceBaseRow = [\r\n balance.warehouseName ?? balance.warehouseId ?? \"unknown\",\r\n totalQuantity,\r\n reservedQuantity,\r\n hasUnlimitedQuantity,\r\n ];\r\n\r\n if (hasAnyTimeToRefill && hasAnyDateOfSupplyUtc) {\r\n return [\r\n ...warehouseBase,\r\n balance.timeToRefill ?? \"\",\r\n formatCompactUtcDate(balance.dateOfSupplyUtc),\r\n ];\r\n }\r\n\r\n if (hasAnyTimeToRefill) {\r\n return [...warehouseBase, balance.timeToRefill ?? \"\"];\r\n }\r\n\r\n if (hasAnyDateOfSupplyUtc) {\r\n return [...warehouseBase, formatCompactUtcDate(balance.dateOfSupplyUtc)];\r\n }\r\n\r\n return warehouseBase;\r\n });\r\n\r\n const globalAvailableQuantity = balances.reduce((accumulator, balance) => {\r\n const totalQuantity = toNumber(balance.totalQuantity);\r\n const reservedQuantity = toNumber(balance.reservedQuantity);\r\n const availableQuantityRaw = balance.availableQuantity;\r\n const availableQuantity =\r\n availableQuantityRaw === undefined\r\n ? Math.max(0, totalQuantity - reservedQuantity)\r\n : toNumber(availableQuantityRaw);\r\n return accumulator + availableQuantity;\r\n }, 0);\r\n const hasUnlimitedQuantity = balances.some((balance) =>\r\n Boolean(balance.hasUnlimitedQuantity ?? balance.isUnlimited ?? false)\r\n );\r\n const skuRow: SkuInventoryRow = [\r\n document.skuId ?? skuId,\r\n globalAvailableQuantity,\r\n inferHealthStatus(globalAvailableQuantity, hasUnlimitedQuantity),\r\n ];\r\n\r\n return {\r\n sku: skuRow,\r\n warehouses,\r\n };\r\n });\r\n\r\n return object(\r\n stripNulls({\r\n metadata: {\r\n profile_id: resolvedProfileId,\r\n requested_ids: skuIds.length,\r\n unique_ids: uniqueSkuIds.length,\r\n max_parallel_requests: MAX_CONCURRENT_REQUESTS,\r\n successful_items: batchResult.successful.length,\r\n failed_items: batchResult.failed.length,\r\n has_failures: batchResult.failed.length > 0,\r\n },\r\n inventory_schema: {\r\n sku: [\"sku_id\", \"global_available_quantity\", \"health_status\"],\r\n warehouse_balance: warehouseBalanceSchema,\r\n },\r\n inventory,\r\n failures: batchResult.failed.map((failure) => ({\r\n sku_id: failure.skuId,\r\n message: failure.message,\r\n status_code: failure.statusCode,\r\n attempts: failure.attempts,\r\n retryable: failure.retryable,\r\n })),\r\n })\r\n );\r\n } catch (err) {\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AAe,OAAO;AAAA,UACtB,YAAY,aAAa;AAAA,UACzB,uBAAuB;AAAA,UACvB,kBAAkB,YAAY,WAAW;AAAA,UACzC,cAAc,YAAY,OAAO;AAAA,UACjC,cAAc,YAAY,OAAO,SAAS;AAAA,QAC5C;AAAA,QACA,kBAAkB;AAAA,UAChB,KAAK,CAAC,UAAU,6BAA6B,eAAe;AAAA,UAC5D,mBAAmB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,UAAU,YAAY,OAAO,IAAI,CAAC,aAAa;AAAA,UAC7C,QAAQ,QAAQ;AAAA,UAChB,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,gBAAgB,KAAK,iCAAiC,CAAC;AAAA,EACtE;AACF;",
|
|
6
6
|
"names": ["hasUnlimitedQuantity"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/invoice-order.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getOrderStateSnapshot,\n invoiceOrder,\n validateOrderForInvoice,\n} from \"../../services/vtex/vtex-orders-write.js\";\nimport {\n buildWriteSuccessResponse,\n confirmationNoteSchemaField,\n confirmationSchemaField,\n handleVtexWriteError,\n requireExplicitConfirmation,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nconst invoiceItemSchema = z.object({\n id: z.string().min(1).describe(\"SKU ID being invoiced.\"),\n price: z\n .number()\n .int()\n .positive()\n .describe(\"Unit price in cents, without decimal separator.\"),\n quantity: z.number().int().positive().describe(\"Quantity being invoiced.\"),\n description: z.string().optional().describe(\"Optional extra description for this line.\"),\n});\n\nexport const invoiceOrderSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n orderId: z.string().min(1).describe(\"VTEX order identifier to invoice.\"),\n confirmed: confirmationSchemaField,\n confirmationNote: confirmationNoteSchemaField,\n type: z.enum([\"Output\", \"Input\"]).describe(\"Invoice type.\"),\n issuanceDate: z.string().min(1).describe(\"Invoice issuance timestamp.\"),\n invoiceNumber: z.string().min(1).describe(\"Invoice number.\"),\n invoiceValue: z\n .string()\n .min(1)\n .describe(\"Invoice total in cents, represented as a string without decimal separator.\"),\n items: z.array(invoiceItemSchema).min(1).describe(\"Items being invoiced.\"),\n invoiceKey: z.string().optional().describe(\"Optional invoice key.\"),\n invoiceUrl: z.string().url().optional().describe(\"Optional invoice URL.\"),\n invoiceOrderNumber: z.string().optional().describe(\"Optional order number from merchant ERP.\"),\n courier: z.string().optional().describe(\"Optional carrier name.\"),\n trackingNumber: z.string().optional().describe(\"Optional tracking number.\"),\n trackingUrl: z.string().url().optional().describe(\"Optional tracking URL.\"),\n});\n\nexport async function invoiceOrderHandler({\n profileId,\n orderId,\n confirmed,\n confirmationNote,\n ...payload\n}: z.infer<typeof invoiceOrderSchema>) {\n const confirmationResponse = requireExplicitConfirmation(confirmed, \"invoice_order\", {\n order_id: orderId,\n });\n if (confirmationResponse) {\n return confirmationResponse;\n }\n\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeOrder = await validateOrderForInvoice(resolvedProfileId, orderId);\n await invoiceOrder(resolvedProfileId, orderId, payload);\n const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"invoice_order\",\n resourceId: orderId,\n riskLevel: \"high\",\n confirmed: true,\n confirmationNote,\n message: \"Order invoiced successfully.\",\n before: beforeOrder as unknown as Record<string, unknown>,\n after: afterOrder as unknown as Record<string, unknown>,\n details: {\n order_id: orderId,\n invoice_number: payload.invoiceNumber,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to invoice order ${orderId}`);\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport {\r\n getOrderStateSnapshot,\r\n invoiceOrder,\r\n validateOrderForInvoice,\r\n} from \"../../services/vtex/vtex-orders-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n confirmationNoteSchemaField,\r\n confirmationSchemaField,\r\n handleVtexWriteError,\r\n requireExplicitConfirmation,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nconst invoiceItemSchema = z.object({\r\n id: z.string().min(1).describe(\"SKU ID being invoiced.\"),\r\n price: z\r\n .number()\r\n .int()\r\n .positive()\r\n .describe(\"Unit price in cents, without decimal separator.\"),\r\n quantity: z.number().int().positive().describe(\"Quantity being invoiced.\"),\r\n description: z.string().optional().describe(\"Optional extra description for this line.\"),\r\n});\r\n\r\nexport const invoiceOrderSchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n orderId: z.string().min(1).describe(\"VTEX order identifier to invoice.\"),\r\n confirmed: confirmationSchemaField,\r\n confirmationNote: confirmationNoteSchemaField,\r\n type: z.enum([\"Output\", \"Input\"]).describe(\"Invoice type.\"),\r\n issuanceDate: z.string().min(1).describe(\"Invoice issuance timestamp.\"),\r\n invoiceNumber: z.string().min(1).describe(\"Invoice number.\"),\r\n invoiceValue: z\r\n .string()\r\n .min(1)\r\n .describe(\"Invoice total in cents, represented as a string without decimal separator.\"),\r\n items: z.array(invoiceItemSchema).min(1).describe(\"Items being invoiced.\"),\r\n invoiceKey: z.string().optional().describe(\"Optional invoice key.\"),\r\n invoiceUrl: z.string().url().optional().describe(\"Optional invoice URL.\"),\r\n invoiceOrderNumber: z.string().optional().describe(\"Optional order number from merchant ERP.\"),\r\n courier: z.string().optional().describe(\"Optional carrier name.\"),\r\n trackingNumber: z.string().optional().describe(\"Optional tracking number.\"),\r\n trackingUrl: z.string().url().optional().describe(\"Optional tracking URL.\"),\r\n});\r\n\r\nexport async function invoiceOrderHandler({\r\n profileId,\r\n orderId,\r\n confirmed,\r\n confirmationNote,\r\n ...payload\r\n}: z.infer<typeof invoiceOrderSchema>) {\r\n const confirmationResponse = requireExplicitConfirmation(confirmed, \"invoice_order\", {\r\n order_id: orderId,\r\n });\r\n if (confirmationResponse) {\r\n return confirmationResponse;\r\n }\r\n\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforeOrder = await validateOrderForInvoice(resolvedProfileId, orderId);\r\n await invoiceOrder(resolvedProfileId, orderId, payload);\r\n const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"invoice_order\",\r\n resourceId: orderId,\r\n riskLevel: \"high\",\r\n confirmed: true,\r\n confirmationNote,\r\n message: \"Order invoiced successfully.\",\r\n before: beforeOrder as unknown as Record<string, unknown>,\r\n after: afterOrder as unknown as Record<string, unknown>,\r\n details: {\r\n order_id: orderId,\r\n invoice_number: payload.invoiceNumber,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(err, `Failed to invoice order ${orderId}`);\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,wBAAwB;AAAA,EACvD,OAAO,EACJ,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,iDAAiD;AAAA,EAC7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Z,CAAC;AACD,MAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,cAAc,MAAM,wBAAwB,mBAAmB,OAAO;AAC5E,UAAM,aAAa,mBAAmB,SAAS,OAAO;AACtD,UAAM,aAAa,MAAM,sBAAsB,mBAAmB,OAAO;AAEzE,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,UAAU;AAAA,QACV,gBAAgB,QAAQ;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,2BAA2B,OAAO,EAAE;AAAA,EACvE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/order-details.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { getOrderDocumentsBatch } from \"../../services/vtex/vtex-orders.js\";\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { formatOrderDetails } from \"../../utils/format-order-details.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nconst MAX_ORDER_IDS = 50;\nconst MAX_CONCURRENT_REQUESTS = 10;\nconst MAX_RETRIES_PER_ORDER = 2;\n\nexport const orderDetailsSchema = z.object({\n profileId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n ),\n orderIds: z\n .array(z.string().trim().min(3).describe(\"VTEX order identifier\"))\n .min(1)\n .max(MAX_ORDER_IDS)\n .describe(\"List of VTEX order identifiers to fetch (up to 50 IDs)\"),\n reason: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\"Optional reason for requesting unmasked PII data when required\"),\n});\n\nexport async function orderDetailsHandler({\n profileId,\n orderIds,\n reason,\n}: z.infer<typeof orderDetailsSchema>) {\n try {\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const uniqueOrderIds = Array.from(new Set(orderIds));\n const batchResult = await getOrderDocumentsBatch(resolvedProfileId, uniqueOrderIds, {\n reason,\n maxConcurrency: MAX_CONCURRENT_REQUESTS,\n maxRetries: MAX_RETRIES_PER_ORDER,\n });\n \n const formattedOrders = batchResult.successful.map(({ document }) => formatOrderDetails(document));\n\n return object(\n stripNulls({\n metadata: {\n profile_id: resolvedProfileId,\n requested: uniqueOrderIds.length,\n successful: batchResult.successful.length,\n failed: batchResult.failed.length,\n },\n schemas: {\n item: [\"id\", \"ref\", \"name\", \"qty\", \"price\", \"list\"],\n shipping: [\"carrier\", \"estimate\", \"delivery_date\"],\n payment: [\"system\", \"installments\", \"value\"],\n payment_validation: {\n payments_total: \"Sum of all payment values\",\n payment_delta: \"Difference between payments_total and order total\",\n payment_mismatch: \"True if |payment_delta| > 0.5 (potential issue)\",\n },\n },\n orders: formattedOrders,\n failures: batchResult.failed.map((failure) => ({\n order_id: failure.orderId,\n message: failure.message,\n status_code: failure.statusCode,\n })),\n })\n );\n } catch (err) {\n return error(formatVtexError(err, \"Failed to fetch order details batch\"));\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { getOrderDocumentsBatch } from \"../../services/vtex/vtex-orders.js\";\r\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\r\nimport { formatOrderDetails } from \"../../utils/format-order-details.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\r\n\r\nconst MAX_ORDER_IDS = 50;\r\nconst MAX_CONCURRENT_REQUESTS = 10;\r\nconst MAX_RETRIES_PER_ORDER = 2;\r\n\r\nexport const orderDetailsSchema = z.object({\r\n profileId: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\r\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\r\n ),\r\n orderIds: z\r\n .array(z.string().trim().min(3).describe(\"VTEX order identifier\"))\r\n .min(1)\r\n .max(MAX_ORDER_IDS)\r\n .describe(\"List of VTEX order identifiers to fetch (up to 50 IDs)\"),\r\n reason: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\"Optional reason for requesting unmasked PII data when required\"),\r\n});\r\n\r\nexport async function orderDetailsHandler({\r\n profileId,\r\n orderIds,\r\n reason,\r\n}: z.infer<typeof orderDetailsSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const uniqueOrderIds = Array.from(new Set(orderIds));\r\n const batchResult = await getOrderDocumentsBatch(resolvedProfileId, uniqueOrderIds, {\r\n reason,\r\n maxConcurrency: MAX_CONCURRENT_REQUESTS,\r\n maxRetries: MAX_RETRIES_PER_ORDER,\r\n });\r\n \r\n const formattedOrders = batchResult.successful.map(({ document }) => formatOrderDetails(document));\r\n\r\n return object(\r\n stripNulls({\r\n metadata: {\r\n profile_id: resolvedProfileId,\r\n requested: uniqueOrderIds.length,\r\n successful: batchResult.successful.length,\r\n failed: batchResult.failed.length,\r\n },\r\n schemas: {\r\n item: [\"id\", \"ref\", \"name\", \"qty\", \"price\", \"list\"],\r\n shipping: [\"carrier\", \"estimate\", \"delivery_date\"],\r\n payment: [\"system\", \"installments\", \"value\"],\r\n payment_validation: {\r\n payments_total: \"Sum of all payment values\",\r\n payment_delta: \"Difference between payments_total and order total\",\r\n payment_mismatch: \"True if |payment_delta| > 0.5 (potential issue)\",\r\n },\r\n },\r\n orders: formattedOrders,\r\n failures: batchResult.failed.map((failure) => ({\r\n order_id: failure.orderId,\r\n message: failure.message,\r\n status_code: failure.statusCode,\r\n })),\r\n })\r\n );\r\n } catch (err) {\r\n return error(formatVtexError(err, \"Failed to fetch order details batch\"));\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAE9C,MAAM,gBAAgB;AACtB,MAAM,0BAA0B;AAChC,MAAM,wBAAwB;AAEvB,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,WAAW,EACR,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,UAAU,EACP,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,uBAAuB,CAAC,EAChE,IAAI,CAAC,EACL,IAAI,aAAa,EACjB,SAAS,wDAAwD;AAAA,EACpE,QAAQ,EACL,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT,SAAS,gEAAgE;AAC9E,CAAC;AAED,eAAsB,oBAAoB;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AACrC,MAAI;AACF,UAAM,oBAAoB,MAAM,8BAA8B,SAAS;AACvE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,iBAAiB,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC;AACnD,UAAM,cAAc,MAAM,uBAAuB,mBAAmB,gBAAgB;AAAA,MAClF;AAAA,MACA,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACd,CAAC;AAED,UAAM,kBAAkB,YAAY,WAAW,IAAI,CAAC,EAAE,SAAS,MAAM,mBAAmB,QAAQ,CAAC;AAEjG,WAAO;AAAA,MACL,WAAW;AAAA,QACT,UAAU;AAAA,UACR,YAAY;AAAA,UACZ,WAAW,eAAe;AAAA,UAC1B,YAAY,YAAY,WAAW;AAAA,UACnC,QAAQ,YAAY,OAAO;AAAA,QAC7B;AAAA,QACA,SAAS;AAAA,UACP,MAAM,CAAC,MAAM,OAAO,QAAQ,OAAO,SAAS,MAAM;AAAA,UAClD,UAAU,CAAC,WAAW,YAAY,eAAe;AAAA,UACjD,SAAS,CAAC,UAAU,gBAAgB,OAAO;AAAA,UAC3C,oBAAoB;AAAA,YAClB,gBAAgB;AAAA,YAChB,eAAe;AAAA,YACf,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,QACA,QAAQ;AAAA,QACR,UAAU,YAAY,OAAO,IAAI,CAAC,aAAa;AAAA,UAC7C,UAAU,QAAQ;AAAA,UAClB,SAAS,QAAQ;AAAA,UACjB,aAAa,QAAQ;AAAA,QACvB,EAAE;AAAA,MACJ,CAAC;AAAA,IACH;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,MAAM,gBAAgB,KAAK,qCAAqC,CAAC;AAAA,EAC1E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/orders-summary.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { listOrders } from \"../../services/vtex/vtex-orders.js\";\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { buildCurrencyMetrics } from \"../../utils/currency.js\";\nimport { moneyFromCents } from \"../../utils/money.js\";\nimport { normalizeOrderStatus } from \"../../utils/order-status.js\";\nimport { createPaginationMetadata } from \"../../utils/pagination.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nconst dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nfunction buildDateFilter(startDate: string, endDate: string): string {\n return `creationDate:[${startDate}T00:00:00.000Z TO ${endDate}T23:59:59.999Z]`;\n}\n\nfunction formatCompactDate(dateTime?: string): string {\n if (!dateTime) {\n return \"\";\n }\n\n const match = dateTime.match(/^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}:\\d{2})/);\n if (!match) {\n return dateTime;\n }\n\n return `${match[1]} ${match[2]}`;\n}\n\nconst ordersSchema = [\"id\", \"date\", \"status\", \"value\", \"currency\", \"payment\", \"channel\", \"items\"] as const;\nconst metricsSchema = {\n breakdown: [\"count\", \"revenue\"] as const,\n};\n\nexport const ordersSummarySchema = z.object({\n profileId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n ),\n startDate: z.string().regex(dateRegex).describe(\"Start date in YYYY-MM-DD format\"),\n endDate: z.string().regex(dateRegex).describe(\"End date in YYYY-MM-DD format\"),\n page: z.number().int().min(1).max(30).optional().describe(\"Page number (1-30)\"),\n perPage: z.number().int().min(1).max(100).optional().describe(\"Orders per page (1-100)\"),\n status: z.string().optional().describe(\"Optional VTEX status filter (f_status)\"),\n salesChannel: z.string().optional().describe(\"Optional sales channel filter (f_salesChannel)\"),\n paymentName: z.string().optional().describe(\"Optional payment filter (f_paymentNames)\"),\n utmSource: z.string().optional().describe(\"Optional UTM source filter (f_UtmSource)\"),\n orderBy: z\n .string()\n .optional()\n .describe(\"Sort order in VTEX format, e.g. creationDate,desc\"),\n});\n\nexport async function ordersSummaryHandler(params: z.infer<typeof ordersSummarySchema>) {\n try {\n const profileResolution = await resolveVtexProfileOrSelection(params.profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const profileId = profileResolution.value.profileId;\n const page = params.page ?? 1;\n const perPage = params.perPage ?? 100;\n\n const ordersResponse = await listOrders(profileId, {\n page,\n per_page: perPage,\n orderBy: params.orderBy,\n f_creationDate: buildDateFilter(params.startDate, params.endDate),\n f_status: params.status,\n f_salesChannel: params.salesChannel,\n f_paymentNames: params.paymentName,\n f_UtmSource: params.utmSource,\n });\n\n const orders = Array.isArray(ordersResponse.list) ? ordersResponse.list : [];\n const metadata = createPaginationMetadata(ordersResponse.paging ?? {}, perPage, orders.length);\n const metrics = buildCurrencyMetrics(orders);\n const compactOrders = orders.map((order) => [\n order.orderId,\n formatCompactDate(order.creationDate),\n normalizeOrderStatus(order.status),\n moneyFromCents(order.totalValue),\n order.currencyCode ?? \"\",\n order.paymentNames ?? \"\",\n order.salesChannel ?? \"\",\n Number(order.totalItems ?? 0),\n ]);\n\n return object(\n stripNulls({\n metadata,\n profile_id: profileId,\n metrics_schema: metricsSchema,\n metrics,\n orders_schema: ordersSchema,\n orders: compactOrders,\n })\n );\n } catch (err) {\n return error(formatVtexError(err, \"Failed to fetch orders summary\"));\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { listOrders } from \"../../services/vtex/vtex-orders.js\";\r\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\r\nimport { buildCurrencyMetrics } from \"../../utils/currency.js\";\r\nimport { moneyFromCents } from \"../../utils/money.js\";\r\nimport { normalizeOrderStatus } from \"../../utils/order-status.js\";\r\nimport { createPaginationMetadata } from \"../../utils/pagination.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\r\n\r\nconst dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\r\n\r\nfunction buildDateFilter(startDate: string, endDate: string): string {\r\n return `creationDate:[${startDate}T00:00:00.000Z TO ${endDate}T23:59:59.999Z]`;\r\n}\r\n\r\nfunction formatCompactDate(dateTime?: string): string {\r\n if (!dateTime) {\r\n return \"\";\r\n }\r\n\r\n const match = dateTime.match(/^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}:\\d{2})/);\r\n if (!match) {\r\n return dateTime;\r\n }\r\n\r\n return `${match[1]} ${match[2]}`;\r\n}\r\n\r\nconst ordersSchema = [\"id\", \"date\", \"status\", \"value\", \"currency\", \"payment\", \"channel\", \"items\"] as const;\r\nconst metricsSchema = {\r\n breakdown: [\"count\", \"revenue\"] as const,\r\n};\r\n\r\nexport const ordersSummarySchema = z.object({\r\n profileId: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\r\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\r\n ),\r\n startDate: z.string().regex(dateRegex).describe(\"Start date in YYYY-MM-DD format\"),\r\n endDate: z.string().regex(dateRegex).describe(\"End date in YYYY-MM-DD format\"),\r\n page: z.number().int().min(1).max(30).optional().describe(\"Page number (1-30)\"),\r\n perPage: z.number().int().min(1).max(100).optional().describe(\"Orders per page (1-100)\"),\r\n status: z.string().optional().describe(\"Optional VTEX status filter (f_status)\"),\r\n salesChannel: z.string().optional().describe(\"Optional sales channel filter (f_salesChannel)\"),\r\n paymentName: z.string().optional().describe(\"Optional payment filter (f_paymentNames)\"),\r\n utmSource: z.string().optional().describe(\"Optional UTM source filter (f_UtmSource)\"),\r\n orderBy: z\r\n .string()\r\n .optional()\r\n .describe(\"Sort order in VTEX format, e.g. creationDate,desc\"),\r\n});\r\n\r\nexport async function ordersSummaryHandler(params: z.infer<typeof ordersSummarySchema>) {\r\n try {\r\n const profileResolution = await resolveVtexProfileOrSelection(params.profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const profileId = profileResolution.value.profileId;\r\n const page = params.page ?? 1;\r\n const perPage = params.perPage ?? 100;\r\n\r\n const ordersResponse = await listOrders(profileId, {\r\n page,\r\n per_page: perPage,\r\n orderBy: params.orderBy,\r\n f_creationDate: buildDateFilter(params.startDate, params.endDate),\r\n f_status: params.status,\r\n f_salesChannel: params.salesChannel,\r\n f_paymentNames: params.paymentName,\r\n f_UtmSource: params.utmSource,\r\n });\r\n\r\n const orders = Array.isArray(ordersResponse.list) ? ordersResponse.list : [];\r\n const metadata = createPaginationMetadata(ordersResponse.paging ?? {}, perPage, orders.length);\r\n const metrics = buildCurrencyMetrics(orders);\r\n const compactOrders = orders.map((order) => [\r\n order.orderId,\r\n formatCompactDate(order.creationDate),\r\n normalizeOrderStatus(order.status),\r\n moneyFromCents(order.totalValue),\r\n order.currencyCode ?? \"\",\r\n order.paymentNames ?? \"\",\r\n order.salesChannel ?? \"\",\r\n Number(order.totalItems ?? 0),\r\n ]);\r\n\r\n return object(\r\n stripNulls({\r\n metadata,\r\n profile_id: profileId,\r\n metrics_schema: metricsSchema,\r\n metrics,\r\n orders_schema: ordersSchema,\r\n orders: compactOrders,\r\n })\r\n );\r\n } catch (err) {\r\n return error(formatVtexError(err, \"Failed to fetch orders summary\"));\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AACzC,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAE9C,MAAM,YAAY;AAElB,SAAS,gBAAgB,WAAmB,SAAyB;AACnE,SAAO,iBAAiB,SAAS,qBAAqB,OAAO;AAC/D;AAEA,SAAS,kBAAkB,UAA2B;AACpD,MAAI,CAAC,UAAU;AACb,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ers.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { getProductOffers } from \"../../services/vtex/vtex-catalog.js\";\nimport { toSnakeCaseKeys } from \"../../utils/case-conversion.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const productOffersSchema = z.object({\n profileId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n ),\n productId: z.string().min(1).describe(\"Product identifier\"),\n});\n\nexport async function productOffersHandler({\n profileId,\n productId,\n}: z.infer<typeof productOffersSchema>) {\n try {\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const offers = await getProductOffers(resolvedProfileId, productId);\n const normalizedOffers = toSnakeCaseKeys(offers);\n\n return object(\n stripNulls({\n profile_id: resolvedProfileId,\n product_id: productId,\n offers: normalizedOffers,\n })\n );\n } catch (err) {\n return error(formatVtexError(err, `Failed to fetch product offers for ${productId}`));\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\r\nimport { getProductOffers } from \"../../services/vtex/vtex-catalog.js\";\r\nimport { toSnakeCaseKeys } from \"../../utils/case-conversion.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\r\n\r\nexport const productOffersSchema = z.object({\r\n profileId: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\r\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\r\n ),\r\n productId: z.string().min(1).describe(\"Product identifier\"),\r\n});\r\n\r\nexport async function productOffersHandler({\r\n profileId,\r\n productId,\r\n}: z.infer<typeof productOffersSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const offers = await getProductOffers(resolvedProfileId, productId);\r\n const normalizedOffers = toSnakeCaseKeys(offers);\r\n\r\n return object(\r\n stripNulls({\r\n profile_id: resolvedProfileId,\r\n product_id: productId,\r\n offers: normalizedOffers,\r\n })\r\n );\r\n } catch (err) {\r\n return error(formatVtexError(err, `Failed to fetch product offers for ${productId}`));\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAEvC,MAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,WAAW,EACR,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oBAAoB;AAC5D,CAAC;AAED,eAAsB,qBAAqB;AAAA,EACzC;AAAA,EACA;AACF,GAAwC;AACtC,MAAI;AACF,UAAM,oBAAoB,MAAM,8BAA8B,SAAS;AACvE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,SAAS,MAAM,iBAAiB,mBAAmB,SAAS;AAClE,UAAM,mBAAmB,gBAAgB,MAAM;AAE/C,WAAO;AAAA,MACL,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,MAAM,gBAAgB,KAAK,sCAAsC,SAAS,EAAE,CAAC;AAAA,EACtF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/profile-resolution.ts"],
|
|
4
|
-
"sourcesContent": ["import { object } from \"mcp-use/server\";\n\nimport { getProfile, listProfiles } from \"../../config/profile-store.js\";\n\nexport type VtexProfileSelectionReason =\n | \"missing_profile\"\n | \"profile_not_found\"\n | \"profile_inactive\";\n\nexport interface ResolvedVtexProfile {\n profileId: string;\n}\n\ninterface VtexProfileSelectionPayload extends Record<string, unknown> {\n selection_required: boolean;\n reason: VtexProfileSelectionReason;\n message: string;\n available_profiles: Array<{\n profile_id: string;\n name: string;\n }>;\n}\n\nfunction buildSelectionMessage(reason: VtexProfileSelectionReason, profileId?: string): string {\n switch (reason) {\n case \"missing_profile\":\n return \"VTEX requiere seleccion explicita de profileId. Reenviar la misma tool con uno de los perfiles activos disponibles.\";\n case \"profile_not_found\":\n return `El profileId \"${profileId}\" no existe. Reenviar la misma tool con uno de los perfiles activos disponibles.`;\n case \"profile_inactive\":\n return `El profileId \"${profileId}\" esta inactivo. Reenviar la misma tool con uno de los perfiles activos disponibles.`;\n }\n}\n\nexport async function resolveVtexProfileOrSelection(\n profileId?: string\n): Promise<\n | { ok: true; value: ResolvedVtexProfile }\n | { ok: false; response: ReturnType<typeof object<Record<string, unknown>>> }\n> {\n const requestedProfileId = profileId?.trim();\n\n if (!requestedProfileId) {\n return {\n ok: false,\n response: await buildSelectionResponse(\"missing_profile\"),\n };\n }\n\n const profile = await getProfile(requestedProfileId);\n if (!profile) {\n return {\n ok: false,\n response: await buildSelectionResponse(\"profile_not_found\", requestedProfileId),\n };\n }\n\n if (!profile.isActive) {\n return {\n ok: false,\n response: await buildSelectionResponse(\"profile_inactive\", requestedProfileId),\n };\n }\n\n return {\n ok: true,\n value: {\n profileId: profile.id,\n },\n };\n}\n\nasync function buildSelectionResponse(\n reason: VtexProfileSelectionReason,\n profileId?: string\n) {\n const profiles = await listProfiles({ activeOnly: true });\n const availableProfiles = profiles.map((profile) => ({\n profile_id: profile.id,\n name: profile.name,\n }));\n\n return object({\n selection_required: true,\n reason,\n message: buildSelectionMessage(reason, profileId),\n available_profiles: availableProfiles,\n });\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { object } from \"mcp-use/server\";\r\n\r\nimport { getProfile, listProfiles } from \"../../config/profile-store.js\";\r\n\r\nexport type VtexProfileSelectionReason =\r\n | \"missing_profile\"\r\n | \"profile_not_found\"\r\n | \"profile_inactive\";\r\n\r\nexport interface ResolvedVtexProfile {\r\n profileId: string;\r\n}\r\n\r\ninterface VtexProfileSelectionPayload extends Record<string, unknown> {\r\n selection_required: boolean;\r\n reason: VtexProfileSelectionReason;\r\n message: string;\r\n available_profiles: Array<{\r\n profile_id: string;\r\n name: string;\r\n }>;\r\n}\r\n\r\nfunction buildSelectionMessage(reason: VtexProfileSelectionReason, profileId?: string): string {\r\n switch (reason) {\r\n case \"missing_profile\":\r\n return \"VTEX requiere seleccion explicita de profileId. Reenviar la misma tool con uno de los perfiles activos disponibles.\";\r\n case \"profile_not_found\":\r\n return `El profileId \"${profileId}\" no existe. Reenviar la misma tool con uno de los perfiles activos disponibles.`;\r\n case \"profile_inactive\":\r\n return `El profileId \"${profileId}\" esta inactivo. Reenviar la misma tool con uno de los perfiles activos disponibles.`;\r\n }\r\n}\r\n\r\nexport async function resolveVtexProfileOrSelection(\r\n profileId?: string\r\n): Promise<\r\n | { ok: true; value: ResolvedVtexProfile }\r\n | { ok: false; response: ReturnType<typeof object<Record<string, unknown>>> }\r\n> {\r\n const requestedProfileId = profileId?.trim();\r\n\r\n if (!requestedProfileId) {\r\n return {\r\n ok: false,\r\n response: await buildSelectionResponse(\"missing_profile\"),\r\n };\r\n }\r\n\r\n const profile = await getProfile(requestedProfileId);\r\n if (!profile) {\r\n return {\r\n ok: false,\r\n response: await buildSelectionResponse(\"profile_not_found\", requestedProfileId),\r\n };\r\n }\r\n\r\n if (!profile.isActive) {\r\n return {\r\n ok: false,\r\n response: await buildSelectionResponse(\"profile_inactive\", requestedProfileId),\r\n };\r\n }\r\n\r\n return {\r\n ok: true,\r\n value: {\r\n profileId: profile.id,\r\n },\r\n };\r\n}\r\n\r\nasync function buildSelectionResponse(\r\n reason: VtexProfileSelectionReason,\r\n profileId?: string\r\n) {\r\n const profiles = await listProfiles({ activeOnly: true });\r\n const availableProfiles = profiles.map((profile) => ({\r\n profile_id: profile.id,\r\n name: profile.name,\r\n }));\r\n\r\n return object({\r\n selection_required: true,\r\n reason,\r\n message: buildSelectionMessage(reason, profileId),\r\n available_profiles: availableProfiles,\r\n });\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,cAAc;AAEvB,SAAS,YAAY,oBAAoB;AAqBzC,SAAS,sBAAsB,QAAoC,WAA4B;AAC7F,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,iBAAiB,SAAS;AAAA,IACnC,KAAK;AACH,aAAO,iBAAiB,SAAS;AAAA,EACrC;AACF;AAEA,eAAsB,8BACpB,WAIA;AACA,QAAM,qBAAqB,WAAW,KAAK;AAE3C,MAAI,CAAC,oBAAoB;AACvB,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,UAAU,MAAM,uBAAuB,iBAAiB;AAAA,IAC1D;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,WAAW,kBAAkB;AACnD,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,UAAU,MAAM,uBAAuB,qBAAqB,kBAAkB;AAAA,IAChF;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,UAAU;AACrB,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,UAAU,MAAM,uBAAuB,oBAAoB,kBAAkB;AAAA,IAC/E;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,MACL,WAAW,QAAQ;AAAA,IACrB;AAAA,EACF;AACF;AAEA,eAAe,uBACb,QACA,WACA;AACA,QAAM,WAAW,MAAM,aAAa,EAAE,YAAY,KAAK,CAAC;AACxD,QAAM,oBAAoB,SAAS,IAAI,CAAC,aAAa;AAAA,IACjD,YAAY,QAAQ;AAAA,IACpB,MAAM,QAAQ;AAAA,EAChB,EAAE;AAEJ,SAAO,OAAO;AAAA,IACZ,oBAAoB;AAAA,IACpB;AAAA,IACA,SAAS,sBAAsB,QAAQ,SAAS;AAAA,IAChD,oBAAoB;AAAA,EACtB,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/sku-offers.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { getSkuOffers } from \"../../services/vtex/vtex-catalog.js\";\nimport { toSnakeCaseKeys } from \"../../utils/case-conversion.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const skuOffersSchema = z.object({\n profileId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n ),\n productId: z.string().min(1).describe(\"Product identifier\"),\n skuId: z.string().min(1).describe(\"SKU identifier\"),\n});\n\nexport async function skuOffersHandler({\n profileId,\n productId,\n skuId,\n}: z.infer<typeof skuOffersSchema>) {\n try {\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const offers = await getSkuOffers(resolvedProfileId, productId, skuId);\n const normalizedOffers = toSnakeCaseKeys(offers);\n\n return object(\n stripNulls({\n profile_id: resolvedProfileId,\n product_id: productId,\n sku_id: skuId,\n offers: normalizedOffers,\n })\n );\n } catch (err) {\n return error(formatVtexError(err, `Failed to fetch SKU offers for product ${productId} and sku ${skuId}`));\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\r\nimport { getSkuOffers } from \"../../services/vtex/vtex-catalog.js\";\r\nimport { toSnakeCaseKeys } from \"../../utils/case-conversion.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\r\n\r\nexport const skuOffersSchema = z.object({\r\n profileId: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\r\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\r\n ),\r\n productId: z.string().min(1).describe(\"Product identifier\"),\r\n skuId: z.string().min(1).describe(\"SKU identifier\"),\r\n});\r\n\r\nexport async function skuOffersHandler({\r\n profileId,\r\n productId,\r\n skuId,\r\n}: z.infer<typeof skuOffersSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const offers = await getSkuOffers(resolvedProfileId, productId, skuId);\r\n const normalizedOffers = toSnakeCaseKeys(offers);\r\n\r\n return object(\r\n stripNulls({\r\n profile_id: resolvedProfileId,\r\n product_id: productId,\r\n sku_id: skuId,\r\n offers: normalizedOffers,\r\n })\r\n );\r\n } catch (err) {\r\n return error(formatVtexError(err, `Failed to fetch SKU offers for product ${productId} and sku ${skuId}`));\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAEvC,MAAM,kBAAkB,EAAE,OAAO;AAAA,EACtC,WAAW,EACR,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oBAAoB;AAAA,EAC1D,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,gBAAgB;AACpD,CAAC;AAED,eAAsB,iBAAiB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,GAAoC;AAClC,MAAI;AACF,UAAM,oBAAoB,MAAM,8BAA8B,SAAS;AACvE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,SAAS,MAAM,aAAa,mBAAmB,WAAW,KAAK;AACrE,UAAM,mBAAmB,gBAAgB,MAAM;AAE/C,WAAO;AAAA,MACL,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAAA,EACF,SAAS,KAAK;AACZ,WAAO,MAAM,gBAAgB,KAAK,0CAA0C,SAAS,YAAY,KAAK,EAAE,CAAC;AAAA,EAC3G;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/sku-price.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\nimport { moneyFromCentsOptional } from \"../../utils/money.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const skuPriceSchema = z.object({\n profileId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n ),\n itemId: z.string().min(1).describe(\"SKU item identifier\"),\n});\n\nexport async function skuPriceHandler({ profileId, itemId }: z.infer<typeof skuPriceSchema>) {\n try {\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const price = await getSkuPrice(resolvedProfileId, itemId);\n\n return object(\n stripNulls({\n profile_id: resolvedProfileId,\n item_id: price.itemId,\n list_price: moneyFromCentsOptional(price.listPrice),\n cost_price: moneyFromCentsOptional(price.costPrice),\n base_price: moneyFromCentsOptional(price.basePrice),\n markup: price.markup,\n fixed_prices: Array.isArray(price.fixedPrices)\n ? price.fixedPrices.map((fixedPrice) =>\n stripNulls({\n min_quantity: fixedPrice.minQuantity,\n trade_policy_id: fixedPrice.tradePolicyId,\n date_range: fixedPrice.dateRange\n ? {\n from: fixedPrice.dateRange.from,\n to: fixedPrice.dateRange.to,\n }\n : undefined,\n value: moneyFromCentsOptional(fixedPrice.value),\n list_price: moneyFromCentsOptional(fixedPrice.listPrice),\n })\n )\n : undefined,\n })\n );\n } catch (err) {\n return error(formatVtexError(err, `Failed to fetch SKU price for item ${itemId}`));\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\r\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\r\nimport { moneyFromCentsOptional } from \"../../utils/money.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\r\n\r\nexport const skuPriceSchema = z.object({\r\n profileId: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\r\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\r\n ),\r\n itemId: z.string().min(1).describe(\"SKU item identifier\"),\r\n});\r\n\r\nexport async function skuPriceHandler({ profileId, itemId }: z.infer<typeof skuPriceSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const price = await getSkuPrice(resolvedProfileId, itemId);\r\n\r\n return object(\r\n stripNulls({\r\n profile_id: resolvedProfileId,\r\n item_id: price.itemId,\r\n list_price: moneyFromCentsOptional(price.listPrice),\r\n cost_price: moneyFromCentsOptional(price.costPrice),\r\n base_price: moneyFromCentsOptional(price.basePrice),\r\n markup: price.markup,\r\n fixed_prices: Array.isArray(price.fixedPrices)\r\n ? price.fixedPrices.map((fixedPrice) =>\r\n stripNulls({\r\n min_quantity: fixedPrice.minQuantity,\r\n trade_policy_id: fixedPrice.tradePolicyId,\r\n date_range: fixedPrice.dateRange\r\n ? {\r\n from: fixedPrice.dateRange.from,\r\n to: fixedPrice.dateRange.to,\r\n }\r\n : undefined,\r\n value: moneyFromCentsOptional(fixedPrice.value),\r\n list_price: moneyFromCentsOptional(fixedPrice.listPrice),\r\n })\r\n )\r\n : undefined,\r\n })\r\n );\r\n } catch (err) {\r\n return error(formatVtexError(err, `Failed to fetch SKU price for item ${itemId}`));\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAEvC,MAAM,i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,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/toggle-unlimited-quantity.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getInventoryByWarehouse,\n updateInventoryQuantity,\n} from \"../../services/vtex/vtex-logistics.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const toggleUnlimitedQuantitySchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU identifier.\"),\n warehouseId: z.string().min(1).describe(\"Warehouse identifier.\"),\n unlimitedQuantity: z\n .boolean()\n .describe(\"New unlimited availability mode for this SKU in the selected warehouse.\"),\n});\n\nexport async function toggleUnlimitedQuantityHandler({\n profileId,\n skuId,\n warehouseId,\n unlimitedQuantity,\n}: z.infer<typeof toggleUnlimitedQuantitySchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n const currentInventory = beforeInventory[0];\n\n if (!currentInventory) {\n throw new Error(`Inventory record not found for SKU ${skuId} in warehouse ${warehouseId}`);\n }\n\n await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {\n quantity: Number(currentInventory.totalQuantity ?? 0),\n unlimitedQuantity,\n });\n\n const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"toggle_unlimited_quantity\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Unlimited quantity mode updated successfully.\",\n before: currentInventory as Record<string, unknown>,\n after: (afterInventory[0] as Record<string, unknown> | undefined) ?? null,\n details: {\n sku_id: skuId,\n warehouse_id: warehouseId,\n unlimited_quantity: unlimitedQuantity,\n },\n });\n } catch (err) {\n return handleVtexWriteError(\n err,\n `Failed to update unlimited quantity mode for SKU ${skuId} in ${warehouseId}`\n );\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport {\r\n getInventoryByWarehouse,\r\n updateInventoryQuantity,\r\n} from \"../../services/vtex/vtex-logistics.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const toggleUnlimitedQuantitySchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"SKU identifier.\"),\r\n warehouseId: z.string().min(1).describe(\"Warehouse identifier.\"),\r\n unlimitedQuantity: z\r\n .boolean()\r\n .describe(\"New unlimited availability mode for this SKU in the selected warehouse.\"),\r\n});\r\n\r\nexport async function toggleUnlimitedQuantityHandler({\r\n profileId,\r\n skuId,\r\n warehouseId,\r\n unlimitedQuantity,\r\n}: z.infer<typeof toggleUnlimitedQuantitySchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\r\n const currentInventory = beforeInventory[0];\r\n\r\n if (!currentInventory) {\r\n throw new Error(`Inventory record not found for SKU ${skuId} in warehouse ${warehouseId}`);\r\n }\r\n\r\n await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {\r\n quantity: Number(currentInventory.totalQuantity ?? 0),\r\n unlimitedQuantity,\r\n });\r\n\r\n const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"toggle_unlimited_quantity\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"Unlimited quantity mode updated successfully.\",\r\n before: currentInventory as Record<string, unknown>,\r\n after: (afterInventory[0] as Record<string, unknown> | undefined) ?? null,\r\n details: {\r\n sku_id: skuId,\r\n warehouse_id: warehouseId,\r\n unlimited_quantity: unlimitedQuantity,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(\r\n err,\r\n `Failed to update unlimited quantity mode for SKU ${skuId} in ${warehouseId}`\r\n );\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,gCAAgC,EAAE,OAAO;AAAA,EACpD,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,iBAAiB;AAAA,EACnD,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,uBAAuB;AAAA,EAC/D,mBAAmB,EAChB,QAAQ,EACR,SAAS,yEAAyE;AACvF,CAAC;AAED,eAAsB,+BAA+B;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,kBAAkB,MAAM,wBAAwB,mBAAmB,OAAO,WAAW;AAC3F,UAAM,mBAAmB,gBAAgB,CAAC;AAE1C,QAAI,CAAC,kBAAkB;AACrB,YAAM,IAAI,MAAM,sCAAsC,KAAK,iBAAiB,WAAW,EAAE;AAAA,IAC3F;AAEA,UAAM,wBAAwB,mBAAmB,OAAO,aAAa;AAAA,MACnE,UAAU,OAAO,iBAAiB,iBAAiB,CAAC;AAAA,MACpD;AAAA,IACF,CAAC;AAED,UAAM,iBAAiB,MAAM,wBAAwB,mBAAmB,OAAO,WAAW;AAE1F,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAQ,eAAe,CAAC,KAA6C;AAAA,MACrE,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,oBAAoB;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,MACA,oDAAoD,KAAK,OAAO,WAAW;AAAA,IAC7E;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/update-inventory.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getInventoryByWarehouse,\n updateInventoryQuantity,\n} from \"../../services/vtex/vtex-logistics.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const updateInventorySchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU identifier\"),\n warehouseId: z.string().min(1).describe(\"Warehouse identifier\"),\n quantity: z.number().int().min(0).describe(\"Inventory quantity to set\"),\n unlimitedQuantity: z\n .boolean()\n .describe(\n \"When true, VTEX keeps the SKU available regardless of stock. This overwrites the current unlimited mode for the SKU in the selected warehouse.\"\n ),\n dateUtcOnBalanceSystem: z\n .string()\n .optional()\n .describe(\"Optional UTC timestamp for inventory update synchronization\"),\n});\n\nexport async function updateInventoryHandler({\n profileId,\n skuId,\n warehouseId,\n quantity,\n unlimitedQuantity,\n dateUtcOnBalanceSystem,\n}: z.infer<typeof updateInventorySchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n\n await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {\n quantity,\n unlimitedQuantity,\n dateUtcOnBalanceSystem,\n });\n\n const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"update_inventory\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Inventory quantity updated successfully.\",\n before: (beforeInventory[0] as Record<string, unknown> | undefined) ?? null,\n after: (afterInventory[0] as Record<string, unknown> | undefined) ?? null,\n details: {\n sku_id: skuId,\n warehouse_id: warehouseId,\n quantity,\n unlimited_quantity: unlimitedQuantity,\n },\n });\n } catch (err) {\n return handleVtexWriteError(\n err,\n `Failed to update inventory quantity for SKU ${skuId} in ${warehouseId}`\n );\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport {\r\n getInventoryByWarehouse,\r\n updateInventoryQuantity,\r\n} from \"../../services/vtex/vtex-logistics.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const updateInventorySchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"SKU identifier\"),\r\n warehouseId: z.string().min(1).describe(\"Warehouse identifier\"),\r\n quantity: z.number().int().min(0).describe(\"Inventory quantity to set\"),\r\n unlimitedQuantity: z\r\n .boolean()\r\n .describe(\r\n \"When true, VTEX keeps the SKU available regardless of stock. This overwrites the current unlimited mode for the SKU in the selected warehouse.\"\r\n ),\r\n dateUtcOnBalanceSystem: z\r\n .string()\r\n .optional()\r\n .describe(\"Optional UTC timestamp for inventory update synchronization\"),\r\n});\r\n\r\nexport async function updateInventoryHandler({\r\n profileId,\r\n skuId,\r\n warehouseId,\r\n quantity,\r\n unlimitedQuantity,\r\n dateUtcOnBalanceSystem,\r\n}: z.infer<typeof updateInventorySchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\r\n\r\n await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {\r\n quantity,\r\n unlimitedQuantity,\r\n dateUtcOnBalanceSystem,\r\n });\r\n\r\n const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"update_inventory\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"Inventory quantity updated successfully.\",\r\n before: (beforeInventory[0] as Record<string, unknown> | undefined) ?? null,\r\n after: (afterInventory[0] as Record<string, unknown> | undefined) ?? null,\r\n details: {\r\n sku_id: skuId,\r\n warehouse_id: warehouseId,\r\n quantity,\r\n unlimited_quantity: unlimitedQuantity,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(\r\n err,\r\n `Failed to update inventory quantity for SKU ${skuId} in ${warehouseId}`\r\n );\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,gBAAgB;AAAA,EAClD,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,sBAAsB;AAAA,EAC9D,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,SAAS,2BAA2B;AAAA,EACtE,mBAAmB,EAChB,QAAQ,EACR;AAAA,IACC;AAAA,EACF;AAAA,EACF,wBAAwB,EACrB,OAAO,EACP,SAAS,EACT,SAAS,6DAA6D;AAC3E,CAAC;AAED,eAAsB,uBAAuB;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA0C;AACxC,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,kBAAkB,MAAM,wBAAwB,mBAAmB,OAAO,WAAW;AAE3F,UAAM,wBAAwB,mBAAmB,OAAO,aAAa;AAAA,MACnE;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,iBAAiB,MAAM,wBAAwB,mBAAmB,OAAO,WAAW;AAE1F,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAS,gBAAgB,CAAC,KAA6C;AAAA,MACvE,OAAQ,eAAe,CAAC,KAA6C;AAAA,MACrE,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd;AAAA,QACA,oBAAoB;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,MACA,+CAA+C,KAAK,OAAO,WAAW;AAAA,IACxE;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/update-lead-time.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getInventoryByWarehouse,\n updateInventoryLeadTime,\n} from \"../../services/vtex/vtex-logistics.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const updateLeadTimeSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU identifier\"),\n warehouseId: z.string().min(1).describe(\"Warehouse identifier\"),\n leadTime: z\n .string()\n .min(1)\n .describe(\n \"Lead time value for the SKU in VTEX expected format (for example `1.00:00:00`). This overwrites the current lead time for the selected warehouse.\"\n ),\n});\n\nexport async function updateLeadTimeHandler({\n profileId,\n skuId,\n warehouseId,\n leadTime,\n}: z.infer<typeof updateLeadTimeSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n await updateInventoryLeadTime(resolvedProfileId, skuId, warehouseId, { leadTime });\n const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"update_lead_time\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Lead time updated successfully.\",\n before: (beforeInventory[0] as Record<string, unknown> | undefined) ?? null,\n after: (afterInventory[0] as Record<string, unknown> | undefined) ?? null,\n details: {\n sku_id: skuId,\n warehouse_id: warehouseId,\n lead_time: leadTime,\n },\n });\n } catch (err) {\n return handleVtexWriteError(\n err,\n `Failed to update lead time for SKU ${skuId} in ${warehouseId}`\n );\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport {\r\n getInventoryByWarehouse,\r\n updateInventoryLeadTime,\r\n} from \"../../services/vtex/vtex-logistics.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const updateLeadTimeSchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"SKU identifier\"),\r\n warehouseId: z.string().min(1).describe(\"Warehouse identifier\"),\r\n leadTime: z\r\n .string()\r\n .min(1)\r\n .describe(\r\n \"Lead time value for the SKU in VTEX expected format (for example `1.00:00:00`). This overwrites the current lead time for the selected warehouse.\"\r\n ),\r\n});\r\n\r\nexport async function updateLeadTimeHandler({\r\n profileId,\r\n skuId,\r\n warehouseId,\r\n leadTime,\r\n}: z.infer<typeof updateLeadTimeSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\r\n await updateInventoryLeadTime(resolvedProfileId, skuId, warehouseId, { leadTime });\r\n const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"update_lead_time\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"Lead time updated successfully.\",\r\n before: (beforeInventory[0] as Record<string, unknown> | undefined) ?? null,\r\n after: (afterInventory[0] as Record<string, unknown> | undefined) ?? null,\r\n details: {\r\n sku_id: skuId,\r\n warehouse_id: warehouseId,\r\n lead_time: leadTime,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(\r\n err,\r\n `Failed to update lead time for SKU ${skuId} in ${warehouseId}`\r\n );\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAA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["import { z } from \"zod\";\n\nimport {\n buildProductUpdatePayload,\n getProduct,\n updateProduct,\n} from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const updateProductBasicFieldsSchema = z\n .object({\n profileId: vtexProfileIdSchemaField,\n productId: z.string().min(1).describe(\"VTEX product identifier.\"),\n name: z.string().min(1).optional().describe(\"New product name.\"),\n categoryId: z.number().int().positive().optional().describe(\"New category identifier.\"),\n brandId: z.number().int().positive().optional().describe(\"New brand identifier.\"),\n description: z.string().optional().describe(\"New product description.\"),\n descriptionShort: z.string().optional().describe(\"New short description.\"),\n title: z.string().optional().describe(\"New SEO title.\"),\n linkId: z.string().optional().describe(\"New product slug.\"),\n refId: z.string().optional().describe(\"New internal reference code.\"),\n isVisible: z.boolean().optional().describe(\"Whether the product should remain visible in listings.\"),\n isActive: z.boolean().optional().describe(\"Whether the product should remain active.\"),\n keyWords: z.string().optional().describe(\"New keywords string.\"),\n releaseDate: z.string().optional().describe(\"New release date in ISO format.\"),\n metaTagDescription: z.string().optional().describe(\"New meta description.\"),\n showWithoutStock: z\n .boolean()\n .optional()\n .describe(\"Whether the product can stay visible without stock.\"),\n })\n .refine(\n (value) =>\n value.name !== undefined ||\n value.categoryId !== undefined ||\n value.brandId !== undefined ||\n value.description !== undefined ||\n value.descriptionShort !== undefined ||\n value.title !== undefined ||\n value.linkId !== undefined ||\n value.refId !== undefined ||\n value.isVisible !== undefined ||\n value.isActive !== undefined ||\n value.keyWords !== undefined ||\n value.releaseDate !== undefined ||\n value.metaTagDescription !== undefined ||\n value.showWithoutStock !== undefined,\n {\n message: \"At least one product field must be provided.\",\n path: [\"name\"],\n }\n );\n\nexport async function updateProductBasicFieldsHandler({\n profileId,\n productId,\n ...updates\n}: z.infer<typeof updateProductBasicFieldsSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeProduct = await getProduct(resolvedProfileId, productId);\n const payload = buildProductUpdatePayload(beforeProduct, updates);\n const afterProduct = await updateProduct(resolvedProfileId, productId, payload);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"update_product_basic_fields\",\n resourceId: productId,\n riskLevel: \"low\",\n message: \"Product fields updated successfully.\",\n before: beforeProduct,\n after: afterProduct,\n details: {\n product_id: productId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to update product ${productId}`);\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport {\r\n buildProductUpdatePayload,\r\n getProduct,\r\n updateProduct,\r\n} from \"../../services/vtex/vtex-catalog-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const updateProductBasicFieldsSchema = z\r\n .object({\r\n profileId: vtexProfileIdSchemaField,\r\n productId: z.string().min(1).describe(\"VTEX product identifier.\"),\r\n name: z.string().min(1).optional().describe(\"New product name.\"),\r\n categoryId: z.number().int().positive().optional().describe(\"New category identifier.\"),\r\n brandId: z.number().int().positive().optional().describe(\"New brand identifier.\"),\r\n description: z.string().optional().describe(\"New product description.\"),\r\n descriptionShort: z.string().optional().describe(\"New short description.\"),\r\n title: z.string().optional().describe(\"New SEO title.\"),\r\n linkId: z.string().optional().describe(\"New product slug.\"),\r\n refId: z.string().optional().describe(\"New internal reference code.\"),\r\n isVisible: z.boolean().optional().describe(\"Whether the product should remain visible in listings.\"),\r\n isActive: z.boolean().optional().describe(\"Whether the product should remain active.\"),\r\n keyWords: z.string().optional().describe(\"New keywords string.\"),\r\n releaseDate: z.string().optional().describe(\"New release date in ISO format.\"),\r\n metaTagDescription: z.string().optional().describe(\"New meta description.\"),\r\n showWithoutStock: z\r\n .boolean()\r\n .optional()\r\n .describe(\"Whether the product can stay visible without stock.\"),\r\n })\r\n .refine(\r\n (value) =>\r\n value.name !== undefined ||\r\n value.categoryId !== undefined ||\r\n value.brandId !== undefined ||\r\n value.description !== undefined ||\r\n value.descriptionShort !== undefined ||\r\n value.title !== undefined ||\r\n value.linkId !== undefined ||\r\n value.refId !== undefined ||\r\n value.isVisible !== undefined ||\r\n value.isActive !== undefined ||\r\n value.keyWords !== undefined ||\r\n value.releaseDate !== undefined ||\r\n value.metaTagDescription !== undefined ||\r\n value.showWithoutStock !== undefined,\r\n {\r\n message: \"At least one product field must be provided.\",\r\n path: [\"name\"],\r\n }\r\n );\r\n\r\nexport async function updateProductBasicFieldsHandler({\r\n profileId,\r\n productId,\r\n ...updates\r\n}: z.infer<typeof updateProductBasicFieldsSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforeProduct = await getProduct(resolvedProfileId, productId);\r\n const payload = buildProductUpdatePayload(beforeProduct, updates);\r\n const afterProduct = await updateProduct(resolvedProfileId, productId, payload);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"update_product_basic_fields\",\r\n resourceId: productId,\r\n riskLevel: \"low\",\r\n message: \"Product fields updated successfully.\",\r\n before: beforeProduct,\r\n after: afterProduct,\r\n details: {\r\n product_id: productId,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(err, `Failed to update product ${productId}`);\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,WAAW;AAAA,EACX,WAAW,EAA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,aAAa,UACnB,MAAM,gBAAgB,UACtB,MAAM,uBAAuB,UAC7B,MAAM,qBAAqB;AAAA,EAC7B;AAAA,IACE,SAAS;AAAA,IACT,MAAM,CAAC,MAAM;AAAA,EACf;AACF;AAEF,eAAsB,gCAAgC;AAAA,EACpD;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAmD;AACjD,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,gBAAgB,MAAM,WAAW,mBAAmB,SAAS;AACnE,UAAM,UAAU,0BAA0B,eAAe,OAAO;AAChE,UAAM,eAAe,MAAM,cAAc,mBAAmB,WAAW,OAAO;AAE9E,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,YAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,4BAA4B,SAAS,EAAE;AAAA,EAC1E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/update-sku-basic-fields.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n buildSkuUpdatePayload,\n createSkuEan,\n deleteAllSkuEans,\n getSku,\n getSkuEans,\n updateSku,\n} from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const updateSkuBasicFieldsSchema = z\n .object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"VTEX SKU identifier.\"),\n name: z.string().min(1).optional().describe(\"New SKU name.\"),\n refId: z.string().optional().describe(\"New SKU reference code.\"),\n ean: z\n .string()\n .optional()\n .describe(\"New EAN. When informed, existing EAN values are replaced with this one.\"),\n packagedHeight: z.number().nonnegative().optional().describe(\"Packaged height.\"),\n packagedLength: z.number().nonnegative().optional().describe(\"Packaged length.\"),\n packagedWidth: z.number().nonnegative().optional().describe(\"Packaged width.\"),\n packagedWeightKg: z.number().nonnegative().optional().describe(\"Packaged weight in kg.\"),\n height: z.number().nonnegative().optional().describe(\"Physical height.\"),\n length: z.number().nonnegative().optional().describe(\"Physical length.\"),\n width: z.number().nonnegative().optional().describe(\"Physical width.\"),\n weightKg: z.number().nonnegative().optional().describe(\"Physical weight in kg.\"),\n measurementUnit: z.string().optional().describe(\"Measurement unit.\"),\n unitMultiplier: z.number().positive().optional().describe(\"Unit multiplier.\"),\n manufacturerCode: z.string().optional().describe(\"Manufacturer code.\"),\n commercialConditionId: z.number().int().positive().optional().describe(\"Commercial condition ID.\"),\n isActive: z.boolean().optional().describe(\"Whether the SKU should remain active.\"),\n activateIfPossible: z\n .boolean()\n .optional()\n .describe(\"Whether VTEX should auto-activate the SKU when possible.\"),\n })\n .refine(\n (value) =>\n value.name !== undefined ||\n value.refId !== undefined ||\n value.ean !== undefined ||\n value.packagedHeight !== undefined ||\n value.packagedLength !== undefined ||\n value.packagedWidth !== undefined ||\n value.packagedWeightKg !== undefined ||\n value.height !== undefined ||\n value.length !== undefined ||\n value.width !== undefined ||\n value.weightKg !== undefined ||\n value.measurementUnit !== undefined ||\n value.unitMultiplier !== undefined ||\n value.manufacturerCode !== undefined ||\n value.commercialConditionId !== undefined ||\n value.isActive !== undefined ||\n value.activateIfPossible !== undefined,\n {\n message: \"At least one SKU field must be provided.\",\n path: [\"name\"],\n }\n );\n\nexport async function updateSkuBasicFieldsHandler({\n profileId,\n skuId,\n ean,\n ...updates\n}: z.infer<typeof updateSkuBasicFieldsSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeSku = await getSku(resolvedProfileId, skuId);\n const beforeEans = await getSkuEans(resolvedProfileId, skuId);\n const payload = buildSkuUpdatePayload(beforeSku, updates);\n const afterSku = await updateSku(resolvedProfileId, skuId, payload);\n\n if (ean !== undefined) {\n await deleteAllSkuEans(resolvedProfileId, skuId);\n if (ean.trim()) {\n await createSkuEan(resolvedProfileId, skuId, ean.trim());\n }\n }\n\n const afterEans = await getSkuEans(resolvedProfileId, skuId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"update_sku_basic_fields\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"SKU fields updated successfully.\",\n before: {\n ...beforeSku,\n Eans: beforeEans,\n },\n after: {\n ...afterSku,\n Eans: afterEans,\n },\n details: {\n sku_id: skuId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to update SKU ${skuId}`);\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport {\r\n buildSkuUpdatePayload,\r\n createSkuEan,\r\n deleteAllSkuEans,\r\n getSku,\r\n getSkuEans,\r\n updateSku,\r\n} from \"../../services/vtex/vtex-catalog-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nexport const updateSkuBasicFieldsSchema = z\r\n .object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"VTEX SKU identifier.\"),\r\n name: z.string().min(1).optional().describe(\"New SKU name.\"),\r\n refId: z.string().optional().describe(\"New SKU reference code.\"),\r\n ean: z\r\n .string()\r\n .optional()\r\n .describe(\"New EAN. When informed, existing EAN values are replaced with this one.\"),\r\n packagedHeight: z.number().nonnegative().optional().describe(\"Packaged height.\"),\r\n packagedLength: z.number().nonnegative().optional().describe(\"Packaged length.\"),\r\n packagedWidth: z.number().nonnegative().optional().describe(\"Packaged width.\"),\r\n packagedWeightKg: z.number().nonnegative().optional().describe(\"Packaged weight in kg.\"),\r\n height: z.number().nonnegative().optional().describe(\"Physical height.\"),\r\n length: z.number().nonnegative().optional().describe(\"Physical length.\"),\r\n width: z.number().nonnegative().optional().describe(\"Physical width.\"),\r\n weightKg: z.number().nonnegative().optional().describe(\"Physical weight in kg.\"),\r\n measurementUnit: z.string().optional().describe(\"Measurement unit.\"),\r\n unitMultiplier: z.number().positive().optional().describe(\"Unit multiplier.\"),\r\n manufacturerCode: z.string().optional().describe(\"Manufacturer code.\"),\r\n commercialConditionId: z.number().int().positive().optional().describe(\"Commercial condition ID.\"),\r\n isActive: z.boolean().optional().describe(\"Whether the SKU should remain active.\"),\r\n activateIfPossible: z\r\n .boolean()\r\n .optional()\r\n .describe(\"Whether VTEX should auto-activate the SKU when possible.\"),\r\n })\r\n .refine(\r\n (value) =>\r\n value.name !== undefined ||\r\n value.refId !== undefined ||\r\n value.ean !== undefined ||\r\n value.packagedHeight !== undefined ||\r\n value.packagedLength !== undefined ||\r\n value.packagedWidth !== undefined ||\r\n value.packagedWeightKg !== undefined ||\r\n value.height !== undefined ||\r\n value.length !== undefined ||\r\n value.width !== undefined ||\r\n value.weightKg !== undefined ||\r\n value.measurementUnit !== undefined ||\r\n value.unitMultiplier !== undefined ||\r\n value.manufacturerCode !== undefined ||\r\n value.commercialConditionId !== undefined ||\r\n value.isActive !== undefined ||\r\n value.activateIfPossible !== undefined,\r\n {\r\n message: \"At least one SKU field must be provided.\",\r\n path: [\"name\"],\r\n }\r\n );\r\n\r\nexport async function updateSkuBasicFieldsHandler({\r\n profileId,\r\n skuId,\r\n ean,\r\n ...updates\r\n}: z.infer<typeof updateSkuBasicFieldsSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforeSku = await getSku(resolvedProfileId, skuId);\r\n const beforeEans = await getSkuEans(resolvedProfileId, skuId);\r\n const payload = buildSkuUpdatePayload(beforeSku, updates);\r\n const afterSku = await updateSku(resolvedProfileId, skuId, payload);\r\n\r\n if (ean !== undefined) {\r\n await deleteAllSkuEans(resolvedProfileId, skuId);\r\n if (ean.trim()) {\r\n await createSkuEan(resolvedProfileId, skuId, ean.trim());\r\n }\r\n }\r\n\r\n const afterEans = await getSkuEans(resolvedProfileId, skuId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"update_sku_basic_fields\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"SKU fields updated successfully.\",\r\n before: {\r\n ...beforeSku,\r\n Eans: beforeEans,\r\n },\r\n after: {\r\n ...afterSku,\r\n Eans: afterEans,\r\n },\r\n details: {\r\n sku_id: skuId,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(err, `Failed to update SKU ${skuId}`);\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,6BAA6B,EACvC,OAAO;AAAA,EACN,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,sBAAsB;AAAA,EACxD,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,eAAe;AAAA,EAC3D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,yBAAyB;AAAA,EAC/D,KAAK,EACF,OAAO,EACP,SAAS,EACT,SAAS,yEAAyE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E;AAAA,EAClE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/update-sku-price.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\nimport { updateSkuPrice } from \"../../services/vtex/vtex-pricing-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nconst fixedPriceSchema = z.object({\n tradePolicyId: z\n .string()\n .min(1)\n .describe(\"Trade policy or price table identifier for the fixed price.\"),\n value: z.number().nonnegative().describe(\"Fixed selling price.\"),\n listPrice: z.number().nonnegative().optional().describe(\"Optional list price for the fixed price.\"),\n minQuantity: z.number().int().positive().describe(\"Minimum quantity required for this fixed price.\"),\n dateRange: z\n .object({\n from: z.string().min(1).describe(\"RFC3339 start timestamp for the fixed price.\"),\n to: z.string().min(1).describe(\"RFC3339 end timestamp for the fixed price.\"),\n })\n .optional()\n .describe(\"Optional validity window for the fixed price.\"),\n});\n\nexport const updateSkuPriceSchema = z\n .object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU item identifier used by VTEX Pricing.\"),\n basePrice: z.number().nonnegative().optional().describe(\"New base price for the SKU.\"),\n costPrice: z.number().nonnegative().optional().describe(\"New cost price for the SKU.\"),\n markup: z.number().nonnegative().optional().describe(\"New markup percentage for the SKU.\"),\n listPrice: z.number().nonnegative().optional().describe(\"New list price for the SKU.\"),\n fixedPrices: z\n .array(fixedPriceSchema)\n .optional()\n .describe(\n \"Optional full fixed price list to persist together with the base price update. VTEX overwrites any existing fixed prices not included here.\"\n ),\n })\n .refine(\n (value) =>\n value.basePrice !== undefined ||\n value.costPrice !== undefined ||\n value.markup !== undefined ||\n value.listPrice !== undefined ||\n value.fixedPrices !== undefined,\n {\n message: \"At least one pricing field must be provided.\",\n path: [\"basePrice\"],\n }\n );\n\nexport async function updateSkuPriceHandler({\n profileId,\n skuId,\n basePrice,\n costPrice,\n markup,\n listPrice,\n fixedPrices,\n}: z.infer<typeof updateSkuPriceSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforePrice = await getSkuPrice(resolvedProfileId, skuId);\n\n await updateSkuPrice(resolvedProfileId, skuId, {\n basePrice,\n costPrice,\n markup,\n listPrice,\n fixedPrices,\n });\n\n const afterPrice = await getSkuPrice(resolvedProfileId, skuId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"update_sku_price\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"SKU price updated successfully.\",\n before: beforePrice as unknown as Record<string, unknown>,\n after: afterPrice as unknown as Record<string, unknown>,\n details: {\n sku_id: skuId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to update price for SKU ${skuId}`);\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\r\nimport { updateSkuPrice } from \"../../services/vtex/vtex-pricing-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nconst fixedPriceSchema = z.object({\r\n tradePolicyId: z\r\n .string()\r\n .min(1)\r\n .describe(\"Trade policy or price table identifier for the fixed price.\"),\r\n value: z.number().nonnegative().describe(\"Fixed selling price.\"),\r\n listPrice: z.number().nonnegative().optional().describe(\"Optional list price for the fixed price.\"),\r\n minQuantity: z.number().int().positive().describe(\"Minimum quantity required for this fixed price.\"),\r\n dateRange: z\r\n .object({\r\n from: z.string().min(1).describe(\"RFC3339 start timestamp for the fixed price.\"),\r\n to: z.string().min(1).describe(\"RFC3339 end timestamp for the fixed price.\"),\r\n })\r\n .optional()\r\n .describe(\"Optional validity window for the fixed price.\"),\r\n});\r\n\r\nexport const updateSkuPriceSchema = z\r\n .object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"SKU item identifier used by VTEX Pricing.\"),\r\n basePrice: z.number().nonnegative().optional().describe(\"New base price for the SKU.\"),\r\n costPrice: z.number().nonnegative().optional().describe(\"New cost price for the SKU.\"),\r\n markup: z.number().nonnegative().optional().describe(\"New markup percentage for the SKU.\"),\r\n listPrice: z.number().nonnegative().optional().describe(\"New list price for the SKU.\"),\r\n fixedPrices: z\r\n .array(fixedPriceSchema)\r\n .optional()\r\n .describe(\r\n \"Optional full fixed price list to persist together with the base price update. VTEX overwrites any existing fixed prices not included here.\"\r\n ),\r\n })\r\n .refine(\r\n (value) =>\r\n value.basePrice !== undefined ||\r\n value.costPrice !== undefined ||\r\n value.markup !== undefined ||\r\n value.listPrice !== undefined ||\r\n value.fixedPrices !== undefined,\r\n {\r\n message: \"At least one pricing field must be provided.\",\r\n path: [\"basePrice\"],\r\n }\r\n );\r\n\r\nexport async function updateSkuPriceHandler({\r\n profileId,\r\n skuId,\r\n basePrice,\r\n costPrice,\r\n markup,\r\n listPrice,\r\n fixedPrices,\r\n}: z.infer<typeof updateSkuPriceSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforePrice = await getSkuPrice(resolvedProfileId, skuId);\r\n\r\n await updateSkuPrice(resolvedProfileId, skuId, {\r\n basePrice,\r\n costPrice,\r\n markup,\r\n listPrice,\r\n fixedPrices,\r\n });\r\n\r\n const afterPrice = await getSkuPrice(resolvedProfileId, skuId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"update_sku_price\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"SKU price updated successfully.\",\r\n before: beforePrice as unknown as Record<string, unknown>,\r\n after: afterPrice as unknown as Record<string, unknown>,\r\n details: {\r\n sku_id: skuId,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(err, `Failed to update price for SKU ${skuId}`);\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,eAAe,EACZ,OAAO,EACP,IAAI,CAAC,EACL,SAAS,6DAA6D;AAAA,EACzE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,sBAAsB;AAAA,EAC/D,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,0CAA0C;AAAA,EAClG,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,iDAAiD;AAAA,EACnG,WAAW,EACR,OAAO;AAAA,IACN,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,8CAA8C;AAAA,IAC/E,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,4CAA4C;AAAA,EAC7E,CAAC,EACA,SAAS,EACT,SAAS,+CAA+C;AAC7D,CAAC;AAEM,MAAM,uBAAuB,EACjC,OAAO;AAAA,EACN,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,2CAA2C;AAAA,EAC7E,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,6BAA6B;AAAA,EACrF,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,6BAA6B;AAAA,EACrF,QAAQ,EAAE,OAAO,EAAE,YA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 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/upsert-fixed-price.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\nimport { upsertFixedPricesForPriceTable } from \"../../services/vtex/vtex-pricing-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nconst fixedPriceEntrySchema = z.object({\n value: z.number().nonnegative().describe(\"Fixed selling price.\"),\n listPrice: z.number().nonnegative().optional().describe(\"Optional fixed list price.\"),\n minQuantity: z.number().int().positive().describe(\"Minimum quantity for the fixed price.\"),\n dateRange: z\n .object({\n from: z.string().min(1).describe(\"RFC3339 start timestamp.\"),\n to: z.string().min(1).describe(\"RFC3339 end timestamp.\"),\n })\n .optional()\n .describe(\"Optional validity window for this fixed price.\"),\n});\n\nexport const upsertFixedPriceSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU item identifier used by VTEX Pricing.\"),\n priceTableId: z.string().min(1).describe(\"Trade policy or price table identifier.\"),\n fixedPrices: z\n .array(fixedPriceEntrySchema)\n .min(1)\n .describe(\"Fixed prices to create or replace inside the selected price table.\"),\n});\n\nexport async function upsertFixedPriceHandler({\n profileId,\n skuId,\n priceTableId,\n fixedPrices,\n}: z.infer<typeof upsertFixedPriceSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforePrice = await getSkuPrice(resolvedProfileId, skuId);\n\n await upsertFixedPricesForPriceTable(\n resolvedProfileId,\n skuId,\n priceTableId,\n fixedPrices\n );\n\n const afterPrice = await getSkuPrice(resolvedProfileId, skuId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"upsert_fixed_price\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Fixed prices updated successfully for the selected price table.\",\n before: beforePrice as unknown as Record<string, unknown>,\n after: afterPrice as unknown as Record<string, unknown>,\n details: {\n sku_id: skuId,\n price_table_id: priceTableId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(\n err,\n `Failed to update fixed prices for SKU ${skuId} on price table ${priceTableId}`\n );\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\r\n\r\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\r\nimport { upsertFixedPricesForPriceTable } from \"../../services/vtex/vtex-pricing-write.js\";\r\nimport {\r\n buildWriteSuccessResponse,\r\n handleVtexWriteError,\r\n resolveVtexWriteProfile,\r\n vtexProfileIdSchemaField,\r\n} from \"./write-helpers.js\";\r\n\r\nconst fixedPriceEntrySchema = z.object({\r\n value: z.number().nonnegative().describe(\"Fixed selling price.\"),\r\n listPrice: z.number().nonnegative().optional().describe(\"Optional fixed list price.\"),\r\n minQuantity: z.number().int().positive().describe(\"Minimum quantity for the fixed price.\"),\r\n dateRange: z\r\n .object({\r\n from: z.string().min(1).describe(\"RFC3339 start timestamp.\"),\r\n to: z.string().min(1).describe(\"RFC3339 end timestamp.\"),\r\n })\r\n .optional()\r\n .describe(\"Optional validity window for this fixed price.\"),\r\n});\r\n\r\nexport const upsertFixedPriceSchema = z.object({\r\n profileId: vtexProfileIdSchemaField,\r\n skuId: z.string().min(1).describe(\"SKU item identifier used by VTEX Pricing.\"),\r\n priceTableId: z.string().min(1).describe(\"Trade policy or price table identifier.\"),\r\n fixedPrices: z\r\n .array(fixedPriceEntrySchema)\r\n .min(1)\r\n .describe(\"Fixed prices to create or replace inside the selected price table.\"),\r\n});\r\n\r\nexport async function upsertFixedPriceHandler({\r\n profileId,\r\n skuId,\r\n priceTableId,\r\n fixedPrices,\r\n}: z.infer<typeof upsertFixedPriceSchema>) {\r\n try {\r\n const profileResolution = await resolveVtexWriteProfile(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const beforePrice = await getSkuPrice(resolvedProfileId, skuId);\r\n\r\n await upsertFixedPricesForPriceTable(\r\n resolvedProfileId,\r\n skuId,\r\n priceTableId,\r\n fixedPrices\r\n );\r\n\r\n const afterPrice = await getSkuPrice(resolvedProfileId, skuId);\r\n\r\n return buildWriteSuccessResponse({\r\n profileId: resolvedProfileId,\r\n operation: \"upsert_fixed_price\",\r\n resourceId: skuId,\r\n riskLevel: \"low\",\r\n message: \"Fixed prices updated successfully for the selected price table.\",\r\n before: beforePrice as unknown as Record<string, unknown>,\r\n after: afterPrice as unknown as Record<string, unknown>,\r\n details: {\r\n sku_id: skuId,\r\n price_table_id: priceTableId,\r\n },\r\n });\r\n } catch (err) {\r\n return handleVtexWriteError(\r\n err,\r\n `Failed to update fixed prices for SKU ${skuId} on price table ${priceTableId}`\r\n );\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAC5B,SAAS,sCAAsC;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,sBAAsB;AAAA,EAC/D,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,4BAA4B;AAAA,EACpF,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,uCAAuC;AAAA,EACzF,WAAW,EACR,OAAO;AAAA,IACN,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,0BAA0B;AAAA,IAC3D,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,wBAAwB;AAAA,EACzD,CAAC,EACA,SAAS,EACT,SAAS,gDAAgD;AAC9D,CAAC;AAEM,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,2CAA2C;AAAA,EAC7E,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,yCAAyC;AAAA,EAClF,aAAa,EACV,MAAM,qBAAqB,EAC3B,IAAI,CAAC,EACL,SAAS,oEAAoE;AAClF,CAAC;AAED,eAAsB,wBAAwB;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA2C;AACzC,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,cAAc,MAAM,YAAY,mBAAmB,KAAK;AAE9D,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,UAAM,aAAa,MAAM,YAAY,mBAAmB,KAAK;AAE7D,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,gBAAgB;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,MACA,yCAAyC,KAAK,mBAAmB,YAAY;AAAA,IAC/E;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/warehouse-inventory.ts"],
|
|
4
|
-
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { getInventoryByWarehouse } from \"../../services/vtex/vtex-logistics.js\";\nimport { stripNulls } from \"../../utils/strip-payload.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const warehouseInventorySchema = z.object({\n profileId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\n ),\n skuId: z.string().min(1).describe(\"SKU identifier\"),\n warehouseId: z.string().min(1).describe(\"Warehouse identifier\"),\n});\n\nexport async function warehouseInventoryHandler({\n profileId,\n skuId,\n warehouseId,\n}: z.infer<typeof warehouseInventorySchema>) {\n try {\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const inventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n\n const normalizedInventory = inventory.map((item) => ({\n sku_id: item.skuId,\n warehouse_id: item.warehouseId,\n total_quantity: item.totalQuantity,\n reserved_quantity: item.reservedQuantity,\n available_quantity: item.availableQuantity,\n is_unlimited: item.isUnlimited,\n keep_selling_after_expiration: item.keepSellingAfterExpiration,\n }));\n\n return object(\n stripNulls({\n profile_id: resolvedProfileId,\n sku_id: skuId,\n warehouse_id: warehouseId,\n inventory: normalizedInventory,\n })\n );\n } catch (err) {\n return error(\n formatVtexError(err, `Failed to fetch inventory for SKU ${skuId} in warehouse ${warehouseId}`)\n );\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { error, object } from \"mcp-use/server\";\r\nimport { z } from \"zod\";\r\n\r\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\r\nimport { getInventoryByWarehouse } from \"../../services/vtex/vtex-logistics.js\";\r\nimport { stripNulls } from \"../../utils/strip-payload.js\";\r\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\r\n\r\nexport const warehouseInventorySchema = z.object({\r\n profileId: z\r\n .string()\r\n .trim()\r\n .min(1)\r\n .optional()\r\n .describe(\r\n \"Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles.\"\r\n ),\r\n skuId: z.string().min(1).describe(\"SKU identifier\"),\r\n warehouseId: z.string().min(1).describe(\"Warehouse identifier\"),\r\n});\r\n\r\nexport async function warehouseInventoryHandler({\r\n profileId,\r\n skuId,\r\n warehouseId,\r\n}: z.infer<typeof warehouseInventorySchema>) {\r\n try {\r\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\r\n if (!profileResolution.ok) {\r\n return profileResolution.response;\r\n }\r\n\r\n const resolvedProfileId = profileResolution.value.profileId;\r\n const inventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\r\n\r\n const normalizedInventory = inventory.map((item) => ({\r\n sku_id: item.skuId,\r\n warehouse_id: item.warehouseId,\r\n total_quantity: item.totalQuantity,\r\n reserved_quantity: item.reservedQuantity,\r\n available_quantity: item.availableQuantity,\r\n is_unlimited: item.isUnlimited,\r\n keep_selling_after_expiration: item.keepSellingAfterExpiration,\r\n }));\r\n\r\n return object(\r\n stripNulls({\r\n profile_id: resolvedProfileId,\r\n sku_id: skuId,\r\n warehouse_id: warehouseId,\r\n inventory: normalizedInventory,\r\n })\r\n );\r\n } catch (err) {\r\n return error(\r\n formatVtexError(err, `Failed to fetch inventory for SKU ${skuId} in warehouse ${warehouseId}`)\r\n );\r\n }\r\n}\r\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AACxC,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAEvC,MAAM,2BAA2B,EAAE,OAAO;AAAA,EAC/C,WAAW,EACR,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,gBAAgB;AAAA,EAClD,aAAa,E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