Skip to content

Fix SPI type mismatches in service plugin references#60

Closed
yanivefraim wants to merge 10 commits intomainfrom
fix/service-plugin-spi-type-mismatches
Closed

Fix SPI type mismatches in service plugin references#60
yanivefraim wants to merge 10 commits intomainfrom
fix/service-plugin-spi-type-mismatches

Conversation

@yanivefraim
Copy link
Copy Markdown
Member

Summary

  • TAX-CALCULATION.md: Fix 10+ type errors to match actual @wix/ecom types — wrong field names (lineItemTaxeslineItemTaxDetails, lineItemId_id, nametaxName), wrong type shapes (item.price.amountitem.price as string, amount object → taxAmount string), wrong request field (shippingAddressaddresses[0]), and wrong rate format (percentage → decimal)
  • SKILL.md: Remove description from generic builder config table and example since it's only available on ecomShippingRates(), not all builder methods

Test plan

  • Review corrected TAX-CALCULATION.md code example against CalculateTaxRequest and CalculateTaxResponse types in @wix/ecom@latest
  • Verify SKILL.md builder config table accurately reflects universal fields
  • Confirm no other reference files were affected

🤖 Generated with Claude Code

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>
@yanivefraim yanivefraim marked this pull request as draft March 19, 2026 09:54
yanivefraim and others added 3 commits March 19, 2026 16:25
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>
@yanivefraim yanivefraim marked this pull request as ready for review March 22, 2026 11:33
yanivefraim and others added 6 commits March 22, 2026 13:33
…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>
Copy link
Copy Markdown
Collaborator

@mirivoWix mirivoWix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't finish to review
There are still a lot of type errors, lets rethink adding them here

Comment on lines +86 to +88
coupon?: { _id?: string; code?: string; name?: string; amount?: string; };
merchantDiscount?: { amount?: string; }; // Discount amount as decimal string
discountRule?: { _id?: string; name?: { original?: string; }; };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +117 to +119
extendedFields?: { // Extended field data
namespaces?: Record<string, Record<string, any>>;
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -37,15 +37,86 @@ The `calculateAdditionalFees` handler receives `{ request, metadata }`. Key fiel
sku: string; // Stock-keeping unit
shippable: boolean; // Whether item is shippable
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 53 to +70
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)
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -23,7 +23,7 @@ The `calculateAdditionalFees` handler receives `{ request, metadata }`. Key fiel
```typescript
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whay about metadata object?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata is the same for all - so I had it in one place

catalogReference?: {
catalogItemId: string;
appId: string;
options?: Record<string, any>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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 |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need metadata here also


### listTriggers Request

The `listTriggers` handler receives `{ request, metadata }`. The `request` object is empty — no fields to read.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is metadata?

@@ -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 |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again metadata

Comment on lines +30 to +32
extendedFields?: { // Extended field data
namespaces?: Record<string, Record<string, any>>;
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants