@yoryoboy/bi-mcp 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +38 -427
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/index.js +302 -2
  4. package/dist/index.js.map +2 -2
  5. package/dist/mcp-use.json +2 -2
  6. package/dist/src/services/search-console/search-console-utils.js +275 -0
  7. package/dist/src/services/search-console/search-console-utils.js.map +7 -0
  8. package/dist/src/services/vtex/vtex-catalog-write.js +233 -0
  9. package/dist/src/services/vtex/vtex-catalog-write.js.map +7 -0
  10. package/dist/src/services/vtex/vtex-orders-write.js +152 -0
  11. package/dist/src/services/vtex/vtex-orders-write.js.map +7 -0
  12. package/dist/src/services/vtex/vtex-pricing-write.js +24 -0
  13. package/dist/src/services/vtex/vtex-pricing-write.js.map +7 -0
  14. package/dist/src/services/vtex/vtex-write.js +38 -0
  15. package/dist/src/services/vtex/vtex-write.js.map +7 -0
  16. package/dist/src/tools/search-console/country-breakdown.js +1 -1
  17. package/dist/src/tools/search-console/country-breakdown.js.map +1 -1
  18. package/dist/src/tools/search-console/device-breakdown.js +1 -1
  19. package/dist/src/tools/search-console/device-breakdown.js.map +1 -1
  20. package/dist/src/tools/search-console/high-impression-low-click-queries.js +1 -1
  21. package/dist/src/tools/search-console/high-impression-low-click-queries.js.map +1 -1
  22. package/dist/src/tools/search-console/list-accessible-sites.js +1 -1
  23. package/dist/src/tools/search-console/list-accessible-sites.js.map +1 -1
  24. package/dist/src/tools/search-console/low-ctr-opportunities.js +1 -1
  25. package/dist/src/tools/search-console/low-ctr-opportunities.js.map +1 -1
  26. package/dist/src/tools/search-console/page-performance.js +1 -1
  27. package/dist/src/tools/search-console/page-performance.js.map +1 -1
  28. package/dist/src/tools/search-console/product-demand-low-capture-queries.js +1 -1
  29. package/dist/src/tools/search-console/product-demand-low-capture-queries.js.map +1 -1
  30. package/dist/src/tools/search-console/query-page-matrix.js +1 -1
  31. package/dist/src/tools/search-console/query-page-matrix.js.map +1 -1
  32. package/dist/src/tools/search-console/query-performance.js +1 -1
  33. package/dist/src/tools/search-console/query-performance.js.map +1 -1
  34. package/dist/src/tools/search-console/quick-win-opportunities.js +1 -1
  35. package/dist/src/tools/search-console/quick-win-opportunities.js.map +1 -1
  36. package/dist/src/tools/search-console/rising-non-brand-queries.js +1 -1
  37. package/dist/src/tools/search-console/rising-non-brand-queries.js.map +1 -1
  38. package/dist/src/tools/search-console/search-performance.js +1 -1
  39. package/dist/src/tools/search-console/search-performance.js.map +1 -1
  40. package/dist/src/tools/search-console/site-context.js +1 -1
  41. package/dist/src/tools/search-console/site-context.js.map +1 -1
  42. package/dist/src/tools/search-console/visibility-declines.js +1 -1
  43. package/dist/src/tools/search-console/visibility-declines.js.map +1 -1
  44. package/dist/src/tools/vtex/activate-sku.js +53 -0
  45. package/dist/src/tools/vtex/activate-sku.js.map +7 -0
  46. package/dist/src/tools/vtex/add-order-tracking.js +103 -0
  47. package/dist/src/tools/vtex/add-order-tracking.js.map +7 -0
  48. package/dist/src/tools/vtex/associate-specification.js +60 -0
  49. package/dist/src/tools/vtex/associate-specification.js.map +7 -0
  50. package/dist/src/tools/vtex/attach-catalog-image.js +63 -0
  51. package/dist/src/tools/vtex/attach-catalog-image.js.map +7 -0
  52. package/dist/src/tools/vtex/cancel-order.js +67 -0
  53. package/dist/src/tools/vtex/cancel-order.js.map +7 -0
  54. package/dist/src/tools/vtex/create-brand.js +69 -0
  55. package/dist/src/tools/vtex/create-brand.js.map +7 -0
  56. package/dist/src/tools/vtex/create-category.js +81 -0
  57. package/dist/src/tools/vtex/create-category.js.map +7 -0
  58. package/dist/src/tools/vtex/create-product-with-sku.js +120 -0
  59. package/dist/src/tools/vtex/create-product-with-sku.js.map +7 -0
  60. package/dist/src/tools/vtex/create-product.js +111 -0
  61. package/dist/src/tools/vtex/create-product.js.map +7 -0
  62. package/dist/src/tools/vtex/create-sku.js +103 -0
  63. package/dist/src/tools/vtex/create-sku.js.map +7 -0
  64. package/dist/src/tools/vtex/create-specification-value.js +53 -0
  65. package/dist/src/tools/vtex/create-specification-value.js.map +7 -0
  66. package/dist/src/tools/vtex/create-specification.js +85 -0
  67. package/dist/src/tools/vtex/create-specification.js.map +7 -0
  68. package/dist/src/tools/vtex/deactivate-sku.js +53 -0
  69. package/dist/src/tools/vtex/deactivate-sku.js.map +7 -0
  70. package/dist/src/tools/vtex/delete-fixed-price.js +53 -0
  71. package/dist/src/tools/vtex/delete-fixed-price.js.map +7 -0
  72. package/dist/src/tools/vtex/index.js +20 -0
  73. package/dist/src/tools/vtex/index.js.map +2 -2
  74. package/dist/src/tools/vtex/invoice-order.js +84 -0
  75. package/dist/src/tools/vtex/invoice-order.js.map +7 -0
  76. package/dist/src/tools/vtex/toggle-unlimited-quantity.js +65 -0
  77. package/dist/src/tools/vtex/toggle-unlimited-quantity.js.map +7 -0
  78. package/dist/src/tools/vtex/update-inventory.js +34 -19
  79. package/dist/src/tools/vtex/update-inventory.js.map +2 -2
  80. package/dist/src/tools/vtex/update-lead-time.js +34 -17
  81. package/dist/src/tools/vtex/update-lead-time.js.map +2 -2
  82. package/dist/src/tools/vtex/update-product-basic-fields.js +71 -0
  83. package/dist/src/tools/vtex/update-product-basic-fields.js.map +7 -0
  84. package/dist/src/tools/vtex/update-sku-basic-fields.js +92 -0
  85. package/dist/src/tools/vtex/update-sku-basic-fields.js.map +7 -0
  86. package/dist/src/tools/vtex/update-sku-price.js +81 -0
  87. package/dist/src/tools/vtex/update-sku-price.js.map +7 -0
  88. package/dist/src/tools/vtex/upsert-fixed-price.js +69 -0
  89. package/dist/src/tools/vtex/upsert-fixed-price.js.map +7 -0
  90. package/dist/src/tools/vtex/write-helpers.js +73 -0
  91. package/dist/src/tools/vtex/write-helpers.js.map +7 -0
  92. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/tools/vtex/update-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 { updateInventoryQuantity } from \"../../services/vtex/vtex-logistics.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const updateInventorySchema = 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 quantity: z.number().int().min(0).describe(\"Inventory quantity to set\"),\n unlimitedQuantity: z\n .boolean()\n .describe(\"When true, SKU remains available regardless of stock quantity\"),\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 resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n\n await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {\n quantity,\n unlimitedQuantity,\n dateUtcOnBalanceSystem,\n });\n\n return object({\n success: true,\n profile_id: resolvedProfileId,\n sku_id: skuId,\n warehouse_id: warehouseId,\n quantity,\n unlimited_quantity: unlimitedQuantity,\n message: \"Inventory quantity updated successfully\",\n });\n } catch (err) {\n return error(\n formatVtexError(err, `Failed to update inventory quantity for SKU ${skuId} in ${warehouseId}`)\n );\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AACxC,SAAS,qCAAqC;AAEvC,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,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,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,SAAS,+DAA+D;AAAA,EAC3E,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,8BAA8B,SAAS;AACvE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAElD,UAAM,wBAAwB,mBAAmB,OAAO,aAAa;AAAA,MACnE;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,OAAO;AAAA,MACZ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,cAAc;AAAA,MACd;AAAA,MACA,oBAAoB;AAAA,MACpB,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,gBAAgB,KAAK,+CAA+C,KAAK,OAAO,WAAW,EAAE;AAAA,IAC/F;AAAA,EACF;AACF;",
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"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA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AAA,MACA,+CAA+C,KAAK,OAAO,WAAW;AAAA,IACxE;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,15 +1,21 @@
1
- import { error, object } from "mcp-use/server";
2
1
  import { z } from "zod";
3
- import { formatVtexError } from "../../services/vtex/vtex-api.js";
4
- import { updateInventoryLeadTime } from "../../services/vtex/vtex-logistics.js";
5
- import { resolveVtexProfileOrSelection } from "./profile-resolution.js";
2
+ import {
3
+ getInventoryByWarehouse,
4
+ updateInventoryLeadTime
5
+ } from "../../services/vtex/vtex-logistics.js";
6
+ import {
7
+ buildWriteSuccessResponse,
8
+ handleVtexWriteError,
9
+ resolveVtexWriteProfile,
10
+ vtexProfileIdSchemaField
11
+ } from "./write-helpers.js";
6
12
  const updateLeadTimeSchema = z.object({
7
- profileId: z.string().trim().min(1).optional().describe(
8
- "Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles."
9
- ),
13
+ profileId: vtexProfileIdSchemaField,
10
14
  skuId: z.string().min(1).describe("SKU identifier"),
11
15
  warehouseId: z.string().min(1).describe("Warehouse identifier"),
12
- leadTime: z.string().min(1).describe("Lead time value for the SKU in VTEX expected format (e.g. 1.00:00:00)")
16
+ leadTime: z.string().min(1).describe(
17
+ "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."
18
+ )
13
19
  });
14
20
  async function updateLeadTimeHandler({
15
21
  profileId,
@@ -18,22 +24,33 @@ async function updateLeadTimeHandler({
18
24
  leadTime
19
25
  }) {
20
26
  try {
21
- const profileResolution = await resolveVtexProfileOrSelection(profileId);
27
+ const profileResolution = await resolveVtexWriteProfile(profileId);
22
28
  if (!profileResolution.ok) {
23
29
  return profileResolution.response;
24
30
  }
25
31
  const resolvedProfileId = profileResolution.value.profileId;
32
+ const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);
26
33
  await updateInventoryLeadTime(resolvedProfileId, skuId, warehouseId, { leadTime });
27
- return object({
28
- success: true,
29
- profile_id: resolvedProfileId,
30
- sku_id: skuId,
31
- warehouse_id: warehouseId,
32
- lead_time: leadTime,
33
- message: "Lead time updated successfully"
34
+ const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);
35
+ return buildWriteSuccessResponse({
36
+ profileId: resolvedProfileId,
37
+ operation: "update_lead_time",
38
+ resourceId: skuId,
39
+ riskLevel: "low",
40
+ message: "Lead time updated successfully.",
41
+ before: beforeInventory[0] ?? null,
42
+ after: afterInventory[0] ?? null,
43
+ details: {
44
+ sku_id: skuId,
45
+ warehouse_id: warehouseId,
46
+ lead_time: leadTime
47
+ }
34
48
  });
35
49
  } catch (err) {
36
- return error(formatVtexError(err, `Failed to update lead time for SKU ${skuId} in ${warehouseId}`));
50
+ return handleVtexWriteError(
51
+ err,
52
+ `Failed to update lead time for SKU ${skuId} in ${warehouseId}`
53
+ );
37
54
  }
38
55
  }
39
56
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/tools/vtex/update-lead-time.ts"],
4
- "sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport { updateInventoryLeadTime } from \"../../services/vtex/vtex-logistics.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const updateLeadTimeSchema = 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 leadTime: z\n .string()\n .min(1)\n .describe(\"Lead time value for the SKU in VTEX expected format (e.g. 1.00:00:00)\"),\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 resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n await updateInventoryLeadTime(resolvedProfileId, skuId, warehouseId, { leadTime });\n\n return object({\n success: true,\n profile_id: resolvedProfileId,\n sku_id: skuId,\n warehouse_id: warehouseId,\n lead_time: leadTime,\n message: \"Lead time updated successfully\",\n });\n } catch (err) {\n return error(formatVtexError(err, `Failed to update lead time for SKU ${skuId} in ${warehouseId}`));\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AACxC,SAAS,qCAAqC;AAEvC,MAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,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,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,sBAAsB;AAAA,EAC9D,UAAU,EACP,OAAO,EACP,IAAI,CAAC,EACL,SAAS,uEAAuE;AACrF,CAAC;AAED,eAAsB,sBAAsB;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyC;AACvC,MAAI;AACF,UAAM,oBAAoB,MAAM,8BAA8B,SAAS;AACvE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,wBAAwB,mBAAmB,OAAO,aAAa,EAAE,SAAS,CAAC;AAEjF,WAAO,OAAO;AAAA,MACZ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,MAAM,gBAAgB,KAAK,sCAAsC,KAAK,OAAO,WAAW,EAAE,CAAC;AAAA,EACpG;AACF;",
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"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAElB;AAA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ildProductUpdatePayload,
4
+ getProduct,
5
+ updateProduct
6
+ } from "../../services/vtex/vtex-catalog-write.js";
7
+ import {
8
+ buildWriteSuccessResponse,
9
+ handleVtexWriteError,
10
+ resolveVtexWriteProfile,
11
+ vtexProfileIdSchemaField
12
+ } from "./write-helpers.js";
13
+ const updateProductBasicFieldsSchema = z.object({
14
+ profileId: vtexProfileIdSchemaField,
15
+ productId: z.string().min(1).describe("VTEX product identifier."),
16
+ name: z.string().min(1).optional().describe("New product name."),
17
+ categoryId: z.number().int().positive().optional().describe("New category identifier."),
18
+ brandId: z.number().int().positive().optional().describe("New brand identifier."),
19
+ description: z.string().optional().describe("New product description."),
20
+ descriptionShort: z.string().optional().describe("New short description."),
21
+ title: z.string().optional().describe("New SEO title."),
22
+ linkId: z.string().optional().describe("New product slug."),
23
+ refId: z.string().optional().describe("New internal reference code."),
24
+ isVisible: z.boolean().optional().describe("Whether the product should remain visible in listings."),
25
+ isActive: z.boolean().optional().describe("Whether the product should remain active."),
26
+ keyWords: z.string().optional().describe("New keywords string."),
27
+ releaseDate: z.string().optional().describe("New release date in ISO format."),
28
+ metaTagDescription: z.string().optional().describe("New meta description."),
29
+ showWithoutStock: z.boolean().optional().describe("Whether the product can stay visible without stock.")
30
+ }).refine(
31
+ (value) => value.name !== void 0 || value.categoryId !== void 0 || value.brandId !== void 0 || value.description !== void 0 || value.descriptionShort !== void 0 || value.title !== void 0 || value.linkId !== void 0 || value.refId !== void 0 || value.isVisible !== void 0 || value.isActive !== void 0 || value.keyWords !== void 0 || value.releaseDate !== void 0 || value.metaTagDescription !== void 0 || value.showWithoutStock !== void 0,
32
+ {
33
+ message: "At least one product field must be provided.",
34
+ path: ["name"]
35
+ }
36
+ );
37
+ async function updateProductBasicFieldsHandler({
38
+ profileId,
39
+ productId,
40
+ ...updates
41
+ }) {
42
+ try {
43
+ const profileResolution = await resolveVtexWriteProfile(profileId);
44
+ if (!profileResolution.ok) {
45
+ return profileResolution.response;
46
+ }
47
+ const resolvedProfileId = profileResolution.value.profileId;
48
+ const beforeProduct = await getProduct(resolvedProfileId, productId);
49
+ const payload = buildProductUpdatePayload(beforeProduct, updates);
50
+ const afterProduct = await updateProduct(resolvedProfileId, productId, payload);
51
+ return buildWriteSuccessResponse({
52
+ profileId: resolvedProfileId,
53
+ operation: "update_product_basic_fields",
54
+ resourceId: productId,
55
+ riskLevel: "low",
56
+ message: "Product fields updated successfully.",
57
+ before: beforeProduct,
58
+ after: afterProduct,
59
+ details: {
60
+ product_id: productId
61
+ }
62
+ });
63
+ } catch (err) {
64
+ return handleVtexWriteError(err, `Failed to update product ${productId}`);
65
+ }
66
+ }
67
+ export {
68
+ updateProductBasicFieldsHandler,
69
+ updateProductBasicFieldsSchema
70
+ };
71
+ //# sourceMappingURL=update-product-basic-fields.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/tools/vtex/update-product-basic-fields.ts"],
4
+ "sourcesContent": ["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"],
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,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,0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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
+ "names": []
7
+ }
@@ -0,0 +1,92 @@
1
+ import { z } from "zod";
2
+ import {
3
+ buildSkuUpdatePayload,
4
+ createSkuEan,
5
+ deleteAllSkuEans,
6
+ getSku,
7
+ getSkuEans,
8
+ updateSku
9
+ } from "../../services/vtex/vtex-catalog-write.js";
10
+ import {
11
+ buildWriteSuccessResponse,
12
+ handleVtexWriteError,
13
+ resolveVtexWriteProfile,
14
+ vtexProfileIdSchemaField
15
+ } from "./write-helpers.js";
16
+ const updateSkuBasicFieldsSchema = z.object({
17
+ profileId: vtexProfileIdSchemaField,
18
+ skuId: z.string().min(1).describe("VTEX SKU identifier."),
19
+ name: z.string().min(1).optional().describe("New SKU name."),
20
+ refId: z.string().optional().describe("New SKU reference code."),
21
+ ean: z.string().optional().describe("New EAN. When informed, existing EAN values are replaced with this one."),
22
+ packagedHeight: z.number().nonnegative().optional().describe("Packaged height."),
23
+ packagedLength: z.number().nonnegative().optional().describe("Packaged length."),
24
+ packagedWidth: z.number().nonnegative().optional().describe("Packaged width."),
25
+ packagedWeightKg: z.number().nonnegative().optional().describe("Packaged weight in kg."),
26
+ height: z.number().nonnegative().optional().describe("Physical height."),
27
+ length: z.number().nonnegative().optional().describe("Physical length."),
28
+ width: z.number().nonnegative().optional().describe("Physical width."),
29
+ weightKg: z.number().nonnegative().optional().describe("Physical weight in kg."),
30
+ measurementUnit: z.string().optional().describe("Measurement unit."),
31
+ unitMultiplier: z.number().positive().optional().describe("Unit multiplier."),
32
+ manufacturerCode: z.string().optional().describe("Manufacturer code."),
33
+ commercialConditionId: z.number().int().positive().optional().describe("Commercial condition ID."),
34
+ isActive: z.boolean().optional().describe("Whether the SKU should remain active."),
35
+ activateIfPossible: z.boolean().optional().describe("Whether VTEX should auto-activate the SKU when possible.")
36
+ }).refine(
37
+ (value) => value.name !== void 0 || value.refId !== void 0 || value.ean !== void 0 || value.packagedHeight !== void 0 || value.packagedLength !== void 0 || value.packagedWidth !== void 0 || value.packagedWeightKg !== void 0 || value.height !== void 0 || value.length !== void 0 || value.width !== void 0 || value.weightKg !== void 0 || value.measurementUnit !== void 0 || value.unitMultiplier !== void 0 || value.manufacturerCode !== void 0 || value.commercialConditionId !== void 0 || value.isActive !== void 0 || value.activateIfPossible !== void 0,
38
+ {
39
+ message: "At least one SKU field must be provided.",
40
+ path: ["name"]
41
+ }
42
+ );
43
+ async function updateSkuBasicFieldsHandler({
44
+ profileId,
45
+ skuId,
46
+ ean,
47
+ ...updates
48
+ }) {
49
+ try {
50
+ const profileResolution = await resolveVtexWriteProfile(profileId);
51
+ if (!profileResolution.ok) {
52
+ return profileResolution.response;
53
+ }
54
+ const resolvedProfileId = profileResolution.value.profileId;
55
+ const beforeSku = await getSku(resolvedProfileId, skuId);
56
+ const beforeEans = await getSkuEans(resolvedProfileId, skuId);
57
+ const payload = buildSkuUpdatePayload(beforeSku, updates);
58
+ const afterSku = await updateSku(resolvedProfileId, skuId, payload);
59
+ if (ean !== void 0) {
60
+ await deleteAllSkuEans(resolvedProfileId, skuId);
61
+ if (ean.trim()) {
62
+ await createSkuEan(resolvedProfileId, skuId, ean.trim());
63
+ }
64
+ }
65
+ const afterEans = await getSkuEans(resolvedProfileId, skuId);
66
+ return buildWriteSuccessResponse({
67
+ profileId: resolvedProfileId,
68
+ operation: "update_sku_basic_fields",
69
+ resourceId: skuId,
70
+ riskLevel: "low",
71
+ message: "SKU fields updated successfully.",
72
+ before: {
73
+ ...beforeSku,
74
+ Eans: beforeEans
75
+ },
76
+ after: {
77
+ ...afterSku,
78
+ Eans: afterEans
79
+ },
80
+ details: {
81
+ sku_id: skuId
82
+ }
83
+ });
84
+ } catch (err) {
85
+ return handleVtexWriteError(err, `Failed to update SKU ${skuId}`);
86
+ }
87
+ }
88
+ export {
89
+ updateSkuBasicFieldsHandler,
90
+ updateSkuBasicFieldsSchema
91
+ };
92
+ //# sourceMappingURL=update-sku-basic-fields.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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"],
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;AAAA,EACrF,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,kBAAkB;AAAA,EAC/E,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,kBAAkB;AAAA,EAC/E,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,SAA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MAAM,CAAC,MAAM;AAAA,EACf;AACF;AAEF,eAAsB,4BAA4B;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA+C;AAC7C,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,aAAa,MAAM,WAAW,mBAAmB,KAAK;AAC5D,UAAM,UAAU,sBAAsB,WAAW,OAAO;AACxD,UAAM,WAAW,MAAM,UAAU,mBAAmB,OAAO,OAAO;AAElE,QAAI,QAAQ,QAAW;AACrB,YAAM,iBAAiB,mBAAmB,KAAK;AAC/C,UAAI,IAAI,KAAK,GAAG;AACd,cAAM,aAAa,mBAAmB,OAAO,IAAI,KAAK,CAAC;AAAA,MACzD;AAAA,IACF;AAEA,UAAM,YAAY,MAAM,WAAW,mBAAmB,KAAK;AAE3D,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,QACN,GAAG;AAAA,QACH,MAAM;AAAA,MACR;AAAA,MACA,OAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,wBAAwB,KAAK,EAAE;AAAA,EAClE;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,81 @@
1
+ import { z } from "zod";
2
+ import { getSkuPrice } from "../../services/vtex/vtex-pricing.js";
3
+ import { updateSkuPrice } from "../../services/vtex/vtex-pricing-write.js";
4
+ import {
5
+ buildWriteSuccessResponse,
6
+ handleVtexWriteError,
7
+ resolveVtexWriteProfile,
8
+ vtexProfileIdSchemaField
9
+ } from "./write-helpers.js";
10
+ const fixedPriceSchema = z.object({
11
+ tradePolicyId: z.string().min(1).describe("Trade policy or price table identifier for the fixed price."),
12
+ value: z.number().nonnegative().describe("Fixed selling price."),
13
+ listPrice: z.number().nonnegative().optional().describe("Optional list price for the fixed price."),
14
+ minQuantity: z.number().int().positive().describe("Minimum quantity required for this fixed price."),
15
+ dateRange: z.object({
16
+ from: z.string().min(1).describe("RFC3339 start timestamp for the fixed price."),
17
+ to: z.string().min(1).describe("RFC3339 end timestamp for the fixed price.")
18
+ }).optional().describe("Optional validity window for the fixed price.")
19
+ });
20
+ const updateSkuPriceSchema = z.object({
21
+ profileId: vtexProfileIdSchemaField,
22
+ skuId: z.string().min(1).describe("SKU item identifier used by VTEX Pricing."),
23
+ basePrice: z.number().nonnegative().optional().describe("New base price for the SKU."),
24
+ costPrice: z.number().nonnegative().optional().describe("New cost price for the SKU."),
25
+ markup: z.number().nonnegative().optional().describe("New markup percentage for the SKU."),
26
+ listPrice: z.number().nonnegative().optional().describe("New list price for the SKU."),
27
+ fixedPrices: z.array(fixedPriceSchema).optional().describe(
28
+ "Optional full fixed price list to persist together with the base price update. VTEX overwrites any existing fixed prices not included here."
29
+ )
30
+ }).refine(
31
+ (value) => value.basePrice !== void 0 || value.costPrice !== void 0 || value.markup !== void 0 || value.listPrice !== void 0 || value.fixedPrices !== void 0,
32
+ {
33
+ message: "At least one pricing field must be provided.",
34
+ path: ["basePrice"]
35
+ }
36
+ );
37
+ async function updateSkuPriceHandler({
38
+ profileId,
39
+ skuId,
40
+ basePrice,
41
+ costPrice,
42
+ markup,
43
+ listPrice,
44
+ fixedPrices
45
+ }) {
46
+ try {
47
+ const profileResolution = await resolveVtexWriteProfile(profileId);
48
+ if (!profileResolution.ok) {
49
+ return profileResolution.response;
50
+ }
51
+ const resolvedProfileId = profileResolution.value.profileId;
52
+ const beforePrice = await getSkuPrice(resolvedProfileId, skuId);
53
+ await updateSkuPrice(resolvedProfileId, skuId, {
54
+ basePrice,
55
+ costPrice,
56
+ markup,
57
+ listPrice,
58
+ fixedPrices
59
+ });
60
+ const afterPrice = await getSkuPrice(resolvedProfileId, skuId);
61
+ return buildWriteSuccessResponse({
62
+ profileId: resolvedProfileId,
63
+ operation: "update_sku_price",
64
+ resourceId: skuId,
65
+ riskLevel: "low",
66
+ message: "SKU price updated successfully.",
67
+ before: beforePrice,
68
+ after: afterPrice,
69
+ details: {
70
+ sku_id: skuId
71
+ }
72
+ });
73
+ } catch (err) {
74
+ return handleVtexWriteError(err, `Failed to update price for SKU ${skuId}`);
75
+ }
76
+ }
77
+ export {
78
+ updateSkuPriceHandler,
79
+ updateSkuPriceSchema
80
+ };
81
+ //# sourceMappingURL=update-sku-price.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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pB;AACF;AAEF,eAAsB,sBAAsB;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyC;AACvC,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,eAAe,mBAAmB,OAAO;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,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,MACV;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,kCAAkC,KAAK,EAAE;AAAA,EAC5E;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ import { getSkuPrice } from "../../services/vtex/vtex-pricing.js";
3
+ import { upsertFixedPricesForPriceTable } from "../../services/vtex/vtex-pricing-write.js";
4
+ import {
5
+ buildWriteSuccessResponse,
6
+ handleVtexWriteError,
7
+ resolveVtexWriteProfile,
8
+ vtexProfileIdSchemaField
9
+ } from "./write-helpers.js";
10
+ const fixedPriceEntrySchema = z.object({
11
+ value: z.number().nonnegative().describe("Fixed selling price."),
12
+ listPrice: z.number().nonnegative().optional().describe("Optional fixed list price."),
13
+ minQuantity: z.number().int().positive().describe("Minimum quantity for the fixed price."),
14
+ dateRange: z.object({
15
+ from: z.string().min(1).describe("RFC3339 start timestamp."),
16
+ to: z.string().min(1).describe("RFC3339 end timestamp.")
17
+ }).optional().describe("Optional validity window for this fixed price.")
18
+ });
19
+ const upsertFixedPriceSchema = z.object({
20
+ profileId: vtexProfileIdSchemaField,
21
+ skuId: z.string().min(1).describe("SKU item identifier used by VTEX Pricing."),
22
+ priceTableId: z.string().min(1).describe("Trade policy or price table identifier."),
23
+ fixedPrices: z.array(fixedPriceEntrySchema).min(1).describe("Fixed prices to create or replace inside the selected price table.")
24
+ });
25
+ async function upsertFixedPriceHandler({
26
+ profileId,
27
+ skuId,
28
+ priceTableId,
29
+ fixedPrices
30
+ }) {
31
+ try {
32
+ const profileResolution = await resolveVtexWriteProfile(profileId);
33
+ if (!profileResolution.ok) {
34
+ return profileResolution.response;
35
+ }
36
+ const resolvedProfileId = profileResolution.value.profileId;
37
+ const beforePrice = await getSkuPrice(resolvedProfileId, skuId);
38
+ await upsertFixedPricesForPriceTable(
39
+ resolvedProfileId,
40
+ skuId,
41
+ priceTableId,
42
+ fixedPrices
43
+ );
44
+ const afterPrice = await getSkuPrice(resolvedProfileId, skuId);
45
+ return buildWriteSuccessResponse({
46
+ profileId: resolvedProfileId,
47
+ operation: "upsert_fixed_price",
48
+ resourceId: skuId,
49
+ riskLevel: "low",
50
+ message: "Fixed prices updated successfully for the selected price table.",
51
+ before: beforePrice,
52
+ after: afterPrice,
53
+ details: {
54
+ sku_id: skuId,
55
+ price_table_id: priceTableId
56
+ }
57
+ });
58
+ } catch (err) {
59
+ return handleVtexWriteError(
60
+ err,
61
+ `Failed to update fixed prices for SKU ${skuId} on price table ${priceTableId}`
62
+ );
63
+ }
64
+ }
65
+ export {
66
+ upsertFixedPriceHandler,
67
+ upsertFixedPriceSchema
68
+ };
69
+ //# sourceMappingURL=upsert-fixed-price.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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"],
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
+ "names": []
7
+ }
@@ -0,0 +1,73 @@
1
+ import { error, object } from "mcp-use/server";
2
+ import { z } from "zod";
3
+ import { formatVtexError } from "../../services/vtex/vtex-api.js";
4
+ import {
5
+ VtexOperationError,
6
+ buildConfirmationRequiredResult,
7
+ buildWriteSuccessResult
8
+ } from "../../services/vtex/vtex-write.js";
9
+ import { toSnakeCaseKeys } from "../../utils/case-conversion.js";
10
+ import { resolveVtexProfileOrSelection } from "./profile-resolution.js";
11
+ const vtexProfileIdSchemaField = z.string().trim().min(1).optional().describe(
12
+ "Explicit VTEX profile id to use. If omitted, the tool returns a guided selection payload with available active profiles."
13
+ );
14
+ const confirmationSchemaField = z.boolean().optional().describe(
15
+ "Set to true only after the assistant has explained the impact of this operation and the user has explicitly confirmed they want to proceed."
16
+ );
17
+ const confirmationNoteSchemaField = z.string().trim().min(1).optional().describe("Optional note summarizing the user's explicit confirmation in natural language.");
18
+ async function resolveVtexWriteProfile(profileId) {
19
+ const profileResolution = await resolveVtexProfileOrSelection(profileId);
20
+ if (!profileResolution.ok) {
21
+ return profileResolution;
22
+ }
23
+ return {
24
+ ok: true,
25
+ value: {
26
+ profileId: profileResolution.value.profileId
27
+ }
28
+ };
29
+ }
30
+ function requireExplicitConfirmation(confirmed, operation, details) {
31
+ if (confirmed === true) {
32
+ return null;
33
+ }
34
+ return object(buildConfirmationRequiredResult(operation, details));
35
+ }
36
+ function toWriteSummary(before, after) {
37
+ return {
38
+ before: before ? toSnakeCaseKeys(before) : before,
39
+ after: after ? toSnakeCaseKeys(after) : after
40
+ };
41
+ }
42
+ function buildWriteSuccessResponse(params) {
43
+ return object(
44
+ buildWriteSuccessResult({
45
+ profileId: params.profileId,
46
+ operation: params.operation,
47
+ resourceId: params.resourceId,
48
+ riskLevel: params.riskLevel,
49
+ confirmed: params.confirmed,
50
+ confirmationNote: params.confirmationNote,
51
+ message: params.message,
52
+ summary: toWriteSummary(params.before, params.after),
53
+ details: params.details ? toSnakeCaseKeys(params.details) : void 0
54
+ })
55
+ );
56
+ }
57
+ function handleVtexWriteError(err, fallback) {
58
+ if (err instanceof VtexOperationError) {
59
+ return error(err.message);
60
+ }
61
+ return error(formatVtexError(err, fallback));
62
+ }
63
+ export {
64
+ buildWriteSuccessResponse,
65
+ confirmationNoteSchemaField,
66
+ confirmationSchemaField,
67
+ handleVtexWriteError,
68
+ requireExplicitConfirmation,
69
+ resolveVtexWriteProfile,
70
+ toWriteSummary,
71
+ vtexProfileIdSchemaField
72
+ };
73
+ //# sourceMappingURL=write-helpers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/tools/vtex/write-helpers.ts"],
4
+ "sourcesContent": ["import { error, object } from \"mcp-use/server\";\nimport { z } from \"zod\";\n\nimport { formatVtexError } from \"../../services/vtex/vtex-api.js\";\nimport {\n VtexOperationError,\n buildConfirmationRequiredResult,\n buildWriteSuccessResult,\n type VtexWriteRiskLevel,\n} from \"../../services/vtex/vtex-write.js\";\nimport { toSnakeCaseKeys } from \"../../utils/case-conversion.js\";\nimport { resolveVtexProfileOrSelection } from \"./profile-resolution.js\";\n\nexport const vtexProfileIdSchemaField = 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\nexport const confirmationSchemaField = z\n .boolean()\n .optional()\n .describe(\n \"Set to true only after the assistant has explained the impact of this operation and the user has explicitly confirmed they want to proceed.\"\n );\n\nexport const confirmationNoteSchemaField = z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\"Optional note summarizing the user's explicit confirmation in natural language.\");\n\nexport async function resolveVtexWriteProfile(profileId?: string) {\n const profileResolution = await resolveVtexProfileOrSelection(profileId);\n if (!profileResolution.ok) {\n return profileResolution;\n }\n\n return {\n ok: true as const,\n value: {\n profileId: profileResolution.value.profileId,\n },\n };\n}\n\nexport function requireExplicitConfirmation(\n confirmed: boolean | undefined,\n operation: string,\n details?: Record<string, unknown>\n) {\n if (confirmed === true) {\n return null;\n }\n\n return object(buildConfirmationRequiredResult(operation, details));\n}\n\nexport function toWriteSummary(\n before?: Record<string, unknown> | null,\n after?: Record<string, unknown> | null\n) {\n return {\n before: before ? (toSnakeCaseKeys(before) as Record<string, unknown>) : before,\n after: after ? (toSnakeCaseKeys(after) as Record<string, unknown>) : after,\n };\n}\n\nexport function buildWriteSuccessResponse(params: {\n profileId: string;\n operation: string;\n resourceId?: string;\n riskLevel: VtexWriteRiskLevel;\n confirmed?: boolean;\n confirmationNote?: string;\n message: string;\n before?: Record<string, unknown> | null;\n after?: Record<string, unknown> | null;\n details?: Record<string, unknown>;\n}) {\n return object(\n buildWriteSuccessResult({\n profileId: params.profileId,\n operation: params.operation,\n resourceId: params.resourceId,\n riskLevel: params.riskLevel,\n confirmed: params.confirmed,\n confirmationNote: params.confirmationNote,\n message: params.message,\n summary: toWriteSummary(params.before, params.after),\n details: params.details ? (toSnakeCaseKeys(params.details) as Record<string, unknown>) : undefined,\n })\n );\n}\n\nexport function handleVtexWriteError(err: unknown, fallback: string) {\n if (err instanceof VtexOperationError) {\n return error(err.message);\n }\n\n return error(formatVtexError(err, fallback));\n}\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,gBAAgB,OAAO,OAAO,IAAgC;AAAA,IAC3F,CAAC;AAAA,EACH;AACF;AAEO,SAAS,qBAAqB,KAAc,UAAkB;AACnE,MAAI,eAAe,oBAAoB;AACrC,WAAO,MAAM,IAAI,OAAO;AAAA,EAC1B;AAEA,SAAO,MAAM,gBAAgB,KAAK,QAAQ,CAAC;AAC7C;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yoryoboy/bi-mcp",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.3.1",
5
5
  "description": "MCP server: bi-mcp",
6
6
  "author": "",
7
7
  "license": "MIT",