jukebox-media-server 0.5.0 → 0.6.0
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 +18 -20
- package/dist/server/better-sqlite3-6WoM5xG0.js +129 -0
- package/dist/server/bun-sqlite-BBdvu820.js +134 -0
- package/dist/server/index.js +14 -14
- package/dist/server/{migrator-CWPnMvx5.js → migrator-CAdL3H58.js} +1 -7
- package/dist/server/migrator-CXTJWgtg.js +8 -0
- package/dist/server/migrator-C_0LpHsF.js +8 -0
- package/dist/server/{better-sqlite3-Dy_YhTFe.js → session-DfEK0QWr.js} +2 -128
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ streaming your personal movie and TV show collection.
|
|
|
11
11
|
rich metadata
|
|
12
12
|
- **Movies and TV shows** — automatic detection of episodes, seasons, and series
|
|
13
13
|
- **Automatic metadata** — fetches titles, posters, backdrops, ratings, and
|
|
14
|
-
trailers
|
|
14
|
+
trailers automatically. No API key required.
|
|
15
15
|
- **Video streaming with seeking** — stream any common video format with full
|
|
16
16
|
range-request support
|
|
17
17
|
- **Watch progress** — automatically saves and resumes playback position
|
|
@@ -21,8 +21,9 @@ streaming your personal movie and TV show collection.
|
|
|
21
21
|
|
|
22
22
|
## Requirements
|
|
23
23
|
|
|
24
|
-
- [Node.js](https://nodejs.org/) 18 or later
|
|
25
|
-
-
|
|
24
|
+
- [Node.js](https://nodejs.org/) 18 or later (or [Bun](https://bun.sh/))
|
|
25
|
+
- [ffmpeg](https://ffmpeg.org/) on your `PATH` (used for media probing and
|
|
26
|
+
on-the-fly transcoding)
|
|
26
27
|
|
|
27
28
|
## Installation
|
|
28
29
|
|
|
@@ -54,34 +55,30 @@ bunx jukebox-media-server@latest
|
|
|
54
55
|
|
|
55
56
|
Then open `http://localhost:1990` in your browser.
|
|
56
57
|
|
|
57
|
-
2. **Add your
|
|
58
|
+
2. **Add your library**
|
|
58
59
|
|
|
59
|
-
On first launch, the setup screen
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
On first launch, the setup screen asks you to point Jukebox at the folders
|
|
61
|
+
containing your movies and TV shows. It will recursively scan for video
|
|
62
|
+
files, parse titles and years from filenames, and fetch metadata
|
|
63
|
+
automatically — no API key needed.
|
|
62
64
|
|
|
63
|
-
3. **
|
|
64
|
-
|
|
65
|
-
Point Jukebox at the folder containing your movies and TV shows. It will
|
|
66
|
-
recursively scan for video files, parse titles and years from filenames, and
|
|
67
|
-
fetch metadata from TMDB.
|
|
68
|
-
|
|
69
|
-
4. **Watch**
|
|
65
|
+
3. **Watch**
|
|
70
66
|
|
|
71
67
|
That's it — your library is ready.
|
|
72
68
|
|
|
73
69
|
## Configuration
|
|
74
70
|
|
|
75
|
-
Jukebox stores its
|
|
71
|
+
Jukebox stores its data in `~/.jukebox/`:
|
|
76
72
|
|
|
77
|
-
- `~/.jukebox/
|
|
78
|
-
|
|
73
|
+
- `~/.jukebox/jukebox.db` — SQLite database with library paths, metadata, and
|
|
74
|
+
watch progress
|
|
79
75
|
|
|
80
76
|
Environment variables:
|
|
81
77
|
|
|
82
|
-
| Variable
|
|
83
|
-
|
|
|
84
|
-
| `PORT`
|
|
78
|
+
| Variable | Description | Default |
|
|
79
|
+
| -------------------------- | -------------------------------------- | ------------------------------------------------ |
|
|
80
|
+
| `PORT` | Server port | `1990` |
|
|
81
|
+
| `JUKEBOX_METADATA_API_URL` | Override the metadata service endpoint | `https://movie-data-api.artgaard.workers.dev` |
|
|
85
82
|
|
|
86
83
|
## Casting
|
|
87
84
|
|
|
@@ -133,3 +130,4 @@ Bug reports, feature requests, and pull requests are welcome. See
|
|
|
133
130
|
## License
|
|
134
131
|
|
|
135
132
|
[MIT](LICENSE)
|
|
133
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { F as isConfig, H as fillPlaceholders, I as mapResultRow, Q as entityKind, U as sql } from "./indexes-VMR6QVVl.js";
|
|
2
|
+
import { a as BaseSQLiteDatabase, c as extractTablesRelationalConfig, i as NoopCache, l as DefaultLogger, n as SQLiteSession, o as SQLiteSyncDialect, r as SQLiteTransaction, s as createTableRelationsHelpers, t as SQLitePreparedQuery, u as NoopLogger } from "./session-DfEK0QWr.js";
|
|
3
|
+
import Client from "better-sqlite3";
|
|
4
|
+
//#region node_modules/drizzle-orm/better-sqlite3/session.js
|
|
5
|
+
var BetterSQLiteSession = class extends SQLiteSession {
|
|
6
|
+
constructor(client, dialect, schema, options = {}) {
|
|
7
|
+
super(dialect);
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.schema = schema;
|
|
10
|
+
this.logger = options.logger ?? new NoopLogger();
|
|
11
|
+
this.cache = options.cache ?? new NoopCache();
|
|
12
|
+
}
|
|
13
|
+
static [entityKind] = "BetterSQLiteSession";
|
|
14
|
+
logger;
|
|
15
|
+
cache;
|
|
16
|
+
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
17
|
+
return new PreparedQuery(this.client.prepare(query.sql), query, this.logger, this.cache, queryMetadata, cacheConfig, fields, executeMethod, isResponseInArrayMode, customResultMapper);
|
|
18
|
+
}
|
|
19
|
+
transaction(transaction, config = {}) {
|
|
20
|
+
const tx = new BetterSQLiteTransaction("sync", this.dialect, this, this.schema);
|
|
21
|
+
return this.client.transaction(transaction)[config.behavior ?? "deferred"](tx);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var BetterSQLiteTransaction = class BetterSQLiteTransaction extends SQLiteTransaction {
|
|
25
|
+
static [entityKind] = "BetterSQLiteTransaction";
|
|
26
|
+
transaction(transaction) {
|
|
27
|
+
const savepointName = `sp${this.nestedIndex}`;
|
|
28
|
+
const tx = new BetterSQLiteTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
|
29
|
+
this.session.run(sql.raw(`savepoint ${savepointName}`));
|
|
30
|
+
try {
|
|
31
|
+
const result = transaction(tx);
|
|
32
|
+
this.session.run(sql.raw(`release savepoint ${savepointName}`));
|
|
33
|
+
return result;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
this.session.run(sql.raw(`rollback to savepoint ${savepointName}`));
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var PreparedQuery = class extends SQLitePreparedQuery {
|
|
41
|
+
constructor(stmt, query, logger, cache, queryMetadata, cacheConfig, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
|
42
|
+
super("sync", executeMethod, query, cache, queryMetadata, cacheConfig);
|
|
43
|
+
this.stmt = stmt;
|
|
44
|
+
this.logger = logger;
|
|
45
|
+
this.fields = fields;
|
|
46
|
+
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
47
|
+
this.customResultMapper = customResultMapper;
|
|
48
|
+
}
|
|
49
|
+
static [entityKind] = "BetterSQLitePreparedQuery";
|
|
50
|
+
run(placeholderValues) {
|
|
51
|
+
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
52
|
+
this.logger.logQuery(this.query.sql, params);
|
|
53
|
+
return this.stmt.run(...params);
|
|
54
|
+
}
|
|
55
|
+
all(placeholderValues) {
|
|
56
|
+
const { fields, joinsNotNullableMap, query, logger, stmt, customResultMapper } = this;
|
|
57
|
+
if (!fields && !customResultMapper) {
|
|
58
|
+
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
|
59
|
+
logger.logQuery(query.sql, params);
|
|
60
|
+
return stmt.all(...params);
|
|
61
|
+
}
|
|
62
|
+
const rows = this.values(placeholderValues);
|
|
63
|
+
if (customResultMapper) return customResultMapper(rows);
|
|
64
|
+
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
65
|
+
}
|
|
66
|
+
get(placeholderValues) {
|
|
67
|
+
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
68
|
+
this.logger.logQuery(this.query.sql, params);
|
|
69
|
+
const { fields, stmt, joinsNotNullableMap, customResultMapper } = this;
|
|
70
|
+
if (!fields && !customResultMapper) return stmt.get(...params);
|
|
71
|
+
const row = stmt.raw().get(...params);
|
|
72
|
+
if (!row) return;
|
|
73
|
+
if (customResultMapper) return customResultMapper([row]);
|
|
74
|
+
return mapResultRow(fields, row, joinsNotNullableMap);
|
|
75
|
+
}
|
|
76
|
+
values(placeholderValues) {
|
|
77
|
+
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
78
|
+
this.logger.logQuery(this.query.sql, params);
|
|
79
|
+
return this.stmt.raw().all(...params);
|
|
80
|
+
}
|
|
81
|
+
/** @internal */
|
|
82
|
+
isResponseInArrayMode() {
|
|
83
|
+
return this._isResponseInArrayMode;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region node_modules/drizzle-orm/better-sqlite3/driver.js
|
|
88
|
+
var BetterSQLite3Database = class extends BaseSQLiteDatabase {
|
|
89
|
+
static [entityKind] = "BetterSQLite3Database";
|
|
90
|
+
};
|
|
91
|
+
function construct(client, config = {}) {
|
|
92
|
+
const dialect = new SQLiteSyncDialect({ casing: config.casing });
|
|
93
|
+
let logger;
|
|
94
|
+
if (config.logger === true) logger = new DefaultLogger();
|
|
95
|
+
else if (config.logger !== false) logger = config.logger;
|
|
96
|
+
let schema;
|
|
97
|
+
if (config.schema) {
|
|
98
|
+
const tablesConfig = extractTablesRelationalConfig(config.schema, createTableRelationsHelpers);
|
|
99
|
+
schema = {
|
|
100
|
+
fullSchema: config.schema,
|
|
101
|
+
schema: tablesConfig.tables,
|
|
102
|
+
tableNamesMap: tablesConfig.tableNamesMap
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const db = new BetterSQLite3Database("sync", dialect, new BetterSQLiteSession(client, dialect, schema, { logger }), schema);
|
|
106
|
+
db.$client = client;
|
|
107
|
+
return db;
|
|
108
|
+
}
|
|
109
|
+
function drizzle(...params) {
|
|
110
|
+
if (params[0] === void 0 || typeof params[0] === "string") return construct(params[0] === void 0 ? new Client() : new Client(params[0]), params[1]);
|
|
111
|
+
if (isConfig(params[0])) {
|
|
112
|
+
const { connection, client, ...drizzleConfig } = params[0];
|
|
113
|
+
if (client) return construct(client, drizzleConfig);
|
|
114
|
+
if (typeof connection === "object") {
|
|
115
|
+
const { source, ...options } = connection;
|
|
116
|
+
return construct(new Client(source, options), drizzleConfig);
|
|
117
|
+
}
|
|
118
|
+
return construct(new Client(connection), drizzleConfig);
|
|
119
|
+
}
|
|
120
|
+
return construct(params[0], params[1]);
|
|
121
|
+
}
|
|
122
|
+
((drizzle2) => {
|
|
123
|
+
function mock(config) {
|
|
124
|
+
return construct({}, config);
|
|
125
|
+
}
|
|
126
|
+
drizzle2.mock = mock;
|
|
127
|
+
})(drizzle || (drizzle = {}));
|
|
128
|
+
//#endregion
|
|
129
|
+
export { drizzle };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { F as isConfig, H as fillPlaceholders, I as mapResultRow, Q as entityKind, U as sql } from "./indexes-VMR6QVVl.js";
|
|
2
|
+
import { a as BaseSQLiteDatabase, c as extractTablesRelationalConfig, l as DefaultLogger, n as SQLiteSession, o as SQLiteSyncDialect, r as SQLiteTransaction, s as createTableRelationsHelpers, t as SQLitePreparedQuery, u as NoopLogger } from "./session-DfEK0QWr.js";
|
|
3
|
+
import { Database } from "bun:sqlite";
|
|
4
|
+
//#region node_modules/drizzle-orm/bun-sqlite/session.js
|
|
5
|
+
var SQLiteBunSession = class extends SQLiteSession {
|
|
6
|
+
constructor(client, dialect, schema, options = {}) {
|
|
7
|
+
super(dialect);
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.schema = schema;
|
|
10
|
+
this.logger = options.logger ?? new NoopLogger();
|
|
11
|
+
}
|
|
12
|
+
static [entityKind] = "SQLiteBunSession";
|
|
13
|
+
logger;
|
|
14
|
+
exec(query) {
|
|
15
|
+
this.client.exec(query);
|
|
16
|
+
}
|
|
17
|
+
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
|
|
18
|
+
return new PreparedQuery(this.client.prepare(query.sql), query, this.logger, fields, executeMethod, isResponseInArrayMode, customResultMapper);
|
|
19
|
+
}
|
|
20
|
+
transaction(transaction, config = {}) {
|
|
21
|
+
const tx = new SQLiteBunTransaction("sync", this.dialect, this, this.schema);
|
|
22
|
+
let result;
|
|
23
|
+
this.client.transaction(() => {
|
|
24
|
+
result = transaction(tx);
|
|
25
|
+
})[config.behavior ?? "deferred"]();
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var SQLiteBunTransaction = class SQLiteBunTransaction extends SQLiteTransaction {
|
|
30
|
+
static [entityKind] = "SQLiteBunTransaction";
|
|
31
|
+
transaction(transaction) {
|
|
32
|
+
const savepointName = `sp${this.nestedIndex}`;
|
|
33
|
+
const tx = new SQLiteBunTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
|
34
|
+
this.session.run(sql.raw(`savepoint ${savepointName}`));
|
|
35
|
+
try {
|
|
36
|
+
const result = transaction(tx);
|
|
37
|
+
this.session.run(sql.raw(`release savepoint ${savepointName}`));
|
|
38
|
+
return result;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
this.session.run(sql.raw(`rollback to savepoint ${savepointName}`));
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var PreparedQuery = class extends SQLitePreparedQuery {
|
|
46
|
+
constructor(stmt, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
|
47
|
+
super("sync", executeMethod, query);
|
|
48
|
+
this.stmt = stmt;
|
|
49
|
+
this.logger = logger;
|
|
50
|
+
this.fields = fields;
|
|
51
|
+
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
52
|
+
this.customResultMapper = customResultMapper;
|
|
53
|
+
}
|
|
54
|
+
static [entityKind] = "SQLiteBunPreparedQuery";
|
|
55
|
+
run(placeholderValues) {
|
|
56
|
+
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
57
|
+
this.logger.logQuery(this.query.sql, params);
|
|
58
|
+
return this.stmt.run(...params);
|
|
59
|
+
}
|
|
60
|
+
all(placeholderValues) {
|
|
61
|
+
const { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;
|
|
62
|
+
if (!fields && !customResultMapper) {
|
|
63
|
+
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
|
64
|
+
logger.logQuery(query.sql, params);
|
|
65
|
+
return stmt.all(...params);
|
|
66
|
+
}
|
|
67
|
+
const rows = this.values(placeholderValues);
|
|
68
|
+
if (customResultMapper) return customResultMapper(rows);
|
|
69
|
+
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
70
|
+
}
|
|
71
|
+
get(placeholderValues) {
|
|
72
|
+
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
73
|
+
this.logger.logQuery(this.query.sql, params);
|
|
74
|
+
const row = this.stmt.values(...params)[0];
|
|
75
|
+
if (!row) return;
|
|
76
|
+
const { fields, joinsNotNullableMap, customResultMapper } = this;
|
|
77
|
+
if (!fields && !customResultMapper) return row;
|
|
78
|
+
if (customResultMapper) return customResultMapper([row]);
|
|
79
|
+
return mapResultRow(fields, row, joinsNotNullableMap);
|
|
80
|
+
}
|
|
81
|
+
values(placeholderValues) {
|
|
82
|
+
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
83
|
+
this.logger.logQuery(this.query.sql, params);
|
|
84
|
+
return this.stmt.values(...params);
|
|
85
|
+
}
|
|
86
|
+
/** @internal */
|
|
87
|
+
isResponseInArrayMode() {
|
|
88
|
+
return this._isResponseInArrayMode;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region node_modules/drizzle-orm/bun-sqlite/driver.js
|
|
93
|
+
var BunSQLiteDatabase = class extends BaseSQLiteDatabase {
|
|
94
|
+
static [entityKind] = "BunSQLiteDatabase";
|
|
95
|
+
};
|
|
96
|
+
function construct(client, config = {}) {
|
|
97
|
+
const dialect = new SQLiteSyncDialect({ casing: config.casing });
|
|
98
|
+
let logger;
|
|
99
|
+
if (config.logger === true) logger = new DefaultLogger();
|
|
100
|
+
else if (config.logger !== false) logger = config.logger;
|
|
101
|
+
let schema;
|
|
102
|
+
if (config.schema) {
|
|
103
|
+
const tablesConfig = extractTablesRelationalConfig(config.schema, createTableRelationsHelpers);
|
|
104
|
+
schema = {
|
|
105
|
+
fullSchema: config.schema,
|
|
106
|
+
schema: tablesConfig.tables,
|
|
107
|
+
tableNamesMap: tablesConfig.tableNamesMap
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const db = new BunSQLiteDatabase("sync", dialect, new SQLiteBunSession(client, dialect, schema, { logger }), schema);
|
|
111
|
+
db.$client = client;
|
|
112
|
+
return db;
|
|
113
|
+
}
|
|
114
|
+
function drizzle(...params) {
|
|
115
|
+
if (params[0] === void 0 || typeof params[0] === "string") return construct(params[0] === void 0 ? new Database() : new Database(params[0]), params[1]);
|
|
116
|
+
if (isConfig(params[0])) {
|
|
117
|
+
const { connection, client, ...drizzleConfig } = params[0];
|
|
118
|
+
if (client) return construct(client, drizzleConfig);
|
|
119
|
+
if (typeof connection === "object") {
|
|
120
|
+
const { source, ...opts } = connection;
|
|
121
|
+
return construct(new Database(source, Object.values(opts).filter((v) => v !== void 0).length ? opts : void 0), drizzleConfig);
|
|
122
|
+
}
|
|
123
|
+
return construct(new Database(connection), drizzleConfig);
|
|
124
|
+
}
|
|
125
|
+
return construct(params[0], params[1]);
|
|
126
|
+
}
|
|
127
|
+
((drizzle2) => {
|
|
128
|
+
function mock(config) {
|
|
129
|
+
return construct({}, config);
|
|
130
|
+
}
|
|
131
|
+
drizzle2.mock = mock;
|
|
132
|
+
})(drizzle || (drizzle = {}));
|
|
133
|
+
//#endregion
|
|
134
|
+
export { drizzle };
|
package/dist/server/index.js
CHANGED
|
@@ -2535,12 +2535,15 @@ var logger$1 = (fn = console.log) => {
|
|
|
2535
2535
|
};
|
|
2536
2536
|
//#endregion
|
|
2537
2537
|
//#region src/runtime-paths.ts
|
|
2538
|
-
const
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2538
|
+
const virtualFileSystemMarkers = [
|
|
2539
|
+
"/$bunfs/",
|
|
2540
|
+
"/~bun/",
|
|
2541
|
+
"/%7ebun/"
|
|
2542
|
+
];
|
|
2543
|
+
function isCompiledExecutable(moduleUrl = import.meta.url) {
|
|
2544
|
+
if (moduleUrl.startsWith("compiled://")) return true;
|
|
2545
|
+
const normalizedUrl = moduleUrl.toLowerCase();
|
|
2546
|
+
return virtualFileSystemMarkers.some((marker) => normalizedUrl.includes(marker));
|
|
2544
2547
|
}
|
|
2545
2548
|
function resolveBinaryDirectory() {
|
|
2546
2549
|
const executablePath = process.execPath;
|
|
@@ -2831,12 +2834,9 @@ ensureConfigDirectory();
|
|
|
2831
2834
|
async function createDatabase() {
|
|
2832
2835
|
const migrationsFolder = getMigrationsDirectory();
|
|
2833
2836
|
if (typeof Bun !== "undefined") {
|
|
2834
|
-
const
|
|
2835
|
-
const
|
|
2836
|
-
const
|
|
2837
|
-
const { Database: BunDatabase } = await import(bunSqliteModule);
|
|
2838
|
-
const { drizzle } = await import(bunSqliteDrizzleModule);
|
|
2839
|
-
const { migrate } = await import(bunSqliteMigratorModule);
|
|
2837
|
+
const { Database: BunDatabase } = await import("bun:sqlite");
|
|
2838
|
+
const { drizzle } = await import("./bun-sqlite-BBdvu820.js");
|
|
2839
|
+
const { migrate } = await import("./migrator-CXTJWgtg.js");
|
|
2840
2840
|
const sqlite = new BunDatabase(databasePath);
|
|
2841
2841
|
sqlite.exec("PRAGMA foreign_keys = ON");
|
|
2842
2842
|
const db = drizzle(sqlite, { schema: schema_exports });
|
|
@@ -2844,8 +2844,8 @@ async function createDatabase() {
|
|
|
2844
2844
|
return db;
|
|
2845
2845
|
}
|
|
2846
2846
|
const { default: NodeDatabase } = await import("better-sqlite3");
|
|
2847
|
-
const { drizzle } = await import("./better-sqlite3-
|
|
2848
|
-
const { migrate } = await import("./migrator-
|
|
2847
|
+
const { drizzle } = await import("./better-sqlite3-6WoM5xG0.js");
|
|
2848
|
+
const { migrate } = await import("./migrator-C_0LpHsF.js");
|
|
2849
2849
|
const sqlite = new NodeDatabase(databasePath);
|
|
2850
2850
|
sqlite.pragma("foreign_keys = ON");
|
|
2851
2851
|
const db = drizzle(sqlite, { schema: schema_exports });
|
|
@@ -28,10 +28,4 @@ function readMigrationFiles(config) {
|
|
|
28
28
|
return migrationQueries;
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
|
-
|
|
32
|
-
function migrate(db, config) {
|
|
33
|
-
const migrations = readMigrationFiles(config);
|
|
34
|
-
db.dialect.migrate(migrations, db.session, config);
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
export { migrate };
|
|
31
|
+
export { readMigrationFiles as t };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as readMigrationFiles } from "./migrator-CAdL3H58.js";
|
|
2
|
+
//#region node_modules/drizzle-orm/bun-sqlite/migrator.js
|
|
3
|
+
function migrate(db, config) {
|
|
4
|
+
const migrations = readMigrationFiles(config);
|
|
5
|
+
db.dialect.migrate(migrations, db.session, config);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { migrate };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as readMigrationFiles } from "./migrator-CAdL3H58.js";
|
|
2
|
+
//#region node_modules/drizzle-orm/better-sqlite3/migrator.js
|
|
3
|
+
function migrate(db, config) {
|
|
4
|
+
const migrations = readMigrationFiles(config);
|
|
5
|
+
db.dialect.migrate(migrations, db.session, config);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { migrate };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { $ as is, A as or, B as SQL, C as ne, D as notIlike, E as notExists,
|
|
2
|
-
import Client from "better-sqlite3";
|
|
1
|
+
import { $ as is, A as or, B as SQL, C as ne, D as notIlike, E as notExists, G as Table, J as ViewBaseConfig, K as getTableName, L as mapUpdateSet, M as getTableColumns, N as getTableLikeName, O as notInArray, P as haveSameKeys, Q as entityKind, R as orderSelectedFields, S as lte, T as notBetween, U as sql, V as View, W as Columns, X as WithSubquery, Y as Subquery, Z as Column, _ as inArray, b as like, c as asc, d as between, f as eq, g as ilike, h as gte, j as applyMixins, k as notLike, l as desc, m as gt, n as SQLiteTable, p as exists, q as getTableUniqueName, s as SQLiteColumn, u as and, v as isNotNull, w as not, x as lt, y as isNull, z as Param } from "./indexes-VMR6QVVl.js";
|
|
3
2
|
//#region node_modules/drizzle-orm/alias.js
|
|
4
3
|
var ColumnAliasProxyHandler = class {
|
|
5
4
|
constructor(table) {
|
|
@@ -2581,129 +2580,4 @@ var SQLiteTransaction = class extends BaseSQLiteDatabase {
|
|
|
2581
2580
|
}
|
|
2582
2581
|
};
|
|
2583
2582
|
//#endregion
|
|
2584
|
-
|
|
2585
|
-
var BetterSQLiteSession = class extends SQLiteSession {
|
|
2586
|
-
constructor(client, dialect, schema, options = {}) {
|
|
2587
|
-
super(dialect);
|
|
2588
|
-
this.client = client;
|
|
2589
|
-
this.schema = schema;
|
|
2590
|
-
this.logger = options.logger ?? new NoopLogger();
|
|
2591
|
-
this.cache = options.cache ?? new NoopCache();
|
|
2592
|
-
}
|
|
2593
|
-
static [entityKind] = "BetterSQLiteSession";
|
|
2594
|
-
logger;
|
|
2595
|
-
cache;
|
|
2596
|
-
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
2597
|
-
return new PreparedQuery(this.client.prepare(query.sql), query, this.logger, this.cache, queryMetadata, cacheConfig, fields, executeMethod, isResponseInArrayMode, customResultMapper);
|
|
2598
|
-
}
|
|
2599
|
-
transaction(transaction, config = {}) {
|
|
2600
|
-
const tx = new BetterSQLiteTransaction("sync", this.dialect, this, this.schema);
|
|
2601
|
-
return this.client.transaction(transaction)[config.behavior ?? "deferred"](tx);
|
|
2602
|
-
}
|
|
2603
|
-
};
|
|
2604
|
-
var BetterSQLiteTransaction = class BetterSQLiteTransaction extends SQLiteTransaction {
|
|
2605
|
-
static [entityKind] = "BetterSQLiteTransaction";
|
|
2606
|
-
transaction(transaction) {
|
|
2607
|
-
const savepointName = `sp${this.nestedIndex}`;
|
|
2608
|
-
const tx = new BetterSQLiteTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
|
2609
|
-
this.session.run(sql.raw(`savepoint ${savepointName}`));
|
|
2610
|
-
try {
|
|
2611
|
-
const result = transaction(tx);
|
|
2612
|
-
this.session.run(sql.raw(`release savepoint ${savepointName}`));
|
|
2613
|
-
return result;
|
|
2614
|
-
} catch (err) {
|
|
2615
|
-
this.session.run(sql.raw(`rollback to savepoint ${savepointName}`));
|
|
2616
|
-
throw err;
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
};
|
|
2620
|
-
var PreparedQuery = class extends SQLitePreparedQuery {
|
|
2621
|
-
constructor(stmt, query, logger, cache, queryMetadata, cacheConfig, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
|
2622
|
-
super("sync", executeMethod, query, cache, queryMetadata, cacheConfig);
|
|
2623
|
-
this.stmt = stmt;
|
|
2624
|
-
this.logger = logger;
|
|
2625
|
-
this.fields = fields;
|
|
2626
|
-
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
2627
|
-
this.customResultMapper = customResultMapper;
|
|
2628
|
-
}
|
|
2629
|
-
static [entityKind] = "BetterSQLitePreparedQuery";
|
|
2630
|
-
run(placeholderValues) {
|
|
2631
|
-
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
2632
|
-
this.logger.logQuery(this.query.sql, params);
|
|
2633
|
-
return this.stmt.run(...params);
|
|
2634
|
-
}
|
|
2635
|
-
all(placeholderValues) {
|
|
2636
|
-
const { fields, joinsNotNullableMap, query, logger, stmt, customResultMapper } = this;
|
|
2637
|
-
if (!fields && !customResultMapper) {
|
|
2638
|
-
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
|
2639
|
-
logger.logQuery(query.sql, params);
|
|
2640
|
-
return stmt.all(...params);
|
|
2641
|
-
}
|
|
2642
|
-
const rows = this.values(placeholderValues);
|
|
2643
|
-
if (customResultMapper) return customResultMapper(rows);
|
|
2644
|
-
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
2645
|
-
}
|
|
2646
|
-
get(placeholderValues) {
|
|
2647
|
-
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
2648
|
-
this.logger.logQuery(this.query.sql, params);
|
|
2649
|
-
const { fields, stmt, joinsNotNullableMap, customResultMapper } = this;
|
|
2650
|
-
if (!fields && !customResultMapper) return stmt.get(...params);
|
|
2651
|
-
const row = stmt.raw().get(...params);
|
|
2652
|
-
if (!row) return;
|
|
2653
|
-
if (customResultMapper) return customResultMapper([row]);
|
|
2654
|
-
return mapResultRow(fields, row, joinsNotNullableMap);
|
|
2655
|
-
}
|
|
2656
|
-
values(placeholderValues) {
|
|
2657
|
-
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
2658
|
-
this.logger.logQuery(this.query.sql, params);
|
|
2659
|
-
return this.stmt.raw().all(...params);
|
|
2660
|
-
}
|
|
2661
|
-
/** @internal */
|
|
2662
|
-
isResponseInArrayMode() {
|
|
2663
|
-
return this._isResponseInArrayMode;
|
|
2664
|
-
}
|
|
2665
|
-
};
|
|
2666
|
-
//#endregion
|
|
2667
|
-
//#region node_modules/drizzle-orm/better-sqlite3/driver.js
|
|
2668
|
-
var BetterSQLite3Database = class extends BaseSQLiteDatabase {
|
|
2669
|
-
static [entityKind] = "BetterSQLite3Database";
|
|
2670
|
-
};
|
|
2671
|
-
function construct(client, config = {}) {
|
|
2672
|
-
const dialect = new SQLiteSyncDialect({ casing: config.casing });
|
|
2673
|
-
let logger;
|
|
2674
|
-
if (config.logger === true) logger = new DefaultLogger();
|
|
2675
|
-
else if (config.logger !== false) logger = config.logger;
|
|
2676
|
-
let schema;
|
|
2677
|
-
if (config.schema) {
|
|
2678
|
-
const tablesConfig = extractTablesRelationalConfig(config.schema, createTableRelationsHelpers);
|
|
2679
|
-
schema = {
|
|
2680
|
-
fullSchema: config.schema,
|
|
2681
|
-
schema: tablesConfig.tables,
|
|
2682
|
-
tableNamesMap: tablesConfig.tableNamesMap
|
|
2683
|
-
};
|
|
2684
|
-
}
|
|
2685
|
-
const db = new BetterSQLite3Database("sync", dialect, new BetterSQLiteSession(client, dialect, schema, { logger }), schema);
|
|
2686
|
-
db.$client = client;
|
|
2687
|
-
return db;
|
|
2688
|
-
}
|
|
2689
|
-
function drizzle(...params) {
|
|
2690
|
-
if (params[0] === void 0 || typeof params[0] === "string") return construct(params[0] === void 0 ? new Client() : new Client(params[0]), params[1]);
|
|
2691
|
-
if (isConfig(params[0])) {
|
|
2692
|
-
const { connection, client, ...drizzleConfig } = params[0];
|
|
2693
|
-
if (client) return construct(client, drizzleConfig);
|
|
2694
|
-
if (typeof connection === "object") {
|
|
2695
|
-
const { source, ...options } = connection;
|
|
2696
|
-
return construct(new Client(source, options), drizzleConfig);
|
|
2697
|
-
}
|
|
2698
|
-
return construct(new Client(connection), drizzleConfig);
|
|
2699
|
-
}
|
|
2700
|
-
return construct(params[0], params[1]);
|
|
2701
|
-
}
|
|
2702
|
-
((drizzle2) => {
|
|
2703
|
-
function mock(config) {
|
|
2704
|
-
return construct({}, config);
|
|
2705
|
-
}
|
|
2706
|
-
drizzle2.mock = mock;
|
|
2707
|
-
})(drizzle || (drizzle = {}));
|
|
2708
|
-
//#endregion
|
|
2709
|
-
export { drizzle };
|
|
2583
|
+
export { BaseSQLiteDatabase as a, extractTablesRelationalConfig as c, NoopCache as i, DefaultLogger as l, SQLiteSession as n, SQLiteSyncDialect as o, SQLiteTransaction as r, createTableRelationsHelpers as s, SQLitePreparedQuery as t, NoopLogger as u };
|
package/package.json
CHANGED