commerce-kit 0.6.1-experimental.9 → 0.8.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/api-types.d.ts +304 -53
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/api-types.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ type APIProductsBrowseResult = {
|
|
|
5
5
|
name: string;
|
|
6
6
|
createdAt: string;
|
|
7
7
|
updatedAt: string;
|
|
8
|
-
type: "product" | "bundle";
|
|
8
|
+
type: "product" | "bundle" | "set";
|
|
9
9
|
slug: string;
|
|
10
|
+
status: "draft" | "published" | "hidden" | null;
|
|
10
11
|
flags: unknown;
|
|
11
|
-
active: boolean | null;
|
|
12
12
|
storeId: string;
|
|
13
13
|
summary: string | null;
|
|
14
14
|
images: string[];
|
|
@@ -202,10 +202,10 @@ type APIProductsBrowseResult = {
|
|
|
202
202
|
name: string;
|
|
203
203
|
createdAt: string;
|
|
204
204
|
updatedAt: string;
|
|
205
|
-
type: "product" | "bundle";
|
|
205
|
+
type: "product" | "bundle" | "set";
|
|
206
206
|
slug: string;
|
|
207
|
+
status: "draft" | "published" | "hidden" | null;
|
|
207
208
|
flags: unknown;
|
|
208
|
-
active: boolean | null;
|
|
209
209
|
storeId: string;
|
|
210
210
|
summary: string | null;
|
|
211
211
|
images: string[];
|
|
@@ -399,10 +399,10 @@ type APIProductsBrowseResult = {
|
|
|
399
399
|
name: string;
|
|
400
400
|
createdAt: string;
|
|
401
401
|
updatedAt: string;
|
|
402
|
-
type: "product" | "bundle";
|
|
402
|
+
type: "product" | "bundle" | "set";
|
|
403
403
|
slug: string;
|
|
404
|
+
status: "draft" | "published" | "hidden" | null;
|
|
404
405
|
flags: unknown;
|
|
405
|
-
active: boolean | null;
|
|
406
406
|
storeId: string;
|
|
407
407
|
summary: string | null;
|
|
408
408
|
images: string[];
|
|
@@ -596,10 +596,10 @@ type APIProductsBrowseResult = {
|
|
|
596
596
|
name: string;
|
|
597
597
|
createdAt: string;
|
|
598
598
|
updatedAt: string;
|
|
599
|
-
type: "product" | "bundle";
|
|
599
|
+
type: "product" | "bundle" | "set";
|
|
600
600
|
slug: string;
|
|
601
|
+
status: "draft" | "published" | "hidden" | null;
|
|
601
602
|
flags: unknown;
|
|
602
|
-
active: boolean | null;
|
|
603
603
|
storeId: string;
|
|
604
604
|
summary: string | null;
|
|
605
605
|
images: string[];
|
|
@@ -794,10 +794,10 @@ type APIProductsBrowseResult = {
|
|
|
794
794
|
name: string;
|
|
795
795
|
createdAt: string;
|
|
796
796
|
updatedAt: string;
|
|
797
|
-
type: "product" | "bundle";
|
|
797
|
+
type: "product" | "bundle" | "set";
|
|
798
798
|
slug: string;
|
|
799
|
+
status: "draft" | "published" | "hidden" | null;
|
|
799
800
|
flags: unknown;
|
|
800
|
-
active: boolean | null;
|
|
801
801
|
storeId: string;
|
|
802
802
|
summary: string | null;
|
|
803
803
|
images: string[];
|
|
@@ -989,8 +989,9 @@ type APIProductsBrowseResult = {
|
|
|
989
989
|
}))[];
|
|
990
990
|
meta: {
|
|
991
991
|
count: number;
|
|
992
|
-
|
|
992
|
+
countPublished: number;
|
|
993
993
|
countDraft: number;
|
|
994
|
+
countHidden: number;
|
|
994
995
|
};
|
|
995
996
|
};
|
|
996
997
|
type APIProductsBrowseQueryParams = {
|
|
@@ -1008,10 +1009,10 @@ type APIProductGetByIdResult = ({
|
|
|
1008
1009
|
name: string;
|
|
1009
1010
|
createdAt: string;
|
|
1010
1011
|
updatedAt: string;
|
|
1011
|
-
type: "product" | "bundle";
|
|
1012
|
+
type: "product" | "bundle" | "set";
|
|
1012
1013
|
slug: string;
|
|
1014
|
+
status: "draft" | "published" | "hidden" | null;
|
|
1013
1015
|
flags: unknown;
|
|
1014
|
-
active: boolean | null;
|
|
1015
1016
|
storeId: string;
|
|
1016
1017
|
summary: string | null;
|
|
1017
1018
|
images: string[];
|
|
@@ -1217,10 +1218,10 @@ type APIProductGetByIdResult = ({
|
|
|
1217
1218
|
name: string;
|
|
1218
1219
|
createdAt: string;
|
|
1219
1220
|
updatedAt: string;
|
|
1220
|
-
type: "product" | "bundle";
|
|
1221
|
+
type: "product" | "bundle" | "set";
|
|
1221
1222
|
slug: string;
|
|
1223
|
+
status: "draft" | "published" | "hidden" | null;
|
|
1222
1224
|
flags: unknown;
|
|
1223
|
-
active: boolean | null;
|
|
1224
1225
|
storeId: string;
|
|
1225
1226
|
summary: string | null;
|
|
1226
1227
|
images: string[];
|
|
@@ -1474,10 +1475,10 @@ type APICartGetResult = {
|
|
|
1474
1475
|
name: string;
|
|
1475
1476
|
createdAt: string;
|
|
1476
1477
|
updatedAt: string;
|
|
1477
|
-
type: "product" | "bundle";
|
|
1478
|
+
type: "product" | "bundle" | "set";
|
|
1478
1479
|
slug: string;
|
|
1480
|
+
status: "draft" | "published" | "hidden" | null;
|
|
1479
1481
|
flags: unknown;
|
|
1480
|
-
active: boolean | null;
|
|
1481
1482
|
storeId: string;
|
|
1482
1483
|
summary: string | null;
|
|
1483
1484
|
images: string[];
|
|
@@ -1515,6 +1516,11 @@ type APICartGetResult = {
|
|
|
1515
1516
|
storeId: string;
|
|
1516
1517
|
};
|
|
1517
1518
|
}[];
|
|
1519
|
+
setProduct: {
|
|
1520
|
+
selectionCount: number;
|
|
1521
|
+
allowDuplicates: boolean;
|
|
1522
|
+
discountPercentage: string;
|
|
1523
|
+
} | null;
|
|
1518
1524
|
};
|
|
1519
1525
|
id: string;
|
|
1520
1526
|
createdAt: string;
|
|
@@ -1599,10 +1605,10 @@ type APICartGetResult = {
|
|
|
1599
1605
|
name: string;
|
|
1600
1606
|
createdAt: string;
|
|
1601
1607
|
updatedAt: string;
|
|
1602
|
-
type: "product" | "bundle";
|
|
1608
|
+
type: "product" | "bundle" | "set";
|
|
1603
1609
|
slug: string;
|
|
1610
|
+
status: "draft" | "published" | "hidden" | null;
|
|
1604
1611
|
flags: unknown;
|
|
1605
|
-
active: boolean | null;
|
|
1606
1612
|
storeId: string;
|
|
1607
1613
|
summary: string | null;
|
|
1608
1614
|
images: string[];
|
|
@@ -1640,6 +1646,11 @@ type APICartGetResult = {
|
|
|
1640
1646
|
storeId: string;
|
|
1641
1647
|
};
|
|
1642
1648
|
}[];
|
|
1649
|
+
setProduct: {
|
|
1650
|
+
selectionCount: number;
|
|
1651
|
+
allowDuplicates: boolean;
|
|
1652
|
+
discountPercentage: string;
|
|
1653
|
+
} | null;
|
|
1643
1654
|
};
|
|
1644
1655
|
id: string;
|
|
1645
1656
|
createdAt: string;
|
|
@@ -1724,10 +1735,10 @@ type APICartGetResult = {
|
|
|
1724
1735
|
name: string;
|
|
1725
1736
|
createdAt: string;
|
|
1726
1737
|
updatedAt: string;
|
|
1727
|
-
type: "product" | "bundle";
|
|
1738
|
+
type: "product" | "bundle" | "set";
|
|
1728
1739
|
slug: string;
|
|
1740
|
+
status: "draft" | "published" | "hidden" | null;
|
|
1729
1741
|
flags: unknown;
|
|
1730
|
-
active: boolean | null;
|
|
1731
1742
|
storeId: string;
|
|
1732
1743
|
summary: string | null;
|
|
1733
1744
|
images: string[];
|
|
@@ -1765,6 +1776,11 @@ type APICartGetResult = {
|
|
|
1765
1776
|
storeId: string;
|
|
1766
1777
|
};
|
|
1767
1778
|
}[];
|
|
1779
|
+
setProduct: {
|
|
1780
|
+
selectionCount: number;
|
|
1781
|
+
allowDuplicates: boolean;
|
|
1782
|
+
discountPercentage: string;
|
|
1783
|
+
} | null;
|
|
1768
1784
|
};
|
|
1769
1785
|
id: string;
|
|
1770
1786
|
createdAt: string;
|
|
@@ -1849,10 +1865,10 @@ type APICartGetResult = {
|
|
|
1849
1865
|
name: string;
|
|
1850
1866
|
createdAt: string;
|
|
1851
1867
|
updatedAt: string;
|
|
1852
|
-
type: "product" | "bundle";
|
|
1868
|
+
type: "product" | "bundle" | "set";
|
|
1853
1869
|
slug: string;
|
|
1870
|
+
status: "draft" | "published" | "hidden" | null;
|
|
1854
1871
|
flags: unknown;
|
|
1855
|
-
active: boolean | null;
|
|
1856
1872
|
storeId: string;
|
|
1857
1873
|
summary: string | null;
|
|
1858
1874
|
images: string[];
|
|
@@ -1890,6 +1906,11 @@ type APICartGetResult = {
|
|
|
1890
1906
|
storeId: string;
|
|
1891
1907
|
};
|
|
1892
1908
|
}[];
|
|
1909
|
+
setProduct: {
|
|
1910
|
+
selectionCount: number;
|
|
1911
|
+
allowDuplicates: boolean;
|
|
1912
|
+
discountPercentage: string;
|
|
1913
|
+
} | null;
|
|
1893
1914
|
};
|
|
1894
1915
|
id: string;
|
|
1895
1916
|
createdAt: string;
|
|
@@ -1975,10 +1996,10 @@ type APICartGetResult = {
|
|
|
1975
1996
|
name: string;
|
|
1976
1997
|
createdAt: string;
|
|
1977
1998
|
updatedAt: string;
|
|
1978
|
-
type: "product" | "bundle";
|
|
1999
|
+
type: "product" | "bundle" | "set";
|
|
1979
2000
|
slug: string;
|
|
2001
|
+
status: "draft" | "published" | "hidden" | null;
|
|
1980
2002
|
flags: unknown;
|
|
1981
|
-
active: boolean | null;
|
|
1982
2003
|
storeId: string;
|
|
1983
2004
|
summary: string | null;
|
|
1984
2005
|
images: string[];
|
|
@@ -2016,6 +2037,11 @@ type APICartGetResult = {
|
|
|
2016
2037
|
storeId: string;
|
|
2017
2038
|
};
|
|
2018
2039
|
}[];
|
|
2040
|
+
setProduct: {
|
|
2041
|
+
selectionCount: number;
|
|
2042
|
+
allowDuplicates: boolean;
|
|
2043
|
+
discountPercentage: string;
|
|
2044
|
+
} | null;
|
|
2019
2045
|
};
|
|
2020
2046
|
id: string;
|
|
2021
2047
|
createdAt: string;
|
|
@@ -2070,6 +2096,23 @@ type APICartGetResult = {
|
|
|
2070
2096
|
interval: number;
|
|
2071
2097
|
cadence: "month" | "week";
|
|
2072
2098
|
} | null;
|
|
2099
|
+
setSelections: {
|
|
2100
|
+
id: string;
|
|
2101
|
+
createdAt: string;
|
|
2102
|
+
updatedAt: string;
|
|
2103
|
+
position: number;
|
|
2104
|
+
quantity: number;
|
|
2105
|
+
lineItemId: string;
|
|
2106
|
+
selectedVariantId: string;
|
|
2107
|
+
selectedVariant: {
|
|
2108
|
+
id: string;
|
|
2109
|
+
price: string;
|
|
2110
|
+
product: {
|
|
2111
|
+
id: string;
|
|
2112
|
+
name: string;
|
|
2113
|
+
};
|
|
2114
|
+
};
|
|
2115
|
+
}[];
|
|
2073
2116
|
}[];
|
|
2074
2117
|
id: string;
|
|
2075
2118
|
createdAt: string;
|
|
@@ -2239,10 +2282,10 @@ type APICartCreateResult = {
|
|
|
2239
2282
|
name: string;
|
|
2240
2283
|
createdAt: string;
|
|
2241
2284
|
updatedAt: string;
|
|
2242
|
-
type: "product" | "bundle";
|
|
2285
|
+
type: "product" | "bundle" | "set";
|
|
2243
2286
|
slug: string;
|
|
2287
|
+
status: "draft" | "published" | "hidden" | null;
|
|
2244
2288
|
flags: unknown;
|
|
2245
|
-
active: boolean | null;
|
|
2246
2289
|
storeId: string;
|
|
2247
2290
|
summary: string | null;
|
|
2248
2291
|
images: string[];
|
|
@@ -2280,6 +2323,11 @@ type APICartCreateResult = {
|
|
|
2280
2323
|
storeId: string;
|
|
2281
2324
|
};
|
|
2282
2325
|
}[];
|
|
2326
|
+
setProduct: {
|
|
2327
|
+
selectionCount: number;
|
|
2328
|
+
allowDuplicates: boolean;
|
|
2329
|
+
discountPercentage: string;
|
|
2330
|
+
} | null;
|
|
2283
2331
|
};
|
|
2284
2332
|
id: string;
|
|
2285
2333
|
createdAt: string;
|
|
@@ -2364,10 +2412,10 @@ type APICartCreateResult = {
|
|
|
2364
2412
|
name: string;
|
|
2365
2413
|
createdAt: string;
|
|
2366
2414
|
updatedAt: string;
|
|
2367
|
-
type: "product" | "bundle";
|
|
2415
|
+
type: "product" | "bundle" | "set";
|
|
2368
2416
|
slug: string;
|
|
2417
|
+
status: "draft" | "published" | "hidden" | null;
|
|
2369
2418
|
flags: unknown;
|
|
2370
|
-
active: boolean | null;
|
|
2371
2419
|
storeId: string;
|
|
2372
2420
|
summary: string | null;
|
|
2373
2421
|
images: string[];
|
|
@@ -2405,6 +2453,11 @@ type APICartCreateResult = {
|
|
|
2405
2453
|
storeId: string;
|
|
2406
2454
|
};
|
|
2407
2455
|
}[];
|
|
2456
|
+
setProduct: {
|
|
2457
|
+
selectionCount: number;
|
|
2458
|
+
allowDuplicates: boolean;
|
|
2459
|
+
discountPercentage: string;
|
|
2460
|
+
} | null;
|
|
2408
2461
|
};
|
|
2409
2462
|
id: string;
|
|
2410
2463
|
createdAt: string;
|
|
@@ -2489,10 +2542,10 @@ type APICartCreateResult = {
|
|
|
2489
2542
|
name: string;
|
|
2490
2543
|
createdAt: string;
|
|
2491
2544
|
updatedAt: string;
|
|
2492
|
-
type: "product" | "bundle";
|
|
2545
|
+
type: "product" | "bundle" | "set";
|
|
2493
2546
|
slug: string;
|
|
2547
|
+
status: "draft" | "published" | "hidden" | null;
|
|
2494
2548
|
flags: unknown;
|
|
2495
|
-
active: boolean | null;
|
|
2496
2549
|
storeId: string;
|
|
2497
2550
|
summary: string | null;
|
|
2498
2551
|
images: string[];
|
|
@@ -2530,6 +2583,11 @@ type APICartCreateResult = {
|
|
|
2530
2583
|
storeId: string;
|
|
2531
2584
|
};
|
|
2532
2585
|
}[];
|
|
2586
|
+
setProduct: {
|
|
2587
|
+
selectionCount: number;
|
|
2588
|
+
allowDuplicates: boolean;
|
|
2589
|
+
discountPercentage: string;
|
|
2590
|
+
} | null;
|
|
2533
2591
|
};
|
|
2534
2592
|
id: string;
|
|
2535
2593
|
createdAt: string;
|
|
@@ -2614,10 +2672,10 @@ type APICartCreateResult = {
|
|
|
2614
2672
|
name: string;
|
|
2615
2673
|
createdAt: string;
|
|
2616
2674
|
updatedAt: string;
|
|
2617
|
-
type: "product" | "bundle";
|
|
2675
|
+
type: "product" | "bundle" | "set";
|
|
2618
2676
|
slug: string;
|
|
2677
|
+
status: "draft" | "published" | "hidden" | null;
|
|
2619
2678
|
flags: unknown;
|
|
2620
|
-
active: boolean | null;
|
|
2621
2679
|
storeId: string;
|
|
2622
2680
|
summary: string | null;
|
|
2623
2681
|
images: string[];
|
|
@@ -2655,6 +2713,11 @@ type APICartCreateResult = {
|
|
|
2655
2713
|
storeId: string;
|
|
2656
2714
|
};
|
|
2657
2715
|
}[];
|
|
2716
|
+
setProduct: {
|
|
2717
|
+
selectionCount: number;
|
|
2718
|
+
allowDuplicates: boolean;
|
|
2719
|
+
discountPercentage: string;
|
|
2720
|
+
} | null;
|
|
2658
2721
|
};
|
|
2659
2722
|
id: string;
|
|
2660
2723
|
createdAt: string;
|
|
@@ -2740,10 +2803,10 @@ type APICartCreateResult = {
|
|
|
2740
2803
|
name: string;
|
|
2741
2804
|
createdAt: string;
|
|
2742
2805
|
updatedAt: string;
|
|
2743
|
-
type: "product" | "bundle";
|
|
2806
|
+
type: "product" | "bundle" | "set";
|
|
2744
2807
|
slug: string;
|
|
2808
|
+
status: "draft" | "published" | "hidden" | null;
|
|
2745
2809
|
flags: unknown;
|
|
2746
|
-
active: boolean | null;
|
|
2747
2810
|
storeId: string;
|
|
2748
2811
|
summary: string | null;
|
|
2749
2812
|
images: string[];
|
|
@@ -2781,6 +2844,11 @@ type APICartCreateResult = {
|
|
|
2781
2844
|
storeId: string;
|
|
2782
2845
|
};
|
|
2783
2846
|
}[];
|
|
2847
|
+
setProduct: {
|
|
2848
|
+
selectionCount: number;
|
|
2849
|
+
allowDuplicates: boolean;
|
|
2850
|
+
discountPercentage: string;
|
|
2851
|
+
} | null;
|
|
2784
2852
|
};
|
|
2785
2853
|
id: string;
|
|
2786
2854
|
createdAt: string;
|
|
@@ -2835,6 +2903,23 @@ type APICartCreateResult = {
|
|
|
2835
2903
|
interval: number;
|
|
2836
2904
|
cadence: "month" | "week";
|
|
2837
2905
|
} | null;
|
|
2906
|
+
setSelections: {
|
|
2907
|
+
id: string;
|
|
2908
|
+
createdAt: string;
|
|
2909
|
+
updatedAt: string;
|
|
2910
|
+
position: number;
|
|
2911
|
+
quantity: number;
|
|
2912
|
+
lineItemId: string;
|
|
2913
|
+
selectedVariantId: string;
|
|
2914
|
+
selectedVariant: {
|
|
2915
|
+
id: string;
|
|
2916
|
+
price: string;
|
|
2917
|
+
product: {
|
|
2918
|
+
id: string;
|
|
2919
|
+
name: string;
|
|
2920
|
+
};
|
|
2921
|
+
};
|
|
2922
|
+
}[];
|
|
2838
2923
|
}[];
|
|
2839
2924
|
id: string;
|
|
2840
2925
|
createdAt: string;
|
|
@@ -2996,10 +3081,10 @@ type APICartRemoveItemResult = {
|
|
|
2996
3081
|
name: string;
|
|
2997
3082
|
createdAt: string;
|
|
2998
3083
|
updatedAt: string;
|
|
2999
|
-
type: "product" | "bundle";
|
|
3084
|
+
type: "product" | "bundle" | "set";
|
|
3000
3085
|
slug: string;
|
|
3086
|
+
status: "draft" | "published" | "hidden" | null;
|
|
3001
3087
|
flags: unknown;
|
|
3002
|
-
active: boolean | null;
|
|
3003
3088
|
storeId: string;
|
|
3004
3089
|
summary: string | null;
|
|
3005
3090
|
images: string[];
|
|
@@ -3037,6 +3122,11 @@ type APICartRemoveItemResult = {
|
|
|
3037
3122
|
storeId: string;
|
|
3038
3123
|
};
|
|
3039
3124
|
}[];
|
|
3125
|
+
setProduct: {
|
|
3126
|
+
selectionCount: number;
|
|
3127
|
+
allowDuplicates: boolean;
|
|
3128
|
+
discountPercentage: string;
|
|
3129
|
+
} | null;
|
|
3040
3130
|
};
|
|
3041
3131
|
id: string;
|
|
3042
3132
|
createdAt: string;
|
|
@@ -3121,10 +3211,10 @@ type APICartRemoveItemResult = {
|
|
|
3121
3211
|
name: string;
|
|
3122
3212
|
createdAt: string;
|
|
3123
3213
|
updatedAt: string;
|
|
3124
|
-
type: "product" | "bundle";
|
|
3214
|
+
type: "product" | "bundle" | "set";
|
|
3125
3215
|
slug: string;
|
|
3216
|
+
status: "draft" | "published" | "hidden" | null;
|
|
3126
3217
|
flags: unknown;
|
|
3127
|
-
active: boolean | null;
|
|
3128
3218
|
storeId: string;
|
|
3129
3219
|
summary: string | null;
|
|
3130
3220
|
images: string[];
|
|
@@ -3162,6 +3252,11 @@ type APICartRemoveItemResult = {
|
|
|
3162
3252
|
storeId: string;
|
|
3163
3253
|
};
|
|
3164
3254
|
}[];
|
|
3255
|
+
setProduct: {
|
|
3256
|
+
selectionCount: number;
|
|
3257
|
+
allowDuplicates: boolean;
|
|
3258
|
+
discountPercentage: string;
|
|
3259
|
+
} | null;
|
|
3165
3260
|
};
|
|
3166
3261
|
id: string;
|
|
3167
3262
|
createdAt: string;
|
|
@@ -3246,10 +3341,10 @@ type APICartRemoveItemResult = {
|
|
|
3246
3341
|
name: string;
|
|
3247
3342
|
createdAt: string;
|
|
3248
3343
|
updatedAt: string;
|
|
3249
|
-
type: "product" | "bundle";
|
|
3344
|
+
type: "product" | "bundle" | "set";
|
|
3250
3345
|
slug: string;
|
|
3346
|
+
status: "draft" | "published" | "hidden" | null;
|
|
3251
3347
|
flags: unknown;
|
|
3252
|
-
active: boolean | null;
|
|
3253
3348
|
storeId: string;
|
|
3254
3349
|
summary: string | null;
|
|
3255
3350
|
images: string[];
|
|
@@ -3287,6 +3382,11 @@ type APICartRemoveItemResult = {
|
|
|
3287
3382
|
storeId: string;
|
|
3288
3383
|
};
|
|
3289
3384
|
}[];
|
|
3385
|
+
setProduct: {
|
|
3386
|
+
selectionCount: number;
|
|
3387
|
+
allowDuplicates: boolean;
|
|
3388
|
+
discountPercentage: string;
|
|
3389
|
+
} | null;
|
|
3290
3390
|
};
|
|
3291
3391
|
id: string;
|
|
3292
3392
|
createdAt: string;
|
|
@@ -3371,10 +3471,10 @@ type APICartRemoveItemResult = {
|
|
|
3371
3471
|
name: string;
|
|
3372
3472
|
createdAt: string;
|
|
3373
3473
|
updatedAt: string;
|
|
3374
|
-
type: "product" | "bundle";
|
|
3474
|
+
type: "product" | "bundle" | "set";
|
|
3375
3475
|
slug: string;
|
|
3476
|
+
status: "draft" | "published" | "hidden" | null;
|
|
3376
3477
|
flags: unknown;
|
|
3377
|
-
active: boolean | null;
|
|
3378
3478
|
storeId: string;
|
|
3379
3479
|
summary: string | null;
|
|
3380
3480
|
images: string[];
|
|
@@ -3412,6 +3512,11 @@ type APICartRemoveItemResult = {
|
|
|
3412
3512
|
storeId: string;
|
|
3413
3513
|
};
|
|
3414
3514
|
}[];
|
|
3515
|
+
setProduct: {
|
|
3516
|
+
selectionCount: number;
|
|
3517
|
+
allowDuplicates: boolean;
|
|
3518
|
+
discountPercentage: string;
|
|
3519
|
+
} | null;
|
|
3415
3520
|
};
|
|
3416
3521
|
id: string;
|
|
3417
3522
|
createdAt: string;
|
|
@@ -3497,10 +3602,10 @@ type APICartRemoveItemResult = {
|
|
|
3497
3602
|
name: string;
|
|
3498
3603
|
createdAt: string;
|
|
3499
3604
|
updatedAt: string;
|
|
3500
|
-
type: "product" | "bundle";
|
|
3605
|
+
type: "product" | "bundle" | "set";
|
|
3501
3606
|
slug: string;
|
|
3607
|
+
status: "draft" | "published" | "hidden" | null;
|
|
3502
3608
|
flags: unknown;
|
|
3503
|
-
active: boolean | null;
|
|
3504
3609
|
storeId: string;
|
|
3505
3610
|
summary: string | null;
|
|
3506
3611
|
images: string[];
|
|
@@ -3538,6 +3643,11 @@ type APICartRemoveItemResult = {
|
|
|
3538
3643
|
storeId: string;
|
|
3539
3644
|
};
|
|
3540
3645
|
}[];
|
|
3646
|
+
setProduct: {
|
|
3647
|
+
selectionCount: number;
|
|
3648
|
+
allowDuplicates: boolean;
|
|
3649
|
+
discountPercentage: string;
|
|
3650
|
+
} | null;
|
|
3541
3651
|
};
|
|
3542
3652
|
id: string;
|
|
3543
3653
|
createdAt: string;
|
|
@@ -3592,6 +3702,23 @@ type APICartRemoveItemResult = {
|
|
|
3592
3702
|
interval: number;
|
|
3593
3703
|
cadence: "month" | "week";
|
|
3594
3704
|
} | null;
|
|
3705
|
+
setSelections: {
|
|
3706
|
+
id: string;
|
|
3707
|
+
createdAt: string;
|
|
3708
|
+
updatedAt: string;
|
|
3709
|
+
position: number;
|
|
3710
|
+
quantity: number;
|
|
3711
|
+
lineItemId: string;
|
|
3712
|
+
selectedVariantId: string;
|
|
3713
|
+
selectedVariant: {
|
|
3714
|
+
id: string;
|
|
3715
|
+
price: string;
|
|
3716
|
+
product: {
|
|
3717
|
+
id: string;
|
|
3718
|
+
name: string;
|
|
3719
|
+
};
|
|
3720
|
+
};
|
|
3721
|
+
}[];
|
|
3595
3722
|
}[];
|
|
3596
3723
|
id: string;
|
|
3597
3724
|
createdAt: string;
|
|
@@ -3790,7 +3917,7 @@ type APIOrdersBrowseResult = {
|
|
|
3790
3917
|
id: string;
|
|
3791
3918
|
name: string;
|
|
3792
3919
|
slug: string;
|
|
3793
|
-
|
|
3920
|
+
status: "draft" | "published" | "hidden" | null;
|
|
3794
3921
|
images: string[];
|
|
3795
3922
|
badge: {
|
|
3796
3923
|
content?: string | undefined;
|
|
@@ -3819,7 +3946,7 @@ type APIOrdersBrowseResult = {
|
|
|
3819
3946
|
flags: {
|
|
3820
3947
|
gold?: boolean | null | undefined;
|
|
3821
3948
|
} | null;
|
|
3822
|
-
type: "product" | "bundle";
|
|
3949
|
+
type: "product" | "bundle" | "set";
|
|
3823
3950
|
bundleDiscountPercentage: string | null;
|
|
3824
3951
|
productCollections: {
|
|
3825
3952
|
collection: {
|
|
@@ -3882,6 +4009,12 @@ type APIOrdersBrowseResult = {
|
|
|
3882
4009
|
storeId: string;
|
|
3883
4010
|
};
|
|
3884
4011
|
}[];
|
|
4012
|
+
setProduct: {
|
|
4013
|
+
selectionCount: number;
|
|
4014
|
+
allowDuplicates: boolean;
|
|
4015
|
+
discountPercentage: string;
|
|
4016
|
+
} | null;
|
|
4017
|
+
active?: boolean | null | undefined;
|
|
3885
4018
|
};
|
|
3886
4019
|
createdAt: string;
|
|
3887
4020
|
productId: string;
|
|
@@ -3923,6 +4056,31 @@ type APIOrdersBrowseResult = {
|
|
|
3923
4056
|
interval: number;
|
|
3924
4057
|
cadence: "month" | "week";
|
|
3925
4058
|
} | null;
|
|
4059
|
+
slotId: string | null;
|
|
4060
|
+
attendees: {
|
|
4061
|
+
name: string;
|
|
4062
|
+
email: string;
|
|
4063
|
+
phone: string | null;
|
|
4064
|
+
dietary: string | null;
|
|
4065
|
+
notes: string | null;
|
|
4066
|
+
}[] | null;
|
|
4067
|
+
setSelections: {
|
|
4068
|
+
id: string;
|
|
4069
|
+
lineItemId: string;
|
|
4070
|
+
selectedVariantId: string;
|
|
4071
|
+
quantity: number;
|
|
4072
|
+
position: number;
|
|
4073
|
+
createdAt: string;
|
|
4074
|
+
updatedAt: string;
|
|
4075
|
+
selectedVariant: {
|
|
4076
|
+
id: string;
|
|
4077
|
+
price: string;
|
|
4078
|
+
product: {
|
|
4079
|
+
id: string;
|
|
4080
|
+
name: string;
|
|
4081
|
+
};
|
|
4082
|
+
};
|
|
4083
|
+
}[];
|
|
3926
4084
|
}[];
|
|
3927
4085
|
updatedAt: string;
|
|
3928
4086
|
couponId: string | null;
|
|
@@ -4090,7 +4248,7 @@ type APIOrdersBrowseResult = {
|
|
|
4090
4248
|
id: string;
|
|
4091
4249
|
name: string;
|
|
4092
4250
|
slug: string;
|
|
4093
|
-
|
|
4251
|
+
status: "draft" | "published" | "hidden" | null;
|
|
4094
4252
|
images: string[];
|
|
4095
4253
|
badge: {
|
|
4096
4254
|
content?: string | undefined;
|
|
@@ -4119,7 +4277,7 @@ type APIOrdersBrowseResult = {
|
|
|
4119
4277
|
flags: {
|
|
4120
4278
|
gold?: boolean | null | undefined;
|
|
4121
4279
|
} | null;
|
|
4122
|
-
type: "product" | "bundle";
|
|
4280
|
+
type: "product" | "bundle" | "set";
|
|
4123
4281
|
bundleDiscountPercentage: string | null;
|
|
4124
4282
|
productCollections: {
|
|
4125
4283
|
collection: {
|
|
@@ -4182,6 +4340,12 @@ type APIOrdersBrowseResult = {
|
|
|
4182
4340
|
storeId: string;
|
|
4183
4341
|
};
|
|
4184
4342
|
}[];
|
|
4343
|
+
setProduct: {
|
|
4344
|
+
selectionCount: number;
|
|
4345
|
+
allowDuplicates: boolean;
|
|
4346
|
+
discountPercentage: string;
|
|
4347
|
+
} | null;
|
|
4348
|
+
active?: boolean | null | undefined;
|
|
4185
4349
|
};
|
|
4186
4350
|
createdAt: string;
|
|
4187
4351
|
productId: string;
|
|
@@ -4223,6 +4387,31 @@ type APIOrdersBrowseResult = {
|
|
|
4223
4387
|
interval: number;
|
|
4224
4388
|
cadence: "month" | "week";
|
|
4225
4389
|
} | null;
|
|
4390
|
+
slotId: string | null;
|
|
4391
|
+
attendees: {
|
|
4392
|
+
name: string;
|
|
4393
|
+
email: string;
|
|
4394
|
+
phone: string | null;
|
|
4395
|
+
dietary: string | null;
|
|
4396
|
+
notes: string | null;
|
|
4397
|
+
}[] | null;
|
|
4398
|
+
setSelections: {
|
|
4399
|
+
id: string;
|
|
4400
|
+
lineItemId: string;
|
|
4401
|
+
selectedVariantId: string;
|
|
4402
|
+
quantity: number;
|
|
4403
|
+
position: number;
|
|
4404
|
+
createdAt: string;
|
|
4405
|
+
updatedAt: string;
|
|
4406
|
+
selectedVariant: {
|
|
4407
|
+
id: string;
|
|
4408
|
+
price: string;
|
|
4409
|
+
product: {
|
|
4410
|
+
id: string;
|
|
4411
|
+
name: string;
|
|
4412
|
+
};
|
|
4413
|
+
};
|
|
4414
|
+
}[];
|
|
4226
4415
|
}[];
|
|
4227
4416
|
updatedAt: string;
|
|
4228
4417
|
couponId: string | null;
|
|
@@ -4406,7 +4595,7 @@ type APIOrderGetByIdResult = {
|
|
|
4406
4595
|
id: string;
|
|
4407
4596
|
name: string;
|
|
4408
4597
|
slug: string;
|
|
4409
|
-
|
|
4598
|
+
status: "draft" | "published" | "hidden" | null;
|
|
4410
4599
|
images: string[];
|
|
4411
4600
|
badge: {
|
|
4412
4601
|
content?: string | undefined;
|
|
@@ -4435,7 +4624,7 @@ type APIOrderGetByIdResult = {
|
|
|
4435
4624
|
flags: {
|
|
4436
4625
|
gold?: boolean | null | undefined;
|
|
4437
4626
|
} | null;
|
|
4438
|
-
type: "product" | "bundle";
|
|
4627
|
+
type: "product" | "bundle" | "set";
|
|
4439
4628
|
bundleDiscountPercentage: string | null;
|
|
4440
4629
|
productCollections: {
|
|
4441
4630
|
collection: {
|
|
@@ -4498,6 +4687,12 @@ type APIOrderGetByIdResult = {
|
|
|
4498
4687
|
storeId: string;
|
|
4499
4688
|
};
|
|
4500
4689
|
}[];
|
|
4690
|
+
setProduct: {
|
|
4691
|
+
selectionCount: number;
|
|
4692
|
+
allowDuplicates: boolean;
|
|
4693
|
+
discountPercentage: string;
|
|
4694
|
+
} | null;
|
|
4695
|
+
active?: boolean | null | undefined;
|
|
4501
4696
|
};
|
|
4502
4697
|
createdAt: string;
|
|
4503
4698
|
productId: string;
|
|
@@ -4539,6 +4734,31 @@ type APIOrderGetByIdResult = {
|
|
|
4539
4734
|
interval: number;
|
|
4540
4735
|
cadence: "month" | "week";
|
|
4541
4736
|
} | null;
|
|
4737
|
+
slotId: string | null;
|
|
4738
|
+
attendees: {
|
|
4739
|
+
name: string;
|
|
4740
|
+
email: string;
|
|
4741
|
+
phone: string | null;
|
|
4742
|
+
dietary: string | null;
|
|
4743
|
+
notes: string | null;
|
|
4744
|
+
}[] | null;
|
|
4745
|
+
setSelections: {
|
|
4746
|
+
id: string;
|
|
4747
|
+
lineItemId: string;
|
|
4748
|
+
selectedVariantId: string;
|
|
4749
|
+
quantity: number;
|
|
4750
|
+
position: number;
|
|
4751
|
+
createdAt: string;
|
|
4752
|
+
updatedAt: string;
|
|
4753
|
+
selectedVariant: {
|
|
4754
|
+
id: string;
|
|
4755
|
+
price: string;
|
|
4756
|
+
product: {
|
|
4757
|
+
id: string;
|
|
4758
|
+
name: string;
|
|
4759
|
+
};
|
|
4760
|
+
};
|
|
4761
|
+
}[];
|
|
4542
4762
|
}[];
|
|
4543
4763
|
updatedAt: string;
|
|
4544
4764
|
couponId: string | null;
|
|
@@ -4722,7 +4942,7 @@ type APIOrderGetByIdResult = {
|
|
|
4722
4942
|
id: string;
|
|
4723
4943
|
name: string;
|
|
4724
4944
|
slug: string;
|
|
4725
|
-
|
|
4945
|
+
status: "draft" | "published" | "hidden" | null;
|
|
4726
4946
|
images: string[];
|
|
4727
4947
|
badge: {
|
|
4728
4948
|
content?: string | undefined;
|
|
@@ -4751,7 +4971,7 @@ type APIOrderGetByIdResult = {
|
|
|
4751
4971
|
flags: {
|
|
4752
4972
|
gold?: boolean | null | undefined;
|
|
4753
4973
|
} | null;
|
|
4754
|
-
type: "product" | "bundle";
|
|
4974
|
+
type: "product" | "bundle" | "set";
|
|
4755
4975
|
bundleDiscountPercentage: string | null;
|
|
4756
4976
|
productCollections: {
|
|
4757
4977
|
collection: {
|
|
@@ -4814,6 +5034,12 @@ type APIOrderGetByIdResult = {
|
|
|
4814
5034
|
storeId: string;
|
|
4815
5035
|
};
|
|
4816
5036
|
}[];
|
|
5037
|
+
setProduct: {
|
|
5038
|
+
selectionCount: number;
|
|
5039
|
+
allowDuplicates: boolean;
|
|
5040
|
+
discountPercentage: string;
|
|
5041
|
+
} | null;
|
|
5042
|
+
active?: boolean | null | undefined;
|
|
4817
5043
|
};
|
|
4818
5044
|
createdAt: string;
|
|
4819
5045
|
productId: string;
|
|
@@ -4855,6 +5081,31 @@ type APIOrderGetByIdResult = {
|
|
|
4855
5081
|
interval: number;
|
|
4856
5082
|
cadence: "month" | "week";
|
|
4857
5083
|
} | null;
|
|
5084
|
+
slotId: string | null;
|
|
5085
|
+
attendees: {
|
|
5086
|
+
name: string;
|
|
5087
|
+
email: string;
|
|
5088
|
+
phone: string | null;
|
|
5089
|
+
dietary: string | null;
|
|
5090
|
+
notes: string | null;
|
|
5091
|
+
}[] | null;
|
|
5092
|
+
setSelections: {
|
|
5093
|
+
id: string;
|
|
5094
|
+
lineItemId: string;
|
|
5095
|
+
selectedVariantId: string;
|
|
5096
|
+
quantity: number;
|
|
5097
|
+
position: number;
|
|
5098
|
+
createdAt: string;
|
|
5099
|
+
updatedAt: string;
|
|
5100
|
+
selectedVariant: {
|
|
5101
|
+
id: string;
|
|
5102
|
+
price: string;
|
|
5103
|
+
product: {
|
|
5104
|
+
id: string;
|
|
5105
|
+
name: string;
|
|
5106
|
+
};
|
|
5107
|
+
};
|
|
5108
|
+
}[];
|
|
4858
5109
|
}[];
|
|
4859
5110
|
updatedAt: string;
|
|
4860
5111
|
couponId: string | null;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-PNKB6P4V.js";var n={DEBUG:0,LOG:1,WARN:2,ERROR:3},
|
|
1
|
+
import"./chunk-PNKB6P4V.js";var n={DEBUG:0,LOG:1,WARN:2,ERROR:3},R=process.env.NEXT_PUBLIC_LOG_LEVEL||"LOG",i=n[R],l="\x1B[0m",m="\x1B[34m",y="\x1B[32m",B="\x1B[33m",w="\x1B[31m",E="\u23F1\uFE0F",$="\u{1F41B}",h="\u2714\uFE0F",A="\u26A0\uFE0F",L="\u274C",f=`${E} `,G=`${m}${$}${l} `,O=`${y}${h}${l} `,v=`${B}${A}${l} `,S=`${w}${L}${l} `,P=u=>{let e=u?`[${u}] `:"";return{getLogger(t){return P([u,t].filter(Boolean).join(" > "))},time(t){i>n.DEBUG||console.time([f,e,t].filter(Boolean).join(" "))},timeEnd(t){i>n.DEBUG||console.timeEnd([f,e,t].filter(Boolean).join(" "))},debug(...t){i>n.DEBUG||console.log(...[G,e,...t].filter(Boolean))},log(...t){i>n.LOG||console.log(...[O,e,...t].filter(Boolean))},dir(t,r){i>n.LOG||console.dir(t,r)},warn(...t){i>n.WARN||console.warn(...[v,e,...t].filter(Boolean))},error(...t){i>n.ERROR||console.error(...[S,e,...t].filter(Boolean))}}},T=P();var I=class{#t;#r=P("YnsProvider");constructor(e){this.#t=e,this.#r.debug("YnsProvider initialized")}async#e(e,t="GET",r){let c=this.#r.getLogger("#restRequest"),s=`${this.#t.endpoint}/api/${this.#t.version}${e}`;c.debug(`Making ${t} request to YNS API: ${s}`);let o=await fetch(s,{method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.#t.token}`},body:r?JSON.stringify(r):void 0});if(!o.ok){let p=o.headers.get("content-type"),d=`YNS REST request failed: ${t} ${s} ${o.status} ${o.statusText}`;if(p?.includes("application/json"))try{let a=await o.json();d=a.error||a.message||d}catch(a){c.error("Failed to parse YNS error response as JSON",a)}else{let a=await o.text();c.error(`YNS API request failed: ${o.status} ${o.statusText}`,d,a)}throw new Error(d)}let g=o.headers.get("content-type");if(!g?.includes("application/json"))throw new Error(`YNS API returned ${g} instead of JSON for ${e}`);return o.json()}async productBrowse(e){let t=this.#r.getLogger("productBrowse");t.debug("Browsing products with params:",e);let r=new URLSearchParams;e.limit&&r.append("limit",e.limit.toString()),e.offset&&r.append("offset",e.offset.toString()),e.category&&r.append("category",e.category),e.query&&r.append("query",e.query),e.active!==void 0&&r.append("active",e.active.toString()),e.orderBy&&r.append("orderBy",e.orderBy),e.orderDirection&&r.append("orderDirection",e.orderDirection);let s=`/products${r.size?`?${r}`:""}`;t.debug("Constructed pathname:",s);let o=await this.#e(s);return t.debug("Received product browse result:",{meta:o.meta}),o}async productGet(e){let t=`/products/${e.idOrSlug}`,r=await this.#e(t);return r||null}async orderBrowse(e){let t=this.#r.getLogger("orderBrowse");t.debug("Browsing orders with params:",e);let r=new URLSearchParams;e.limit&&r.append("limit",e.limit.toString()),e.offset&&r.append("offset",e.offset.toString());let s=`/orders${r.size?`?${r}`:""}`;t.debug("Constructed pathname:",s);let o=await this.#e(s);return t.debug("Received orders browse result:",{meta:o.meta}),o}async orderGet(e){let t=`/orders/${e.id}`,r=await this.#e(t);return r||null}async cartUpsert(e){return await this.#e("/carts","POST",e)}async cartRemoveItem(e){let t=`/carts/${e.cartId}/line-items/${e.variantId}`,r=await this.#e(t,"DELETE");return null}async cartGet(e){let t=`/carts/${e.cartId}`;return await this.#e(t)}};export{I as YnsProvider};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/logger.ts","../src/providers/yns.ts"],"sourcesContent":["import type { InspectOptions } from \"node:util\";\n\ntype LogParms = [message: unknown, ...optionalParams: unknown[]];\n\n/**\n * Vercel only supports 3 levels of logging. We're adding additional DEBUG level.\n * https://vercel.com/docs/observability/runtime-logs#level\n *\n * ERROR - Fatal for a particular request. Should be fixed sooner than later.\n *\n * WARN - A note on something that should probably be looked at eventually.\n *\n * LOG - Detail on regular operation.\n *\n * DEBUG - Debug only info as well as time and timeEnd functions.\n */\nconst LogLevel = {\n\tDEBUG: 0,\n\tLOG: 1,\n\tWARN: 2,\n\tERROR: 3,\n} as const;\ntype LogLevel = keyof typeof LogLevel;\n\nconst strLogLevel = (process.env.NEXT_PUBLIC_LOG_LEVEL || \"LOG\") as LogLevel;\nconst valueLogLevel = LogLevel[strLogLevel];\n\nconst RESET = \"\\x1b[0m\";\nconst BLUE = \"\\x1b[34m\";\nconst GREEN = \"\\x1b[32m\";\nconst YELLOW = \"\\x1b[33m\";\nconst RED = \"\\x1b[31m\";\n\nconst TIME = `⏱️`;\nconst DEBUG = `🐛`;\nconst OK = `✔️`;\nconst WARN = `⚠️`;\nconst ERROR = `❌`;\n\nconst PREFIX_TIME = `${TIME} `;\nconst PREFIX_DEBUG = `${BLUE}${DEBUG}${RESET} `;\nconst PREFIX_OK = `${GREEN}${OK}${RESET} `;\nconst PREFIX_WARN = `${YELLOW}${WARN}${RESET} `;\nconst PREFIX_ERROR = `${RED}${ERROR}${RESET} `;\n\nexport const getLogger = (groupLabel?: string) => {\n\tconst PREFIX = groupLabel ? `[${groupLabel}] ` : \"\";\n\treturn {\n\t\tgetLogger(subGroupLabel: string) {\n\t\t\treturn getLogger([groupLabel, subGroupLabel].filter(Boolean).join(\" > \"));\n\t\t},\n\t\ttime(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.time([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\ttimeEnd(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.timeEnd([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\tdebug(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.log(...[PREFIX_DEBUG, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tlog(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.log(...[PREFIX_OK, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tdir(item?: unknown, options?: InspectOptions) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.dir(item, options);\n\t\t},\n\t\twarn(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.WARN) return;\n\t\t\tconsole.warn(...[PREFIX_WARN, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\terror(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.ERROR) return;\n\t\t\tconsole.error(...[PREFIX_ERROR, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t};\n};\n\nexport const logger = getLogger();\n","import type {\n\tAPICartCreateBody,\n\tAPICartCreateResult,\n\tAPICartGetResult,\n\tAPIOrderGetByIdParams,\n\tAPIOrderGetByIdResult,\n\tAPIOrdersBrowseQueryParams,\n\tAPIOrdersBrowseResult,\n\tAPIProductGetByIdParams,\n\tAPIProductGetByIdResult,\n\tAPIProductsBrowseQueryParams,\n\tAPIProductsBrowseResult,\n} from \"../api-types\";\nimport { getLogger } from \"../logger\";\n\ninterface YnsProviderConfig {\n\tversion: \"v1\";\n\tendpoint: string;\n\ttoken: string;\n}\n\nexport class YnsProvider {\n\t#config;\n\t#logger = getLogger(\"YnsProvider\");\n\tconstructor(config: YnsProviderConfig) {\n\t\tthis.#config = config;\n\t\tthis.#logger.debug(\"YnsProvider initialized\");\n\t}\n\n\tasync #restRequest<T>(\n\t\tpathname: `/${string}`,\n\t\tmethod: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" = \"GET\",\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst logger = this.#logger.getLogger(\"#restRequest\");\n\n\t\tconst endpoint = `${this.#config.endpoint}/api/${this.#config.version}${pathname}`;\n\t\tlogger.debug(`Making ${method} request to YNS API: ${endpoint}`);\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tAuthorization: `Bearer ${this.#config.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\t// Handle different error types\n\t\t\tconst contentType = response.headers.get(\"content-type\");\n\t\t\tlet errorMessage = `YNS REST request failed: ${response.status} ${response.statusText}`;\n\n\t\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\t\ttry {\n\t\t\t\t\tconst errorData = await response.json();\n\t\t\t\t\terrorMessage = errorData.error || errorData.message || errorMessage;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(\"Failed to parse YNS error response as JSON\", error);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tlogger.error(\n\t\t\t\t\t`YNS API request failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\terrorMessage,\n\t\t\t\t\terrorText,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\n\t\t// Check if response is JSON before parsing\n\t\tconst contentType = response.headers.get(\"content-type\");\n\t\tif (!contentType?.includes(\"application/json\")) {\n\t\t\tthrow new Error(`YNS API returned ${contentType} instead of JSON for ${pathname}`);\n\t\t}\n\n\t\treturn response.json();\n\t}\n\n\tasync productBrowse(params: APIProductsBrowseQueryParams): Promise<APIProductsBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"productBrowse\");\n\t\tlogger.debug(\"Browsing products with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.category) queryParams.append(\"category\", params.category);\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\t\tif (params.orderBy) queryParams.append(\"orderBy\", params.orderBy);\n\t\tif (params.orderDirection) queryParams.append(\"orderDirection\", params.orderDirection);\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/products${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIProductsBrowseResult>(pathname);\n\t\tlogger.debug(\"Received product browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync productGet(params: APIProductGetByIdParams): Promise<APIProductGetByIdResult | null> {\n\t\tconst pathname = `/products/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APIProductGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tasync orderBrowse(params: APIOrdersBrowseQueryParams): Promise<APIOrdersBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"orderBrowse\");\n\t\tlogger.debug(\"Browsing orders with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/orders${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIOrdersBrowseResult>(pathname);\n\t\tlogger.debug(\"Received orders browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync orderGet(params: APIOrderGetByIdParams): Promise<APIOrderGetByIdResult | null> {\n\t\tconst pathname = `/orders/${params.id}` as const;\n\n\t\tconst result = await this.#restRequest<APIOrderGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// @todo\n\t// async cartAdd(params: APICartAddBody): Promise<APICartAddResult> {\n\t// \tconst body = {\n\t// \t\tvariantId: params.variantId,\n\t// \t\tcartId: params.cartId,\n\t// \t\tquantity: params.quantity,\n\t// \t\tsubscriptionId: params.subscriptionId,\n\t// \t};\n\n\t// \tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"PUT\", body);\n\t// \treturn result;\n\t// }\n\n\tasync cartUpsert(body: APICartCreateBody): Promise<APICartCreateResult> {\n\t\tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"POST\", body);\n\t\treturn result;\n\t}\n\n\tasync cartRemoveItem(params: { cartId: string; variantId: string }): Promise<null> {\n\t\tconst pathname = `/carts/${params.cartId}/line-items/${params.variantId}` as const;\n\t\tconst result = await this.#restRequest<unknown>(pathname, \"DELETE\");\n\t\t// return result;\n\t\treturn null;\n\t}\n\n\tasync cartGet(params: { cartId: string }): Promise<APICartGetResult | null> {\n\t\tconst pathname = `/carts/${params.cartId}` as const;\n\t\tconst result = await this.#restRequest<APICartGetResult>(pathname);\n\t\treturn result;\n\t}\n}\n"],"mappings":"4BAgBA,IAAMA,EAAW,CAChB,MAAO,EACP,IAAK,EACL,KAAM,EACN,MAAO,CACR,EAGMC,EAAe,QAAQ,IAAI,uBAAyB,MACpDC,EAAgBF,EAASC,CAAW,EAEpCE,EAAQ,UACRC,EAAO,WACPC,EAAQ,WACRC,EAAS,WACTC,EAAM,WAENC,EAAO,eACPC,EAAQ,YACRC,EAAK,eACLC,EAAO,eACPC,EAAQ,SAERC,EAAc,GAAGL,CAAI,IACrBM,EAAe,GAAGV,CAAI,GAAGK,CAAK,GAAGN,CAAK,IACtCY,EAAY,GAAGV,CAAK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O,MAAM,wBAAyBH,CAAQ,EAC9C,IAAMa,EAAS,MAAM,KAAKd,GAAoCC,CAAQ,EACtE,OAAAG,EAAO,MAAM,iCAAkC,CAAE,KAAMU,EAAO,IAAK,CAAC,EAC7DA,CACR,CAEA,MAAM,SAASF,EAAsE,CACpF,IAAMX,EAAW,WAAWW,EAAO,EAAE,GAE/BE,EAAS,MAAM,KAAKd,GAAoCC,CAAQ,EAEtE,OAAKa,GACG,IAIT,CAeA,MAAM,WAAWX,EAAuD,CAEvE,OADe,MAAM,KAAKH,GAAkC,SAAU,OAAQG,CAAI,CAEnF,CAEA,MAAM,eAAeS,EAA8D,CAClF,IAAMX,EAAW,UAAUW,EAAO,MAAM,eAAeA,EAAO,SAAS,GACjEE,EAAS,MAAM,KAAKd,GAAsBC,EAAU,QAAQ,EAElE,OAAO,IACR,CAEA,MAAM,QAAQW,EAA8D,CAC3E,IAAMX,EAAW,UAAUW,EAAO,MAAM,GAExC,OADe,MAAM,KAAKZ,GAA+BC,CAAQ,CAElE,CACD","names":["LogLevel","strLogLevel","valueLogLevel","RESET","BLUE","GREEN","YELLOW","RED","TIME","DEBUG","OK","WARN","ERROR","PREFIX_TIME","PREFIX_DEBUG","PREFIX_OK","PREFIX_WARN","PREFIX_ERROR","getLogger","groupLabel","PREFIX","subGroupLabel","label","args","item","options","logger","YnsProvider","#config","#logger","getLogger","config","#restRequest","pathname","method","body","logger","endpoint","response","contentType","errorMessage","errorData","error","errorText","params","queryParams","result"]}
|
|
1
|
+
{"version":3,"sources":["../src/logger.ts","../src/providers/yns.ts"],"sourcesContent":["import type { InspectOptions } from \"node:util\";\n\ntype LogParms = [message: unknown, ...optionalParams: unknown[]];\n\n/**\n * Vercel only supports 3 levels of logging. We're adding additional DEBUG level.\n * https://vercel.com/docs/observability/runtime-logs#level\n *\n * ERROR - Fatal for a particular request. Should be fixed sooner than later.\n *\n * WARN - A note on something that should probably be looked at eventually.\n *\n * LOG - Detail on regular operation.\n *\n * DEBUG - Debug only info as well as time and timeEnd functions.\n */\nconst LogLevel = {\n\tDEBUG: 0,\n\tLOG: 1,\n\tWARN: 2,\n\tERROR: 3,\n} as const;\ntype LogLevel = keyof typeof LogLevel;\n\nconst strLogLevel = (process.env.NEXT_PUBLIC_LOG_LEVEL || \"LOG\") as LogLevel;\nconst valueLogLevel = LogLevel[strLogLevel];\n\nconst RESET = \"\\x1b[0m\";\nconst BLUE = \"\\x1b[34m\";\nconst GREEN = \"\\x1b[32m\";\nconst YELLOW = \"\\x1b[33m\";\nconst RED = \"\\x1b[31m\";\n\nconst TIME = `⏱️`;\nconst DEBUG = `🐛`;\nconst OK = `✔️`;\nconst WARN = `⚠️`;\nconst ERROR = `❌`;\n\nconst PREFIX_TIME = `${TIME} `;\nconst PREFIX_DEBUG = `${BLUE}${DEBUG}${RESET} `;\nconst PREFIX_OK = `${GREEN}${OK}${RESET} `;\nconst PREFIX_WARN = `${YELLOW}${WARN}${RESET} `;\nconst PREFIX_ERROR = `${RED}${ERROR}${RESET} `;\n\nexport const getLogger = (groupLabel?: string) => {\n\tconst PREFIX = groupLabel ? `[${groupLabel}] ` : \"\";\n\treturn {\n\t\tgetLogger(subGroupLabel: string) {\n\t\t\treturn getLogger([groupLabel, subGroupLabel].filter(Boolean).join(\" > \"));\n\t\t},\n\t\ttime(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.time([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\ttimeEnd(label: string) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.timeEnd([PREFIX_TIME, PREFIX, label].filter(Boolean).join(\" \"));\n\t\t},\n\t\tdebug(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.DEBUG) return;\n\t\t\tconsole.log(...[PREFIX_DEBUG, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tlog(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.log(...[PREFIX_OK, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\tdir(item?: unknown, options?: InspectOptions) {\n\t\t\tif (valueLogLevel > LogLevel.LOG) return;\n\t\t\tconsole.dir(item, options);\n\t\t},\n\t\twarn(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.WARN) return;\n\t\t\tconsole.warn(...[PREFIX_WARN, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t\terror(...args: LogParms) {\n\t\t\tif (valueLogLevel > LogLevel.ERROR) return;\n\t\t\tconsole.error(...[PREFIX_ERROR, PREFIX, ...args].filter(Boolean));\n\t\t},\n\t};\n};\n\nexport const logger = getLogger();\n","import type {\n\tAPICartCreateBody,\n\tAPICartCreateResult,\n\tAPICartGetResult,\n\tAPIOrderGetByIdParams,\n\tAPIOrderGetByIdResult,\n\tAPIOrdersBrowseQueryParams,\n\tAPIOrdersBrowseResult,\n\tAPIProductGetByIdParams,\n\tAPIProductGetByIdResult,\n\tAPIProductsBrowseQueryParams,\n\tAPIProductsBrowseResult,\n} from \"../api-types\";\nimport { getLogger } from \"../logger\";\n\ninterface YnsProviderConfig {\n\tversion: \"v1\";\n\tendpoint: string;\n\ttoken: string;\n}\n\nexport class YnsProvider {\n\t#config;\n\t#logger = getLogger(\"YnsProvider\");\n\tconstructor(config: YnsProviderConfig) {\n\t\tthis.#config = config;\n\t\tthis.#logger.debug(\"YnsProvider initialized\");\n\t}\n\n\tasync #restRequest<T>(\n\t\tpathname: `/${string}`,\n\t\tmethod: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" = \"GET\",\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst logger = this.#logger.getLogger(\"#restRequest\");\n\n\t\tconst endpoint = `${this.#config.endpoint}/api/${this.#config.version}${pathname}`;\n\t\tlogger.debug(`Making ${method} request to YNS API: ${endpoint}`);\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\tAuthorization: `Bearer ${this.#config.token}`,\n\t\t\t},\n\t\t\tbody: body ? JSON.stringify(body) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\t// Handle different error types\n\t\t\tconst contentType = response.headers.get(\"content-type\");\n\t\t\tlet errorMessage = `YNS REST request failed: ${method} ${endpoint} ${response.status} ${response.statusText}`;\n\n\t\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\t\ttry {\n\t\t\t\t\tconst errorData = await response.json();\n\t\t\t\t\terrorMessage = errorData.error || errorData.message || errorMessage;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(\"Failed to parse YNS error response as JSON\", error);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tlogger.error(\n\t\t\t\t\t`YNS API request failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\terrorMessage,\n\t\t\t\t\terrorText,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\n\t\t// Check if response is JSON before parsing\n\t\tconst contentType = response.headers.get(\"content-type\");\n\t\tif (!contentType?.includes(\"application/json\")) {\n\t\t\tthrow new Error(`YNS API returned ${contentType} instead of JSON for ${pathname}`);\n\t\t}\n\n\t\treturn response.json();\n\t}\n\n\tasync productBrowse(params: APIProductsBrowseQueryParams): Promise<APIProductsBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"productBrowse\");\n\t\tlogger.debug(\"Browsing products with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\t\tif (params.category) queryParams.append(\"category\", params.category);\n\t\tif (params.query) queryParams.append(\"query\", params.query);\n\t\tif (params.active !== undefined) queryParams.append(\"active\", params.active.toString());\n\t\tif (params.orderBy) queryParams.append(\"orderBy\", params.orderBy);\n\t\tif (params.orderDirection) queryParams.append(\"orderDirection\", params.orderDirection);\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/products${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIProductsBrowseResult>(pathname);\n\t\tlogger.debug(\"Received product browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync productGet(params: APIProductGetByIdParams): Promise<APIProductGetByIdResult | null> {\n\t\tconst pathname = `/products/${params.idOrSlug}` as const;\n\n\t\tconst result = await this.#restRequest<APIProductGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tasync orderBrowse(params: APIOrdersBrowseQueryParams): Promise<APIOrdersBrowseResult> {\n\t\tconst logger = this.#logger.getLogger(\"orderBrowse\");\n\t\tlogger.debug(\"Browsing orders with params:\", params);\n\n\t\tconst queryParams = new URLSearchParams();\n\n\t\tif (params.limit) queryParams.append(\"limit\", params.limit.toString());\n\t\tif (params.offset) queryParams.append(\"offset\", params.offset.toString());\n\n\t\tconst searchParams = queryParams.size ? `?${queryParams}` : \"\";\n\t\tconst pathname = `/orders${searchParams}` as const;\n\t\tlogger.debug(\"Constructed pathname:\", pathname);\n\t\tconst result = await this.#restRequest<APIOrdersBrowseResult>(pathname);\n\t\tlogger.debug(\"Received orders browse result:\", { meta: result.meta });\n\t\treturn result;\n\t}\n\n\tasync orderGet(params: APIOrderGetByIdParams): Promise<APIOrderGetByIdResult | null> {\n\t\tconst pathname = `/orders/${params.id}` as const;\n\n\t\tconst result = await this.#restRequest<APIOrderGetByIdResult>(pathname);\n\n\t\tif (!result) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// @todo\n\t// async cartAdd(params: APICartAddBody): Promise<APICartAddResult> {\n\t// \tconst body = {\n\t// \t\tvariantId: params.variantId,\n\t// \t\tcartId: params.cartId,\n\t// \t\tquantity: params.quantity,\n\t// \t\tsubscriptionId: params.subscriptionId,\n\t// \t};\n\n\t// \tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"PUT\", body);\n\t// \treturn result;\n\t// }\n\n\tasync cartUpsert(body: APICartCreateBody): Promise<APICartCreateResult> {\n\t\tconst result = await this.#restRequest<APICartCreateResult>(\"/carts\", \"POST\", body);\n\t\treturn result;\n\t}\n\n\tasync cartRemoveItem(params: { cartId: string; variantId: string }): Promise<null> {\n\t\tconst pathname = `/carts/${params.cartId}/line-items/${params.variantId}` as const;\n\t\tconst result = await this.#restRequest<unknown>(pathname, \"DELETE\");\n\t\t// return result;\n\t\treturn null;\n\t}\n\n\tasync cartGet(params: { cartId: string }): Promise<APICartGetResult | null> {\n\t\tconst pathname = `/carts/${params.cartId}` as const;\n\t\tconst result = await this.#restRequest<APICartGetResult>(pathname);\n\t\treturn result;\n\t}\n}\n"],"mappings":"4BAgBA,IAAMA,EAAW,CAChB,MAAO,EACP,IAAK,EACL,KAAM,EACN,MAAO,CACR,EAGMC,EAAe,QAAQ,IAAI,uBAAyB,MACpDC,EAAgBF,EAASC,CAAW,EAEpCE,EAAQ,UACRC,EAAO,WACPC,EAAQ,WACRC,EAAS,WACTC,EAAM,WAENC,EAAO,eACPC,EAAQ,YACRC,EAAK,eACLC,EAAO,eACPC,EAAQ,SAERC,EAAc,GAAGL,CAAI,IACrBM,EAAe,GAAGV,CAAI,GAAGK,CAAK,GAAGN,CAAK,IACtCY,EAAY,GAAGV,CAAK,GAAGK,CAAE,GAAGP,CAAK,IACjCa,EAAc,GAAGV,CAAM,GAAGK,CAAI,GAAGR,CAAK,IACtCc,EAAe,GAAGV,CAAG,GAAGK,CAAK,GAAGT,CAAK,IAE9Be,EAAaC,GAAwB,CACjD,IAAMC,EAASD,EAAa,IAAIA,CAAU,KAAO,GACjD,MAAO,CACN,UAAUE,EAAuB,CAChC,OAAOH,EAAU,CAACC,EAAYE,CAAa,EAAE,OAAO,OAAO,EAAE,KAAK,KAAK,CAAC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T,CAeA,MAAM,WAAWX,EAAuD,CAEvE,OADe,MAAM,KAAKH,GAAkC,SAAU,OAAQG,CAAI,CAEnF,CAEA,MAAM,eAAeS,EAA8D,CAClF,IAAMX,EAAW,UAAUW,EAAO,MAAM,eAAeA,EAAO,SAAS,GACjEE,EAAS,MAAM,KAAKd,GAAsBC,EAAU,QAAQ,EAElE,OAAO,IACR,CAEA,MAAM,QAAQW,EAA8D,CAC3E,IAAMX,EAAW,UAAUW,EAAO,MAAM,GAExC,OADe,MAAM,KAAKZ,GAA+BC,CAAQ,CAElE,CACD","names":["LogLevel","strLogLevel","valueLogLevel","RESET","BLUE","GREEN","YELLOW","RED","TIME","DEBUG","OK","WARN","ERROR","PREFIX_TIME","PREFIX_DEBUG","PREFIX_OK","PREFIX_WARN","PREFIX_ERROR","getLogger","groupLabel","PREFIX","subGroupLabel","label","args","item","options","logger","YnsProvider","#config","#logger","getLogger","config","#restRequest","pathname","method","body","logger","endpoint","response","contentType","errorMessage","errorData","error","errorText","params","queryParams","result"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "commerce-kit",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"keywords": [
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"prepare": "husky"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@biomejs/biome": "2.
|
|
43
|
+
"@biomejs/biome": "2.3.8",
|
|
44
44
|
"@types/node": "^24.3.1",
|
|
45
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
45
|
+
"@typescript/native-preview": "7.0.0-dev.20251129.1",
|
|
46
46
|
"husky": "9.1.7",
|
|
47
|
-
"lint-staged": "16.2.
|
|
48
|
-
"rimraf": "6.
|
|
49
|
-
"tsup": "8.5.
|
|
47
|
+
"lint-staged": "16.2.7",
|
|
48
|
+
"rimraf": "6.1.2",
|
|
49
|
+
"tsup": "8.5.1",
|
|
50
50
|
"tsx": "^4.20.5",
|
|
51
51
|
"typescript": "5.9.3",
|
|
52
52
|
"zod": "^4.1.5"
|