@pikku/kysely-node-sqlite 0.12.8 → 0.12.10

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.
@@ -16,5 +16,11 @@ export interface CreateNodeSqliteKyselyOptions {
16
16
  * register functions. Using it is a decision to stay on Node.
17
17
  */
18
18
  functions?: SqliteFunctionMap;
19
+ /**
20
+ * Absolute paths of loadable SQLite extensions (sqlite-vec's `vec0`, say) to
21
+ * load before the database is handed to Kysely. Loaded through the C API;
22
+ * SQL's own `load_extension()` stays refused.
23
+ */
24
+ extensions?: string[];
19
25
  }
20
26
  export declare function createNodeSqliteKysely<DB>(options: CreateNodeSqliteKyselyOptions): Kysely<DB>;
@@ -3,7 +3,17 @@ import { Kysely, SqliteDialect, CamelCasePlugin, } from 'kysely';
3
3
  import { NodeSqliteDatabase } from './node-sqlite-adapter.js';
4
4
  import { registerSqliteFunctions } from './register-functions.js';
5
5
  export function createNodeSqliteKysely(options) {
6
- const db = new DatabaseSync(options.filename);
6
+ const extensions = options.extensions ?? [];
7
+ // node:sqlite refuses loadExtension on a connection not opened allowing it,
8
+ // so allow it only when there is something to load, and shut it again after.
9
+ const db = new DatabaseSync(options.filename, {
10
+ allowExtension: extensions.length > 0,
11
+ });
12
+ if (extensions.length > 0) {
13
+ for (const path of extensions)
14
+ db.loadExtension(path);
15
+ db.enableLoadExtension(false);
16
+ }
7
17
  if (options.functions)
8
18
  registerSqliteFunctions(db, options.functions);
9
19
  const plugins = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/kysely-node-sqlite",
3
- "version": "0.12.8",
3
+ "version": "0.12.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -15,29 +15,35 @@
15
15
  "scripts": {
16
16
  "tsc": "tsc",
17
17
  "ncu": "npx npm-check-updates",
18
- "build": "tsc -b",
18
+ "build": "bun run clean && tsc -b",
19
19
  "test": "bash run-tests.sh",
20
20
  "test:watch": "bash run-tests.sh --watch",
21
21
  "test:coverage": "bash run-tests.sh --coverage",
22
- "prepublishOnly": "bun run build"
22
+ "prepublishOnly": "bun run build",
23
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
23
24
  },
24
25
  "engines": {
25
26
  "node": ">=22.10"
26
27
  },
27
28
  "dependencies": {
28
- "@pikku/kysely": "^0.13.25",
29
- "@pikku/kysely-sqlite": "^0.12.14",
30
- "kysely": "^0.29.5"
29
+ "@pikku/kysely": "^0.13.39",
30
+ "@pikku/kysely-sqlite": "^0.12.18",
31
+ "kysely": "^0.29.6"
31
32
  },
32
33
  "peerDependencies": {
33
- "@pikku/core": "^0.12.108"
34
+ "@pikku/core": "^0.12.144"
34
35
  },
35
36
  "devDependencies": {
36
- "@pikku/core": "^0.12.108",
37
- "@types/node": "^22",
38
- "tsx": "^4.23.12"
37
+ "@pikku/core": "^0.12.144",
38
+ "@types/node": "^26",
39
+ "tsx": "^4.23.15"
39
40
  },
40
41
  "exports": {
41
- ".": "./dist/src/index.js"
42
- }
42
+ ".": "./dist/src/index.js",
43
+ "./package.json": "./package.json"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "!dist/**/*.tsbuildinfo"
48
+ ]
43
49
  }
package/CHANGELOG.md DELETED
@@ -1,187 +0,0 @@
1
- # @pikku/kysely-node-sqlite
2
-
3
- ## 0.12.8
4
-
5
- ### Patch Changes
6
-
7
- - 4c7a1b5: Run the monorepo's own scripts through bun instead of yarn. What moves is the
8
- package manager each package's `prepublishOnly` and build scripts invoke, plus
9
- the two manifest fixes bun needs to resolve the tree: `uWebSockets.js` is
10
- declared with an explicit `github:` specifier, and `@pikku/uws-handler` marks
11
- its `uWebSockets.js` peer optional so a bun install of a consumer that brings
12
- its own uWS app does not try to fetch it from the registry.
13
-
14
- Three published behaviours change, all of them cases where an isolated
15
- `node_modules` or bun as the runtime had been papered over by yarn's hoisting:
16
-
17
- - `@pikku/migrator-sql` turns foreign keys on when it opens a sqlite database
18
- through bun. `node:sqlite` enforces them by default and `bun:sqlite` does not,
19
- which silently turned every `ON DELETE CASCADE` into a no-op under
20
- `bunx --bun pikku`.
21
- - `@pikku/cli` resolves a deploy provider against the project being deployed
22
- rather than against wherever the CLI itself is installed, which is what its
23
- own "is not installed" error asks the user to arrange.
24
- - `@pikku/cli` treats a specifier a runtime hands straight back — bun does this
25
- for the modules it implements itself — as not resolved from the project, so
26
- it falls back rather than loading the runtime's own copy.
27
-
28
- - Updated dependencies [4c7a1b5]
29
- - @pikku/core@0.12.108
30
- - @pikku/kysely@0.13.25
31
- - @pikku/kysely-sqlite@0.12.14
32
-
33
- ## 0.12.7
34
-
35
- ### Patch Changes
36
-
37
- - 746ed6a: fix: one coercion plugin, not three
38
-
39
- The Kysely coercion plugin existed in three copies — the CLI's local database,
40
- `@pikku/kysely-node-sqlite` and `@pikku/kysely-bun-sqlite` — and all three had
41
- drifted apart. Only the CLI's resolved a column against the tables the query
42
- actually named, so two tables that disagree on the kind of a same-named column
43
- coerced correctly in local development and silently did not at runtime; only
44
- bun's dropped a genuinely ambiguous column instead of letting the last table
45
- processed win.
46
-
47
- The single implementation now lives in `@pikku/kysely`, which all three already
48
- depended on, and keeps both behaviours: table-qualified resolution first, an
49
- ambiguity-safe bare-name fallback second.
50
-
51
- `ColumnKind` — the value type of the generated `coercion.gen.ts` — is
52
- `'date' | 'bool' | 'json'`. The CLI's fourth member, `uuid`, was never a
53
- coercion kind: the codegen excludes it from the map by construction, because a
54
- UUID is a string in both Postgres and SQLite. It is now `AnnotationKind` in the
55
- CLI, the union a column may declare in `db/annotations.ts`, of which
56
- `ColumnKind` is the coercible subset.
57
-
58
- `@pikku/cli` also drops its unused dependency on the Node-only
59
- `@pikku/kysely-node-sqlite`.
60
-
61
- - Updated dependencies [5a1a962]
62
- - Updated dependencies [746ed6a]
63
- - @pikku/core@0.12.86
64
- - @pikku/kysely@0.13.18
65
-
66
- ## 0.12.6
67
-
68
- ### Patch Changes
69
-
70
- - 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
71
- - Updated dependencies [7722ceb]
72
- - Updated dependencies [375c1ff]
73
- - Updated dependencies [02a70cd]
74
- - Updated dependencies [aeef159]
75
- - Updated dependencies [a281de6]
76
- - Updated dependencies [266e3bc]
77
- - Updated dependencies [02a70cd]
78
- - Updated dependencies [786dae5]
79
- - Updated dependencies [6eef0a0]
80
- - Updated dependencies [3561d67]
81
- - Updated dependencies [a91c433]
82
- - Updated dependencies [02a70cd]
83
- - Updated dependencies [9537f74]
84
- - Updated dependencies [2b57ca8]
85
- - Updated dependencies [266e3bc]
86
- - Updated dependencies [9fce0f1]
87
- - Updated dependencies [83683a0]
88
- - Updated dependencies [456c88b]
89
- - Updated dependencies [456c88b]
90
- - Updated dependencies [c127273]
91
- - @pikku/core@0.12.85
92
- - @pikku/kysely@0.13.17
93
- - @pikku/kysely-sqlite@0.12.13
94
-
95
- ## 0.12.5
96
-
97
- ### Patch Changes
98
-
99
- - fd9d834: Stop publishing internals that only their own package or file used. The declarations stay; only the entrypoint re-export is removed, so nothing that imported a name from where it is declared is affected.
100
- - Updated dependencies [063f43a]
101
- - Updated dependencies [ce66bf8]
102
- - Updated dependencies [d0307a8]
103
- - Updated dependencies [ce66bf8]
104
- - Updated dependencies [3ad2131]
105
- - Updated dependencies [b930dca]
106
- - Updated dependencies [b95e77d]
107
- - Updated dependencies [fd9d834]
108
- - Updated dependencies [8978fbd]
109
- - @pikku/core@0.12.82
110
- - @pikku/kysely@0.13.15
111
- - @pikku/kysely-sqlite@0.12.11
112
-
113
- ## 0.12.4
114
-
115
- ### Patch Changes
116
-
117
- - 9d62571: Make user-defined SQL functions an explicit, checked capability of the SQLite drivers.
118
-
119
- `node:sqlite` can register scalar UDFs (`db.function()`); `bun:sqlite` cannot. Until now
120
- neither driver mentioned that, so an app that registered a UDF by reaching for the raw
121
- connection worked on Node and, on bun, failed as `no such function: …` from whichever
122
- query used it — typically one endpoint breaking in production while everything else
123
- looked healthy.
124
-
125
- Both drivers now export `registerSqliteFunctions(db, functions)` and accept a
126
- `functions` option on `createNodeSqliteKysely` / `createBunSqliteKysely`. The Node
127
- implementation registers them as deterministic; the bun implementation throws
128
- `SqliteFunctionsUnsupportedError` — exported from `@pikku/kysely-sqlite`, and naming
129
- every function requested — so the incompatibility surfaces at wiring time with a message
130
- saying what to do about it.
131
-
132
- - Updated dependencies [32277d5]
133
- - Updated dependencies [ea8aabf]
134
- - Updated dependencies [33e96ab]
135
- - Updated dependencies [fd72e58]
136
- - Updated dependencies [cabd9dc]
137
- - Updated dependencies [fd72e58]
138
- - Updated dependencies [fd72e58]
139
- - Updated dependencies [894b2f8]
140
- - Updated dependencies [dd19aa7]
141
- - Updated dependencies [50ec500]
142
- - Updated dependencies [9d62571]
143
- - @pikku/core@0.12.75
144
- - @pikku/kysely@0.13.8
145
- - @pikku/kysely-sqlite@0.12.10
146
-
147
- ## 0.12.3
148
-
149
- ### Patch Changes
150
-
151
- - 41ce2cb: Upgrade to TypeScript 6 and raise the minimum Node.js version to 22.
152
-
153
- All packages now build against `typescript@^6.0.3` and declare `engines.node >= 22`. Internal tooling (`ts-json-schema-generator`, `zod-to-ts`) was bumped to TypeScript 6-compatible releases.
154
-
155
- - Updated dependencies [241e6cf]
156
- - Updated dependencies [41ce2cb]
157
- - @pikku/kysely@0.13.0
158
- - @pikku/core@0.12.44
159
- - @pikku/kysely-sqlite@0.12.7
160
-
161
- ## 0.12.2
162
-
163
- ### Patch Changes
164
-
165
- - 34f254e: Bump the `kysely` dependency range to `^0.29.0` so it dedupes onto a single
166
- copy alongside Better Auth (which bundles kysely 0.29.x), avoiding two
167
- incompatible `Kysely` classes (the `#private` brand mismatch) when both pikku's
168
- adapters and Better Auth share a database connection.
169
-
170
- kysely 0.29 is ESM-only, which the unmaintained `kysely-plugin-serialize`
171
- (no `exports` map, CommonJS build) cannot import. Its `SerializePlugin` is now
172
- maintained directly in `@pikku/kysely` and re-exported, and the external
173
- dependency is dropped from `@pikku/kysely`, `@pikku/kysely-sqlite`, and
174
- `@pikku/cloudflare`.
175
-
176
- - Updated dependencies [6565b97]
177
- - Updated dependencies [34f254e]
178
- - @pikku/kysely@0.12.16
179
- - @pikku/kysely-sqlite@0.12.6
180
-
181
- ## 0.12.1
182
-
183
- ### Patch Changes
184
-
185
- - 9060165: New `@pikku/kysely-node-sqlite` provides a Kysely dialect and migrator for Node's built-in `node:sqlite`. `@pikku/kysely-sqlite` adds a `LibsqlWebDialect` for running Kysely against Cloudflare Workers and Turso databases over HTTP.
186
- - Updated dependencies [9060165]
187
- - @pikku/kysely-sqlite@0.12.5
package/run-tests.sh DELETED
@@ -1,68 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Enable nullglob to handle cases where no files match the pattern
4
- shopt -s nullglob
5
-
6
- # Initialize variables for options
7
- watch_mode=false
8
- coverage_mode=false
9
-
10
- # Parse command-line options
11
- while [[ $# -gt 0 ]]; do
12
- case $1 in
13
- --watch)
14
- watch_mode=true
15
- shift
16
- ;;
17
- --coverage)
18
- coverage_mode=true
19
- shift
20
- ;;
21
- *)
22
- echo "Unknown option: $1"
23
- exit 1
24
- ;;
25
- esac
26
- done
27
-
28
- # Define the pattern to match your test files
29
- pattern="src/*.test.ts"
30
-
31
- # Expand the pattern into an array of files
32
- files=($(find src -type f -name "*.test.ts"))
33
-
34
- # Check if any files matched the pattern
35
- if [ ${#files[@]} -eq 0 ]; then
36
- echo "No test files found matching pattern: $pattern"
37
- if [ "${STRICT_TEST_DISCOVERY}" = "1" ]; then
38
- exit 1
39
- fi
40
- exit 0
41
- fi
42
-
43
- # Construct the bun command
44
- #
45
- # --parallel gives every test file its own worker process, which is what node's
46
- # `--test` did. Several suites keep module-level caches (a TypeScript program, a
47
- # temp fixture directory) that a shared process would leak between files.
48
- #
49
- # --timeout because bun caps a test at 5s by default where node had no cap, and
50
- # the suites that build real TypeScript programs run well past that.
51
- bun_cmd=(bun test --parallel --timeout 120000)
52
-
53
- # Append options based on flags
54
- if [ "$watch_mode" = true ]; then
55
- # --watch reruns in one process; parallel workers have nothing to watch.
56
- bun_cmd=(bun test --watch --timeout 120000)
57
- fi
58
-
59
- if [ "$coverage_mode" = true ]; then
60
- # --coverage-dir=. keeps lcov.info at the package root: CI merges every
61
- # package's report by prefixing its SF paths with the file's own directory,
62
- # so a nested coverage/ directory would re-root them one level too deep.
63
- bun_cmd+=(--coverage --coverage-reporter=lcov --coverage-reporter=text --coverage-dir=.)
64
- export PIKKU_TEST_COVERAGE=1
65
- fi
66
-
67
- # Execute the bun command with the expanded list of files
68
- "${bun_cmd[@]}" "${files[@]}"