@shopify/app-bridge-types 0.3.0 → 0.5.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#781](https://github.com/Shopify/extensibility/pull/781) [`e8e0b29249891fd59e7a709b8c6990fa5ae6908b`](https://github.com/Shopify/extensibility/commit/e8e0b29249891fd59e7a709b8c6990fa5ae6908b) Thanks [@charlesdobson](https://github.com/charlesdobson)! - add types for intents.invoke API
8
+
9
+ ## 0.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#760](https://github.com/Shopify/extensibility/pull/760) [`4f7742e4aacb581a380c76742689dca617c86b6d`](https://github.com/Shopify/extensibility/commit/4f7742e4aacb581a380c76742689dca617c86b6d) Thanks [@Fionoble](https://github.com/Fionoble)! - Add new s-app-\* types
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -13,3 +13,26 @@ You can install Shopify App Bridge Types by using [Yarn](https://yarnpkg.com):
13
13
  ```sh
14
14
  yarn add --dev @shopify/app-bridge-types
15
15
  ```
16
+
17
+ ## Development
18
+
19
+ ### How Types are Generated
20
+
21
+ The types in this package are automatically generated from the `sandboxes/app-bridge-next` source code:
22
+
23
+ 1. Types are defined in `sandboxes/app-bridge-next/src/features/`
24
+ 2. During build, they're compiled to `sandboxes/app-bridge-next/dist/app-bridge.d.ts`
25
+ 3. The build script (`scripts/build.mjs`) processes and copies these types to the `dist` folder
26
+ 4. The processed types are then published to npm
27
+
28
+ ### Releasing a New Version
29
+
30
+ To release a new version of the types package:
31
+
32
+ 1. Make your changes to the type definitions in `sandboxes/app-bridge-next/src/features/`
33
+ 2. Run `pnpm changeset` from the root of the repository
34
+ 3. Select `@shopify/app-bridge-types` to bump its version
35
+ 4. Commit your changes
36
+ 5. CI will automatically handle building and publishing the updated package
37
+
38
+ The automation ensures that the types stay in sync with the app-bridge-next implementation.
package/dist/index.d.ts CHANGED
@@ -4,11 +4,15 @@ import type {
4
4
  AppBridgeElements,
5
5
  AppBridgeAttributes,
6
6
  UIModalElement as BaseUIModalElement,
7
+ SAppWindowElement as BaseSAppWindowElement,
7
8
  UINavMenuElement as BaseUINavMenuElement,
9
+ SAppNavElement as BaseSAppNavElement,
8
10
  UITitleBarElement as BaseUITitleBarElement,
9
11
  UISaveBarElement as BaseUISaveBarElement,
10
12
  UIModalAttributes,
13
+ SAppWindowAttributes,
11
14
  UINavMenuAttributes,
15
+ SAppNavAttributes,
12
16
  UITitleBarAttributes,
13
17
  UISaveBarAttributes,
14
18
  ToastOptions,
@@ -20,7 +24,9 @@ import type {
20
24
  export {
21
25
  ShopifyGlobal,
22
26
  UIModalAttributes,
27
+ SAppWindowAttributes,
23
28
  UINavMenuAttributes,
29
+ SAppNavAttributes,
24
30
  UITitleBarAttributes,
25
31
  UISaveBarAttributes,
26
32
  ToastOptions,
@@ -37,7 +43,9 @@ declare global {
37
43
  interface HTMLAnchorElement extends AugmentedElement<'a'> {}
38
44
 
39
45
  interface UIModalElement extends BaseUIModalElement {}
46
+ interface SAppWindowElement extends BaseSAppWindowElement {}
40
47
  interface UINavMenuElement extends BaseUINavMenuElement {}
48
+ interface SAppNavElement extends BaseSAppNavElement {}
41
49
  interface UITitleBarElement extends BaseUITitleBarElement {}
42
50
  interface UISaveBarElement extends BaseUISaveBarElement {}
43
51
 
package/dist/shopify.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+
1
3
  interface Address {
2
4
  /**
3
5
  * The customer's primary address.
@@ -136,10 +138,12 @@ interface AppBridgeConfig {
136
138
 
137
139
  export interface AppBridgeElements {
138
140
  'ui-modal': UIModalAttributes;
141
+ 's-app-window': SAppWindowAttributes;
139
142
  'ui-nav-menu': UINavMenuAttributes;
140
143
  's-app-nav': SAppNavAttributes;
141
144
  'ui-save-bar': UISaveBarAttributes;
142
145
  'ui-title-bar': UITitleBarAttributes;
146
+ 's-page': SPageAttributes;
143
147
  }
144
148
 
145
149
  export type AugmentedElement<T extends keyof AugmentedElements> = AugmentedElements[T];
@@ -210,6 +214,13 @@ interface Cart {
210
214
  */
211
215
  type CartSubscriber = (cart: Cart) => void;
212
216
 
217
+ /**
218
+ * User dismissed or closed the workflow without completing it.
219
+ */
220
+ interface ClosedIntentResponse {
221
+ code?: 'closed';
222
+ }
223
+
213
224
  export interface Collection extends Resource {
214
225
  availablePublicationCount: number;
215
226
  description: string;
@@ -353,6 +364,15 @@ interface _EnvironmentApi {
353
364
  pos?: boolean;
354
365
  }
355
366
 
367
+ /**
368
+ * Failed intent completion.
369
+ */
370
+ interface ErrorIntentResponse {
371
+ code?: 'error';
372
+ message?: string;
373
+ issues?: StandardSchemaV1.Issue[];
374
+ }
375
+
356
376
  /**
357
377
  * Represents an activation record for an extension.
358
378
  * Contains information about where an extension is activated.
@@ -456,10 +476,61 @@ interface Intent {
456
476
  finish: Finish;
457
477
  }
458
478
 
459
- interface IntentsApi {
479
+ /**
480
+ * The action to perform on a resource.
481
+ */
482
+ type IntentAction = 'create' | 'edit';
483
+
484
+ /**
485
+ * Activity handle for tracking intent workflow progress.
486
+ */
487
+ interface IntentActivity {
488
+ /**
489
+ * A Promise that resolves when the intent workflow completes, returning the response.
490
+ */
491
+ complete?: Promise<IntentResponse>;
492
+ }
493
+
494
+ interface IntentQuery extends IntentQueryOptions {
495
+ action: IntentAction;
496
+ type: IntentType;
497
+ }
498
+
499
+ /**
500
+ * Options for invoking intents when using the query string format.
501
+ */
502
+ interface IntentQueryOptions {
503
+ /**
504
+ * The resource identifier for edit actions (e.g., 'gid://shopify/Product/123').
505
+ */
506
+ value?: string;
507
+ /**
508
+ * Additional data required for certain intent types.
509
+ * For example:
510
+ * - Discount creation requires { type: 'amount-off-product' | 'amount-off-order' | 'buy-x-get-y' | 'free-shipping' }
511
+ * - ProductVariant creation requires { productId: 'gid://shopify/Product/123' }
512
+ * - Metaobject creation requires { type: 'shopify--color-pattern' }
513
+ */
514
+ data?: {
515
+ [key: string]: unknown;
516
+ };
517
+ }
518
+
519
+ /**
520
+ * Result of an intent activity.
521
+ * Discriminated union representing all possible completion outcomes.
522
+ */
523
+ type IntentResponse = ClosedIntentResponse | SuccessIntentResponse | ErrorIntentResponse;
524
+
525
+ interface IntentsApi extends PublicIntentsApi {
460
526
  register(callback: (intent: Intent) => void): () => void;
461
527
  }
462
528
 
529
+ /**
530
+ * Supported resource types that can be targeted by intents.
531
+ */
532
+ type IntentType = 'shopify/Article' | 'shopify/Catalog' | 'shopify/Collection' | 'shopify/Customer' | 'shopify/Discount' | 'shopify/Market' | 'shopify/Menu' | 'shopify/MetafieldDefinition' | 'shopify/Metaobject' | 'shopify/MetaobjectDefinition' | 'shopify/Page' | 'shopify/Product' | 'shopify/ProductVariant';
533
+
463
534
  interface LineItem {
464
535
  /**
465
536
  * Unique id of line item
@@ -871,6 +942,37 @@ enum ProductVariantInventoryPolicy {
871
942
 
872
943
  type Progress = 'incomplete' | 'partiallyComplete' | 'complete';
873
944
 
945
+ /**
946
+ * Entry point for Shopify intents.
947
+ *
948
+ * A unified surface for describing and orchestrating operations. Intents pair
949
+ * an `action` (verb) with a resource `type` and optional `value` and `data`
950
+ * to request a workflow.
951
+ */
952
+ interface PublicIntentsApi {
953
+ /**
954
+ * Invoke an intent using the object syntax.
955
+ *
956
+ * @param query - Structured intent description, including `action` and `type`.
957
+ * @returns A promise for an {@link IntentActivity} that completes with an
958
+ * {@link IntentResponse}.
959
+ */
960
+ invoke?(query: IntentQuery): Promise<IntentActivity>;
961
+ /**
962
+ * Invoke an intent using the URL syntax.
963
+ *
964
+ * URL format: `action:type[,value][?params]`.
965
+ *
966
+ * @param intentURL - Intent in URL form, e.g. `create:shopify/Product` or
967
+ * `edit:shopify/Product,gid://shopify/Product/123?title=Updated` or
968
+ * `edit:gid://shopify/Product/123`.
969
+ * @param options - Optional supplemental inputs such as `value` or `data`.
970
+ * @returns A promise for an {@link IntentActivity} that completes with an
971
+ * {@link IntentResponse}.
972
+ */
973
+ invoke?(intentURL: string, options?: IntentQueryOptions): Promise<IntentActivity>;
974
+ }
975
+
874
976
  interface Resource {
875
977
  /** in GraphQL id format, ie 'gid://shopify/Product/1' */
876
978
  id: string;
@@ -948,8 +1050,61 @@ export interface SAppNavAttributes {
948
1050
  children?: any;
949
1051
  }
950
1052
 
951
- export interface SAppNavElement extends HTMLElement {
1053
+ interface SAppNavElement_2 extends HTMLElement {
952
1054
  }
1055
+ export type { SAppNavElement_2 as SAppNavElement }
1056
+
1057
+ export interface SAppWindowAttributes {
1058
+ /**
1059
+ * A unique identifier for the S-App-Window
1060
+ */
1061
+ id?: string;
1062
+ /**
1063
+ * The URL of the content to display within the S-App-Window.
1064
+ * S-App-Window only supports src-based content (required).
1065
+ */
1066
+ src: string;
1067
+ }
1068
+
1069
+ interface _SAppWindowElement {
1070
+ /**
1071
+ * Always returns undefined for s-app-window (src-only)
1072
+ */
1073
+ readonly content: undefined;
1074
+ /**
1075
+ * A getter/setter for the s-app-window src URL
1076
+ */
1077
+ src?: string;
1078
+ /**
1079
+ * A getter for the Window object of the s-app-window iframe.
1080
+ * Only accessible when the s-app-window is open.
1081
+ */
1082
+ readonly contentWindow?: Window | null;
1083
+ /**
1084
+ * Shows the s-app-window element
1085
+ */
1086
+ show?(): Promise<void>;
1087
+ /**
1088
+ * Hides the s-app-window element
1089
+ */
1090
+ hide?(): Promise<void>;
1091
+ /**
1092
+ * Toggles the s-app-window element between showing and hidden states
1093
+ */
1094
+ toggle?(): Promise<void>;
1095
+ /**
1096
+ * Add 'show' | 'hide' event listeners.
1097
+ */
1098
+ addEventListener?(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
1099
+ /**
1100
+ * Remove 'show' | 'hide' event listeners.
1101
+ */
1102
+ removeEventListener?(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
1103
+ }
1104
+
1105
+ interface SAppWindowElement_2 extends Omit<HTMLElement, 'addEventListener' | 'removeEventListener'>, Required<Omit<_SAppWindowElement, 'src' | 'contentWindow'>>, Pick<_SAppWindowElement, 'src' | 'contentWindow'> {
1106
+ }
1107
+ export type { SAppWindowElement_2 as SAppWindowElement }
953
1108
 
954
1109
  interface SaveBarApi extends Required<_SaveBarApi> {
955
1110
  }
@@ -1058,6 +1213,32 @@ export interface ShopifyGlobal {
1058
1213
  app: AppApi;
1059
1214
  }
1060
1215
 
1216
+ export interface SPageAttributes {
1217
+ heading?: string;
1218
+ children?: SPageChildren;
1219
+ }
1220
+
1221
+ interface SPageChildren {
1222
+ primaryAction?: HTMLElement;
1223
+ secondaryActions?: HTMLElement[];
1224
+ breadcrumbActions?: HTMLElement;
1225
+ }
1226
+
1227
+ export interface SPageElement {
1228
+ heading?: string;
1229
+ children?: SPageChildren;
1230
+ }
1231
+
1232
+ /**
1233
+ * Successful intent completion.
1234
+ */
1235
+ interface SuccessIntentResponse {
1236
+ code?: 'ok';
1237
+ data?: {
1238
+ [key: string]: unknown;
1239
+ };
1240
+ }
1241
+
1061
1242
  interface SupportApi {
1062
1243
  registerHandler?: (callback: SupportCallback | null) => Promise<void>;
1063
1244
  }
@@ -1154,7 +1335,7 @@ interface _UIModalElement {
1154
1335
  /**
1155
1336
  * A getter/setter that is used to set modal variant.
1156
1337
  */
1157
- variant?: Variant;
1338
+ variant?: 'small' | 'base' | 'large' | 'max';
1158
1339
  /**
1159
1340
  * A getter/setter that is used to get the DOM content of the modal
1160
1341
  * element and update the content after the modal has been opened.
@@ -1172,15 +1353,15 @@ interface _UIModalElement {
1172
1353
  */
1173
1354
  readonly contentWindow?: Window | null;
1174
1355
  /**
1175
- * Shows the save bar element
1356
+ * Shows the modal element
1176
1357
  */
1177
1358
  show?(): Promise<void>;
1178
1359
  /**
1179
- * Hides the save bar element
1360
+ * Hides the modal element
1180
1361
  */
1181
1362
  hide?(): Promise<void>;
1182
1363
  /**
1183
- * Toggles the save bar element between the showing and hidden states
1364
+ * Toggles the modal element between the showing and hidden states
1184
1365
  */
1185
1366
  toggle?(): Promise<void>;
1186
1367
  /**
@@ -1341,8 +1522,6 @@ type UserApi = () => Promise<User>;
1341
1522
  */
1342
1523
  type UserResult = 'granted-all' | 'declined-all';
1343
1524
 
1344
- type Variant = 'small' | 'base' | 'large' | 'max';
1345
-
1346
1525
  interface WebVitalsApi {
1347
1526
  onReport?: (callback: WebVitalsCallback | null) => Promise<void>;
1348
1527
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/app-bridge-types",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Companion types library for the Shopify App Bridge script",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -18,6 +18,7 @@
18
18
  "default": "./dist/index.js"
19
19
  },
20
20
  "devDependencies": {
21
+ "@standard-schema/spec": "^1.0.0",
21
22
  "cjyes": "^0.3.1"
22
23
  },
23
24
  "files": [