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