@voltro/plugin-broadcast 0.86.0 → 0.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5321 -0
- package/THIRD-PARTY-NOTICES.md +46 -214
- package/dist/index.d.ts +28 -82
- package/dist/plugin.js +34 -21
- package/dist/providers.js +36 -107
- package/dist/resolve.js +64 -47
- package/package.json +4 -7
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -870,6 +870,34 @@ Apache License
|
|
|
870
870
|
limitations under the License.
|
|
871
871
|
```
|
|
872
872
|
|
|
873
|
+
## @upstash/redis@1.38.4
|
|
874
|
+
|
|
875
|
+
License: MIT
|
|
876
|
+
|
|
877
|
+
```
|
|
878
|
+
The MIT License (MIT)
|
|
879
|
+
|
|
880
|
+
Copyright (c) 2021 Upstash, Inc.
|
|
881
|
+
|
|
882
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
883
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
884
|
+
in the Software without restriction, including without limitation the rights
|
|
885
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
886
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
887
|
+
furnished to do so, subject to the following conditions:
|
|
888
|
+
|
|
889
|
+
The above copyright notice and this permission notice shall be included in all
|
|
890
|
+
copies or substantial portions of the Software.
|
|
891
|
+
|
|
892
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
893
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
894
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
895
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
896
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
897
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
898
|
+
SOFTWARE.
|
|
899
|
+
```
|
|
900
|
+
|
|
873
901
|
## cluster-key-slot@1.1.1
|
|
874
902
|
|
|
875
903
|
License: Apache-2.0
|
|
@@ -1324,214 +1352,6 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|
|
1324
1352
|
For more information, please refer to <http://unlicense.org>
|
|
1325
1353
|
```
|
|
1326
1354
|
|
|
1327
|
-
## typeid-js@1.2.0
|
|
1328
|
-
|
|
1329
|
-
License: Apache-2.0
|
|
1330
|
-
|
|
1331
|
-
```
|
|
1332
|
-
Apache License
|
|
1333
|
-
Version 2.0, January 2004
|
|
1334
|
-
http://www.apache.org/licenses/
|
|
1335
|
-
|
|
1336
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
1337
|
-
|
|
1338
|
-
1. Definitions.
|
|
1339
|
-
|
|
1340
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
1341
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
1342
|
-
|
|
1343
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
1344
|
-
the copyright owner that is granting the License.
|
|
1345
|
-
|
|
1346
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
1347
|
-
other entities that control, are controlled by, or are under common
|
|
1348
|
-
control with that entity. For the purposes of this definition,
|
|
1349
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
1350
|
-
direction or management of such entity, whether by contract or
|
|
1351
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
1352
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
1353
|
-
|
|
1354
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
1355
|
-
exercising permissions granted by this License.
|
|
1356
|
-
|
|
1357
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
1358
|
-
including but not limited to software source code, documentation
|
|
1359
|
-
source, and configuration files.
|
|
1360
|
-
|
|
1361
|
-
"Object" form shall mean any form resulting from mechanical
|
|
1362
|
-
transformation or translation of a Source form, including but
|
|
1363
|
-
not limited to compiled object code, generated documentation,
|
|
1364
|
-
and conversions to other media types.
|
|
1365
|
-
|
|
1366
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
1367
|
-
Object form, made available under the License, as indicated by a
|
|
1368
|
-
copyright notice that is included in or attached to the work
|
|
1369
|
-
(an example is provided in the Appendix below).
|
|
1370
|
-
|
|
1371
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
1372
|
-
form, that is based on (or derived from) the Work and for which the
|
|
1373
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
1374
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
1375
|
-
of this License, Derivative Works shall not include works that remain
|
|
1376
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
1377
|
-
the Work and Derivative Works thereof.
|
|
1378
|
-
|
|
1379
|
-
"Contribution" shall mean any work of authorship, including
|
|
1380
|
-
the original version of the Work and any modifications or additions
|
|
1381
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
1382
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
1383
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
1384
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
1385
|
-
means any form of electronic, verbal, or written communication sent
|
|
1386
|
-
to the Licensor or its representatives, including but not limited to
|
|
1387
|
-
communication on electronic mailing lists, source code control systems,
|
|
1388
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
1389
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
1390
|
-
excluding communication that is conspicuously marked or otherwise
|
|
1391
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
1392
|
-
|
|
1393
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
1394
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
1395
|
-
subsequently incorporated within the Work.
|
|
1396
|
-
|
|
1397
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
1398
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
1399
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
1400
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
1401
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
1402
|
-
Work and such Derivative Works in Source or Object form.
|
|
1403
|
-
|
|
1404
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
1405
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
1406
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
1407
|
-
(except as stated in this section) patent license to make, have made,
|
|
1408
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
1409
|
-
where such license applies only to those patent claims licensable
|
|
1410
|
-
by such Contributor that are necessarily infringed by their
|
|
1411
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
1412
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
1413
|
-
institute patent litigation against any entity (including a
|
|
1414
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
1415
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
1416
|
-
or contributory patent infringement, then any patent licenses
|
|
1417
|
-
granted to You under this License for that Work shall terminate
|
|
1418
|
-
as of the date such litigation is filed.
|
|
1419
|
-
|
|
1420
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
1421
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
1422
|
-
modifications, and in Source or Object form, provided that You
|
|
1423
|
-
meet the following conditions:
|
|
1424
|
-
|
|
1425
|
-
(a) You must give any other recipients of the Work or
|
|
1426
|
-
Derivative Works a copy of this License; and
|
|
1427
|
-
|
|
1428
|
-
(b) You must cause any modified files to carry prominent notices
|
|
1429
|
-
stating that You changed the files; and
|
|
1430
|
-
|
|
1431
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
1432
|
-
that You distribute, all copyright, patent, trademark, and
|
|
1433
|
-
attribution notices from the Source form of the Work,
|
|
1434
|
-
excluding those notices that do not pertain to any part of
|
|
1435
|
-
the Derivative Works; and
|
|
1436
|
-
|
|
1437
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
1438
|
-
distribution, then any Derivative Works that You distribute must
|
|
1439
|
-
include a readable copy of the attribution notices contained
|
|
1440
|
-
within such NOTICE file, excluding those notices that do not
|
|
1441
|
-
pertain to any part of the Derivative Works, in at least one
|
|
1442
|
-
of the following places: within a NOTICE text file distributed
|
|
1443
|
-
as part of the Derivative Works; within the Source form or
|
|
1444
|
-
documentation, if provided along with the Derivative Works; or,
|
|
1445
|
-
within a display generated by the Derivative Works, if and
|
|
1446
|
-
wherever such third-party notices normally appear. The contents
|
|
1447
|
-
of the NOTICE file are for informational purposes only and
|
|
1448
|
-
do not modify the License. You may add Your own attribution
|
|
1449
|
-
notices within Derivative Works that You distribute, alongside
|
|
1450
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
1451
|
-
that such additional attribution notices cannot be construed
|
|
1452
|
-
as modifying the License.
|
|
1453
|
-
|
|
1454
|
-
You may add Your own copyright statement to Your modifications and
|
|
1455
|
-
may provide additional or different license terms and conditions
|
|
1456
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
1457
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
1458
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
1459
|
-
the conditions stated in this License.
|
|
1460
|
-
|
|
1461
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
1462
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
1463
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
1464
|
-
this License, without any additional terms or conditions.
|
|
1465
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
1466
|
-
the terms of any separate license agreement you may have executed
|
|
1467
|
-
with Licensor regarding such Contributions.
|
|
1468
|
-
|
|
1469
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
1470
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
1471
|
-
except as required for reasonable and customary use in describing the
|
|
1472
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
1473
|
-
|
|
1474
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
1475
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
1476
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
1477
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
1478
|
-
implied, including, without limitation, any warranties or conditions
|
|
1479
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
1480
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
1481
|
-
appropriateness of using or redistributing the Work and assume any
|
|
1482
|
-
risks associated with Your exercise of permissions under this License.
|
|
1483
|
-
|
|
1484
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
1485
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
1486
|
-
unless required by applicable law (such as deliberate and grossly
|
|
1487
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
1488
|
-
liable to You for damages, including any direct, indirect, special,
|
|
1489
|
-
incidental, or consequential damages of any character arising as a
|
|
1490
|
-
result of this License or out of the use or inability to use the
|
|
1491
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
1492
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
1493
|
-
other commercial damages or losses), even if such Contributor
|
|
1494
|
-
has been advised of the possibility of such damages.
|
|
1495
|
-
|
|
1496
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
1497
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
1498
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
1499
|
-
or other liability obligations and/or rights consistent with this
|
|
1500
|
-
License. However, in accepting such obligations, You may act only
|
|
1501
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
1502
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
1503
|
-
defend, and hold each Contributor harmless for any liability
|
|
1504
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
1505
|
-
of your accepting any such warranty or additional liability.
|
|
1506
|
-
|
|
1507
|
-
END OF TERMS AND CONDITIONS
|
|
1508
|
-
|
|
1509
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
1510
|
-
|
|
1511
|
-
To apply the Apache License to your work, attach the following
|
|
1512
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
1513
|
-
replaced with your own identifying information. (Don't include
|
|
1514
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
1515
|
-
comment syntax for the file format. We also recommend that a
|
|
1516
|
-
file or class name and description of purpose be included on the
|
|
1517
|
-
same "printed page" as the copyright notice for easier
|
|
1518
|
-
identification within third-party archives.
|
|
1519
|
-
|
|
1520
|
-
Copyright [yyyy] [name of copyright owner]
|
|
1521
|
-
|
|
1522
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1523
|
-
you may not use this file except in compliance with the License.
|
|
1524
|
-
You may obtain a copy of the License at
|
|
1525
|
-
|
|
1526
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
1527
|
-
|
|
1528
|
-
Unless required by applicable law or agreed to in writing, software
|
|
1529
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1530
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1531
|
-
See the License for the specific language governing permissions and
|
|
1532
|
-
limitations under the License.
|
|
1533
|
-
```
|
|
1534
|
-
|
|
1535
1355
|
## ulid@3.0.2
|
|
1536
1356
|
|
|
1537
1357
|
License: MIT
|
|
@@ -1560,19 +1380,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
1560
1380
|
SOFTWARE.
|
|
1561
1381
|
```
|
|
1562
1382
|
|
|
1563
|
-
##
|
|
1383
|
+
## uncrypto@0.1.3
|
|
1564
1384
|
|
|
1565
1385
|
License: MIT
|
|
1566
1386
|
|
|
1567
1387
|
```
|
|
1568
|
-
|
|
1388
|
+
MIT License
|
|
1569
1389
|
|
|
1570
|
-
Copyright (c)
|
|
1390
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
|
1571
1391
|
|
|
1572
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1392
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1393
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1394
|
+
in the Software without restriction, including without limitation the rights
|
|
1395
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1396
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1397
|
+
furnished to do so, subject to the following conditions:
|
|
1573
1398
|
|
|
1574
|
-
The above copyright notice and this permission notice shall be included in all
|
|
1399
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1400
|
+
copies or substantial portions of the Software.
|
|
1575
1401
|
|
|
1576
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1402
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1403
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1404
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1405
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1406
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1407
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1408
|
+
SOFTWARE.
|
|
1577
1409
|
```
|
|
1578
1410
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ChangeEvent } from '@voltro/database';
|
|
2
|
+
import { ConnectionPubSub } from '@voltro/kv/connection';
|
|
3
|
+
import { ConnectionRef } from '@voltro/kv/connection';
|
|
2
4
|
import { Effect } from 'effect';
|
|
3
5
|
import { Schema } from 'effect';
|
|
4
6
|
import { VoltroPlugin } from '@voltro/protocol';
|
|
@@ -72,6 +74,12 @@ export declare interface BroadcastBusLogger {
|
|
|
72
74
|
* `voltro start` WEB process rather than an api replica. */
|
|
73
75
|
export declare type BroadcastChannelKind = 'changes' | 'events' | 'members' | 'presence' | 'revalidate';
|
|
74
76
|
|
|
77
|
+
export declare interface BroadcastConnectionSelection {
|
|
78
|
+
readonly role: string;
|
|
79
|
+
readonly kind: 'redis' | 'nats';
|
|
80
|
+
readonly reference?: BrokerReference;
|
|
81
|
+
}
|
|
82
|
+
|
|
75
83
|
/**
|
|
76
84
|
* What rides the wire on the `voltro:changes` channel. `origin` is the
|
|
77
85
|
* publishing replica's id; subscribers skip their OWN origin (the writer
|
|
@@ -193,7 +201,6 @@ export declare interface BroadcastHealth {
|
|
|
193
201
|
export declare interface BroadcastPlugin extends VoltroPlugin {
|
|
194
202
|
readonly broadcast: {
|
|
195
203
|
readonly provider: BroadcastProvider;
|
|
196
|
-
readonly url: string | null;
|
|
197
204
|
readonly crossReplica: boolean;
|
|
198
205
|
/**
|
|
199
206
|
* The namespace as DECLARED here, before the app name or env is consulted.
|
|
@@ -208,18 +215,14 @@ export declare const broadcastPlugin: (options?: BroadcastPluginOptions) => Broa
|
|
|
208
215
|
|
|
209
216
|
export declare interface BroadcastPluginOptions {
|
|
210
217
|
/** Provider name (`'redis' | 'nats' | 'memory'`) or a pre-built
|
|
211
|
-
* `BroadcastProvider`. Default:
|
|
212
|
-
* `BROADCAST_PROVIDER` / `REDIS_URL` env, else `'memory'`. */
|
|
218
|
+
* `BroadcastProvider`. Default: reference kind, provider Env or registry endpoint Env, else memory. */
|
|
213
219
|
readonly provider?: BroadcastProviderName | BroadcastProvider;
|
|
214
|
-
/**
|
|
215
|
-
|
|
216
|
-
readonly
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
* `REDIS_URL`). Point broadcast at its own server or the shared one purely
|
|
221
|
-
* by which env var you set. */
|
|
222
|
-
readonly connection?: string;
|
|
220
|
+
/** Default broker reference. Endpoints and credentials belong in app connections. */
|
|
221
|
+
readonly connection?: ConnectionRef<'redis' | 'nats'>;
|
|
222
|
+
readonly events?: ConnectionRef<'redis' | 'nats'>;
|
|
223
|
+
readonly members?: ConnectionRef<'redis' | 'nats'>;
|
|
224
|
+
readonly presence?: ConnectionRef<'redis' | 'nats'>;
|
|
225
|
+
readonly revalidate?: ConnectionRef<'redis' | 'nats'>;
|
|
223
226
|
/**
|
|
224
227
|
* Namespace for EVERY framework channel on this broker — changes, events,
|
|
225
228
|
* membership and presence alike.
|
|
@@ -299,6 +302,8 @@ export declare interface BroadcastTransportEvent {
|
|
|
299
302
|
readonly detail?: string;
|
|
300
303
|
}
|
|
301
304
|
|
|
305
|
+
declare type BrokerReference = ConnectionRef<'redis' | 'nats'>;
|
|
306
|
+
|
|
302
307
|
/**
|
|
303
308
|
* One framework channel inside a namespace.
|
|
304
309
|
*
|
|
@@ -362,63 +367,17 @@ export declare const getBroadcastPlugin: (plugins: ReadonlyArray<VoltroPlugin>)
|
|
|
362
367
|
*/
|
|
363
368
|
export declare const memoryProvider: (bus?: string) => BroadcastProvider;
|
|
364
369
|
|
|
365
|
-
declare interface NatsLike {
|
|
366
|
-
publish: (subject: string, data: Uint8Array) => void;
|
|
367
|
-
subscribe: (subject: string) => NatsSubscription;
|
|
368
|
-
drain: () => Promise<void>;
|
|
369
|
-
/** nats.js' connection events. Read for two reasons: to report a reconnect as
|
|
370
|
-
* the hole it is, and to notice a connection that gave up. */
|
|
371
|
-
status: () => AsyncIterable<{
|
|
372
|
-
type: string;
|
|
373
|
-
data?: unknown;
|
|
374
|
-
}>;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
370
|
export declare const natsProvider: (options: NatsProviderOptions) => BroadcastProvider;
|
|
378
371
|
|
|
379
|
-
export declare interface NatsProviderOptions {
|
|
380
|
-
/** `nats://host:port` (comma-separated for a cluster). Required. */
|
|
381
|
-
readonly url: string;
|
|
382
|
-
/** Bring your own connected NATS connection (e.g. for shared creds). */
|
|
383
|
-
readonly connection?: NatsLike;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
declare interface NatsSubscription extends AsyncIterable<{
|
|
387
|
-
data: Uint8Array;
|
|
388
|
-
}> {
|
|
389
|
-
unsubscribe: () => void;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/** The slice of ioredis the provider touches — keeps the optional dep out
|
|
393
|
-
* of the type surface. */
|
|
394
|
-
declare interface RedisLike {
|
|
395
|
-
publish: (channel: string, message: string) => Promise<number>;
|
|
396
|
-
subscribe: (channel: string) => Promise<unknown>;
|
|
397
|
-
unsubscribe: (channel: string) => Promise<unknown>;
|
|
398
|
-
on(event: 'message', listener: (channel: string, message: string) => void): void;
|
|
399
|
-
/** ioredis' connection lifecycle. The subscriber re-subscribes its channels
|
|
400
|
-
* itself on `ready`; what it does NOT do is tell anyone that the messages
|
|
401
|
-
* sent while it was away are gone. That is what these are read for. */
|
|
402
|
-
on(event: 'ready' | 'reconnecting' | 'end' | 'close', listener: () => void): void;
|
|
403
|
-
/** `error` is REQUIRED, not optional decoration: an `EventEmitter` with no
|
|
404
|
-
* `error` listener turns the event into an uncaught exception. See the
|
|
405
|
-
* registration below. */
|
|
406
|
-
on(event: 'error', listener: (err: unknown) => void): void;
|
|
407
|
-
off(event: 'message', listener: (channel: string, message: string) => void): void;
|
|
408
|
-
off(event: 'ready' | 'reconnecting' | 'end' | 'close', listener: () => void): void;
|
|
409
|
-
duplicate: () => RedisLike;
|
|
410
|
-
quit: () => Promise<unknown>;
|
|
372
|
+
export declare interface NatsProviderOptions extends RedisProviderOptions {
|
|
411
373
|
}
|
|
412
374
|
|
|
375
|
+
/** Both adapters borrow the same consumer contract; neither owns a broker. */
|
|
413
376
|
export declare const redisProvider: (options: RedisProviderOptions) => BroadcastProvider;
|
|
414
377
|
|
|
415
378
|
export declare interface RedisProviderOptions {
|
|
416
|
-
/**
|
|
417
|
-
readonly
|
|
418
|
-
/** Bring your own ioredis client (publisher). A `subscriber` is
|
|
419
|
-
* `client.duplicate()`d internally — a RESP connection in subscribe
|
|
420
|
-
* mode can't issue normal commands. */
|
|
421
|
-
readonly client?: RedisLike;
|
|
379
|
+
/** Acquire a consumer from the app's ConnectionRegistry, never a raw socket. */
|
|
380
|
+
readonly pubsub: Effect.Effect<ConnectionPubSub, unknown>;
|
|
422
381
|
}
|
|
423
382
|
|
|
424
383
|
/* Excluded from this release type: resetMemoryBus */
|
|
@@ -435,31 +394,18 @@ export declare interface ResolveBroadcastNamespaceInput {
|
|
|
435
394
|
}
|
|
436
395
|
|
|
437
396
|
export declare interface ResolveBroadcastOptions {
|
|
438
|
-
/** Explicit provider name or a pre-built `BroadcastProvider`. */
|
|
439
397
|
readonly provider?: BroadcastProviderName | BroadcastProvider;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
readonly
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
* ratelimit), so a deployment points broadcast at the same server or its own
|
|
446
|
-
* purely by env. Default `'broadcast'` (→ `BROADCAST_REDIS_URL`). */
|
|
447
|
-
readonly connection?: string;
|
|
398
|
+
readonly connection?: BrokerReference;
|
|
399
|
+
readonly events?: BrokerReference;
|
|
400
|
+
readonly members?: BrokerReference;
|
|
401
|
+
readonly presence?: BrokerReference;
|
|
402
|
+
readonly revalidate?: BrokerReference;
|
|
448
403
|
}
|
|
449
404
|
|
|
450
|
-
|
|
451
|
-
* Resolve the bus backend. Order: an object provider is used verbatim; a
|
|
452
|
-
* named provider builds from `url`/env; absent → `BROADCAST_PROVIDER` env,
|
|
453
|
-
* else inferred from a `redis://` / `nats://` URL, else `memory`.
|
|
454
|
-
*
|
|
455
|
-
* Returns the provider plus the URL it resolved (for the boot banner) and
|
|
456
|
-
* whether the choice is a real cross-replica bus or the single-process
|
|
457
|
-
* memory fallback.
|
|
458
|
-
*/
|
|
459
|
-
export declare const resolveBroadcastProvider: (options: ResolveBroadcastOptions, env: NodeJS.ProcessEnv) => {
|
|
405
|
+
export declare const resolveBroadcastProvider: (options: ResolveBroadcastOptions, environment: NodeJS.ProcessEnv, pubsub?: (role: string) => Effect.Effect<ConnectionPubSub, unknown>) => {
|
|
460
406
|
provider: BroadcastProvider;
|
|
461
|
-
url: string | null;
|
|
462
407
|
crossReplica: boolean;
|
|
408
|
+
selections: ReadonlyArray<BroadcastConnectionSelection>;
|
|
463
409
|
};
|
|
464
410
|
|
|
465
411
|
/** Retry cadence for a subscribe that could not land: 500ms doubling to a 10s
|
package/dist/plugin.js
CHANGED
|
@@ -4,64 +4,77 @@ import { definePlugin as n } from "@voltro/protocol";
|
|
|
4
4
|
//#region src/plugin.ts
|
|
5
5
|
var r = ["network:outbound:*"], i = [
|
|
6
6
|
{
|
|
7
|
-
name: "
|
|
7
|
+
name: "BROADCAST_NATS_URL",
|
|
8
8
|
required: !1,
|
|
9
9
|
secret: !0,
|
|
10
|
-
description: "
|
|
11
|
-
example: "
|
|
10
|
+
description: "Named NATS registry endpoint for broadcast; falls back to NATS_URL.",
|
|
11
|
+
example: "nats://localhost:4222"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
name: "BROADCAST_REDIS_URL",
|
|
15
15
|
required: !1,
|
|
16
16
|
secret: !0,
|
|
17
|
-
description: "Named-connection redis url for the bus (the shared <NAME>_REDIS_URL convention, like CACHE_REDIS_URL / KV_REDIS_URL). Used when the redis provider is selected and no
|
|
17
|
+
description: "Named-connection redis url for the bus (the shared <NAME>_REDIS_URL convention, like CACHE_REDIS_URL / KV_REDIS_URL). Used when the redis provider is selected and no explicit connection reference is set; falls back to REDIS_URL. Set it to put broadcast on its own server.",
|
|
18
18
|
example: "redis://localhost:6379"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
name: "BROADCAST_PROVIDER",
|
|
22
22
|
required: !1,
|
|
23
23
|
secret: !1,
|
|
24
|
-
description: "Explicit provider: 'redis' | 'nats' | 'memory'.
|
|
24
|
+
description: "Explicit provider: 'redis' | 'nats' | 'memory'. The selected registry reference must match.",
|
|
25
25
|
example: "redis"
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
name: "REDIS_URL",
|
|
29
29
|
required: !1,
|
|
30
30
|
secret: !0,
|
|
31
|
-
description: "Fallback
|
|
31
|
+
description: "Fallback endpoint for registry-owned Redis broadcast (also infers the redis provider when no provider/URL is given).",
|
|
32
32
|
example: "redis://localhost:6379"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
name: "NATS_URL",
|
|
36
36
|
required: !1,
|
|
37
37
|
secret: !0,
|
|
38
|
-
description: "Fallback broker URL used when the resolved provider is nats and no
|
|
38
|
+
description: "Fallback broker URL used when the resolved provider is nats and no BROADCAST_NATS_URL is set (comma-separated for a cluster).",
|
|
39
39
|
example: "nats://localhost:4222"
|
|
40
40
|
}
|
|
41
41
|
], a = (a = {}) => {
|
|
42
|
-
let o = e({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, process.env);
|
|
42
|
+
let o, s = /* @__PURE__ */ new Map(), c = e(a, process.env, (e) => t.suspend(() => {
|
|
43
|
+
let n = s.get(e);
|
|
44
|
+
return o === void 0 || n === void 0 ? t.fail(/* @__PURE__ */ Error("Broadcast requires an activated app connection registry")) : o.pubsub(n);
|
|
45
|
+
})), l = Object.fromEntries(c.selections.flatMap((e) => e.reference === void 0 ? [] : [[e.role, e.reference]]));
|
|
47
46
|
return {
|
|
48
47
|
...n({
|
|
49
48
|
name: a.name ? `@voltro/plugin-broadcast#${a.name}` : "@voltro/plugin-broadcast",
|
|
50
49
|
description: "Cross-replica reactivity — fans out app-mutation ChangeEvents to every replica over a pub/sub bus (Redis / NATS). ADDITIVE to inline emit: local reactivity survives a broker outage. Closes the single-instance gap for every non-postgres dialect.",
|
|
51
50
|
permissions: r,
|
|
52
51
|
declaredEnv: i,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
...c.selections.length === 0 ? {} : {
|
|
53
|
+
needs: {
|
|
54
|
+
connections: c.selections.map(({ kind: e, role: t }) => ({
|
|
55
|
+
kind: e,
|
|
56
|
+
role: t
|
|
57
|
+
})),
|
|
58
|
+
pubsub: !0
|
|
59
|
+
},
|
|
60
|
+
connectionBindings: l
|
|
61
|
+
},
|
|
62
|
+
onActivate: (e) => t.gen(function* () {
|
|
63
|
+
o = e.connectionRegistry;
|
|
64
|
+
for (let t of c.selections) {
|
|
65
|
+
if (o === void 0) throw Error("Broadcast requires the app connection registry");
|
|
66
|
+
let n = e.connectionReference?.(t.role, t.kind) ?? t.reference ?? (t.kind === "nats" ? `nats:${t.role}` : process.env[`${t.role.toUpperCase()}_REDIS_URL`] ? `redis:${t.role}` : "");
|
|
67
|
+
s.set(t.role, n);
|
|
68
|
+
let r = yield* o.config(n);
|
|
69
|
+
if (t.kind === "redis" && (!("driver" in r) || r.driver !== "resp")) throw Error("Redis broadcast requires a RESP connection");
|
|
70
|
+
}
|
|
71
|
+
c.crossReplica ? e.logger.info("broadcast active", { provider: c.provider.name }) : e.logger.warn("broadcast: resolved to the in-process memory provider — NO cross-replica fan-out. Select a Redis or NATS connection for a cross-replica bus.");
|
|
58
72
|
}),
|
|
59
|
-
onDeactivate: () =>
|
|
73
|
+
onDeactivate: () => c.provider.close()
|
|
60
74
|
}),
|
|
61
75
|
broadcast: {
|
|
62
|
-
provider:
|
|
63
|
-
|
|
64
|
-
crossReplica: o.crossReplica,
|
|
76
|
+
provider: c.provider,
|
|
77
|
+
crossReplica: c.crossReplica,
|
|
65
78
|
namespace: a.namespace
|
|
66
79
|
}
|
|
67
80
|
};
|