@shopify/app-bridge-types 0.0.3 → 0.0.5

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
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.0.3] - 2023-07-27
9
+
10
+ ### Changed
11
+
12
+ - Correct `resourcePicker()` return value and TS types to return the Array of selected entities directly. For the time being, the Array has a `.selection` property for backwards compatibility with the interface we launched with. ([#131](https://github.com/Shopify/app-bridge-next/pull/131))
13
+
8
14
  ## [0.0.2] - 2023-07-19
9
15
 
10
16
  ### Added
package/index.d.ts CHANGED
@@ -3,6 +3,9 @@ import type {
3
3
  AugmentedElement,
4
4
  AppBridgeElements,
5
5
  AppBridgeAttributes,
6
+ UIModalElement as BaseUIModalElement,
7
+ UINavMenuElement as BaseUINavMenuElement,
8
+ UITitleBarElement as BaseUITitleBarElement,
6
9
  } from './shopify';
7
10
 
8
11
  export {ShopifyGlobal};
@@ -14,6 +17,10 @@ declare global {
14
17
  interface HTMLButtonElement extends AugmentedElement<'button'> {}
15
18
  interface HTMLAnchorElement extends AugmentedElement<'a'> {}
16
19
 
20
+ interface UIModalElement extends BaseUIModalElement {}
21
+ interface UINavMenuElement extends BaseUINavMenuElement {}
22
+ interface UITitleBarElement extends BaseUITitleBarElement {}
23
+
17
24
  // Install property augmentations onto ReactElement prop definitions
18
25
  namespace React {
19
26
  interface ButtonHTMLAttributes<T> extends AugmentedElement<'button'> {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/app-bridge-types",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
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
@@ -1,22 +1,35 @@
1
+ interface Address {
2
+ address1?: string;
3
+ address2?: string;
4
+ city?: string;
5
+ company?: string;
6
+ firstName?: string;
7
+ lastName?: string;
8
+ phone?: string;
9
+ province?: string;
10
+ country?: string;
11
+ zip?: string;
12
+ name?: string;
13
+ provinceCode?: string;
14
+ countryCode?: string;
15
+ }
16
+
1
17
  export interface AppBridgeAttributes {
2
18
  }
3
19
 
4
20
  interface AppBridgeConfig {
5
- host: string;
21
+ host?: string;
6
22
  apiKey: string;
7
23
  shop: string;
8
24
  locale: string;
9
- disabledFeatures?: [string];
25
+ disabledFeatures?: string[];
26
+ experimentalFeatures?: string[];
10
27
  }
11
28
 
12
29
  export interface AppBridgeElements {
13
- 'ui-nav-menu': {
14
- children?: any;
15
- };
16
- 'ui-title-bar': {
17
- title?: string;
18
- children?: any;
19
- };
30
+ 'ui-modal': UIModalAttributes;
31
+ 'ui-nav-menu': UINavMenuAttributes;
32
+ 'ui-title-bar': UITitleBarAttributes;
20
33
  }
21
34
 
22
35
  export type AugmentedElement<T extends keyof AugmentedElements> = AugmentedElements[T];
@@ -30,6 +43,19 @@ interface BaseResource extends Resource {
30
43
  variants?: Resource[];
31
44
  }
32
45
 
46
+ interface Cart {
47
+ subtotal: string;
48
+ taxTotal: string;
49
+ grandTotal: string;
50
+ note?: string;
51
+ cartDiscount?: Discount;
52
+ customer?: Customer;
53
+ lineItems: LineItem[];
54
+ properties: Record<string, string>;
55
+ }
56
+
57
+ type CartSubscriber = (cart: Cart) => void;
58
+
33
59
  interface Collection extends Resource {
34
60
  availablePublicationCount: number;
35
61
  description: string;
@@ -71,6 +97,25 @@ enum CollectionSortOrder {
71
97
  MostRelevant = "MOST_RELEVANT"
72
98
  }
73
99
 
100
+ interface Customer {
101
+ id?: number;
102
+ email?: string;
103
+ firstName?: string;
104
+ lastName?: string;
105
+ note?: string;
106
+ }
107
+
108
+ interface Device {
109
+ name: string;
110
+ serialNumber: string;
111
+ }
112
+
113
+ interface Discount {
114
+ amount: number;
115
+ title?: string;
116
+ type?: string;
117
+ }
118
+
74
119
  interface Environment {
75
120
  mobile: boolean;
76
121
  embedded: boolean;
@@ -89,12 +134,76 @@ interface Image_2 {
89
134
  originalSrc: string;
90
135
  }
91
136
 
137
+ interface LineItem {
138
+ uuid: string;
139
+ price?: number;
140
+ quantity: number;
141
+ title?: string;
142
+ variantId?: number;
143
+ productId?: number;
144
+ discounts: Discount[];
145
+ taxable: boolean;
146
+ sku?: string;
147
+ vendor?: string;
148
+ properties: {
149
+ [key: string]: string;
150
+ };
151
+ isGiftCard: boolean;
152
+ }
153
+
154
+ interface LineItemDiscount {
155
+ title: string;
156
+ type: 'Percentage' | 'FixedAmount';
157
+ amount: string;
158
+ }
159
+
160
+ interface Location_2 {
161
+ id: number;
162
+ active: boolean;
163
+ name: string;
164
+ locationType?: string;
165
+ address1?: string;
166
+ address2?: string;
167
+ zip?: string;
168
+ city?: string;
169
+ province?: string;
170
+ countryCode?: string;
171
+ countryName?: string;
172
+ phone?: string;
173
+ }
174
+
92
175
  export interface MenuItemProperties {
93
176
  variant?: 'primary' | 'breadcrumb' | null | undefined;
94
177
  }
95
178
 
96
179
  type Money = string;
97
180
 
181
+ interface Pos {
182
+ cart: {
183
+ fetch(): Promise<Cart>;
184
+ subscribe(onSubscribe: CartSubscriber): Unsubscribe;
185
+ setCustomer(customer: Customer): Promise<void>;
186
+ removeCustomer(): Promise<void>;
187
+ addAddress(address: Address): Promise<void>;
188
+ updateAddress(index: number, address: Address): Promise<void>;
189
+ applyCartDiscount(discount: Discount): Promise<void>;
190
+ removeCartDiscount(): Promise<void>;
191
+ addCartProperties(properties: Record<string, string>): Promise<void>;
192
+ removeCartProperties(properties: string[]): Promise<void>;
193
+ clear(): Promise<void>;
194
+ addLineItem(variantId: number, quantity: number): Promise<void>;
195
+ updateLineItem(index: string, quantity: number): Promise<void>;
196
+ removeLineItem(index: string): Promise<void>;
197
+ setLineItemDiscount(index: number, discount: LineItemDiscount): Promise<void>;
198
+ removeLineItemDiscount(index: number): Promise<void>;
199
+ addLineItemProperties(index: number, properties: Record<string, string>): Promise<void>;
200
+ removeLineItemProperties(index: number, properties: string[]): Promise<void>;
201
+ };
202
+ close(): Promise<void>;
203
+ device(): Promise<Device>;
204
+ location(): Promise<Location_2>;
205
+ }
206
+
98
207
  interface Product extends Resource {
99
208
  availablePublicationCount: number;
100
209
  createdAt: string;
@@ -189,6 +298,7 @@ interface ResourcePickerOptions {
189
298
  variants?: boolean;
190
299
  draft?: boolean | undefined;
191
300
  archived?: boolean | undefined;
301
+ query?: string;
192
302
  };
193
303
  }
194
304
 
@@ -205,6 +315,10 @@ interface RuleSet {
205
315
  rules: CollectionRule[];
206
316
  }
207
317
 
318
+ interface ScannerPayload {
319
+ data: string;
320
+ }
321
+
208
322
  type SelectPayload<Type extends keyof ResourceTypes> = WithSelection<ResourceSelection<Type>[]>;
209
323
 
210
324
  export interface ShopifyGlobal {
@@ -220,6 +334,15 @@ export interface ShopifyGlobal {
220
334
  hide(id: string): void;
221
335
  };
222
336
  resourcePicker<Options extends ResourcePickerOptions>(options: Options): Promise<SelectPayload<Options['type']> | undefined>;
337
+ scanner: {
338
+ capture(): Promise<ScannerPayload>;
339
+ };
340
+ modal: {
341
+ show(id: string): Promise<void>;
342
+ hide(id: string): Promise<void>;
343
+ toggle(id: string): Promise<void>;
344
+ };
345
+ pos: Pos;
223
346
  }
224
347
 
225
348
  interface ToastOptions {
@@ -230,6 +353,43 @@ interface ToastOptions {
230
353
  onDismiss: () => void;
231
354
  }
232
355
 
356
+ interface UIModalAttributes {
357
+ id?: string;
358
+ variant?: Variant;
359
+ children?: any;
360
+ }
361
+
362
+ interface UIModalElement_2 extends Omit<HTMLElement, 'addEventListener' | 'removeEventListener'> {
363
+ variant: Variant;
364
+ content: HTMLElement;
365
+ show(): Promise<void>;
366
+ hide(): Promise<void>;
367
+ toggle(): Promise<void>;
368
+ addEventListener(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
369
+ removeEventListener(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
370
+ }
371
+ export type { UIModalElement_2 as UIModalElement }
372
+
373
+ interface UINavMenuAttributes {
374
+ children?: any;
375
+ }
376
+
377
+ interface UINavMenuElement_2 extends HTMLElement {
378
+ }
379
+ export type { UINavMenuElement_2 as UINavMenuElement }
380
+
381
+ interface UITitleBarAttributes {
382
+ title?: string;
383
+ children?: any;
384
+ }
385
+
386
+ interface UITitleBarElement_2 extends HTMLElement {
387
+ title: string;
388
+ }
389
+ export type { UITitleBarElement_2 as UITitleBarElement }
390
+
391
+ type Unsubscribe = () => void;
392
+
233
393
  interface User {
234
394
  id: string;
235
395
  name: string;
@@ -240,6 +400,8 @@ interface User {
240
400
  accountType: string;
241
401
  }
242
402
 
403
+ type Variant = 'small' | 'base' | 'large' | 'max';
404
+
243
405
  enum WeightUnit {
244
406
  Kilograms = "KILOGRAMS",
245
407
  Grams = "GRAMS",