@shopify/app-bridge-types 0.5.2 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#943](https://github.com/Shopify/extensibility/pull/943) [`9f8ecdb615732364fbdb1c010f385e58b4b5525d`](https://github.com/Shopify/extensibility/commit/9f8ecdb615732364fbdb1c010f385e58b4b5525d) Thanks [@bashu-shopify](https://github.com/bashu-shopify)! - Add theme app extension types to the App Bridge extensions API
8
+
9
+ This adds support for theme app extensions (blocks and embeds) in the `shopify.app.extensions()` API response. New types include:
10
+
11
+ - `ExtensionType`: `'ui_extension' | 'theme_app_extension'`
12
+ - `ActivationStatus`: `'active' | 'available' | 'unavailable'`
13
+ - `ThemeExtensionActivation`: Represents a theme app block or embed
14
+ - `ThemeAppBlockActivation`: Represents where a block is placed in a theme
15
+ - `ThemeAppBlockTarget` and `ThemeAppEmbedTarget`: Target location types
16
+
17
+ The `ExtensionInfo` interface is now a generic that provides typed activations based on the extension type.
18
+
19
+ ## 0.6.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#932](https://github.com/Shopify/extensibility/pull/932) [`e6a8c26486ab44faa524d8041bbdcb3bbb6b1515`](https://github.com/Shopify/extensibility/commit/e6a8c26486ab44faa524d8041bbdcb3bbb6b1515) Thanks [@bashu-shopify](https://github.com/bashu-shopify)! - Add theme app extension types to the App Bridge extensions API
24
+
25
+ This adds support for theme app extensions (blocks and embeds) in the `shopify.app.extensions()` API response. New types include:
26
+
27
+ - `ExtensionType`: `'ui_extension' | 'theme_app_extension'`
28
+ - `ActivationStatus`: `'active' | 'available' | 'unavailable'`
29
+ - `ThemeExtensionActivation`: Represents a theme app block or embed
30
+ - `ThemeAppBlockActivation`: Represents where a block is placed in a theme
31
+ - `ThemeAppBlockTarget` and `ThemeAppEmbedTarget`: Target location types
32
+
33
+ The `ExtensionInfo` interface is now a generic that provides typed activations based on the extension type.
34
+
35
+ ## 0.5.3
36
+
37
+ ### Patch Changes
38
+
39
+ - [#817](https://github.com/Shopify/extensibility/pull/817) [`196fc00a83f058c00a07ff0393cf7c82fd0e8537`](https://github.com/Shopify/extensibility/commit/196fc00a83f058c00a07ff0393cf7c82fd0e8537) Thanks [@olavoasantos](https://github.com/olavoasantos)! - Fix WebVitals onReport payload type
40
+
3
41
  ## 0.5.2
4
42
 
5
43
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ import type {
20
20
  ProductVariant,
21
21
  Collection,
22
22
  } from './shopify';
23
+ import {type InternalPolarisApi} from './types';
23
24
 
24
25
  export {
25
26
  ShopifyGlobal,
@@ -37,6 +38,7 @@ export {
37
38
 
38
39
  declare global {
39
40
  var shopify: ShopifyGlobal;
41
+ var polaris: InternalPolarisApi['global'] | undefined;
40
42
 
41
43
  // Install property augmentations onto DOM prototypes
42
44
  interface HTMLButtonElement extends AugmentedElement<'button'> {}
package/dist/shopify.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
2
 
3
+ /**
4
+ * The availability status of a theme app block or embed.
5
+ * - 'active': Block/embed is currently present in a theme.
6
+ * - 'available': Block/embed exists but is not currently active
7
+ * - 'unavailable': Block/embed exists but is disabled (e.g., via available_if condition)
8
+ *
9
+ * Note that if a block is present in a theme but is not available, its status will be 'unavailable'.
10
+ */
11
+ type ActivationStatus = 'active' | 'available' | 'unavailable';
12
+
3
13
  interface Address {
4
14
  /**
5
15
  * The customer's primary address.
@@ -68,7 +78,7 @@ interface AdminUser {
68
78
  interface AppApi {
69
79
  /**
70
80
  * The list of extensions from the current app.
71
- * @returns A promise that resolves to the array of ExtensionResponse containing extension status information.
81
+ * @returns A promise that resolves to the array of ExtensionInfo containing extension status information.
72
82
  *
73
83
  * This array may be empty if the app has no extensions.
74
84
  *
@@ -374,32 +384,39 @@ interface ErrorIntentResponse {
374
384
  }
375
385
 
376
386
  /**
377
- * Represents an activation record for an extension.
378
- * Contains information about where an extension is activated.
379
- */
380
- interface ExtensionActivation {
381
- /**
382
- * The target identifier for the extension activation.
383
- */
384
- target: string;
385
- }
386
-
387
- /**
388
- * Contains the status information for the app's extension.
389
- * This includes the extension's handle, and activation targets.
387
+ * Contains the status information for the App's extension.
388
+ * This includes the extension's handle, activation targets, status, and type.
389
+ *
390
+ * @typeParam Type - The extension type, either 'ui_extension' or 'theme_app_extension'.
391
+ * When specified, the `activations` field will be typed accordingly:
392
+ * - `ExtensionInfo<'ui_extension'>` has `activations: UiExtensionActivation[]`
393
+ * - `ExtensionInfo<'theme_app_extension'>` has `activations: ThemeExtensionActivation[]`
390
394
  */
391
- interface ExtensionInfo {
395
+ interface ExtensionInfo<Type extends ExtensionType = ExtensionType> {
392
396
  /**
393
397
  * The unique identifier for the extension.
394
398
  */
395
399
  handle: string;
396
400
  /**
397
401
  * List of activation records for the extension.
398
- * Contains information about where the extension is currently activated.
402
+ * The shape depends on the extension type:
403
+ * - UI extensions have activations with only `target`
404
+ * - Theme app extensions have nested activations representing blocks/embeds
405
+ */
406
+ activations: Type extends 'ui_extension' ? UiExtensionActivation[] : Type extends 'theme_app_extension' ? ThemeExtensionActivation[] : never;
407
+ /**
408
+ * The type of the extension.
399
409
  */
400
- activations: ExtensionActivation[];
410
+ type: Type;
401
411
  }
402
412
 
413
+ /**
414
+ * The type of extension.
415
+ * - 'ui_extension' for checkout and customer account extensions
416
+ * - 'theme_app_extension' for theme app extensions (blocks and embeds)
417
+ */
418
+ type ExtensionType = 'ui_extension' | 'theme_app_extension';
419
+
403
420
  interface Filters {
404
421
  /**
405
422
  * Whether to show hidden resources, referring to products that are not published on any sales channels.
@@ -1245,6 +1262,65 @@ interface SupportApi {
1245
1262
 
1246
1263
  type SupportCallback = () => void | Promise<void>;
1247
1264
 
1265
+ /**
1266
+ * Represents a theme-specific activation for a block/embed.
1267
+ * Contains the specific placement within a theme.
1268
+ */
1269
+ interface ThemeAppBlockActivation {
1270
+ /**
1271
+ * The target identifier for the block/embed placement within the theme.
1272
+ * Example: 'template--product.alternate/main/my_app_product_rating_GPzUYy'
1273
+ */
1274
+ target: string;
1275
+ /**
1276
+ * The theme ID where this block/embed is activated.
1277
+ * Format: gid://shopify/OnlineStoreTheme/{id}
1278
+ */
1279
+ themeId: string;
1280
+ }
1281
+
1282
+ /**
1283
+ * Target location for theme app blocks.
1284
+ */
1285
+ type ThemeAppBlockTarget = 'section';
1286
+
1287
+ /**
1288
+ * Target location for theme app embeds.
1289
+ */
1290
+ type ThemeAppEmbedTarget = 'head' | 'body' | 'compliance_head';
1291
+
1292
+ /**
1293
+ * Represents an activation record for a theme app block or embed.
1294
+ * Each block/embed within a theme app extension has its own handle, status, and activations.
1295
+ */
1296
+ interface ThemeExtensionActivation {
1297
+ /**
1298
+ * The target location type for this block/embed.
1299
+ * - 'section' for blocks
1300
+ * - 'head', 'body', or 'compliance_head' for embeds
1301
+ */
1302
+ target: ThemeAppBlockTarget | ThemeAppEmbedTarget;
1303
+ /**
1304
+ * The filename of the block/embed within the theme app extension (without extension).
1305
+ * This is configured by the developer when creating the block file.
1306
+ */
1307
+ handle: string;
1308
+ /**
1309
+ * The developer-configured display name of this block/embed, defined in the block's schema.
1310
+ * @see https://shopify.dev/docs/apps/build/online-store/theme-app-extensions/configuration#schema
1311
+ */
1312
+ name: string;
1313
+ /**
1314
+ * The availability status of this block/embed.
1315
+ */
1316
+ status: ActivationStatus;
1317
+ /**
1318
+ * List of theme-specific activations for this block/embed.
1319
+ * Contains where the block is actually placed within themes.
1320
+ */
1321
+ activations: ThemeAppBlockActivation[];
1322
+ }
1323
+
1248
1324
  /**
1249
1325
  * The Toast API provides methods to display Toast notifications in the Shopify admin.
1250
1326
  */
@@ -1297,6 +1373,17 @@ type ToastShow = (message: string, opts?: ToastOptions) => string;
1297
1373
 
1298
1374
  type Tone = 'info' | 'success' | 'warning' | 'critical';
1299
1375
 
1376
+ /**
1377
+ * Represents an activation record for a UI extension (checkout, customer account).
1378
+ */
1379
+ interface UiExtensionActivation {
1380
+ /**
1381
+ * The target identifier for the extension activation.
1382
+ * Example: 'purchase.thank-you.block.render'
1383
+ */
1384
+ target: string;
1385
+ }
1386
+
1300
1387
  export interface UIModalAttributes extends _UIModalAttributes {
1301
1388
  children?: any;
1302
1389
  }
@@ -1526,7 +1613,7 @@ interface WebVitalsApi {
1526
1613
  onReport?: (callback: WebVitalsCallback | null) => Promise<void>;
1527
1614
  }
1528
1615
 
1529
- type WebVitalsCallback = (metrics: WebVitalsMetric) => void | Promise<void>;
1616
+ type WebVitalsCallback = (payload: WebVitalsReport) => void | Promise<void>;
1530
1617
 
1531
1618
  /**
1532
1619
  * WebVitals API
@@ -1537,6 +1624,10 @@ interface WebVitalsMetric {
1537
1624
  value: number;
1538
1625
  }
1539
1626
 
1627
+ interface WebVitalsReport {
1628
+ metrics: WebVitalsMetric[];
1629
+ }
1630
+
1540
1631
  enum WeightUnit {
1541
1632
  Kilograms = "KILOGRAMS",
1542
1633
  Grams = "GRAMS",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/app-bridge-types",
3
- "version": "0.5.2",
3
+ "version": "0.7.0",
4
4
  "description": "Companion types library for the Shopify App Bridge script",
5
5
  "private": false,
6
6
  "publishConfig": {