tina4-nodejs 3.13.164 → 3.13.166
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 +12 -5
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +1312 -979
- package/packages/cli/src/bin.ts +5 -2
- package/packages/cli/src/commands/lint.ts +3 -1
- package/packages/cli/src/commands/seed.ts +10 -11
- package/packages/core/dist/index.js +1232 -897
- package/packages/core/src/batchSpawn.ts +129 -0
- package/packages/core/src/connectionUrl.ts +242 -0
- package/packages/core/src/devAdmin.ts +25 -11
- package/packages/core/src/fakeData.ts +51 -13
- package/packages/core/src/index.ts +1 -1
- package/packages/core/src/mcp.ts +4 -1
- package/packages/core/src/mqtt.ts +24 -48
- package/packages/core/src/portTakeover.ts +31 -13
- package/packages/core/src/projectIndex.ts +3 -4
- package/packages/core/src/projectIndexStorage.ts +9 -1
- package/packages/core/src/queueBackends/rabbitmqBackend.ts +32 -20
- package/packages/core/src/response.ts +4 -1
- package/packages/core/src/routeDiscovery.ts +8 -2
- package/packages/core/src/router.ts +44 -30
- package/packages/core/src/server.ts +53 -33
- package/packages/core/src/session.ts +5 -0
- package/packages/core/src/sessionHandlers/databaseHandler.ts +16 -0
- package/packages/core/src/urlRedaction.ts +252 -0
- package/packages/core/src/websocketBackplane.ts +15 -3
- package/packages/orm/dist/index.js +1259 -925
- package/packages/orm/src/database.ts +7 -1
- package/packages/orm/src/databaseUrl.ts +73 -190
- package/packages/orm/src/docstore.ts +8 -1
- package/packages/orm/src/graph/graphUrl.ts +43 -7
- package/packages/orm/src/model.ts +2 -1
- package/types/core/src/batchSpawn.d.ts +28 -0
- package/types/core/src/connectionUrl.d.ts +61 -0
- package/types/core/src/fakeData.d.ts +11 -2
- package/types/core/src/index.d.ts +1 -1
- package/types/core/src/portTakeover.d.ts +15 -0
- package/types/core/src/projectIndexStorage.d.ts +5 -0
- package/types/core/src/queueBackends/rabbitmqBackend.d.ts +0 -7
- package/types/core/src/router.d.ts +17 -2
- package/types/core/src/server.d.ts +13 -0
- package/types/core/src/session.d.ts +5 -0
- package/types/core/src/sessionHandlers/databaseHandler.d.ts +8 -0
- package/types/core/src/urlRedaction.d.ts +61 -0
- package/types/orm/src/databaseUrl.d.ts +18 -19
- package/types/orm/src/graph/graphUrl.d.ts +18 -0
|
@@ -12,13 +12,6 @@ export interface RabbitMQConfig {
|
|
|
12
12
|
*/
|
|
13
13
|
visibilityTimeout?: number;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Parse an AMQP URL (amqp://[user:pass@]host[:port][/vhost]) into a partial
|
|
17
|
-
* RabbitMQConfig. Mirrors the Python/PHP/Ruby `parse_amqp_url` semantics:
|
|
18
|
-
* strips a leading amqp:// or amqps:// scheme, splits optional credentials,
|
|
19
|
-
* and reads the path segment as the URL-decoded vhost name. Only fields
|
|
20
|
-
* present in the URL are populated.
|
|
21
|
-
*/
|
|
22
15
|
export declare function parseAmqpUrl(url: string): RabbitMQConfig;
|
|
23
16
|
export interface QueueBackend {
|
|
24
17
|
push(queue: string, payload: unknown, delay?: number, priority?: number, raw?: boolean): string;
|
|
@@ -60,12 +60,16 @@ export declare class WsRouteRef {
|
|
|
60
60
|
/**
|
|
61
61
|
* Thin reference to a registered route, enabling chained modifiers.
|
|
62
62
|
*
|
|
63
|
+
* A ref may cover several compiled routes: `any()` registers one route per
|
|
64
|
+
* method, and a modifier chained on it must reach every one of them, not only
|
|
65
|
+
* the last one registered.
|
|
66
|
+
*
|
|
63
67
|
* Usage:
|
|
64
68
|
* router.get("/api/data", handler).secure().cache();
|
|
65
69
|
*/
|
|
66
70
|
export declare class RouteRef {
|
|
67
|
-
private
|
|
68
|
-
constructor(route: CompiledRoute);
|
|
71
|
+
private routes;
|
|
72
|
+
constructor(route: CompiledRoute | CompiledRoute[]);
|
|
69
73
|
/** Mark this route as requiring bearer-token authentication. */
|
|
70
74
|
secure(): this;
|
|
71
75
|
/** Opt out of secure-by-default auth (for public write routes). */
|
|
@@ -88,6 +92,12 @@ export declare class RouteRef {
|
|
|
88
92
|
* concrete requirement. Chain for AND. Implies auth. Feature 138.
|
|
89
93
|
*/
|
|
90
94
|
can(...permissions: string[]): this;
|
|
95
|
+
/**
|
|
96
|
+
* Add one OR-group of roles or permissions to every route this ref covers,
|
|
97
|
+
* and secure them (a guard implies auth). Empty names are dropped; a call
|
|
98
|
+
* with none left changes nothing.
|
|
99
|
+
*/
|
|
100
|
+
private guard;
|
|
91
101
|
/** Mark this route's response as cacheable. */
|
|
92
102
|
cache(): this;
|
|
93
103
|
/**
|
|
@@ -128,6 +138,8 @@ export declare class Router {
|
|
|
128
138
|
* Add a raw route definition (used internally and by file-based routing).
|
|
129
139
|
*/
|
|
130
140
|
addRoute(definition: RouteDefinition): RouteRef;
|
|
141
|
+
/** Compile and store one route definition; returns the stored route. */
|
|
142
|
+
private registerRoute;
|
|
131
143
|
/**
|
|
132
144
|
* Register a GET route programmatically.
|
|
133
145
|
*/
|
|
@@ -166,6 +178,9 @@ export declare class Router {
|
|
|
166
178
|
options(path: string, handler: RouteHandler, middlewares?: MiddlewareSpec[], meta?: RouteMeta): RouteRef;
|
|
167
179
|
/**
|
|
168
180
|
* Register a route that matches ANY HTTP method.
|
|
181
|
+
*
|
|
182
|
+
* One route is stored per method; the returned ref covers all of them, so
|
|
183
|
+
* `any(...).secure()` / `.role()` / `.noAuth()` apply to every method.
|
|
169
184
|
*/
|
|
170
185
|
any(path: string, handler: RouteHandler, middlewares?: MiddlewareSpec[], meta?: RouteMeta): RouteRef;
|
|
171
186
|
/**
|
|
@@ -17,6 +17,19 @@ export declare const DEFAULT_SHUTDOWN_TIMEOUT_SECONDS = 30;
|
|
|
17
17
|
* zero-second force-kill.
|
|
18
18
|
*/
|
|
19
19
|
export declare function shutdownTimeoutSeconds(): number;
|
|
20
|
+
/**
|
|
21
|
+
* The signals `startServer()` traps into its graceful shutdown on this platform.
|
|
22
|
+
*
|
|
23
|
+
* POSIX: SIGTERM (an orchestrator's stop) and SIGINT (Ctrl+C).
|
|
24
|
+
*
|
|
25
|
+
* Windows adds SIGBREAK: Ctrl+Break, and the CTRL_BREAK_EVENT a console or
|
|
26
|
+
* service manager sends a process group, arrive as SIGBREAK, and with no
|
|
27
|
+
* listener Node's default action kills the process on the spot (exit
|
|
28
|
+
* 0xC000013A) - in-flight requests dropped, no drain. Parity with tina4-python,
|
|
29
|
+
* which traps SIGINT/SIGBREAK/SIGTERM on Windows. Every listener registered for
|
|
30
|
+
* these replaces Node's default and therefore MUST exit (see background.ts).
|
|
31
|
+
*/
|
|
32
|
+
export declare function shutdownSignals(platform?: NodeJS.Platform): NodeJS.Signals[];
|
|
20
33
|
/**
|
|
21
34
|
* Build the startup banner's optional surface lines (issue #99).
|
|
22
35
|
*
|
|
@@ -47,6 +47,11 @@ export interface SessionHandler {
|
|
|
47
47
|
destroy(sessionId: string): void;
|
|
48
48
|
/** Garbage-collect expired sessions. Optional — Redis/Valkey/Mongo handle TTL natively. */
|
|
49
49
|
gc?(maxLifetime: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Release a connection the handler opened itself. Optional; idempotent; the
|
|
52
|
+
* next read or write reopens it.
|
|
53
|
+
*/
|
|
54
|
+
close?(): void;
|
|
50
55
|
}
|
|
51
56
|
export declare class FileSessionHandler implements SessionHandler {
|
|
52
57
|
private storagePath;
|
|
@@ -54,6 +54,14 @@ export declare class DatabaseSessionHandler implements SessionHandler {
|
|
|
54
54
|
constructor(config?: DatabaseSessionConfig);
|
|
55
55
|
/** Open the SQLite database on FIRST USE, not at construction. */
|
|
56
56
|
private get sqlite();
|
|
57
|
+
/**
|
|
58
|
+
* Release the SQLite connection this handler opened, so its file (and the
|
|
59
|
+
* WAL's -wal / -shm side files) is no longer held open: on Windows an open
|
|
60
|
+
* file cannot be deleted or replaced. Idempotent, and the next read or write
|
|
61
|
+
* reopens the connection. A server engine needs nothing here - each call goes
|
|
62
|
+
* through the sync bridge, which holds no connection between calls.
|
|
63
|
+
*/
|
|
64
|
+
close(): void;
|
|
57
65
|
private get engine();
|
|
58
66
|
/**
|
|
59
67
|
* Decide, from TINA4_DATABASE_URL, which engine this handler talks to.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection URL credentials: the ONE redaction rule, shared by every path
|
|
3
|
+
* that can put a connection string in front of a human (GHSA-h2mr-m3v3-cq8c).
|
|
4
|
+
* Its parsing half - the ONE userinfo splitter every parser uses - is the
|
|
5
|
+
* sibling connectionUrl.ts, which takes its port-versus-password test from
|
|
6
|
+
* here so the two halves cannot drift.
|
|
7
|
+
*
|
|
8
|
+
* IMPORTS NOTHING, on purpose. @tina4/orm imports it (databaseUrl.ts) and so
|
|
9
|
+
* does @tina4/core (the websocket backplane, the boot log, the dev admin) - a
|
|
10
|
+
* leaf module is the only place both can reach without a cycle.
|
|
11
|
+
*
|
|
12
|
+
* THE RULE
|
|
13
|
+
* - The authority starts after `scheme://`, `scheme:/` or `scheme//`.
|
|
14
|
+
* - Userinfo ends at the LAST `@` on the line; the password starts at the
|
|
15
|
+
* first `:` after the authority start. A `/`, `?` or `#` before that `:`
|
|
16
|
+
* means the text is a path, not a password.
|
|
17
|
+
* - With no `@`, a non-numeric "port" is the password: it is masked to the end
|
|
18
|
+
* of the line, keeping a trailing `?key=value` query.
|
|
19
|
+
* - Parsers refuse a URL without `scheme://`, or whose `@` count differs from
|
|
20
|
+
* what the parser took as userinfo, with a GENERIC message that never
|
|
21
|
+
* echoes the value and never chains an error that does.
|
|
22
|
+
* - Scheme, user and host stay visible, so the line is still useful.
|
|
23
|
+
*
|
|
24
|
+
* Why this replaced the old rules: they cut the authority at the first `/`, `?`
|
|
25
|
+
* or `#`, or split userinfo at the first `@`, so `postgres://u:Pq1/Rs2@h/db`,
|
|
26
|
+
* `postgres:/u:pw@h/db`, `postgres://u:pw` and `postgres://u:pw@h:notaport/db`
|
|
27
|
+
* all printed the password - in redacted log lines, in "invalid URL" errors
|
|
28
|
+
* that named `u:Pq1` as the host, and in driver errors downstream.
|
|
29
|
+
*
|
|
30
|
+
* KNOWN LIMITS (unmaskable by any rule):
|
|
31
|
+
* - A host-less URL whose password is all digits (`postgres://u:123/x`) is a
|
|
32
|
+
* valid URL with port 123, so the digits are shown.
|
|
33
|
+
* - A host-less URL whose password holds an unencoded `@`
|
|
34
|
+
* (`postgres://u:Pq1@Rs2`) is a valid URL whose HOST is `Rs2`; the tail
|
|
35
|
+
* after the `@` is shown as the host.
|
|
36
|
+
* Over-redaction is accepted instead: a second `@` later on the same line
|
|
37
|
+
* (`... failed for admin@corp`) masks up to it, hiding a host, never showing a
|
|
38
|
+
* password.
|
|
39
|
+
*/
|
|
40
|
+
/** The single mask. One spelling, so grepping for it finds every redaction. */
|
|
41
|
+
export declare const REDACTED = "***";
|
|
42
|
+
/**
|
|
43
|
+
* True when the text after a host-less `x:digits` cannot be what follows a
|
|
44
|
+
* port - a `#fragment`, or a `?query` that is not `key=value` pairs - so the
|
|
45
|
+
* digits are the start of a password (`postgres://u:12?Pq1Rs2`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function digitLedPassword(afterPort: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Remove every password from an arbitrary connection string or message.
|
|
50
|
+
*
|
|
51
|
+
* THE single redaction primitive. It works on RAW text - valid or malformed, a
|
|
52
|
+
* URL, an ODBC DSN, or an error message that embeds either - so error paths can
|
|
53
|
+
* use it too. `postgres://u:pw@host/db` becomes `postgres://u:***@host/db`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function redactCredentials(raw: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Like redactCredentials(), but drops the whole userinfo (`user:pass@`) rather
|
|
58
|
+
* than masking the password - for the boot log, which names the database
|
|
59
|
+
* target and nothing about who connects to it.
|
|
60
|
+
*/
|
|
61
|
+
export declare function stripCredentials(raw: string): string;
|
|
@@ -12,22 +12,10 @@
|
|
|
12
12
|
* key, byte-identical in all four.
|
|
13
13
|
*/
|
|
14
14
|
import { inspect } from "node:util";
|
|
15
|
+
import { redactCredentials } from "../../core/src/urlRedaction.js";
|
|
15
16
|
/** The canonical engine names. Aliases resolve to these ONCE, at parse. */
|
|
16
17
|
export type DatabaseEngine = "sqlite" | "postgres" | "mysql" | "mssql" | "firebird" | "mongodb" | "odbc";
|
|
17
|
-
|
|
18
|
-
* Remove every credential from an arbitrary connection string.
|
|
19
|
-
*
|
|
20
|
-
* THE single redaction primitive. It works on a RAW string - valid or
|
|
21
|
-
* malformed, a URL or an ODBC DSN - so the error paths can use it too, and it
|
|
22
|
-
* is what `toSafeString()` calls for the odbc form rather than hand-rolling a
|
|
23
|
-
* second, weaker rule.
|
|
24
|
-
*
|
|
25
|
-
* It cannot be complete on a string with no recognisable credential structure
|
|
26
|
-
* (`notaurl-with-hunter2` has nothing to key off), which is exactly why the
|
|
27
|
-
* invalid-URL error reports the scheme and host instead of any form of the
|
|
28
|
-
* input. Redaction is for strings we can parse enough to redact.
|
|
29
|
-
*/
|
|
30
|
-
export declare function redactCredentials(raw: string): string;
|
|
18
|
+
export { redactCredentials };
|
|
31
19
|
/**
|
|
32
20
|
* DISPLAY REDACTS, FIDELITY DOES NOT. JSON.stringify, util.inspect, String() and
|
|
33
21
|
* toSafeString() replace the password with the redaction marker, so a log line, a
|
|
@@ -109,17 +97,28 @@ export declare class DatabaseUrl {
|
|
|
109
97
|
*/
|
|
110
98
|
private static parseSqlite;
|
|
111
99
|
/**
|
|
112
|
-
* mssql and firebird:
|
|
113
|
-
* matched directly.
|
|
100
|
+
* mssql and firebird: `host[:port]/database`, split by the shared splitter.
|
|
114
101
|
*
|
|
115
|
-
*
|
|
102
|
+
* These used to be one regex each that split userinfo at the FIRST `@` and
|
|
103
|
+
* the password at the first `/`, so `mssql://u:p@ss@h/db` connected to a host
|
|
104
|
+
* named `ss@h` and printed it in the driver's error.
|
|
105
|
+
*
|
|
106
|
+
* The database keeps its own leading slash when the URL had two, which is
|
|
116
107
|
* how the documented absolute Firebird form survives. The old code did
|
|
117
108
|
* `"/" + match[5]`, ADDING a slash - so an absolute path came back with two
|
|
118
109
|
* and a relative path was silently made absolute. Verified against live
|
|
119
110
|
* Firebird 5.0.4: the driver takes one or two leading slashes and rejects a
|
|
120
111
|
* relative path outright.
|
|
121
112
|
*/
|
|
122
|
-
private static
|
|
123
|
-
/**
|
|
113
|
+
private static parsePathForm;
|
|
114
|
+
/**
|
|
115
|
+
* postgres / mysql / mongodb.
|
|
116
|
+
*
|
|
117
|
+
* Userinfo comes from the shared splitter (the last-`@` rule), never from the
|
|
118
|
+
* URL class: `new URL()` cuts a password at its first `/`, `?` or `#`, reads
|
|
119
|
+
* `postgres:/u:pw@h` as a path, and throws a TypeError whose `.input` is the
|
|
120
|
+
* whole URL. The class only sees a credential-free rebuild, for the host,
|
|
121
|
+
* port and path it already normalises the way every corpus row expects.
|
|
122
|
+
*/
|
|
124
123
|
private static parseStandard;
|
|
125
124
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph connection URL parser — the DatabaseUrl sibling for graph engines.
|
|
3
|
+
*
|
|
4
|
+
* Parse a graph connection URL into its parts, the same way DatabaseUrl does for
|
|
5
|
+
* SQL. `engine` is the CANONICAL name the factory selects an adapter by; a scheme
|
|
6
|
+
* alias (bolt/neo4j/memgraph all speak Bolt/Cypher and share ONE adapter) resolves
|
|
7
|
+
* to its engine here. See tina4-documentation/plan/v3/features/139-graph-databases.md.
|
|
8
|
+
*/
|
|
9
|
+
import { inspect } from "node:util";
|
|
1
10
|
/** The canonical graph engine names. */
|
|
2
11
|
export type GraphEngine = "ultipa" | "bolt" | "arango";
|
|
3
12
|
/** A parsed graph URL: engine, host, port, graph, credentials, params. */
|
|
@@ -14,6 +23,15 @@ export declare class GraphUrl {
|
|
|
14
23
|
readonly params: Record<string, string>;
|
|
15
24
|
readonly useTls: boolean;
|
|
16
25
|
constructor(url: string);
|
|
26
|
+
/**
|
|
27
|
+
* What `JSON.stringify` emits, directly or as one field of a logged object.
|
|
28
|
+
* `password` and `raw` both hold the secret, so the default dump printed it
|
|
29
|
+
* twice (GHSA-h2mr-m3v3-cq8c). DatabaseUrl guards the same way; PHP has
|
|
30
|
+
* __debugInfo/jsonSerialize and Ruby a redacted #inspect.
|
|
31
|
+
*/
|
|
32
|
+
toJSON(): Record<string, unknown>;
|
|
33
|
+
/** What `console.log(url)` / `util.inspect(url)` print. */
|
|
34
|
+
[inspect.custom](): string;
|
|
17
35
|
/** host:port/graph — for messages, never carrying credentials. */
|
|
18
36
|
getDsn(): string;
|
|
19
37
|
static fromEnv(envKey?: string): GraphUrl | null;
|