Fix SPI type mismatches in service plugin references#60
Fix SPI type mismatches in service plugin references#60yanivefraim wants to merge 10 commits intomainfrom
Conversation
Fix type errors in TAX-CALCULATION.md to match actual @wix/ecom types: request.shippingAddress → request.addresses[0], item.price.amount → item.price, lineItemTaxes → lineItemTaxDetails, lineItemId → _id, name → taxName, amount object → taxAmount string, rate as decimal not percentage. Remove `description` from generic builder config in SKILL.md since it's only available on ecomShippingRates(), not all builder methods. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflicts in SKILL.md by accepting main's version, which contains more comprehensive improvements that supersede this branch's changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ddress resolution Replace naive `request.addresses?.[0]` with proper `addressIndex` lookup that resolves each line item's address individually via `singleAddress` or `multipleAddresses.destination`, matching the official Wix Tax Calculation SPI schema. Also enriches the example with full taxBreakdown fields and per-item taxSummary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…al fees reference Change `id` to `_id` in ADDITIONAL-FEES.md request structure to match the actual LineItem type in @wix/ecom additional-fees package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…fields to all SPI references Add Request Structure sections to references that were missing them (Shipping Rates, Discount Triggers, Gift Cards, Validations, Tax Calculation) so generated code is complete without TypeScript introspection. Also add missing optional fields across all references: - TAX-CALCULATION: request types, top-level taxSummary in response/example - SHIPPING-RATES: full request with ProductItem, shippingDestination, buyerContactDetails, weightUnit; add logistics.instructions - DISCOUNT-TRIGGERS: getEligibleTriggers request (lineItems, triggers, shippingInfo); note listTriggers request is empty - GIFT-CARDS: request types for getBalance, redeem, _void; add externalId to getBalance response - VALIDATIONS: request with sourceInfo, validationInfo (lineItems with MultiCurrencyPrice and ProductName objects, priceSummary, addresses, buyerDetails); add NameInLineItem to lineItem target - ADDITIONAL-FEES: add depositAmount, appliedDiscounts, shippingInfo, purchaseFlowId, extendedFields to request; taxGroupId to response Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…encyPrice in validations reference priceSummary fields (total, subtotal, discount, tax, shipping) were documented as plain strings but are actually MultiCurrencyPrice objects. Define the MultiCurrencyPrice type and reference it for both lineItem.price and all priceSummary fields so generated code uses .amount correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…o structures in additional fees reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ion to SKILL.md Document the Wix request envelope metadata object (requestId, instanceId, currency, languages, identity) that is common to all service plugin handlers, sourced from official Wix docs. Centralized in SKILL.md to avoid duplication across individual SPI reference files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eScript type definitions Added missing fields, corrected type mismatches, and expanded request structures across all 7 SPI reference docs after systematic comparison against .d.ts sources. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mirivoWix
left a comment
There was a problem hiding this comment.
Didn't finish to review
There are still a lot of type errors, lets rethink adding them here
| coupon?: { _id?: string; code?: string; name?: string; amount?: string; }; | ||
| merchantDiscount?: { amount?: string; }; // Discount amount as decimal string | ||
| discountRule?: { _id?: string; name?: { original?: string; }; }; |
There was a problem hiding this comment.
One Of coupon/discountRule/merchantDiscount
https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/calculate-additional-fees?apiView=SDK
| extendedFields?: { // Extended field data | ||
| namespaces?: Record<string, Record<string, any>>; | ||
| }; |
There was a problem hiding this comment.
This is not correct, Record <string, Struct> and Record <string, Value>
https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/calculate-additional-fees?apiView=SDK
| @@ -37,15 +37,86 @@ The `calculateAdditionalFees` handler receives `{ request, metadata }`. Key fiel | |||
| sku: string; // Stock-keeping unit | |||
| shippable: boolean; // Whether item is shippable | |||
| }; | |||
There was a problem hiding this comment.
catalogReference.options has a type also it isn't Record<string, any>
https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/calculate-additional-fees?apiView=SDK
| shippingAddress?: { // Shipping address (if provided) | ||
| country: string; // ISO-3166 alpha-2 country code | ||
| country?: string; // ISO-3166 alpha-2 country code | ||
| subdivision?: string; // State/province code | ||
| city?: string; | ||
| postalCode?: string; | ||
| addressLine1?: string; // Main address line (street name and number) | ||
| addressLine2?: string; // Additional address info (apt, suite, floor) | ||
| streetAddress?: { // Structured street address | ||
| number?: string; // Street number | ||
| name?: string; // Street name | ||
| }; | ||
| location?: { // Geocode coordinates | ||
| latitude?: number; | ||
| longitude?: number; | ||
| }; | ||
| countryFullname?: string; // Country full name (read-only) | ||
| subdivisionFullname?: string; // Subdivision full name (read-only) | ||
| }; |
There was a problem hiding this comment.
| @@ -23,7 +23,7 @@ The `calculateAdditionalFees` handler receives `{ request, metadata }`. Key fiel | |||
| ```typescript | |||
There was a problem hiding this comment.
Whay about metadata object?
There was a problem hiding this comment.
Metadata is the same for all - so I had it in one place
| catalogReference?: { | ||
| catalogItemId: string; | ||
| appId: string; | ||
| options?: Record<string, any>; |
There was a problem hiding this comment.
| @@ -17,6 +17,46 @@ import { customTriggers } from "@wix/ecom/service-plugins"; | |||
| | `getEligibleTriggers` | Evaluate current conditions and return which triggers are active | | |||
| | `listTriggers` | Return the list of all available custom triggers | | |||
|
|
|||
There was a problem hiding this comment.
we need metadata here also
|
|
||
| ### listTriggers Request | ||
|
|
||
| The `listTriggers` handler receives `{ request, metadata }`. The `request` object is empty — no fields to read. |
| @@ -18,6 +18,43 @@ import { giftVouchersProvider } from '@wix/ecom/service-plugins'; | |||
| | `getBalance` | Check the current balance of a gift card | | |||
| | `_void` | Cancel/void a previous redemption | | |||
|
|
|||
| extendedFields?: { // Extended field data | ||
| namespaces?: Record<string, Record<string, any>>; | ||
| }; |
There was a problem hiding this comment.
Summary
@wix/ecomtypes — wrong field names (lineItemTaxes→lineItemTaxDetails,lineItemId→_id,name→taxName), wrong type shapes (item.price.amount→item.priceas string,amountobject →taxAmountstring), wrong request field (shippingAddress→addresses[0]), and wrong rate format (percentage → decimal)descriptionfrom generic builder config table and example since it's only available onecomShippingRates(), not all builder methodsTest plan
CalculateTaxRequestandCalculateTaxResponsetypes in@wix/ecom@latest🤖 Generated with Claude Code