@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.
- package/README.md +38 -427
- 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/search-console/search-console-utils.js +275 -0
- package/dist/src/services/search-console/search-console-utils.js.map +7 -0
- 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/search-console/country-breakdown.js +1 -1
- package/dist/src/tools/search-console/country-breakdown.js.map +1 -1
- package/dist/src/tools/search-console/device-breakdown.js +1 -1
- package/dist/src/tools/search-console/device-breakdown.js.map +1 -1
- package/dist/src/tools/search-console/high-impression-low-click-queries.js +1 -1
- package/dist/src/tools/search-console/high-impression-low-click-queries.js.map +1 -1
- package/dist/src/tools/search-console/list-accessible-sites.js +1 -1
- package/dist/src/tools/search-console/list-accessible-sites.js.map +1 -1
- package/dist/src/tools/search-console/low-ctr-opportunities.js +1 -1
- package/dist/src/tools/search-console/low-ctr-opportunities.js.map +1 -1
- package/dist/src/tools/search-console/page-performance.js +1 -1
- package/dist/src/tools/search-console/page-performance.js.map +1 -1
- package/dist/src/tools/search-console/product-demand-low-capture-queries.js +1 -1
- package/dist/src/tools/search-console/product-demand-low-capture-queries.js.map +1 -1
- package/dist/src/tools/search-console/query-page-matrix.js +1 -1
- package/dist/src/tools/search-console/query-page-matrix.js.map +1 -1
- package/dist/src/tools/search-console/query-performance.js +1 -1
- package/dist/src/tools/search-console/query-performance.js.map +1 -1
- package/dist/src/tools/search-console/quick-win-opportunities.js +1 -1
- package/dist/src/tools/search-console/quick-win-opportunities.js.map +1 -1
- package/dist/src/tools/search-console/rising-non-brand-queries.js +1 -1
- package/dist/src/tools/search-console/rising-non-brand-queries.js.map +1 -1
- package/dist/src/tools/search-console/search-performance.js +1 -1
- package/dist/src/tools/search-console/search-performance.js.map +1 -1
- package/dist/src/tools/search-console/site-context.js +1 -1
- package/dist/src/tools/search-console/site-context.js.map +1 -1
- package/dist/src/tools/search-console/visibility-declines.js +1 -1
- package/dist/src/tools/search-console/visibility-declines.js.map +1 -1
- 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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/create-sku.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport { createSku, createSkuEan } from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const createSkuSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n productId: z.number().int().positive().describe(\"Parent product ID.\"),\n name: z.string().min(1).describe(\"SKU name.\"),\n refId: z.string().min(1).describe(\"Internal SKU reference code.\"),\n ean: z.string().optional().describe(\"Optional EAN to attach after SKU creation.\"),\n packagedHeight: z.number().nonnegative().describe(\"Packaged height.\"),\n packagedLength: z.number().nonnegative().describe(\"Packaged length.\"),\n packagedWidth: z.number().nonnegative().describe(\"Packaged width.\"),\n packagedWeightKg: z.number().nonnegative().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 isActive: z\n .boolean()\n .optional()\n .describe(\"Whether the SKU should be created as active. VTEX recommends false during creation.\"),\n activateIfPossible: z\n .boolean()\n .optional()\n .describe(\"Whether VTEX should auto-activate the SKU when an image or active component exists.\"),\n measurementUnit: z.string().optional().describe(\"Measurement unit, for example `un`.\"),\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});\n\nexport async function createSkuHandler({\n profileId,\n productId,\n name,\n refId,\n ean,\n packagedHeight,\n packagedLength,\n packagedWidth,\n packagedWeightKg,\n height,\n length,\n width,\n weightKg,\n isActive,\n activateIfPossible,\n measurementUnit,\n unitMultiplier,\n manufacturerCode,\n commercialConditionId,\n}: z.infer<typeof createSkuSchema>) {\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 ProductId: productId,\n Name: name,\n RefId: refId,\n PackagedHeight: packagedHeight,\n PackagedLength: packagedLength,\n PackagedWidth: packagedWidth,\n PackagedWeightKg: packagedWeightKg,\n ActivateIfPossible: activateIfPossible ?? true,\n IsActive: isActive ?? false,\n };\n\n if (height !== undefined) payload.Height = height;\n if (length !== undefined) payload.Length = length;\n if (width !== undefined) payload.Width = width;\n if (weightKg !== undefined) payload.WeightKg = weightKg;\n if (measurementUnit !== undefined) payload.MeasurementUnit = measurementUnit;\n if (unitMultiplier !== undefined) payload.UnitMultiplier = unitMultiplier;\n if (manufacturerCode !== undefined) payload.ManufacturerCode = manufacturerCode;\n if (commercialConditionId !== undefined) payload.CommercialConditionId = commercialConditionId;\n\n const createdSku = await createSku(resolvedProfileId, payload);\n const resourceId = createdSku.Id == null ? undefined : String(createdSku.Id);\n\n if (resourceId && ean?.trim()) {\n await createSkuEan(resolvedProfileId, resourceId, ean.trim());\n createdSku.Eans = [ean.trim()];\n }\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"create_sku\",\n resourceId,\n riskLevel: \"low\",\n message: \"SKU created successfully.\",\n before: null,\n after: createdSku,\n details: {\n product_id: productId,\n sku_id: resourceId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, \"Failed to create SKU in VTEX\");\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,WAAW,oBAAoB;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,kBAAkB,EAAE,OAAO;AAAA,EACtC,WAAW;AAAA,EACX,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,oBAAoB;AAAA,EACpE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,WAAW;AAAA,EAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,8BAA8B;AAAA,EAChE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,4CAA4C;AAAA,EAChF,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,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+1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createSpecificationValue } from "../../services/vtex/vtex-catalog-write.js";
|
|
3
|
+
import {
|
|
4
|
+
buildWriteSuccessResponse,
|
|
5
|
+
handleVtexWriteError,
|
|
6
|
+
resolveVtexWriteProfile,
|
|
7
|
+
vtexProfileIdSchemaField
|
|
8
|
+
} from "./write-helpers.js";
|
|
9
|
+
const createSpecificationValueSchema = z.object({
|
|
10
|
+
profileId: vtexProfileIdSchemaField,
|
|
11
|
+
fieldId: z.number().int().positive().describe("Specification field ID."),
|
|
12
|
+
name: z.string().min(1).describe("Specification value name."),
|
|
13
|
+
isActive: z.boolean().optional().describe("Whether the value should be active."),
|
|
14
|
+
position: z.number().int().nonnegative().optional().describe("Display position.")
|
|
15
|
+
});
|
|
16
|
+
async function createSpecificationValueHandler({
|
|
17
|
+
profileId,
|
|
18
|
+
fieldId,
|
|
19
|
+
name,
|
|
20
|
+
isActive,
|
|
21
|
+
position
|
|
22
|
+
}) {
|
|
23
|
+
try {
|
|
24
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
25
|
+
if (!profileResolution.ok) {
|
|
26
|
+
return profileResolution.response;
|
|
27
|
+
}
|
|
28
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
29
|
+
const createdValue = await createSpecificationValue(resolvedProfileId, {
|
|
30
|
+
FieldId: fieldId,
|
|
31
|
+
Name: name,
|
|
32
|
+
IsActive: isActive ?? true,
|
|
33
|
+
Position: position ?? 0,
|
|
34
|
+
Text: null
|
|
35
|
+
});
|
|
36
|
+
return buildWriteSuccessResponse({
|
|
37
|
+
profileId: resolvedProfileId,
|
|
38
|
+
operation: "create_specification_value",
|
|
39
|
+
resourceId: String(createdValue.FieldValueId ?? ""),
|
|
40
|
+
riskLevel: "low",
|
|
41
|
+
message: "Specification value created successfully.",
|
|
42
|
+
before: null,
|
|
43
|
+
after: createdValue
|
|
44
|
+
});
|
|
45
|
+
} catch (err) {
|
|
46
|
+
return handleVtexWriteError(err, "Failed to create specification value in VTEX");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
createSpecificationValueHandler,
|
|
51
|
+
createSpecificationValueSchema
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=create-specification-value.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/create-specification-value.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport { createSpecificationValue } from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const createSpecificationValueSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n fieldId: z.number().int().positive().describe(\"Specification field ID.\"),\n name: z.string().min(1).describe(\"Specification value name.\"),\n isActive: z.boolean().optional().describe(\"Whether the value should be active.\"),\n position: z.number().int().nonnegative().optional().describe(\"Display position.\"),\n});\n\nexport async function createSpecificationValueHandler({\n profileId,\n fieldId,\n name,\n isActive,\n position,\n}: z.infer<typeof createSpecificationValueSchema>) {\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 createdValue = await createSpecificationValue(resolvedProfileId, {\n FieldId: fieldId,\n Name: name,\n IsActive: isActive ?? true,\n Position: position ?? 0,\n Text: null,\n });\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"create_specification_value\",\n resourceId: String(createdValue.FieldValueId ?? \"\"),\n riskLevel: \"low\",\n message: \"Specification value created successfully.\",\n before: null,\n after: createdValue,\n });\n } catch (err) {\n return handleVtexWriteError(err, \"Failed to create specification value in VTEX\");\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,iCAAiC,EAAE,OAAO;AAAA,EACrD,WAAW;AAAA,EACX,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,yBAAyB;AAAA,EACvE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,2BAA2B;AAAA,EAC5D,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,qCAAqC;AAAA,EAC/E,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,mBAAmB;AAClF,CAAC;AAED,eAAsB,gCAAgC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,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,eAAe,MAAM,yBAAyB,mBAAmB;AAAA,MACrE,SAAS;AAAA,MACT,MAAM;AAAA,MACN,UAAU,YAAY;AAAA,MACtB,UAAU,YAAY;AAAA,MACtB,MAAM;AAAA,IACR,CAAC;AAED,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY,OAAO,aAAa,gBAAgB,EAAE;AAAA,MAClD,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,IACT,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,8CAA8C;AAAA,EACjF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createSpecification } from "../../services/vtex/vtex-catalog-write.js";
|
|
3
|
+
import {
|
|
4
|
+
buildWriteSuccessResponse,
|
|
5
|
+
handleVtexWriteError,
|
|
6
|
+
resolveVtexWriteProfile,
|
|
7
|
+
vtexProfileIdSchemaField
|
|
8
|
+
} from "./write-helpers.js";
|
|
9
|
+
const createSpecificationSchema = z.object({
|
|
10
|
+
profileId: vtexProfileIdSchemaField,
|
|
11
|
+
fieldTypeId: z.enum(["1", "2", "4", "5", "6", "7", "8", "9"]).transform((value) => Number(value)).describe("Specification field type ID."),
|
|
12
|
+
fieldGroupId: z.number().int().positive().describe("Specification group ID."),
|
|
13
|
+
name: z.string().min(1).describe("Specification name."),
|
|
14
|
+
categoryId: z.number().int().positive().optional().describe("Optional category ID."),
|
|
15
|
+
description: z.string().optional().describe("Specification description."),
|
|
16
|
+
position: z.number().int().nonnegative().optional().describe("Display position."),
|
|
17
|
+
isFilter: z.boolean().optional().describe("Whether the specification should act as a filter."),
|
|
18
|
+
isRequired: z.boolean().optional().describe("Whether the specification is required."),
|
|
19
|
+
isOnProductDetails: z.boolean().optional().describe("Whether the specification should appear on product details."),
|
|
20
|
+
isStockKeepingUnit: z.boolean().optional().describe("Whether this is an SKU specification."),
|
|
21
|
+
isWizard: z.boolean().optional().describe("Wizard flag from VTEX."),
|
|
22
|
+
isActive: z.boolean().optional().describe("Whether the specification is active."),
|
|
23
|
+
isTopMenuLinkActive: z.boolean().optional().describe("Top menu link flag."),
|
|
24
|
+
isSideMenuLinkActive: z.boolean().optional().describe("Side menu link flag."),
|
|
25
|
+
defaultValue: z.string().optional().describe("Default value.")
|
|
26
|
+
});
|
|
27
|
+
async function createSpecificationHandler({
|
|
28
|
+
profileId,
|
|
29
|
+
fieldTypeId,
|
|
30
|
+
fieldGroupId,
|
|
31
|
+
name,
|
|
32
|
+
categoryId,
|
|
33
|
+
description,
|
|
34
|
+
position,
|
|
35
|
+
isFilter,
|
|
36
|
+
isRequired,
|
|
37
|
+
isOnProductDetails,
|
|
38
|
+
isStockKeepingUnit,
|
|
39
|
+
isWizard,
|
|
40
|
+
isActive,
|
|
41
|
+
isTopMenuLinkActive,
|
|
42
|
+
isSideMenuLinkActive,
|
|
43
|
+
defaultValue
|
|
44
|
+
}) {
|
|
45
|
+
try {
|
|
46
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
47
|
+
if (!profileResolution.ok) {
|
|
48
|
+
return profileResolution.response;
|
|
49
|
+
}
|
|
50
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
51
|
+
const createdSpecification = await createSpecification(resolvedProfileId, {
|
|
52
|
+
FieldTypeId: fieldTypeId,
|
|
53
|
+
FieldGroupId: fieldGroupId,
|
|
54
|
+
Name: name,
|
|
55
|
+
CategoryId: categoryId,
|
|
56
|
+
Description: description ?? null,
|
|
57
|
+
Position: position ?? 0,
|
|
58
|
+
IsFilter: isFilter ?? false,
|
|
59
|
+
IsRequired: isRequired ?? false,
|
|
60
|
+
IsOnProductDetails: isOnProductDetails ?? true,
|
|
61
|
+
IsStockKeepingUnit: isStockKeepingUnit ?? false,
|
|
62
|
+
IsWizard: isWizard ?? false,
|
|
63
|
+
IsActive: isActive ?? true,
|
|
64
|
+
IsTopMenuLinkActive: isTopMenuLinkActive ?? false,
|
|
65
|
+
IsSideMenuLinkActive: isSideMenuLinkActive ?? false,
|
|
66
|
+
DefaultValue: defaultValue ?? ""
|
|
67
|
+
});
|
|
68
|
+
return buildWriteSuccessResponse({
|
|
69
|
+
profileId: resolvedProfileId,
|
|
70
|
+
operation: "create_specification",
|
|
71
|
+
resourceId: String(createdSpecification.Id ?? ""),
|
|
72
|
+
riskLevel: "low",
|
|
73
|
+
message: "Specification created successfully.",
|
|
74
|
+
before: null,
|
|
75
|
+
after: createdSpecification
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
return handleVtexWriteError(err, "Failed to create specification in VTEX");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
createSpecificationHandler,
|
|
83
|
+
createSpecificationSchema
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=create-specification.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/create-specification.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport { createSpecification } from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const createSpecificationSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n fieldTypeId: z\n .enum([\"1\", \"2\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"])\n .transform((value) => Number(value))\n .describe(\"Specification field type ID.\"),\n fieldGroupId: z.number().int().positive().describe(\"Specification group ID.\"),\n name: z.string().min(1).describe(\"Specification name.\"),\n categoryId: z.number().int().positive().optional().describe(\"Optional category ID.\"),\n description: z.string().optional().describe(\"Specification description.\"),\n position: z.number().int().nonnegative().optional().describe(\"Display position.\"),\n isFilter: z.boolean().optional().describe(\"Whether the specification should act as a filter.\"),\n isRequired: z.boolean().optional().describe(\"Whether the specification is required.\"),\n isOnProductDetails: z.boolean().optional().describe(\"Whether the specification should appear on product details.\"),\n isStockKeepingUnit: z.boolean().optional().describe(\"Whether this is an SKU specification.\"),\n isWizard: z.boolean().optional().describe(\"Wizard flag from VTEX.\"),\n isActive: z.boolean().optional().describe(\"Whether the specification is active.\"),\n isTopMenuLinkActive: z.boolean().optional().describe(\"Top menu link flag.\"),\n isSideMenuLinkActive: z.boolean().optional().describe(\"Side menu link flag.\"),\n defaultValue: z.string().optional().describe(\"Default value.\"),\n});\n\nexport async function createSpecificationHandler({\n profileId,\n fieldTypeId,\n fieldGroupId,\n name,\n categoryId,\n description,\n position,\n isFilter,\n isRequired,\n isOnProductDetails,\n isStockKeepingUnit,\n isWizard,\n isActive,\n isTopMenuLinkActive,\n isSideMenuLinkActive,\n defaultValue,\n}: z.infer<typeof createSpecificationSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const createdSpecification = await createSpecification(resolvedProfileId, {\n FieldTypeId: fieldTypeId,\n FieldGroupId: fieldGroupId,\n Name: name,\n CategoryId: categoryId,\n Description: description ?? null,\n Position: position ?? 0,\n IsFilter: isFilter ?? false,\n IsRequired: isRequired ?? false,\n IsOnProductDetails: isOnProductDetails ?? true,\n IsStockKeepingUnit: isStockKeepingUnit ?? false,\n IsWizard: isWizard ?? false,\n IsActive: isActive ?? true,\n IsTopMenuLinkActive: isTopMenuLinkActive ?? false,\n IsSideMenuLinkActive: isSideMenuLinkActive ?? false,\n DefaultValue: defaultValue ?? \"\",\n });\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"create_specification\",\n resourceId: String(createdSpecification.Id ?? \"\"),\n riskLevel: \"low\",\n message: \"Specification created successfully.\",\n before: null,\n after: createdSpecification,\n });\n } catch (err) {\n return handleVtexWriteError(err, \"Failed to create specification in VTEX\");\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,WAAW;AAAA,EACX,aAAa,EACV,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG,CAAC,EAC7C,UAAU,CAAC,UAAU,OAAO,KAAK,CAAC,EAClC,SAAS,8BAA8B;AAAA,EAC1C,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,yBAAyB;AAAA,EAC5E,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,qBAAqB;AAAA,EACtD,YAAY,EAAE,OAAO,EAAE,IAA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AAc;AAAA,MACd,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,aAAa,eAAe;AAAA,MAC5B,UAAU,YAAY;AAAA,MACtB,UAAU,YAAY;AAAA,MACtB,YAAY,cAAc;AAAA,MAC1B,oBAAoB,sBAAsB;AAAA,MAC1C,oBAAoB,sBAAsB;AAAA,MAC1C,UAAU,YAAY;AAAA,MACtB,UAAU,YAAY;AAAA,MACtB,qBAAqB,uBAAuB;AAAA,MAC5C,sBAAsB,wBAAwB;AAAA,MAC9C,cAAc,gBAAgB;AAAA,IAChC,CAAC;AAED,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY,OAAO,qBAAqB,MAAM,EAAE;AAAA,MAChD,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,IACT,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,wCAAwC;AAAA,EAC3E;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
buildSkuUpdatePayload,
|
|
4
|
+
getSku,
|
|
5
|
+
updateSku
|
|
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 deactivateSkuSchema = z.object({
|
|
14
|
+
profileId: vtexProfileIdSchemaField,
|
|
15
|
+
skuId: z.string().min(1).describe("VTEX SKU identifier to deactivate.")
|
|
16
|
+
});
|
|
17
|
+
async function deactivateSkuHandler({
|
|
18
|
+
profileId,
|
|
19
|
+
skuId
|
|
20
|
+
}) {
|
|
21
|
+
try {
|
|
22
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
23
|
+
if (!profileResolution.ok) {
|
|
24
|
+
return profileResolution.response;
|
|
25
|
+
}
|
|
26
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
27
|
+
const beforeSku = await getSku(resolvedProfileId, skuId);
|
|
28
|
+
const afterSku = await updateSku(
|
|
29
|
+
resolvedProfileId,
|
|
30
|
+
skuId,
|
|
31
|
+
buildSkuUpdatePayload(beforeSku, { isActive: false })
|
|
32
|
+
);
|
|
33
|
+
return buildWriteSuccessResponse({
|
|
34
|
+
profileId: resolvedProfileId,
|
|
35
|
+
operation: "deactivate_sku",
|
|
36
|
+
resourceId: skuId,
|
|
37
|
+
riskLevel: "low",
|
|
38
|
+
message: "SKU deactivated successfully.",
|
|
39
|
+
before: beforeSku,
|
|
40
|
+
after: afterSku,
|
|
41
|
+
details: {
|
|
42
|
+
sku_id: skuId
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
} catch (err) {
|
|
46
|
+
return handleVtexWriteError(err, `Failed to deactivate SKU ${skuId}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
deactivateSkuHandler,
|
|
51
|
+
deactivateSkuSchema
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=deactivate-sku.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/deactivate-sku.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n buildSkuUpdatePayload,\n getSku,\n updateSku,\n} from \"../../services/vtex/vtex-catalog-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const deactivateSkuSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"VTEX SKU identifier to deactivate.\"),\n});\n\nexport async function deactivateSkuHandler({\n profileId,\n skuId,\n}: z.infer<typeof deactivateSkuSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeSku = await getSku(resolvedProfileId, skuId);\n const afterSku = await updateSku(\n resolvedProfileId,\n skuId,\n buildSkuUpdatePayload(beforeSku, { isActive: false })\n );\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"deactivate_sku\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"SKU deactivated successfully.\",\n before: beforeSku,\n after: afterSku,\n details: {\n sku_id: skuId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to deactivate SKU ${skuId}`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,oCAAoC;AACxE,CAAC;AAED,eAAsB,qBAAqB;AAAA,EACzC;AAAA,EACA;AACF,GAAwC;AACtC,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,YAAY,MAAM,OAAO,mBAAmB,KAAK;AACvD,UAAM,WAAW,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA,sBAAsB,WAAW,EAAE,UAAU,MAAM,CAAC;AAAA,IACtD;AAEA,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,4BAA4B,KAAK,EAAE;AAAA,EACtE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getSkuPrice } from "../../services/vtex/vtex-pricing.js";
|
|
3
|
+
import { deleteFixedPricesForPriceTable } from "../../services/vtex/vtex-pricing-write.js";
|
|
4
|
+
import {
|
|
5
|
+
buildWriteSuccessResponse,
|
|
6
|
+
handleVtexWriteError,
|
|
7
|
+
resolveVtexWriteProfile,
|
|
8
|
+
vtexProfileIdSchemaField
|
|
9
|
+
} from "./write-helpers.js";
|
|
10
|
+
const deleteFixedPriceSchema = z.object({
|
|
11
|
+
profileId: vtexProfileIdSchemaField,
|
|
12
|
+
skuId: z.string().min(1).describe("SKU item identifier used by VTEX Pricing."),
|
|
13
|
+
priceTableId: z.string().min(1).describe("Trade policy or price table identifier to clear.")
|
|
14
|
+
});
|
|
15
|
+
async function deleteFixedPriceHandler({
|
|
16
|
+
profileId,
|
|
17
|
+
skuId,
|
|
18
|
+
priceTableId
|
|
19
|
+
}) {
|
|
20
|
+
try {
|
|
21
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
22
|
+
if (!profileResolution.ok) {
|
|
23
|
+
return profileResolution.response;
|
|
24
|
+
}
|
|
25
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
26
|
+
const beforePrice = await getSkuPrice(resolvedProfileId, skuId);
|
|
27
|
+
await deleteFixedPricesForPriceTable(resolvedProfileId, skuId, priceTableId);
|
|
28
|
+
const afterPrice = await getSkuPrice(resolvedProfileId, skuId);
|
|
29
|
+
return buildWriteSuccessResponse({
|
|
30
|
+
profileId: resolvedProfileId,
|
|
31
|
+
operation: "delete_fixed_price",
|
|
32
|
+
resourceId: skuId,
|
|
33
|
+
riskLevel: "low",
|
|
34
|
+
message: "Fixed prices deleted successfully for the selected price table.",
|
|
35
|
+
before: beforePrice,
|
|
36
|
+
after: afterPrice,
|
|
37
|
+
details: {
|
|
38
|
+
sku_id: skuId,
|
|
39
|
+
price_table_id: priceTableId
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return handleVtexWriteError(
|
|
44
|
+
err,
|
|
45
|
+
`Failed to delete fixed prices for SKU ${skuId} on price table ${priceTableId}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
deleteFixedPriceHandler,
|
|
51
|
+
deleteFixedPriceSchema
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=delete-fixed-price.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/delete-fixed-price.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport { getSkuPrice } from \"../../services/vtex/vtex-pricing.js\";\nimport { deleteFixedPricesForPriceTable } from \"../../services/vtex/vtex-pricing-write.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const deleteFixedPriceSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU item identifier used by VTEX Pricing.\"),\n priceTableId: z.string().min(1).describe(\"Trade policy or price table identifier to clear.\"),\n});\n\nexport async function deleteFixedPriceHandler({\n profileId,\n skuId,\n priceTableId,\n}: z.infer<typeof deleteFixedPriceSchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforePrice = await getSkuPrice(resolvedProfileId, skuId);\n\n await deleteFixedPricesForPriceTable(resolvedProfileId, skuId, priceTableId);\n\n const afterPrice = await getSkuPrice(resolvedProfileId, skuId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"delete_fixed_price\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Fixed prices deleted successfully for the selected price table.\",\n before: beforePrice as unknown as Record<string, unknown>,\n after: afterPrice as unknown as Record<string, unknown>,\n details: {\n sku_id: skuId,\n price_table_id: priceTableId,\n },\n });\n } catch (err) {\n return handleVtexWriteError(\n err,\n `Failed to delete fixed prices for SKU ${skuId} on price table ${priceTableId}`\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAC5B,SAAS,sCAAsC;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,2CAA2C;AAAA,EAC7E,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,kDAAkD;AAC7F,CAAC;AAED,eAAsB,wBAAwB;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AACF,GAA2C;AACzC,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,cAAc,MAAM,YAAY,mBAAmB,KAAK;AAE9D,UAAM,+BAA+B,mBAAmB,OAAO,YAAY;AAE3E,UAAM,aAAa,MAAM,YAAY,mBAAmB,KAAK;AAE7D,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,gBAAgB;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,MACA,yCAAyC,KAAK,mBAAmB,YAAY;AAAA,IAC/E;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,9 +4,29 @@ export * from "./inventory-check.js";
|
|
|
4
4
|
export * from "./warehouse-inventory.js";
|
|
5
5
|
export * from "./update-inventory.js";
|
|
6
6
|
export * from "./update-lead-time.js";
|
|
7
|
+
export * from "./toggle-unlimited-quantity.js";
|
|
7
8
|
export * from "./sku-price.js";
|
|
8
9
|
export * from "./computed-price.js";
|
|
9
10
|
export * from "./product-offers.js";
|
|
10
11
|
export * from "./sku-offers.js";
|
|
12
|
+
export * from "./update-sku-price.js";
|
|
13
|
+
export * from "./upsert-fixed-price.js";
|
|
14
|
+
export * from "./delete-fixed-price.js";
|
|
15
|
+
export * from "./activate-sku.js";
|
|
16
|
+
export * from "./deactivate-sku.js";
|
|
17
|
+
export * from "./update-product-basic-fields.js";
|
|
18
|
+
export * from "./update-sku-basic-fields.js";
|
|
19
|
+
export * from "./create-product.js";
|
|
20
|
+
export * from "./create-sku.js";
|
|
21
|
+
export * from "./create-product-with-sku.js";
|
|
22
|
+
export * from "./create-brand.js";
|
|
23
|
+
export * from "./create-category.js";
|
|
24
|
+
export * from "./create-specification.js";
|
|
25
|
+
export * from "./create-specification-value.js";
|
|
26
|
+
export * from "./associate-specification.js";
|
|
27
|
+
export * from "./attach-catalog-image.js";
|
|
28
|
+
export * from "./cancel-order.js";
|
|
29
|
+
export * from "./invoice-order.js";
|
|
30
|
+
export * from "./add-order-tracking.js";
|
|
11
31
|
export * from "./profile-resolution.js";
|
|
12
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/tools/vtex/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./orders-summary.js\";\nexport * from \"./order-details.js\";\nexport * from \"./inventory-check.js\";\nexport * from \"./warehouse-inventory.js\";\nexport * from \"./update-inventory.js\";\nexport * from \"./update-lead-time.js\";\nexport * from \"./sku-price.js\";\nexport * from \"./computed-price.js\";\nexport * from \"./product-offers.js\";\nexport * from \"./sku-offers.js\";\nexport * from \"./profile-resolution.js\";\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from \"./orders-summary.js\";\nexport * from \"./order-details.js\";\nexport * from \"./inventory-check.js\";\nexport * from \"./warehouse-inventory.js\";\nexport * from \"./update-inventory.js\";\nexport * from \"./update-lead-time.js\";\nexport * from \"./toggle-unlimited-quantity.js\";\nexport * from \"./sku-price.js\";\nexport * from \"./computed-price.js\";\nexport * from \"./product-offers.js\";\nexport * from \"./sku-offers.js\";\nexport * from \"./update-sku-price.js\";\nexport * from \"./upsert-fixed-price.js\";\nexport * from \"./delete-fixed-price.js\";\nexport * from \"./activate-sku.js\";\nexport * from \"./deactivate-sku.js\";\nexport * from \"./update-product-basic-fields.js\";\nexport * from \"./update-sku-basic-fields.js\";\nexport * from \"./create-product.js\";\nexport * from \"./create-sku.js\";\nexport * from \"./create-product-with-sku.js\";\nexport * from \"./create-brand.js\";\nexport * from \"./create-category.js\";\nexport * from \"./create-specification.js\";\nexport * from \"./create-specification-value.js\";\nexport * from \"./associate-specification.js\";\nexport * from \"./attach-catalog-image.js\";\nexport * from \"./cancel-order.js\";\nexport * from \"./invoice-order.js\";\nexport * from \"./add-order-tracking.js\";\nexport * from \"./profile-resolution.js\";\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
getOrderStateSnapshot,
|
|
4
|
+
invoiceOrder,
|
|
5
|
+
validateOrderForInvoice
|
|
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 invoiceItemSchema = z.object({
|
|
17
|
+
id: z.string().min(1).describe("SKU ID being invoiced."),
|
|
18
|
+
price: z.number().int().positive().describe("Unit price in cents, without decimal separator."),
|
|
19
|
+
quantity: z.number().int().positive().describe("Quantity being invoiced."),
|
|
20
|
+
description: z.string().optional().describe("Optional extra description for this line.")
|
|
21
|
+
});
|
|
22
|
+
const invoiceOrderSchema = z.object({
|
|
23
|
+
profileId: vtexProfileIdSchemaField,
|
|
24
|
+
orderId: z.string().min(1).describe("VTEX order identifier to invoice."),
|
|
25
|
+
confirmed: confirmationSchemaField,
|
|
26
|
+
confirmationNote: confirmationNoteSchemaField,
|
|
27
|
+
type: z.enum(["Output", "Input"]).describe("Invoice type."),
|
|
28
|
+
issuanceDate: z.string().min(1).describe("Invoice issuance timestamp."),
|
|
29
|
+
invoiceNumber: z.string().min(1).describe("Invoice number."),
|
|
30
|
+
invoiceValue: z.string().min(1).describe("Invoice total in cents, represented as a string without decimal separator."),
|
|
31
|
+
items: z.array(invoiceItemSchema).min(1).describe("Items being invoiced."),
|
|
32
|
+
invoiceKey: z.string().optional().describe("Optional invoice key."),
|
|
33
|
+
invoiceUrl: z.string().url().optional().describe("Optional invoice URL."),
|
|
34
|
+
invoiceOrderNumber: z.string().optional().describe("Optional order number from merchant ERP."),
|
|
35
|
+
courier: z.string().optional().describe("Optional carrier name."),
|
|
36
|
+
trackingNumber: z.string().optional().describe("Optional tracking number."),
|
|
37
|
+
trackingUrl: z.string().url().optional().describe("Optional tracking URL.")
|
|
38
|
+
});
|
|
39
|
+
async function invoiceOrderHandler({
|
|
40
|
+
profileId,
|
|
41
|
+
orderId,
|
|
42
|
+
confirmed,
|
|
43
|
+
confirmationNote,
|
|
44
|
+
...payload
|
|
45
|
+
}) {
|
|
46
|
+
const confirmationResponse = requireExplicitConfirmation(confirmed, "invoice_order", {
|
|
47
|
+
order_id: orderId
|
|
48
|
+
});
|
|
49
|
+
if (confirmationResponse) {
|
|
50
|
+
return confirmationResponse;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
54
|
+
if (!profileResolution.ok) {
|
|
55
|
+
return profileResolution.response;
|
|
56
|
+
}
|
|
57
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
58
|
+
const beforeOrder = await validateOrderForInvoice(resolvedProfileId, orderId);
|
|
59
|
+
await invoiceOrder(resolvedProfileId, orderId, payload);
|
|
60
|
+
const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId);
|
|
61
|
+
return buildWriteSuccessResponse({
|
|
62
|
+
profileId: resolvedProfileId,
|
|
63
|
+
operation: "invoice_order",
|
|
64
|
+
resourceId: orderId,
|
|
65
|
+
riskLevel: "high",
|
|
66
|
+
confirmed: true,
|
|
67
|
+
confirmationNote,
|
|
68
|
+
message: "Order invoiced successfully.",
|
|
69
|
+
before: beforeOrder,
|
|
70
|
+
after: afterOrder,
|
|
71
|
+
details: {
|
|
72
|
+
order_id: orderId,
|
|
73
|
+
invoice_number: payload.invoiceNumber
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
} catch (err) {
|
|
77
|
+
return handleVtexWriteError(err, `Failed to invoice order ${orderId}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
invoiceOrderHandler,
|
|
82
|
+
invoiceOrderSchema
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=invoice-order.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/invoice-order.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getOrderStateSnapshot,\n invoiceOrder,\n validateOrderForInvoice,\n} from \"../../services/vtex/vtex-orders-write.js\";\nimport {\n buildWriteSuccessResponse,\n confirmationNoteSchemaField,\n confirmationSchemaField,\n handleVtexWriteError,\n requireExplicitConfirmation,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nconst invoiceItemSchema = z.object({\n id: z.string().min(1).describe(\"SKU ID being invoiced.\"),\n price: z\n .number()\n .int()\n .positive()\n .describe(\"Unit price in cents, without decimal separator.\"),\n quantity: z.number().int().positive().describe(\"Quantity being invoiced.\"),\n description: z.string().optional().describe(\"Optional extra description for this line.\"),\n});\n\nexport const invoiceOrderSchema = z.object({\n profileId: vtexProfileIdSchemaField,\n orderId: z.string().min(1).describe(\"VTEX order identifier to invoice.\"),\n confirmed: confirmationSchemaField,\n confirmationNote: confirmationNoteSchemaField,\n type: z.enum([\"Output\", \"Input\"]).describe(\"Invoice type.\"),\n issuanceDate: z.string().min(1).describe(\"Invoice issuance timestamp.\"),\n invoiceNumber: z.string().min(1).describe(\"Invoice number.\"),\n invoiceValue: z\n .string()\n .min(1)\n .describe(\"Invoice total in cents, represented as a string without decimal separator.\"),\n items: z.array(invoiceItemSchema).min(1).describe(\"Items being invoiced.\"),\n invoiceKey: z.string().optional().describe(\"Optional invoice key.\"),\n invoiceUrl: z.string().url().optional().describe(\"Optional invoice URL.\"),\n invoiceOrderNumber: z.string().optional().describe(\"Optional order number from merchant ERP.\"),\n courier: z.string().optional().describe(\"Optional carrier name.\"),\n trackingNumber: z.string().optional().describe(\"Optional tracking number.\"),\n trackingUrl: z.string().url().optional().describe(\"Optional tracking URL.\"),\n});\n\nexport async function invoiceOrderHandler({\n profileId,\n orderId,\n confirmed,\n confirmationNote,\n ...payload\n}: z.infer<typeof invoiceOrderSchema>) {\n const confirmationResponse = requireExplicitConfirmation(confirmed, \"invoice_order\", {\n order_id: orderId,\n });\n if (confirmationResponse) {\n return confirmationResponse;\n }\n\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeOrder = await validateOrderForInvoice(resolvedProfileId, orderId);\n await invoiceOrder(resolvedProfileId, orderId, payload);\n const afterOrder = await getOrderStateSnapshot(resolvedProfileId, orderId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"invoice_order\",\n resourceId: orderId,\n riskLevel: \"high\",\n confirmed: true,\n confirmationNote,\n message: \"Order invoiced successfully.\",\n before: beforeOrder as unknown as Record<string, unknown>,\n after: afterOrder as unknown as Record<string, unknown>,\n details: {\n order_id: orderId,\n invoice_number: payload.invoiceNumber,\n },\n });\n } catch (err) {\n return handleVtexWriteError(err, `Failed to invoice order ${orderId}`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AA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EAC1E,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,wBAAwB;AAC5E,CAAC;AAED,eAAsB,oBAAoB;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuC;AACrC,QAAM,uBAAuB,4BAA4B,WAAW,iBAAiB;AAAA,IACnF,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,wBAAwB,mBAAmB,OAAO;AAC5E,UAAM,aAAa,mBAAmB,SAAS,OAAO;AACtD,UAAM,aAAa,MAAM,sBAAsB,mBAAmB,OAAO;AAEzE,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,QACP,UAAU;AAAA,QACV,gBAAgB,QAAQ;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,qBAAqB,KAAK,2BAA2B,OAAO,EAAE;AAAA,EACvE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
getInventoryByWarehouse,
|
|
4
|
+
updateInventoryQuantity
|
|
5
|
+
} from "../../services/vtex/vtex-logistics.js";
|
|
6
|
+
import {
|
|
7
|
+
buildWriteSuccessResponse,
|
|
8
|
+
handleVtexWriteError,
|
|
9
|
+
resolveVtexWriteProfile,
|
|
10
|
+
vtexProfileIdSchemaField
|
|
11
|
+
} from "./write-helpers.js";
|
|
12
|
+
const toggleUnlimitedQuantitySchema = z.object({
|
|
13
|
+
profileId: vtexProfileIdSchemaField,
|
|
14
|
+
skuId: z.string().min(1).describe("SKU identifier."),
|
|
15
|
+
warehouseId: z.string().min(1).describe("Warehouse identifier."),
|
|
16
|
+
unlimitedQuantity: z.boolean().describe("New unlimited availability mode for this SKU in the selected warehouse.")
|
|
17
|
+
});
|
|
18
|
+
async function toggleUnlimitedQuantityHandler({
|
|
19
|
+
profileId,
|
|
20
|
+
skuId,
|
|
21
|
+
warehouseId,
|
|
22
|
+
unlimitedQuantity
|
|
23
|
+
}) {
|
|
24
|
+
try {
|
|
25
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
26
|
+
if (!profileResolution.ok) {
|
|
27
|
+
return profileResolution.response;
|
|
28
|
+
}
|
|
29
|
+
const resolvedProfileId = profileResolution.value.profileId;
|
|
30
|
+
const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);
|
|
31
|
+
const currentInventory = beforeInventory[0];
|
|
32
|
+
if (!currentInventory) {
|
|
33
|
+
throw new Error(`Inventory record not found for SKU ${skuId} in warehouse ${warehouseId}`);
|
|
34
|
+
}
|
|
35
|
+
await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {
|
|
36
|
+
quantity: Number(currentInventory.totalQuantity ?? 0),
|
|
37
|
+
unlimitedQuantity
|
|
38
|
+
});
|
|
39
|
+
const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);
|
|
40
|
+
return buildWriteSuccessResponse({
|
|
41
|
+
profileId: resolvedProfileId,
|
|
42
|
+
operation: "toggle_unlimited_quantity",
|
|
43
|
+
resourceId: skuId,
|
|
44
|
+
riskLevel: "low",
|
|
45
|
+
message: "Unlimited quantity mode updated successfully.",
|
|
46
|
+
before: currentInventory,
|
|
47
|
+
after: afterInventory[0] ?? null,
|
|
48
|
+
details: {
|
|
49
|
+
sku_id: skuId,
|
|
50
|
+
warehouse_id: warehouseId,
|
|
51
|
+
unlimited_quantity: unlimitedQuantity
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
} catch (err) {
|
|
55
|
+
return handleVtexWriteError(
|
|
56
|
+
err,
|
|
57
|
+
`Failed to update unlimited quantity mode for SKU ${skuId} in ${warehouseId}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
toggleUnlimitedQuantityHandler,
|
|
63
|
+
toggleUnlimitedQuantitySchema
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=toggle-unlimited-quantity.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tools/vtex/toggle-unlimited-quantity.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\n\nimport {\n getInventoryByWarehouse,\n updateInventoryQuantity,\n} from \"../../services/vtex/vtex-logistics.js\";\nimport {\n buildWriteSuccessResponse,\n handleVtexWriteError,\n resolveVtexWriteProfile,\n vtexProfileIdSchemaField,\n} from \"./write-helpers.js\";\n\nexport const toggleUnlimitedQuantitySchema = z.object({\n profileId: vtexProfileIdSchemaField,\n skuId: z.string().min(1).describe(\"SKU identifier.\"),\n warehouseId: z.string().min(1).describe(\"Warehouse identifier.\"),\n unlimitedQuantity: z\n .boolean()\n .describe(\"New unlimited availability mode for this SKU in the selected warehouse.\"),\n});\n\nexport async function toggleUnlimitedQuantityHandler({\n profileId,\n skuId,\n warehouseId,\n unlimitedQuantity,\n}: z.infer<typeof toggleUnlimitedQuantitySchema>) {\n try {\n const profileResolution = await resolveVtexWriteProfile(profileId);\n if (!profileResolution.ok) {\n return profileResolution.response;\n }\n\n const resolvedProfileId = profileResolution.value.profileId;\n const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n const currentInventory = beforeInventory[0];\n\n if (!currentInventory) {\n throw new Error(`Inventory record not found for SKU ${skuId} in warehouse ${warehouseId}`);\n }\n\n await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {\n quantity: Number(currentInventory.totalQuantity ?? 0),\n unlimitedQuantity,\n });\n\n const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);\n\n return buildWriteSuccessResponse({\n profileId: resolvedProfileId,\n operation: \"toggle_unlimited_quantity\",\n resourceId: skuId,\n riskLevel: \"low\",\n message: \"Unlimited quantity mode updated successfully.\",\n before: currentInventory as Record<string, unknown>,\n after: (afterInventory[0] as Record<string, unknown> | undefined) ?? null,\n details: {\n sku_id: skuId,\n warehouse_id: warehouseId,\n unlimited_quantity: unlimitedQuantity,\n },\n });\n } catch (err) {\n return handleVtexWriteError(\n err,\n `Failed to update unlimited quantity mode for SKU ${skuId} in ${warehouseId}`\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,gCAAgC,EAAE,OAAO;AAAA,EACpD,WAAW;AAAA,EACX,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,iBAAiB;AAAA,EACnD,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,uBAAuB;AAAA,EAC/D,mBAAmB,EAChB,QAAQ,EACR,SAAS,yEAAyE;AACvF,CAAC;AAED,eAAsB,+BAA+B;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI;AACF,UAAM,oBAAoB,MAAM,wBAAwB,SAAS;AACjE,QAAI,CAAC,kBAAkB,IAAI;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,UAAM,kBAAkB,MAAM,wBAAwB,mBAAmB,OAAO,WAAW;AAC3F,UAAM,mBAAmB,gBAAgB,CAAC;AAE1C,QAAI,CAAC,kBAAkB;AACrB,YAAM,IAAI,MAAM,sCAAsC,KAAK,iBAAiB,WAAW,EAAE;AAAA,IAC3F;AAEA,UAAM,wBAAwB,mBAAmB,OAAO,aAAa;AAAA,MACnE,UAAU,OAAO,iBAAiB,iBAAiB,CAAC;AAAA,MACpD;AAAA,IACF,CAAC;AAED,UAAM,iBAAiB,MAAM,wBAAwB,mBAAmB,OAAO,WAAW;AAE1F,WAAO,0BAA0B;AAAA,MAC/B,WAAW;AAAA,MACX,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAQ,eAAe,CAAC,KAA6C;AAAA,MACrE,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,oBAAoB;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,MACA,oDAAoD,KAAK,OAAO,WAAW;AAAA,IAC7E;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { error, object } from "mcp-use/server";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
getInventoryByWarehouse,
|
|
4
|
+
updateInventoryQuantity
|
|
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 updateInventorySchema = z.object({
|
|
7
|
-
profileId:
|
|
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
16
|
quantity: z.number().int().min(0).describe("Inventory quantity to set"),
|
|
13
|
-
unlimitedQuantity: z.boolean().describe(
|
|
17
|
+
unlimitedQuantity: z.boolean().describe(
|
|
18
|
+
"When true, VTEX keeps the SKU available regardless of stock. This overwrites the current unlimited mode for the SKU in the selected warehouse."
|
|
19
|
+
),
|
|
14
20
|
dateUtcOnBalanceSystem: z.string().optional().describe("Optional UTC timestamp for inventory update synchronization")
|
|
15
21
|
});
|
|
16
22
|
async function updateInventoryHandler({
|
|
@@ -22,28 +28,37 @@ async function updateInventoryHandler({
|
|
|
22
28
|
dateUtcOnBalanceSystem
|
|
23
29
|
}) {
|
|
24
30
|
try {
|
|
25
|
-
const profileResolution = await
|
|
31
|
+
const profileResolution = await resolveVtexWriteProfile(profileId);
|
|
26
32
|
if (!profileResolution.ok) {
|
|
27
33
|
return profileResolution.response;
|
|
28
34
|
}
|
|
29
35
|
const resolvedProfileId = profileResolution.value.profileId;
|
|
36
|
+
const beforeInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);
|
|
30
37
|
await updateInventoryQuantity(resolvedProfileId, skuId, warehouseId, {
|
|
31
38
|
quantity,
|
|
32
39
|
unlimitedQuantity,
|
|
33
40
|
dateUtcOnBalanceSystem
|
|
34
41
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const afterInventory = await getInventoryByWarehouse(resolvedProfileId, skuId, warehouseId);
|
|
43
|
+
return buildWriteSuccessResponse({
|
|
44
|
+
profileId: resolvedProfileId,
|
|
45
|
+
operation: "update_inventory",
|
|
46
|
+
resourceId: skuId,
|
|
47
|
+
riskLevel: "low",
|
|
48
|
+
message: "Inventory quantity updated successfully.",
|
|
49
|
+
before: beforeInventory[0] ?? null,
|
|
50
|
+
after: afterInventory[0] ?? null,
|
|
51
|
+
details: {
|
|
52
|
+
sku_id: skuId,
|
|
53
|
+
warehouse_id: warehouseId,
|
|
54
|
+
quantity,
|
|
55
|
+
unlimited_quantity: unlimitedQuantity
|
|
56
|
+
}
|
|
43
57
|
});
|
|
44
58
|
} catch (err) {
|
|
45
|
-
return
|
|
46
|
-
|
|
59
|
+
return handleVtexWriteError(
|
|
60
|
+
err,
|
|
61
|
+
`Failed to update inventory quantity for SKU ${skuId} in ${warehouseId}`
|
|
47
62
|
);
|
|
48
63
|
}
|
|
49
64
|
}
|