@storyshelf/db-sqlite 0.10.0-next-4a042db → 0.10.0-next-7df132f

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.
@@ -37,7 +37,7 @@ function createBetterSqlite3Database(options) {
37
37
  const adapter = createDrizzleAdapter(db, {
38
38
  metadata: {
39
39
  name: "better-sqlite3",
40
- version: "0.10.0-next-4a042db",
40
+ version: "0.10.0-next-7df132f",
41
41
  description: "better-sqlite3 database adapter (native + Drizzle)",
42
42
  kind: "better-sqlite3",
43
43
  category: "database"
@@ -37,7 +37,7 @@ function createBunSqliteDatabase(options) {
37
37
  const adapter = createDrizzleAdapter(db, {
38
38
  metadata: {
39
39
  name: "Bun SQLite",
40
- version: "0.10.0-next-4a042db",
40
+ version: "0.10.0-next-7df132f",
41
41
  description: "Bun SQLite database adapter (bun:sqlite + Drizzle)",
42
42
  kind: "bun-sqlite",
43
43
  category: "database"
package/dist/d1.mjs CHANGED
@@ -22,7 +22,7 @@ function createD1Database(options) {
22
22
  return createDrizzleAdapter(db, {
23
23
  metadata: {
24
24
  name: "Cloudflare D1",
25
- version: "0.10.0-next-4a042db",
25
+ version: "0.10.0-next-7df132f",
26
26
  description: "Cloudflare D1 database adapter (D1 binding + Drizzle)",
27
27
  kind: "d1",
28
28
  category: "database",
package/dist/index.mjs CHANGED
@@ -27,7 +27,7 @@ function createSqliteDatabase(path) {
27
27
  return createDrizzleAdapter(db, {
28
28
  metadata: {
29
29
  name: "SQLite",
30
- version: "0.10.0-next-4a042db",
30
+ version: "0.10.0-next-7df132f",
31
31
  description: "SQLite database adapter (node:sqlite + Drizzle)",
32
32
  kind: "sqlite",
33
33
  category: "database"
@@ -11,21 +11,35 @@ const BUILD_REVIEW_COLUMNS = [
11
11
  "body",
12
12
  "created_at"
13
13
  ];
14
- /** Integer columns the upgrade adds; one that exists with another type was made by hand. */
14
+ /** Integer columns the upgrade adds (`run_a11y` is the accessibility switch); one that exists with another type was made by hand. */
15
15
  const INTEGER_COLUMNS = [
16
16
  ["projects", "review_enabled"],
17
17
  ["projects", "review_approvals"],
18
18
  ["builds", "review_cycle"],
19
- ["builds", "review_requested_cycle"]
19
+ ["builds", "review_requested_cycle"],
20
+ ["projects", "run_a11y"]
20
21
  ];
22
+ /** SQLite's own rule (datatype3): a declared type containing `INT` has integer affinity (`TINYINT`, `BIGINT`, ...). */
23
+ function hasIntegerAffinity(type) {
24
+ return type.includes("INT");
25
+ }
26
+ /** SQLite's own rule: a declared type containing `CHAR`, `CLOB` or `TEXT` has text affinity (`VARCHAR`, ...). */
27
+ function hasTextAffinity(type) {
28
+ return [
29
+ "CHAR",
30
+ "CLOB",
31
+ "TEXT"
32
+ ].some((part) => type.includes(part));
33
+ }
21
34
  function conflict(what) {
22
- return /* @__PURE__ */ new Error(`Cannot upgrade the review schema: ${what}. It was not created by StoryShelf; rename or drop it (keep a backup) and start again.`);
35
+ return /* @__PURE__ */ new Error(`Cannot upgrade the schema: ${what}. It was not created by StoryShelf; rename or drop it (keep a backup) and start again.`);
23
36
  }
24
37
  /** The tables the check looks at. */
25
38
  const REVIEW_TABLES = [
26
39
  "projects",
27
40
  "builds",
28
- "build_reviews"
41
+ "build_reviews",
42
+ "snapshots"
29
43
  ];
30
44
  /** Throw when `build_reviews` or a review column already exists in a shape the upgrade cannot use. */
31
45
  function assertReviewColumns(tables) {
@@ -36,8 +50,14 @@ function assertReviewColumns(tables) {
36
50
  }
37
51
  for (const [table, column] of INTEGER_COLUMNS) {
38
52
  const type = tables.get(table)?.get(column);
39
- if (type !== void 0 && !type.startsWith("INT")) throw conflict(`column ${table}.${column} has type ${type}, expected INTEGER`);
53
+ if (type !== void 0 && !hasIntegerAffinity(type)) throw conflict(`column ${table}.${column} has type ${type}, expected INTEGER`);
40
54
  }
55
+ assertFindingsColumn(tables);
56
+ }
57
+ /** `snapshots.a11y_violations` holds the stored axe findings as TEXT. */
58
+ function assertFindingsColumn(tables) {
59
+ const violations = tables.get("snapshots")?.get("a11y_violations");
60
+ if (violations !== void 0 && !hasTextAffinity(violations)) throw conflict(`column snapshots.a11y_violations has type ${violations}, expected TEXT`);
41
61
  }
42
62
  /**
43
63
  * Read the review tables through the preset's own reader, then check them. A reader that cannot
@@ -1 +1 @@
1
- {"version":3,"file":"review-schema-check.mjs","names":[],"sources":["../src/review-schema-check.ts"],"sourcesContent":["/**\n * Refuse an upgrade that cannot adopt a review table or column made outside StoryShelf, with an\n * error that names the table and column instead of a raw driver message.\n */\nimport type { TableColumns, TableInfoReader } from \"./table-info.ts\";\n\n/** Columns the review code needs in `build_reviews`. */\nconst BUILD_REVIEW_COLUMNS = [\"id\", \"build_id\", \"user_id\", \"verdict\", \"body\", \"created_at\"];\n\n/** Integer columns the upgrade adds; one that exists with another type was made by hand. */\nconst INTEGER_COLUMNS = [\n [\"projects\", \"review_enabled\"],\n [\"projects\", \"review_approvals\"],\n [\"builds\", \"review_cycle\"],\n [\"builds\", \"review_requested_cycle\"],\n] as const;\n\nfunction conflict(what: string): Error {\n return new Error(\n `Cannot upgrade the review schema: ${what}. It was not created by StoryShelf; rename or drop it (keep a backup) and start again.`,\n );\n}\n\n/** The tables the check looks at. */\nconst REVIEW_TABLES = [\"projects\", \"builds\", \"build_reviews\"];\n\n/** Throw when `build_reviews` or a review column already exists in a shape the upgrade cannot use. */\nexport function assertReviewColumns(tables: ReadonlyMap<string, TableColumns>): void {\n const reviews = tables.get(\"build_reviews\") ?? new Map<string, string>();\n if (reviews.size > 0) {\n const missing = BUILD_REVIEW_COLUMNS.find((column) => !reviews.has(column));\n if (missing !== undefined) {\n throw conflict(`table build_reviews has no column ${missing}`);\n }\n }\n for (const [table, column] of INTEGER_COLUMNS) {\n const type = tables.get(table)?.get(column);\n if (type !== undefined && !type.startsWith(\"INT\")) {\n throw conflict(`column ${table}.${column} has type ${type}, expected INTEGER`);\n }\n }\n}\n\n/**\n * Read the review tables through the preset's own reader, then check them. A reader that cannot\n * serve `PRAGMA` (a binding that refuses it) is the preset's to handle: it returns no columns, which\n * passes, so the check never blocks a database it cannot see.\n */\nexport async function assertReviewSchema(read: TableInfoReader): Promise<void> {\n const columns = await Promise.all(REVIEW_TABLES.map(async (table) => await read(table)));\n assertReviewColumns(\n new Map(REVIEW_TABLES.map((table, index) => [table, columns[index] ?? new Map()])),\n );\n}\n"],"mappings":";;;;;AAOA,MAAM,uBAAuB;CAAC;CAAM;CAAY;CAAW;CAAW;CAAQ;AAAY;;AAG1F,MAAM,kBAAkB;CACtB,CAAC,YAAY,gBAAgB;CAC7B,CAAC,YAAY,kBAAkB;CAC/B,CAAC,UAAU,cAAc;CACzB,CAAC,UAAU,wBAAwB;AACrC;AAEA,SAAS,SAAS,MAAqB;CACrC,uBAAO,IAAI,MACT,qCAAqC,KAAK,uFAC5C;AACF;;AAGA,MAAM,gBAAgB;CAAC;CAAY;CAAU;AAAe;;AAG5D,SAAgB,oBAAoB,QAAiD;CACnF,MAAM,UAAU,OAAO,IAAI,eAAe,qBAAK,IAAI,IAAoB;CACvE,IAAI,QAAQ,OAAO,GAAG;EACpB,MAAM,UAAU,qBAAqB,MAAM,WAAW,CAAC,QAAQ,IAAI,MAAM,CAAC;EAC1E,IAAI,YAAY,KAAA,GACd,MAAM,SAAS,qCAAqC,SAAS;CAEjE;CACA,KAAK,MAAM,CAAC,OAAO,WAAW,iBAAiB;EAC7C,MAAM,OAAO,OAAO,IAAI,KAAK,CAAC,EAAE,IAAI,MAAM;EAC1C,IAAI,SAAS,KAAA,KAAa,CAAC,KAAK,WAAW,KAAK,GAC9C,MAAM,SAAS,UAAU,MAAM,GAAG,OAAO,YAAY,KAAK,mBAAmB;CAEjF;AACF;;;;;;AAOA,eAAsB,mBAAmB,MAAsC;CAC7E,MAAM,UAAU,MAAM,QAAQ,IAAI,cAAc,IAAI,OAAO,UAAU,MAAM,KAAK,KAAK,CAAC,CAAC;CACvF,oBACE,IAAI,IAAI,cAAc,KAAK,OAAO,UAAU,CAAC,OAAO,QAAQ,0BAAU,IAAI,IAAI,CAAC,CAAC,CAAC,CACnF;AACF"}
1
+ {"version":3,"file":"review-schema-check.mjs","names":[],"sources":["../src/review-schema-check.ts"],"sourcesContent":["/**\n * Refuse an upgrade that cannot adopt a review or accessibility table or column made outside StoryShelf, with an\n * error that names the table and column instead of a raw driver message.\n */\nimport type { TableColumns, TableInfoReader } from \"./table-info.ts\";\n\n/** Columns the review code needs in `build_reviews`. */\nconst BUILD_REVIEW_COLUMNS = [\"id\", \"build_id\", \"user_id\", \"verdict\", \"body\", \"created_at\"];\n\n/** Integer columns the upgrade adds (`run_a11y` is the accessibility switch); one that exists with another type was made by hand. */\nconst INTEGER_COLUMNS = [\n [\"projects\", \"review_enabled\"],\n [\"projects\", \"review_approvals\"],\n [\"builds\", \"review_cycle\"],\n [\"builds\", \"review_requested_cycle\"],\n [\"projects\", \"run_a11y\"],\n] as const;\n\n/** SQLite's own rule (datatype3): a declared type containing `INT` has integer affinity (`TINYINT`, `BIGINT`, ...). */\nfunction hasIntegerAffinity(type: string): boolean {\n return type.includes(\"INT\");\n}\n\n/** SQLite's own rule: a declared type containing `CHAR`, `CLOB` or `TEXT` has text affinity (`VARCHAR`, ...). */\nfunction hasTextAffinity(type: string): boolean {\n return [\"CHAR\", \"CLOB\", \"TEXT\"].some((part) => type.includes(part));\n}\n\nfunction conflict(what: string): Error {\n return new Error(\n `Cannot upgrade the schema: ${what}. It was not created by StoryShelf; rename or drop it (keep a backup) and start again.`,\n );\n}\n\n/** The tables the check looks at. */\nconst REVIEW_TABLES = [\"projects\", \"builds\", \"build_reviews\", \"snapshots\"];\n\n/** Throw when `build_reviews` or a review column already exists in a shape the upgrade cannot use. */\nexport function assertReviewColumns(tables: ReadonlyMap<string, TableColumns>): void {\n const reviews = tables.get(\"build_reviews\") ?? new Map<string, string>();\n if (reviews.size > 0) {\n const missing = BUILD_REVIEW_COLUMNS.find((column) => !reviews.has(column));\n if (missing !== undefined) {\n throw conflict(`table build_reviews has no column ${missing}`);\n }\n }\n for (const [table, column] of INTEGER_COLUMNS) {\n const type = tables.get(table)?.get(column);\n if (type !== undefined && !hasIntegerAffinity(type)) {\n throw conflict(`column ${table}.${column} has type ${type}, expected INTEGER`);\n }\n }\n assertFindingsColumn(tables);\n}\n\n/** `snapshots.a11y_violations` holds the stored axe findings as TEXT. */\nfunction assertFindingsColumn(tables: ReadonlyMap<string, TableColumns>): void {\n const violations = tables.get(\"snapshots\")?.get(\"a11y_violations\");\n if (violations !== undefined && !hasTextAffinity(violations)) {\n throw conflict(`column snapshots.a11y_violations has type ${violations}, expected TEXT`);\n }\n}\n\n/**\n * Read the review tables through the preset's own reader, then check them. A reader that cannot\n * serve `PRAGMA` (a binding that refuses it) is the preset's to handle: it returns no columns, which\n * passes, so the check never blocks a database it cannot see.\n */\nexport async function assertReviewSchema(read: TableInfoReader): Promise<void> {\n const columns = await Promise.all(REVIEW_TABLES.map(async (table) => await read(table)));\n assertReviewColumns(\n new Map(REVIEW_TABLES.map((table, index) => [table, columns[index] ?? new Map()])),\n );\n}\n"],"mappings":";;;;;AAOA,MAAM,uBAAuB;CAAC;CAAM;CAAY;CAAW;CAAW;CAAQ;AAAY;;AAG1F,MAAM,kBAAkB;CACtB,CAAC,YAAY,gBAAgB;CAC7B,CAAC,YAAY,kBAAkB;CAC/B,CAAC,UAAU,cAAc;CACzB,CAAC,UAAU,wBAAwB;CACnC,CAAC,YAAY,UAAU;AACzB;;AAGA,SAAS,mBAAmB,MAAuB;CACjD,OAAO,KAAK,SAAS,KAAK;AAC5B;;AAGA,SAAS,gBAAgB,MAAuB;CAC9C,OAAO;EAAC;EAAQ;EAAQ;CAAM,CAAC,CAAC,MAAM,SAAS,KAAK,SAAS,IAAI,CAAC;AACpE;AAEA,SAAS,SAAS,MAAqB;CACrC,uBAAO,IAAI,MACT,8BAA8B,KAAK,uFACrC;AACF;;AAGA,MAAM,gBAAgB;CAAC;CAAY;CAAU;CAAiB;AAAW;;AAGzE,SAAgB,oBAAoB,QAAiD;CACnF,MAAM,UAAU,OAAO,IAAI,eAAe,qBAAK,IAAI,IAAoB;CACvE,IAAI,QAAQ,OAAO,GAAG;EACpB,MAAM,UAAU,qBAAqB,MAAM,WAAW,CAAC,QAAQ,IAAI,MAAM,CAAC;EAC1E,IAAI,YAAY,KAAA,GACd,MAAM,SAAS,qCAAqC,SAAS;CAEjE;CACA,KAAK,MAAM,CAAC,OAAO,WAAW,iBAAiB;EAC7C,MAAM,OAAO,OAAO,IAAI,KAAK,CAAC,EAAE,IAAI,MAAM;EAC1C,IAAI,SAAS,KAAA,KAAa,CAAC,mBAAmB,IAAI,GAChD,MAAM,SAAS,UAAU,MAAM,GAAG,OAAO,YAAY,KAAK,mBAAmB;CAEjF;CACA,qBAAqB,MAAM;AAC7B;;AAGA,SAAS,qBAAqB,QAAiD;CAC7E,MAAM,aAAa,OAAO,IAAI,WAAW,CAAC,EAAE,IAAI,iBAAiB;CACjE,IAAI,eAAe,KAAA,KAAa,CAAC,gBAAgB,UAAU,GACzD,MAAM,SAAS,6CAA6C,WAAW,gBAAgB;AAE3F;;;;;;AAOA,eAAsB,mBAAmB,MAAsC;CAC7E,MAAM,UAAU,MAAM,QAAQ,IAAI,cAAc,IAAI,OAAO,UAAU,MAAM,KAAK,KAAK,CAAC,CAAC;CACvF,oBACE,IAAI,IAAI,cAAc,KAAK,OAAO,UAAU,CAAC,OAAO,QAAQ,0BAAU,IAAI,IAAI,CAAC,CAAC,CAAC,CACnF;AACF"}
package/dist/turso.mjs CHANGED
@@ -32,7 +32,7 @@ function createTursoDatabase(options) {
32
32
  return createDrizzleAdapter(db, {
33
33
  metadata: {
34
34
  name: "Turso",
35
- version: "0.10.0-next-4a042db",
35
+ version: "0.10.0-next-7df132f",
36
36
  description: "Turso/libSQL database adapter",
37
37
  kind: "turso",
38
38
  category: "database"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyshelf/db-sqlite",
3
- "version": "0.10.0-next-4a042db",
3
+ "version": "0.10.0-next-7df132f",
4
4
  "description": "SQLite database adapter for StoryShelf (node:sqlite + Drizzle).",
5
5
  "keywords": [
6
6
  "database",
@@ -87,7 +87,7 @@
87
87
  "prepublishOnly": "nub run build"
88
88
  },
89
89
  "dependencies": {
90
- "@storyshelf/core": "0.10.0-next-4a042db",
90
+ "@storyshelf/core": "0.10.0-next-7df132f",
91
91
  "drizzle-orm": "^0.45.4"
92
92
  },
93
93
  "devDependencies": {