@holo-js/broadcast 0.1.3

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.
@@ -0,0 +1,91 @@
1
+ import { BroadcastDefinition, BroadcastDefinitionInput, PendingBroadcastDispatch, BroadcastSendResult, RawBroadcastSendInput, ResolvedRawBroadcastSendInput, BroadcastDelayValue, BroadcastDriver, BroadcastRuntimeBindings, BroadcastRuntimeFacade } from './contracts.js';
2
+ import '@holo-js/config';
3
+ import '@holo-js/validation';
4
+
5
+ type MutableDispatchOptions = {
6
+ broadcaster?: string;
7
+ connection?: string;
8
+ queue?: string;
9
+ delay?: BroadcastDelayValue;
10
+ afterCommit?: boolean;
11
+ };
12
+ type ResolvedQueuePlan = {
13
+ readonly queued: boolean;
14
+ readonly connection?: string;
15
+ readonly queue?: string;
16
+ readonly delay?: BroadcastDelayValue;
17
+ readonly afterCommit: boolean;
18
+ };
19
+ type ResolvedBroadcastConnection = {
20
+ readonly name: string;
21
+ readonly driver: string;
22
+ };
23
+ type ResolvedDriver = {
24
+ readonly connection: ResolvedBroadcastConnection;
25
+ readonly driver: string;
26
+ readonly implementation: BroadcastDriver;
27
+ };
28
+ type QueueDispatchChain = {
29
+ onConnection(name: string): QueueDispatchChain;
30
+ onQueue(name: string): QueueDispatchChain;
31
+ delay(value: number | Date): QueueDispatchChain;
32
+ dispatch(): Promise<unknown>;
33
+ };
34
+ type QueueModule = {
35
+ defineJob(definition: {
36
+ handle(payload: QueuedBroadcastPayload): Promise<unknown> | unknown;
37
+ }): unknown;
38
+ dispatch(jobName: string, payload: QueuedBroadcastPayload): QueueDispatchChain;
39
+ getRegisteredQueueJob(name: string): unknown;
40
+ registerQueueJob(definition: unknown, options: {
41
+ name: string;
42
+ }): void;
43
+ };
44
+ type DbModule = {
45
+ connectionAsyncContext: {
46
+ getActive(): {
47
+ connection: {
48
+ getScope(): {
49
+ kind: string;
50
+ };
51
+ afterCommit(callback: () => Promise<void>): void;
52
+ };
53
+ } | undefined;
54
+ };
55
+ };
56
+ type QueuedBroadcastPayload = Readonly<{
57
+ readonly messageId: string;
58
+ readonly raw: ResolvedRawBroadcastSendInput;
59
+ readonly context: Readonly<{
60
+ readonly connection: string;
61
+ readonly driver: string;
62
+ }>;
63
+ }>;
64
+ declare function normalizeDelayValue(value: BroadcastDelayValue, label: string): BroadcastDelayValue;
65
+ declare function resolveBroadcastConnection(selectedConnection: string | undefined): ResolvedBroadcastConnection;
66
+ declare function normalizeRawBroadcastInput(input: RawBroadcastSendInput, selectedConnection?: string): Readonly<ResolvedRawBroadcastSendInput>;
67
+ declare function createRawInputFromDefinition(definition: BroadcastDefinition, selectedConnection?: string): Readonly<ResolvedRawBroadcastSendInput>;
68
+ declare function resolveQueuePlan(definition: BroadcastDefinition | null, options: Readonly<MutableDispatchOptions>): ResolvedQueuePlan;
69
+ declare function resolveDriver(connectionName: string): ResolvedDriver;
70
+ declare function ensureBroadcastQueueJobRegistered(queueModule?: QueueModule): Promise<QueueModule>;
71
+ declare function configureBroadcastRuntime(bindings?: BroadcastRuntimeBindings): void;
72
+ declare function getBroadcastRuntimeBindings(): BroadcastRuntimeBindings;
73
+ declare function resetBroadcastRuntime(): void;
74
+ declare function broadcast(definition: BroadcastDefinition | BroadcastDefinitionInput): PendingBroadcastDispatch<BroadcastSendResult>;
75
+ declare function broadcastRaw(input: RawBroadcastSendInput): PendingBroadcastDispatch<BroadcastSendResult>;
76
+ declare function getBroadcastRuntime(): BroadcastRuntimeFacade;
77
+ declare const broadcastRuntimeInternals: {
78
+ createRawInputFromDefinition: typeof createRawInputFromDefinition;
79
+ ensureBroadcastQueueJobRegistered: typeof ensureBroadcastQueueJobRegistered;
80
+ normalizeDelayValue: typeof normalizeDelayValue;
81
+ normalizeRawBroadcastInput: typeof normalizeRawBroadcastInput;
82
+ resolveBroadcastConnection: typeof resolveBroadcastConnection;
83
+ resolveDriver: typeof resolveDriver;
84
+ resolveQueuePlan: typeof resolveQueuePlan;
85
+ resetBroadcastRuntime: typeof resetBroadcastRuntime;
86
+ runQueuedBroadcastDelivery(payload: QueuedBroadcastPayload): Promise<Readonly<BroadcastSendResult>>;
87
+ setLoadDbModuleForTesting(loader?: () => Promise<DbModule | null>): void;
88
+ setLoadQueueModuleForTesting(loader?: () => Promise<QueueModule>): void;
89
+ };
90
+
91
+ export { broadcast, broadcastRaw, broadcastRuntimeInternals, configureBroadcastRuntime, getBroadcastRuntime, getBroadcastRuntimeBindings, resetBroadcastRuntime };
@@ -0,0 +1,19 @@
1
+ import {
2
+ broadcast,
3
+ broadcastRaw,
4
+ broadcastRuntimeInternals,
5
+ configureBroadcastRuntime,
6
+ getBroadcastRuntime,
7
+ getBroadcastRuntimeBindings,
8
+ resetBroadcastRuntime
9
+ } from "./chunk-742LGR5P.mjs";
10
+ import "./chunk-QW6MHEWS.mjs";
11
+ export {
12
+ broadcast,
13
+ broadcastRaw,
14
+ broadcastRuntimeInternals,
15
+ configureBroadcastRuntime,
16
+ getBroadcastRuntime,
17
+ getBroadcastRuntimeBindings,
18
+ resetBroadcastRuntime
19
+ };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@holo-js/broadcast",
3
+ "version": "0.1.3",
4
+ "description": "Holo-JS Framework - broadcast contracts, channel definitions, and driver registration seams",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "default": "./dist/index.mjs"
12
+ },
13
+ "./auth": {
14
+ "types": "./dist/auth.d.ts",
15
+ "import": "./dist/auth.mjs",
16
+ "default": "./dist/auth.mjs"
17
+ },
18
+ "./contracts": {
19
+ "types": "./dist/contracts.d.ts",
20
+ "import": "./dist/contracts.mjs",
21
+ "default": "./dist/contracts.mjs"
22
+ },
23
+ "./runtime": {
24
+ "types": "./dist/runtime.d.ts",
25
+ "import": "./dist/runtime.mjs",
26
+ "default": "./dist/runtime.mjs"
27
+ }
28
+ },
29
+ "main": "./dist/index.mjs",
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsup",
36
+ "stub": "tsup",
37
+ "typecheck": "tsc -p tsconfig.json --noEmit",
38
+ "test": "vitest --run"
39
+ },
40
+ "dependencies": {
41
+ "@holo-js/config": "^0.1.3",
42
+ "@holo-js/validation": "^0.1.3",
43
+ "ws": "^8.18.3"
44
+ },
45
+ "peerDependencies": {
46
+ "ioredis": "catalog:"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "ioredis": {
50
+ "optional": true
51
+ }
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^22.10.2",
55
+ "@types/ws": "^8.18.1",
56
+ "ioredis": "catalog:",
57
+ "tsup": "^8.3.5",
58
+ "typescript": "^5.7.2",
59
+ "vitest": "^2.1.8"
60
+ }
61
+ }