tina4-nodejs 3.13.163 → 3.13.165

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
@@ -14,13 +14,13 @@ Even if the skill text is not currently loaded, these are non-negotiable:
14
14
 
15
15
  The full discipline lives in `.claude/skills/tina4-maintainer/SKILL.md`; this block is the always-on floor.
16
16
 
17
- # CLAUDE.md - AI Developer Guide for tina4-nodejs (v3.13.163)
17
+ # CLAUDE.md - AI Developer Guide for tina4-nodejs (v3.13.165)
18
18
 
19
19
  > This file helps AI assistants (Claude, Copilot, Cursor, etc.) understand and work on this codebase effectively.
20
20
 
21
21
  ## What This Project Is
22
22
 
23
- Tina4 for Node.js/TypeScript v3.13.163 - The Intelligent Native Application 4ramework. A convention-over-configuration structural paradigm. The developer writes TypeScript; Tina4 is invisible infrastructure.
23
+ Tina4 for Node.js/TypeScript v3.13.165 - The Intelligent Native Application 4ramework. A convention-over-configuration structural paradigm. The developer writes TypeScript; Tina4 is invisible infrastructure.
24
24
 
25
25
  The philosophy: zero ceremony, batteries included, file system as source of truth.
26
26
 
@@ -82,9 +82,9 @@ This is an **npm workspaces monorepo**. All packages are in `packages/*`.
82
82
  ## Tech Stack
83
83
 
84
84
  - **Language:** TypeScript (strict mode, ES2022 target, Node16 module resolution)
85
- - **Runtime:** Node.js 20+ (ESM only, `"type": "module"` everywhere)
85
+ - **Runtime:** Node.js 22+ (`engines.node >=22.0.0`; ESM only, `"type": "module"` everywhere)
86
86
  - **HTTP:** Native `node:http` — no Express, no Fastify
87
- - **Database:** SQLite via `node:sqlite` (default), with adapters for Postgres, MySQL, MSSQL/SQL Server, and Firebird
87
+ - **Database:** SQLite via `node:sqlite` (default), with adapters for Postgres, MySQL, MSSQL/SQL Server, Firebird, MongoDB and ODBC
88
88
  - **Templates:** Frond — built-in zero-dependency Twig-compatible engine (`@tina4/frond`)
89
89
  - **Dev tooling:** `tsx` for runtime TS execution, `esbuild` for builds
90
90
  - **Testing:** 267 `*.test.ts` files via `tsx test/run-all.ts`
@@ -163,6 +163,8 @@ Database layer with auto-CRUD generation, seeding, fake data, and SQL translatio
163
163
  - `adapters/mysql.ts` — MySQL adapter
164
164
  - `adapters/mssql.ts` — MSSQL / SQL Server adapter (`mssql` or `sqlserver` scheme)
165
165
  - `adapters/firebird.ts` — Firebird adapter
166
+ - `adapters/mongodb.ts` — MongoDB adapter (SQL translated to MongoDB queries)
167
+ - `adapters/odbc.ts` — ODBC adapter
166
168
  - `model.ts` — Discovers models from `src/models/`, reads `static tableName` and `static fields`
167
169
  - `migration.ts` — Schema sync on startup (creates tables, adds columns, warns on destructive changes)
168
170
  - `autoCrud.ts` — Generates GET/POST/PUT/DELETE route handlers for each model
@@ -210,11 +212,11 @@ Max upload size: `TINA4_MAX_UPLOAD_SIZE` env var (default 10MB).
210
212
  ### Auth
211
213
 
212
214
  ```typescript
213
- // expires_in is in MINUTES (default 60). Reads SECRET from env if not passed.
215
+ // expires_in is in MINUTES (default 60). Reads TINA4_SECRET from env if not passed.
214
216
  getToken(payload, secret?, expiresIn=60): string
215
217
  validToken(token, secret?): Record | null
216
218
  getPayload(token): Record | null
217
- refreshToken(token, expiresIn=60): string | null // reads SECRET from env
219
+ refreshToken(token, expiresIn=60): string | null // reads TINA4_SECRET from env
218
220
  hashPassword(password, salt?, iterations=260000): string // PBKDF2-SHA256, $ delimiter
219
221
  checkPassword(password, hash): boolean // timing-safe
220
222
  validateApiKey(provided, expected?): boolean // reads TINA4_API_KEY from env
@@ -1213,6 +1215,8 @@ No configuration needed — set `TINA4_DEBUG=true` to enable. If you're running
1213
1215
 
1214
1216
  ## Conventions You Must Follow
1215
1217
 
1218
+ - **Pull requests only (ADR-0073)** — Never push directly to `v3` or `main` (or `v2`); work on a feature branch, open a PR, wait for the required checks, then merge. Never force-push or move a tag. A tag publishes, merging never does.
1219
+
1216
1220
  ### Route Files
1217
1221
  - Located in `src/routes/`
1218
1222
  - Filename = HTTP method: `get.ts`, `post.ts`, `put.ts`, `delete.ts`, `patch.ts`
@@ -1267,7 +1271,7 @@ import { Router } from "./router.js"; // .js even though the file is .ts
1267
1271
  3. **Convention-based models** — `static fields = {}` over decorators. No special TypeScript config needed.
1268
1272
  4. **CDN for Swagger UI** — Keeps install under 8MB. Single HTML file loads from jsdelivr.net (the same default across all four frameworks).
1269
1273
  5. **Browser reload, not process restart** — The `tina4` Rust CLI watches `src/`, `migrations/`, `.env` and POSTs `/__dev/api/reload` to the running server. The server stays up; only the browser reloads (via WS on `/__dev_reload`, polling fallback on `GET /__dev/api/mtime`). No ESM HMR gymnastics, no server restart, no framework-side watcher.
1270
- 6. **SQLite default** — `node:sqlite` is synchronous and fast. Full adapters for Postgres, MySQL, MSSQL/SQL Server, and Firebird.
1274
+ 6. **SQLite default** — `node:sqlite` is synchronous and fast. Full adapters for Postgres, MySQL, MSSQL/SQL Server, Firebird, MongoDB and ODBC.
1271
1275
  7. **CLI named `tina4nodejs`** (primary) with `tina4` as alias — So `npx tina4nodejs init` or `npx tina4 init` both work.
1272
1276
  8. **Event system** — Static `Events` class, synchronous dispatch, priority ordering, zero deps.
1273
1277
  9. **Inline testing** — Tests as decorators on functions, no external test runner for unit-level checks.
@@ -1481,7 +1485,7 @@ When adding new features, add a corresponding `test/<feature>.test.ts` file.
1481
1485
  - **Frond template engine optimizations**: pre-compiled regexes, lazy loop context (copy-on-write), filter chain caching, path split caching, inline common filters (11-15% speedup)
1482
1486
  - **Production server auto-detect**: `npx tina4nodejs serve --production` auto-uses cluster mode
1483
1487
  - **`tina4 generate`**: model, route, migration, middleware scaffolding. `tina4nodejs` is the Node package's own CLI; the `tina4` client forwards `generate` to it.
1484
- - **Database**: 5 engines (SQLite, PostgreSQL, MySQL, MSSQL, Firebird), DB query caching — request-scoped auto cache **off by default — opt-in via `TINA4_AUTO_CACHING=true`** (TTL `TINA4_AUTO_CACHING_TTL=5`s) which dedupes identical `db.fetch()`/ORM reads within a request and flushes on writes (always in-process); default OFF because a request-scoped cache defaulting on is a read-after-write footgun (cached pre-write `SELECT MAX(id)` → duplicate PKs); persistent cross-request cache opt-in via `TINA4_DB_CACHE=true` (TTL `TINA4_DB_CACHE_TTL=30`s) routed through the unified async backend set via `TINA4_DB_CACHE_BACKEND` (memory/file/redis/valkey/memcached/mongodb/database) + `TINA4_DB_CACHE_URL`, so instances share one cache with global write-invalidation (full parity with Python/PHP/Ruby). `db.cacheStats()` reports `mode` (request/persistent/off) + `backend`
1488
+ - **Database**: 7 engines (SQLite, PostgreSQL, MySQL, MSSQL, Firebird, MongoDB, ODBC), DB query caching — request-scoped auto cache **off by default — opt-in via `TINA4_AUTO_CACHING=true`** (TTL `TINA4_AUTO_CACHING_TTL=5`s) which dedupes identical `db.fetch()`/ORM reads within a request and flushes on writes (always in-process); default OFF because a request-scoped cache defaulting on is a read-after-write footgun (cached pre-write `SELECT MAX(id)` → duplicate PKs); persistent cross-request cache opt-in via `TINA4_DB_CACHE=true` (TTL `TINA4_DB_CACHE_TTL=30`s) routed through the unified async backend set via `TINA4_DB_CACHE_BACKEND` (memory/file/redis/valkey/memcached/mongodb/database) + `TINA4_DB_CACHE_URL`, so instances share one cache with global write-invalidation (full parity with Python/PHP/Ruby). `db.cacheStats()` reports `mode` (request/persistent/off) + `backend`
1485
1489
  - **Cache**: unified backend set — `memory` (default), `file`, `redis`, `valkey`, `memcached`, `mongodb`, `database` — via `TINA4_CACHE_BACKEND` (+ `TINA4_CACHE_URL`/credentials); file-backend fallback if a backend is unreachable. The KV API, the `responseCache` middleware, and the persistent DB query cache all route through this async backend set (native async clients, no child processes) — a network backend distributes them cross-instance, full parity with Python/PHP/Ruby; `memory` (default) keeps them in-process. `await` the async API (`cacheGet`/`cacheSet`/`clearCache`)
1486
1490
  - **Sessions**: file backend (default). `TINA4_SESSION_SAMESITE` env var (default: Lax)
1487
1491
  - **Queue**: file/RabbitMQ/Kafka/MongoDB backends, configured via env vars. **Reservation/visibility timeout** (file + MongoDB): a popped job is reserved for `TINA4_QUEUE_VISIBILITY_TIMEOUT` seconds (default 300; `visibilityTimeout` Queue option; `<= 0` disables) — if the consumer dies before `complete()`/`fail()`, the next `pop()` reclaims it (incrementing `attempts`, dead-lettering past `maxRetries`), so a crashed/evicted consumer never strands a job. RabbitMQ/Kafka delegate redelivery to the broker.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tina4-nodejs",
3
- "version": "3.13.163",
3
+ "version": "3.13.165",
4
4
  "type": "module",
5
5
  "description": "Tina4 for Node.js/TypeScript - native TypeScript conventions and shared Tina4 contracts",
6
6
  "keywords": [