tina4-nodejs 3.13.162 → 3.13.164
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 -8
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +413 -177
- package/packages/cli/src/bin.ts +8 -3
- package/packages/cli/src/commands/test.ts +2 -2
- package/packages/core/dist/index.js +381 -172
- package/packages/core/src/devAdmin.ts +8 -3
- package/packages/core/src/index.ts +1 -1
- package/packages/core/src/mcp.ts +10 -4
- package/packages/core/src/portTakeover.ts +44 -10
- package/packages/core/src/queueBackends/kafkaBackend.ts +56 -10
- package/packages/core/src/server.ts +79 -5
- package/packages/core/src/testing.ts +181 -69
- package/packages/frond/dist/index.js +66 -19
- package/packages/frond/src/engine.ts +74 -23
- package/packages/orm/dist/index.js +380 -172
- package/types/core/src/index.d.ts +1 -1
- package/types/core/src/mcp.d.ts +2 -2
- package/types/core/src/portTakeover.d.ts +3 -1
- package/types/core/src/testing.d.ts +27 -4
- package/types/frond/src/engine.d.ts +31 -2
|
@@ -80,7 +80,7 @@ export { MongoSessionHandler } from "./sessionHandlers/mongoHandler.js";
|
|
|
80
80
|
export type { MongoSessionConfig } from "./sessionHandlers/mongoHandler.js";
|
|
81
81
|
export { ValkeySessionHandler } from "./sessionHandlers/valkeyHandler.js";
|
|
82
82
|
export type { ValkeySessionConfig } from "./sessionHandlers/valkeyHandler.js";
|
|
83
|
-
export { tests, expectEqual, expectRaises, expectTrue, expectFalse, runAll, reset } from "./testing.js";
|
|
83
|
+
export { tests, expectEqual, expectRaises, expectTrue, expectFalse, runAll, runAllAsync, reset } from "./testing.js";
|
|
84
84
|
export { TestClient, TestResponse } from "./testClient.js";
|
|
85
85
|
export { Tina4Test, AssertionError as Tina4AssertionError } from "./test.js";
|
|
86
86
|
export type { TestRunResults } from "./test.js";
|
package/types/core/src/mcp.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface McpResourceDefinition {
|
|
|
21
21
|
name: string;
|
|
22
22
|
description: string;
|
|
23
23
|
mimeType: string;
|
|
24
|
-
handler: () => unknown
|
|
24
|
+
handler: () => unknown | Promise<unknown>;
|
|
25
25
|
}
|
|
26
26
|
export interface JsonSchema {
|
|
27
27
|
type: string;
|
|
@@ -179,7 +179,7 @@ export declare class McpServer {
|
|
|
179
179
|
*/
|
|
180
180
|
sseStream(sessionId: string, endpointUrl: string, keepaliveMs?: number): AsyncGenerator<string>;
|
|
181
181
|
registerTool(name: string, handler: (args: Record<string, unknown>) => unknown, description?: string, schema?: JsonSchema): void;
|
|
182
|
-
registerResource(uri: string, handler: () => unknown
|
|
182
|
+
registerResource(uri: string, handler: () => unknown | Promise<unknown>, description?: string, mimeType?: string): void;
|
|
183
183
|
handleMessage(rawData: string | Record<string, unknown>): Promise<string>;
|
|
184
184
|
private _handleInitialize;
|
|
185
185
|
private _handleInitialized;
|
|
@@ -46,5 +46,7 @@ export declare function removePidfile(port: number, baseDir?: string): void;
|
|
|
46
46
|
* guarded path for both the CLI (`tina4 serve`) and the runtime bind-failure
|
|
47
47
|
* fallback. `dev`/`noTakeover` are passed in so this stays pure and directly
|
|
48
48
|
* testable; callers resolve them from isDev() / noTakeoverOptedOut().
|
|
49
|
+
* Before a bind, the caller passes the `host` it will bind, so a free port is
|
|
50
|
+
* reported as nothing rather than refused as "in use".
|
|
49
51
|
*/
|
|
50
|
-
export declare function takeOverPort(port: number, dev: boolean, noTakeover: boolean, baseDir?: string, grace?: number): TakeoverResult;
|
|
52
|
+
export declare function takeOverPort(port: number, dev: boolean, noTakeover: boolean, baseDir?: string, grace?: number, host?: string): TakeoverResult;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* return a + b;
|
|
14
14
|
* });
|
|
15
15
|
*
|
|
16
|
-
* runAll();
|
|
16
|
+
* runAll(); // synchronous test functions
|
|
17
|
+
* await runAllAsync(); // async test functions (awaited, with a timeout)
|
|
17
18
|
*
|
|
18
19
|
* The builders are named expect* — DESCRIPTORS that record an expectation for the
|
|
19
20
|
* runner — deliberately distinct from the xUnit assert* on Tina4Test (test.ts),
|
|
@@ -52,11 +53,33 @@ export declare function expectFalse(args: unknown[]): Assertion;
|
|
|
52
53
|
* const myFn = tests(assertEqual([1,2], 3))(function myFn(a,b) { return a+b; });
|
|
53
54
|
*/
|
|
54
55
|
export declare function tests(...assertions: Assertion[]): <T extends (...args: unknown[]) => unknown>(fn: T) => T;
|
|
55
|
-
|
|
56
|
-
export declare function runAll(options?: {
|
|
56
|
+
interface RunOptions {
|
|
57
57
|
quiet?: boolean;
|
|
58
58
|
failfast?: boolean;
|
|
59
|
-
}
|
|
59
|
+
}
|
|
60
|
+
interface AsyncRunOptions extends RunOptions {
|
|
61
|
+
/** Per-call limit in milliseconds for an async test function (default 30000). */
|
|
62
|
+
timeoutMs?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Run all registered tests synchronously. Returns the results summary.
|
|
66
|
+
*
|
|
67
|
+
* A test function that returns a Promise (an async function) cannot be judged
|
|
68
|
+
* here: its result is not known yet. It is reported as an ERROR naming
|
|
69
|
+
* `runAllAsync()`, never as a pass. Use `await runAllAsync()` for async tests.
|
|
70
|
+
*/
|
|
71
|
+
export declare function runAll(options?: RunOptions): TestResults;
|
|
72
|
+
/**
|
|
73
|
+
* Run all registered tests, awaiting each test function. Resolves to the
|
|
74
|
+
* results summary.
|
|
75
|
+
*
|
|
76
|
+
* An async function is judged on what it resolves to or rejects with. A call
|
|
77
|
+
* that has not settled after `timeoutMs` (default 30000) is reported as an
|
|
78
|
+
* error, so one stuck test cannot hang the run. `timeoutMs: Infinity` turns the
|
|
79
|
+
* timeout off; any other value must be a positive number of milliseconds no
|
|
80
|
+
* larger than 2147483647 (the largest delay a Node timer accepts).
|
|
81
|
+
*/
|
|
82
|
+
export declare function runAllAsync(options?: AsyncRunOptions): Promise<TestResults>;
|
|
60
83
|
/** Reset the test registry (useful between test runs). */
|
|
61
84
|
export declare function reset(): void;
|
|
62
85
|
export {};
|
|
@@ -90,23 +90,28 @@ export declare class Frond {
|
|
|
90
90
|
private static classFilters;
|
|
91
91
|
private static classGlobals;
|
|
92
92
|
private static classTests;
|
|
93
|
+
private static classRegistryVersion;
|
|
93
94
|
private static liveFragments;
|
|
94
95
|
private static liveSources;
|
|
95
96
|
private static liveWsPaths;
|
|
96
97
|
private static liveBroadcaster;
|
|
97
98
|
/**
|
|
98
99
|
* Register a custom filter at the class level — available to every
|
|
99
|
-
*
|
|
100
|
+
* instance, existing ones included: an engine merges the class filters
|
|
101
|
+
* again at its next render (ADR-0107). Callable as ``Frond.addFilter()``
|
|
100
102
|
* (static) or ``frond.addFilter()`` (instance). See instance method
|
|
101
103
|
* below for the dual-call semantics.
|
|
102
104
|
*/
|
|
103
105
|
static addFilter(name: string, fn: FilterFn): void;
|
|
104
106
|
/**
|
|
105
107
|
* Register a global variable available in all templates of every
|
|
106
|
-
*
|
|
108
|
+
* instance, existing ones included: class globals are read at render time
|
|
109
|
+
* (ADR-0106). Callable as ``Frond.addGlobal()`` (static) or
|
|
107
110
|
* ``frond.addGlobal()`` (instance).
|
|
108
111
|
*/
|
|
109
112
|
static addGlobal(name: string, value: unknown): void;
|
|
113
|
+
/** True when a class-level global with this name is registered. */
|
|
114
|
+
static hasGlobal(name: string): boolean;
|
|
110
115
|
/**
|
|
111
116
|
* Register a custom test (``{% if x is positive %}``) at the class
|
|
112
117
|
* level. Callable as ``Frond.addTest()`` (static) or
|
|
@@ -121,8 +126,17 @@ export declare class Frond {
|
|
|
121
126
|
*/
|
|
122
127
|
static clearRegistry(): void;
|
|
123
128
|
private templateDir;
|
|
129
|
+
/** Effective filters: built-in < class < instance (see syncRegistries). */
|
|
124
130
|
private filters;
|
|
131
|
+
/** Filters / tests registered on THIS instance only (ADR-0052). */
|
|
132
|
+
private localFilters;
|
|
133
|
+
private localTests;
|
|
134
|
+
/** The class-registry version `filters` / `tests` were last merged at. */
|
|
135
|
+
private registryVersion;
|
|
136
|
+
/** Globals registered on THIS instance only (ADR-0052). */
|
|
125
137
|
private globals;
|
|
138
|
+
/** Built-in globals (formToken, range, dump, csp_nonce, ...). */
|
|
139
|
+
private builtinGlobals;
|
|
126
140
|
private tests;
|
|
127
141
|
private _sandbox;
|
|
128
142
|
private _allowedFilters;
|
|
@@ -149,6 +163,13 @@ export declare class Frond {
|
|
|
149
163
|
private readonly _applyFiltersBound;
|
|
150
164
|
getTemplateDir(): string;
|
|
151
165
|
constructor(templateDir?: string);
|
|
166
|
+
/**
|
|
167
|
+
* Rebuild the merged filter/test maps when the class registry changed.
|
|
168
|
+
* Same layering as globals -- built-ins < class < this instance. Filter
|
|
169
|
+
* lookup is on the hot path, so the merge is a plain object rebuilt only
|
|
170
|
+
* when the class-registry version moves, never a per-lookup chain.
|
|
171
|
+
*/
|
|
172
|
+
private syncRegistries;
|
|
152
173
|
sandbox(filters?: string[], tags?: string[], vars?: string[]): Frond;
|
|
153
174
|
unsandbox(): Frond;
|
|
154
175
|
/**
|
|
@@ -172,6 +193,14 @@ export declare class Frond {
|
|
|
172
193
|
* isn't a reliable freshness signal.
|
|
173
194
|
*/
|
|
174
195
|
private cacheTtlSeconds;
|
|
196
|
+
/**
|
|
197
|
+
* Layer the globals under the render data: built-ins < class globals (read
|
|
198
|
+
* live, so registration order never matters) < this instance's own globals
|
|
199
|
+
* < the data passed to render(). Every render starts here, so this is also
|
|
200
|
+
* where the filter/test maps catch up with any class registration made
|
|
201
|
+
* since the last render.
|
|
202
|
+
*/
|
|
203
|
+
private withGlobals;
|
|
175
204
|
render(template: string, data?: Record<string, unknown>): string;
|
|
176
205
|
renderString(source: string, data?: Record<string, unknown>): string;
|
|
177
206
|
/** Clear all compiled template caches. */
|