@shopify/shop-minis-platform 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-platform",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.21.0",
4
+ "version": "0.23.0",
5
5
  "description": "Shared type definitions for Shop Minis Platform",
6
6
  "main": "src/index.ts",
7
7
  "exports": {
@@ -91,8 +91,20 @@ export interface SelectProductVariantParams {
91
91
  * inventory (or unbounded when stock is not tracked).
92
92
  */
93
93
  maxQuantity?: number
94
- /** Whether to show the quantity stepper. Defaults to `true`. */
94
+ /**
95
+ * Whether to show the quantity stepper. Defaults to `false` for the
96
+ * `select` intent (selection is informational; quantity is rarely
97
+ * relevant). Pass `true` to opt into the stepper.
98
+ */
95
99
  showQuantity?: boolean
100
+ /**
101
+ * When `true`, the sheet's confirm CTA stays enabled even for a sold-out
102
+ * variant — the host hands the selection back to the mini without
103
+ * touching the cart. Defaults to `true` for the `select` intent so flows
104
+ * like “notify me when back in stock” can pick a sold-out variant. Pass
105
+ * `false` to restore the cart-style sold-out guard.
106
+ */
107
+ allowOutOfStockSelection?: boolean
96
108
  /**
97
109
  * When `true`, always render the sheet — even for products with a single
98
110
  * variant. The single-variant short-circuit (resolving instantly without
@@ -248,6 +260,89 @@ export type AddToCartProductVariantResult =
248
260
  | AddToCartAddedResult
249
261
  | AddToCartNavigatedToProductResult
250
262
 
263
+ // ---------------------------------------------------------------------------
264
+ // Buy Now Intent — buy_now:shopify/ProductVariant
265
+ // ---------------------------------------------------------------------------
266
+
267
+ /**
268
+ * Data payload for the `buy_now:shopify/ProductVariant` intent.
269
+ *
270
+ * Sends the user to express checkout for a variant, bypassing the cart. If
271
+ * `productVariantId` is omitted (or `forceShow` is `true`), the host opens
272
+ * the same native variant selector sheet as the other variant intents — the
273
+ * user picks a variant and quantity, and the host then creates the checkout
274
+ * on confirm.
275
+ *
276
+ * For products outside Shop's catalog (referral products), the host
277
+ * navigates the user to the product's PDP instead.
278
+ *
279
+ * @publicDocs
280
+ */
281
+ export interface BuyNowProductVariantParams {
282
+ /** The GID of the product. E.g. `gid://shopify/Product/123`. */
283
+ productId: string
284
+ /**
285
+ * The GID of the variant to buy. When provided, the host creates the
286
+ * checkout directly without showing the sheet. Omit to let the user pick.
287
+ */
288
+ productVariantId?: string
289
+ /** Quantity to buy. Defaults to `1`. */
290
+ quantity?: number
291
+ /** Discount code to apply to the checkout. */
292
+ discountCode?: string
293
+ /** Allow-list of variant GIDs surfaced in the sheet. */
294
+ includedProductVariantGIDs?: string[]
295
+ /** Variant initially highlighted in the picker. */
296
+ initialVariantId?: string
297
+ /** Initial quantity in the stepper. Defaults to `quantity ?? 1`. */
298
+ initialQuantity?: number
299
+ /** Max quantity selectable in the stepper. */
300
+ maxQuantity?: number
301
+ /** Whether to show the quantity stepper. Defaults to `true`. */
302
+ showQuantity?: boolean
303
+ /**
304
+ * When `true`, always render the sheet — even for single-variant products
305
+ * or when `productVariantId` is supplied. Defaults to `false`.
306
+ */
307
+ forceShow?: boolean
308
+ }
309
+
310
+ /**
311
+ * Checkout opened for a concrete variant by `buy_now:shopify/ProductVariant`.
312
+ */
313
+ export interface BuyNowCheckoutOpenedResult extends ProductVariantSelection {
314
+ /** Discriminator. The host opened express checkout for a variant. */
315
+ outcome: 'checkout_opened'
316
+ }
317
+
318
+ /**
319
+ * Returned when the product cannot be bought from the mini (e.g. referral
320
+ * products outside Shop's catalog) and the host instead sent the user to
321
+ * the product's PDP. The mini should treat this as a successful hand-off.
322
+ */
323
+ export interface BuyNowNavigatedToProductResult {
324
+ /** Discriminator. The host navigated the user to the PDP instead. */
325
+ outcome: 'navigated_to_product'
326
+ /** GID of the product the host navigated to. */
327
+ productId: string
328
+ }
329
+
330
+ /**
331
+ * Successful payload returned from `buy_now:shopify/ProductVariant`.
332
+ *
333
+ * Discriminate via `data.outcome`:
334
+ * - `'checkout_opened'` — express checkout opened for a concrete variant;
335
+ * selection fields (`productVariantId`, `quantity`, `source`) are present.
336
+ * - `'navigated_to_product'` — the host could not buy this product (e.g.
337
+ * referral product on another merchant's storefront) and instead sent
338
+ * the user to the PDP. Only `productId` is present.
339
+ *
340
+ * @publicDocs
341
+ */
342
+ export type BuyNowProductVariantResult =
343
+ | BuyNowCheckoutOpenedResult
344
+ | BuyNowNavigatedToProductResult
345
+
251
346
  // ---------------------------------------------------------------------------
252
347
  // Intent Registry
253
348
  // ---------------------------------------------------------------------------
@@ -277,6 +372,12 @@ export interface IntentDefinitions {
277
372
  data: AddToCartProductVariantParams
278
373
  result: AddToCartProductVariantResult
279
374
  }
375
+ buyNowProductVariant: {
376
+ action: 'buy_now'
377
+ type: 'shopify/ProductVariant'
378
+ data: BuyNowProductVariantParams
379
+ result: BuyNowProductVariantResult
380
+ }
280
381
  }
281
382
 
282
383
  export type IntentKey = keyof IntentDefinitions
@@ -296,6 +397,10 @@ export const INTENT_REGISTRY = {
296
397
  action: 'add_to_cart',
297
398
  type: 'shopify/ProductVariant',
298
399
  },
400
+ buyNowProductVariant: {
401
+ action: 'buy_now',
402
+ type: 'shopify/ProductVariant',
403
+ },
299
404
  } as const satisfies {
300
405
  [K in IntentKey]: {
301
406
  action: IntentDefinitions[K]['action']