@elizaos/plugin-sql 1.0.0-alpha.2 → 1.0.0-alpha.21

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.
@@ -0,0 +1,53 @@
1
+ import {
2
+ PGliteClientManager,
3
+ PostgresConnectionManager,
4
+ __name
5
+ } from "./chunk-2FOOMI3E.js";
6
+
7
+ // src/migrate.ts
8
+ import { logger } from "@elizaos/core";
9
+ import { config } from "dotenv";
10
+ config({ path: "../../.env" });
11
+ async function runMigrations() {
12
+ if (process.env.POSTGRES_URL) {
13
+ try {
14
+ const connectionManager = new PostgresConnectionManager(
15
+ process.env.POSTGRES_URL
16
+ );
17
+ await connectionManager.initialize();
18
+ await connectionManager.runMigrations();
19
+ await connectionManager.close();
20
+ logger.success("PostgreSQL migrations completed successfully");
21
+ process.exit(0);
22
+ } catch (error) {
23
+ logger.warn("PostgreSQL migration failed:", error);
24
+ process.exit(1);
25
+ }
26
+ } else {
27
+ logger.info("Using PGlite database");
28
+ const clientManager = new PGliteClientManager({
29
+ dataDir: "../../pglite"
30
+ });
31
+ try {
32
+ await clientManager.initialize();
33
+ await clientManager.runMigrations();
34
+ logger.success("PGlite migrations completed successfully");
35
+ await clientManager.close();
36
+ process.exit(0);
37
+ } catch (error) {
38
+ logger.error("PGlite migration failed:", error);
39
+ try {
40
+ await clientManager.close();
41
+ } catch (closeError) {
42
+ logger.error("Failed to close PGlite connection:", closeError);
43
+ }
44
+ process.exit(1);
45
+ }
46
+ }
47
+ }
48
+ __name(runMigrations, "runMigrations");
49
+ runMigrations().catch((error) => {
50
+ logger.error("Unhandled error in migrations:", error);
51
+ process.exit(1);
52
+ });
53
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/migrate.ts"],"sourceRoot":"./","sourcesContent":["import { logger } from \"@elizaos/core\";\nimport { config } from \"dotenv\";\nimport { PGliteClientManager } from \"./pg-lite/manager.js\";\nimport { PostgresConnectionManager } from \"./pg/manager.js\";\n\nconfig({ path: \"../../.env\" });\n\n/**\n * Runs the database migrations based on the environment variable POSTGRES_URL.\n * If the POSTGRES_URL is provided, it indicates the use of a PostgreSQL database and the corresponding migration logic needs to be implemented.\n * If POSTGRES_URL is not provided, it uses a PGlite database and runs the migrations on it.\n * @returns {Promise<void>} A promise that resolves once the migrations are completed successfully or rejects if an error occurs.\n */\nasync function runMigrations() {\n\tif (process.env.POSTGRES_URL) {\n\t\ttry {\n\t\t\tconst connectionManager = new PostgresConnectionManager(\n\t\t\t\tprocess.env.POSTGRES_URL,\n\t\t\t);\n\t\t\tawait connectionManager.initialize();\n\t\t\tawait connectionManager.runMigrations();\n\t\t\tawait connectionManager.close();\n\t\t\tlogger.success(\"PostgreSQL migrations completed successfully\");\n\t\t\tprocess.exit(0);\n\t\t} catch (error) {\n\t\t\tlogger.warn(\"PostgreSQL migration failed:\", error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t} else {\n\t\tlogger.info(\"Using PGlite database\");\n\t\tconst clientManager = new PGliteClientManager({\n\t\t\tdataDir: \"../../pglite\",\n\t\t});\n\n\t\ttry {\n\t\t\tawait clientManager.initialize();\n\t\t\tawait clientManager.runMigrations();\n\t\t\tlogger.success(\"PGlite migrations completed successfully\");\n\t\t\tawait clientManager.close();\n\t\t\tprocess.exit(0);\n\t\t} catch (error) {\n\t\t\tlogger.error(\"PGlite migration failed:\", error);\n\t\t\ttry {\n\t\t\t\tawait clientManager.close();\n\t\t\t} catch (closeError) {\n\t\t\t\tlogger.error(\"Failed to close PGlite connection:\", closeError);\n\t\t\t}\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n}\n\nrunMigrations().catch((error) => {\n\tlogger.error(\"Unhandled error in migrations:\", error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,cAAc;AAIvB,OAAO,EAAE,MAAM,aAAa,CAAC;AAQ7B,eAAe,gBAAgB;AAC9B,MAAI,QAAQ,IAAI,cAAc;AAC7B,QAAI;AACH,YAAM,oBAAoB,IAAI;AAAA,QAC7B,QAAQ,IAAI;AAAA,MACb;AACA,YAAM,kBAAkB,WAAW;AACnC,YAAM,kBAAkB,cAAc;AACtC,YAAM,kBAAkB,MAAM;AAC9B,aAAO,QAAQ,8CAA8C;AAC7D,cAAQ,KAAK,CAAC;AAAA,IACf,SAAS,OAAO;AACf,aAAO,KAAK,gCAAgC,KAAK;AACjD,cAAQ,KAAK,CAAC;AAAA,IACf;AAAA,EACD,OAAO;AACN,WAAO,KAAK,uBAAuB;AACnC,UAAM,gBAAgB,IAAI,oBAAoB;AAAA,MAC7C,SAAS;AAAA,IACV,CAAC;AAED,QAAI;AACH,YAAM,cAAc,WAAW;AAC/B,YAAM,cAAc,cAAc;AAClC,aAAO,QAAQ,0CAA0C;AACzD,YAAM,cAAc,MAAM;AAC1B,cAAQ,KAAK,CAAC;AAAA,IACf,SAAS,OAAO;AACf,aAAO,MAAM,4BAA4B,KAAK;AAC9C,UAAI;AACH,cAAM,cAAc,MAAM;AAAA,MAC3B,SAAS,YAAY;AACpB,eAAO,MAAM,sCAAsC,UAAU;AAAA,MAC9D;AACA,cAAQ,KAAK,CAAC;AAAA,IACf;AAAA,EACD;AACD;AArCe;AAuCf,cAAc,EAAE,MAAM,CAAC,UAAU;AAChC,SAAO,MAAM,kCAAkC,KAAK;AACpD,UAAQ,KAAK,CAAC;AACf,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-sql",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.21",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -23,24 +23,26 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@electric-sql/pglite": "^0.2.17",
26
- "@elizaos/core": "^1.0.0-alpha.2",
26
+ "@elizaos/core": "^1.0.0-alpha.21",
27
27
  "@types/pg": "8.11.10",
28
28
  "drizzle-kit": "^0.30.4",
29
29
  "drizzle-orm": "^0.39.1",
30
- "pg": "8.13.1"
30
+ "pg": "^8.13.3"
31
31
  },
32
32
  "devDependencies": {
33
33
  "dockerode": "^4.0.4",
34
34
  "tsup": "8.4.0"
35
35
  },
36
36
  "scripts": {
37
- "build": "tsup --format esm --dts",
38
- "dev": "tsup --format esm --dts --watch",
37
+ "build": "tsup",
38
+ "dev": "tsup --watch",
39
39
  "migrate:generate": "drizzle-kit generate:pg",
40
- "migrate": "tsup src/migrate.ts --format esm --onSuccess \"node dist/migrate.js\""
40
+ "migrate": "tsup src/migrate.ts --format esm --clean=false --onSuccess=\"node dist/migrate.js\"",
41
+ "lint": "biome check ./src --config-path=./ --apply-unsafe && biome format ./ --config-path=./ --write",
42
+ "clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo"
41
43
  },
42
44
  "peerDependencies": {
43
45
  "typescript": "5.8.2"
44
46
  },
45
- "gitHead": "e638f35197577f1b0c6adc6ae5b019b40610ad26"
47
+ "gitHead": "a1bb2c8ab6805f9585540a9a9e6b6ae39bfd4ed1"
46
48
  }
package/dist/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { Plugin, UUID, IDatabaseAdapter } from '@elizaos/core';
2
-
3
- declare function createDatabaseAdapter(config: {
4
- dataDir?: string;
5
- postgresUrl?: string;
6
- }, agentId: UUID): IDatabaseAdapter;
7
- declare const drizzlePlugin: Plugin;
8
-
9
- export { createDatabaseAdapter, drizzlePlugin as default };