@liquidmetal-ai/raindrop 0.4.3 → 0.4.6
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 +36 -36
- package/dist/base-command.d.ts +1 -1
- package/dist/base-command.d.ts.map +1 -1
- package/dist/base-command.js +2 -2
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +4 -0
- package/dist/codegen.test.js +33 -1
- package/dist/commands/object/delete.d.ts.map +1 -1
- package/dist/commands/object/delete.js +15 -33
- package/dist/commands/object/get.d.ts.map +1 -1
- package/dist/commands/object/get.js +15 -31
- package/dist/commands/object/list.d.ts.map +1 -1
- package/dist/commands/object/list.js +16 -33
- package/dist/commands/object/put.d.ts.map +1 -1
- package/dist/commands/object/put.js +16 -36
- package/oclif.manifest.json +1030 -1030
- package/package.json +1 -1
- package/templates/db/package.json +2 -1
- package/templates/db/scripts/create_migration.mts +24 -5
- package/templates/db/scripts/seed.ts.hbs +0 -1
- package/templates/init/tsconfig.json +2 -2
package/package.json
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"scripts": {
|
|
3
3
|
"create-migration": "npx ts-node ./scripts/create_migration.mts",
|
|
4
4
|
"postinstall": "for dir in ./prisma/*/; do dbName=$(basename \"$dir\"); npx prisma generate --schema \"./prisma/$dbName/schema.prisma\"; done",
|
|
5
|
+
"clean-seed": "find ./db -name '*seed*' -type f -delete",
|
|
5
6
|
"seed:createSql": "npx ts-node ./scripts/seed-sql.mts",
|
|
6
|
-
"render-db": "npm run create-migration && npm run seed:createSql"
|
|
7
|
+
"render-db": "npm run clean-seed && npm run create-migration && npm run seed:createSql"
|
|
7
8
|
},
|
|
8
9
|
"dependencies": {
|
|
9
10
|
"kysely": "^0.27.2",
|
|
@@ -31,7 +31,9 @@ for (const dbName of dbFolders) {
|
|
|
31
31
|
process.exit(0);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const database1 = await makeD1Database({
|
|
34
|
+
const database1 = await makeD1Database({
|
|
35
|
+
migrations: migrationFolderBasepath,
|
|
36
|
+
});
|
|
35
37
|
const sqlData = await database1
|
|
36
38
|
.prepare(`SELECT sql FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%';`)
|
|
37
39
|
.raw();
|
|
@@ -45,14 +47,31 @@ for (const dbName of dbFolders) {
|
|
|
45
47
|
const db = new Database(tempFile);
|
|
46
48
|
// Create the tables in the database
|
|
47
49
|
for (const [sql] of sqlData) {
|
|
48
|
-
db.exec(sql);
|
|
50
|
+
db.exec(sql as string);
|
|
49
51
|
}
|
|
50
52
|
db.close();
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
// Generate migration name: use argv._[0] or next number with Unix timestamp
|
|
55
|
+
let migrationName: string;
|
|
56
|
+
if (argv._[0]) {
|
|
57
|
+
migrationName = argv._[0];
|
|
58
|
+
} else {
|
|
59
|
+
// Find the highest numbered migration to get the next number
|
|
60
|
+
const existingMigrations = await glob(`${migrationFolderBasepath}/*.sql`);
|
|
61
|
+
const migrationNumbers = existingMigrations
|
|
62
|
+
.map((file) => {
|
|
63
|
+
const match = file.match(/(\d+)_/);
|
|
64
|
+
return match ? parseInt(match[1]!) : -1;
|
|
65
|
+
})
|
|
66
|
+
.filter((num) => num >= 0);
|
|
67
|
+
|
|
68
|
+
const nextNumber = Math.max(...migrationNumbers, -1) + 1;
|
|
69
|
+
const timestamp = Math.floor(Date.now() / 1000); // Unix timestamp
|
|
70
|
+
migrationName = `${nextNumber.toString().padStart(4, '0')}_${timestamp}`;
|
|
71
|
+
}
|
|
54
72
|
|
|
55
|
-
|
|
73
|
+
console.log(`Migration name: ${migrationName}`);
|
|
74
|
+
const migrationFilePath = `${migrationFolderBasepath}/${migrationName}.sql`;
|
|
56
75
|
|
|
57
76
|
console.log('Created migration: ' + chalk.green(migrationFilePath));
|
|
58
77
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Kysely } from 'kysely';
|
|
2
2
|
import { DB } from '../src/db/{{dbName}}/types';
|
|
3
|
-
import { AddressType } from '../src/db/{{dbName}}/enums';
|
|
4
3
|
import { D1Dialect } from 'kysely-d1';
|
|
5
4
|
import { makeD1Database } from '@liquidmetal-ai/in-memory-d1';
|
|
6
5
|
import fs from 'fs';
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"incremental": false,
|
|
13
13
|
"isolatedModules": true,
|
|
14
14
|
"jsx": "react",
|
|
15
|
-
"lib": ["
|
|
15
|
+
"lib": ["es2022"],
|
|
16
16
|
"module": "es2022",
|
|
17
17
|
"moduleDetection": "force",
|
|
18
18
|
"moduleResolution": "Bundler",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"resolveJsonModule": true,
|
|
23
23
|
"skipLibCheck": true,
|
|
24
24
|
"strict": true,
|
|
25
|
-
"target": "
|
|
25
|
+
"target": "es2022"
|
|
26
26
|
},
|
|
27
27
|
"exclude": ["test"]
|
|
28
28
|
}
|