@amazon-sp-api-release/dev-mcp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +82 -0
  2. package/dist/auth/sp-api-auth.d.ts +17 -0
  3. package/dist/auth/sp-api-auth.d.ts.map +1 -0
  4. package/dist/auth/sp-api-auth.js +55 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +96 -0
  8. package/dist/tools/api-tools/orders-api-tools.d.ts +103 -0
  9. package/dist/tools/api-tools/orders-api-tools.d.ts.map +1 -0
  10. package/dist/tools/api-tools/orders-api-tools.js +459 -0
  11. package/dist/tools/migration-assistant-tools/migration-tools.d.ts +21 -0
  12. package/dist/tools/migration-assistant-tools/migration-tools.d.ts.map +1 -0
  13. package/dist/tools/migration-assistant-tools/migration-tools.js +82 -0
  14. package/dist/tools/migration-assistant-tools/orders-api-migration/code-analyzer.d.ts +19 -0
  15. package/dist/tools/migration-assistant-tools/orders-api-migration/code-analyzer.d.ts.map +1 -0
  16. package/dist/tools/migration-assistant-tools/orders-api-migration/code-analyzer.js +52 -0
  17. package/dist/tools/migration-assistant-tools/orders-api-migration/code-generator.d.ts +3 -0
  18. package/dist/tools/migration-assistant-tools/orders-api-migration/code-generator.d.ts.map +1 -0
  19. package/dist/tools/migration-assistant-tools/orders-api-migration/code-generator.js +45 -0
  20. package/dist/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.d.ts +3 -0
  21. package/dist/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.d.ts.map +1 -0
  22. package/dist/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.js +134 -0
  23. package/dist/tools/migration-assistant-tools/orders-api-migration/migration-data.d.ts +13 -0
  24. package/dist/tools/migration-assistant-tools/orders-api-migration/migration-data.d.ts.map +1 -0
  25. package/dist/tools/migration-assistant-tools/orders-api-migration/migration-data.js +181 -0
  26. package/dist/tools/migration-assistant-tools/orders-api-migration/report-formatter.d.ts +5 -0
  27. package/dist/tools/migration-assistant-tools/orders-api-migration/report-formatter.d.ts.map +1 -0
  28. package/dist/tools/migration-assistant-tools/orders-api-migration/report-formatter.js +64 -0
  29. package/dist/zod-schemas/migration-schemas.d.ts +24 -0
  30. package/dist/zod-schemas/migration-schemas.d.ts.map +1 -0
  31. package/dist/zod-schemas/migration-schemas.js +24 -0
  32. package/dist/zod-schemas/orders-schemas.d.ts +291 -0
  33. package/dist/zod-schemas/orders-schemas.d.ts.map +1 -0
  34. package/dist/zod-schemas/orders-schemas.js +178 -0
  35. package/package.json +66 -0
  36. package/src/auth/sp-api-auth.ts +88 -0
  37. package/src/index.ts +168 -0
  38. package/src/tools/api-tools/orders-api-tools.ts +684 -0
  39. package/src/tools/migration-assistant-tools/migration-tools.ts +143 -0
  40. package/src/tools/migration-assistant-tools/orders-api-migration/code-analyzer.ts +72 -0
  41. package/src/tools/migration-assistant-tools/orders-api-migration/code-generator.ts +64 -0
  42. package/src/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.ts +154 -0
  43. package/src/tools/migration-assistant-tools/orders-api-migration/migration-data.ts +221 -0
  44. package/src/tools/migration-assistant-tools/orders-api-migration/report-formatter.ts +85 -0
  45. package/src/utils/logger.ts +75 -0
  46. package/src/zod-schemas/migration-schemas.ts +28 -0
  47. package/src/zod-schemas/orders-schemas.ts +196 -0
@@ -0,0 +1,45 @@
1
+ export function generateRefactoredOrdersApiCode(sourceCode, analysis, targetVersion) {
2
+ let refactoredCode = sourceCode;
3
+ // Replace attribute mappings
4
+ analysis.usedAttributes.forEach((attr) => {
5
+ const v0Pattern = new RegExp(`\\b${attr.v0.replace(/\./g, "\\.")}\\b`, "g");
6
+ refactoredCode = refactoredCode.replace(v0Pattern, attr.v1);
7
+ });
8
+ // Replace API method calls
9
+ const apiReplacements = {
10
+ getOrders: "searchOrders",
11
+ getOrder: "getOrder",
12
+ getOrderBuyerInfo: "getOrder", // with includedData
13
+ getOrderAddress: "getOrder", // with includedData
14
+ getOrderItems: "getOrder", // items included by default
15
+ getOrderItemsBuyerInfo: "getOrder", // with includedData
16
+ cancelOrder: "cancelOrder",
17
+ };
18
+ Object.entries(apiReplacements).forEach(([v0Method, v1Method]) => {
19
+ const regex = new RegExp(`\\b${v0Method}\\b`, "g");
20
+ refactoredCode = refactoredCode.replace(regex, v1Method);
21
+ });
22
+ // Add comments for V0-only APIs
23
+ analysis.deprecatedEndpoints.forEach((endpoint) => {
24
+ if (endpoint.replacement.includes("No V1 counterpart")) {
25
+ const regex = new RegExp(`(\\b${endpoint.endpoint}\\b)`, "g");
26
+ refactoredCode = refactoredCode.replace(regex, `$1 /* ⚠️ Continue using V0 API - No V1 equivalent */`);
27
+ }
28
+ });
29
+ // Update endpoint URLs
30
+ refactoredCode = refactoredCode.replace(/\/orders\/v0\//g, "/orders/2026-01-01/");
31
+ // Add migration header comment
32
+ const header = `/**
33
+ * πŸ”„ Migrated from ${analysis.apiCalls.length > 0 ? "Orders API V0" : "V0"} to ${targetVersion}
34
+ *
35
+ * Migration Summary:
36
+ * - ${analysis.usedAttributes.length} attributes updated
37
+ * - ${analysis.apiCalls.length} API methods analyzed
38
+ * - ${analysis.breakingChanges.length} breaking changes identified
39
+ *
40
+ * ⚠️ Note: Some V0 APIs have no V1 counterpart and must continue using V0
41
+ */
42
+
43
+ `;
44
+ return header + refactoredCode;
45
+ }
@@ -0,0 +1,3 @@
1
+ import { MigrationData } from "./migration-data.js";
2
+ export declare function formatGeneralGuidance(migrationData: MigrationData): string;
3
+ //# sourceMappingURL=guidance-formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guidance-formatter.d.ts","sourceRoot":"","sources":["../../../../src/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAuJ1E"}
@@ -0,0 +1,134 @@
1
+ export function formatGeneralGuidance(migrationData) {
2
+ let guidance = `# πŸ”„ Orders API Migration Guide: V0 β†’ V1 (2026-01-01)\n\n`;
3
+ guidance += `## πŸ“‹ Overview\n\n`;
4
+ guidance += `This guide helps you migrate from Orders API V0 to V1 (2026-01-01).\n\n`;
5
+ guidance += `**Key Changes:**\n`;
6
+ guidance += `- New nested data structure (buyer, recipient, fulfillment, etc.)\n`;
7
+ guidance += `- Enhanced data sets with \`includedData\` parameter\n`;
8
+ guidance += `- New programs array replaces boolean flags\n`;
9
+ guidance += `- Better financial breakdown with proceeds and expense tracking\n`;
10
+ guidance += `- Some V0 APIs have no V1 counterpart (continue using V0)\n\n`;
11
+ // API Availability
12
+ guidance += `## πŸ”Œ API Method Mapping\n\n`;
13
+ guidance += `### βœ… Available in V1:\n\n`;
14
+ Object.entries(migrationData.apiMapping).forEach(([v0Method, mapping]) => {
15
+ if (mapping.status.includes("βœ…")) {
16
+ guidance += `- **${v0Method}** β†’ ${mapping.v1}\n`;
17
+ guidance += ` ${mapping.notes}\n\n`;
18
+ }
19
+ });
20
+ guidance += `### ❌ NOT Available in V1 (Continue using V0):\n\n`;
21
+ Object.entries(migrationData.apiMapping).forEach(([v0Method, mapping]) => {
22
+ if (mapping.status.includes("❌")) {
23
+ guidance += `- **${v0Method}**\n`;
24
+ guidance += ` ${mapping.notes}\n\n`;
25
+ }
26
+ });
27
+ // Attribute Mappings
28
+ guidance += `## πŸ—ΊοΈ Key Attribute Mappings\n\n`;
29
+ guidance += `Common V0 attributes and their V1 equivalents:\n\n`;
30
+ const highlightedMappings = [
31
+ "AmazonOrderId",
32
+ "OrderStatus",
33
+ "IsPrime",
34
+ "IsBusinessOrder",
35
+ "OrderTotal",
36
+ "ShippingAddress",
37
+ "BuyerInfo.BuyerEmail",
38
+ "QuantityShipped",
39
+ ];
40
+ highlightedMappings.forEach((v0Attr) => {
41
+ const v1Attr = migrationData.mappingExamples[v0Attr];
42
+ if (v1Attr) {
43
+ guidance += `- \`${v0Attr}\` β†’ \`${v1Attr}\`\n`;
44
+ }
45
+ });
46
+ guidance += `\n[View complete mapping list for all ${Object.keys(migrationData.mappingExamples).length} attributes]\n\n`;
47
+ // Breaking Changes
48
+ guidance += `## ⚠️ Breaking Changes\n\n`;
49
+ guidance += `### Deprecated Attributes (${migrationData.deprecated.length})\n\n`;
50
+ guidance += `These attributes are removed in V1 with no replacement:\n\n`;
51
+ migrationData.deprecated.slice(0, 5).forEach((attr) => {
52
+ guidance += `- ${attr}\n`;
53
+ });
54
+ if (migrationData.deprecated.length > 5) {
55
+ guidance += `- ... and ${migrationData.deprecated.length - 5} more\n`;
56
+ }
57
+ guidance += `\n`;
58
+ guidance += `### Not Supported Attributes (${migrationData.notSupported.length})\n\n`;
59
+ guidance += `These attributes are not available in current V1 release:\n\n`;
60
+ migrationData.notSupported.slice(0, 5).forEach((attr) => {
61
+ guidance += `- ${attr}\n`;
62
+ });
63
+ if (migrationData.notSupported.length > 5) {
64
+ guidance += `- ... and ${migrationData.notSupported.length - 5} more\n`;
65
+ }
66
+ guidance += `\n`;
67
+ // New Features
68
+ guidance += `## πŸ†• New Features in V1\n\n`;
69
+ migrationData.newFeatures.forEach((feature) => {
70
+ guidance += `- ${feature}\n`;
71
+ });
72
+ guidance += `\n`;
73
+ // Code Examples
74
+ guidance += `## πŸ’» Code Examples\n\n`;
75
+ guidance += `### Checking Prime Orders\n\n`;
76
+ guidance += `**V0:**\n`;
77
+ guidance += `\`\`\`javascript\n`;
78
+ guidance += `if (order.IsPrime) {\n`;
79
+ guidance += ` // handle prime order\n`;
80
+ guidance += `}\n`;
81
+ guidance += `\`\`\`\n\n`;
82
+ guidance += `**V1:**\n`;
83
+ guidance += `\`\`\`javascript\n`;
84
+ guidance += `if (order.programs?.includes('PRIME')) {\n`;
85
+ guidance += ` // handle prime order\n`;
86
+ guidance += `}\n`;
87
+ guidance += `\`\`\`\n\n`;
88
+ guidance += `### Getting Order Status\n\n`;
89
+ guidance += `**V0:**\n`;
90
+ guidance += `\`\`\`javascript\n`;
91
+ guidance += `const status = order.OrderStatus;\n`;
92
+ guidance += `\`\`\`\n\n`;
93
+ guidance += `**V1:**\n`;
94
+ guidance += `\`\`\`javascript\n`;
95
+ guidance += `const status = order.fulfillment.fulfillmentStatus;\n`;
96
+ guidance += `\`\`\`\n\n`;
97
+ guidance += `### Search Orders (V1)\n\n`;
98
+ guidance += `\`\`\`javascript\n`;
99
+ guidance += `const response = await fetch(\n`;
100
+ guidance += ` 'https://sellingpartnerapi-na.amazon.com/orders/2026-01-01/orders?' +\n`;
101
+ guidance += ` new URLSearchParams({\n`;
102
+ guidance += ` createdAfter: '2025-12-01T00:00:00Z',\n`;
103
+ guidance += ` marketplaceIds: 'ATVPDKIKX0DER',\n`;
104
+ guidance += ` includedData: 'BUYER,RECIPIENT,FULFILLMENT'\n`;
105
+ guidance += ` }),\n`;
106
+ guidance += ` {\n`;
107
+ guidance += ` headers: {\n`;
108
+ guidance += ` 'x-amz-access-token': accessToken\n`;
109
+ guidance += ` }\n`;
110
+ guidance += ` }\n`;
111
+ guidance += `);\n`;
112
+ guidance += `\`\`\`\n\n`;
113
+ // Migration Checklist
114
+ guidance += `## βœ… Migration Checklist\n\n`;
115
+ guidance += `- [ ] Review API method availability (some require V0)\n`;
116
+ guidance += `- [ ] Update attribute references to new nested structure\n`;
117
+ guidance += `- [ ] Replace boolean flags with programs array checks\n`;
118
+ guidance += `- [ ] Add \`includedData\` parameter for additional data\n`;
119
+ guidance += `- [ ] Update endpoint URLs from \`/orders/v0/\` to \`/orders/2026-01-01/\`\n`;
120
+ guidance += `- [ ] Update error handling for new response formats\n`;
121
+ guidance += `- [ ] Test with sandbox environment\n`;
122
+ guidance += `- [ ] Update TypeScript types/interfaces\n`;
123
+ guidance += `- [ ] Plan V0 fallback for unsupported operations\n\n`;
124
+ // Resources
125
+ guidance += `## πŸ“š Resources\n\n`;
126
+ guidance += `- [SP-API Orders V1 Documentation](https://developer-docs.amazon.com/sp-api/docs/orders-api-v1-reference)\n`;
127
+ guidance += `- [Migration Guide](https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-to-v1-migration-guide)\n`;
128
+ guidance += `- [SP-API Developer Guide](https://developer-docs.amazon.com/sp-api/)\n\n`;
129
+ guidance += `## πŸ” Need More Help?\n\n`;
130
+ guidance += `- **Code Analysis:** Provide your source code for detailed analysis and automated refactoring\n`;
131
+ guidance += `- **Specific Attributes:** Ask about specific V0 attributes for detailed mapping\n`;
132
+ guidance += `- **API Methods:** Ask about specific V0 API methods for migration guidance\n`;
133
+ return guidance;
134
+ }
@@ -0,0 +1,13 @@
1
+ export interface MigrationData {
2
+ deprecated: string[];
3
+ notSupported: string[];
4
+ mappingExamples: Record<string, string>;
5
+ newFeatures: string[];
6
+ apiMapping: Record<string, {
7
+ v1: string;
8
+ status: string;
9
+ notes: string;
10
+ }>;
11
+ }
12
+ export declare function getOrdersApiMigrationData(): MigrationData;
13
+ //# sourceMappingURL=migration-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-data.d.ts","sourceRoot":"","sources":["../../../../src/tools/migration-assistant-tools/orders-api-migration/migration-data.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED,wBAAgB,yBAAyB,IAAI,aAAa,CAoNzD"}
@@ -0,0 +1,181 @@
1
+ export function getOrdersApiMigrationData() {
2
+ return {
3
+ deprecated: [
4
+ "OrderChannel",
5
+ "ShipServiceLevel",
6
+ "CbaDisplayableShippingLabel",
7
+ "IsGlobalExpressEnabled",
8
+ "PromiseResponseDueDate",
9
+ "IsEstimatedShipDateSet",
10
+ "IsSoldByAB",
11
+ "BuyerInfo.BuyerCounty",
12
+ ],
13
+ notSupported: [
14
+ "NumberOfItemsShipped",
15
+ "NumberOfItemsUnshipped",
16
+ "PaymentExecutionDetail",
17
+ "PaymentMethod",
18
+ "PaymentMethodDetails",
19
+ "IsIBA",
20
+ "HasRegulatedItems",
21
+ "DefaultShipFromLocationAddress",
22
+ "ElectronicInvoiceStatus",
23
+ "BuyerInvoicePreference",
24
+ "BuyerTaxInformation",
25
+ "FulfillmentInstruction",
26
+ "MarketplaceTaxInfo",
27
+ "SellerDisplayName",
28
+ "AutomatedShippingSettings",
29
+ "BuyerInfo.BuyerTaxInfo",
30
+ "ProductInfo",
31
+ "ProductInfo.NumberOfItems",
32
+ "TaxCollection",
33
+ "TaxCollection.Model",
34
+ "TaxCollection.ResponsibleParty",
35
+ "DeemedResellerCategory",
36
+ "StoreChainStoreId",
37
+ "SerialNumberRequired",
38
+ "AssociatedItems",
39
+ "AssociatedItem.OrderId",
40
+ "AssociatedItem.OrderItemId",
41
+ "AssociatedItem.AssociationType",
42
+ "PointsGrantedDetail.PointsNumber",
43
+ "PointsGrantedDetail.PointsMonetaryValue",
44
+ "ConditionId",
45
+ "ConditionSubtypeId",
46
+ ],
47
+ mappingExamples: {
48
+ AmazonOrderId: "Order.orderId",
49
+ SellerOrderId: "Order.orderAliases (with aliasType == SELLER_ORDER_ID)",
50
+ MarketplaceId: "Order.salesChannel.marketplaceId",
51
+ PurchaseDate: "Order.createdTime",
52
+ LastUpdateDate: "Order.lastUpdatedTime",
53
+ OrderType: "Order.programs (check for PREORDER)",
54
+ OrderStatus: "Order.fulfillment.fulfillmentStatus",
55
+ FulfillmentChannel: "Order.fulfillment.fulfilledBy",
56
+ SalesChannel: "Order.salesChannel.marketplaceName",
57
+ ShipmentServiceLevelCategory: "Order.fulfillment.fulfillmentServiceLevel",
58
+ OrderTotal: "Order.proceeds.grandTotal",
59
+ EasyShipShipmentStatus: "Order.packages.packageStatus.detailedStatus",
60
+ EarliestShipDate: "Order.fulfillment.shipByWindow.earliestDateTime",
61
+ LatestShipDate: "Order.fulfillment.shipByWindow.latestDateTime",
62
+ EarliestDeliveryDate: "Order.fulfillment.deliverByWindow.earliestDateTime",
63
+ LatestDeliveryDate: "Order.fulfillment.deliverByWindow.latestDateTime",
64
+ IsBusinessOrder: "Order.programs (check for AMAZON_BUSINESS)",
65
+ IsPrime: "Order.programs (check for PRIME)",
66
+ IsPremiumOrder: "Order.programs (check for PRIMIUM)",
67
+ ReplacedOrderId: "Order.associatedOrders (with associationType == REPLACEMENT_ORIGINAL_ID or EXCHANGE_ORIGINAL_ID)",
68
+ IsISPU: "Order.programs (check for IN_STORE_PICK_UP)",
69
+ IsAccessPointOrder: "Order.recipient.deliveryAddress.addressType (check for PICKUP_POINT)",
70
+ ShippingAddress: "Order.recipient.deliveryAddress",
71
+ "BuyerInfo.BuyerEmail": "Order.buyer.buyerEmail",
72
+ "BuyerInfo.BuyerName": "Order.buyer.buyerName",
73
+ "BuyerInfo.PurchaseOrderNumber": "Order.buyer.buyerPurchaseOrderNumber",
74
+ BuyerCompanyName: "Order.buyer.buyerCompanyName",
75
+ DeliveryPreferences: "Order.recipient.deliveryPreference",
76
+ ASIN: "Order.orderItems.product.asin",
77
+ SellerSKU: "Order.orderItems.product.sellerSku",
78
+ OrderItemId: "Order.orderItems.orderItemId",
79
+ Title: "Order.orderItems.product.title",
80
+ QuantityOrdered: "Order.orderItems.quantityOrdered",
81
+ QuantityShipped: "Order.orderItems.fulfillment.quantityFulfilled",
82
+ PointsGranted: "Order.orderItems.expense.pointsCost.pointsGranted",
83
+ ItemPrice: "Order.orderItems.proceeds.breakdowns.subtotal (with type == ITEM)",
84
+ ShippingPrice: "Order.orderItems.proceeds.breakdowns.subtotal (with type == SHIPPING)",
85
+ ItemTax: "Order.orderItems.proceeds.breakdowns.detailedBreakdowns.value (type == TAX && subtype == ITEM)",
86
+ ShippingTax: "Order.orderItems.proceeds.breakdowns.detailedBreakdowns.value (type == TAX && subtype == SHIPPING)",
87
+ ShippingDiscount: "Order.orderItems.proceeds.breakdowns.detailedBreakdowns.value (type == DISCOUNT && subtype == SHIPPING)",
88
+ PromotionDiscount: "Order.orderItems.proceeds.breakdowns.subtotal (with type == DISCOUNT)",
89
+ PromotionDiscountTax: "Order.orderItems.proceeds.breakdowns.detailedBreakdowns.value (type == TAX && subtype == DISCOUNT)",
90
+ CODFee: "Order.orderItems.proceeds.breakdowns.subtotal (with type == COD_FEE)",
91
+ CODFeeDiscount: "Order.orderItems.proceeds.breakdowns.detailedBreakdowns.value (type == DISCOUNT && subtype == COD_FEE)",
92
+ "ItemBuyerInfo.GiftWrapPrice": "Order.orderItems.proceeds.breakdowns.subtotal (with type == GIFT_WRAP)",
93
+ "ItemBuyerInfo.GiftWrapTax": "Order.orderItems.proceeds.breakdowns.detailedBreakdowns.value (type == TAX && subtype == GIFT_WRAP)",
94
+ PromotionIds: "Order.orderItems.promotion.breakdowns.promotionId",
95
+ IsGift: "Order.orderItems.fulfillment.packing.giftOption",
96
+ ConditionNote: "Order.orderItems.product.condition",
97
+ ScheduledDeliveryStartDate: "Order.orderItems.fulfillment.shipping.scheduledDeliveryWindow",
98
+ ScheduledDeliveryEndDate: "Order.orderItems.fulfillment.shipping.scheduledDeliveryWindow",
99
+ PriceDesignation: "Order.orderItems.product.price.priceDesignation",
100
+ IossNumber: "Order.orderItems.fulfillment.shipping.internationalShipping.iossNumber",
101
+ IsTransparency: "Order.orderItems.programs (check for TRANSPARENCY)",
102
+ "ItemBuyerInfo.BuyerCustomizedInfo": "Order.orderItems.product.customization",
103
+ "ItemBuyerInfo.BuyerCustomizedInfo.CustomizedURL": "Order.orderItems.product.customization.customizedUrl",
104
+ "ItemBuyerInfo.GiftMessageText": "Order.orderItems.fulfillment.packing.giftOption.giftMessage",
105
+ "ItemBuyerInfo.GiftWrapLevel": "Order.orderItems.fulfillment.packing.giftOption.giftWrapLevel",
106
+ "BuyerRequestedCancel.IsBuyerRequestedCancel": "Order.orderItems.cancellation.requester (check for BUYER)",
107
+ "BuyerRequestedCancel.BuyerCancelReason": "Order.orderItems.cancellation.cancelReason",
108
+ SerialNumbers: "Order.orderItems.product.serialNumbers",
109
+ SubstitutionPreferences: "Order.orderItems.fulfillment.picking.substitutionPreference",
110
+ Measurement: "Order.orderItems.measurement",
111
+ ShippingConstraints: "Order.orderItems.fulfillment.shipping.shippingConstraints",
112
+ AmazonPrograms: "Order.orderItems.programs or Order.programs (check for SUBSCRIBE_AND_SAVE, FBM_SHIP_PULS)",
113
+ },
114
+ newFeatures: [
115
+ "Order.programs with AMAZON_BAZAAR",
116
+ "Order.programs with AMAZON_HAUL",
117
+ "Order.programs with AMAZON_EASY_SHIP (non-Brazil) or DELIVERY_BY_AMAZON (Brazil only)",
118
+ "Order.orderItems.product.price.unitPrice",
119
+ "Order.orderItems.proceeds.proceedsTotal",
120
+ "Order.orderItems.fulfillment.shipping.shippingConstraints.cashOnDelivery",
121
+ "Order.packages for FBM orders (carrier, shippingService, trackingNumber, package status)",
122
+ ],
123
+ apiMapping: {
124
+ getOrders: {
125
+ v1: "search_orders (with filters)",
126
+ status: "βœ… Available",
127
+ notes: "Use with filters like createdAfter, marketplaceIds, etc.",
128
+ },
129
+ getOrder: {
130
+ v1: "get_order (with includedData parameter)",
131
+ status: "βœ… Available",
132
+ notes: "Order items included by default, use includedData for additional data",
133
+ },
134
+ getOrderBuyerInfo: {
135
+ v1: "get_order (with includedData=['BUYER'])",
136
+ status: "βœ… Available",
137
+ notes: "Include BUYER in includedData parameter",
138
+ },
139
+ getOrderAddress: {
140
+ v1: "get_order (with includedData=['RECIPIENT'])",
141
+ status: "βœ… Available",
142
+ notes: "Include RECIPIENT in includedData parameter",
143
+ },
144
+ getOrderItems: {
145
+ v1: "get_order (order items included by default)",
146
+ status: "βœ… Available",
147
+ notes: "Order items are always included, no need for separate call",
148
+ },
149
+ getOrderItemsBuyerInfo: {
150
+ v1: "get_order (with includedData=['BUYER'])",
151
+ status: "βœ… Available",
152
+ notes: "Item buyer info included when BUYER is in includedData",
153
+ },
154
+ getOrderRegulatedInfo: {
155
+ v1: "No V1 counterpart",
156
+ status: "❌ Not Available",
157
+ notes: "Continue using V0 API: GET /orders/v0/orders/{orderId}/regulatedInfo",
158
+ },
159
+ updateShipmentStatus: {
160
+ v1: "No V1 counterpart",
161
+ status: "❌ Not Available",
162
+ notes: "Continue using V0 API: POST /orders/v0/orders/{orderId}/shipment",
163
+ },
164
+ updateVerificationStatus: {
165
+ v1: "No V1 counterpart",
166
+ status: "❌ Not Available",
167
+ notes: "Continue using V0 API: PATCH /orders/v0/orders/{orderId}/verificationStatus",
168
+ },
169
+ confirmShipment: {
170
+ v1: "No V1 counterpart",
171
+ status: "❌ Not Available",
172
+ notes: "Continue using V0 API: POST /orders/v0/orders/{orderId}/shipConfirmation",
173
+ },
174
+ cancelOrder: {
175
+ v1: "cancel_order",
176
+ status: "βœ… Available",
177
+ notes: "Available in V1 as PUT /orders/v1/orders/{orderId}/cancellation",
178
+ },
179
+ },
180
+ };
181
+ }
@@ -0,0 +1,5 @@
1
+ import { CodeAnalysis } from "./code-analyzer.js";
2
+ import { MigrationData } from "./migration-data.js";
3
+ export declare function formatAnalysisReport(analysis: CodeAnalysis, migrationData: MigrationData): string;
4
+ export declare function formatMigrationReport(analysis: CodeAnalysis, refactoredCode: string, migrationData: MigrationData): string;
5
+ //# sourceMappingURL=report-formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-formatter.d.ts","sourceRoot":"","sources":["../../../../src/tools/migration-assistant-tools/orders-api-migration/report-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,aAAa,GAC3B,MAAM,CAoDR;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,YAAY,EACtB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,aAAa,GAC3B,MAAM,CAoBR"}
@@ -0,0 +1,64 @@
1
+ export function formatAnalysisReport(analysis, migrationData) {
2
+ let report = `# πŸ” Migration Analysis Report\n\n`;
3
+ report += `## πŸ“Š Summary\n\n`;
4
+ report += `- **API Calls Found:** ${analysis.apiCalls.length}\n`;
5
+ report += `- **Attributes to Update:** ${analysis.usedAttributes.length}\n`;
6
+ report += `- **Breaking Changes:** ${analysis.breakingChanges.length}\n`;
7
+ report += `- **Deprecated Endpoints:** ${analysis.deprecatedEndpoints.length}\n\n`;
8
+ if (analysis.deprecatedEndpoints.length > 0) {
9
+ report += `## ❌ Deprecated Endpoints\n\n`;
10
+ analysis.deprecatedEndpoints.forEach((endpoint) => {
11
+ report += `- **${endpoint.endpoint}** β†’ ${endpoint.replacement}\n`;
12
+ });
13
+ report += `\n`;
14
+ }
15
+ if (analysis.breakingChanges.length > 0) {
16
+ report += `## ⚠️ Breaking Changes\n\n`;
17
+ analysis.breakingChanges.forEach((change, index) => {
18
+ report += `${index + 1}. **${change.change}**\n`;
19
+ report += ` ${change.explanation}\n\n`;
20
+ });
21
+ }
22
+ if (analysis.usedAttributes.length > 0) {
23
+ report += `## πŸ—ΊοΈ Attribute Mappings\n\n`;
24
+ analysis.usedAttributes.forEach((attr) => {
25
+ report += `- \`${attr.v0}\` β†’ \`${attr.v1}\`\n`;
26
+ });
27
+ report += `\n`;
28
+ }
29
+ if (analysis.apiCalls.length > 0) {
30
+ report += `## πŸ”Œ API Methods Detected\n\n`;
31
+ analysis.apiCalls.forEach((method) => {
32
+ const mapping = migrationData.apiMapping[method];
33
+ const status = mapping?.status || "Unknown";
34
+ report += `- **${method}** - ${status}\n`;
35
+ });
36
+ report += `\n`;
37
+ }
38
+ report += `## βœ… Migration Checklist\n\n`;
39
+ report += `- [ ] Review all deprecated endpoints and plan V0 fallback strategy\n`;
40
+ report += `- [ ] Update attribute references to new V1 structure\n`;
41
+ report += `- [ ] Add \`includedData\` parameter where needed (BUYER, RECIPIENT, etc.)\n`;
42
+ report += `- [ ] Update error handling for new response formats\n`;
43
+ report += `- [ ] Test with sandbox environment before production\n`;
44
+ report += `- [ ] Update TypeScript types/interfaces\n`;
45
+ report += `- [ ] Monitor for V0 API deprecation announcements\n\n`;
46
+ return report;
47
+ }
48
+ export function formatMigrationReport(analysis, refactoredCode, migrationData) {
49
+ let report = formatAnalysisReport(analysis, migrationData);
50
+ report += `\n---\n\n`;
51
+ report += `## πŸ’» Refactored Code\n\n`;
52
+ report += `\`\`\`javascript\n${refactoredCode}\n\`\`\`\n\n`;
53
+ report += `## πŸ§ͺ Testing Recommendations\n\n`;
54
+ report += `1. **Unit Tests:** Update test cases to match new V1 response structure\n`;
55
+ report += `2. **Integration Tests:** Test with SP-API sandbox environment\n`;
56
+ report += `3. **Error Handling:** Verify error responses match V1 format\n`;
57
+ report += `4. **Performance:** Monitor API response times and adjust \`includedData\` usage\n`;
58
+ report += `5. **Backward Compatibility:** Ensure V0 fallback works for unsupported operations\n\n`;
59
+ report += `## πŸ“š Additional Resources\n\n`;
60
+ report += `- [SP-API Orders V1 Documentation](https://developer-docs.amazon.com/sp-api/docs/orders-api-v1-reference)\n`;
61
+ report += `- [Migration Guide](https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-to-v1-migration-guide)\n`;
62
+ report += `- Use \`getMigrationGuide\` tool for detailed attribute mappings\n\n`;
63
+ return report;
64
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Zod schemas for Migration Assistant tool
3
+ */
4
+ import { z } from "zod";
5
+ export declare const migrationAssistantSchema: z.ZodObject<{
6
+ source_code: z.ZodOptional<z.ZodString>;
7
+ source_version: z.ZodString;
8
+ target_version: z.ZodString;
9
+ language: z.ZodOptional<z.ZodString>;
10
+ analysis_only: z.ZodDefault<z.ZodBoolean>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ source_version: string;
13
+ target_version: string;
14
+ analysis_only: boolean;
15
+ source_code?: string | undefined;
16
+ language?: string | undefined;
17
+ }, {
18
+ source_version: string;
19
+ target_version: string;
20
+ source_code?: string | undefined;
21
+ analysis_only?: boolean | undefined;
22
+ language?: string | undefined;
23
+ }>;
24
+ //# sourceMappingURL=migration-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-schemas.d.ts","sourceRoot":"","sources":["../../src/zod-schemas/migration-schemas.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAqBnC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Zod schemas for Migration Assistant tool
3
+ */
4
+ import { z } from "zod";
5
+ export const migrationAssistantSchema = z.object({
6
+ source_code: z
7
+ .string()
8
+ .optional()
9
+ .describe("Your existing API integration code (optional - if not provided, returns general migration guidance)"),
10
+ source_version: z
11
+ .string()
12
+ .describe("Current API version (e.g., 'orders-v0')"),
13
+ target_version: z
14
+ .string()
15
+ .describe("Target API version (e.g., 'orders-2026-01-01')"),
16
+ language: z
17
+ .string()
18
+ .optional()
19
+ .describe("Programming language of the source code"),
20
+ analysis_only: z
21
+ .boolean()
22
+ .default(false)
23
+ .describe("Only analyze without generating code (default: false)"),
24
+ });