From 265710e146ddb252b6099e0a43e141a03ef337e5 Mon Sep 17 00:00:00 2001 From: Clay Stewart Date: Tue, 1 Sep 2026 23:15:49 -0500 Subject: [PATCH] Preview store create labels its requests and opts in to the warm pool The backend stocks warm preview stores per (country, source) cell and hands one out only when the request's label matches the cell. Sending source: "shopify_cli" and pool: true together makes the CLI's create shape a stockable cell; both fields are inert until the backend enables the pool for this source (falls back to inline creation, response shape unchanged). Assisted-By: devx/d9f7a8a7-1f7d-4574-9579-5c2486504a94 --- .changeset/preview-store-pool-opt-in.md | 5 +++++ .../cli/services/store/create/preview/client.test.ts | 6 ++++-- .../src/cli/services/store/create/preview/client.ts | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .changeset/preview-store-pool-opt-in.md diff --git a/.changeset/preview-store-pool-opt-in.md b/.changeset/preview-store-pool-opt-in.md new file mode 100644 index 00000000000..f34aaf90368 --- /dev/null +++ b/.changeset/preview-store-pool-opt-in.md @@ -0,0 +1,5 @@ +--- +'@shopify/store': patch +--- + +Preview store creation now labels its requests (`source: "shopify_cli"`) and opts in to the backend's warm pool (`pool: true`). Inert until the backend enables the pool for this source; creation falls back to inline behavior otherwise, with an unchanged response shape. diff --git a/packages/store/src/cli/services/store/create/preview/client.test.ts b/packages/store/src/cli/services/store/create/preview/client.test.ts index e422c75e55e..e909549833d 100644 --- a/packages/store/src/cli/services/store/create/preview/client.test.ts +++ b/packages/store/src/cli/services/store/create/preview/client.test.ts @@ -111,6 +111,8 @@ describe('preview store client', () => { }), body: JSON.stringify({ name: 'Lavender Candles', + source: 'shopify_cli', + pool: true, variables: {storeCreatePayload: {country: 'US'}}, }), }) @@ -153,7 +155,7 @@ describe('preview store client', () => { expect(got.adminApiScopes).toEqual(['read_themes', 'write_themes']) }) - test('omits name and country variables when absent', async () => { + test('omits name and country variables when absent (label and pool opt-in always sent)', async () => { vi.mocked(shopifyFetch).mockResolvedValueOnce( response(201, { shop: {id: 123, name: 'My Store', domain: 'x.myshopify.com'}, @@ -165,7 +167,7 @@ describe('preview store client', () => { await createPreviewStore({}, {storage: inMemoryStorage('instance-1')}) - expect(vi.mocked(shopifyFetch).mock.calls[0]![1]!.body).toBe('{}') + expect(vi.mocked(shopifyFetch).mock.calls[0]![1]!.body).toBe(JSON.stringify({source: 'shopify_cli', pool: true})) }) test.each([ diff --git a/packages/store/src/cli/services/store/create/preview/client.ts b/packages/store/src/cli/services/store/create/preview/client.ts index 5de06e37bab..e5038f50b9c 100644 --- a/packages/store/src/cli/services/store/create/preview/client.ts +++ b/packages/store/src/cli/services/store/create/preview/client.ts @@ -25,6 +25,15 @@ function clientStorage() { export interface PreviewStoreClientOptions extends PreviewStoreRequestOptions {} +// The CLI's create label + warm-pool opt-in, sent together on purpose: the +// backend stocks warm preview stores per (country, source) cell, so the same +// release that asks for a pooled store (pool: true) must label the request +// (source: "shopify_cli") for the pool to have a matching cell. Both fields +// are inert until the backend enables the pool for this source: an unstocked +// or disabled pool falls back to inline creation and the response shape is +// unchanged. +export const PREVIEW_STORE_SOURCE = 'shopify_cli' + interface PreviewStoreCreateRequest { name?: string country?: string @@ -137,6 +146,8 @@ export async function createPreviewStore( const url = `https://${fqdn}/services/preview-stores` const body = JSON.stringify({ ...(request.name ? {name: request.name} : {}), + source: PREVIEW_STORE_SOURCE, + pool: true, ...(request.country ? { variables: {