@01.software/sdk 0.8.0 → 0.9.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.
Files changed (48) hide show
  1. package/README.md +16 -18
  2. package/dist/{const-dv0zuAxG.d.cts → const-DZ04SC2y.d.cts} +1 -1
  3. package/dist/{const-CCh99Gxu.d.ts → const-hXu9oG66.d.ts} +1 -1
  4. package/dist/index.cjs +48 -164
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +21 -33
  7. package/dist/index.d.ts +21 -33
  8. package/dist/index.js +48 -164
  9. package/dist/index.js.map +1 -1
  10. package/dist/{payload-types-FfZ2Zxp1.d.cts → payload-types-DICC2-Zr.d.cts} +120 -25
  11. package/dist/{payload-types-FfZ2Zxp1.d.ts → payload-types-DICC2-Zr.d.ts} +120 -25
  12. package/dist/{realtime-DupPIYx-.d.cts → realtime-D7HtUpqt.d.cts} +2 -2
  13. package/dist/{realtime-DupPIYx-.d.ts → realtime-D7HtUpqt.d.ts} +2 -2
  14. package/dist/realtime.cjs +8 -7
  15. package/dist/realtime.cjs.map +1 -1
  16. package/dist/realtime.d.cts +6 -6
  17. package/dist/realtime.d.ts +6 -6
  18. package/dist/realtime.js +8 -7
  19. package/dist/realtime.js.map +1 -1
  20. package/dist/{server-DxhuG-_s.d.cts → server-JR9TvKZ5.d.cts} +0 -2
  21. package/dist/{server-DxhuG-_s.d.ts → server-JR9TvKZ5.d.ts} +0 -2
  22. package/dist/ui/canvas/server.cjs +1 -2
  23. package/dist/ui/canvas/server.cjs.map +1 -1
  24. package/dist/ui/canvas/server.d.cts +1 -1
  25. package/dist/ui/canvas/server.d.ts +1 -1
  26. package/dist/ui/canvas/server.js +1 -2
  27. package/dist/ui/canvas/server.js.map +1 -1
  28. package/dist/ui/canvas.cjs +1 -2
  29. package/dist/ui/canvas.cjs.map +1 -1
  30. package/dist/ui/canvas.d.cts +2 -2
  31. package/dist/ui/canvas.d.ts +2 -2
  32. package/dist/ui/canvas.js +1 -2
  33. package/dist/ui/canvas.js.map +1 -1
  34. package/dist/ui/form.d.cts +1 -1
  35. package/dist/ui/form.d.ts +1 -1
  36. package/dist/ui/video.d.cts +1 -1
  37. package/dist/ui/video.d.ts +1 -1
  38. package/dist/{webhook-B9MDrH22.d.ts → webhook-BD9ivfyR.d.ts} +2 -2
  39. package/dist/{webhook-t7JGFLKQ.d.cts → webhook-D8ogsafv.d.cts} +2 -2
  40. package/dist/webhook.d.cts +3 -3
  41. package/dist/webhook.d.ts +3 -3
  42. package/package.json +3 -13
  43. package/dist/auth.cjs +0 -109
  44. package/dist/auth.cjs.map +0 -1
  45. package/dist/auth.d.cts +0 -36
  46. package/dist/auth.d.ts +0 -36
  47. package/dist/auth.js +0 -86
  48. package/dist/auth.js.map +0 -1
@@ -27,6 +27,8 @@ interface Config {
27
27
  'system-media': SystemMedia;
28
28
  audiences: Audience;
29
29
  'email-logs': EmailLog;
30
+ 'api-keys': ApiKey;
31
+ 'personal-access-tokens': PersonalAccessToken;
30
32
  tenants: Tenant;
31
33
  'tenant-metadata': TenantMetadatum;
32
34
  'api-usage': ApiUsage;
@@ -155,6 +157,8 @@ interface Config {
155
157
  'system-media': SystemMediaSelect<false> | SystemMediaSelect<true>;
156
158
  audiences: AudiencesSelect<false> | AudiencesSelect<true>;
157
159
  'email-logs': EmailLogsSelect<false> | EmailLogsSelect<true>;
160
+ 'api-keys': ApiKeysSelect<false> | ApiKeysSelect<true>;
161
+ 'personal-access-tokens': PersonalAccessTokensSelect<false> | PersonalAccessTokensSelect<true>;
158
162
  tenants: TenantsSelect<false> | TenantsSelect<true>;
159
163
  'tenant-metadata': TenantMetadataSelect<false> | TenantMetadataSelect<true>;
160
164
  'api-usage': ApiUsageSelect<false> | ApiUsageSelect<true>;
@@ -407,21 +411,10 @@ interface Tenant {
407
411
  origin: string;
408
412
  id?: string | null;
409
413
  }[] | null;
410
- clientKey: string;
411
- secretKeys?: {
412
- name: string;
413
- keyHash?: string | null;
414
- /**
415
- * First 8 characters of the key (identification only)
416
- */
417
- prefix?: string | null;
418
- /**
419
- * Last 4 characters of the key
420
- */
421
- last4?: string | null;
422
- lastUsedAt?: string | null;
423
- id?: string | null;
424
- }[] | null;
414
+ /**
415
+ * Publishable Key — safe to embed in browser code. Prefix: pk01_
416
+ */
417
+ publishableKey: string;
425
418
  /**
426
419
  * Webhook endpoints to notify on data changes.
427
420
  */
@@ -619,6 +612,69 @@ interface EmailLog {
619
612
  updatedAt: string;
620
613
  createdAt: string;
621
614
  }
615
+ /**
616
+ * This interface was referenced by `Config`'s JSON-Schema
617
+ * via the `definition` "api-keys".
618
+ */
619
+ interface ApiKey {
620
+ id: string;
621
+ tenant: string | Tenant;
622
+ name: string;
623
+ secretHash: string;
624
+ /**
625
+ * Key prefix (e.g. sk01_ab12cd3)
626
+ */
627
+ displayPrefix: string;
628
+ displaySuffix: string;
629
+ /**
630
+ * Not enforced in v1. Reserved for future use. E.g. ["*"] or ["read:products", "write:orders"]
631
+ */
632
+ scopes?: {
633
+ [k: string]: unknown;
634
+ } | unknown[] | string | number | boolean | null;
635
+ createdBy?: (string | null) | User;
636
+ createdByIp?: string | null;
637
+ lastUsedAt?: string | null;
638
+ lastUsedIp?: string | null;
639
+ revokedAt?: string | null;
640
+ revokedBy?: (string | null) | User;
641
+ /**
642
+ * Optional expiration. Empty = never expires.
643
+ */
644
+ expiresAt?: string | null;
645
+ updatedAt: string;
646
+ createdAt: string;
647
+ }
648
+ /**
649
+ * This interface was referenced by `Config`'s JSON-Schema
650
+ * via the `definition` "personal-access-tokens".
651
+ */
652
+ interface PersonalAccessToken {
653
+ id: string;
654
+ user: string | User;
655
+ /**
656
+ * e.g. "CLI: MacBook Pro (darwin)", "GitHub Actions"
657
+ */
658
+ name: string;
659
+ secretHash: string;
660
+ displayPrefix: string;
661
+ displaySuffix: string;
662
+ /**
663
+ * Default tenant ID for CLI operations. Set via `01 tenant use <name>`.
664
+ */
665
+ defaultTenant?: string | null;
666
+ createdByIp?: string | null;
667
+ lastUsedAt?: string | null;
668
+ lastUsedIp?: string | null;
669
+ revokedAt?: string | null;
670
+ revokedBy?: (string | null) | User;
671
+ /**
672
+ * PATs expire after 90 days by default.
673
+ */
674
+ expiresAt?: string | null;
675
+ updatedAt: string;
676
+ createdAt: string;
677
+ }
622
678
  /**
623
679
  * This interface was referenced by `Config`'s JSON-Schema
624
680
  * via the `definition` "tenant-metadata".
@@ -3993,6 +4049,12 @@ interface PayloadLockedDocument {
3993
4049
  } | null) | ({
3994
4050
  relationTo: 'email-logs';
3995
4051
  value: string | EmailLog;
4052
+ } | null) | ({
4053
+ relationTo: 'api-keys';
4054
+ value: string | ApiKey;
4055
+ } | null) | ({
4056
+ relationTo: 'personal-access-tokens';
4057
+ value: string | PersonalAccessToken;
3996
4058
  } | null) | ({
3997
4059
  relationTo: 'tenants';
3998
4060
  value: string | Tenant;
@@ -4431,6 +4493,47 @@ interface EmailLogsSelect<T extends boolean = true> {
4431
4493
  updatedAt?: T;
4432
4494
  createdAt?: T;
4433
4495
  }
4496
+ /**
4497
+ * This interface was referenced by `Config`'s JSON-Schema
4498
+ * via the `definition` "api-keys_select".
4499
+ */
4500
+ interface ApiKeysSelect<T extends boolean = true> {
4501
+ tenant?: T;
4502
+ name?: T;
4503
+ secretHash?: T;
4504
+ displayPrefix?: T;
4505
+ displaySuffix?: T;
4506
+ scopes?: T;
4507
+ createdBy?: T;
4508
+ createdByIp?: T;
4509
+ lastUsedAt?: T;
4510
+ lastUsedIp?: T;
4511
+ revokedAt?: T;
4512
+ revokedBy?: T;
4513
+ expiresAt?: T;
4514
+ updatedAt?: T;
4515
+ createdAt?: T;
4516
+ }
4517
+ /**
4518
+ * This interface was referenced by `Config`'s JSON-Schema
4519
+ * via the `definition` "personal-access-tokens_select".
4520
+ */
4521
+ interface PersonalAccessTokensSelect<T extends boolean = true> {
4522
+ user?: T;
4523
+ name?: T;
4524
+ secretHash?: T;
4525
+ displayPrefix?: T;
4526
+ displaySuffix?: T;
4527
+ defaultTenant?: T;
4528
+ createdByIp?: T;
4529
+ lastUsedAt?: T;
4530
+ lastUsedIp?: T;
4531
+ revokedAt?: T;
4532
+ revokedBy?: T;
4533
+ expiresAt?: T;
4534
+ updatedAt?: T;
4535
+ createdAt?: T;
4536
+ }
4434
4537
  /**
4435
4538
  * This interface was referenced by `Config`'s JSON-Schema
4436
4539
  * via the `definition` "tenants_select".
@@ -4451,15 +4554,7 @@ interface TenantsSelect<T extends boolean = true> {
4451
4554
  origin?: T;
4452
4555
  id?: T;
4453
4556
  };
4454
- clientKey?: T;
4455
- secretKeys?: T | {
4456
- name?: T;
4457
- keyHash?: T;
4458
- prefix?: T;
4459
- last4?: T;
4460
- lastUsedAt?: T;
4461
- id?: T;
4462
- };
4557
+ publishableKey?: T;
4463
4558
  webhooks?: T | {
4464
4559
  name?: T;
4465
4560
  url?: T;
@@ -6539,4 +6634,4 @@ declare module 'payload' {
6539
6634
  }
6540
6635
  }
6541
6636
 
6542
- export type { DocumentType as $, Audience as A, BrandLogo as B, Config as C, ProductCollection as D, EmailLog as E, Form as F, Customer as G, CustomerGroup as H, IframeBlock as I, CustomerAddress as J, FulfillmentItem as K, LiveStream as L, ReturnItem as M, OrderStatusLog as N, Order as O, Product as P, Discount as Q, Return as R, SupportedTimezones as S, Transaction as T, UserAuthOperations as U, Video as V, Post as W, PostAuthor as X, PostCategory as Y, PostTag as Z, Document as _, OrderItem as a, CustomerAddressesSelect as a$, DocumentCategory as a0, Playlist as a1, PlaylistCategory as a2, PlaylistTag as a3, Music as a4, MusicCategory as a5, MusicTag as a6, Gallery as a7, GalleryCategory as a8, GalleryTag as a9, AudiencesSelect as aA, EmailLogsSelect as aB, TenantsSelect as aC, TenantMetadataSelect as aD, ApiUsageSelect as aE, SubscriptionsSelect as aF, BillingHistorySelect as aG, TenantLogosSelect as aH, ProductsSelect as aI, ProductVariantsSelect as aJ, ProductOptionsSelect as aK, ProductOptionValuesSelect as aL, ProductCategoriesSelect as aM, ProductTagsSelect as aN, ProductCollectionsSelect as aO, BrandsSelect as aP, BrandLogosSelect as aQ, OrdersSelect as aR, OrderItemsSelect as aS, TransactionsSelect as aT, OrderStatusLogsSelect as aU, FulfillmentsSelect as aV, FulfillmentItemsSelect as aW, ReturnsSelect as aX, ReturnItemsSelect as aY, ShippingPoliciesSelect as aZ, CustomersSelect as a_, GalleryItem as aa, Link as ab, LinkCategory as ac, LinkTag as ad, Canvase as ae, CanvasCategory as af, CanvasTag as ag, CanvasNodeType as ah, CanvasEdgeType as ai, Thread as aj, ThreadCategory as ak, Comment as al, Reaction as am, ReactionType as an, Bookmark as ao, Report as ap, CommunityBan as aq, FormSubmission as ar, PayloadKv as as, PayloadLockedDocument as at, PayloadPreference as au, PayloadMigration as av, UsersSelect as aw, FieldConfigsSelect as ax, ImagesSelect as ay, SystemMediaSelect as az, Fulfillment as b, CustomerGroupsSelect as b0, CartsSelect as b1, CartItemsSelect as b2, DiscountsSelect as b3, PostsSelect as b4, PostAuthorsSelect as b5, PostCategoriesSelect as b6, PostTagsSelect as b7, DocumentsSelect as b8, DocumentCategoriesSelect as b9, ReactionTypesSelect as bA, BookmarksSelect as bB, ThreadCategoriesSelect as bC, ReportsSelect as bD, CommunityBansSelect as bE, FormsSelect as bF, FormSubmissionsSelect as bG, PayloadKvSelect as bH, PayloadLockedDocumentsSelect as bI, PayloadPreferencesSelect as bJ, PayloadMigrationsSelect as bK, CollectionsWidget as bL, Auth as bM, DocumentTypesSelect as ba, PlaylistsSelect as bb, PlaylistCategoriesSelect as bc, PlaylistTagsSelect as bd, MusicsSelect as be, MusicCategoriesSelect as bf, MusicTagsSelect as bg, GalleriesSelect as bh, GalleryCategoriesSelect as bi, GalleryTagsSelect as bj, GalleryItemsSelect as bk, LinksSelect as bl, LinkCategoriesSelect as bm, LinkTagsSelect as bn, CanvasesSelect as bo, CanvasNodeTypesSelect as bp, CanvasEdgeTypesSelect as bq, CanvasCategoriesSelect as br, CanvasTagsSelect as bs, VideosSelect as bt, VideoCategoriesSelect as bu, VideoTagsSelect as bv, LiveStreamsSelect as bw, ThreadsSelect as bx, CommentsSelect as by, ReactionsSelect as bz, Cart as c, CartItem as d, CustomerAuthOperations as e, PlayerBlock as f, CodeBlock as g, User as h, Tenant as i, Image as j, FieldConfig as k, SystemMedia as l, TenantMetadatum as m, ApiUsage as n, Subscription as o, BillingHistory as p, TenantLogo as q, VideoCategory as r, VideoTag as s, ProductVariant as t, ProductOptionValue as u, ProductOption as v, ProductCategory as w, ProductTag as x, Brand as y, ShippingPolicy as z };
6637
+ export type { PostTag as $, Audience as A, BrandLogo as B, Config as C, Brand as D, EmailLog as E, Form as F, ShippingPolicy as G, ProductCollection as H, IframeBlock as I, Customer as J, CustomerGroup as K, LiveStream as L, CustomerAddress as M, FulfillmentItem as N, Order as O, Product as P, ReturnItem as Q, Return as R, SupportedTimezones as S, Transaction as T, UserAuthOperations as U, Video as V, OrderStatusLog as W, Discount as X, Post as Y, PostAuthor as Z, PostCategory as _, OrderItem as a, ReturnsSelect as a$, Document as a0, DocumentType as a1, DocumentCategory as a2, Playlist as a3, PlaylistCategory as a4, PlaylistTag as a5, Music as a6, MusicCategory as a7, MusicTag as a8, Gallery as a9, ImagesSelect as aA, SystemMediaSelect as aB, AudiencesSelect as aC, EmailLogsSelect as aD, ApiKeysSelect as aE, PersonalAccessTokensSelect as aF, TenantsSelect as aG, TenantMetadataSelect as aH, ApiUsageSelect as aI, SubscriptionsSelect as aJ, BillingHistorySelect as aK, TenantLogosSelect as aL, ProductsSelect as aM, ProductVariantsSelect as aN, ProductOptionsSelect as aO, ProductOptionValuesSelect as aP, ProductCategoriesSelect as aQ, ProductTagsSelect as aR, ProductCollectionsSelect as aS, BrandsSelect as aT, BrandLogosSelect as aU, OrdersSelect as aV, OrderItemsSelect as aW, TransactionsSelect as aX, OrderStatusLogsSelect as aY, FulfillmentsSelect as aZ, FulfillmentItemsSelect as a_, GalleryCategory as aa, GalleryTag as ab, GalleryItem as ac, Link as ad, LinkCategory as ae, LinkTag as af, Canvase as ag, CanvasCategory as ah, CanvasTag as ai, CanvasNodeType as aj, CanvasEdgeType as ak, Thread as al, ThreadCategory as am, Comment as an, Reaction as ao, ReactionType as ap, Bookmark as aq, Report as ar, CommunityBan as as, FormSubmission as at, PayloadKv as au, PayloadLockedDocument as av, PayloadPreference as aw, PayloadMigration as ax, UsersSelect as ay, FieldConfigsSelect as az, Fulfillment as b, ReturnItemsSelect as b0, ShippingPoliciesSelect as b1, CustomersSelect as b2, CustomerAddressesSelect as b3, CustomerGroupsSelect as b4, CartsSelect as b5, CartItemsSelect as b6, DiscountsSelect as b7, PostsSelect as b8, PostAuthorsSelect as b9, LiveStreamsSelect as bA, ThreadsSelect as bB, CommentsSelect as bC, ReactionsSelect as bD, ReactionTypesSelect as bE, BookmarksSelect as bF, ThreadCategoriesSelect as bG, ReportsSelect as bH, CommunityBansSelect as bI, FormsSelect as bJ, FormSubmissionsSelect as bK, PayloadKvSelect as bL, PayloadLockedDocumentsSelect as bM, PayloadPreferencesSelect as bN, PayloadMigrationsSelect as bO, CollectionsWidget as bP, Auth as bQ, PostCategoriesSelect as ba, PostTagsSelect as bb, DocumentsSelect as bc, DocumentCategoriesSelect as bd, DocumentTypesSelect as be, PlaylistsSelect as bf, PlaylistCategoriesSelect as bg, PlaylistTagsSelect as bh, MusicsSelect as bi, MusicCategoriesSelect as bj, MusicTagsSelect as bk, GalleriesSelect as bl, GalleryCategoriesSelect as bm, GalleryTagsSelect as bn, GalleryItemsSelect as bo, LinksSelect as bp, LinkCategoriesSelect as bq, LinkTagsSelect as br, CanvasesSelect as bs, CanvasNodeTypesSelect as bt, CanvasEdgeTypesSelect as bu, CanvasCategoriesSelect as bv, CanvasTagsSelect as bw, VideosSelect as bx, VideoCategoriesSelect as by, VideoTagsSelect as bz, Cart as c, CartItem as d, CustomerAuthOperations as e, PlayerBlock as f, CodeBlock as g, User as h, Tenant as i, Image as j, FieldConfig as k, SystemMedia as l, ApiKey as m, PersonalAccessToken as n, TenantMetadatum as o, ApiUsage as p, Subscription as q, BillingHistory as r, TenantLogo as s, VideoCategory as t, VideoTag as u, ProductVariant as v, ProductOptionValue as w, ProductOption as x, ProductCategory as y, ProductTag as z };
@@ -27,6 +27,8 @@ interface Config {
27
27
  'system-media': SystemMedia;
28
28
  audiences: Audience;
29
29
  'email-logs': EmailLog;
30
+ 'api-keys': ApiKey;
31
+ 'personal-access-tokens': PersonalAccessToken;
30
32
  tenants: Tenant;
31
33
  'tenant-metadata': TenantMetadatum;
32
34
  'api-usage': ApiUsage;
@@ -155,6 +157,8 @@ interface Config {
155
157
  'system-media': SystemMediaSelect<false> | SystemMediaSelect<true>;
156
158
  audiences: AudiencesSelect<false> | AudiencesSelect<true>;
157
159
  'email-logs': EmailLogsSelect<false> | EmailLogsSelect<true>;
160
+ 'api-keys': ApiKeysSelect<false> | ApiKeysSelect<true>;
161
+ 'personal-access-tokens': PersonalAccessTokensSelect<false> | PersonalAccessTokensSelect<true>;
158
162
  tenants: TenantsSelect<false> | TenantsSelect<true>;
159
163
  'tenant-metadata': TenantMetadataSelect<false> | TenantMetadataSelect<true>;
160
164
  'api-usage': ApiUsageSelect<false> | ApiUsageSelect<true>;
@@ -407,21 +411,10 @@ interface Tenant {
407
411
  origin: string;
408
412
  id?: string | null;
409
413
  }[] | null;
410
- clientKey: string;
411
- secretKeys?: {
412
- name: string;
413
- keyHash?: string | null;
414
- /**
415
- * First 8 characters of the key (identification only)
416
- */
417
- prefix?: string | null;
418
- /**
419
- * Last 4 characters of the key
420
- */
421
- last4?: string | null;
422
- lastUsedAt?: string | null;
423
- id?: string | null;
424
- }[] | null;
414
+ /**
415
+ * Publishable Key — safe to embed in browser code. Prefix: pk01_
416
+ */
417
+ publishableKey: string;
425
418
  /**
426
419
  * Webhook endpoints to notify on data changes.
427
420
  */
@@ -619,6 +612,69 @@ interface EmailLog {
619
612
  updatedAt: string;
620
613
  createdAt: string;
621
614
  }
615
+ /**
616
+ * This interface was referenced by `Config`'s JSON-Schema
617
+ * via the `definition` "api-keys".
618
+ */
619
+ interface ApiKey {
620
+ id: string;
621
+ tenant: string | Tenant;
622
+ name: string;
623
+ secretHash: string;
624
+ /**
625
+ * Key prefix (e.g. sk01_ab12cd3)
626
+ */
627
+ displayPrefix: string;
628
+ displaySuffix: string;
629
+ /**
630
+ * Not enforced in v1. Reserved for future use. E.g. ["*"] or ["read:products", "write:orders"]
631
+ */
632
+ scopes?: {
633
+ [k: string]: unknown;
634
+ } | unknown[] | string | number | boolean | null;
635
+ createdBy?: (string | null) | User;
636
+ createdByIp?: string | null;
637
+ lastUsedAt?: string | null;
638
+ lastUsedIp?: string | null;
639
+ revokedAt?: string | null;
640
+ revokedBy?: (string | null) | User;
641
+ /**
642
+ * Optional expiration. Empty = never expires.
643
+ */
644
+ expiresAt?: string | null;
645
+ updatedAt: string;
646
+ createdAt: string;
647
+ }
648
+ /**
649
+ * This interface was referenced by `Config`'s JSON-Schema
650
+ * via the `definition` "personal-access-tokens".
651
+ */
652
+ interface PersonalAccessToken {
653
+ id: string;
654
+ user: string | User;
655
+ /**
656
+ * e.g. "CLI: MacBook Pro (darwin)", "GitHub Actions"
657
+ */
658
+ name: string;
659
+ secretHash: string;
660
+ displayPrefix: string;
661
+ displaySuffix: string;
662
+ /**
663
+ * Default tenant ID for CLI operations. Set via `01 tenant use <name>`.
664
+ */
665
+ defaultTenant?: string | null;
666
+ createdByIp?: string | null;
667
+ lastUsedAt?: string | null;
668
+ lastUsedIp?: string | null;
669
+ revokedAt?: string | null;
670
+ revokedBy?: (string | null) | User;
671
+ /**
672
+ * PATs expire after 90 days by default.
673
+ */
674
+ expiresAt?: string | null;
675
+ updatedAt: string;
676
+ createdAt: string;
677
+ }
622
678
  /**
623
679
  * This interface was referenced by `Config`'s JSON-Schema
624
680
  * via the `definition` "tenant-metadata".
@@ -3993,6 +4049,12 @@ interface PayloadLockedDocument {
3993
4049
  } | null) | ({
3994
4050
  relationTo: 'email-logs';
3995
4051
  value: string | EmailLog;
4052
+ } | null) | ({
4053
+ relationTo: 'api-keys';
4054
+ value: string | ApiKey;
4055
+ } | null) | ({
4056
+ relationTo: 'personal-access-tokens';
4057
+ value: string | PersonalAccessToken;
3996
4058
  } | null) | ({
3997
4059
  relationTo: 'tenants';
3998
4060
  value: string | Tenant;
@@ -4431,6 +4493,47 @@ interface EmailLogsSelect<T extends boolean = true> {
4431
4493
  updatedAt?: T;
4432
4494
  createdAt?: T;
4433
4495
  }
4496
+ /**
4497
+ * This interface was referenced by `Config`'s JSON-Schema
4498
+ * via the `definition` "api-keys_select".
4499
+ */
4500
+ interface ApiKeysSelect<T extends boolean = true> {
4501
+ tenant?: T;
4502
+ name?: T;
4503
+ secretHash?: T;
4504
+ displayPrefix?: T;
4505
+ displaySuffix?: T;
4506
+ scopes?: T;
4507
+ createdBy?: T;
4508
+ createdByIp?: T;
4509
+ lastUsedAt?: T;
4510
+ lastUsedIp?: T;
4511
+ revokedAt?: T;
4512
+ revokedBy?: T;
4513
+ expiresAt?: T;
4514
+ updatedAt?: T;
4515
+ createdAt?: T;
4516
+ }
4517
+ /**
4518
+ * This interface was referenced by `Config`'s JSON-Schema
4519
+ * via the `definition` "personal-access-tokens_select".
4520
+ */
4521
+ interface PersonalAccessTokensSelect<T extends boolean = true> {
4522
+ user?: T;
4523
+ name?: T;
4524
+ secretHash?: T;
4525
+ displayPrefix?: T;
4526
+ displaySuffix?: T;
4527
+ defaultTenant?: T;
4528
+ createdByIp?: T;
4529
+ lastUsedAt?: T;
4530
+ lastUsedIp?: T;
4531
+ revokedAt?: T;
4532
+ revokedBy?: T;
4533
+ expiresAt?: T;
4534
+ updatedAt?: T;
4535
+ createdAt?: T;
4536
+ }
4434
4537
  /**
4435
4538
  * This interface was referenced by `Config`'s JSON-Schema
4436
4539
  * via the `definition` "tenants_select".
@@ -4451,15 +4554,7 @@ interface TenantsSelect<T extends boolean = true> {
4451
4554
  origin?: T;
4452
4555
  id?: T;
4453
4556
  };
4454
- clientKey?: T;
4455
- secretKeys?: T | {
4456
- name?: T;
4457
- keyHash?: T;
4458
- prefix?: T;
4459
- last4?: T;
4460
- lastUsedAt?: T;
4461
- id?: T;
4462
- };
4557
+ publishableKey?: T;
4463
4558
  webhooks?: T | {
4464
4559
  name?: T;
4465
4560
  url?: T;
@@ -6539,4 +6634,4 @@ declare module 'payload' {
6539
6634
  }
6540
6635
  }
6541
6636
 
6542
- export type { DocumentType as $, Audience as A, BrandLogo as B, Config as C, ProductCollection as D, EmailLog as E, Form as F, Customer as G, CustomerGroup as H, IframeBlock as I, CustomerAddress as J, FulfillmentItem as K, LiveStream as L, ReturnItem as M, OrderStatusLog as N, Order as O, Product as P, Discount as Q, Return as R, SupportedTimezones as S, Transaction as T, UserAuthOperations as U, Video as V, Post as W, PostAuthor as X, PostCategory as Y, PostTag as Z, Document as _, OrderItem as a, CustomerAddressesSelect as a$, DocumentCategory as a0, Playlist as a1, PlaylistCategory as a2, PlaylistTag as a3, Music as a4, MusicCategory as a5, MusicTag as a6, Gallery as a7, GalleryCategory as a8, GalleryTag as a9, AudiencesSelect as aA, EmailLogsSelect as aB, TenantsSelect as aC, TenantMetadataSelect as aD, ApiUsageSelect as aE, SubscriptionsSelect as aF, BillingHistorySelect as aG, TenantLogosSelect as aH, ProductsSelect as aI, ProductVariantsSelect as aJ, ProductOptionsSelect as aK, ProductOptionValuesSelect as aL, ProductCategoriesSelect as aM, ProductTagsSelect as aN, ProductCollectionsSelect as aO, BrandsSelect as aP, BrandLogosSelect as aQ, OrdersSelect as aR, OrderItemsSelect as aS, TransactionsSelect as aT, OrderStatusLogsSelect as aU, FulfillmentsSelect as aV, FulfillmentItemsSelect as aW, ReturnsSelect as aX, ReturnItemsSelect as aY, ShippingPoliciesSelect as aZ, CustomersSelect as a_, GalleryItem as aa, Link as ab, LinkCategory as ac, LinkTag as ad, Canvase as ae, CanvasCategory as af, CanvasTag as ag, CanvasNodeType as ah, CanvasEdgeType as ai, Thread as aj, ThreadCategory as ak, Comment as al, Reaction as am, ReactionType as an, Bookmark as ao, Report as ap, CommunityBan as aq, FormSubmission as ar, PayloadKv as as, PayloadLockedDocument as at, PayloadPreference as au, PayloadMigration as av, UsersSelect as aw, FieldConfigsSelect as ax, ImagesSelect as ay, SystemMediaSelect as az, Fulfillment as b, CustomerGroupsSelect as b0, CartsSelect as b1, CartItemsSelect as b2, DiscountsSelect as b3, PostsSelect as b4, PostAuthorsSelect as b5, PostCategoriesSelect as b6, PostTagsSelect as b7, DocumentsSelect as b8, DocumentCategoriesSelect as b9, ReactionTypesSelect as bA, BookmarksSelect as bB, ThreadCategoriesSelect as bC, ReportsSelect as bD, CommunityBansSelect as bE, FormsSelect as bF, FormSubmissionsSelect as bG, PayloadKvSelect as bH, PayloadLockedDocumentsSelect as bI, PayloadPreferencesSelect as bJ, PayloadMigrationsSelect as bK, CollectionsWidget as bL, Auth as bM, DocumentTypesSelect as ba, PlaylistsSelect as bb, PlaylistCategoriesSelect as bc, PlaylistTagsSelect as bd, MusicsSelect as be, MusicCategoriesSelect as bf, MusicTagsSelect as bg, GalleriesSelect as bh, GalleryCategoriesSelect as bi, GalleryTagsSelect as bj, GalleryItemsSelect as bk, LinksSelect as bl, LinkCategoriesSelect as bm, LinkTagsSelect as bn, CanvasesSelect as bo, CanvasNodeTypesSelect as bp, CanvasEdgeTypesSelect as bq, CanvasCategoriesSelect as br, CanvasTagsSelect as bs, VideosSelect as bt, VideoCategoriesSelect as bu, VideoTagsSelect as bv, LiveStreamsSelect as bw, ThreadsSelect as bx, CommentsSelect as by, ReactionsSelect as bz, Cart as c, CartItem as d, CustomerAuthOperations as e, PlayerBlock as f, CodeBlock as g, User as h, Tenant as i, Image as j, FieldConfig as k, SystemMedia as l, TenantMetadatum as m, ApiUsage as n, Subscription as o, BillingHistory as p, TenantLogo as q, VideoCategory as r, VideoTag as s, ProductVariant as t, ProductOptionValue as u, ProductOption as v, ProductCategory as w, ProductTag as x, Brand as y, ShippingPolicy as z };
6637
+ export type { PostTag as $, Audience as A, BrandLogo as B, Config as C, Brand as D, EmailLog as E, Form as F, ShippingPolicy as G, ProductCollection as H, IframeBlock as I, Customer as J, CustomerGroup as K, LiveStream as L, CustomerAddress as M, FulfillmentItem as N, Order as O, Product as P, ReturnItem as Q, Return as R, SupportedTimezones as S, Transaction as T, UserAuthOperations as U, Video as V, OrderStatusLog as W, Discount as X, Post as Y, PostAuthor as Z, PostCategory as _, OrderItem as a, ReturnsSelect as a$, Document as a0, DocumentType as a1, DocumentCategory as a2, Playlist as a3, PlaylistCategory as a4, PlaylistTag as a5, Music as a6, MusicCategory as a7, MusicTag as a8, Gallery as a9, ImagesSelect as aA, SystemMediaSelect as aB, AudiencesSelect as aC, EmailLogsSelect as aD, ApiKeysSelect as aE, PersonalAccessTokensSelect as aF, TenantsSelect as aG, TenantMetadataSelect as aH, ApiUsageSelect as aI, SubscriptionsSelect as aJ, BillingHistorySelect as aK, TenantLogosSelect as aL, ProductsSelect as aM, ProductVariantsSelect as aN, ProductOptionsSelect as aO, ProductOptionValuesSelect as aP, ProductCategoriesSelect as aQ, ProductTagsSelect as aR, ProductCollectionsSelect as aS, BrandsSelect as aT, BrandLogosSelect as aU, OrdersSelect as aV, OrderItemsSelect as aW, TransactionsSelect as aX, OrderStatusLogsSelect as aY, FulfillmentsSelect as aZ, FulfillmentItemsSelect as a_, GalleryCategory as aa, GalleryTag as ab, GalleryItem as ac, Link as ad, LinkCategory as ae, LinkTag as af, Canvase as ag, CanvasCategory as ah, CanvasTag as ai, CanvasNodeType as aj, CanvasEdgeType as ak, Thread as al, ThreadCategory as am, Comment as an, Reaction as ao, ReactionType as ap, Bookmark as aq, Report as ar, CommunityBan as as, FormSubmission as at, PayloadKv as au, PayloadLockedDocument as av, PayloadPreference as aw, PayloadMigration as ax, UsersSelect as ay, FieldConfigsSelect as az, Fulfillment as b, ReturnItemsSelect as b0, ShippingPoliciesSelect as b1, CustomersSelect as b2, CustomerAddressesSelect as b3, CustomerGroupsSelect as b4, CartsSelect as b5, CartItemsSelect as b6, DiscountsSelect as b7, PostsSelect as b8, PostAuthorsSelect as b9, LiveStreamsSelect as bA, ThreadsSelect as bB, CommentsSelect as bC, ReactionsSelect as bD, ReactionTypesSelect as bE, BookmarksSelect as bF, ThreadCategoriesSelect as bG, ReportsSelect as bH, CommunityBansSelect as bI, FormsSelect as bJ, FormSubmissionsSelect as bK, PayloadKvSelect as bL, PayloadLockedDocumentsSelect as bM, PayloadPreferencesSelect as bN, PayloadMigrationsSelect as bO, CollectionsWidget as bP, Auth as bQ, PostCategoriesSelect as ba, PostTagsSelect as bb, DocumentsSelect as bc, DocumentCategoriesSelect as bd, DocumentTypesSelect as be, PlaylistsSelect as bf, PlaylistCategoriesSelect as bg, PlaylistTagsSelect as bh, MusicsSelect as bi, MusicCategoriesSelect as bj, MusicTagsSelect as bk, GalleriesSelect as bl, GalleryCategoriesSelect as bm, GalleryTagsSelect as bn, GalleryItemsSelect as bo, LinksSelect as bp, LinkCategoriesSelect as bq, LinkTagsSelect as br, CanvasesSelect as bs, CanvasNodeTypesSelect as bt, CanvasEdgeTypesSelect as bu, CanvasCategoriesSelect as bv, CanvasTagsSelect as bw, VideosSelect as bx, VideoCategoriesSelect as by, VideoTagsSelect as bz, Cart as c, CartItem as d, CustomerAuthOperations as e, PlayerBlock as f, CodeBlock as g, User as h, Tenant as i, Image as j, FieldConfig as k, SystemMedia as l, ApiKey as m, PersonalAccessToken as n, TenantMetadatum as o, ApiUsage as p, Subscription as q, BillingHistory as r, TenantLogo as s, VideoCategory as t, VideoTag as u, ProductVariant as v, ProductOptionValue as w, ProductOption as x, ProductCategory as y, ProductTag as z };
@@ -11,7 +11,7 @@ interface RealtimeEvent {
11
11
  type RealtimeListener = (event: RealtimeEvent) => void;
12
12
  declare class RealtimeConnection {
13
13
  private baseUrl;
14
- private clientKey;
14
+ private publishableKey;
15
15
  private getToken;
16
16
  private collections?;
17
17
  private abortController;
@@ -20,7 +20,7 @@ declare class RealtimeConnection {
20
20
  private reconnectTimer;
21
21
  private listeners;
22
22
  private _connected;
23
- constructor(baseUrl: string, clientKey: string, getToken: () => string | null, collections?: string[] | undefined);
23
+ constructor(baseUrl: string, publishableKey: string, getToken: () => string | null, collections?: string[] | undefined);
24
24
  get connected(): boolean;
25
25
  addListener(fn: RealtimeListener): () => void;
26
26
  connect(): void;
@@ -11,7 +11,7 @@ interface RealtimeEvent {
11
11
  type RealtimeListener = (event: RealtimeEvent) => void;
12
12
  declare class RealtimeConnection {
13
13
  private baseUrl;
14
- private clientKey;
14
+ private publishableKey;
15
15
  private getToken;
16
16
  private collections?;
17
17
  private abortController;
@@ -20,7 +20,7 @@ declare class RealtimeConnection {
20
20
  private reconnectTimer;
21
21
  private listeners;
22
22
  private _connected;
23
- constructor(baseUrl: string, clientKey: string, getToken: () => string | null, collections?: string[] | undefined);
23
+ constructor(baseUrl: string, publishableKey: string, getToken: () => string | null, collections?: string[] | undefined);
24
24
  get connected(): boolean;
25
25
  addListener(fn: RealtimeListener): () => void;
26
26
  connect(): void;
package/dist/realtime.cjs CHANGED
@@ -35,9 +35,9 @@ var MAX_RECONNECT_DELAY = 3e4;
35
35
  var RECONNECT_BACKOFF_FACTOR = 2;
36
36
  var MAX_NO_TOKEN_RETRIES = 5;
37
37
  var RealtimeConnection = class {
38
- constructor(baseUrl, clientKey, getToken, collections) {
38
+ constructor(baseUrl, publishableKey, getToken, collections) {
39
39
  this.baseUrl = baseUrl;
40
- this.clientKey = clientKey;
40
+ this.publishableKey = publishableKey;
41
41
  this.getToken = getToken;
42
42
  this.collections = collections;
43
43
  this.abortController = null;
@@ -90,7 +90,7 @@ var RealtimeConnection = class {
90
90
  try {
91
91
  const response = await fetch(url, {
92
92
  headers: {
93
- "X-Client-Key": this.clientKey,
93
+ "X-Publishable-Key": this.publishableKey,
94
94
  Authorization: `Bearer ${token}`
95
95
  },
96
96
  signal
@@ -200,17 +200,18 @@ function collectionKeys(collection) {
200
200
 
201
201
  // src/core/query/realtime-hooks.ts
202
202
  function useRealtimeQuery(options) {
203
- const { clientKey, getToken, collections, enabled = true } = options;
203
+ const { getToken, collections, enabled = true } = options;
204
+ const publishableKey = options.publishableKey;
204
205
  const queryClient = (0, import_react_query.useQueryClient)();
205
206
  const [connected, setConnected] = (0, import_react.useState)(false);
206
207
  const [lastEvent, setLastEvent] = (0, import_react.useState)(null);
207
208
  const connectionRef = (0, import_react.useRef)(null);
208
209
  (0, import_react.useEffect)(() => {
209
- if (!enabled || !clientKey) return;
210
+ if (!enabled || !publishableKey) return;
210
211
  const baseUrl = resolveApiUrl();
211
212
  const conn = new RealtimeConnection(
212
213
  baseUrl,
213
- clientKey,
214
+ publishableKey,
214
215
  getToken,
215
216
  collections
216
217
  );
@@ -231,7 +232,7 @@ function useRealtimeQuery(options) {
231
232
  connectionRef.current = null;
232
233
  setConnected(false);
233
234
  };
234
- }, [clientKey, enabled, collections?.join(",")]);
235
+ }, [publishableKey, enabled, collections?.join(",")]);
235
236
  return { connected, lastEvent };
236
237
  }
237
238
  //# sourceMappingURL=realtime.cjs.map
@@ -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 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 ClientConfig {\n clientKey: string\n /**\n * Customer authentication options.\n * Used to initialize CustomerAuth on Client.\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 ClientConfig {\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 /** Per-collection field selection for populated relationships (keyed by collection slug) */\n populate?: Record<string, boolean | Record<string, boolean>>\n /** Join field control: pagination/filter per join, or false to disable */\n joins?:\n | Record<\n string,\n | {\n limit?: number\n page?: number\n sort?: string\n where?: Where\n count?: boolean\n }\n | false\n >\n | false\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,IAA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AU;AAAA,IACxC,UAAU,CAAC,YACT,CAAC,YAAY,YAAY,OAAO;AAAA,EACpC;AACF;;;AHqBO,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,aAAa,KAAK,GAAG,CAAC,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 * publishableKey: 'your-key',\n * getToken: () => client.customer.getToken(),\n * collections: ['products', 'orders'],\n * })\n * ```\n */\nexport function useRealtimeQuery(options: {\n publishableKey: string\n getToken: () => string | null\n collections?: PublicCollection[]\n enabled?: boolean\n}): UseRealtimeQueryResult {\n const { getToken, collections, enabled = true } = options\n const publishableKey = options.publishableKey\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 || !publishableKey) return\n\n const baseUrl = resolveApiUrl()\n const conn = new RealtimeConnection(\n baseUrl,\n publishableKey,\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 }, [publishableKey, 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 publishableKey: 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-Publishable-Key': this.publishableKey,\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 ClientConfig {\n publishableKey: string\n /**\n * Customer authentication options.\n * Used to initialize CustomerAuth on Client.\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\n// Server client: requires both publishableKey (for CDN routing + rate limit +\n// monthly quota enforcement via the edge proxy) and secretKey (sk01_ opaque\n// bearer token, the authentication credential).\n// The proxy keys its tenant lookup off `X-Publishable-Key`, so omitting\n// publishableKey would silently bypass rate limiting and plan-based quota\n// enforcement.\nexport interface ClientServerConfig extends ClientConfig {\n secretKey: string\n}\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 /** Per-collection field selection for populated relationships (keyed by collection slug) */\n populate?: Record<string, boolean | Record<string, boolean>>\n /** Join field control: pagination/filter per join, or false to disable */\n joins?:\n | Record<\n string,\n | {\n limit?: number\n page?: number\n sort?: string\n where?: Where\n count?: boolean\n }\n | false\n >\n | false\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,gBACA,UACA,aACR;AAJQ;AACA;AACA;AACA;AAXV,SAAQ,kBAA0C;AAClD,SAAQ,mBAAmB;AAC3B,SAAQ,kBAAkB;AAC1B,SAAQ,iBAAuD;AAC/D,SAAQ,YAAY,oBAAI,IAAsB;AAC9C,SAAQ,aAAa;AAAA,EAOlB;AAAA,EAEH,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,IAAkC;AAC5C,SAAK,UAAU,IAAI,EAAE;AACrB,WAAO,MAAM,KAAK,UAAU,OAAO,EAAE;AAAA,EACvC;AAAA,EAEA,UAAgB;AACd,QAAI,KAAK,gBAAiB;AAE1B,SAAK,kBAAkB,IAAI,gBAAgB;AAC3C,SAAK,YAAY,KAAK,gBAAgB,MAAM;AAAA,EAC9C;AAAA,EAEA,aAAmB;AACjB,SAAK,aAAa;AAClB,QAAI,KAAK,gBAAgB;AACvB,mBAAa,KAAK,cAAc;AAChC,WAAK,iBAAiB;AAAA,IACx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AC;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,gBAAgB,SAAS,aAAa,KAAK,GAAG,CAAC,CAAC;AAEpD,SAAO,EAAE,WAAW,UAAU;AAChC;","names":[]}
@@ -1,7 +1,7 @@
1
- import { R as RealtimeEvent } from './realtime-DupPIYx-.cjs';
2
- export { a as RealtimeConnection, b as RealtimeListener } from './realtime-DupPIYx-.cjs';
3
- import { P as PublicCollection } from './const-dv0zuAxG.cjs';
4
- import './payload-types-FfZ2Zxp1.cjs';
1
+ import { R as RealtimeEvent } from './realtime-D7HtUpqt.cjs';
2
+ export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
3
+ import { P as PublicCollection } from './const-DZ04SC2y.cjs';
4
+ import './payload-types-DICC2-Zr.cjs';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
@@ -22,14 +22,14 @@ interface UseRealtimeQueryResult {
22
22
  * @example
23
23
  * ```tsx
24
24
  * const { connected } = useRealtimeQuery({
25
- * clientKey: 'your-key',
25
+ * publishableKey: 'your-key',
26
26
  * getToken: () => client.customer.getToken(),
27
27
  * collections: ['products', 'orders'],
28
28
  * })
29
29
  * ```
30
30
  */
31
31
  declare function useRealtimeQuery(options: {
32
- clientKey: string;
32
+ publishableKey: string;
33
33
  getToken: () => string | null;
34
34
  collections?: PublicCollection[];
35
35
  enabled?: boolean;