tina4-nodejs 3.13.132 → 3.13.134
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 +4 -3
- package/README.md +2 -2
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +3415 -3251
- package/packages/cli/src/commands/generate.ts +33 -22
- package/packages/cli/src/commands/lint.ts +77 -111
- package/packages/core/dist/index.js +3241 -3069
- package/packages/core/src/.tina4-metrics.json +15004 -0
- package/packages/core/src/aiClient.ts +199 -161
- package/packages/core/src/dispatchPipeline.ts +65 -67
- package/packages/core/src/docs.ts +52 -544
- package/packages/core/src/docsParser.ts +270 -0
- package/packages/core/src/docsScanner.ts +121 -0
- package/packages/core/src/docsSignatures.ts +165 -0
- package/packages/core/src/index.ts +2 -0
- package/packages/core/src/logger.ts +68 -82
- package/packages/core/src/mcp.ts +32 -60
- package/packages/core/src/messenger.ts +136 -157
- package/packages/core/src/middleware.ts +56 -60
- package/packages/core/src/plan.ts +78 -70
- package/packages/core/src/projectIndex.ts +15 -288
- package/packages/core/src/projectIndexExtractors.ts +126 -0
- package/packages/core/src/projectIndexStorage.ts +122 -0
- package/packages/core/src/push.ts +281 -0
- package/packages/core/src/server.ts +182 -183
- package/packages/frond/dist/index.js +607 -770
- package/packages/frond/src/engine.ts +670 -818
- package/packages/orm/dist/index.js +3334 -3165
- package/packages/orm/src/adapters/mongodb.ts +99 -144
- package/packages/orm/src/baseModel.ts +429 -515
- package/packages/orm/src/fakeData.ts +73 -61
- package/packages/orm/src/migration.ts +96 -126
- package/packages/orm/src/seeder.ts +6 -238
- package/packages/orm/src/seederTable.ts +101 -0
- package/packages/orm/src/seederTypes.ts +14 -0
- package/packages/orm/src/validation.ts +97 -80
- package/packages/swagger/dist/index.js +150 -116
- package/packages/swagger/src/generator.ts +261 -154
- package/types/core/src/aiClient.d.ts +5 -0
- package/types/core/src/docsParser.d.ts +28 -0
- package/types/core/src/docsScanner.d.ts +1 -0
- package/types/core/src/docsSignatures.d.ts +11 -0
- package/types/core/src/index.d.ts +2 -0
- package/types/core/src/messenger.d.ts +8 -0
- package/types/core/src/projectIndexExtractors.d.ts +3 -0
- package/types/core/src/projectIndexStorage.d.ts +13 -0
- package/types/core/src/push.d.ts +45 -0
- package/types/frond/src/engine.d.ts +25 -0
- package/types/orm/src/fakeData.d.ts +3 -0
- package/types/orm/src/seeder.d.ts +3 -89
- package/types/orm/src/seederTable.d.ts +9 -0
- package/types/orm/src/seederTypes.d.ts +16 -0
|
@@ -97,6 +97,7 @@ export declare class Frond {
|
|
|
97
97
|
private _allowedVars;
|
|
98
98
|
private fragmentCache;
|
|
99
99
|
private _autoEscape;
|
|
100
|
+
private readonly blockHandlers;
|
|
100
101
|
/**
|
|
101
102
|
* Token pre-compilation cache for file templates.
|
|
102
103
|
*
|
|
@@ -188,6 +189,10 @@ export declare class Frond {
|
|
|
188
189
|
*/
|
|
189
190
|
private substituteBlocks;
|
|
190
191
|
private renderWithBlocks;
|
|
192
|
+
private dispatchBlock;
|
|
193
|
+
private renderTextToken;
|
|
194
|
+
private renderVarToken;
|
|
195
|
+
private renderBlockToken;
|
|
191
196
|
private renderTokens;
|
|
192
197
|
/**
|
|
193
198
|
* May this filter RUN under the current sandbox?
|
|
@@ -206,6 +211,7 @@ export declare class Frond {
|
|
|
206
211
|
* instead of the four names that happened to be checked individually.
|
|
207
212
|
*/
|
|
208
213
|
private tagPermitted;
|
|
214
|
+
private applyFilterValue;
|
|
209
215
|
/**
|
|
210
216
|
* Consume a denied tag WITHOUT running it, returning the index past its body.
|
|
211
217
|
*
|
|
@@ -228,8 +234,22 @@ export declare class Frond {
|
|
|
228
234
|
private applyFilters;
|
|
229
235
|
private evalVar;
|
|
230
236
|
private evalVarRaw;
|
|
237
|
+
/**
|
|
238
|
+
* Apply the no-argument filters that are common enough to avoid generic
|
|
239
|
+
* dispatch. Keeping this table separate from evalVarInner makes the
|
|
240
|
+
* expression pipeline easier to audit without changing filter order.
|
|
241
|
+
*/
|
|
242
|
+
private applyFastFilter;
|
|
243
|
+
private applyRenderedFilter;
|
|
244
|
+
private variablePermitted;
|
|
245
|
+
private resolveConcatenation;
|
|
246
|
+
private applyRenderedFilters;
|
|
231
247
|
private evalVarInner;
|
|
248
|
+
private pushIfBranch;
|
|
249
|
+
private collectIfBranches;
|
|
232
250
|
private handleIf;
|
|
251
|
+
private collectForTokens;
|
|
252
|
+
private forItems;
|
|
233
253
|
private handleFor;
|
|
234
254
|
private handleSet;
|
|
235
255
|
private handleInclude;
|
|
@@ -257,6 +277,8 @@ export declare class Frond {
|
|
|
257
277
|
*/
|
|
258
278
|
private handleImportAs;
|
|
259
279
|
private handleFromImport;
|
|
280
|
+
private collectMacroDefinitions;
|
|
281
|
+
private createMacro;
|
|
260
282
|
/**
|
|
261
283
|
* Collect the body tokens of a {% <openTag> %}...{% end<openTag> %} block,
|
|
262
284
|
* starting from the token after the opening tag (start + 1). Nested same-tag
|
|
@@ -279,6 +301,9 @@ export declare class Frond {
|
|
|
279
301
|
* Python master's _handle_live and PHP/Ruby handleLive.
|
|
280
302
|
*/
|
|
281
303
|
private handleLive;
|
|
304
|
+
private parseLiveOptions;
|
|
305
|
+
private collectLiveBody;
|
|
306
|
+
private liveAttributes;
|
|
282
307
|
/**
|
|
283
308
|
* Re-render a registered {% live %} fragment by name with fresh data.
|
|
284
309
|
* Returns the rendered HTML, or null if no fragment is registered under that
|
|
@@ -19,6 +19,9 @@ export declare class FakeData extends CoreFakeData {
|
|
|
19
19
|
* Matches the Python API's datetime() method.
|
|
20
20
|
*/
|
|
21
21
|
datetime(startYear?: number, endYear?: number): Date;
|
|
22
|
+
private heuristicValue;
|
|
23
|
+
private stringValue;
|
|
24
|
+
private typedValue;
|
|
22
25
|
/**
|
|
23
26
|
* Generate a fake value appropriate for an ORM field definition.
|
|
24
27
|
* Respects min/max, minLength/maxLength, and type constraints.
|
|
@@ -1,92 +1,7 @@
|
|
|
1
|
-
import { FakeData } from "./fakeData.js";
|
|
2
1
|
import type { DatabaseAdapter, FieldDefinition } from "./types.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* `errors` is a list of `{ row, message }` describing every skipped row
|
|
7
|
-
* (`row` is the 0-based index). Mirrors the Python `SeedSummary`; Node tests
|
|
8
|
-
* compare `.seeded` / `.failed` rather than the bare integer.
|
|
9
|
-
*/
|
|
10
|
-
export interface SeedSummary {
|
|
11
|
-
seeded: number;
|
|
12
|
-
failed: number;
|
|
13
|
-
errors: Array<{
|
|
14
|
-
row: number;
|
|
15
|
-
message: string;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
18
|
-
/** Options shared by seedTable / seedOrm / seedModels. */
|
|
19
|
-
export interface SeedOptions {
|
|
20
|
-
/** Static values applied to every row (overrides generated values). */
|
|
21
|
-
overrides?: Record<string, unknown>;
|
|
22
|
-
/** Delete every existing row in the target before seeding (P2). */
|
|
23
|
-
clear?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* PRNG seed for reproducible FakeData output (P3). Honoured by seedOrm and
|
|
26
|
-
* seedModels, which build and seed their own FakeData internally.
|
|
27
|
-
*
|
|
28
|
-
* NOT honoured by seedTable (SEED-TABLE-SEED-INERT, SEED-DEC-01, ratified
|
|
29
|
-
* 2026-08-11 — same principle as the no-op ForeignKeyField on_delete):
|
|
30
|
-
* seedTable has no generators of its own to seed — fieldMap callables are
|
|
31
|
-
* opaque — so this used to be a silent no-op there. Passing it to seedTable
|
|
32
|
-
* now THROWS instead. Build your own `new FakeData(seed)` and close over it
|
|
33
|
-
* in fieldMap: `const fake = new FakeData(42); seedTable(db, table, count,
|
|
34
|
-
* { name: () => fake.name() })`.
|
|
35
|
-
*/
|
|
36
|
-
seed?: number;
|
|
37
|
-
/** Re-raise on the first failed row instead of skipping it (P1). */
|
|
38
|
-
strict?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Introspect `table`'s columns and build a column->generator field map for
|
|
42
|
-
* {@link seedTable}, skipping the auto-increment / `id` primary key (the engine
|
|
43
|
-
* assigns it). Mirrors the Python master's `auto_field_map`
|
|
44
|
-
* (tina4_python/seeder/__init__.py): the shared "seed a table I did not
|
|
45
|
-
* hand-write generators for" helper that both the dev-admin seed endpoint and
|
|
46
|
-
* the MCP `seed_table` dev tool use — `seedTable` itself stays explicit
|
|
47
|
-
* (no map = no rows), and this is how a caller opts into automatic generation.
|
|
48
|
-
*
|
|
49
|
-
* Reuses `FakeData.forField()` (column-name + type heuristics) so the generated
|
|
50
|
-
* data matches every other Tina4 seeding path. Returns an empty map when the
|
|
51
|
-
* table has no seedable columns, so `seedTable` then seeds nothing rather than
|
|
52
|
-
* crashing.
|
|
53
|
-
*
|
|
54
|
-
* @param db - A DatabaseAdapter instance (pass `getAdapter()`, NOT the Database
|
|
55
|
-
* wrapper — the wrapper has no `columns()`).
|
|
56
|
-
* @param table - The table to introspect.
|
|
57
|
-
* @param fake - Optional shared FakeData (pass one seeded via `new FakeData(n)`
|
|
58
|
-
* for reproducible output).
|
|
59
|
-
* @returns `{ column -> () => value }`, ready to hand to `seedTable`.
|
|
60
|
-
*/
|
|
61
|
-
export declare function autoFieldMap(db: DatabaseAdapter, table: string, fake?: FakeData): Promise<Record<string, () => unknown>>;
|
|
62
|
-
/**
|
|
63
|
-
* Seed a database table with fake data using raw SQL inserts.
|
|
64
|
-
*
|
|
65
|
-
* Visible-but-resilient (P1): each row is wrapped. On a row failure the cause
|
|
66
|
-
* is logged (with the row index) and the row is skipped — unless `strict: true`,
|
|
67
|
-
* in which case the first failure RE-RAISES. At the end a one-line summary is
|
|
68
|
-
* logged ("seeded N, M failed").
|
|
69
|
-
*
|
|
70
|
-
* @param db - A DatabaseAdapter instance
|
|
71
|
-
* @param tableName - The table to insert into
|
|
72
|
-
* @param count - Number of rows to insert (default 10)
|
|
73
|
-
* @param fieldMap - Dict of column_name -> callable that generates a value
|
|
74
|
-
* (or a static value). If not provided, no rows are inserted.
|
|
75
|
-
* @param overrides - (legacy positional) Static values applied to every row.
|
|
76
|
-
* Prefer `opts.overrides`.
|
|
77
|
-
* @param opts - Seed options: `{ overrides, clear, strict }`. `opts.seed` is
|
|
78
|
-
* NOT honoured here (see {@link SeedOptions.seed}) and throws if supplied.
|
|
79
|
-
* @returns A SeedSummary `{ seeded, failed, errors }`.
|
|
80
|
-
* @throws {Error} If `opts.seed` is defined (SEED-TABLE-SEED-INERT removal).
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* const fake = new FakeData();
|
|
84
|
-
* await seedTable(db, "users", 50, {
|
|
85
|
-
* name: () => fake.name(),
|
|
86
|
-
* email: () => fake.email(),
|
|
87
|
-
* }, undefined, { clear: true });
|
|
88
|
-
*/
|
|
89
|
-
export declare function seedTable(db: DatabaseAdapter, tableName: string, count?: number, fieldMap?: Record<string, (() => unknown) | unknown>, overrides?: Record<string, unknown>, opts?: SeedOptions): Promise<SeedSummary>;
|
|
2
|
+
import type { SeedOptions, SeedSummary } from "./seederTypes.js";
|
|
3
|
+
export { autoFieldMap, seedTable } from "./seederTable.js";
|
|
4
|
+
export type { SeedOptions, SeedSummary } from "./seederTypes.js";
|
|
90
5
|
/** A model-like shape the seeder can drive (real BaseModel subclass or mock). */
|
|
91
6
|
interface SeedableModel {
|
|
92
7
|
tableName: string;
|
|
@@ -128,4 +43,3 @@ export declare function seedOrm(ormClass: SeedableModel, count?: number, overrid
|
|
|
128
43
|
export declare function seedModels(ormClasses: SeedableModel[], count?: number, opts?: SeedOptions & {
|
|
129
44
|
overrides?: Record<string, unknown> | Map<SeedableModel, Record<string, unknown>>;
|
|
130
45
|
}): Promise<Record<string, SeedSummary>>;
|
|
131
|
-
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FakeData } from "./fakeData.js";
|
|
2
|
+
import type { DatabaseAdapter } from "./types.js";
|
|
3
|
+
import type { SeedOptions, SeedSummary } from "./seederTypes.js";
|
|
4
|
+
/** Delete every row, logging but not hiding a clear failure. */
|
|
5
|
+
export declare function clearTable(db: DatabaseAdapter, tableName: string): Promise<void>;
|
|
6
|
+
/** Build generators from live table metadata for the explicit seedTable path. */
|
|
7
|
+
export declare function autoFieldMap(db: DatabaseAdapter, table: string, fake?: FakeData): Promise<Record<string, () => unknown>>;
|
|
8
|
+
/** Seed a table through the adapter insert path, counting or re-raising row failures. */
|
|
9
|
+
export declare function seedTable(db: DatabaseAdapter, tableName: string, count?: number, fieldMap?: Record<string, (() => unknown) | unknown>, overrides?: Record<string, unknown>, opts?: SeedOptions): Promise<SeedSummary>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Result of a seed run. */
|
|
2
|
+
export interface SeedSummary {
|
|
3
|
+
seeded: number;
|
|
4
|
+
failed: number;
|
|
5
|
+
errors: Array<{
|
|
6
|
+
row: number;
|
|
7
|
+
message: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/** Options shared by the table and ORM seed paths. */
|
|
11
|
+
export interface SeedOptions {
|
|
12
|
+
overrides?: Record<string, unknown>;
|
|
13
|
+
clear?: boolean;
|
|
14
|
+
seed?: number;
|
|
15
|
+
strict?: boolean;
|
|
16
|
+
}
|