@type32/tauri-sqlite-orm 0.1.18-9 → 0.1.19
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/dist/index.d.mts +176 -160
- package/dist/index.d.ts +176 -160
- package/dist/index.js +516 -394
- package/dist/index.mjs +516 -395
- package/package.json +5 -4
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -63
- package/dist/cli.mjs +0 -62
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@type32/tauri-sqlite-orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "A Drizzle-like ORM for Tauri v2's SQL JS API plugin.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
"author": "Type-32",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^24.
|
|
31
|
+
"@types/node": "^24.10.0",
|
|
32
32
|
"tsup": "^8.5.0",
|
|
33
|
-
"typescript": "^5.9.
|
|
33
|
+
"typescript": "^5.9.3"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tauri-apps/plugin-sql": "^2.3.
|
|
36
|
+
"@tauri-apps/plugin-sql": "^2.3.1",
|
|
37
|
+
"nuxt": "^4.2.0"
|
|
37
38
|
}
|
|
38
39
|
}
|
package/dist/cli.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
// src/cli.ts
|
|
5
|
-
var import_node_fs = require("fs");
|
|
6
|
-
var import_node_path = require("path");
|
|
7
|
-
var help = `
|
|
8
|
-
tauriorm-kit
|
|
9
|
-
|
|
10
|
-
Usage:
|
|
11
|
-
bunx tauriorm-kit generate --out ./src/lib/db-client.ts --schema ./src/lib/schema.ts
|
|
12
|
-
|
|
13
|
-
Options:
|
|
14
|
-
--out <file> Output file where a typed client factory will be written
|
|
15
|
-
--schema <file> Path to a module that exports your tables and optional relations
|
|
16
|
-
--driver <uri> Database URI (default: sqlite:app.db)
|
|
17
|
-
`;
|
|
18
|
-
async function main() {
|
|
19
|
-
const args = process.argv.slice(2);
|
|
20
|
-
if (args.length === 0 || args.includes("-h") || args.includes("--help")) {
|
|
21
|
-
console.log(help);
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
const cmd = args[0];
|
|
25
|
-
if (cmd !== "generate") {
|
|
26
|
-
console.error("Unknown command.\n" + help);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
const outIdx = args.indexOf("--out");
|
|
30
|
-
const schemaIdx = args.indexOf("--schema");
|
|
31
|
-
const driverIdx = args.indexOf("--driver");
|
|
32
|
-
if (outIdx === -1 || schemaIdx === -1) {
|
|
33
|
-
console.error("Missing --out or --schema.\n" + help);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
const outPath = (0, import_node_path.resolve)(process.cwd(), args[outIdx + 1]);
|
|
37
|
-
const schemaPath = (0, import_node_path.resolve)(process.cwd(), args[schemaIdx + 1]);
|
|
38
|
-
const driverUri = driverIdx !== -1 ? args[driverIdx + 1] : "sqlite:app.db";
|
|
39
|
-
const content = `
|
|
40
|
-
import { TauriORM } from "@type32/tauri-sqlite-orm";
|
|
41
|
-
import * as Schema from ${JSON.stringify(schemaPath)};
|
|
42
|
-
|
|
43
|
-
export function createDb() {
|
|
44
|
-
const db = new TauriORM(${JSON.stringify(driverUri)}).configure(
|
|
45
|
-
// collect tables: any export that looks like a table (has _tableName)
|
|
46
|
-
Object.fromEntries(
|
|
47
|
-
Object.entries(Schema).filter(([, v]) => v && typeof v === 'object' && '_tableName' in v)
|
|
48
|
-
) as any,
|
|
49
|
-
// optional relations export
|
|
50
|
-
(Schema as any).relations || {}
|
|
51
|
-
);
|
|
52
|
-
return db;
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
const dir = (0, import_node_path.resolve)(outPath, "..");
|
|
56
|
-
if (!(0, import_node_fs.existsSync)(dir)) (0, import_node_fs.mkdirSync)(dir, { recursive: true });
|
|
57
|
-
(0, import_node_fs.writeFileSync)(outPath, content, "utf8");
|
|
58
|
-
console.log(`\u2714 Wrote ${outPath}`);
|
|
59
|
-
}
|
|
60
|
-
main().catch((err) => {
|
|
61
|
-
console.error(err);
|
|
62
|
-
process.exit(1);
|
|
63
|
-
});
|
package/dist/cli.mjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/cli.ts
|
|
4
|
-
import { writeFileSync, mkdirSync, existsSync } from "fs";
|
|
5
|
-
import { resolve } from "path";
|
|
6
|
-
var help = `
|
|
7
|
-
tauriorm-kit
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
bunx tauriorm-kit generate --out ./src/lib/db-client.ts --schema ./src/lib/schema.ts
|
|
11
|
-
|
|
12
|
-
Options:
|
|
13
|
-
--out <file> Output file where a typed client factory will be written
|
|
14
|
-
--schema <file> Path to a module that exports your tables and optional relations
|
|
15
|
-
--driver <uri> Database URI (default: sqlite:app.db)
|
|
16
|
-
`;
|
|
17
|
-
async function main() {
|
|
18
|
-
const args = process.argv.slice(2);
|
|
19
|
-
if (args.length === 0 || args.includes("-h") || args.includes("--help")) {
|
|
20
|
-
console.log(help);
|
|
21
|
-
process.exit(0);
|
|
22
|
-
}
|
|
23
|
-
const cmd = args[0];
|
|
24
|
-
if (cmd !== "generate") {
|
|
25
|
-
console.error("Unknown command.\n" + help);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
const outIdx = args.indexOf("--out");
|
|
29
|
-
const schemaIdx = args.indexOf("--schema");
|
|
30
|
-
const driverIdx = args.indexOf("--driver");
|
|
31
|
-
if (outIdx === -1 || schemaIdx === -1) {
|
|
32
|
-
console.error("Missing --out or --schema.\n" + help);
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
const outPath = resolve(process.cwd(), args[outIdx + 1]);
|
|
36
|
-
const schemaPath = resolve(process.cwd(), args[schemaIdx + 1]);
|
|
37
|
-
const driverUri = driverIdx !== -1 ? args[driverIdx + 1] : "sqlite:app.db";
|
|
38
|
-
const content = `
|
|
39
|
-
import { TauriORM } from "@type32/tauri-sqlite-orm";
|
|
40
|
-
import * as Schema from ${JSON.stringify(schemaPath)};
|
|
41
|
-
|
|
42
|
-
export function createDb() {
|
|
43
|
-
const db = new TauriORM(${JSON.stringify(driverUri)}).configure(
|
|
44
|
-
// collect tables: any export that looks like a table (has _tableName)
|
|
45
|
-
Object.fromEntries(
|
|
46
|
-
Object.entries(Schema).filter(([, v]) => v && typeof v === 'object' && '_tableName' in v)
|
|
47
|
-
) as any,
|
|
48
|
-
// optional relations export
|
|
49
|
-
(Schema as any).relations || {}
|
|
50
|
-
);
|
|
51
|
-
return db;
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
const dir = resolve(outPath, "..");
|
|
55
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
56
|
-
writeFileSync(outPath, content, "utf8");
|
|
57
|
-
console.log(`\u2714 Wrote ${outPath}`);
|
|
58
|
-
}
|
|
59
|
-
main().catch((err) => {
|
|
60
|
-
console.error(err);
|
|
61
|
-
process.exit(1);
|
|
62
|
-
});
|