@01.software/sdk 0.4.0 → 0.4.2

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 (39) hide show
  1. package/dist/auth.d.cts +1 -1
  2. package/dist/auth.d.ts +1 -1
  3. package/dist/{const-BpirbGBD.d.cts → const-CWZ70tFe.d.cts} +1 -1
  4. package/dist/{const-qZSQiSSC.d.ts → const-nftKBzYp.d.ts} +1 -1
  5. package/dist/index.cjs +73 -9
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +6 -6
  8. package/dist/index.d.ts +6 -6
  9. package/dist/index.js +73 -9
  10. package/dist/index.js.map +1 -1
  11. package/dist/{payload-types-CZiaL4Wr.d.cts → payload-types-BbEEk9Ji.d.cts} +68 -3
  12. package/dist/{payload-types-CZiaL4Wr.d.ts → payload-types-BbEEk9Ji.d.ts} +68 -3
  13. package/dist/realtime.cjs +5 -3
  14. package/dist/realtime.cjs.map +1 -1
  15. package/dist/realtime.d.cts +2 -2
  16. package/dist/realtime.d.ts +2 -2
  17. package/dist/realtime.js +5 -3
  18. package/dist/realtime.js.map +1 -1
  19. package/dist/ui/flow.cjs +264 -36
  20. package/dist/ui/flow.cjs.map +1 -1
  21. package/dist/ui/flow.d.cts +105 -4
  22. package/dist/ui/flow.d.ts +105 -4
  23. package/dist/ui/flow.js +252 -21
  24. package/dist/ui/flow.js.map +1 -1
  25. package/dist/ui/form.d.cts +1 -1
  26. package/dist/ui/form.d.ts +1 -1
  27. package/dist/ui/rich-text.cjs +8 -1
  28. package/dist/ui/rich-text.cjs.map +1 -1
  29. package/dist/ui/rich-text.d.cts +20 -1
  30. package/dist/ui/rich-text.d.ts +20 -1
  31. package/dist/ui/rich-text.js +8 -1
  32. package/dist/ui/rich-text.js.map +1 -1
  33. package/dist/ui/video.d.cts +1 -1
  34. package/dist/ui/video.d.ts +1 -1
  35. package/dist/{webhook-DuTqrH9x.d.ts → webhook-C4nmpBmQ.d.ts} +2 -2
  36. package/dist/{webhook-3iL9OEyq.d.cts → webhook-DRGm9rPn.d.cts} +2 -2
  37. package/dist/webhook.d.cts +3 -3
  38. package/dist/webhook.d.ts +3 -3
  39. package/package.json +2 -1
@@ -341,6 +341,10 @@ interface Tenant {
341
341
  * Require email verification on customer registration. Verification token is delivered via webhook (operation: verification). You must configure a webhook URL first.
342
342
  */
343
343
  requireEmailVerification?: boolean | null;
344
+ /**
345
+ * Dev mode shows configuration tools like the field settings panel. Turn off after setup for a clean production UI.
346
+ */
347
+ devMode?: boolean | null;
344
348
  /**
345
349
  * Allowed CORS origins for browser SDK requests. Empty = all origins allowed.
346
350
  */
@@ -383,7 +387,7 @@ interface Tenant {
383
387
  interface FieldConfig {
384
388
  id: string;
385
389
  tenant?: (string | null) | Tenant;
386
- collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'customers' | 'customer-groups' | 'carts' | 'transactions' | 'returns' | 'exchanges' | 'post-authors' | 'documents' | 'posts' | 'post-categories' | 'post-tags' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'document-categories' | 'document-types' | 'flows' | 'flow-categories' | 'flow-tags' | 'flow-node-types' | 'flow-edge-types' | 'forms' | 'musics' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams';
390
+ collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'customers' | 'customer-groups' | 'carts' | 'transactions' | 'returns' | 'exchanges' | 'post-authors' | 'posts' | 'post-categories' | 'post-tags' | 'documents' | 'document-categories' | 'document-types' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'musics' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'flows' | 'flow-categories' | 'flow-tags' | 'flow-node-types' | 'flow-edge-types' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams' | 'forms';
387
391
  isHidden?: boolean | null;
388
392
  hiddenFields?: {
389
393
  [k: string]: unknown;
@@ -1302,6 +1306,9 @@ interface VideoCategory {
1302
1306
  */
1303
1307
  generateSlug?: boolean | null;
1304
1308
  slug?: string | null;
1309
+ /**
1310
+ * Short summary for listing/cards
1311
+ */
1305
1312
  description?: string | null;
1306
1313
  image?: (string | null) | Image;
1307
1314
  parent?: (string | null) | VideoCategory;
@@ -1324,6 +1331,9 @@ interface VideoTag {
1324
1331
  */
1325
1332
  generateSlug?: boolean | null;
1326
1333
  slug?: string | null;
1334
+ /**
1335
+ * Short summary for listing/cards
1336
+ */
1327
1337
  description?: string | null;
1328
1338
  image?: (string | null) | Image;
1329
1339
  parent?: (string | null) | VideoTag;
@@ -1450,6 +1460,9 @@ interface ProductCategory {
1450
1460
  */
1451
1461
  generateSlug?: boolean | null;
1452
1462
  slug?: string | null;
1463
+ /**
1464
+ * Short summary for listing/cards
1465
+ */
1453
1466
  description?: string | null;
1454
1467
  image?: (string | null) | Image;
1455
1468
  parent?: (string | null) | ProductCategory;
@@ -1472,6 +1485,9 @@ interface ProductTag {
1472
1485
  */
1473
1486
  generateSlug?: boolean | null;
1474
1487
  slug?: string | null;
1488
+ /**
1489
+ * Short summary for listing/cards
1490
+ */
1475
1491
  description?: string | null;
1476
1492
  image?: (string | null) | Image;
1477
1493
  parent?: (string | null) | ProductTag;
@@ -1490,7 +1506,7 @@ interface Brand {
1490
1506
  tenant?: (string | null) | Tenant;
1491
1507
  name: string;
1492
1508
  /**
1493
- * Short intro for listing/cards
1509
+ * Short summary for listing/cards
1494
1510
  */
1495
1511
  description?: string | null;
1496
1512
  content?: {
@@ -1810,6 +1826,9 @@ interface CustomerGroup {
1810
1826
  */
1811
1827
  generateSlug?: boolean | null;
1812
1828
  slug?: string | null;
1829
+ /**
1830
+ * Short summary for listing/cards
1831
+ */
1813
1832
  description?: string | null;
1814
1833
  color?: string | null;
1815
1834
  image?: (string | null) | Image;
@@ -2213,7 +2232,7 @@ interface Post {
2213
2232
  title: string;
2214
2233
  subtitle?: string | null;
2215
2234
  /**
2216
- * Brief summary for listing pages
2235
+ * Short summary for listing/cards
2217
2236
  */
2218
2237
  description?: string | null;
2219
2238
  content?: {
@@ -2332,6 +2351,9 @@ interface PostCategory {
2332
2351
  */
2333
2352
  generateSlug?: boolean | null;
2334
2353
  slug?: string | null;
2354
+ /**
2355
+ * Short summary for listing/cards
2356
+ */
2335
2357
  description?: string | null;
2336
2358
  image?: (string | null) | Image;
2337
2359
  parent?: (string | null) | PostCategory;
@@ -2354,6 +2376,9 @@ interface PostTag {
2354
2376
  */
2355
2377
  generateSlug?: boolean | null;
2356
2378
  slug?: string | null;
2379
+ /**
2380
+ * Short summary for listing/cards
2381
+ */
2357
2382
  description?: string | null;
2358
2383
  image?: (string | null) | Image;
2359
2384
  parent?: (string | null) | PostTag;
@@ -2371,6 +2396,9 @@ interface Document {
2371
2396
  _order?: string | null;
2372
2397
  tenant?: (string | null) | Tenant;
2373
2398
  title: string;
2399
+ /**
2400
+ * Short summary for listing/cards
2401
+ */
2374
2402
  description?: string | null;
2375
2403
  content: {
2376
2404
  root: {
@@ -2480,6 +2508,9 @@ interface DocumentType {
2480
2508
  */
2481
2509
  generateSlug?: boolean | null;
2482
2510
  slug?: string | null;
2511
+ /**
2512
+ * Short summary for listing/cards
2513
+ */
2483
2514
  description?: string | null;
2484
2515
  image?: (string | null) | Image;
2485
2516
  color?: string | null;
@@ -2501,6 +2532,9 @@ interface DocumentCategory {
2501
2532
  */
2502
2533
  generateSlug?: boolean | null;
2503
2534
  slug?: string | null;
2535
+ /**
2536
+ * Short summary for listing/cards
2537
+ */
2504
2538
  description?: string | null;
2505
2539
  image?: (string | null) | Image;
2506
2540
  parent?: (string | null) | DocumentCategory;
@@ -2518,6 +2552,9 @@ interface Playlist {
2518
2552
  _order?: string | null;
2519
2553
  tenant?: (string | null) | Tenant;
2520
2554
  title: string;
2555
+ /**
2556
+ * Short summary for listing/cards
2557
+ */
2521
2558
  description?: string | null;
2522
2559
  videos?: (string | Video)[] | null;
2523
2560
  categories?: (string | PlaylistCategory)[] | null;
@@ -2593,6 +2630,9 @@ interface PlaylistCategory {
2593
2630
  */
2594
2631
  generateSlug?: boolean | null;
2595
2632
  slug?: string | null;
2633
+ /**
2634
+ * Short summary for listing/cards
2635
+ */
2596
2636
  description?: string | null;
2597
2637
  image?: (string | null) | Image;
2598
2638
  parent?: (string | null) | PlaylistCategory;
@@ -2615,6 +2655,9 @@ interface PlaylistTag {
2615
2655
  */
2616
2656
  generateSlug?: boolean | null;
2617
2657
  slug?: string | null;
2658
+ /**
2659
+ * Short summary for listing/cards
2660
+ */
2618
2661
  description?: string | null;
2619
2662
  image?: (string | null) | Image;
2620
2663
  parent?: (string | null) | PlaylistTag;
@@ -2666,6 +2709,9 @@ interface Gallery {
2666
2709
  _order?: string | null;
2667
2710
  tenant?: (string | null) | Tenant;
2668
2711
  title: string;
2712
+ /**
2713
+ * Short summary for listing/cards
2714
+ */
2669
2715
  description?: string | null;
2670
2716
  videos?: (string | Video)[] | null;
2671
2717
  categories?: (string | GalleryCategory)[] | null;
@@ -2737,6 +2783,9 @@ interface GalleryCategory {
2737
2783
  */
2738
2784
  generateSlug?: boolean | null;
2739
2785
  slug?: string | null;
2786
+ /**
2787
+ * Short summary for listing/cards
2788
+ */
2740
2789
  description?: string | null;
2741
2790
  image?: (string | null) | Image;
2742
2791
  parent?: (string | null) | GalleryCategory;
@@ -2759,6 +2808,9 @@ interface GalleryTag {
2759
2808
  */
2760
2809
  generateSlug?: boolean | null;
2761
2810
  slug?: string | null;
2811
+ /**
2812
+ * Short summary for listing/cards
2813
+ */
2762
2814
  description?: string | null;
2763
2815
  image?: (string | null) | Image;
2764
2816
  parent?: (string | null) | GalleryTag;
@@ -2805,6 +2857,9 @@ interface Flow {
2805
2857
  id: string;
2806
2858
  tenant?: (string | null) | Tenant;
2807
2859
  title: string;
2860
+ /**
2861
+ * Short summary for listing/cards
2862
+ */
2808
2863
  description?: string | null;
2809
2864
  videos?: (string | Video)[] | null;
2810
2865
  canvas: {
@@ -2875,6 +2930,9 @@ interface FlowCategory {
2875
2930
  */
2876
2931
  generateSlug?: boolean | null;
2877
2932
  slug?: string | null;
2933
+ /**
2934
+ * Short summary for listing/cards
2935
+ */
2878
2936
  description?: string | null;
2879
2937
  image?: (string | null) | Image;
2880
2938
  parent?: (string | null) | FlowCategory;
@@ -2897,6 +2955,9 @@ interface FlowTag {
2897
2955
  */
2898
2956
  generateSlug?: boolean | null;
2899
2957
  slug?: string | null;
2958
+ /**
2959
+ * Short summary for listing/cards
2960
+ */
2900
2961
  description?: string | null;
2901
2962
  image?: (string | null) | Image;
2902
2963
  parent?: (string | null) | FlowTag;
@@ -3011,6 +3072,9 @@ interface Form {
3011
3072
  _order?: string | null;
3012
3073
  tenant?: (string | null) | Tenant;
3013
3074
  title: string;
3075
+ /**
3076
+ * Short summary for listing/cards
3077
+ */
3014
3078
  description?: string | null;
3015
3079
  status: 'active' | 'inactive';
3016
3080
  /**
@@ -3614,6 +3678,7 @@ interface TenantsSelect<T extends boolean = true> {
3614
3678
  plan?: T;
3615
3679
  features?: T;
3616
3680
  requireEmailVerification?: T;
3681
+ devMode?: T;
3617
3682
  cors?: T | {
3618
3683
  origin?: T;
3619
3684
  id?: T;
@@ -341,6 +341,10 @@ interface Tenant {
341
341
  * Require email verification on customer registration. Verification token is delivered via webhook (operation: verification). You must configure a webhook URL first.
342
342
  */
343
343
  requireEmailVerification?: boolean | null;
344
+ /**
345
+ * Dev mode shows configuration tools like the field settings panel. Turn off after setup for a clean production UI.
346
+ */
347
+ devMode?: boolean | null;
344
348
  /**
345
349
  * Allowed CORS origins for browser SDK requests. Empty = all origins allowed.
346
350
  */
@@ -383,7 +387,7 @@ interface Tenant {
383
387
  interface FieldConfig {
384
388
  id: string;
385
389
  tenant?: (string | null) | Tenant;
386
- collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'customers' | 'customer-groups' | 'carts' | 'transactions' | 'returns' | 'exchanges' | 'post-authors' | 'documents' | 'posts' | 'post-categories' | 'post-tags' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'document-categories' | 'document-types' | 'flows' | 'flow-categories' | 'flow-tags' | 'flow-node-types' | 'flow-edge-types' | 'forms' | 'musics' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams';
390
+ collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'customers' | 'customer-groups' | 'carts' | 'transactions' | 'returns' | 'exchanges' | 'post-authors' | 'posts' | 'post-categories' | 'post-tags' | 'documents' | 'document-categories' | 'document-types' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'musics' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'flows' | 'flow-categories' | 'flow-tags' | 'flow-node-types' | 'flow-edge-types' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams' | 'forms';
387
391
  isHidden?: boolean | null;
388
392
  hiddenFields?: {
389
393
  [k: string]: unknown;
@@ -1302,6 +1306,9 @@ interface VideoCategory {
1302
1306
  */
1303
1307
  generateSlug?: boolean | null;
1304
1308
  slug?: string | null;
1309
+ /**
1310
+ * Short summary for listing/cards
1311
+ */
1305
1312
  description?: string | null;
1306
1313
  image?: (string | null) | Image;
1307
1314
  parent?: (string | null) | VideoCategory;
@@ -1324,6 +1331,9 @@ interface VideoTag {
1324
1331
  */
1325
1332
  generateSlug?: boolean | null;
1326
1333
  slug?: string | null;
1334
+ /**
1335
+ * Short summary for listing/cards
1336
+ */
1327
1337
  description?: string | null;
1328
1338
  image?: (string | null) | Image;
1329
1339
  parent?: (string | null) | VideoTag;
@@ -1450,6 +1460,9 @@ interface ProductCategory {
1450
1460
  */
1451
1461
  generateSlug?: boolean | null;
1452
1462
  slug?: string | null;
1463
+ /**
1464
+ * Short summary for listing/cards
1465
+ */
1453
1466
  description?: string | null;
1454
1467
  image?: (string | null) | Image;
1455
1468
  parent?: (string | null) | ProductCategory;
@@ -1472,6 +1485,9 @@ interface ProductTag {
1472
1485
  */
1473
1486
  generateSlug?: boolean | null;
1474
1487
  slug?: string | null;
1488
+ /**
1489
+ * Short summary for listing/cards
1490
+ */
1475
1491
  description?: string | null;
1476
1492
  image?: (string | null) | Image;
1477
1493
  parent?: (string | null) | ProductTag;
@@ -1490,7 +1506,7 @@ interface Brand {
1490
1506
  tenant?: (string | null) | Tenant;
1491
1507
  name: string;
1492
1508
  /**
1493
- * Short intro for listing/cards
1509
+ * Short summary for listing/cards
1494
1510
  */
1495
1511
  description?: string | null;
1496
1512
  content?: {
@@ -1810,6 +1826,9 @@ interface CustomerGroup {
1810
1826
  */
1811
1827
  generateSlug?: boolean | null;
1812
1828
  slug?: string | null;
1829
+ /**
1830
+ * Short summary for listing/cards
1831
+ */
1813
1832
  description?: string | null;
1814
1833
  color?: string | null;
1815
1834
  image?: (string | null) | Image;
@@ -2213,7 +2232,7 @@ interface Post {
2213
2232
  title: string;
2214
2233
  subtitle?: string | null;
2215
2234
  /**
2216
- * Brief summary for listing pages
2235
+ * Short summary for listing/cards
2217
2236
  */
2218
2237
  description?: string | null;
2219
2238
  content?: {
@@ -2332,6 +2351,9 @@ interface PostCategory {
2332
2351
  */
2333
2352
  generateSlug?: boolean | null;
2334
2353
  slug?: string | null;
2354
+ /**
2355
+ * Short summary for listing/cards
2356
+ */
2335
2357
  description?: string | null;
2336
2358
  image?: (string | null) | Image;
2337
2359
  parent?: (string | null) | PostCategory;
@@ -2354,6 +2376,9 @@ interface PostTag {
2354
2376
  */
2355
2377
  generateSlug?: boolean | null;
2356
2378
  slug?: string | null;
2379
+ /**
2380
+ * Short summary for listing/cards
2381
+ */
2357
2382
  description?: string | null;
2358
2383
  image?: (string | null) | Image;
2359
2384
  parent?: (string | null) | PostTag;
@@ -2371,6 +2396,9 @@ interface Document {
2371
2396
  _order?: string | null;
2372
2397
  tenant?: (string | null) | Tenant;
2373
2398
  title: string;
2399
+ /**
2400
+ * Short summary for listing/cards
2401
+ */
2374
2402
  description?: string | null;
2375
2403
  content: {
2376
2404
  root: {
@@ -2480,6 +2508,9 @@ interface DocumentType {
2480
2508
  */
2481
2509
  generateSlug?: boolean | null;
2482
2510
  slug?: string | null;
2511
+ /**
2512
+ * Short summary for listing/cards
2513
+ */
2483
2514
  description?: string | null;
2484
2515
  image?: (string | null) | Image;
2485
2516
  color?: string | null;
@@ -2501,6 +2532,9 @@ interface DocumentCategory {
2501
2532
  */
2502
2533
  generateSlug?: boolean | null;
2503
2534
  slug?: string | null;
2535
+ /**
2536
+ * Short summary for listing/cards
2537
+ */
2504
2538
  description?: string | null;
2505
2539
  image?: (string | null) | Image;
2506
2540
  parent?: (string | null) | DocumentCategory;
@@ -2518,6 +2552,9 @@ interface Playlist {
2518
2552
  _order?: string | null;
2519
2553
  tenant?: (string | null) | Tenant;
2520
2554
  title: string;
2555
+ /**
2556
+ * Short summary for listing/cards
2557
+ */
2521
2558
  description?: string | null;
2522
2559
  videos?: (string | Video)[] | null;
2523
2560
  categories?: (string | PlaylistCategory)[] | null;
@@ -2593,6 +2630,9 @@ interface PlaylistCategory {
2593
2630
  */
2594
2631
  generateSlug?: boolean | null;
2595
2632
  slug?: string | null;
2633
+ /**
2634
+ * Short summary for listing/cards
2635
+ */
2596
2636
  description?: string | null;
2597
2637
  image?: (string | null) | Image;
2598
2638
  parent?: (string | null) | PlaylistCategory;
@@ -2615,6 +2655,9 @@ interface PlaylistTag {
2615
2655
  */
2616
2656
  generateSlug?: boolean | null;
2617
2657
  slug?: string | null;
2658
+ /**
2659
+ * Short summary for listing/cards
2660
+ */
2618
2661
  description?: string | null;
2619
2662
  image?: (string | null) | Image;
2620
2663
  parent?: (string | null) | PlaylistTag;
@@ -2666,6 +2709,9 @@ interface Gallery {
2666
2709
  _order?: string | null;
2667
2710
  tenant?: (string | null) | Tenant;
2668
2711
  title: string;
2712
+ /**
2713
+ * Short summary for listing/cards
2714
+ */
2669
2715
  description?: string | null;
2670
2716
  videos?: (string | Video)[] | null;
2671
2717
  categories?: (string | GalleryCategory)[] | null;
@@ -2737,6 +2783,9 @@ interface GalleryCategory {
2737
2783
  */
2738
2784
  generateSlug?: boolean | null;
2739
2785
  slug?: string | null;
2786
+ /**
2787
+ * Short summary for listing/cards
2788
+ */
2740
2789
  description?: string | null;
2741
2790
  image?: (string | null) | Image;
2742
2791
  parent?: (string | null) | GalleryCategory;
@@ -2759,6 +2808,9 @@ interface GalleryTag {
2759
2808
  */
2760
2809
  generateSlug?: boolean | null;
2761
2810
  slug?: string | null;
2811
+ /**
2812
+ * Short summary for listing/cards
2813
+ */
2762
2814
  description?: string | null;
2763
2815
  image?: (string | null) | Image;
2764
2816
  parent?: (string | null) | GalleryTag;
@@ -2805,6 +2857,9 @@ interface Flow {
2805
2857
  id: string;
2806
2858
  tenant?: (string | null) | Tenant;
2807
2859
  title: string;
2860
+ /**
2861
+ * Short summary for listing/cards
2862
+ */
2808
2863
  description?: string | null;
2809
2864
  videos?: (string | Video)[] | null;
2810
2865
  canvas: {
@@ -2875,6 +2930,9 @@ interface FlowCategory {
2875
2930
  */
2876
2931
  generateSlug?: boolean | null;
2877
2932
  slug?: string | null;
2933
+ /**
2934
+ * Short summary for listing/cards
2935
+ */
2878
2936
  description?: string | null;
2879
2937
  image?: (string | null) | Image;
2880
2938
  parent?: (string | null) | FlowCategory;
@@ -2897,6 +2955,9 @@ interface FlowTag {
2897
2955
  */
2898
2956
  generateSlug?: boolean | null;
2899
2957
  slug?: string | null;
2958
+ /**
2959
+ * Short summary for listing/cards
2960
+ */
2900
2961
  description?: string | null;
2901
2962
  image?: (string | null) | Image;
2902
2963
  parent?: (string | null) | FlowTag;
@@ -3011,6 +3072,9 @@ interface Form {
3011
3072
  _order?: string | null;
3012
3073
  tenant?: (string | null) | Tenant;
3013
3074
  title: string;
3075
+ /**
3076
+ * Short summary for listing/cards
3077
+ */
3014
3078
  description?: string | null;
3015
3079
  status: 'active' | 'inactive';
3016
3080
  /**
@@ -3614,6 +3678,7 @@ interface TenantsSelect<T extends boolean = true> {
3614
3678
  plan?: T;
3615
3679
  features?: T;
3616
3680
  requireEmailVerification?: T;
3681
+ devMode?: T;
3617
3682
  cors?: T | {
3618
3683
  origin?: T;
3619
3684
  id?: T;
package/dist/realtime.cjs CHANGED
@@ -202,9 +202,11 @@ var RealtimeConnection = class {
202
202
 
203
203
  // src/core/client/types.ts
204
204
  function resolveApiUrl() {
205
- const envUrl = process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL;
206
- if (envUrl) {
207
- return envUrl.replace(/\/$/, "");
205
+ if (typeof process !== "undefined" && process.env) {
206
+ const envUrl = process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL;
207
+ if (envUrl) {
208
+ return envUrl.replace(/\/$/, "");
209
+ }
208
210
  }
209
211
  return "https://api.01.software";
210
212
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/realtime.ts","../src/core/query/realtime-hooks.ts","../src/core/query/realtime.ts","../src/core/client/types.ts","../src/core/query/query-keys.ts"],"sourcesContent":["export { useRealtimeQuery } from './core/query/realtime-hooks'\nexport type {\n UseRealtimeQueryOptions,\n UseRealtimeQueryResult,\n RealtimeEvent,\n} from './core/query/realtime-hooks'\nexport { RealtimeConnection, type RealtimeListener } from './core/query/realtime'\n","import { useEffect, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { RealtimeConnection, type RealtimeEvent } from './realtime'\nimport { resolveApiUrl, type PublicCollection } from '../client/types'\nimport { collectionKeys } from './query-keys'\n\nexport type { RealtimeEvent }\n\nexport interface UseRealtimeQueryOptions {\n /** Filter events to specific collections. Empty/undefined = all collections. */\n collections?: PublicCollection[]\n /** Enable/disable the SSE connection. Default: true. */\n enabled?: boolean\n}\n\nexport interface UseRealtimeQueryResult {\n /** Whether the SSE connection is currently active. */\n connected: boolean\n /** The last received event, or null. */\n lastEvent: RealtimeEvent | null\n}\n\n/**\n * React hook that subscribes to real-time collection change events via SSE.\n * Automatically invalidates React Query cache when changes are detected.\n *\n * @example\n * ```tsx\n * const { connected } = useRealtimeQuery({\n * clientKey: 'your-key',\n * getToken: () => client.customer.getToken(),\n * collections: ['products', 'orders'],\n * })\n * ```\n */\nexport function useRealtimeQuery(options: {\n clientKey: string\n getToken: () => string | null\n collections?: PublicCollection[]\n enabled?: boolean\n}): UseRealtimeQueryResult {\n const { clientKey, getToken, collections, enabled = true } = options\n const queryClient = useQueryClient()\n const [connected, setConnected] = useState(false)\n const [lastEvent, setLastEvent] = useState<RealtimeEvent | null>(null)\n const connectionRef = useRef<RealtimeConnection | null>(null)\n\n useEffect(() => {\n if (!enabled || !clientKey) return\n\n const baseUrl = resolveApiUrl()\n const conn = new RealtimeConnection(\n baseUrl,\n clientKey,\n getToken,\n collections,\n )\n connectionRef.current = conn\n\n // Listen for events and invalidate queries\n const removeListener = conn.addListener((event) => {\n setLastEvent(event)\n\n // Invalidate all queries for the changed collection\n const keys = collectionKeys(event.collection as PublicCollection)\n queryClient.invalidateQueries({ queryKey: keys.all })\n })\n\n // Track connection state\n const pollInterval = setInterval(() => {\n setConnected(conn.connected)\n }, 1000)\n\n conn.connect()\n\n return () => {\n conn.disconnect()\n removeListener()\n clearInterval(pollInterval)\n connectionRef.current = null\n setConnected(false)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clientKey, enabled, collections?.join(',')])\n\n return { connected, lastEvent }\n}\n","/**\n * Fetch-based SSE connection manager for real-time collection change events.\n * Uses fetch + ReadableStream to support custom auth headers (unlike native EventSource).\n */\n\nexport interface RealtimeEvent {\n collection: string\n operation: string\n id: string | null\n timestamp: string\n}\n\nexport type RealtimeListener = (event: RealtimeEvent) => void\n\nconst INITIAL_RECONNECT_DELAY = 1_000\nconst MAX_RECONNECT_DELAY = 30_000\nconst RECONNECT_BACKOFF_FACTOR = 2\nconst MAX_NO_TOKEN_RETRIES = 5\n\nexport class RealtimeConnection {\n private abortController: AbortController | null = null\n private reconnectAttempt = 0\n private noTokenAttempts = 0\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null\n private listeners = new Set<RealtimeListener>()\n private _connected = false\n\n constructor(\n private baseUrl: string,\n private clientKey: string,\n private getToken: () => string | null,\n private collections?: string[],\n ) {}\n\n get connected(): boolean {\n return this._connected\n }\n\n addListener(fn: RealtimeListener): () => void {\n this.listeners.add(fn)\n return () => this.listeners.delete(fn)\n }\n\n connect(): void {\n if (this.abortController) return // Already connecting/connected\n\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }\n\n disconnect(): void {\n this._connected = false\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer)\n this.reconnectTimer = null\n }\n if (this.abortController) {\n this.abortController.abort()\n this.abortController = null\n }\n this.reconnectAttempt = 0\n this.noTokenAttempts = 0\n }\n\n private async startStream(signal: AbortSignal): Promise<void> {\n const token = this.getToken()\n if (!token) {\n this.noTokenAttempts++\n if (this.noTokenAttempts >= MAX_NO_TOKEN_RETRIES) {\n // Stop reconnecting — no token available after multiple attempts\n this._connected = false\n this.abortController = null\n return\n }\n this.scheduleReconnect()\n return\n }\n this.noTokenAttempts = 0\n\n const params = this.collections?.length\n ? `?collections=${this.collections.join(',')}`\n : ''\n const url = `${this.baseUrl}/api/events/stream${params}`\n\n try {\n const response = await fetch(url, {\n headers: {\n 'X-Client-Key': this.clientKey,\n Authorization: `Bearer ${token}`,\n },\n signal,\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n // Token expired — try reconnecting (will get fresh token)\n this.scheduleReconnect()\n return\n }\n throw new Error(`SSE connection failed: ${response.status}`)\n }\n\n if (!response.body) {\n throw new Error('SSE response has no body')\n }\n\n this._connected = true\n this.reconnectAttempt = 0\n\n await this.readStream(response.body, signal)\n } catch {\n if (signal.aborted) return // Intentional disconnect\n this._connected = false\n this.scheduleReconnect()\n }\n }\n\n private async readStream(\n body: ReadableStream<Uint8Array>,\n signal: AbortSignal,\n ): Promise<void> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let currentEvent = ''\n let currentData = ''\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done || signal.aborted) break\n\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? '' // Keep incomplete last line in buffer\n\n for (const line of lines) {\n if (line.startsWith('event: ')) {\n currentEvent = line.slice(7)\n } else if (line.startsWith('data: ')) {\n currentData += (currentData ? '\\n' : '') + line.slice(6)\n } else if (line === '') {\n // Empty line = end of event\n if (currentEvent === 'collection:change' && currentData) {\n try {\n const event: RealtimeEvent = JSON.parse(currentData)\n for (const listener of this.listeners) {\n try {\n listener(event)\n } catch {\n // Listener error — ignore\n }\n }\n } catch {\n // Malformed JSON — ignore\n }\n }\n currentEvent = ''\n currentData = ''\n }\n // Ignore comment lines (: heartbeat)\n }\n }\n } catch {\n // Stream read error\n } finally {\n reader.releaseLock()\n this._connected = false\n if (!signal.aborted) {\n this.scheduleReconnect()\n }\n }\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer) return\n\n const delay = Math.min(\n INITIAL_RECONNECT_DELAY *\n Math.pow(RECONNECT_BACKOFF_FACTOR, this.reconnectAttempt),\n MAX_RECONNECT_DELAY,\n )\n this.reconnectAttempt++\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }, delay)\n }\n}\n","import type { Sort, Where } from 'payload'\n\nimport type { Collection, PublicCollection } from '../collection/const'\n\nexport type { Collection, PublicCollection }\n\n// ============================================================================\n// API URL Configuration\n// ============================================================================\n\ndeclare const __DEFAULT_API_URL__: string\n\n/**\n * API URL을 반환합니다.\n * 환경변수 SOFTWARE_API_URL 또는 NEXT_PUBLIC_SOFTWARE_API_URL로 오버라이드 가능.\n * 빌드 시 버전에 따라 기본값 결정: dev 빌드 → api-dev, 정식 → api.01.software\n */\nexport function resolveApiUrl(): string {\n const envUrl =\n process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL\n if (envUrl) {\n return envUrl.replace(/\\/$/, '')\n }\n return __DEFAULT_API_URL__\n}\n\n// ============================================================================\n// Client Configuration\n// ============================================================================\n\nexport interface ClientBrowserConfig {\n clientKey: string\n /**\n * Customer authentication options.\n * Used to initialize CustomerAuth on BrowserClient.\n */\n customer?: {\n /**\n * Persist token in localStorage. Defaults to `true`.\n * - `true` (default): uses key `'customer-token'`\n * - `string`: uses the given string as localStorage key\n * - `false`: disables persistence (token/onTokenChange used instead)\n *\n * Handles SSR safely (no-op on server).\n * When enabled, `token` and `onTokenChange` are ignored.\n */\n persist?: boolean | string\n /** Initial token (e.g. from SSR cookie) */\n token?: string\n /** Called when token changes (login/logout) — use to persist in localStorage/cookie */\n onTokenChange?: (token: string | null) => void\n }\n}\n\nexport interface ClientServerConfig extends ClientBrowserConfig {\n secretKey: string\n}\n\nexport interface ClientMetadata {\n userAgent?: string\n timestamp: number\n}\n\nexport interface ClientState {\n metadata: ClientMetadata\n}\n\n// ============================================================================\n// API Response Types\n// ============================================================================\n\nexport interface PaginationMeta {\n page: number\n limit: number\n totalDocs: number\n totalPages: number\n hasNextPage: boolean\n hasPrevPage: boolean\n pagingCounter: number\n prevPage: number | null\n nextPage: number | null\n}\n\n// ============================================================================\n// Payload CMS Native Response Types\n// ============================================================================\n\n/**\n * Payload CMS Find (List) Response\n * GET /api/{collection}\n */\nexport interface PayloadFindResponse<T = unknown> {\n docs: T[]\n totalDocs: number\n limit: number\n totalPages: number\n page: number\n pagingCounter: number\n hasPrevPage: boolean\n hasNextPage: boolean\n prevPage: number | null\n nextPage: number | null\n}\n\n/**\n * Payload CMS Create/Update Response\n * POST /api/{collection}\n * PATCH /api/{collection}/{id}\n */\nexport interface PayloadMutationResponse<T = unknown> {\n message: string\n doc: T\n errors?: unknown[]\n}\n\n// ============================================================================\n// Query Options\n// ============================================================================\n\nexport interface ApiQueryOptions {\n page?: number\n limit?: number\n sort?: Sort\n where?: Where\n depth?: number\n select?: Record<string, boolean>\n}\n\nexport interface ApiQueryReactOptions {\n keepPreviousData?: boolean\n}\n\n// ============================================================================\n// Debug & Retry Configuration\n// ============================================================================\n\nexport interface DebugConfig {\n logRequests?: boolean\n logResponses?: boolean\n logErrors?: boolean\n}\n\nexport interface RetryConfig {\n maxRetries?: number\n retryableStatuses?: number[]\n retryDelay?: (attempt: number) => number\n}\n\n\n// ============================================================================\n// Collection Types (re-exported from collection/const)\n// ============================================================================\n\n// ============================================================================\n// Type Utilities\n// ============================================================================\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]\n}\n\nexport type ExtractArrayType<T> = T extends (infer U)[] ? U : never\n","import type { PublicCollection, ApiQueryOptions } from '../client/types'\n\nexport function collectionKeys<T extends PublicCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>) =>\n [collection, 'infinite', options] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4C;AAC5C,yBAA+B;;;ACa/B,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAC5B,IAAM,2BAA2B;AACjC,IAAM,uBAAuB;AAEtB,IAAM,qBAAN,MAAyB;AAAA,EAQ9B,YACU,SACA,WACA,UACA,aACR;AAJQ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BO,SAAS,iBAAiB,SAKN;AACzB,QAAM,EAAE,WAAW,UAAU,aAAa,UAAU,KAAK,IAAI;AAC7D,QAAM,kBAAc,mCAAe;AACnC,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,CAAC,WAAW,YAAY,QAAI,uBAA+B,IAAI;AACrE,QAAM,oBAAgB,qBAAkC,IAAI;AAE5D,8BAAU,MAAM;AACd,QAAI,CAAC,WAAW,CAAC,UAAW;AAE5B,UAAM,UAAU,cAAc;AAC9B,UAAM,OAAO,IAAI;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,kBAAc,UAAU;AAGxB,UAAM,iBAAiB,KAAK,YAAY,CAAC,UAAU;AACjD,mBAAa,KAAK;AAGlB,YAAM,OAAO,eAAe,MAAM,UAA8B;AAChE,kBAAY,kBAAkB,EAAE,UAAU,KAAK,IAAI,CAAC;AAAA,IACtD,CAAC;AAGD,UAAM,eAAe,YAAY,MAAM;AACrC,mBAAa,KAAK,SAAS;AAAA,IAC7B,GAAG,GAAI;AAEP,SAAK,QAAQ;AAEb,WAAO,MAAM;AACX,WAAK,WAAW;AAChB,qBAAe;AACf,oBAAc,YAAY;AAC1B,oBAAc,UAAU;AACxB,mBAAa,KAAK;AAAA,IACpB;AAAA,EAEF,GAAG,CAAC,WAAW,SAAS,2CAAa,KAAK,IAAI,CAAC;AAE/C,SAAO,EAAE,WAAW,UAAU;AAChC;","names":[]}
1
+ {"version":3,"sources":["../src/realtime.ts","../src/core/query/realtime-hooks.ts","../src/core/query/realtime.ts","../src/core/client/types.ts","../src/core/query/query-keys.ts"],"sourcesContent":["export { useRealtimeQuery } from './core/query/realtime-hooks'\nexport type {\n UseRealtimeQueryOptions,\n UseRealtimeQueryResult,\n RealtimeEvent,\n} from './core/query/realtime-hooks'\nexport { RealtimeConnection, type RealtimeListener } from './core/query/realtime'\n","import { useEffect, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { RealtimeConnection, type RealtimeEvent } from './realtime'\nimport { resolveApiUrl, type PublicCollection } from '../client/types'\nimport { collectionKeys } from './query-keys'\n\nexport type { RealtimeEvent }\n\nexport interface UseRealtimeQueryOptions {\n /** Filter events to specific collections. Empty/undefined = all collections. */\n collections?: PublicCollection[]\n /** Enable/disable the SSE connection. Default: true. */\n enabled?: boolean\n}\n\nexport interface UseRealtimeQueryResult {\n /** Whether the SSE connection is currently active. */\n connected: boolean\n /** The last received event, or null. */\n lastEvent: RealtimeEvent | null\n}\n\n/**\n * React hook that subscribes to real-time collection change events via SSE.\n * Automatically invalidates React Query cache when changes are detected.\n *\n * @example\n * ```tsx\n * const { connected } = useRealtimeQuery({\n * clientKey: 'your-key',\n * getToken: () => client.customer.getToken(),\n * collections: ['products', 'orders'],\n * })\n * ```\n */\nexport function useRealtimeQuery(options: {\n clientKey: string\n getToken: () => string | null\n collections?: PublicCollection[]\n enabled?: boolean\n}): UseRealtimeQueryResult {\n const { clientKey, getToken, collections, enabled = true } = options\n const queryClient = useQueryClient()\n const [connected, setConnected] = useState(false)\n const [lastEvent, setLastEvent] = useState<RealtimeEvent | null>(null)\n const connectionRef = useRef<RealtimeConnection | null>(null)\n\n useEffect(() => {\n if (!enabled || !clientKey) return\n\n const baseUrl = resolveApiUrl()\n const conn = new RealtimeConnection(\n baseUrl,\n clientKey,\n getToken,\n collections,\n )\n connectionRef.current = conn\n\n // Listen for events and invalidate queries\n const removeListener = conn.addListener((event) => {\n setLastEvent(event)\n\n // Invalidate all queries for the changed collection\n const keys = collectionKeys(event.collection as PublicCollection)\n queryClient.invalidateQueries({ queryKey: keys.all })\n })\n\n // Track connection state\n const pollInterval = setInterval(() => {\n setConnected(conn.connected)\n }, 1000)\n\n conn.connect()\n\n return () => {\n conn.disconnect()\n removeListener()\n clearInterval(pollInterval)\n connectionRef.current = null\n setConnected(false)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clientKey, enabled, collections?.join(',')])\n\n return { connected, lastEvent }\n}\n","/**\n * Fetch-based SSE connection manager for real-time collection change events.\n * Uses fetch + ReadableStream to support custom auth headers (unlike native EventSource).\n */\n\nexport interface RealtimeEvent {\n collection: string\n operation: string\n id: string | null\n timestamp: string\n}\n\nexport type RealtimeListener = (event: RealtimeEvent) => void\n\nconst INITIAL_RECONNECT_DELAY = 1_000\nconst MAX_RECONNECT_DELAY = 30_000\nconst RECONNECT_BACKOFF_FACTOR = 2\nconst MAX_NO_TOKEN_RETRIES = 5\n\nexport class RealtimeConnection {\n private abortController: AbortController | null = null\n private reconnectAttempt = 0\n private noTokenAttempts = 0\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null\n private listeners = new Set<RealtimeListener>()\n private _connected = false\n\n constructor(\n private baseUrl: string,\n private clientKey: string,\n private getToken: () => string | null,\n private collections?: string[],\n ) {}\n\n get connected(): boolean {\n return this._connected\n }\n\n addListener(fn: RealtimeListener): () => void {\n this.listeners.add(fn)\n return () => this.listeners.delete(fn)\n }\n\n connect(): void {\n if (this.abortController) return // Already connecting/connected\n\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }\n\n disconnect(): void {\n this._connected = false\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer)\n this.reconnectTimer = null\n }\n if (this.abortController) {\n this.abortController.abort()\n this.abortController = null\n }\n this.reconnectAttempt = 0\n this.noTokenAttempts = 0\n }\n\n private async startStream(signal: AbortSignal): Promise<void> {\n const token = this.getToken()\n if (!token) {\n this.noTokenAttempts++\n if (this.noTokenAttempts >= MAX_NO_TOKEN_RETRIES) {\n // Stop reconnecting — no token available after multiple attempts\n this._connected = false\n this.abortController = null\n return\n }\n this.scheduleReconnect()\n return\n }\n this.noTokenAttempts = 0\n\n const params = this.collections?.length\n ? `?collections=${this.collections.join(',')}`\n : ''\n const url = `${this.baseUrl}/api/events/stream${params}`\n\n try {\n const response = await fetch(url, {\n headers: {\n 'X-Client-Key': this.clientKey,\n Authorization: `Bearer ${token}`,\n },\n signal,\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n // Token expired — try reconnecting (will get fresh token)\n this.scheduleReconnect()\n return\n }\n throw new Error(`SSE connection failed: ${response.status}`)\n }\n\n if (!response.body) {\n throw new Error('SSE response has no body')\n }\n\n this._connected = true\n this.reconnectAttempt = 0\n\n await this.readStream(response.body, signal)\n } catch {\n if (signal.aborted) return // Intentional disconnect\n this._connected = false\n this.scheduleReconnect()\n }\n }\n\n private async readStream(\n body: ReadableStream<Uint8Array>,\n signal: AbortSignal,\n ): Promise<void> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let currentEvent = ''\n let currentData = ''\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done || signal.aborted) break\n\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? '' // Keep incomplete last line in buffer\n\n for (const line of lines) {\n if (line.startsWith('event: ')) {\n currentEvent = line.slice(7)\n } else if (line.startsWith('data: ')) {\n currentData += (currentData ? '\\n' : '') + line.slice(6)\n } else if (line === '') {\n // Empty line = end of event\n if (currentEvent === 'collection:change' && currentData) {\n try {\n const event: RealtimeEvent = JSON.parse(currentData)\n for (const listener of this.listeners) {\n try {\n listener(event)\n } catch {\n // Listener error — ignore\n }\n }\n } catch {\n // Malformed JSON — ignore\n }\n }\n currentEvent = ''\n currentData = ''\n }\n // Ignore comment lines (: heartbeat)\n }\n }\n } catch {\n // Stream read error\n } finally {\n reader.releaseLock()\n this._connected = false\n if (!signal.aborted) {\n this.scheduleReconnect()\n }\n }\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer) return\n\n const delay = Math.min(\n INITIAL_RECONNECT_DELAY *\n Math.pow(RECONNECT_BACKOFF_FACTOR, this.reconnectAttempt),\n MAX_RECONNECT_DELAY,\n )\n this.reconnectAttempt++\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }, delay)\n }\n}\n","import type { Sort, Where } from 'payload'\n\nimport type { Collection, PublicCollection } from '../collection/const'\n\nexport type { Collection, PublicCollection }\n\n// ============================================================================\n// API URL Configuration\n// ============================================================================\n\ndeclare const __DEFAULT_API_URL__: string\n\n/**\n * API URL을 반환합니다.\n * 환경변수 SOFTWARE_API_URL 또는 NEXT_PUBLIC_SOFTWARE_API_URL로 오버라이드 가능.\n * 빌드 시 버전에 따라 기본값 결정: dev 빌드 → api-dev, 정식 → api.01.software\n */\nexport function resolveApiUrl(): string {\n if (typeof process !== 'undefined' && process.env) {\n const envUrl =\n process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL\n if (envUrl) {\n return envUrl.replace(/\\/$/, '')\n }\n }\n return __DEFAULT_API_URL__\n}\n\n// ============================================================================\n// Client Configuration\n// ============================================================================\n\nexport interface ClientBrowserConfig {\n clientKey: string\n /**\n * Customer authentication options.\n * Used to initialize CustomerAuth on BrowserClient.\n */\n customer?: {\n /**\n * Persist token in localStorage. Defaults to `true`.\n * - `true` (default): uses key `'customer-token'`\n * - `string`: uses the given string as localStorage key\n * - `false`: disables persistence (token/onTokenChange used instead)\n *\n * Handles SSR safely (no-op on server).\n * When enabled, `token` and `onTokenChange` are ignored.\n */\n persist?: boolean | string\n /** Initial token (e.g. from SSR cookie) */\n token?: string\n /** Called when token changes (login/logout) — use to persist in localStorage/cookie */\n onTokenChange?: (token: string | null) => void\n }\n}\n\nexport interface ClientServerConfig extends ClientBrowserConfig {\n secretKey: string\n}\n\nexport interface ClientMetadata {\n userAgent?: string\n timestamp: number\n}\n\nexport interface ClientState {\n metadata: ClientMetadata\n}\n\n// ============================================================================\n// API Response Types\n// ============================================================================\n\nexport interface PaginationMeta {\n page: number\n limit: number\n totalDocs: number\n totalPages: number\n hasNextPage: boolean\n hasPrevPage: boolean\n pagingCounter: number\n prevPage: number | null\n nextPage: number | null\n}\n\n// ============================================================================\n// Payload CMS Native Response Types\n// ============================================================================\n\n/**\n * Payload CMS Find (List) Response\n * GET /api/{collection}\n */\nexport interface PayloadFindResponse<T = unknown> {\n docs: T[]\n totalDocs: number\n limit: number\n totalPages: number\n page: number\n pagingCounter: number\n hasPrevPage: boolean\n hasNextPage: boolean\n prevPage: number | null\n nextPage: number | null\n}\n\n/**\n * Payload CMS Create/Update Response\n * POST /api/{collection}\n * PATCH /api/{collection}/{id}\n */\nexport interface PayloadMutationResponse<T = unknown> {\n message: string\n doc: T\n errors?: unknown[]\n}\n\n// ============================================================================\n// Query Options\n// ============================================================================\n\nexport interface ApiQueryOptions {\n page?: number\n limit?: number\n sort?: Sort\n where?: Where\n depth?: number\n select?: Record<string, boolean>\n}\n\nexport interface ApiQueryReactOptions {\n keepPreviousData?: boolean\n}\n\n// ============================================================================\n// Debug & Retry Configuration\n// ============================================================================\n\nexport interface DebugConfig {\n logRequests?: boolean\n logResponses?: boolean\n logErrors?: boolean\n}\n\nexport interface RetryConfig {\n maxRetries?: number\n retryableStatuses?: number[]\n retryDelay?: (attempt: number) => number\n}\n\n\n// ============================================================================\n// Collection Types (re-exported from collection/const)\n// ============================================================================\n\n// ============================================================================\n// Type Utilities\n// ============================================================================\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]\n}\n\nexport type ExtractArrayType<T> = T extends (infer U)[] ? U : never\n","import type { PublicCollection, ApiQueryOptions } from '../client/types'\n\nexport function collectionKeys<T extends PublicCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>) =>\n [collection, 'infinite', options] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n"],"mappings":";;;;;;;;;;;;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@ -1,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-DupPIYx-.cjs';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-DupPIYx-.cjs';
3
- import { P as PublicCollection } from './const-BpirbGBD.cjs';
4
- import './payload-types-CZiaL4Wr.cjs';
3
+ import { P as PublicCollection } from './const-CWZ70tFe.cjs';
4
+ import './payload-types-BbEEk9Ji.cjs';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
@@ -1,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-DupPIYx-.js';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-DupPIYx-.js';
3
- import { P as PublicCollection } from './const-qZSQiSSC.js';
4
- import './payload-types-CZiaL4Wr.js';
3
+ import { P as PublicCollection } from './const-nftKBzYp.js';
4
+ import './payload-types-BbEEk9Ji.js';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
package/dist/realtime.js CHANGED
@@ -176,9 +176,11 @@ var RealtimeConnection = class {
176
176
 
177
177
  // src/core/client/types.ts
178
178
  function resolveApiUrl() {
179
- const envUrl = process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL;
180
- if (envUrl) {
181
- return envUrl.replace(/\/$/, "");
179
+ if (typeof process !== "undefined" && process.env) {
180
+ const envUrl = process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL;
181
+ if (envUrl) {
182
+ return envUrl.replace(/\/$/, "");
183
+ }
182
184
  }
183
185
  return "https://api.01.software";
184
186
  }