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.

Support Prices and Price Lists in Admin SDK

Damian Legawiec5bec5bbcb978
diff --git a/packages/admin-sdk/examples/markets/get.ts b/packages/admin-sdk/examples/markets/get.ts
new file mode 100644
index 0000000000..cf52a66097
--- /dev/null
+++ b/packages/admin-sdk/examples/markets/get.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const market = await client.markets.get('market_xxx')
+// endregion:example
+
+export { market }
diff --git a/packages/admin-sdk/examples/markets/list.ts b/packages/admin-sdk/examples/markets/list.ts
new file mode 100644
index 0000000000..543144d47f
--- /dev/null
+++ b/packages/admin-sdk/examples/markets/list.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const { data: markets } = await client.markets.list()
+// endregion:example
+
+export { markets }
diff --git a/packages/admin-sdk/examples/price-lists/activate.ts b/packages/admin-sdk/examples/price-lists/activate.ts
new file mode 100644
index 0000000000..0e6e8adaf9
--- /dev/null
+++ b/packages/admin-sdk/examples/price-lists/activate.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const priceList = await client.priceLists.activate('pl_xxx')
+// endregion:example
+
+export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/create.ts b/packages/admin-sdk/examples/price-lists/create.ts
new file mode 100644
index 0000000000..37bb8f2d08
--- /dev/null
+++ b/packages/admin-sdk/examples/price-lists/create.ts
@@ -0,0 +1,46 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+// Server-to-server one-shot create. Ship the rules that gate the list
+// and the exact per-variant prices in a single request — variants in
+// `prices` implicitly become part of the list (upserted on the unique
+// key `(variant_id, currency, price_list_id)`), so there's no need to
+// pre-declare `product_ids` separately.
+const priceList = await client.priceLists.create({
+ name: 'EU wholesale',
+ description: 'Tiered pricing for verified B2B customers',
+ match_policy: 'all',
+ starts_at: '2026-06-01T00:00:00Z',
+ ends_at: '2026-09-01T00:00:00Z',
+ rules: [
+ {
+ type: 'customer_group_rule',
+ preferences: { customer_group_ids: ['cg_aBc123'] },
+ },
+ {
+ type: 'volume_rule',
+ preferences: { min_quantity: 10 },
+ },
+ ],
+ prices: [
+ {
+ variant_id: 'variant_xY9',
+ currency: 'USD',
+ amount: '19.99',
+ compare_at_amount: '24.99',
+ },
+ {
+ variant_id: 'variant_aB7',
+ currency: 'USD',
+ amount: '21.99',
+ },
+ ],
+})
+// endregion:example
+
+export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/deactivate.ts b/packages/admin-sdk/examples/price-lists/deactivate.ts
new file mode 100644
index 0000000000..368a60cf69
--- /dev/null
+++ b/packages/admin-sdk/examples/price-lists/deactivate.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const priceList = await client.priceLists.deactivate('pl_xxx')
+// endregion:example
+
+export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/delete.ts b/packages/admin-sdk/examples/price-lists/delete.ts
new file mode 100644
index 0000000000..4d266ddb41
--- /dev/null
+++ b/packages/admin-sdk/examples/price-lists/delete.ts
@@ -0,0 +1,10 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+await client.priceLists.delete('pl_xxx')
+// endregion:example
diff --git a/packages/admin-sdk/examples/price-lists/get.ts b/packages/admin-sdk/examples/price-lists/get.ts
new file mode 100644
index 0000000000..89a25458fe
--- /dev/null
+++ b/packages/admin-sdk/examples/price-lists/get.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const priceList = await client.priceLists.get('pl_xxx')
+// endregion:example
+
+export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/list.ts b/packages/admin-sdk/examples/price-lists/list.ts
new file mode 100644
index 0000000000..456edcef9e
--- /dev/null
+++ b/packages/admin-sdk/examples/price-lists/list.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const { data: priceLists } = await client.priceLists.list()
+// endregion:example
+
+export { priceLists }
diff --git a/packages/admin-sdk/examples/price-lists/update.ts b/packages/admin-sdk/examples/price-lists/update.ts
new file mode 100644
index 0000000000..6615395011
--- /dev/null
+++ b/packages/admin-sdk/examples/price-lists/update.ts
@@ -0,0 +1,14 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const priceList = await client.priceLists.update('pl_xxx', {
+ name: 'Wholesale (Q3)',
+})
+// endregion:example
+
+export { priceList }
diff --git a/packages/admin-sdk/examples/prices/bulk-destroy.ts b/packages/admin-sdk/examples/prices/bulk-destroy.ts
new file mode 100644
index 0000000000..a483587de3
--- /dev/null
+++ b/packages/admin-sdk/examples/prices/bulk-destroy.ts
@@ -0,0 +1,14 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const { price_count } = await client.prices.bulkDestroy({
+ ids: ['price_xxx', 'price_yyy'],
+})
+// endregion:example
+
+export { price_count }
diff --git a/packages/admin-sdk/examples/prices/bulk-upsert.ts b/packages/admin-sdk/examples/prices/bulk-upsert.ts
new file mode 100644
index 0000000000..f7c4705836
--- /dev/null
+++ b/packages/admin-sdk/examples/prices/bulk-upsert.ts
@@ -0,0 +1,27 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const { price_count } = await client.prices.bulkUpsert({
+ prices: [
+ {
+ variant_id: 'variant_xxx',
+ currency: 'USD',
+ price_list_id: 'pl_xxx',
+ amount: '11.11',
+ },
+ {
+ variant_id: 'variant_yyy',
+ currency: 'USD',
+ price_list_id: 'pl_xxx',
+ amount: '22.22',
+ },
+ ],
+})
+// endregion:example
+
+export { price_count }
diff --git a/packages/admin-sdk/examples/prices/create.ts b/packages/admin-sdk/examples/prices/create.ts
new file mode 100644
index 0000000000..579b217f3c
--- /dev/null
+++ b/packages/admin-sdk/examples/prices/create.ts
@@ -0,0 +1,16 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const price = await client.prices.create({
+ variant_id: 'variant_xxx',
+ currency: 'USD',
+ amount: '19.99',
+})
+// endregion:example
+
+export { price }
diff --git a/packages/admin-sdk/examples/prices/delete.ts b/packages/admin-sdk/examples/prices/delete.ts
new file mode 100644
index 0000000000..4e5c158720
--- /dev/null
+++ b/packages/admin-sdk/examples/prices/delete.ts
@@ -0,0 +1,10 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+await client.prices.delete('price_xxx')
+// endregion:example
diff --git a/packages/admin-sdk/examples/prices/get.ts b/packages/admin-sdk/examples/prices/get.ts
new file mode 100644
index 0000000000..c9451611d0
--- /dev/null
+++ b/packages/admin-sdk/examples/prices/get.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const price = await client.prices.get('price_xxx')
+// endregion:example
+
+export { price }
diff --git a/packages/admin-sdk/examples/prices/list.ts b/packages/admin-sdk/examples/prices/list.ts
new file mode 100644
index 0000000000..398ade816f
--- /dev/null
+++ b/packages/admin-sdk/examples/prices/list.ts
@@ -0,0 +1,16 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const { data: prices } = await client.prices.list({
+ price_list_id_eq: 'pl_xxx',
+ currency_eq: 'USD',
+ expand: ['variant'],
+})
+// endregion:example
+
+export { prices }
diff --git a/packages/admin-sdk/examples/prices/update.ts b/packages/admin-sdk/examples/prices/update.ts
new file mode 100644
index 0000000000..9150b35528
--- /dev/null
+++ b/packages/admin-sdk/examples/prices/update.ts
@@ -0,0 +1,14 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const price = await client.prices.update('price_xxx', {
+ amount: '12.34',
+})
+// endregion:example
+
+export { price }
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index bb52a4eae5..39f4814f95 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -104,6 +104,11 @@ import type {
PaymentMethodCreateParams,
PaymentMethodType,
PaymentMethodUpdateParams,
+ PriceBulkUpsertRow,
+ PriceCreateParams,
+ PriceListCreateParams,
+ PriceListUpdateParams,
+ PriceUpdateParams,
ProductCreateParams,
ProductUpdateParams,
PromotionActionCalculator,
@@ -144,11 +149,14 @@ import type {
GiftCardBatch,
Invitation,
LineItem,
+ Market,
Media,
OptionType,
Order,
Payment,
PaymentMethod,
+ Price,
+ PriceList,
Product,
Promotion,
PromotionAction,
@@ -962,6 +970,130 @@ export class AdminClient {
this.request<{ data: PaymentMethodType[] }>('GET', '/payment_methods/types', options),
}
+ // ============================================
+ // Price Lists (admin-only — wholesale, regional, volume pricing)
+ // ============================================
+
+ /**
+ * CRUD plus lifecycle (`activate` / `deactivate`) for `Spree::PriceList`.
+ * Membership (`product_ids: [...]`), rules (`rules: [...]`), and per-row
+ * price overrides (`prices: [...]`) all ride along on the normal
+ * `update` payload — one PATCH saves the entire editor. `prices(id)`
+ * fetches the spreadsheet's initial render data. Price lists are
+ * admin-only; the storefront only ever sees the resolved price (see
+ * `PriceSerializer#price_list_id`).
+ */
+ readonly priceLists = {
+ list: (
+ params?: ListParams & Record<string, unknown>,
+ options?: RequestOptions,
+ ): Promise<PaginatedResponse<PriceList>> =>
+ this.request<PaginatedResponse<PriceList>>('GET', '/price_lists', {
+ ...options,
+ params: params ? transformListParams(params) : undefined,
+ }),
+
+ get: (
+ id: string,
+ params?: { expand?: string[] },
+ options?: RequestOptions,
+ ): Promise<PriceList> =>
+ this.request<PriceList>('GET', `/price_lists/${id}`, {
+ ...options,
+ params: getParams(params),
+ }),
+
+ create: (params: PriceListCreateParams, options?: RequestOptions): Promise<PriceList> =>
+ this.request<PriceList>('POST', '/price_lists', { ...options, body: params }),
+
+ update: (
+ id: string,
+ params: PriceListUpdateParams,
+ options?: RequestOptions,
+ ): Promise<PriceList> =>
+ this.request<PriceList>('PATCH', `/price_lists/${id}`, { ...options, body: params }),
+
+ delete: (id: string, options?: RequestOptions): Promise<void> =>
+ this.request<void>('DELETE', `/price_lists/${id}`, options),
+
+ /** draft|inactive → active (or → scheduled if `starts_at` is in the future). */
+ activate: (id: string, options?: RequestOptions): Promise<PriceList> =>
+ this.request<PriceList>('PATCH', `/price_lists/${id}/activate`, options),
+
+ /** active|scheduled → inactive. */
+ deactivate: (id: string, options?: RequestOptions): Promise<PriceList> =>
+ this.request<PriceList>('PATCH', `/price_lists/${id}/deactivate`, options),
+
+ /**
+ * Returns `[{ type, label, description, preference_schema }]` for
+ * every registered subclass in `Spree.pricing.rules`. Used to build
+ * the "Add rule" picker + render a generic preferences form per
+ * subclass. Rules themselves are not a separate REST resource —
+ * the SPA ships them inline on the list's `update` payload.
+ */
+ ruleTypes: (options?: RequestOptions): Promise<{ data: ResourceTypeDefinition[] }> =>
+ this.request<{ data: ResourceTypeDefinition[] }>(
+ 'GET',
+ '/price_lists/price_rule_types',
+ options,
+ ),
+ }
+
+ // ============================================
+ // Prices (generic — base prices AND price-list overrides)
+ // ============================================
+
+ /**
+ * CRUD + bulk endpoints for `Spree::Price`. One resource covers both
+ * base prices (`price_list_id: null`) and price-list overrides
+ * (`price_list_id: pl_…`). The spreadsheet UI for a price list uses
+ * `list({ price_list_id_eq, currency_eq, page, limit })` for the
+ * paginated read and `bulkUpsert(...)` for the save.
+ */
+ readonly prices = {
+ list: (
+ params?: ListParams & Record<string, unknown>,
+ options?: RequestOptions,
+ ): Promise<PaginatedResponse<Price>> =>
+ this.request<PaginatedResponse<Price>>('GET', '/prices', {
+ ...options,
+ params: params ? transformListParams(params) : undefined,
+ }),
+
+ get: (id: string, params?: { expand?: string[] }, options?: RequestOptions): Promise<Price> =>
+ this.request<Price>('GET', `/prices/${id}`, {
+ ...options,
+ params: getParams(params),
+ }),
+
+ create: (params: PriceCreateParams, options?: RequestOptions): Promise<Price> =>
+ this.request<Price>('POST', '/prices', { ...options, body: params }),
+
+ update: (id: string, params: PriceUpdateParams, options?: RequestOptions): Promise<Price> =>
+ this.request<Price>('PATCH', `/prices/${id}`, { ...options, body: params }),
+
+ delete: (id: string, options?: RequestOptions): Promise<void> =>
+ this.request<void>('DELETE', `/prices/${id}`, options),
+
+ /**
+ * One SQL round trip via `upsert_all` — model callbacks (PriceHistory,
+ * after_save hooks) are bypassed for speed. Caller is responsible
+ * for shipping sane values. Response is just `{ price_count }`: the
+ * number of rows the DB touched.
+ */
+ bulkUpsert: (
+ params: { prices: PriceBulkUpsertRow[] },
+ options?: RequestOptions,
+ ): Promise<{ price_count: number }> =>
+ this.request('POST', '/prices/bulk_upsert', { ...options, body: params }),
+
+ bulkDestroy: (
+ params: { ids: string[] },
+ options?: RequestOptions,
+ ): Promise<{ price_count: number }> =>
+ this.request('DELETE', '/prices/bulk_destroy', { ...options, body: params }),
+ }
+
// ============================================
// Promotions (with nested actions, rules, coupon codes)
// ============================================
@@ -1567,6 +1699,32 @@ export class AdminClient {
// Store Credit Categories (read-only — for category dropdowns)
// ============================================
+ /**
+ * Markets — read-only admin surface. Drives label resolution for
+ * `Spree::PriceRules::MarketRule` and similar pickers. Write surface
+ * lives in the legacy Rails admin pending the Channel/Catalog rework.
+ */
+ readonly markets = {
+ list: (
+ params?: ListParams & Record<string, unknown>,
+ options?: RequestOptions,
+ ): Promise<PaginatedResponse<Market>> =>
+ this.request<PaginatedResponse<Market>>('GET', '/markets', {
+ ...options,
+ params: params ? transformListParams(params) : undefined,
+ }),
+
+ get: (id: string, params?: { expand?: string[] }, options?: RequestOptions): Promise<Market> =>
+ this.request<Market>('GET', `/markets/${id}`, {
+ ...options,
+ params: getParams(params),
+ }),
+ }
+
+ // ============================================
+ // Store Credit Categories
+ // ============================================
+
readonly storeCreditCategories = {
list: (
params?: ListParams & Record<string, unknown>,
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index 356d66d8d3..fa47a629e4 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -581,6 +581,149 @@ export interface ResourceTypeDefinition {
preference_schema: PreferenceField[]
}
+// ---------------------------------------------------------------------------
+// Price Lists
+// ---------------------------------------------------------------------------
+
+/**
+ * Nested-rule payload accepted by both create and update. Existing rules
+ * are matched by `id` and updated, new rules build, anything not in the
+ * array is destroyed — mirrors the Promotions editor's "save the whole
+ * thing in one PATCH" flow.
+ */
+export interface PriceListRuleDraft {
+ /** Present for existing rules. Omit to create a new one. */
+ id?: string | null
+ /** Wire shorthand for the STI subclass — e.g. `volume_rule`, `market_rule`. */
+ type: string
+ /** Subclass-specific configuration; coerced server-side via typed preference setters. */
+ preferences?: Record<string, unknown>
+}
+
+export interface PriceListCreateParams {
+ name: string
+ description?: string | null
+ /**
+ * ISO 8601 timestamp. Pair with `ends_at` to schedule the list — an
+ * activated list with a future `starts_at` is auto-marked `scheduled`
+ * (mirrors the legacy admin).
+ */
+ starts_at?: string | null
+ ends_at?: string | null
+ /** `all` — every rule must match. `any` — first match wins. */
+ match_policy?: 'all' | 'any'
+ position?: number
+ /**
+ * Admin UI shape. Prefixed product ids to seed the list with —
+ * placeholder prices (`amount: null`) are inserted for each variant
+ * × supported currency. The spreadsheet editor then fills them in.
+ *
+ * Prefer `prices` for server-to-server use: it lets you create the
+ * list and ship the exact per-variant amounts in one request.
+ */
+ product_ids?: string[]
+ /** Optional nested rules — reconciled on save. */
+ rules?: PriceListRuleDraft[]
+ /**
+ * Server-to-server alternative to `product_ids`. Each row upserts on
+ * `(variant_id, currency, price_list_id)`, so variants in this array
+ * implicitly become part of the list with the supplied amount.
+ */
+ prices?: PriceListPriceOverrideParams[]
+}
+
+export interface PriceListUpdateParams {
+ name?: string
+ description?: string | null
+ starts_at?: string | null
+ ends_at?: string | null
+ match_policy?: 'all' | 'any'
+ position?: number
+ /**
+ * Reconciles list membership: every id in the array is kept (placeholder
+ * prices created if missing); every id currently in the list but not in
+ * the array is dropped. Send the desired full set on every update —
+ * the server diffs it against the current state.
+ */
+ product_ids?: string[]
+ rules?: PriceListRuleDraft[]
+ /**
+ * Inline spreadsheet payload. Only ship the rows whose `amount` /
+ * `compare_at_amount` actually changed — the server skips unchanged
+ * cells, but a smaller body is still nicer. Runs in `after_save` so
+ * it picks up rows created by `product_ids=` in the same request.
+ */
+ prices?: PriceListPriceOverrideParams[]
+}
+
+/**
+ * One row in the inline `prices: [...]` array carried by
+ * `PriceListCreateParams` / `PriceListUpdateParams`. The server upserts
+ * on the unique key `(variant_id, currency, price_list_id)`, so the
+ * row matches by triple — `id` is only useful when echoing back rows
+ * read from a previous response. For first-time creates ship
+ * `variant_id` + `currency` + `amount` directly.
+ */
+export interface PriceListPriceOverrideParams {
+ id?: string
+ variant_id: string
+ currency: string
+ amount?: string | number | null
+ compare_at_amount?: string | number | null
+}
+
+// ---------------------------------------------------------------------------
+// Prices (generic — base prices AND price-list overrides)
+// ---------------------------------------------------------------------------
+
+/**
+ * Create or update a single Spree::Price. Set `price_list_id: null`
+ * (or omit it) for a base price on the variant; pass a prefixed
+ * `pl_…` to attach the row to a price list.
+ */
+export interface PriceCreateParams {
+ variant_id: string
+ currency: string
+ amount: string | number | null
+ compare_at_amount?: string | number | null
+ /** Omit / null for a base price; prefixed `pl_…` for a list override. */
+ price_list_id?: string | null
+}
+
+export interface PriceUpdateParams {
+ /** Mutating these would re-key the row against the unique
+ * `(variant_id, currency, price_list_id)` index — not supported. */
+ // variant_id, currency, price_list_id intentionally omitted.
+ amount?: string | number | null
+ compare_at_amount?: string | number | null
+}
+
+/**
+ * One row in the `POST /admin/prices/bulk_upsert` payload.
+ *
+ * Two modes, picked by whether `id` is set:
+ *
+ * - `id` present → updates that row (404s if it doesn't exist or
+ * is out of the caller's store scope).
+ * - `id` absent → upserts by `(variant_id, currency, price_list_id)`.
+ * The unique index on `spree_prices` decides update-vs-create.
+ *
+ * Useful for the spreadsheet (mostly updates) and for ad-hoc seeding
+ * a fresh currency across many variants (mostly creates).
+ */
+export interface PriceBulkUpsertRow {
+ /** Present → update by id. Absent → upsert by the unique key. */
+ id?: string
+ /** Required when `id` is absent. */
+ variant_id?: string
+ /** Required when `id` is absent. */
+ currency?: string
+ /** Null / omitted = base price; prefixed `pl_…` = list override. */
+ price_list_id?: string | null
+ amount?: string | number | null
+ compare_at_amount?: string | number | null
+}
+
export interface PaymentMethodCreateParams {
/** Fully-qualified STI subclass name, e.g. 'Spree::PaymentMethod::Check'. */
type: string
diff --git a/packages/admin-sdk/src/types/index.ts b/packages/admin-sdk/src/types/index.ts
index fde83f2981..5972a35f23 100644
--- a/packages/admin-sdk/src/types/index.ts
+++ b/packages/admin-sdk/src/types/index.ts
@@ -42,6 +42,8 @@ export type { default as PaymentMethod } from './generated/PaymentMethod'
export type { default as PaymentSource } from './generated/PaymentSource'
export type { default as Price } from './generated/Price'
export type { default as PriceHistory } from './generated/PriceHistory'
+export type { default as PriceList } from './generated/PriceList'
+export type { default as PriceRule } from './generated/PriceRule'
export type { default as Product } from './generated/Product'
export type { default as Promotion } from './generated/Promotion'
export type { default as PromotionAction } from './generated/PromotionAction'
diff --git a/packages/admin-sdk/tests/price-lists.test.ts b/packages/admin-sdk/tests/price-lists.test.ts
new file mode 100644
index 0000000000..916e49bc96
--- /dev/null
+++ b/packages/admin-sdk/tests/price-lists.test.ts
@@ -0,0 +1,193 @@
+import { HttpResponse, http } from 'msw'
+import { describe, expect, it } from 'vitest'
+import { createAdminClient } from '../src'
+import { server } from './mocks/server'
+
+const BASE_URL = 'https://demo.spreecommerce.org'
+const API_PREFIX = `${BASE_URL}/api/v3/admin`
+
+const samplePriceList = {
+ id: 'pl_abc123',
+ name: 'Wholesale',
+ description: null,
+ status: 'draft',
+ position: 1,
+ match_policy: 'all',
+ starts_at: null,
+ ends_at: null,
+ created_at: '2026-05-01T00:00:00Z',
+ updated_at: '2026-05-01T00:00:00Z',
+ currently_active: false,
+ products_count: 0,
+ prices_count: 0,
+}
+
+describe('priceLists', () => {
+ describe('list', () => {
+ it('GETs /price_lists and returns paginated data', async () => {
+ server.use(
+ http.get(`${API_PREFIX}/price_lists`, () =>
+ HttpResponse.json({
+ data: [samplePriceList],
+ meta: { page: 1, limit: 25, count: 1, pages: 1 },
+ }),
+ ),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ const res = await client.priceLists.list()
+
+ expect(res.data).toHaveLength(1)
+ expect(res.data[0]?.id).toBe('pl_abc123')
+ })
+
+ it('wraps Ransack predicates via transformListParams', async () => {
+ let url: URL | null = null
+ server.use(
+ http.get(`${API_PREFIX}/price_lists`, ({ request }) => {
+ url = new URL(request.url)
+ return HttpResponse.json({ data: [], meta: { page: 1, limit: 25, count: 0, pages: 0 } })
+ }),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ await client.priceLists.list({ status_eq: 'active', name_cont: 'whole' })
+
+ expect(url!.searchParams.get('q[status_eq]')).toBe('active')
+ expect(url!.searchParams.get('q[name_cont]')).toBe('whole')
+ })
+ })
+
+ describe('create', () => {
+ it('POSTs the params verbatim', async () => {
+ let body: Record<string, unknown> | null = null
+ server.use(
+ http.post(`${API_PREFIX}/price_lists`, async ({ request }) => {
+ body = (await request.json()) as Record<string, unknown>
+ return HttpResponse.json(samplePriceList, { status: 201 })
+ }),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ await client.priceLists.create({ name: 'Wholesale', match_policy: 'all' })
+
+ expect(body).toEqual({ name: 'Wholesale', match_policy: 'all' })
+ })
+ })
+
+ describe('activate / deactivate', () => {
+ it('PATCHes /activate', async () => {
+ let hit = false
+ server.use(
+ http.patch(`${API_PREFIX}/price_lists/pl_abc123/activate`, () => {
+ hit = true
+ return HttpResponse.json({ ...samplePriceList, status: 'active', currently_active: true })
+ }),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ const res = await client.priceLists.activate('pl_abc123')
+
+ expect(hit).toBe(true)
+ expect(res.status).toBe('active')
+ })
+
+ it('PATCHes /deactivate', async () => {
+ server.use(
+ http.patch(`${API_PREFIX}/price_lists/pl_abc123/deactivate`, () =>
+ HttpResponse.json({ ...samplePriceList, status: 'inactive' }),
+ ),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ const res = await client.priceLists.deactivate('pl_abc123')
+
+ expect(res.status).toBe('inactive')
+ })
+ })
+
+ describe('update with product_ids', () => {
+ it('PATCHes the desired product set as part of the regular update payload', async () => {
+ let body: Record<string, unknown> | null = null
+ server.use(
+ http.patch(`${API_PREFIX}/price_lists/pl_abc123`, async ({ request }) => {
+ body = (await request.json()) as Record<string, unknown>
+ return HttpResponse.json({
+ ...samplePriceList,
+ product_ids: ['prod_a', 'prod_b'],
+ })
+ }),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ const res = await client.priceLists.update('pl_abc123', {
+ name: 'Wholesale',
+ product_ids: ['prod_a', 'prod_b'],
+ })
+
+ // Membership reconciliation is part of the same PATCH that carries
+ // name / description / rules — there are no separate endpoints.
+ expect(body).toEqual({ name: 'Wholesale', product_ids: ['prod_a', 'prod_b'] })
+ expect(res).toMatchObject({ product_ids: ['prod_a', 'prod_b'] })
+ })
+ })
+
+ describe('update with prices', () => {
+ it('PATCHes price overrides as part of the regular update payload', async () => {
+ let body: Record<string, unknown> | null = null
+ server.use(
+ http.patch(`${API_PREFIX}/price_lists/pl_abc123`, async ({ request }) => {
+ body = (await request.json()) as Record<string, unknown>
+ return HttpResponse.json(samplePriceList)
+ }),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ await client.priceLists.update('pl_abc123', {
+ prices: [
+ { id: 'price_x', variant_id: 'variant_x', currency: 'USD', amount: '12.50' },
+ {
+ id: 'price_y',
+ variant_id: 'variant_y',
+ currency: 'USD',
+ amount: null,
+ compare_at_amount: '15.00',
+ },
+ ],
+ })
+
+ // Membership / rules / individual price overrides all reconcile in
+ // the same PATCH — there's no separate bulk endpoint.
+ expect((body as { prices: unknown[] }).prices).toHaveLength(2)
+ })
+ })
+
+ // Rules themselves aren't a separate REST resource — they ride along
+ // on the price list's `update` payload. The one exception is the
+ // discovery endpoint below, which the SPA hits to build the "Add rule"
+ // picker without hard-coding subclass labels.
+ describe('ruleTypes', () => {
+ it('lists rule types with preference schema', async () => {
+ server.use(
+ http.get(`${API_PREFIX}/price_lists/price_rule_types`, () =>
+ HttpResponse.json({
+ data: [
+ {
+ type: 'volume_rule',
+ label: 'Volume Rule',
+ description: 'Apply pricing based on quantity purchased',
+ preference_schema: [{ key: 'min_quantity', type: 'integer', default: 1 }],
+ },
+ ],
+ }),
+ ),
+ )
+
+ const client = createAdminClient({ baseUrl: BASE_URL })
+ const res = await client.priceLists.ruleTypes()
+
+ expect(res.data).toHaveLength(1)
+ expect(res.data[0]?.type).toBe('volume_rule')
+ })
+ })
+})