@elizaos/plugin-sql 1.0.0-beta.48 → 1.0.0-beta.49
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.js +163 -107
- package/dist/index.js.map +1 -1
- package/dist/migrate.js +11 -5
- package/dist/migrate.js.map +1 -1
- package/package.json +3 -3
package/dist/migrate.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-EYE2J2N6.js";
|
|
6
6
|
|
|
7
7
|
// src/migrate.ts
|
|
8
|
-
import { logger } from "@elizaos/core";
|
|
8
|
+
import { logger, stringToUuid } from "@elizaos/core";
|
|
9
9
|
import { config } from "dotenv";
|
|
10
10
|
import os from "node:os";
|
|
11
11
|
import path from "node:path";
|
|
@@ -23,10 +23,16 @@ async function runMigrations() {
|
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
} else {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
let elizaDbDir = process.env.PGLITE_DATA_DIR;
|
|
27
|
+
if (!elizaDbDir) {
|
|
28
|
+
const homeDir = os.homedir();
|
|
29
|
+
const elizaDir = path.join(homeDir, ".eliza");
|
|
30
|
+
elizaDbDir = path.join(elizaDir, "projects", stringToUuid(process.cwd()), "pglite");
|
|
31
|
+
logger.info(`PGLITE_DATA_DIR not set, defaulting to project-specific path: ${elizaDbDir}`);
|
|
32
|
+
} else {
|
|
33
|
+
logger.info(`Using PGLITE_DATA_DIR: ${elizaDbDir}`);
|
|
34
|
+
}
|
|
35
|
+
logger.info("Using PGlite database at:", elizaDbDir);
|
|
30
36
|
const clientManager = new PGliteClientManager({
|
|
31
37
|
dataDir: elizaDbDir
|
|
32
38
|
});
|
package/dist/migrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrate.ts"],"sourceRoot":"./","sourcesContent":["import { logger } from '@elizaos/core';\nimport { config } from 'dotenv';\nimport { PGliteClientManager } from './pglite/manager.js';\nimport { PostgresConnectionManager } from './pg/manager.js';\nimport os from 'node:os';\nimport path from 'node:path';\n\nconfig({ path: '../../.env' });\n\n/**\n *
|
|
1
|
+
{"version":3,"sources":["../src/migrate.ts"],"sourceRoot":"./","sourcesContent":["import { logger, stringToUuid } from '@elizaos/core';\nimport { config } from 'dotenv';\nimport { PGliteClientManager } from './pglite/manager.js';\nimport { PostgresConnectionManager } from './pg/manager.js';\nimport os from 'node:os';\nimport path from 'node:path';\n\nconfig({ path: '../../.env' });\n\n/**\n * Executes database migrations using either PostgreSQL or PGlite, depending on environment configuration.\n *\n * If the `POSTGRES_URL` environment variable is set, migrations are run against the specified PostgreSQL database. Otherwise, migrations are run using a PGlite database, with the data directory determined by the `PGLITE_DATA_DIR` environment variable or a project-specific default path.\n *\n * @remark This function terminates the Node.js process upon completion or failure.\n */\nasync function runMigrations() {\n if (process.env.POSTGRES_URL) {\n try {\n const connectionManager = new PostgresConnectionManager(process.env.POSTGRES_URL);\n await connectionManager.initialize();\n await connectionManager.runMigrations();\n // await connectionManager.close();\n logger.success('PostgreSQL migrations completed successfully');\n process.exit(0);\n } catch (error) {\n logger.warn('PostgreSQL migration failed:', error);\n process.exit(1);\n }\n } else {\n let elizaDbDir = process.env.PGLITE_DATA_DIR;\n if (!elizaDbDir) {\n const homeDir = os.homedir();\n const elizaDir = path.join(homeDir, '.eliza');\n // Construct project-specific path\n elizaDbDir = path.join(elizaDir, 'projects', stringToUuid(process.cwd()), 'pglite');\n logger.info(`PGLITE_DATA_DIR not set, defaulting to project-specific path: ${elizaDbDir}`);\n } else {\n logger.info(`Using PGLITE_DATA_DIR: ${elizaDbDir}`);\n }\n\n logger.info('Using PGlite database at:', elizaDbDir);\n const clientManager = new PGliteClientManager({\n dataDir: elizaDbDir,\n });\n\n try {\n await clientManager.initialize();\n await clientManager.runMigrations();\n logger.success('PGlite migrations completed successfully');\n await clientManager.close();\n process.exit(0);\n } catch (error) {\n logger.error('PGlite migration failed:', error);\n try {\n await clientManager.close();\n } catch (closeError) {\n logger.error('Failed to close PGlite connection:', closeError);\n }\n process.exit(1);\n }\n }\n}\n\nrunMigrations().catch((error) => {\n logger.error('Unhandled error in migrations:', error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAAA,SAAS,QAAQ,oBAAoB;AACrC,SAAS,cAAc;AAGvB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,OAAO,EAAE,MAAM,aAAa,CAAC;AAS7B,eAAe,gBAAgB;AAC7B,MAAI,QAAQ,IAAI,cAAc;AAC5B,QAAI;AACF,YAAM,oBAAoB,IAAI,0BAA0B,QAAQ,IAAI,YAAY;AAChF,YAAM,kBAAkB,WAAW;AACnC,YAAM,kBAAkB,cAAc;AAEtC,aAAO,QAAQ,8CAA8C;AAC7D,cAAQ,KAAK,CAAC;AAAA,IAChB,SAAS,OAAO;AACd,aAAO,KAAK,gCAAgC,KAAK;AACjD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,OAAO;AACL,QAAI,aAAa,QAAQ,IAAI;AAC7B,QAAI,CAAC,YAAY;AACf,YAAM,UAAU,GAAG,QAAQ;AAC3B,YAAM,WAAW,KAAK,KAAK,SAAS,QAAQ;AAE5C,mBAAa,KAAK,KAAK,UAAU,YAAY,aAAa,QAAQ,IAAI,CAAC,GAAG,QAAQ;AAClF,aAAO,KAAK,iEAAiE,UAAU,EAAE;AAAA,IAC3F,OAAO;AACL,aAAO,KAAK,0BAA0B,UAAU,EAAE;AAAA,IACpD;AAEA,WAAO,KAAK,6BAA6B,UAAU;AACnD,UAAM,gBAAgB,IAAI,oBAAoB;AAAA,MAC5C,SAAS;AAAA,IACX,CAAC;AAED,QAAI;AACF,YAAM,cAAc,WAAW;AAC/B,YAAM,cAAc,cAAc;AAClC,aAAO,QAAQ,0CAA0C;AACzD,YAAM,cAAc,MAAM;AAC1B,cAAQ,KAAK,CAAC;AAAA,IAChB,SAAS,OAAO;AACd,aAAO,MAAM,4BAA4B,KAAK;AAC9C,UAAI;AACF,cAAM,cAAc,MAAM;AAAA,MAC5B,SAAS,YAAY;AACnB,eAAO,MAAM,sCAAsC,UAAU;AAAA,MAC/D;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;AA9Ce;AAgDf,cAAc,EAAE,MAAM,CAAC,UAAU;AAC/B,SAAO,MAAM,kCAAkC,KAAK;AACpD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-sql",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@electric-sql/pglite": "^0.2.17",
|
|
30
|
-
"@elizaos/core": "^1.0.0-beta.
|
|
30
|
+
"@elizaos/core": "^1.0.0-beta.49",
|
|
31
31
|
"@types/pg": "8.11.10",
|
|
32
32
|
"drizzle-kit": "^0.30.4",
|
|
33
33
|
"drizzle-orm": "^0.39.1",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"typescript": "5.8.2",
|
|
59
59
|
"whatwg-url": "7.1.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "739eb780a017ed33f2e399b5afef2f8d6f02fd7e"
|
|
62
62
|
}
|