Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Bumped admin-sdk to 0.5.0

Damian Legawiecdd84b511bf32
diff --git a/packages/admin-sdk/CHANGELOG.md b/packages/admin-sdk/CHANGELOG.md
index ce82ea6ca6..22e6ad25b2 100644
--- a/packages/admin-sdk/CHANGELOG.md
+++ b/packages/admin-sdk/CHANGELOG.md
@@ -1,5 +1,19 @@
# @spree/admin-sdk
+## 0.5.0
+
+### Minor Changes
+
+- Align the variant write params with the v3 API: variants are priced exclusively through the per-currency `prices` array — the legacy singular `compare_at_price` field is no longer accepted.
+
+ **Note on bump type:** `@spree/admin-sdk` is on a 0.x version line (`next` dist-tag, Developer Preview). Per Changesets convention, breaking changes on 0.x packages bump the minor — moving to `major` would mean 1.0.0 and signal API stability we do not yet guarantee. The changes below are breaking; coordinated with the server-side change shipping in Spree 6.0.
+
+ **Breaking changes:**
+
+ - `VariantCreateParams` and `VariantUpdateParams` no longer accept `compare_at_price`. Set the compare-at price per currency via `prices: [{ currency, amount, compare_at_amount }]` instead.
+ - `VariantCreateParams.options` is now required. The standalone `variants.create` endpoint always creates a non-master variant, which must declare at least one option pair (e.g. size + color) or creation fails with `422`.
+ - `ProductCreateParams.variants` / `ProductUpdateParams.variants` now use the new `ProductVariantInput` type instead of `VariantCreateParams[]` / `VariantUpdateParams[]`. A nested variant entry keeps `options` optional: an options-less entry upserts onto the product's default variant (the simple, no-options product case).
+
## 0.4.0
### Minor Changes
diff --git a/packages/admin-sdk/package.json b/packages/admin-sdk/package.json
index df4430de57..113f694d68 100644
--- a/packages/admin-sdk/package.json
+++ b/packages/admin-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/admin-sdk",
- "version": "0.4.0",
+ "version": "0.5.0",
"description": "Official TypeScript SDK for Spree Commerce Admin API",
"type": "module",
"main": "./dist/index.cjs",
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index 349ac43d78..1a01706801 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -316,7 +316,7 @@ export interface ProductCreateParams {
prices?: VariantPrice[]
/** Every purchasable attribute (sku, prices, stock, weight, dimensions) lives
* on variants. Pass at least one variant to make the product purchasable. */
- variants?: VariantCreateParams[]
+ variants?: ProductVariantInput[]
product_publications?: ProductPublicationInput[]
}
@@ -330,10 +330,41 @@ export interface ProductUpdateParams {
tags?: Array<string>
/** Shorthand for a simple (no-options) product — see `ProductCreateParams.prices`. */
prices?: VariantPrice[]
- variants?: VariantUpdateParams[]
+ variants?: ProductVariantInput[]
product_publications?: ProductPublicationInput[]
}
+/**
+ * A variant entry nested inside a product create/update payload.
+ *
+ * Unlike the standalone `POST /products/:id/variants` endpoint (see
+ * `VariantCreateParams`, where `options` is required because the variant is
+ * always non-master), a nested entry may omit `options`: an options-less
+ * entry upserts onto the product's default (master) variant — the simple,
+ * no-options product case. Pass `id` to update an existing variant.
+ */
+export interface ProductVariantInput {
+ id?: string
+ sku?: string
+ cost_price?: string | number
+ cost_currency?: string
+ weight?: number
+ height?: number
+ width?: number
+ depth?: number
+ weight_unit?: string
+ dimensions_unit?: string
+ track_inventory?: boolean
+ tax_category_id?: string
+ position?: number
+ barcode?: string
+ /** Omit for a simple no-options product (upserts onto the default variant). */
+ options?: VariantOptionPair[]
+ /** Per-currency prices. Upserted by currency. */
+ prices?: VariantPrice[]
+ stock_items?: VariantStockItem[]
+}
+
export interface CategoryCreateParams {
name: string
parent_id?: string
@@ -387,8 +418,6 @@ export interface VariantStockItem {
export interface VariantCreateParams {
sku?: string
/** Decimal amount; see `VariantPrice.amount` for the string rationale. */
- compare_at_price?: string | number
- /** Decimal amount; see `VariantPrice.amount` for the string rationale. */
cost_price?: string | number
cost_currency?: string
weight?: number
@@ -401,7 +430,15 @@ export interface VariantCreateParams {
tax_category_id?: string
position?: number
barcode?: string
- options?: VariantOptionPair[]
+ /**
+ * Required on create — a variant created via this endpoint is always
+ * non-master, so it must declare at least one option pair (e.g. size +
+ * color) or creation fails with 422. The non-empty tuple type enforces
+ * this at compile time. Option types and values are auto-created if
+ * missing.
+ */
+ options: [VariantOptionPair, ...VariantOptionPair[]]
+ /** Per-currency prices. Upserted by currency. */
prices?: VariantPrice[]
stock_items?: VariantStockItem[]
}
@@ -409,8 +446,6 @@ export interface VariantCreateParams {
export interface VariantUpdateParams {
sku?: string
/** Decimal amount; see `VariantPrice.amount` for the string rationale. */
- compare_at_price?: string | number
- /** Decimal amount; see `VariantPrice.amount` for the string rationale. */
cost_price?: string | number
cost_currency?: string
weight?: number
@@ -423,7 +458,9 @@ export interface VariantUpdateParams {
tax_category_id?: string
position?: number
barcode?: string
+ /** Partial update — omit to leave option values untouched. */
options?: VariantOptionPair[]
+ /** Per-currency prices. Upserted by currency. */
prices?: VariantPrice[]
stock_items?: VariantStockItem[]
}