@kasuvia/sdk 0.0.1
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 +112 -0
- package/dist/index.d.mts +1891 -0
- package/dist/index.d.ts +1891 -0
- package/dist/index.js +3540 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3314 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -0
- package/src/client/authClient.ts +135 -0
- package/src/client/graphqlClient.ts +53 -0
- package/src/client/httpClient.ts +298 -0
- package/src/config/index.ts +102 -0
- package/src/graphql/collections.graphql.ts +56 -0
- package/src/graphql/index.ts +7 -0
- package/src/graphql/products.graphql.ts +710 -0
- package/src/graphql/wishlist.graphql.ts +33 -0
- package/src/hooks/index.ts +26 -0
- package/src/hooks/use-auth.ts +182 -0
- package/src/hooks/use-bespoke-availability.ts +20 -0
- package/src/hooks/use-cart.ts +207 -0
- package/src/hooks/use-cms.ts +165 -0
- package/src/hooks/use-collections.ts +40 -0
- package/src/hooks/use-consultation-stream.ts +141 -0
- package/src/hooks/use-consultations.ts +76 -0
- package/src/hooks/use-countries.ts +24 -0
- package/src/hooks/use-currencies.ts +27 -0
- package/src/hooks/use-google-translate.ts +164 -0
- package/src/hooks/use-is-mounted.ts +9 -0
- package/src/hooks/use-languages.ts +33 -0
- package/src/hooks/use-order-stream.ts +195 -0
- package/src/hooks/use-orders.ts +64 -0
- package/src/hooks/use-payment.ts +68 -0
- package/src/hooks/use-products.ts +113 -0
- package/src/hooks/use-service-booking.ts +118 -0
- package/src/hooks/use-states.ts +28 -0
- package/src/hooks/use-wishlist.ts +121 -0
- package/src/index.ts +65 -0
- package/src/services/app.service.ts +17 -0
- package/src/services/auth.service.ts +332 -0
- package/src/services/bespoke.service.ts +17 -0
- package/src/services/cart.service.ts +245 -0
- package/src/services/cms.service.ts +112 -0
- package/src/services/collection.service.ts +77 -0
- package/src/services/config.service.ts +42 -0
- package/src/services/consultation.service.ts +51 -0
- package/src/services/index.ts +21 -0
- package/src/services/logistics.service.ts +95 -0
- package/src/services/notifications.service.ts +50 -0
- package/src/services/order.service.ts +169 -0
- package/src/services/payment.service.ts +127 -0
- package/src/services/product.service.ts +678 -0
- package/src/services/service-booking.service.ts +86 -0
- package/src/services/wishlist.service.ts +84 -0
- package/src/types/auth/index.ts +126 -0
- package/src/types/bespoke/index.ts +39 -0
- package/src/types/business/index.ts +6 -0
- package/src/types/cms/index.ts +77 -0
- package/src/types/consultations/index.ts +79 -0
- package/src/types/index.ts +27 -0
- package/src/types/media/index.ts +41 -0
- package/src/types/payments/index.ts +120 -0
- package/src/types/services/index.ts +80 -0
- package/src/types/store/index.ts +282 -0
- package/src/types/store/shipping.ts +38 -0
- package/src/types/ui/index.ts +32 -0
- package/src/utils/cache.ts +33 -0
- package/src/utils/checkout.ts +39 -0
- package/src/utils/customer.ts +20 -0
- package/src/utils/error-handler.ts +14 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/logger.ts +79 -0
- package/src/utils/sanitize-url.ts +55 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Service
|
|
3
|
+
*
|
|
4
|
+
* Handles product operations using GraphQL.
|
|
5
|
+
*/
|
|
6
|
+
import { getGraphQLClient } from '../client/graphqlClient'
|
|
7
|
+
import type { Product, PaginatedResponse, ListParams } from '../types/store'
|
|
8
|
+
|
|
9
|
+
// GraphQL queries would be defined here or imported
|
|
10
|
+
// For now, we'll use placeholder queries that need to be replaced with actual GraphQL
|
|
11
|
+
|
|
12
|
+
const GET_STOREFRONT_PRODUCTS = `
|
|
13
|
+
query GetStorefrontProducts($page: Int!, $pageSize: Int!, $collectionSlug: String, $search: String) {
|
|
14
|
+
storefront_products(page: $page, pageSize: $pageSize, collectionSlug: $collectionSlug, search: $search) {
|
|
15
|
+
items {
|
|
16
|
+
id
|
|
17
|
+
business_id
|
|
18
|
+
name
|
|
19
|
+
slug
|
|
20
|
+
description
|
|
21
|
+
brand
|
|
22
|
+
product_type
|
|
23
|
+
requires_shipping
|
|
24
|
+
is_consumable
|
|
25
|
+
is_bespoke
|
|
26
|
+
base_price
|
|
27
|
+
currency
|
|
28
|
+
images { url alt id }
|
|
29
|
+
tags
|
|
30
|
+
custom_fields { label unit required }
|
|
31
|
+
is_published
|
|
32
|
+
is_featured
|
|
33
|
+
is_popular
|
|
34
|
+
is_new
|
|
35
|
+
is_temporary
|
|
36
|
+
digital_file_key
|
|
37
|
+
download_limit
|
|
38
|
+
download_expires_at
|
|
39
|
+
weight_kg
|
|
40
|
+
length_cm
|
|
41
|
+
width_cm
|
|
42
|
+
height_cm
|
|
43
|
+
created_at
|
|
44
|
+
updated_at
|
|
45
|
+
variants {
|
|
46
|
+
id
|
|
47
|
+
product_id
|
|
48
|
+
sku
|
|
49
|
+
attributes
|
|
50
|
+
price
|
|
51
|
+
images { url alt id }
|
|
52
|
+
weight_kg
|
|
53
|
+
is_active
|
|
54
|
+
inventory {
|
|
55
|
+
id
|
|
56
|
+
product_id
|
|
57
|
+
variant_id
|
|
58
|
+
quantity
|
|
59
|
+
reserved
|
|
60
|
+
reorder_point
|
|
61
|
+
reorder_quantity
|
|
62
|
+
track_quantity
|
|
63
|
+
allow_backorder
|
|
64
|
+
available
|
|
65
|
+
is_in_stock
|
|
66
|
+
is_low_stock
|
|
67
|
+
updated_at
|
|
68
|
+
}
|
|
69
|
+
created_at
|
|
70
|
+
updated_at
|
|
71
|
+
}
|
|
72
|
+
collections {
|
|
73
|
+
id
|
|
74
|
+
business_id
|
|
75
|
+
name
|
|
76
|
+
slug
|
|
77
|
+
description
|
|
78
|
+
image { url alt id }
|
|
79
|
+
collection_type
|
|
80
|
+
rules
|
|
81
|
+
status
|
|
82
|
+
sort_order
|
|
83
|
+
created_at
|
|
84
|
+
updated_at
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
total
|
|
88
|
+
page
|
|
89
|
+
page_size
|
|
90
|
+
total_pages
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`
|
|
94
|
+
|
|
95
|
+
const GET_STOREFRONT_PRODUCT_BY_SLUG = `
|
|
96
|
+
query GetStorefrontProductBySlug($slug: String!) {
|
|
97
|
+
storefront_product_by_slug(slug: $slug) {
|
|
98
|
+
id
|
|
99
|
+
business_id
|
|
100
|
+
name
|
|
101
|
+
slug
|
|
102
|
+
description
|
|
103
|
+
brand
|
|
104
|
+
product_type
|
|
105
|
+
requires_shipping
|
|
106
|
+
is_consumable
|
|
107
|
+
is_bespoke
|
|
108
|
+
base_price
|
|
109
|
+
currency
|
|
110
|
+
images { url alt id }
|
|
111
|
+
tags
|
|
112
|
+
custom_fields { label unit required }
|
|
113
|
+
is_published
|
|
114
|
+
is_featured
|
|
115
|
+
is_popular
|
|
116
|
+
is_new
|
|
117
|
+
is_temporary
|
|
118
|
+
digital_file_key
|
|
119
|
+
download_limit
|
|
120
|
+
download_expires_at
|
|
121
|
+
weight_kg
|
|
122
|
+
length_cm
|
|
123
|
+
width_cm
|
|
124
|
+
height_cm
|
|
125
|
+
created_at
|
|
126
|
+
updated_at
|
|
127
|
+
variants {
|
|
128
|
+
id
|
|
129
|
+
product_id
|
|
130
|
+
sku
|
|
131
|
+
attributes
|
|
132
|
+
price
|
|
133
|
+
images { url alt id }
|
|
134
|
+
weight_kg
|
|
135
|
+
is_active
|
|
136
|
+
inventory {
|
|
137
|
+
id
|
|
138
|
+
product_id
|
|
139
|
+
variant_id
|
|
140
|
+
quantity
|
|
141
|
+
reserved
|
|
142
|
+
reorder_point
|
|
143
|
+
reorder_quantity
|
|
144
|
+
track_quantity
|
|
145
|
+
allow_backorder
|
|
146
|
+
available
|
|
147
|
+
is_in_stock
|
|
148
|
+
is_low_stock
|
|
149
|
+
updated_at
|
|
150
|
+
}
|
|
151
|
+
created_at
|
|
152
|
+
updated_at
|
|
153
|
+
}
|
|
154
|
+
collections {
|
|
155
|
+
id
|
|
156
|
+
business_id
|
|
157
|
+
name
|
|
158
|
+
slug
|
|
159
|
+
description
|
|
160
|
+
image { url alt id }
|
|
161
|
+
collection_type
|
|
162
|
+
rules
|
|
163
|
+
status
|
|
164
|
+
sort_order
|
|
165
|
+
created_at
|
|
166
|
+
updated_at
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`
|
|
171
|
+
|
|
172
|
+
const GET_STOREFRONT_LATEST = `
|
|
173
|
+
query GetStorefrontLatest($page: Int!, $pageSize: Int!) {
|
|
174
|
+
storefront_latest(page: $page, pageSize: $pageSize) {
|
|
175
|
+
items {
|
|
176
|
+
id
|
|
177
|
+
business_id
|
|
178
|
+
name
|
|
179
|
+
slug
|
|
180
|
+
description
|
|
181
|
+
brand
|
|
182
|
+
product_type
|
|
183
|
+
requires_shipping
|
|
184
|
+
is_consumable
|
|
185
|
+
is_bespoke
|
|
186
|
+
base_price
|
|
187
|
+
currency
|
|
188
|
+
images { url alt id }
|
|
189
|
+
tags
|
|
190
|
+
custom_fields { label unit required }
|
|
191
|
+
is_published
|
|
192
|
+
is_featured
|
|
193
|
+
is_popular
|
|
194
|
+
is_new
|
|
195
|
+
is_temporary
|
|
196
|
+
digital_file_key
|
|
197
|
+
download_limit
|
|
198
|
+
download_expires_at
|
|
199
|
+
weight_kg
|
|
200
|
+
length_cm
|
|
201
|
+
width_cm
|
|
202
|
+
height_cm
|
|
203
|
+
created_at
|
|
204
|
+
updated_at
|
|
205
|
+
variants {
|
|
206
|
+
id
|
|
207
|
+
product_id
|
|
208
|
+
sku
|
|
209
|
+
attributes
|
|
210
|
+
price
|
|
211
|
+
images { url alt id }
|
|
212
|
+
weight_kg
|
|
213
|
+
is_active
|
|
214
|
+
inventory {
|
|
215
|
+
id
|
|
216
|
+
product_id
|
|
217
|
+
variant_id
|
|
218
|
+
quantity
|
|
219
|
+
reserved
|
|
220
|
+
reorder_point
|
|
221
|
+
reorder_quantity
|
|
222
|
+
track_quantity
|
|
223
|
+
allow_backorder
|
|
224
|
+
available
|
|
225
|
+
is_in_stock
|
|
226
|
+
is_low_stock
|
|
227
|
+
updated_at
|
|
228
|
+
}
|
|
229
|
+
created_at
|
|
230
|
+
updated_at
|
|
231
|
+
}
|
|
232
|
+
collections {
|
|
233
|
+
id
|
|
234
|
+
business_id
|
|
235
|
+
name
|
|
236
|
+
slug
|
|
237
|
+
description
|
|
238
|
+
image { url alt id }
|
|
239
|
+
collection_type
|
|
240
|
+
rules
|
|
241
|
+
status
|
|
242
|
+
sort_order
|
|
243
|
+
created_at
|
|
244
|
+
updated_at
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
total
|
|
248
|
+
page
|
|
249
|
+
page_size
|
|
250
|
+
total_pages
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
`
|
|
254
|
+
|
|
255
|
+
const GET_STOREFRONT_POPULAR = `
|
|
256
|
+
query GetStorefrontPopular($page: Int!, $pageSize: Int!) {
|
|
257
|
+
storefront_popular(page: $page, pageSize: $pageSize) {
|
|
258
|
+
items {
|
|
259
|
+
id
|
|
260
|
+
business_id
|
|
261
|
+
name
|
|
262
|
+
slug
|
|
263
|
+
description
|
|
264
|
+
brand
|
|
265
|
+
product_type
|
|
266
|
+
requires_shipping
|
|
267
|
+
is_consumable
|
|
268
|
+
is_bespoke
|
|
269
|
+
base_price
|
|
270
|
+
currency
|
|
271
|
+
images { url alt id }
|
|
272
|
+
tags
|
|
273
|
+
custom_fields { label unit required }
|
|
274
|
+
is_published
|
|
275
|
+
is_featured
|
|
276
|
+
is_popular
|
|
277
|
+
is_new
|
|
278
|
+
is_temporary
|
|
279
|
+
digital_file_key
|
|
280
|
+
download_limit
|
|
281
|
+
download_expires_at
|
|
282
|
+
weight_kg
|
|
283
|
+
length_cm
|
|
284
|
+
width_cm
|
|
285
|
+
height_cm
|
|
286
|
+
created_at
|
|
287
|
+
updated_at
|
|
288
|
+
variants {
|
|
289
|
+
id
|
|
290
|
+
product_id
|
|
291
|
+
sku
|
|
292
|
+
attributes
|
|
293
|
+
price
|
|
294
|
+
images { url alt id }
|
|
295
|
+
weight_kg
|
|
296
|
+
is_active
|
|
297
|
+
inventory {
|
|
298
|
+
id
|
|
299
|
+
product_id
|
|
300
|
+
variant_id
|
|
301
|
+
quantity
|
|
302
|
+
reserved
|
|
303
|
+
reorder_point
|
|
304
|
+
reorder_quantity
|
|
305
|
+
track_quantity
|
|
306
|
+
allow_backorder
|
|
307
|
+
available
|
|
308
|
+
is_in_stock
|
|
309
|
+
is_low_stock
|
|
310
|
+
updated_at
|
|
311
|
+
}
|
|
312
|
+
created_at
|
|
313
|
+
updated_at
|
|
314
|
+
}
|
|
315
|
+
collections {
|
|
316
|
+
id
|
|
317
|
+
business_id
|
|
318
|
+
name
|
|
319
|
+
slug
|
|
320
|
+
description
|
|
321
|
+
image { url alt id }
|
|
322
|
+
collection_type
|
|
323
|
+
rules
|
|
324
|
+
status
|
|
325
|
+
sort_order
|
|
326
|
+
created_at
|
|
327
|
+
updated_at
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
total
|
|
331
|
+
page
|
|
332
|
+
page_size
|
|
333
|
+
total_pages
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
`
|
|
337
|
+
|
|
338
|
+
const GET_STOREFRONT_FEATURED = `
|
|
339
|
+
query GetStorefrontFeatured($page: Int!, $pageSize: Int!) {
|
|
340
|
+
storefront_featured(page: $page, pageSize: $pageSize) {
|
|
341
|
+
items {
|
|
342
|
+
id
|
|
343
|
+
business_id
|
|
344
|
+
name
|
|
345
|
+
slug
|
|
346
|
+
description
|
|
347
|
+
brand
|
|
348
|
+
product_type
|
|
349
|
+
requires_shipping
|
|
350
|
+
is_consumable
|
|
351
|
+
is_bespoke
|
|
352
|
+
base_price
|
|
353
|
+
currency
|
|
354
|
+
images { url alt id }
|
|
355
|
+
tags
|
|
356
|
+
custom_fields { label unit required }
|
|
357
|
+
is_published
|
|
358
|
+
is_featured
|
|
359
|
+
is_popular
|
|
360
|
+
is_new
|
|
361
|
+
is_temporary
|
|
362
|
+
digital_file_key
|
|
363
|
+
download_limit
|
|
364
|
+
download_expires_at
|
|
365
|
+
weight_kg
|
|
366
|
+
length_cm
|
|
367
|
+
width_cm
|
|
368
|
+
height_cm
|
|
369
|
+
created_at
|
|
370
|
+
updated_at
|
|
371
|
+
variants {
|
|
372
|
+
id
|
|
373
|
+
product_id
|
|
374
|
+
sku
|
|
375
|
+
attributes
|
|
376
|
+
price
|
|
377
|
+
images { url alt id }
|
|
378
|
+
weight_kg
|
|
379
|
+
is_active
|
|
380
|
+
inventory {
|
|
381
|
+
id
|
|
382
|
+
product_id
|
|
383
|
+
variant_id
|
|
384
|
+
quantity
|
|
385
|
+
reserved
|
|
386
|
+
reorder_point
|
|
387
|
+
reorder_quantity
|
|
388
|
+
track_quantity
|
|
389
|
+
allow_backorder
|
|
390
|
+
available
|
|
391
|
+
is_in_stock
|
|
392
|
+
is_low_stock
|
|
393
|
+
updated_at
|
|
394
|
+
}
|
|
395
|
+
created_at
|
|
396
|
+
updated_at
|
|
397
|
+
}
|
|
398
|
+
collections {
|
|
399
|
+
id
|
|
400
|
+
business_id
|
|
401
|
+
name
|
|
402
|
+
slug
|
|
403
|
+
description
|
|
404
|
+
image { url alt id }
|
|
405
|
+
collection_type
|
|
406
|
+
rules
|
|
407
|
+
status
|
|
408
|
+
sort_order
|
|
409
|
+
created_at
|
|
410
|
+
updated_at
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
total
|
|
414
|
+
page
|
|
415
|
+
page_size
|
|
416
|
+
total_pages
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
`
|
|
420
|
+
|
|
421
|
+
const GET_STOREFRONT_NEW = `
|
|
422
|
+
query GetStorefrontNew($page: Int!, $pageSize: Int!) {
|
|
423
|
+
storefront_new(page: $page, pageSize: $pageSize) {
|
|
424
|
+
items {
|
|
425
|
+
id
|
|
426
|
+
business_id
|
|
427
|
+
name
|
|
428
|
+
slug
|
|
429
|
+
description
|
|
430
|
+
brand
|
|
431
|
+
product_type
|
|
432
|
+
requires_shipping
|
|
433
|
+
is_consumable
|
|
434
|
+
is_bespoke
|
|
435
|
+
base_price
|
|
436
|
+
currency
|
|
437
|
+
images { url alt id }
|
|
438
|
+
tags
|
|
439
|
+
custom_fields { label unit required }
|
|
440
|
+
is_published
|
|
441
|
+
is_featured
|
|
442
|
+
is_popular
|
|
443
|
+
is_new
|
|
444
|
+
is_temporary
|
|
445
|
+
digital_file_key
|
|
446
|
+
download_limit
|
|
447
|
+
download_expires_at
|
|
448
|
+
weight_kg
|
|
449
|
+
length_cm
|
|
450
|
+
width_cm
|
|
451
|
+
height_cm
|
|
452
|
+
created_at
|
|
453
|
+
updated_at
|
|
454
|
+
variants {
|
|
455
|
+
id
|
|
456
|
+
product_id
|
|
457
|
+
sku
|
|
458
|
+
attributes
|
|
459
|
+
price
|
|
460
|
+
images { url alt id }
|
|
461
|
+
weight_kg
|
|
462
|
+
is_active
|
|
463
|
+
inventory {
|
|
464
|
+
id
|
|
465
|
+
product_id
|
|
466
|
+
variant_id
|
|
467
|
+
quantity
|
|
468
|
+
reserved
|
|
469
|
+
reorder_point
|
|
470
|
+
reorder_quantity
|
|
471
|
+
track_quantity
|
|
472
|
+
allow_backorder
|
|
473
|
+
available
|
|
474
|
+
is_in_stock
|
|
475
|
+
is_low_stock
|
|
476
|
+
updated_at
|
|
477
|
+
}
|
|
478
|
+
created_at
|
|
479
|
+
updated_at
|
|
480
|
+
}
|
|
481
|
+
collections {
|
|
482
|
+
id
|
|
483
|
+
business_id
|
|
484
|
+
name
|
|
485
|
+
slug
|
|
486
|
+
description
|
|
487
|
+
image { url alt id }
|
|
488
|
+
collection_type
|
|
489
|
+
rules
|
|
490
|
+
status
|
|
491
|
+
sort_order
|
|
492
|
+
created_at
|
|
493
|
+
updated_at
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
total
|
|
497
|
+
page
|
|
498
|
+
page_size
|
|
499
|
+
total_pages
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
`
|
|
503
|
+
|
|
504
|
+
const GET_STOREFRONT_RECOMMENDED = `
|
|
505
|
+
query GetStorefrontRecommended($page: Int!, $pageSize: Int!, $excludeProductId: String) {
|
|
506
|
+
storefront_recommended(page: $page, pageSize: $pageSize, excludeProductId: $excludeProductId) {
|
|
507
|
+
items {
|
|
508
|
+
id
|
|
509
|
+
business_id
|
|
510
|
+
name
|
|
511
|
+
slug
|
|
512
|
+
description
|
|
513
|
+
brand
|
|
514
|
+
product_type
|
|
515
|
+
requires_shipping
|
|
516
|
+
is_consumable
|
|
517
|
+
is_bespoke
|
|
518
|
+
base_price
|
|
519
|
+
currency
|
|
520
|
+
images { url alt id }
|
|
521
|
+
tags
|
|
522
|
+
custom_fields { label unit required }
|
|
523
|
+
is_published
|
|
524
|
+
is_featured
|
|
525
|
+
is_popular
|
|
526
|
+
is_new
|
|
527
|
+
is_temporary
|
|
528
|
+
digital_file_key
|
|
529
|
+
download_limit
|
|
530
|
+
download_expires_at
|
|
531
|
+
weight_kg
|
|
532
|
+
length_cm
|
|
533
|
+
width_cm
|
|
534
|
+
height_cm
|
|
535
|
+
created_at
|
|
536
|
+
updated_at
|
|
537
|
+
variants {
|
|
538
|
+
id
|
|
539
|
+
product_id
|
|
540
|
+
sku
|
|
541
|
+
attributes
|
|
542
|
+
price
|
|
543
|
+
images { url alt id }
|
|
544
|
+
weight_kg
|
|
545
|
+
is_active
|
|
546
|
+
inventory {
|
|
547
|
+
id
|
|
548
|
+
product_id
|
|
549
|
+
variant_id
|
|
550
|
+
quantity
|
|
551
|
+
reserved
|
|
552
|
+
reorder_point
|
|
553
|
+
reorder_quantity
|
|
554
|
+
track_quantity
|
|
555
|
+
allow_backorder
|
|
556
|
+
available
|
|
557
|
+
is_in_stock
|
|
558
|
+
is_low_stock
|
|
559
|
+
updated_at
|
|
560
|
+
}
|
|
561
|
+
created_at
|
|
562
|
+
updated_at
|
|
563
|
+
}
|
|
564
|
+
collections {
|
|
565
|
+
id
|
|
566
|
+
business_id
|
|
567
|
+
name
|
|
568
|
+
slug
|
|
569
|
+
description
|
|
570
|
+
image { url alt id }
|
|
571
|
+
collection_type
|
|
572
|
+
rules
|
|
573
|
+
status
|
|
574
|
+
sort_order
|
|
575
|
+
created_at
|
|
576
|
+
updated_at
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
total
|
|
580
|
+
page
|
|
581
|
+
page_size
|
|
582
|
+
total_pages
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
`
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Fetch all active products for the storefront.
|
|
589
|
+
*/
|
|
590
|
+
export async function getStorefrontProducts(params?: ListParams): Promise<PaginatedResponse<Product>> {
|
|
591
|
+
const client = getGraphQLClient()
|
|
592
|
+
const variables = {
|
|
593
|
+
page: params?.page || 1,
|
|
594
|
+
pageSize: params?.pageSize || 20,
|
|
595
|
+
collectionSlug: params?.collectionSlug,
|
|
596
|
+
search: params?.search,
|
|
597
|
+
}
|
|
598
|
+
const data = await client.request(GET_STOREFRONT_PRODUCTS, variables)
|
|
599
|
+
return data.storefront_products
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Fetch a single product by slug for the storefront.
|
|
604
|
+
*/
|
|
605
|
+
export async function getStorefrontProductBySlug(slug: string): Promise<Product> {
|
|
606
|
+
const client = getGraphQLClient()
|
|
607
|
+
const data = await client.request(GET_STOREFRONT_PRODUCT_BY_SLUG, { slug })
|
|
608
|
+
return data.storefront_product_by_slug
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Fetch latest products for the storefront.
|
|
613
|
+
*/
|
|
614
|
+
export async function getLatestProducts(params?: ListParams): Promise<PaginatedResponse<Product>> {
|
|
615
|
+
const client = getGraphQLClient()
|
|
616
|
+
const variables = {
|
|
617
|
+
page: params?.page || 1,
|
|
618
|
+
pageSize: params?.pageSize || 4,
|
|
619
|
+
}
|
|
620
|
+
const data = await client.request(GET_STOREFRONT_LATEST, variables)
|
|
621
|
+
return data.storefront_latest
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Fetch popular products for the storefront.
|
|
626
|
+
*/
|
|
627
|
+
export async function getPopularProducts(params?: ListParams): Promise<PaginatedResponse<Product>> {
|
|
628
|
+
const client = getGraphQLClient()
|
|
629
|
+
const variables = {
|
|
630
|
+
page: params?.page || 1,
|
|
631
|
+
pageSize: params?.pageSize || 4,
|
|
632
|
+
}
|
|
633
|
+
const data = await client.request(GET_STOREFRONT_POPULAR, variables)
|
|
634
|
+
return data.storefront_popular
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Fetch featured products for the storefront.
|
|
639
|
+
*/
|
|
640
|
+
export async function getFeaturedProducts(params?: ListParams): Promise<PaginatedResponse<Product>> {
|
|
641
|
+
const client = getGraphQLClient()
|
|
642
|
+
const variables = {
|
|
643
|
+
page: params?.page || 1,
|
|
644
|
+
pageSize: params?.pageSize || 4,
|
|
645
|
+
}
|
|
646
|
+
const data = await client.request(GET_STOREFRONT_FEATURED, variables)
|
|
647
|
+
return data.storefront_featured
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Fetch new products for the storefront.
|
|
652
|
+
*/
|
|
653
|
+
export async function getNewProducts(params?: ListParams): Promise<PaginatedResponse<Product>> {
|
|
654
|
+
const client = getGraphQLClient()
|
|
655
|
+
const variables = {
|
|
656
|
+
page: params?.page || 1,
|
|
657
|
+
pageSize: params?.pageSize || 4,
|
|
658
|
+
}
|
|
659
|
+
const data = await client.request(GET_STOREFRONT_NEW, variables)
|
|
660
|
+
return data.storefront_new
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Fetch recommended products for the storefront.
|
|
665
|
+
* Returns featured, popular, and new products.
|
|
666
|
+
* Optionally excludes a specific product ID.
|
|
667
|
+
*/
|
|
668
|
+
export async function getRecommendedProducts(params?: ListParams & { excludeProductId?: string }): Promise<PaginatedResponse<Product>> {
|
|
669
|
+
const client = getGraphQLClient()
|
|
670
|
+
const variables = {
|
|
671
|
+
page: params?.page || 1,
|
|
672
|
+
pageSize: params?.pageSize || 4,
|
|
673
|
+
excludeProductId: params?.excludeProductId,
|
|
674
|
+
}
|
|
675
|
+
const data = await client.request(GET_STOREFRONT_RECOMMENDED, variables)
|
|
676
|
+
return data.storefront_recommended
|
|
677
|
+
}
|
|
678
|
+
|