@wix/realtime 1.0.33 → 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.
@@ -38,7 +38,7 @@
38
38
  "summary": [
39
39
  {
40
40
  "kind": "text",
41
- "text": "Publishes a message to a realtime channel.\n\nRequires a service identity (server-side only). The caller must have\napp-level permissions to publish messages."
41
+ "text": "Publishes a message to a channel or resource.\n\nThe 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.\n\n> **Authentication**\n>\n> This method may require higher-level permissions than the caller has, based on their [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities) and [roles and permissions](https://support.wix.com/en/article/roles-permissions-overview). In these cases, you can ensure the method is called with the required level of authorization by using [elevated permissions](https://dev.wix.com/docs/api-reference/articles/authentication/about-elevated-permissions).\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->"
42
42
  }
43
43
  ],
44
44
  "blockTags": [
@@ -47,11 +47,11 @@
47
47
  "content": [
48
48
  {
49
49
  "kind": "text",
50
- "text": "Manual client (self-hosted / explicit auth)\n"
50
+ "text": "Publish a message to the specified channel\n"
51
51
  },
52
52
  {
53
53
  "kind": "code",
54
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { publisher },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
54
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
55
55
  }
56
56
  ]
57
57
  },
@@ -60,11 +60,11 @@
60
60
  "content": [
61
61
  {
62
62
  "kind": "text",
63
- "text": "Contextual client (Wix-hosted)\n"
63
+ "text": "Publish a message to the specified channel: Self-hosted\n"
64
64
  },
65
65
  {
66
66
  "kind": "code",
67
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
67
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { publisher },\n // Include the auth strategy and host as relevant\n});\n\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
68
68
  }
69
69
  ]
70
70
  }
@@ -81,7 +81,7 @@
81
81
  "summary": [
82
82
  {
83
83
  "kind": "text",
84
- "text": "The channel, and optionally the resource, to publish to."
84
+ "text": "Channel or resource to publish to."
85
85
  }
86
86
  ]
87
87
  },
@@ -102,7 +102,7 @@
102
102
  "summary": [
103
103
  {
104
104
  "kind": "text",
105
- "text": "Message payload. Max: 10kb"
105
+ "text": "Message payload. Max: 10 KB."
106
106
  }
107
107
  ]
108
108
  },
@@ -153,7 +153,7 @@
153
153
  "summary": [
154
154
  {
155
155
  "kind": "text",
156
- "text": "Publishes a message to a realtime channel.\n\nRequires a service identity (server-side only). The caller must have\napp-level permissions to publish messages."
156
+ "text": "Publishes a message to a channel or resource.\n\nThe 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.\n\n> **Authentication**\n>\n> This method may require higher-level permissions than the caller has, based on their [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities) and [roles and permissions](https://support.wix.com/en/article/roles-permissions-overview). In these cases, you can ensure the method is called with the required level of authorization by using [elevated permissions](https://dev.wix.com/docs/api-reference/articles/authentication/about-elevated-permissions).\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->"
157
157
  }
158
158
  ],
159
159
  "blockTags": [
@@ -162,11 +162,11 @@
162
162
  "content": [
163
163
  {
164
164
  "kind": "text",
165
- "text": "Manual client (self-hosted / explicit auth)\n"
165
+ "text": "Publish a message to the specified channel\n"
166
166
  },
167
167
  {
168
168
  "kind": "code",
169
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { publisher },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
169
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
170
170
  }
171
171
  ]
172
172
  },
@@ -175,11 +175,11 @@
175
175
  "content": [
176
176
  {
177
177
  "kind": "text",
178
- "text": "Contextual client (Wix-hosted)\n"
178
+ "text": "Publish a message to the specified channel: Self-hosted\n"
179
179
  },
180
180
  {
181
181
  "kind": "code",
182
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
182
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { publisher },\n // Include the auth strategy and host as relevant\n});\n\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
183
183
  }
184
184
  ]
185
185
  }
@@ -249,7 +249,7 @@
249
249
  "summary": [
250
250
  {
251
251
  "kind": "text",
252
- "text": "A router for defining and checking permissions.\n\nUse the permissions router to define the permissions you want to grant to subscribers\n on channels or channel resources. You can set permissions on the channel and channel\n resource level. If you do not define permissions for a particular channel resource,\n that resource inherits the permissions of its parent channel.\n\n Typically you use the permissions router in the **realtime-permissions.js** file in\n your site's backend to:\n\n + Set default permissions for all channels and channel resources where no explicit\n permissions are defined.\n + Add permissions logic for specific channels or channel resources.\n + Check the permissions for a specific subscriber on a specific channel.\n\n > **Note:** Although it is recommended, you do not need to use the permissions router to set permissions. You can also define all your permissions logic in the ["
252
+ "text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources. You can set permissions at the channel level as well as the resource level. When a resource isn't assigned explicit permissions, it inherits the permissions of its parent channel.\n\nUse the permissions router in the **realtime-permissions.js** file in the site's backend to:\n\n- Set default permissions for all channels that don't have explicit permissions.\n- Add permissions logic for specific channels or resources.\n- Check permissions for a subscriber on a channel or resource.\n\n> **Note:** You can also define permissions directly in the "
253
253
  },
254
254
  {
255
255
  "kind": "code",
@@ -257,7 +257,7 @@
257
257
  },
258
258
  {
259
259
  "kind": "text",
260
- "text": "](#realtime_check_permission) function."
260
+ "text": " hook."
261
261
  }
262
262
  ]
263
263
  },
@@ -279,23 +279,7 @@
279
279
  "summary": [
280
280
  {
281
281
  "kind": "text",
282
- "text": "Sets a permissions handler for a specific channel or channel resource.\n\nThe handler set by the "
283
- },
284
- {
285
- "kind": "code",
286
- "text": "`add()`"
287
- },
288
- {
289
- "kind": "text",
290
- "text": " function is used for permission checks by the permissions\n router for the channel or channel resource specified in the "
291
- },
292
- {
293
- "kind": "code",
294
- "text": "`channel`"
295
- },
296
- {
297
- "kind": "text",
298
- "text": " property.\n\n Adding a handler to a specific channel without a specified resource adds a handler for\n all permissions checks on the channel and all permissions checks on any of the channel's\n resources that do not have their own permissions handlers.\n\n For example, suppose you have the following channel, resources, and permissions:\n\n + channel: A, permissions: handler X is specified using the "
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\nhandler to the channel itself and to any of its resources that don't have\ntheir own handler.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: handler X (set with "
299
283
  },
300
284
  {
301
285
  "kind": "code",
@@ -303,7 +287,7 @@
303
287
  },
304
288
  {
305
289
  "kind": "text",
306
- "text": " function\n + channel: A, resource: 1, permissions: handler Y is specified using the "
290
+ "text": ")\n+ channel: A, resource: 1, permissions: handler Y (set with "
307
291
  },
308
292
  {
309
293
  "kind": "code",
@@ -311,7 +295,7 @@
311
295
  },
312
296
  {
313
297
  "kind": "text",
314
- "text": " function\n + channel: A, resource: 2, permissions: no handler is specified\n\n\n Permissions will be checked as follows:\n\n + A: use handler X\n + A, 1: use handler Y\n + A, 2: use handler X"
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)"
315
299
  }
316
300
  ],
317
301
  "blockTags": [
@@ -364,7 +348,7 @@
364
348
  "summary": [
365
349
  {
366
350
  "kind": "text",
367
- "text": "Channel or channel resource to add a permissions handler for."
351
+ "text": "Channel or resource to set a permissions handler for."
368
352
  }
369
353
  ]
370
354
  },
@@ -385,7 +369,7 @@
385
369
  "summary": [
386
370
  {
387
371
  "kind": "text",
388
- "text": "The name of the\n function or the function expression to use when checking permissions for the specified channel."
372
+ "text": "Handler to run when checking permissions for the specified channel."
389
373
  }
390
374
  ]
391
375
  },
@@ -441,15 +425,7 @@
441
425
  "summary": [
442
426
  {
443
427
  "kind": "text",
444
- "text": "Checks the permissions for a subscriber on a channel or channel resource.\n\nThe "
445
- },
446
- {
447
- "kind": "code",
448
- "text": "`check()`"
449
- },
450
- {
451
- "kind": "text",
452
- "text": " function returns a Promise that resolves to the permissions for the\n specified user on the specified channel or channel resource.\n\n The check is performed as follows:\n\n 1. If a permissions handler for the specified channel or channel resource exists,\n it's invoked and its result is returned.\n 1. If no handler is found for the specified channel resource, but a handler\n exists for the resource's channel, it's invoked and its result is returned.\n 1. If no handler is found for the specified channel, but a default permissions handler\n exists, it's invoked and its result is returned.\n 1. If the default handler has not been found, the default permissions are returned.\n\n The default permissions are:\n "
428
+ "text": "Checks permissions for a subscriber on a channel or resource.\n\nThe resolution chain is:\n\n1. If a handler exists for the specified channel or resource, it runs and\n its result is returned.\n1. If no handler exists for the resource, the parent channel's handler\n runs instead.\n1. If no channel handler exists, the default handler runs.\n1. If no default handler is set, the built-in default permissions are\n returned: "
453
429
  },
454
430
  {
455
431
  "kind": "code",
@@ -457,7 +433,7 @@
457
433
  },
458
434
  {
459
435
  "kind": "text",
460
- "text": "\n\n\n This function is typically called in the body of the\n ["
436
+ "text": ".\n\nTypically, call this method in the body of the "
461
437
  },
462
438
  {
463
439
  "kind": "code",
@@ -465,11 +441,11 @@
465
441
  },
466
442
  {
467
443
  "kind": "text",
468
- "text": "](#realtime_check_permission) function like so:\n\n "
444
+ "text": "\nfunction:\n\n"
469
445
  },
470
446
  {
471
447
  "kind": "code",
472
- "text": "```JavaScript\n export function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel,subscriber);\n }\n ```"
448
+ "text": "```JavaScript\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n```"
473
449
  }
474
450
  ],
475
451
  "blockTags": [
@@ -514,7 +490,7 @@
514
490
  "content": [
515
491
  {
516
492
  "kind": "text",
517
- "text": "The permissions granted to the subscriber on the channel or channel resource."
493
+ "text": "Permissions granted to the subscriber for the specified channel or resource."
518
494
  }
519
495
  ]
520
496
  },
@@ -549,7 +525,7 @@
549
525
  "summary": [
550
526
  {
551
527
  "kind": "text",
552
- "text": "Channel to check permissions for."
528
+ "text": "Channel or resource to check permissions for."
553
529
  }
554
530
  ]
555
531
  },
@@ -630,43 +606,39 @@
630
606
  "summary": [
631
607
  {
632
608
  "kind": "text",
633
- "text": "Sets a permissions handler for default permissions.\n\nThe handler set by the "
609
+ "text": "Sets the default permissions handler.\n\nThe default handler runs for all channels and resources where no explicit\nhandler has been added with "
634
610
  },
635
611
  {
636
612
  "kind": "code",
637
- "text": "`default()`"
613
+ "text": "`add()`"
638
614
  },
639
615
  {
640
616
  "kind": "text",
641
- "text": " function is used for permission checks by the permissions\n router for all channels where an explicit handler has not been added. For channel resources,\n if no explicit handler has been set, the resource will inherit the permissions of its parent\n channel.\n\n For example, suppose you have the following channel, resources, and permissions:\n\n + channel: A, permissions: no handler specified\n + channel: A, resource: 1, permissions: no handler specified\n + channel: A, resource: 2, permissions: handler is specified\n\n\n Permissions will be checked as follows:\n\n + A: use the handler set by "
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 "
642
618
  },
643
619
  {
644
620
  "kind": "code",
645
- "text": "`default()`"
621
+ "text": "`add()`"
646
622
  },
647
623
  {
648
624
  "kind": "text",
649
- "text": " function\n + A, 1: use the handler set by "
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 "
650
626
  },
651
627
  {
652
628
  "kind": "code",
653
- "text": "`default()`"
629
+ "text": "`add()`"
654
630
  },
655
631
  {
656
632
  "kind": "text",
657
- "text": " function\n + A, 2: use the handler set by "
633
+ "text": "\n\nIf no default handler is set, the built-in default permissions are used:\n"
658
634
  },
659
635
  {
660
636
  "kind": "code",
661
- "text": "`add()`"
637
+ "text": "`{\"read\": true}`"
662
638
  },
663
639
  {
664
640
  "kind": "text",
665
- "text": " function for this resource\n\n\n If no default handler is set, subscribers to channels without explicit permissions handlers will\n receive the following permissions:\n "
666
- },
667
- {
668
- "kind": "code",
669
- "text": "`{\"read\": true}`"
641
+ "text": "."
670
642
  }
671
643
  ],
672
644
  "blockTags": [
@@ -701,7 +673,7 @@
701
673
  "summary": [
702
674
  {
703
675
  "kind": "text",
704
- "text": "The name of the\n function or the function expression to use when checking default permissions."
676
+ "text": "Handler to run when checking default permissions."
705
677
  }
706
678
  ]
707
679
  },
@@ -757,7 +729,15 @@
757
729
  "summary": [
758
730
  {
759
731
  "kind": "text",
760
- "text": "undefined\n\nHandles setting of permissions for a subscriber on a channel or\n channel resource."
732
+ "text": "Determines the permissions for a subscriber on a channel or resource. Return a "
733
+ },
734
+ {
735
+ "kind": "code",
736
+ "text": "`ChannelPermissions`"
737
+ },
738
+ {
739
+ "kind": "text",
740
+ "text": " object to grant or deny access."
761
741
  }
762
742
  ],
763
743
  "blockTags": [
@@ -828,7 +808,7 @@
828
808
  "summary": [
829
809
  {
830
810
  "kind": "text",
831
- "text": "The channel to grant permissions to."
811
+ "text": "Channel or resource being checked."
832
812
  }
833
813
  ]
834
814
  },
@@ -849,7 +829,7 @@
849
829
  "summary": [
850
830
  {
851
831
  "kind": "text",
852
- "text": "The subscriber to grant permissions to."
832
+ "text": "Subscriber whose permissions are being checked."
853
833
  }
854
834
  ]
855
835
  },
@@ -911,23 +891,7 @@
911
891
  "summary": [
912
892
  {
913
893
  "kind": "text",
914
- "text": "Sets a permissions handler for a specific channel or channel resource.\n\nThe handler set by the "
915
- },
916
- {
917
- "kind": "code",
918
- "text": "`add()`"
919
- },
920
- {
921
- "kind": "text",
922
- "text": " function is used for permission checks by the permissions\n router for the channel or channel resource specified in the "
923
- },
924
- {
925
- "kind": "code",
926
- "text": "`channel`"
927
- },
928
- {
929
- "kind": "text",
930
- "text": " property.\n\n Adding a handler to a specific channel without a specified resource adds a handler for\n all permissions checks on the channel and all permissions checks on any of the channel's\n resources that do not have their own permissions handlers.\n\n For example, suppose you have the following channel, resources, and permissions:\n\n + channel: A, permissions: handler X is specified using the "
894
+ "text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the\nhandler to the channel itself and to any of its resources that don't have\ntheir own handler.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: handler X (set with "
931
895
  },
932
896
  {
933
897
  "kind": "code",
@@ -935,7 +899,7 @@
935
899
  },
936
900
  {
937
901
  "kind": "text",
938
- "text": " function\n + channel: A, resource: 1, permissions: handler Y is specified using the "
902
+ "text": ")\n+ channel: A, resource: 1, permissions: handler Y (set with "
939
903
  },
940
904
  {
941
905
  "kind": "code",
@@ -943,7 +907,7 @@
943
907
  },
944
908
  {
945
909
  "kind": "text",
946
- "text": " function\n + channel: A, resource: 2, permissions: no handler is specified\n\n\n Permissions will be checked as follows:\n\n + A: use handler X\n + A, 1: use handler Y\n + A, 2: use handler X"
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)"
947
911
  }
948
912
  ],
949
913
  "blockTags": [
@@ -996,7 +960,7 @@
996
960
  "summary": [
997
961
  {
998
962
  "kind": "text",
999
- "text": "Channel or channel resource to add a permissions handler for."
963
+ "text": "Channel or resource to set a permissions handler for."
1000
964
  }
1001
965
  ]
1002
966
  },
@@ -1017,7 +981,7 @@
1017
981
  "summary": [
1018
982
  {
1019
983
  "kind": "text",
1020
- "text": "The name of the\n function or the function expression to use when checking permissions for the specified channel."
984
+ "text": "Function to run when checking permissions for the specified channel."
1021
985
  }
1022
986
  ]
1023
987
  },
@@ -1064,15 +1028,7 @@
1064
1028
  "summary": [
1065
1029
  {
1066
1030
  "kind": "text",
1067
- "text": "Checks the permissions for a subscriber on a channel or channel resource.\n\nThe "
1068
- },
1069
- {
1070
- "kind": "code",
1071
- "text": "`check()`"
1072
- },
1073
- {
1074
- "kind": "text",
1075
- "text": " function returns a Promise that resolves to the permissions for the\n specified user on the specified channel or channel resource.\n\n The check is performed as follows:\n\n 1. If a permissions handler for the specified channel or channel resource exists,\n it's invoked and its result is returned.\n 1. If no handler is found for the specified channel resource, but a handler\n exists for the resource's channel, it's invoked and its result is returned.\n 1. If no handler is found for the specified channel, but a default permissions handler\n exists, it's invoked and its result is returned.\n 1. If the default handler has not been found, the default permissions are returned.\n\n The default permissions are:\n "
1031
+ "text": "Checks the permissions for a subscriber on a channel or resource.\n\nThe resolution chain is:\n\n1. If a handler exists for the specified channel or resource, it runs and\n its result is returned.\n1. If no handler exists for the resource, the parent channel's handler\n runs instead.\n1. If no channel handler exists, the default handler runs.\n1. If no default handler is set, the built-in default permissions are\n returned: "
1076
1032
  },
1077
1033
  {
1078
1034
  "kind": "code",
@@ -1080,7 +1036,7 @@
1080
1036
  },
1081
1037
  {
1082
1038
  "kind": "text",
1083
- "text": "\n\n\n This function is typically called in the body of the\n ["
1039
+ "text": ".\n\nTypically, call this method in the body of the "
1084
1040
  },
1085
1041
  {
1086
1042
  "kind": "code",
@@ -1088,11 +1044,11 @@
1088
1044
  },
1089
1045
  {
1090
1046
  "kind": "text",
1091
- "text": "](#realtime_check_permission) function like so:\n\n "
1047
+ "text": "\nfunction:\n\n"
1092
1048
  },
1093
1049
  {
1094
1050
  "kind": "code",
1095
- "text": "```JavaScript\n export function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel,subscriber);\n }\n ```"
1051
+ "text": "```JavaScript\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n```"
1096
1052
  }
1097
1053
  ],
1098
1054
  "blockTags": [
@@ -1137,7 +1093,7 @@
1137
1093
  "content": [
1138
1094
  {
1139
1095
  "kind": "text",
1140
- "text": "The permissions granted to the subscriber on the channel or channel resource."
1096
+ "text": "Permissions granted to the subscriber for the specified channel or resource."
1141
1097
  }
1142
1098
  ]
1143
1099
  },
@@ -1172,7 +1128,7 @@
1172
1128
  "summary": [
1173
1129
  {
1174
1130
  "kind": "text",
1175
- "text": "Channel to check permissions for."
1131
+ "text": "Channel or resource to check permissions for."
1176
1132
  }
1177
1133
  ]
1178
1134
  },
@@ -1242,43 +1198,39 @@
1242
1198
  "summary": [
1243
1199
  {
1244
1200
  "kind": "text",
1245
- "text": "Sets a permissions handler for default permissions.\n\nThe handler set by the "
1201
+ "text": "Sets the default permissions handler.\n\nThe default handler runs for all channels and resources where no explicit\nhandler has been added with "
1246
1202
  },
1247
1203
  {
1248
1204
  "kind": "code",
1249
- "text": "`default()`"
1205
+ "text": "`add()`"
1250
1206
  },
1251
1207
  {
1252
1208
  "kind": "text",
1253
- "text": " function is used for permission checks by the permissions\n router for all channels where an explicit handler has not been added. For channel resources,\n if no explicit handler has been set, the resource will inherit the permissions of its parent\n channel.\n\n For example, suppose you have the following channel, resources, and permissions:\n\n + channel: A, permissions: no handler specified\n + channel: A, resource: 1, permissions: no handler specified\n + channel: A, resource: 2, permissions: handler is specified\n\n\n Permissions will be checked as follows:\n\n + A: use the handler set by "
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 "
1254
1210
  },
1255
1211
  {
1256
1212
  "kind": "code",
1257
- "text": "`default()`"
1213
+ "text": "`add()`"
1258
1214
  },
1259
1215
  {
1260
1216
  "kind": "text",
1261
- "text": " function\n + A, 1: use the handler set by "
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 "
1262
1218
  },
1263
1219
  {
1264
1220
  "kind": "code",
1265
- "text": "`default()`"
1221
+ "text": "`add()`"
1266
1222
  },
1267
1223
  {
1268
1224
  "kind": "text",
1269
- "text": " function\n + A, 2: use the handler set by "
1225
+ "text": "\n\nIf no default handler is set, the built-in default permissions are used:\n"
1270
1226
  },
1271
1227
  {
1272
1228
  "kind": "code",
1273
- "text": "`add()`"
1229
+ "text": "`{\"read\": true}`"
1274
1230
  },
1275
1231
  {
1276
1232
  "kind": "text",
1277
- "text": " function for this resource\n\n\n If no default handler is set, subscribers to channels without explicit permissions handlers will\n receive the following permissions:\n "
1278
- },
1279
- {
1280
- "kind": "code",
1281
- "text": "`{\"read\": true}`"
1233
+ "text": "."
1282
1234
  }
1283
1235
  ],
1284
1236
  "blockTags": [
@@ -1313,7 +1265,7 @@
1313
1265
  "summary": [
1314
1266
  {
1315
1267
  "kind": "text",
1316
- "text": "The name of the\n function or the function expression to use when checking default permissions."
1268
+ "text": "Function to run when checking default permissions."
1317
1269
  }
1318
1270
  ]
1319
1271
  },
@@ -1366,7 +1318,7 @@
1366
1318
  "summary": [
1367
1319
  {
1368
1320
  "kind": "text",
1369
- "text": "An object representing a realtime channel."
1321
+ "text": "Realtime broadcast channel. Publishers send messages to channels and subscribers listen to them."
1370
1322
  }
1371
1323
  ]
1372
1324
  },
@@ -1381,7 +1333,7 @@
1381
1333
  "summary": [
1382
1334
  {
1383
1335
  "kind": "text",
1384
- "text": "Channel name. Only alphanumeric characters, hyphens, and underscores are allowed.\nThe combined length of "
1336
+ "text": "Channel name.\n\n> **Notes:**\n> - Supports only alphanumeric characters, hyphens, and underscores.\n> - The combined length of "
1385
1337
  },
1386
1338
  {
1387
1339
  "kind": "code",
@@ -1397,7 +1349,7 @@
1397
1349
  },
1398
1350
  {
1399
1351
  "kind": "text",
1400
- "text": " cannot exceed 140 characters."
1352
+ "text": " can't exceed 140 characters."
1401
1353
  }
1402
1354
  ]
1403
1355
  },
@@ -1418,7 +1370,7 @@
1418
1370
  "summary": [
1419
1371
  {
1420
1372
  "kind": "text",
1421
- "text": "ID of a specific channel resource."
1373
+ "text": "Resource ID.\n\nResources are isolated sub-channels in a channel. A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa."
1422
1374
  }
1423
1375
  ]
1424
1376
  },
@@ -1448,7 +1400,7 @@
1448
1400
  "summary": [
1449
1401
  {
1450
1402
  "kind": "text",
1451
- "text": "An object containing permission settings for a channel."
1403
+ "text": "Permissions for a subscriber on a channel or resource."
1452
1404
  }
1453
1405
  ]
1454
1406
  },
@@ -1465,7 +1417,7 @@
1465
1417
  "summary": [
1466
1418
  {
1467
1419
  "kind": "text",
1468
- "text": "Whether the subscriber has read permissions. Defaults to "
1420
+ "text": "Whether the subscriber can receive messages on the channel.\n\nDefault: "
1469
1421
  },
1470
1422
  {
1471
1423
  "kind": "code",
@@ -1581,7 +1533,7 @@
1581
1533
  "summary": [
1582
1534
  {
1583
1535
  "kind": "text",
1584
- "text": "An object representing a channel subscriber."
1536
+ "text": "Subscriber to a channel or resource.\n\nWix checks [subscriber permissions](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) before they can listen to messages."
1585
1537
  }
1586
1538
  ]
1587
1539
  },
@@ -1596,7 +1548,7 @@
1596
1548
  "summary": [
1597
1549
  {
1598
1550
  "kind": "text",
1599
- "text": "The subscriber's user ID."
1551
+ "text": "Subscriber ID."
1600
1552
  }
1601
1553
  ],
1602
1554
  "blockTags": [
@@ -1626,7 +1578,7 @@
1626
1578
  "summary": [
1627
1579
  {
1628
1580
  "kind": "text",
1629
- "text": "The type of subscriber."
1581
+ "text": "Subscriber identity type.\n\nLearn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities)."
1630
1582
  }
1631
1583
  ],
1632
1584
  "blockTags": [
@@ -1674,7 +1626,7 @@
1674
1626
  "summary": [
1675
1627
  {
1676
1628
  "kind": "text",
1677
- "text": "Returns the realtime permissions router.\n\nUse the permissions router to define the permissions you want to grant to subscribers\n on channels or channel resources. You can set permissions on the channel and channel\n resource level. If you do not define permissions for a particular channel resource,\n that resource inherits the permissions of its parent channel.\n\n Typically you use the permissions router in the **realtime-permissions.js** file in\n your site's backend to:\n\n + Set default permissions for all channels and channel resources where no explicit\n permissions are defined.\n + Add permissions logic for specific channels or channel resources.\n + Check the permissions for a specific subscriber on a specific channel.\n\n > **Note:** Although it is recommended, you do not need to use the permissions router to set permissions. You can also define all your permissions logic in the ["
1629
+ "text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources. You can set permissions at the channel level as well as the resource level. When a resource isn't assigned explicit permissions, it inherits the permissions of its parent channel.\n\nUse the permissions router in the **realtime-permissions.js** file in the site's backend to:\n\n- Set default permissions for all channels that don't have explicit permissions.\n- Add permissions logic for specific channels or resources.\n- Check permissions for a subscriber on a channel or resource.\n\n> **Note:** You can also define permissions directly in the ["
1678
1630
  },
1679
1631
  {
1680
1632
  "kind": "code",
@@ -1682,7 +1634,7 @@
1682
1634
  },
1683
1635
  {
1684
1636
  "kind": "text",
1685
- "text": "](#realtime_check_permission) function."
1637
+ "text": "](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) hook."
1686
1638
  }
1687
1639
  ],
1688
1640
  "blockTags": [
@@ -1721,23 +1673,7 @@
1721
1673
  "summary": [
1722
1674
  {
1723
1675
  "kind": "text",
1724
- "text": "Publishes a message to a channel or channel resource.\n\nThe "
1725
- },
1726
- {
1727
- "kind": "code",
1728
- "text": "`publish()`"
1729
- },
1730
- {
1731
- "kind": "text",
1732
- "text": " function publishes a message to the specified channel or\n channel resource.\n\n When site visitors subscribe to a channel, they do not\n receive messages published to a resource on that same channel. Similarly,\n when site visitors subscribe to a channel resource, they do not\n receive messages published to that same channel without a specified resource.\n\n To publish a message to specific users only, specify the users by ID in\n the "
1733
- },
1734
- {
1735
- "kind": "code",
1736
- "text": "`PublishOptions`"
1737
- },
1738
- {
1739
- "kind": "text",
1740
- "text": " object sent to the "
1676
+ "text": "Publishes a message to a channel or resource.\n\nSubscribers to a channel don't receive messages published to a resource on\nthat channel, and vice versa.\n\nTo publish a message to specific users only, specify the users by ID in\nthe "
1741
1677
  },
1742
1678
  {
1743
1679
  "kind": "code",
@@ -1745,7 +1681,7 @@
1745
1681
  },
1746
1682
  {
1747
1683
  "kind": "text",
1748
- "text": " parameter.\n\n To include the ID of the user who triggered the publish in the published message,\n set the "
1684
+ "text": " parameter. To include the publisher's identity in the message,\nset "
1749
1685
  },
1750
1686
  {
1751
1687
  "kind": "code",
@@ -1753,23 +1689,23 @@
1753
1689
  },
1754
1690
  {
1755
1691
  "kind": "text",
1756
- "text": " property of the "
1692
+ "text": " to "
1757
1693
  },
1758
1694
  {
1759
1695
  "kind": "code",
1760
- "text": "`PublishOptions`"
1696
+ "text": "`true`"
1761
1697
  },
1762
1698
  {
1763
1699
  "kind": "text",
1764
- "text": " object to "
1700
+ "text": " in the "
1765
1701
  },
1766
1702
  {
1767
1703
  "kind": "code",
1768
- "text": "`true`"
1704
+ "text": "`options`"
1769
1705
  },
1770
1706
  {
1771
1707
  "kind": "text",
1772
- "text": "."
1708
+ "text": " parameter."
1773
1709
  }
1774
1710
  ],
1775
1711
  "blockTags": [
@@ -1782,11 +1718,11 @@
1782
1718
  },
1783
1719
  {
1784
1720
  "kind": "code",
1785
- "text": "`publisher.publish`"
1721
+ "text": "`publisher.publish()`"
1786
1722
  },
1787
1723
  {
1788
1724
  "kind": "text",
1789
- "text": " from "
1725
+ "text": " from the "
1790
1726
  },
1791
1727
  {
1792
1728
  "kind": "code",
@@ -1794,7 +1730,7 @@
1794
1730
  },
1795
1731
  {
1796
1732
  "kind": "text",
1797
- "text": " instead."
1733
+ "text": " module instead."
1798
1734
  }
1799
1735
  ]
1800
1736
  },
@@ -1839,15 +1775,7 @@
1839
1775
  "content": [
1840
1776
  {
1841
1777
  "kind": "text",
1842
- "text": "When the message is published to the channel or channel resource, "
1843
- },
1844
- {
1845
- "kind": "code",
1846
- "text": "`void`"
1847
- },
1848
- {
1849
- "kind": "text",
1850
- "text": " is returned. Does not indicate that the message was received."
1778
+ "text": "Resolves when the message is published. Doesn't indicate that the message was received by subscribers."
1851
1779
  }
1852
1780
  ]
1853
1781
  }
@@ -1864,7 +1792,7 @@
1864
1792
  "summary": [
1865
1793
  {
1866
1794
  "kind": "text",
1867
- "text": "The channel, and optionally the resource, to\n publish to."
1795
+ "text": "Channel, and optionally resource, to publish to."
1868
1796
  }
1869
1797
  ]
1870
1798
  },
@@ -1885,7 +1813,7 @@
1885
1813
  "summary": [
1886
1814
  {
1887
1815
  "kind": "text",
1888
- "text": "Message payload.\n Max: 10kb"
1816
+ "text": "Message payload. Max: 10 KB."
1889
1817
  }
1890
1818
  ]
1891
1819
  },
@@ -1906,7 +1834,7 @@
1906
1834
  "summary": [
1907
1835
  {
1908
1836
  "kind": "text",
1909
- "text": "Options to use when publishing."
1837
+ "text": "Options for publishing, such as targeting specific users."
1910
1838
  }
1911
1839
  ]
1912
1840
  },
@@ -1953,47 +1881,47 @@
1953
1881
  "summary": [
1954
1882
  {
1955
1883
  "kind": "text",
1956
- "text": "Checks permissions for a subscriber on a channel or channel resource.\n\nThe "
1884
+ "text": "Checks permissions for a subscriber on a channel or resource.\n\nThis handler runs automatically whenever a new subscription is attempted. Define it as a named export in the **realtime-permissions.js** file in the site's backend.\n\n> **Notes:**\n>\n> - When this handler isn't defined, all subscribers are assigned the default permissions of "
1957
1885
  },
1958
1886
  {
1959
1887
  "kind": "code",
1960
- "text": "`realtime_check_permission`"
1888
+ "text": "`\"read\": true`"
1961
1889
  },
1962
1890
  {
1963
1891
  "kind": "text",
1964
- "text": " hook is triggered when a site visitor subscribes\n to a channel to check what permissions the subscriber will have.\n\n The "
1892
+ "text": ".\n> - When previewing the site, "
1965
1893
  },
1966
1894
  {
1967
1895
  "kind": "code",
1968
- "text": "`realtime_check_permission()`"
1896
+ "text": "`read`"
1969
1897
  },
1970
1898
  {
1971
1899
  "kind": "text",
1972
- "text": " function is not a function that you call from\n your code. You define the function in a file named **realtime-permissions.js**\n in your site's Backend section.\n\n\n\n__Important:__\n- If this function isn't defined, all subscribers will receive the default permissions: "
1900
+ "text": " permissions are always set to "
1973
1901
  },
1974
1902
  {
1975
1903
  "kind": "code",
1976
- "text": "`{\"read\": true}`"
1904
+ "text": "`true`"
1977
1905
  },
1978
1906
  {
1979
1907
  "kind": "text",
1980
- "text": ".\n- In Wix Studio, you don't need to define this function, but you must create a backend file named **realtime-permissions.js**. Without this file, subscriptions will fail.\n\n\n\n\n Implement permissions logic for channels and subscribers by either:\n\n + Including all permissions logic in the body of this function.\n + Use the "
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 "
1981
1909
  },
1982
1910
  {
1983
1911
  "kind": "code",
1984
- "text": "`PermissionsRouter`"
1912
+ "text": "`permissionsRouter.add()`"
1985
1913
  },
1986
1914
  {
1987
1915
  "kind": "text",
1988
- "text": " to add permissions\n logic per channel. Then call ["
1916
+ "text": ", then calling "
1989
1917
  },
1990
1918
  {
1991
1919
  "kind": "code",
1992
- "text": "`check()`"
1920
+ "text": "`permissionsRouter.check()`"
1993
1921
  },
1994
1922
  {
1995
1923
  "kind": "text",
1996
- "text": "](https://dev.wix.com/docs/sdk/backend-modules/realtime/site/permissions-router/check) in the body of\n this function and return the permissions object it returns.\n\n\n> **Note:** When previewing your site, permissions for read are always granted."
1924
+ "text": " to evaluate each subscription request."
1997
1925
  }
1998
1926
  ],
1999
1927
  "blockTags": [
@@ -2038,7 +1966,7 @@
2038
1966
  "content": [
2039
1967
  {
2040
1968
  "kind": "text",
2041
- "text": "The permissions granted to the subscriber on the channel or channel resource."
1969
+ "text": "Permissions granted to the subscriber for the specified channel or resource."
2042
1970
  }
2043
1971
  ]
2044
1972
  },
@@ -2073,7 +2001,7 @@
2073
2001
  "summary": [
2074
2002
  {
2075
2003
  "kind": "text",
2076
- "text": "The channel, and optionally the resource,\n to check permissions for."
2004
+ "text": "Channel and resource to check permissions for."
2077
2005
  }
2078
2006
  ]
2079
2007
  },
@@ -2094,7 +2022,7 @@
2094
2022
  "summary": [
2095
2023
  {
2096
2024
  "kind": "text",
2097
- "text": "The subscriber to check permissions\n for."
2025
+ "text": "Subscriber to check permissions for."
2098
2026
  }
2099
2027
  ]
2100
2028
  },
@@ -2182,7 +2110,7 @@
2182
2110
  "summary": [
2183
2111
  {
2184
2112
  "kind": "text",
2185
- "text": "Subscribe to a channel. Returns a subscriptionId immediately; the\nactual connection is established asynchronously in the background. Use the\noptional "
2113
+ "text": "Subscribes to a channel or resource.\n\nThe 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.\n\nUse the "
2186
2114
  },
2187
2115
  {
2188
2116
  "kind": "code",
@@ -2190,7 +2118,15 @@
2190
2118
  },
2191
2119
  {
2192
2120
  "kind": "text",
2193
- "text": " parameter to handle subscription lifecycle events."
2121
+ "text": " parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The "
2122
+ },
2123
+ {
2124
+ "kind": "code",
2125
+ "text": "`onSubscribed()`"
2126
+ },
2127
+ {
2128
+ "kind": "text",
2129
+ "text": " handler runs on every successful re-subscription."
2194
2130
  }
2195
2131
  ],
2196
2132
  "blockTags": [
@@ -2199,11 +2135,11 @@
2199
2135
  "content": [
2200
2136
  {
2201
2137
  "kind": "text",
2202
- "text": "Manual client (self-hosted / explicit auth)\n"
2138
+ "text": "Subscribe to a channel\n"
2203
2139
  },
2204
2140
  {
2205
2141
  "kind": "code",
2206
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2142
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2207
2143
  }
2208
2144
  ]
2209
2145
  },
@@ -2212,11 +2148,11 @@
2212
2148
  "content": [
2213
2149
  {
2214
2150
  "kind": "text",
2215
- "text": "Contextual client (Wix-hosted)\n"
2151
+ "text": "Subscribe to a channel: Self-hosted\n"
2216
2152
  },
2217
2153
  {
2218
2154
  "kind": "code",
2219
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2155
+ "text": "```ts\nimport { createClient } from '@wix/sdk';\nimport { subscriber } from '@wix/realtime';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2220
2156
  }
2221
2157
  ]
2222
2158
  }
@@ -2233,7 +2169,7 @@
2233
2169
  "summary": [
2234
2170
  {
2235
2171
  "kind": "text",
2236
- "text": "The channel, and optionally the resource, to subscribe to."
2172
+ "text": "Channel, and optionally resource, to subscribe to."
2237
2173
  }
2238
2174
  ]
2239
2175
  },
@@ -2254,7 +2190,7 @@
2254
2190
  "summary": [
2255
2191
  {
2256
2192
  "kind": "text",
2257
- "text": "Callback invoked whenever a message is published to the channel."
2193
+ "text": "Callback that runs whenever a message is published to the channel."
2258
2194
  }
2259
2195
  ]
2260
2196
  },
@@ -2277,7 +2213,7 @@
2277
2213
  "summary": [
2278
2214
  {
2279
2215
  "kind": "text",
2280
- "text": "Optional lifecycle handlers for subscription events."
2216
+ "text": "Lifecycle handlers for subscription events."
2281
2217
  }
2282
2218
  ]
2283
2219
  },
@@ -2304,7 +2240,7 @@
2304
2240
  "summary": [
2305
2241
  {
2306
2242
  "kind": "text",
2307
- "text": "Subscribe to a channel. Returns a subscriptionId immediately; the\nactual connection is established asynchronously in the background. Use the\noptional "
2243
+ "text": "Subscribes to a channel or resource.\n\nThe 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.\n\nUse the "
2308
2244
  },
2309
2245
  {
2310
2246
  "kind": "code",
@@ -2312,7 +2248,15 @@
2312
2248
  },
2313
2249
  {
2314
2250
  "kind": "text",
2315
- "text": " parameter to handle subscription lifecycle events."
2251
+ "text": " parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The "
2252
+ },
2253
+ {
2254
+ "kind": "code",
2255
+ "text": "`onSubscribed()`"
2256
+ },
2257
+ {
2258
+ "kind": "text",
2259
+ "text": " handler runs on every successful re-subscription."
2316
2260
  }
2317
2261
  ],
2318
2262
  "blockTags": [
@@ -2321,11 +2265,11 @@
2321
2265
  "content": [
2322
2266
  {
2323
2267
  "kind": "text",
2324
- "text": "Manual client (self-hosted / explicit auth)\n"
2268
+ "text": "Subscribe to a channel\n"
2325
2269
  },
2326
2270
  {
2327
2271
  "kind": "code",
2328
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2272
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2329
2273
  }
2330
2274
  ]
2331
2275
  },
@@ -2334,11 +2278,11 @@
2334
2278
  "content": [
2335
2279
  {
2336
2280
  "kind": "text",
2337
- "text": "Contextual client (Wix-hosted)\n"
2281
+ "text": "Subscribe to a channel: Self-hosted\n"
2338
2282
  },
2339
2283
  {
2340
2284
  "kind": "code",
2341
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2285
+ "text": "```ts\nimport { createClient } from '@wix/sdk';\nimport { subscriber } from '@wix/realtime';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2342
2286
  }
2343
2287
  ]
2344
2288
  }
@@ -2391,7 +2335,7 @@
2391
2335
  "summary": [
2392
2336
  {
2393
2337
  "kind": "text",
2394
- "text": "Unsubscribe from a subscription by its ID, by channel, or both.\n\nYou can unsubscribe in three ways:\n- By "
2338
+ "text": "Removes 1 or more subscriptions.\n\nYou can unsubscribe in 3 ways:\n- By "
2395
2339
  },
2396
2340
  {
2397
2341
  "kind": "code",
@@ -2399,7 +2343,7 @@
2399
2343
  },
2400
2344
  {
2401
2345
  "kind": "text",
2402
- "text": " — removes a single subscription.\n- By "
2346
+ "text": ": removes a single subscription.\n- By "
2403
2347
  },
2404
2348
  {
2405
2349
  "kind": "code",
@@ -2407,7 +2351,7 @@
2407
2351
  },
2408
2352
  {
2409
2353
  "kind": "text",
2410
- "text": " — removes all subscriptions to that channel.\n- By both — removes the specific subscription, verifying it matches the channel."
2354
+ "text": ": removes all subscriptions to that channel or resource.\n- By both: removes the specific subscription, verifying it matches the channel.\n\nWhen the last subscription on a connection is removed, the connection\ncloses automatically."
2411
2355
  }
2412
2356
  ],
2413
2357
  "blockTags": [
@@ -2416,11 +2360,11 @@
2416
2360
  "content": [
2417
2361
  {
2418
2362
  "kind": "text",
2419
- "text": "Manual client (self-hosted / explicit auth)\n"
2363
+ "text": "Remove the specified subscription.\n"
2420
2364
  },
2421
2365
  {
2422
2366
  "kind": "code",
2423
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\n// Unsubscribe by subscription ID\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Unsubscribe from all subscriptions to a channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2367
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2424
2368
  }
2425
2369
  ]
2426
2370
  },
@@ -2429,11 +2373,11 @@
2429
2373
  "content": [
2430
2374
  {
2431
2375
  "kind": "text",
2432
- "text": "Contextual client (Wix-hosted)\n"
2376
+ "text": "Remove the specified subscription: Self-hosted\n"
2433
2377
  },
2434
2378
  {
2435
2379
  "kind": "code",
2436
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2380
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\n// Remove the specified subscription\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Remove all subscriptions from the specified channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2437
2381
  }
2438
2382
  ]
2439
2383
  }
@@ -2450,7 +2394,23 @@
2450
2394
  "summary": [
2451
2395
  {
2452
2396
  "kind": "text",
2453
- "text": "Identifies what to unsubscribe from — by subscription ID, channel, or both."
2397
+ "text": "Unsubscribe information. You must specify "
2398
+ },
2399
+ {
2400
+ "kind": "code",
2401
+ "text": "`channel`"
2402
+ },
2403
+ {
2404
+ "kind": "text",
2405
+ "text": ", "
2406
+ },
2407
+ {
2408
+ "kind": "code",
2409
+ "text": "`subscriptionId`"
2410
+ },
2411
+ {
2412
+ "kind": "text",
2413
+ "text": ", or both."
2454
2414
  }
2455
2415
  ]
2456
2416
  },
@@ -2477,7 +2437,7 @@
2477
2437
  "summary": [
2478
2438
  {
2479
2439
  "kind": "text",
2480
- "text": "Unsubscribe from a subscription by its ID, by channel, or both.\n\nYou can unsubscribe in three ways:\n- By "
2440
+ "text": "Removes 1 or more subscriptions.\n\nYou can unsubscribe in 3 ways:\n- By "
2481
2441
  },
2482
2442
  {
2483
2443
  "kind": "code",
@@ -2485,7 +2445,7 @@
2485
2445
  },
2486
2446
  {
2487
2447
  "kind": "text",
2488
- "text": " — removes a single subscription.\n- By "
2448
+ "text": ": removes a single subscription.\n- By "
2489
2449
  },
2490
2450
  {
2491
2451
  "kind": "code",
@@ -2493,7 +2453,7 @@
2493
2453
  },
2494
2454
  {
2495
2455
  "kind": "text",
2496
- "text": " — removes all subscriptions to that channel.\n- By both — removes the specific subscription, verifying it matches the channel."
2456
+ "text": ": removes all subscriptions to that channel or resource.\n- By both: removes the specific subscription, verifying it matches the channel.\n\nWhen the last subscription on a connection is removed, the connection\ncloses automatically."
2497
2457
  }
2498
2458
  ],
2499
2459
  "blockTags": [
@@ -2502,11 +2462,11 @@
2502
2462
  "content": [
2503
2463
  {
2504
2464
  "kind": "text",
2505
- "text": "Manual client (self-hosted / explicit auth)\n"
2465
+ "text": "Remove the specified subscription.\n"
2506
2466
  },
2507
2467
  {
2508
2468
  "kind": "code",
2509
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\n// Unsubscribe by subscription ID\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Unsubscribe from all subscriptions to a channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2469
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2510
2470
  }
2511
2471
  ]
2512
2472
  },
@@ -2515,11 +2475,11 @@
2515
2475
  "content": [
2516
2476
  {
2517
2477
  "kind": "text",
2518
- "text": "Contextual client (Wix-hosted)\n"
2478
+ "text": "Remove the specified subscription: Self-hosted\n"
2519
2479
  },
2520
2480
  {
2521
2481
  "kind": "code",
2522
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2482
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\n// Remove the specified subscription\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Remove all subscriptions from the specified channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2523
2483
  }
2524
2484
  ]
2525
2485
  }
@@ -2576,7 +2536,7 @@
2576
2536
  "summary": [
2577
2537
  {
2578
2538
  "kind": "text",
2579
- "text": "Error codes for realtime errors."
2539
+ "text": "Error codes."
2580
2540
  }
2581
2541
  ]
2582
2542
  },
@@ -2591,7 +2551,7 @@
2591
2551
  "summary": [
2592
2552
  {
2593
2553
  "kind": "text",
2594
- "text": "Invalid input (e.g. bad channel name)."
2554
+ "text": "Invalid input such as a channel name with unsupported characters."
2595
2555
  }
2596
2556
  ]
2597
2557
  },
@@ -2610,7 +2570,7 @@
2610
2570
  "summary": [
2611
2571
  {
2612
2572
  "kind": "text",
2613
- "text": "A connection attempt failed. The client keeps retrying automatically."
2573
+ "text": "Connection attempt failed. Wix automatically attempts to establish the subscription."
2614
2574
  }
2615
2575
  ]
2616
2576
  },
@@ -2629,7 +2589,15 @@
2629
2589
  "summary": [
2630
2590
  {
2631
2591
  "kind": "text",
2632
- "text": "The connection was closed, either intentionally or due to an error."
2592
+ "text": "Connection closed intentionally or due to an error. Check "
2593
+ },
2594
+ {
2595
+ "kind": "code",
2596
+ "text": "`error.recoverable`"
2597
+ },
2598
+ {
2599
+ "kind": "text",
2600
+ "text": " to determine whether the client is attempting to reconnect. Learn more about [realtime SDK errors](ADDLINK)."
2633
2601
  }
2634
2602
  ]
2635
2603
  },
@@ -2648,7 +2616,7 @@
2648
2616
  "summary": [
2649
2617
  {
2650
2618
  "kind": "text",
2651
- "text": "The subscription request failed (e.g. authorization error)."
2619
+ "text": "Subscription request rejected, for example, due to an authorization failure. This error is non-recoverable."
2652
2620
  }
2653
2621
  ]
2654
2622
  },
@@ -2680,7 +2648,7 @@
2680
2648
  "summary": [
2681
2649
  {
2682
2650
  "kind": "text",
2683
- "text": "An object representing an error."
2651
+ "text": "Error thrown by a subscription or connection."
2684
2652
  }
2685
2653
  ]
2686
2654
  },
@@ -2827,7 +2795,7 @@
2827
2795
  "summary": [
2828
2796
  {
2829
2797
  "kind": "text",
2830
- "text": "Channel related to the error."
2798
+ "text": "Channel that caused the error."
2831
2799
  }
2832
2800
  ]
2833
2801
  },
@@ -2871,7 +2839,7 @@
2871
2839
  "summary": [
2872
2840
  {
2873
2841
  "kind": "text",
2874
- "text": "Whether the error is recoverable. When "
2842
+ "text": "Whether the error is automatically recoverable.\n\nWhen "
2875
2843
  },
2876
2844
  {
2877
2845
  "kind": "code",
@@ -2879,7 +2847,7 @@
2879
2847
  },
2880
2848
  {
2881
2849
  "kind": "text",
2882
- "text": ", the client is\nautomatically attempting to reconnect. When "
2850
+ "text": ", the client automatically attempts to reconnect. When "
2883
2851
  },
2884
2852
  {
2885
2853
  "kind": "code",
@@ -2887,7 +2855,15 @@
2887
2855
  },
2888
2856
  {
2889
2857
  "kind": "text",
2890
- "text": ", user action\nis required (for example, the subscription must be re-created)."
2858
+ "text": ", you must attempt to re-subscribe manually.\n\nDefault: "
2859
+ },
2860
+ {
2861
+ "kind": "code",
2862
+ "text": "`false`"
2863
+ },
2864
+ {
2865
+ "kind": "text",
2866
+ "text": "."
2891
2867
  }
2892
2868
  ]
2893
2869
  },
@@ -2908,7 +2884,23 @@
2908
2884
  "summary": [
2909
2885
  {
2910
2886
  "kind": "text",
2911
- "text": "HTTP status code from the server response.\nPresent on subscription failed errors (e.g. 401, 403, 500)."
2887
+ "text": "[HTTP status code](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/troubleshooting/about-errors#http-status-codes).\n\nReturned only when "
2888
+ },
2889
+ {
2890
+ "kind": "code",
2891
+ "text": "`errorCode`"
2892
+ },
2893
+ {
2894
+ "kind": "text",
2895
+ "text": " is "
2896
+ },
2897
+ {
2898
+ "kind": "code",
2899
+ "text": "`SUBSCRIPTION_FAILED`"
2900
+ },
2901
+ {
2902
+ "kind": "text",
2903
+ "text": "."
2912
2904
  }
2913
2905
  ]
2914
2906
  },
@@ -2957,7 +2949,7 @@
2957
2949
  "summary": [
2958
2950
  {
2959
2951
  "kind": "text",
2960
- "text": "An object representing a published message."
2952
+ "text": "Message received on a channel."
2961
2953
  }
2962
2954
  ]
2963
2955
  },
@@ -2972,7 +2964,7 @@
2972
2964
  "summary": [
2973
2965
  {
2974
2966
  "kind": "text",
2975
- "text": "Message payload.\nMax: 10kb"
2967
+ "text": "Message payload that contains the published data.\n\nMax: 10 KB."
2976
2968
  }
2977
2969
  ]
2978
2970
  },
@@ -3008,7 +3000,7 @@
3008
3000
  "summary": [
3009
3001
  {
3010
3002
  "kind": "text",
3011
- "text": "Message publisher, if sent."
3003
+ "text": "Publisher details.\n\nReturned only when the publisher's identity is available."
3012
3004
  }
3013
3005
  ]
3014
3006
  },
@@ -3040,7 +3032,7 @@
3040
3032
  "summary": [
3041
3033
  {
3042
3034
  "kind": "text",
3043
- "text": "An object representing a publisher."
3035
+ "text": "Publisher details."
3044
3036
  }
3045
3037
  ]
3046
3038
  },
@@ -3055,7 +3047,7 @@
3055
3047
  "summary": [
3056
3048
  {
3057
3049
  "kind": "text",
3058
- "text": "ID of the publisher."
3050
+ "text": "Publisher ID.\n\n<!-- TODO: Where does the caller get the publisher ID? -->"
3059
3051
  }
3060
3052
  ]
3061
3053
  },
@@ -3084,7 +3076,7 @@
3084
3076
  "summary": [
3085
3077
  {
3086
3078
  "kind": "text",
3087
- "text": "An object containing optional lifecycle handlers for a subscription."
3079
+ "text": "Subscription status handlers that run whenever a subscription is established, re-established, or fails."
3088
3080
  }
3089
3081
  ]
3090
3082
  },
@@ -3101,7 +3093,7 @@
3101
3093
  "summary": [
3102
3094
  {
3103
3095
  "kind": "text",
3104
- "text": "Runs when the subscription is successfully established.\n\nThis fires on the initial subscription and again every time the\nsubscription is automatically restored after a reconnection, so make\nsure your handler is idempotent.\n\nThe "
3096
+ "text": "Runs whenever the subscription is successfully established or re-established after a prior failure. To avoid unnecessary actions, make the handler idempotent.\n\nThe "
3105
3097
  },
3106
3098
  {
3107
3099
  "kind": "code",
@@ -3109,31 +3101,7 @@
3109
3101
  },
3110
3102
  {
3111
3103
  "kind": "text",
3112
- "text": " flag indicates whether the server was able to restore\nmissed messages since the last disconnection:\n\n- **First subscription** — always "
3113
- },
3114
- {
3115
- "kind": "code",
3116
- "text": "`false`"
3117
- },
3118
- {
3119
- "kind": "text",
3120
- "text": ". The client has no prior\n message history, so the server cannot restore anything. The app\n should load its own initial state.\n\n- **Re-subscription after reconnect, "
3121
- },
3122
- {
3123
- "kind": "code",
3124
- "text": "`isSynced: true`"
3125
- },
3126
- {
3127
- "kind": "text",
3128
- "text": "** — the server\n found the last received message and replayed everything since.\n No action needed from the app.\n\n- **Re-subscription after reconnect, "
3129
- },
3130
- {
3131
- "kind": "code",
3132
- "text": "`isSynced: false`"
3133
- },
3134
- {
3135
- "kind": "text",
3136
- "text": "** — the server\n could not restore missed messages (e.g. they expired). The app\n should resync its state independently."
3104
+ "text": " parameter indicates whether missed messages were restored."
3137
3105
  }
3138
3106
  ],
3139
3107
  "blockTags": [
@@ -3143,7 +3111,7 @@
3143
3111
  "content": [
3144
3112
  {
3145
3113
  "kind": "text",
3146
- "text": "The ID of the subscription that was established."
3114
+ "text": "ID of the subscription."
3147
3115
  }
3148
3116
  ]
3149
3117
  },
@@ -3153,7 +3121,55 @@
3153
3121
  "content": [
3154
3122
  {
3155
3123
  "kind": "text",
3156
- "text": "Whether the server successfully restored missed messages."
3124
+ "text": "Whether the server successfully restored missed messages since the last disconnection.\n\nThe value of this parameter depends on the scenario:\n\n- When subscribing for the first time, "
3125
+ },
3126
+ {
3127
+ "kind": "code",
3128
+ "text": "`isSynced`"
3129
+ },
3130
+ {
3131
+ "kind": "text",
3132
+ "text": " is "
3133
+ },
3134
+ {
3135
+ "kind": "code",
3136
+ "text": "`false`"
3137
+ },
3138
+ {
3139
+ "kind": "text",
3140
+ "text": ", as there are no prior messages to restore. In this scenario, load your initial state independently.\n\n- When re-subscribing and all messages were successfully restored, "
3141
+ },
3142
+ {
3143
+ "kind": "code",
3144
+ "text": "`isSynced`"
3145
+ },
3146
+ {
3147
+ "kind": "text",
3148
+ "text": " is "
3149
+ },
3150
+ {
3151
+ "kind": "code",
3152
+ "text": "`true`"
3153
+ },
3154
+ {
3155
+ "kind": "text",
3156
+ "text": ". No further action is necessary.\n\n- When re-subscribing but some messages weren't restored, "
3157
+ },
3158
+ {
3159
+ "kind": "code",
3160
+ "text": "`isSynced`"
3161
+ },
3162
+ {
3163
+ "kind": "text",
3164
+ "text": " is "
3165
+ },
3166
+ {
3167
+ "kind": "code",
3168
+ "text": "`false`"
3169
+ },
3170
+ {
3171
+ "kind": "text",
3172
+ "text": ". The server is unable to restore all missed messages. In this scenario, you need to resync your state independently.\n\n<!-- TODO: Document server-side buffer limits for message replay. -->"
3157
3173
  }
3158
3174
  ]
3159
3175
  }
@@ -3178,31 +3194,15 @@
3178
3194
  "summary": [
3179
3195
  {
3180
3196
  "kind": "text",
3181
- "text": "Runs when a subscription error occurs.\n\nThis handler is triggered in the following scenarios:\n\n- **Subscription failed** — Authorization failure. The subscription\n request returned a non-2xx status. The error includes the HTTP\n "
3182
- },
3183
- {
3184
- "kind": "code",
3185
- "text": "`status`"
3186
- },
3187
- {
3188
- "kind": "text",
3189
- "text": " code and a "
3197
+ "text": "Runs when a subscription error occurs. It can run multiple times in a single session.\n\nThis handler runs in the following scenarios:\n\n- **Subscription failed**: The subscription request was rejected, for example, due to an authorization failure. This error is non-recoverable, so the subscription isn't automatically re-attempted.\n\n- **Subscription disconnected**: The connection between the subscriber and publisher was closed. Check "
3190
3198
  },
3191
3199
  {
3192
3200
  "kind": "code",
3193
- "text": "`message`"
3194
- },
3195
- {
3196
- "kind": "text",
3197
- "text": " with details. This is non-recoverable;\n the subscription will not retry automatically.\n\n- **Disconnected** — The connection was closed, either intentionally\n or due to an error. When caused by an error, the "
3198
- },
3199
- {
3200
- "kind": "code",
3201
- "text": "`recoverable`"
3201
+ "text": "`error.recoverable`"
3202
3202
  },
3203
3203
  {
3204
3204
  "kind": "text",
3205
- "text": " flag\n on the error indicates whether the client will auto-reconnect\n ("
3205
+ "text": ":\n - When "
3206
3206
  },
3207
3207
  {
3208
3208
  "kind": "code",
@@ -3210,7 +3210,7 @@
3210
3210
  },
3211
3211
  {
3212
3212
  "kind": "text",
3213
- "text": ") or whether manual action is required ("
3213
+ "text": ", the error is recoverable. The subscription is automatically re-attempted. No further action necessary.\n - When "
3214
3214
  },
3215
3215
  {
3216
3216
  "kind": "code",
@@ -3218,11 +3218,11 @@
3218
3218
  },
3219
3219
  {
3220
3220
  "kind": "text",
3221
- "text": ", e.g. a 401\n means the signed instance is invalid).\n\n- **Connection error** — Fired on every reconnection attempt that\n fails. The "
3221
+ "text": ", the error isn't recoverable. Establish the subscription again.\n\n- **Connection error**: Runs on each failed subscription attempt. The "
3222
3222
  },
3223
3223
  {
3224
3224
  "kind": "code",
3225
- "text": "`recoverable`"
3225
+ "text": "`error.recoverable`"
3226
3226
  },
3227
3227
  {
3228
3228
  "kind": "text",
@@ -3234,31 +3234,7 @@
3234
3234
  },
3235
3235
  {
3236
3236
  "kind": "text",
3237
- "text": " for these errors\n (the client keeps retrying with exponential backoff). If the error\n becomes non-recoverable, a disconnection with "
3238
- },
3239
- {
3240
- "kind": "code",
3241
- "text": "`recoverable: false`"
3242
- },
3243
- {
3244
- "kind": "text",
3245
- "text": "\n is fired instead.\n\nInspect "
3246
- },
3247
- {
3248
- "kind": "code",
3249
- "text": "`error.recoverable`"
3250
- },
3251
- {
3252
- "kind": "text",
3253
- "text": " to distinguish transient errors (where\nthe client is auto-reconnecting) from permanent failures (where user\naction is required).\n\nNote: this handler may fire multiple times during a single session.\nFor example, a typical recovery flow looks like:\n"
3254
- },
3255
- {
3256
- "kind": "code",
3257
- "text": "`subscribed → error (recoverable) → error (recoverable) → subscribed`"
3258
- },
3259
- {
3260
- "kind": "text",
3261
- "text": "\nThis happens because the client automatically tries to recover itself\nafter an unexpected disconnection."
3237
+ "text": ", as the subscription is re-established."
3262
3238
  }
3263
3239
  ],
3264
3240
  "blockTags": [
@@ -3268,39 +3244,23 @@
3268
3244
  "content": [
3269
3245
  {
3270
3246
  "kind": "text",
3271
- "text": "The error that occurred, including "
3247
+ "text": "Error that occurred. Check "
3272
3248
  },
3273
3249
  {
3274
3250
  "kind": "code",
3275
3251
  "text": "`errorCode`"
3276
3252
  },
3277
- {
3278
- "kind": "text",
3279
- "text": ",\n "
3280
- },
3281
- {
3282
- "kind": "code",
3283
- "text": "`recoverable`"
3284
- },
3285
- {
3286
- "kind": "text",
3287
- "text": ", and optionally "
3288
- },
3289
- {
3290
- "kind": "code",
3291
- "text": "`channel`"
3292
- },
3293
3253
  {
3294
3254
  "kind": "text",
3295
3255
  "text": " and "
3296
3256
  },
3297
3257
  {
3298
3258
  "kind": "code",
3299
- "text": "`status`"
3259
+ "text": "`recoverable`"
3300
3260
  },
3301
3261
  {
3302
3262
  "kind": "text",
3303
- "text": "."
3263
+ "text": " to determine the type and whether manual action is required."
3304
3264
  }
3305
3265
  ]
3306
3266
  },
@@ -3310,7 +3270,7 @@
3310
3270
  "content": [
3311
3271
  {
3312
3272
  "kind": "text",
3313
- "text": "The ID of the affected subscription."
3273
+ "text": "ID of the subscription that generated the error."
3314
3274
  }
3315
3275
  ]
3316
3276
  }
@@ -3344,7 +3304,39 @@
3344
3304
  "summary": [
3345
3305
  {
3346
3306
  "kind": "text",
3347
- "text": "An object containing options to be used when unsubscribing from a\nchannel or channel resource."
3307
+ "text": "Unsubscribe options. Specify "
3308
+ },
3309
+ {
3310
+ "kind": "code",
3311
+ "text": "`channel`"
3312
+ },
3313
+ {
3314
+ "kind": "text",
3315
+ "text": ", "
3316
+ },
3317
+ {
3318
+ "kind": "code",
3319
+ "text": "`subscriptionId`"
3320
+ },
3321
+ {
3322
+ "kind": "text",
3323
+ "text": ", or both:\n\n- To remove all subscriptions from a channel, specify the channel in "
3324
+ },
3325
+ {
3326
+ "kind": "code",
3327
+ "text": "`channel.name`"
3328
+ },
3329
+ {
3330
+ "kind": "text",
3331
+ "text": ".\n- To remove a single subscription, specify the "
3332
+ },
3333
+ {
3334
+ "kind": "code",
3335
+ "text": "`subscriptionId`"
3336
+ },
3337
+ {
3338
+ "kind": "text",
3339
+ "text": ".\n- To remove a single subscription with channel verification, specify both. This removes the specified subscription only if it listens to the specified channel."
3348
3340
  }
3349
3341
  ]
3350
3342
  },
@@ -3361,7 +3353,7 @@
3361
3353
  "summary": [
3362
3354
  {
3363
3355
  "kind": "text",
3364
- "text": "The channel, and optionally the resource, to\nunsubscribe from. Use this property when unsubscribing from all subscriptions to a channel\nor channel resource."
3356
+ "text": "Channel or resource to unsubscribe from.\n\nWhen empty, the subscription is removed without verifying that it belongs to the channel."
3365
3357
  }
3366
3358
  ]
3367
3359
  },
@@ -3384,7 +3376,7 @@
3384
3376
  "summary": [
3385
3377
  {
3386
3378
  "kind": "text",
3387
- "text": "ID of the subscription to unsubscribe from. Use this\nproperty when unsubscribing from one of multiple subscriptions to a channel or channel\nresource."
3379
+ "text": "ID of the subscription to remove.\n\nWhen empty, all subscriptions to the specified channel are removed."
3388
3380
  }
3389
3381
  ]
3390
3382
  },
@@ -3429,7 +3421,7 @@
3429
3421
  "summary": [
3430
3422
  {
3431
3423
  "kind": "text",
3432
- "text": "Handles a message published to a channel or channel resource."
3424
+ "text": "Runs when a message is published to a channel or resource the subscriber listens to."
3433
3425
  }
3434
3426
  ]
3435
3427
  },
@@ -3440,6 +3432,14 @@
3440
3432
  "variant": "param",
3441
3433
  "kind": 32768,
3442
3434
  "flags": {},
3435
+ "comment": {
3436
+ "summary": [
3437
+ {
3438
+ "kind": "text",
3439
+ "text": "Published message."
3440
+ }
3441
+ ]
3442
+ },
3443
3443
  "type": {
3444
3444
  "type": "reference",
3445
3445
  "target": 73,
@@ -3453,6 +3453,14 @@
3453
3453
  "variant": "param",
3454
3454
  "kind": 32768,
3455
3455
  "flags": {},
3456
+ "comment": {
3457
+ "summary": [
3458
+ {
3459
+ "kind": "text",
3460
+ "text": "Channel the message was published to."
3461
+ }
3462
+ ]
3463
+ },
3456
3464
  "type": {
3457
3465
  "type": "reference",
3458
3466
  "target": 31,
@@ -3495,7 +3503,7 @@
3495
3503
  "summary": [
3496
3504
  {
3497
3505
  "kind": "text",
3498
- "text": "Handles a subscription error event."
3506
+ "text": "Runs when a subscription error occurs."
3499
3507
  }
3500
3508
  ]
3501
3509
  },
@@ -3506,6 +3514,14 @@
3506
3514
  "variant": "param",
3507
3515
  "kind": 32768,
3508
3516
  "flags": {},
3517
+ "comment": {
3518
+ "summary": [
3519
+ {
3520
+ "kind": "text",
3521
+ "text": "Error that occurred."
3522
+ }
3523
+ ]
3524
+ },
3509
3525
  "type": {
3510
3526
  "type": "reference",
3511
3527
  "target": 99,
@@ -3519,6 +3535,14 @@
3519
3535
  "variant": "param",
3520
3536
  "kind": 32768,
3521
3537
  "flags": {},
3538
+ "comment": {
3539
+ "summary": [
3540
+ {
3541
+ "kind": "text",
3542
+ "text": "ID of the subscription that generated the error."
3543
+ }
3544
+ ]
3545
+ },
3522
3546
  "type": {
3523
3547
  "type": "intrinsic",
3524
3548
  "name": "string"
@@ -3559,7 +3583,15 @@
3559
3583
  "summary": [
3560
3584
  {
3561
3585
  "kind": "text",
3562
- "text": "Handles a successful subscription or re-subscription event."
3586
+ "text": "Runs when a subscription is successfully established or re-established.\n\nWhen a subscription fails and is re-established, the subscriber might not receive all messages published during the failure. The "
3587
+ },
3588
+ {
3589
+ "kind": "code",
3590
+ "text": "`isSynced`"
3591
+ },
3592
+ {
3593
+ "kind": "text",
3594
+ "text": " flag indicates whether all missed messages were successfully delivered.\n\nLearn more about [realtime SDK errors](ADDLINK).\n<!-- TODO: Document server-side buffer limits for message replay. -->"
3563
3595
  }
3564
3596
  ]
3565
3597
  },
@@ -3570,6 +3602,14 @@
3570
3602
  "variant": "param",
3571
3603
  "kind": 32768,
3572
3604
  "flags": {},
3605
+ "comment": {
3606
+ "summary": [
3607
+ {
3608
+ "kind": "text",
3609
+ "text": "Subscription ID."
3610
+ }
3611
+ ]
3612
+ },
3573
3613
  "type": {
3574
3614
  "type": "intrinsic",
3575
3615
  "name": "string"
@@ -3581,6 +3621,14 @@
3581
3621
  "variant": "param",
3582
3622
  "kind": 32768,
3583
3623
  "flags": {},
3624
+ "comment": {
3625
+ "summary": [
3626
+ {
3627
+ "kind": "text",
3628
+ "text": "Whether the message history was fully restored."
3629
+ }
3630
+ ]
3631
+ },
3584
3632
  "type": {
3585
3633
  "type": "intrinsic",
3586
3634
  "name": "boolean"
@@ -3646,11 +3694,11 @@
3646
3694
  "symbolIdMap": {}
3647
3695
  },
3648
3696
  "appendices": {
3649
- "/site": [
3697
+ "/": [
3650
3698
  {
3651
3699
  "type": "GUIDE",
3652
3700
  "title": "Introduction",
3653
- "src": "# Introduction\n\n> **Note:** This API is only intended for use in [site development](https://dev.wix.com/docs/sdk/articles/get-started/about-site-development).\n\nUsing the Realtime API you can create channels and channel resources where messages\ncan be published. Site visitors who subscribe to a channel receive the\nmessages published to that channel. When a message is received you can handle the message any\nway you choose, such as displaying the contents of the message or changing the state\nof page elements depending on the contents of the message. You can also manage the\npermissions of who can read from specific channels.\n\nThe `@wix/realtime` module is used in conjunction with the [`@wix/site-realtime`](https://dev.wix.com/docs/sdk/frontend-modules/site-realtime/introduction) module.\n\nGet hands-on experience with the Realtime API on our [Hello Realtime](https://www.wix.com/velo/example/hello-realtime) example page.\n\nTypical uses of the Realtime API include implementing a messaging system or\nas an alternative to using a polling mechanism.\n\nThe Realtime API uses the following terminology:\n\n+ **Channel**: A specific channel on which messages are published. Each channel\n has a unique name. Site visitors can subscribe to a channel to receive the \n messages that are published on it. When site visitors subscribe to a channel, they do not \n receive messages published to a resource on that same channel.\n+ **Channel resource**: A subchannel on which messages are published. Subchannels\n can share a name with a channel and other subchannels, but they have a unique\n resource ID. When site visitors subscribe to a channel resource, they do not \n receive messages published to that same channel without a specified resource.\n Channel resources inherit their parent channel's permissions, unless specified\n otherwise.\n+ **Message**: A message published on a channel or channel resource. A message can\n be of any type, such as a string, number, or object. Channel subscribers receive\n the messages published on the channel.\n+ **Publish**: Sending a message over a channel or channel resource.\n+ **Subscribe**: A site visitor subscribes to receive the messages published on a \n channel or channel resource.\n+ **Permissions router**: The permissions router is used to define the permissions\n you want to grant to subscribers on channels and channel resources.\n+ **Permissions handler**: Handles a permissions check for a specific user on a \n specific channel or channel resource.\n\nFor a tutorial on using the Realtime API, see \n[Sending Messages with the Realtime API](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-editor-elements/sending-messages-with-the-realtime-api).\n"
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**](ADDLINK): Backend module that sends messages to channels.\n- [**Site**](ADDLINK): Backend module that manages subscriber permissions.\n- [**Subscriber**](ADDLINK): 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](ADDLINK).\n2. A client subscribes to a channel or channel resource using the [Subscriber API](ADDLINK).\n3. The `realtime_check_permission` hook checks the subscriber's permissions.\n4. The [Publisher](ADDLINK) 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](ADDLINK) is a backend module that sends messages to subscribers listening to the specified channel or resource.\n\nLearn more about [publishing messages](ADDLINK).\n\n## Site\n\nThe [Site API](ADDLINK) controls subscriber permissions. It determines which subscribers can receive messages on specific channels and resources.\n\nLearn more about [permissions in the Site API](ADDLINK).\n\n<!-- ### Permissions\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\nYou can define permissions by adding a **realtime-permissions.js** file in a site's backend and setting up the [`realtime_check_permission` hook](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission). You can include all permissions logic directly in the hook, or use the [Permissions Router API](ADDLINK) to organize permissions logic per channel and 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 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\nLearn more about [setting up permissions](ADDLINK). -->\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](ADDLINK) 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](ADDLINK).\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](ADDLINK) at a later time. \n\nYou can register lifecycle handlers to respond when the subscription succeeds or fails. The [`onSubscribed` handler](ADDLINK) runs on every successful connection, including automatic re-subscriptions attempted after network interruptions. The [`onSubscriptionError` handler](ADDLINK) runs whenever an error occurs. \n\nLearn more about the [Subscriber API](ADDLINK).\n\n### Subscription errors\n\nSubscription errors are caused by the subscription being rejected or by connection or reconnection failures. While some errors are automatically recoverable, some require manual handling. \n\nLearn more about [handling subscription errors](ADDLINK). -->\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"
3654
3702
  },
3655
3703
  {
3656
3704
  "type": "GUIDE",
@@ -3658,6 +3706,27 @@
3658
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```"
3659
3707
  }
3660
3708
  ],
3709
+ "/publisher": [
3710
+ {
3711
+ "type": "GUIDE",
3712
+ "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](ADDLINK) with suitable [permissions](ADDLINK) 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
+ }
3715
+ ],
3716
+ "/subscriber": [
3717
+ {
3718
+ "type": "GUIDE",
3719
+ "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 [Publisher](ADDLINK) 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](ADDLINK) at a later time. \n\nYou can register lifecycle handlers to respond when the subscription succeeds or fails. The [`onSubscribed` handler](ADDLINK) runs on every successful connection, including automatic re-subscriptions attempted after network interruptions. The [`onSubscriptionError` handler](ADDLINK) 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
+ }
3722
+ ],
3723
+ "/site": [
3724
+ {
3725
+ "type": "GUIDE",
3726
+ "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](ADDLINK) can receive messages on specific [channels and resources](ADDLINK).\n\nTo define permissions, set up the [`realtime_check_permission` hook](ADDLINK) 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](ADDLINK) 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](ADDLINK) 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](ADDLINK).\n\n## Use cases\n\n- [Restrict channels to logged-in members](ADDLINK).\n\n@sdk_package_setup"
3728
+ }
3729
+ ],
3661
3730
  "/site/publish": [
3662
3731
  {
3663
3732
  "type": "EXAMPLE",
@@ -3713,7 +3782,7 @@
3713
3782
  {
3714
3783
  "type": "GUIDE",
3715
3784
  "title": "Introduction",
3716
- "src": "# Introduction\n\nUse the permissions router to define the permissions you want to grant to subscribers\non channels or channel resources. You can set permissions on the channel and channel\nresource level. If you do not define permissions for a particular channel resource,\nthat resource inherits the permissions of its parent channel.\n\nTypically you use the permissions router in the **realtime-permissions.js** file in\nyour site's backend to:\n\n+ Set default permissions for all channels and channel resources where no explicit\n permissions are defined.\n+ Add permissions logic for specific channels or channel resources.\n+ Check the permissions for a specific subscriber on a specific channel.\n\n> **Note:** Although it is recommended, you do not need to use the permissions router to set permissions. You can also define all your permissions logic in the [`realtime_check_permission()`](https://dev.wix.com/docs/sdk/backend-modules/realtime/site/realtime-check-permission) function."
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()`](ADDLINK) hook.\n\nLearn more about the [Site API](ADDLINK) and the [Realtime APIs](ADDLINK).\n\nWith the Permissions Router API, you can:\n\n- [Add a handler](ADDLINK) for a specific channel or resource.\n- [Set a default handler](ADDLINK) for channels that don't have explicit handlers.\n- [Check](ADDLINK) 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"
3717
3786
  }
3718
3787
  ],
3719
3788
  "/site/PermissionsRouter/add": [