tina4-nodejs 3.13.85 → 3.13.86

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 CHANGED
@@ -1,10 +1,10 @@
1
- # CLAUDE.md - AI Developer Guide for tina4-nodejs (v3.13.85)
1
+ # CLAUDE.md - AI Developer Guide for tina4-nodejs (v3.13.86)
2
2
 
3
3
  > This file helps AI assistants (Claude, Copilot, Cursor, etc.) understand and work on this codebase effectively.
4
4
 
5
5
  ## What This Project Is
6
6
 
7
- Tina4 for Node.js/TypeScript v3.13.85 - The Intelligent Native Application 4ramework. A convention-over-configuration structural paradigm. The developer writes TypeScript; Tina4 is invisible infrastructure.
7
+ Tina4 for Node.js/TypeScript v3.13.86 - The Intelligent Native Application 4ramework. A convention-over-configuration structural paradigm. The developer writes TypeScript; Tina4 is invisible infrastructure.
8
8
 
9
9
  The philosophy: zero ceremony, batteries included, file system as source of truth.
10
10
 
@@ -232,10 +232,10 @@ Backends: file, redis, redis-npm, valkey, mongodb, database.
232
232
  ### Database extras
233
233
 
234
234
  ```typescript
235
- db.execute(sql, params?): boolean | unknown // RAISES on SQL error (never returns false; cause on getError()); on success: bool for writes, result for RETURNING/CALL/EXEC. try/catch — don't test the return.
236
- db.getLastId(): string | number
237
- db.getError(): string | null
238
- db.cacheStats(): { enabled, size, ttl }
235
+ await db.execute(sql, params?): Promise<boolean | unknown> // ASYNC — await it. RAISES on SQL error (never returns false; cause on getError()); on success: bool for writes, result for RETURNING/CALL/EXEC. try/catch — don't test the return.
236
+ db.getLastId(): string | number // synchronous
237
+ db.getError(): string | null // synchronous
238
+ db.cacheStats(): { enabled, size, ttl } // synchronous
239
239
  ```
240
240
 
241
241
  ### DocStore — pymongo-style document store (zero-config SQLite fallback)
@@ -627,43 +627,49 @@ import { initDatabase, bindDatabase, createAdapterFromUrl, Database, DatabaseRes
627
627
  const db = await initDatabase({ url: "sqlite:///app.db" });
628
628
  // Connection pooling: pass `pool: 4` for round-robin connections.
629
629
 
630
- // Reads synchronous (node:sqlite is sync; other adapters are wrapped)
631
- db.fetch(sql, params?, limit?, offset?): DatabaseResult // .records, .count, .limit, .offset
632
- db.fetchOne<T>(sql, params?): T | null
630
+ // EVERY db method that touches the database is ASYNC on the Database wrapper --
631
+ // it returns a Promise, so `await` it. (The node:sqlite ADAPTER underneath is
632
+ // synchronous, but the wrapper is async so the query cache and the pg/mysql/
633
+ // mssql/firebird adapters share one uniform API.) Only getLastId(), getError()
634
+ // and close() are synchronous.
635
+
636
+ // Reads — async, await them
637
+ await db.fetch(sql, params?, limit?, offset?): Promise<DatabaseResult> // .records, .count, .limit, .offset
638
+ await db.fetchOne<T>(sql, params?): Promise<T | null>
633
639
 
634
640
  // Writes — execute() RAISES on a SQL error (bad SQL, constraint violation,
635
641
  // dead connection, missing driver): it records the cause on getError() then
636
642
  // re-throws — it never swallows and returns false (mirrors fetch()/fetchOne()).
637
- // On SUCCESS it returns boolean for simple writes, the result set for
643
+ // On SUCCESS it resolves to boolean for simple writes, the result set for
638
644
  // RETURNING / CALL / EXEC / SELECT. Callers needing a bool (ORM save(),
639
645
  // createTable(), migration runner, dev-admin/MCP DB tools) try/catch and
640
646
  // convert — they must NOT test the return value for false.
641
- db.execute(sql, params?): boolean | unknown
642
- db.executeMany(sql, paramSets): unknown[] // wrapped in a transaction
643
- db.insert(table, data): DatabaseWriteResult
644
- db.update(table, data, filter?, params?): DatabaseWriteResult
645
- db.delete(table, filter?, params?): DatabaseWriteResult
646
-
647
- // Last-write metadata
648
- db.getLastId(): string | number | null
647
+ await db.execute(sql, params?): Promise<boolean | unknown>
648
+ await db.executeMany(sql, paramSets): Promise<unknown[]> // wrapped in a transaction
649
+ await db.insert(table, data): Promise<DatabaseWriteResult>
650
+ await db.update(table, data, filter?, params?): Promise<DatabaseWriteResult>
651
+ await db.delete(table, filter?, params?): Promise<DatabaseWriteResult>
652
+
653
+ // Last-write metadata — SYNCHRONOUS (no await)
654
+ db.getLastId(): string | number
649
655
  db.getError(): string | null
650
656
 
651
- // Transactions — autoCommit defaults to ON: a standalone write commits on its
652
- // own connection (durable + visible across the pool); inside startTransaction()
653
- // the per-statement commit is suppressed so the transaction stays atomic. Set
654
- // TINA4_AUTOCOMMIT=false for strict manual-commit mode.
655
- db.startTransaction(): void
656
- db.commit(): void
657
- db.rollback(): void
657
+ // Transactions — async (await). autoCommit defaults to ON: a standalone write
658
+ // commits on its own connection (durable + visible across the pool); inside
659
+ // startTransaction() the per-statement commit is suppressed so the transaction
660
+ // stays atomic. Set TINA4_AUTOCOMMIT=false for strict manual-commit mode.
661
+ await db.startTransaction(): Promise<void>
662
+ await db.commit(): Promise<void>
663
+ await db.rollback(): Promise<void>
658
664
 
659
- // Schema introspection
660
- db.tableExists(name): boolean
661
- db.getTables(): string[]
662
- db.getColumns(table): { name, type, nullable?, default?, primaryKey? }[]
665
+ // Schema introspection — async (await)
666
+ await db.tableExists(name): Promise<boolean>
667
+ await db.getTables(): Promise<string[]>
668
+ await db.getColumns(table): Promise<{ name, type, nullable?, default?, primaryKey? }[]>
663
669
 
664
- // Race-safe sequence — uses tina4_sequences for SQLite/MySQL/MSSQL,
670
+ // Race-safe sequence — async (await). Uses tina4_sequences for SQLite/MySQL/MSSQL,
665
671
  // auto-creates Postgres sequences, and uses native Firebird generators.
666
- db.getNextId(table, pkColumn?, generatorName?): number
672
+ await db.getNextId(table, pkColumn?, generatorName?): Promise<number>
667
673
 
668
674
  // DB query cache — request-scoped auto cache is OFF by default (opt-in via
669
675
  // TINA4_AUTO_CACHING=true, TTL TINA4_AUTO_CACHING_TTL=5s): when enabled it dedupes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tina4-nodejs",
3
- "version": "3.13.85",
3
+ "version": "3.13.86",
4
4
  "type": "module",
5
5
  "description": "Tina4 for Node.js/TypeScript - 54 built-in features, zero dependencies",
6
6
  "keywords": [
@@ -26,10 +26,26 @@
26
26
  "main": "packages/core/dist/index.js",
27
27
  "types": "packages/core/src/index.ts",
28
28
  "exports": {
29
- ".": "./packages/core/src/index.ts",
30
- "./orm": "./packages/orm/src/index.ts",
31
- "./swagger": "./packages/swagger/src/index.ts",
32
- "./frond": "./packages/frond/src/engine.ts"
29
+ ".": {
30
+ "types": "./packages/core/src/index.ts",
31
+ "import": "./packages/core/dist/index.js",
32
+ "default": "./packages/core/dist/index.js"
33
+ },
34
+ "./orm": {
35
+ "types": "./packages/orm/src/index.ts",
36
+ "import": "./packages/orm/dist/index.js",
37
+ "default": "./packages/orm/dist/index.js"
38
+ },
39
+ "./swagger": {
40
+ "types": "./packages/swagger/src/index.ts",
41
+ "import": "./packages/swagger/dist/index.js",
42
+ "default": "./packages/swagger/dist/index.js"
43
+ },
44
+ "./frond": {
45
+ "types": "./packages/frond/src/engine.ts",
46
+ "import": "./packages/frond/dist/index.js",
47
+ "default": "./packages/frond/dist/index.js"
48
+ }
33
49
  },
34
50
  "files": [
35
51
  "packages/frond/dist/**/*",
@@ -58,6 +74,7 @@
58
74
  "scripts": {
59
75
  "build": "npm run build --workspaces",
60
76
  "clean": "rm -rf packages/*/dist",
77
+ "pretest": "npm run build",
61
78
  "test": "tsx test/run-all.ts && npm run test:i18n",
62
79
  "test:i18n": "vitest run test/i18n.test.ts test/i18n-leaf-alias.test.ts",
63
80
  "typecheck": "tsc -p tsconfig.typecheck.json",