@shopify/app-bridge-types 0.0.4 → 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/index.d.ts +7 -0
- package/package.json +1 -1
- package/shopify.ts +148 -7
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
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,13 @@ interface AppBridgeConfig {
|
|
|
7
23
|
shop: string;
|
|
8
24
|
locale: string;
|
|
9
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
|
-
};
|
|
20
30
|
'ui-modal': UIModalAttributes;
|
|
31
|
+
'ui-nav-menu': UINavMenuAttributes;
|
|
32
|
+
'ui-title-bar': UITitleBarAttributes;
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
export type AugmentedElement<T extends keyof AugmentedElements> = AugmentedElements[T];
|
|
@@ -31,6 +43,19 @@ interface BaseResource extends Resource {
|
|
|
31
43
|
variants?: Resource[];
|
|
32
44
|
}
|
|
33
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
|
+
|
|
34
59
|
interface Collection extends Resource {
|
|
35
60
|
availablePublicationCount: number;
|
|
36
61
|
description: string;
|
|
@@ -72,6 +97,25 @@ enum CollectionSortOrder {
|
|
|
72
97
|
MostRelevant = "MOST_RELEVANT"
|
|
73
98
|
}
|
|
74
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
|
+
|
|
75
119
|
interface Environment {
|
|
76
120
|
mobile: boolean;
|
|
77
121
|
embedded: boolean;
|
|
@@ -90,12 +134,76 @@ interface Image_2 {
|
|
|
90
134
|
originalSrc: string;
|
|
91
135
|
}
|
|
92
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
|
+
|
|
93
175
|
export interface MenuItemProperties {
|
|
94
176
|
variant?: 'primary' | 'breadcrumb' | null | undefined;
|
|
95
177
|
}
|
|
96
178
|
|
|
97
179
|
type Money = string;
|
|
98
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
|
+
|
|
99
207
|
interface Product extends Resource {
|
|
100
208
|
availablePublicationCount: number;
|
|
101
209
|
createdAt: string;
|
|
@@ -190,6 +298,7 @@ interface ResourcePickerOptions {
|
|
|
190
298
|
variants?: boolean;
|
|
191
299
|
draft?: boolean | undefined;
|
|
192
300
|
archived?: boolean | undefined;
|
|
301
|
+
query?: string;
|
|
193
302
|
};
|
|
194
303
|
}
|
|
195
304
|
|
|
@@ -233,6 +342,7 @@ export interface ShopifyGlobal {
|
|
|
233
342
|
hide(id: string): Promise<void>;
|
|
234
343
|
toggle(id: string): Promise<void>;
|
|
235
344
|
};
|
|
345
|
+
pos: Pos;
|
|
236
346
|
}
|
|
237
347
|
|
|
238
348
|
interface ToastOptions {
|
|
@@ -249,6 +359,37 @@ interface UIModalAttributes {
|
|
|
249
359
|
children?: any;
|
|
250
360
|
}
|
|
251
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
|
+
|
|
252
393
|
interface User {
|
|
253
394
|
id: string;
|
|
254
395
|
name: string;
|