@shopify/app-bridge-types 0.4.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 +6 -0
- package/dist/shopify.ts +128 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 0.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
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.
|
|
@@ -141,6 +143,7 @@ export interface AppBridgeElements {
|
|
|
141
143
|
's-app-nav': SAppNavAttributes;
|
|
142
144
|
'ui-save-bar': UISaveBarAttributes;
|
|
143
145
|
'ui-title-bar': UITitleBarAttributes;
|
|
146
|
+
's-page': SPageAttributes;
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
export type AugmentedElement<T extends keyof AugmentedElements> = AugmentedElements[T];
|
|
@@ -211,6 +214,13 @@ interface Cart {
|
|
|
211
214
|
*/
|
|
212
215
|
type CartSubscriber = (cart: Cart) => void;
|
|
213
216
|
|
|
217
|
+
/**
|
|
218
|
+
* User dismissed or closed the workflow without completing it.
|
|
219
|
+
*/
|
|
220
|
+
interface ClosedIntentResponse {
|
|
221
|
+
code?: 'closed';
|
|
222
|
+
}
|
|
223
|
+
|
|
214
224
|
export interface Collection extends Resource {
|
|
215
225
|
availablePublicationCount: number;
|
|
216
226
|
description: string;
|
|
@@ -354,6 +364,15 @@ interface _EnvironmentApi {
|
|
|
354
364
|
pos?: boolean;
|
|
355
365
|
}
|
|
356
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Failed intent completion.
|
|
369
|
+
*/
|
|
370
|
+
interface ErrorIntentResponse {
|
|
371
|
+
code?: 'error';
|
|
372
|
+
message?: string;
|
|
373
|
+
issues?: StandardSchemaV1.Issue[];
|
|
374
|
+
}
|
|
375
|
+
|
|
357
376
|
/**
|
|
358
377
|
* Represents an activation record for an extension.
|
|
359
378
|
* Contains information about where an extension is activated.
|
|
@@ -457,10 +476,61 @@ interface Intent {
|
|
|
457
476
|
finish: Finish;
|
|
458
477
|
}
|
|
459
478
|
|
|
460
|
-
|
|
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 {
|
|
461
526
|
register(callback: (intent: Intent) => void): () => void;
|
|
462
527
|
}
|
|
463
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
|
+
|
|
464
534
|
interface LineItem {
|
|
465
535
|
/**
|
|
466
536
|
* Unique id of line item
|
|
@@ -872,6 +942,37 @@ enum ProductVariantInventoryPolicy {
|
|
|
872
942
|
|
|
873
943
|
type Progress = 'incomplete' | 'partiallyComplete' | 'complete';
|
|
874
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
|
+
|
|
875
976
|
interface Resource {
|
|
876
977
|
/** in GraphQL id format, ie 'gid://shopify/Product/1' */
|
|
877
978
|
id: string;
|
|
@@ -1112,6 +1213,32 @@ export interface ShopifyGlobal {
|
|
|
1112
1213
|
app: AppApi;
|
|
1113
1214
|
}
|
|
1114
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
|
+
|
|
1115
1242
|
interface SupportApi {
|
|
1116
1243
|
registerHandler?: (callback: SupportCallback | null) => Promise<void>;
|
|
1117
1244
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/app-bridge-types",
|
|
3
|
-
"version": "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": [
|