@gem-sdk/adapter-common 1.0.0
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/dist/types/index.d.ts +1 -0
- package/dist/types/types/cart.d.ts +205 -0
- package/dist/types/types/checkout.d.ts +53 -0
- package/dist/types/types/common.d.ts +15 -0
- package/dist/types/types/customer/address.d.ts +110 -0
- package/dist/types/types/customer/card.d.ts +113 -0
- package/dist/types/types/customer/index.d.ts +24 -0
- package/dist/types/types/global-style.d.ts +32 -0
- package/dist/types/types/index.d.ts +13 -0
- package/dist/types/types/login.d.ts +27 -0
- package/dist/types/types/logout.d.ts +17 -0
- package/dist/types/types/page.d.ts +24 -0
- package/dist/types/types/product.d.ts +100 -0
- package/dist/types/types/signup.d.ts +23 -0
- package/dist/types/types/site.d.ts +21 -0
- package/dist/types/types/wishlist.d.ts +83 -0
- package/package.json +25 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types';
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { Discount, Measurement, Image } from './common';
|
|
2
|
+
export type SelectedOption = {
|
|
3
|
+
id?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
export type Attribute = {
|
|
8
|
+
key: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
};
|
|
11
|
+
export type LineItem = {
|
|
12
|
+
id: string;
|
|
13
|
+
variantId: string;
|
|
14
|
+
productId: string;
|
|
15
|
+
productTitle: string;
|
|
16
|
+
name: string;
|
|
17
|
+
quantity: number;
|
|
18
|
+
discounts: Discount[];
|
|
19
|
+
path?: string;
|
|
20
|
+
variant: ProductVariant;
|
|
21
|
+
options?: SelectedOption[];
|
|
22
|
+
attributes?: Attribute[];
|
|
23
|
+
};
|
|
24
|
+
export type ProductVariant = {
|
|
25
|
+
id: string;
|
|
26
|
+
sku: string;
|
|
27
|
+
name: string;
|
|
28
|
+
requiresShipping: boolean;
|
|
29
|
+
price: number;
|
|
30
|
+
listPrice: number;
|
|
31
|
+
image?: Image;
|
|
32
|
+
isInStock?: boolean;
|
|
33
|
+
availableForSale?: boolean;
|
|
34
|
+
weight?: Measurement;
|
|
35
|
+
height?: Measurement;
|
|
36
|
+
width?: Measurement;
|
|
37
|
+
depth?: Measurement;
|
|
38
|
+
};
|
|
39
|
+
export type Cart = {
|
|
40
|
+
id: string;
|
|
41
|
+
customerId?: string;
|
|
42
|
+
email?: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
currency: {
|
|
45
|
+
code?: string;
|
|
46
|
+
};
|
|
47
|
+
taxesIncluded: boolean;
|
|
48
|
+
lineItems: LineItem[];
|
|
49
|
+
lineItemsSubtotalPrice: number;
|
|
50
|
+
subtotalPrice: number;
|
|
51
|
+
totalPrice: number;
|
|
52
|
+
discounts?: Discount[];
|
|
53
|
+
checkoutUrl?: string;
|
|
54
|
+
/** Cart note */
|
|
55
|
+
note?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Base cart item body used for cart mutations
|
|
59
|
+
*/
|
|
60
|
+
export type CartItemBody = {
|
|
61
|
+
variantId: string;
|
|
62
|
+
productId?: string;
|
|
63
|
+
quantity?: number;
|
|
64
|
+
attributes?: {
|
|
65
|
+
key: string;
|
|
66
|
+
value: string;
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Hooks schema
|
|
71
|
+
*/
|
|
72
|
+
export type CartTypes = {
|
|
73
|
+
cart?: Cart;
|
|
74
|
+
item: LineItem;
|
|
75
|
+
itemBody: CartItemBody;
|
|
76
|
+
};
|
|
77
|
+
export type CartHooks<T extends CartTypes = CartTypes> = {
|
|
78
|
+
getCart: GetCartHook<T>;
|
|
79
|
+
addItem: AddItemHook<T>;
|
|
80
|
+
updateItem: UpdateItemHook<T>;
|
|
81
|
+
removeItem: RemoveItemHook<T>;
|
|
82
|
+
};
|
|
83
|
+
export type GetCartHook<T extends CartTypes = CartTypes> = {
|
|
84
|
+
data: T['cart'] | null;
|
|
85
|
+
input: {};
|
|
86
|
+
fetcherInput: {
|
|
87
|
+
cartId?: string;
|
|
88
|
+
};
|
|
89
|
+
swrState: {
|
|
90
|
+
isEmpty: boolean;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export type AddItemHook<T extends CartTypes = CartTypes> = {
|
|
94
|
+
data: T['cart'];
|
|
95
|
+
input?: T['itemBody'];
|
|
96
|
+
fetcherInput: T['itemBody'];
|
|
97
|
+
body: {
|
|
98
|
+
item: T['itemBody'];
|
|
99
|
+
};
|
|
100
|
+
actionInput: T['itemBody'];
|
|
101
|
+
};
|
|
102
|
+
export type UpdateItemHook<T extends CartTypes = CartTypes> = {
|
|
103
|
+
data: T['cart'] | null;
|
|
104
|
+
input: {
|
|
105
|
+
item?: T['item'];
|
|
106
|
+
wait?: number;
|
|
107
|
+
};
|
|
108
|
+
fetcherInput: {
|
|
109
|
+
itemId: string;
|
|
110
|
+
item: T['itemBody'];
|
|
111
|
+
};
|
|
112
|
+
body: {
|
|
113
|
+
itemId: string;
|
|
114
|
+
item: T['itemBody'];
|
|
115
|
+
};
|
|
116
|
+
actionInput: T['itemBody'] & {
|
|
117
|
+
id: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export type RemoveItemHook<T extends CartTypes = CartTypes> = {
|
|
121
|
+
data: T['cart'] | null;
|
|
122
|
+
input: {
|
|
123
|
+
item?: T['item'];
|
|
124
|
+
};
|
|
125
|
+
fetcherInput: {
|
|
126
|
+
itemId: string;
|
|
127
|
+
};
|
|
128
|
+
body: {
|
|
129
|
+
itemId: string;
|
|
130
|
+
};
|
|
131
|
+
actionInput: {
|
|
132
|
+
id: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* API Schema
|
|
137
|
+
*/
|
|
138
|
+
export type CartSchema<T extends CartTypes = CartTypes> = {
|
|
139
|
+
endpoint: {
|
|
140
|
+
options: {};
|
|
141
|
+
handlers: CartHandlers<T>;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
export type CartHandlers<T extends CartTypes = CartTypes> = {
|
|
145
|
+
getCart: GetCartHandler<T>;
|
|
146
|
+
addItem: AddItemHandler<T>;
|
|
147
|
+
updateItem: UpdateItemHandler<T>;
|
|
148
|
+
removeItem: RemoveItemHandler<T>;
|
|
149
|
+
};
|
|
150
|
+
export type GetCartHandler<T extends CartTypes = CartTypes> = GetCartHook<T> & {
|
|
151
|
+
body: {
|
|
152
|
+
cartId?: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
export type AddItemHandler<T extends CartTypes = CartTypes> = AddItemHook<T> & {
|
|
156
|
+
body: {
|
|
157
|
+
cartId: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
export type UpdateItemHandler<T extends CartTypes = CartTypes> = UpdateItemHook<T> & {
|
|
161
|
+
data: T['cart'];
|
|
162
|
+
body: {
|
|
163
|
+
cartId: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
export type RemoveItemHandler<T extends CartTypes = CartTypes> = RemoveItemHook<T> & {
|
|
167
|
+
body: {
|
|
168
|
+
cartId: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
export type RemoveCartLineInput = {
|
|
172
|
+
cartId: string;
|
|
173
|
+
lineId: string;
|
|
174
|
+
};
|
|
175
|
+
export type UpdateCartLineInput = {
|
|
176
|
+
cartId: string;
|
|
177
|
+
line: CartItemBody & {
|
|
178
|
+
id: string;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export type AddCartLineInput = {
|
|
182
|
+
cartId: string;
|
|
183
|
+
lines: CartItemBody[];
|
|
184
|
+
};
|
|
185
|
+
export type CreateCartInput = {
|
|
186
|
+
items: CartItemBody[];
|
|
187
|
+
};
|
|
188
|
+
export type GetCartParams = {
|
|
189
|
+
cartId: string;
|
|
190
|
+
};
|
|
191
|
+
export type CartNoteUpdateInput = {
|
|
192
|
+
cartId: string;
|
|
193
|
+
note?: string;
|
|
194
|
+
};
|
|
195
|
+
export type CartDiscountCodesUpdateInput = {
|
|
196
|
+
cartId: string;
|
|
197
|
+
discountCodes?: string[];
|
|
198
|
+
};
|
|
199
|
+
export type GetCartFunc = (variables: GetCartParams) => Promise<Cart | undefined>;
|
|
200
|
+
export type CreateCartFunc = (variables: CreateCartInput) => Promise<Cart>;
|
|
201
|
+
export type UpdateCartLineFunc = (variables: UpdateCartLineInput) => Promise<Cart>;
|
|
202
|
+
export type RemoveCartLineFunc = (variables: RemoveCartLineInput) => Promise<Cart>;
|
|
203
|
+
export type AddCartLineFunc = (variables: AddCartLineInput) => Promise<Cart>;
|
|
204
|
+
export type CartNoteUpdateFunc = (variables: CartNoteUpdateInput) => Promise<Cart>;
|
|
205
|
+
export type CartDiscountCodesUpdateFunc = (variables: CartDiscountCodesUpdateInput) => Promise<Cart>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Address, AddressFields } from './customer/address';
|
|
2
|
+
import type { Card, CardFields } from './customer/card';
|
|
3
|
+
export type Checkout = any;
|
|
4
|
+
export type CheckoutTypes = {
|
|
5
|
+
card?: Card | CardFields;
|
|
6
|
+
address?: Address | AddressFields;
|
|
7
|
+
checkout?: Checkout;
|
|
8
|
+
hasPayment?: boolean;
|
|
9
|
+
hasShipping?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type SubmitCheckoutHook<T extends CheckoutTypes = CheckoutTypes> = {
|
|
12
|
+
data: T;
|
|
13
|
+
input?: T;
|
|
14
|
+
fetcherInput: T;
|
|
15
|
+
body: {
|
|
16
|
+
item: T;
|
|
17
|
+
};
|
|
18
|
+
actionInput: T;
|
|
19
|
+
};
|
|
20
|
+
export type GetCheckoutHook<T extends CheckoutTypes = CheckoutTypes> = {
|
|
21
|
+
data: T['checkout'] | null;
|
|
22
|
+
input: {};
|
|
23
|
+
fetcherInput: {
|
|
24
|
+
cartId?: string;
|
|
25
|
+
};
|
|
26
|
+
swrState: {
|
|
27
|
+
isEmpty: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type CheckoutHooks<T extends CheckoutTypes = CheckoutTypes> = {
|
|
31
|
+
submitCheckout?: SubmitCheckoutHook<T>;
|
|
32
|
+
getCheckout: GetCheckoutHook<T>;
|
|
33
|
+
};
|
|
34
|
+
export type GetCheckoutHandler<T extends CheckoutTypes = CheckoutTypes> = GetCheckoutHook<T> & {
|
|
35
|
+
body: {
|
|
36
|
+
cartId: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type SubmitCheckoutHandler<T extends CheckoutTypes = CheckoutTypes> = SubmitCheckoutHook<T> & {
|
|
40
|
+
body: {
|
|
41
|
+
cartId: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type CheckoutHandlers<T extends CheckoutTypes = CheckoutTypes> = {
|
|
45
|
+
getCheckout: GetCheckoutHandler<T>;
|
|
46
|
+
submitCheckout?: SubmitCheckoutHandler<T>;
|
|
47
|
+
};
|
|
48
|
+
export type CheckoutSchema<T extends CheckoutTypes = CheckoutTypes> = {
|
|
49
|
+
endpoint: {
|
|
50
|
+
options: {};
|
|
51
|
+
handlers: CheckoutHandlers<T>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Discount = {
|
|
2
|
+
value?: number;
|
|
3
|
+
code: string;
|
|
4
|
+
applicable?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type Measurement = {
|
|
7
|
+
value: number;
|
|
8
|
+
unit: 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES';
|
|
9
|
+
};
|
|
10
|
+
export type Image = {
|
|
11
|
+
url: string;
|
|
12
|
+
altText?: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export interface Address {
|
|
2
|
+
id: string;
|
|
3
|
+
mask: string;
|
|
4
|
+
}
|
|
5
|
+
export interface AddressFields {
|
|
6
|
+
type: string;
|
|
7
|
+
firstName: string;
|
|
8
|
+
lastName: string;
|
|
9
|
+
company: string;
|
|
10
|
+
streetNumber: string;
|
|
11
|
+
apartments: string;
|
|
12
|
+
zipCode: string;
|
|
13
|
+
city: string;
|
|
14
|
+
country: string;
|
|
15
|
+
}
|
|
16
|
+
export type CustomerAddressTypes = {
|
|
17
|
+
address?: Address;
|
|
18
|
+
fields: AddressFields;
|
|
19
|
+
};
|
|
20
|
+
export type GetAddressesHook<T extends CustomerAddressTypes = CustomerAddressTypes> = {
|
|
21
|
+
data: T['address'][] | null;
|
|
22
|
+
input: {};
|
|
23
|
+
fetcherInput: {
|
|
24
|
+
cartId?: string;
|
|
25
|
+
};
|
|
26
|
+
swrState: {
|
|
27
|
+
isEmpty: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type AddItemHook<T extends CustomerAddressTypes = CustomerAddressTypes> = {
|
|
31
|
+
data: T['address'];
|
|
32
|
+
input?: T['fields'];
|
|
33
|
+
fetcherInput: T['fields'];
|
|
34
|
+
body: {
|
|
35
|
+
item: T['fields'];
|
|
36
|
+
};
|
|
37
|
+
actionInput: T['fields'];
|
|
38
|
+
};
|
|
39
|
+
export type UpdateItemHook<T extends CustomerAddressTypes = CustomerAddressTypes> = {
|
|
40
|
+
data: T['address'] | null;
|
|
41
|
+
input: {
|
|
42
|
+
item?: T['fields'];
|
|
43
|
+
wait?: number;
|
|
44
|
+
};
|
|
45
|
+
fetcherInput: {
|
|
46
|
+
itemId: string;
|
|
47
|
+
item: T['fields'];
|
|
48
|
+
};
|
|
49
|
+
body: {
|
|
50
|
+
itemId: string;
|
|
51
|
+
item: T['fields'];
|
|
52
|
+
};
|
|
53
|
+
actionInput: T['fields'] & {
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type RemoveItemHook<T extends CustomerAddressTypes = CustomerAddressTypes> = {
|
|
58
|
+
data: T['address'] | null;
|
|
59
|
+
input: {
|
|
60
|
+
item?: T['address'];
|
|
61
|
+
};
|
|
62
|
+
fetcherInput: {
|
|
63
|
+
itemId: string;
|
|
64
|
+
};
|
|
65
|
+
body: {
|
|
66
|
+
itemId: string;
|
|
67
|
+
};
|
|
68
|
+
actionInput: {
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export type CustomerAddressHooks<T extends CustomerAddressTypes = CustomerAddressTypes> = {
|
|
73
|
+
getAddresses: GetAddressesHook<T>;
|
|
74
|
+
addItem: AddItemHook<T>;
|
|
75
|
+
updateItem: UpdateItemHook<T>;
|
|
76
|
+
removeItem: RemoveItemHook<T>;
|
|
77
|
+
};
|
|
78
|
+
export type AddressHandler<T extends CustomerAddressTypes = CustomerAddressTypes> = GetAddressesHook<T> & {
|
|
79
|
+
body: {
|
|
80
|
+
cartId?: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export type AddItemHandler<T extends CustomerAddressTypes = CustomerAddressTypes> = AddItemHook<T> & {
|
|
84
|
+
body: {
|
|
85
|
+
cartId: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export type UpdateItemHandler<T extends CustomerAddressTypes = CustomerAddressTypes> = UpdateItemHook<T> & {
|
|
89
|
+
data: T['address'];
|
|
90
|
+
body: {
|
|
91
|
+
cartId: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export type RemoveItemHandler<T extends CustomerAddressTypes = CustomerAddressTypes> = RemoveItemHook<T> & {
|
|
95
|
+
body: {
|
|
96
|
+
cartId: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export type CustomerAddressHandlers<T extends CustomerAddressTypes = CustomerAddressTypes> = {
|
|
100
|
+
getAddresses: GetAddressesHook<T>;
|
|
101
|
+
addItem: AddItemHandler<T>;
|
|
102
|
+
updateItem: UpdateItemHandler<T>;
|
|
103
|
+
removeItem: RemoveItemHandler<T>;
|
|
104
|
+
};
|
|
105
|
+
export type CustomerAddressSchema<T extends CustomerAddressTypes = CustomerAddressTypes> = {
|
|
106
|
+
endpoint: {
|
|
107
|
+
options: {};
|
|
108
|
+
handlers: CustomerAddressHandlers<T>;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export interface Card {
|
|
2
|
+
id: string;
|
|
3
|
+
mask: string;
|
|
4
|
+
provider: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CardFields {
|
|
7
|
+
cardHolder: string;
|
|
8
|
+
cardNumber: string;
|
|
9
|
+
cardExpireDate: string;
|
|
10
|
+
cardCvc: string;
|
|
11
|
+
firstName: string;
|
|
12
|
+
lastName: string;
|
|
13
|
+
company: string;
|
|
14
|
+
streetNumber: string;
|
|
15
|
+
zipCode: string;
|
|
16
|
+
city: string;
|
|
17
|
+
country: string;
|
|
18
|
+
}
|
|
19
|
+
export type CustomerCardTypes = {
|
|
20
|
+
card?: Card;
|
|
21
|
+
fields: CardFields;
|
|
22
|
+
};
|
|
23
|
+
export type GetCardsHook<T extends CustomerCardTypes = CustomerCardTypes> = {
|
|
24
|
+
data: T['card'][] | null;
|
|
25
|
+
input: {};
|
|
26
|
+
fetcherInput: {
|
|
27
|
+
cartId?: string;
|
|
28
|
+
};
|
|
29
|
+
swrState: {
|
|
30
|
+
isEmpty: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type AddItemHook<T extends CustomerCardTypes = CustomerCardTypes> = {
|
|
34
|
+
data: T['card'];
|
|
35
|
+
input?: T['fields'];
|
|
36
|
+
fetcherInput: T['fields'];
|
|
37
|
+
body: {
|
|
38
|
+
item: T['fields'];
|
|
39
|
+
};
|
|
40
|
+
actionInput: T['fields'];
|
|
41
|
+
};
|
|
42
|
+
export type UpdateItemHook<T extends CustomerCardTypes = CustomerCardTypes> = {
|
|
43
|
+
data: T['card'] | null;
|
|
44
|
+
input: {
|
|
45
|
+
item?: T['fields'];
|
|
46
|
+
wait?: number;
|
|
47
|
+
};
|
|
48
|
+
fetcherInput: {
|
|
49
|
+
itemId: string;
|
|
50
|
+
item: T['fields'];
|
|
51
|
+
};
|
|
52
|
+
body: {
|
|
53
|
+
itemId: string;
|
|
54
|
+
item: T['fields'];
|
|
55
|
+
};
|
|
56
|
+
actionInput: T['fields'] & {
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type RemoveItemHook<T extends CustomerCardTypes = CustomerCardTypes> = {
|
|
61
|
+
data: T['card'] | null;
|
|
62
|
+
input: {
|
|
63
|
+
item?: T['card'];
|
|
64
|
+
};
|
|
65
|
+
fetcherInput: {
|
|
66
|
+
itemId: string;
|
|
67
|
+
};
|
|
68
|
+
body: {
|
|
69
|
+
itemId: string;
|
|
70
|
+
};
|
|
71
|
+
actionInput: {
|
|
72
|
+
id: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type CustomerCardHooks<T extends CustomerCardTypes = CustomerCardTypes> = {
|
|
76
|
+
getCards: GetCardsHook<T>;
|
|
77
|
+
addItem: AddItemHook<T>;
|
|
78
|
+
updateItem: UpdateItemHook<T>;
|
|
79
|
+
removeItem: RemoveItemHook<T>;
|
|
80
|
+
};
|
|
81
|
+
export type CardsHandler<T extends CustomerCardTypes = CustomerCardTypes> = GetCardsHook<T> & {
|
|
82
|
+
body: {
|
|
83
|
+
cartId?: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export type AddItemHandler<T extends CustomerCardTypes = CustomerCardTypes> = AddItemHook<T> & {
|
|
87
|
+
body: {
|
|
88
|
+
cartId: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export type UpdateItemHandler<T extends CustomerCardTypes = CustomerCardTypes> = UpdateItemHook<T> & {
|
|
92
|
+
data: T['card'];
|
|
93
|
+
body: {
|
|
94
|
+
cartId: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export type RemoveItemHandler<T extends CustomerCardTypes = CustomerCardTypes> = RemoveItemHook<T> & {
|
|
98
|
+
body: {
|
|
99
|
+
cartId: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export type CustomerCardHandlers<T extends CustomerCardTypes = CustomerCardTypes> = {
|
|
103
|
+
getCards: GetCardsHook<T>;
|
|
104
|
+
addItem: AddItemHandler<T>;
|
|
105
|
+
updateItem: UpdateItemHandler<T>;
|
|
106
|
+
removeItem: RemoveItemHandler<T>;
|
|
107
|
+
};
|
|
108
|
+
export type CustomerCardSchema<T extends CustomerCardTypes = CustomerCardTypes> = {
|
|
109
|
+
endpoint: {
|
|
110
|
+
options: {};
|
|
111
|
+
handlers: CustomerCardHandlers<T>;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * as Card from './card';
|
|
2
|
+
export * as Address from './address';
|
|
3
|
+
export type Customer = any;
|
|
4
|
+
export type CustomerTypes = {
|
|
5
|
+
customer: Customer;
|
|
6
|
+
};
|
|
7
|
+
export type CustomerHook<T extends CustomerTypes = CustomerTypes> = {
|
|
8
|
+
data: T['customer'] | null;
|
|
9
|
+
fetchData: {
|
|
10
|
+
customer: T['customer'];
|
|
11
|
+
} | null;
|
|
12
|
+
};
|
|
13
|
+
export type CustomerSchema<T extends CustomerTypes = CustomerTypes> = {
|
|
14
|
+
endpoint: {
|
|
15
|
+
options: {};
|
|
16
|
+
handlers: {
|
|
17
|
+
getLoggedInCustomer: {
|
|
18
|
+
data: {
|
|
19
|
+
customer: T['customer'];
|
|
20
|
+
} | null;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type TypographyProps = {
|
|
2
|
+
fontSize?: string;
|
|
3
|
+
fontWeight?: string | number;
|
|
4
|
+
fontStyle?: string;
|
|
5
|
+
fontFamily?: string;
|
|
6
|
+
lineHeight?: string;
|
|
7
|
+
letterSpacing?: string;
|
|
8
|
+
};
|
|
9
|
+
type ColorType = 'brand' | 'text' | 'background' | 'line';
|
|
10
|
+
type FuncColorObject = {
|
|
11
|
+
info: string;
|
|
12
|
+
warn: string;
|
|
13
|
+
success: string;
|
|
14
|
+
danger: string;
|
|
15
|
+
};
|
|
16
|
+
type TypographyType = 'heading-1' | 'heading-2' | 'heading-3' | 'subheading-1' | 'subheading-2' | 'subheading-3' | 'paragraph-1' | 'paragraph-2' | 'paragraph-3';
|
|
17
|
+
type ObjectDeviceType<T> = {
|
|
18
|
+
desktop: T;
|
|
19
|
+
tablet?: T;
|
|
20
|
+
mobile?: T;
|
|
21
|
+
};
|
|
22
|
+
type SpacingType = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
|
|
23
|
+
type RoundedSize = 'small' | 'medium' | 'large';
|
|
24
|
+
export type GlobalStyleConfig = {
|
|
25
|
+
color: Record<ColorType, Record<string, string>> & {
|
|
26
|
+
func: FuncColorObject;
|
|
27
|
+
};
|
|
28
|
+
typography: Record<TypographyType, ObjectDeviceType<TypographyProps>>;
|
|
29
|
+
spacing: Record<SpacingType, ObjectDeviceType<string>>;
|
|
30
|
+
radius: Record<RoundedSize, string>;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as Cart from './cart';
|
|
2
|
+
import type * as Checkout from './checkout';
|
|
3
|
+
import type * as Common from './common';
|
|
4
|
+
import type * as Customer from './customer';
|
|
5
|
+
import type * as Login from './login';
|
|
6
|
+
import type * as Logout from './logout';
|
|
7
|
+
import type * as Page from './page';
|
|
8
|
+
import type * as Product from './product';
|
|
9
|
+
import type * as Signup from './signup';
|
|
10
|
+
import type * as Site from './site';
|
|
11
|
+
import type * as Wishlist from './wishlist';
|
|
12
|
+
import type { GlobalStyleConfig, TypographyProps } from './global-style';
|
|
13
|
+
export type { Cart, Checkout, Common, Customer, Login, Logout, Page, Product, Signup, Site, Wishlist, GlobalStyleConfig, TypographyProps, };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type LoginBody = {
|
|
2
|
+
email: string;
|
|
3
|
+
password: string;
|
|
4
|
+
};
|
|
5
|
+
export type LoginTypes = {
|
|
6
|
+
body: LoginBody;
|
|
7
|
+
};
|
|
8
|
+
export type LoginHook<T extends LoginTypes = LoginTypes> = {
|
|
9
|
+
data: null;
|
|
10
|
+
actionInput: LoginBody;
|
|
11
|
+
fetcherInput: LoginBody;
|
|
12
|
+
body: T['body'];
|
|
13
|
+
};
|
|
14
|
+
export type LoginSchema<T extends LoginTypes = LoginTypes> = {
|
|
15
|
+
endpoint: {
|
|
16
|
+
options: {};
|
|
17
|
+
handlers: {
|
|
18
|
+
login: LoginHook<T>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type LoginOperation = {
|
|
23
|
+
data: {
|
|
24
|
+
result?: string;
|
|
25
|
+
};
|
|
26
|
+
variables: unknown;
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type LogoutTypes = {
|
|
2
|
+
body: {
|
|
3
|
+
redirectTo?: string;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
export type LogoutHook<T extends LogoutTypes = LogoutTypes> = {
|
|
7
|
+
data: null;
|
|
8
|
+
body: T['body'];
|
|
9
|
+
};
|
|
10
|
+
export type LogoutSchema<T extends LogoutTypes = LogoutTypes> = {
|
|
11
|
+
endpoint: {
|
|
12
|
+
options: {};
|
|
13
|
+
handlers: {
|
|
14
|
+
logout: LogoutHook<T>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type Page = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
body: string;
|
|
6
|
+
is_visible?: boolean;
|
|
7
|
+
sort_order?: number;
|
|
8
|
+
};
|
|
9
|
+
export type PageTypes = {
|
|
10
|
+
page: Page;
|
|
11
|
+
};
|
|
12
|
+
export type GetAllPagesOperation<T extends PageTypes = PageTypes> = {
|
|
13
|
+
data: {
|
|
14
|
+
pages: T['page'][];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type GetPageOperation<T extends PageTypes = PageTypes> = {
|
|
18
|
+
data: {
|
|
19
|
+
page?: T['page'];
|
|
20
|
+
};
|
|
21
|
+
variables: {
|
|
22
|
+
id: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export type ProductImage = {
|
|
2
|
+
url: string;
|
|
3
|
+
alt?: string;
|
|
4
|
+
};
|
|
5
|
+
export type ProductPrice = {
|
|
6
|
+
value: number;
|
|
7
|
+
currencyCode?: 'USD' | 'EUR' | 'ARS' | 'GBP' | string;
|
|
8
|
+
retailPrice?: number;
|
|
9
|
+
salePrice?: number;
|
|
10
|
+
listPrice?: number;
|
|
11
|
+
extendedSalePrice?: number;
|
|
12
|
+
extendedListPrice?: number;
|
|
13
|
+
};
|
|
14
|
+
export type ProductOption = {
|
|
15
|
+
__typename?: 'MultipleChoiceOption';
|
|
16
|
+
id: string;
|
|
17
|
+
displayName: string;
|
|
18
|
+
values: ProductOptionValues[];
|
|
19
|
+
};
|
|
20
|
+
export type ProductOptionValues = {
|
|
21
|
+
label: string;
|
|
22
|
+
hexColors?: string[];
|
|
23
|
+
};
|
|
24
|
+
export type ProductVariant = {
|
|
25
|
+
id: string | number;
|
|
26
|
+
options: ProductOption[];
|
|
27
|
+
availableForSale?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type Product = {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
descriptionHtml?: string;
|
|
34
|
+
sku?: string;
|
|
35
|
+
slug?: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
images: ProductImage[];
|
|
38
|
+
variants: ProductVariant[];
|
|
39
|
+
price: ProductPrice;
|
|
40
|
+
options: ProductOption[];
|
|
41
|
+
vendor?: string;
|
|
42
|
+
};
|
|
43
|
+
export type SearchProductsBody = {
|
|
44
|
+
search?: string;
|
|
45
|
+
categoryId?: string | number;
|
|
46
|
+
brandId?: string | number;
|
|
47
|
+
sort?: string;
|
|
48
|
+
locale?: string;
|
|
49
|
+
};
|
|
50
|
+
export type ProductTypes = {
|
|
51
|
+
product: Product;
|
|
52
|
+
searchBody: SearchProductsBody;
|
|
53
|
+
};
|
|
54
|
+
export type SearchProductsHook<T extends ProductTypes = ProductTypes> = {
|
|
55
|
+
data: {
|
|
56
|
+
products: T['product'][];
|
|
57
|
+
found: boolean;
|
|
58
|
+
};
|
|
59
|
+
body: T['searchBody'];
|
|
60
|
+
input: T['searchBody'];
|
|
61
|
+
fetcherInput: T['searchBody'];
|
|
62
|
+
};
|
|
63
|
+
export type ProductsSchema<T extends ProductTypes = ProductTypes> = {
|
|
64
|
+
endpoint: {
|
|
65
|
+
options: {};
|
|
66
|
+
handlers: {
|
|
67
|
+
getProducts: SearchProductsHook<T>;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export type GetAllProductPathsOperation<T extends ProductTypes = ProductTypes> = {
|
|
72
|
+
data: {
|
|
73
|
+
products: Pick<T['product'], 'path'>[];
|
|
74
|
+
};
|
|
75
|
+
variables: {
|
|
76
|
+
first?: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export type GetAllProductsOperation<T extends ProductTypes = ProductTypes> = {
|
|
80
|
+
data: {
|
|
81
|
+
products: T['product'][];
|
|
82
|
+
};
|
|
83
|
+
variables: {
|
|
84
|
+
relevance?: 'featured' | 'best_selling' | 'newest';
|
|
85
|
+
ids?: string[];
|
|
86
|
+
first?: number;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export type GetProductOperation<T extends ProductTypes = ProductTypes> = {
|
|
90
|
+
data: {
|
|
91
|
+
product?: T['product'];
|
|
92
|
+
};
|
|
93
|
+
variables: {
|
|
94
|
+
path: string;
|
|
95
|
+
slug?: never;
|
|
96
|
+
} | {
|
|
97
|
+
path?: never;
|
|
98
|
+
slug: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type SignupBody = {
|
|
2
|
+
firstName: string;
|
|
3
|
+
lastName: string;
|
|
4
|
+
email: string;
|
|
5
|
+
password: string;
|
|
6
|
+
};
|
|
7
|
+
export type SignupTypes = {
|
|
8
|
+
body: SignupBody;
|
|
9
|
+
};
|
|
10
|
+
export type SignupHook<T extends SignupTypes = SignupTypes> = {
|
|
11
|
+
data: null;
|
|
12
|
+
body: T['body'];
|
|
13
|
+
actionInput: T['body'];
|
|
14
|
+
fetcherInput: T['body'];
|
|
15
|
+
};
|
|
16
|
+
export type SignupSchema<T extends SignupTypes = SignupTypes> = {
|
|
17
|
+
endpoint: {
|
|
18
|
+
options: {};
|
|
19
|
+
handlers: {
|
|
20
|
+
signup: SignupHook<T>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type Category = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
slug: string;
|
|
5
|
+
path: string;
|
|
6
|
+
};
|
|
7
|
+
export type Brand = any;
|
|
8
|
+
export type SiteTypes = {
|
|
9
|
+
category: Category;
|
|
10
|
+
brand: Brand;
|
|
11
|
+
};
|
|
12
|
+
export type GetSiteInfoOperation<T extends SiteTypes = SiteTypes> = {
|
|
13
|
+
data: {
|
|
14
|
+
categories: T['category'][];
|
|
15
|
+
brands: T['brand'][];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type ProviderConfig = {
|
|
19
|
+
storefrontUrl?: string;
|
|
20
|
+
storefrontToken?: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type Wishlist = any;
|
|
2
|
+
export type WishlistItemBody = {
|
|
3
|
+
variantId: string | number;
|
|
4
|
+
productId: string;
|
|
5
|
+
};
|
|
6
|
+
export type WishlistTypes = {
|
|
7
|
+
wishlist: Wishlist;
|
|
8
|
+
itemBody: WishlistItemBody;
|
|
9
|
+
};
|
|
10
|
+
export type GetWishlistHook<T extends WishlistTypes = WishlistTypes> = {
|
|
11
|
+
data: T['wishlist'] | null;
|
|
12
|
+
body: {
|
|
13
|
+
includeProducts?: boolean;
|
|
14
|
+
};
|
|
15
|
+
input: {
|
|
16
|
+
includeProducts?: boolean;
|
|
17
|
+
};
|
|
18
|
+
fetcherInput: {
|
|
19
|
+
customerId: string;
|
|
20
|
+
includeProducts?: boolean;
|
|
21
|
+
};
|
|
22
|
+
swrState: {
|
|
23
|
+
isEmpty: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type AddItemHook<T extends WishlistTypes = WishlistTypes> = {
|
|
27
|
+
data: T['wishlist'];
|
|
28
|
+
body: {
|
|
29
|
+
item: T['itemBody'];
|
|
30
|
+
};
|
|
31
|
+
fetcherInput: {
|
|
32
|
+
item: T['itemBody'];
|
|
33
|
+
};
|
|
34
|
+
actionInput: T['itemBody'];
|
|
35
|
+
};
|
|
36
|
+
export type RemoveItemHook<T extends WishlistTypes = WishlistTypes> = {
|
|
37
|
+
data: T['wishlist'] | null;
|
|
38
|
+
body: {
|
|
39
|
+
itemId: string;
|
|
40
|
+
};
|
|
41
|
+
fetcherInput: {
|
|
42
|
+
itemId: string;
|
|
43
|
+
};
|
|
44
|
+
actionInput: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
input: {
|
|
48
|
+
wishlist?: {
|
|
49
|
+
includeProducts?: boolean;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type WishlistSchema<T extends WishlistTypes = WishlistTypes> = {
|
|
54
|
+
endpoint: {
|
|
55
|
+
options: {};
|
|
56
|
+
handlers: {
|
|
57
|
+
getWishlist: GetWishlistHook<T> & {
|
|
58
|
+
data: T['wishlist'] | null;
|
|
59
|
+
body: {
|
|
60
|
+
customerToken?: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
addItem: AddItemHook<T> & {
|
|
64
|
+
body: {
|
|
65
|
+
customerToken?: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
removeItem: RemoveItemHook<T> & {
|
|
69
|
+
body: {
|
|
70
|
+
customerToken?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export type GetCustomerWishlistOperation<T extends WishlistTypes = WishlistTypes> = {
|
|
77
|
+
data: {
|
|
78
|
+
wishlist?: T['wishlist'];
|
|
79
|
+
};
|
|
80
|
+
variables: {
|
|
81
|
+
customerId: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gem-sdk/adapter-common",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"pre:publish": "node ./scripts/convert-publish.js -p",
|
|
10
|
+
"post:publish": "node ./scripts/convert-publish.js",
|
|
11
|
+
"cleanup": "rimraf es dist lib",
|
|
12
|
+
"prebuild": "yarn cleanup",
|
|
13
|
+
"ts-types": "tsc -p tsconfig.json --emitDeclarationOnly --noEmit false",
|
|
14
|
+
"build": "yarn ts-types",
|
|
15
|
+
"type-check": "yarn tsc --noEmit",
|
|
16
|
+
"lint": "eslint ./src --ext .tsx,.ts"
|
|
17
|
+
},
|
|
18
|
+
"types": "dist/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/types/index.d.ts"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|