@shopify/app-bridge-types 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/shopify.ts +18 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/app-bridge-types",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Companion types library for the Shopify App Bridge script",
5
5
  "license": "ISC",
6
6
  "main": "./index.js",
package/shopify.ts CHANGED
@@ -90,7 +90,7 @@ interface Image_2 {
90
90
  }
91
91
 
92
92
  export interface MenuItemProperties {
93
- variant?: 'primary' | undefined;
93
+ variant?: 'primary' | 'breadcrumb' | null | undefined;
94
94
  }
95
95
 
96
96
  type Money = string;
@@ -192,17 +192,20 @@ interface ResourcePickerOptions {
192
192
  };
193
193
  }
194
194
 
195
- type ResourceSelection = Product | ProductVariant | Collection;
195
+ type ResourceSelection<Type extends keyof ResourceTypes> = ResourceTypes[Type];
196
+
197
+ type ResourceTypes = {
198
+ product: Product;
199
+ variant: ProductVariant;
200
+ collection: Collection;
201
+ };
196
202
 
197
203
  interface RuleSet {
198
204
  appliedDisjunctively: boolean;
199
205
  rules: CollectionRule[];
200
206
  }
201
207
 
202
- interface SelectPayload {
203
- readonly id?: string;
204
- selection: ResourceSelection[];
205
- }
208
+ type SelectPayload<Type extends keyof ResourceTypes> = WithSelection<ResourceSelection<Type>[]>;
206
209
 
207
210
  export interface ShopifyGlobal {
208
211
  config: AppBridgeConfig;
@@ -216,7 +219,7 @@ export interface ShopifyGlobal {
216
219
  show(message: string, opts?: Partial<ToastOptions>): string;
217
220
  hide(id: string): void;
218
221
  };
219
- resourcePicker(options?: ResourcePickerOptions): Promise<SelectPayload | undefined>;
222
+ resourcePicker<Options extends ResourcePickerOptions>(options: Options): Promise<SelectPayload<Options['type']> | undefined>;
220
223
  }
221
224
 
222
225
  interface ToastOptions {
@@ -244,4 +247,12 @@ enum WeightUnit {
244
247
  Ounces = "OUNCES"
245
248
  }
246
249
 
250
+ type WithSelection<T> = T & {
251
+ /**
252
+ * @private
253
+ * @deprecated
254
+ */
255
+ selection: T;
256
+ };
257
+
247
258
  export { }