tina4-nodejs 3.13.37 → 3.13.39
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/CLAUDE.md +65 -20
- package/README.md +6 -6
- package/package.json +5 -3
- package/packages/cli/src/bin.ts +7 -0
- package/packages/cli/src/commands/init.ts +1 -0
- package/packages/cli/src/commands/metrics.ts +154 -0
- package/packages/cli/src/commands/routes.ts +3 -3
- package/packages/core/src/api.ts +64 -1
- package/packages/core/src/auth.ts +112 -2
- package/packages/core/src/cache.ts +2 -2
- package/packages/core/src/devAdmin.ts +66 -44
- package/packages/core/src/devMailbox.ts +4 -0
- package/packages/core/src/dotenv.ts +13 -4
- package/packages/core/src/events.ts +86 -4
- package/packages/core/src/graphql.ts +182 -128
- package/packages/core/src/htmlElement.ts +62 -3
- package/packages/core/src/index.ts +21 -10
- package/packages/core/src/logger.ts +85 -28
- package/packages/core/src/mcp.test.ts +1 -1
- package/packages/core/src/mcp.ts +25 -8
- package/packages/core/src/messenger.ts +111 -11
- package/packages/core/src/metrics.ts +557 -98
- package/packages/core/src/middleware.ts +130 -40
- package/packages/core/src/plan.ts +1 -1
- package/packages/core/src/queue.ts +1 -1
- package/packages/core/src/queueBackends/kafkaBackend.ts +98 -1
- package/packages/core/src/queueBackends/mongoBackend.ts +1 -1
- package/packages/core/src/queueBackends/rabbitmqBackend.ts +1 -1
- package/packages/core/src/rateLimiter.ts +1 -1
- package/packages/core/src/response.ts +90 -6
- package/packages/core/src/router.ts +56 -8
- package/packages/core/src/server.ts +138 -23
- package/packages/core/src/session.ts +130 -18
- package/packages/core/src/sessionHandlers/databaseHandler.ts +10 -0
- package/packages/core/src/sessionHandlers/mongoHandler.ts +21 -4
- package/packages/core/src/sessionHandlers/redisHandler.ts +28 -7
- package/packages/core/src/sessionHandlers/valkeyHandler.ts +27 -8
- package/packages/core/src/testClient.ts +1 -1
- package/packages/core/src/types.ts +17 -2
- package/packages/core/src/websocket.ts +666 -42
- package/packages/core/src/websocketBackplane.ts +210 -10
- package/packages/core/src/websocketConnection.ts +6 -0
- package/packages/core/src/wsdl.ts +55 -21
- package/packages/orm/src/adapters/pg-types.d.ts +60 -0
- package/packages/orm/src/adapters/postgres.ts +26 -4
- package/packages/orm/src/adapters/sqlite.ts +112 -13
- package/packages/orm/src/baseModel.ts +175 -25
- package/packages/orm/src/cachedDatabase.ts +15 -6
- package/packages/orm/src/database.ts +257 -55
- package/packages/orm/src/index.ts +6 -1
- package/packages/orm/src/migration.ts +151 -24
- package/packages/orm/src/queryBuilder.ts +14 -2
- package/packages/orm/src/seeder.ts +443 -65
- package/packages/orm/src/types.ts +7 -0
- package/packages/orm/src/validation.ts +14 -0
- package/packages/swagger/src/ui.ts +1 -1
|
@@ -26,6 +26,16 @@ export interface ValkeySessionConfig {
|
|
|
26
26
|
password?: string;
|
|
27
27
|
prefix?: string;
|
|
28
28
|
db?: number;
|
|
29
|
+
// Unified SessionConfig fields are tolerated (and ignored) so the central
|
|
30
|
+
// Session can forward its config object without a structural mismatch.
|
|
31
|
+
backend?: string;
|
|
32
|
+
path?: string;
|
|
33
|
+
ttl?: number;
|
|
34
|
+
redisHost?: string;
|
|
35
|
+
redisPort?: number;
|
|
36
|
+
redisPassword?: string;
|
|
37
|
+
redisPrefix?: string;
|
|
38
|
+
redisDb?: number;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
/**
|
|
@@ -67,7 +77,10 @@ export class ValkeySessionHandler implements SessionHandler {
|
|
|
67
77
|
/**
|
|
68
78
|
* Execute a RESP command synchronously via a short-lived TCP connection.
|
|
69
79
|
*
|
|
70
|
-
* Returns the
|
|
80
|
+
* Returns the command result string. A genuine key miss yields `""`. A
|
|
81
|
+
* transport/connection FAILURE (server unreachable, AUTH error, timeout)
|
|
82
|
+
* THROWS so the Session boundary can distinguish "not found" (silent) from
|
|
83
|
+
* "backend failed" (log-loud + degrade). Backend-failure policy parity.
|
|
71
84
|
*/
|
|
72
85
|
private execSync(args: string[]): string {
|
|
73
86
|
const script = `
|
|
@@ -141,18 +154,24 @@ export class ValkeySessionHandler implements SessionHandler {
|
|
|
141
154
|
setTimeout(() => { sock.destroy(); process.exit(1); }, 3000);
|
|
142
155
|
`;
|
|
143
156
|
|
|
157
|
+
let result: string;
|
|
144
158
|
try {
|
|
145
|
-
|
|
159
|
+
result = execFileSync(process.execPath, ["-e", script], {
|
|
146
160
|
encoding: "utf-8",
|
|
147
161
|
timeout: 5000,
|
|
148
162
|
stdio: ["pipe", "pipe", "pipe"],
|
|
149
163
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
} catch (err) {
|
|
165
|
+
// Non-zero exit = the child hit a socket error / AUTH failure / timeout.
|
|
166
|
+
// That is a transport FAILURE, not a key miss — surface it so the
|
|
167
|
+
// Session boundary logs + degrades (or re-throws under strict mode).
|
|
168
|
+
throw new Error(`Valkey command failed: ${(err as Error).message}`);
|
|
169
|
+
}
|
|
170
|
+
if (result === "__NULL__") return ""; // genuine key miss
|
|
171
|
+
if (result.startsWith("__ERR__")) {
|
|
172
|
+
throw new Error(`Valkey error: ${result.slice("__ERR__".length)}`);
|
|
155
173
|
}
|
|
174
|
+
return result;
|
|
156
175
|
}
|
|
157
176
|
|
|
158
177
|
private key(sessionId: string): string {
|
|
@@ -161,7 +180,7 @@ export class ValkeySessionHandler implements SessionHandler {
|
|
|
161
180
|
|
|
162
181
|
read(sessionId: string): SessionData | null {
|
|
163
182
|
const raw = this.execSync(["GET", this.key(sessionId)]);
|
|
164
|
-
if (!raw) return null;
|
|
183
|
+
if (!raw) return null; // key miss — normal "no session yet", NOT an error
|
|
165
184
|
try {
|
|
166
185
|
return JSON.parse(raw) as SessionData;
|
|
167
186
|
} catch {
|
|
@@ -179,13 +179,28 @@ export type MiddlewareSpec = Middleware | string;
|
|
|
179
179
|
* event — one of "open", "message", or "close".
|
|
180
180
|
* data — the incoming text message (only present for "message" events).
|
|
181
181
|
*/
|
|
182
|
-
export type WebSocketRouteHandler = (
|
|
182
|
+
export type WebSocketRouteHandler = ((
|
|
183
183
|
connection: import("./websocketConnection.js").WebSocketConnection,
|
|
184
184
|
event: "open" | "message" | "close",
|
|
185
185
|
data: string,
|
|
186
|
-
) => void | Promise<void
|
|
186
|
+
) => void | Promise<void>) & {
|
|
187
|
+
/**
|
|
188
|
+
* Decorator-style secured flag — mirrors Python's `handler._secured`. When
|
|
189
|
+
* truthy the WS route requires a valid JWT on the upgrade. `Router.websocket`
|
|
190
|
+
* reads this into the route's `authRequired`. Lets a handler be marked
|
|
191
|
+
* secured in EITHER order (before or after registration).
|
|
192
|
+
*/
|
|
193
|
+
_secured?: boolean;
|
|
194
|
+
};
|
|
187
195
|
|
|
188
196
|
export interface WebSocketRouteDefinition {
|
|
189
197
|
pattern: string;
|
|
190
198
|
handler: WebSocketRouteHandler;
|
|
199
|
+
/**
|
|
200
|
+
* True when this WS route requires a valid JWT on the upgrade. Public by
|
|
201
|
+
* default (mirrors GET). Set imperatively via `Router.websocket(path, fn,
|
|
202
|
+
* { secured: true })` / the returned `.secure()`, or by a `_secured` flag on
|
|
203
|
+
* the handler (decorator style).
|
|
204
|
+
*/
|
|
205
|
+
authRequired?: boolean;
|
|
191
206
|
}
|