@wix/realtime 1.0.34 → 1.0.35

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,41 +1,41 @@
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 channel or channel resource.
4
+ * Publishes a message to a channel or resource.
5
5
  *
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.
6
+ * The method publishes a message to all subscriptions on the specified channel or resource. Channels and resources are isolated, so subscribers to a channel don't receive messages published to a resource. Similarly, subscribers to a resource don't receive messages published to the parent channel.
9
7
  *
10
- * This method is backend-only and requires elevated permissions.
8
+ * > **Authentication**
9
+ * >
10
+ * > 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).
11
11
  *
12
12
  * <!-- TODO: Check whether this API is relevant for headless projects. -->
13
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.
17
- *
18
- * @example Manual client (self-hosted / explicit auth)
14
+ * @example Publish a message to the specified channel
19
15
  * ```ts
20
16
  * import { publisher } from '@wix/realtime';
21
- * import { createClient, AppStrategy } from '@wix/sdk';
17
+ * import { elevate } from '@wix/sdk/context';
22
18
  *
23
- * const client = createClient({
24
- * modules: { publisher },
25
- * auth: AppStrategy({ appId, appSecret, instanceId }),
26
- * });
27
- * await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
19
+ * await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
28
20
  * ```
29
21
  *
30
- * @example Contextual client (Wix-hosted)
22
+ * @example Publish a message to the specified channel: Self-hosted
31
23
  * ```ts
32
24
  * import { publisher } from '@wix/realtime';
33
- * import { elevate } from '@wix/sdk/context';
25
+ * import { createClient } from '@wix/sdk';
34
26
  *
35
- * await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
27
+ * // Import the auth strategy for the relevant access type
28
+ * // Import the relevant host module if needed
29
+ *
30
+ * const client = createClient({
31
+ * modules: { publisher },
32
+ * // Include the auth strategy and host as relevant
33
+ * });
34
+ *
35
+ * await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
36
36
  * ```
37
37
  *
38
- * @param channel - Channel, and optionally resource, to publish to.
38
+ * @param channel - Channel or resource to publish to.
39
39
  * @param payload - Message payload. Max: 10 KB.
40
40
  */
41
41
  export declare const publish: MaybeContext<BuildRESTFunction<typeof publicPublish> & typeof publicPublish>;
@@ -1,41 +1,41 @@
1
1
  import { publish as publicPublish } from './publisher.public.js';
2
2
  import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
3
3
  /**
4
- * Publishes a message to a channel or channel resource.
4
+ * Publishes a message to a channel or resource.
5
5
  *
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.
6
+ * The method publishes a message to all subscriptions on the specified channel or resource. Channels and resources are isolated, so subscribers to a channel don't receive messages published to a resource. Similarly, subscribers to a resource don't receive messages published to the parent channel.
9
7
  *
10
- * This method is backend-only and requires elevated permissions.
8
+ * > **Authentication**
9
+ * >
10
+ * > 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).
11
11
  *
12
12
  * <!-- TODO: Check whether this API is relevant for headless projects. -->
13
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.
17
- *
18
- * @example Manual client (self-hosted / explicit auth)
14
+ * @example Publish a message to the specified channel
19
15
  * ```ts
20
16
  * import { publisher } from '@wix/realtime';
21
- * import { createClient, AppStrategy } from '@wix/sdk';
17
+ * import { elevate } from '@wix/sdk/context';
22
18
  *
23
- * const client = createClient({
24
- * modules: { publisher },
25
- * auth: AppStrategy({ appId, appSecret, instanceId }),
26
- * });
27
- * await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
19
+ * await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
28
20
  * ```
29
21
  *
30
- * @example Contextual client (Wix-hosted)
22
+ * @example Publish a message to the specified channel: Self-hosted
31
23
  * ```ts
32
24
  * import { publisher } from '@wix/realtime';
33
- * import { elevate } from '@wix/sdk/context';
25
+ * import { createClient } from '@wix/sdk';
34
26
  *
35
- * await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
27
+ * // Import the auth strategy for the relevant access type
28
+ * // Import the relevant host module if needed
29
+ *
30
+ * const client = createClient({
31
+ * modules: { publisher },
32
+ * // Include the auth strategy and host as relevant
33
+ * });
34
+ *
35
+ * await client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });
36
36
  * ```
37
37
  *
38
- * @param channel - Channel, and optionally resource, to publish to.
38
+ * @param channel - Channel or resource to publish to.
39
39
  * @param payload - Message payload. Max: 10 KB.
40
40
  */
41
41
  export const publish = /*#__PURE__*/ createRESTModule(publicPublish);
@@ -1,48 +1,46 @@
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
- * Subscribes to a channel or channel resource.
4
+ * Subscribes to a channel or resource.
5
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.
6
+ * The method attempts to establish a subscription to the specified channel or resource. While the subscription is attempted asynchronously, the method returns the subscription ID immediately.
10
7
  *
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.
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.
14
9
  *
15
- * @example Manual client (self-hosted / explicit auth)
10
+ * @example Subscribe to a channel
16
11
  * ```ts
17
12
  * import { subscriber } from '@wix/realtime';
18
- * import { createClient, AppStrategy } from '@wix/sdk';
19
13
  *
20
- * const client = createClient({
21
- * modules: { subscriber },
22
- * auth: AppStrategy({ appId, appSecret, instanceId }),
23
- * });
24
- *
25
- * const subscriptionId = client.subscriber.subscribe(
14
+ * const subscriptionId = subscriber.subscribe(
26
15
  * { name: 'my-channel' },
27
16
  * (message, channel) => {
28
17
  * console.log('Received:', message.payload);
29
18
  * },
30
- * {
31
- * onSubscribed: (id, isSynced) => console.log('Subscribed', id),
32
- * onSubscriptionError: (error, id) => console.error('Error', error),
33
- * },
34
19
  * );
35
20
  * ```
36
21
  *
37
- * @example Contextual client (Wix-hosted)
22
+ * @example Subscribe to a channel: Self-hosted
38
23
  * ```ts
24
+ * import { createClient } from '@wix/sdk';
39
25
  * import { subscriber } from '@wix/realtime';
40
26
  *
41
- * const subscriptionId = subscriber.subscribe(
27
+ * // Import the auth strategy for the relevant access type
28
+ * // Import the relevant host module if needed
29
+ *
30
+ * const client = createClient({
31
+ * modules: { subscriber },
32
+ * // Include the auth strategy and host as relevant
33
+ * });
34
+ *
35
+ * const subscriptionId = client.subscriber.subscribe(
42
36
  * { name: 'my-channel' },
43
37
  * (message, channel) => {
44
38
  * console.log('Received:', message.payload);
45
39
  * },
40
+ * {
41
+ * onSubscribed: (id, isSynced) => console.log('Subscribed', id),
42
+ * onSubscriptionError: (error, id) => console.error('Error', error),
43
+ * },
46
44
  * );
47
45
  * ```
48
46
  *
@@ -52,40 +50,43 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
52
50
  */
53
51
  export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubscribe> & typeof publicSubscribe>;
54
52
  /**
55
- * Removes one or more subscriptions.
53
+ * Removes 1 or more subscriptions.
56
54
  *
57
- * You can unsubscribe in three ways:
55
+ * You can unsubscribe in 3 ways:
58
56
  * - By `subscriptionId`: removes a single subscription.
59
- * - By `channel`: removes all subscriptions to that channel or channel resource.
57
+ * - By `channel`: removes all subscriptions to that channel or resource.
60
58
  * - By both: removes the specific subscription, verifying it matches the channel.
61
59
  *
62
60
  * When the last subscription on a connection is removed, the connection
63
61
  * closes automatically.
64
62
  *
65
- * @example Manual client (self-hosted / explicit auth)
63
+ * @example Remove the specified subscription.
66
64
  * ```ts
67
65
  * import { subscriber } from '@wix/realtime';
68
- * import { createClient, AppStrategy } from '@wix/sdk';
66
+ *
67
+ * subscriber.unsubscribe({ subscriptionId });
68
+ * ```
69
+ *
70
+ * @example Remove the specified subscription: Self-hosted
71
+ * ```ts
72
+ * import { subscriber } from '@wix/realtime';
73
+ * import { createClient } from '@wix/sdk';
74
+ *
75
+ * // Import the auth strategy for the relevant access type
76
+ * // Import the relevant host module if needed
69
77
  *
70
78
  * const client = createClient({
71
79
  * modules: { subscriber },
72
- * auth: AppStrategy({ appId, appSecret, instanceId }),
80
+ * // Include the auth strategy and host as relevant
73
81
  * });
74
82
  *
75
- * // Unsubscribe by subscription ID
83
+ * // Remove the specified subscription
76
84
  * client.subscriber.unsubscribe({ subscriptionId });
77
85
  *
78
- * // Unsubscribe from all subscriptions to a channel
86
+ * // Remove all subscriptions from the specified channel
79
87
  * client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
80
88
  * ```
81
89
  *
82
- * @example Contextual client (Wix-hosted)
83
- * ```ts
84
- * import { subscriber } from '@wix/realtime';
85
- *
86
- * subscriber.unsubscribe({ subscriptionId });
87
- * ```
88
- *
89
- * @param options - Specifies what to unsubscribe from. At least one of `channel` or `subscriptionId` is required.
90
+ * @param options - Unsubscribe information. You must specify `channel`, `subscriptionId`, or both.
90
91
  */
91
92
  export declare const unsubscribe: MaybeContext<BuildRESTFunction<typeof publicUnsubscribe> & typeof publicUnsubscribe>;
@@ -1,48 +1,46 @@
1
1
  import { subscribe as publicSubscribe, unsubscribe as publicUnsubscribe, } from './subscriber.public.js';
2
2
  import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
3
3
  /**
4
- * Subscribes to a channel or channel resource.
4
+ * Subscribes to a channel or resource.
5
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.
6
+ * The method attempts to establish a subscription to the specified channel or resource. While the subscription is attempted asynchronously, the method returns the subscription ID immediately.
10
7
  *
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.
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.
14
9
  *
15
- * @example Manual client (self-hosted / explicit auth)
10
+ * @example Subscribe to a channel
16
11
  * ```ts
17
12
  * import { subscriber } from '@wix/realtime';
18
- * import { createClient, AppStrategy } from '@wix/sdk';
19
13
  *
20
- * const client = createClient({
21
- * modules: { subscriber },
22
- * auth: AppStrategy({ appId, appSecret, instanceId }),
23
- * });
24
- *
25
- * const subscriptionId = client.subscriber.subscribe(
14
+ * const subscriptionId = subscriber.subscribe(
26
15
  * { name: 'my-channel' },
27
16
  * (message, channel) => {
28
17
  * console.log('Received:', message.payload);
29
18
  * },
30
- * {
31
- * onSubscribed: (id, isSynced) => console.log('Subscribed', id),
32
- * onSubscriptionError: (error, id) => console.error('Error', error),
33
- * },
34
19
  * );
35
20
  * ```
36
21
  *
37
- * @example Contextual client (Wix-hosted)
22
+ * @example Subscribe to a channel: Self-hosted
38
23
  * ```ts
24
+ * import { createClient } from '@wix/sdk';
39
25
  * import { subscriber } from '@wix/realtime';
40
26
  *
41
- * const subscriptionId = subscriber.subscribe(
27
+ * // Import the auth strategy for the relevant access type
28
+ * // Import the relevant host module if needed
29
+ *
30
+ * const client = createClient({
31
+ * modules: { subscriber },
32
+ * // Include the auth strategy and host as relevant
33
+ * });
34
+ *
35
+ * const subscriptionId = client.subscriber.subscribe(
42
36
  * { name: 'my-channel' },
43
37
  * (message, channel) => {
44
38
  * console.log('Received:', message.payload);
45
39
  * },
40
+ * {
41
+ * onSubscribed: (id, isSynced) => console.log('Subscribed', id),
42
+ * onSubscriptionError: (error, id) => console.error('Error', error),
43
+ * },
46
44
  * );
47
45
  * ```
48
46
  *
@@ -52,40 +50,43 @@ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
52
50
  */
53
51
  export const subscribe = /*#__PURE__*/ createRESTModule(publicSubscribe);
54
52
  /**
55
- * Removes one or more subscriptions.
53
+ * Removes 1 or more subscriptions.
56
54
  *
57
- * You can unsubscribe in three ways:
55
+ * You can unsubscribe in 3 ways:
58
56
  * - By `subscriptionId`: removes a single subscription.
59
- * - By `channel`: removes all subscriptions to that channel or channel resource.
57
+ * - By `channel`: removes all subscriptions to that channel or resource.
60
58
  * - By both: removes the specific subscription, verifying it matches the channel.
61
59
  *
62
60
  * When the last subscription on a connection is removed, the connection
63
61
  * closes automatically.
64
62
  *
65
- * @example Manual client (self-hosted / explicit auth)
63
+ * @example Remove the specified subscription.
66
64
  * ```ts
67
65
  * import { subscriber } from '@wix/realtime';
68
- * import { createClient, AppStrategy } from '@wix/sdk';
66
+ *
67
+ * subscriber.unsubscribe({ subscriptionId });
68
+ * ```
69
+ *
70
+ * @example Remove the specified subscription: Self-hosted
71
+ * ```ts
72
+ * import { subscriber } from '@wix/realtime';
73
+ * import { createClient } from '@wix/sdk';
74
+ *
75
+ * // Import the auth strategy for the relevant access type
76
+ * // Import the relevant host module if needed
69
77
  *
70
78
  * const client = createClient({
71
79
  * modules: { subscriber },
72
- * auth: AppStrategy({ appId, appSecret, instanceId }),
80
+ * // Include the auth strategy and host as relevant
73
81
  * });
74
82
  *
75
- * // Unsubscribe by subscription ID
83
+ * // Remove the specified subscription
76
84
  * client.subscriber.unsubscribe({ subscriptionId });
77
85
  *
78
- * // Unsubscribe from all subscriptions to a channel
86
+ * // Remove all subscriptions from the specified channel
79
87
  * client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
80
88
  * ```
81
89
  *
82
- * @example Contextual client (Wix-hosted)
83
- * ```ts
84
- * import { subscriber } from '@wix/realtime';
85
- *
86
- * subscriber.unsubscribe({ subscriptionId });
87
- * ```
88
- *
89
- * @param options - Specifies what to unsubscribe from. At least one of `channel` or `subscriptionId` is required.
90
+ * @param options - Unsubscribe information. You must specify `channel`, `subscriptionId`, or both.
90
91
  */
91
92
  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.34",
3
+ "version": "1.0.35",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -37,11 +37,11 @@
37
37
  "dependencies": {
38
38
  "@wix/auto_sdk_duplexer_publisher": "^1.0.10",
39
39
  "@wix/duplexer-js": "^2.0.6",
40
- "@wix/realtime-common": "1.0.13",
40
+ "@wix/realtime-common": "1.0.14",
41
41
  "@wix/sdk": "^1.21.4",
42
42
  "@wix/sdk-runtime": "^1.0.9",
43
43
  "@wix/sdk-types": "^1.17.5",
44
- "@wix/sdk_realtime_site": "1.0.29",
44
+ "@wix/sdk_realtime_site": "1.0.30",
45
45
  "uuid": "^11.1.0"
46
46
  },
47
47
  "devDependencies": {
@@ -65,5 +65,5 @@
65
65
  "isRootPublicSdk": true
66
66
  }
67
67
  },
68
- "falconPackageHash": "90b2dac8512fe6d53c9783658589fba10ec676575cd1a491d6974748"
68
+ "falconPackageHash": "ebbe942c0c0c816ccc4f8831a2dfb124127eb2fc4b59fdb863d4e34b"
69
69
  }