@wix/realtime 1.0.41 → 1.0.43
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/cjs/build/publisher/publisher.context.d.ts +4 -2
- package/cjs/build/publisher/publisher.context.js +4 -2
- package/cjs/build/subscriber/subscriber.context.d.ts +10 -5
- package/cjs/build/subscriber/subscriber.context.js +10 -5
- package/dist/statics/docs-ts-model.json +148 -26
- package/es/build/publisher/publisher.context.d.ts +4 -2
- package/es/build/publisher/publisher.context.js +4 -2
- package/es/build/subscriber/subscriber.context.d.ts +10 -5
- package/es/build/subscriber/subscriber.context.js +10 -5
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Publishes a message to a channel or resource.
|
|
5
5
|
*
|
|
6
|
-
* The method publishes a message to all
|
|
6
|
+
* The method publishes a message to all subscribers on the specified channel or resource. Channels and resources are independent, so subscribers to a channel don't receive messages sent to a resource on that channel. Similarly, subscribers to a resource don't receive messages sent to its parent channel.
|
|
7
7
|
*
|
|
8
8
|
* > **Authentication**
|
|
9
9
|
* >
|
|
@@ -35,7 +35,9 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
35
35
|
* await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @param channel - Channel
|
|
38
|
+
* @param channel - Channel and resource to publish to.
|
|
39
|
+
* @requiredField channel
|
|
39
40
|
* @param payload - Message payload. Max: 10 KB.
|
|
41
|
+
* @requiredField payload
|
|
40
42
|
*/
|
|
41
43
|
export declare const publish: MaybeContext<BuildRESTFunction<typeof publicPublish> & typeof publicPublish>;
|
|
@@ -6,7 +6,7 @@ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
|
|
|
6
6
|
/**
|
|
7
7
|
* Publishes a message to a channel or resource.
|
|
8
8
|
*
|
|
9
|
-
* The method publishes a message to all
|
|
9
|
+
* The method publishes a message to all subscribers on the specified channel or resource. Channels and resources are independent, so subscribers to a channel don't receive messages sent to a resource on that channel. Similarly, subscribers to a resource don't receive messages sent to its parent channel.
|
|
10
10
|
*
|
|
11
11
|
* > **Authentication**
|
|
12
12
|
* >
|
|
@@ -38,7 +38,9 @@ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
|
|
|
38
38
|
* await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
|
|
39
39
|
* ```
|
|
40
40
|
*
|
|
41
|
-
* @param channel - Channel
|
|
41
|
+
* @param channel - Channel and resource to publish to.
|
|
42
|
+
* @requiredField channel
|
|
42
43
|
* @param payload - Message payload. Max: 10 KB.
|
|
44
|
+
* @requiredField payload
|
|
43
45
|
*/
|
|
44
46
|
exports.publish = (0, rest_modules_1.createRESTModule)(publisher_public_js_1.publish);
|
|
@@ -3,10 +3,12 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Subscribes to a channel or resource.
|
|
5
5
|
*
|
|
6
|
-
* The method attempts to establish a subscription to the specified channel or resource.
|
|
6
|
+
* The method attempts to establish a subscription to the specified channel or resource. It returns the subscription ID immediately while the subscription is attempted in the background.
|
|
7
7
|
*
|
|
8
8
|
* Use the `options` parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The `onSubscribed()` handler runs on every successful re-subscription.
|
|
9
9
|
*
|
|
10
|
+
* Learn more about the [subscription lifecycle](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle).
|
|
11
|
+
*
|
|
10
12
|
* @example Subscribe to a channel
|
|
11
13
|
* ```ts
|
|
12
14
|
* import { subscriber } from '@wix/realtime';
|
|
@@ -44,9 +46,11 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
44
46
|
* );
|
|
45
47
|
* ```
|
|
46
48
|
*
|
|
47
|
-
* @param channel - Channel
|
|
48
|
-
* @
|
|
49
|
-
* @param
|
|
49
|
+
* @param channel - Channel and resource to subscribe to.
|
|
50
|
+
* @requiredField channel
|
|
51
|
+
* @param messageHandler - Handler that runs whenever a message is published to the channel or resource.
|
|
52
|
+
* @requiredField messageHandler
|
|
53
|
+
* @param options - [Lifecycle handlers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle) for subscription events.
|
|
50
54
|
*/
|
|
51
55
|
export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubscribe> & typeof publicSubscribe>;
|
|
52
56
|
/**
|
|
@@ -87,6 +91,7 @@ export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubs
|
|
|
87
91
|
* client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
|
|
88
92
|
* ```
|
|
89
93
|
*
|
|
90
|
-
* @param options - Unsubscribe
|
|
94
|
+
* @param options - Unsubscribe details. You must specify `channel`, `subscriptionId`, or both.
|
|
95
|
+
* @requiredField options
|
|
91
96
|
*/
|
|
92
97
|
export declare const unsubscribe: MaybeContext<BuildRESTFunction<typeof publicUnsubscribe> & typeof publicUnsubscribe>;
|
|
@@ -6,10 +6,12 @@ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
|
|
|
6
6
|
/**
|
|
7
7
|
* Subscribes to a channel or resource.
|
|
8
8
|
*
|
|
9
|
-
* The method attempts to establish a subscription to the specified channel or resource.
|
|
9
|
+
* The method attempts to establish a subscription to the specified channel or resource. It returns the subscription ID immediately while the subscription is attempted in the background.
|
|
10
10
|
*
|
|
11
11
|
* Use the `options` parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The `onSubscribed()` handler runs on every successful re-subscription.
|
|
12
12
|
*
|
|
13
|
+
* Learn more about the [subscription lifecycle](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle).
|
|
14
|
+
*
|
|
13
15
|
* @example Subscribe to a channel
|
|
14
16
|
* ```ts
|
|
15
17
|
* import { subscriber } from '@wix/realtime';
|
|
@@ -47,9 +49,11 @@ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
|
|
|
47
49
|
* );
|
|
48
50
|
* ```
|
|
49
51
|
*
|
|
50
|
-
* @param channel - Channel
|
|
51
|
-
* @
|
|
52
|
-
* @param
|
|
52
|
+
* @param channel - Channel and resource to subscribe to.
|
|
53
|
+
* @requiredField channel
|
|
54
|
+
* @param messageHandler - Handler that runs whenever a message is published to the channel or resource.
|
|
55
|
+
* @requiredField messageHandler
|
|
56
|
+
* @param options - [Lifecycle handlers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle) for subscription events.
|
|
53
57
|
*/
|
|
54
58
|
exports.subscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.subscribe);
|
|
55
59
|
/**
|
|
@@ -90,6 +94,7 @@ exports.subscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.
|
|
|
90
94
|
* client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
|
|
91
95
|
* ```
|
|
92
96
|
*
|
|
93
|
-
* @param options - Unsubscribe
|
|
97
|
+
* @param options - Unsubscribe details. You must specify `channel`, `subscriptionId`, or both.
|
|
98
|
+
* @requiredField options
|
|
94
99
|
*/
|
|
95
100
|
exports.unsubscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.unsubscribe);
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"summary": [
|
|
39
39
|
{
|
|
40
40
|
"kind": "text",
|
|
41
|
-
"text": "Publishes a message to a channel or resource.\n\nThe method publishes a message to all
|
|
41
|
+
"text": "Publishes a message to a channel or resource.\n\nThe method publishes a message to all subscribers on the specified channel or resource. Channels and resources are independent, so subscribers to a channel don't receive messages sent to a resource on that channel. Similarly, subscribers to a resource don't receive messages sent to its parent channel.\n\n> **Authentication**\n>\n> This method may require higher-level permissions than the caller has, based on their [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities) and [roles and permissions](https://support.wix.com/en/article/roles-permissions-overview). In these cases, you can ensure the method is called with the required level of authorization by using [elevated permissions](https://dev.wix.com/docs/api-reference/articles/authentication/about-elevated-permissions).\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->"
|
|
42
42
|
}
|
|
43
43
|
],
|
|
44
44
|
"blockTags": [
|
|
@@ -67,6 +67,24 @@
|
|
|
67
67
|
"text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { publisher },\n // Include the auth strategy and host as relevant\n});\n\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
|
|
68
68
|
}
|
|
69
69
|
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"tag": "@requiredField",
|
|
73
|
+
"content": [
|
|
74
|
+
{
|
|
75
|
+
"kind": "text",
|
|
76
|
+
"text": "channel"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"tag": "@requiredField",
|
|
82
|
+
"content": [
|
|
83
|
+
{
|
|
84
|
+
"kind": "text",
|
|
85
|
+
"text": "payload"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
70
88
|
}
|
|
71
89
|
]
|
|
72
90
|
},
|
|
@@ -81,7 +99,7 @@
|
|
|
81
99
|
"summary": [
|
|
82
100
|
{
|
|
83
101
|
"kind": "text",
|
|
84
|
-
"text": "Channel
|
|
102
|
+
"text": "Channel and resource to publish to."
|
|
85
103
|
}
|
|
86
104
|
]
|
|
87
105
|
},
|
|
@@ -153,7 +171,7 @@
|
|
|
153
171
|
"summary": [
|
|
154
172
|
{
|
|
155
173
|
"kind": "text",
|
|
156
|
-
"text": "Publishes a message to a channel or resource.\n\nThe method publishes a message to all
|
|
174
|
+
"text": "Publishes a message to a channel or resource.\n\nThe method publishes a message to all subscribers on the specified channel or resource. Channels and resources are independent, so subscribers to a channel don't receive messages sent to a resource on that channel. Similarly, subscribers to a resource don't receive messages sent to its parent channel.\n\n> **Authentication**\n>\n> This method may require higher-level permissions than the caller has, based on their [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities) and [roles and permissions](https://support.wix.com/en/article/roles-permissions-overview). In these cases, you can ensure the method is called with the required level of authorization by using [elevated permissions](https://dev.wix.com/docs/api-reference/articles/authentication/about-elevated-permissions).\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->"
|
|
157
175
|
}
|
|
158
176
|
],
|
|
159
177
|
"blockTags": [
|
|
@@ -182,6 +200,24 @@
|
|
|
182
200
|
"text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { publisher },\n // Include the auth strategy and host as relevant\n});\n\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
|
|
183
201
|
}
|
|
184
202
|
]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"tag": "@requiredField",
|
|
206
|
+
"content": [
|
|
207
|
+
{
|
|
208
|
+
"kind": "text",
|
|
209
|
+
"text": "channel"
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"tag": "@requiredField",
|
|
215
|
+
"content": [
|
|
216
|
+
{
|
|
217
|
+
"kind": "text",
|
|
218
|
+
"text": "payload"
|
|
219
|
+
}
|
|
220
|
+
]
|
|
185
221
|
}
|
|
186
222
|
]
|
|
187
223
|
},
|
|
@@ -271,7 +307,7 @@
|
|
|
271
307
|
"summary": [
|
|
272
308
|
{
|
|
273
309
|
"kind": "text",
|
|
274
|
-
"text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the handler to the channel and to
|
|
310
|
+
"text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the handler to the channel and to all of its resources that don't have their own handler.\n\nLearn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
|
|
275
311
|
}
|
|
276
312
|
],
|
|
277
313
|
"blockTags": [
|
|
@@ -324,7 +360,7 @@
|
|
|
324
360
|
"summary": [
|
|
325
361
|
{
|
|
326
362
|
"kind": "text",
|
|
327
|
-
"text": "Channel or resource to
|
|
363
|
+
"text": "Channel or resource to add the permissions handler for."
|
|
328
364
|
}
|
|
329
365
|
]
|
|
330
366
|
},
|
|
@@ -345,7 +381,7 @@
|
|
|
345
381
|
"summary": [
|
|
346
382
|
{
|
|
347
383
|
"kind": "text",
|
|
348
|
-
"text": "Handler
|
|
384
|
+
"text": "Handler that runs when checking permissions for the specified channel."
|
|
349
385
|
}
|
|
350
386
|
]
|
|
351
387
|
},
|
|
@@ -401,7 +437,15 @@
|
|
|
401
437
|
"summary": [
|
|
402
438
|
{
|
|
403
439
|
"kind": "text",
|
|
404
|
-
"text": "Checks permissions for a subscriber on a channel or resource.\n\nRuns the
|
|
440
|
+
"text": "Checks permissions for a subscriber on a channel or resource.\n\nRuns the associated permissions handler to check whether the subscriber can receive messages on the specified channel or resource. To delegate permissions check to the router, call this method in the body of the ["
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"kind": "code",
|
|
444
|
+
"text": "`realtime_check_permission()`"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"kind": "text",
|
|
448
|
+
"text": "](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) hook."
|
|
405
449
|
}
|
|
406
450
|
],
|
|
407
451
|
"blockTags": [
|
|
@@ -553,7 +597,7 @@
|
|
|
553
597
|
"summary": [
|
|
554
598
|
{
|
|
555
599
|
"kind": "text",
|
|
556
|
-
"text": "Sets the default permissions handler.\n\nThe default handler runs
|
|
600
|
+
"text": "Sets the default permissions handler.\n\nThe default handler runs in the following cases:\n- When subscribing to a channel, when no explicit handler is set for that channel.\n- When subscribing to a resource, when no explicit handler is set for that resource or its parent channel.\n\nLearn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
|
|
557
601
|
}
|
|
558
602
|
],
|
|
559
603
|
"blockTags": [
|
|
@@ -797,7 +841,7 @@
|
|
|
797
841
|
"summary": [
|
|
798
842
|
{
|
|
799
843
|
"kind": "text",
|
|
800
|
-
"text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the handler to the channel and to any of its resources that don't have their own
|
|
844
|
+
"text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the handler to the channel and to any of its resources that don't have their own handlers. Learn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
|
|
801
845
|
}
|
|
802
846
|
],
|
|
803
847
|
"blockTags": [
|
|
@@ -918,7 +962,15 @@
|
|
|
918
962
|
"summary": [
|
|
919
963
|
{
|
|
920
964
|
"kind": "text",
|
|
921
|
-
"text": "Checks permissions for a subscriber on a channel or resource.\n\nRuns the appropriate permissions handler to check whether the subscriber can receive messages on the specified channel or resource
|
|
965
|
+
"text": "Checks permissions for a subscriber on a channel or resource.\n\nRuns the appropriate permissions handler to check whether the subscriber can receive messages on the specified channel or resource. Call this method in the body of the ["
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"kind": "code",
|
|
969
|
+
"text": "`realtime_check_permission()`"
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
"kind": "text",
|
|
973
|
+
"text": "](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) hook.\n\nLearn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
|
|
922
974
|
}
|
|
923
975
|
],
|
|
924
976
|
"blockTags": [
|
|
@@ -1059,7 +1111,7 @@
|
|
|
1059
1111
|
"summary": [
|
|
1060
1112
|
{
|
|
1061
1113
|
"kind": "text",
|
|
1062
|
-
"text": "Sets the default permissions handler.\n\nThe default handler runs
|
|
1114
|
+
"text": "Sets the default permissions handler.\n\nThe default handler runs in the following cases:\n- When subscribing to a channel, when no explicit handler is set for that channel.\n- When subscribing to a resource, when no explicit handler is set for that resource or its parent channel.\n\nLearn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
|
|
1063
1115
|
}
|
|
1064
1116
|
],
|
|
1065
1117
|
"blockTags": [
|
|
@@ -1199,7 +1251,7 @@
|
|
|
1199
1251
|
"summary": [
|
|
1200
1252
|
{
|
|
1201
1253
|
"kind": "text",
|
|
1202
|
-
"text": "Resource ID.\n\nResources are
|
|
1254
|
+
"text": "Resource ID.\n\nResources are independent sub-channels in a channel. A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa."
|
|
1203
1255
|
}
|
|
1204
1256
|
]
|
|
1205
1257
|
},
|
|
@@ -1702,7 +1754,23 @@
|
|
|
1702
1754
|
"summary": [
|
|
1703
1755
|
{
|
|
1704
1756
|
"kind": "text",
|
|
1705
|
-
"text": "Checks permissions for a subscriber on a channel or resource.\n\
|
|
1757
|
+
"text": "Checks permissions for a subscriber on a channel or resource.\n\nSet up this hook as a named export in the "
|
|
1758
|
+
},
|
|
1759
|
+
{
|
|
1760
|
+
"kind": "code",
|
|
1761
|
+
"text": "`realtime-permissions.js`"
|
|
1762
|
+
},
|
|
1763
|
+
{
|
|
1764
|
+
"kind": "text",
|
|
1765
|
+
"text": " file in a site's backend. The hook runs automatically whenever a new subscription is attempted, including [re-subscriptions after reconnection](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_reconnection-and-message-sync). Permissions are checked once per subscription attempt. Changes to permissions don't affect active subscriptions until the subscriber reconnects.\n\nCall ["
|
|
1766
|
+
},
|
|
1767
|
+
{
|
|
1768
|
+
"kind": "code",
|
|
1769
|
+
"text": "`check()`"
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
"kind": "text",
|
|
1773
|
+
"text": "](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/check) in the body of this hook to use the [Permissions Router](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) to organize permissions logic. Alternatively, you can also include permissions logic directly in the hook body.\n\nLearn more about [setting up permissions](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#setting-up-permissions)."
|
|
1706
1774
|
}
|
|
1707
1775
|
],
|
|
1708
1776
|
"blockTags": [
|
|
@@ -1882,7 +1950,7 @@
|
|
|
1882
1950
|
"summary": [
|
|
1883
1951
|
{
|
|
1884
1952
|
"kind": "text",
|
|
1885
|
-
"text": "Subscribes to a channel or resource.\n\nThe method attempts to establish a subscription to the specified channel or resource.
|
|
1953
|
+
"text": "Subscribes to a channel or resource.\n\nThe method attempts to establish a subscription to the specified channel or resource. It returns the subscription ID immediately while the subscription is attempted in the background.\n\nUse the "
|
|
1886
1954
|
},
|
|
1887
1955
|
{
|
|
1888
1956
|
"kind": "code",
|
|
@@ -1898,7 +1966,7 @@
|
|
|
1898
1966
|
},
|
|
1899
1967
|
{
|
|
1900
1968
|
"kind": "text",
|
|
1901
|
-
"text": " handler runs on every successful re-subscription."
|
|
1969
|
+
"text": " handler runs on every successful re-subscription.\n\nLearn more about the [subscription lifecycle](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle)."
|
|
1902
1970
|
}
|
|
1903
1971
|
],
|
|
1904
1972
|
"blockTags": [
|
|
@@ -1927,6 +1995,24 @@
|
|
|
1927
1995
|
"text": "```ts\nimport { createClient } from '@wix/sdk';\nimport { subscriber } from '@wix/realtime';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
|
|
1928
1996
|
}
|
|
1929
1997
|
]
|
|
1998
|
+
},
|
|
1999
|
+
{
|
|
2000
|
+
"tag": "@requiredField",
|
|
2001
|
+
"content": [
|
|
2002
|
+
{
|
|
2003
|
+
"kind": "text",
|
|
2004
|
+
"text": "channel"
|
|
2005
|
+
}
|
|
2006
|
+
]
|
|
2007
|
+
},
|
|
2008
|
+
{
|
|
2009
|
+
"tag": "@requiredField",
|
|
2010
|
+
"content": [
|
|
2011
|
+
{
|
|
2012
|
+
"kind": "text",
|
|
2013
|
+
"text": "messageHandler"
|
|
2014
|
+
}
|
|
2015
|
+
]
|
|
1930
2016
|
}
|
|
1931
2017
|
]
|
|
1932
2018
|
},
|
|
@@ -1941,7 +2027,7 @@
|
|
|
1941
2027
|
"summary": [
|
|
1942
2028
|
{
|
|
1943
2029
|
"kind": "text",
|
|
1944
|
-
"text": "Channel
|
|
2030
|
+
"text": "Channel and resource to subscribe to."
|
|
1945
2031
|
}
|
|
1946
2032
|
]
|
|
1947
2033
|
},
|
|
@@ -1962,7 +2048,7 @@
|
|
|
1962
2048
|
"summary": [
|
|
1963
2049
|
{
|
|
1964
2050
|
"kind": "text",
|
|
1965
|
-
"text": "
|
|
2051
|
+
"text": "Handler that runs whenever a message is published to the channel or resource."
|
|
1966
2052
|
}
|
|
1967
2053
|
]
|
|
1968
2054
|
},
|
|
@@ -1985,7 +2071,7 @@
|
|
|
1985
2071
|
"summary": [
|
|
1986
2072
|
{
|
|
1987
2073
|
"kind": "text",
|
|
1988
|
-
"text": "Lifecycle handlers for subscription events."
|
|
2074
|
+
"text": "[Lifecycle handlers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle) for subscription events."
|
|
1989
2075
|
}
|
|
1990
2076
|
]
|
|
1991
2077
|
},
|
|
@@ -2012,7 +2098,7 @@
|
|
|
2012
2098
|
"summary": [
|
|
2013
2099
|
{
|
|
2014
2100
|
"kind": "text",
|
|
2015
|
-
"text": "Subscribes to a channel or resource.\n\nThe method attempts to establish a subscription to the specified channel or resource.
|
|
2101
|
+
"text": "Subscribes to a channel or resource.\n\nThe method attempts to establish a subscription to the specified channel or resource. It returns the subscription ID immediately while the subscription is attempted in the background.\n\nUse the "
|
|
2016
2102
|
},
|
|
2017
2103
|
{
|
|
2018
2104
|
"kind": "code",
|
|
@@ -2028,7 +2114,7 @@
|
|
|
2028
2114
|
},
|
|
2029
2115
|
{
|
|
2030
2116
|
"kind": "text",
|
|
2031
|
-
"text": " handler runs on every successful re-subscription."
|
|
2117
|
+
"text": " handler runs on every successful re-subscription.\n\nLearn more about the [subscription lifecycle](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle)."
|
|
2032
2118
|
}
|
|
2033
2119
|
],
|
|
2034
2120
|
"blockTags": [
|
|
@@ -2057,6 +2143,24 @@
|
|
|
2057
2143
|
"text": "```ts\nimport { createClient } from '@wix/sdk';\nimport { subscriber } from '@wix/realtime';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
|
|
2058
2144
|
}
|
|
2059
2145
|
]
|
|
2146
|
+
},
|
|
2147
|
+
{
|
|
2148
|
+
"tag": "@requiredField",
|
|
2149
|
+
"content": [
|
|
2150
|
+
{
|
|
2151
|
+
"kind": "text",
|
|
2152
|
+
"text": "channel"
|
|
2153
|
+
}
|
|
2154
|
+
]
|
|
2155
|
+
},
|
|
2156
|
+
{
|
|
2157
|
+
"tag": "@requiredField",
|
|
2158
|
+
"content": [
|
|
2159
|
+
{
|
|
2160
|
+
"kind": "text",
|
|
2161
|
+
"text": "messageHandler"
|
|
2162
|
+
}
|
|
2163
|
+
]
|
|
2060
2164
|
}
|
|
2061
2165
|
]
|
|
2062
2166
|
},
|
|
@@ -2152,6 +2256,15 @@
|
|
|
2152
2256
|
"text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\n// Remove the specified subscription\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Remove all subscriptions from the specified channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
|
|
2153
2257
|
}
|
|
2154
2258
|
]
|
|
2259
|
+
},
|
|
2260
|
+
{
|
|
2261
|
+
"tag": "@requiredField",
|
|
2262
|
+
"content": [
|
|
2263
|
+
{
|
|
2264
|
+
"kind": "text",
|
|
2265
|
+
"text": "options"
|
|
2266
|
+
}
|
|
2267
|
+
]
|
|
2155
2268
|
}
|
|
2156
2269
|
]
|
|
2157
2270
|
},
|
|
@@ -2166,7 +2279,7 @@
|
|
|
2166
2279
|
"summary": [
|
|
2167
2280
|
{
|
|
2168
2281
|
"kind": "text",
|
|
2169
|
-
"text": "Unsubscribe
|
|
2282
|
+
"text": "Unsubscribe details. You must specify "
|
|
2170
2283
|
},
|
|
2171
2284
|
{
|
|
2172
2285
|
"kind": "code",
|
|
@@ -2254,6 +2367,15 @@
|
|
|
2254
2367
|
"text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\n// Remove the specified subscription\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Remove all subscriptions from the specified channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
|
|
2255
2368
|
}
|
|
2256
2369
|
]
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
"tag": "@requiredField",
|
|
2373
|
+
"content": [
|
|
2374
|
+
{
|
|
2375
|
+
"kind": "text",
|
|
2376
|
+
"text": "options"
|
|
2377
|
+
}
|
|
2378
|
+
]
|
|
2257
2379
|
}
|
|
2258
2380
|
]
|
|
2259
2381
|
},
|
|
@@ -3470,7 +3592,7 @@
|
|
|
3470
3592
|
{
|
|
3471
3593
|
"type": "GUIDE",
|
|
3472
3594
|
"title": "Introduction",
|
|
3473
|
-
"src": "---\narticleType: intro\n---\n\n# About the Publisher API\n\nThe Publisher API is a backend module for sending messages to [channels and resources](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction#channels-and-channel-resources).
|
|
3595
|
+
"src": "---\narticleType: intro\n---\n\n# About the Publisher API\n\nThe Publisher API is a backend module for sending messages to [channels and resources](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction#channels-and-channel-resources). Subscribers with suitable permissions receive these messages instantly. Channels and resources are independent, so messages sent to a channel aren't delivered to a resource, and vice versa.\n\nLearn more [about the Realtime APIs](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction).\n\nWith the Publisher API, you can:\n\n- Publish messages to a channel or resource.\n\n<!-- TODO check that elevation note appears in method description -->\n<!-- TODO: Check whether this API is relevant for headless projects. -->\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- Messages don't persist across tab sessions. Closing the browser tab or window closes the connection.\n- Messages aren't queued. When no subscribers are listening, the message is dropped.\n\n<!-- ## Use cases\n\n- [Send notifications to connected clients](ADDLINK).\n- [Broadcast data updates in real time](ADDLINK).\n- [Push state changes to a live dashboard](ADDLINK). -->\n\n## See also\n\n- [Subscriber API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction)\n- [Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction)\n- [Permissions Router API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction)\n\n@sdk_package_setup\n"
|
|
3474
3596
|
},
|
|
3475
3597
|
{
|
|
3476
3598
|
"type": "GUIDE",
|
|
@@ -3482,7 +3604,7 @@
|
|
|
3482
3604
|
{
|
|
3483
3605
|
"type": "GUIDE",
|
|
3484
3606
|
"title": "Introduction",
|
|
3485
|
-
"src": "---\narticleType: intro\n---\n\n# About the Subscriber API\n\nThe Subscriber API lets clients subscribe to [channels and resources](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction#channels-and-channel-resources)
|
|
3607
|
+
"src": "---\narticleType: intro\n---\n\n# About the Subscriber API\n\nThe Subscriber API lets clients subscribe to [channels and resources](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction#channels-and-channel-resources) to receive messages in real time. Subscribers with suitable permissions instantly receive messages sent by a publisher. Channels and resources are independent, so messages sent to a channel aren't delivered to a resource, and vice versa.\n\nLearn more [about the Realtime APIs](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction).\n\nWith the Subscriber API, you can:\n\n- Subscribe or unsubscribe from a channel or resource.\n- Respond to subscription successes, connection errors, and incoming messages with dedicated handlers.\n\n## Subscription lifecycle\n\nThe `subscribe()` method returns a subscription ID immediately, but the connection is established in the background. Subscribers can use the subscription ID to [unsubscribe](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/unsubscribe) at a later time.\n\nYou can register lifecycle handlers to respond when the subscription succeeds or fails:\n\n- The [`onSubscribed` handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) runs on every successful connection, including [automatic re-connections](#reconnection-and-message-sync) attempted after network interruptions.\n- The [`onSubscriptionError` handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) runs whenever an [error occurs](#subscription-errors).\n\n### Reconnection and message sync\n\nIf the connection drops, the client automatically attempts to reconnect and re-subscribe. When subscribing or re-subscribing, the `isSynced` parameter of the `onSubscribed()` handler indicates whether all missed messages were successfully restored, or whether the subscriber needs to take further action.\n\nLearn more about [subscribing](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) to a channel or resource.\n\n<!-- TODO: Document backend buffer limits for message replay. -->\n\n### Subscription errors\n\nSubscription errors occur when a subscription is rejected or when the connection fails. Each error includes `errorCode` and `recoverable` parameters that indicate the error type and whether the client is automatically trying to reconnect.\n\nLearn more about how the [`subscribe()`](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) method handles subscription errors.\n\n## Unsubscribing\n\nYou can unsubscribe in the following ways:\n\n- By `subscriptionId`: Removes a single subscription.\n<!-- TODO: Confirm with dev that unsubscribing by channel doesn't affect resource subscriptions, and vice versa. Item 2.13-->\n- By `channel`: Removes all subscriptions that match the specified channel and resource exactly. Unsubscribing from a channel doesn't affect subscriptions to resources on that channel, and vice versa.\n- By both: Removes the specific subscription, verifying it matches the specified channel or resource. If it doesn't, the subscription isn't removed.\n\nWhen the last subscription on a connection is removed, the connection closes automatically.\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- The Realtime SDK checks permissions when a subscription is first established. When a subscriber doesn't have `read` permission on the channel, the subscription fails.\n- Subscriptions don't persist across sessions. Closing a browser tab removes all its subscriptions.\n<!-- TODO: Document channel/subscription limits per site/app. -->\n\n<!-- ## Use cases\n\n- [Send notifications to connected clients](ADDLINK).\n- [Broadcast data updates in real time](ADDLINK).\n- [Push state changes to a live dashboard](ADDLINK). -->\n\n## See also\n\n- [Publisher API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction)\n- [Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction)\n- [Permissions Router API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction)\n\n@sdk_package_setup\n"
|
|
3486
3608
|
},
|
|
3487
3609
|
{
|
|
3488
3610
|
"type": "GUIDE",
|
|
@@ -3494,7 +3616,7 @@
|
|
|
3494
3616
|
{
|
|
3495
3617
|
"type": "GUIDE",
|
|
3496
3618
|
"title": "Introduction",
|
|
3497
|
-
"src": "---\narticleType: intro\n---\n\n# About the Site API\n\nThe Site API lets you control subscriber permissions for the [Realtime APIs](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction). It determines which [subscribers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction) can receive messages on specific [channels and resources](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction#channels-and-channel-resources).\n\
|
|
3619
|
+
"src": "---\narticleType: intro\n---\n\n# About the Site API\n\nThe Site API lets you control subscriber permissions for the [Realtime APIs](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction). It determines which [subscribers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction) can receive messages on specific [channels and resources](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction#channels-and-channel-resources).\n\nWith the Site API, you can:\n\n- Use the [permissions router](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) to organize permission logic per channel or resource.\n- Control subscriber access using the [`realtime_check_permission` hook](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission).\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- In Wix Studio, you must create a `realtime-permissions.js` file in a site's backend, even if `realtime_check_permission` isn't defined. Without the file, subscriptions fail.\n- When the `realtime_check_permission` hook isn't defined, all subscribers receive the default permissions of `{\"read\": true}`.\n- When previewing a site, `read` permissions are always `true`.\n\n## Use cases\n\nRestrict a channel so only the Wix user can receive messages. Use the [permissions router](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) to add a handler that checks `subscriber.type`:\n\n```js\nimport { site } from \"@wix/realtime\";\nconst { permissionsRouter } = site;\n\npermissionsRouter.add({ name: \"owner-only\" }, (channel, subscriber) => {\n return { read: subscriber.type === \"USER\" };\n});\n\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n```\n\n## See also\n\n- [Realtime APIs](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction)\n- [Permissions Router API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction)\n- [Subscriber API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction)\n- [Publisher API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction)\n\n@sdk_package_setup\n"
|
|
3498
3620
|
},
|
|
3499
3621
|
{
|
|
3500
3622
|
"type": "GUIDE",
|
|
@@ -3557,14 +3679,14 @@
|
|
|
3557
3679
|
{
|
|
3558
3680
|
"type": "GUIDE",
|
|
3559
3681
|
"title": "Introduction",
|
|
3560
|
-
"src": "---\narticleType: intro\n---\n\n# About the Permissions Router API\n\nThe Permissions Router API is a utility for organizing channel permission logic. The router lets you set up a default permissions handler as well as handlers specific to channels or resources.\n\n> **Note
|
|
3682
|
+
"src": "---\narticleType: intro\n---\n\n# About the Permissions Router API\n\nThe Permissions Router API is a utility for organizing channel permission logic. The router lets you set up a default permissions handler as well as handlers specific to channels or resources.\n\n> **Note:** Alternatively, you can include permissions logic directly in the [`realtime_check_permission()` hook](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission).\n\nLearn more about the [Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction) and the [Realtime APIs](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction).\n\nWith the Permissions Router API, you can:\n\n- [Add a handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/add) for a specific channel or resource.\n- [Set a default handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/default) for channels that don't have explicit handlers.\n- [Check](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/check) subscriber permissions.\n\n## Setting up permissions\n\nTo set up permissions using the router:\n\n1. Create a `realtime-permissions.js` file in a site's backend.\n2. Import the `permissionsRouter`:\n\n ```js\n import { site } from \"@wix/realtime\";\n const { permissionsRouter } = site;\n ```\n\n3. Define permission handlers. Use [`add()`](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/add) for specific channels or resources, and [`default()`](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/default) for a default fallback handler:\n\n ```js\n // Set a default handler that grants read access to all subscribers\n permissionsRouter.default((channel, subscriber) => {\n return { read: true };\n });\n\n // Restrict a specific channel to logged-in members\n permissionsRouter.add({ name: \"members-only\" }, (channel, subscriber) => {\n return { read: subscriber.type === \"MEMBER\" };\n });\n ```\n\n4. Export the `realtime_check_permission` hook and call `check()` in the body of the hook to delegate to the router:\n\n ```js\n export function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n }\n ```\n\n## Permission resolution\n\nPermissions can be set at the channel level or the resource level. They determine whether subscribers can receive messages published to that channel or resource.\n\nPermissions follow a cascading pattern:\n\n- When a resource [doesn't have a permissions handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/add), the handler for its parent channel runs.\n- When the parent channel doesn't have a permissions handler, the [default permissions handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/default) runs.\n- When no default handler is set, all subscribers receive the default permissions of `{ \"read\": true }`.\n\n> **Note:** Permissions are checked once per subscription attempt, including [re-subscriptions after reconnection](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_reconnection-and-message-sync). Changes to permissions don't affect active subscriptions until the subscriber reconnects.\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- You must create a `realtime-permissions.js` file in a site's backend, even if you don't define any custom permissions. Without it, all subscriptions fail in Wix Studio.\n- When the `realtime_check_permission` hook isn't defined, all subscribers receive the default permissions of `{\"read\": true}`.\n- When previewing a site, `read` permissions are always `true`.\n\n## Use cases\n\nRestrict the `announcements` channel so only logged-in members can receive messages. All other channels remain open to everyone:\n\n```js\nimport { site } from \"@wix/realtime\";\nconst { permissionsRouter } = site;\n\n// Only logged-in members can listen to announcements\npermissionsRouter.add({ name: \"announcements\" }, (channel, subscriber) => {\n return { read: subscriber.type === \"MEMBER\" };\n});\n\n// All other channels are open to everyone\npermissionsRouter.default((channel, subscriber) => {\n return { read: true };\n});\n\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n```\n\n## See also\n\n- [Realtime APIs](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/introduction)\n- [Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction)\n- [Subscriber API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction)\n- [Publisher API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction)\n\n@sdk_package_setup\n"
|
|
3561
3683
|
}
|
|
3562
3684
|
],
|
|
3563
3685
|
"/site/PermissionsRouter/add": [
|
|
3564
3686
|
{
|
|
3565
3687
|
"type": "EXAMPLE",
|
|
3566
3688
|
"title": "Set a permissions handler for a specific channel",
|
|
3567
|
-
"src": "// In realtime-permissions.js\n\nimport { site } from \"@wix/realtime\";\n\n//
|
|
3689
|
+
"src": "// In realtime-permissions.js\n\nimport { site } from \"@wix/realtime\";\nconst { permissionsRouter } = site;\n\n// Only the Wix user can listen to announcements\npermissionsRouter.add({ name: \"announcements\" }, (channel, subscriber) => {\n return { read: subscriber.type === \"USER\" };\n});\n\n// Export the hook and delegate to the router\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n"
|
|
3568
3690
|
},
|
|
3569
3691
|
{
|
|
3570
3692
|
"type": "EXAMPLE",
|
|
@@ -3,7 +3,7 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Publishes a message to a channel or resource.
|
|
5
5
|
*
|
|
6
|
-
* The method publishes a message to all
|
|
6
|
+
* The method publishes a message to all subscribers on the specified channel or resource. Channels and resources are independent, so subscribers to a channel don't receive messages sent to a resource on that channel. Similarly, subscribers to a resource don't receive messages sent to its parent channel.
|
|
7
7
|
*
|
|
8
8
|
* > **Authentication**
|
|
9
9
|
* >
|
|
@@ -35,7 +35,9 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
35
35
|
* await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @param channel - Channel
|
|
38
|
+
* @param channel - Channel and resource to publish to.
|
|
39
|
+
* @requiredField channel
|
|
39
40
|
* @param payload - Message payload. Max: 10 KB.
|
|
41
|
+
* @requiredField payload
|
|
40
42
|
*/
|
|
41
43
|
export declare const publish: MaybeContext<BuildRESTFunction<typeof publicPublish> & typeof publicPublish>;
|
|
@@ -3,7 +3,7 @@ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
|
|
|
3
3
|
/**
|
|
4
4
|
* Publishes a message to a channel or resource.
|
|
5
5
|
*
|
|
6
|
-
* The method publishes a message to all
|
|
6
|
+
* The method publishes a message to all subscribers on the specified channel or resource. Channels and resources are independent, so subscribers to a channel don't receive messages sent to a resource on that channel. Similarly, subscribers to a resource don't receive messages sent to its parent channel.
|
|
7
7
|
*
|
|
8
8
|
* > **Authentication**
|
|
9
9
|
* >
|
|
@@ -35,7 +35,9 @@ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
|
|
|
35
35
|
* await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @param channel - Channel
|
|
38
|
+
* @param channel - Channel and resource to publish to.
|
|
39
|
+
* @requiredField channel
|
|
39
40
|
* @param payload - Message payload. Max: 10 KB.
|
|
41
|
+
* @requiredField payload
|
|
40
42
|
*/
|
|
41
43
|
export const publish = /*#__PURE__*/ createRESTModule(publicPublish);
|
|
@@ -3,10 +3,12 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Subscribes to a channel or resource.
|
|
5
5
|
*
|
|
6
|
-
* The method attempts to establish a subscription to the specified channel or resource.
|
|
6
|
+
* The method attempts to establish a subscription to the specified channel or resource. It returns the subscription ID immediately while the subscription is attempted in the background.
|
|
7
7
|
*
|
|
8
8
|
* Use the `options` parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The `onSubscribed()` handler runs on every successful re-subscription.
|
|
9
9
|
*
|
|
10
|
+
* Learn more about the [subscription lifecycle](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle).
|
|
11
|
+
*
|
|
10
12
|
* @example Subscribe to a channel
|
|
11
13
|
* ```ts
|
|
12
14
|
* import { subscriber } from '@wix/realtime';
|
|
@@ -44,9 +46,11 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
44
46
|
* );
|
|
45
47
|
* ```
|
|
46
48
|
*
|
|
47
|
-
* @param channel - Channel
|
|
48
|
-
* @
|
|
49
|
-
* @param
|
|
49
|
+
* @param channel - Channel and resource to subscribe to.
|
|
50
|
+
* @requiredField channel
|
|
51
|
+
* @param messageHandler - Handler that runs whenever a message is published to the channel or resource.
|
|
52
|
+
* @requiredField messageHandler
|
|
53
|
+
* @param options - [Lifecycle handlers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle) for subscription events.
|
|
50
54
|
*/
|
|
51
55
|
export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubscribe> & typeof publicSubscribe>;
|
|
52
56
|
/**
|
|
@@ -87,6 +91,7 @@ export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubs
|
|
|
87
91
|
* client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
|
|
88
92
|
* ```
|
|
89
93
|
*
|
|
90
|
-
* @param options - Unsubscribe
|
|
94
|
+
* @param options - Unsubscribe details. You must specify `channel`, `subscriptionId`, or both.
|
|
95
|
+
* @requiredField options
|
|
91
96
|
*/
|
|
92
97
|
export declare const unsubscribe: MaybeContext<BuildRESTFunction<typeof publicUnsubscribe> & typeof publicUnsubscribe>;
|
|
@@ -3,10 +3,12 @@ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
|
|
|
3
3
|
/**
|
|
4
4
|
* Subscribes to a channel or resource.
|
|
5
5
|
*
|
|
6
|
-
* The method attempts to establish a subscription to the specified channel or resource.
|
|
6
|
+
* The method attempts to establish a subscription to the specified channel or resource. It returns the subscription ID immediately while the subscription is attempted in the background.
|
|
7
7
|
*
|
|
8
8
|
* Use the `options` parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The `onSubscribed()` handler runs on every successful re-subscription.
|
|
9
9
|
*
|
|
10
|
+
* Learn more about the [subscription lifecycle](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle).
|
|
11
|
+
*
|
|
10
12
|
* @example Subscribe to a channel
|
|
11
13
|
* ```ts
|
|
12
14
|
* import { subscriber } from '@wix/realtime';
|
|
@@ -44,9 +46,11 @@ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
|
|
|
44
46
|
* );
|
|
45
47
|
* ```
|
|
46
48
|
*
|
|
47
|
-
* @param channel - Channel
|
|
48
|
-
* @
|
|
49
|
-
* @param
|
|
49
|
+
* @param channel - Channel and resource to subscribe to.
|
|
50
|
+
* @requiredField channel
|
|
51
|
+
* @param messageHandler - Handler that runs whenever a message is published to the channel or resource.
|
|
52
|
+
* @requiredField messageHandler
|
|
53
|
+
* @param options - [Lifecycle handlers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction#business-solutions_realtime_realtime_subscriber_subscription-lifecycle) for subscription events.
|
|
50
54
|
*/
|
|
51
55
|
export const subscribe = /*#__PURE__*/ createRESTModule(publicSubscribe);
|
|
52
56
|
/**
|
|
@@ -87,6 +91,7 @@ export const subscribe = /*#__PURE__*/ createRESTModule(publicSubscribe);
|
|
|
87
91
|
* client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
|
|
88
92
|
* ```
|
|
89
93
|
*
|
|
90
|
-
* @param options - Unsubscribe
|
|
94
|
+
* @param options - Unsubscribe details. You must specify `channel`, `subscriptionId`, or both.
|
|
95
|
+
* @requiredField options
|
|
91
96
|
*/
|
|
92
97
|
export const unsubscribe = /*#__PURE__*/ createRESTModule(publicUnsubscribe);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/realtime",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@wix/auto_sdk_duplexer_publisher": "^1.0.10",
|
|
45
45
|
"@wix/auto_sdk_duplexer_realtime-permissions-provider": "^1.0.0",
|
|
46
46
|
"@wix/duplexer-js": "^2.0.6",
|
|
47
|
-
"@wix/realtime-common": "1.0.
|
|
47
|
+
"@wix/realtime-common": "1.0.16",
|
|
48
48
|
"@wix/sdk": "^1.21.4",
|
|
49
49
|
"@wix/sdk-runtime": "^1.0.9",
|
|
50
50
|
"@wix/sdk-types": "^1.17.5",
|
|
51
|
-
"@wix/sdk_realtime_site": "1.0.
|
|
51
|
+
"@wix/sdk_realtime_site": "1.0.34",
|
|
52
52
|
"uuid": "^11.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"isRootPublicSdk": true
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
-
"falconPackageHash": "
|
|
75
|
+
"falconPackageHash": "98a58218df0dbaf6198e0884b49f7b38343e8de6e3e82f8d76a1ca2d"
|
|
76
76
|
}
|