@ku6epxboctuk/sqlite-up 0.0.0-stage → 0.6.1

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.
@@ -0,0 +1,12 @@
1
+ import type { MigratorDatabase } from '../types.js';
2
+ import type { SqliteProvider } from './types.js';
3
+ /**
4
+ * Creates the best provider adapter for a supported SQLite database client.
5
+ */
6
+ export declare function createSqliteProvider(db: MigratorDatabase): SqliteProvider;
7
+ export { createBetterSqlite3Provider, isBetterSqlite3Database } from './better-sqlite3.js';
8
+ export { createBunSqlProvider, isBunSqlDatabase } from './bun-sql.js';
9
+ export { createBunSqliteProvider, isBunSqliteDatabase } from './bun-sqlite.js';
10
+ export { createNodeSqliteProvider, isNodeSqliteDatabase } from './node-sqlite.js';
11
+ export type { SqliteProvider } from './types.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,aAAa,CAAC;AAMpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAUjD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,gBAAgB,GAAG,cAAc,CA0BzE;AAED,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAClF,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { SqliteDatabase } from '../types.js';
2
+ import type { SqliteProvider } from './types.js';
3
+ /**
4
+ * Creates a provider that wraps migration work in explicit SQL transactions.
5
+ */
6
+ export declare function createManualTransactionProvider(db: SqliteDatabase): SqliteProvider;
7
+ //# sourceMappingURL=manual-transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manual-transaction.d.ts","sourceRoot":"","sources":["../../src/providers/manual-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CAsBlF"}
@@ -0,0 +1,17 @@
1
+ import type { SqliteDatabase } from '../types.js';
2
+ import type { SqliteProvider } from './types.js';
3
+ /**
4
+ * Structural database shape used to identify Node's node:sqlite DatabaseSync.
5
+ */
6
+ export type NodeSqliteDatabase = SqliteDatabase & {
7
+ isOpen?: boolean;
8
+ };
9
+ /**
10
+ * Checks whether a value looks like a node:sqlite database instance.
11
+ */
12
+ export declare function isNodeSqliteDatabase(db: unknown): db is NodeSqliteDatabase;
13
+ /**
14
+ * Creates a sqlite-up provider for node:sqlite database instances.
15
+ */
16
+ export declare function createNodeSqliteProvider(db: NodeSqliteDatabase): SqliteProvider;
17
+ //# sourceMappingURL=node-sqlite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-sqlite.d.ts","sourceRoot":"","sources":["../../src/providers/node-sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG;IAChD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,kBAAkB,CAO1E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,kBAAkB,GAAG,cAAc,CAE/E"}
@@ -0,0 +1,15 @@
1
+ import type { MaybePromise, SqliteDatabase } from '../types.js';
2
+ /**
3
+ * Adapter that normalizes driver-specific SQLite behavior for the migrator.
4
+ */
5
+ export interface SqliteProvider {
6
+ /**
7
+ * Database facade used by migration code.
8
+ */
9
+ db: SqliteDatabase;
10
+ /**
11
+ * Runs migration bookkeeping and user migration code atomically.
12
+ */
13
+ transaction(fn: () => MaybePromise<void>): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,EAAE,EAAE,cAAc,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * A value or a promise for that value.
3
+ */
4
+ export type MaybePromise<T> = T | Promise<T>;
5
+ /**
6
+ * Optional context argument tuple. Context is omitted by default and required
7
+ * when a migrator or migration is typed with a context value.
8
+ */
9
+ export type ContextArg<T> = [T] extends [undefined] ? [] : [ctx: T];
10
+ /**
11
+ * Result returned by SQLite statement execution.
12
+ */
13
+ export interface SqliteRunResult {
14
+ /**
15
+ * Number of rows changed by the statement, when reported by the driver.
16
+ */
17
+ changes?: number | bigint;
18
+ /**
19
+ * Last inserted row identifier, when reported by the driver.
20
+ */
21
+ lastInsertRowid?: number | bigint;
22
+ }
23
+ /**
24
+ * Minimal prepared statement surface used by sqlite-up.
25
+ * Compatible with Node's `node:sqlite`, Bun's `bun:sqlite`, Bun SQL, and
26
+ * similar SQLite clients.
27
+ */
28
+ export interface SqliteStatement {
29
+ /**
30
+ * Runs the prepared statement and returns all result rows.
31
+ */
32
+ all(...params: unknown[]): MaybePromise<unknown[]>;
33
+ /**
34
+ * Runs the prepared statement and returns the first result row.
35
+ */
36
+ get(...params: unknown[]): MaybePromise<unknown>;
37
+ /**
38
+ * Runs the prepared statement for side effects and returns the driver result.
39
+ */
40
+ run(...params: unknown[]): MaybePromise<SqliteRunResult | unknown>;
41
+ }
42
+ /**
43
+ * Transaction function returned by SQLite drivers that provide native
44
+ * async-compatible transaction wrappers.
45
+ */
46
+ export interface SqliteTransaction<Args extends unknown[] = unknown[], Result = unknown> {
47
+ (...args: Args): MaybePromise<Result>;
48
+ /**
49
+ * Runs the transaction with deferred locking semantics when supported.
50
+ */
51
+ deferred?: (...args: Args) => MaybePromise<Result>;
52
+ /**
53
+ * Runs the transaction with immediate locking semantics when supported.
54
+ */
55
+ immediate?: (...args: Args) => MaybePromise<Result>;
56
+ /**
57
+ * Runs the transaction with exclusive locking semantics when supported.
58
+ */
59
+ exclusive?: (...args: Args) => MaybePromise<Result>;
60
+ }
61
+ /**
62
+ * Minimal SQLite database surface passed to migration files.
63
+ * Node 24+ `DatabaseSync`, Bun `Database`, better-sqlite3 `Database`,
64
+ * and Bun SQL adapters are structurally compatible with this interface.
65
+ */
66
+ export interface SqliteDatabase {
67
+ /**
68
+ * Executes one or more SQL statements without returning result rows.
69
+ */
70
+ exec(sql: string): MaybePromise<unknown>;
71
+ /**
72
+ * Prepares a SQL statement for repeated execution.
73
+ */
74
+ prepare(sql: string): SqliteStatement;
75
+ }
76
+ /**
77
+ * Structural subset of Bun's Promise-based SQL client when configured for SQLite.
78
+ * sqlite-up wraps this into the `SqliteDatabase` migration surface.
79
+ */
80
+ export interface BunSqliteDatabase {
81
+ /**
82
+ * Executes raw SQL through Bun SQL and returns all result rows.
83
+ */
84
+ unsafe(sql: string, params?: unknown[]): PromiseLike<unknown[]> | unknown[];
85
+ /**
86
+ * Runs a callback inside a Bun SQL transaction when supported.
87
+ */
88
+ begin?<Result>(fn: (tx: BunSqliteDatabase) => MaybePromise<Result>): MaybePromise<Result>;
89
+ }
90
+ /**
91
+ * Database instances accepted by `Migrator`.
92
+ */
93
+ export type MigratorDatabase = SqliteDatabase | BunSqliteDatabase;
94
+ /**
95
+ * Options for initializing the Migrator.
96
+ */
97
+ export interface MigratorOptions {
98
+ /**
99
+ * SQLite database instance
100
+ */
101
+ db: MigratorDatabase;
102
+ /**
103
+ * Directory containing migration files
104
+ */
105
+ migrationsDir: string;
106
+ /**
107
+ * Name of the migrations table (default: schema_migrations)
108
+ */
109
+ migrationsTable?: string;
110
+ /**
111
+ * Name of the migrations lock table (default: schema_migrations_lock)
112
+ */
113
+ migrationsLockTable?: string;
114
+ /**
115
+ * File extensions to look for when loading migrations (default: ['ts', 'js'])
116
+ * Note: .d.ts files are always ignored
117
+ */
118
+ fileExtensions?: string[];
119
+ }
120
+ /**
121
+ * Represents a single migration file/module.
122
+ */
123
+ export interface Migration<T = undefined> {
124
+ /**
125
+ * Name of the migration (derived from filename)
126
+ */
127
+ name: string;
128
+ /**
129
+ * Function to apply the migration
130
+ */
131
+ up: (db: SqliteDatabase, ...args: ContextArg<T>) => MaybePromise<void>;
132
+ /**
133
+ * Function to revert the migration
134
+ */
135
+ down: (db: SqliteDatabase, ...args: ContextArg<T>) => MaybePromise<void>;
136
+ }
137
+ /**
138
+ * A record of applied migrations as stored in the database.
139
+ */
140
+ export interface MigrationRecord {
141
+ /**
142
+ * Name of the migration
143
+ */
144
+ name: string;
145
+ /**
146
+ * ISO timestamp when the migration was executed
147
+ */
148
+ executed_at: string;
149
+ /**
150
+ * Batch number for the migration
151
+ */
152
+ batch: number;
153
+ }
154
+ /**
155
+ * Result type returned by migration actions.
156
+ */
157
+ export interface MigrationResult {
158
+ /**
159
+ * Whether the migration operation was successful
160
+ */
161
+ success: boolean;
162
+ /**
163
+ * Error if the operation failed
164
+ */
165
+ error?: Error;
166
+ /**
167
+ * List of migrations that were applied/rolled back
168
+ */
169
+ appliedMigrations: string[];
170
+ }
171
+ /**
172
+ * Represents the plan for pending migrations.
173
+ */
174
+ export interface MigrationPlan {
175
+ /**
176
+ * The next batch number that will be used
177
+ */
178
+ nextBatch: number;
179
+ /**
180
+ * List of migrations that will be applied
181
+ */
182
+ pendingMigrations: string[];
183
+ }
184
+ /**
185
+ * Represents the status of migrations.
186
+ */
187
+ export interface MigrationStatus {
188
+ /**
189
+ * Current highest batch number
190
+ */
191
+ currentBatch: number;
192
+ /**
193
+ * Number of pending migrations
194
+ */
195
+ pending: number;
196
+ /**
197
+ * List of applied migrations
198
+ */
199
+ applied: MigrationRecord[];
200
+ }
201
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;IAEnD;;OAEG;IACH,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAEj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IAErB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
package/package.json CHANGED
@@ -1,6 +1,81 @@
1
1
  {
2
2
  "name": "@ku6epxboctuk/sqlite-up",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "author": "Sandrino Di Mattia",
4
+ "contributors": [
5
+ "Ku6epXBOCTuK (https://github.com/Ku6epXBOCTuK)"
6
+ ],
7
+ "version": "0.6.1",
8
+ "description": "A lightweight SQLite migration system for Node.js and Bun (fork with Windows ESM path fix)",
9
+ "type": "module",
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/Ku6epXBOCTuK/sqlite-up.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/Ku6epXBOCTuK/sqlite-up/issues"
17
+ },
18
+ "homepage": "https://github.com/Ku6epXBOCTuK/sqlite-up#readme",
19
+ "engines": {
20
+ "node": ">=24.0.0"
21
+ },
22
+ "packageManager": "pnpm@10.30.3",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "import": "./dist/index.js",
32
+ "types": "./dist/index.d.ts"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "LICENSE",
38
+ "README.md"
39
+ ],
40
+ "scripts": {
41
+ "build": "tsup src/index.ts --format esm --sourcemap && tsc -p tsconfig.build.json",
42
+ "check": "biome check .",
43
+ "check:fix": "biome check --write --unsafe .",
44
+ "format": "biome format --write .",
45
+ "lint": "biome lint . && jsdoc-lint src",
46
+ "typecheck": "pnpm typecheck:src && pnpm typecheck:test",
47
+ "typecheck:src": "tsc --noEmit",
48
+ "typecheck:test": "tsc --noEmit -p tsconfig.test.json",
49
+ "test": "vitest run",
50
+ "test:bun": "bun test ./src/*.bun.test.ts ./src/providers/*.bun.test.ts",
51
+ "test:coverage": "vitest run --coverage",
52
+ "test:node": "vitest run",
53
+ "test:watch": "vitest",
54
+ "prepare": "husky install",
55
+ "release": "node scripts/release.mjs",
56
+ "prepublishOnly": "pnpm run build"
57
+ },
58
+ "keywords": [
59
+ "bun",
60
+ "database",
61
+ "migrations",
62
+ "node",
63
+ "sqlite",
64
+ "typescript"
65
+ ],
66
+ "devDependencies": {
67
+ "@biomejs/biome": "^2.4.13",
68
+ "@types/better-sqlite3": "^7.6.13",
69
+ "@types/bun": "^1.3.13",
70
+ "@types/node": "^25.6.0",
71
+ "@vitest/coverage-v8": "^4.1.5",
72
+ "better-sqlite3": "^12.9.0",
73
+ "husky": "^9.1.7",
74
+ "jsdoc-lint": "0.4.0",
75
+ "lint-staged": "^16.4.0",
76
+ "tsup": "^8.5.1",
77
+ "tsx": "^4.21.0",
78
+ "typescript": "^6.0.3",
79
+ "vitest": "^4.1.5"
80
+ }
81
+ }