@velajs/vela 1.15.0 → 1.17.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/dist/config/config.module.d.ts +8 -1
- package/dist/config/config.module.js +89 -42
- package/dist/config/config.service.d.ts +17 -4
- package/dist/config/config.service.js +18 -20
- package/dist/config/config.store.d.ts +46 -0
- package/dist/config/config.store.js +119 -0
- package/dist/config/config.tokens.d.ts +11 -0
- package/dist/config/config.tokens.js +12 -0
- package/dist/config/config.types.d.ts +37 -1
- package/dist/config/config.types.js +4 -1
- package/dist/config/index.d.ts +5 -2
- package/dist/config/index.js +3 -1
- package/dist/config/register-as.d.ts +52 -0
- package/dist/config/register-as.js +39 -0
- package/dist/{storage → crypto}/signed-url.js +5 -0
- package/dist/factory/bootstrap.js +10 -0
- package/dist/http/decorators.d.ts +18 -9
- package/dist/http/decorators.js +4 -1
- package/dist/http/index.d.ts +4 -0
- package/dist/http/index.js +2 -0
- package/dist/http/route-map.d.ts +30 -0
- package/dist/http/route-map.js +27 -0
- package/dist/http/route.manager.d.ts +2 -0
- package/dist/http/route.manager.js +4 -1
- package/dist/http/types.d.ts +2 -0
- package/dist/http/url/index.d.ts +4 -0
- package/dist/http/url/index.js +3 -0
- package/dist/http/url/signed-url.guard.d.ts +27 -0
- package/dist/http/url/signed-url.guard.js +62 -0
- package/dist/http/url/signing-secret.d.ts +20 -0
- package/dist/http/url/signing-secret.js +24 -0
- package/dist/http/url/url-generator.service.d.ts +52 -0
- package/dist/http/url/url-generator.service.js +104 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +5 -3
- package/dist/live/index.d.ts +12 -0
- package/dist/live/index.js +16 -0
- package/dist/live/live.cursor.d.ts +22 -0
- package/dist/live/live.cursor.js +56 -0
- package/dist/live/live.decorators.d.ts +32 -0
- package/dist/live/live.decorators.js +46 -0
- package/dist/live/live.delta.d.ts +15 -0
- package/dist/live/live.delta.js +51 -0
- package/dist/live/live.engine.d.ts +81 -0
- package/dist/live/live.engine.js +448 -0
- package/dist/live/live.invalidation.d.ts +27 -0
- package/dist/live/live.invalidation.js +56 -0
- package/dist/live/live.module.d.ts +28 -0
- package/dist/live/live.module.js +83 -0
- package/dist/live/live.tokens.d.ts +9 -0
- package/dist/live/live.tokens.js +8 -0
- package/dist/live/live.types.d.ts +138 -0
- package/dist/live/live.types.js +1 -0
- package/dist/live/presence.d.ts +44 -0
- package/dist/live/presence.js +130 -0
- package/dist/openapi/document.js +2 -1
- package/dist/registry/types.d.ts +2 -0
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +4 -1
- package/dist/websocket/index.d.ts +3 -3
- package/dist/websocket/index.js +2 -2
- package/dist/websocket/websocket.decorators.d.ts +14 -0
- package/dist/websocket/websocket.decorators.js +23 -1
- package/dist/websocket/websocket.tokens.d.ts +7 -0
- package/dist/websocket/websocket.tokens.js +6 -0
- package/dist/websocket/websocket.types.d.ts +16 -0
- package/dist/websocket/ws-dispatcher.d.ts +9 -0
- package/dist/websocket/ws-dispatcher.js +64 -1
- package/dist/websocket-node/index.d.ts +2 -0
- package/dist/websocket-node/index.js +1 -0
- package/dist/websocket-node/redis-live.d.ts +24 -0
- package/dist/websocket-node/redis-live.js +57 -0
- package/package.json +11 -2
- /package/dist/{storage → crypto}/signed-url.d.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LiveDriver } from '../live/index';
|
|
2
|
+
import type { RedisPubSubClient } from './redis-sync';
|
|
3
|
+
export interface RedisLiveOptions {
|
|
4
|
+
/** Connection used to publish invalidations. */
|
|
5
|
+
pub: RedisPubSubClient;
|
|
6
|
+
/** Separate connection kept in subscriber mode. */
|
|
7
|
+
sub: RedisPubSubClient;
|
|
8
|
+
/** Channel prefix. Default `vela:live`. */
|
|
9
|
+
prefix?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Cross-instance live-invalidation driver for node/bun via Redis pub/sub —
|
|
13
|
+
* the live sibling of the WebSocket `redis()` sync driver, carrying TAGS
|
|
14
|
+
* instead of frames. Local-first: `dispatch` applies to this instance's
|
|
15
|
+
* engine immediately (its log stamps the returned commit cursor), then fans
|
|
16
|
+
* the command out so every peer re-runs ITS local subscriptions.
|
|
17
|
+
*
|
|
18
|
+
* Guarantees (same honesty as `redis()`): at-most-once, no cross-publisher
|
|
19
|
+
* ordering, no replay. Each instance keeps its own per-process epoch, so a
|
|
20
|
+
* client reconnecting onto a different instance always receives a full
|
|
21
|
+
* snapshot — exactly the protocol's multi-instance-node rule. Real cursor
|
|
22
|
+
* resume needs a shared ordered log (the Cloudflare DO transport).
|
|
23
|
+
*/
|
|
24
|
+
export declare function redisLive(options: RedisLiveOptions): LiveDriver;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const swallow = (op)=>{
|
|
2
|
+
void Promise.resolve(op).catch(()=>{});
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Cross-instance live-invalidation driver for node/bun via Redis pub/sub —
|
|
6
|
+
* the live sibling of the WebSocket `redis()` sync driver, carrying TAGS
|
|
7
|
+
* instead of frames. Local-first: `dispatch` applies to this instance's
|
|
8
|
+
* engine immediately (its log stamps the returned commit cursor), then fans
|
|
9
|
+
* the command out so every peer re-runs ITS local subscriptions.
|
|
10
|
+
*
|
|
11
|
+
* Guarantees (same honesty as `redis()`): at-most-once, no cross-publisher
|
|
12
|
+
* ordering, no replay. Each instance keeps its own per-process epoch, so a
|
|
13
|
+
* client reconnecting onto a different instance always receives a full
|
|
14
|
+
* snapshot — exactly the protocol's multi-instance-node rule. Real cursor
|
|
15
|
+
* resume needs a shared ordered log (the Cloudflare DO transport).
|
|
16
|
+
*/ export function redisLive(options) {
|
|
17
|
+
const prefix = options.prefix ?? 'vela:live';
|
|
18
|
+
const channel = `${prefix}:invalidate`;
|
|
19
|
+
const origin = crypto.randomUUID();
|
|
20
|
+
let sink;
|
|
21
|
+
let bound = false;
|
|
22
|
+
const onMessage = (ch, message)=>{
|
|
23
|
+
if (ch !== channel) return;
|
|
24
|
+
let cmd;
|
|
25
|
+
try {
|
|
26
|
+
cmd = JSON.parse(message);
|
|
27
|
+
} catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (cmd.origin === origin) return; // our own publish — already applied locally
|
|
31
|
+
if (sink) swallow(sink.applyInvalidation(cmd));
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
kind: 'redis',
|
|
35
|
+
bind (boundSink) {
|
|
36
|
+
sink = boundSink;
|
|
37
|
+
if (bound) return; // idempotent — never stack duplicate 'message' listeners
|
|
38
|
+
bound = true;
|
|
39
|
+
swallow(options.sub.subscribe(channel));
|
|
40
|
+
options.sub.on('message', onMessage);
|
|
41
|
+
},
|
|
42
|
+
async dispatch (cmd) {
|
|
43
|
+
swallow(options.pub.publish(channel, JSON.stringify({
|
|
44
|
+
...cmd,
|
|
45
|
+
origin
|
|
46
|
+
})));
|
|
47
|
+
return sink?.applyInvalidation(cmd);
|
|
48
|
+
},
|
|
49
|
+
stop () {
|
|
50
|
+
if (!bound) return;
|
|
51
|
+
bound = false;
|
|
52
|
+
options.sub.off?.('message', onMessage);
|
|
53
|
+
options.sub.removeListener?.('message', onMessage);
|
|
54
|
+
swallow(options.sub.unsubscribe?.(channel));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velajs/vela",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "NestJS-compatible framework for edge runtimes, powered by Hono",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"types": "./dist/queue/index.d.ts",
|
|
39
39
|
"import": "./dist/queue/index.js"
|
|
40
40
|
},
|
|
41
|
+
"./live": {
|
|
42
|
+
"types": "./dist/live/index.d.ts",
|
|
43
|
+
"import": "./dist/live/index.js"
|
|
44
|
+
},
|
|
41
45
|
"./storage": {
|
|
42
46
|
"types": "./dist/storage/index.d.ts",
|
|
43
47
|
"import": "./dist/storage/index.js"
|
|
@@ -84,6 +88,7 @@
|
|
|
84
88
|
"node": ">=20"
|
|
85
89
|
},
|
|
86
90
|
"dependencies": {
|
|
91
|
+
"@velajs/live-protocol": "^1.0.0",
|
|
87
92
|
"hono": "^4.12.26"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
@@ -102,6 +107,7 @@
|
|
|
102
107
|
"@vitest/runner": "^4.1.9",
|
|
103
108
|
"@vitest/snapshot": "^4.1.9",
|
|
104
109
|
"intl-messageformat": "^11.2.9",
|
|
110
|
+
"typedoc": "~0.28.19",
|
|
105
111
|
"typescript": "^6.0.3",
|
|
106
112
|
"unplugin-swc": "^1.5.9",
|
|
107
113
|
"vitest": "^4.1.9",
|
|
@@ -112,6 +118,9 @@
|
|
|
112
118
|
"test": "vitest run",
|
|
113
119
|
"test:workers": "vitest run --config vitest.config.workers.ts",
|
|
114
120
|
"test:workers:als": "vitest run --config vitest.config.workers-als.ts",
|
|
115
|
-
"typecheck": "tsc --noEmit"
|
|
121
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.type-tests.json",
|
|
122
|
+
"check:skill": "node scripts/check-skill.mjs",
|
|
123
|
+
"docs": "typedoc",
|
|
124
|
+
"docs:check": "typedoc --emit none"
|
|
116
125
|
}
|
|
117
126
|
}
|
|
File without changes
|