@voscarmv/aimessagestore 1.0.6 → 1.0.8
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 +7 -3
- package/dist/migrate.d.ts +3 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +34 -0
- package/dist/migrate.js.map +1 -0
- package/package.json +6 -2
- package/src/migrate.ts +36 -0
package/README.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Message storage and retrieval backend for [@voscarmv/aichatbot](https://www.npmjs.com/package/@voscarmv/aichatbot)
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
-
You may
|
|
7
|
+
You may use this as per [the demo.](https://github.com/voscarmv/aibot)
|
|
8
|
+
|
|
9
|
+
Or as a standalone backend for a @voscarmv/aichatbot project. For that, install `postgresql` and create a new username, password and database, with this script:
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
#!/bin/bash
|
|
@@ -33,4 +35,6 @@ echo "DATABASE_URL=postgres://$PGUSER:$PASS@localhost/$DB" >> .env
|
|
|
33
35
|
echo "✅ Database, user, and .env file created. Edit .env if needed."
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
You may now run `npx migrate --dburl postgres://username:password@host/database` with your own DB URL to migrate the schema.
|
|
39
|
+
|
|
40
|
+
And then just run an instance of `MessageStoreBackend()` as in [this example.](https://github.com/voscarmv/aibot/blob/main/src/server.ts)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":""}
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import { migrate } from 'drizzle-orm/node-postgres/migrator';
|
|
5
|
+
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
6
|
+
import { program } from 'commander';
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
program.name('migrate')
|
|
10
|
+
.description('Migrate the postgres database for server')
|
|
11
|
+
.option('-u, --username <string>', 'DB Username')
|
|
12
|
+
.option('-p, --password <string>', 'DB Password')
|
|
13
|
+
.option('-h, --host <string>', 'DB Host', 'localhost')
|
|
14
|
+
.option('-n, --name <string>', 'DB Name')
|
|
15
|
+
.option('-d, --dburl <string>', 'DB URL, e.g. postgres://username:password@host/database');
|
|
16
|
+
program.parse();
|
|
17
|
+
const options = program.opts();
|
|
18
|
+
const host = options.host ? options.host : 'localhost';
|
|
19
|
+
const dbUrl = options.dburl ? options.dburl : `postgres://${options.username}:${options.password}@${host}/${options.name}`;
|
|
20
|
+
(async () => {
|
|
21
|
+
try {
|
|
22
|
+
const db = drizzle(dbUrl);
|
|
23
|
+
console.log(`${__dirname}/drizzle`);
|
|
24
|
+
await migrate(db, { migrationsFolder: `${__dirname}/drizzle` });
|
|
25
|
+
console.log('Done.');
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.log('Error.');
|
|
30
|
+
console.log(e.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
34
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,EAA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AAC,OAAO,CAAM,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voscarmv/aimessagestore",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Message storage and retrieval for aichatbot framework ",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -37,7 +37,11 @@
|
|
|
37
37
|
"db:generate": "npx drizzle-kit generate",
|
|
38
38
|
"db:migrate": "npx drizzle-kit migrate"
|
|
39
39
|
},
|
|
40
|
+
"bin": {
|
|
41
|
+
"migrate": "./dist/migrate.js"
|
|
42
|
+
},
|
|
40
43
|
"dependencies": {
|
|
44
|
+
"commander": "^14.0.2",
|
|
41
45
|
"cors": "^2.8.5",
|
|
42
46
|
"dotenv": "^17.2.3",
|
|
43
47
|
"drizzle-orm": "^0.45.1",
|
|
@@ -56,4 +60,4 @@
|
|
|
56
60
|
"drizzle-kit": "^0.31.8",
|
|
57
61
|
"typescript": "^5.9.3"
|
|
58
62
|
}
|
|
59
|
-
}
|
|
63
|
+
}
|
package/src/migrate.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import { migrate } from 'drizzle-orm/node-postgres/migrator';
|
|
5
|
+
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
6
|
+
import { program } from 'commander';
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
program.name('migrate')
|
|
11
|
+
.description('Migrate the postgres database for server')
|
|
12
|
+
.option('-u, --username <string>', 'DB Username')
|
|
13
|
+
.option('-p, --password <string>', 'DB Password')
|
|
14
|
+
.option('-h, --host <string>', 'DB Host', 'localhost')
|
|
15
|
+
.option('-n, --name <string>', 'DB Name')
|
|
16
|
+
.option('-d, --dburl <string>', 'DB URL, e.g. postgres://username:password@host/database')
|
|
17
|
+
|
|
18
|
+
program.parse();
|
|
19
|
+
const options = program.opts();
|
|
20
|
+
|
|
21
|
+
const host = options.host ? options.host : 'localhost';
|
|
22
|
+
const dbUrl = options.dburl ? options.dburl : `postgres://${options.username}:${options.password}@${host}/${options.name}`;
|
|
23
|
+
|
|
24
|
+
(async () => {
|
|
25
|
+
try {
|
|
26
|
+
const db = drizzle(dbUrl);
|
|
27
|
+
console.log(`${__dirname}/drizzle`);
|
|
28
|
+
await migrate(db, { migrationsFolder: `${__dirname}/drizzle` });
|
|
29
|
+
console.log('Done.')
|
|
30
|
+
process.exit(0);
|
|
31
|
+
} catch (e: any) {
|
|
32
|
+
console.log('Error.');
|
|
33
|
+
console.log(e.message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
})();
|