@wix/realtime 1.0.35 → 1.0.36
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/dist/statics/docs-ts-model.json +24 -225
- package/package.json +4 -4
|
@@ -249,15 +249,7 @@
|
|
|
249
249
|
"summary": [
|
|
250
250
|
{
|
|
251
251
|
"kind": "text",
|
|
252
|
-
"text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources.
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
"kind": "code",
|
|
256
|
-
"text": "`realtime_check_permission()`"
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
"kind": "text",
|
|
260
|
-
"text": " hook."
|
|
252
|
+
"text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources. Learn more about [permission resolution](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#permission-resolution)."
|
|
261
253
|
}
|
|
262
254
|
]
|
|
263
255
|
},
|
|
@@ -279,23 +271,7 @@
|
|
|
279
271
|
"summary": [
|
|
280
272
|
{
|
|
281
273
|
"kind": "text",
|
|
282
|
-
"text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
"kind": "code",
|
|
286
|
-
"text": "`add()`"
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
"kind": "text",
|
|
290
|
-
"text": ")\n+ channel: A, resource: 1, permissions: handler Y (set with "
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"kind": "code",
|
|
294
|
-
"text": "`add()`"
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
"kind": "text",
|
|
298
|
-
"text": ")\n+ channel: A, resource: 2, permissions: no handler\n\nPermissions are checked as follows:\n\n+ A: handler X\n+ A, resource 1: handler Y\n+ A, resource 2: handler X (inherited from channel)"
|
|
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 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)."
|
|
299
275
|
}
|
|
300
276
|
],
|
|
301
277
|
"blockTags": [
|
|
@@ -425,27 +401,7 @@
|
|
|
425
401
|
"summary": [
|
|
426
402
|
{
|
|
427
403
|
"kind": "text",
|
|
428
|
-
"text": "Checks permissions for a subscriber on a channel or resource.\n\
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
"kind": "code",
|
|
432
|
-
"text": "`{\"read\": true}`"
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
"kind": "text",
|
|
436
|
-
"text": ".\n\nTypically, call this method in the body of the "
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
"kind": "code",
|
|
440
|
-
"text": "`realtime_check_permission()`"
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
"kind": "text",
|
|
444
|
-
"text": "\nfunction:\n\n"
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
"kind": "code",
|
|
448
|
-
"text": "```JavaScript\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n```"
|
|
404
|
+
"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)."
|
|
449
405
|
}
|
|
450
406
|
],
|
|
451
407
|
"blockTags": [
|
|
@@ -606,39 +562,7 @@
|
|
|
606
562
|
"summary": [
|
|
607
563
|
{
|
|
608
564
|
"kind": "text",
|
|
609
|
-
"text": "Sets the default permissions handler.\n\nThe default handler runs
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
"kind": "code",
|
|
613
|
-
"text": "`add()`"
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
"kind": "text",
|
|
617
|
-
"text": ". Resources without their own handler\ninherit the parent channel's handler before falling back to the default.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: no handler\n+ channel: A, resource: 1, permissions: no handler\n+ channel: A, resource: 2, permissions: handler set with "
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
"kind": "code",
|
|
621
|
-
"text": "`add()`"
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
"kind": "text",
|
|
625
|
-
"text": "\n\nPermissions are checked as follows:\n\n+ A: default handler\n+ A, resource 1: default handler\n+ A, resource 2: handler set with "
|
|
626
|
-
},
|
|
627
|
-
{
|
|
628
|
-
"kind": "code",
|
|
629
|
-
"text": "`add()`"
|
|
630
|
-
},
|
|
631
|
-
{
|
|
632
|
-
"kind": "text",
|
|
633
|
-
"text": "\n\nIf no default handler is set, the built-in default permissions are used:\n"
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
"kind": "code",
|
|
637
|
-
"text": "`{\"read\": true}`"
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
"kind": "text",
|
|
641
|
-
"text": "."
|
|
565
|
+
"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)."
|
|
642
566
|
}
|
|
643
567
|
],
|
|
644
568
|
"blockTags": [
|
|
@@ -891,23 +815,7 @@
|
|
|
891
815
|
"summary": [
|
|
892
816
|
{
|
|
893
817
|
"kind": "text",
|
|
894
|
-
"text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource
|
|
895
|
-
},
|
|
896
|
-
{
|
|
897
|
-
"kind": "code",
|
|
898
|
-
"text": "`add()`"
|
|
899
|
-
},
|
|
900
|
-
{
|
|
901
|
-
"kind": "text",
|
|
902
|
-
"text": ")\n+ channel: A, resource: 1, permissions: handler Y (set with "
|
|
903
|
-
},
|
|
904
|
-
{
|
|
905
|
-
"kind": "code",
|
|
906
|
-
"text": "`add()`"
|
|
907
|
-
},
|
|
908
|
-
{
|
|
909
|
-
"kind": "text",
|
|
910
|
-
"text": ")\n+ channel: A, resource: 2, permissions: no handler\n\nPermissions are checked as follows:\n\n+ A: handler X\n+ A, resource 1: handler Y\n+ A, resource 2: handler X (inherited from channel)"
|
|
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)."
|
|
911
819
|
}
|
|
912
820
|
],
|
|
913
821
|
"blockTags": [
|
|
@@ -981,7 +889,7 @@
|
|
|
981
889
|
"summary": [
|
|
982
890
|
{
|
|
983
891
|
"kind": "text",
|
|
984
|
-
"text": "
|
|
892
|
+
"text": "Handler to run when checking permissions for the specified channel."
|
|
985
893
|
}
|
|
986
894
|
]
|
|
987
895
|
},
|
|
@@ -1028,27 +936,7 @@
|
|
|
1028
936
|
"summary": [
|
|
1029
937
|
{
|
|
1030
938
|
"kind": "text",
|
|
1031
|
-
"text": "Checks
|
|
1032
|
-
},
|
|
1033
|
-
{
|
|
1034
|
-
"kind": "code",
|
|
1035
|
-
"text": "`{\"read\": true}`"
|
|
1036
|
-
},
|
|
1037
|
-
{
|
|
1038
|
-
"kind": "text",
|
|
1039
|
-
"text": ".\n\nTypically, call this method in the body of the "
|
|
1040
|
-
},
|
|
1041
|
-
{
|
|
1042
|
-
"kind": "code",
|
|
1043
|
-
"text": "`realtime_check_permission()`"
|
|
1044
|
-
},
|
|
1045
|
-
{
|
|
1046
|
-
"kind": "text",
|
|
1047
|
-
"text": "\nfunction:\n\n"
|
|
1048
|
-
},
|
|
1049
|
-
{
|
|
1050
|
-
"kind": "code",
|
|
1051
|
-
"text": "```JavaScript\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n```"
|
|
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)."
|
|
1052
940
|
}
|
|
1053
941
|
],
|
|
1054
942
|
"blockTags": [
|
|
@@ -1198,39 +1086,7 @@
|
|
|
1198
1086
|
"summary": [
|
|
1199
1087
|
{
|
|
1200
1088
|
"kind": "text",
|
|
1201
|
-
"text": "Sets the default permissions handler.\n\nThe default handler runs
|
|
1202
|
-
},
|
|
1203
|
-
{
|
|
1204
|
-
"kind": "code",
|
|
1205
|
-
"text": "`add()`"
|
|
1206
|
-
},
|
|
1207
|
-
{
|
|
1208
|
-
"kind": "text",
|
|
1209
|
-
"text": ". Resources without their own handler\ninherit the parent channel's handler before falling back to the default.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: no handler\n+ channel: A, resource: 1, permissions: no handler\n+ channel: A, resource: 2, permissions: handler set with "
|
|
1210
|
-
},
|
|
1211
|
-
{
|
|
1212
|
-
"kind": "code",
|
|
1213
|
-
"text": "`add()`"
|
|
1214
|
-
},
|
|
1215
|
-
{
|
|
1216
|
-
"kind": "text",
|
|
1217
|
-
"text": "\n\nPermissions are checked as follows:\n\n+ A: default handler\n+ A, resource 1: default handler\n+ A, resource 2: handler set with "
|
|
1218
|
-
},
|
|
1219
|
-
{
|
|
1220
|
-
"kind": "code",
|
|
1221
|
-
"text": "`add()`"
|
|
1222
|
-
},
|
|
1223
|
-
{
|
|
1224
|
-
"kind": "text",
|
|
1225
|
-
"text": "\n\nIf no default handler is set, the built-in default permissions are used:\n"
|
|
1226
|
-
},
|
|
1227
|
-
{
|
|
1228
|
-
"kind": "code",
|
|
1229
|
-
"text": "`{\"read\": true}`"
|
|
1230
|
-
},
|
|
1231
|
-
{
|
|
1232
|
-
"kind": "text",
|
|
1233
|
-
"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)."
|
|
1234
1090
|
}
|
|
1235
1091
|
],
|
|
1236
1092
|
"blockTags": [
|
|
@@ -1265,7 +1121,7 @@
|
|
|
1265
1121
|
"summary": [
|
|
1266
1122
|
{
|
|
1267
1123
|
"kind": "text",
|
|
1268
|
-
"text": "
|
|
1124
|
+
"text": "Default handler to run when checking permissions."
|
|
1269
1125
|
}
|
|
1270
1126
|
]
|
|
1271
1127
|
},
|
|
@@ -1626,15 +1482,7 @@
|
|
|
1626
1482
|
"summary": [
|
|
1627
1483
|
{
|
|
1628
1484
|
"kind": "text",
|
|
1629
|
-
"text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources.
|
|
1630
|
-
},
|
|
1631
|
-
{
|
|
1632
|
-
"kind": "code",
|
|
1633
|
-
"text": "`realtime_check_permission()`"
|
|
1634
|
-
},
|
|
1635
|
-
{
|
|
1636
|
-
"kind": "text",
|
|
1637
|
-
"text": "](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) hook."
|
|
1485
|
+
"text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources. Learn more about the [permissions router](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction)."
|
|
1638
1486
|
}
|
|
1639
1487
|
],
|
|
1640
1488
|
"blockTags": [
|
|
@@ -1881,47 +1729,7 @@
|
|
|
1881
1729
|
"summary": [
|
|
1882
1730
|
{
|
|
1883
1731
|
"kind": "text",
|
|
1884
|
-
"text": "Checks permissions for a subscriber on a channel or resource.\n\nThis
|
|
1885
|
-
},
|
|
1886
|
-
{
|
|
1887
|
-
"kind": "code",
|
|
1888
|
-
"text": "`\"read\": true`"
|
|
1889
|
-
},
|
|
1890
|
-
{
|
|
1891
|
-
"kind": "text",
|
|
1892
|
-
"text": ".\n> - When previewing the site, "
|
|
1893
|
-
},
|
|
1894
|
-
{
|
|
1895
|
-
"kind": "code",
|
|
1896
|
-
"text": "`read`"
|
|
1897
|
-
},
|
|
1898
|
-
{
|
|
1899
|
-
"kind": "text",
|
|
1900
|
-
"text": " permissions are always set to "
|
|
1901
|
-
},
|
|
1902
|
-
{
|
|
1903
|
-
"kind": "code",
|
|
1904
|
-
"text": "`true`"
|
|
1905
|
-
},
|
|
1906
|
-
{
|
|
1907
|
-
"kind": "text",
|
|
1908
|
-
"text": ".\n> - In Wix Studio, you don't need to define this handler. However, you must create the **realtime-permissions.js** file. Without it, all subscriptions fail.\n\nYou can set up permissions logic by:\n\n- Including all permissions logic directly in the handler body.\n- Defining permissions logic per channel or resource with "
|
|
1909
|
-
},
|
|
1910
|
-
{
|
|
1911
|
-
"kind": "code",
|
|
1912
|
-
"text": "`permissionsRouter.add()`"
|
|
1913
|
-
},
|
|
1914
|
-
{
|
|
1915
|
-
"kind": "text",
|
|
1916
|
-
"text": ", then calling "
|
|
1917
|
-
},
|
|
1918
|
-
{
|
|
1919
|
-
"kind": "code",
|
|
1920
|
-
"text": "`permissionsRouter.check()`"
|
|
1921
|
-
},
|
|
1922
|
-
{
|
|
1923
|
-
"kind": "text",
|
|
1924
|
-
"text": " to evaluate each subscription request."
|
|
1732
|
+
"text": "Checks permissions for a subscriber on a channel or resource.\n\nThis hook runs automatically whenever a new subscription is attempted.\n\nSet up this hook as a named export in the **realtime-permissions.js** file in a site's backend.\n\nLearn more about [setting up permissions](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/introduction#setting-up-permissions)."
|
|
1925
1733
|
}
|
|
1926
1734
|
],
|
|
1927
1735
|
"blockTags": [
|
|
@@ -1970,15 +1778,6 @@
|
|
|
1970
1778
|
}
|
|
1971
1779
|
]
|
|
1972
1780
|
},
|
|
1973
|
-
{
|
|
1974
|
-
"tag": "@servicePath",
|
|
1975
|
-
"content": [
|
|
1976
|
-
{
|
|
1977
|
-
"kind": "text",
|
|
1978
|
-
"text": "wix-realtime-backend.ChannelPermissions"
|
|
1979
|
-
}
|
|
1980
|
-
]
|
|
1981
|
-
},
|
|
1982
1781
|
{
|
|
1983
1782
|
"tag": "@servicePath",
|
|
1984
1783
|
"content": [
|
|
@@ -2597,7 +2396,7 @@
|
|
|
2597
2396
|
},
|
|
2598
2397
|
{
|
|
2599
2398
|
"kind": "text",
|
|
2600
|
-
"text": " to determine whether the client is attempting to reconnect.
|
|
2399
|
+
"text": " to determine whether the client is attempting to reconnect."
|
|
2601
2400
|
}
|
|
2602
2401
|
]
|
|
2603
2402
|
},
|
|
@@ -3047,7 +2846,7 @@
|
|
|
3047
2846
|
"summary": [
|
|
3048
2847
|
{
|
|
3049
2848
|
"kind": "text",
|
|
3050
|
-
"text": "Publisher ID
|
|
2849
|
+
"text": "Publisher ID."
|
|
3051
2850
|
}
|
|
3052
2851
|
]
|
|
3053
2852
|
},
|
|
@@ -3591,7 +3390,7 @@
|
|
|
3591
3390
|
},
|
|
3592
3391
|
{
|
|
3593
3392
|
"kind": "text",
|
|
3594
|
-
"text": " flag indicates whether all missed messages were successfully delivered.\n\
|
|
3393
|
+
"text": " flag indicates whether all missed messages were successfully delivered.\n\n<!-- TODO: Document server-side buffer limits for message replay. -->"
|
|
3595
3394
|
}
|
|
3596
3395
|
]
|
|
3597
3396
|
},
|
|
@@ -3698,33 +3497,33 @@
|
|
|
3698
3497
|
{
|
|
3699
3498
|
"type": "GUIDE",
|
|
3700
3499
|
"title": "Introduction",
|
|
3701
|
-
"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**](
|
|
3702
|
-
},
|
|
3703
|
-
{
|
|
3704
|
-
"type": "GUIDE",
|
|
3705
|
-
"title": "Setup",
|
|
3706
|
-
"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 [Wix 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 { site } from `@wix/realtime`;\n```"
|
|
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"
|
|
3707
3501
|
}
|
|
3708
3502
|
],
|
|
3709
3503
|
"/publisher": [
|
|
3710
3504
|
{
|
|
3711
3505
|
"type": "GUIDE",
|
|
3712
3506
|
"title": "Introduction",
|
|
3713
|
-
"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](
|
|
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"
|
|
3714
3508
|
}
|
|
3715
3509
|
],
|
|
3716
3510
|
"/subscriber": [
|
|
3717
3511
|
{
|
|
3718
3512
|
"type": "GUIDE",
|
|
3719
3513
|
"title": "Introduction",
|
|
3720
|
-
"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 [
|
|
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"
|
|
3721
3515
|
}
|
|
3722
3516
|
],
|
|
3723
3517
|
"/site": [
|
|
3724
3518
|
{
|
|
3725
3519
|
"type": "GUIDE",
|
|
3726
3520
|
"title": "Introduction",
|
|
3727
|
-
"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](
|
|
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"
|
|
3522
|
+
},
|
|
3523
|
+
{
|
|
3524
|
+
"type": "GUIDE",
|
|
3525
|
+
"title": "Setup",
|
|
3526
|
+
"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 [Wix 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 { site } from `@wix/realtime`;\n```"
|
|
3728
3527
|
}
|
|
3729
3528
|
],
|
|
3730
3529
|
"/site/publish": [
|
|
@@ -3782,7 +3581,7 @@
|
|
|
3782
3581
|
{
|
|
3783
3582
|
"type": "GUIDE",
|
|
3784
3583
|
"title": "Introduction",
|
|
3785
|
-
"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()`](
|
|
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"
|
|
3786
3585
|
}
|
|
3787
3586
|
],
|
|
3788
3587
|
"/site/PermissionsRouter/add": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/realtime",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
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.
|
|
40
|
+
"@wix/realtime-common": "1.0.15",
|
|
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.
|
|
44
|
+
"@wix/sdk_realtime_site": "1.0.31",
|
|
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": "
|
|
68
|
+
"falconPackageHash": "c16f25034259a8263b0ea9dc82e596b620606ce1d74d106114c2530c"
|
|
69
69
|
}
|