@01.software/sdk 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -71
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/const-CMdmNgEs.d.ts +34 -0
- package/dist/const-Cgd4op4V.d.cts +34 -0
- package/dist/index.cjs +50 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +50 -8
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DeLBmtzd.d.cts → payload-types-D8-G1PiT.d.cts} +129 -8
- package/dist/{payload-types-DeLBmtzd.d.ts → payload-types-D8-G1PiT.d.ts} +129 -8
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js.map +1 -1
- package/dist/{server-BARh_6zH.d.ts → server-D7FcHj7J.d.ts} +35 -12
- package/dist/{server-BcQr-nGn.d.cts → server-DJcDyOmM.d.cts} +35 -12
- package/dist/server.cjs +9 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +9 -1
- package/dist/server.js.map +1 -1
- package/dist/{types-D7iFEsPc.d.cts → types-BQqfXbB2.d.ts} +18 -2
- package/dist/{types-KkuKwsli.d.ts → types-C_kwEIvY.d.cts} +18 -2
- package/dist/ui/code-block.cjs.map +1 -1
- package/dist/ui/code-block.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/rich-text.cjs +170 -10
- package/dist/ui/rich-text.cjs.map +1 -1
- package/dist/ui/rich-text.d.cts +22 -3
- package/dist/ui/rich-text.d.ts +22 -3
- package/dist/ui/rich-text.js +165 -5
- package/dist/ui/rich-text.js.map +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +5 -4
- package/dist/const-CfcjPbOu.d.ts +0 -24
- package/dist/const-DraU44bA.d.cts +0 -24
|
@@ -51,6 +51,7 @@ interface Config {
|
|
|
51
51
|
'shipping-policies': ShippingPolicy;
|
|
52
52
|
customers: Customer;
|
|
53
53
|
'customer-profiles': CustomerProfile;
|
|
54
|
+
'customer-profile-lists': CustomerProfileList;
|
|
54
55
|
'customer-addresses': CustomerAddress;
|
|
55
56
|
'customer-groups': CustomerGroup;
|
|
56
57
|
carts: Cart;
|
|
@@ -199,6 +200,7 @@ interface Config {
|
|
|
199
200
|
'shipping-policies': ShippingPoliciesSelect<false> | ShippingPoliciesSelect<true>;
|
|
200
201
|
customers: CustomersSelect<false> | CustomersSelect<true>;
|
|
201
202
|
'customer-profiles': CustomerProfilesSelect<false> | CustomerProfilesSelect<true>;
|
|
203
|
+
'customer-profile-lists': CustomerProfileListsSelect<false> | CustomerProfileListsSelect<true>;
|
|
202
204
|
'customer-addresses': CustomerAddressesSelect<false> | CustomerAddressesSelect<true>;
|
|
203
205
|
'customer-groups': CustomerGroupsSelect<false> | CustomerGroupsSelect<true>;
|
|
204
206
|
carts: CartsSelect<false> | CartsSelect<true>;
|
|
@@ -589,7 +591,7 @@ interface Image {
|
|
|
589
591
|
interface FieldConfig {
|
|
590
592
|
id: string;
|
|
591
593
|
tenant?: (string | null) | Tenant;
|
|
592
|
-
collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-option-values' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'carts' | 'transactions' | 'fulfillments' | 'returns' | 'customers' | 'customer-groups' | 'customer-profiles' | 'article-authors' | 'articles' | 'article-categories' | 'article-tags' | 'documents' | 'document-categories' | 'document-types' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'tracks' | 'track-categories' | 'track-tags' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'gallery-items' | 'links' | 'link-categories' | 'link-tags' | 'canvases' | 'canvas-categories' | 'canvas-tags' | 'canvas-node-types' | 'canvas-edge-types' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams' | 'forms' | 'posts' | 'comments' | 'reactions' | 'reaction-types' | 'bookmarks' | 'post-categories' | 'event-calendars' | 'events' | 'event-categories' | 'event-tags' | 'event-occurrences' | 'event-registrations';
|
|
594
|
+
collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-option-values' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'carts' | 'transactions' | 'fulfillments' | 'returns' | 'customers' | 'customer-groups' | 'customer-profiles' | 'customer-profile-lists' | 'article-authors' | 'articles' | 'article-categories' | 'article-tags' | 'documents' | 'document-categories' | 'document-types' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'tracks' | 'track-categories' | 'track-tags' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'gallery-items' | 'links' | 'link-categories' | 'link-tags' | 'canvases' | 'canvas-categories' | 'canvas-tags' | 'canvas-node-types' | 'canvas-edge-types' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams' | 'forms' | 'posts' | 'comments' | 'reactions' | 'reaction-types' | 'bookmarks' | 'post-categories' | 'event-calendars' | 'events' | 'event-categories' | 'event-tags' | 'event-occurrences' | 'event-registrations';
|
|
593
595
|
isHidden?: boolean | null;
|
|
594
596
|
hiddenFields?: {
|
|
595
597
|
[k: string]: unknown;
|
|
@@ -1977,7 +1979,7 @@ interface ProductVariant {
|
|
|
1977
1979
|
isUnlimited?: boolean | null;
|
|
1978
1980
|
stock?: number | null;
|
|
1979
1981
|
/**
|
|
1980
|
-
* Paid orders in transit (
|
|
1982
|
+
* Paid orders in transit (available quantity is stock - reservedStock)
|
|
1981
1983
|
*/
|
|
1982
1984
|
reservedStock?: number | null;
|
|
1983
1985
|
/**
|
|
@@ -2020,11 +2022,17 @@ interface ProductOptionValue {
|
|
|
2020
2022
|
* Display label (e.g. Black, S)
|
|
2021
2023
|
*/
|
|
2022
2024
|
value: string;
|
|
2025
|
+
/**
|
|
2026
|
+
* Color swatch for this option value (for example #111111)
|
|
2027
|
+
*/
|
|
2028
|
+
swatchColor?: string | null;
|
|
2023
2029
|
/**
|
|
2024
2030
|
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2025
2031
|
*/
|
|
2026
2032
|
generateSlug?: boolean | null;
|
|
2027
2033
|
slug?: string | null;
|
|
2034
|
+
thumbnail?: (string | null) | Image;
|
|
2035
|
+
images?: (string | Image)[] | null;
|
|
2028
2036
|
metadata?: {
|
|
2029
2037
|
[k: string]: unknown;
|
|
2030
2038
|
} | unknown[] | string | number | boolean | null;
|
|
@@ -2589,6 +2597,29 @@ interface CustomerGroup {
|
|
|
2589
2597
|
color?: string | null;
|
|
2590
2598
|
image?: (string | null) | Image;
|
|
2591
2599
|
isActive?: boolean | null;
|
|
2600
|
+
/**
|
|
2601
|
+
* Show this group as a customer-facing membership badge. The group collection itself remains private.
|
|
2602
|
+
*/
|
|
2603
|
+
customerVisible?: boolean | null;
|
|
2604
|
+
/**
|
|
2605
|
+
* Customer-facing label. Falls back to title when empty.
|
|
2606
|
+
*/
|
|
2607
|
+
publicTitle?: string | null;
|
|
2608
|
+
publicDescription?: string | null;
|
|
2609
|
+
publicBenefits?: {
|
|
2610
|
+
title?: string | null;
|
|
2611
|
+
description?: string | null;
|
|
2612
|
+
id?: string | null;
|
|
2613
|
+
}[] | null;
|
|
2614
|
+
/**
|
|
2615
|
+
* Customer-facing badge color. Example: #2563eb
|
|
2616
|
+
*/
|
|
2617
|
+
badgeColor?: string | null;
|
|
2618
|
+
badgeImage?: (string | null) | Image;
|
|
2619
|
+
/**
|
|
2620
|
+
* Customer membership display order. Lower values appear first.
|
|
2621
|
+
*/
|
|
2622
|
+
displayOrder?: number | null;
|
|
2592
2623
|
metadata?: {
|
|
2593
2624
|
[k: string]: unknown;
|
|
2594
2625
|
} | unknown[] | string | number | boolean | null;
|
|
@@ -2930,6 +2961,47 @@ interface OrderStatusLog {
|
|
|
2930
2961
|
updatedAt: string;
|
|
2931
2962
|
createdAt: string;
|
|
2932
2963
|
}
|
|
2964
|
+
/**
|
|
2965
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
2966
|
+
* via the `definition` "customer-profile-lists".
|
|
2967
|
+
*/
|
|
2968
|
+
interface CustomerProfileList {
|
|
2969
|
+
id: string;
|
|
2970
|
+
_order?: string | null;
|
|
2971
|
+
tenant?: (string | null) | Tenant;
|
|
2972
|
+
title: string;
|
|
2973
|
+
/**
|
|
2974
|
+
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2975
|
+
*/
|
|
2976
|
+
generateSlug?: boolean | null;
|
|
2977
|
+
slug?: string | null;
|
|
2978
|
+
/**
|
|
2979
|
+
* Short summary for listing/cards
|
|
2980
|
+
*/
|
|
2981
|
+
description?: string | null;
|
|
2982
|
+
isActive?: boolean | null;
|
|
2983
|
+
visibility?: ('public' | 'private') | null;
|
|
2984
|
+
displayMode?: ('grid' | 'list' | 'ranking') | null;
|
|
2985
|
+
sortMode?: ('manual' | 'score') | null;
|
|
2986
|
+
entries?: {
|
|
2987
|
+
profile?: (string | null) | CustomerProfile;
|
|
2988
|
+
label?: string | null;
|
|
2989
|
+
caption?: string | null;
|
|
2990
|
+
score?: number | null;
|
|
2991
|
+
badgeColor?: string | null;
|
|
2992
|
+
badgeImage?: (string | null) | Image;
|
|
2993
|
+
publicMetadata?: {
|
|
2994
|
+
[k: string]: unknown;
|
|
2995
|
+
} | unknown[] | string | number | boolean | null;
|
|
2996
|
+
id?: string | null;
|
|
2997
|
+
}[] | null;
|
|
2998
|
+
metadata?: {
|
|
2999
|
+
[k: string]: unknown;
|
|
3000
|
+
} | unknown[] | string | number | boolean | null;
|
|
3001
|
+
updatedAt: string;
|
|
3002
|
+
createdAt: string;
|
|
3003
|
+
deletedAt?: string | null;
|
|
3004
|
+
}
|
|
2933
3005
|
/**
|
|
2934
3006
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
2935
3007
|
* via the `definition` "carts".
|
|
@@ -4030,7 +4102,7 @@ interface Canvase {
|
|
|
4030
4102
|
*/
|
|
4031
4103
|
description?: string | null;
|
|
4032
4104
|
videos?: (string | Video)[] | null;
|
|
4033
|
-
canvas
|
|
4105
|
+
canvas?: {
|
|
4034
4106
|
[k: string]: unknown;
|
|
4035
4107
|
} | unknown[] | string | number | boolean | null;
|
|
4036
4108
|
categories?: (string | CanvasCategory)[] | null;
|
|
@@ -4312,7 +4384,7 @@ interface Post {
|
|
|
4312
4384
|
id: string;
|
|
4313
4385
|
_order?: string | null;
|
|
4314
4386
|
tenant?: (string | null) | Tenant;
|
|
4315
|
-
title
|
|
4387
|
+
title?: string | null;
|
|
4316
4388
|
content?: {
|
|
4317
4389
|
root: {
|
|
4318
4390
|
type: string;
|
|
@@ -4337,6 +4409,7 @@ interface Post {
|
|
|
4337
4409
|
hasNextPage?: boolean;
|
|
4338
4410
|
totalDocs?: number;
|
|
4339
4411
|
};
|
|
4412
|
+
displayTitle?: string | null;
|
|
4340
4413
|
status?: ('draft' | 'published' | 'archived') | null;
|
|
4341
4414
|
/**
|
|
4342
4415
|
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
@@ -4344,9 +4417,9 @@ interface Post {
|
|
|
4344
4417
|
generateSlug?: boolean | null;
|
|
4345
4418
|
slug?: string | null;
|
|
4346
4419
|
thumbnail?: (string | null) | Image;
|
|
4347
|
-
authorProfile
|
|
4348
|
-
authorSnapshot
|
|
4349
|
-
displayName
|
|
4420
|
+
authorProfile?: (string | null) | CustomerProfile;
|
|
4421
|
+
authorSnapshot?: {
|
|
4422
|
+
displayName?: string | null;
|
|
4350
4423
|
handle?: string | null;
|
|
4351
4424
|
avatar?: (string | null) | Image;
|
|
4352
4425
|
avatarUrl?: string | null;
|
|
@@ -5317,6 +5390,9 @@ interface PayloadLockedDocument {
|
|
|
5317
5390
|
} | null) | ({
|
|
5318
5391
|
relationTo: 'customer-profiles';
|
|
5319
5392
|
value: string | CustomerProfile;
|
|
5393
|
+
} | null) | ({
|
|
5394
|
+
relationTo: 'customer-profile-lists';
|
|
5395
|
+
value: string | CustomerProfileList;
|
|
5320
5396
|
} | null) | ({
|
|
5321
5397
|
relationTo: 'customer-addresses';
|
|
5322
5398
|
value: string | CustomerAddress;
|
|
@@ -6334,8 +6410,11 @@ interface ProductOptionValuesSelect<T extends boolean = true> {
|
|
|
6334
6410
|
tenant?: T;
|
|
6335
6411
|
option?: T;
|
|
6336
6412
|
value?: T;
|
|
6413
|
+
swatchColor?: T;
|
|
6337
6414
|
generateSlug?: T;
|
|
6338
6415
|
slug?: T;
|
|
6416
|
+
thumbnail?: T;
|
|
6417
|
+
images?: T;
|
|
6339
6418
|
metadata?: T;
|
|
6340
6419
|
updatedAt?: T;
|
|
6341
6420
|
createdAt?: T;
|
|
@@ -6867,6 +6946,36 @@ interface CustomerProfilesSelect<T extends boolean = true> {
|
|
|
6867
6946
|
anonymizedAt?: T;
|
|
6868
6947
|
metadata?: T;
|
|
6869
6948
|
}
|
|
6949
|
+
/**
|
|
6950
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
6951
|
+
* via the `definition` "customer-profile-lists_select".
|
|
6952
|
+
*/
|
|
6953
|
+
interface CustomerProfileListsSelect<T extends boolean = true> {
|
|
6954
|
+
_order?: T;
|
|
6955
|
+
tenant?: T;
|
|
6956
|
+
title?: T;
|
|
6957
|
+
generateSlug?: T;
|
|
6958
|
+
slug?: T;
|
|
6959
|
+
description?: T;
|
|
6960
|
+
isActive?: T;
|
|
6961
|
+
visibility?: T;
|
|
6962
|
+
displayMode?: T;
|
|
6963
|
+
sortMode?: T;
|
|
6964
|
+
entries?: T | {
|
|
6965
|
+
profile?: T;
|
|
6966
|
+
label?: T;
|
|
6967
|
+
caption?: T;
|
|
6968
|
+
score?: T;
|
|
6969
|
+
badgeColor?: T;
|
|
6970
|
+
badgeImage?: T;
|
|
6971
|
+
publicMetadata?: T;
|
|
6972
|
+
id?: T;
|
|
6973
|
+
};
|
|
6974
|
+
metadata?: T;
|
|
6975
|
+
updatedAt?: T;
|
|
6976
|
+
createdAt?: T;
|
|
6977
|
+
deletedAt?: T;
|
|
6978
|
+
}
|
|
6870
6979
|
/**
|
|
6871
6980
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
6872
6981
|
* via the `definition` "customer-addresses_select".
|
|
@@ -6906,6 +7015,17 @@ interface CustomerGroupsSelect<T extends boolean = true> {
|
|
|
6906
7015
|
color?: T;
|
|
6907
7016
|
image?: T;
|
|
6908
7017
|
isActive?: T;
|
|
7018
|
+
customerVisible?: T;
|
|
7019
|
+
publicTitle?: T;
|
|
7020
|
+
publicDescription?: T;
|
|
7021
|
+
publicBenefits?: T | {
|
|
7022
|
+
title?: T;
|
|
7023
|
+
description?: T;
|
|
7024
|
+
id?: T;
|
|
7025
|
+
};
|
|
7026
|
+
badgeColor?: T;
|
|
7027
|
+
badgeImage?: T;
|
|
7028
|
+
displayOrder?: T;
|
|
6909
7029
|
metadata?: T;
|
|
6910
7030
|
customers?: T;
|
|
6911
7031
|
updatedAt?: T;
|
|
@@ -7843,6 +7963,7 @@ interface PostsSelect<T extends boolean = true> {
|
|
|
7843
7963
|
content?: T;
|
|
7844
7964
|
categories?: T;
|
|
7845
7965
|
comments?: T;
|
|
7966
|
+
displayTitle?: T;
|
|
7846
7967
|
status?: T;
|
|
7847
7968
|
generateSlug?: T;
|
|
7848
7969
|
slug?: T;
|
|
@@ -8437,4 +8558,4 @@ declare module 'payload' {
|
|
|
8437
8558
|
}
|
|
8438
8559
|
}
|
|
8439
8560
|
|
|
8440
|
-
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V,
|
|
8561
|
+
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V, CustomerProfileList as a, Comment as b, Config as c, Cart as d, CartItem as e, Product as f, ArticleAuthor as g, ArticleCategory as h, ArticleTag as i, PostCategory as j, ProductVariant as k, OrderItem as l, Transaction as m, Fulfillment as n, Return as o };
|
|
@@ -51,6 +51,7 @@ interface Config {
|
|
|
51
51
|
'shipping-policies': ShippingPolicy;
|
|
52
52
|
customers: Customer;
|
|
53
53
|
'customer-profiles': CustomerProfile;
|
|
54
|
+
'customer-profile-lists': CustomerProfileList;
|
|
54
55
|
'customer-addresses': CustomerAddress;
|
|
55
56
|
'customer-groups': CustomerGroup;
|
|
56
57
|
carts: Cart;
|
|
@@ -199,6 +200,7 @@ interface Config {
|
|
|
199
200
|
'shipping-policies': ShippingPoliciesSelect<false> | ShippingPoliciesSelect<true>;
|
|
200
201
|
customers: CustomersSelect<false> | CustomersSelect<true>;
|
|
201
202
|
'customer-profiles': CustomerProfilesSelect<false> | CustomerProfilesSelect<true>;
|
|
203
|
+
'customer-profile-lists': CustomerProfileListsSelect<false> | CustomerProfileListsSelect<true>;
|
|
202
204
|
'customer-addresses': CustomerAddressesSelect<false> | CustomerAddressesSelect<true>;
|
|
203
205
|
'customer-groups': CustomerGroupsSelect<false> | CustomerGroupsSelect<true>;
|
|
204
206
|
carts: CartsSelect<false> | CartsSelect<true>;
|
|
@@ -589,7 +591,7 @@ interface Image {
|
|
|
589
591
|
interface FieldConfig {
|
|
590
592
|
id: string;
|
|
591
593
|
tenant?: (string | null) | Tenant;
|
|
592
|
-
collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-option-values' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'carts' | 'transactions' | 'fulfillments' | 'returns' | 'customers' | 'customer-groups' | 'customer-profiles' | 'article-authors' | 'articles' | 'article-categories' | 'article-tags' | 'documents' | 'document-categories' | 'document-types' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'tracks' | 'track-categories' | 'track-tags' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'gallery-items' | 'links' | 'link-categories' | 'link-tags' | 'canvases' | 'canvas-categories' | 'canvas-tags' | 'canvas-node-types' | 'canvas-edge-types' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams' | 'forms' | 'posts' | 'comments' | 'reactions' | 'reaction-types' | 'bookmarks' | 'post-categories' | 'event-calendars' | 'events' | 'event-categories' | 'event-tags' | 'event-occurrences' | 'event-registrations';
|
|
594
|
+
collectionSlug: 'products' | 'product-variants' | 'product-options' | 'product-option-values' | 'product-collections' | 'product-categories' | 'product-tags' | 'brands' | 'discounts' | 'shipping-policies' | 'orders' | 'carts' | 'transactions' | 'fulfillments' | 'returns' | 'customers' | 'customer-groups' | 'customer-profiles' | 'customer-profile-lists' | 'article-authors' | 'articles' | 'article-categories' | 'article-tags' | 'documents' | 'document-categories' | 'document-types' | 'playlists' | 'playlist-categories' | 'playlist-tags' | 'tracks' | 'track-categories' | 'track-tags' | 'galleries' | 'gallery-categories' | 'gallery-tags' | 'gallery-items' | 'links' | 'link-categories' | 'link-tags' | 'canvases' | 'canvas-categories' | 'canvas-tags' | 'canvas-node-types' | 'canvas-edge-types' | 'videos' | 'video-categories' | 'video-tags' | 'live-streams' | 'forms' | 'posts' | 'comments' | 'reactions' | 'reaction-types' | 'bookmarks' | 'post-categories' | 'event-calendars' | 'events' | 'event-categories' | 'event-tags' | 'event-occurrences' | 'event-registrations';
|
|
593
595
|
isHidden?: boolean | null;
|
|
594
596
|
hiddenFields?: {
|
|
595
597
|
[k: string]: unknown;
|
|
@@ -1977,7 +1979,7 @@ interface ProductVariant {
|
|
|
1977
1979
|
isUnlimited?: boolean | null;
|
|
1978
1980
|
stock?: number | null;
|
|
1979
1981
|
/**
|
|
1980
|
-
* Paid orders in transit (
|
|
1982
|
+
* Paid orders in transit (available quantity is stock - reservedStock)
|
|
1981
1983
|
*/
|
|
1982
1984
|
reservedStock?: number | null;
|
|
1983
1985
|
/**
|
|
@@ -2020,11 +2022,17 @@ interface ProductOptionValue {
|
|
|
2020
2022
|
* Display label (e.g. Black, S)
|
|
2021
2023
|
*/
|
|
2022
2024
|
value: string;
|
|
2025
|
+
/**
|
|
2026
|
+
* Color swatch for this option value (for example #111111)
|
|
2027
|
+
*/
|
|
2028
|
+
swatchColor?: string | null;
|
|
2023
2029
|
/**
|
|
2024
2030
|
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2025
2031
|
*/
|
|
2026
2032
|
generateSlug?: boolean | null;
|
|
2027
2033
|
slug?: string | null;
|
|
2034
|
+
thumbnail?: (string | null) | Image;
|
|
2035
|
+
images?: (string | Image)[] | null;
|
|
2028
2036
|
metadata?: {
|
|
2029
2037
|
[k: string]: unknown;
|
|
2030
2038
|
} | unknown[] | string | number | boolean | null;
|
|
@@ -2589,6 +2597,29 @@ interface CustomerGroup {
|
|
|
2589
2597
|
color?: string | null;
|
|
2590
2598
|
image?: (string | null) | Image;
|
|
2591
2599
|
isActive?: boolean | null;
|
|
2600
|
+
/**
|
|
2601
|
+
* Show this group as a customer-facing membership badge. The group collection itself remains private.
|
|
2602
|
+
*/
|
|
2603
|
+
customerVisible?: boolean | null;
|
|
2604
|
+
/**
|
|
2605
|
+
* Customer-facing label. Falls back to title when empty.
|
|
2606
|
+
*/
|
|
2607
|
+
publicTitle?: string | null;
|
|
2608
|
+
publicDescription?: string | null;
|
|
2609
|
+
publicBenefits?: {
|
|
2610
|
+
title?: string | null;
|
|
2611
|
+
description?: string | null;
|
|
2612
|
+
id?: string | null;
|
|
2613
|
+
}[] | null;
|
|
2614
|
+
/**
|
|
2615
|
+
* Customer-facing badge color. Example: #2563eb
|
|
2616
|
+
*/
|
|
2617
|
+
badgeColor?: string | null;
|
|
2618
|
+
badgeImage?: (string | null) | Image;
|
|
2619
|
+
/**
|
|
2620
|
+
* Customer membership display order. Lower values appear first.
|
|
2621
|
+
*/
|
|
2622
|
+
displayOrder?: number | null;
|
|
2592
2623
|
metadata?: {
|
|
2593
2624
|
[k: string]: unknown;
|
|
2594
2625
|
} | unknown[] | string | number | boolean | null;
|
|
@@ -2930,6 +2961,47 @@ interface OrderStatusLog {
|
|
|
2930
2961
|
updatedAt: string;
|
|
2931
2962
|
createdAt: string;
|
|
2932
2963
|
}
|
|
2964
|
+
/**
|
|
2965
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
2966
|
+
* via the `definition` "customer-profile-lists".
|
|
2967
|
+
*/
|
|
2968
|
+
interface CustomerProfileList {
|
|
2969
|
+
id: string;
|
|
2970
|
+
_order?: string | null;
|
|
2971
|
+
tenant?: (string | null) | Tenant;
|
|
2972
|
+
title: string;
|
|
2973
|
+
/**
|
|
2974
|
+
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
2975
|
+
*/
|
|
2976
|
+
generateSlug?: boolean | null;
|
|
2977
|
+
slug?: string | null;
|
|
2978
|
+
/**
|
|
2979
|
+
* Short summary for listing/cards
|
|
2980
|
+
*/
|
|
2981
|
+
description?: string | null;
|
|
2982
|
+
isActive?: boolean | null;
|
|
2983
|
+
visibility?: ('public' | 'private') | null;
|
|
2984
|
+
displayMode?: ('grid' | 'list' | 'ranking') | null;
|
|
2985
|
+
sortMode?: ('manual' | 'score') | null;
|
|
2986
|
+
entries?: {
|
|
2987
|
+
profile?: (string | null) | CustomerProfile;
|
|
2988
|
+
label?: string | null;
|
|
2989
|
+
caption?: string | null;
|
|
2990
|
+
score?: number | null;
|
|
2991
|
+
badgeColor?: string | null;
|
|
2992
|
+
badgeImage?: (string | null) | Image;
|
|
2993
|
+
publicMetadata?: {
|
|
2994
|
+
[k: string]: unknown;
|
|
2995
|
+
} | unknown[] | string | number | boolean | null;
|
|
2996
|
+
id?: string | null;
|
|
2997
|
+
}[] | null;
|
|
2998
|
+
metadata?: {
|
|
2999
|
+
[k: string]: unknown;
|
|
3000
|
+
} | unknown[] | string | number | boolean | null;
|
|
3001
|
+
updatedAt: string;
|
|
3002
|
+
createdAt: string;
|
|
3003
|
+
deletedAt?: string | null;
|
|
3004
|
+
}
|
|
2933
3005
|
/**
|
|
2934
3006
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
2935
3007
|
* via the `definition` "carts".
|
|
@@ -4030,7 +4102,7 @@ interface Canvase {
|
|
|
4030
4102
|
*/
|
|
4031
4103
|
description?: string | null;
|
|
4032
4104
|
videos?: (string | Video)[] | null;
|
|
4033
|
-
canvas
|
|
4105
|
+
canvas?: {
|
|
4034
4106
|
[k: string]: unknown;
|
|
4035
4107
|
} | unknown[] | string | number | boolean | null;
|
|
4036
4108
|
categories?: (string | CanvasCategory)[] | null;
|
|
@@ -4312,7 +4384,7 @@ interface Post {
|
|
|
4312
4384
|
id: string;
|
|
4313
4385
|
_order?: string | null;
|
|
4314
4386
|
tenant?: (string | null) | Tenant;
|
|
4315
|
-
title
|
|
4387
|
+
title?: string | null;
|
|
4316
4388
|
content?: {
|
|
4317
4389
|
root: {
|
|
4318
4390
|
type: string;
|
|
@@ -4337,6 +4409,7 @@ interface Post {
|
|
|
4337
4409
|
hasNextPage?: boolean;
|
|
4338
4410
|
totalDocs?: number;
|
|
4339
4411
|
};
|
|
4412
|
+
displayTitle?: string | null;
|
|
4340
4413
|
status?: ('draft' | 'published' | 'archived') | null;
|
|
4341
4414
|
/**
|
|
4342
4415
|
* When enabled, the slug will auto-generate from the title field on save and autosave.
|
|
@@ -4344,9 +4417,9 @@ interface Post {
|
|
|
4344
4417
|
generateSlug?: boolean | null;
|
|
4345
4418
|
slug?: string | null;
|
|
4346
4419
|
thumbnail?: (string | null) | Image;
|
|
4347
|
-
authorProfile
|
|
4348
|
-
authorSnapshot
|
|
4349
|
-
displayName
|
|
4420
|
+
authorProfile?: (string | null) | CustomerProfile;
|
|
4421
|
+
authorSnapshot?: {
|
|
4422
|
+
displayName?: string | null;
|
|
4350
4423
|
handle?: string | null;
|
|
4351
4424
|
avatar?: (string | null) | Image;
|
|
4352
4425
|
avatarUrl?: string | null;
|
|
@@ -5317,6 +5390,9 @@ interface PayloadLockedDocument {
|
|
|
5317
5390
|
} | null) | ({
|
|
5318
5391
|
relationTo: 'customer-profiles';
|
|
5319
5392
|
value: string | CustomerProfile;
|
|
5393
|
+
} | null) | ({
|
|
5394
|
+
relationTo: 'customer-profile-lists';
|
|
5395
|
+
value: string | CustomerProfileList;
|
|
5320
5396
|
} | null) | ({
|
|
5321
5397
|
relationTo: 'customer-addresses';
|
|
5322
5398
|
value: string | CustomerAddress;
|
|
@@ -6334,8 +6410,11 @@ interface ProductOptionValuesSelect<T extends boolean = true> {
|
|
|
6334
6410
|
tenant?: T;
|
|
6335
6411
|
option?: T;
|
|
6336
6412
|
value?: T;
|
|
6413
|
+
swatchColor?: T;
|
|
6337
6414
|
generateSlug?: T;
|
|
6338
6415
|
slug?: T;
|
|
6416
|
+
thumbnail?: T;
|
|
6417
|
+
images?: T;
|
|
6339
6418
|
metadata?: T;
|
|
6340
6419
|
updatedAt?: T;
|
|
6341
6420
|
createdAt?: T;
|
|
@@ -6867,6 +6946,36 @@ interface CustomerProfilesSelect<T extends boolean = true> {
|
|
|
6867
6946
|
anonymizedAt?: T;
|
|
6868
6947
|
metadata?: T;
|
|
6869
6948
|
}
|
|
6949
|
+
/**
|
|
6950
|
+
* This interface was referenced by `Config`'s JSON-Schema
|
|
6951
|
+
* via the `definition` "customer-profile-lists_select".
|
|
6952
|
+
*/
|
|
6953
|
+
interface CustomerProfileListsSelect<T extends boolean = true> {
|
|
6954
|
+
_order?: T;
|
|
6955
|
+
tenant?: T;
|
|
6956
|
+
title?: T;
|
|
6957
|
+
generateSlug?: T;
|
|
6958
|
+
slug?: T;
|
|
6959
|
+
description?: T;
|
|
6960
|
+
isActive?: T;
|
|
6961
|
+
visibility?: T;
|
|
6962
|
+
displayMode?: T;
|
|
6963
|
+
sortMode?: T;
|
|
6964
|
+
entries?: T | {
|
|
6965
|
+
profile?: T;
|
|
6966
|
+
label?: T;
|
|
6967
|
+
caption?: T;
|
|
6968
|
+
score?: T;
|
|
6969
|
+
badgeColor?: T;
|
|
6970
|
+
badgeImage?: T;
|
|
6971
|
+
publicMetadata?: T;
|
|
6972
|
+
id?: T;
|
|
6973
|
+
};
|
|
6974
|
+
metadata?: T;
|
|
6975
|
+
updatedAt?: T;
|
|
6976
|
+
createdAt?: T;
|
|
6977
|
+
deletedAt?: T;
|
|
6978
|
+
}
|
|
6870
6979
|
/**
|
|
6871
6980
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
6872
6981
|
* via the `definition` "customer-addresses_select".
|
|
@@ -6906,6 +7015,17 @@ interface CustomerGroupsSelect<T extends boolean = true> {
|
|
|
6906
7015
|
color?: T;
|
|
6907
7016
|
image?: T;
|
|
6908
7017
|
isActive?: T;
|
|
7018
|
+
customerVisible?: T;
|
|
7019
|
+
publicTitle?: T;
|
|
7020
|
+
publicDescription?: T;
|
|
7021
|
+
publicBenefits?: T | {
|
|
7022
|
+
title?: T;
|
|
7023
|
+
description?: T;
|
|
7024
|
+
id?: T;
|
|
7025
|
+
};
|
|
7026
|
+
badgeColor?: T;
|
|
7027
|
+
badgeImage?: T;
|
|
7028
|
+
displayOrder?: T;
|
|
6909
7029
|
metadata?: T;
|
|
6910
7030
|
customers?: T;
|
|
6911
7031
|
updatedAt?: T;
|
|
@@ -7843,6 +7963,7 @@ interface PostsSelect<T extends boolean = true> {
|
|
|
7843
7963
|
content?: T;
|
|
7844
7964
|
categories?: T;
|
|
7845
7965
|
comments?: T;
|
|
7966
|
+
displayTitle?: T;
|
|
7846
7967
|
status?: T;
|
|
7847
7968
|
generateSlug?: T;
|
|
7848
7969
|
slug?: T;
|
|
@@ -8437,4 +8558,4 @@ declare module 'payload' {
|
|
|
8437
8558
|
}
|
|
8438
8559
|
}
|
|
8439
8560
|
|
|
8440
|
-
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V,
|
|
8561
|
+
export type { Article as A, CustomerProfile as C, Document as D, Form as F, Image as I, Order as O, Post as P, Reaction as R, Tenant as T, Video as V, CustomerProfileList as a, Comment as b, Config as c, Cart as d, CartItem as e, Product as f, ArticleAuthor as g, ArticleCategory as h, ArticleTag as i, PostCategory as j, ProductVariant as k, OrderItem as l, Transaction as m, Fulfillment as n, Return as o };
|
package/dist/realtime.cjs.map
CHANGED
|
@@ -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 * 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\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\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\n/**\n * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic\n * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module\n * augmentation; external SDK consumers who skip that get degenerate types\n * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.\n * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.\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 /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */\n pagination?: boolean\n /** Include draft versions (access control still applies on the server) */\n draft?: boolean\n /** Include soft-deleted documents (requires `trash` enabled on the collection) */\n trash?: 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// 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'\nimport type { ProductListingGroupsQueryOptions } from './query-hooks'\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\nexport const productKeys = {\n listingGroups: (options?: ProductListingGroupsQueryOptions) =>\n ['products', 'listing-groups', 'list', options] as const,\n listingGroupsInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n ) =>\n ['products', 'listing-groups', 'infinite', options] as const,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4C;AAC5C,yBAA+B;;;ACa/B,IAAM,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AY,UAAU,IAAI,OAAO;AAAA,IACpC,WAAW,MAAM,CAAC,YAAY,UAAU;AAAA,IACxC,UAAU,CAAC,YACT,CAAC,YAAY,YAAY,OAAO;AAAA,EACpC;AACF;;;AHoBO,SAAS,iBAAiB,SAKN;AACzB,QAAM,EAAE,UAAU,aAAa,UAAU,KAAK,IAAI;AAClD,QAAM,iBAAiB,QAAQ;AAC/B,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,eAAgB;AAEjC,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,gBAAgB,SAAS,aAAa,KAAK,GAAG,CAAC,CAAC;AAEpD,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 {\n Collection,\n PublicCollection,\n ServerCollection,\n ServerOnlyCollection,\n} from '../collection/const'\n\nexport type {\n Collection,\n PublicCollection,\n ServerCollection,\n ServerOnlyCollection,\n}\n\n// ============================================================================\n// API URL Configuration\n// ============================================================================\n\ndeclare const __DEFAULT_API_URL__: string\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\nexport interface ClientMetadata {\n userAgent?: string\n timestamp: number\n}\n\nexport interface ClientState {\n metadata: ClientMetadata\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\n/**\n * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic\n * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module\n * augmentation; external SDK consumers who skip that get degenerate types\n * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.\n * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.\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 /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */\n pagination?: boolean\n /** Include draft versions (access control still applies on the server) */\n draft?: boolean\n /** Include soft-deleted documents (requires `trash` enabled on the collection) */\n trash?: 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// 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'\nimport type { ProductListingGroupsQueryOptions } from './query-hooks'\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\nexport const productKeys = {\n listingGroups: (options?: ProductListingGroupsQueryOptions) =>\n ['products', 'listing-groups', 'list', options] as const,\n listingGroupsInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n ) =>\n ['products', 'listing-groups', 'infinite', options] 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,iBAA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/B,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,eAAgB;AAEjC,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,gBAAgB,SAAS,aAAa,KAAK,GAAG,CAAC,CAAC;AAEpD,SAAO,EAAE,WAAW,UAAU;AAChC;","names":[]}
|
package/dist/realtime.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RealtimeEvent } from './realtime-D7HtUpqt.cjs';
|
|
2
2
|
export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
|
|
3
|
-
import { P as PublicCollection } from './const-
|
|
4
|
-
import './payload-types-
|
|
3
|
+
import { P as PublicCollection } from './const-Cgd4op4V.cjs';
|
|
4
|
+
import './payload-types-D8-G1PiT.cjs';
|
|
5
5
|
|
|
6
6
|
interface UseRealtimeQueryOptions {
|
|
7
7
|
/** Filter events to specific collections. Empty/undefined = all collections. */
|
package/dist/realtime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RealtimeEvent } from './realtime-D7HtUpqt.js';
|
|
2
2
|
export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.js';
|
|
3
|
-
import { P as PublicCollection } from './const-
|
|
4
|
-
import './payload-types-
|
|
3
|
+
import { P as PublicCollection } from './const-CMdmNgEs.js';
|
|
4
|
+
import './payload-types-D8-G1PiT.js';
|
|
5
5
|
|
|
6
6
|
interface UseRealtimeQueryOptions {
|
|
7
7
|
/** Filter events to specific collections. Empty/undefined = all collections. */
|