@wix/realtime 1.0.40 → 1.0.41

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.
@@ -450,15 +450,6 @@
450
450
  }
451
451
  ]
452
452
  },
453
- {
454
- "tag": "@servicePath",
455
- "content": [
456
- {
457
- "kind": "text",
458
- "text": "wix-realtime-backend.ChannelPermissions"
459
- }
460
- ]
461
- },
462
453
  {
463
454
  "tag": "@servicePath",
464
455
  "content": [
@@ -701,15 +692,6 @@
701
692
  }
702
693
  ]
703
694
  },
704
- {
705
- "tag": "@servicePath",
706
- "content": [
707
- {
708
- "kind": "text",
709
- "text": "wix-realtime-backend.ChannelPermissions"
710
- }
711
- ]
712
- },
713
695
  {
714
696
  "tag": "@servicePath",
715
697
  "content": [
@@ -732,7 +714,7 @@
732
714
  "summary": [
733
715
  {
734
716
  "kind": "text",
735
- "text": "Channel or resource being checked."
717
+ "text": "Channel or resource to check."
736
718
  }
737
719
  ]
738
720
  },
@@ -753,7 +735,7 @@
753
735
  "summary": [
754
736
  {
755
737
  "kind": "text",
756
- "text": "Subscriber whose permissions are being checked."
738
+ "text": "Subscriber to check permissions for."
757
739
  }
758
740
  ]
759
741
  },
@@ -815,7 +797,7 @@
815
797
  "summary": [
816
798
  {
817
799
  "kind": "text",
818
- "text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource adds the handler to the channel and to all resources that don't have their own handler. Learn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
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 handler. Learn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
819
801
  }
820
802
  ],
821
803
  "blockTags": [
@@ -936,7 +918,7 @@
936
918
  "summary": [
937
919
  {
938
920
  "kind": "text",
939
- "text": "Checks permissions for a subscriber on a channel or resource.\n\nRuns the permissions handler appropriate for the subscriber on the specified channel or resource.\n\nLearn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
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.\n\nLearn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
940
922
  }
941
923
  ],
942
924
  "blockTags": [
@@ -985,15 +967,6 @@
985
967
  }
986
968
  ]
987
969
  },
988
- {
989
- "tag": "@servicePath",
990
- "content": [
991
- {
992
- "kind": "text",
993
- "text": "wix-realtime-backend.ChannelPermissions"
994
- }
995
- ]
996
- },
997
970
  {
998
971
  "tag": "@servicePath",
999
972
  "content": [
@@ -1086,7 +1059,7 @@
1086
1059
  "summary": [
1087
1060
  {
1088
1061
  "kind": "text",
1089
- "text": "Sets the default permissions handler.\n\nThe default handler runs when the specified channel or resource doesn't have an explicit handler.\n\nLearn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
1062
+ "text": "Sets the default permissions handler.\n\nThe default handler runs when the specified channel or resource doesn't have an explicit handler. Learn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
1090
1063
  }
1091
1064
  ],
1092
1065
  "blockTags": [
@@ -3493,32 +3466,35 @@
3493
3466
  "symbolIdMap": {}
3494
3467
  },
3495
3468
  "appendices": {
3496
- "/": [
3469
+ "/publisher": [
3497
3470
  {
3498
3471
  "type": "GUIDE",
3499
3472
  "title": "Introduction",
3500
- "src": "---\narticleType: intro\n---\n\n# About the Realtime APIs\n\nThe Realtime APIs let you send and receive messages between a site backend and connected clients in real time. When a backend service publishes messages to a channel, clients subscribed to that channel receive them instantly.\n\nWith the Realtime APIs, you can:\n\n- Publish messages from the backend to channels and channel resources.\n- Subscribe to channels and resources to receive messages on connected clients.\n- Control which subscribers receive messages on specific channels or channel resources.\n\nThe Realtime APIs consist of the following modules that work together:\n\n- [**Publisher**](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction): Backend module that sends messages to channels.\n- [**Site**](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction): Backend module that manages subscriber permissions.\n- [**Subscriber**](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction): Client module that listens to channels and receives messages.\n\n## How the modules work together\n\nThe Publisher sends a message to a channel or channel resource. The Site module checks whether each subscriber has permission to listen on that channel. Subscribers that have the appropriate permissions receive the message in real time.\n\nA typical flow looks like this:\n\n1. Define permissions in the **realtime-permissions.js** in the site's backend using the [Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction).\n2. A client subscribes to a channel or channel resource using the [Subscriber API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction).\n3. The [`realtime_check_permission`](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) hook checks the subscriber's permissions.\n4. The [Publisher](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction) publishes a message to the channel.\n5. The subscriber receives the message.\n\n## Channels and channel resources\n\nChannels are the mechanism by which publishers send messages to subscribers. Each channel has a unique name and can contain resources that act as sub-channels. Clients can subscribe to a channel or resource. When a publisher sends a message, subscribers receive the messages instantly if they have the appropriate permissions.\n\nChannels and resources are strictly isolated: subscribing to a channel doesn't include messages published to a resource on that channel, and subscribing to a resource doesn't include messages published to the parent channel.\n\n## Publisher\n\nThe [Publisher API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction) is a backend module that sends messages to subscribers listening to the specified channel or resource.\n\n## Site\n\nThe [Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction) controls subscriber permissions. It determines which subscribers can receive messages on specific channels and resources.\n\nLearn more about [permissions in the Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction).\n\n## Subscribers\n\nA subscriber is a client that listens to a channel or resource. When a message is published to a channel or resource, all subscribers with [the appropriate permissions](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) receive the message. \n\nYou can set up dedicated handlers for incoming messages, subscription successes, and subscription failures.\n\nLearn more about the [Subscriber API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction).\n\n\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- Messages are ephemeral. They don't persist across sessions.\n- When previewing the site, `read` permissions are always `true`.\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## Terminology\n\n- **Channel**: Named broadcast channel that publishers send messages to and subscribers listen on.\n- **Resource**: Isolated sub-channel in a channel. Messages on a resource are isolated from messages on its parent channel.\n- **Message**: Data published to a channel or resource.\n- **Publisher**: Service that sends messages to subscribers.\n- **Subscriber**: Client that listens for messages on a channel or resource.\n- **Subscription**: Active connection between a subscriber and a channel or resource, identified by a subscription ID.\n\n"
3501
- }
3502
- ],
3503
- "/publisher": [
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). [Subscribers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction) with suitable [permissions](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) receive these messages instantly. Channels and resources are isolated, 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\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 aren't queued. When no subscribers are listening, the message is dropped.\n- Messages don't persist across sessions.\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@sdk_package_setup\n"
3474
+ },
3504
3475
  {
3505
3476
  "type": "GUIDE",
3506
- "title": "Introduction",
3507
- "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](ADDLINK). [Subscribers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction) with suitable [permissions](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) receive these messages instantly. Channels and resources are isolated, so messages sent to a channel are not published to a resource, and vice versa.\n\nLearn more [about the Realtime APIs](ADDLINK).\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 aren't queued. When no subscribers are listening, the message is dropped.\n- Messages don't persist across sessions.\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@sdk_package_setup\n"
3477
+ "title": "Setup",
3478
+ "src": "# Setup\n\n@package_metadata:@wix/realtime\n\nTo use the Realtime API, install the `@wix/realtime` package.\n\n#### Install the package\n\nFollow the installation instructions for your development environment.\n\n| Development environment | Installation method |\n| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Wix sites (editor or IDE) | Use the [package manager](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/packages/work-with-npm-packages-in-the-editor). |\n| Wix sites (local IDE) | Run `wix install @wix/realtime` using the [CLI](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/packages/work-with-npm-packages-with-the-wix-cli). |\n\n#### Import the package\n\nTo import the package in your code:\n\n```js\nimport { publisher } from '@wix/realtime';\n```\n"
3508
3479
  }
3509
3480
  ],
3510
3481
  "/subscriber": [
3511
3482
  {
3512
3483
  "type": "GUIDE",
3513
3484
  "title": "Introduction",
3514
- "src": "---\narticleType: intro\n---\n\n# About the Subscriber API\n\nThe Subscriber API allows users to subscribe to [channels and resources](ADDLINK). When a [publisher](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction) sends messages, subscribers with suitable permissions receive them in real time. Channels and resources are isolated, so messages sent to a channel aren't published to a resource, and vice versa.\n\nLearn more [about the Realtime APIs](ADDLINK).\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\nWhile subscribing is asynchronous, the `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. The [`onSubscribed` handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) runs on every successful connection, including automatic re-subscriptions attempted after network interruptions. The [`onSubscriptionError` handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) runs whenever an error occurs.\n\n### Unsubscribing\n\nYou can unsubscribe in the following ways:\n\n- By `subscriptionId`: Removes a single subscription.\n- By `channel`: Removes all subscriptions to that channel or resource.\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## 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()` hook indicates whether all missed messages were successfully restored, or whether manual 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 server-side buffer limits for message replay. -->\n\n## Subscription errors\n\nSubscription errors are caused by the subscription being rejected or by connection failures. Each error includes `errorCode` and `recoverable` properties that indicate the error type and whether the client is automatically retrying.\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## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- Subscriptions are ephemeral. They don't persist across sessions.\n- Closing a browser tab removes all its subscriptions.\n- Permissions are checked when a subscription is first established. When a subscriber doesn't have `read` permission on the channel, their subscription fails.\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## Terminology\n\n- **Subscription**: An active connection between a client and a channel or resource, identified by a subscription ID.\n- **Subscription ID**: A unique identifier returned by `subscribe()`. Use it to unsubscribe or track lifecycle events.\n\n@sdk_package_setup\n"
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). When a [publisher](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/publisher/introduction) sends messages, subscribers with suitable permissions receive them in real time. Channels and resources are isolated, so messages sent to a channel aren't published to a resource, and vice versa.\n\nLearn more [about the Realtime APIs](ADDLINK).\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. The [`onSubscribed` handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) runs on every successful connection, including automatic re-subscriptions attempted after network interruptions. The [`onSubscriptionError` handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) runs whenever an error occurs.\n\n### Unsubscribing\n\nYou can unsubscribe in the following ways:\n\n- By `subscriptionId`: Removes a single subscription.\n- By `channel`: Removes all subscriptions to that channel or resource.\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## 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` properties that indicate the error type and whether the client is automatically retrying.\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## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- Subscriptions are ephemeral. They don't persist across sessions.\n- Closing a browser tab removes all its subscriptions.\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<!-- 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## Terminology\n\n- **Subscription**: An active connection between a client and a channel or resource, identified by a subscription ID.\n- **Subscription ID**: A unique identifier returned by `subscribe()`. Use it to unsubscribe or track lifecycle events.\n\n@sdk_package_setup\n"
3486
+ },
3487
+ {
3488
+ "type": "GUIDE",
3489
+ "title": "Setup",
3490
+ "src": "# Setup\n\n@package_metadata:@wix/realtime\n\nTo use the Realtime API, install the `@wix/realtime` package.\n\n#### Install the package\n\nFollow the installation instructions for your development environment.\n\n| Development environment | Installation method |\n| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Wix sites (editor or IDE) | Use the [package manager](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/packages/work-with-npm-packages-in-the-editor). |\n| Wix sites (local IDE) | Run `wix install @wix/realtime` using the [CLI](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/packages/work-with-npm-packages-with-the-wix-cli). |\n\n#### Import the package\n\nTo import the package in your code:\n\n```js\nimport { subscriber } from '@wix/realtime';\n```\n"
3515
3491
  }
3516
3492
  ],
3517
3493
  "/site": [
3518
3494
  {
3519
3495
  "type": "GUIDE",
3520
3496
  "title": "Introduction",
3521
- "src": "---\narticleType: intro\n---\n\n# About the Site API\n\nThe Site API lets you control subscriber permissions for the [Realtime APIs](ADDLINK). It determines which [subscribers](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/introduction) can receive messages on specific [channels and resources](ADDLINK).\n\nTo define permissions, set up the [`realtime_check_permission` hook](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) in the **realtime-permissions.js** file in a site's backend. You can include all permissions logic directly in the hook, or use the [permissions router](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) to organize permissions logic per channel and resource.\n\nWith the Site API, you can:\n\n- Define the `realtime_check_permission` hook to control subscriber access.\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\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 the `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- Learn more about [permissions in the realtime SDK](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction).\n\n<!-- ## Use cases\n\n- [Restrict channels to logged-in members](ADDLINK). -->\n\n@sdk_package_setup"
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\nTo define permissions, set up the [`realtime_check_permission` hook](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) in the **realtime-permissions.js** file in a site's backend. You can include all permissions logic directly in the hook, or use the [permissions router](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction) to organize permissions logic per channel and resource.\n\nWith the Site API, you can:\n\n- Define the `realtime_check_permission` hook to control subscriber access.\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\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\nLearn more about [permissions in the realtime SDK](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction).\n\n<!-- ## Use cases\n\n- [Restrict channels to logged-in members](ADDLINK). -->\n\n@sdk_package_setup\n"
3522
3498
  },
3523
3499
  {
3524
3500
  "type": "GUIDE",
@@ -3581,7 +3557,7 @@
3581
3557
  {
3582
3558
  "type": "GUIDE",
3583
3559
  "title": "Introduction",
3584
- "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 in the [`realtime_check_permission()` hook](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction).\n\nLearn more about the [Site API](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/introduction) and the [Realtime APIs](ADDLINK).\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:\n\n1. Create a **realtime-permissions.js** file in a site's backend.\n2. Export a `realtime_check_permission` hook. This hook runs automatically whenever a subscription is attempted.\n3. In the hook body, call `permissionsRouter.check()` to evaluate the subscriber's permissions based on the handlers you've registered.\n\n```js\nimport { permissionsRouter } from '@wix/realtime';\n\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## 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 the specified 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 specified or 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## 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. 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\n- [Restrict channels to logged-in members](ADDLINK). -->\n\n@sdk_package_setup"
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**: 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:\n\n1. Create a **realtime-permissions.js** file in a site's backend.\n2. Import the `permissionsRouter` in your code:\n\n ```js\n import { permissionsRouter } from \"@wix/realtime\";\n ```\n\n3. Export a `realtime_check_permission` hook. This hook runs automatically whenever a subscription is attempted.\n4. In the hook body, call `permissionsRouter.check()` to evaluate the subscriber's permissions based on the handlers you've registered.\n\n ```js\n permissionsRouter.default((channel, subscriber) => {\n return { read: true };\n });\n\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 the specified 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 specified or 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## 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. 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\n- [Restrict channels to logged-in members](ADDLINK). -->\n\n@sdk_package_setup\n"
3585
3561
  }
3586
3562
  ],
3587
3563
  "/site/PermissionsRouter/add": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/realtime",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -48,7 +48,7 @@
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.31",
51
+ "@wix/sdk_realtime_site": "1.0.32",
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": "00192eae4fb863495ba7cb35954ffb6f00076bbd32c605132020be11"
75
+ "falconPackageHash": "0cb740b899101f216960582b4cf3b79b8eda373e7510a3e7f9d7a72b"
76
76
  }