jukebox-media-server 0.5.1 → 0.7.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.
Files changed (32) hide show
  1. package/README.md +18 -20
  2. package/dist/client/assets/{Watch-Ja4PAA8Y.js → Watch-BiR2iXrC.js} +33 -33
  3. package/dist/client/assets/index-CKZbQJYY.css +1 -0
  4. package/dist/client/assets/index-CoxOmmZz.js +87 -0
  5. package/dist/client/index.html +2 -2
  6. package/dist/client/sw.js +1 -1
  7. package/dist/server/HttpApiBuilder-DWwOvarr.js +42786 -0
  8. package/dist/server/better-sqlite3-CkwhTVXW.js +129 -0
  9. package/dist/server/bun-database-CqinoQgb.js +14 -0
  10. package/dist/server/bun-database-oVoIc-C8.js +15 -0
  11. package/dist/server/bun-sqlite-Bk_yjDLi.js +134 -0
  12. package/dist/server/chunk-CrysgU_F.js +36 -0
  13. package/dist/server/config-CCAveLuN.js +12 -0
  14. package/dist/server/esm-Dm4Gq4cv.js +40975 -0
  15. package/dist/server/index.js +3884 -5603
  16. package/dist/server/{indexes-VMR6QVVl.js → indexes-vPbUiKXP.js} +4 -100
  17. package/dist/server/{better-sqlite3-Dy_YhTFe.js → logger-ygdFSBOU.js} +243 -368
  18. package/dist/server/{migrator-CWPnMvx5.js → migrator-8uumkKvi.js} +1 -7
  19. package/dist/server/migrator-CpDrzLY4.js +8 -0
  20. package/dist/server/migrator-D9F-ETAB.js +8 -0
  21. package/dist/server/schema-1sWMC8cP.js +59 -0
  22. package/dist/server/schema-B7-kIAVY.js +145 -0
  23. package/dist/server/select-62doObBa.js +101 -0
  24. package/drizzle/0011_loose_eternity.sql +1 -0
  25. package/drizzle/meta/0011_snapshot.json +1066 -0
  26. package/drizzle/meta/_journal.json +8 -1
  27. package/drizzle-telemetry/0000_great_thor.sql +45 -0
  28. package/drizzle-telemetry/meta/0000_snapshot.json +320 -0
  29. package/drizzle-telemetry/meta/_journal.json +13 -0
  30. package/package.json +22 -8
  31. package/dist/client/assets/index-AENKhh_8.css +0 -1
  32. package/dist/client/assets/index-Cm9WIhoR.js +0 -58
@@ -0,0 +1,129 @@
1
+ import { P as entityKind, S as fillPlaceholders, T as sql, m as mapResultRow, p as isConfig } from "./indexes-vPbUiKXP.js";
2
+ import { a as SQLiteTransaction, c as SQLiteSyncDialect, i as SQLiteSession, l as createTableRelationsHelpers, n as NoopLogger, o as NoopCache, r as SQLitePreparedQuery, s as BaseSQLiteDatabase, t as DefaultLogger, u as extractTablesRelationalConfig } from "./logger-ygdFSBOU.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 { BetterSQLite3Database, BetterSQLiteSession, BetterSQLiteTransaction, PreparedQuery, drizzle };
@@ -0,0 +1,14 @@
1
+ import { i as telemetryDatabasePath, n as schema_exports } from "./schema-1sWMC8cP.js";
2
+ //#region src/telemetry/bun-database.ts
3
+ async function createBunTelemetryDatabase(migrationsFolder) {
4
+ const { Database: BunDatabase } = await import("bun:sqlite");
5
+ const { drizzle } = await import("./bun-sqlite-Bk_yjDLi.js");
6
+ const { migrate } = await import("./migrator-D9F-ETAB.js");
7
+ const sqlite = new BunDatabase(telemetryDatabasePath);
8
+ sqlite.exec("PRAGMA journal_mode = WAL");
9
+ const db = drizzle(sqlite, { schema: schema_exports });
10
+ migrate(db, { migrationsFolder });
11
+ return db;
12
+ }
13
+ //#endregion
14
+ export { createBunTelemetryDatabase };
@@ -0,0 +1,15 @@
1
+ import { n as databasePath } from "./config-CCAveLuN.js";
2
+ import { c as schema_exports } from "./schema-B7-kIAVY.js";
3
+ //#region src/database/bun-database.ts
4
+ async function createBunDatabase(migrationsFolder) {
5
+ const { Database: BunDatabase } = await import("bun:sqlite");
6
+ const { drizzle } = await import("./bun-sqlite-Bk_yjDLi.js");
7
+ const { migrate } = await import("./migrator-D9F-ETAB.js");
8
+ const sqlite = new BunDatabase(databasePath);
9
+ sqlite.exec("PRAGMA foreign_keys = ON");
10
+ const db = drizzle(sqlite, { schema: schema_exports });
11
+ migrate(db, { migrationsFolder });
12
+ return db;
13
+ }
14
+ //#endregion
15
+ export { createBunDatabase };
@@ -0,0 +1,134 @@
1
+ import { P as entityKind, S as fillPlaceholders, T as sql, m as mapResultRow, p as isConfig } from "./indexes-vPbUiKXP.js";
2
+ import { a as SQLiteTransaction, c as SQLiteSyncDialect, i as SQLiteSession, l as createTableRelationsHelpers, n as NoopLogger, r as SQLitePreparedQuery, s as BaseSQLiteDatabase, t as DefaultLogger, u as extractTablesRelationalConfig } from "./logger-ygdFSBOU.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 };
@@ -0,0 +1,36 @@
1
+ import { createRequire } from "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
+ var __exportAll = (all, no_symbols) => {
11
+ let target = {};
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
+ return target;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
+ key = keys[i];
22
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
+ get: ((k) => from[k]).bind(null, key),
24
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
+ });
26
+ }
27
+ return to;
28
+ };
29
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
+ value: mod,
32
+ enumerable: true
33
+ }) : target, mod));
34
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
35
+ //#endregion
36
+ export { __toESM as a, __require as i, __exportAll as n, __reExport as r, __commonJSMin as t };
@@ -0,0 +1,12 @@
1
+ import { mkdirSync } from "fs";
2
+ import { join } from "path";
3
+ import { homedir } from "os";
4
+ //#region src/config/index.ts
5
+ const configDirectory = join(homedir(), ".jukebox");
6
+ join(configDirectory, "config.json");
7
+ const databasePath = join(configDirectory, "jukebox.db");
8
+ function ensureConfigDirectory() {
9
+ mkdirSync(configDirectory, { recursive: true });
10
+ }
11
+ //#endregion
12
+ export { databasePath as n, ensureConfigDirectory as r, configDirectory as t };