@wix/realtime 1.0.33 → 1.0.34

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.
@@ -1,10 +1,19 @@
1
1
  import { publish as publicPublish } from './publisher.public.js';
2
2
  import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
3
3
  /**
4
- * Publishes a message to a realtime channel.
4
+ * Publishes a message to a channel or channel resource.
5
5
  *
6
- * Requires a service identity (server-side only). The caller must have
7
- * app-level permissions to publish messages.
6
+ * All subscribers currently listening to the specified channel receive the
7
+ * message. Subscribers to a channel don't receive messages published to a
8
+ * resource on that channel, and vice versa.
9
+ *
10
+ * This method is backend-only and requires elevated permissions.
11
+ *
12
+ * <!-- TODO: Check whether this API is relevant for headless projects. -->
13
+ *
14
+ * > **Note:** This function requires elevated permissions and runs only on the backend.
15
+ * > You can also call this method from the frontend using `elevate()`.
16
+ * > Elevated permissions are only available for apps and service accounts.
8
17
  *
9
18
  * @example Manual client (self-hosted / explicit auth)
10
19
  * ```ts
@@ -26,7 +35,7 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
26
35
  * await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
27
36
  * ```
28
37
  *
29
- * @param channel - The channel, and optionally the resource, to publish to.
30
- * @param payload - Message payload. Max: 10kb
38
+ * @param channel - Channel, and optionally resource, to publish to.
39
+ * @param payload - Message payload. Max: 10 KB.
31
40
  */
32
41
  export declare const publish: MaybeContext<BuildRESTFunction<typeof publicPublish> & typeof publicPublish>;
@@ -4,10 +4,19 @@ exports.publish = void 0;
4
4
  const publisher_public_js_1 = require("./publisher.public.js");
5
5
  const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
6
6
  /**
7
- * Publishes a message to a realtime channel.
7
+ * Publishes a message to a channel or channel resource.
8
8
  *
9
- * Requires a service identity (server-side only). The caller must have
10
- * app-level permissions to publish messages.
9
+ * All subscribers currently listening to the specified channel receive the
10
+ * message. Subscribers to a channel don't receive messages published to a
11
+ * resource on that channel, and vice versa.
12
+ *
13
+ * This method is backend-only and requires elevated permissions.
14
+ *
15
+ * <!-- TODO: Check whether this API is relevant for headless projects. -->
16
+ *
17
+ * > **Note:** This function requires elevated permissions and runs only on the backend.
18
+ * > You can also call this method from the frontend using `elevate()`.
19
+ * > Elevated permissions are only available for apps and service accounts.
11
20
  *
12
21
  * @example Manual client (self-hosted / explicit auth)
13
22
  * ```ts
@@ -29,7 +38,7 @@ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
29
38
  * await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
30
39
  * ```
31
40
  *
32
- * @param channel - The channel, and optionally the resource, to publish to.
33
- * @param payload - Message payload. Max: 10kb
41
+ * @param channel - Channel, and optionally resource, to publish to.
42
+ * @param payload - Message payload. Max: 10 KB.
34
43
  */
35
44
  exports.publish = (0, rest_modules_1.createRESTModule)(publisher_public_js_1.publish);
@@ -1,9 +1,16 @@
1
1
  import { subscribe as publicSubscribe, unsubscribe as publicUnsubscribe } from './subscriber.public.js';
2
2
  import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
3
3
  /**
4
- * Subscribe to a channel. Returns a subscriptionId immediately; the
5
- * actual connection is established asynchronously in the background. Use the
6
- * optional `options` parameter to handle subscription lifecycle events.
4
+ * Subscribes to a channel or channel resource.
5
+ *
6
+ * The method returns a subscription ID immediately. The connection is
7
+ * established asynchronously in the background. Use the `options` parameter
8
+ * to register lifecycle handlers that notify you when the subscription
9
+ * succeeds or encounters an error.
10
+ *
11
+ * If the connection drops, the client automatically attempts to reconnect
12
+ * and re-subscribe. The `onSubscribed` handler fires again on each
13
+ * successful re-subscription.
7
14
  *
8
15
  * @example Manual client (self-hosted / explicit auth)
9
16
  * ```ts
@@ -39,18 +46,21 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
39
46
  * );
40
47
  * ```
41
48
  *
42
- * @param channel - The channel, and optionally the resource, to subscribe to.
43
- * @param messageHandler - Callback invoked whenever a message is published to the channel.
44
- * @param options - Optional lifecycle handlers for subscription events.
49
+ * @param channel - Channel, and optionally resource, to subscribe to.
50
+ * @param messageHandler - Callback that runs whenever a message is published to the channel.
51
+ * @param options - Lifecycle handlers for subscription events.
45
52
  */
46
53
  export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubscribe> & typeof publicSubscribe>;
47
54
  /**
48
- * Unsubscribe from a subscription by its ID, by channel, or both.
55
+ * Removes one or more subscriptions.
49
56
  *
50
57
  * You can unsubscribe in three ways:
51
- * - By `subscriptionId` removes a single subscription.
52
- * - By `channel` removes all subscriptions to that channel.
53
- * - By both removes the specific subscription, verifying it matches the channel.
58
+ * - By `subscriptionId`: removes a single subscription.
59
+ * - By `channel`: removes all subscriptions to that channel or channel resource.
60
+ * - By both: removes the specific subscription, verifying it matches the channel.
61
+ *
62
+ * When the last subscription on a connection is removed, the connection
63
+ * closes automatically.
54
64
  *
55
65
  * @example Manual client (self-hosted / explicit auth)
56
66
  * ```ts
@@ -76,6 +86,6 @@ export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubs
76
86
  * subscriber.unsubscribe({ subscriptionId });
77
87
  * ```
78
88
  *
79
- * @param options - Identifies what to unsubscribe from by subscription ID, channel, or both.
89
+ * @param options - Specifies what to unsubscribe from. At least one of `channel` or `subscriptionId` is required.
80
90
  */
81
91
  export declare const unsubscribe: MaybeContext<BuildRESTFunction<typeof publicUnsubscribe> & typeof publicUnsubscribe>;
@@ -4,9 +4,16 @@ exports.unsubscribe = exports.subscribe = void 0;
4
4
  const subscriber_public_js_1 = require("./subscriber.public.js");
5
5
  const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
6
6
  /**
7
- * Subscribe to a channel. Returns a subscriptionId immediately; the
8
- * actual connection is established asynchronously in the background. Use the
9
- * optional `options` parameter to handle subscription lifecycle events.
7
+ * Subscribes to a channel or channel resource.
8
+ *
9
+ * The method returns a subscription ID immediately. The connection is
10
+ * established asynchronously in the background. Use the `options` parameter
11
+ * to register lifecycle handlers that notify you when the subscription
12
+ * succeeds or encounters an error.
13
+ *
14
+ * If the connection drops, the client automatically attempts to reconnect
15
+ * and re-subscribe. The `onSubscribed` handler fires again on each
16
+ * successful re-subscription.
10
17
  *
11
18
  * @example Manual client (self-hosted / explicit auth)
12
19
  * ```ts
@@ -42,18 +49,21 @@ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
42
49
  * );
43
50
  * ```
44
51
  *
45
- * @param channel - The channel, and optionally the resource, to subscribe to.
46
- * @param messageHandler - Callback invoked whenever a message is published to the channel.
47
- * @param options - Optional lifecycle handlers for subscription events.
52
+ * @param channel - Channel, and optionally resource, to subscribe to.
53
+ * @param messageHandler - Callback that runs whenever a message is published to the channel.
54
+ * @param options - Lifecycle handlers for subscription events.
48
55
  */
49
56
  exports.subscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.subscribe);
50
57
  /**
51
- * Unsubscribe from a subscription by its ID, by channel, or both.
58
+ * Removes one or more subscriptions.
52
59
  *
53
60
  * You can unsubscribe in three ways:
54
- * - By `subscriptionId` removes a single subscription.
55
- * - By `channel` removes all subscriptions to that channel.
56
- * - By both removes the specific subscription, verifying it matches the channel.
61
+ * - By `subscriptionId`: removes a single subscription.
62
+ * - By `channel`: removes all subscriptions to that channel or channel resource.
63
+ * - By both: removes the specific subscription, verifying it matches the channel.
64
+ *
65
+ * When the last subscription on a connection is removed, the connection
66
+ * closes automatically.
57
67
  *
58
68
  * @example Manual client (self-hosted / explicit auth)
59
69
  * ```ts
@@ -79,6 +89,6 @@ exports.subscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.
79
89
  * subscriber.unsubscribe({ subscriptionId });
80
90
  * ```
81
91
  *
82
- * @param options - Identifies what to unsubscribe from by subscription ID, channel, or both.
92
+ * @param options - Specifies what to unsubscribe from. At least one of `channel` or `subscriptionId` is required.
83
93
  */
84
94
  exports.unsubscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.unsubscribe);