@chromav/sizzler 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Stop bikeshedding IDs, timestamps, and foreign keys. Define your schema, seed your database, and get back to building.
6
6
 
7
7
  ```typescript
8
- import { primaryKey, foreignKey, createdAt, updatedAt, table, text, enums } from "sizzler";
8
+ import { primaryKey, foreignKey, createdAt, updatedAt, table, text, enums } from "@chromav/sizzler";
9
9
 
10
10
  const status = ["pending", "in_progress", "done"] as const;
11
11
 
@@ -42,10 +42,10 @@ Every factory returns a standard Drizzle column builder. Chain `.notNull()`, `.u
42
42
 
43
43
  ### 2. Local dev helpers
44
44
 
45
- The `sizzler/node` entry point gets you connected and seeded fast:
45
+ The `@chromav/sizzler/node` entry point gets you connected and seeded fast:
46
46
 
47
47
  ```typescript
48
- import { computeD1Filename, getLocalD1Path, createJSONSeeder, resetDatabase } from "sizzler/node";
48
+ import { computeD1Filename, getLocalD1Path, createJSONSeeder, resetDatabase } from "@chromav/sizzler/node";
49
49
 
50
50
  // Compute the exact filename miniflare uses for a D1 database
51
51
  const filename = computeD1Filename("3c9d1256-e9bd-4617-ad46-22315915a680");
@@ -69,12 +69,12 @@ No more hunting for SQLite files in `.wrangler/`. No more reverse-engineering mi
69
69
 
70
70
  ### 3. Golden snapshots
71
71
 
72
- Also on `sizzler/node`: helpers for creating and restoring self-contained SQLite
72
+ Also on `@chromav/sizzler/node`: helpers for creating and restoring self-contained SQLite
73
73
  "golden" snapshots — the foundation of fast, reproducible E2E tests (build the DB
74
74
  once, restore the file per run instead of migrating + seeding every time).
75
75
 
76
76
  ```typescript
77
- import { createSnapshot, restoreSnapshot } from "sizzler/node";
77
+ import { createSnapshot, restoreSnapshot } from "@chromav/sizzler/node";
78
78
 
79
79
  // Create a golden snapshot from a live DB: checkpoints the WAL into the main
80
80
  // file (so the .sqlite is self-contained), copies it, and verifies it has data.
@@ -105,7 +105,7 @@ file to snapshot or restore.
105
105
  ## Installation
106
106
 
107
107
  ```bash
108
- npm install sizzler drizzle-orm
108
+ npm install @chromav/sizzler drizzle-orm
109
109
  ```
110
110
 
111
111
  ## The boilerplate it replaces
@@ -133,7 +133,7 @@ export const tasks = sqliteTable("tasks", {
133
133
  **After:**
134
134
 
135
135
  ```typescript
136
- import { primaryKey, foreignKey, createdAt, updatedAt, table, text, enums } from "sizzler";
136
+ import { primaryKey, foreignKey, createdAt, updatedAt, table, text, enums } from "@chromav/sizzler";
137
137
 
138
138
  const status = ["pending", "in_progress", "done"] as const;
139
139
 
@@ -1 +1 @@
1
- {"version":3,"file":"foreign-key.d.ts","sourceRoot":"","sources":["../../src/columns/foreign-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAGjC,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,SAAS,GAAG,MAAM,GAAG,MAAM,EAC9D,MAAM,MAAM,EACZ,KAAK,YAAY,EACjB,OAAM,CAAe,EACrB,UAAU,YAAY,KACrB,CAAC,SAAS,SAAS,GAAG,oBAAoB,GAAG,iBAAiB,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAKzC,CAAC"}
1
+ {"version":3,"file":"foreign-key.d.ts","sourceRoot":"","sources":["../../src/columns/foreign-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAGjC,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,SAAS,GAAG,MAAM,GAAG,MAAM,QACxD,MAAM,OACP,YAAY,SACX,CAAC,YACG,YAAY,KACrB,CAAC,SAAS,SAAS,GAAG,oBAAoB,GAAG,iBAAiB,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAKzC,CAAC"}
@@ -1,10 +1,11 @@
1
- import { index as sqliteIndex, integer as sqliteInteger, real as sqliteReal, text as sqliteText } from "drizzle-orm/sqlite-core";
1
+ import { index as sqliteIndex, integer as sqliteInteger, real as sqliteReal, text as sqliteText, uniqueIndex as sqliteUniqueIndex } from "drizzle-orm/sqlite-core";
2
2
  type EnumValues = readonly [string, ...string[]];
3
3
  export declare const table: import("drizzle-orm/sqlite-core").SQLiteTableFn<undefined>;
4
4
  export declare const index: typeof sqliteIndex;
5
5
  export declare const integer: typeof sqliteInteger;
6
6
  export declare const real: typeof sqliteReal;
7
7
  export declare const text: typeof sqliteText;
8
+ export declare const uniqueIndex: typeof sqliteUniqueIndex;
8
9
  /**
9
10
  * Creates a boolean column stored as integer (0/1).
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/columns/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,WAAW,EACpB,OAAO,IAAI,aAAa,EACxB,IAAI,IAAI,UAAU,EAElB,IAAI,IAAI,UAAU,EACnB,MAAM,yBAAyB,CAAC;AAEjC,KAAK,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAGjD,eAAO,MAAM,KAAK,4DAAc,CAAC;AACjC,eAAO,MAAM,KAAK,oBAAc,CAAC;AACjC,eAAO,MAAM,OAAO,sBAAgB,CAAC;AACrC,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;;GAeG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,GAAG,MAAM,EAAE,QAAQ,MAAM,4FAA4C,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { foreignKey } from "./foreign-key";
2
- export { boolean, enums, index, integer, jsonArray, real, table, text, } from "./helpers";
2
+ export { boolean, enums, index, integer, jsonArray, real, table, text, uniqueIndex, } from "./helpers";
3
3
  export { primaryKey } from "./primary-key";
4
4
  export { createdAt, timestamp, timestamp_ms, updatedAt } from "./timestamps";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/columns/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,IAAI,EAEJ,KAAK,EACL,IAAI,GACL,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/columns/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,IAAI,EAEJ,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"primary-key.d.ts","sourceRoot":"","sources":["../../src/columns/primary-key.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GAAI,aAAW,6NAIT,CAAC"}
1
+ {"version":3,"file":"primary-key.d.ts","sourceRoot":"","sources":["../../src/columns/primary-key.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,6OAIM,CAAC"}
@@ -45,13 +45,28 @@ export declare const timestamp_ms: (columnName: string) => import("drizzle-orm/s
45
45
  */
46
46
  export declare const createdAt: () => import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/sqlite-core").SQLiteTimestampBuilder>>;
47
47
  /**
48
- * Creates an updated_at timestamp column with automatic default.
49
- * Uses SQLite's unixepoch() for the default value.
48
+ * Creates an updated_at timestamp column that maintains itself.
50
49
  *
51
- * Note: Auto-update on modification requires application-level handling
52
- * or a database trigger.
50
+ * `unixepoch()` supplies the value on INSERT; `$onUpdate` re-stamps it on every
51
+ * UPDATE. The `$onUpdate` half matters more than it looks: drizzle applies it in
52
+ * `buildUpdateSet` at the **dialect** layer, so it fires for every `.update().set()`
53
+ * — ORM helpers, hand-written statements, and anything inside `db.batch()` alike.
54
+ * There is no code path that silently skips it, which is the point: without it the
55
+ * column is insert-time-only and freezes at `created_at` for the life of the row.
53
56
  *
54
- * @returns A non-null timestamp column defaulting to current time
57
+ * `$onUpdate` is runtime-only and invisible to drizzle-kit, so adding it needs no
58
+ * migration.
59
+ *
60
+ * **Opting out of one write.** A caller-supplied value wins (drizzle only applies
61
+ * `onUpdateFn` when the column is absent from `set`), so a write that must NOT
62
+ * count as a modification — acquiring a lock, bookkeeping — can hold the column
63
+ * still by setting it to itself:
64
+ *
65
+ * ```ts
66
+ * db.update(tasks).set({ lockedAt: now, updatedAt: sql`updated_at` })
67
+ * ```
68
+ *
69
+ * @returns A non-null timestamp column defaulting to, and refreshed with, current time
55
70
  *
56
71
  * @example
57
72
  * ```ts
@@ -61,5 +76,5 @@ export declare const createdAt: () => import("drizzle-orm").HasDefault<import("d
61
76
  * });
62
77
  * ```
63
78
  */
64
- export declare const updatedAt: () => import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/sqlite-core").SQLiteTimestampBuilder>>;
79
+ export declare const updatedAt: () => import("drizzle-orm").HasDefault<import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/sqlite-core").SQLiteTimestampBuilder>>>;
65
80
  //# sourceMappingURL=timestamps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timestamps.d.ts","sourceRoot":"","sources":["../../src/columns/timestamps.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,GAAI,YAAY,MAAM,6DAA+C,CAAC;AAE5F;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,GAAI,YAAY,MAAM,6DAAkD,CAAC;AAElG;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,iIAAsE,CAAC;AAE7F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,iIAAsE,CAAC"}
1
+ {"version":3,"file":"timestamps.d.ts","sourceRoot":"","sources":["../../src/columns/timestamps.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,eAAgB,MAAM,6DAA+C,CAAC;AAE5F;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,6DAAkD,CAAC;AAElG;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,iIAAsE,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,SAAS,mKAIU,CAAC"}
package/dist/index.d.ts CHANGED
@@ -27,5 +27,5 @@
27
27
  * });
28
28
  * ```
29
29
  */
30
- export { boolean, createdAt, enums, foreignKey, index, integer, jsonArray, primaryKey, real, table, text, timestamp, timestamp_ms, updatedAt, } from "./columns";
30
+ export { boolean, createdAt, enums, foreignKey, index, integer, jsonArray, primaryKey, real, table, text, timestamp, timestamp_ms, uniqueIndex, updatedAt, } from "./columns";
31
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EACL,OAAO,EACP,SAAS,EACT,KAAK,EACL,UAAU,EACV,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,IAAI,EAEJ,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,GACV,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EACL,OAAO,EACP,SAAS,EACT,KAAK,EACL,UAAU,EACV,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,IAAI,EAEJ,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,GACV,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -8,13 +8,15 @@ import {
8
8
  integer as sqliteInteger,
9
9
  real as sqliteReal,
10
10
  sqliteTable,
11
- text as sqliteText
11
+ text as sqliteText,
12
+ uniqueIndex as sqliteUniqueIndex
12
13
  } from "drizzle-orm/sqlite-core";
13
14
  var table = sqliteTable;
14
15
  var index = sqliteIndex;
15
16
  var integer2 = sqliteInteger;
16
17
  var real = sqliteReal;
17
18
  var text2 = sqliteText;
19
+ var uniqueIndex = sqliteUniqueIndex;
18
20
  var boolean = (name) => integer2(name, { mode: "boolean" });
19
21
  var enums = (name, values, defaultValue) => text2(name, {
20
22
  enum: values
@@ -32,7 +34,7 @@ import { integer as integer3 } from "drizzle-orm/sqlite-core";
32
34
  var timestamp = (columnName) => integer3(columnName, { mode: "timestamp" });
33
35
  var timestamp_ms = (columnName) => integer3(columnName, { mode: "timestamp_ms" });
34
36
  var createdAt = () => timestamp("created_at").notNull().default(sql`(unixepoch())`);
35
- var updatedAt = () => timestamp("updated_at").notNull().default(sql`(unixepoch())`);
37
+ var updatedAt = () => timestamp("updated_at").notNull().default(sql`(unixepoch())`).$onUpdate(() => /* @__PURE__ */ new Date());
36
38
  export {
37
39
  boolean,
38
40
  createdAt,
@@ -47,5 +49,6 @@ export {
47
49
  text2 as text,
48
50
  timestamp,
49
51
  timestamp_ms,
52
+ uniqueIndex,
50
53
  updatedAt
51
54
  };
@@ -1 +1 @@
1
- {"version":3,"file":"wrangler-config.d.ts","sourceRoot":"","sources":["../../../src/node/connection/wrangler-config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,GAAE,MAAsB,GAAG,cAAc,CA4CvF"}
1
+ {"version":3,"file":"wrangler-config.d.ts","sourceRoot":"","sources":["../../../src/node/connection/wrangler-config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,GAAE,MAAsB,GAAG,cAAc,CAevF"}
@@ -1 +1 @@
1
- {"version":3,"file":"json-seeder.d.ts","sourceRoot":"","sources":["../../../src/node/seeding/json-seeder.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC;CAC5D;AAyBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB;eAMvC,CAAC,0BAA0B,MAAM,KAAG,CAAC;wBAW5B,CAAC,0BAA0B,MAAM,KAAG,CAAC,EAAE;+BAUhC,MAAM,KAAG,OAAO;EASnD;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;;;;;;OAUG;6BACsB,MAAM,EAAE,4BACY,OAAO,KAAK,OAAO;IAOhE;;;;;;;;;;OAUG;+BACwB,MAAM,EAAE,4BACU,OAAO,KAAK,OAAO;CAMjE,CAAC"}
1
+ {"version":3,"file":"json-seeder.d.ts","sourceRoot":"","sources":["../../../src/node/seeding/json-seeder.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC;CAC5D;AAyBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB;eAMvC,CAAC,0BAA0B,MAAM,KAAG,CAAC;wBAW5B,CAAC,0BAA0B,MAAM,KAAG,CAAC,EAAE;+BAUhC,MAAM,KAAG,OAAO;EASnD;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;;;;;;OAUG;IACH,UAAU,eAAe,MAAM,EAAE,4BACY,OAAO,KAAK,OAAO;IAOhE;;;;;;;;;;OAUG;IACH,YAAY,eAAe,MAAM,EAAE,4BACU,OAAO,KAAK,OAAO;CAMjE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
1
+ import type { SQLiteAsyncDatabase } from "drizzle-orm/sqlite-core";
2
2
  /**
3
3
  * Reset database with enhanced error handling and logging.
4
4
  * Requires explicit confirmation to prevent accidental data loss.
@@ -17,7 +17,7 @@ import type { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
17
17
  * });
18
18
  * ```
19
19
  */
20
- export declare function resetDatabase(db: BaseSQLiteDatabase<"sync" | "async", unknown>, schema: Record<string, unknown>, options?: {
20
+ export declare function resetDatabase(db: SQLiteAsyncDatabase<"sync" | "async", unknown>, schema: Record<string, unknown>, options?: {
21
21
  confirm?: boolean;
22
22
  verbose?: boolean;
23
23
  logger?: {
@@ -1 +1 @@
1
- {"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/node/seeding/reset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,kBAAkB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,CAAC,EACjD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;CAChF,iBAwBP"}
1
+ {"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/node/seeding/reset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,mBAAmB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,CAAC,EAClD,MAAM,EAAE,MAAM,C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AAE,cAAc,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,IAAI,CA+BpH"}
package/dist/node.js CHANGED
@@ -14,30 +14,45 @@ function parseWranglerConfig(projectRoot = process.cwd()) {
14
14
  wranglerPath = join(projectRoot, "wrangler.jsonc");
15
15
  }
16
16
  const content = readFileSync(wranglerPath, "utf8");
17
- const cleanedContent = content.split("\n").map((line) => {
18
- let inString = false;
19
- let escaped = false;
20
- for (let i = 0; i < line.length; i++) {
21
- const char = line[i];
22
- if (escaped) {
23
- escaped = false;
24
- continue;
25
- }
26
- if (char === "\\" && inString) {
27
- escaped = true;
17
+ const cleanedContent = stripJsonComments(content).replaceAll(/,(\s*[}\]])/g, "$1");
18
+ return JSON.parse(cleanedContent);
19
+ }
20
+ function stripJsonComments(content) {
21
+ let out = "";
22
+ let inString = false;
23
+ let i = 0;
24
+ while (i < content.length) {
25
+ const char = content[i];
26
+ const next = content[i + 1];
27
+ if (inString) {
28
+ out += char;
29
+ if (char === "\\") {
30
+ out += next ?? "";
31
+ i += 2;
28
32
  continue;
29
33
  }
30
34
  if (char === '"') {
31
- inString = !inString;
32
- continue;
33
- }
34
- if (!inString && line.substring(i, i + 2) === "//") {
35
- return line.slice(0, i).trim();
35
+ inString = false;
36
36
  }
37
+ i++;
38
+ continue;
37
39
  }
38
- return line;
39
- }).join("\n").replace(/\/\*[\s\S]*?\*\//g, "").replace(/,(\s*[}\]])/g, "$1");
40
- return JSON.parse(cleanedContent);
40
+ if (char === '"') {
41
+ inString = true;
42
+ out += char;
43
+ i++;
44
+ } else if (char === "/" && next === "/") {
45
+ const newline = content.indexOf("\n", i);
46
+ i = newline === -1 ? content.length : newline;
47
+ } else if (char === "/" && next === "*") {
48
+ const close = content.indexOf("*/", i + 2);
49
+ i = close === -1 ? content.length : close + 2;
50
+ } else {
51
+ out += char;
52
+ i++;
53
+ }
54
+ }
55
+ return out;
41
56
  }
42
57
 
43
58
  // src/node/connection/d1-helpers.ts
@@ -241,7 +256,9 @@ function verifySnapshot(snapshotPath, countQuery) {
241
256
  }
242
257
  function removeOldSnapshot(snapshotPath) {
243
258
  const dir = dirname(snapshotPath);
244
- if (!existsSync(dir)) mkdirSync2(dir, { recursive: true });
259
+ if (!existsSync(dir)) {
260
+ mkdirSync2(dir, { recursive: true });
261
+ }
245
262
  if (existsSync(snapshotPath)) {
246
263
  rmSync(snapshotPath, { force: true });
247
264
  removeWalFiles(snapshotPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chromav/sizzler",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Sizzling column factories and utilities for Drizzle ORM with SQLite, D1, and Turso",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,10 +45,10 @@
45
45
  "devDependencies": {
46
46
  "@types/better-sqlite3": "^7.6.13",
47
47
  "better-sqlite3": "^12.0.0",
48
- "drizzle-orm": "1.0.0-beta.22",
49
- "drizzle-seed": "^1.0.0-beta.22",
48
+ "drizzle-orm": "1.0.0-rc.5-ab785fc",
49
+ "drizzle-seed": "1.0.0-rc.5-ab785fc",
50
50
  "tsup": "^8.5.1",
51
- "typescript": "^6.0.3",
51
+ "typescript": "^7.0.2",
52
52
  "vitest": "^4.1.5"
53
53
  },
54
54
  "keywords": [