@asteby/storefront 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +164 -2
- package/dist/index.cjs +324 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +257 -0
- package/dist/index.d.ts +257 -0
- package/dist/index.js +312 -0
- package/dist/index.js.map +1 -0
- package/dist/mock.cjs +986 -0
- package/dist/mock.cjs.map +1 -0
- package/dist/mock.d.cts +95 -0
- package/dist/mock.d.ts +95 -0
- package/dist/mock.js +981 -0
- package/dist/mock.js.map +1 -0
- package/dist/types-BdaQ9Pxq.d.cts +375 -0
- package/dist/types-BdaQ9Pxq.d.ts +375 -0
- package/package.json +59 -3
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storefront API v1 contract types.
|
|
3
|
+
*
|
|
4
|
+
* Field names match the wire format exactly (snake_case). Money amounts are
|
|
5
|
+
* decimal strings ("1899.00") so no precision is lost in transit.
|
|
6
|
+
*/
|
|
7
|
+
type Money = {
|
|
8
|
+
amount: string;
|
|
9
|
+
currency_code: string;
|
|
10
|
+
};
|
|
11
|
+
type Image = {
|
|
12
|
+
url: string;
|
|
13
|
+
alt: string | null;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
};
|
|
17
|
+
type SEO = {
|
|
18
|
+
title: string | null;
|
|
19
|
+
description: string | null;
|
|
20
|
+
};
|
|
21
|
+
type PageInfo = {
|
|
22
|
+
has_next_page: boolean;
|
|
23
|
+
end_cursor: string | null;
|
|
24
|
+
};
|
|
25
|
+
type Connection<T> = {
|
|
26
|
+
nodes: T[];
|
|
27
|
+
page_info: PageInfo;
|
|
28
|
+
total_count?: number;
|
|
29
|
+
};
|
|
30
|
+
type ProductOption = {
|
|
31
|
+
name: string;
|
|
32
|
+
values: string[];
|
|
33
|
+
};
|
|
34
|
+
type SelectedOption = {
|
|
35
|
+
name: string;
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
38
|
+
type ProductVariant = {
|
|
39
|
+
id: string;
|
|
40
|
+
sku: string;
|
|
41
|
+
title: string;
|
|
42
|
+
selected_options: SelectedOption[];
|
|
43
|
+
price: Money;
|
|
44
|
+
compare_at_price: Money | null;
|
|
45
|
+
available_for_sale: boolean;
|
|
46
|
+
quantity_available: number | null;
|
|
47
|
+
image: Image | null;
|
|
48
|
+
barcode: string | null;
|
|
49
|
+
};
|
|
50
|
+
type ProductAttributeValue = string | number | boolean;
|
|
51
|
+
type ProductCategory = {
|
|
52
|
+
id: string;
|
|
53
|
+
handle: string;
|
|
54
|
+
title: string;
|
|
55
|
+
};
|
|
56
|
+
type MoneyRange = {
|
|
57
|
+
min: Money;
|
|
58
|
+
max: Money;
|
|
59
|
+
};
|
|
60
|
+
type Product = {
|
|
61
|
+
id: string;
|
|
62
|
+
handle: string;
|
|
63
|
+
title: string;
|
|
64
|
+
description: string;
|
|
65
|
+
/** HTML sanitized server-side. */
|
|
66
|
+
description_html: string;
|
|
67
|
+
/** Brand. */
|
|
68
|
+
vendor: string | null;
|
|
69
|
+
product_type: string | null;
|
|
70
|
+
category: ProductCategory | null;
|
|
71
|
+
tags: string[];
|
|
72
|
+
/** Free-form typed attributes, e.g. tire specs: width, aspect, rim, size_key. */
|
|
73
|
+
attributes: Record<string, ProductAttributeValue>;
|
|
74
|
+
featured_image: Image | null;
|
|
75
|
+
images: Image[];
|
|
76
|
+
options: ProductOption[];
|
|
77
|
+
variants: ProductVariant[];
|
|
78
|
+
price_range: MoneyRange;
|
|
79
|
+
compare_at_price_range: MoneyRange | null;
|
|
80
|
+
available_for_sale: boolean;
|
|
81
|
+
seo: SEO;
|
|
82
|
+
/** RFC 3339. */
|
|
83
|
+
updated_at: string;
|
|
84
|
+
};
|
|
85
|
+
type Collection = {
|
|
86
|
+
id: string;
|
|
87
|
+
handle: string;
|
|
88
|
+
title: string;
|
|
89
|
+
description: string;
|
|
90
|
+
image: Image | null;
|
|
91
|
+
seo: SEO;
|
|
92
|
+
parent_handle: string | null;
|
|
93
|
+
};
|
|
94
|
+
type FacetValue = {
|
|
95
|
+
value: string;
|
|
96
|
+
label: string;
|
|
97
|
+
count: number;
|
|
98
|
+
};
|
|
99
|
+
type Facet = {
|
|
100
|
+
key: string;
|
|
101
|
+
label: string;
|
|
102
|
+
type: 'list' | 'price_range';
|
|
103
|
+
values: FacetValue[];
|
|
104
|
+
};
|
|
105
|
+
type ProductSort = 'relevance' | 'price_asc' | 'price_desc' | 'newest' | 'title_asc';
|
|
106
|
+
type ProductConnection = Connection<Product> & {
|
|
107
|
+
facets: Facet[];
|
|
108
|
+
};
|
|
109
|
+
type StockLevel = {
|
|
110
|
+
sku: string;
|
|
111
|
+
quantity_available: number;
|
|
112
|
+
};
|
|
113
|
+
type ShopContact = {
|
|
114
|
+
email: string | null;
|
|
115
|
+
phone: string | null;
|
|
116
|
+
whatsapp: string | null;
|
|
117
|
+
};
|
|
118
|
+
type ShopBranch = {
|
|
119
|
+
id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
address: string;
|
|
122
|
+
city: string;
|
|
123
|
+
phone: string | null;
|
|
124
|
+
lat: number | null;
|
|
125
|
+
lng: number | null;
|
|
126
|
+
hours: string | null;
|
|
127
|
+
};
|
|
128
|
+
type ShopPolicies = {
|
|
129
|
+
free_shipping_min: Money | null;
|
|
130
|
+
returns_days: number | null;
|
|
131
|
+
};
|
|
132
|
+
type Shop = {
|
|
133
|
+
name: string;
|
|
134
|
+
description: string | null;
|
|
135
|
+
domain: string | null;
|
|
136
|
+
currency_code: string;
|
|
137
|
+
locale: string;
|
|
138
|
+
locales: string[];
|
|
139
|
+
country_code: string;
|
|
140
|
+
logo: Image | null;
|
|
141
|
+
contact: ShopContact;
|
|
142
|
+
branches: ShopBranch[];
|
|
143
|
+
policies: ShopPolicies;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Postal address. The contract references `Address` without spelling it out;
|
|
147
|
+
* this is the shape the client sends and the mock returns.
|
|
148
|
+
*/
|
|
149
|
+
type Address = {
|
|
150
|
+
/** Present on saved customer addresses. */
|
|
151
|
+
id?: string;
|
|
152
|
+
first_name: string | null;
|
|
153
|
+
last_name: string | null;
|
|
154
|
+
company: string | null;
|
|
155
|
+
address1: string;
|
|
156
|
+
address2: string | null;
|
|
157
|
+
city: string;
|
|
158
|
+
province: string | null;
|
|
159
|
+
zip: string;
|
|
160
|
+
country_code: string;
|
|
161
|
+
phone: string | null;
|
|
162
|
+
};
|
|
163
|
+
type AddressInput = Partial<Omit<Address, 'id' | 'address1' | 'city' | 'zip' | 'country_code'>> & Pick<Address, 'address1' | 'city' | 'zip' | 'country_code'>;
|
|
164
|
+
type CartLineMerchandise = ProductVariant & {
|
|
165
|
+
product: Pick<Product, 'handle' | 'title' | 'featured_image'>;
|
|
166
|
+
};
|
|
167
|
+
type CartLine = {
|
|
168
|
+
id: string;
|
|
169
|
+
quantity: number;
|
|
170
|
+
merchandise: CartLineMerchandise;
|
|
171
|
+
cost: {
|
|
172
|
+
total: Money;
|
|
173
|
+
unit: Money;
|
|
174
|
+
compare_at_unit: Money | null;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
type CartDiscountCode = {
|
|
178
|
+
code: string;
|
|
179
|
+
applicable: boolean;
|
|
180
|
+
};
|
|
181
|
+
type CartBuyer = {
|
|
182
|
+
email: string | null;
|
|
183
|
+
phone: string | null;
|
|
184
|
+
customer_id: string | null;
|
|
185
|
+
};
|
|
186
|
+
type DeliveryMethod = 'shipping' | 'pickup';
|
|
187
|
+
type CartDelivery = {
|
|
188
|
+
method: DeliveryMethod | null;
|
|
189
|
+
rate_id: string | null;
|
|
190
|
+
branch_id: string | null;
|
|
191
|
+
};
|
|
192
|
+
type CartCost = {
|
|
193
|
+
subtotal: Money;
|
|
194
|
+
discount: Money;
|
|
195
|
+
shipping: Money | null;
|
|
196
|
+
tax: Money | null;
|
|
197
|
+
total: Money;
|
|
198
|
+
tax_included: boolean;
|
|
199
|
+
};
|
|
200
|
+
type Cart = {
|
|
201
|
+
id: string;
|
|
202
|
+
lines: CartLine[];
|
|
203
|
+
total_quantity: number;
|
|
204
|
+
discount_codes: CartDiscountCode[];
|
|
205
|
+
buyer: CartBuyer;
|
|
206
|
+
shipping_address: Address | null;
|
|
207
|
+
delivery: CartDelivery;
|
|
208
|
+
cost: CartCost;
|
|
209
|
+
updated_at: string;
|
|
210
|
+
};
|
|
211
|
+
type CartLineInput = {
|
|
212
|
+
variant_id: string;
|
|
213
|
+
quantity: number;
|
|
214
|
+
};
|
|
215
|
+
type CartLineUpdateInput = {
|
|
216
|
+
id: string;
|
|
217
|
+
quantity: number;
|
|
218
|
+
};
|
|
219
|
+
type CartBuyerInput = {
|
|
220
|
+
email?: string | null;
|
|
221
|
+
phone?: string | null;
|
|
222
|
+
};
|
|
223
|
+
type ShippingRate = {
|
|
224
|
+
id: string;
|
|
225
|
+
title: string;
|
|
226
|
+
cost: Money;
|
|
227
|
+
eta: string | null;
|
|
228
|
+
};
|
|
229
|
+
type PickupOption = {
|
|
230
|
+
branch_id: string;
|
|
231
|
+
name: string;
|
|
232
|
+
};
|
|
233
|
+
type DeliveryOptions = {
|
|
234
|
+
rates: ShippingRate[];
|
|
235
|
+
pickup: PickupOption[];
|
|
236
|
+
};
|
|
237
|
+
type DeliveryInput = {
|
|
238
|
+
method: DeliveryMethod;
|
|
239
|
+
rate_id?: string;
|
|
240
|
+
branch_id?: string;
|
|
241
|
+
};
|
|
242
|
+
type InvoiceRequest = {
|
|
243
|
+
rfc?: string;
|
|
244
|
+
legal_name?: string;
|
|
245
|
+
tax_regime?: string;
|
|
246
|
+
zip?: string;
|
|
247
|
+
cfdi_use?: string;
|
|
248
|
+
email?: string;
|
|
249
|
+
[key: string]: unknown;
|
|
250
|
+
};
|
|
251
|
+
type CheckoutInput = {
|
|
252
|
+
payment_method: string;
|
|
253
|
+
invoice?: InvoiceRequest;
|
|
254
|
+
return_url: string;
|
|
255
|
+
};
|
|
256
|
+
type CheckoutPayment = {
|
|
257
|
+
provider: string;
|
|
258
|
+
status: string;
|
|
259
|
+
redirect_url?: string | null;
|
|
260
|
+
client_secret?: string | null;
|
|
261
|
+
};
|
|
262
|
+
type CheckoutResult = {
|
|
263
|
+
order: {
|
|
264
|
+
id: string;
|
|
265
|
+
number: string;
|
|
266
|
+
};
|
|
267
|
+
payment: CheckoutPayment;
|
|
268
|
+
};
|
|
269
|
+
type Customer = {
|
|
270
|
+
id: string;
|
|
271
|
+
email: string | null;
|
|
272
|
+
phone: string | null;
|
|
273
|
+
first_name: string | null;
|
|
274
|
+
last_name: string | null;
|
|
275
|
+
default_address_id: string | null;
|
|
276
|
+
created_at: string;
|
|
277
|
+
};
|
|
278
|
+
type CustomerIdentifier = {
|
|
279
|
+
email: string;
|
|
280
|
+
phone?: never;
|
|
281
|
+
} | {
|
|
282
|
+
phone: string;
|
|
283
|
+
email?: never;
|
|
284
|
+
};
|
|
285
|
+
type CustomerSessionInput = CustomerIdentifier & {
|
|
286
|
+
code: string;
|
|
287
|
+
};
|
|
288
|
+
type CustomerSession = {
|
|
289
|
+
token: string;
|
|
290
|
+
expires_at: string;
|
|
291
|
+
customer: Customer;
|
|
292
|
+
};
|
|
293
|
+
type OrderLine = {
|
|
294
|
+
title: string;
|
|
295
|
+
variant_title: string | null;
|
|
296
|
+
sku: string | null;
|
|
297
|
+
quantity: number;
|
|
298
|
+
unit: Money;
|
|
299
|
+
total: Money;
|
|
300
|
+
image: Image | null;
|
|
301
|
+
};
|
|
302
|
+
type Order = {
|
|
303
|
+
id: string;
|
|
304
|
+
number: string;
|
|
305
|
+
status: string;
|
|
306
|
+
created_at: string;
|
|
307
|
+
total: Money;
|
|
308
|
+
lines: OrderLine[];
|
|
309
|
+
};
|
|
310
|
+
type ReturnRequestInput = {
|
|
311
|
+
lines: {
|
|
312
|
+
sku: string;
|
|
313
|
+
quantity: number;
|
|
314
|
+
}[];
|
|
315
|
+
reason?: string;
|
|
316
|
+
};
|
|
317
|
+
type ReturnRequest = {
|
|
318
|
+
id: string;
|
|
319
|
+
order_id: string;
|
|
320
|
+
status: string;
|
|
321
|
+
};
|
|
322
|
+
type InvoiceResult = {
|
|
323
|
+
status: string;
|
|
324
|
+
url?: string | null;
|
|
325
|
+
};
|
|
326
|
+
type Theme = {
|
|
327
|
+
/** Design tokens, e.g. `{ primary: '#0f766e', 'primary-foreground': '#ffffff' }`. */
|
|
328
|
+
tokens: Record<string, string>;
|
|
329
|
+
/** Font roles, e.g. `{ heading: 'Inter', body: 'Inter' }`. */
|
|
330
|
+
fonts: Record<string, string>;
|
|
331
|
+
/** Base radius as a CSS length, e.g. `0.5rem`. */
|
|
332
|
+
radius: string;
|
|
333
|
+
};
|
|
334
|
+
type Section<P extends Record<string, unknown> = Record<string, unknown>> = {
|
|
335
|
+
id: string;
|
|
336
|
+
type: string;
|
|
337
|
+
props: P;
|
|
338
|
+
};
|
|
339
|
+
type Page = {
|
|
340
|
+
handle: string;
|
|
341
|
+
title: string;
|
|
342
|
+
seo: SEO;
|
|
343
|
+
sections: Section[];
|
|
344
|
+
};
|
|
345
|
+
type MenuItem = {
|
|
346
|
+
title: string;
|
|
347
|
+
url: string;
|
|
348
|
+
items?: MenuItem[];
|
|
349
|
+
};
|
|
350
|
+
type Menu = {
|
|
351
|
+
handle?: string;
|
|
352
|
+
items: MenuItem[];
|
|
353
|
+
};
|
|
354
|
+
type Article = {
|
|
355
|
+
id: string;
|
|
356
|
+
handle: string;
|
|
357
|
+
title: string;
|
|
358
|
+
excerpt: string | null;
|
|
359
|
+
content_html: string;
|
|
360
|
+
image: Image | null;
|
|
361
|
+
author: string | null;
|
|
362
|
+
tags: string[];
|
|
363
|
+
published_at: string;
|
|
364
|
+
seo: SEO;
|
|
365
|
+
};
|
|
366
|
+
type StorefrontErrorCode = 'validation' | 'unauthorized' | 'forbidden' | 'not_found' | 'conflict' | 'insufficient_stock' | 'price_mismatch' | 'invalid_state' | 'rate_limited' | 'not_modified' | 'server_error' | 'network' | 'timeout' | 'aborted' | 'invalid_response' | (string & {});
|
|
367
|
+
type StorefrontErrorBody = {
|
|
368
|
+
error: {
|
|
369
|
+
code: StorefrontErrorCode;
|
|
370
|
+
message: string;
|
|
371
|
+
field?: string;
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export type { ShopBranch as $, Address as A, Money as B, Cart as C, DeliveryInput as D, MoneyRange as E, Facet as F, OrderLine as G, PageInfo as H, Image as I, PickupOption as J, Product as K, ProductAttributeValue as L, Menu as M, ProductCategory as N, Order as O, Page as P, ProductConnection as Q, ProductOption as R, ProductSort as S, ProductVariant as T, ReturnRequest as U, ReturnRequestInput as V, SEO as W, Section as X, SelectedOption as Y, ShippingRate as Z, Shop as _, AddressInput as a, ShopContact as a0, ShopPolicies as a1, StockLevel as a2, StorefrontErrorBody as a3, StorefrontErrorCode as a4, Theme as a5, Article as b, CartBuyer as c, CartBuyerInput as d, CartCost as e, CartDelivery as f, CartDiscountCode as g, CartLine as h, CartLineInput as i, CartLineMerchandise as j, CartLineUpdateInput as k, CheckoutInput as l, CheckoutPayment as m, CheckoutResult as n, Collection as o, Connection as p, Customer as q, CustomerIdentifier as r, CustomerSession as s, CustomerSessionInput as t, DeliveryMethod as u, DeliveryOptions as v, FacetValue as w, InvoiceRequest as x, InvoiceResult as y, MenuItem as z };
|