@shopify/app-bridge-types 0.0.4 → 0.0.6
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/index.d.ts +16 -1
- package/package.json +1 -1
- package/shopify.ts +150 -8
package/index.d.ts
CHANGED
|
@@ -3,9 +3,20 @@ import type {
|
|
|
3
3
|
AugmentedElement,
|
|
4
4
|
AppBridgeElements,
|
|
5
5
|
AppBridgeAttributes,
|
|
6
|
+
UIModalElement as BaseUIModalElement,
|
|
7
|
+
UINavMenuElement as BaseUINavMenuElement,
|
|
8
|
+
UITitleBarElement as BaseUITitleBarElement,
|
|
9
|
+
UIModalAttributes,
|
|
10
|
+
UINavMenuAttributes,
|
|
11
|
+
UITitleBarAttributes,
|
|
6
12
|
} from './shopify';
|
|
7
13
|
|
|
8
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
ShopifyGlobal,
|
|
16
|
+
UIModalAttributes,
|
|
17
|
+
UINavMenuAttributes,
|
|
18
|
+
UITitleBarAttributes,
|
|
19
|
+
};
|
|
9
20
|
|
|
10
21
|
declare global {
|
|
11
22
|
var shopify: ShopifyGlobal;
|
|
@@ -14,6 +25,10 @@ declare global {
|
|
|
14
25
|
interface HTMLButtonElement extends AugmentedElement<'button'> {}
|
|
15
26
|
interface HTMLAnchorElement extends AugmentedElement<'a'> {}
|
|
16
27
|
|
|
28
|
+
interface UIModalElement extends BaseUIModalElement {}
|
|
29
|
+
interface UINavMenuElement extends BaseUINavMenuElement {}
|
|
30
|
+
interface UITitleBarElement extends BaseUITitleBarElement {}
|
|
31
|
+
|
|
17
32
|
// Install property augmentations onto ReactElement prop definitions
|
|
18
33
|
namespace React {
|
|
19
34
|
interface ButtonHTMLAttributes<T> extends AugmentedElement<'button'> {}
|
package/package.json
CHANGED
package/shopify.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
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
|
|
|
@@ -7,17 +23,14 @@ interface AppBridgeConfig {
|
|
|
7
23
|
shop: string;
|
|
8
24
|
locale: string;
|
|
9
25
|
disabledFeatures?: string[];
|
|
26
|
+
experimentalFeatures?: string[];
|
|
27
|
+
appOrigins?: string[];
|
|
10
28
|
}
|
|
11
29
|
|
|
12
30
|
export interface AppBridgeElements {
|
|
13
|
-
'ui-nav-menu': {
|
|
14
|
-
children?: any;
|
|
15
|
-
};
|
|
16
|
-
'ui-title-bar': {
|
|
17
|
-
title?: string;
|
|
18
|
-
children?: any;
|
|
19
|
-
};
|
|
20
31
|
'ui-modal': UIModalAttributes;
|
|
32
|
+
'ui-nav-menu': UINavMenuAttributes;
|
|
33
|
+
'ui-title-bar': UITitleBarAttributes;
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
export type AugmentedElement<T extends keyof AugmentedElements> = AugmentedElements[T];
|
|
@@ -31,6 +44,19 @@ interface BaseResource extends Resource {
|
|
|
31
44
|
variants?: Resource[];
|
|
32
45
|
}
|
|
33
46
|
|
|
47
|
+
interface Cart {
|
|
48
|
+
subtotal: string;
|
|
49
|
+
taxTotal: string;
|
|
50
|
+
grandTotal: string;
|
|
51
|
+
note?: string;
|
|
52
|
+
cartDiscount?: Discount;
|
|
53
|
+
customer?: Customer;
|
|
54
|
+
lineItems: LineItem[];
|
|
55
|
+
properties: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type CartSubscriber = (cart: Cart) => void;
|
|
59
|
+
|
|
34
60
|
interface Collection extends Resource {
|
|
35
61
|
availablePublicationCount: number;
|
|
36
62
|
description: string;
|
|
@@ -72,6 +98,25 @@ enum CollectionSortOrder {
|
|
|
72
98
|
MostRelevant = "MOST_RELEVANT"
|
|
73
99
|
}
|
|
74
100
|
|
|
101
|
+
interface Customer {
|
|
102
|
+
id?: number;
|
|
103
|
+
email?: string;
|
|
104
|
+
firstName?: string;
|
|
105
|
+
lastName?: string;
|
|
106
|
+
note?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface Device {
|
|
110
|
+
name: string;
|
|
111
|
+
serialNumber: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface Discount {
|
|
115
|
+
amount: number;
|
|
116
|
+
title?: string;
|
|
117
|
+
type?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
75
120
|
interface Environment {
|
|
76
121
|
mobile: boolean;
|
|
77
122
|
embedded: boolean;
|
|
@@ -90,12 +135,76 @@ interface Image_2 {
|
|
|
90
135
|
originalSrc: string;
|
|
91
136
|
}
|
|
92
137
|
|
|
138
|
+
interface LineItem {
|
|
139
|
+
uuid: string;
|
|
140
|
+
price?: number;
|
|
141
|
+
quantity: number;
|
|
142
|
+
title?: string;
|
|
143
|
+
variantId?: number;
|
|
144
|
+
productId?: number;
|
|
145
|
+
discounts: Discount[];
|
|
146
|
+
taxable: boolean;
|
|
147
|
+
sku?: string;
|
|
148
|
+
vendor?: string;
|
|
149
|
+
properties: {
|
|
150
|
+
[key: string]: string;
|
|
151
|
+
};
|
|
152
|
+
isGiftCard: boolean;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface LineItemDiscount {
|
|
156
|
+
title: string;
|
|
157
|
+
type: 'Percentage' | 'FixedAmount';
|
|
158
|
+
amount: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface Location_2 {
|
|
162
|
+
id: number;
|
|
163
|
+
active: boolean;
|
|
164
|
+
name: string;
|
|
165
|
+
locationType?: string;
|
|
166
|
+
address1?: string;
|
|
167
|
+
address2?: string;
|
|
168
|
+
zip?: string;
|
|
169
|
+
city?: string;
|
|
170
|
+
province?: string;
|
|
171
|
+
countryCode?: string;
|
|
172
|
+
countryName?: string;
|
|
173
|
+
phone?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
93
176
|
export interface MenuItemProperties {
|
|
94
177
|
variant?: 'primary' | 'breadcrumb' | null | undefined;
|
|
95
178
|
}
|
|
96
179
|
|
|
97
180
|
type Money = string;
|
|
98
181
|
|
|
182
|
+
interface Pos {
|
|
183
|
+
cart: {
|
|
184
|
+
fetch(): Promise<Cart>;
|
|
185
|
+
subscribe(onSubscribe: CartSubscriber): Unsubscribe;
|
|
186
|
+
setCustomer(customer: Customer): Promise<void>;
|
|
187
|
+
removeCustomer(): Promise<void>;
|
|
188
|
+
addAddress(address: Address): Promise<void>;
|
|
189
|
+
updateAddress(index: number, address: Address): Promise<void>;
|
|
190
|
+
applyCartDiscount(discount: Discount): Promise<void>;
|
|
191
|
+
removeCartDiscount(): Promise<void>;
|
|
192
|
+
addCartProperties(properties: Record<string, string>): Promise<void>;
|
|
193
|
+
removeCartProperties(properties: string[]): Promise<void>;
|
|
194
|
+
clear(): Promise<void>;
|
|
195
|
+
addLineItem(variantId: number, quantity: number): Promise<void>;
|
|
196
|
+
updateLineItem(index: string, quantity: number): Promise<void>;
|
|
197
|
+
removeLineItem(index: string): Promise<void>;
|
|
198
|
+
setLineItemDiscount(index: number, discount: LineItemDiscount): Promise<void>;
|
|
199
|
+
removeLineItemDiscount(index: number): Promise<void>;
|
|
200
|
+
addLineItemProperties(index: number, properties: Record<string, string>): Promise<void>;
|
|
201
|
+
removeLineItemProperties(index: number, properties: string[]): Promise<void>;
|
|
202
|
+
};
|
|
203
|
+
close(): Promise<void>;
|
|
204
|
+
device(): Promise<Device>;
|
|
205
|
+
location(): Promise<Location_2>;
|
|
206
|
+
}
|
|
207
|
+
|
|
99
208
|
interface Product extends Resource {
|
|
100
209
|
availablePublicationCount: number;
|
|
101
210
|
createdAt: string;
|
|
@@ -190,6 +299,7 @@ interface ResourcePickerOptions {
|
|
|
190
299
|
variants?: boolean;
|
|
191
300
|
draft?: boolean | undefined;
|
|
192
301
|
archived?: boolean | undefined;
|
|
302
|
+
query?: string;
|
|
193
303
|
};
|
|
194
304
|
}
|
|
195
305
|
|
|
@@ -233,6 +343,7 @@ export interface ShopifyGlobal {
|
|
|
233
343
|
hide(id: string): Promise<void>;
|
|
234
344
|
toggle(id: string): Promise<void>;
|
|
235
345
|
};
|
|
346
|
+
pos: Pos;
|
|
236
347
|
}
|
|
237
348
|
|
|
238
349
|
interface ToastOptions {
|
|
@@ -243,12 +354,43 @@ interface ToastOptions {
|
|
|
243
354
|
onDismiss: () => void;
|
|
244
355
|
}
|
|
245
356
|
|
|
246
|
-
interface UIModalAttributes {
|
|
357
|
+
export interface UIModalAttributes {
|
|
247
358
|
id?: string;
|
|
248
359
|
variant?: Variant;
|
|
249
360
|
children?: any;
|
|
250
361
|
}
|
|
251
362
|
|
|
363
|
+
interface UIModalElement_2 extends Omit<HTMLElement, 'addEventListener' | 'removeEventListener'> {
|
|
364
|
+
variant: Variant;
|
|
365
|
+
content: HTMLElement;
|
|
366
|
+
show(): Promise<void>;
|
|
367
|
+
hide(): Promise<void>;
|
|
368
|
+
toggle(): Promise<void>;
|
|
369
|
+
addEventListener(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
|
|
370
|
+
removeEventListener(type: 'show' | 'hide', listener: EventListenerOrEventListenerObject): void;
|
|
371
|
+
}
|
|
372
|
+
export type { UIModalElement_2 as UIModalElement }
|
|
373
|
+
|
|
374
|
+
export interface UINavMenuAttributes {
|
|
375
|
+
children?: any;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
interface UINavMenuElement_2 extends HTMLElement {
|
|
379
|
+
}
|
|
380
|
+
export type { UINavMenuElement_2 as UINavMenuElement }
|
|
381
|
+
|
|
382
|
+
export interface UITitleBarAttributes {
|
|
383
|
+
title?: string;
|
|
384
|
+
children?: any;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
interface UITitleBarElement_2 extends HTMLElement {
|
|
388
|
+
title: string;
|
|
389
|
+
}
|
|
390
|
+
export type { UITitleBarElement_2 as UITitleBarElement }
|
|
391
|
+
|
|
392
|
+
type Unsubscribe = () => void;
|
|
393
|
+
|
|
252
394
|
interface User {
|
|
253
395
|
id: string;
|
|
254
396
|
name: string;
|