@yoryoboy/bi-mcp 1.2.0 → 1.3.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/dist/.tsbuildinfo +1 -1
- package/dist/index.js +302 -2
- package/dist/index.js.map +2 -2
- package/dist/mcp-use.json +2 -2
- package/dist/src/services/vtex/vtex-catalog-write.js +233 -0
- package/dist/src/services/vtex/vtex-catalog-write.js.map +7 -0
- package/dist/src/services/vtex/vtex-orders-write.js +152 -0
- package/dist/src/services/vtex/vtex-orders-write.js.map +7 -0
- package/dist/src/services/vtex/vtex-pricing-write.js +24 -0
- package/dist/src/services/vtex/vtex-pricing-write.js.map +7 -0
- package/dist/src/services/vtex/vtex-write.js +38 -0
- package/dist/src/services/vtex/vtex-write.js.map +7 -0
- package/dist/src/tools/vtex/activate-sku.js +53 -0
- package/dist/src/tools/vtex/activate-sku.js.map +7 -0
- package/dist/src/tools/vtex/add-order-tracking.js +103 -0
- package/dist/src/tools/vtex/add-order-tracking.js.map +7 -0
- package/dist/src/tools/vtex/associate-specification.js +60 -0
- package/dist/src/tools/vtex/associate-specification.js.map +7 -0
- package/dist/src/tools/vtex/attach-catalog-image.js +63 -0
- package/dist/src/tools/vtex/attach-catalog-image.js.map +7 -0
- package/dist/src/tools/vtex/cancel-order.js +67 -0
- package/dist/src/tools/vtex/cancel-order.js.map +7 -0
- package/dist/src/tools/vtex/create-brand.js +69 -0
- package/dist/src/tools/vtex/create-brand.js.map +7 -0
- package/dist/src/tools/vtex/create-category.js +81 -0
- package/dist/src/tools/vtex/create-category.js.map +7 -0
- package/dist/src/tools/vtex/create-product-with-sku.js +120 -0
- package/dist/src/tools/vtex/create-product-with-sku.js.map +7 -0
- package/dist/src/tools/vtex/create-product.js +111 -0
- package/dist/src/tools/vtex/create-product.js.map +7 -0
- package/dist/src/tools/vtex/create-sku.js +103 -0
- package/dist/src/tools/vtex/create-sku.js.map +7 -0
- package/dist/src/tools/vtex/create-specification-value.js +53 -0
- package/dist/src/tools/vtex/create-specification-value.js.map +7 -0
- package/dist/src/tools/vtex/create-specification.js +85 -0
- package/dist/src/tools/vtex/create-specification.js.map +7 -0
- package/dist/src/tools/vtex/deactivate-sku.js +53 -0
- package/dist/src/tools/vtex/deactivate-sku.js.map +7 -0
- package/dist/src/tools/vtex/delete-fixed-price.js +53 -0
- package/dist/src/tools/vtex/delete-fixed-price.js.map +7 -0
- package/dist/src/tools/vtex/index.js +20 -0
- package/dist/src/tools/vtex/index.js.map +2 -2
- package/dist/src/tools/vtex/invoice-order.js +84 -0
- package/dist/src/tools/vtex/invoice-order.js.map +7 -0
- package/dist/src/tools/vtex/toggle-unlimited-quantity.js +65 -0
- package/dist/src/tools/vtex/toggle-unlimited-quantity.js.map +7 -0
- package/dist/src/tools/vtex/update-inventory.js +34 -19
- package/dist/src/tools/vtex/update-inventory.js.map +2 -2
- package/dist/src/tools/vtex/update-lead-time.js +34 -17
- package/dist/src/tools/vtex/update-lead-time.js.map +2 -2
- package/dist/src/tools/vtex/update-product-basic-fields.js +71 -0
- package/dist/src/tools/vtex/update-product-basic-fields.js.map +7 -0
- package/dist/src/tools/vtex/update-sku-basic-fields.js +92 -0
- package/dist/src/tools/vtex/update-sku-basic-fields.js.map +7 -0
- package/dist/src/tools/vtex/update-sku-price.js +81 -0
- package/dist/src/tools/vtex/update-sku-price.js.map +7 -0
- package/dist/src/tools/vtex/upsert-fixed-price.js +69 -0
- package/dist/src/tools/vtex/upsert-fixed-price.js.map +7 -0
- package/dist/src/tools/vtex/write-helpers.js +73 -0
- package/dist/src/tools/vtex/write-helpers.js.map +7 -0
- package/package.json +1 -1
|
@@ -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;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,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Q;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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AA,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}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,OAAO,cAAc;AAC9B,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB;AAChC,SAAS,qCAAqC;AAEvC,MAAM,2BAA2B,EACrC,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT;AAAA,EACC;AACF;AAEK,MAAM,0BAA0B,EACpC,QAAQ,EACR,SAAS,EACT;AAAA,EACC;AACF;AAEK,MAAM,8BAA8B,EACxC,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,EACT,SAAS,iFAAiF;AAE7F,eAAsB,wBAAwB,WAAoB;AAChE,QAAM,oBAAoB,MAAM,8BAA8B,SAAS;AACvE,MAAI,CAAC,kBAAkB,IAAI;AACzB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,MACL,WAAW,kBAAkB,MAAM;AAAA,IACrC;AAAA,EACF;AACF;AAEO,SAAS,4BACd,WACA,WACA,SACA;AACA,MAAI,cAAc,MAAM;AACtB,WAAO;AA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