@shopify/app-bridge-types 0.0.1 → 0.0.2
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 +19 -0
- package/index.d.ts +22 -3
- package/package.json +3 -4
- package/shopify.ts +247 -0
- package/internal.d.ts +0 -72
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.0.2] - 2023-07-19
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- ResourcePicker types ([#97](https://github.com/Shopify/app-bridge-next/pull/97))
|
|
13
|
+
- Custom element types for ui-title-bar and ui-nav-menu ([#108](https://github.com/Shopify/app-bridge-next/pull/108))
|
|
14
|
+
- Custom attribute types for React buttons ([#108](https://github.com/Shopify/app-bridge-next/pull/108))
|
|
15
|
+
- shopify global types for reference outside of window ([#108](https://github.com/Shopify/app-bridge-next/pull/108))
|
|
16
|
+
|
|
17
|
+
### Removed
|
|
18
|
+
|
|
19
|
+
- Unused titleBar setState type on ShopifyGlobal ([#108](https://github.com/Shopify/app-bridge-next/pull/108))
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
ShopifyGlobal,
|
|
3
|
+
AugmentedElement,
|
|
4
|
+
AppBridgeElements,
|
|
5
|
+
AppBridgeAttributes,
|
|
6
|
+
} from './shopify';
|
|
2
7
|
|
|
3
8
|
export {ShopifyGlobal};
|
|
4
9
|
|
|
5
10
|
declare global {
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
var shopify: ShopifyGlobal;
|
|
12
|
+
|
|
13
|
+
// Install property augmentations onto DOM prototypes
|
|
14
|
+
interface HTMLButtonElement extends AugmentedElement<'button'> {}
|
|
15
|
+
interface HTMLAnchorElement extends AugmentedElement<'a'> {}
|
|
16
|
+
|
|
17
|
+
// Install property augmentations onto ReactElement prop definitions
|
|
18
|
+
namespace React {
|
|
19
|
+
interface ButtonHTMLAttributes<T> extends AugmentedElement<'button'> {}
|
|
20
|
+
interface LinkHTMLAttributes<T> extends AugmentedElement<'a'> {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Install Element/attribute augmentations into JSX definitions
|
|
24
|
+
namespace JSX {
|
|
25
|
+
interface IntrinsicElements extends AppBridgeElements {}
|
|
26
|
+
interface IntrinsicAttributes extends AppBridgeAttributes {}
|
|
8
27
|
}
|
|
9
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/app-bridge-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Companion types library for the Shopify App Bridge script",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -13,15 +13,14 @@
|
|
|
13
13
|
"default": "./index.js"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "cjyes &&
|
|
17
|
-
"types": "cp ../../dist/app-bridge.d.ts ./internal.d.ts"
|
|
16
|
+
"build": "cjyes && node ./scripts/build.mjs"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"cjyes": "^0.3.1"
|
|
21
20
|
},
|
|
22
21
|
"files": [
|
|
23
22
|
"index.d.ts",
|
|
24
|
-
"
|
|
23
|
+
"shopify.ts",
|
|
25
24
|
"index.mjs",
|
|
26
25
|
"index.js"
|
|
27
26
|
]
|
package/shopify.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
export interface AppBridgeAttributes {
|
|
2
|
+
}
|
|
3
|
+
|
|
4
|
+
interface AppBridgeConfig {
|
|
5
|
+
host: string;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
shop: string;
|
|
8
|
+
locale: string;
|
|
9
|
+
disabledFeatures?: [string];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AppBridgeElements {
|
|
13
|
+
'ui-nav-menu': {
|
|
14
|
+
children?: any;
|
|
15
|
+
};
|
|
16
|
+
'ui-title-bar': {
|
|
17
|
+
title?: string;
|
|
18
|
+
children?: any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type AugmentedElement<T extends keyof AugmentedElements> = AugmentedElements[T];
|
|
23
|
+
|
|
24
|
+
export interface AugmentedElements {
|
|
25
|
+
button: MenuItemProperties;
|
|
26
|
+
a: MenuItemProperties;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface BaseResource extends Resource {
|
|
30
|
+
variants?: Resource[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface Collection extends Resource {
|
|
34
|
+
availablePublicationCount: number;
|
|
35
|
+
description: string;
|
|
36
|
+
descriptionHtml: string;
|
|
37
|
+
handle: string;
|
|
38
|
+
id: string;
|
|
39
|
+
image?: Image_2 | null;
|
|
40
|
+
productsAutomaticallySortedCount: number;
|
|
41
|
+
productsCount: number;
|
|
42
|
+
productsManuallySortedCount: number;
|
|
43
|
+
publicationCount: number;
|
|
44
|
+
ruleSet?: RuleSet | null;
|
|
45
|
+
seo: {
|
|
46
|
+
description?: string | null;
|
|
47
|
+
title?: string | null;
|
|
48
|
+
};
|
|
49
|
+
sortOrder: CollectionSortOrder;
|
|
50
|
+
storefrontId: string;
|
|
51
|
+
templateSuffix?: string | null;
|
|
52
|
+
title: string;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface CollectionRule {
|
|
57
|
+
column: string;
|
|
58
|
+
condition: string;
|
|
59
|
+
relation: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
enum CollectionSortOrder {
|
|
63
|
+
Manual = "MANUAL",
|
|
64
|
+
BestSelling = "BEST_SELLING",
|
|
65
|
+
AlphaAsc = "ALPHA_ASC",
|
|
66
|
+
AlphaDesc = "ALPHA_DESC",
|
|
67
|
+
PriceDesc = "PRICE_DESC",
|
|
68
|
+
PriceAsc = "PRICE_ASC",
|
|
69
|
+
CreatedDesc = "CREATED_DESC",
|
|
70
|
+
Created = "CREATED",
|
|
71
|
+
MostRelevant = "MOST_RELEVANT"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface Environment {
|
|
75
|
+
mobile: boolean;
|
|
76
|
+
embedded: boolean;
|
|
77
|
+
pos: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
enum FulfillmentServiceType {
|
|
81
|
+
GiftCard = "GIFT_CARD",
|
|
82
|
+
Manual = "MANUAL",
|
|
83
|
+
ThirdParty = "THIRD_PARTY"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface Image_2 {
|
|
87
|
+
id: string;
|
|
88
|
+
altText?: string;
|
|
89
|
+
originalSrc: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface MenuItemProperties {
|
|
93
|
+
variant?: 'primary' | undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
type Money = string;
|
|
97
|
+
|
|
98
|
+
interface Product extends Resource {
|
|
99
|
+
availablePublicationCount: number;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
descriptionHtml: string;
|
|
102
|
+
handle: string;
|
|
103
|
+
hasOnlyDefaultVariant: boolean;
|
|
104
|
+
images: Image_2[];
|
|
105
|
+
options: {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
position: number;
|
|
109
|
+
values: string[];
|
|
110
|
+
}[];
|
|
111
|
+
productType: string;
|
|
112
|
+
publishedAt?: string | null;
|
|
113
|
+
tags: string[];
|
|
114
|
+
templateSuffix?: string | null;
|
|
115
|
+
title: string;
|
|
116
|
+
totalInventory: number;
|
|
117
|
+
tracksInventory: boolean;
|
|
118
|
+
variants: Partial<ProductVariant>[];
|
|
119
|
+
vendor: string;
|
|
120
|
+
updatedAt: string;
|
|
121
|
+
status: ProductStatus;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
enum ProductStatus {
|
|
125
|
+
Active = "ACTIVE",
|
|
126
|
+
Archived = "ARCHIVED",
|
|
127
|
+
Draft = "DRAFT"
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface ProductVariant extends Resource {
|
|
131
|
+
availableForSale: boolean;
|
|
132
|
+
barcode?: string | null;
|
|
133
|
+
compareAtPrice?: Money | null;
|
|
134
|
+
createdAt: string;
|
|
135
|
+
displayName: string;
|
|
136
|
+
fulfillmentService?: {
|
|
137
|
+
id: string;
|
|
138
|
+
inventoryManagement: boolean;
|
|
139
|
+
productBased: boolean;
|
|
140
|
+
serviceName: string;
|
|
141
|
+
type: FulfillmentServiceType;
|
|
142
|
+
};
|
|
143
|
+
image?: Image_2 | null;
|
|
144
|
+
inventoryItem: {
|
|
145
|
+
id: string;
|
|
146
|
+
};
|
|
147
|
+
inventoryManagement: ProductVariantInventoryManagement;
|
|
148
|
+
inventoryPolicy: ProductVariantInventoryPolicy;
|
|
149
|
+
inventoryQuantity?: number | null;
|
|
150
|
+
position: number;
|
|
151
|
+
price: Money;
|
|
152
|
+
product: Partial<Product>;
|
|
153
|
+
requiresShipping: boolean;
|
|
154
|
+
selectedOptions: {
|
|
155
|
+
value?: string | null;
|
|
156
|
+
}[];
|
|
157
|
+
sku?: string | null;
|
|
158
|
+
taxable: boolean;
|
|
159
|
+
title: string;
|
|
160
|
+
weight?: number | null;
|
|
161
|
+
weightUnit: WeightUnit;
|
|
162
|
+
updatedAt: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
enum ProductVariantInventoryManagement {
|
|
166
|
+
Shopify = "SHOPIFY",
|
|
167
|
+
NotManaged = "NOT_MANAGED",
|
|
168
|
+
FulfillmentService = "FULFILLMENT_SERVICE"
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
enum ProductVariantInventoryPolicy {
|
|
172
|
+
Deny = "DENY",
|
|
173
|
+
Continue = "CONTINUE"
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface Resource {
|
|
177
|
+
/** in GraphQL id format, ie 'gid://shopify/Product/1' */
|
|
178
|
+
id: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface ResourcePickerOptions {
|
|
182
|
+
type: 'product' | 'variant' | 'collection';
|
|
183
|
+
query?: string;
|
|
184
|
+
selectionIds?: BaseResource[];
|
|
185
|
+
action?: 'add' | 'select';
|
|
186
|
+
multiple?: boolean | number;
|
|
187
|
+
filter?: {
|
|
188
|
+
hidden?: boolean;
|
|
189
|
+
variants?: boolean;
|
|
190
|
+
draft?: boolean | undefined;
|
|
191
|
+
archived?: boolean | undefined;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
type ResourceSelection = Product | ProductVariant | Collection;
|
|
196
|
+
|
|
197
|
+
interface RuleSet {
|
|
198
|
+
appliedDisjunctively: boolean;
|
|
199
|
+
rules: CollectionRule[];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
interface SelectPayload {
|
|
203
|
+
readonly id?: string;
|
|
204
|
+
selection: ResourceSelection[];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface ShopifyGlobal {
|
|
208
|
+
config: AppBridgeConfig;
|
|
209
|
+
origin: string;
|
|
210
|
+
ready: Promise<void>;
|
|
211
|
+
environment: Environment;
|
|
212
|
+
loading(isLoading?: boolean): void;
|
|
213
|
+
idToken(): Promise<string>;
|
|
214
|
+
user(): Promise<User>;
|
|
215
|
+
toast: {
|
|
216
|
+
show(message: string, opts?: Partial<ToastOptions>): string;
|
|
217
|
+
hide(id: string): void;
|
|
218
|
+
};
|
|
219
|
+
resourcePicker(options?: ResourcePickerOptions): Promise<SelectPayload | undefined>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface ToastOptions {
|
|
223
|
+
duration: number;
|
|
224
|
+
isError: boolean;
|
|
225
|
+
action: string;
|
|
226
|
+
onAction: () => void;
|
|
227
|
+
onDismiss: () => void;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
interface User {
|
|
231
|
+
id: string;
|
|
232
|
+
name: string;
|
|
233
|
+
firstName?: string;
|
|
234
|
+
lastName?: string;
|
|
235
|
+
email: string;
|
|
236
|
+
accountAccess: string;
|
|
237
|
+
accountType: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
enum WeightUnit {
|
|
241
|
+
Kilograms = "KILOGRAMS",
|
|
242
|
+
Grams = "GRAMS",
|
|
243
|
+
Pounds = "POUNDS",
|
|
244
|
+
Ounces = "OUNCES"
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export { }
|
package/internal.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
declare interface AppBridgeConfig {
|
|
2
|
-
host: string;
|
|
3
|
-
apiKey: string;
|
|
4
|
-
shop: string;
|
|
5
|
-
locale: string;
|
|
6
|
-
disabledFeatures?: [string];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare interface Button {
|
|
10
|
-
id: string;
|
|
11
|
-
label: string;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare interface ButtonGroup {
|
|
16
|
-
id: string;
|
|
17
|
-
label: string;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
buttons: Button[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare interface Environment {
|
|
23
|
-
mobile: boolean;
|
|
24
|
-
embedded: boolean;
|
|
25
|
-
pos: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export declare interface ShopifyGlobal {
|
|
29
|
-
config: AppBridgeConfig;
|
|
30
|
-
origin: string;
|
|
31
|
-
ready: Promise<void>;
|
|
32
|
-
environment: Environment;
|
|
33
|
-
loading(isLoading?: boolean): void;
|
|
34
|
-
idToken(): Promise<string>;
|
|
35
|
-
user(): Promise<User>;
|
|
36
|
-
titleBar: {
|
|
37
|
-
setState(state?: TitleBarState): void;
|
|
38
|
-
};
|
|
39
|
-
toast: {
|
|
40
|
-
show(message: string, opts?: Partial<ToastOptions>): string;
|
|
41
|
-
hide(id: string): void;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
declare interface TitleBarState {
|
|
46
|
-
title?: string;
|
|
47
|
-
buttons?: {
|
|
48
|
-
primary?: Button;
|
|
49
|
-
secondary?: (Button | ButtonGroup)[];
|
|
50
|
-
};
|
|
51
|
-
breadcrumbs?: Button;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare interface ToastOptions {
|
|
55
|
-
duration: number;
|
|
56
|
-
isError: boolean;
|
|
57
|
-
action: string;
|
|
58
|
-
onAction: () => void;
|
|
59
|
-
onDismiss: () => void;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
declare interface User {
|
|
63
|
-
id: string;
|
|
64
|
-
name: string;
|
|
65
|
-
firstName?: string;
|
|
66
|
-
lastName?: string;
|
|
67
|
-
email: string;
|
|
68
|
-
accountAccess: string;
|
|
69
|
-
accountType: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export { }
|