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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Bring back exporting to Admin SPA (#13997)
Damian Legawieca78ef18c8825
diff --git a/CLAUDE.md b/CLAUDE.mdindex 9c54c352c4..3b9c706da8 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -39,6 +39,7 @@ Current plans:- `5.4-centralized-translations-admin.md` — Centralized Translations admin page under Products, overview grid + bulk CSV import/export- `5.4-metafield-translations.md` — Translate MetafieldDefinition names + Metafield text values (ShortText, LongText, RichText) via Mobility translation tables- `5.5-admin-auth-cookie-refresh.md` — Move admin SPA refresh token to httpOnly cookie, access token in memory, double-submit CSRF, server-side logout that destroys RefreshToken row. Breaking change shipped as a single coordinated bump (admin-sdk is unreleased)+- `5.5-admin-spa-csv-export.md` — Reuse existing `Spree::Export` infra; add Admin API CRUD + `client.exports` SDK + toolbar button/modal + polling flow on Products/Orders/Customers index pages. Filters round-trip via Ransack JSON; download via short-lived signed Blob URLCompleted plans:- `5.4-store-api-bridges.md` — Bridge 6.0 naming into 5.4 Store API (implemented, PR #13782)diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yamlindex 3e0d0fef7d..1a9ead526f 100644--- a/docs/api-reference/admin.yaml+++ b/docs/api-reference/admin.yaml@@ -82,11 +82,11 @@ paths:example:data:- id: admin_UkLWZg9DAJ- email: [email protected]- first_name: Akiko- last_name: Gibson- created_at: '2026-05-06T21:12:11.889Z'- updated_at: '2026-05-06T21:12:11.889Z'+ email: [email protected]+ first_name: Charmaine+ last_name: Rosenbaum+ created_at: '2026-05-07T13:39:14.442Z'+ updated_at: '2026-05-07T13:39:14.442Z'roles:- id: role_UkLWZg9DAJname: admin@@ -144,11 +144,11 @@ paths:application/json:example:id: admin_UkLWZg9DAJ- email: [email protected]- first_name: Jerrie- last_name: Lueilwitz- created_at: '2026-05-06T21:12:12.227Z'- updated_at: '2026-05-06T21:12:12.227Z'+ email: [email protected]+ first_name: Twanna+ last_name: Bruen+ created_at: '2026-05-07T13:39:14.784Z'+ updated_at: '2026-05-07T13:39:14.784Z'roles:- id: role_UkLWZg9DAJname: admin@@ -201,11 +201,11 @@ paths:application/json:example:id: admin_UkLWZg9DAJ- email: [email protected]+ email: [email protected]first_name: Renamed- last_name: Rath- created_at: '2026-05-06T21:12:12.556Z'- updated_at: '2026-05-06T21:12:12.576Z'+ last_name: Legros+ created_at: '2026-05-07T13:39:15.114Z'+ updated_at: '2026-05-07T13:39:15.136Z'roles:- id: role_UkLWZg9DAJname: admin@@ -314,32 +314,32 @@ paths:key_type: publishabletoken_prefix:scopes: []- created_at: '2026-05-06T21:12:12.877Z'- updated_at: '2026-05-06T21:12:12.877Z'+ created_at: '2026-05-07T13:39:15.437Z'+ updated_at: '2026-05-07T13:39:15.437Z'revoked_at:last_used_at:- plaintext_token: pk_jtLEBWVqeXqwnrnwMe7XPePW+ plaintext_token: pk_V52ATyQ8rdp7T8Wx68nb9CcVcreated_by_email:- id: key_gbHJdmfrXBname: Backend integrationkey_type: secret- token_prefix: sk_o9W7g6Zdu+ token_prefix: sk_uiwy9MQ3escopes:- write_all- created_at: '2026-05-06T21:12:12.878Z'- updated_at: '2026-05-06T21:12:12.878Z'+ created_at: '2026-05-07T13:39:15.438Z'+ updated_at: '2026-05-07T13:39:15.438Z'revoked_at:last_used_at:plaintext_token:created_by_email:- id: key_EfhxLZ9ck8- name: officiis+ name: reprehenderitkey_type: secret- token_prefix: sk_bRwx5fM7c+ token_prefix: sk_7jzuAdSdascopes:- write_all- created_at: '2026-05-06T21:12:12.879Z'- updated_at: '2026-05-06T21:12:12.879Z'+ created_at: '2026-05-07T13:39:15.439Z'+ updated_at: '2026-05-07T13:39:15.439Z'revoked_at:last_used_at:plaintext_token:@@ -402,15 +402,15 @@ paths:id: key_VqXmZF31wYname: CI keykey_type: secret- token_prefix: sk_G3qtCfeaX+ token_prefix: sk_gwpZWTy3xscopes:- read_orders- created_at: '2026-05-06T21:12:13.449Z'- updated_at: '2026-05-06T21:12:13.449Z'+ created_at: '2026-05-07T13:39:16.006Z'+ updated_at: '2026-05-07T13:39:16.006Z'revoked_at:last_used_at:- plaintext_token: sk_G3qtCfeaXTfUChwdYVRbYXGp- created_by_email: [email protected]+ plaintext_token: sk_gwpZWTy3xWycvbs6fnBqQrdv+ created_by_email: [email protected]'422':description: validation errorcontent:@@ -496,11 +496,11 @@ paths:key_type: publishabletoken_prefix:scopes: []- created_at: '2026-05-06T21:12:13.738Z'- updated_at: '2026-05-06T21:12:13.738Z'+ created_at: '2026-05-07T13:39:16.311Z'+ updated_at: '2026-05-07T13:39:16.311Z'revoked_at:last_used_at:- plaintext_token: pk_wKAFVz9hkEti83avhmmuc7vm+ plaintext_token: pk_7n8XLJnPRDVctnzavKYtLjSwcreated_by_email:delete:summary: Delete an API key@@ -590,12 +590,12 @@ paths:id: key_gbHJdmfrXBname: Backend integrationkey_type: secret- token_prefix: sk_uSf36YXuL+ token_prefix: sk_ixBGz16c7scopes:- write_all- created_at: '2026-05-06T21:12:14.312Z'- updated_at: '2026-05-06T21:12:14.608Z'- revoked_at: '2026-05-06T21:12:14.605Z'+ created_at: '2026-05-07T13:39:16.918Z'+ updated_at: '2026-05-07T13:39:17.217Z'+ revoked_at: '2026-05-07T13:39:17.215Z'last_used_at:plaintext_token:created_by_email:@@ -664,8 +664,8 @@ paths:field_type: short_textresource_type: Spree::Productstorefront_visible: true- created_at: '2026-05-06T21:12:14.626Z'- updated_at: '2026-05-06T21:12:14.626Z'+ created_at: '2026-05-07T13:39:17.236Z'+ updated_at: '2026-05-07T13:39:17.236Z'- id: cfdef_gbHJdmfrXBnamespace: customkey: order_notes@@ -673,8 +673,8 @@ paths:field_type: short_textresource_type: Spree::Orderstorefront_visible: true- created_at: '2026-05-06T21:12:14.629Z'- updated_at: '2026-05-06T21:12:14.629Z'+ created_at: '2026-05-07T13:39:17.239Z'+ updated_at: '2026-05-07T13:39:17.239Z'meta:page: 1limit: 25@@ -737,8 +737,8 @@ paths:field_type: short_textresource_type: Spree::Productstorefront_visible: true- created_at: '2026-05-06T21:12:15.228Z'- updated_at: '2026-05-06T21:12:15.228Z'+ created_at: '2026-05-07T13:39:17.864Z'+ updated_at: '2026-05-07T13:39:17.864Z'requestBody:content:application/json:@@ -821,8 +821,8 @@ paths:field_type: short_textresource_type: Spree::Productstorefront_visible: true- created_at: '2026-05-06T21:12:15.231Z'- updated_at: '2026-05-06T21:12:15.231Z'+ created_at: '2026-05-07T13:39:17.868Z'+ updated_at: '2026-05-07T13:39:17.868Z'patch:summary: Update a custom field definitiontags:@@ -861,8 +861,8 @@ paths:field_type: short_textresource_type: Spree::Productstorefront_visible: false- created_at: '2026-05-06T21:12:15.513Z'- updated_at: '2026-05-06T21:12:15.792Z'+ created_at: '2026-05-07T13:39:18.160Z'+ updated_at: '2026-05-07T13:39:18.442Z'requestBody:content:application/json:@@ -984,8 +984,8 @@ paths:state_name: New Yorklabel:metadata: {}- created_at: '2026-05-06T21:12:16.363Z'- updated_at: '2026-05-06T21:12:16.363Z'+ created_at: '2026-05-07T13:39:19.033Z'+ updated_at: '2026-05-07T13:39:19.033Z'customer_id: cus_UkLWZg9DAJmeta:page: 1@@ -1073,8 +1073,8 @@ paths:state_name: New Yorklabel: Officemetadata: {}- created_at: '2026-05-06T21:12:17.756Z'- updated_at: '2026-05-06T21:12:17.756Z'+ created_at: '2026-05-07T13:39:20.397Z'+ updated_at: '2026-05-07T13:39:20.397Z'customer_id: cus_UkLWZg9DAJrequestBody:content:@@ -1185,8 +1185,8 @@ paths:state_name: New Yorklabel:metadata: {}- created_at: '2026-05-06T21:12:18.027Z'- updated_at: '2026-05-06T21:12:18.571Z'+ created_at: '2026-05-07T13:39:20.674Z'+ updated_at: '2026-05-07T13:39:21.234Z'customer_id: cus_UkLWZg9DAJrequestBody:content:@@ -1319,8 +1319,8 @@ paths:customer_id: cus_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJmetadata: {}- created_at: '2026-05-06T21:12:19.742Z'- updated_at: '2026-05-06T21:12:19.742Z'+ created_at: '2026-05-07T13:39:22.416Z'+ updated_at: '2026-05-07T13:39:22.416Z'meta:page: 1limit: 25@@ -1407,8 +1407,8 @@ paths:customer_id: cus_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJmetadata: {}- created_at: '2026-05-06T21:12:20.315Z'- updated_at: '2026-05-06T21:12:20.315Z'+ created_at: '2026-05-07T13:39:22.972Z'+ updated_at: '2026-05-07T13:39:22.972Z'delete:summary: Delete a customer credit cardtags:@@ -1526,8 +1526,8 @@ paths:display_amount_remaining: "$50.00"currency: USDmetadata: {}- created_at: '2026-05-06T21:12:21.711Z'- updated_at: '2026-05-06T21:12:21.711Z'+ created_at: '2026-05-07T13:39:24.386Z'+ updated_at: '2026-05-07T13:39:24.386Z'customer_id: cus_UkLWZg9DAJcreated_by_id: admin_UkLWZg9DAJmeta:@@ -1599,8 +1599,8 @@ paths:display_amount_remaining: "$25.00"currency: USDmetadata: {}- created_at: '2026-05-06T21:12:22.827Z'- updated_at: '2026-05-06T21:12:22.827Z'+ created_at: '2026-05-07T13:39:25.562Z'+ updated_at: '2026-05-07T13:39:25.562Z'customer_id: cus_UkLWZg9DAJcreated_by_id: admin_gbHJdmfrXBrequestBody:@@ -1688,8 +1688,8 @@ paths:display_amount_remaining: "$50.00"currency: USDmetadata: {}- created_at: '2026-05-06T21:12:23.372Z'- updated_at: '2026-05-06T21:12:23.661Z'+ created_at: '2026-05-07T13:39:26.121Z'+ updated_at: '2026-05-07T13:39:26.408Z'customer_id: cus_UkLWZg9DAJcreated_by_id: admin_UkLWZg9DAJrequestBody:@@ -1841,8 +1841,8 @@ paths:metadata: {}last_sign_in_at:current_sign_in_at:- created_at: '2026-05-06T21:12:24.763Z'- updated_at: '2026-05-06T21:12:24.763Z'+ created_at: '2026-05-07T13:39:27.536Z'+ updated_at: '2026-05-07T13:39:27.536Z'sign_in_count: 0failed_attempts: 0last_sign_in_ip:@@ -1925,8 +1925,8 @@ paths:metadata: {}last_sign_in_at:current_sign_in_at:- created_at: '2026-05-06T21:12:25.621Z'- updated_at: '2026-05-06T21:12:25.621Z'+ created_at: '2026-05-07T13:39:28.386Z'+ updated_at: '2026-05-07T13:39:28.386Z'sign_in_count: 0failed_attempts: 0last_sign_in_ip:@@ -2042,8 +2042,8 @@ paths:metadata: {}last_sign_in_at:current_sign_in_at:- created_at: '2026-05-06T21:12:25.897Z'- updated_at: '2026-05-06T21:12:25.897Z'+ created_at: '2026-05-07T13:39:28.665Z'+ updated_at: '2026-05-07T13:39:28.665Z'sign_in_count: 0failed_attempts: 0last_sign_in_ip:@@ -2117,8 +2117,8 @@ paths:metadata: {}last_sign_in_at:current_sign_in_at:- created_at: '2026-05-06T21:12:26.452Z'- updated_at: '2026-05-06T21:12:26.735Z'+ created_at: '2026-05-07T13:39:29.268Z'+ updated_at: '2026-05-07T13:39:29.638Z'sign_in_count: 0failed_attempts: 0last_sign_in_ip:@@ -2197,6 +2197,323 @@ paths:responses:'204':description: customer deleted+ "/api/v3/admin/exports":+ get:+ summary: List exports+ tags:+ - Exports+ security:+ - api_key: []+ bearer_auth: []+ description: |-+ Returns CSV exports queued or completed for the current store. Polled by the admin SPA to detect when an export finishes (`done: true`).++ **Required scope:** `read_exports` (for API-key authentication).+ x-codeSamples:+ - lang: javascript+ label: Spree Admin SDK+ source: |-+ import { createAdminClient } from '@spree/admin-sdk'++ const client = createAdminClient({+ baseUrl: 'https://your-store.com',+ secretKey: 'sk_xxx',+ })++ const { data: exports } = await client.exports.list()+ parameters:+ - name: x-spree-api-key+ in: header+ required: true+ schema:+ type: string+ - name: Authorization+ in: header+ required: true+ schema:+ type: string+ responses:+ '200':+ description: exports found+ content:+ application/json:+ example:+ data:+ - id: exp_UkLWZg9DAJ+ number: EF112212968+ type: Spree::Exports::Products+ format: csv+ created_at: '2026-05-07T13:39:30.547Z'+ updated_at: '2026-05-07T13:39:30.547Z'+ user_id: admin_UkLWZg9DAJ+ done: false+ filename:+ byte_size:+ download_url:+ meta:+ page: 1+ limit: 25+ count: 1+ pages: 1+ from: 1+ to: 1+ in: 1+ previous:+ next:+ post:+ summary: Create an export+ tags:+ - Exports+ security:+ - api_key: []+ bearer_auth: []+ description: |-+ Queues a CSV export. The `type` selects the dataset; `search_params` is an+ optional Ransack query (same shape used by the `q[...]` params on list endpoints)+ that filters which records are exported. Pass `record_selection: "all"` to+ clear the filter server-side and export everything in scope.++ Generation is asynchronous. Poll `GET /admin/exports/{id}` until `done` is `true`,+ then redirect the browser to `download_url` to fetch the file.+++ **Required scope:** `write_exports` (for API-key authentication).+ x-codeSamples:+ - lang: javascript+ label: Spree Admin SDK+ source: |-+ import { createAdminClient } from '@spree/admin-sdk'++ const client = createAdminClient({+ baseUrl: 'https://your-store.com',+ secretKey: 'sk_xxx',+ })++ const exp = await client.exports.create({+ type: 'Spree::Exports::Products',+ search_params: { name_cont: 'shirt' }+ })+ parameters:+ - name: x-spree-api-key+ in: header+ required: true+ schema:+ type: string+ - name: Authorization+ in: header+ required: true+ schema:+ type: string+ responses:+ '201':+ description: export queued+ content:+ application/json:+ example:+ id: exp_gbHJdmfrXB+ number: EF083996482+ type: Spree::Exports::Products+ format: csv+ created_at: '2026-05-07T13:39:30.906Z'+ updated_at: '2026-05-07T13:39:30.906Z'+ user_id: admin_UkLWZg9DAJ+ done: false+ filename:+ byte_size:+ download_url:+ requestBody:+ content:+ application/json:+ schema:+ type: object+ required:+ - type+ properties:+ type:+ type: string+ enum:+ - Spree::Exports::Products+ - Spree::Exports::Orders+ - Spree::Exports::Customers+ - Spree::Exports::ProductTranslations+ - Spree::Exports::GiftCards+ - Spree::Exports::CouponCodes+ - Spree::Exports::NewsletterSubscribers+ example: Spree::Exports::Products+ record_selection:+ type: string+ enum:+ - filtered+ - all+ description: Set to "all" to ignore search_params and export everything+ in scope.+ example: filtered+ search_params:+ type: object+ description: Ransack query hash. Same predicates accepted by the+ list endpoint.+ example:+ name_cont: shirt+ additionalProperties: true+ "/api/v3/admin/exports/{id}":+ get:+ summary: Show an export+ tags:+ - Exports+ security:+ - api_key: []+ bearer_auth: []+ description: |-+ Returns export status. While `done` is `false`, the SPA continues polling.++ **Required scope:** `read_exports` (for API-key authentication).+ x-codeSamples:+ - lang: javascript+ label: Spree Admin SDK+ source: |-+ import { createAdminClient } from '@spree/admin-sdk'++ const client = createAdminClient({+ baseUrl: 'https://your-store.com',+ secretKey: 'sk_xxx',+ })++ const exp = await client.exports.get('exp_xxx')+ parameters:+ - name: x-spree-api-key+ in: header+ required: true+ schema:+ type: string+ - name: Authorization+ in: header+ required: true+ schema:+ type: string+ - name: id+ in: path+ required: true+ schema:+ type: string+ responses:+ '200':+ description: export found+ content:+ application/json:+ example:+ id: exp_UkLWZg9DAJ+ number: EF749423618+ type: Spree::Exports::Products+ format: csv+ created_at: '2026-05-07T13:39:31.192Z'+ updated_at: '2026-05-07T13:39:31.192Z'+ user_id: admin_UkLWZg9DAJ+ done: false+ filename:+ byte_size:+ download_url:+ delete:+ summary: Delete an export+ tags:+ - Exports+ security:+ - api_key: []+ bearer_auth: []+ description: |-+ Removes the export and purges its attachment.++ **Required scope:** `write_exports` (for API-key authentication).+ x-codeSamples:+ - lang: javascript+ label: Spree Admin SDK+ source: |-+ import { createAdminClient } from '@spree/admin-sdk'++ const client = createAdminClient({+ baseUrl: 'https://your-store.com',+ secretKey: 'sk_xxx',+ })++ await client.exports.delete('exp_xxx')+ parameters:+ - name: x-spree-api-key+ in: header+ required: true+ schema:+ type: string+ - name: Authorization+ in: header+ required: true+ schema:+ type: string+ - name: id+ in: path+ required: true+ schema:+ type: string+ responses:+ '204':+ description: export deleted+ "/api/v3/admin/exports/{id}/download":+ get:+ summary: Download an export+ tags:+ - Exports+ security:+ - api_key: []+ bearer_auth: []+ description: |-+ Streams the exported CSV with `Content-Disposition: attachment`. Returns 422 with `code: export_not_ready` while `done` is still `false`. The endpoint is JWT/API-key protected, so SPA clients must fetch it (with `Authorization` header) and trigger the browser download via a Blob URL — a top-level navigation cannot carry the JWT.++ **Required scope:** `read_exports` (for API-key authentication).+ x-codeSamples:+ - lang: javascript+ label: Spree Admin SDK+ source: |-+ import { createAdminClient } from '@spree/admin-sdk'++ const client = createAdminClient({+ baseUrl: 'https://your-store.com',+ secretKey: 'sk_xxx',+ })++ // Fetch with the Bearer token, then drive the browser download:+ const res = await fetch(exp.download_url, {+ headers: { Authorization: `Bearer ${token}` }+ })+ const blob = await res.blob()+ const url = URL.createObjectURL(blob)+ const a = Object.assign(document.createElement('a'), {+ href: url,+ download: exp.filename+ })+ a.click()+ URL.revokeObjectURL(url)+ parameters:+ - name: x-spree-api-key+ in: header+ required: true+ schema:+ type: string+ - name: Authorization+ in: header+ required: true+ schema:+ type: string+ - name: id+ in: path+ required: true+ schema:+ type: string+ responses:+ '200':+ description: CSV file+ content:+ application/json: {}+ text/csv:+ schema:+ type: string+ format: binary"/api/v3/admin/invitations":get:summary: List invitations@@ -2240,15 +2557,15 @@ paths:example:data:- id: inv_UkLWZg9DAJ- email: [email protected]+ email: [email protected]status: pending- created_at: '2026-05-06T21:12:27.594Z'- updated_at: '2026-05-06T21:12:27.594Z'- expires_at: '2026-05-20T21:12:27.591Z'+ created_at: '2026-05-07T13:39:32.080Z'+ updated_at: '2026-05-07T13:39:32.080Z'+ expires_at: '2026-05-21T13:39:32.077Z'role_id: role_UkLWZg9DAJrole_name: admin- inviter_email: [email protected]- acceptance_url: http://www.example.com:3000/accept-invitation/inv_UkLWZg9DAJ?token=JBqWjFZtQprH3XSau1A1Ntro+ inviter_email: [email protected]+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=FxWAYtT2p63WCdDuJUyv5Dej"meta:page: 1limit: 25@@ -2305,13 +2622,13 @@ paths:id: inv_gbHJdmfrXBemail: [email protected]status: pending- created_at: '2026-05-06T21:12:27.895Z'- updated_at: '2026-05-06T21:12:27.895Z'- expires_at: '2026-05-20T21:12:27.893Z'+ created_at: '2026-05-07T13:39:32.404Z'+ updated_at: '2026-05-07T13:39:32.404Z'+ expires_at: '2026-05-21T13:39:32.400Z'role_id: role_UkLWZg9DAJrole_name: admin- inviter_email: [email protected]- acceptance_url: http://www.example.com:3000/accept-invitation/inv_gbHJdmfrXB?token=eyDL2pSnFzJ6U8SzNtK7QmiZ+ inviter_email: [email protected]+ acceptance_url: "/accept-invitation/inv_gbHJdmfrXB?token=4LBvXu2SuxL2qBCXk6Ms4tqe"requestBody:content:application/json:@@ -2414,15 +2731,15 @@ paths:application/json:example:id: inv_UkLWZg9DAJ- email: [email protected]+ email: [email protected]status: pending- created_at: '2026-05-06T21:12:28.469Z'- updated_at: '2026-05-06T21:12:28.469Z'- expires_at: '2026-05-20T21:12:28.467Z'+ created_at: '2026-05-07T13:39:33.000Z'+ updated_at: '2026-05-07T13:39:33.000Z'+ expires_at: '2026-05-21T13:39:32.996Z'role_id: role_UkLWZg9DAJrole_name: admin- inviter_email: [email protected]- acceptance_url: http://www.example.com:3000/accept-invitation/inv_UkLWZg9DAJ?token=4jiinc4bwD3VyLUPRmXwiPAo+ inviter_email: [email protected]+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=a88JaJJAu5qDfp4D5tsTZv6F""/api/v3/admin/me":get:summary: Get current admin user and permissions@@ -2468,11 +2785,11 @@ paths:example:user:id: admin_UkLWZg9DAJ- email: [email protected]- first_name: Colene- last_name: Beier- created_at: '2026-05-06T21:12:28.752Z'- updated_at: '2026-05-06T21:12:28.752Z'+ email: [email protected]+ first_name: Sunny+ last_name: Kohler+ created_at: '2026-05-07T13:39:33.285Z'+ updated_at: '2026-05-07T13:39:33.285Z'roles:- id: role_UkLWZg9DAJname: admin@@ -2621,8 +2938,8 @@ paths:position: 1kind: dropdownmetadata: {}- created_at: '2026-05-06T21:12:28.803Z'- updated_at: '2026-05-06T21:12:28.803Z'+ created_at: '2026-05-07T13:39:33.332Z'+ updated_at: '2026-05-07T13:39:33.332Z'option_values: []meta:page: 1@@ -2713,8 +3030,8 @@ paths:position: 2kind: dropdownmetadata: {}- created_at: '2026-05-06T21:12:29.459Z'- updated_at: '2026-05-06T21:12:29.459Z'+ created_at: '2026-05-07T13:39:33.916Z'+ updated_at: '2026-05-07T13:39:33.916Z'option_values: []schema:"$ref": "#/components/schemas/OptionType"@@ -2835,8 +3152,8 @@ paths:position: 1kind: dropdownmetadata: {}- created_at: '2026-05-06T21:12:29.757Z'- updated_at: '2026-05-06T21:12:29.757Z'+ created_at: '2026-05-07T13:39:34.201Z'+ updated_at: '2026-05-07T13:39:34.201Z'option_values: []schema:"$ref": "#/components/schemas/OptionType"@@ -2908,8 +3225,8 @@ paths:position: 1kind: dropdownmetadata: {}- created_at: '2026-05-06T21:12:30.327Z'- updated_at: '2026-05-06T21:12:30.609Z'+ created_at: '2026-05-07T13:39:34.764Z'+ updated_at: '2026-05-07T13:39:35.044Z'option_values: []schema:"$ref": "#/components/schemas/OptionType"@@ -3069,7 +3386,7 @@ paths:example:data:- id: ful_UkLWZg9DAJ- number: H08564278295+ number: H75338635909tracking: U10000tracking_url:cost: '10.0'@@ -3094,8 +3411,8 @@ paths:metadata: {}adjustment_total: '0.0'pre_tax_amount: '0.0'- created_at: '2026-05-06T21:12:31.565Z'- updated_at: '2026-05-06T21:12:31.662Z'+ created_at: '2026-05-07T13:39:36.013Z'+ updated_at: '2026-05-07T13:39:36.142Z'order_id: or_UkLWZg9DAJstock_location_id: sloc_UkLWZg9DAJmeta:@@ -3178,7 +3495,7 @@ paths:application/json:example:id: ful_UkLWZg9DAJ- number: H54780302716+ number: H00929181921tracking: U10000tracking_url:cost: '10.0'@@ -3203,8 +3520,8 @@ paths:metadata: {}adjustment_total: '0.0'pre_tax_amount: '0.0'- created_at: '2026-05-06T21:12:32.298Z'- updated_at: '2026-05-06T21:12:32.369Z'+ created_at: '2026-05-07T13:39:36.778Z'+ updated_at: '2026-05-07T13:39:36.843Z'order_id: or_UkLWZg9DAJstock_location_id: sloc_UkLWZg9DAJpatch:@@ -3263,7 +3580,7 @@ paths:application/json:example:id: ful_UkLWZg9DAJ- number: H96611884798+ number: H55672113063tracking: 1Z999AA10123456784tracking_url: https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z999AA10123456784cost: '10.0'@@ -3288,8 +3605,8 @@ paths:metadata: {}adjustment_total: '0.0'pre_tax_amount: '0.0'- created_at: '2026-05-06T21:12:32.977Z'- updated_at: '2026-05-06T21:12:33.327Z'+ created_at: '2026-05-07T13:39:37.444Z'+ updated_at: '2026-05-07T13:39:37.790Z'order_id: or_UkLWZg9DAJstock_location_id: sloc_UkLWZg9DAJrequestBody:@@ -3358,7 +3675,7 @@ paths:application/json:example:id: ful_UkLWZg9DAJ- number: H97200604879+ number: H98294370858tracking: U10000tracking_url:cost: '10.0'@@ -3375,7 +3692,7 @@ paths:display_tax_total: "$0.00"status: shippedfulfillment_type: shipping- fulfilled_at: '2026-05-06T21:12:34Z'+ fulfilled_at: '2026-05-07T13:39:38Z'items:- item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ@@ -3383,8 +3700,8 @@ paths:metadata: {}adjustment_total: '0.0'pre_tax_amount: '0.0'- created_at: '2026-05-06T21:12:33.652Z'- updated_at: '2026-05-06T21:12:34.001Z'+ created_at: '2026-05-07T13:39:38.116Z'+ updated_at: '2026-05-07T13:39:38.481Z'order_id: or_UkLWZg9DAJstock_location_id: sloc_UkLWZg9DAJ"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":@@ -3442,7 +3759,7 @@ paths:application/json:example:id: ful_UkLWZg9DAJ- number: H25693165413+ number: H43565339771tracking: U10000tracking_url:cost: '10.0'@@ -3467,8 +3784,8 @@ paths:metadata: {}adjustment_total: '0.0'pre_tax_amount: '0.0'- created_at: '2026-05-06T21:12:34.344Z'- updated_at: '2026-05-06T21:12:34.695Z'+ created_at: '2026-05-07T13:39:38.820Z'+ updated_at: '2026-05-07T13:39:39.165Z'order_id: or_UkLWZg9DAJstock_location_id: sloc_UkLWZg9DAJ"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":@@ -3526,7 +3843,7 @@ paths:application/json:example:id: ful_UkLWZg9DAJ- number: H74113970852+ number: H90988617804tracking: U10000tracking_url:cost: '10.0'@@ -3551,8 +3868,8 @@ paths:metadata: {}adjustment_total: '0.0'pre_tax_amount: '0.0'- created_at: '2026-05-06T21:12:35.032Z'- updated_at: '2026-05-06T21:12:35.388Z'+ created_at: '2026-05-07T13:39:39.497Z'+ updated_at: '2026-05-07T13:39:39.859Z'order_id: or_UkLWZg9DAJstock_location_id: sloc_UkLWZg9DAJ"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":@@ -3613,7 +3930,7 @@ paths:example:data:- id: ful_gbHJdmfrXB- number: H99928001254+ number: H68390199147tracking:tracking_url:cost: '10.0'@@ -3638,8 +3955,8 @@ paths:metadata: {}adjustment_total: '0.0'pre_tax_amount: '0.0'- created_at: '2026-05-06T21:12:36.092Z'- updated_at: '2026-05-06T21:12:36.142Z'+ created_at: '2026-05-07T13:39:40.559Z'+ updated_at: '2026-05-07T13:39:40.608Z'order_id: or_UkLWZg9DAJstock_location_id: sloc_gbHJdmfrXBrequestBody:@@ -3711,7 +4028,7 @@ paths:application/json:example:id: gc_UkLWZg9DAJ- code: AE724B235ADB6B1D+ code: 44B94AB9D43BC417status: activecurrency: USDamount: '10.0'@@ -3725,8 +4042,8 @@ paths:redeemed_at:expired: falseactive: true- created_at: '2026-05-06T21:12:36.493Z'- updated_at: '2026-05-06T21:12:36.810Z'+ created_at: '2026-05-07T13:39:40.954Z'+ updated_at: '2026-05-07T13:39:41.257Z'requestBody:content:application/json:@@ -3857,8 +4174,8 @@ paths:variant_id: variant_gbHJdmfrXBquantity: 2currency: USD- name: Product 108785- slug: product-108785+ name: Product 102182+ slug: product-102182options_text: 'Size: S'price: '10.0'display_price: "$10.00"@@ -3890,12 +4207,12 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:12:37.594Z'- updated_at: '2026-05-06T21:12:37.594Z'+ created_at: '2026-05-07T13:39:41.965Z'+ updated_at: '2026-05-07T13:39:41.965Z'digital_links: []metadata: {}- created_at: '2026-05-06T21:12:37.897Z'- updated_at: '2026-05-06T21:12:37.897Z'+ created_at: '2026-05-07T13:39:42.252Z'+ updated_at: '2026-05-07T13:39:42.252Z'cost_price: '17.0'tax_category_id: taxcat_UkLWZg9DAJmeta:@@ -3962,8 +4279,8 @@ paths:variant_id: variant_VqXmZF31wYquantity: 3currency: USD- name: Product 12276- slug: product-12276+ name: Product 122810+ slug: product-122810options_text: 'Size: S'price: '19.99'display_price: "$19.99"@@ -3995,12 +4312,12 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:12:38.826Z'- updated_at: '2026-05-06T21:12:38.826Z'+ created_at: '2026-05-07T13:39:43.332Z'+ updated_at: '2026-05-07T13:39:43.332Z'digital_links: []metadata: {}- created_at: '2026-05-06T21:12:38.858Z'- updated_at: '2026-05-06T21:12:38.858Z'+ created_at: '2026-05-07T13:39:43.375Z'+ updated_at: '2026-05-07T13:39:43.375Z'cost_price: '17.0'tax_category_id: taxcat_UkLWZg9DAJrequestBody:@@ -4089,8 +4406,8 @@ paths:variant_id: variant_gbHJdmfrXBquantity: 2currency: USD- name: Product 138755- slug: product-138755+ name: Product 139601+ slug: product-139601options_text: 'Size: S'price: '10.0'display_price: "$10.00"@@ -4122,12 +4439,12 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:12:38.931Z'- updated_at: '2026-05-06T21:12:38.931Z'+ created_at: '2026-05-07T13:39:43.514Z'+ updated_at: '2026-05-07T13:39:43.514Z'digital_links: []metadata: {}- created_at: '2026-05-06T21:12:39.218Z'- updated_at: '2026-05-06T21:12:39.218Z'+ created_at: '2026-05-07T13:39:43.821Z'+ updated_at: '2026-05-07T13:39:43.821Z'cost_price: '17.0'tax_category_id: taxcat_UkLWZg9DAJpatch:@@ -4189,8 +4506,8 @@ paths:variant_id: variant_gbHJdmfrXBquantity: 5currency: USD- name: Product 149103- slug: product-149103+ name: Product 145190+ slug: product-145190options_text: 'Size: S'price: '19.99'display_price: "$19.99"@@ -4222,12 +4539,12 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:12:39.556Z'- updated_at: '2026-05-06T21:12:39.556Z'+ created_at: '2026-05-07T13:39:44.159Z'+ updated_at: '2026-05-07T13:39:44.159Z'digital_links: []metadata: {}- created_at: '2026-05-06T21:12:39.850Z'- updated_at: '2026-05-06T21:12:40.159Z'+ created_at: '2026-05-07T13:39:44.446Z'+ updated_at: '2026-05-07T13:39:44.745Z'cost_price: '17.0'tax_category_id: taxcat_UkLWZg9DAJrequestBody:@@ -4353,8 +4670,8 @@ paths:data:- id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJ- response_code: BGS-8d041cdf0eac- number: PVWX4G07+ response_code: BGS-b9c02ebf95ca+ number: PA2Z1OGSamount: '110.0'display_amount: "$110.00"status: completed@@ -4372,14 +4689,14 @@ paths:customer_id:payment_method_id: pm_gbHJdmfrXBmetadata: {}- created_at: '2026-05-06T21:12:41.155Z'- updated_at: '2026-05-06T21:12:41.159Z'+ created_at: '2026-05-07T13:39:45.736Z'+ updated_at: '2026-05-07T13:39:45.739Z'metadata: {}avs_response:cvv_response_code:cvv_response_message:- created_at: '2026-05-06T21:12:41.158Z'- updated_at: '2026-05-06T21:12:41.158Z'+ created_at: '2026-05-07T13:39:45.738Z'+ updated_at: '2026-05-07T13:39:45.738Z'captured_amount: '0.0'order_id: or_UkLWZg9DAJmeta:@@ -4446,7 +4763,7 @@ paths:id: py_gbHJdmfrXBpayment_method_id: pm_EfhxLZ9ck8response_code:- number: PBREQ1M7+ number: PDDFESIEamount: '110.0'display_amount: "$110.00"status: checkout@@ -4457,8 +4774,8 @@ paths:avs_response:cvv_response_code:cvv_response_message:- created_at: '2026-05-06T21:12:42.486Z'- updated_at: '2026-05-06T21:12:42.486Z'+ created_at: '2026-05-07T13:39:47.146Z'+ updated_at: '2026-05-07T13:39:47.146Z'captured_amount: '0.0'order_id: or_gbHJdmfrXBrequestBody:@@ -4548,8 +4865,8 @@ paths:example:id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJ- response_code: BGS-0191ee7524a9- number: P31KTS3Y+ response_code: BGS-326401616af8+ number: PSJ3I98Kamount: '110.0'display_amount: "$110.00"status: completed@@ -4567,14 +4884,14 @@ paths:customer_id:payment_method_id: pm_gbHJdmfrXBmetadata: {}- created_at: '2026-05-06T21:12:42.869Z'- updated_at: '2026-05-06T21:12:42.872Z'+ created_at: '2026-05-07T13:39:47.520Z'+ updated_at: '2026-05-07T13:39:47.522Z'metadata: {}avs_response:cvv_response_code:cvv_response_message:- created_at: '2026-05-06T21:12:42.871Z'- updated_at: '2026-05-06T21:12:42.871Z'+ created_at: '2026-05-07T13:39:47.521Z'+ updated_at: '2026-05-07T13:39:47.521Z'captured_amount: '0.0'order_id: or_UkLWZg9DAJ"/api/v3/admin/orders/{order_id}/payments/{id}/capture":@@ -4633,8 +4950,8 @@ paths:example:id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJ- response_code: BGS-2c4ffa541b1c- number: P8EWLHDQ+ response_code: BGS-b724905736e0+ number: PO4WKVSIamount: '110.0'display_amount: "$110.00"status: completed@@ -4652,14 +4969,14 @@ paths:customer_id:payment_method_id: pm_gbHJdmfrXBmetadata: {}- created_at: '2026-05-06T21:12:43.527Z'- updated_at: '2026-05-06T21:12:43.530Z'+ created_at: '2026-05-07T13:39:48.184Z'+ updated_at: '2026-05-07T13:39:48.187Z'metadata: {}avs_response:cvv_response_code:cvv_response_message:- created_at: '2026-05-06T21:12:43.529Z'- updated_at: '2026-05-06T21:12:43.873Z'+ created_at: '2026-05-07T13:39:48.186Z'+ updated_at: '2026-05-07T13:39:48.516Z'captured_amount: '110.0'order_id: or_UkLWZg9DAJ'422':@@ -4728,8 +5045,8 @@ paths:example:id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJ- response_code: void-BGS-49e1dfec2645- number: P2L0IA91+ response_code: void-BGS-2f2887a4dcf8+ number: PNE7W24Pamount: '110.0'display_amount: "$110.00"status: void@@ -4747,14 +5064,14 @@ paths:customer_id:payment_method_id: pm_gbHJdmfrXBmetadata: {}- created_at: '2026-05-06T21:12:44.970Z'- updated_at: '2026-05-06T21:12:44.973Z'+ created_at: '2026-05-07T13:39:49.566Z'+ updated_at: '2026-05-07T13:39:49.569Z'metadata: {}avs_response:cvv_response_code:cvv_response_message:- created_at: '2026-05-06T21:12:44.972Z'- updated_at: '2026-05-06T21:12:45.277Z'+ created_at: '2026-05-07T13:39:49.568Z'+ updated_at: '2026-05-07T13:39:49.876Z'captured_amount: '0.0'order_id: or_UkLWZg9DAJ"/api/v3/admin/orders/{order_id}/refunds":@@ -4882,14 +5199,14 @@ paths:application/json:example:id: re_UkLWZg9DAJ- transaction_id: BGS-ee195def7f75+ transaction_id: BGS-dc3ac7486198amount: '5.0'payment_id: py_UkLWZg9DAJrefund_reason_id: rr_UkLWZg9DAJreimbursement_id:metadata: {}- created_at: '2026-05-06T21:12:46.658Z'- updated_at: '2026-05-06T21:12:46.658Z'+ created_at: '2026-05-07T13:39:51.234Z'+ updated_at: '2026-05-07T13:39:51.234Z'requestBody:content:application/json:@@ -4960,8 +5277,8 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R136324746- email: [email protected]+ number: R169796219+ email: [email protected]customer_note:currency: USDlocale: en@@ -5004,8 +5321,8 @@ paths:metadata: {}canceled_at:approved_at:- created_at: '2026-05-06T21:12:46.981Z'- updated_at: '2026-05-06T21:12:47.037Z'+ created_at: '2026-05-07T13:39:51.528Z'+ updated_at: '2026-05-07T13:39:51.584Z'tags: []internal_note:approver_id:@@ -5174,8 +5491,8 @@ paths:data:- id: or_UkLWZg9DAJmarket_id:- number: R411430777- email: [email protected]+ number: R547242231+ email: [email protected]customer_note:currency: USDlocale: en@@ -5218,8 +5535,8 @@ paths:metadata: {}canceled_at:approved_at:- created_at: '2026-05-06T21:12:48.821Z'- updated_at: '2026-05-06T21:12:48.821Z'+ created_at: '2026-05-07T13:39:53.339Z'+ updated_at: '2026-05-07T13:39:53.339Z'tags: []internal_note:approver_id:@@ -5348,7 +5665,7 @@ paths:example:id: or_gbHJdmfrXBmarket_id:- number: R338449249+ number: R845060014email: [email protected]customer_note:currency: USD@@ -5392,8 +5709,8 @@ paths:metadata: {}canceled_at:approved_at:- created_at: '2026-05-06T21:12:49.958Z'- updated_at: '2026-05-06T21:12:49.963Z'+ created_at: '2026-05-07T13:39:54.549Z'+ updated_at: '2026-05-07T13:39:54.552Z'tags: []internal_note:approver_id:@@ -5565,8 +5882,8 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R095578452- email: [email protected]+ number: R406122509+ email: [email protected]customer_note:currency: USDlocale: en@@ -5609,8 +5926,8 @@ paths:metadata: {}canceled_at:approved_at:- created_at: '2026-05-06T21:12:50.243Z'- updated_at: '2026-05-06T21:12:50.243Z'+ created_at: '2026-05-07T13:39:54.842Z'+ updated_at: '2026-05-07T13:39:54.842Z'tags: []internal_note:approver_id:@@ -5679,7 +5996,7 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R782700219+ number: R335768882email: [email protected]customer_note:currency: USD@@ -5723,8 +6040,8 @@ paths:metadata: {}canceled_at:approved_at:- created_at: '2026-05-06T21:12:51.410Z'- updated_at: '2026-05-06T21:12:51.726Z'+ created_at: '2026-05-07T13:39:56.035Z'+ updated_at: '2026-05-07T13:39:56.351Z'tags: []internal_note:approver_id:@@ -5895,8 +6212,8 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R744752476- email: [email protected]+ number: R868799164+ email: [email protected]customer_note:currency: USDlocale: en@@ -5923,7 +6240,7 @@ paths:display_delivery_total: "$100.00"fulfillment_status: readypayment_status: paid- completed_at: '2026-05-06T21:12:52.665Z'+ completed_at: '2026-05-07T13:39:57.265Z'store_credit_total: '0.0'display_store_credit_total: "$0.00"covered_by_store_credit: false@@ -5939,8 +6256,8 @@ paths:metadata: {}canceled_at:approved_at:- created_at: '2026-05-06T21:12:52.605Z'- updated_at: '2026-05-06T21:12:52.691Z'+ created_at: '2026-05-07T13:39:57.212Z'+ updated_at: '2026-05-07T13:39:57.289Z'tags: []internal_note:approver_id:@@ -6019,8 +6336,8 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R746542679- email: [email protected]+ number: R735653505+ email: [email protected]customer_note:currency: USDlocale: en@@ -6047,7 +6364,7 @@ paths:display_delivery_total: "$10.00"fulfillment_status: canceledpayment_status: void- completed_at: '2026-05-06T21:12:53.952Z'+ completed_at: '2026-05-07T13:39:58.543Z'store_credit_total: '0.0'display_store_credit_total: "$0.00"covered_by_store_credit: false@@ -6061,10 +6378,10 @@ paths:payment_total: '0.0'display_payment_total: "$0.00"metadata: {}- canceled_at: '2026-05-06T21:12:54.250Z'+ canceled_at: '2026-05-07T13:39:58.834Z'approved_at:- created_at: '2026-05-06T21:12:53.892Z'- updated_at: '2026-05-06T21:12:54.297Z'+ created_at: '2026-05-07T13:39:58.493Z'+ updated_at: '2026-05-07T13:39:58.885Z'tags: []internal_note:approver_id:@@ -6121,8 +6438,8 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R486757219- email: [email protected]+ number: R839879088+ email: [email protected]customer_note:currency: USDlocale: en@@ -6149,7 +6466,7 @@ paths:display_delivery_total: "$100.00"fulfillment_status:payment_status:- completed_at: '2026-05-06T21:12:54.670Z'+ completed_at: '2026-05-07T13:39:59.242Z'store_credit_total: '0.0'display_store_credit_total: "$0.00"covered_by_store_credit: false@@ -6164,9 +6481,9 @@ paths:display_payment_total: "$0.00"metadata: {}canceled_at:- approved_at: '2026-05-06T21:12:54.962Z'- created_at: '2026-05-06T21:12:54.610Z'- updated_at: '2026-05-06T21:12:54.670Z'+ approved_at: '2026-05-07T13:39:59.533Z'+ created_at: '2026-05-07T13:39:59.185Z'+ updated_at: '2026-05-07T13:39:59.242Z'tags: []internal_note:approver_id: admin_UkLWZg9DAJ@@ -6223,8 +6540,8 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R050394121- email: [email protected]+ number: R048120637+ email: [email protected]customer_note:currency: USDlocale: en@@ -6251,7 +6568,7 @@ paths:display_delivery_total: "$10.00"fulfillment_status: canceledpayment_status: void- completed_at: '2026-05-06T21:12:55.301Z'+ completed_at: '2026-05-07T13:39:59.871Z'store_credit_total: '0.0'display_store_credit_total: "$0.00"covered_by_store_credit: false@@ -6265,10 +6582,10 @@ paths:payment_total: '0.0'display_payment_total: "$0.00"metadata: {}- canceled_at: '2026-05-06T21:12:55.582Z'+ canceled_at: '2026-05-07T13:40:00.151Z'approved_at:- created_at: '2026-05-06T21:12:55.245Z'- updated_at: '2026-05-06T21:12:55.692Z'+ created_at: '2026-05-07T13:39:59.816Z'+ updated_at: '2026-05-07T13:40:00.233Z'tags: []internal_note:approver_id:@@ -6325,8 +6642,8 @@ paths:example:id: or_UkLWZg9DAJmarket_id:- number: R555316893- email: [email protected]+ number: R012387799+ email: [email protected]customer_note:currency: USDlocale: en@@ -6353,7 +6670,7 @@ paths:display_delivery_total: "$100.00"fulfillment_status:payment_status:- completed_at: '2026-05-06T21:12:56.028Z'+ completed_at: '2026-05-07T13:40:00.564Z'store_credit_total: '0.0'display_store_credit_total: "$0.00"covered_by_store_credit: false@@ -6369,8 +6686,8 @@ paths:metadata: {}canceled_at:approved_at:- created_at: '2026-05-06T21:12:55.975Z'- updated_at: '2026-05-06T21:12:56.028Z'+ created_at: '2026-05-07T13:40:00.513Z'+ updated_at: '2026-05-07T13:40:00.564Z'tags: []internal_note:approver_id:@@ -6442,8 +6759,8 @@ paths:metadata: {}active: trueauto_capture:- created_at: '2026-05-06T21:12:56.340Z'- updated_at: '2026-05-06T21:12:56.342Z'+ created_at: '2026-05-07T13:40:00.878Z'+ updated_at: '2026-05-07T13:40:00.879Z'meta:page: 1limit: 25@@ -6523,8 +6840,8 @@ paths:metadata: {}active: trueauto_capture:- created_at: '2026-05-06T21:12:56.633Z'- updated_at: '2026-05-06T21:12:56.635Z'+ created_at: '2026-05-07T13:40:01.169Z'+ updated_at: '2026-05-07T13:40:01.170Z'"/api/v3/admin/products/{product_id}/custom_fields":get:summary: List product custom fields@@ -6592,8 +6909,8 @@ paths:field_type: short_textkey: custom.titlevalue: wool- created_at: '2026-05-06T21:12:56.964Z'- updated_at: '2026-05-06T21:12:56.964Z'+ created_at: '2026-05-07T13:40:01.490Z'+ updated_at: '2026-05-07T13:40:01.490Z'storefront_visible: truecustom_field_definition_id: cfdef_UkLWZg9DAJmeta:@@ -6660,8 +6977,8 @@ paths:field_type: long_textkey: custom.descriptionvalue: A longer description- created_at: '2026-05-06T21:12:57.577Z'- updated_at: '2026-05-06T21:12:57.577Z'+ created_at: '2026-05-07T13:40:02.099Z'+ updated_at: '2026-05-07T13:40:02.099Z'storefront_visible: truecustom_field_definition_id: cfdef_gbHJdmfrXB'422':@@ -6745,8 +7062,8 @@ paths:field_type: short_textkey: custom.titlevalue: wool- created_at: '2026-05-06T21:12:58.006Z'- updated_at: '2026-05-06T21:12:58.006Z'+ created_at: '2026-05-07T13:40:02.453Z'+ updated_at: '2026-05-07T13:40:02.453Z'storefront_visible: truecustom_field_definition_id: cfdef_UkLWZg9DAJpatch:@@ -6793,8 +7110,8 @@ paths:field_type: short_textkey: custom.titlevalue: cotton- created_at: '2026-05-06T21:12:58.326Z'- updated_at: '2026-05-06T21:12:58.612Z'+ created_at: '2026-05-07T13:40:02.768Z'+ updated_at: '2026-05-07T13:40:03.050Z'storefront_visible: truecustom_field_definition_id: cfdef_UkLWZg9DAJrequestBody:@@ -6932,26 +7249,35 @@ paths:example:data:- id: prod_UkLWZg9DAJ- name: Product 399635- slug: product-399635+ name: Product 397563+ slug: product-397563meta_description:meta_keywords:variant_count: 0- available_on: '2025-05-06T21:12:58.945Z'+ available_on: '2025-05-07T13:40:03.380Z'purchasable: truein_stock: falsebackorderable: trueavailable: true- description: Nesciunt ut sed impedit iusto molestias voluptates.- Reiciendis saepe unde accusamus aut. Alias sed reiciendis magni- neque sit fugiat fugit eius. Cumque aut neque quas et illum optio.- Dolor laboriosam iusto aliquid beatae error temporibus saepe accusamus.- Eligendi ratione ad id quas. Maiores occaecati minus ducimus ipsa- pariatur consequatur natus facilis. Facere labore inventore nihil- ullam.+ description: Sequi excepturi autem eveniet provident. Quidem soluta+ fugit fugiat sapiente fuga. Ab a dolores ea magnam voluptatum+ ipsa. Non recusandae ducimus voluptatibus velit mollitia porro+ est dolorem. Sapiente provident nihil eveniet recusandae. Pariatur+ modi officia maiores omnis nostrum. Quasi a quo ex amet. Quidem+ dicta voluptatibus autem ut reiciendis ad sapiente aliquam. Consequuntur+ est sit ad necessitatibus facilis sed. Quasi esse consectetur+ ut porro ipsa temporibus. Perferendis necessitatibus distinctio+ blanditiis repudiandae quibusdam ea. Sed asperiores harum assumenda+ explicabo unde. Pariatur sapiente assumenda eaque nam numquam+ quod consectetur. Dicta commodi temporibus tenetur sed similique+ repudiandae modi. Laudantium impedit asperiores quibusdam eum+ nulla quis quasi. Id impedit cumque similique reprehenderit officiis+ quia.description_html: |-- Nesciunt ut sed impedit iusto molestias voluptates. Reiciendis saepe unde accusamus aut. Alias sed reiciendis magni neque sit fugiat fugit eius.- Cumque aut neque quas et illum optio. Dolor laboriosam iusto aliquid beatae error temporibus saepe accusamus. Eligendi ratione ad id quas. Maiores occaecati minus ducimus ipsa pariatur consequatur natus facilis. Facere labore inventore nihil ullam.+ Sequi excepturi autem eveniet provident. Quidem soluta fugit fugiat sapiente fuga. Ab a dolores ea magnam voluptatum ipsa.+ Non recusandae ducimus voluptatibus velit mollitia porro est dolorem. Sapiente provident nihil eveniet recusandae. Pariatur modi officia maiores omnis nostrum. Quasi a quo ex amet. Quidem dicta voluptatibus autem ut reiciendis ad sapiente aliquam.+ Consequuntur est sit ad necessitatibus facilis sed. Quasi esse consectetur ut porro ipsa temporibus. Perferendis necessitatibus distinctio blanditiis repudiandae quibusdam ea. Sed asperiores harum assumenda explicabo unde.+ Pariatur sapiente assumenda eaque nam numquam quod consectetur. Dicta commodi temporibus tenetur sed similique repudiandae modi. Laudantium impedit asperiores quibusdam eum nulla quis quasi. Id impedit cumque similique reprehenderit officiis quia.default_variant_id: variant_UkLWZg9DAJthumbnail_url:tags: []@@ -6966,16 +7292,16 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_UkLWZg9DAJ- created_at: '2026-05-06T21:12:58.977Z'- updated_at: '2026-05-06T21:12:58.977Z'+ created_at: '2026-05-07T13:40:03.412Z'+ updated_at: '2026-05-07T13:40:03.412Z'original_price:status: active- make_active_at: '2025-05-06T21:12:58.945Z'+ make_active_at: '2025-05-07T13:40:03.380Z'discontinue_on:metadata: {}deleted_at:- created_at: '2026-05-06T21:12:58.961Z'- updated_at: '2026-05-06T21:12:58.978Z'+ created_at: '2026-05-07T13:40:03.395Z'+ updated_at: '2026-05-07T13:40:03.413Z'cost_price: '17.0'cost_currency: USDmeta:@@ -7114,16 +7440,16 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_gbHJdmfrXB- created_at: '2026-05-06T21:12:59.662Z'- updated_at: '2026-05-06T21:12:59.662Z'+ created_at: '2026-05-07T13:40:04.083Z'+ updated_at: '2026-05-07T13:40:04.083Z'original_price:status: draftmake_active_at:discontinue_on:metadata: {}deleted_at:- created_at: '2026-05-06T21:12:59.660Z'- updated_at: '2026-05-06T21:12:59.667Z'+ created_at: '2026-05-07T13:40:04.081Z'+ updated_at: '2026-05-07T13:40:04.088Z'cost_price:cost_currency: USDschema:@@ -7310,25 +7636,35 @@ paths:application/json:example:id: prod_UkLWZg9DAJ- name: Product 435751- slug: product-435751+ name: Product 43541+ slug: product-43541meta_description:meta_keywords:variant_count: 0- available_on: '2025-05-06T21:13:00.057Z'+ available_on: '2025-05-07T13:40:04.486Z'purchasable: truein_stock: falsebackorderable: trueavailable: true- description: Repudiandae dicta eaque deserunt eligendi vitae. Totam- eligendi est reprehenderit rerum maxime veritatis vel expedita.- Numquam omnis amet corrupti repellat corporis labore. Assumenda- vel sequi eos minus. Amet eaque enim vitae doloremque omnis alias- iure. Ducimus animi quo doloremque fuga delectus tempora enim iure.- Rerum omnis nobis recusandae voluptatem neque nulla alias sit.+ description: Quos magni occaecati ratione ullam expedita possimus+ consectetur vel. At magnam earum aperiam illo labore ipsum reiciendis.+ Libero nisi hic ea placeat beatae accusantium est repudiandae. Iusto+ est nobis commodi nemo unde quia. Optio ipsum sapiente exercitationem+ accusantium corporis vel et alias. Excepturi sapiente officia earum+ eveniet amet at ea pariatur. Laborum rerum veniam quo blanditiis+ illum amet numquam. Dicta amet commodi deleniti natus autem non+ itaque. Error asperiores a laudantium aperiam amet sit iusto nisi.+ Eius autem fuga cum in consequuntur beatae quisquam natus. Quasi+ quibusdam sequi assumenda molestias maxime itaque ex. Numquam nemo+ quaerat pariatur omnis iste vel. Voluptatum non officia quia ipsa+ in. Nostrum voluptas ut consectetur neque. Nam numquam eligendi+ nulla provident amet optio. Autem voluptatum itaque impedit cum+ iste facilis totam quisquam.description_html: |-- Repudiandae dicta eaque deserunt eligendi vitae. Totam eligendi est reprehenderit rerum maxime veritatis vel expedita. Numquam omnis amet corrupti repellat corporis labore. Assumenda vel sequi eos minus.- Amet eaque enim vitae doloremque omnis alias iure. Ducimus animi quo doloremque fuga delectus tempora enim iure. Rerum omnis nobis recusandae voluptatem neque nulla alias sit.+ Quos magni occaecati ratione ullam expedita possimus consectetur vel. At magnam earum aperiam illo labore ipsum reiciendis. Libero nisi hic ea placeat beatae accusantium est repudiandae. Iusto est nobis commodi nemo unde quia. Optio ipsum sapiente exercitationem accusantium corporis vel et alias.+ Excepturi sapiente officia earum eveniet amet at ea pariatur. Laborum rerum veniam quo blanditiis illum amet numquam. Dicta amet commodi deleniti natus autem non itaque.+ Error asperiores a laudantium aperiam amet sit iusto nisi. Eius autem fuga cum in consequuntur beatae quisquam natus. Quasi quibusdam sequi assumenda molestias maxime itaque ex.+ Numquam nemo quaerat pariatur omnis iste vel. Voluptatum non officia quia ipsa in. Nostrum voluptas ut consectetur neque. Nam numquam eligendi nulla provident amet optio. Autem voluptatum itaque impedit cum iste facilis totam quisquam.default_variant_id: variant_UkLWZg9DAJthumbnail_url:tags: []@@ -7343,16 +7679,16 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_UkLWZg9DAJ- created_at: '2026-05-06T21:13:00.106Z'- updated_at: '2026-05-06T21:13:00.106Z'+ created_at: '2026-05-07T13:40:04.539Z'+ updated_at: '2026-05-07T13:40:04.539Z'original_price:status: active- make_active_at: '2025-05-06T21:13:00.057Z'+ make_active_at: '2025-05-07T13:40:04.486Z'discontinue_on:metadata: {}deleted_at:- created_at: '2026-05-06T21:13:00.080Z'- updated_at: '2026-05-06T21:13:00.108Z'+ created_at: '2026-05-07T13:40:04.512Z'+ updated_at: '2026-05-07T13:40:04.540Z'cost_price: '17.0'cost_currency: USDschema:@@ -7420,29 +7756,23 @@ paths:example:id: prod_UkLWZg9DAJname: Updated Name- slug: product-452240+ slug: product-456072meta_description:meta_keywords:variant_count: 0- available_on: '2025-05-06T21:13:00.762Z'+ available_on: '2025-05-07T13:40:05.198Z'purchasable: truein_stock: falsebackorderable: trueavailable: true- description: Tempore id reprehenderit culpa earum illum debitis accusamus- quas. Nihil consequatur quae necessitatibus quos. Voluptas ipsum- aliquam possimus id et qui. Veniam fugit non exercitationem placeat.- Ipsam suscipit quaerat quod earum aliquam natus recusandae ex. Tempora- neque id tempore voluptate in beatae voluptatibus ipsa. Harum tempore- officiis eius assumenda. Optio officiis iusto harum itaque minima.- Quisquam officiis nobis eum tenetur. Autem pariatur non qui molestias- minima odit commodi. Voluptatum rerum atque quo vero rem. Autem- perspiciatis amet dolore neque. Quod voluptatem delectus eaque minus.- Id consequatur iusto enim minus alias accusamus in.+ description: Iure quis sequi cumque odit quidem assumenda. Fuga recusandae+ numquam aliquam totam aperiam commodi nobis. Tempora adipisci illum+ rerum deleniti numquam tenetur sunt aut. Sapiente quis temporibus+ sed exercitationem quibusdam nostrum. Architecto mollitia eaque+ modi minus. Illum beatae sed nihil officia corrupti facilis dolorum.description_html: |-- Tempore id reprehenderit culpa earum illum debitis accusamus quas. Nihil consequatur quae necessitatibus quos. Voluptas ipsum aliquam possimus id et qui. Veniam fugit non exercitationem placeat. Ipsam suscipit quaerat quod earum aliquam natus recusandae ex.- Tempora neque id tempore voluptate in beatae voluptatibus ipsa. Harum tempore officiis eius assumenda. Optio officiis iusto harum itaque minima. Quisquam officiis nobis eum tenetur. Autem pariatur non qui molestias minima odit commodi.- Voluptatum rerum atque quo vero rem. Autem perspiciatis amet dolore neque. Quod voluptatem delectus eaque minus. Id consequatur iusto enim minus alias accusamus in.+ Iure quis sequi cumque odit quidem assumenda. Fuga recusandae numquam aliquam totam aperiam commodi nobis. Tempora adipisci illum rerum deleniti numquam tenetur sunt aut.+ Sapiente quis temporibus sed exercitationem quibusdam nostrum. Architecto mollitia eaque modi minus. Illum beatae sed nihil officia corrupti facilis dolorum.default_variant_id: variant_UkLWZg9DAJthumbnail_url:tags: []@@ -7457,16 +7787,16 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_UkLWZg9DAJ- created_at: '2026-05-06T21:13:00.793Z'- updated_at: '2026-05-06T21:13:00.793Z'+ created_at: '2026-05-07T13:40:05.223Z'+ updated_at: '2026-05-07T13:40:05.223Z'original_price:status: active- make_active_at: '2025-05-06T21:13:00.762Z'+ make_active_at: '2025-05-07T13:40:05.199Z'discontinue_on:metadata: {}deleted_at:- created_at: '2026-05-06T21:13:00.778Z'- updated_at: '2026-05-06T21:13:01.085Z'+ created_at: '2026-05-07T13:40:05.212Z'+ updated_at: '2026-05-07T13:40:05.513Z'cost_price: '17.0'cost_currency: USDschema:@@ -7673,8 +8003,8 @@ paths:data:- id: role_UkLWZg9DAJname: admin- created_at: '2026-05-06T21:13:01.768Z'- updated_at: '2026-05-06T21:13:01.768Z'+ created_at: '2026-05-07T13:40:06.196Z'+ updated_at: '2026-05-07T13:40:06.196Z'meta:page: 1limit: 25@@ -7736,8 +8066,8 @@ paths:preferred_timezone: UTCpreferred_weight_unit: lbpreferred_unit_system: imperial- created_at: '2026-05-06T21:12:11.579Z'- updated_at: '2026-05-06T21:13:02.074Z'+ created_at: '2026-05-07T13:39:14.132Z'+ updated_at: '2026-05-07T13:40:06.502Z'url: http://www.example.com:3000supported_currencies:- USD@@ -7808,8 +8138,8 @@ paths:preferred_timezone: UTCpreferred_weight_unit: lbpreferred_unit_system: imperial- created_at: '2026-05-06T21:12:11.579Z'- updated_at: '2026-05-06T21:13:02.703Z'+ created_at: '2026-05-07T13:39:14.132Z'+ updated_at: '2026-05-07T13:40:07.189Z'url: http://www.example.com:3000supported_currencies:- USD@@ -8028,9 +8358,9 @@ paths:cost_price: '17.0'cost_currency: USDdeleted_at:- created_at: '2026-05-06T21:13:04.139Z'- updated_at: '2026-05-06T21:13:04.152Z'- product_name: Product 48396+ created_at: '2026-05-07T13:40:08.595Z'+ updated_at: '2026-05-07T13:40:08.608Z'+ product_name: Product 4887display_price: "$0.00"- id: variant_gbHJdmfrXBproduct_id: prod_UkLWZg9DAJ@@ -8042,10 +8372,10 @@ paths:purchasable: truein_stock: falsebackorderable: true- weight: 159.63- height: 159.24- width: 160.44- depth: 81.44+ weight: 198.27+ height: 0.22+ width: 99.24+ depth: 175.9price:id: price_gbHJdmfrXBamount: '19.99'@@ -8068,8 +8398,8 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:13:04.163Z'- updated_at: '2026-05-06T21:13:04.163Z'+ created_at: '2026-05-07T13:40:08.619Z'+ updated_at: '2026-05-07T13:40:08.619Z'metadata: {}position: 2total_on_hand: 0@@ -8077,9 +8407,9 @@ paths:cost_price: '17.0'cost_currency: USDdeleted_at:- created_at: '2026-05-06T21:13:04.161Z'- updated_at: '2026-05-06T21:13:04.175Z'- product_name: Product 48396+ created_at: '2026-05-07T13:40:08.616Z'+ updated_at: '2026-05-07T13:40:08.629Z'+ product_name: Product 4887display_price: "$19.99"meta:page: 1@@ -8191,8 +8521,8 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:13:04.838Z'- updated_at: '2026-05-06T21:13:04.838Z'+ created_at: '2026-05-07T13:40:09.266Z'+ updated_at: '2026-05-07T13:40:09.266Z'metadata: {}position: 3total_on_hand: 0@@ -8200,9 +8530,9 @@ paths:cost_price:cost_currency: USDdeleted_at:- created_at: '2026-05-06T21:13:04.843Z'- updated_at: '2026-05-06T21:13:04.844Z'- product_name: Product 498498+ created_at: '2026-05-07T13:40:09.269Z'+ updated_at: '2026-05-07T13:40:09.271Z'+ product_name: Product 496423display_price: "$24.99"'422':description: validation error@@ -8390,10 +8720,10 @@ paths:purchasable: truein_stock: falsebackorderable: true- weight: 188.28- height: 142.74- width: 142.25- depth: 92.52+ weight: 115.3+ height: 21.47+ width: 135.36+ depth: 176.53price:id: price_gbHJdmfrXBamount: '19.99'@@ -8416,8 +8746,8 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:13:05.265Z'- updated_at: '2026-05-06T21:13:05.265Z'+ created_at: '2026-05-07T13:40:09.682Z'+ updated_at: '2026-05-07T13:40:09.682Z'metadata: {}position: 2total_on_hand: 0@@ -8425,9 +8755,9 @@ paths:cost_price: '17.0'cost_currency: USDdeleted_at:- created_at: '2026-05-06T21:13:05.262Z'- updated_at: '2026-05-06T21:13:05.277Z'- product_name: Product 512379+ created_at: '2026-05-07T13:40:09.680Z'+ updated_at: '2026-05-07T13:40:09.692Z'+ product_name: Product 517973display_price: "$19.99"'404':description: variant not found@@ -8507,10 +8837,10 @@ paths:purchasable: truein_stock: falsebackorderable: true- weight: 96.68- height: 107.82- width: 121.52- depth: 184.21+ weight: 0.89+ height: 91.57+ width: 55.68+ depth: 125.5price:id: price_gbHJdmfrXBamount: '19.99'@@ -8533,8 +8863,8 @@ paths:option_type_label: Sizeimage_url:metadata: {}- created_at: '2026-05-06T21:13:05.948Z'- updated_at: '2026-05-06T21:13:05.948Z'+ created_at: '2026-05-07T13:40:10.350Z'+ updated_at: '2026-05-07T13:40:10.350Z'metadata: {}position: 2total_on_hand: 0@@ -8542,9 +8872,9 @@ paths:cost_price: '17.0'cost_currency: USDdeleted_at:- created_at: '2026-05-06T21:13:05.946Z'- updated_at: '2026-05-06T21:13:06.253Z'- product_name: Product 53313+ created_at: '2026-05-07T13:40:10.347Z'+ updated_at: '2026-05-07T13:40:10.645Z'+ product_name: Product 539379display_price: "$19.99"requestBody:content:@@ -9678,6 +10008,50 @@ components:- created_at- updated_atx-typelizer: true+ Export:+ type: object+ properties:+ id:+ type: string+ number:+ type: string+ type:+ type: string+ nullable: true+ format:+ type: string+ nullable: true+ created_at:+ type: string+ updated_at:+ type: string+ user_id:+ type: string+ nullable: true+ done:+ type: boolean+ filename:+ type: string+ nullable: true+ byte_size:+ type: number+ nullable: true+ download_url:+ type: string+ nullable: true+ required:+ - id+ - number+ - type+ - format+ - created_at+ - updated_at+ - user_id+ - done+ - filename+ - byte_size+ - download_url+ x-typelizer: trueFulfillment:type: objectproperties:diff --git a/docs/plans/5.5-admin-api-key-scopes.md b/docs/plans/5.5-admin-api-key-scopes.mdindex d962edc5bf..56023be5e1 100644--- a/docs/plans/5.5-admin-api-key-scopes.md+++ b/docs/plans/5.5-admin-api-key-scopes.md@@ -53,6 +53,7 @@ class Spree::ApiKey < Spree.base_classread_gift_cards write_gift_cardsread_store_credits write_store_creditsread_categories write_categories+ read_exports write_exportsread_settings write_settingsread_webhooks write_webhooksread_dashboard@@ -89,6 +90,7 @@ end| `read_gift_cards` / `write_gift_cards` | `/orders/:id/gift_cards`, future `/gift_cards/*` || `read_store_credits` / `write_store_credits` | `/customers/:id/store_credits`, `/orders/:id/store_credits` || `read_categories` / `write_categories` | `/categories/*` |+| `read_exports` / `write_exports` | `/exports/*`, `/exports/:id/download` || `read_settings` / `write_settings` | `/payment_methods`, `/markets`, `/countries`, `/tax_categories`, `/stores` || `read_webhooks` / `write_webhooks` | future `/webhooks/*` || `read_dashboard` | `/dashboard/*` (analytics; no write counterpart) |diff --git a/docs/plans/5.5-admin-spa-csv-export.md b/docs/plans/5.5-admin-spa-csv-export.mdnew file mode 100644index 0000000000..f70cef59ae--- /dev/null+++ b/docs/plans/5.5-admin-spa-csv-export.md@@ -0,0 +1,298 @@+# Admin SPA CSV Export++**Status:** Draft+**Target:** Spree 5.5+**Depends on:** `6.0-admin-spa.md`, `6.0-admin-api.md`, `5.5-admin-api-key-scopes.md`+**Author:** Damian Legawiec+**Last updated:** 2026-05-07++## Summary++The legacy Rails admin (`spree/admin`) supports CSV export for products, orders, customers, gift cards, coupon codes, and newsletter subscribers via a modal that captures the current Ransack filters and queues a background job. The new Vite/React admin SPA (`packages/admin`) does not yet expose this. All backend infrastructure (`Spree::Export` polymorphic model, subclasses, `GenerateJob`, ActiveStorage attachment, email notification) already exists and is in production. This plan brings the feature back to the SPA by adding an Admin API CRUD surface for `Spree::Export`, an `exports` resource on the Admin SDK, and a toolbar button + modal + polling flow on the products, orders, and customers index pages.++## Key Decisions (do not deviate without discussion)++- **Reuse the existing `Spree::Export` model and subclasses verbatim.** No new model, no new job, no new presenters. The legacy Rails `Spree::Admin::ExportsController` stays in place for now (`spree/admin` is being phased out, but other surfaces still mount it); the new endpoints live alongside it under `Spree::Api::V3::Admin::ExportsController`.+- **Filters travel as Ransack JSON.** The SPA already converts its structured `FilterRule[]` to Ransack params (`resource-table.tsx:152–157`) for list endpoints. The same conversion is reused for exports — the server stores it in `search_params` exactly as the legacy modal does. We do **not** invent a new SPA-shaped filter contract on the server; the API contract stays Ransack-native.+- **Status feedback is toast + polling, then auto-download.** No separate page in v1. Email notification (existing `Spree::ExportMailer.export_done`) remains the durable backup. A future iteration can add a persistent `/exports` page if users ask for history.+- **Scope for v1: Products, Orders, Customers.** Other types (gift cards, coupons, newsletter, translations) work backend-side once endpoints exist; we just won't surface buttons for them in v1.+- **Download via signed Blob URL, not a server-side redirect.** The Admin API serializer exposes a short-lived signed URL the SPA fetches and triggers a browser download. This is the only way an SPA on a different origin can reliably download an attachment without losing JWT auth context. The legacy Rails admin's `redirect_to attachment.url` works for the same-origin Turbo flow but does not translate to the SPA.+- **Auth: JWT only in v1.** Secret API keys (`sk_xxx`) with scopes (per `5.5-admin-api-key-scopes.md`) get exports later. Adding a `read_exports` / `write_exports` scope is straightforward but out of scope here.+- **No multi-select bulk export.** Like the legacy admin: export "filtered" (current Ransack query) or "all" (clears filters). Multi-select is a broader bulk-actions concern not yet built into the SPA.++## Design Details++### Backend: `Spree::Api::V3::Admin::ExportsController`++A new thin controller mounted under `/api/v3/admin/exports`. Inherits from `Spree::Api::V3::Admin::ResourceController`, gets `index`, `show`, `create`, `destroy` for free. Subclassed exports (`Spree::Exports::Products`, etc.) are dispatched via the `type` param exactly the way the legacy `assign_params` does it.++```ruby+# spree/api/app/controllers/spree/api/v3/admin/exports_controller.rb+module Spree::Api::V3::Admin+ class ExportsController < ResourceController+ protected++ def model_class+ Spree::Export+ end++ def serializer_class+ Spree.api.admin_export_serializer+ end++ def collection_includes+ [:user, attachment_attachment: :blob]+ end++ def permitted_params+ params.permit(:type, :format, :record_selection, search_params: {})+ end++ def build_resource+ type_name = available_type(permitted_params[:type])+ klass = type_name&.constantize || Spree::Export+ attrs = permitted_params.except(:type).merge(+ store: current_store,+ user: current_admin_user+ )+ klass.new(attrs)+ end++ def available_type(name)+ Spree::Export.available_types.map(&:to_s).find { |t| t == name }+ end+ end+end+```++`update` is intentionally omitted — exports are immutable once created. `destroy` is allowed so users can clean up old exports.++### Backend: API routes++Add to `spree/api/config/routes.rb` inside the admin v3 namespace:++```ruby+resources :exports, only: [:index, :show, :create, :destroy]+```++### Backend: `Spree::Api::V3::Admin::ExportSerializer`++Extends the existing `Spree::Api::V3::ExportSerializer`. Adds `done` (boolean), `download_url` (signed, short-lived URL via ActiveStorage), `filename`, `byte_size`. Per the CLAUDE.md store/admin split rule, timestamps stay; nothing customer-facing here so no Store serializer.++```ruby+# spree/api/app/serializers/spree/api/v3/admin/export_serializer.rb+module Spree::Api::V3::Admin+ class ExportSerializer < V3::ExportSerializer+ typelize done: :boolean,+ download_url: [:string, nullable: true],+ filename: [:string, nullable: true],+ byte_size: [:number, nullable: true]++ attribute :done, &:done?++ attribute :filename do |export|+ export.attachment&.filename&.to_s if export.done?+ end++ attribute :byte_size do |export|+ export.attachment&.byte_size if export.done?+ end++ attribute :download_url do |export|+ next nil unless export.done?+ Rails.application.routes.url_helpers.rails_blob_url(+ export.attachment,+ host: Spree::Current.store&.formatted_url || Rails.application.config.action_mailer.default_url_options[:host],+ disposition: 'attachment',+ expires_in: 5.minutes+ )+ end+ end+end+```++The signed URL approach is the correct one for cross-origin SPAs and is consistent with how other ActiveStorage attachments are exposed in the Admin API (verified pattern). `expires_in: 5.minutes` is enough for the SPA to initiate the download; the URL is regenerated on every poll/refresh.++The `Spree.api.admin_export_serializer` configurable lives on `Spree.api` (the `Dependencies` system), matching how every other admin serializer is registered.++### Backend: tests++`spree/api/spec/integration/api/v3/admin/exports_spec.rb` — RSwag integration spec covering:++- `POST /admin/exports` with `type: 'Spree::Exports::Products'` and inline Ransack `search_params` → 201, returns serialized export, queues job.+- `POST` with `record_selection: 'all'` → search_params cleared on persisted record.+- `GET /admin/exports` → paginated list, only current user's exports (or all if admin? — see Open Questions).+- `GET /admin/exports/:id` → returns `done: false` immediately, then `done: true` with `download_url` after the job runs.+- `DELETE /admin/exports/:id` → 204, attachment purged.+- Authorization: 401 without JWT, 403 for users without `manage Spree::Export` ability.++Then run the full pipeline (per CLAUDE.md):+1. `bundle exec rake typelizer:generate` — regenerates `AdminExport.ts` and `Export.ts`+2. `pnpm --filter @spree/sdk generate:zod` — regenerates Zod schema+3. `bundle exec rake rswag:specs:swaggerize` — updates `docs/api-reference/store.yaml`++### Admin SDK: `client.exports`++New resource block in `packages/admin-sdk/src/admin-client.ts`:++```ts+readonly exports = {+ list: (params?: ListParams & Record<string, unknown>, options?: RequestOptions) =>+ this.request<PaginatedResponse<AdminExport>>('GET', '/exports', {+ ...options,+ params: params ? transformListParams(params) : undefined,+ }),++ get: (id: string, options?: RequestOptions) =>+ this.request<AdminExport>('GET', `/exports/${id}`, options),++ create: (params: ExportCreateParams, options?: RequestOptions) =>+ this.request<AdminExport>('POST', '/exports', { ...options, body: params }),++ delete: (id: string, options?: RequestOptions) =>+ this.request<void>('DELETE', `/exports/${id}`, options),+}+```++Where `ExportCreateParams` is:++```ts+export interface ExportCreateParams {+ type:+ | 'Spree::Exports::Products'+ | 'Spree::Exports::Orders'+ | 'Spree::Exports::Customers'+ /** Ransack query as a plain object. Server stores it in search_params. */+ search_params?: Record<string, unknown>+ /** 'filtered' (default) keeps search_params; 'all' clears them server-side. */+ record_selection?: 'filtered' | 'all'+ format?: 'csv'+}+```++A changeset goes in `packages/admin-sdk/.changeset/`. Per the [admin-sdk-unreleased] memory, no back-compat shim needed.++### SPA: shared `useExport` hook++`packages/admin/src/hooks/use-export.ts` — wraps SDK `create` + polling:++```ts+export function useExport() {+ const { adminClient } = useAdminClient()+ const queryClient = useQueryClient()++ return useMutation({+ mutationFn: async (params: ExportCreateParams) => {+ const exp = await adminClient.exports.create(params)+ // Poll every 2s, max 5 minutes+ return await pollUntilDone(adminClient, exp.id, {+ intervalMs: 2000,+ timeoutMs: 5 * 60 * 1000,+ })+ },+ onSuccess: (exp) => {+ if (exp.download_url) {+ triggerBrowserDownload(exp.download_url, exp.filename ?? 'export.csv')+ toast.success('Export ready — downloading')+ } else {+ toast.info('Export still processing — check your email')+ }+ },+ onError: (err) => toast.error(`Export failed: ${err.message}`),+ })+}+```++`triggerBrowserDownload` uses an anchor + `download` attribute with the signed URL — no fetch-and-blob needed because the URL is already signed and public for its 5-minute window.++If polling times out the toast falls back to "still processing — check your email" — the existing `Spree::ExportMailer.export_done` already covers this case server-side.++### SPA: shared filter conversion util++Extract the existing logic in `resource-table.tsx:152–157` into `packages/admin/src/lib/filters-to-ransack.ts`:++```ts+export function filtersToRansack(filters: FilterRule[], columns: ColumnDef[]) {+ const out: Record<string, unknown> = {}+ for (const filter of filters) {+ const col = columns.find((c) => c.key === filter.field)+ const ransackKey = col?.ransackAttribute ?? filter.field+ out[`${ransackKey}_${filter.operator}`] = filter.value+ }+ return out+}+```++Update `resource-table.tsx` to call this util (the inner flattening + `q[]` wrapping still happens server-bound via `transformListParams`). The export modal calls the same helper, then drops the result into `search_params`.++### SPA: `<ExportButton>` and `<ExportModal>`++`packages/admin/src/components/spree/export-button.tsx` — renders inside the `<TableToolbar actions={…}>` slot:++```tsx+<ExportButton+ type="Spree::Exports::Products"+ search={search} // free-text term currently in toolbar+ searchParam={table.searchParam}+ filters={filters}+ columns={table.columns}+/>+```++The button opens a Radix dialog (`<ExportModal>`) with two radio options ("Current filter" / "All records"), Submit button, and a tiny copy of how many records will be exported (read from the current list query's meta count). On submit it builds the Ransack hash, calls `useExport().mutate(...)`.++The modal is a thin shell around the existing shadcn `<Dialog>` — same pattern used for product delete confirmation.++### SPA: wiring on index pages++Three one-line additions:++```tsx+// routes/_authenticated/$storeId/products/index.tsx+<ResourceTable+ ...+ toolbarActions={(ctx) => <ExportButton type="Spree::Exports::Products" {...ctx} />}+/>+```++Same for `orders/index.tsx` (`Spree::Exports::Orders`) and `customers/index.tsx` (`Spree::Exports::Customers`). `ResourceTable` already accepts an `actions` prop on its toolbar — extend it to pass the current `search`, `filters`, and `columns` into a `toolbarActions` render-prop so the button has the data it needs without a context provider.++Permission check: hide the button if `useAbility().can('create', 'Spree::Export')` is false. The `useAbility` hook already exists for other gated UI.++### SPA: tests++- Vitest unit test for `filtersToRansack` (round-trip a few rules → expected hash).+- Vitest + MSW test for `useExport` hook covering: create → poll → download URL → success toast; create → poll timeout → fallback toast.+- No Playwright/E2E in v1 — the admin SPA does not yet have an E2E harness.++## Migration Path++1. **Backend (PR 1)** — `Spree::Api::V3::Admin::ExportsController`, route, admin serializer, `Spree.api.admin_export_serializer` registration, RSwag spec. Run typelizer + zod + swaggerize. Ship.+2. **Admin SDK (PR 2)** — `client.exports` resource, `ExportCreateParams` type, changeset, vitest with MSW. Ship.+3. **SPA (PR 3)** — `filtersToRansack` extraction, `useExport` hook, `ExportButton`, `ExportModal`, wiring on Products/Orders/Customers index pages. Test manually against local server. Ship.++PRs are sequential because each depends on the previous one's API contract.++## Constraints on Current Work++- **Do not re-implement CSV generation logic.** Adding columns, changing format, or supporting new export types means editing the existing `Spree::Exports::*` subclasses and `Spree::CSV::*Presenter` classes — not the new API controller.+- **Do not break the legacy `Spree::Admin::ExportsController`.** Other surfaces (legacy admin, multi-vendor admin docs) still link to it. The new endpoints sit alongside; nothing in `spree/admin` changes.+- **Filters must round-trip through Ransack.** When extending `FilterRule` operators or column metadata, anything that isn't a clean Ransack predicate suffix will silently fail in the export. The shared `filtersToRansack` util is the single source of truth for the SPA → Ransack mapping.+- **Signed URL expiration must stay short** (≤ 5 min). Long-lived URLs leak via shared screen captures, browser history, and Slack link unfurls. The polling flow regenerates them; the email mailer regenerates on click via the standard `rails_blob_url` helper.++## Open Questions++- **Scoping `index` to current user vs all admins.** Legacy admin uses `accessible_by(current_ability)` which gives full-store admins everyone's exports. The SPA polling flow only needs the user's own. Default to `accessible_by` for parity, but consider an `mine: true` filter param if it becomes noisy.+- **Should `download_url` 30x redirect through our backend** so we can revoke individual exports? Probably not in v1 — `destroy` already purges the attachment, which invalidates the signed URL. Revisit if compliance asks.+- **Do we want a dedicated `/exports` history page?** Not in v1 per design decision above. Reassess after dogfooding — if users export weekly and re-download often, the page is cheap to add (it's just a `ResourceTable` over `client.exports.list`).+- **Admin API key scopes for exports.** Out of scope here; needs a `read_exports` / `write_exports` scope added in `5.5-admin-api-key-scopes.md` before secret-key clients can hit these endpoints.++## References++- `docs/plans/6.0-admin-spa.md` — admin SPA architecture, table registry, extension points+- `docs/plans/6.0-admin-api.md` — Admin API conventions, resource controllers, prefixed IDs+- `docs/plans/5.5-admin-api-key-scopes.md` — future scope-based authorization (deferred for exports)+- Legacy: `spree/admin/app/controllers/spree/admin/exports_controller.rb` — reference implementation+- Existing model: `spree/core/app/models/spree/export.rb`, `spree/core/app/models/spree/exports/`+- Existing serializer: `spree/api/app/serializers/spree/api/v3/export_serializer.rb`+- CSV presenters: `spree/core/app/presenters/spree/csv/`diff --git a/packages/admin-sdk/.changeset/admin-csv-exports.md b/packages/admin-sdk/.changeset/admin-csv-exports.mdnew file mode 100644index 0000000000..31a26bd02a--- /dev/null+++ b/packages/admin-sdk/.changeset/admin-csv-exports.md@@ -0,0 +1,11 @@+---+'@spree/admin-sdk': minor+---++Admin CSV exports — bring back filtered CSV downloads of products, orders, customers, etc. that the legacy Rails admin supported.++- New `client.exports` resource with `list / get / create / delete`.+- New `ExportCreateParams` / `ExportType` request types and `Export` entity type.+- `Export.download_url` is the path to a server-side download endpoint (`GET /api/v3/admin/exports/:id/download`) that 303s to a freshly-signed ActiveStorage URL — assign it to `window.location.href` to trigger the download.+- `Export.done` flips to `true` once the background job finishes generating and attaching the CSV; clients should poll `get(id)` until then.+- `search_params` accepts the same Ransack predicate shape (`{ name_cont, price_gt, … }`) used on list endpoints, so toolbar filter state can be forwarded as-is.diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.tsindex 5b9c98caa3..d58063d1bc 100644--- a/packages/admin-sdk/src/admin-client.ts+++ b/packages/admin-sdk/src/admin-client.ts@@ -102,6 +102,7 @@ import type {CustomFieldOwnerType,CustomFieldUpdateParams,DirectUploadCreateParams,+ ExportCreateParams,FulfillmentUpdateParams,GiftCardApplyParams,InvitationAcceptParams,@@ -135,6 +136,7 @@ import type {Customer,CustomField,CustomFieldDefinition,+ Export,Fulfillment,Invitation,LineItem,@@ -897,6 +899,37 @@ export class AdminClient {}),}+ // ============================================+ // Exports (CSV: products, orders, customers, …)+ // ============================================++ /**+ * Queues asynchronous CSV exports and reports their progress. After+ * `create()`, poll `get(id)` until `done === true`, then fetch+ * `download_url` (with `Authorization: Bearer …`) and drive the browser+ * download via a Blob — top-level navigation cannot carry an in-memory+ * JWT, so `window.location.href = download_url` does not work.+ */+ readonly exports = {+ list: (+ params?: ListParams & Record<string, unknown>,+ options?: RequestOptions,+ ): Promise<PaginatedResponse<Export>> =>+ this.request<PaginatedResponse<Export>>('GET', '/exports', {+ ...options,+ params: params ? transformListParams(params) : undefined,+ }),++ get: (id: string, options?: RequestOptions): Promise<Export> =>+ this.request<Export>('GET', `/exports/${id}`, options),++ create: (params: ExportCreateParams, options?: RequestOptions): Promise<Export> =>+ this.request<Export>('POST', '/exports', { ...options, body: params }),++ delete: (id: string, options?: RequestOptions): Promise<void> =>+ this.request<void>('DELETE', `/exports/${id}`, options),+ }+// ============================================// Customers// ============================================diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.tsindex 1b091c7baa..e5fcd51033 100644--- a/packages/admin-sdk/src/params.ts+++ b/packages/admin-sdk/src/params.ts@@ -384,6 +384,39 @@ export interface AdminUserUpdateParams {role_ids?: string[]}+/**+ * Built-in `Spree::Export` subclasses. The server validates `type` against+ * the configured allowlist (`Spree::Export.available_types`); a plugin can+ * register additional types, which arrive here as the trailing `string & {}`+ * arm. Use one of the named constants for autocomplete.+ */+export type ExportType =+ | 'Spree::Exports::Products'+ | 'Spree::Exports::Orders'+ | 'Spree::Exports::Customers'+ | 'Spree::Exports::ProductTranslations'+ | 'Spree::Exports::GiftCards'+ | 'Spree::Exports::CouponCodes'+ | 'Spree::Exports::NewsletterSubscribers'+ | (string & {})++export interface ExportCreateParams {+ /** Which dataset to export. Server validates against `Spree::Export.available_types`. */+ type: ExportType+ /**+ * Ransack query hash. Same predicate shape used on list endpoints+ * (`{ name_cont: 'shirt', price_gt: 10 }`). Ignored when `record_selection`+ * is `'all'`. Use `filtersToRansack(filters, columns)` from the SPA helper+ * to turn the toolbar filter state into this shape.+ */+ search_params?: Record<string, unknown>+ /**+ * `'filtered'` (default) keeps `search_params`; `'all'` clears them on the+ * server and exports every record in scope.+ */+ record_selection?: 'filtered' | 'all'+}+/*** Owner type passed to the generic `client.customFields(ownerType, ownerId)`* escape hatch. The first-class six (products, variants, orders, customers,diff --git a/packages/admin-sdk/src/types/generated/Export.ts b/packages/admin-sdk/src/types/generated/Export.tsnew file mode 100644index 0000000000..0c4c2de14b--- /dev/null+++ b/packages/admin-sdk/src/types/generated/Export.ts@@ -0,0 +1,19 @@+// Typelizer digest e043672f76e195ecd3c3065bea54f6dd+//+// DO NOT MODIFY: This file was automatically generated by Typelizer.++interface Export {+ id: string;+ number: string;+ type: string | null;+ format: string | null;+ created_at: string;+ updated_at: string;+ user_id: string | null;+ done: boolean;+ filename: string | null;+ byte_size: number | null;+ download_url: string | null;+}++export default Export;diff --git a/packages/admin-sdk/src/types/generated/index.ts b/packages/admin-sdk/src/types/generated/index.tsindex dd6d371c01..2aae82167e 100644--- a/packages/admin-sdk/src/types/generated/index.ts+++ b/packages/admin-sdk/src/types/generated/index.ts@@ -1,4 +1,4 @@-// Typelizer digest ba039c928f7378234dfb83913d8b1211+// Typelizer digest c085aef7d14ed6ccfe1984560df20418//// DO NOT MODIFY: This file was automatically generated by Typelizer.export type { default as Address } from './Address'@@ -16,6 +16,7 @@ export type { default as DeliveryMethod } from './DeliveryMethod'export type { default as DeliveryRate } from './DeliveryRate'export type { default as DigitalLink } from './DigitalLink'export type { default as Discount } from './Discount'+export type { default as Export } from './Export'export type { default as Fulfillment } from './Fulfillment'export type { default as GiftCard } from './GiftCard'export type { default as Invitation } from './Invitation'diff --git a/packages/admin-sdk/src/types/index.ts b/packages/admin-sdk/src/types/index.tsindex be73161db8..51a65488d2 100644--- a/packages/admin-sdk/src/types/index.ts+++ b/packages/admin-sdk/src/types/index.ts@@ -24,6 +24,7 @@ export type { default as DeliveryMethod } from './generated/DeliveryMethod'export type { default as DeliveryRate } from './generated/DeliveryRate'export type { default as DigitalLink } from './generated/DigitalLink'export type { default as Discount } from './generated/Discount'+export type { default as Export } from './generated/Export'export type { default as Fulfillment } from './generated/Fulfillment'export type { default as GiftCard } from './generated/GiftCard'export type { default as Invitation } from './generated/Invitation'diff --git a/packages/admin-sdk/tests/exports.test.ts b/packages/admin-sdk/tests/exports.test.tsnew file mode 100644index 0000000000..91095441a7--- /dev/null+++ b/packages/admin-sdk/tests/exports.test.ts@@ -0,0 +1,140 @@+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 sampleExport = {+ id: 'exp_abc123',+ number: 'EF000001',+ type: 'Spree::Exports::Products',+ format: 'csv',+ user_id: 'usr_admin',+ done: false,+ filename: null,+ byte_size: null,+ download_url: null,+ created_at: '2026-05-07T12:00:00Z',+ updated_at: '2026-05-07T12:00:00Z',+}++describe('exports', () => {+ describe('list', () => {+ it('GETs /exports and returns paginated data', async () => {+ server.use(+ http.get(`${API_PREFIX}/exports`, () =>+ HttpResponse.json({+ data: [sampleExport],+ meta: { page: 1, limit: 25, count: 1, pages: 1 },+ }),+ ),+ )++ const client = createAdminClient({ baseUrl: BASE_URL })+ const res = await client.exports.list()++ expect(res.data).toHaveLength(1)+ expect(res.data[0]?.id).toBe('exp_abc123')+ })++ it('passes ListParams through transformListParams (q[...] wrapping)', async () => {+ let url: URL | null = null+ server.use(+ http.get(`${API_PREFIX}/exports`, ({ 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.exports.list({ type_eq: 'Spree::Exports::Products' })++ // transformListParams wraps free predicates in q[...]+ expect(url!.searchParams.get('q[type_eq]')).toBe('Spree::Exports::Products')+ })+ })++ describe('get', () => {+ it('GETs /exports/:id', async () => {+ server.use(+ http.get(`${API_PREFIX}/exports/exp_abc123`, () =>+ HttpResponse.json({+ ...sampleExport,+ done: true,+ download_url: '/api/v3/admin/exports/exp_abc123/download',+ }),+ ),+ )++ const client = createAdminClient({ baseUrl: BASE_URL })+ const res = await client.exports.get('exp_abc123')++ expect(res.done).toBe(true)+ expect(res.download_url).toBe('/api/v3/admin/exports/exp_abc123/download')+ })+ })++ describe('create', () => {+ it('POSTs the type and search_params verbatim', async () => {+ let body: Record<string, unknown> | null = null+ server.use(+ http.post(`${API_PREFIX}/exports`, async ({ request }) => {+ body = (await request.json()) as Record<string, unknown>+ return HttpResponse.json(sampleExport, { status: 201 })+ }),+ )++ const client = createAdminClient({ baseUrl: BASE_URL })+ const res = await client.exports.create({+ type: 'Spree::Exports::Products',+ search_params: { name_cont: 'shirt', price_gt: 10 },+ })++ expect(body).toEqual({+ type: 'Spree::Exports::Products',+ search_params: { name_cont: 'shirt', price_gt: 10 },+ })+ expect(res.id).toBe('exp_abc123')+ })++ it('supports record_selection: "all" for unfiltered exports', async () => {+ let body: Record<string, unknown> | null = null+ server.use(+ http.post(`${API_PREFIX}/exports`, async ({ request }) => {+ body = (await request.json()) as Record<string, unknown>+ return HttpResponse.json(sampleExport, { status: 201 })+ }),+ )++ const client = createAdminClient({ baseUrl: BASE_URL })+ await client.exports.create({+ type: 'Spree::Exports::Orders',+ record_selection: 'all',+ })++ expect(body).toEqual({+ type: 'Spree::Exports::Orders',+ record_selection: 'all',+ })+ })+ })++ describe('delete', () => {+ it('DELETEs /exports/:id', async () => {+ let hit = false+ server.use(+ http.delete(`${API_PREFIX}/exports/exp_abc123`, () => {+ hit = true+ return new HttpResponse(null, { status: 204 })+ }),+ )++ const client = createAdminClient({ baseUrl: BASE_URL })+ await client.exports.delete('exp_abc123')++ expect(hit).toBe(true)+ })+ })+})diff --git a/packages/admin/src/components/spree/export-button.tsx b/packages/admin/src/components/spree/export-button.tsxnew file mode 100644index 0000000000..7b798e3375--- /dev/null+++ b/packages/admin/src/components/spree/export-button.tsx@@ -0,0 +1,159 @@+import type { ExportType } from '@spree/admin-sdk'+import { DownloadIcon, FilterIcon, GlobeIcon } from 'lucide-react'+import { useState } from 'react'+import type { ResourceActionsContext } from '@/components/spree/resource-table'+import { Button } from '@/components/ui/button'+import {+ Dialog,+ DialogBody,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/components/ui/dialog'+import { useExport } from '@/hooks/use-export'+import { filtersToRansack } from '@/lib/filters-to-ransack'+import { cn } from '@/lib/utils'++interface ExportButtonProps extends ResourceActionsContext {+ /** Which dataset to export. Server validates against `Spree::Export.available_types`. */+ type: ExportType+ /** Label shown on the button. Defaults to "Export". */+ label?: string+}++type Selection = 'filtered' | 'all'++export function ExportButton({+ type,+ label = 'Export',+ filters,+ search,+ searchParam,+ columns,+ totalCount,+}: ExportButtonProps) {+ const [open, setOpen] = useState(false)+ const [selection, setSelection] = useState<Selection>('filtered')+ const exportMutation = useExport()++ const hasActiveFilter = filters.length > 0 || search.trim().length > 0++ function handleExport() {+ const search_params: Record<string, unknown> = filtersToRansack(filters, columns)+ if (search.trim()) {+ search_params[searchParam] = search.trim()+ }++ exportMutation.mutate({+ type,+ record_selection: selection,+ search_params: selection === 'filtered' ? search_params : undefined,+ })+ setOpen(false)+ }++ return (+ <>+ <Button+ size="sm"+ variant="outline"+ className="h-[2.125rem]"+ onClick={() => setOpen(true)}+ disabled={exportMutation.isPending}+ >+ <DownloadIcon className="size-4" />+ {label}+ </Button>++ <Dialog open={open} onOpenChange={setOpen}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>Export to CSV</DialogTitle>+ <DialogDescription>+ We'll prepare your CSV in the background and download it as soon as it's ready. If it+ takes a while you'll get an email link too.+ </DialogDescription>+ </DialogHeader>++ <DialogBody className="grid gap-3">+ <RadioOption+ icon={<FilterIcon className="size-4" />}+ title="Current filter"+ description={describeFiltered(hasActiveFilter, totalCount)}+ selected={selection === 'filtered'}+ onSelect={() => setSelection('filtered')}+ />+ <RadioOption+ icon={<GlobeIcon className="size-4" />}+ title="All records"+ description="Ignore filters and export everything in this store."+ selected={selection === 'all'}+ onSelect={() => setSelection('all')}+ />+ </DialogBody>++ <DialogFooter>+ <Button variant="outline" onClick={() => setOpen(false)}>+ Cancel+ </Button>+ <Button onClick={handleExport} disabled={exportMutation.isPending}>+ {exportMutation.isPending ? 'Exporting…' : 'Export'}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ </>+ )+}++function describeFiltered(hasActiveFilter: boolean, totalCount: number | undefined): string {+ if (!hasActiveFilter) return 'No filter active — same as exporting all records.'+ if (totalCount === undefined) return 'Export the records matching your current filter.'+ const noun = totalCount === 1 ? 'record' : 'records'+ return `Export the ${totalCount.toLocaleString()} ${noun} matching your current filter.`+}++function RadioOption({+ icon,+ title,+ description,+ selected,+ onSelect,+}: {+ icon: React.ReactNode+ title: string+ description: string+ selected: boolean+ onSelect: () => void+}) {+ return (+ <button+ type="button"+ onClick={onSelect}+ aria-pressed={selected}+ className={cn(+ 'flex items-start gap-3 rounded-lg border p-3 text-left transition-colors',+ 'hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',+ selected ? 'border-primary bg-muted/30' : 'border-border',+ )}+ >+ <span className="mt-0.5 text-muted-foreground">{icon}</span>+ <span className="flex-1">+ <span className="block text-sm font-medium">{title}</span>+ <span className="block text-xs text-muted-foreground">{description}</span>+ </span>+ <span+ className={cn(+ 'mt-1 size-4 shrink-0 rounded-full border',+ selected ? 'border-primary bg-primary' : 'border-border',+ )}+ >+ {selected && (+ <span className="block size-full rounded-full ring-2 ring-background ring-inset" />+ )}+ </span>+ </button>+ )+}diff --git a/packages/admin/src/components/spree/resource-table.tsx b/packages/admin/src/components/spree/resource-table.tsxindex d7b4548212..bd4a50ff3a 100644--- a/packages/admin/src/components/spree/resource-table.tsx+++ b/packages/admin/src/components/spree/resource-table.tsx@@ -16,7 +16,9 @@ import {} from '@/components/ui/data-table'import { Pagination, type PaginationMeta } from '@/components/ui/pagination'import { useAuth } from '@/hooks/use-auth'+import { filtersToRansack } from '@/lib/filters-to-ransack'import {+ type ColumnDef,type FilterRule,getDefaultColumnKeys,getDisplayableColumns,@@ -68,6 +70,22 @@ export type ResourceSearch = z.infer<typeof resourceSearchSchema>// Props// ============================================================================+/**+ * Per-render context handed to the `actions` render-prop. Gives toolbar+ * actions enough state to act on the *current* table view — needed for+ * features like "export filtered records" that have to mirror what the user+ * is looking at.+ */+export interface ResourceActionsContext {+ filters: FilterRule[]+ search: string+ searchParam: string+ /** All columns (incl. filter-only) — needed by `filtersToRansack`. */+ columns: ColumnDef[]+ /** Total record count for the active filter, or `undefined` while loading. */+ totalCount: number | undefined+}+interface ResourceTableProps<T> {/** Registry key (e.g., 'products') */tableKey: string@@ -81,8 +99,13 @@ interface ResourceTableProps<T> {title?: string/** Default params always sent with every request (e.g., { complete: 1 } for orders) */defaultParams?: Record<string, unknown>- /** Actions to render in the toolbar (e.g., "Add Product" button) */- actions?: ReactNode+ /**+ * Actions to render in the toolbar (e.g., "Add Product" button). Either a+ * static node, or a function that receives the current table state — use+ * the function form for actions that depend on filters/search (e.g. CSV+ * export of the active view).+ */+ actions?: ReactNode | ((ctx: ResourceActionsContext) => ReactNode)}// ============================================================================@@ -149,12 +172,7 @@ export function ResourceTable<T extends Record<string, any>>({params[searchParam] = deferredSearch}- // Convert FilterRule[] to Ransack params- for (const filter of filters as FilterRule[]) {- const col = table.columns.find((c) => c.key === filter.field)- const ransackKey = col?.ransackAttribute ?? filter.field- params[`${ransackKey}_${filter.operator}`] = filter.value- }+ Object.assign(params, filtersToRansack(filters as FilterRule[], table.columns))return queryFn(params)},@@ -202,6 +220,17 @@ export function ResourceTable<T extends Record<string, any>>({}})+ const resolvedActions =+ typeof actions === 'function'+ ? actions({+ filters: filters as FilterRule[],+ search: deferredSearch,+ searchParam: table.searchParam ?? 'name_cont',+ columns: table.columns,+ totalCount: meta?.count,+ })+ : actions+return (<Card className="rounded-2xl"><TableToolbar@@ -217,7 +246,7 @@ export function ResourceTable<T extends Record<string, any>>({onFiltersChange={handleFiltersChange}allColumns={table.columns}title={title ?? table.title}- actions={actions}+ actions={resolvedActions}/><CardContent className="p-0"><Table>diff --git a/packages/admin/src/hooks/use-export.ts b/packages/admin/src/hooks/use-export.tsnew file mode 100644index 0000000000..b76b86ac21--- /dev/null+++ b/packages/admin/src/hooks/use-export.ts@@ -0,0 +1,103 @@+import type { Export, ExportCreateParams } from '@spree/admin-sdk'+import { useMutation } from '@tanstack/react-query'+import { toast } from 'sonner'+import { adminClient } from '@/client'+import { useAuth } from '@/hooks/use-auth'++const POLL_INTERVAL_MS = 2000+const POLL_TIMEOUT_MS = 5 * 60 * 1000+const API_BASE_URL = import.meta.env.VITE_SPREE_API_URL || ''+const API_ORIGIN = API_BASE_URL ? new URL(API_BASE_URL).origin : window.location.origin++class ExportTimeoutError extends Error {+ constructor() {+ super('Export timed out')+ this.name = 'ExportTimeoutError'+ }+}++/**+ * Resolve `download_url` (a path or absolute URL) against the API base.+ * Returns both the resolved URL and whether it points at the trusted API+ * origin — only same-origin requests get the `Authorization` header so we+ * can't accidentally leak a JWT to a third-party host.+ */+function resolveDownload(downloadUrl: string): { url: string; sameOrigin: boolean } {+ const url = /^https?:\/\//.test(downloadUrl) ? downloadUrl : `${API_BASE_URL}${downloadUrl}`+ const sameOrigin = new URL(url, window.location.origin).origin === API_ORIGIN+ return { url, sameOrigin }+}++async function pollUntilDone(id: string): Promise<Export> {+ const deadline = Date.now() + POLL_TIMEOUT_MS++ while (Date.now() < deadline) {+ const exp = await adminClient.exports.get(id)+ if (exp.done) return exp+ await new Promise<void>((resolve) => setTimeout(resolve, POLL_INTERVAL_MS))+ }++ throw new ExportTimeoutError()+}++// `window.location` won't carry the in-memory JWT, so we fetch the file+// ourselves and drive the download via a Blob URL.+async function downloadExportFile(exp: Export, token: string | null): Promise<void> {+ if (!exp.download_url) throw new Error('Export has no download_url')++ const { url, sameOrigin } = resolveDownload(exp.download_url)+ const headers: Record<string, string> = {}+ if (sameOrigin && token) headers.Authorization = `Bearer ${token}`++ const response = await fetch(url, {+ headers,+ credentials: sameOrigin ? 'include' : 'omit',+ })++ if (!response.ok) throw new Error(`Download failed: ${response.status}`)++ const blob = await response.blob()+ const objectUrl = URL.createObjectURL(blob)+ const anchor = document.createElement('a')+ anchor.href = objectUrl+ anchor.download = exp.filename ?? 'export.csv'+ document.body.appendChild(anchor)+ anchor.click()+ anchor.remove()+ URL.revokeObjectURL(objectUrl)+}++/**+ * Queue a CSV export and drive it to completion: create → poll → download.+ * On poll timeout, falls back to the email-link path —+ * `Spree::ExportMailer.export_done` already covers that server-side.+ */+export function useExport() {+ const { token } = useAuth()++ return useMutation({+ mutationFn: async (params: ExportCreateParams) => {+ // Per-invocation id so concurrent exports don't collide on a single+ // sticky toast.+ const toastId = `export-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`+ toast.loading('Preparing export…', { id: toastId })++ try {+ const created = await adminClient.exports.create(params)+ const finished = await pollUntilDone(created.id)+ await downloadExportFile(finished, token)+ toast.success('Export downloaded', { id: toastId })+ return finished+ } catch (err) {+ if (err instanceof ExportTimeoutError) {+ toast.info("Still processing — we'll email you a link when it's ready.", {+ id: toastId,+ })+ } else {+ toast.error(`Export failed: ${(err as Error).message}`, { id: toastId })+ }+ throw err+ }+ },+ })+}diff --git a/packages/admin/src/lib/filters-to-ransack.ts b/packages/admin/src/lib/filters-to-ransack.tsnew file mode 100644index 0000000000..b5fe4eb11b--- /dev/null+++ b/packages/admin/src/lib/filters-to-ransack.ts@@ -0,0 +1,30 @@+import type { ColumnDef, FilterRule } from '@/lib/table-registry'++/**+ * Convert toolbar `FilterRule[]` state into a flat Ransack predicate hash:+ *+ * [{ field: 'name', operator: 'cont', value: 'shirt' }]+ *+ * becomes+ *+ * { name_cont: 'shirt' }+ *+ * Columns can override the predicate target via `ransackAttribute` (e.g.+ * the `sku` column on products filters through `master_sku_cont`).+ *+ * The output shape is what both the list endpoints (after+ * `transformListParams` wraps each key in `q[...]`) and the export endpoint+ * (which stores the hash as `search_params`) expect.+ */+export function filtersToRansack(+ filters: FilterRule[],+ columns: ColumnDef[],+): Record<string, string> {+ const out: Record<string, string> = {}+ for (const filter of filters) {+ const col = columns.find((c) => c.key === filter.field)+ const ransackKey = col?.ransackAttribute ?? filter.field+ out[`${ransackKey}_${filter.operator}`] = filter.value+ }+ return out+}diff --git a/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx b/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsxindex b1c4dbeaf5..7a697546eb 100644--- a/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx+++ b/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx@@ -1,5 +1,6 @@import { createFileRoute } from '@tanstack/react-router'import { adminClient } from '@/client'+import { ExportButton } from '@/components/spree/export-button'import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'import '@/tables/customers'@@ -17,6 +18,7 @@ function CustomersPage() {queryKey="customers"queryFn={(params) => adminClient.customers.list(params)}searchParams={searchParams}+ actions={(ctx) => <ExportButton type="Spree::Exports::Customers" {...ctx} />}/>)}diff --git a/packages/admin/src/routes/_authenticated/$storeId/orders/index.tsx b/packages/admin/src/routes/_authenticated/$storeId/orders/index.tsxindex 3b950bddfa..362b1f42dc 100644--- a/packages/admin/src/routes/_authenticated/$storeId/orders/index.tsx+++ b/packages/admin/src/routes/_authenticated/$storeId/orders/index.tsx@@ -1,6 +1,7 @@import { createFileRoute, Link } from '@tanstack/react-router'import { PlusIcon } from 'lucide-react'import { adminClient } from '@/client'+import { ExportButton } from '@/components/spree/export-button'import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'import { Button } from '@/components/ui/button'import '@/tables/orders'@@ -21,14 +22,17 @@ function OrdersPage() {queryFn={(params) => adminClient.orders.list(params)}searchParams={searchParams}defaultParams={{ complete: 1 }}- actions={- <Button size="sm" className="h-[2.125rem]" asChild>- <Link to="/$storeId/orders/new" params={{ storeId }}>- <PlusIcon className="size-4" />- New Order- </Link>- </Button>- }+ actions={(ctx) => (+ <>+ <ExportButton type="Spree::Exports::Orders" {...ctx} />+ <Button size="sm" className="h-[2.125rem]" asChild>+ <Link to="/$storeId/orders/new" params={{ storeId }}>+ <PlusIcon className="size-4" />+ New Order+ </Link>+ </Button>+ </>+ )}/>)}diff --git a/packages/admin/src/routes/_authenticated/$storeId/products/index.tsx b/packages/admin/src/routes/_authenticated/$storeId/products/index.tsxindex bf76123934..0a543fde74 100644--- a/packages/admin/src/routes/_authenticated/$storeId/products/index.tsx+++ b/packages/admin/src/routes/_authenticated/$storeId/products/index.tsx@@ -1,6 +1,7 @@import { createFileRoute } from '@tanstack/react-router'import { PlusIcon } from 'lucide-react'import { adminClient } from '@/client'+import { ExportButton } from '@/components/spree/export-button'import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'import { Button } from '@/components/ui/button'import '@/tables/products'@@ -19,12 +20,15 @@ function ProductsPage() {queryKey="products"queryFn={(params) => adminClient.products.list(params)}searchParams={searchParams}- actions={- <Button size="sm" className="h-[2.125rem]">- <PlusIcon className="size-4" />- Add Product- </Button>- }+ actions={(ctx) => (+ <>+ <ExportButton type="Spree::Exports::Products" {...ctx} />+ <Button size="sm" className="h-[2.125rem]">+ <PlusIcon className="size-4" />+ Add Product+ </Button>+ </>+ )}/>)}diff --git a/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rb b/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rbindex 38feaf5d2e..a3989ad026 100644--- a/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rb+++ b/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rb@@ -60,6 +60,9 @@ module Spreedigital_link_expired: 'digital_link_expired',download_limit_exceeded: 'download_limit_exceeded',+ # Export errors+ export_not_ready: 'export_not_ready',+# Rate limiting errorsrate_limit_exceeded: 'rate_limit_exceeded',diff --git a/spree/api/app/controllers/spree/api/v3/admin/exports_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/exports_controller.rbnew file mode 100644index 0000000000..52e570d4f7--- /dev/null+++ b/spree/api/app/controllers/spree/api/v3/admin/exports_controller.rb@@ -0,0 +1,89 @@+module Spree+ module Api+ module V3+ module Admin+ # See `docs/plans/5.5-admin-spa-csv-export.md`.+ class ExportsController < ResourceController+ include ActiveStorage::SetCurrent++ scoped_resource :exports++ # We stream the CSV inline rather than redirecting to ActiveStorage's+ # signed-URL endpoint because the SPA's Vite proxy only forwards+ # `/api/*`. A cross-origin redirect to `/rails/active_storage/...`+ # strips the Authorization header and the download fails silently.+ def download+ @resource = find_resource+ authorize_resource!(@resource, :show)++ unless @resource.done?+ return render_error(+ code: Spree::Api::V3::ErrorHandler::ERROR_CODES[:export_not_ready],+ message: 'Export is not ready yet',+ status: :unprocessable_content+ )+ end++ attachment = @resource.attachment+ send_data(+ attachment.download,+ filename: attachment.filename.to_s,+ type: attachment.content_type || 'text/csv',+ disposition: 'attachment'+ )+ end++ protected++ def model_class+ Spree::Export+ end++ def serializer_class+ Spree.api.admin_export_serializer+ end++ def scope_includes+ [:user, { attachment_attachment: :blob }]+ end++ def build_resource+ klass = resolve_export_type(permitted_params[:type]) || Spree::Export+ attrs = permitted_params.except(:type).merge(+ store: current_store,+ user: try_spree_current_user+ )+ klass.new(attrs)+ end++ # `search_params` carries an arbitrary Ransack hash with nested+ # groupings (`{ g: [{ name_cont: 'foo' }] }`). Rails' `permit(k: {})`+ # rejects nested hashes, so we extract via `to_unsafe_h`. `:format`+ # is intentionally dropped — only CSV is supported and Rails' request+ # format would otherwise overwrite the model's enum.+ def permitted_params+ attrs = params.permit(:type, :record_selection)+ raw = params[:search_params]+ attrs[:search_params] = raw.respond_to?(:to_unsafe_h) ? raw.to_unsafe_h : raw if raw.present?+ attrs+ end++ # Returns the registered Export subclass matching `name`, or nil.+ #+ # The constantize target comes from `available_types` (a trusted+ # in-process registry), not from the request — `name` is only used+ # to *select* an entry in the allowlist. This keeps the data flow+ # from user input → trusted-string → `constantize` legible to+ # static analyzers (CodeQL otherwise flags the inverse pattern of+ # gating user input with `include?` before calling `constantize`).+ def resolve_export_type(name)+ return nil if name.blank?++ target = Spree::Export.available_types.map(&:to_s).find { |t| t == name.to_s }+ target&.constantize+ end+ end+ end+ end+ end+enddiff --git a/spree/api/app/serializers/spree/api/v3/admin/export_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/export_serializer.rbnew file mode 100644index 0000000000..feb8be26b1--- /dev/null+++ b/spree/api/app/serializers/spree/api/v3/admin/export_serializer.rb@@ -0,0 +1,40 @@+module Spree+ module Api+ module V3+ module Admin+ # Admin API serializer for {Spree::Export}.+ #+ # `download_url` is the path to our own download endpoint, not a+ # pre-signed ActiveStorage URL — the controller streams bytes inline+ # so the JWT auth flow runs on every download and works through the+ # SPA's `/api/*`-only dev proxy.+ class ExportSerializer < V3::ExportSerializer+ typelize done: :boolean,+ download_url: [:string, nullable: true],+ filename: [:string, nullable: true],+ byte_size: [:number, nullable: true]++ attribute(:done) { |export| export.done? }++ # Safe-nav on `blob` — `attachment.attached?` can stay true while a+ # background job purges the underlying blob (e.g. retention sweeps).+ attribute :filename do |export|+ export.attachment.blob&.filename&.to_s if export.done?+ end++ attribute :byte_size do |export|+ export.attachment.blob&.byte_size if export.done?+ end++ attribute :download_url do |export|+ next nil unless export.done?++ Spree::Core::Engine.routes.url_helpers.download_api_v3_admin_export_path(+ id: export.prefixed_id+ )+ end+ end+ end+ end+ end+enddiff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rbindex 7f8e8a3d3e..5ed57599c5 100644--- a/spree/api/config/routes.rb+++ b/spree/api/config/routes.rb@@ -139,6 +139,13 @@ Spree::Core::Engine.add_routes do# Direct Uploads (Active Storage)resources :direct_uploads, only: [:create]+ # CSV Exports — see docs/plans/5.5-admin-spa-csv-export.md+ resources :exports, only: [:index, :show, :create, :destroy] do+ member do+ get :download+ end+ end+# Productsresources :products, concerns: :custom_fieldable domember dodiff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rbindex c3a55b64cf..0a16974a0f 100644--- a/spree/api/lib/spree/api/dependencies.rb+++ b/spree/api/lib/spree/api/dependencies.rb@@ -200,6 +200,7 @@ module Spreeadmin_api_key_serializer: 'Spree::Api::V3::Admin::ApiKeySerializer',admin_invitation_serializer: 'Spree::Api::V3::Admin::InvitationSerializer',admin_role_serializer: 'Spree::Api::V3::Admin::RoleSerializer',+ admin_export_serializer: 'Spree::Api::V3::Admin::ExportSerializer',# platform serializersplatform_metafield_serializer: 'Spree::Api::V2::Platform::MetafieldSerializer',diff --git a/spree/api/spec/controllers/spree/api/v3/admin/exports_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/exports_controller_spec.rbnew file mode 100644index 0000000000..12004c9881--- /dev/null+++ b/spree/api/spec/controllers/spree/api/v3/admin/exports_controller_spec.rb@@ -0,0 +1,229 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Admin::ExportsController, type: :controller do+ render_views++ include_context 'API v3 Admin authenticated'++ before { request.headers.merge!(headers) }++ let!(:product_export) do+ create(:export, type: 'Spree::Exports::Products', store: store, user: admin_user)+ end++ describe 'GET #index' do+ subject { get :index, as: :json }++ it 'returns exports for the current store' do+ subject+ expect(response).to have_http_status(:ok)+ expect(json_response['data']).to be_an(Array)+ expect(json_response['data'].map { |e| e['id'] }).to include(product_export.prefixed_id)+ end++ it 'omits exports from other stores' do+ other_store = create(:store)+ create(:export, type: 'Spree::Exports::Products', store: other_store, user: admin_user)++ subject+ ids = json_response['data'].map { |e| e['id'] }+ expect(ids).to contain_exactly(product_export.prefixed_id)+ end++ it 'serializes status fields' do+ subject+ row = json_response['data'].find { |e| e['id'] == product_export.prefixed_id }++ expect(row).to include('done' => false, 'download_url' => nil)+ expect(row['type']).to eq('Spree::Exports::Products')+ expect(row['format']).to eq('csv')+ end+ end++ describe 'GET #show' do+ subject { get :show, params: { id: product_export.prefixed_id }, as: :json }++ it 'returns the export' do+ subject+ expect(response).to have_http_status(:ok)+ expect(json_response['id']).to eq(product_export.prefixed_id)+ expect(json_response['done']).to eq(false)+ end++ context 'when the export has a generated attachment' do+ before do+ product_export.attachment.attach(+ io: StringIO.new("name,sku\nFoo,FOO-1\n"),+ filename: 'products.csv',+ content_type: 'text/csv'+ )+ end++ it 'reports done with filename and byte_size' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['done']).to eq(true)+ expect(json_response['filename']).to eq('products.csv')+ expect(json_response['byte_size']).to be > 0+ end++ it 'exposes download_url as the API download endpoint path' do+ subject++ expect(json_response['download_url']).to eq(+ "/api/v3/admin/exports/#{product_export.prefixed_id}/download"+ )+ end+ end++ it 'returns 404 for an unknown id' do+ get :show, params: { id: 'exp_unknown' }, as: :json+ expect(response).to have_http_status(:not_found)+ end+ end++ describe 'POST #create' do+ it 'creates a Products export with a Ransack search_params hash' do+ expect {+ post :create,+ params: {+ type: 'Spree::Exports::Products',+ search_params: { name_cont: 'shirt' }+ },+ as: :json+ }.to change(Spree::Export, :count).by(1)++ expect(response).to have_http_status(:created)+ created = Spree::Export.find_by_prefix_id(json_response['id'])+ expect(created).to be_a(Spree::Exports::Products)+ expect(created.user).to eq(admin_user)+ expect(created.store).to eq(store)+ # Model normalizes the hash to a JSON string before persistence+ expect(JSON.parse(created.search_params.to_s)).to eq('name_cont' => 'shirt')+ end++ it 'creates an Orders export' do+ post :create, params: { type: 'Spree::Exports::Orders' }, as: :json++ expect(response).to have_http_status(:created)+ expect(Spree::Export.find_by_prefix_id(json_response['id'])).to be_a(Spree::Exports::Orders)+ end++ it 'creates a Customers export' do+ post :create, params: { type: 'Spree::Exports::Customers' }, as: :json++ expect(response).to have_http_status(:created)+ expect(Spree::Export.find_by_prefix_id(json_response['id'])).to be_a(Spree::Exports::Customers)+ end++ it 'clears search_params when record_selection is "all"' do+ post :create,+ params: {+ type: 'Spree::Exports::Products',+ record_selection: 'all',+ search_params: { name_cont: 'shirt' }+ },+ as: :json++ expect(response).to have_http_status(:created)+ created = Spree::Export.find_by_prefix_id(json_response['id'])+ expect(created.search_params).to be_blank+ end++ it 'rejects unregistered export types' do+ post :create, params: { type: 'Spree::User' }, as: :json++ # Falls back to Spree::Export which fails the `type: presence` validation+ expect(response).to have_http_status(:unprocessable_content)+ end++ end++ describe 'GET #download' do+ subject { get :download, params: { id: product_export.prefixed_id }, as: :json }++ context 'when the export is not done yet' do+ it 'returns 422 with export_not_ready code' do+ subject+ expect(response).to have_http_status(:unprocessable_content)+ expect(json_response.dig('error', 'code')).to eq('export_not_ready')+ end+ end++ context 'when the export is done' do+ before do+ product_export.attachment.attach(+ io: StringIO.new("name,sku\nFoo,FOO-1\n"),+ filename: 'products.csv',+ content_type: 'text/csv'+ )+ end++ it 'streams the CSV with attachment disposition' do+ subject++ expect(response).to have_http_status(:ok)+ expect(response.content_type).to include('text/csv')+ expect(response.headers['Content-Disposition']).to include('attachment')+ expect(response.headers['Content-Disposition']).to include('products.csv')+ expect(response.body).to eq("name,sku\nFoo,FOO-1\n")+ end+ end++ it 'returns 404 for an unknown id' do+ get :download, params: { id: 'exp_unknown' }, as: :json+ expect(response).to have_http_status(:not_found)+ end+ end++ describe 'DELETE #destroy' do+ subject { delete :destroy, params: { id: product_export.prefixed_id }, as: :json }++ it 'deletes the export' do+ product_export # touch let!+ expect { subject }.to change(Spree::Export, :count).by(-1)+ expect(response).to have_http_status(:no_content)+ end+ end++ describe 'authentication' do+ context 'without any credential' do+ let(:headers) { {} }+ subject { get :index, as: :json }++ it 'returns 401 unauthorized' do+ subject+ expect(response).to have_http_status(:unauthorized)+ end+ end++ context 'with a secret API key' do+ let(:headers) { api_key_headers }++ it 'allows index with read_exports scope' do+ secret_api_key.update!(scopes: ['read_exports'])+ get :index, as: :json+ expect(response).to have_http_status(:ok)+ end++ it 'allows create with write_exports scope' do+ secret_api_key.update!(scopes: ['write_exports'])+ post :create, params: { type: 'Spree::Exports::Products' }, as: :json+ expect(response).to have_http_status(:created)+ end++ it 'rejects create when the key only has read_exports' do+ secret_api_key.update!(scopes: ['read_exports'])+ post :create, params: { type: 'Spree::Exports::Products' }, as: :json+ expect(response).to have_http_status(:forbidden)+ end++ it 'rejects exports endpoints when the key has only an unrelated scope' do+ secret_api_key.update!(scopes: ['read_orders'])+ get :index, as: :json+ expect(response).to have_http_status(:forbidden)+ end+ end+ end+enddiff --git a/spree/api/spec/integration/spree/api/v3/admin/exports_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/exports_spec.rbnew file mode 100644index 0000000000..f3a301d506--- /dev/null+++ b/spree/api/spec/integration/spree/api/v3/admin/exports_spec.rb@@ -0,0 +1,215 @@+# frozen_string_literal: true++require 'swagger_helper'++RSpec.describe 'Admin Exports API', type: :request, swagger_doc: 'api-reference/admin.yaml' do+ include_context 'API v3 Admin'++ let(:Authorization) { "Bearer #{admin_jwt_token}" }+ let!(:product_export) do+ create(:export, type: 'Spree::Exports::Products', store: store, user: admin_user)+ end++ path '/api/v3/admin/exports' do+ get 'List exports' do+ tags 'Exports'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Returns CSV exports queued or completed for the current store. ' \+ 'Polled by the admin SPA to detect when an export finishes (`done: true`).'+ admin_scope :read, :exports++ admin_sdk_example <<~JS+ const { data: exports } = await client.exports.list()+ JS++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true++ response '200', 'exports found' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['data']).to be_an(Array)+ expect(data['data'].pluck('id')).to include(product_export.prefixed_id)+ end+ end+ end++ post 'Create an export' do+ tags 'Exports'+ consumes 'application/json'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description <<~MD+ Queues a CSV export. The `type` selects the dataset; `search_params` is an+ optional Ransack query (same shape used by the `q[...]` params on list endpoints)+ that filters which records are exported. Pass `record_selection: "all"` to+ clear the filter server-side and export everything in scope.++ Generation is asynchronous. Poll `GET /admin/exports/{id}` until `done` is `true`,+ then redirect the browser to `download_url` to fetch the file.+ MD+ admin_scope :write, :exports++ admin_sdk_example <<~JS+ const exp = await client.exports.create({+ type: 'Spree::Exports::Products',+ search_params: { name_cont: 'shirt' }+ })+ JS++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true+ parameter name: :body, in: :body, schema: {+ type: :object,+ required: %w[type],+ properties: {+ type: {+ type: :string,+ enum: %w[+ Spree::Exports::Products+ Spree::Exports::Orders+ Spree::Exports::Customers+ Spree::Exports::ProductTranslations+ Spree::Exports::GiftCards+ Spree::Exports::CouponCodes+ Spree::Exports::NewsletterSubscribers+ ],+ example: 'Spree::Exports::Products'+ },+ record_selection: {+ type: :string,+ enum: %w[filtered all],+ description: 'Set to "all" to ignore search_params and export everything in scope.',+ example: 'filtered'+ },+ search_params: {+ type: :object,+ description: 'Ransack query hash. Same predicates accepted by the list endpoint.',+ example: { name_cont: 'shirt' },+ additionalProperties: true+ }+ }+ }++ response '201', 'export queued' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let(:body) { { type: 'Spree::Exports::Products', search_params: { name_cont: 'shirt' } } }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['type']).to eq('Spree::Exports::Products')+ expect(data['done']).to eq(false)+ end+ end+ end+ end++ path '/api/v3/admin/exports/{id}' do+ let(:id) { product_export.prefixed_id }++ get 'Show an export' do+ tags 'Exports'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Returns export status. While `done` is `false`, the SPA continues polling.'+ admin_scope :read, :exports++ admin_sdk_example <<~JS+ const exp = await client.exports.get('exp_xxx')+ JS++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true+ parameter name: :id, in: :path, type: :string, required: true++ response '200', 'export found' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['id']).to eq(product_export.prefixed_id)+ end+ end+ end++ delete 'Delete an export' do+ tags 'Exports'+ security [api_key: [], bearer_auth: []]+ description 'Removes the export and purges its attachment.'+ admin_scope :write, :exports++ admin_sdk_example <<~JS+ await client.exports.delete('exp_xxx')+ JS++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true+ parameter name: :id, in: :path, type: :string, required: true++ response '204', 'export deleted' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test!+ end+ end+ end++ path '/api/v3/admin/exports/{id}/download' do+ let(:id) { product_export.prefixed_id }++ before do+ product_export.attachment.attach(+ io: StringIO.new("name,sku\nFoo,FOO-1\n"),+ filename: 'products.csv',+ content_type: 'text/csv'+ )+ end++ get 'Download an export' do+ tags 'Exports'+ produces 'text/csv'+ security [api_key: [], bearer_auth: []]+ description 'Streams the exported CSV with `Content-Disposition: attachment`. ' \+ 'Returns 422 with `code: export_not_ready` while `done` is still ' \+ '`false`. The endpoint is JWT/API-key protected, so SPA clients ' \+ 'must fetch it (with `Authorization` header) and trigger the ' \+ 'browser download via a Blob URL — a top-level navigation cannot ' \+ 'carry the JWT.'+ admin_scope :read, :exports++ admin_sdk_example <<~JS+ // Fetch with the Bearer token, then drive the browser download:+ const res = await fetch(exp.download_url, {+ headers: { Authorization: `Bearer ${token}` }+ })+ const blob = await res.blob()+ const url = URL.createObjectURL(blob)+ const a = Object.assign(document.createElement('a'), {+ href: url,+ download: exp.filename+ })+ a.click()+ URL.revokeObjectURL(url)+ JS++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true+ parameter name: :id, in: :path, type: :string, required: true++ response '200', 'CSV file' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ produces 'text/csv'+ schema type: :string, format: :binary++ run_test! do |response|+ expect(response.content_type).to include('text/csv')+ expect(response.headers['Content-Disposition']).to include('attachment')+ end+ end+ end+ end+enddiff --git a/spree/core/app/models/spree/api_key.rb b/spree/core/app/models/spree/api_key.rbindex a47dcf1d1d..d7d720f0f2 100644--- a/spree/core/app/models/spree/api_key.rb+++ b/spree/core/app/models/spree/api_key.rb@@ -20,6 +20,7 @@ module Spreeread_store_credits write_store_creditsread_categories write_categoriesread_custom_field_definitions write_custom_field_definitions+ read_exports write_exportsread_settings write_settingsread_webhooks write_webhooksread_dashboarddiff --git a/spree/core/app/models/spree/export.rb b/spree/core/app/models/spree/export.rbindex b03bd35396..b476a742c3 100644--- a/spree/core/app/models/spree/export.rb+++ b/spree/core/app/models/spree/export.rb@@ -22,13 +22,16 @@ module Spree# Associations#belongs_to :store, class_name: 'Spree::Store'- belongs_to :user, class_name: Spree.admin_user_class.to_s+ # Optional so secret-API-key callers (apps / server-to-server) can create+ # exports without a human user attached. The email notification is+ # skipped for these — apps poll instead.+ belongs_to :user, class_name: Spree.admin_user_class.to_s, optional: truebelongs_to :vendor, -> { with_deleted }, class_name: 'Spree::Vendor', optional: true## Validations#- validates :format, :store, :user, :type, presence: true+ validates :format, :store, :type, presence: true## Enums@@ -181,6 +184,8 @@ module Spreeenddef send_export_done_email+ return if user.blank? # App-created exports (secret API key) have no user to email.+Spree::ExportMailer.export_done(self).deliver_laterenddiff --git a/spree/core/spec/models/spree/export_spec.rb b/spree/core/spec/models/spree/export_spec.rbindex d902c5341d..f90034d402 100644--- a/spree/core/spec/models/spree/export_spec.rb+++ b/spree/core/spec/models/spree/export_spec.rb@@ -36,6 +36,20 @@ RSpec.describe Spree::Export, :job, type: :model doexpect { export.generate }.to have_enqueued_job(ActionMailer::MailDeliveryJob)end+ context 'when the export has no user (created via secret API key)' do+ let(:export) { build(:product_export, store: store, user: nil, format: 'csv') }++ it 'still generates and attaches the CSV' do+ export.save!+ expect { export.generate }.to change(export.attachment, :attached?).from(false).to(true)+ end++ it 'does not enqueue the export done email' do+ export.save!+ expect { export.generate }.not_to have_enqueued_job(ActionMailer::MailDeliveryJob)+ end+ end+context 'when the export type is Spree::Exports::Customers' dolet(:export) { build(:customer_export, store: store, user: user, format: 'csv') }@@ -72,6 +86,14 @@ RSpec.describe Spree::Export, :job, type: :model doit 'queues the export done email' doexpect { export.send_export_done_email }.to have_enqueued_job(ActionMailer::MailDeliveryJob)end++ context 'when the export has no user' do+ let(:export) { build(:product_export, store: store, user: nil, format: 'csv') }++ it 'does not queue an email — apps polling via secret API key have no inbox' do+ expect { export.send_export_done_email }.not_to have_enqueued_job(ActionMailer::MailDeliveryJob)+ end+ endenddescribe '#normalize_search_params' do