tina4-nodejs 3.10.23 → 3.10.30

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.10.23)
1
+ # CLAUDE.md — AI Developer Guide for tina4-nodejs (v3.10.24)
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.10.23 — a convention-over-configuration structural paradigm. **Not a framework.** The developer writes TypeScript; Tina4 is invisible infrastructure.
7
+ Tina4 for Node.js/TypeScript v3.10.24 — a convention-over-configuration structural paradigm. **Not a framework.** 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
 
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </p>
4
4
 
5
5
  <h1 align="center">Tina4 Node.js</h1>
6
- <h3 align="center">This is not a framework</h3>
6
+ <h3 align="center">This Is Now A 4Framework</h3>
7
7
 
8
8
  <p align="center">
9
9
  Laravel joy. TypeScript speed. 10x less code. Zero third-party dependencies.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tina4-nodejs",
3
- "version": "3.10.23",
3
+ "version": "3.10.30",
4
4
  "type": "module",
5
5
  "description": "This is not a framework. Tina4 for Node.js/TypeScript — zero deps, 38 built-in features.",
6
6
  "keywords": ["tina4", "framework", "web", "api", "orm", "graphql", "websocket", "typescript"],
@@ -20,7 +20,7 @@ import { isTruthy } from "./dotenv.js";
20
20
 
21
21
  const cpuCount = osCpus().length;
22
22
 
23
- const TINA4_VERSION = "3.0.0";
23
+ const TINA4_VERSION = "3.10.30";
24
24
 
25
25
  // ---------------------------------------------------------------------------
26
26
  // Types
@@ -29,7 +29,7 @@ const BUILTIN_ERROR_TEMPLATES_DIR = resolve(__dirname, "..", "templates");
29
29
  /** Built-in public directory for framework-bundled static assets. */
30
30
  const BUILTIN_PUBLIC_DIR = resolve(__dirname, "..", "public");
31
31
 
32
- const TINA4_VERSION = "3.0.0";
32
+ const TINA4_VERSION = "3.10.30";
33
33
 
34
34
  /** Cache Frond instances by template directory to avoid repeated instantiation. */
35
35
  const frondCache = new Map<string, InstanceType<any>>();
@@ -1172,20 +1172,16 @@ export class Frond {
1172
1172
  }
1173
1173
 
1174
1174
  const debugMode = (process.env.TINA4_DEBUG || "").toLowerCase() === "true";
1175
- const cached = this.compiled.get(template);
1176
1175
 
1177
- if (cached) {
1178
- if (debugMode) {
1179
- // Dev mode: check if file changed
1180
- const mtime = statSync(filePath).mtimeMs;
1181
- if (cached.mtime === mtime) {
1182
- return this.executeCached(cached.tokens, context);
1183
- }
1184
- } else {
1185
- // Production: skip mtime check, cache is permanent
1176
+ if (!debugMode) {
1177
+ // Production: use permanent cache (no filesystem checks)
1178
+ const cached = this.compiled.get(template);
1179
+ if (cached) {
1186
1180
  return this.executeCached(cached.tokens, context);
1187
1181
  }
1188
1182
  }
1183
+ // Dev mode: skip cache entirely — always re-read and re-tokenize
1184
+ // so edits to partials and extended base templates are detected
1189
1185
 
1190
1186
  // Cache miss — load, tokenize, cache
1191
1187
  const source = readFileSync(filePath, "utf-8");
@@ -236,37 +236,43 @@ export class BaseModel {
236
236
  const pkValue = this[pk];
237
237
  this._relCache = {}; // Clear relationship cache on save
238
238
 
239
- if (pkValue !== undefined && pkValue !== null) {
240
- // Update
241
- const updateFields = Object.entries(ModelClass.fields).filter(
242
- ([name, def]) => !def.primaryKey && this[name] !== undefined,
243
- );
244
- if (updateFields.length === 0) return;
245
-
246
- const setClause = updateFields.map(([k]) => `"${ModelClass.getDbColumn(k)}" = ?`).join(", ");
247
- const values = [...updateFields.map(([k]) => this[k]), pkValue];
248
-
249
- db.execute(`UPDATE "${ModelClass.tableName}" SET ${setClause} WHERE "${pkCol}" = ?`, values);
250
- } else {
251
- // Insert
252
- const insertFields = Object.entries(ModelClass.fields).filter(
253
- ([name, def]) => !(def.primaryKey && def.autoIncrement) && this[name] !== undefined,
254
- );
255
-
256
- const columns = insertFields.map(([k]) => `"${ModelClass.getDbColumn(k)}"`).join(", ");
257
- const placeholders = insertFields.map(() => "?").join(", ");
258
- const values = insertFields.map(([k]) => this[k]);
259
-
260
- const result = db.execute(
261
- `INSERT INTO "${ModelClass.tableName}" (${columns}) VALUES (${placeholders})`,
262
- values,
263
- ) as { lastInsertRowid?: number };
264
-
265
- if (result.lastInsertRowid) {
266
- this[pk] = result.lastInsertRowid;
239
+ db.startTransaction();
240
+ try {
241
+ if (pkValue !== undefined && pkValue !== null) {
242
+ // Update
243
+ const updateFields = Object.entries(ModelClass.fields).filter(
244
+ ([name, def]) => !def.primaryKey && this[name] !== undefined,
245
+ );
246
+ if (updateFields.length === 0) { db.commit(); return; }
247
+
248
+ const setClause = updateFields.map(([k]) => `"${ModelClass.getDbColumn(k)}" = ?`).join(", ");
249
+ const values = [...updateFields.map(([k]) => this[k]), pkValue];
250
+
251
+ db.execute(`UPDATE "${ModelClass.tableName}" SET ${setClause} WHERE "${pkCol}" = ?`, values);
252
+ } else {
253
+ // Insert
254
+ const insertFields = Object.entries(ModelClass.fields).filter(
255
+ ([name, def]) => !(def.primaryKey && def.autoIncrement) && this[name] !== undefined,
256
+ );
257
+
258
+ const columns = insertFields.map(([k]) => `"${ModelClass.getDbColumn(k)}"`).join(", ");
259
+ const placeholders = insertFields.map(() => "?").join(", ");
260
+ const values = insertFields.map(([k]) => this[k]);
261
+
262
+ const result = db.execute(
263
+ `INSERT INTO "${ModelClass.tableName}" (${columns}) VALUES (${placeholders})`,
264
+ values,
265
+ ) as { lastInsertRowid?: number };
266
+
267
+ if (result.lastInsertRowid) {
268
+ this[pk] = result.lastInsertRowid;
269
+ }
267
270
  }
271
+ db.commit();
272
+ } catch (e) {
273
+ db.rollback();
274
+ throw e;
268
275
  }
269
- db.commit();
270
276
  }
271
277
 
272
278
  /**
@@ -283,19 +289,25 @@ export class BaseModel {
283
289
  throw new Error("Cannot delete a model without a primary key value");
284
290
  }
285
291
 
286
- if (ModelClass.softDelete) {
287
- db.execute(
288
- `UPDATE "${ModelClass.tableName}" SET is_deleted = 1 WHERE "${pkCol}" = ?`,
289
- [pkValue],
290
- );
291
- this.is_deleted = 1;
292
- } else {
293
- db.execute(
294
- `DELETE FROM "${ModelClass.tableName}" WHERE "${pkCol}" = ?`,
295
- [pkValue],
296
- );
292
+ db.startTransaction();
293
+ try {
294
+ if (ModelClass.softDelete) {
295
+ db.execute(
296
+ `UPDATE "${ModelClass.tableName}" SET is_deleted = 1 WHERE "${pkCol}" = ?`,
297
+ [pkValue],
298
+ );
299
+ this.is_deleted = 1;
300
+ } else {
301
+ db.execute(
302
+ `DELETE FROM "${ModelClass.tableName}" WHERE "${pkCol}" = ?`,
303
+ [pkValue],
304
+ );
305
+ }
306
+ db.commit();
307
+ } catch (e) {
308
+ db.rollback();
309
+ throw e;
297
310
  }
298
- db.commit();
299
311
  }
300
312
 
301
313
  /**
@@ -459,9 +471,15 @@ export class BaseModel {
459
471
  }
460
472
 
461
473
  const sql = `CREATE TABLE IF NOT EXISTS "${this.tableName}" (${colDefs.join(", ")})`;
462
- db.execute(sql);
474
+ db.startTransaction();
475
+ try {
476
+ db.execute(sql);
477
+ db.commit();
478
+ } catch (e) {
479
+ db.rollback();
480
+ throw e;
481
+ }
463
482
  }
464
- db.commit();
465
483
  }
466
484
 
467
485
  /**
@@ -504,11 +522,17 @@ export class BaseModel {
504
522
  throw new Error("Cannot delete a model without a primary key value");
505
523
  }
506
524
 
507
- db.execute(
508
- `DELETE FROM "${ModelClass.tableName}" WHERE "${pkCol}" = ?`,
509
- [pkValue],
510
- );
511
- db.commit();
525
+ db.startTransaction();
526
+ try {
527
+ db.execute(
528
+ `DELETE FROM "${ModelClass.tableName}" WHERE "${pkCol}" = ?`,
529
+ [pkValue],
530
+ );
531
+ db.commit();
532
+ } catch (e) {
533
+ db.rollback();
534
+ throw e;
535
+ }
512
536
  }
513
537
 
514
538
  /**
@@ -529,11 +553,17 @@ export class BaseModel {
529
553
  throw new Error("Cannot restore a model without a primary key value");
530
554
  }
531
555
 
532
- db.execute(
533
- `UPDATE "${ModelClass.tableName}" SET is_deleted = 0 WHERE "${pkCol}" = ?`,
534
- [pkValue],
535
- );
536
- db.commit();
556
+ db.startTransaction();
557
+ try {
558
+ db.execute(
559
+ `UPDATE "${ModelClass.tableName}" SET is_deleted = 0 WHERE "${pkCol}" = ?`,
560
+ [pkValue],
561
+ );
562
+ db.commit();
563
+ } catch (e) {
564
+ db.rollback();
565
+ throw e;
566
+ }
537
567
  this.is_deleted = 0;
538
568
  }
539
569