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: {