tina4-nodejs 3.13.133 → 3.13.135

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.
Files changed (52) hide show
  1. package/CLAUDE.md +3 -3
  2. package/README.md +2 -2
  3. package/package.json +1 -1
  4. package/packages/cli/dist/bin.js +3213 -3062
  5. package/packages/cli/src/commands/generate.ts +33 -22
  6. package/packages/cli/src/commands/lint.ts +77 -111
  7. package/packages/core/dist/index.js +3122 -2963
  8. package/packages/core/src/.tina4-metrics.json +15004 -0
  9. package/packages/core/src/aiClient.ts +199 -161
  10. package/packages/core/src/devAdmin.ts +46 -14
  11. package/packages/core/src/dispatchPipeline.ts +65 -67
  12. package/packages/core/src/docs.ts +52 -544
  13. package/packages/core/src/docsParser.ts +270 -0
  14. package/packages/core/src/docsScanner.ts +121 -0
  15. package/packages/core/src/docsSignatures.ts +165 -0
  16. package/packages/core/src/index.ts +2 -0
  17. package/packages/core/src/logger.ts +68 -82
  18. package/packages/core/src/mcp.ts +32 -60
  19. package/packages/core/src/messenger.ts +136 -157
  20. package/packages/core/src/middleware.ts +56 -60
  21. package/packages/core/src/plan.ts +78 -70
  22. package/packages/core/src/projectIndex.ts +15 -288
  23. package/packages/core/src/projectIndexExtractors.ts +126 -0
  24. package/packages/core/src/projectIndexStorage.ts +122 -0
  25. package/packages/core/src/push.ts +293 -0
  26. package/packages/core/src/server.ts +187 -183
  27. package/packages/frond/dist/index.js +607 -770
  28. package/packages/frond/src/engine.ts +670 -818
  29. package/packages/orm/dist/index.js +3132 -2976
  30. package/packages/orm/src/adapters/mongodb.ts +99 -144
  31. package/packages/orm/src/baseModel.ts +429 -515
  32. package/packages/orm/src/fakeData.ts +73 -61
  33. package/packages/orm/src/migration.ts +96 -126
  34. package/packages/orm/src/seeder.ts +6 -238
  35. package/packages/orm/src/seederTable.ts +101 -0
  36. package/packages/orm/src/seederTypes.ts +14 -0
  37. package/packages/orm/src/validation.ts +97 -80
  38. package/types/core/src/aiClient.d.ts +5 -0
  39. package/types/core/src/devAdmin.d.ts +23 -1
  40. package/types/core/src/docsParser.d.ts +28 -0
  41. package/types/core/src/docsScanner.d.ts +1 -0
  42. package/types/core/src/docsSignatures.d.ts +11 -0
  43. package/types/core/src/index.d.ts +2 -0
  44. package/types/core/src/messenger.d.ts +8 -0
  45. package/types/core/src/projectIndexExtractors.d.ts +3 -0
  46. package/types/core/src/projectIndexStorage.d.ts +13 -0
  47. package/types/core/src/push.d.ts +45 -0
  48. package/types/frond/src/engine.d.ts +25 -0
  49. package/types/orm/src/fakeData.d.ts +3 -0
  50. package/types/orm/src/seeder.d.ts +3 -89
  51. package/types/orm/src/seederTable.d.ts +9 -0
  52. package/types/orm/src/seederTypes.d.ts +16 -0
@@ -1,92 +1,7 @@
1
- import { FakeData } from "./fakeData.js";
2
1
  import type { DatabaseAdapter, FieldDefinition } from "./types.js";
3
- /**
4
- * Result of a seed run — `{ seeded, failed, errors }`.
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
+ }