@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,103 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
getOrderStateSnapshot,
|
|
4
|
+
updateOrderTrackingStatus,
|
|
5
|
+
updatePartialInvoiceTracking,
|
|
6
|
+
validateOrderForTracking
|
|
7
|
+
} from "../../services/vtex/vtex-orders-write.js";
|
|
8
|
+
import {
|
|
9
|
+
buildWriteSuccessResponse,
|
|
10
|
+
confirmationNoteSchemaField,
|
|
11
|
+
confirmationSchemaField,
|
|
12
|
+
handleVtexWriteError,
|
|
13
|
+
requireExplicitConfirmation,
|
|
14
|
+
resolveVtexWriteProfile,
|
|
15
|
+
vtexProfileIdSchemaField
|
|
16
|
+
} from "./write-helpers.js";
|
|
17
|
+
const trackingEventSchema = z.object({
|
|
18
|
+
city: z.string().min(1).describe("Tracking event city."),
|
|
19
|
+
state: z.string().min(1).describe("Tracking event state."),
|
|
20
|
+
description: z.string().min(1).describe("Tracking event description."),
|
|
21
|
+
date: z.string().min(1).describe("Tracking event date string.")
|
|
22
|
+
});
|
|
23
|
+
const addOrderTrackingSchema = z.object({
|
|
24
|
+
profileId: vtexProfileIdSchemaField,
|
|
25
|
+
orderId: z.string().min(1).describe("VTEX order identifier."),
|
|
26
|
+
invoiceNumber: z.string().min(1).describe("Invoice number that will receive tracking data."),
|
|
27
|
+
confirmed: confirmationSchemaField,
|
|
28
|
+
confirmationNote: confirmationNoteSchemaField,
|
|
29
|
+
trackingNumber: z.string().min(1).describe("Tracking number."),
|
|
30
|
+
trackingUrl: z.string().url().optional().describe("Tracking URL."),
|
|
31
|
+
courier: z.string().optional().describe("Carrier name."),
|
|
32
|
+
dispatchedDate: z.string().min(1).describe("Dispatch timestamp."),
|
|
33
|
+
isDelivered: z.boolean().optional().describe("Optional delivery status to send to VTEX tracking timeline."),
|
|
34
|
+
deliveredDate: z.string().optional().describe("Optional delivered date in `yyyy-mm-dd hh:mm` format."),
|
|
35
|
+
events: z.array(trackingEventSchema).optional().describe("Optional tracking events timeline.")
|
|
36
|
+
});
|
|
37
|
+
async function addOrderTrackingHandler({
|
|
38
|
+
profileId,
|
|
39
|
+
orderId,
|
|
40
|
+
invoiceNumber,
|
|
41
|
+
confirmed,
|
|
42
|
+
confirmationNote,
|
|
43
|
+
trackingNumber,
|
|
44
|
+
trackingUrl,
|
|
45
|
+
courier,
|
|
46
|
+
dispatchedDate,
|
|
47
|
+
isDelivered,
|
|
48
|
+
deliveredDate,
|
|
49
|
+
events
|
|
50
|
+
}) {
|
|
51
|
+
const confirmationResponse = requireExplicitConfirmation(confirmed, "add_order_tracking", {
|
|
52
|
+
order_id: orderId,
|
|
53
|
+
invoice_number: invoiceNumber
|
|
54
|
+
});
|
|
55
|
+
if (confirmationResponse) {
|
|
56
|
+
return confirmationResponse;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
60
|
+
if (!profileResolution.ok) {
|
|
61
|
+
return profileResolution.response;
|
|
62
|
+
}
|
|
63
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
64
|
+
const beforeOrder = await validateOrderForTracking(resolvedProfileId, orderId, invoiceNumber);
|
|
65
|
+
await updatePartialInvoiceTracking(resolvedProfileId, orderId, invoiceNumber, {
|
|
66
|
+
trackingNumber,
|
|
67
|
+
trackingUrl,
|
|
68
|
+
courier,
|
|
69
|
+
dispatchedDate
|
|
70
|
+
});
|
|
71
|
+
if (events?.length || isDelivered !== void 0) {
|
|
72
|
+
await updateOrderTrackingStatus(resolvedProfileId, orderId, invoiceNumber, {
|
|
73
|
+
isDelivered: isDelivered ?? false,
|
|
74
|
+
deliveredDate: deliveredDate ?? null,
|
|
75
|
+
events: events ?? []
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId);
|
|
79
|
+
return buildWriteSuccessResponse({
|
|
80
|
+
profileId: resolvedProfileId,
|
|
81
|
+
operation: "add_order_tracking",
|
|
82
|
+
resourceId: orderId,
|
|
83
|
+
riskLevel: "high",
|
|
84
|
+
confirmed: true,
|
|
85
|
+
confirmationNote,
|
|
86
|
+
message: "Order tracking updated successfully.",
|
|
87
|
+
before: beforeOrder,
|
|
88
|
+
after: afterOrder,
|
|
89
|
+
details: {
|
|
90
|
+
order_id: orderId,
|
|
91
|
+
invoice_number: invoiceNumber,
|
|
92
|
+
tracking_number: trackingNumber
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
} catch (err) {
|
|
96
|
+
return handleVtexWriteError(err, `Failed to update tracking for order ${orderId}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
addOrderTrackingHandler,
|
|
101
|
+
addOrderTrackingSchema
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=add-order-tracking.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/add-order-tracking.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getOrderStateSnapshot,\n updateOrderTrackingStatus,\n updatePartialInvoiceTracking,\n validateOrderForTracking,\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 trackingEventSchema = z.object({\n city: z.string().min(1).describe(\"Tracking event city.\"),\n state: z.string().min(1).describe(\"Tracking event state.\"),\n description: z.string().min(1).describe(\"Tracking event description.\"),\n date: z.string().min(1).describe(\"Tracking event date string.\"),\n});\n\nexport const addOrderTrackingSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n orderId: z.string().min(1).describe(\"VTEX order identifier.\"),\n invoiceNumber: z.string().min(1).describe(\"Invoice number that will receive tracking data.\"),\n confirmed: confirmationSchemaField,\n confirmationNote: confirmationNoteSchemaField,\n trackingNumber: z.string().min(1).describe(\"Tracking number.\"),\n trackingUrl: z.string().url().optional().describe(\"Tracking URL.\"),\n courier: z.string().optional().describe(\"Carrier name.\"),\n dispatchedDate: z.string().min(1).describe(\"Dispatch timestamp.\"),\n isDelivered: z\n .boolean()\n .optional()\n .describe(\"Optional delivery status to send to VTEX tracking timeline.\"),\n deliveredDate: z\n .string()\n .optional()\n .describe(\"Optional delivered date in `yyyy-mm-dd hh:mm` format.\"),\n events: z.array(trackingEventSchema).optional().describe(\"Optional tracking events timeline.\"),\n});\n\nexport async function addOrderTrackingHandler({\n profileId,\n orderId,\n invoiceNumber,\n confirmed,\n confirmationNote,\n trackingNumber,\n trackingUrl,\n courier,\n dispatchedDate,\n isDelivered,\n deliveredDate,\n events,\n}: z.infer<typeof addOrderTrackingSchema>) {\n const confirmationResponse = requireExplicitConfirmation(confirmed, \"add_order_tracking\", {\n order_id: orderId,\n invoice_number: invoiceNumber,\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 validateOrderForTracking(resolvedProfileId, orderId, invoiceNumber);\n\n await updatePartialInvoiceTracking(resolvedProfileId, orderId, invoiceNumber, {\n trackingNumber,\n trackingUrl,\n courier,\n dispatchedDate,\n });\n\n if (events?.length || isDelivered !== undefined) {\n await updateOrderTrackingStatus(resolvedProfileId, orderId, invoiceNumber, {\n isDelivered: isDelivered ?? false,\n deliveredDate: deliveredDate ?? null,\n events: events ?? [],\n });\n }\n\n const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"add_order_tracking\",\n resourceId: orderId,\n riskLevel: \"high\",\n confirmed: true,\n confirmationNote,\n message: \"Order tracking updated 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: invoiceNumber,\n tracking_number: trackingNumber,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to update tracking for order ${orderId}`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB;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{ z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
associateProductSpecification,
|
|
4
|
+
associateSkuSpecification
|
|
5
|
+
} from "../../services/vtex/vtex-catalog-write.js";
|
|
6
|
+
import {
|
|
7
|
+
buildWriteSuccessResponse,
|
|
8
|
+
handleVtexWriteError,
|
|
9
|
+
resolveVtexWriteProfile,
|
|
10
|
+
vtexProfileIdSchemaField
|
|
11
|
+
} from "./write-helpers.js";
|
|
12
|
+
const associateSpecificationSchema = z.object({
|
|
13
|
+
profileId: vtexProfileIdSchemaField,
|
|
14
|
+
entityType: z.enum(["product", "sku"]).describe("Whether the specification should be associated to a product or an SKU."),
|
|
15
|
+
resourceId: z.string().min(1).describe("Product ID or SKU ID depending on entityType."),
|
|
16
|
+
fieldId: z.number().int().positive().describe("Specification field ID."),
|
|
17
|
+
fieldValueId: z.number().int().positive().optional().describe("Specification value ID. Required for combo, radio, and checkbox fields."),
|
|
18
|
+
text: z.string().optional().describe("Raw text value. Use for free text specifications instead of fieldValueId.")
|
|
19
|
+
});
|
|
20
|
+
async function associateSpecificationHandler({
|
|
21
|
+
profileId,
|
|
22
|
+
entityType,
|
|
23
|
+
resourceId,
|
|
24
|
+
fieldId,
|
|
25
|
+
fieldValueId,
|
|
26
|
+
text
|
|
27
|
+
}) {
|
|
28
|
+
try {
|
|
29
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
30
|
+
if (!profileResolution.ok) {
|
|
31
|
+
return profileResolution.response;
|
|
32
|
+
}
|
|
33
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
34
|
+
const payload = {
|
|
35
|
+
FieldId: fieldId
|
|
36
|
+
};
|
|
37
|
+
if (fieldValueId !== void 0) payload.FieldValueId = fieldValueId;
|
|
38
|
+
if (text !== void 0) payload.Text = text;
|
|
39
|
+
const association = entityType === "product" ? await associateProductSpecification(resolvedProfileId, resourceId, payload) : await associateSkuSpecification(resolvedProfileId, resourceId, payload);
|
|
40
|
+
return buildWriteSuccessResponse({
|
|
41
|
+
profileId: resolvedProfileId,
|
|
42
|
+
operation: "associate_specification",
|
|
43
|
+
resourceId,
|
|
44
|
+
riskLevel: "low",
|
|
45
|
+
message: "Specification associated successfully.",
|
|
46
|
+
before: null,
|
|
47
|
+
after: association,
|
|
48
|
+
details: {
|
|
49
|
+
entity_type: entityType
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return handleVtexWriteError(err, `Failed to associate specification to ${entityType} ${resourceId}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
associateSpecificationHandler,
|
|
58
|
+
associateSpecificationSchema
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=associate-specification.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/associate-specification.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n associateProductSpecification,\n associateSkuSpecification,\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 associateSpecificationSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n entityType: z.enum([\"product\", \"sku\"]).describe(\"Whether the specification should be associated to a product or an SKU.\"),\n resourceId: z.string().min(1).describe(\"Product ID or SKU ID depending on entityType.\"),\n fieldId: z.number().int().positive().describe(\"Specification field ID.\"),\n fieldValueId: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\"Specification value ID. Required for combo, radio, and checkbox fields.\"),\n text: z\n .string()\n .optional()\n .describe(\"Raw text value. Use for free text specifications instead of fieldValueId.\"),\n});\n\nexport async function associateSpecificationHandler({\n profileId,\n entityType,\n resourceId,\n fieldId,\n fieldValueId,\n text,\n}: z.infer<typeof associateSpecificationSchema>) {\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 payload: Record<string, unknown> = {\n FieldId: fieldId,\n };\n if (fieldValueId !== undefined) payload.FieldValueId = fieldValueId;\n if (text !== undefined) payload.Text = text;\n\n const association =\n entityType === \"product\"\n ? await associateProductSpecification(resolvedProfileId, resourceId, payload)\n : await associateSkuSpecification(resolvedProfileId, resourceId, payload);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"associate_specification\",\n resourceId,\n riskLevel: \"low\",\n message: \"Specification associated successfully.\",\n before: null,\n after: association,\n details: {\n entity_type: entityType,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to associate specification to ${entityType} ${resourceId}`);\n }\n}\n"],
|
|
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,+BAA+B,EAAE,OAAO;AAAA,EACnD,WAAW;AAAA,EACX,YAAY,EAAE,KAAK,CAAC,WAAW,KAAK,CAAC,EAAE,SAAS,wEAAwE;AAAA,EACxH,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,+CAA+C;AAAA,EACtF,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,yBAAyB;AAAA,EACvE,cAAc,EACX,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,EACT,SAAS,yEAAyE;AAAA,EACrF,MAAM,EACH,OAAO,EACP,SAAS,EACT,SAAS,2EAA2E;AACzF,CAAC;AAED,eAAsB,8BAA8B;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAiD;AAC/C,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,UAAmC;AAAA,MACvC,SAAS;AAAA,IACX;AACA,QAAI,iBAAiB,OAAW,SAAQ,eAAe;AACvD,QAAI,SAAS,OAAW,SAAQ,OAAO;AAEvC,UAAM,cACJ,eAAe,YACX,MAAM,8BAA8B,mBAAmB,YAAY,OAAO,IAC1E,MAAM,0BAA0B,mBAAmB,YAAY,OAAO;AAE5E,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,aAAa;AAAA,MACf;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,wCAAwC,UAAU,IAAI,UAAU,EAAE;AAAA,EACrG;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createSkuFile } from "../../services/vtex/vtex-catalog-write.js";
|
|
3
|
+
import {
|
|
4
|
+
buildWriteSuccessResponse,
|
|
5
|
+
handleVtexWriteError,
|
|
6
|
+
resolveVtexWriteProfile,
|
|
7
|
+
vtexProfileIdSchemaField
|
|
8
|
+
} from "./write-helpers.js";
|
|
9
|
+
const attachCatalogImageSchema = z.object({
|
|
10
|
+
profileId: vtexProfileIdSchemaField,
|
|
11
|
+
skuId: z.string().min(1).describe("SKU identifier that will receive the image."),
|
|
12
|
+
name: z.string().min(1).describe("Image name."),
|
|
13
|
+
url: z.string().url().describe("Public image URL. VTEX expects http(s) and a valid image extension."),
|
|
14
|
+
isMain: z.boolean().optional().describe("Whether this image should be the main image."),
|
|
15
|
+
label: z.string().optional().describe("Optional image label."),
|
|
16
|
+
text: z.string().optional().describe("Optional image text."),
|
|
17
|
+
position: z.number().int().nonnegative().optional().describe("Image position in storefront.")
|
|
18
|
+
});
|
|
19
|
+
async function attachCatalogImageHandler({
|
|
20
|
+
profileId,
|
|
21
|
+
skuId,
|
|
22
|
+
name,
|
|
23
|
+
url,
|
|
24
|
+
isMain,
|
|
25
|
+
label,
|
|
26
|
+
text,
|
|
27
|
+
position
|
|
28
|
+
}) {
|
|
29
|
+
try {
|
|
30
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
31
|
+
if (!profileResolution.ok) {
|
|
32
|
+
return profileResolution.response;
|
|
33
|
+
}
|
|
34
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
35
|
+
const createdImage = await createSkuFile(resolvedProfileId, skuId, {
|
|
36
|
+
Name: name,
|
|
37
|
+
Url: url,
|
|
38
|
+
IsMain: isMain,
|
|
39
|
+
Label: label,
|
|
40
|
+
Text: text,
|
|
41
|
+
Position: position
|
|
42
|
+
});
|
|
43
|
+
return buildWriteSuccessResponse({
|
|
44
|
+
profileId: resolvedProfileId,
|
|
45
|
+
operation: "attach_catalog_image",
|
|
46
|
+
resourceId: skuId,
|
|
47
|
+
riskLevel: "low",
|
|
48
|
+
message: "Catalog image attached successfully.",
|
|
49
|
+
before: null,
|
|
50
|
+
after: createdImage,
|
|
51
|
+
details: {
|
|
52
|
+
sku_id: skuId
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
} catch (err) {
|
|
56
|
+
return handleVtexWriteError(err, `Failed to attach image to SKU ${skuId}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
attachCatalogImageHandler,
|
|
61
|
+
attachCatalogImageSchema
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=attach-catalog-image.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/attach-catalog-image.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport { createSkuFile } from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const attachCatalogImageSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU identifier that will receive the image.\"),\n name: z.string().min(1).describe(\"Image name.\"),\n url: z\n .string()\n .url()\n .describe(\"Public image URL. VTEX expects http(s) and a valid image extension.\"),\n isMain: z.boolean().optional().describe(\"Whether this image should be the main image.\"),\n label: z.string().optional().describe(\"Optional image label.\"),\n text: z.string().optional().describe(\"Optional image text.\"),\n position: z.number().int().nonnegative().optional().describe(\"Image position in storefront.\"),\n});\n\nexport async function attachCatalogImageHandler({\n profileId,\n skuId,\n name,\n url,\n isMain,\n label,\n text,\n position,\n}: z.infer<typeof attachCatalogImageSchema>) {\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 createdImage = await createSkuFile(resolvedProfileId, skuId, {\n Name: name,\n Url: url,\n IsMain: isMain,\n Label: label,\n Text: text,\n Position: position,\n });\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"attach_catalog_image\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Catalog image attached successfully.\",\n before: null,\n after: createdImage,\n details: {\n sku_id: skuId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to attach image to SKU ${skuId}`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EAC/C,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,6CAA6C;AAAA,EA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|
|
2
|
+
import {
|
|
3
|
+
cancelOrder,
|
|
4
|
+
getOrderStateSnapshot,
|
|
5
|
+
validateOrderForCancellation
|
|
6
|
+
} from "../../services/vtex/vtex-orders-write.js";
|
|
7
|
+
import {
|
|
8
|
+
buildWriteSuccessResponse,
|
|
9
|
+
confirmationNoteSchemaField,
|
|
10
|
+
confirmationSchemaField,
|
|
11
|
+
handleVtexWriteError,
|
|
12
|
+
requireExplicitConfirmation,
|
|
13
|
+
resolveVtexWriteProfile,
|
|
14
|
+
vtexProfileIdSchemaField
|
|
15
|
+
} from "./write-helpers.js";
|
|
16
|
+
const cancelOrderSchema = z.object({
|
|
17
|
+
profileId: vtexProfileIdSchemaField,
|
|
18
|
+
orderId: z.string().min(1).describe("VTEX order identifier to cancel."),
|
|
19
|
+
confirmed: confirmationSchemaField,
|
|
20
|
+
reason: z.string().trim().min(1).describe("Reason for canceling the order. VTEX persists this reason.").optional(),
|
|
21
|
+
confirmationNote: confirmationNoteSchemaField
|
|
22
|
+
});
|
|
23
|
+
async function cancelOrderHandler({
|
|
24
|
+
profileId,
|
|
25
|
+
orderId,
|
|
26
|
+
confirmed,
|
|
27
|
+
reason,
|
|
28
|
+
confirmationNote
|
|
29
|
+
}) {
|
|
30
|
+
const confirmationResponse = requireExplicitConfirmation(confirmed, "cancel_order", {
|
|
31
|
+
order_id: orderId
|
|
32
|
+
});
|
|
33
|
+
if (confirmationResponse) {
|
|
34
|
+
return confirmationResponse;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
38
|
+
if (!profileResolution.ok) {
|
|
39
|
+
return profileResolution.response;
|
|
40
|
+
}
|
|
41
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
42
|
+
const beforeOrder = await validateOrderForCancellation(resolvedProfileId, orderId, reason);
|
|
43
|
+
await cancelOrder(resolvedProfileId, orderId, reason);
|
|
44
|
+
const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId, reason);
|
|
45
|
+
return buildWriteSuccessResponse({
|
|
46
|
+
profileId: resolvedProfileId,
|
|
47
|
+
operation: "cancel_order",
|
|
48
|
+
resourceId: orderId,
|
|
49
|
+
riskLevel: "high",
|
|
50
|
+
confirmed: true,
|
|
51
|
+
confirmationNote,
|
|
52
|
+
message: "Order canceled successfully.",
|
|
53
|
+
before: beforeOrder,
|
|
54
|
+
after: afterOrder,
|
|
55
|
+
details: {
|
|
56
|
+
order_id: orderId
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
} catch (err) {
|
|
60
|
+
return handleVtexWriteError(err, `Failed to cancel order ${orderId}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
cancelOrderHandler,
|
|
65
|
+
cancelOrderSchema
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=cancel-order.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/cancel-order.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n cancelOrder,\n getOrderStateSnapshot,\n validateOrderForCancellation,\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\nexport const cancelOrderSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n orderId: z.string().min(1).describe(\"VTEX order identifier to cancel.\"),\n confirmed: confirmationSchemaField,\n reason: z\n .string()\n .trim()\n .min(1)\n .describe(\"Reason for canceling the order. VTEX persists this reason.\")\n .optional(),\n confirmationNote: confirmationNoteSchemaField,\n});\n\nexport async function cancelOrderHandler({\n profileId,\n orderId,\n confirmed,\n reason,\n confirmationNote,\n}: z.infer<typeof cancelOrderSchema>) {\n const confirmationResponse = requireExplicitConfirmation(confirmed, \"cancel_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 validateOrderForCancellation(resolvedProfileId, orderId, reason);\n await cancelOrder(resolvedProfileId, orderId, reason);\n const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId, reason);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"cancel_order\",\n resourceId: orderId,\n riskLevel: \"high\",\n confirmed: true,\n confirmationNote,\n message: \"Order canceled 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 },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to cancel order ${orderId}`);\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,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,WAAW;AAAA,EACX,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,kCAAkC;AAAA,EACtE,WAAW;AAAA,EACX,QAAQ,EACL,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,SAAS,4DAA4D,EACrE,SAAS;AAAA,EACZ,kBAAkB;AACpB,CAAC;AAED,eAAsB,mBAAmB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsC;AACpC,QAAM,uBAAuB,4BAA4B,WAAW,gBAAgB;AAAA,IAClF,UAAU;AAAA,EACZ,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,6BAA6B,mBAAmB,SAAS,MAAM;AACzF,UAAM,YAAY,mBAAmB,SAAS,MAAM;AACpD,UAAM,aAAa,MAAM,sBAAsB,mBAAmB,SAAS,MAAM;AAEjF,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,MACZ;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,0BAA0B,OAAO,EAAE;AAAA,EACtE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createBrand } from "../../services/vtex/vtex-catalog-write.js";
|
|
3
|
+
import {
|
|
4
|
+
buildWriteSuccessResponse,
|
|
5
|
+
handleVtexWriteError,
|
|
6
|
+
resolveVtexWriteProfile,
|
|
7
|
+
vtexProfileIdSchemaField
|
|
8
|
+
} from "./write-helpers.js";
|
|
9
|
+
const createBrandSchema = z.object({
|
|
10
|
+
profileId: vtexProfileIdSchemaField,
|
|
11
|
+
id: z.number().int().positive().describe("Brand ID required by VTEX Catalog API."),
|
|
12
|
+
name: z.string().min(1).describe("Brand name."),
|
|
13
|
+
text: z.string().optional().describe("Meta description text."),
|
|
14
|
+
keywords: z.string().optional().describe("Alternative search terms."),
|
|
15
|
+
siteTitle: z.string().optional().describe("Brand page title."),
|
|
16
|
+
active: z.boolean().optional().describe("Whether the brand should be active."),
|
|
17
|
+
menuHome: z.boolean().optional().describe("Whether the brand should appear in the home menu."),
|
|
18
|
+
linkId: z.string().optional().describe("Brand slug."),
|
|
19
|
+
score: z.number().int().optional().describe("Search score.")
|
|
20
|
+
});
|
|
21
|
+
async function createBrandHandler({
|
|
22
|
+
profileId,
|
|
23
|
+
id,
|
|
24
|
+
name,
|
|
25
|
+
text,
|
|
26
|
+
keywords,
|
|
27
|
+
siteTitle,
|
|
28
|
+
active,
|
|
29
|
+
menuHome,
|
|
30
|
+
linkId,
|
|
31
|
+
score
|
|
32
|
+
}) {
|
|
33
|
+
try {
|
|
34
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
35
|
+
if (!profileResolution.ok) {
|
|
36
|
+
return profileResolution.response;
|
|
37
|
+
}
|
|
38
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
39
|
+
const createdBrand = await createBrand(resolvedProfileId, {
|
|
40
|
+
Id: id,
|
|
41
|
+
Name: name,
|
|
42
|
+
Text: text ?? name,
|
|
43
|
+
Keywords: keywords ?? "",
|
|
44
|
+
SiteTitle: siteTitle ?? name,
|
|
45
|
+
Active: active ?? true,
|
|
46
|
+
MenuHome: menuHome ?? false,
|
|
47
|
+
LinkId: linkId,
|
|
48
|
+
Score: score ?? null,
|
|
49
|
+
AdWordsRemarketingCode: null,
|
|
50
|
+
LomadeeCampaignCode: null
|
|
51
|
+
});
|
|
52
|
+
return buildWriteSuccessResponse({
|
|
53
|
+
profileId: resolvedProfileId,
|
|
54
|
+
operation: "create_brand",
|
|
55
|
+
resourceId: String(createdBrand.Id ?? id),
|
|
56
|
+
riskLevel: "low",
|
|
57
|
+
message: "Brand created successfully.",
|
|
58
|
+
before: null,
|
|
59
|
+
after: createdBrand
|
|
60
|
+
});
|
|
61
|
+
} catch (err) {
|
|
62
|
+
return handleVtexWriteError(err, "Failed to create brand in VTEX");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
createBrandHandler,
|
|
67
|
+
createBrandSchema
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=create-brand.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/create-brand.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport { createBrand } from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const createBrandSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n id: z.number().int().positive().describe(\"Brand ID required by VTEX Catalog API.\"),\n name: z.string().min(1).describe(\"Brand name.\"),\n text: z.string().optional().describe(\"Meta description text.\"),\n keywords: z.string().optional().describe(\"Alternative search terms.\"),\n siteTitle: z.string().optional().describe(\"Brand page title.\"),\n active: z.boolean().optional().describe(\"Whether the brand should be active.\"),\n menuHome: z.boolean().optional().describe(\"Whether the brand should appear in the home menu.\"),\n linkId: z.string().optional().describe(\"Brand slug.\"),\n score: z.number().int().optional().describe(\"Search score.\"),\n});\n\nexport async function createBrandHandler({\n profileId,\n id,\n name,\n text,\n keywords,\n siteTitle,\n active,\n menuHome,\n linkId,\n score,\n}: z.infer<typeof createBrandSchema>) {\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 createdBrand = await createBrand(resolvedProfileId, {\n Id: id,\n Name: name,\n Text: text ?? name,\n Keywords: keywords ?? \"\",\n SiteTitle: siteTitle ?? name,\n Active: active ?? true,\n MenuHome: menuHome ?? false,\n LinkId: linkId,\n Score: score ?? null,\n AdWordsRemarketingCode: null,\n LomadeeCampaignCode: null,\n });\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"create_brand\",\n resourceId: String(createdBrand.Id ?? id),\n riskLevel: \"low\",\n message: \"Brand created successfully.\",\n before: null,\n after: createdBrand,\n });\n } catch (err) {\n return handleVtexWriteError(err, \"Failed to create brand in VTEX\");\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,WAAW;AAAA,EACX,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,wCAAwC;AAAA,EACjF,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,aAAa;AAAA,EAC9C,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,wBAAwB;AAAA,EAC7D,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,2BAA2B;AAAA,EACpE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,mBAAmB;AAAA,EAC7D,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,qCAAqC;AAAA,EAC7E,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,mDAAmD;AAAA,EAC7F,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,aAAa;AAAA,EACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,eAAe;AAC7D,CAAC;AAED,eAAsB,mBAAmB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsC;AACpC,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,eAAe,MAAM,YAAY,mBAAmB;AAAA,MACxD,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,MAAM,QAAQ;AAAA,MACd,UAAU,YAAY;AAAA,MACtB,WAAW,aAAa;AAAA,MACxB,QAAQ,UAAU;AAAA,MAClB,UAAU,YAAY;AAAA,MACtB,QAAQ;AAAA,MACR,OAAO,SAAS;AAAA,MAChB,wBAAwB;AAAA,MACxB,qBAAqB;AAAA,IACvB,CAAC;AAED,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY,OAAO,aAAa,MAAM,EAAE;AAAA,MACxC,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,IACT,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,gCAAgC;AAAA,EACnE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCategory } from "../../services/vtex/vtex-catalog-write.js";
|
|
3
|
+
import {
|
|
4
|
+
buildWriteSuccessResponse,
|
|
5
|
+
handleVtexWriteError,
|
|
6
|
+
resolveVtexWriteProfile,
|
|
7
|
+
vtexProfileIdSchemaField
|
|
8
|
+
} from "./write-helpers.js";
|
|
9
|
+
const createCategorySchema = z.object({
|
|
10
|
+
profileId: vtexProfileIdSchemaField,
|
|
11
|
+
id: z.number().int().positive().optional().describe("Optional category ID. VTEX can generate it."),
|
|
12
|
+
name: z.string().min(1).describe("Category name."),
|
|
13
|
+
title: z.string().min(1).describe("Category page title."),
|
|
14
|
+
description: z.string().min(1).describe("Category meta description."),
|
|
15
|
+
fatherCategoryId: z.number().int().positive().nullable().optional().describe("Parent category ID. Use null for a top-level category."),
|
|
16
|
+
globalCategoryId: z.number().int().nonnegative().describe("Google global category ID."),
|
|
17
|
+
stockKeepingUnitSelectionMode: z.enum(["SPECIFICATION", "LIST"]).describe("How shoppers should choose SKUs in storefront."),
|
|
18
|
+
keywords: z.string().optional().describe("Alternative search terms."),
|
|
19
|
+
showInStoreFront: z.boolean().optional().describe("Whether the category should appear in menus."),
|
|
20
|
+
isActive: z.boolean().optional().describe("Whether the category should be active."),
|
|
21
|
+
activeStoreFrontLink: z.boolean().optional().describe("Whether the category link should be active in storefront."),
|
|
22
|
+
showBrandFilter: z.boolean().optional().describe("Whether the category page should show brand filters."),
|
|
23
|
+
score: z.number().int().nullable().optional().describe("Search score.")
|
|
24
|
+
});
|
|
25
|
+
async function createCategoryHandler({
|
|
26
|
+
profileId,
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
title,
|
|
30
|
+
description,
|
|
31
|
+
fatherCategoryId,
|
|
32
|
+
globalCategoryId,
|
|
33
|
+
stockKeepingUnitSelectionMode,
|
|
34
|
+
keywords,
|
|
35
|
+
showInStoreFront,
|
|
36
|
+
isActive,
|
|
37
|
+
activeStoreFrontLink,
|
|
38
|
+
showBrandFilter,
|
|
39
|
+
score
|
|
40
|
+
}) {
|
|
41
|
+
try {
|
|
42
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
43
|
+
if (!profileResolution.ok) {
|
|
44
|
+
return profileResolution.response;
|
|
45
|
+
}
|
|
46
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
47
|
+
const createdCategory = await createCategory(resolvedProfileId, {
|
|
48
|
+
Id: id,
|
|
49
|
+
Name: name,
|
|
50
|
+
Keywords: keywords ?? "",
|
|
51
|
+
Title: title,
|
|
52
|
+
Description: description,
|
|
53
|
+
AdWordsRemarketingCode: null,
|
|
54
|
+
LomadeeCampaignCode: null,
|
|
55
|
+
FatherCategoryId: fatherCategoryId ?? null,
|
|
56
|
+
GlobalCategoryId: globalCategoryId,
|
|
57
|
+
ShowInStoreFront: showInStoreFront ?? true,
|
|
58
|
+
IsActive: isActive ?? true,
|
|
59
|
+
ActiveStoreFrontLink: activeStoreFrontLink ?? true,
|
|
60
|
+
ShowBrandFilter: showBrandFilter ?? true,
|
|
61
|
+
Score: score ?? null,
|
|
62
|
+
StockKeepingUnitSelectionMode: stockKeepingUnitSelectionMode
|
|
63
|
+
});
|
|
64
|
+
return buildWriteSuccessResponse({
|
|
65
|
+
profileId: resolvedProfileId,
|
|
66
|
+
operation: "create_category",
|
|
67
|
+
resourceId: String(createdCategory.Id ?? id ?? ""),
|
|
68
|
+
riskLevel: "low",
|
|
69
|
+
message: "Category created successfully.",
|
|
70
|
+
before: null,
|
|
71
|
+
after: createdCategory
|
|
72
|
+
});
|
|
73
|
+
} catch (err) {
|
|
74
|
+
return handleVtexWriteError(err, "Failed to create category in VTEX");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
createCategoryHandler,
|
|
79
|
+
createCategorySchema
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=create-category.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/create-category.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport { createCategory } from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const createCategorySchema = z.object({\n profileId: vtexProfileIdSchemaField,\n id: z.number().int().positive().optional().describe(\"Optional category ID. VTEX can generate it.\"),\n name: z.string().min(1).describe(\"Category name.\"),\n title: z.string().min(1).describe(\"Category page title.\"),\n description: z.string().min(1).describe(\"Category meta description.\"),\n fatherCategoryId: z\n .number()\n .int()\n .positive()\n .nullable()\n .optional()\n .describe(\"Parent category ID. Use null for a top-level category.\"),\n globalCategoryId: z.number().int().nonnegative().describe(\"Google global category ID.\"),\n stockKeepingUnitSelectionMode: z\n .enum([\"SPECIFICATION\", \"LIST\"])\n .describe(\"How shoppers should choose SKUs in storefront.\"),\n keywords: z.string().optional().describe(\"Alternative search terms.\"),\n showInStoreFront: z.boolean().optional().describe(\"Whether the category should appear in menus.\"),\n isActive: z.boolean().optional().describe(\"Whether the category should be active.\"),\n activeStoreFrontLink: z\n .boolean()\n .optional()\n .describe(\"Whether the category link should be active in storefront.\"),\n showBrandFilter: z.boolean().optional().describe(\"Whether the category page should show brand filters.\"),\n score: z.number().int().nullable().optional().describe(\"Search score.\"),\n});\n\nexport async function createCategoryHandler({\n profileId,\n id,\n name,\n title,\n description,\n fatherCategoryId,\n globalCategoryId,\n stockKeepingUnitSelectionMode,\n keywords,\n showInStoreFront,\n isActive,\n activeStoreFrontLink,\n showBrandFilter,\n score,\n}: z.infer<typeof createCategorySchema>) {\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 createdCategory = await createCategory(resolvedProfileId, {\n Id: id,\n Name: name,\n Keywords: keywords ?? \"\",\n Title: title,\n Description: description,\n AdWordsRemarketingCode: null,\n LomadeeCampaignCode: null,\n FatherCategoryId: fatherCategoryId ?? null,\n GlobalCategoryId: globalCategoryId,\n ShowInStoreFront: showInStoreFront ?? true,\n IsActive: isActive ?? true,\n ActiveStoreFrontLink: activeStoreFrontLink ?? true,\n ShowBrandFilter: showBrandFilter ?? true,\n Score: score ?? null,\n StockKeepingUnitSelectionMode: stockKeepingUnitSelectionMode,\n });\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"create_category\",\n resourceId: String(createdCategory.Id ?? id ?? \"\"),\n riskLevel: \"low\",\n message: \"Category created successfully.\",\n before: null,\n after: createdCategory,\n });\n } catch (err) {\n return handleVtexWriteError(err, \"Failed to create category in VTEX\");\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,W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B,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,kBAAkB,MAAM,eAAe,mBAAmB;AAAA,MAC9D,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU,YAAY;AAAA,MACtB,OAAO;AAAA,MACP,aAAa;AAAA,MACb,wBAAwB;AAAA,MACxB,qBAAqB;AAAA,MACrB,kBAAkB,oBAAoB;AAAA,MACtC,kBAAkB;AAAA,MAClB,kBAAkB,oBAAoB;AAAA,MACtC,UAAU,YAAY;AAAA,MACtB,sBAAsB,wBAAwB;AAAA,MAC9C,iBAAiB,mBAAmB;AAAA,MACpC,OAAO,SAAS;AAAA,MAChB,+BAA+B;AAAA,IACjC,CAAC;AAED,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY,OAAO,gBAAgB,MAAM,MAAM,EAAE;AAAA,MACjD,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,IACT,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,mCAAmC;AAAA,EACtE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createProduct, createSku, createSkuEan } from "../../services/vtex/vtex-catalog-write.js";
|
|
3
|
+
import {
|
|
4
|
+
buildWriteSuccessResponse,
|
|
5
|
+
handleVtexWriteError,
|
|
6
|
+
resolveVtexWriteProfile,
|
|
7
|
+
vtexProfileIdSchemaField
|
|
8
|
+
} from "./write-helpers.js";
|
|
9
|
+
const productInputSchema = z.object({
|
|
10
|
+
name: z.string().min(1).describe("Product name."),
|
|
11
|
+
categoryId: z.number().int().positive().optional().describe("Existing category ID."),
|
|
12
|
+
categoryPath: z.string().min(1).optional().describe("Category path to create or reuse."),
|
|
13
|
+
brandId: z.number().int().positive().optional().describe("Existing brand ID."),
|
|
14
|
+
brandName: z.string().min(1).optional().describe("Brand name to create or reuse."),
|
|
15
|
+
departmentId: z.number().int().positive().optional().describe("Department ID."),
|
|
16
|
+
refId: z.string().optional().describe("Product reference code."),
|
|
17
|
+
title: z.string().optional().describe("SEO title."),
|
|
18
|
+
description: z.string().optional().describe("Product description."),
|
|
19
|
+
descriptionShort: z.string().optional().describe("Short description."),
|
|
20
|
+
linkId: z.string().optional().describe("Product slug.")
|
|
21
|
+
}).refine((value) => value.categoryId !== void 0 || value.categoryPath !== void 0, {
|
|
22
|
+
message: "Provide either categoryId or categoryPath for the product.",
|
|
23
|
+
path: ["categoryId"]
|
|
24
|
+
}).refine((value) => value.brandId !== void 0 || value.brandName !== void 0, {
|
|
25
|
+
message: "Provide either brandId or brandName for the product.",
|
|
26
|
+
path: ["brandId"]
|
|
27
|
+
});
|
|
28
|
+
const skuInputSchema = z.object({
|
|
29
|
+
name: z.string().min(1).describe("SKU name."),
|
|
30
|
+
refId: z.string().min(1).describe("Internal SKU reference code."),
|
|
31
|
+
ean: z.string().optional().describe("Optional EAN to attach after creation."),
|
|
32
|
+
packagedHeight: z.number().nonnegative().describe("Packaged height."),
|
|
33
|
+
packagedLength: z.number().nonnegative().describe("Packaged length."),
|
|
34
|
+
packagedWidth: z.number().nonnegative().describe("Packaged width."),
|
|
35
|
+
packagedWeightKg: z.number().nonnegative().describe("Packaged weight in kg."),
|
|
36
|
+
height: z.number().nonnegative().optional().describe("Physical height."),
|
|
37
|
+
length: z.number().nonnegative().optional().describe("Physical length."),
|
|
38
|
+
width: z.number().nonnegative().optional().describe("Physical width."),
|
|
39
|
+
weightKg: z.number().nonnegative().optional().describe("Physical weight in kg."),
|
|
40
|
+
activateIfPossible: z.boolean().optional().describe("Whether VTEX should auto-activate the SKU."),
|
|
41
|
+
measurementUnit: z.string().optional().describe("Measurement unit."),
|
|
42
|
+
unitMultiplier: z.number().positive().optional().describe("Unit multiplier.")
|
|
43
|
+
});
|
|
44
|
+
const createProductWithSkuSchema = z.object({
|
|
45
|
+
profileId: vtexProfileIdSchemaField,
|
|
46
|
+
product: productInputSchema.describe("Product payload."),
|
|
47
|
+
sku: skuInputSchema.describe("SKU payload.")
|
|
48
|
+
});
|
|
49
|
+
async function createProductWithSkuHandler({
|
|
50
|
+
profileId,
|
|
51
|
+
product,
|
|
52
|
+
sku
|
|
53
|
+
}) {
|
|
54
|
+
try {
|
|
55
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
56
|
+
if (!profileResolution.ok) {
|
|
57
|
+
return profileResolution.response;
|
|
58
|
+
}
|
|
59
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
60
|
+
const createdProduct = await createProduct(resolvedProfileId, {
|
|
61
|
+
Name: product.name,
|
|
62
|
+
CategoryId: product.categoryId,
|
|
63
|
+
CategoryPath: product.categoryPath,
|
|
64
|
+
BrandId: product.brandId,
|
|
65
|
+
BrandName: product.brandName,
|
|
66
|
+
DepartmentId: product.departmentId,
|
|
67
|
+
RefId: product.refId,
|
|
68
|
+
Title: product.title,
|
|
69
|
+
Description: product.description,
|
|
70
|
+
DescriptionShort: product.descriptionShort,
|
|
71
|
+
LinkId: product.linkId
|
|
72
|
+
});
|
|
73
|
+
const productId = Number(createdProduct.Id);
|
|
74
|
+
const createdSku = await createSku(resolvedProfileId, {
|
|
75
|
+
ProductId: productId,
|
|
76
|
+
Name: sku.name,
|
|
77
|
+
RefId: sku.refId,
|
|
78
|
+
PackagedHeight: sku.packagedHeight,
|
|
79
|
+
PackagedLength: sku.packagedLength,
|
|
80
|
+
PackagedWidth: sku.packagedWidth,
|
|
81
|
+
PackagedWeightKg: sku.packagedWeightKg,
|
|
82
|
+
Height: sku.height,
|
|
83
|
+
Length: sku.length,
|
|
84
|
+
Width: sku.width,
|
|
85
|
+
WeightKg: sku.weightKg,
|
|
86
|
+
ActivateIfPossible: sku.activateIfPossible ?? true,
|
|
87
|
+
IsActive: false,
|
|
88
|
+
MeasurementUnit: sku.measurementUnit,
|
|
89
|
+
UnitMultiplier: sku.unitMultiplier
|
|
90
|
+
});
|
|
91
|
+
const skuId = createdSku.Id == null ? void 0 : String(createdSku.Id);
|
|
92
|
+
if (skuId && sku.ean?.trim()) {
|
|
93
|
+
await createSkuEan(resolvedProfileId, skuId, sku.ean.trim());
|
|
94
|
+
createdSku.Eans = [sku.ean.trim()];
|
|
95
|
+
}
|
|
96
|
+
return buildWriteSuccessResponse({
|
|
97
|
+
profileId: resolvedProfileId,
|
|
98
|
+
operation: "create_product_with_sku",
|
|
99
|
+
resourceId: String(createdProduct.Id),
|
|
100
|
+
riskLevel: "low",
|
|
101
|
+
message: "Product and SKU created successfully.",
|
|
102
|
+
before: null,
|
|
103
|
+
after: {
|
|
104
|
+
product: createdProduct,
|
|
105
|
+
sku: createdSku
|
|
106
|
+
},
|
|
107
|
+
details: {
|
|
108
|
+
product_id: createdProduct.Id,
|
|
109
|
+
sku_id: createdSku.Id
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
} catch (err) {
|
|
113
|
+
return handleVtexWriteError(err, "Failed to create product with SKU in VTEX");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
createProductWithSkuHandler,
|
|
118
|
+
createProductWithSkuSchema
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=create-product-with-sku.js.map
|