Skip to content

armgit / spree

Public Imported from GitHub
0

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

Let a seller complete every kind of onboarding task

Damian Legawiec862fb4f34123
diff --git a/packages/admin-sdk/examples/admin-users/get.ts b/packages/admin-sdk/examples/admin-users/get.ts
index c7247eca2c..342e64d6b1 100644
--- a/packages/admin-sdk/examples/admin-users/get.ts
+++ b/packages/admin-sdk/examples/admin-users/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const staff = await client.adminUsers.get('admin_xxx')
+
// endregion:example
export { staff }
diff --git a/packages/admin-sdk/examples/admin-users/list.ts b/packages/admin-sdk/examples/admin-users/list.ts
index 856522f50c..3b9b258468 100644
--- a/packages/admin-sdk/examples/admin-users/list.ts
+++ b/packages/admin-sdk/examples/admin-users/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: staff } = await client.adminUsers.list()
+
// endregion:example
export { staff }
diff --git a/packages/admin-sdk/examples/admin-users/update.ts b/packages/admin-sdk/examples/admin-users/update.ts
index d8f4e24810..398d6ef493 100644
--- a/packages/admin-sdk/examples/admin-users/update.ts
+++ b/packages/admin-sdk/examples/admin-users/update.ts
@@ -8,8 +8,9 @@ const client = createAdminClient({
// region:example
const staff = await client.adminUsers.update('admin_xxx', {
first_name: 'Ada',
- role_ids: ['role_xxx']
+ role_ids: ['role_xxx'],
})
+
// endregion:example
export { staff }
diff --git a/packages/admin-sdk/examples/api-keys/create.ts b/packages/admin-sdk/examples/api-keys/create.ts
index 46797c6802..b924887717 100644
--- a/packages/admin-sdk/examples/api-keys/create.ts
+++ b/packages/admin-sdk/examples/api-keys/create.ts
@@ -9,8 +9,9 @@ const client = createAdminClient({
const key = await client.apiKeys.create({
name: 'Backend integration',
key_type: 'secret',
- scopes: ['read_orders', 'write_orders']
+ scopes: ['read_orders', 'write_orders'],
})
+
// `key.plaintext_token` is available only on this response.
// endregion:example
diff --git a/packages/admin-sdk/examples/api-keys/get.ts b/packages/admin-sdk/examples/api-keys/get.ts
index 98127f406b..8c772bc7e8 100644
--- a/packages/admin-sdk/examples/api-keys/get.ts
+++ b/packages/admin-sdk/examples/api-keys/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const key = await client.apiKeys.get('key_xxx')
+
// endregion:example
export { key }
diff --git a/packages/admin-sdk/examples/api-keys/list.ts b/packages/admin-sdk/examples/api-keys/list.ts
index fc85508230..e7e90a9c51 100644
--- a/packages/admin-sdk/examples/api-keys/list.ts
+++ b/packages/admin-sdk/examples/api-keys/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: keys } = await client.apiKeys.list()
+
// endregion:example
export { keys }
diff --git a/packages/admin-sdk/examples/api-keys/revoke.ts b/packages/admin-sdk/examples/api-keys/revoke.ts
index d48d9d66d9..04a4447e6f 100644
--- a/packages/admin-sdk/examples/api-keys/revoke.ts
+++ b/packages/admin-sdk/examples/api-keys/revoke.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const key = await client.apiKeys.revoke('key_xxx')
+
// endregion:example
export { key }
diff --git a/packages/admin-sdk/examples/auth/login.ts b/packages/admin-sdk/examples/auth/login.ts
index 883a41915a..f4462c8b1d 100644
--- a/packages/admin-sdk/examples/auth/login.ts
+++ b/packages/admin-sdk/examples/auth/login.ts
@@ -11,6 +11,7 @@ const auth = await client.auth.login({
password: 'password123',
})
+
// endregion:example
export { auth }
diff --git a/packages/admin-sdk/examples/auth/logout.ts b/packages/admin-sdk/examples/auth/logout.ts
index 2a18c9b084..bf0965555e 100644
--- a/packages/admin-sdk/examples/auth/logout.ts
+++ b/packages/admin-sdk/examples/auth/logout.ts
@@ -8,5 +8,3 @@ const client = createAdminClient({
// region:example
await client.auth.logout()
// endregion:example
-
-export {}
diff --git a/packages/admin-sdk/examples/auth/refresh.ts b/packages/admin-sdk/examples/auth/refresh.ts
index 14a6f721a3..e745a3788c 100644
--- a/packages/admin-sdk/examples/auth/refresh.ts
+++ b/packages/admin-sdk/examples/auth/refresh.ts
@@ -8,6 +8,7 @@ const client = createAdminClient({
// region:example
// Driven entirely by the HttpOnly refresh-token cookie + CSRF header (set by the SDK).
const auth = await client.auth.refresh()
+
// endregion:example
export { auth }
diff --git a/packages/admin-sdk/examples/coupon-codes/list.ts b/packages/admin-sdk/examples/coupon-codes/list.ts
index f157f171df..0321fe8fa7 100644
--- a/packages/admin-sdk/examples/coupon-codes/list.ts
+++ b/packages/admin-sdk/examples/coupon-codes/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: coupons } = await client.promotions.couponCodes.list('promo_UkLWZg9DAJ')
+
// endregion:example
export { coupons }
diff --git a/packages/admin-sdk/examples/custom-field-definitions/create.ts b/packages/admin-sdk/examples/custom-field-definitions/create.ts
index 6338391de8..8e3556c3f3 100644
--- a/packages/admin-sdk/examples/custom-field-definitions/create.ts
+++ b/packages/admin-sdk/examples/custom-field-definitions/create.ts
@@ -14,6 +14,7 @@ const definition = await client.customFieldDefinitions.create({
resource_type: 'Spree::Product',
storefront_visible: true,
})
+
// endregion:example
export { definition }
diff --git a/packages/admin-sdk/examples/custom-field-definitions/list.ts b/packages/admin-sdk/examples/custom-field-definitions/list.ts
index d991fc9e18..1f64af5f43 100644
--- a/packages/admin-sdk/examples/custom-field-definitions/list.ts
+++ b/packages/admin-sdk/examples/custom-field-definitions/list.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const { data: definitions } = await client.customFieldDefinitions.list({
q: { resource_type_eq: 'Spree::Product' },
})
+
// endregion:example
export { definitions }
diff --git a/packages/admin-sdk/examples/customer-addresses/list.ts b/packages/admin-sdk/examples/customer-addresses/list.ts
index fe084cf19a..e40e35ebb9 100644
--- a/packages/admin-sdk/examples/customer-addresses/list.ts
+++ b/packages/admin-sdk/examples/customer-addresses/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: addresses } = await client.customers.addresses.list('cus_UkLWZg9DAJ')
+
// endregion:example
export { addresses }
diff --git a/packages/admin-sdk/examples/customer-addresses/update.ts b/packages/admin-sdk/examples/customer-addresses/update.ts
index 4a8c451a0a..4cd8ff3ac6 100644
--- a/packages/admin-sdk/examples/customer-addresses/update.ts
+++ b/packages/admin-sdk/examples/customer-addresses/update.ts
@@ -6,11 +6,10 @@ const client = createAdminClient({
})
// region:example
-const address = await client.customers.addresses.update(
- 'cus_UkLWZg9DAJ',
- 'addr_UkLWZg9DAJ',
- { city: 'Manhattan' },
-)
+const address = await client.customers.addresses.update('cus_UkLWZg9DAJ', 'addr_UkLWZg9DAJ', {
+ city: 'Manhattan',
+})
+
// endregion:example
export { address }
diff --git a/packages/admin-sdk/examples/customer-credit-cards/get.ts b/packages/admin-sdk/examples/customer-credit-cards/get.ts
index 405def0ddf..d728b6d4f6 100644
--- a/packages/admin-sdk/examples/customer-credit-cards/get.ts
+++ b/packages/admin-sdk/examples/customer-credit-cards/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const card = await client.customers.creditCards.get('cus_UkLWZg9DAJ', 'cc_UkLWZg9DAJ')
+
// endregion:example
export { card }
diff --git a/packages/admin-sdk/examples/customer-credit-cards/list.ts b/packages/admin-sdk/examples/customer-credit-cards/list.ts
index d9ee9f46a8..a6bc15d9d2 100644
--- a/packages/admin-sdk/examples/customer-credit-cards/list.ts
+++ b/packages/admin-sdk/examples/customer-credit-cards/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: cards } = await client.customers.creditCards.list('cus_UkLWZg9DAJ')
+
// endregion:example
export { cards }
diff --git a/packages/admin-sdk/examples/customer-groups/create.ts b/packages/admin-sdk/examples/customer-groups/create.ts
index ea31832d6f..314ad74a8f 100644
--- a/packages/admin-sdk/examples/customer-groups/create.ts
+++ b/packages/admin-sdk/examples/customer-groups/create.ts
@@ -11,6 +11,7 @@ const group = await client.customerGroups.create({
description: 'Top spenders, eligible for early access',
customer_ids: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'],
})
+
// endregion:example
export { group }
diff --git a/packages/admin-sdk/examples/customer-groups/get.ts b/packages/admin-sdk/examples/customer-groups/get.ts
index 22539f4579..700d5e4e58 100644
--- a/packages/admin-sdk/examples/customer-groups/get.ts
+++ b/packages/admin-sdk/examples/customer-groups/get.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
// Pass `expand: ['customers']` to embed the group's customers in the response
// — omit it for the much smaller index-payload shape.
const group = await client.customerGroups.get('cg_UkLWZg9DAJ', { expand: ['customers'] })
+
// endregion:example
export { group }
diff --git a/packages/admin-sdk/examples/customer-groups/list.ts b/packages/admin-sdk/examples/customer-groups/list.ts
index ee6431d402..373dbbf31d 100644
--- a/packages/admin-sdk/examples/customer-groups/list.ts
+++ b/packages/admin-sdk/examples/customer-groups/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: groups } = await client.customerGroups.list({ page: 1, limit: 25 })
+
// endregion:example
export { groups }
diff --git a/packages/admin-sdk/examples/customer-groups/update.ts b/packages/admin-sdk/examples/customer-groups/update.ts
index cf99fbb25f..8c9a1429f4 100644
--- a/packages/admin-sdk/examples/customer-groups/update.ts
+++ b/packages/admin-sdk/examples/customer-groups/update.ts
@@ -12,6 +12,7 @@ const group = await client.customerGroups.update('cg_UkLWZg9DAJ', {
name: 'VIP customers (Q1)',
customer_ids: ['cus_UkLWZg9DAJ'],
})
+
// endregion:example
export { group }
diff --git a/packages/admin-sdk/examples/customer-store-credits/list.ts b/packages/admin-sdk/examples/customer-store-credits/list.ts
index 4ab104cddb..a746111674 100644
--- a/packages/admin-sdk/examples/customer-store-credits/list.ts
+++ b/packages/admin-sdk/examples/customer-store-credits/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: storeCredits } = await client.customers.storeCredits.list('cus_UkLWZg9DAJ')
+
// endregion:example
export { storeCredits }
diff --git a/packages/admin-sdk/examples/customer-store-credits/update.ts b/packages/admin-sdk/examples/customer-store-credits/update.ts
index 4324f89a6c..4ade8f96b3 100644
--- a/packages/admin-sdk/examples/customer-store-credits/update.ts
+++ b/packages/admin-sdk/examples/customer-store-credits/update.ts
@@ -6,11 +6,10 @@ const client = createAdminClient({
})
// region:example
-const credit = await client.customers.storeCredits.update(
- 'cus_UkLWZg9DAJ',
- 'sc_UkLWZg9DAJ',
- { memo: 'Reissued for damaged shipment' },
-)
+const credit = await client.customers.storeCredits.update('cus_UkLWZg9DAJ', 'sc_UkLWZg9DAJ', {
+ memo: 'Reissued for damaged shipment',
+})
+
// endregion:example
export { credit }
diff --git a/packages/admin-sdk/examples/customers/bulk-add-tags.ts b/packages/admin-sdk/examples/customers/bulk-add-tags.ts
index 0bfb2e257d..fcc469274d 100644
--- a/packages/admin-sdk/examples/customers/bulk-add-tags.ts
+++ b/packages/admin-sdk/examples/customers/bulk-add-tags.ts
@@ -10,6 +10,7 @@ const result = await client.customers.bulkAddTags({
ids: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'],
tags: ['vip', 'newsletter'],
})
+
// endregion:example
export { result }
diff --git a/packages/admin-sdk/examples/customers/bulk-add-to-groups.ts b/packages/admin-sdk/examples/customers/bulk-add-to-groups.ts
index 092e73812d..7ffacd7cb6 100644
--- a/packages/admin-sdk/examples/customers/bulk-add-to-groups.ts
+++ b/packages/admin-sdk/examples/customers/bulk-add-to-groups.ts
@@ -10,6 +10,7 @@ const result = await client.customers.bulkAddToGroups({
ids: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'],
customer_group_ids: ['cg_UkLWZg9DAJ'],
})
+
// endregion:example
export { result }
diff --git a/packages/admin-sdk/examples/customers/bulk-remove-from-groups.ts b/packages/admin-sdk/examples/customers/bulk-remove-from-groups.ts
index d595b2d75f..e3461135c1 100644
--- a/packages/admin-sdk/examples/customers/bulk-remove-from-groups.ts
+++ b/packages/admin-sdk/examples/customers/bulk-remove-from-groups.ts
@@ -10,6 +10,7 @@ const result = await client.customers.bulkRemoveFromGroups({
ids: ['cus_UkLWZg9DAJ'],
customer_group_ids: ['cg_UkLWZg9DAJ'],
})
+
// endregion:example
export { result }
diff --git a/packages/admin-sdk/examples/customers/bulk-remove-tags.ts b/packages/admin-sdk/examples/customers/bulk-remove-tags.ts
index 97870dd821..a157b78429 100644
--- a/packages/admin-sdk/examples/customers/bulk-remove-tags.ts
+++ b/packages/admin-sdk/examples/customers/bulk-remove-tags.ts
@@ -10,6 +10,7 @@ const result = await client.customers.bulkRemoveTags({
ids: ['cus_UkLWZg9DAJ'],
tags: ['vip'],
})
+
// endregion:example
export { result }
diff --git a/packages/admin-sdk/examples/customers/create.ts b/packages/admin-sdk/examples/customers/create.ts
index ac48d0083c..7e1579318e 100644
--- a/packages/admin-sdk/examples/customers/create.ts
+++ b/packages/admin-sdk/examples/customers/create.ts
@@ -14,6 +14,7 @@ const customer = await client.customers.create({
tags: ['wholesale'],
accepts_email_marketing: true,
})
+
// endregion:example
export { customer }
diff --git a/packages/admin-sdk/examples/customers/get.ts b/packages/admin-sdk/examples/customers/get.ts
index 53b2a836e3..905aa871bf 100644
--- a/packages/admin-sdk/examples/customers/get.ts
+++ b/packages/admin-sdk/examples/customers/get.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const customer = await client.customers.get('cus_UkLWZg9DAJ', {
expand: ['addresses', 'store_credits'],
})
+
// endregion:example
export { customer }
diff --git a/packages/admin-sdk/examples/customers/list.ts b/packages/admin-sdk/examples/customers/list.ts
index c08bb51aee..0c19a91ebc 100644
--- a/packages/admin-sdk/examples/customers/list.ts
+++ b/packages/admin-sdk/examples/customers/list.ts
@@ -11,6 +11,7 @@ const { data: customers } = await client.customers.list({
sort: '-created_at',
limit: 25,
})
+
// endregion:example
export { customers }
diff --git a/packages/admin-sdk/examples/customers/update.ts b/packages/admin-sdk/examples/customers/update.ts
index 8db6a9d54b..6e6b8a38ba 100644
--- a/packages/admin-sdk/examples/customers/update.ts
+++ b/packages/admin-sdk/examples/customers/update.ts
@@ -10,6 +10,7 @@ const customer = await client.customers.update('cus_UkLWZg9DAJ', {
first_name: 'Updated',
tags: ['wholesale', 'vip'],
})
+
// endregion:example
export { customer }
diff --git a/packages/admin-sdk/examples/exports/create.ts b/packages/admin-sdk/examples/exports/create.ts
index 5e49a55dc9..8b6bfe9d9a 100644
--- a/packages/admin-sdk/examples/exports/create.ts
+++ b/packages/admin-sdk/examples/exports/create.ts
@@ -8,8 +8,9 @@ const client = createAdminClient({
// region:example
const exp = await client.exports.create({
type: 'Spree::Exports::Products',
- search_params: { name_cont: 'shirt' }
+ search_params: { name_cont: 'shirt' },
})
+
// endregion:example
export { exp }
diff --git a/packages/admin-sdk/examples/exports/download.ts b/packages/admin-sdk/examples/exports/download.ts
index f578e37a61..00aad68aea 100644
--- a/packages/admin-sdk/examples/exports/download.ts
+++ b/packages/admin-sdk/examples/exports/download.ts
@@ -14,13 +14,13 @@ const exp = _exp as { download_url: string; filename: string }
// region:example
// Fetch with the Bearer token, then drive the browser download:
const res = await fetch(exp.download_url, {
- headers: { Authorization: `Bearer ${token}` }
+ 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
+ download: exp.filename,
})
a.click()
URL.revokeObjectURL(url)
diff --git a/packages/admin-sdk/examples/exports/get.ts b/packages/admin-sdk/examples/exports/get.ts
index f1839633a9..77dfdfd8db 100644
--- a/packages/admin-sdk/examples/exports/get.ts
+++ b/packages/admin-sdk/examples/exports/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const exp = await client.exports.get('exp_xxx')
+
// endregion:example
export { exp }
diff --git a/packages/admin-sdk/examples/exports/list.ts b/packages/admin-sdk/examples/exports/list.ts
index 102bd14c5e..9c7137dc0f 100644
--- a/packages/admin-sdk/examples/exports/list.ts
+++ b/packages/admin-sdk/examples/exports/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: exports } = await client.exports.list()
+
// endregion:example
export { exports }
diff --git a/packages/admin-sdk/examples/gift-card-batches/create.ts b/packages/admin-sdk/examples/gift-card-batches/create.ts
index cebf517b5a..5d418acf77 100644
--- a/packages/admin-sdk/examples/gift-card-batches/create.ts
+++ b/packages/admin-sdk/examples/gift-card-batches/create.ts
@@ -13,6 +13,7 @@ const batch = await client.giftCardBatches.create({
codes_count: 100,
expires_at: '2030-12-31',
})
+
// endregion:example
export { batch }
diff --git a/packages/admin-sdk/examples/gift-card-batches/get.ts b/packages/admin-sdk/examples/gift-card-batches/get.ts
index 13f612f233..22898ec0fe 100644
--- a/packages/admin-sdk/examples/gift-card-batches/get.ts
+++ b/packages/admin-sdk/examples/gift-card-batches/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const batch = await client.giftCardBatches.get('gcb_K3zr8x')
+
// endregion:example
export { batch }
diff --git a/packages/admin-sdk/examples/gift-card-batches/list.ts b/packages/admin-sdk/examples/gift-card-batches/list.ts
index ac190f7b6c..3dd077b143 100644
--- a/packages/admin-sdk/examples/gift-card-batches/list.ts
+++ b/packages/admin-sdk/examples/gift-card-batches/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: batches } = await client.giftCardBatches.list({ page: 1, limit: 25 })
+
// endregion:example
export { batches }
diff --git a/packages/admin-sdk/examples/gift-cards/create.ts b/packages/admin-sdk/examples/gift-cards/create.ts
index 913d66263e..75a737c25a 100644
--- a/packages/admin-sdk/examples/gift-cards/create.ts
+++ b/packages/admin-sdk/examples/gift-cards/create.ts
@@ -12,6 +12,7 @@ const giftCard = await client.giftCards.create({
expires_at: '2030-12-31',
user_id: 'cus_UkLWZg9DAJ',
})
+
// endregion:example
export { giftCard }
diff --git a/packages/admin-sdk/examples/gift-cards/get.ts b/packages/admin-sdk/examples/gift-cards/get.ts
index ba5c87141e..9c94f8f11e 100644
--- a/packages/admin-sdk/examples/gift-cards/get.ts
+++ b/packages/admin-sdk/examples/gift-cards/get.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const giftCard = await client.giftCards.get('gc_K3zr8x', {
expand: ['customer', 'created_by', 'orders'],
})
+
// endregion:example
export { giftCard }
diff --git a/packages/admin-sdk/examples/gift-cards/list.ts b/packages/admin-sdk/examples/gift-cards/list.ts
index dda37b10dd..8fc3b6049e 100644
--- a/packages/admin-sdk/examples/gift-cards/list.ts
+++ b/packages/admin-sdk/examples/gift-cards/list.ts
@@ -11,6 +11,7 @@ const { data: giftCards } = await client.giftCards.list({
limit: 25,
expand: ['customer', 'created_by'],
})
+
// endregion:example
export { giftCards }
diff --git a/packages/admin-sdk/examples/gift-cards/update.ts b/packages/admin-sdk/examples/gift-cards/update.ts
index 4699ec2641..e72db56547 100644
--- a/packages/admin-sdk/examples/gift-cards/update.ts
+++ b/packages/admin-sdk/examples/gift-cards/update.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const giftCard = await client.giftCards.update('gc_K3zr8x', {
amount: '75.00',
})
+
// endregion:example
export { giftCard }
diff --git a/packages/admin-sdk/examples/invitations/create.ts b/packages/admin-sdk/examples/invitations/create.ts
index d5955226ed..4371f4c048 100644
--- a/packages/admin-sdk/examples/invitations/create.ts
+++ b/packages/admin-sdk/examples/invitations/create.ts
@@ -8,8 +8,9 @@ const client = createAdminClient({
// region:example
const invitation = await client.invitations.create({
- role_id: 'role_xxx'
+ role_id: 'role_xxx',
})
+
// endregion:example
export { invitation }
diff --git a/packages/admin-sdk/examples/invitations/list.ts b/packages/admin-sdk/examples/invitations/list.ts
index 6041e86208..5238d8257c 100644
--- a/packages/admin-sdk/examples/invitations/list.ts
+++ b/packages/admin-sdk/examples/invitations/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: invitations } = await client.invitations.list()
+
// endregion:example
export { invitations }
diff --git a/packages/admin-sdk/examples/invitations/resend.ts b/packages/admin-sdk/examples/invitations/resend.ts
index cff0fa5c60..1cdd12e075 100644
--- a/packages/admin-sdk/examples/invitations/resend.ts
+++ b/packages/admin-sdk/examples/invitations/resend.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const invitation = await client.invitations.resend('inv_xxx')
+
// endregion:example
export { invitation }
diff --git a/packages/admin-sdk/examples/markets/get.ts b/packages/admin-sdk/examples/markets/get.ts
index cf52a66097..8b716cdc5a 100644
--- a/packages/admin-sdk/examples/markets/get.ts
+++ b/packages/admin-sdk/examples/markets/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const market = await client.markets.get('market_xxx')
+
// endregion:example
export { market }
diff --git a/packages/admin-sdk/examples/markets/list.ts b/packages/admin-sdk/examples/markets/list.ts
index 543144d47f..667b021c6d 100644
--- a/packages/admin-sdk/examples/markets/list.ts
+++ b/packages/admin-sdk/examples/markets/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: markets } = await client.markets.list()
+
// endregion:example
export { markets }
diff --git a/packages/admin-sdk/examples/me/get.ts b/packages/admin-sdk/examples/me/get.ts
index d65fc5b5bf..be79d149d2 100644
--- a/packages/admin-sdk/examples/me/get.ts
+++ b/packages/admin-sdk/examples/me/get.ts
@@ -7,9 +7,14 @@ const client = createAdminClient({
// region:example
const me = await client.me.get()
-if (me.permissions.some((r) => r.allow && r.actions.includes('manage') && r.subjects.includes('Spree::Product'))) {
+if (
+ me.permissions.some(
+ (r) => r.allow && r.actions.includes('manage') && r.subjects.includes('Spree::Product'),
+ )
+) {
// show "Create product" button
}
+
// endregion:example
export { me }
diff --git a/packages/admin-sdk/examples/option-types/get.ts b/packages/admin-sdk/examples/option-types/get.ts
index 15dc43c160..a8e0c529c9 100644
--- a/packages/admin-sdk/examples/option-types/get.ts
+++ b/packages/admin-sdk/examples/option-types/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const optionType = await client.optionTypes.get('ot_UkLWZg9DAJ')
+
// endregion:example
export { optionType }
diff --git a/packages/admin-sdk/examples/option-types/list.ts b/packages/admin-sdk/examples/option-types/list.ts
index b39597ec34..7f868fde2c 100644
--- a/packages/admin-sdk/examples/option-types/list.ts
+++ b/packages/admin-sdk/examples/option-types/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: optionTypes } = await client.optionTypes.list()
+
// endregion:example
export { optionTypes }
diff --git a/packages/admin-sdk/examples/order-fulfillments/cancel.ts b/packages/admin-sdk/examples/order-fulfillments/cancel.ts
index 86a6d78d8c..64ab09bf78 100644
--- a/packages/admin-sdk/examples/order-fulfillments/cancel.ts
+++ b/packages/admin-sdk/examples/order-fulfillments/cancel.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const fulfillment = await client.orders.fulfillments.cancel('or_UkLWZg9DAJ', 'ful_UkLWZg9DAJ')
+
// endregion:example
export { fulfillment }
diff --git a/packages/admin-sdk/examples/order-fulfillments/fulfill.ts b/packages/admin-sdk/examples/order-fulfillments/fulfill.ts
index 9c8d8266be..21039ca82f 100644
--- a/packages/admin-sdk/examples/order-fulfillments/fulfill.ts
+++ b/packages/admin-sdk/examples/order-fulfillments/fulfill.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const fulfillment = await client.orders.fulfillments.fulfill('or_UkLWZg9DAJ', 'ful_UkLWZg9DAJ')
+
// endregion:example
export { fulfillment }
diff --git a/packages/admin-sdk/examples/order-fulfillments/get.ts b/packages/admin-sdk/examples/order-fulfillments/get.ts
index bb872d9a4b..5b7f82d62a 100644
--- a/packages/admin-sdk/examples/order-fulfillments/get.ts
+++ b/packages/admin-sdk/examples/order-fulfillments/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const fulfillment = await client.orders.fulfillments.get('or_UkLWZg9DAJ', 'ful_UkLWZg9DAJ')
+
// endregion:example
export { fulfillment }
diff --git a/packages/admin-sdk/examples/order-fulfillments/list.ts b/packages/admin-sdk/examples/order-fulfillments/list.ts
index 85a94608ab..f122df3049 100644
--- a/packages/admin-sdk/examples/order-fulfillments/list.ts
+++ b/packages/admin-sdk/examples/order-fulfillments/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: fulfillments } = await client.orders.fulfillments.list('or_UkLWZg9DAJ')
+
// endregion:example
export { fulfillments }
diff --git a/packages/admin-sdk/examples/order-fulfillments/resume.ts b/packages/admin-sdk/examples/order-fulfillments/resume.ts
index 721e1c3af4..3b03bd1cfd 100644
--- a/packages/admin-sdk/examples/order-fulfillments/resume.ts
+++ b/packages/admin-sdk/examples/order-fulfillments/resume.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const fulfillment = await client.orders.fulfillments.resume('or_UkLWZg9DAJ', 'ful_UkLWZg9DAJ')
+
// endregion:example
export { fulfillment }
diff --git a/packages/admin-sdk/examples/order-fulfillments/update.ts b/packages/admin-sdk/examples/order-fulfillments/update.ts
index bf6122489a..eec947ff25 100644
--- a/packages/admin-sdk/examples/order-fulfillments/update.ts
+++ b/packages/admin-sdk/examples/order-fulfillments/update.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const fulfillment = await client.orders.fulfillments.update('or_UkLWZg9DAJ', 'ful_UkLWZg9DAJ', {
tracking: '1Z999AA10123456784',
})
+
// endregion:example
export { fulfillment }
diff --git a/packages/admin-sdk/examples/order-items/create.ts b/packages/admin-sdk/examples/order-items/create.ts
index ffc5920a68..6ab595125b 100644
--- a/packages/admin-sdk/examples/order-items/create.ts
+++ b/packages/admin-sdk/examples/order-items/create.ts
@@ -10,6 +10,7 @@ const item = await client.orders.items.create('or_UkLWZg9DAJ', {
variant_id: 'variant_k5nR8xLq',
quantity: 2,
})
+
// endregion:example
export { item }
diff --git a/packages/admin-sdk/examples/order-items/get.ts b/packages/admin-sdk/examples/order-items/get.ts
index 2cd6ed14d1..42d70b38d9 100644
--- a/packages/admin-sdk/examples/order-items/get.ts
+++ b/packages/admin-sdk/examples/order-items/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const item = await client.orders.items.get('or_UkLWZg9DAJ', 'li_UkLWZg9DAJ')
+
// endregion:example
export { item }
diff --git a/packages/admin-sdk/examples/order-items/list.ts b/packages/admin-sdk/examples/order-items/list.ts
index 282a26371a..6a5bfca627 100644
--- a/packages/admin-sdk/examples/order-items/list.ts
+++ b/packages/admin-sdk/examples/order-items/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: items } = await client.orders.items.list('or_UkLWZg9DAJ')
+
// endregion:example
export { items }
diff --git a/packages/admin-sdk/examples/order-items/update.ts b/packages/admin-sdk/examples/order-items/update.ts
index c2faec5e03..4bc061937a 100644
--- a/packages/admin-sdk/examples/order-items/update.ts
+++ b/packages/admin-sdk/examples/order-items/update.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const item = await client.orders.items.update('or_UkLWZg9DAJ', 'li_UkLWZg9DAJ', {
quantity: 5,
})
+
// endregion:example
export { item }
diff --git a/packages/admin-sdk/examples/order-payments/capture.ts b/packages/admin-sdk/examples/order-payments/capture.ts
index 0e629cd7c6..910df92e69 100644
--- a/packages/admin-sdk/examples/order-payments/capture.ts
+++ b/packages/admin-sdk/examples/order-payments/capture.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const payment = await client.orders.payments.capture('or_UkLWZg9DAJ', 'pay_UkLWZg9DAJ')
+
// endregion:example
export { payment }
diff --git a/packages/admin-sdk/examples/order-payments/get.ts b/packages/admin-sdk/examples/order-payments/get.ts
index e8fac7221d..8593d6002f 100644
--- a/packages/admin-sdk/examples/order-payments/get.ts
+++ b/packages/admin-sdk/examples/order-payments/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const payment = await client.orders.payments.get('or_UkLWZg9DAJ', 'pay_UkLWZg9DAJ')
+
// endregion:example
export { payment }
diff --git a/packages/admin-sdk/examples/order-payments/list.ts b/packages/admin-sdk/examples/order-payments/list.ts
index e37760d6f4..068b445e9b 100644
--- a/packages/admin-sdk/examples/order-payments/list.ts
+++ b/packages/admin-sdk/examples/order-payments/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: payments } = await client.orders.payments.list('or_UkLWZg9DAJ')
+
// endregion:example
export { payments }
diff --git a/packages/admin-sdk/examples/order-payments/void.ts b/packages/admin-sdk/examples/order-payments/void.ts
index b1841de917..2b9a82ca50 100644
--- a/packages/admin-sdk/examples/order-payments/void.ts
+++ b/packages/admin-sdk/examples/order-payments/void.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const payment = await client.orders.payments.void('or_UkLWZg9DAJ', 'pay_UkLWZg9DAJ')
+
// endregion:example
export { payment }
diff --git a/packages/admin-sdk/examples/order-refunds/list.ts b/packages/admin-sdk/examples/order-refunds/list.ts
index 753aa421da..7fd7bee445 100644
--- a/packages/admin-sdk/examples/order-refunds/list.ts
+++ b/packages/admin-sdk/examples/order-refunds/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: refunds } = await client.orders.refunds.list('or_UkLWZg9DAJ')
+
// endregion:example
export { refunds }
diff --git a/packages/admin-sdk/examples/orders/approve.ts b/packages/admin-sdk/examples/orders/approve.ts
index 6a2c2d5c6b..07f40ab365 100644
--- a/packages/admin-sdk/examples/orders/approve.ts
+++ b/packages/admin-sdk/examples/orders/approve.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const order = await client.orders.approve('or_UkLWZg9DAJ')
+
// endregion:example
export { order }
diff --git a/packages/admin-sdk/examples/orders/cancel.ts b/packages/admin-sdk/examples/orders/cancel.ts
index e52a60ca0d..910e55fea3 100644
--- a/packages/admin-sdk/examples/orders/cancel.ts
+++ b/packages/admin-sdk/examples/orders/cancel.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const order = await client.orders.cancel('or_UkLWZg9DAJ')
+
// endregion:example
export { order }
diff --git a/packages/admin-sdk/examples/orders/complete.ts b/packages/admin-sdk/examples/orders/complete.ts
index 4f95ee2a71..98fb5925b9 100644
--- a/packages/admin-sdk/examples/orders/complete.ts
+++ b/packages/admin-sdk/examples/orders/complete.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const order = await client.orders.complete('or_UkLWZg9DAJ', {
notify_customer: true,
})
+
// endregion:example
export { order }
diff --git a/packages/admin-sdk/examples/orders/get.ts b/packages/admin-sdk/examples/orders/get.ts
index 693508c0eb..b3ae18c384 100644
--- a/packages/admin-sdk/examples/orders/get.ts
+++ b/packages/admin-sdk/examples/orders/get.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const order = await client.orders.get('or_UkLWZg9DAJ', {
expand: ['items', 'fulfillments', 'payments', 'customer'],
})
+
// endregion:example
export { order }
diff --git a/packages/admin-sdk/examples/orders/list.ts b/packages/admin-sdk/examples/orders/list.ts
index 97b9a41944..41a756a76b 100644
--- a/packages/admin-sdk/examples/orders/list.ts
+++ b/packages/admin-sdk/examples/orders/list.ts
@@ -12,6 +12,7 @@ const { data: orders, meta } = await client.orders.list({
sort: '-completed_at',
limit: 25,
})
+
// endregion:example
-export { orders, meta }
+export { meta, orders }
diff --git a/packages/admin-sdk/examples/orders/resume.ts b/packages/admin-sdk/examples/orders/resume.ts
index 05ff74e5bf..a639cbc92d 100644
--- a/packages/admin-sdk/examples/orders/resume.ts
+++ b/packages/admin-sdk/examples/orders/resume.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const order = await client.orders.resume('or_UkLWZg9DAJ')
+
// endregion:example
export { order }
diff --git a/packages/admin-sdk/examples/payment-methods/get.ts b/packages/admin-sdk/examples/payment-methods/get.ts
index 160996fc69..1b0a18d940 100644
--- a/packages/admin-sdk/examples/payment-methods/get.ts
+++ b/packages/admin-sdk/examples/payment-methods/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const paymentMethod = await client.paymentMethods.get('pm_UkLWZg9DAJ')
+
// endregion:example
export { paymentMethod }
diff --git a/packages/admin-sdk/examples/payment-methods/list.ts b/packages/admin-sdk/examples/payment-methods/list.ts
index e143d50a0b..463313fe70 100644
--- a/packages/admin-sdk/examples/payment-methods/list.ts
+++ b/packages/admin-sdk/examples/payment-methods/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: paymentMethods } = await client.paymentMethods.list()
+
// endregion:example
export { paymentMethods }
diff --git a/packages/admin-sdk/examples/payment-methods/types.ts b/packages/admin-sdk/examples/payment-methods/types.ts
index c4b35ce71b..b18dd5f004 100644
--- a/packages/admin-sdk/examples/payment-methods/types.ts
+++ b/packages/admin-sdk/examples/payment-methods/types.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: types } = await client.paymentMethods.types()
+
// endregion:example
export { types }
diff --git a/packages/admin-sdk/examples/price-lists/activate.ts b/packages/admin-sdk/examples/price-lists/activate.ts
index 0e6e8adaf9..9e634f0d4e 100644
--- a/packages/admin-sdk/examples/price-lists/activate.ts
+++ b/packages/admin-sdk/examples/price-lists/activate.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const priceList = await client.priceLists.activate('pl_xxx')
+
// endregion:example
export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/create.ts b/packages/admin-sdk/examples/price-lists/create.ts
index 37bb8f2d08..160d0400ea 100644
--- a/packages/admin-sdk/examples/price-lists/create.ts
+++ b/packages/admin-sdk/examples/price-lists/create.ts
@@ -41,6 +41,7 @@ const priceList = await client.priceLists.create({
},
],
})
+
// endregion:example
export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/deactivate.ts b/packages/admin-sdk/examples/price-lists/deactivate.ts
index 368a60cf69..c7f4865da8 100644
--- a/packages/admin-sdk/examples/price-lists/deactivate.ts
+++ b/packages/admin-sdk/examples/price-lists/deactivate.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const priceList = await client.priceLists.deactivate('pl_xxx')
+
// endregion:example
export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/get.ts b/packages/admin-sdk/examples/price-lists/get.ts
index 89a25458fe..8da1f5a1fa 100644
--- a/packages/admin-sdk/examples/price-lists/get.ts
+++ b/packages/admin-sdk/examples/price-lists/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const priceList = await client.priceLists.get('pl_xxx')
+
// endregion:example
export { priceList }
diff --git a/packages/admin-sdk/examples/price-lists/list.ts b/packages/admin-sdk/examples/price-lists/list.ts
index 456edcef9e..1a9da7078f 100644
--- a/packages/admin-sdk/examples/price-lists/list.ts
+++ b/packages/admin-sdk/examples/price-lists/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: priceLists } = await client.priceLists.list()
+
// endregion:example
export { priceLists }
diff --git a/packages/admin-sdk/examples/price-lists/update.ts b/packages/admin-sdk/examples/price-lists/update.ts
index 6615395011..c04caa2780 100644
--- a/packages/admin-sdk/examples/price-lists/update.ts
+++ b/packages/admin-sdk/examples/price-lists/update.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const priceList = await client.priceLists.update('pl_xxx', {
name: 'Wholesale (Q3)',
})
+
// endregion:example
export { priceList }
diff --git a/packages/admin-sdk/examples/prices/bulk-destroy.ts b/packages/admin-sdk/examples/prices/bulk-destroy.ts
index a483587de3..1501687ea8 100644
--- a/packages/admin-sdk/examples/prices/bulk-destroy.ts
+++ b/packages/admin-sdk/examples/prices/bulk-destroy.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const { price_count } = await client.prices.bulkDestroy({
ids: ['price_xxx', 'price_yyy'],
})
+
// endregion:example
export { price_count }
diff --git a/packages/admin-sdk/examples/prices/bulk-upsert.ts b/packages/admin-sdk/examples/prices/bulk-upsert.ts
index f7c4705836..02b92a7b86 100644
--- a/packages/admin-sdk/examples/prices/bulk-upsert.ts
+++ b/packages/admin-sdk/examples/prices/bulk-upsert.ts
@@ -22,6 +22,7 @@ const { price_count } = await client.prices.bulkUpsert({
},
],
})
+
// endregion:example
export { price_count }
diff --git a/packages/admin-sdk/examples/prices/create.ts b/packages/admin-sdk/examples/prices/create.ts
index 579b217f3c..b40aef0472 100644
--- a/packages/admin-sdk/examples/prices/create.ts
+++ b/packages/admin-sdk/examples/prices/create.ts
@@ -11,6 +11,7 @@ const price = await client.prices.create({
currency: 'USD',
amount: '19.99',
})
+
// endregion:example
export { price }
diff --git a/packages/admin-sdk/examples/prices/get.ts b/packages/admin-sdk/examples/prices/get.ts
index c9451611d0..5b67fc7de4 100644
--- a/packages/admin-sdk/examples/prices/get.ts
+++ b/packages/admin-sdk/examples/prices/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const price = await client.prices.get('price_xxx')
+
// endregion:example
export { price }
diff --git a/packages/admin-sdk/examples/prices/list.ts b/packages/admin-sdk/examples/prices/list.ts
index 398ade816f..8819a9026e 100644
--- a/packages/admin-sdk/examples/prices/list.ts
+++ b/packages/admin-sdk/examples/prices/list.ts
@@ -11,6 +11,7 @@ const { data: prices } = await client.prices.list({
currency_eq: 'USD',
expand: ['variant'],
})
+
// endregion:example
export { prices }
diff --git a/packages/admin-sdk/examples/prices/update.ts b/packages/admin-sdk/examples/prices/update.ts
index 9150b35528..2215adec74 100644
--- a/packages/admin-sdk/examples/prices/update.ts
+++ b/packages/admin-sdk/examples/prices/update.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const price = await client.prices.update('price_xxx', {
amount: '12.34',
})
+
// endregion:example
export { price }
diff --git a/packages/admin-sdk/examples/product-custom-fields/create.ts b/packages/admin-sdk/examples/product-custom-fields/create.ts
index 2d054dcc16..1cde549360 100644
--- a/packages/admin-sdk/examples/product-custom-fields/create.ts
+++ b/packages/admin-sdk/examples/product-custom-fields/create.ts
@@ -10,6 +10,7 @@ const customField = await client.products.customFields.create('prod_UkLWZg9DAJ',
custom_field_definition_id: 'cfdef_AbC123XyZ',
value: 'wool',
})
+
// endregion:example
export { customField }
diff --git a/packages/admin-sdk/examples/product-custom-fields/list.ts b/packages/admin-sdk/examples/product-custom-fields/list.ts
index 681eaf8c9e..456d2db3d1 100644
--- a/packages/admin-sdk/examples/product-custom-fields/list.ts
+++ b/packages/admin-sdk/examples/product-custom-fields/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: customFields } = await client.products.customFields.list('prod_UkLWZg9DAJ')
+
// endregion:example
export { customFields }
diff --git a/packages/admin-sdk/examples/products/get.ts b/packages/admin-sdk/examples/products/get.ts
index 6ed0487a19..81651160df 100644
--- a/packages/admin-sdk/examples/products/get.ts
+++ b/packages/admin-sdk/examples/products/get.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const product = await client.products.get('prod_86Rf07xd4z', {
expand: ['variants', 'option_types'],
})
+
// endregion:example
export { product }
diff --git a/packages/admin-sdk/examples/products/list.ts b/packages/admin-sdk/examples/products/list.ts
index c2835890c6..24af03afe5 100644
--- a/packages/admin-sdk/examples/products/list.ts
+++ b/packages/admin-sdk/examples/products/list.ts
@@ -12,6 +12,7 @@ const { data: products } = await client.products.list({
sort: '-created_at',
limit: 25,
})
+
// endregion:example
export { products }
diff --git a/packages/admin-sdk/examples/products/update.ts b/packages/admin-sdk/examples/products/update.ts
index 31360a2301..c961e07aec 100644
--- a/packages/admin-sdk/examples/products/update.ts
+++ b/packages/admin-sdk/examples/products/update.ts
@@ -11,6 +11,7 @@ const product = await client.products.update('prod_86Rf07xd4z', {
status: 'active',
tags: ['eco', 'sale'],
})
+
// endregion:example
export { product }
diff --git a/packages/admin-sdk/examples/promotion-actions/create.ts b/packages/admin-sdk/examples/promotion-actions/create.ts
index 5782b1d37a..fb4491832f 100644
--- a/packages/admin-sdk/examples/promotion-actions/create.ts
+++ b/packages/admin-sdk/examples/promotion-actions/create.ts
@@ -9,6 +9,7 @@ const client = createAdminClient({
const action = await client.promotions.actions.create('promo_UkLWZg9DAJ', {
type: 'free_shipping',
})
+
// endregion:example
export { action }
diff --git a/packages/admin-sdk/examples/promotion-actions/list.ts b/packages/admin-sdk/examples/promotion-actions/list.ts
index b982c860a3..a115729252 100644
--- a/packages/admin-sdk/examples/promotion-actions/list.ts
+++ b/packages/admin-sdk/examples/promotion-actions/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: actions } = await client.promotions.actions.list('promo_UkLWZg9DAJ')
+
// endregion:example
export { actions }
diff --git a/packages/admin-sdk/examples/promotion-rules/create.ts b/packages/admin-sdk/examples/promotion-rules/create.ts
index 8bdfbb018c..347648b377 100644
--- a/packages/admin-sdk/examples/promotion-rules/create.ts
+++ b/packages/admin-sdk/examples/promotion-rules/create.ts
@@ -10,6 +10,7 @@ const rule = await client.promotions.rules.create('promo_UkLWZg9DAJ', {
type: 'currency',
preferences: { currency: 'EUR' },
})
+
// endregion:example
export { rule }
diff --git a/packages/admin-sdk/examples/promotion-rules/list.ts b/packages/admin-sdk/examples/promotion-rules/list.ts
index 3e18b8bc34..f2e973c026 100644
--- a/packages/admin-sdk/examples/promotion-rules/list.ts
+++ b/packages/admin-sdk/examples/promotion-rules/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: rules } = await client.promotions.rules.list('promo_UkLWZg9DAJ')
+
// endregion:example
export { rules }
diff --git a/packages/admin-sdk/examples/promotions/action-types.ts b/packages/admin-sdk/examples/promotions/action-types.ts
index 1ce8980f3b..490cdc52ad 100644
--- a/packages/admin-sdk/examples/promotions/action-types.ts
+++ b/packages/admin-sdk/examples/promotions/action-types.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: actionTypes } = await client.promotionActions.types()
+
// endregion:example
export { actionTypes }
diff --git a/packages/admin-sdk/examples/promotions/create.ts b/packages/admin-sdk/examples/promotions/create.ts
index dc97260394..6579f1a6b7 100644
--- a/packages/admin-sdk/examples/promotions/create.ts
+++ b/packages/admin-sdk/examples/promotions/create.ts
@@ -48,7 +48,8 @@ const blackFriday = await client.promotions.create({
{ type: 'free_shipping' },
],
})
+
// endregion:example
// Suppress unused-binding warnings — these are display-only example values.
-export { promotion, blackFriday }
+export { blackFriday, promotion }
diff --git a/packages/admin-sdk/examples/promotions/list.ts b/packages/admin-sdk/examples/promotions/list.ts
index 337773d938..3fcf7ff4c8 100644
--- a/packages/admin-sdk/examples/promotions/list.ts
+++ b/packages/admin-sdk/examples/promotions/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: promotions } = await client.promotions.list()
+
// endregion:example
export { promotions }
diff --git a/packages/admin-sdk/examples/promotions/rule-types.ts b/packages/admin-sdk/examples/promotions/rule-types.ts
index 2bb13544dd..ad5d5b7a9c 100644
--- a/packages/admin-sdk/examples/promotions/rule-types.ts
+++ b/packages/admin-sdk/examples/promotions/rule-types.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: ruleTypes } = await client.promotionRules.types()
+
// endregion:example
export { ruleTypes }
diff --git a/packages/admin-sdk/examples/roles/list.ts b/packages/admin-sdk/examples/roles/list.ts
index 6b5715ecd4..52121a5e7f 100644
--- a/packages/admin-sdk/examples/roles/list.ts
+++ b/packages/admin-sdk/examples/roles/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: roles } = await client.roles.list()
+
// endregion:example
export { roles }
diff --git a/packages/admin-sdk/examples/stock-locations/get.ts b/packages/admin-sdk/examples/stock-locations/get.ts
index d38524c059..0a49aba5bc 100644
--- a/packages/admin-sdk/examples/stock-locations/get.ts
+++ b/packages/admin-sdk/examples/stock-locations/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const stockLocation = await client.stockLocations.get('sloc_UkLWZg9DAJ')
+
// endregion:example
export { stockLocation }
diff --git a/packages/admin-sdk/examples/stock-locations/list.ts b/packages/admin-sdk/examples/stock-locations/list.ts
index ae16429900..349ee088b9 100644
--- a/packages/admin-sdk/examples/stock-locations/list.ts
+++ b/packages/admin-sdk/examples/stock-locations/list.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const { data: stockLocations } = await client.stockLocations.list()
+
// endregion:example
export { stockLocations }
diff --git a/packages/admin-sdk/examples/stock-locations/update.ts b/packages/admin-sdk/examples/stock-locations/update.ts
index a1f33113d2..0a5cfa8df7 100644
--- a/packages/admin-sdk/examples/stock-locations/update.ts
+++ b/packages/admin-sdk/examples/stock-locations/update.ts
@@ -11,6 +11,7 @@ const stockLocation = await client.stockLocations.update('sloc_UkLWZg9DAJ', {
pickup_ready_in_minutes: 45,
pickup_instructions: 'Enter through the back door, ring the bell.',
})
+
// endregion:example
export { stockLocation }
diff --git a/packages/admin-sdk/examples/store/get.ts b/packages/admin-sdk/examples/store/get.ts
index 0333b9e404..072a265b4e 100644
--- a/packages/admin-sdk/examples/store/get.ts
+++ b/packages/admin-sdk/examples/store/get.ts
@@ -7,6 +7,7 @@ const client = createAdminClient({
// region:example
const store = await client.store.get()
+
// endregion:example
export { store }
diff --git a/packages/admin-sdk/examples/store/update.ts b/packages/admin-sdk/examples/store/update.ts
index bdc644a9c0..8a97fd282a 100644
--- a/packages/admin-sdk/examples/store/update.ts
+++ b/packages/admin-sdk/examples/store/update.ts
@@ -7,8 +7,9 @@ const client = createAdminClient({
// region:example
const store = await client.store.update({
- name: 'My Store'
+ name: 'My Store',
})
+
// endregion:example
export { store }
diff --git a/packages/admin-sdk/examples/tags/list.ts b/packages/admin-sdk/examples/tags/list.ts
index 29da535843..9be0ed23af 100644
--- a/packages/admin-sdk/examples/tags/list.ts
+++ b/packages/admin-sdk/examples/tags/list.ts
@@ -10,6 +10,7 @@ const { data: tags } = await client.tags.list({
taggable_type: 'Spree::User',
q: 'vip',
})
+
// endregion:example
export { tags }
diff --git a/packages/admin-sdk/src/types/generated/Seller.ts b/packages/admin-sdk/src/types/generated/Seller.ts
index 8f1bb6f3b5..0d72e497ac 100644
--- a/packages/admin-sdk/src/types/generated/Seller.ts
+++ b/packages/admin-sdk/src/types/generated/Seller.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 9ea0fa57629e2cfbc989efe587510dc2
+// Typelizer digest 1131a5f9f219ca1e88ba4e34354f4d98
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {Address} from '@/types'
@@ -30,6 +30,8 @@ interface Seller {
users_count: number;
onboarding_progress: { done: number; total: number; percentage: number };
onboarding_complete: boolean;
+ legal_name: string | null;
+ registration_number: string | null;
billing_address?: Address;
returns_address?: Address;
}
diff --git a/packages/dashboard-core/src/api-client.ts b/packages/dashboard-core/src/api-client.ts
index ee32bce9f2..80d0173c8b 100644
--- a/packages/dashboard-core/src/api-client.ts
+++ b/packages/dashboard-core/src/api-client.ts
@@ -76,6 +76,20 @@ export interface PanelApiClient {
* it: a location holds stock levels and is named on historical
* fulfillments, so they retire one by deactivating it.
*/
+ /**
+ * Exchanges blob metadata for a presigned upload URL.
+ *
+ * Registered rather than imported for the same reason as everything else
+ * here: the shared upload field would otherwise work only in the
+ * operator's panel, and a seller uploading an onboarding document would
+ * get a 401 from an API they hold no key for.
+ */
+ createDirectUpload?(params: {
+ blob: { filename: string; byte_size: number; checksum: string; content_type: string }
+ }): Promise<{
+ direct_upload: { url: string; headers: Record<string, string> }
+ signed_id: string
+ }>
stockLocations?: {
list(params?: Record<string, unknown>): Promise<{ data: PanelStockLocation[]; meta?: unknown }>
get(id: string): Promise<PanelStockLocation>
diff --git a/packages/dashboard-core/src/hooks/use-direct-upload.ts b/packages/dashboard-core/src/hooks/use-direct-upload.ts
index 5be8e1aa93..aaff6b358a 100644
--- a/packages/dashboard-core/src/hooks/use-direct-upload.ts
+++ b/packages/dashboard-core/src/hooks/use-direct-upload.ts
@@ -1,6 +1,6 @@
import { useMutation } from '@tanstack/react-query'
import SparkMD5 from 'spark-md5'
-import { adminClient } from '../client'
+import { getApiClient } from '../api-client'
function computeMD5Checksum(file: File): Promise<string> {
return new Promise((resolve, reject) => {
@@ -62,7 +62,10 @@ export function useDirectUpload() {
signed_id: string
}
try {
- response = await adminClient.directUploads.create({
+ const presign = getApiClient().createDirectUpload
+ if (!presign) throw new Error('This panel cannot upload files.')
+
+ response = await presign({
blob: {
filename: file.name,
byte_size: file.size,
diff --git a/packages/dashboard/src/api-client-setup.ts b/packages/dashboard/src/api-client-setup.ts
index 82b6108178..311443a85c 100644
--- a/packages/dashboard/src/api-client-setup.ts
+++ b/packages/dashboard/src/api-client-setup.ts
@@ -19,6 +19,7 @@ setApiClient({
return { rules: response.permissions, keys: response.permission_keys ?? [] }
},
listCountries: () => adminClient.countries.list({ expand: ['states'] }),
+ createDirectUpload: (params) => adminClient.directUploads.create(params),
// Backs the shared stock-locations page, which both panels render.
stockLocations: {
list: (params) => adminClient.stockLocations.list(params),
diff --git a/packages/docs/scripts/build.js b/packages/docs/scripts/build.js
index 061dab5364..31a9180120 100644
--- a/packages/docs/scripts/build.js
+++ b/packages/docs/scripts/build.js
@@ -7,25 +7,19 @@
* - Outputs clean .md files to dist/
*/
-import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, statSync } from 'fs'
-import { join, dirname, relative, resolve } from 'path'
-import { convertContent, resolveImports, extractFrontmatter, rewriteLinks } from './convert.js'
+import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'fs'
+import { dirname, join, relative, resolve } from 'path'
+import { convertContent, extractFrontmatter, resolveImports, rewriteLinks } from './convert.js'
const ROOT = resolve(import.meta.dirname, '..', '..', '..')
const DOCS_DIR = join(ROOT, 'docs')
const DIST_DIR = resolve(import.meta.dirname, '..', 'dist')
// Directories to include in the output
-const INCLUDE_DIRS = [
- 'developer',
- 'api-reference',
- 'integrations',
-]
+const INCLUDE_DIRS = ['developer', 'api-reference', 'integrations']
// Paths to exclude (relative to DOCS_DIR)
-const EXCLUDE_PATHS = [
- 'developer/storefront/rails',
-]
+const EXCLUDE_PATHS = ['developer/storefront/rails']
// ---------------------------------------------------------------------------
// Snippet resolution (uses filesystem — not in convert.js)
@@ -54,7 +48,7 @@ function resolveSnippet(importPath) {
// ---------------------------------------------------------------------------
function processFile(filePath) {
- let content = readFileSync(filePath, 'utf-8')
+ const content = readFileSync(filePath, 'utf-8')
const { frontmatter, body } = extractFrontmatter(content)
const fileRelDir = dirname(relative(DOCS_DIR, filePath))
@@ -117,9 +111,7 @@ for (const dir of INCLUDE_DIRS) {
// Copy OpenAPI specs
// ---------------------------------------------------------------------------
-const OPENAPI_FILES = [
- 'api-reference/store.yaml',
-]
+const OPENAPI_FILES = ['api-reference/store.yaml']
for (const file of OPENAPI_FILES) {
const src = join(DOCS_DIR, file)
diff --git a/packages/docs/scripts/convert.js b/packages/docs/scripts/convert.js
index b12ec3dd37..0f1bf438ad 100644
--- a/packages/docs/scripts/convert.js
+++ b/packages/docs/scripts/convert.js
@@ -3,52 +3,52 @@
* Separated from build.js for testability.
*/
-import { relative } from "path";
+import { relative } from 'path'
// ---------------------------------------------------------------------------
// Callout mapping
// ---------------------------------------------------------------------------
const CALLOUT_MAP = {
- Info: "INFO",
- Warning: "WARNING",
- Tip: "TIP",
- Note: "NOTE",
- Hint: "HINT",
-};
+ Info: 'INFO',
+ Warning: 'WARNING',
+ Tip: 'TIP',
+ Note: 'NOTE',
+ Hint: 'HINT',
+}
// ---------------------------------------------------------------------------
// Import resolution
// ---------------------------------------------------------------------------
-export function resolveImports(content, snippetResolver = () => "") {
+export function resolveImports(content, snippetResolver = () => '') {
// Collect import mappings: import Name from '/snippets/...'
- const importMap = new Map();
- const importRegex = /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?\s*$/gm;
- let match;
-
- while ((match = importRegex.exec(content)) !== null) {
- const [, componentName, importPath] = match;
+ const importMap = new Map()
+ const importRegex = /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?\s*$/gm
+ // Assignment lifted out of the condition: `while ((m = re.exec(s)))` is the
+ // classic form, but it reads as a comparison typo and the linter rejects it.
+ let match = importRegex.exec(content)
+
+ while (match !== null) {
+ const [, componentName, importPath] = match
// Only resolve snippet imports (from /snippets/ or relative .mdx)
- if (importPath.includes("/snippets/") || importPath.endsWith(".mdx")) {
- importMap.set(componentName, importPath);
+ if (importPath.includes('/snippets/') || importPath.endsWith('.mdx')) {
+ importMap.set(componentName, importPath)
}
+ match = importRegex.exec(content)
}
// Remove all import lines
- content = content.replace(
- /^import\s+\w+\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm,
- "",
- );
+ content = content.replace(/^import\s+\w+\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm, '')
// Replace <ComponentName /> self-closing tags with inlined snippet content
for (const [name, path] of importMap) {
- const selfClosingRegex = new RegExp(`<${name}\\s*/>`, "g");
- const snippetContent = snippetResolver(path);
- content = content.replace(selfClosingRegex, snippetContent);
+ const selfClosingRegex = new RegExp(`<${name}\\s*/>`, 'g')
+ const snippetContent = snippetResolver(path)
+ content = content.replace(selfClosingRegex, snippetContent)
}
- return content;
+ return content
}
// ---------------------------------------------------------------------------
@@ -57,23 +57,20 @@ export function resolveImports(content, snippetResolver = () => "") {
export function convertContent(content) {
// Protect code blocks from conversion
- const codeBlocks = [];
+ const codeBlocks = []
content = content.replace(/(```[\s\S]*?```|`[^`\n]+`)/g, (match) => {
- const index = codeBlocks.length;
- codeBlocks.push(match);
- return `__CODE_BLOCK_${index}__`;
- });
+ const index = codeBlocks.length
+ codeBlocks.push(match)
+ return `__CODE_BLOCK_${index}__`
+ })
// --- Callout components → GitHub-style blockquote alerts ---
for (const [component, label] of Object.entries(CALLOUT_MAP)) {
- const regex = new RegExp(
- `<${component}>\\s*([\\s\\S]*?)\\s*</${component}>`,
- "gi",
- );
+ const regex = new RegExp(`<${component}>\\s*([\\s\\S]*?)\\s*</${component}>`, 'gi')
content = content.replace(regex, (_, inner) => {
- const lines = inner.trim().split("\n");
- return `> **${label}:** ${lines.join("\n> ")}`;
- });
+ const lines = inner.trim().split('\n')
+ return `> **${label}:** ${lines.join('\n> ')}`
+ })
}
// --- Tabs → Sections with headers ---
@@ -81,133 +78,118 @@ export function convertContent(content) {
return inner.replace(
/<Tab\s+title="([^"]*)">\s*([\s\S]*?)\s*<\/Tab>/gi,
(_, title, tabContent) => {
- return `**${title}:**\n\n${tabContent.trim()}\n`;
+ return `**${title}:**\n\n${tabContent.trim()}\n`
},
- );
- });
+ )
+ })
// --- Steps → Numbered list ---
- let stepCounter = 0;
- content = content.replace(
- /<Steps>\s*([\s\S]*?)\s*<\/Steps>/gi,
- (_, inner) => {
- stepCounter = 0;
- return inner.replace(
- /<Step\s+title="([^"]*)">\s*([\s\S]*?)\s*<\/Step>/gi,
- (_, title, stepContent) => {
- stepCounter++;
- return `**Step ${stepCounter}: ${title}**\n\n${stepContent.trim()}\n`;
- },
- );
- },
- );
+ let stepCounter = 0
+ content = content.replace(/<Steps>\s*([\s\S]*?)\s*<\/Steps>/gi, (_, inner) => {
+ stepCounter = 0
+ return inner.replace(
+ /<Step\s+title="([^"]*)">\s*([\s\S]*?)\s*<\/Step>/gi,
+ (_, title, stepContent) => {
+ stepCounter++
+ return `**Step ${stepCounter}: ${title}**\n\n${stepContent.trim()}\n`
+ },
+ )
+ })
// --- CodeGroup → Just keep the code blocks inside ---
- content = content.replace(/<\/?CodeGroup>/gi, "");
+ content = content.replace(/<\/?CodeGroup>/gi, '')
// --- Accordion/AccordionGroup → Details/summary ---
content = content.replace(
/<AccordionGroup>\s*([\s\S]*?)\s*<\/AccordionGroup>/gi,
(_, inner) => inner,
- );
+ )
content = content.replace(
/<Accordion\s+title="([^"]*)">\s*([\s\S]*?)\s*<\/Accordion>/gi,
(_, title, inner) => {
- return `<details>\n<summary>${title}</summary>\n\n${inner.trim()}\n\n</details>\n`;
+ return `<details>\n<summary>${title}</summary>\n\n${inner.trim()}\n\n</details>\n`
},
- );
+ )
// --- Card/CardGroup → Bold title + description ---
- content = content.replace(/<\/?CardGroup[^>]*>/gi, "");
- content = content.replace(
- /<Card\s+([^>]*)>([\s\S]*?)<\/Card>/gi,
- (_, attrs, inner) => {
- const titleMatch = attrs.match(/title="([^"]*)"/);
- const hrefMatch = attrs.match(/href="([^"]*)"/);
- const title = titleMatch ? titleMatch[1] : "";
- const href = hrefMatch ? hrefMatch[1] : "";
- const titleText = href ? `[${title}](${href})` : `**${title}**`;
- const body = inner.trim();
- return body ? `- ${titleText} — ${body}` : `- ${titleText}`;
- },
- );
+ content = content.replace(/<\/?CardGroup[^>]*>/gi, '')
+ content = content.replace(/<Card\s+([^>]*)>([\s\S]*?)<\/Card>/gi, (_, attrs, inner) => {
+ const titleMatch = attrs.match(/title="([^"]*)"/)
+ const hrefMatch = attrs.match(/href="([^"]*)"/)
+ const title = titleMatch ? titleMatch[1] : ''
+ const href = hrefMatch ? hrefMatch[1] : ''
+ const titleText = href ? `[${title}](${href})` : `**${title}**`
+ const body = inner.trim()
+ return body ? `- ${titleText} — ${body}` : `- ${titleText}`
+ })
// Self-closing cards
content = content.replace(/<Card\s+([\s\S]*?)\/>/gi, (_, attrs) => {
- const titleMatch = attrs.match(/title="([^"]*)"/);
- const hrefMatch = attrs.match(/href="([^"]*)"/);
- const title = titleMatch ? titleMatch[1] : "";
- const href = hrefMatch ? hrefMatch[1] : "";
- return href ? `- [${title}](${href})` : `- **${title}**`;
- });
+ const titleMatch = attrs.match(/title="([^"]*)"/)
+ const hrefMatch = attrs.match(/href="([^"]*)"/)
+ const title = titleMatch ? titleMatch[1] : ''
+ const href = hrefMatch ? hrefMatch[1] : ''
+ return href ? `- [${title}](${href})` : `- **${title}**`
+ })
// --- Frame → Just keep the content (strip the wrapper) ---
- content = content.replace(
- /<Frame[^>]*>\s*([\s\S]*?)\s*<\/Frame>/gi,
- (_, inner) => inner.trim(),
- );
+ content = content.replace(/<Frame[^>]*>\s*([\s\S]*?)\s*<\/Frame>/gi, (_, inner) => inner.trim())
// --- Expandable → Details/summary ---
content = content.replace(
/<Expandable\s+title="([^"]*)">\s*([\s\S]*?)\s*<\/Expandable>/gi,
(_, title, inner) => {
- return `<details>\n<summary>${title}</summary>\n\n${inner.trim()}\n\n</details>\n`;
+ return `<details>\n<summary>${title}</summary>\n\n${inner.trim()}\n\n</details>\n`
},
- );
+ )
// --- ResponseField → Bold field name with type ---
content = content.replace(
/<ResponseField\s+name="([^"]*)"\s+type="([^"]*)">\s*([\s\S]*?)\s*<\/ResponseField>/gi,
(_, name, type, desc) => {
- return `- **\`${name}\`** (\`${type}\`) — ${desc.trim()}`;
+ return `- **\`${name}\`** (\`${type}\`) — ${desc.trim()}`
},
- );
+ )
// --- ParamField → Bold param name with type ---
content = content.replace(
/<ParamField\s+([^>]*)>\s*([\s\S]*?)\s*<\/ParamField>/gi,
(_, attrs, desc) => {
- const nameMatch = attrs.match(/(?:name|path|query|body)="([^"]*)"/);
- const typeMatch = attrs.match(/type="([^"]*)"/);
- const name = nameMatch ? nameMatch[1] : "";
- const type = typeMatch ? ` (\`${typeMatch[1]}\`)` : "";
- return `- **\`${name}\`**${type} — ${desc.trim()}`;
+ const nameMatch = attrs.match(/(?:name|path|query|body)="([^"]*)"/)
+ const typeMatch = attrs.match(/type="([^"]*)"/)
+ const name = nameMatch ? nameMatch[1] : ''
+ const type = typeMatch ? ` (\`${typeMatch[1]}\`)` : ''
+ return `- **\`${name}\`**${type} — ${desc.trim()}`
},
- );
+ )
// --- Icon → just remove ---
- content = content.replace(/<Icon\s[^>]*\/>/gi, "");
- content = content.replace(/<Icon\s[^>]*>[^<]*<\/Icon>/gi, "");
+ content = content.replace(/<Icon\s[^>]*\/>/gi, '')
+ content = content.replace(/<Icon\s[^>]*>[^<]*<\/Icon>/gi, '')
// --- CopyCommand → code block ---
- content = content.replace(
- /<CopyCommand\s+command="([^"]*)"[^>]*\/>/gi,
- (_, cmd) => {
- return "```bash\n" + cmd + "\n```";
- },
- );
+ content = content.replace(/<CopyCommand\s+command="([^"]*)"[^>]*\/>/gi, (_, cmd) => {
+ return '```bash\n' + cmd + '\n```'
+ })
// --- Columns → just keep content ---
- content = content.replace(/<\/?Columns[^>]*>/gi, "");
+ content = content.replace(/<\/?Columns[^>]*>/gi, '')
// --- Any remaining self-closing custom components → remove ---
- content = content.replace(/<[A-Z]\w*\s[^>]*\/>/g, "");
+ content = content.replace(/<[A-Z]\w*\s[^>]*\/>/g, '')
// --- Any remaining paired custom components → keep inner content ---
content = content.replace(
/<([A-Z]\w*)(?:\s[^>]*)?>[\s]*([\s\S]*?)[\s]*<\/\1>/g,
(_, _tag, inner) => inner.trim(),
- );
+ )
// --- Clean up: remove excessive blank lines ---
- content = content.replace(/\n{4,}/g, "\n\n\n");
+ content = content.replace(/\n{4,}/g, '\n\n\n')
// --- Restore code blocks ---
- content = content.replace(
- /__CODE_BLOCK_(\d+)__/g,
- (_, index) => codeBlocks[parseInt(index)],
- );
+ content = content.replace(/__CODE_BLOCK_(\d+)__/g, (_, index) => codeBlocks[parseInt(index)])
- return content;
+ return content
}
// ---------------------------------------------------------------------------
@@ -215,9 +197,9 @@ export function convertContent(content) {
// ---------------------------------------------------------------------------
export function extractFrontmatter(content) {
- const match = content.match(/^---\n([\s\S]*?)\n---\n/);
- if (!match) return { frontmatter: null, body: content };
- return { frontmatter: match[0], body: content.slice(match[0].length) };
+ const match = content.match(/^---\n([\s\S]*?)\n---\n/)
+ if (!match) return { frontmatter: null, body: content }
+ return { frontmatter: match[0], body: content.slice(match[0].length) }
}
// ---------------------------------------------------------------------------
@@ -227,12 +209,12 @@ export function extractFrontmatter(content) {
export function rewriteLinks(content, fileRelDir) {
return content.replace(
/\[([^\]]*)\]\(\/(developer|api-reference|integrations)(\/[^)]*)\)/g,
- (match, text, prefix, rest) => {
- const [pathPart, anchor] = rest.split("#", 2);
- const targetPath = prefix + pathPart;
- const relPath = relative(fileRelDir, targetPath) || ".";
- const suffix = anchor ? `#${anchor}` : "";
- return `[${text}](${relPath}.md${suffix})`;
+ (_match, text, prefix, rest) => {
+ const [pathPart, anchor] = rest.split('#', 2)
+ const targetPath = prefix + pathPart
+ const relPath = relative(fileRelDir, targetPath) || '.'
+ const suffix = anchor ? `#${anchor}` : ''
+ return `[${text}](${relPath}.md${suffix})`
},
- );
+ )
}
diff --git a/packages/docs/tests/convert.test.js b/packages/docs/tests/convert.test.js
index 4a90ba13d3..aff993a4a1 100644
--- a/packages/docs/tests/convert.test.js
+++ b/packages/docs/tests/convert.test.js
@@ -1,5 +1,10 @@
-import { describe, it, expect } from 'vitest'
-import { convertContent, resolveImports, extractFrontmatter, rewriteLinks } from '../scripts/convert.js'
+import { describe, expect, it } from 'vitest'
+import {
+ convertContent,
+ extractFrontmatter,
+ resolveImports,
+ rewriteLinks,
+} from '../scripts/convert.js'
// ---------------------------------------------------------------------------
// extractFrontmatter
@@ -168,7 +173,8 @@ describe('convertContent — accordion', () => {
describe('convertContent — cards', () => {
it('converts Card with title and href to link', () => {
- const input = '<Card title="Products" href="/developer/core-concepts/products">Product docs</Card>'
+ const input =
+ '<Card title="Products" href="/developer/core-concepts/products">Product docs</Card>'
const result = convertContent(input)
expect(result).toContain('- [Products](/developer/core-concepts/products) — Product docs')
})
diff --git a/packages/sdk/examples/auth/login.ts b/packages/sdk/examples/auth/login.ts
index b27b72744d..4886008edd 100644
--- a/packages/sdk/examples/auth/login.ts
+++ b/packages/sdk/examples/auth/login.ts
@@ -10,6 +10,7 @@ const auth = await client.auth.login({
password: 'password123',
})
+
// endregion:example
export { auth }
diff --git a/packages/sdk/examples/auth/refresh.ts b/packages/sdk/examples/auth/refresh.ts
index e71e8d411f..dd02eac99f 100644
--- a/packages/sdk/examples/auth/refresh.ts
+++ b/packages/sdk/examples/auth/refresh.ts
@@ -9,6 +9,7 @@ const client = createClient({
const auth = await client.auth.refresh({
refresh_token: 'rt_xxx',
})
+
// endregion:example
export { auth }
diff --git a/packages/sdk/examples/carts/associate.ts b/packages/sdk/examples/carts/associate.ts
index 74511fee99..8c23d06192 100644
--- a/packages/sdk/examples/carts/associate.ts
+++ b/packages/sdk/examples/carts/associate.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.associate('cart_abc123', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/complete.ts b/packages/sdk/examples/carts/complete.ts
index 60f9750e7e..2891d2f91d 100644
--- a/packages/sdk/examples/carts/complete.ts
+++ b/packages/sdk/examples/carts/complete.ts
@@ -9,6 +9,7 @@ const client = createClient({
const order = await client.carts.complete('cart_abc123', {
token: '<token>',
})
+
// endregion:example
export { order }
diff --git a/packages/sdk/examples/carts/create.ts b/packages/sdk/examples/carts/create.ts
index 8f8ad3156b..f6c28739b1 100644
--- a/packages/sdk/examples/carts/create.ts
+++ b/packages/sdk/examples/carts/create.ts
@@ -11,10 +11,9 @@ const cart = await client.carts.create()
// Create a cart with items
const cartWithItems = await client.carts.create({
- items: [
- { variant_id: 'variant_abc123', quantity: 2 },
- ],
+ items: [{ variant_id: 'variant_abc123', quantity: 2 }],
})
+
// endregion:example
export { cart, cartWithItems }
diff --git a/packages/sdk/examples/carts/discount-codes-apply.ts b/packages/sdk/examples/carts/discount-codes-apply.ts
index 4680bebd23..9f12dff55a 100644
--- a/packages/sdk/examples/carts/discount-codes-apply.ts
+++ b/packages/sdk/examples/carts/discount-codes-apply.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.discountCodes.apply('cart_abc123', 'SAVE10', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/discount-codes-remove.ts b/packages/sdk/examples/carts/discount-codes-remove.ts
index f370398140..e88ffae0f8 100644
--- a/packages/sdk/examples/carts/discount-codes-remove.ts
+++ b/packages/sdk/examples/carts/discount-codes-remove.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.discountCodes.remove('cart_abc123', 'SAVE10', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/fulfillments-update.ts b/packages/sdk/examples/carts/fulfillments-update.ts
index 71b687ebd2..fa39258e27 100644
--- a/packages/sdk/examples/carts/fulfillments-update.ts
+++ b/packages/sdk/examples/carts/fulfillments-update.ts
@@ -6,11 +6,17 @@ const client = createClient({
})
// region:example
-const cart = await client.carts.fulfillments.update('cart_abc123', 'ful_abc123', {
- selected_delivery_rate_id: 'dr_abc123',
-}, {
- token: '<token>',
-})
+const cart = await client.carts.fulfillments.update(
+ 'cart_abc123',
+ 'ful_abc123',
+ {
+ selected_delivery_rate_id: 'dr_abc123',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/get.ts b/packages/sdk/examples/carts/get.ts
index 38a47287bc..8f5ba80d08 100644
--- a/packages/sdk/examples/carts/get.ts
+++ b/packages/sdk/examples/carts/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.get('cart_abc123', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/gift-cards-apply.ts b/packages/sdk/examples/carts/gift-cards-apply.ts
index dc67d9ce98..5ec2e6b55d 100644
--- a/packages/sdk/examples/carts/gift-cards-apply.ts
+++ b/packages/sdk/examples/carts/gift-cards-apply.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.giftCards.apply('cart_abc123', 'GC-ABCD-1234', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/gift-cards-remove.ts b/packages/sdk/examples/carts/gift-cards-remove.ts
index 994f72de10..d0ee73a229 100644
--- a/packages/sdk/examples/carts/gift-cards-remove.ts
+++ b/packages/sdk/examples/carts/gift-cards-remove.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.giftCards.remove('cart_abc123', 'gc_abc123', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/items-create.ts b/packages/sdk/examples/carts/items-create.ts
index 7a7d666ec0..49b06eeda7 100644
--- a/packages/sdk/examples/carts/items-create.ts
+++ b/packages/sdk/examples/carts/items-create.ts
@@ -6,12 +6,17 @@ const client = createClient({
})
// region:example
-const cart = await client.carts.items.create('cart_abc123', {
- variant_id: 'variant_abc123',
- quantity: 2,
-}, {
- token: '<token>',
-})
+const cart = await client.carts.items.create(
+ 'cart_abc123',
+ {
+ variant_id: 'variant_abc123',
+ quantity: 2,
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/items-delete.ts b/packages/sdk/examples/carts/items-delete.ts
index e79f228b87..664c4d7799 100644
--- a/packages/sdk/examples/carts/items-delete.ts
+++ b/packages/sdk/examples/carts/items-delete.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.items.delete('cart_abc123', 'li_abc123', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/items-update.ts b/packages/sdk/examples/carts/items-update.ts
index db4a47953b..afd2aa6b24 100644
--- a/packages/sdk/examples/carts/items-update.ts
+++ b/packages/sdk/examples/carts/items-update.ts
@@ -6,11 +6,17 @@ const client = createClient({
})
// region:example
-const cart = await client.carts.items.update('cart_abc123', 'li_abc123', {
- quantity: 5,
-}, {
- token: '<token>',
-})
+const cart = await client.carts.items.update(
+ 'cart_abc123',
+ 'li_abc123',
+ {
+ quantity: 5,
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/list.ts b/packages/sdk/examples/carts/list.ts
index 77c725fc6c..007cb6d1da 100644
--- a/packages/sdk/examples/carts/list.ts
+++ b/packages/sdk/examples/carts/list.ts
@@ -9,6 +9,7 @@ const client = createClient({
const carts = await client.carts.list({
token: '<token>',
})
+
// endregion:example
export { carts }
diff --git a/packages/sdk/examples/carts/payment-sessions-complete.ts b/packages/sdk/examples/carts/payment-sessions-complete.ts
index 6690431dc3..6cc4e957ec 100644
--- a/packages/sdk/examples/carts/payment-sessions-complete.ts
+++ b/packages/sdk/examples/carts/payment-sessions-complete.ts
@@ -6,11 +6,17 @@ const client = createClient({
})
// region:example
-const session = await client.carts.paymentSessions.complete('cart_abc123', 'ps_abc123', {
- session_result: 'success',
-}, {
- token: '<token>',
-})
+const session = await client.carts.paymentSessions.complete(
+ 'cart_abc123',
+ 'ps_abc123',
+ {
+ session_result: 'success',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { session }
diff --git a/packages/sdk/examples/carts/payment-sessions-create.ts b/packages/sdk/examples/carts/payment-sessions-create.ts
index 068c32361f..8b681a8764 100644
--- a/packages/sdk/examples/carts/payment-sessions-create.ts
+++ b/packages/sdk/examples/carts/payment-sessions-create.ts
@@ -6,11 +6,16 @@ const client = createClient({
})
// region:example
-const session = await client.carts.paymentSessions.create('cart_abc123', {
- payment_method_id: 'pm_abc123',
-}, {
- token: '<token>',
-})
+const session = await client.carts.paymentSessions.create(
+ 'cart_abc123',
+ {
+ payment_method_id: 'pm_abc123',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { session }
diff --git a/packages/sdk/examples/carts/payment-sessions-get.ts b/packages/sdk/examples/carts/payment-sessions-get.ts
index 85a83c3f49..122c11a3ee 100644
--- a/packages/sdk/examples/carts/payment-sessions-get.ts
+++ b/packages/sdk/examples/carts/payment-sessions-get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const session = await client.carts.paymentSessions.get('cart_abc123', 'ps_abc123', {
token: '<token>',
})
+
// endregion:example
export { session }
diff --git a/packages/sdk/examples/carts/payment-sessions-update.ts b/packages/sdk/examples/carts/payment-sessions-update.ts
index 3aa729a3ba..fa5fa724e4 100644
--- a/packages/sdk/examples/carts/payment-sessions-update.ts
+++ b/packages/sdk/examples/carts/payment-sessions-update.ts
@@ -6,11 +6,17 @@ const client = createClient({
})
// region:example
-const session = await client.carts.paymentSessions.update('cart_abc123', 'ps_abc123', {
- amount: '50.00',
-}, {
- token: '<token>',
-})
+const session = await client.carts.paymentSessions.update(
+ 'cart_abc123',
+ 'ps_abc123',
+ {
+ amount: '50.00',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { session }
diff --git a/packages/sdk/examples/carts/payments-create.ts b/packages/sdk/examples/carts/payments-create.ts
index a1c1fa4aee..1df32b9c43 100644
--- a/packages/sdk/examples/carts/payments-create.ts
+++ b/packages/sdk/examples/carts/payments-create.ts
@@ -6,11 +6,16 @@ const client = createClient({
})
// region:example
-const payment = await client.carts.payments.create('cart_abc123', {
- payment_method_id: 'pm_abc123',
-}, {
- token: '<token>',
-})
+const payment = await client.carts.payments.create(
+ 'cart_abc123',
+ {
+ payment_method_id: 'pm_abc123',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { payment }
diff --git a/packages/sdk/examples/carts/store-credits-apply.ts b/packages/sdk/examples/carts/store-credits-apply.ts
index 7a49e59523..38e1af576b 100644
--- a/packages/sdk/examples/carts/store-credits-apply.ts
+++ b/packages/sdk/examples/carts/store-credits-apply.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.storeCredits.apply('cart_abc123', 10.0, {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/carts/store-credits-remove.ts b/packages/sdk/examples/carts/store-credits-remove.ts
index 6d43806771..1ff8cb6a8e 100644
--- a/packages/sdk/examples/carts/store-credits-remove.ts
+++ b/packages/sdk/examples/carts/store-credits-remove.ts
@@ -9,6 +9,7 @@ const client = createClient({
const cart = await client.carts.storeCredits.remove('cart_abc123', {
token: '<token>',
})
+
// endregion:example
export { cart }
diff --git a/packages/sdk/examples/categories/get.ts b/packages/sdk/examples/categories/get.ts
index 221c96d580..2d2d7e445f 100644
--- a/packages/sdk/examples/categories/get.ts
+++ b/packages/sdk/examples/categories/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const category = await client.categories.get('categories/clothing/shirts', {
expand: ['children'],
})
+
// endregion:example
export { category }
diff --git a/packages/sdk/examples/categories/list.ts b/packages/sdk/examples/categories/list.ts
index ed003c81d4..f65d6c8de5 100644
--- a/packages/sdk/examples/categories/list.ts
+++ b/packages/sdk/examples/categories/list.ts
@@ -10,6 +10,7 @@ const categories = await client.categories.list({
page: 1,
limit: 25,
})
+
// endregion:example
export { categories }
diff --git a/packages/sdk/examples/countries/get.ts b/packages/sdk/examples/countries/get.ts
index becd62b01c..29fb846f3e 100644
--- a/packages/sdk/examples/countries/get.ts
+++ b/packages/sdk/examples/countries/get.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const country = await client.countries.get('US')
+
// endregion:example
export { country }
diff --git a/packages/sdk/examples/countries/list.ts b/packages/sdk/examples/countries/list.ts
index 53457653ff..9ae14e2d82 100644
--- a/packages/sdk/examples/countries/list.ts
+++ b/packages/sdk/examples/countries/list.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const countries = await client.countries.list()
+
// endregion:example
export { countries }
diff --git a/packages/sdk/examples/currencies/list.ts b/packages/sdk/examples/currencies/list.ts
index 821c7996c2..03a4f174da 100644
--- a/packages/sdk/examples/currencies/list.ts
+++ b/packages/sdk/examples/currencies/list.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const currencies = await client.currencies.list()
+
// endregion:example
export { currencies }
diff --git a/packages/sdk/examples/customer-addresses/get.ts b/packages/sdk/examples/customer-addresses/get.ts
index 5e7d1478ad..e7164ff593 100644
--- a/packages/sdk/examples/customer-addresses/get.ts
+++ b/packages/sdk/examples/customer-addresses/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const address = await client.customer.addresses.get('addr_abc123', {
token: '<token>',
})
+
// endregion:example
export { address }
diff --git a/packages/sdk/examples/customer-addresses/list.ts b/packages/sdk/examples/customer-addresses/list.ts
index b6cfce4969..e456990b25 100644
--- a/packages/sdk/examples/customer-addresses/list.ts
+++ b/packages/sdk/examples/customer-addresses/list.ts
@@ -6,9 +6,13 @@ const client = createClient({
})
// region:example
-const addresses = await client.customer.addresses.list({}, {
- token: '<token>',
-})
+const addresses = await client.customer.addresses.list(
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { addresses }
diff --git a/packages/sdk/examples/customer-addresses/update.ts b/packages/sdk/examples/customer-addresses/update.ts
index 4371b28287..d693998cff 100644
--- a/packages/sdk/examples/customer-addresses/update.ts
+++ b/packages/sdk/examples/customer-addresses/update.ts
@@ -6,11 +6,16 @@ const client = createClient({
})
// region:example
-const address = await client.customer.addresses.update('addr_abc123', {
- city: 'Los Angeles',
-}, {
- token: '<token>',
-})
+const address = await client.customer.addresses.update(
+ 'addr_abc123',
+ {
+ city: 'Los Angeles',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { address }
diff --git a/packages/sdk/examples/customer-credit-cards/get.ts b/packages/sdk/examples/customer-credit-cards/get.ts
index a0e56c4bd5..0eac5f5f90 100644
--- a/packages/sdk/examples/customer-credit-cards/get.ts
+++ b/packages/sdk/examples/customer-credit-cards/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const card = await client.customer.creditCards.get('card_abc123', {
token: '<token>',
})
+
// endregion:example
export { card }
diff --git a/packages/sdk/examples/customer-credit-cards/list.ts b/packages/sdk/examples/customer-credit-cards/list.ts
index fdbec6002f..d0f3fade86 100644
--- a/packages/sdk/examples/customer-credit-cards/list.ts
+++ b/packages/sdk/examples/customer-credit-cards/list.ts
@@ -6,9 +6,13 @@ const client = createClient({
})
// region:example
-const cards = await client.customer.creditCards.list({}, {
- token: '<token>',
-})
+const cards = await client.customer.creditCards.list(
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { cards }
diff --git a/packages/sdk/examples/customer-gift-cards/get.ts b/packages/sdk/examples/customer-gift-cards/get.ts
index 6836330026..1b36c0cbf0 100644
--- a/packages/sdk/examples/customer-gift-cards/get.ts
+++ b/packages/sdk/examples/customer-gift-cards/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const giftCard = await client.customer.giftCards.get('gc_abc123', {
token: '<token>',
})
+
// endregion:example
export { giftCard }
diff --git a/packages/sdk/examples/customer-gift-cards/list.ts b/packages/sdk/examples/customer-gift-cards/list.ts
index fc9fd451ab..9477c62881 100644
--- a/packages/sdk/examples/customer-gift-cards/list.ts
+++ b/packages/sdk/examples/customer-gift-cards/list.ts
@@ -6,9 +6,13 @@ const client = createClient({
})
// region:example
-const giftCards = await client.customer.giftCards.list({}, {
- token: '<token>',
-})
+const giftCards = await client.customer.giftCards.list(
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { giftCards }
diff --git a/packages/sdk/examples/customer-orders/get.ts b/packages/sdk/examples/customer-orders/get.ts
index d6fb013783..78bec8b223 100644
--- a/packages/sdk/examples/customer-orders/get.ts
+++ b/packages/sdk/examples/customer-orders/get.ts
@@ -6,9 +6,14 @@ const client = createClient({
})
// region:example
-const order = await client.customer.orders.get('or_abc123', {}, {
- token: '<token>',
-})
+const order = await client.customer.orders.get(
+ 'or_abc123',
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { order }
diff --git a/packages/sdk/examples/customer-orders/list.ts b/packages/sdk/examples/customer-orders/list.ts
index 9b64ff96f7..8c83e42836 100644
--- a/packages/sdk/examples/customer-orders/list.ts
+++ b/packages/sdk/examples/customer-orders/list.ts
@@ -13,6 +13,7 @@ const orders = await client.customer.orders.list(
},
{ token: '<token>' },
)
+
// endregion:example
export { orders }
diff --git a/packages/sdk/examples/customer-password-resets/update.ts b/packages/sdk/examples/customer-password-resets/update.ts
index c3f51774cf..057906ad29 100644
--- a/packages/sdk/examples/customer-password-resets/update.ts
+++ b/packages/sdk/examples/customer-password-resets/update.ts
@@ -6,13 +6,11 @@ const client = createClient({
})
// region:example
-const auth = await client.passwordResets.update(
- 'reset-token-from-email',
- {
- password: 'newsecurepassword',
- password_confirmation: 'newsecurepassword',
- }
-)
+const auth = await client.passwordResets.update('reset-token-from-email', {
+ password: 'newsecurepassword',
+ password_confirmation: 'newsecurepassword',
+})
+
// endregion:example
export { auth }
diff --git a/packages/sdk/examples/customer-payment-setup-sessions/complete.ts b/packages/sdk/examples/customer-payment-setup-sessions/complete.ts
index 960e4a1579..7fce8f582d 100644
--- a/packages/sdk/examples/customer-payment-setup-sessions/complete.ts
+++ b/packages/sdk/examples/customer-payment-setup-sessions/complete.ts
@@ -6,9 +6,14 @@ const client = createClient({
})
// region:example
-const session = await client.customer.paymentSetupSessions.complete('pss_abc123', {}, {
- token: '<token>',
-})
+const session = await client.customer.paymentSetupSessions.complete(
+ 'pss_abc123',
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { session }
diff --git a/packages/sdk/examples/customer-payment-setup-sessions/create.ts b/packages/sdk/examples/customer-payment-setup-sessions/create.ts
index bc8b5d761f..b4534ac9a1 100644
--- a/packages/sdk/examples/customer-payment-setup-sessions/create.ts
+++ b/packages/sdk/examples/customer-payment-setup-sessions/create.ts
@@ -6,11 +6,15 @@ const client = createClient({
})
// region:example
-const session = await client.customer.paymentSetupSessions.create({
- payment_method_id: 'pm_abc123',
-}, {
- token: '<token>',
-})
+const session = await client.customer.paymentSetupSessions.create(
+ {
+ payment_method_id: 'pm_abc123',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { session }
diff --git a/packages/sdk/examples/customer-payment-setup-sessions/get.ts b/packages/sdk/examples/customer-payment-setup-sessions/get.ts
index 3a0555cb98..b854016a35 100644
--- a/packages/sdk/examples/customer-payment-setup-sessions/get.ts
+++ b/packages/sdk/examples/customer-payment-setup-sessions/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const session = await client.customer.paymentSetupSessions.get('pss_abc123', {
token: '<token>',
})
+
// endregion:example
export { session }
diff --git a/packages/sdk/examples/customer-store-credits/get.ts b/packages/sdk/examples/customer-store-credits/get.ts
index 96808e8419..e14ce8d809 100644
--- a/packages/sdk/examples/customer-store-credits/get.ts
+++ b/packages/sdk/examples/customer-store-credits/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const credit = await client.customer.storeCredits.get('credit_abc123', {
token: '<token>',
})
+
// endregion:example
export { credit }
diff --git a/packages/sdk/examples/customer-store-credits/list.ts b/packages/sdk/examples/customer-store-credits/list.ts
index 50f0e56914..1ed8d785ef 100644
--- a/packages/sdk/examples/customer-store-credits/list.ts
+++ b/packages/sdk/examples/customer-store-credits/list.ts
@@ -6,9 +6,13 @@ const client = createClient({
})
// region:example
-const credits = await client.customer.storeCredits.list({}, {
- token: '<token>',
-})
+const credits = await client.customer.storeCredits.list(
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { credits }
diff --git a/packages/sdk/examples/customers/create.ts b/packages/sdk/examples/customers/create.ts
index 05ffd55fe8..db24d67491 100644
--- a/packages/sdk/examples/customers/create.ts
+++ b/packages/sdk/examples/customers/create.ts
@@ -16,6 +16,7 @@ const auth = await client.customers.create({
accepts_email_marketing: true,
metadata: { source: 'storefront' },
})
+
// endregion:example
export { auth }
diff --git a/packages/sdk/examples/customers/get.ts b/packages/sdk/examples/customers/get.ts
index 8683e5a10b..515e1fe726 100644
--- a/packages/sdk/examples/customers/get.ts
+++ b/packages/sdk/examples/customers/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const customer = await client.customer.get({
token: '<token>',
})
+
// endregion:example
export { customer }
diff --git a/packages/sdk/examples/customers/update.ts b/packages/sdk/examples/customers/update.ts
index fb754a3ac8..fd9f18b255 100644
--- a/packages/sdk/examples/customers/update.ts
+++ b/packages/sdk/examples/customers/update.ts
@@ -6,13 +6,17 @@ const client = createClient({
})
// region:example
-const customer = await client.customer.update({
- first_name: 'John',
- last_name: 'Doe',
- metadata: { preferred_contact: 'email' },
-}, {
- token: '<token>',
-})
+const customer = await client.customer.update(
+ {
+ first_name: 'John',
+ last_name: 'Doe',
+ metadata: { preferred_contact: 'email' },
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { customer }
diff --git a/packages/sdk/examples/locales/list.ts b/packages/sdk/examples/locales/list.ts
index ca3eb26063..6f14eec598 100644
--- a/packages/sdk/examples/locales/list.ts
+++ b/packages/sdk/examples/locales/list.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const locales = await client.locales.list()
+
// endregion:example
export { locales }
diff --git a/packages/sdk/examples/markets/countries-get.ts b/packages/sdk/examples/markets/countries-get.ts
index c61e9a554b..5628e7a00f 100644
--- a/packages/sdk/examples/markets/countries-get.ts
+++ b/packages/sdk/examples/markets/countries-get.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const country = await client.markets.countries.get('mkt_xxx', 'DE')
+
// endregion:example
export { country }
diff --git a/packages/sdk/examples/markets/countries-list.ts b/packages/sdk/examples/markets/countries-list.ts
index d961c4a0d6..44a284349b 100644
--- a/packages/sdk/examples/markets/countries-list.ts
+++ b/packages/sdk/examples/markets/countries-list.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const countries = await client.markets.countries.list('mkt_xxx')
+
// endregion:example
export { countries }
diff --git a/packages/sdk/examples/markets/get.ts b/packages/sdk/examples/markets/get.ts
index b22c1ba14d..5a8b986694 100644
--- a/packages/sdk/examples/markets/get.ts
+++ b/packages/sdk/examples/markets/get.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const market = await client.markets.get('mkt_xxx')
+
// endregion:example
export { market }
diff --git a/packages/sdk/examples/markets/list.ts b/packages/sdk/examples/markets/list.ts
index 8301aaca34..00a60d7560 100644
--- a/packages/sdk/examples/markets/list.ts
+++ b/packages/sdk/examples/markets/list.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const markets = await client.markets.list()
+
// endregion:example
export { markets }
diff --git a/packages/sdk/examples/markets/resolve.ts b/packages/sdk/examples/markets/resolve.ts
index 88984680aa..bfa24f8d58 100644
--- a/packages/sdk/examples/markets/resolve.ts
+++ b/packages/sdk/examples/markets/resolve.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const market = await client.markets.resolve('DE')
+
// endregion:example
export { market }
diff --git a/packages/sdk/examples/newsletter-subscribers/create.ts b/packages/sdk/examples/newsletter-subscribers/create.ts
index c1369032a2..da046e5a22 100644
--- a/packages/sdk/examples/newsletter-subscribers/create.ts
+++ b/packages/sdk/examples/newsletter-subscribers/create.ts
@@ -10,6 +10,7 @@ const subscriber = await client.newsletterSubscribers.create({
redirect_url: 'https://your-store.com/newsletter/confirm',
})
+
// endregion:example
export { subscriber }
diff --git a/packages/sdk/examples/newsletter-subscribers/verify.ts b/packages/sdk/examples/newsletter-subscribers/verify.ts
index 55ea514fda..e566026c36 100644
--- a/packages/sdk/examples/newsletter-subscribers/verify.ts
+++ b/packages/sdk/examples/newsletter-subscribers/verify.ts
@@ -9,6 +9,7 @@ const client = createClient({
const subscriber = await client.newsletterSubscribers.verify({
token: 'abc123def456',
})
+
// endregion:example
export { subscriber }
diff --git a/packages/sdk/examples/orders/get.ts b/packages/sdk/examples/orders/get.ts
index 030886036c..e81be10d28 100644
--- a/packages/sdk/examples/orders/get.ts
+++ b/packages/sdk/examples/orders/get.ts
@@ -6,9 +6,14 @@ const client = createClient({
})
// region:example
-const order = await client.orders.get('or_abc123', {}, {
- token: '<token>',
-})
+const order = await client.orders.get(
+ 'or_abc123',
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { order }
diff --git a/packages/sdk/examples/policies/get.ts b/packages/sdk/examples/policies/get.ts
index 8c0a64f8f5..5ce1fcb53c 100644
--- a/packages/sdk/examples/policies/get.ts
+++ b/packages/sdk/examples/policies/get.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const policy = await client.policies.get('return-policy')
+
// endregion:example
export { policy }
diff --git a/packages/sdk/examples/policies/list.ts b/packages/sdk/examples/policies/list.ts
index 7bf17e8e57..64fbbd7676 100644
--- a/packages/sdk/examples/policies/list.ts
+++ b/packages/sdk/examples/policies/list.ts
@@ -7,6 +7,7 @@ const client = createClient({
// region:example
const policies = await client.policies.list()
+
// endregion:example
export { policies }
diff --git a/packages/sdk/examples/products/filters.ts b/packages/sdk/examples/products/filters.ts
index 45aeead0d2..4164e5a843 100644
--- a/packages/sdk/examples/products/filters.ts
+++ b/packages/sdk/examples/products/filters.ts
@@ -9,6 +9,7 @@ const client = createClient({
const filters = await client.products.filters({
category_id: 'ctg_abc123',
})
+
// endregion:example
export { filters }
diff --git a/packages/sdk/examples/products/get.ts b/packages/sdk/examples/products/get.ts
index baef6a1af3..cf8cdf9efe 100644
--- a/packages/sdk/examples/products/get.ts
+++ b/packages/sdk/examples/products/get.ts
@@ -9,6 +9,7 @@ const client = createClient({
const product = await client.products.get('spree-tote', {
expand: ['variants', 'media'],
})
+
// endregion:example
export { product }
diff --git a/packages/sdk/examples/products/list.ts b/packages/sdk/examples/products/list.ts
index 43f9f11e15..de562508b3 100644
--- a/packages/sdk/examples/products/list.ts
+++ b/packages/sdk/examples/products/list.ts
@@ -16,6 +16,7 @@ const products = await client.products.list({
with_option_value_ids: ['optval_abc', 'optval_def'],
expand: ['variants', 'media'],
})
+
// endregion:example
export { products }
diff --git a/packages/sdk/examples/wishlists/create.ts b/packages/sdk/examples/wishlists/create.ts
index a9b647a932..5b9512f07f 100644
--- a/packages/sdk/examples/wishlists/create.ts
+++ b/packages/sdk/examples/wishlists/create.ts
@@ -6,12 +6,16 @@ const client = createClient({
})
// region:example
-const wishlist = await client.wishlists.create({
- name: 'Birthday Ideas',
- is_private: true,
-}, {
- token: '<token>',
-})
+const wishlist = await client.wishlists.create(
+ {
+ name: 'Birthday Ideas',
+ is_private: true,
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { wishlist }
diff --git a/packages/sdk/examples/wishlists/items-create.ts b/packages/sdk/examples/wishlists/items-create.ts
index d53c0f4bb8..454d8fefba 100644
--- a/packages/sdk/examples/wishlists/items-create.ts
+++ b/packages/sdk/examples/wishlists/items-create.ts
@@ -6,12 +6,17 @@ const client = createClient({
})
// region:example
-const item = await client.wishlists.items.create('wl_abc123', {
- variant_id: 'variant_abc123',
- quantity: 1,
-}, {
- token: '<token>',
-})
+const item = await client.wishlists.items.create(
+ 'wl_abc123',
+ {
+ variant_id: 'variant_abc123',
+ quantity: 1,
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { item }
diff --git a/packages/sdk/examples/wishlists/list.ts b/packages/sdk/examples/wishlists/list.ts
index c1a9dd8ca4..4ebc4c6364 100644
--- a/packages/sdk/examples/wishlists/list.ts
+++ b/packages/sdk/examples/wishlists/list.ts
@@ -6,9 +6,13 @@ const client = createClient({
})
// region:example
-const wishlists = await client.wishlists.list({}, {
- token: '<token>',
-})
+const wishlists = await client.wishlists.list(
+ {},
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { wishlists }
diff --git a/packages/sdk/examples/wishlists/update.ts b/packages/sdk/examples/wishlists/update.ts
index 0e36eb1a0d..b30fcf957d 100644
--- a/packages/sdk/examples/wishlists/update.ts
+++ b/packages/sdk/examples/wishlists/update.ts
@@ -6,11 +6,16 @@ const client = createClient({
})
// region:example
-const wishlist = await client.wishlists.update('wl_abc123', {
- name: 'Updated Name',
-}, {
- token: '<token>',
-})
+const wishlist = await client.wishlists.update(
+ 'wl_abc123',
+ {
+ name: 'Updated Name',
+ },
+ {
+ token: '<token>',
+ },
+)
+
// endregion:example
export { wishlist }
diff --git a/packages/seller-dashboard/src/api-client.ts b/packages/seller-dashboard/src/api-client.ts
index cb536abe73..7bfbb5d2da 100644
--- a/packages/seller-dashboard/src/api-client.ts
+++ b/packages/seller-dashboard/src/api-client.ts
@@ -55,6 +55,7 @@ export function createSellerApiClient({
// The shared address form reads countries through the registered client,
// so it works in a panel that has no admin credential.
listCountries: () => sellerClient().countries.list(),
+ createDirectUpload: (params) => sellerClient().directUploads.create(params),
// Backs the shared stock-locations page. No `delete`: a location holds
// stock levels and is named on historical fulfillments, so the Seller API
// does not offer it and the page hides the action accordingly.
diff --git a/packages/seller-dashboard/src/components/seller-business-card.tsx b/packages/seller-dashboard/src/components/seller-business-card.tsx
new file mode 100644
index 0000000000..9e3c9c5a4c
--- /dev/null
+++ b/packages/seller-dashboard/src/components/seller-business-card.tsx
@@ -0,0 +1,149 @@
+import {
+ Button,
+ Card,
+ CardAction,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Field,
+ FieldLabel,
+ Input,
+ Sheet,
+ SheetContent,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
+} from '@spree/dashboard-ui'
+import type { Profile } from '@spree/seller-sdk'
+import { useMutation, useQueryClient } from '@tanstack/react-query'
+import { useParams } from '@tanstack/react-router'
+import { PencilIcon } from 'lucide-react'
+import { useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { toast } from 'sonner'
+import { sellerClient } from '../api-client'
+
+/** The registration kind this panel collects. */
+const VAT_KIND = 'eu_vat'
+
+/**
+ * The business behind the seller, as the marketplace's commission invoice
+ * must address it: legal name, registration number, and the VAT number that
+ * decides whether that invoice carries VAT or is reverse-charged.
+ *
+ * Separate from the billing address, which is only where post goes. Most of
+ * what an invoice needs is not an address, and putting a VAT number in an
+ * address form is what makes it get lost.
+ */
+export function SellerBusinessCard({ profile }: { profile: Profile }) {
+ const { t } = useTranslation()
+ const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
+ const queryClient = useQueryClient()
+ const [editing, setEditing] = useState(false)
+
+ const vat = profile.tax_identifiers?.find((identifier) => identifier.kind === VAT_KIND)
+
+ const [legalName, setLegalName] = useState(profile.legal_name ?? '')
+ const [registrationNumber, setRegistrationNumber] = useState(profile.registration_number ?? '')
+ const [vatNumber, setVatNumber] = useState(vat?.value ?? '')
+
+ const save = useMutation({
+ mutationFn: () =>
+ sellerClient().profile.update({
+ legal_name: legalName || null,
+ registration_number: registrationNumber || null,
+ tax_identifier: { kind: VAT_KIND, value: vatNumber },
+ }),
+ onSuccess: (updated) => {
+ queryClient.setQueryData(['seller', sellerId, 'profile'], updated)
+ // A checklist kind may read these, so it has to re-evaluate.
+ void queryClient.invalidateQueries({ queryKey: ['seller', sellerId, 'onboarding'] })
+ setEditing(false)
+ toast.success(t('profile.saved'))
+ },
+ onError: (err) => toast.error(err instanceof Error ? err.message : t('common.error')),
+ })
+
+ const rows = [
+ { label: t('profile.legal_name'), value: profile.legal_name },
+ { label: t('profile.registration_number'), value: profile.registration_number },
+ { label: t('profile.vat_number'), value: vat?.value },
+ ]
+
+ return (
+ <>
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('profile.business_details')}</CardTitle>
+ <CardAction>
+ <Button variant="outline" size="sm" onClick={() => setEditing(true)}>
+ <PencilIcon className="size-4" />
+ {t('profile.edit')}
+ </Button>
+ </CardAction>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-2 text-sm">
+ {rows.map((row) => (
+ <div key={row.label} className="flex justify-between gap-4">
+ <span className="text-muted-foreground">{row.label}</span>
+ <span className="text-right">{row.value || '—'}</span>
+ </div>
+ ))}
+ {/* A number the seller believes is on file but which came back
+ unverified is worth them knowing about. */}
+ {vat?.validation_status && vat.validation_status !== 'verified' && (
+ <p className="text-muted-foreground text-xs">
+ {t(`profile.vat_status.${vat.validation_status}`, {
+ defaultValue: vat.validation_status,
+ })}
+ </p>
+ )}
+ </CardContent>
+ </Card>
+
+ <Sheet open={editing} onOpenChange={setEditing}>
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{t('profile.business_details')}</SheetTitle>
+ </SheetHeader>
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <Field>
+ <FieldLabel htmlFor="legal-name">{t('profile.legal_name')}</FieldLabel>
+ <Input
+ id="legal-name"
+ value={legalName}
+ onChange={(event) => setLegalName(event.target.value)}
+ />
+ </Field>
+ <Field>
+ <FieldLabel htmlFor="registration-number">
+ {t('profile.registration_number')}
+ </FieldLabel>
+ <Input
+ id="registration-number"
+ value={registrationNumber}
+ onChange={(event) => setRegistrationNumber(event.target.value)}
+ />
+ </Field>
+ <Field>
+ <FieldLabel htmlFor="vat-number">{t('profile.vat_number')}</FieldLabel>
+ <Input
+ id="vat-number"
+ value={vatNumber}
+ onChange={(event) => setVatNumber(event.target.value)}
+ />
+ </Field>
+ </div>
+ <SheetFooter>
+ <Button variant="outline" size="sm" onClick={() => setEditing(false)}>
+ {t('common.cancel')}
+ </Button>
+ <Button size="sm" disabled={save.isPending} onClick={() => save.mutate()}>
+ {t('common.save')}
+ </Button>
+ </SheetFooter>
+ </SheetContent>
+ </Sheet>
+ </>
+ )
+}
diff --git a/packages/seller-dashboard/src/locales/en.json b/packages/seller-dashboard/src/locales/en.json
index 76075f8f27..16f662c788 100644
--- a/packages/seller-dashboard/src/locales/en.json
+++ b/packages/seller-dashboard/src/locales/en.json
@@ -19,7 +19,8 @@
"cancel": "Cancel",
"error": "Something went wrong.",
"loading": "Loading…",
- "retry": "Try again"
+ "retry": "Try again",
+ "save": "Save"
},
"home": {
"products": "Products",
@@ -56,6 +57,8 @@
"accept_terms": "Accept the terms",
"awaiting_review": "Waiting for the marketplace to review this.",
"confirm": "Confirm",
+ "document_help": "PDF or an image of the document.",
+ "document_label": "Document",
"done": "This one is done.",
"go": "Go there",
"note_placeholder": "Anything the marketplace should know (optional)",
@@ -72,6 +75,7 @@
"rejected": "Needs another look"
},
"submit": "Submit for review",
+ "submit_document": "Submit for review",
"submitted": "Sent for review",
"submitted_requirement": "Sent",
"submitting": "Submitting…",
@@ -89,10 +93,12 @@
"at_a_glance": "At a glance",
"billing_address": "Billing address",
"billing_email": "Billing email",
+ "business_details": "Business details",
"contact_email": "Contact email",
"edit": "Edit",
"edit_title": "Edit your profile",
"joined": "Joined",
+ "legal_name": "Legal name",
"minimum_payout": "Minimum payout",
"name": "Name",
"no_about": "You have not written a description yet.",
@@ -101,6 +107,7 @@
"operator_managed": "Set by the marketplace",
"payout_schedule": "Payout schedule",
"products_count": "Products",
+ "registration_number": "Registration number",
"returns_address": "Returns address",
"save": "Save changes",
"saved": "Profile saved",
@@ -120,7 +127,14 @@
},
"subtitle": "How your storefront presents you, and how the marketplace reaches you.",
"tax_remittance": "Tax remitted by",
- "team_count": "Team members"
+ "team_count": "Team members",
+ "vat_number": "VAT number",
+ "vat_status": {
+ "pending": "We are checking this number.",
+ "unavailable": "The registry could not be reached — we will try again.",
+ "unsupported": "This number is recorded as entered; we cannot check it automatically.",
+ "unverified": "This number could not be verified."
+ }
},
"seller_picker": {
"status": "Status",
diff --git a/packages/seller-dashboard/src/pages/onboarding.tsx b/packages/seller-dashboard/src/pages/onboarding.tsx
index 32a119cf6d..c0c3eca61f 100644
--- a/packages/seller-dashboard/src/pages/onboarding.tsx
+++ b/packages/seller-dashboard/src/pages/onboarding.tsx
@@ -1,3 +1,8 @@
+import {
+ EMPTY_FILE_UPLOAD_VALUE,
+ FileUploadField,
+ type FileUploadValue,
+} from '@spree/dashboard-core'
import {
Badge,
Button,
@@ -5,6 +10,9 @@ import {
CardContent,
CardHeader,
CardTitle,
+ Field,
+ FieldLabel,
+ Input,
Progress,
Textarea,
} from '@spree/dashboard-ui'
@@ -183,6 +191,8 @@ function RequirementAction({ requirement }: { requirement: RequirementStatus })
const { sellerId } = useParams({ from: '/_authenticated/$sellerId' })
const queryClient = useQueryClient()
const [note, setNote] = useState('')
+ const [file, setFile] = useState<FileUploadValue>(EMPTY_FILE_UPLOAD_VALUE)
+ const [fields, setFields] = useState<Record<string, string>>({})
// Only the address kinds need it, and it is already loaded by the profile
// page and the sidebar switcher — this reads the same cache entry.
@@ -204,17 +214,41 @@ function RequirementAction({ requirement }: { requirement: RequirementStatus })
onError: (err) => toast.error(err instanceof Error ? err.message : t('common.error')),
})
- const attest = useMutation({
+ // One submit for every kind that takes one — an attestation the seller
+ // ticks, a document they upload, a manual check they say is ready. What
+ // differs is which controls render above it, not what posting means.
+ const submit = useMutation({
mutationFn: () =>
- sellerClient().requirementSubmissions.create(requirement.id, { note: note || undefined }),
+ sellerClient().requirementSubmissions.create(requirement.id, {
+ note: note || undefined,
+ file: file.signedId || undefined,
+ }),
onSuccess: () => {
setNote('')
+ setFile(EMPTY_FILE_UPLOAD_VALUE)
toast.success(t('onboarding.submitted_requirement'))
void invalidate()
},
onError: (err) => toast.error(err instanceof Error ? err.message : t('common.error')),
})
+ // Custom fields are the seller's own profile data, so they save through the
+ // profile like the addresses do rather than as a submission.
+ const saveFields = useMutation({
+ mutationFn: () =>
+ sellerClient().profile.update({
+ custom_fields: Object.entries(fields).map(([id, value]) => ({
+ custom_field_definition_id: id,
+ value,
+ })),
+ }),
+ onSuccess: () => {
+ toast.success(t('profile.saved'))
+ void invalidate()
+ },
+ onError: (err) => toast.error(err instanceof Error ? err.message : t('common.error')),
+ })
+
const submission = requirement.submission
// A rejection the seller cannot read is a rejection they cannot act on.
@@ -264,17 +298,69 @@ function RequirementAction({ requirement }: { requirement: RequirementStatus })
</div>
)}
- {requirement.kind === 'attestation' && (
- <div className="flex flex-col gap-2">
+ {/* Every kind that takes a submission gets the same form: a note, a
+ file picker when the kind asks for one, and one button. Keyed off
+ what the server says the kind accepts rather than off its name, so a
+ kind a gem adds is usable without this file knowing about it. */}
+ {requirement.accepts_submissions && requirement.kind !== 'accept_terms' && (
+ <div className="flex flex-col gap-3">
+ {requirement.requires_file && (
+ <FileUploadField
+ value={file}
+ onChange={setFile}
+ accept={requirement.accepted_content_types?.join(',')}
+ label={t('onboarding.document_label')}
+ help={t('onboarding.document_help')}
+ />
+ )}
+
<Textarea
rows={2}
value={note}
placeholder={t('onboarding.note_placeholder')}
onChange={(event) => setNote(event.target.value)}
/>
+
+ <div className="flex justify-start">
+ <Button
+ size="sm"
+ // A document requirement with nothing attached is an empty
+ // submission the operator can only reject.
+ disabled={submit.isPending || (requirement.requires_file && !file.signedId)}
+ onClick={() => submit.mutate()}
+ >
+ {requirement.requires_file
+ ? t('onboarding.submit_document')
+ : t('onboarding.confirm')}
+ </Button>
+ </div>
+ </div>
+ )}
+
+ {/* The fields the marketplace asks this seller to fill in, rendered
+ here rather than behind a link: the checklist is where they were
+ asked, so it is where they answer. */}
+ {requirement.custom_fields && requirement.custom_fields.length > 0 && (
+ <div className="flex flex-col gap-3">
+ {requirement.custom_fields.map((field) => (
+ <Field key={field.id}>
+ <FieldLabel htmlFor={`cf-${field.id}`}>{field.label}</FieldLabel>
+ <Input
+ id={`cf-${field.id}`}
+ value={fields[field.id] ?? (field.value == null ? '' : String(field.value))}
+ onChange={(event) =>
+ setFields((current) => ({ ...current, [field.id]: event.target.value }))
+ }
+ />
+ </Field>
+ ))}
<div className="flex justify-start">
- <Button size="sm" disabled={attest.isPending} onClick={() => attest.mutate()}>
- {t('onboarding.confirm')}
+ <Button
+ size="sm"
+ disabled={saveFields.isPending || Object.keys(fields).length === 0}
+ onClick={() => saveFields.mutate()}
+ >
+ {t('common.save')}
</Button>
</div>
</div>
@@ -339,11 +425,13 @@ function isAddressKind(kind: string): boolean {
function panelRoute(kind: string): string | undefined {
switch (kind) {
case 'complete_profile':
- case 'required_custom_fields':
return '/$sellerId/profile'
- // `minimum_products` belongs here too, once the panel has a products
- // page — until then it falls through and reads as a plain instruction
- // rather than a link to nowhere.
+ // `required_custom_fields` is not here: it renders its own fields inline,
+ // so a link away would offer a second, worse route to the same thing.
+ //
+ // `minimum_products` belongs here once the panel has a products page —
+ // until then it falls through and reads as a plain instruction rather
+ // than a link to nowhere.
default:
return undefined
}
diff --git a/packages/seller-dashboard/src/pages/profile.tsx b/packages/seller-dashboard/src/pages/profile.tsx
index 26682acccb..7acee05046 100644
--- a/packages/seller-dashboard/src/pages/profile.tsx
+++ b/packages/seller-dashboard/src/pages/profile.tsx
@@ -32,6 +32,7 @@ import { toast } from 'sonner'
import { sellerClient } from '../api-client'
import { CenteredMessage } from '../components/centered-message'
import { SellerAddressCard } from '../components/seller-address-card'
+import { SellerBusinessCard } from '../components/seller-business-card'
import { SellerReturnsLocationCard } from '../components/seller-returns-location-card'
interface ProfileValues {
@@ -92,6 +93,7 @@ export function ProfilePage() {
<StandingCard profile={profile} />
<AtAGlanceCard profile={profile} teamCount={team?.data?.length} />
<ContactCard profile={profile} onEdit={() => setEditing(true)} />
+ <SellerBusinessCard profile={profile} />
<SellerAddressCard profile={profile} />
<SellerReturnsLocationCard />
<SettlementCard profile={profile} />
diff --git a/packages/seller-sdk/src/seller-client.ts b/packages/seller-sdk/src/seller-client.ts
index feb36c9fcc..207a6c7b2b 100644
--- a/packages/seller-sdk/src/seller-client.ts
+++ b/packages/seller-sdk/src/seller-client.ts
@@ -219,6 +219,23 @@ export class SellerClient {
this.request<void>('DELETE', `/products/${id}`, options),
}
+ /**
+ * Presigning for the documents onboarding asks for. Exchange the blob's
+ * metadata for an upload URL, PUT the file to it, then post the returned
+ * `signed_id` as a submission's `file`.
+ */
+ readonly directUploads = {
+ create: (
+ params: {
+ blob: { filename: string; byte_size: number; checksum: string; content_type: string }
+ },
+ options?: RequestOptions,
+ ): Promise<{
+ direct_upload: { url: string; headers: Record<string, string> }
+ signed_id: string
+ }> => this.request('POST', '/direct_uploads', { ...options, body: params }),
+ }
+
/**
* Where this seller keeps stock, and so where their returns are sent.
*
@@ -349,8 +366,23 @@ export interface ProfileUpdateParams {
logo?: string | null
square_logo?: string | null
cover_photo?: string | null
+ /** The business a commission invoice is made out to. */
+ legal_name?: string | null
+ registration_number?: string | null
+ /**
+ * The seller's tax registration. One per kind — re-sending a kind corrects
+ * the number, and an empty value removes it. A changed number drops its
+ * validation verdict, since that answer was about the old one.
+ */
+ tax_identifier?: { kind: string; value: string }
billing_address?: SellerAddressParams
returns_address?: SellerAddressParams
+ /**
+ * Answers to the custom fields this marketplace's onboarding asks for.
+ * Narrowed server-side to those definitions — a field nothing asked for is
+ * ignored rather than written.
+ */
+ custom_fields?: Array<{ custom_field_definition_id: string; value: unknown }>
/**
* Accepts the marketplace's terms, stamping the moment. One-way: the stamp
* records that it happened, so sending `false` does not unmake it.
diff --git a/packages/seller-sdk/src/types/generated/Invitation.ts b/packages/seller-sdk/src/types/generated/Invitation.ts
index 3d5c5d9711..2911e9bb78 100644
--- a/packages/seller-sdk/src/types/generated/Invitation.ts
+++ b/packages/seller-sdk/src/types/generated/Invitation.ts
@@ -1,4 +1,4 @@
-// Typelizer digest bc9f7c8d41a89f2345c24a7defaddce3
+// Typelizer digest f58e4be1fc6a1aa2f830c76f832ea562
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
@@ -6,10 +6,10 @@ type Invitation = {
id: string;
email: string;
created_at: string;
- status: string;
- acceptance_url: string;
expires_at: string | null;
accepted_at: string | null;
+ status: string;
+ acceptance_url: string;
}
export default Invitation;
diff --git a/packages/seller-sdk/src/types/generated/Profile.ts b/packages/seller-sdk/src/types/generated/Profile.ts
index 04c304e156..3a7691ac64 100644
--- a/packages/seller-sdk/src/types/generated/Profile.ts
+++ b/packages/seller-sdk/src/types/generated/Profile.ts
@@ -1,7 +1,7 @@
-// Typelizer digest 6b7b053665b4f97a30ab33385227b3c6
+// Typelizer digest b4c08dcba24c392295bc53ff5e5aa51d
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {Address} from '@/types'
+import type {TaxIdentifier, Address} from '@/types'
type Profile = {
id: string;
@@ -13,6 +13,8 @@ type Profile = {
square_logo_url: string | null;
cover_photo_url: string | null;
status: string;
+ legal_name: string | null;
+ registration_number: string | null;
contact_email: string | null;
billing_email: string | null;
tax_remittance: string;
@@ -24,6 +26,7 @@ type Profile = {
on_holiday: boolean;
sellable: boolean;
products_count: number;
+ tax_identifiers: Array<TaxIdentifier>;
billing_address?: Address;
returns_address?: Address;
}
diff --git a/packages/seller-sdk/src/types/generated/RequirementCustomField.ts b/packages/seller-sdk/src/types/generated/RequirementCustomField.ts
new file mode 100644
index 0000000000..fbebaa3b16
--- /dev/null
+++ b/packages/seller-sdk/src/types/generated/RequirementCustomField.ts
@@ -0,0 +1,13 @@
+// Typelizer digest e9669ad0fe85abe55fcbed2497905f03
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+type RequirementCustomField = {
+ id: string;
+ key: string;
+ label: string;
+ field_type: 'short_text' | 'long_text' | 'rich_text' | 'number' | 'boolean' | 'json';
+ value: any;
+}
+
+export default RequirementCustomField;
diff --git a/packages/seller-sdk/src/types/generated/RequirementStatus.ts b/packages/seller-sdk/src/types/generated/RequirementStatus.ts
index bb561f039f..9e9279f463 100644
--- a/packages/seller-sdk/src/types/generated/RequirementStatus.ts
+++ b/packages/seller-sdk/src/types/generated/RequirementStatus.ts
@@ -1,7 +1,7 @@
-// Typelizer digest be0c4985af14b02c335f192aa17291c0
+// Typelizer digest 434bfb90137616b68851e9a0fec33b60
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {RequirementSubmission} from '@/types'
+import type {RequirementSubmission, RequirementCustomField} from '@/types'
type RequirementStatus = {
id: string;
@@ -13,7 +13,11 @@ type RequirementStatus = {
status: string;
action_url: string | null;
blocking: boolean;
+ accepts_submissions: boolean;
+ requires_file: boolean;
+ accepted_content_types: Array<string>;
submission?: RequirementSubmission;
+ custom_fields?: Array<RequirementCustomField>;
}
export default RequirementStatus;
diff --git a/packages/seller-sdk/src/types/generated/TaxIdentifier.ts b/packages/seller-sdk/src/types/generated/TaxIdentifier.ts
new file mode 100644
index 0000000000..b50ae86b81
--- /dev/null
+++ b/packages/seller-sdk/src/types/generated/TaxIdentifier.ts
@@ -0,0 +1,13 @@
+// Typelizer digest 4d689e8d66e721fad8e5b02990a68888
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+type TaxIdentifier = {
+ id: string;
+ kind: string;
+ value: string;
+ validation_status: string | null;
+ validated_at: string | null;
+}
+
+export default TaxIdentifier;
diff --git a/packages/seller-sdk/src/types/generated/index.ts b/packages/seller-sdk/src/types/generated/index.ts
index 4006f68e38..4951a1d084 100644
--- a/packages/seller-sdk/src/types/generated/index.ts
+++ b/packages/seller-sdk/src/types/generated/index.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 7332362643df45117ff27e135f8d3e38
+// Typelizer digest 53306523edc4d3f2294f0a0ff019019b
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as Address } from './Address'
@@ -12,9 +12,11 @@ export type { default as Price } from './Price'
export type { default as Invitation } from './Invitation'
export type { default as Product } from './Product'
export type { default as Profile } from './Profile'
+export type { default as RequirementCustomField } from './RequirementCustomField'
export type { default as RequirementStatus } from './RequirementStatus'
export type { default as RequirementSubmission } from './RequirementSubmission'
export type { default as StockLocation } from './StockLocation'
+export type { default as TaxIdentifier } from './TaxIdentifier'
export type { default as TeamMember } from './TeamMember'
export type { default as Seller } from './Seller'
export type { default as Variant } from './Variant'
diff --git a/spree/api/app/controllers/spree/api/v3/seller/direct_uploads_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/direct_uploads_controller.rb
new file mode 100644
index 0000000000..c4eb7f19c9
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/seller/direct_uploads_controller.rb
@@ -0,0 +1,38 @@
+module Spree
+ module Api
+ module V3
+ module Seller
+ # Presigning for a seller's own uploads — today the documents their
+ # onboarding asks for.
+ #
+ # A blob created here is not attached to anything yet: it becomes a
+ # submission only when the seller posts its signed id, and that
+ # endpoint is the one that checks the requirement is theirs. So the
+ # narrowest meaningful gate is the seller's own profile, which every
+ # member of a seller's team holds.
+ class DirectUploadsController < Seller::BaseController
+ scoped_resource :seller_profile
+
+ # POST /api/v3/seller/direct_uploads
+ def create
+ blob = ActiveStorage::Blob.create_before_direct_upload!(**blob_params)
+
+ render json: {
+ direct_upload: {
+ url: blob.service_url_for_direct_upload,
+ headers: blob.service_headers_for_direct_upload
+ },
+ signed_id: blob.signed_id
+ }, status: :created
+ end
+
+ private
+
+ def blob_params
+ params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type).to_h.symbolize_keys
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rb
index f46a0c6a13..143bb6bce4 100644
--- a/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/seller/profile_controller.rb
@@ -25,7 +25,21 @@ module Spree
end
def update
- if current_seller.update(permitted_params.merge(terms_attributes))
+ attributes = permitted_params.merge(terms_attributes)
+ # `normalize_params` rewrites `custom_fields` to the nested-attributes
+ # key. Narrow it, then hand it back under the original name: the
+ # model's `custom_fields=` upserts by definition, while the nested
+ # writer builds a row every time — so a seller correcting a value
+ # they had already saved would hit the uniqueness index instead.
+ if attributes.key?(:custom_fields_attributes)
+ attributes[:custom_fields] =
+ requested_custom_fields(attributes.delete(:custom_fields_attributes))
+ end
+
+ tax_identifier = attributes.delete(:tax_identifier)
+
+ if current_seller.update(attributes)
+ upsert_tax_identifier(tax_identifier) if tax_identifier.present?
render json: serialize_seller
else
render_validation_error(current_seller.errors)
@@ -62,11 +76,60 @@ module Spree
{ terms_accepted_at: Time.current }
end
+ # One registration per kind, so re-sending a kind corrects the number
+ # rather than stacking a second row the model would reject.
+ #
+ # A changed number drops its verdict — the validator's answer was
+ # about the old one, and carrying it over would show a number as
+ # verified that nobody has checked.
+ def upsert_tax_identifier(attributes)
+ kind = attributes[:kind].presence
+ value = attributes[:value]
+ return if kind.blank?
+
+ identifier = current_seller.tax_identifiers.find_or_initialize_by(kind: kind)
+
+ if value.blank?
+ identifier.destroy if identifier.persisted?
+ return
+ end
+
+ identifier.value = value
+ identifier.save
+ end
+
+ # Narrowed to the definitions this marketplace's onboarding actually
+ # asks this seller for.
+ #
+ # Custom fields on `Spree::Seller` are the operator's schema, and
+ # some of them are the operator's own — an internal risk note, a
+ # compliance flag. A seller may fill in what they were asked for;
+ # permitting the association wholesale would let them write, and
+ # then read back, every field the operator defined.
+ def requested_custom_fields(submitted)
+ return [] if submitted.blank?
+
+ allowed = Spree::SellerRequirementCustomField.
+ joins(:seller_requirement).
+ where(Spree::SellerRequirement.table_name => {
+ store_id: current_store.id, active: true
+ }).
+ pluck(:custom_field_definition_id).to_set
+
+ Array(submitted).select do |field|
+ allowed.include?(field[:custom_field_definition_id])
+ end
+ end
+
def permitted_params
normalize_params(
params.permit(:name, :contact_email, :billing_email, :about,
+ :legal_name, :registration_number,
:logo, :square_logo, :cover_photo,
- billing_address: ADDRESS_KEYS)
+ tax_identifier: [:kind, :value],
+ billing_address: ADDRESS_KEYS,
+ custom_fields: [:id, :custom_field_definition_id, :value,
+ { value: [] }, { value: {} }])
)
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/seller_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/seller_serializer.rb
index e8444bf847..02e8744dbd 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/seller_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/seller_serializer.rb
@@ -7,6 +7,8 @@ module Spree
# tax configuration only the operator sets.
class SellerSerializer < V3::SellerSerializer
typelize status: :string,
+ legal_name: [:string, nullable: true],
+ registration_number: [:string, nullable: true],
contact_email: [:string, nullable: true], billing_email: [:string, nullable: true],
tax_remittance: :string,
payouts_schedule_interval: [:string, nullable: true],
@@ -66,6 +68,9 @@ module Spree
seller.onboarding_complete?
end
+ attribute :legal_name, &:legal_name
+ attribute :registration_number, &:registration_number
+
one :billing_address,
resource: proc { Spree.api.admin_address_serializer },
if: proc { |seller| seller.billing_address.present? }
diff --git a/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rb
index d0aae4042e..f8adde996f 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rb
@@ -21,10 +21,6 @@ module Spree
:pickup_ready_in_minutes, :pickup_instructions,
created_at: :iso8601, updated_at: :iso8601
- # Whose shelf this is — nil for the marketplace's own. On a
- # marketplace the operator's list holds both, and without this the
- # two are indistinguishable. The name rides along so the list can
- # show it without expanding; the full profile is `?expand=seller`.
attribute :seller_id do |stock_location|
stock_location.seller&.prefixed_id
end
diff --git a/spree/api/app/serializers/spree/api/v3/seller/invitation_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/invitation_serializer.rb
index f1bb40948c..6e2e7e0950 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/invitation_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/invitation_serializer.rb
@@ -2,29 +2,19 @@ module Spree
module Api
module V3
module Seller
- # A pending invitation to join this seller.
- #
- # Only what the inviting seller needs to see: who was invited, whether
- # they have accepted, and when it lapses. The shared serializer's
- # polymorphic fields (`resource_type`, `inviter_id`, `role_id`) describe
- # plumbing the seller cannot act on — and the invitation is always to
- # the seller whose panel they are already looking at.
class InvitationSerializer < V3::BaseSerializer
typelize email: :string, status: :string,
expires_at: [:string, nullable: true],
accepted_at: [:string, nullable: true],
acceptance_url: :string
- attributes :email, created_at: :iso8601
+ attributes :email,
+ created_at: :iso8601, expires_at: :iso8601, accepted_at: :iso8601
attribute :status do |invitation|
invitation.status.to_s
end
- # So the panel can offer "copy link" for a colleague who never got
- # the email. Absolute when a panel origin is configured — the route
- # sends a seller invitation to the seller panel — otherwise the path,
- # which the panel resolves against its own origin.
attribute :acceptance_url do |invitation|
if Spree::Config[:seller_panel_url].present? || Spree::Config[:dashboard_url].present?
Rails.application.routes.url_helpers.admin_invitation_acceptance_url(invitation)
@@ -32,14 +22,6 @@ module Spree
"/accept-invitation/#{invitation.prefixed_id}?token=#{invitation.token}"
end
end
-
- attribute :expires_at do |invitation|
- invitation.expires_at&.iso8601
- end
-
- attribute :accepted_at do |invitation|
- invitation.accepted_at&.iso8601
- end
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rb
index 1bb2b79618..315f27cf69 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rb
@@ -2,18 +2,6 @@ module Spree
module Api
module V3
module Seller
- # A seller's own product, as they manage it.
- #
- # Extends the store serializer, NOT the admin one, deliberately. The
- # admin serializer's nested associations (`variants`, `channels`,
- # `product_publications`) render through admin serializers that carry
- # operator data — cost prices, publication state, internal metadata —
- # and a seller must not read those even on their own product. The
- # store serializer's nested pieces are all customer-safe, so building
- # up from there means nothing leaks by inheritance.
- #
- # On top of the public view, a seller needs `status` (their product may
- # be a draft the storefront cannot see yet) and timestamps.
class ProductSerializer < V3::ProductSerializer
typelize status: :string
diff --git a/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb
index b8711ca838..17cb466a2e 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb
@@ -2,18 +2,10 @@ module Spree
module Api
module V3
module Seller
- # A seller's own record, as they see it.
- #
- # Sits between the two existing views: more than the shopper's public
- # profile (the seller needs their contact details and where they stand
- # in the marketplace), less than the operator's (they read their
- # settlement terms but never the operator's private notes).
- #
- # `status` and `sellable` are readable but not writable — a seller
- # should know they are suspended; moving between states is the
- # operator's decision, made through workflows.
class ProfileSerializer < V3::SellerSerializer
typelize status: :string,
+ legal_name: [:string, nullable: true],
+ registration_number: [:string, nullable: true],
contact_email: [:string, nullable: true],
billing_email: [:string, nullable: true],
tax_remittance: :string,
@@ -24,7 +16,8 @@ module Spree
on_holiday: :boolean, sellable: :boolean,
products_count: :number
- attributes :status, :contact_email, :billing_email,
+ attributes :status, :legal_name, :registration_number,
+ :contact_email, :billing_email,
:tax_remittance, :payouts_schedule_interval,
holiday_mode_until: :iso8601,
terms_accepted_at: :iso8601,
@@ -46,6 +39,9 @@ module Spree
seller.products.count
end
+ many :tax_identifiers,
+ resource: proc { Spree.api.seller_tax_identifier_serializer }
+
one :billing_address,
resource: proc { Spree.api.address_serializer },
if: proc { |seller| seller.billing_address.present? }
diff --git a/spree/api/app/serializers/spree/api/v3/seller/requirement_custom_field_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/requirement_custom_field_serializer.rb
new file mode 100644
index 0000000000..7beaf18637
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/seller/requirement_custom_field_serializer.rb
@@ -0,0 +1,36 @@
+module Spree
+ module Api
+ module V3
+ module Seller
+ class RequirementCustomFieldSerializer
+ include Alba::Resource
+ include Typelizer::DSL
+
+ typelize id: :string, key: :string, label: :string,
+ field_type: Spree::CustomField::FIELD_TYPE_TOKENS,
+ value: :any
+
+ attribute :id do |pair|
+ pair[:definition].prefixed_id
+ end
+
+ attribute :key do |pair|
+ pair[:definition].full_key
+ end
+
+ attribute :label do |pair|
+ pair[:definition].label
+ end
+
+ attribute :field_type do |pair|
+ pair[:definition].field_type
+ end
+
+ attribute :value do |pair|
+ pair[:custom_field]&.serialize_value
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/serializers/spree/api/v3/seller/requirement_status_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/requirement_status_serializer.rb
index 4853ef7c11..0321417ad3 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/requirement_status_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/requirement_status_serializer.rb
@@ -2,22 +2,6 @@ module Spree
module Api
module V3
module Seller
- # One line of this seller's onboarding checklist.
- #
- # A value object, so no id of its own: the `id` is the requirement it
- # came from, which is what the panel posts a submission against.
- #
- # `blocking` is serialized rather than derived client-side so the
- # panel's "what is stopping me" list and the server's refusal on
- # submit-for-review cannot disagree. `kind` is what the panel keys
- # presentation off — which line gets a file picker, which gets a
- # checkbox, which just links away.
- #
- # Includes Alba directly instead of inheriting BaseSerializer, as the
- # operator's twin does: the base renders `id` by calling
- # `object.prefixed_id`, and this is a value object whose `id` is
- # already a prefixed id string. Inheriting would render `id: nil` and
- # cost the panel the one field it posts submissions against.
class RequirementStatusSerializer
include Alba::Resource
include Typelizer::DSL
@@ -25,7 +9,9 @@ module Spree
typelize id: :string, kind: :string, name: :string,
description: [:string, nullable: true],
required: :boolean, position: :number, status: :string,
- blocking: :boolean, action_url: [:string, nullable: true]
+ blocking: :boolean, action_url: [:string, nullable: true],
+ accepts_submissions: :boolean, requires_file: :boolean,
+ accepted_content_types: [:string, multi: true]
attributes :id, :kind, :name, :description, :required, :position, :status, :action_url
@@ -33,9 +19,27 @@ module Spree
status.blocking?
end
+ attribute :accepts_submissions do |status|
+ status.requirement.class.accepts_submissions?
+ end
+
+ attribute :requires_file do |status|
+ status.requirement.class.requires_file?
+ end
+
+ attribute :accepted_content_types do |status|
+ status.requirement.class.requires_file? ? status.requirement.class.accepted_content_types : []
+ end
+
one :submission,
resource: proc { Spree.api.seller_requirement_submission_serializer },
if: proc { |status| status.submission.present? }
+
+ many :custom_fields,
+ resource: proc { Spree.api.seller_requirement_custom_field_serializer },
+ if: proc { |status| status.respond_to?(:custom_fields) && status.custom_fields.any? } do |status|
+ status.custom_fields
+ end
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/seller/requirement_submission_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/requirement_submission_serializer.rb
index 51c33dd2a4..8a1f81f181 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/requirement_submission_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/requirement_submission_serializer.rb
@@ -2,17 +2,6 @@ module Spree
module Api
module V3
module Seller
- # What this seller submitted about one requirement, and what the
- # marketplace made of it.
- #
- # Narrower than the operator's view on purpose: no `seller_id` (there
- # is exactly one seller in play and it is the caller), no
- # `requirement_name` (the checklist line already carries it), and no
- # `metadata` — that is the operator's and any provider's workspace,
- # not something a seller reads back.
- #
- # `review_note` IS included: a rejection the seller cannot read is a
- # rejection they cannot act on.
class RequirementSubmissionSerializer < V3::BaseSerializer
typelize status: :string, note: [:string, nullable: true],
review_note: [:string, nullable: true],
@@ -26,9 +15,6 @@ module Spree
created_at: :iso8601,
updated_at: :iso8601
- # This API's own download action, not a storage URL: these are
- # identity documents, so each download is authorized per request
- # rather than readable by anyone holding the link.
attribute :file_url do |submission|
next nil unless submission.file.attached?
diff --git a/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rb
index 71b11ebf24..786e1ce1d3 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rb
@@ -2,14 +2,6 @@ module Spree
module Api
module V3
module Seller
- # A seller's own stock location, as they manage it in the panel.
- #
- # Extends the store serializer rather than the admin one: the fields
- # an operator sees that a seller does not need are the ones about
- # running the marketplace's own inventory (`admin_name`,
- # `propagate_all_variants`, `backorderable_default`). What a seller
- # needs is the address, whether it is live, and whether it is the one
- # their returns go to.
class StockLocationSerializer < V3::StockLocationSerializer
typelize address2: [:string, nullable: true], state_name: [:string, nullable: true],
phone: [:string, nullable: true], company: [:string, nullable: true],
diff --git a/spree/api/app/serializers/spree/api/v3/seller/tax_identifier_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/tax_identifier_serializer.rb
new file mode 100644
index 0000000000..11a2f9a49b
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/seller/tax_identifier_serializer.rb
@@ -0,0 +1,15 @@
+module Spree
+ module Api
+ module V3
+ module Seller
+ class TaxIdentifierSerializer < V3::BaseSerializer
+ typelize kind: :string, value: :string,
+ validation_status: [:string, nullable: true],
+ validated_at: [:string, nullable: true]
+
+ attributes :kind, :value, :validation_status, validated_at: :iso8601
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/serializers/spree/api/v3/seller/team_member_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/team_member_serializer.rb
index 241b8a4ab2..5508b7af16 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/team_member_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/team_member_serializer.rb
@@ -2,15 +2,6 @@ module Spree
module Api
module V3
module Seller
- # A teammate, as their colleagues on the same seller see them.
- #
- # Deliberately not the operator's `AdminUserSerializer`. That one
- # renders every store the user holds a role on, so the marketplace's
- # own store switcher can offer them — rendered to a seller it would
- # disclose the name and code of unrelated stores their teammate happens
- # to work for. It also scopes `roles` to the current *store*, which
- # answers a question nobody asked here: what matters is the teammate's
- # standing on this seller.
class TeamMemberSerializer < V3::BaseSerializer
typelize email: :string,
first_name: [:string, nullable: true],
diff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rb
index 722c082c3a..df3242791c 100644
--- a/spree/api/config/routes.rb
+++ b/spree/api/config/routes.rb
@@ -686,6 +686,9 @@ Spree::Core::Engine.add_routes do
# shape every later one follows — rooted in the seller by the anchor.
resources :products, only: [:index, :show, :create, :update, :destroy]
+ # Presigning for the documents onboarding asks a seller to upload.
+ resources :direct_uploads, only: [:create]
+
# Where this seller keeps stock, and so where their returns are sent.
# No destroy: a location holds stock levels and is named on historical
# fulfillments, so a seller retires one by deactivating it.
diff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rb
index d2590afe92..2a1d58845e 100644
--- a/spree/api/lib/spree/api/dependencies.rb
+++ b/spree/api/lib/spree/api/dependencies.rb
@@ -161,6 +161,8 @@ module Spree
seller_invitation_serializer: 'Spree::Api::V3::Seller::InvitationSerializer',
seller_product_serializer: 'Spree::Api::V3::Seller::ProductSerializer',
seller_stock_location_serializer: 'Spree::Api::V3::Seller::StockLocationSerializer',
+ seller_requirement_custom_field_serializer: 'Spree::Api::V3::Seller::RequirementCustomFieldSerializer',
+ seller_tax_identifier_serializer: 'Spree::Api::V3::Seller::TaxIdentifierSerializer',
seller_requirement_status_serializer: 'Spree::Api::V3::Seller::RequirementStatusSerializer',
seller_requirement_submission_serializer: 'Spree::Api::V3::Seller::RequirementSubmissionSerializer',
admin_seller_serializer: 'Spree::Api::V3::Admin::SellerSerializer',
diff --git a/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb
index b7952302a8..5a584a9afc 100644
--- a/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb
@@ -145,4 +145,109 @@ RSpec.describe Spree::Api::V3::Seller::ProfileController, type: :controller do
expect(response).to have_http_status(:forbidden)
end
end
+ # Custom fields on Spree::Seller are the operator's schema, and some are
+ # theirs alone. A seller fills in what onboarding asked them for.
+ describe 'PATCH #update custom fields' do
+ let(:asked_for) do
+ create(:custom_field_definition, resource_type: 'Spree::Seller', namespace: 'seller',
+ key: 'vat_number', label: 'VAT number')
+ end
+ let(:operator_only) do
+ create(:custom_field_definition, resource_type: 'Spree::Seller', namespace: 'seller',
+ key: 'risk_note', label: 'Risk note')
+ end
+ let!(:requirement) do
+ create(:required_custom_fields_requirement, store: store).tap do |req|
+ req.custom_field_definitions << asked_for
+ end
+ end
+
+ it 'writes a field the checklist asks for' do
+ patch :update, params: {
+ custom_fields: [{ custom_field_definition_id: asked_for.prefixed_id, value: 'GB123456789' }]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(seller.reload.custom_fields.find_by(custom_field_definition: asked_for).value).
+ to eq('GB123456789')
+ end
+
+ # The nested-attributes writer builds a row every time, so a seller
+ # correcting a value they had already saved hit the uniqueness index and
+ # got "has already been taken". The upserting writer is the right one.
+ it 'updates a field the seller already answered' do
+ patch :update, params: {
+ custom_fields: [{ custom_field_definition_id: asked_for.prefixed_id, value: 'GB111' }]
+ }, as: :json
+ patch :update, params: {
+ custom_fields: [{ custom_field_definition_id: asked_for.prefixed_id, value: 'GB222' }]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ fields = seller.reload.custom_fields.where(custom_field_definition: asked_for)
+ expect(fields.count).to eq(1)
+ expect(fields.first.value).to eq('GB222')
+ end
+
+ it 'ignores a field nothing asked them for' do
+ patch :update, params: {
+ custom_fields: [{ custom_field_definition_id: operator_only.prefixed_id, value: 'sneaky' }]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(seller.reload.custom_fields.find_by(custom_field_definition: operator_only)).to be_nil
+ end
+ end
+
+ # The business identity a commission invoice is made out to — legal name,
+ # registration number, and the VAT number EU reverse charge turns on.
+ describe 'PATCH #update business identity' do
+ it 'writes the legal name and registration number' do
+ patch :update, params: {
+ legal_name: 'Sparks Trading Ltd', registration_number: '01234567'
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(seller.reload.legal_name).to eq('Sparks Trading Ltd')
+ expect(seller.registration_number).to eq('01234567')
+ end
+
+ it 'records a tax registration' do
+ patch :update, params: { tax_identifier: { kind: 'eu_vat', value: 'GB123456789' } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ identifier = seller.reload.tax_identifiers.find_by(kind: 'eu_vat')
+ expect(identifier.value).to eq('GB123456789')
+ end
+
+ # One per kind, so correcting the number replaces it rather than stacking
+ # a second row the model would refuse.
+ it 'corrects a registration rather than adding a second' do
+ patch :update, params: { tax_identifier: { kind: 'eu_vat', value: 'GB111' } }, as: :json
+ patch :update, params: { tax_identifier: { kind: 'eu_vat', value: 'GB222' } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ identifiers = seller.reload.tax_identifiers.where(kind: 'eu_vat')
+ expect(identifiers.count).to eq(1)
+ expect(identifiers.first.value).to eq('GB222')
+ end
+
+ it 'removes it when the seller clears the number' do
+ patch :update, params: { tax_identifier: { kind: 'eu_vat', value: 'GB111' } }, as: :json
+ patch :update, params: { tax_identifier: { kind: 'eu_vat', value: '' } }, as: :json
+
+ expect(seller.reload.tax_identifiers.where(kind: 'eu_vat')).to be_empty
+ end
+
+ it 'serializes them back' do
+ seller.tax_identifiers.create!(kind: 'eu_vat', value: 'GB123456789')
+
+ get :show, as: :json
+
+ expect(json_response['tax_identifiers'].first).to include(
+ 'kind' => 'eu_vat', 'value' => 'GB123456789'
+ )
+ end
+ end
+
end
diff --git a/spree/core/app/models/spree/seller_requirement_status.rb b/spree/core/app/models/spree/seller_requirement_status.rb
index d1a2c0c1e5..8ef0e9ddf3 100644
--- a/spree/core/app/models/spree/seller_requirement_status.rb
+++ b/spree/core/app/models/spree/seller_requirement_status.rb
@@ -34,6 +34,41 @@ module Spree
# @return [Spree::SellerRequirementSubmission, nil]
attr_accessor :submission
+ # The requirement this was evaluated from.
+ #
+ # Carried so a serializer can ask the kind its own questions — which
+ # custom fields it names, whether it takes a file — without re-fetching a
+ # row the evaluator has already loaded. Not serialized itself: what a
+ # client needs is the answers, not the configuration row.
+ #
+ # @return [Spree::SellerRequirement, nil]
+ attr_accessor :requirement
+
+ # The seller this was evaluated against, so kind-specific readers can ask
+ # about them without the caller passing them a second time.
+ #
+ # @return [Spree::Seller, nil]
+ attr_accessor :seller
+
+ # The custom fields this line asks for, each paired with the seller's
+ # current answer — empty for every kind that asks for none.
+ #
+ # Built here rather than in the serializer because it is the answer to
+ # "what does this requirement want", which is the value object's job; the
+ # serializer only decides how to render it.
+ #
+ # @return [Array<Hash>] `{ definition:, custom_field: }` pairs
+ def custom_fields
+ return [] unless requirement.respond_to?(:custom_field_definitions)
+ return [] if seller.nil?
+
+ answered = seller.custom_fields.index_by(&:custom_field_definition_id)
+
+ requirement.custom_field_definitions.map do |definition|
+ { definition: definition, custom_field: answered[definition.id] }
+ end
+ end
+
# ActiveModel::Attributes gives readers, not predicates.
def required?
!!required
diff --git a/spree/core/app/services/spree/sellers/requirements.rb b/spree/core/app/services/spree/sellers/requirements.rb
index ecaba79aa1..92406d8f0e 100644
--- a/spree/core/app/services/spree/sellers/requirements.rb
+++ b/spree/core/app/services/spree/sellers/requirements.rb
@@ -114,7 +114,9 @@ module Spree
position: requirement.position,
status: requirement.status_for(seller),
action_url: requirement.action_url(seller),
- submission: requirement.latest_submission(seller)
+ submission: requirement.latest_submission(seller),
+ requirement: requirement,
+ seller: seller
)
end
end