@elizaos/plugin-sql 1.0.0-alpha.30 → 1.0.0-alpha.31
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.
|
@@ -159,6 +159,7 @@ var PGliteClientManager = class {
|
|
|
159
159
|
logger.info("Migrations completed successfully!");
|
|
160
160
|
} catch (error) {
|
|
161
161
|
logger.error("Failed to run database migrations (pglite):", error);
|
|
162
|
+
console.trace(error);
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
};
|
|
@@ -360,6 +361,7 @@ var PostgresConnectionManager = class {
|
|
|
360
361
|
logger2.info("Migrations completed successfully!");
|
|
361
362
|
} catch (error) {
|
|
362
363
|
logger2.error("Failed to run database migrations (pg):", error);
|
|
364
|
+
console.trace(error);
|
|
363
365
|
}
|
|
364
366
|
}
|
|
365
367
|
};
|
|
@@ -369,4 +371,4 @@ export {
|
|
|
369
371
|
PGliteClientManager,
|
|
370
372
|
PostgresConnectionManager
|
|
371
373
|
};
|
|
372
|
-
//# sourceMappingURL=chunk-
|
|
374
|
+
//# sourceMappingURL=chunk-RJZ6IRRA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pg-lite/manager.ts","../src/pg/manager.ts"],"sourceRoot":"./","sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { PGlite, type PGliteOptions } from \"@electric-sql/pglite\";\nimport { fuzzystrmatch } from \"@electric-sql/pglite/contrib/fuzzystrmatch\";\nimport { vector } from \"@electric-sql/pglite/vector\";\nimport { logger } from \"@elizaos/core\";\nimport { drizzle } from \"drizzle-orm/pglite\";\nimport { migrate } from \"drizzle-orm/pglite/migrator\";\nimport type { IDatabaseClientManager } from \"../types\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Class representing a database client manager for PGlite.\n * @implements { IDatabaseClientManager }\n */\nexport class PGliteClientManager implements IDatabaseClientManager<PGlite> {\n\tprivate client: PGlite;\n\tprivate shuttingDown = false;\n\tprivate readonly shutdownTimeout = 500;\n\n\t/**\n\t * Constructor for creating a new instance of PGlite with the provided options.\n\t * Initializes the PGlite client with additional extensions.\n\t * @param {PGliteOptions} options - The options to configure the PGlite client.\n\t */\n\tconstructor(options: PGliteOptions) {\n\t\tthis.client = new PGlite({\n\t\t\t...options,\n\t\t\textensions: {\n\t\t\t\tvector,\n\t\t\t\tfuzzystrmatch,\n\t\t\t},\n\t\t});\n\t\tthis.setupShutdownHandlers();\n\t}\n\n\t/**\n\t * Retrieves the PostgreSQL lite connection.\n\t *\n\t * @returns {PGlite} The PostgreSQL lite connection.\n\t * @throws {Error} If the client manager is currently shutting down.\n\t */\n\tpublic getConnection(): PGlite {\n\t\tif (this.shuttingDown) {\n\t\t\tthrow new Error(\"Client manager is shutting down\");\n\t\t}\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Initiates a graceful shutdown of the PGlite client.\n\t * Checks if the client is already in the process of shutting down.\n\t * Logs the start of shutdown process and sets shuttingDown flag to true.\n\t * Sets a timeout for the shutdown process and forces closure of database connection if timeout is reached.\n\t * Handles the shutdown process, closes the client connection, clears the timeout, and logs the completion of shutdown.\n\t * Logs any errors that occur during the shutdown process.\n\t */\n\tprivate async gracefulShutdown() {\n\t\tif (this.shuttingDown) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.shuttingDown = true;\n\t\tlogger.info(\"Starting graceful shutdown of PGlite client...\");\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tlogger.warn(\n\t\t\t\t\"Shutdown timeout reached, forcing database connection closure...\",\n\t\t\t);\n\t\t\tthis.client.close().finally(() => {\n\t\t\t\tprocess.exit(1);\n\t\t\t});\n\t\t}, this.shutdownTimeout);\n\n\t\ttry {\n\t\t\tawait this.client.close();\n\t\t\tclearTimeout(timeout);\n\t\t\tlogger.info(\"PGlite client shutdown completed successfully\");\n\t\t\tprocess.exit(0);\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Error during graceful shutdown:\", error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\t/**\n\t * Sets up shutdown handlers for SIGINT, SIGTERM, and beforeExit events to gracefully shutdown the application.\n\t * @private\n\t */\n\tprivate setupShutdownHandlers() {\n\t\tprocess.on(\"SIGINT\", async () => {\n\t\t\tawait this.gracefulShutdown();\n\t\t});\n\n\t\tprocess.on(\"SIGTERM\", async () => {\n\t\t\tawait this.gracefulShutdown();\n\t\t});\n\n\t\tprocess.on(\"beforeExit\", async () => {\n\t\t\tawait this.gracefulShutdown();\n\t\t});\n\t}\n\n\t/**\n\t * Asynchronously checks if migrations exist in the database.\n\t * @returns {Promise<boolean>} A Promise that resolves to true if migrations exist, otherwise false.\n\t */\n\tprivate async hasMigrations(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.client.query(\n\t\t\t\t\"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '__drizzle_migrations')\"\n\t\t\t);\n\t\t\treturn (result.rows[0] as any).exists;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to check migrations:\", error);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\n\t/**\n\t * Initializes the client for PGlite.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves when the client is initialized successfully\n\t */\n\tpublic async initialize(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.client.waitReady;\n\t\t\tlogger.info(\"PGlite client initialized successfully\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to initialize PGlite client:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously closes the resource. If the resource is not already shutting down,\n\t * it performs a graceful shutdown before closing.\n\t *\n\t * @returns A promise that resolves once the resource has been closed.\n\t */\n\tpublic async close(): Promise<void> {\n\t\tif (!this.shuttingDown) {\n\t\t\tawait this.gracefulShutdown();\n\t\t}\n\t}\n\n\t/**\n\t * Check if the system is currently shutting down.\n\t *\n\t * @returns {boolean} True if the system is shutting down, false otherwise.\n\t */\n\tpublic isShuttingDown(): boolean {\n\t\treturn this.shuttingDown;\n\t}\n\n\t/**\n\t * Asynchronously runs database migrations using Drizzle.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves once the migrations are completed successfully.\n\t */\n\tasync runMigrations(): Promise<void> {\n\t\ttry {\n\t\t\tconst db = drizzle(this.client);\n\t\t\tif (await this.hasMigrations()) {\n\t\t\t\tlogger.info(\"Migrations already exist, skipping...\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait migrate(db, {\n\t\t\t\tmigrationsFolder: path.resolve(__dirname, \"../drizzle/migrations\"),\n\t\t\t});\n\t\t\tlogger.info(\"Migrations completed successfully!\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to run database migrations (pglite):\", error);\n\t\t\t// throw error;\n\t\t\tconsole.trace(error);\n\t\t}\n\t}\n}\n","import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { logger } from \"@elizaos/core\";\nimport { drizzle } from \"drizzle-orm/node-postgres\";\nimport { migrate } from \"drizzle-orm/node-postgres/migrator\";\nimport pkg, { type Pool as PgPool } from \"pg\";\nimport type { IDatabaseClientManager } from \"../types\";\n\nconst { Pool } = pkg;\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Manages connections to a PostgreSQL database using a connection pool.\n * Implements IDatabaseClientManager interface.\n */\n\nexport class PostgresConnectionManager\n\timplements IDatabaseClientManager<PgPool>\n{\n\tprivate pool: PgPool;\n\tprivate isShuttingDown = false;\n\tprivate readonly connectionTimeout: number = 5000;\n\n\t/**\n\t * Constructor for creating a connection pool.\n\t * @param {string} connectionString - The connection string used to connect to the database.\n\t */\n\tconstructor(connectionString: string) {\n\t\tconst defaultConfig = {\n\t\t\tmax: 20,\n\t\t\tidleTimeoutMillis: 30000,\n\t\t\tconnectionTimeoutMillis: this.connectionTimeout,\n\t\t};\n\n\t\tthis.pool = new Pool({\n\t\t\t...defaultConfig,\n\t\t\tconnectionString,\n\t\t});\n\n\t\tthis.pool.on(\"error\", (err) => {\n\t\t\tlogger.error(\"Unexpected pool error\", err);\n\t\t\tthis.handlePoolError(err);\n\t\t});\n\n\t\tthis.setupPoolErrorHandling();\n\t\tthis.testConnection();\n\t}\n\n\t/**\n\t * Handles a pool error by attempting to reconnect the pool.\n\t *\n\t * @param {Error} error The error that occurred in the pool.\n\t * @throws {Error} If failed to reconnect the pool.\n\t */\n\tprivate async handlePoolError(error: Error) {\n\t\tlogger.error(\"Pool error occurred, attempting to reconnect\", {\n\t\t\terror: error.message,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.pool.end();\n\n\t\t\tthis.pool = new Pool({\n\t\t\t\t...this.pool.options,\n\t\t\t\tconnectionTimeoutMillis: this.connectionTimeout,\n\t\t\t});\n\n\t\t\tawait this.testConnection();\n\t\t\tlogger.success(\"Pool reconnection successful\");\n\t\t} catch (reconnectError) {\n\t\t\tlogger.error(\"Failed to reconnect pool\", {\n\t\t\t\terror:\n\t\t\t\t\treconnectError instanceof Error\n\t\t\t\t\t\t? reconnectError.message\n\t\t\t\t\t\t: String(reconnectError),\n\t\t\t});\n\t\t\tthrow reconnectError;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously tests the database connection by executing a query to get the current timestamp.\n\t *\n\t * @returns {Promise<boolean>} - A Promise that resolves to true if the database connection test is successful.\n\t */\n\tasync testConnection(): Promise<boolean> {\n\t\tlet client: pkg.PoolClient | null = null;\n\t\ttry {\n\t\t\tclient = await this.pool.connect();\n\t\t\tconst result = await client.query(\"SELECT NOW()\");\n\t\t\tlogger.success(\"Database connection test successful:\", result.rows[0]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Database connection test failed:\", error);\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to connect to database: ${(error as Error).message}`,\n\t\t\t);\n\t\t} finally {\n\t\t\tif (client) client.release();\n\t\t}\n\t}\n\n\t/**\n\t * Sets up event listeners to handle pool cleanup on SIGINT, SIGTERM, and beforeExit events.\n\t */\n\tprivate setupPoolErrorHandling() {\n\t\tprocess.on(\"SIGINT\", async () => {\n\t\t\tawait this.cleanup();\n\t\t\tprocess.exit(0);\n\t\t});\n\n\t\tprocess.on(\"SIGTERM\", async () => {\n\t\t\tawait this.cleanup();\n\t\t\tprocess.exit(0);\n\t\t});\n\n\t\tprocess.on(\"beforeExit\", async () => {\n\t\t\tawait this.cleanup();\n\t\t});\n\t}\n\n\t/**\n\t * Get the connection pool.\n\t * @returns {PgPool} The connection pool\n\t * @throws {Error} If the connection manager is shutting down or an error occurs when trying to get the connection from the pool\n\t */\n\tpublic getConnection(): PgPool {\n\t\tif (this.isShuttingDown) {\n\t\t\tthrow new Error(\"Connection manager is shutting down\");\n\t\t}\n\n\t\ttry {\n\t\t\treturn this.pool;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to get connection from pool:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously acquires a database client from the connection pool.\n\t *\n\t * @returns {Promise<pkg.PoolClient>} A Promise that resolves with the acquired database client.\n\t * @throws {Error} If an error occurs while acquiring the database client.\n\t */\n\tpublic async getClient(): Promise<pkg.PoolClient> {\n\t\ttry {\n\t\t\treturn await this.pool.connect();\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to acquire a database client:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the PostgreSQL connection manager by testing the connection and logging the result.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves once the manager is successfully initialized\n\t * @throws {Error} If there is an error initializing the connection manager\n\t */\n\tpublic async initialize(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.testConnection();\n\t\t\tlogger.info(\"PostgreSQL connection manager initialized successfully\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to initialize connection manager:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously close the current process by executing a cleanup function.\n\t * @returns A promise that resolves once the cleanup is complete.\n\t */\n\tpublic async close(): Promise<void> {\n\t\tawait this.cleanup();\n\t}\n\n\t/**\n\t * Asynchronously checks if migrations exist in the database.\n\t * @returns {Promise<boolean>} A Promise that resolves to true if migrations exist, otherwise false.\n\t */\n\tprivate async hasMigrations(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.pool.query(\n\t\t\t\t\"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '__drizzle_migrations')\"\n\t\t\t);\n\t\t\treturn result.rows[0].exists;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to check migrations:\", error);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Cleans up and closes the database pool.\n\t * @returns {Promise<void>} A Promise that resolves when the database pool is closed.\n\t */\n\tasync cleanup(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.pool.end();\n\t\t\tlogger.info(\"Database pool closed\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Error closing database pool:\", error);\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously runs database migrations using the Drizzle library.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves once the migrations are completed successfully.\n\t */\n\tasync runMigrations(): Promise<void> {\n\t\ttry {\n\t\t\tconst db = drizzle(this.pool);\n\t\t\tif (await this.hasMigrations()) {\n\t\t\t\tlogger.info(\"Migrations already exist, skipping...\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait migrate(db, {\n\t\t\t\tmigrationsFolder: path.resolve(__dirname, \"../drizzle/migrations\"),\n\t\t\t});\n\t\t\tlogger.info(\"Migrations completed successfully!\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to run database migrations (pg):\", error);\n\t\t\t// throw error;\n\t\t\tconsole.trace(error);\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAAA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,cAAkC;AAC3C,SAAS,qBAAqB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O;AACf,MAAAA,QAAO,MAAM,2CAA2C,KAAK;AAE7D,cAAQ,MAAM,KAAK;AAAA,IACpB;AAAA,EACD;AACD;","names":["path","fileURLToPath","logger","drizzle","migrate","__filename","fileURLToPath","__dirname","path","logger","drizzle","migrate"]}
|
package/dist/index.js
CHANGED
package/dist/migrate.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-sql",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@electric-sql/pglite": "^0.2.17",
|
|
29
|
-
"@elizaos/core": "1.0.0-alpha.
|
|
29
|
+
"@elizaos/core": "1.0.0-alpha.31",
|
|
30
30
|
"@types/pg": "8.11.10",
|
|
31
31
|
"drizzle-kit": "^0.30.4",
|
|
32
32
|
"drizzle-orm": "^0.39.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"typescript": "5.8.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "e44730fa4fecb228efcae550982d6a2ee0c76f4d"
|
|
51
51
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/pg-lite/manager.ts","../src/pg/manager.ts"],"sourceRoot":"./","sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { PGlite, type PGliteOptions } from \"@electric-sql/pglite\";\nimport { fuzzystrmatch } from \"@electric-sql/pglite/contrib/fuzzystrmatch\";\nimport { vector } from \"@electric-sql/pglite/vector\";\nimport { logger } from \"@elizaos/core\";\nimport { drizzle } from \"drizzle-orm/pglite\";\nimport { migrate } from \"drizzle-orm/pglite/migrator\";\nimport type { IDatabaseClientManager } from \"../types\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Class representing a database client manager for PGlite.\n * @implements { IDatabaseClientManager }\n */\nexport class PGliteClientManager implements IDatabaseClientManager<PGlite> {\n\tprivate client: PGlite;\n\tprivate shuttingDown = false;\n\tprivate readonly shutdownTimeout = 500;\n\n\t/**\n\t * Constructor for creating a new instance of PGlite with the provided options.\n\t * Initializes the PGlite client with additional extensions.\n\t * @param {PGliteOptions} options - The options to configure the PGlite client.\n\t */\n\tconstructor(options: PGliteOptions) {\n\t\tthis.client = new PGlite({\n\t\t\t...options,\n\t\t\textensions: {\n\t\t\t\tvector,\n\t\t\t\tfuzzystrmatch,\n\t\t\t},\n\t\t});\n\t\tthis.setupShutdownHandlers();\n\t}\n\n\t/**\n\t * Retrieves the PostgreSQL lite connection.\n\t *\n\t * @returns {PGlite} The PostgreSQL lite connection.\n\t * @throws {Error} If the client manager is currently shutting down.\n\t */\n\tpublic getConnection(): PGlite {\n\t\tif (this.shuttingDown) {\n\t\t\tthrow new Error(\"Client manager is shutting down\");\n\t\t}\n\t\treturn this.client;\n\t}\n\n\t/**\n\t * Initiates a graceful shutdown of the PGlite client.\n\t * Checks if the client is already in the process of shutting down.\n\t * Logs the start of shutdown process and sets shuttingDown flag to true.\n\t * Sets a timeout for the shutdown process and forces closure of database connection if timeout is reached.\n\t * Handles the shutdown process, closes the client connection, clears the timeout, and logs the completion of shutdown.\n\t * Logs any errors that occur during the shutdown process.\n\t */\n\tprivate async gracefulShutdown() {\n\t\tif (this.shuttingDown) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.shuttingDown = true;\n\t\tlogger.info(\"Starting graceful shutdown of PGlite client...\");\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tlogger.warn(\n\t\t\t\t\"Shutdown timeout reached, forcing database connection closure...\",\n\t\t\t);\n\t\t\tthis.client.close().finally(() => {\n\t\t\t\tprocess.exit(1);\n\t\t\t});\n\t\t}, this.shutdownTimeout);\n\n\t\ttry {\n\t\t\tawait this.client.close();\n\t\t\tclearTimeout(timeout);\n\t\t\tlogger.info(\"PGlite client shutdown completed successfully\");\n\t\t\tprocess.exit(0);\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Error during graceful shutdown:\", error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\t/**\n\t * Sets up shutdown handlers for SIGINT, SIGTERM, and beforeExit events to gracefully shutdown the application.\n\t * @private\n\t */\n\tprivate setupShutdownHandlers() {\n\t\tprocess.on(\"SIGINT\", async () => {\n\t\t\tawait this.gracefulShutdown();\n\t\t});\n\n\t\tprocess.on(\"SIGTERM\", async () => {\n\t\t\tawait this.gracefulShutdown();\n\t\t});\n\n\t\tprocess.on(\"beforeExit\", async () => {\n\t\t\tawait this.gracefulShutdown();\n\t\t});\n\t}\n\n\t/**\n\t * Asynchronously checks if migrations exist in the database.\n\t * @returns {Promise<boolean>} A Promise that resolves to true if migrations exist, otherwise false.\n\t */\n\tprivate async hasMigrations(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.client.query(\n\t\t\t\t\"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '__drizzle_migrations')\"\n\t\t\t);\n\t\t\treturn (result.rows[0] as any).exists;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to check migrations:\", error);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\n\t/**\n\t * Initializes the client for PGlite.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves when the client is initialized successfully\n\t */\n\tpublic async initialize(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.client.waitReady;\n\t\t\tlogger.info(\"PGlite client initialized successfully\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to initialize PGlite client:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously closes the resource. If the resource is not already shutting down,\n\t * it performs a graceful shutdown before closing.\n\t *\n\t * @returns A promise that resolves once the resource has been closed.\n\t */\n\tpublic async close(): Promise<void> {\n\t\tif (!this.shuttingDown) {\n\t\t\tawait this.gracefulShutdown();\n\t\t}\n\t}\n\n\t/**\n\t * Check if the system is currently shutting down.\n\t *\n\t * @returns {boolean} True if the system is shutting down, false otherwise.\n\t */\n\tpublic isShuttingDown(): boolean {\n\t\treturn this.shuttingDown;\n\t}\n\n\t/**\n\t * Asynchronously runs database migrations using Drizzle.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves once the migrations are completed successfully.\n\t */\n\tasync runMigrations(): Promise<void> {\n\t\ttry {\n\t\t\tconst db = drizzle(this.client);\n\t\t\tif (await this.hasMigrations()) {\n\t\t\t\tlogger.info(\"Migrations already exist, skipping...\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait migrate(db, {\n\t\t\t\tmigrationsFolder: path.resolve(__dirname, \"../drizzle/migrations\"),\n\t\t\t});\n\t\t\tlogger.info(\"Migrations completed successfully!\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to run database migrations (pglite):\", error);\n\t\t\t// throw error;\n\t\t}\n\t}\n}\n","import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { logger } from \"@elizaos/core\";\nimport { drizzle } from \"drizzle-orm/node-postgres\";\nimport { migrate } from \"drizzle-orm/node-postgres/migrator\";\nimport pkg, { type Pool as PgPool } from \"pg\";\nimport type { IDatabaseClientManager } from \"../types\";\n\nconst { Pool } = pkg;\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Manages connections to a PostgreSQL database using a connection pool.\n * Implements IDatabaseClientManager interface.\n */\n\nexport class PostgresConnectionManager\n\timplements IDatabaseClientManager<PgPool>\n{\n\tprivate pool: PgPool;\n\tprivate isShuttingDown = false;\n\tprivate readonly connectionTimeout: number = 5000;\n\n\t/**\n\t * Constructor for creating a connection pool.\n\t * @param {string} connectionString - The connection string used to connect to the database.\n\t */\n\tconstructor(connectionString: string) {\n\t\tconst defaultConfig = {\n\t\t\tmax: 20,\n\t\t\tidleTimeoutMillis: 30000,\n\t\t\tconnectionTimeoutMillis: this.connectionTimeout,\n\t\t};\n\n\t\tthis.pool = new Pool({\n\t\t\t...defaultConfig,\n\t\t\tconnectionString,\n\t\t});\n\n\t\tthis.pool.on(\"error\", (err) => {\n\t\t\tlogger.error(\"Unexpected pool error\", err);\n\t\t\tthis.handlePoolError(err);\n\t\t});\n\n\t\tthis.setupPoolErrorHandling();\n\t\tthis.testConnection();\n\t}\n\n\t/**\n\t * Handles a pool error by attempting to reconnect the pool.\n\t *\n\t * @param {Error} error The error that occurred in the pool.\n\t * @throws {Error} If failed to reconnect the pool.\n\t */\n\tprivate async handlePoolError(error: Error) {\n\t\tlogger.error(\"Pool error occurred, attempting to reconnect\", {\n\t\t\terror: error.message,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.pool.end();\n\n\t\t\tthis.pool = new Pool({\n\t\t\t\t...this.pool.options,\n\t\t\t\tconnectionTimeoutMillis: this.connectionTimeout,\n\t\t\t});\n\n\t\t\tawait this.testConnection();\n\t\t\tlogger.success(\"Pool reconnection successful\");\n\t\t} catch (reconnectError) {\n\t\t\tlogger.error(\"Failed to reconnect pool\", {\n\t\t\t\terror:\n\t\t\t\t\treconnectError instanceof Error\n\t\t\t\t\t\t? reconnectError.message\n\t\t\t\t\t\t: String(reconnectError),\n\t\t\t});\n\t\t\tthrow reconnectError;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously tests the database connection by executing a query to get the current timestamp.\n\t *\n\t * @returns {Promise<boolean>} - A Promise that resolves to true if the database connection test is successful.\n\t */\n\tasync testConnection(): Promise<boolean> {\n\t\tlet client: pkg.PoolClient | null = null;\n\t\ttry {\n\t\t\tclient = await this.pool.connect();\n\t\t\tconst result = await client.query(\"SELECT NOW()\");\n\t\t\tlogger.success(\"Database connection test successful:\", result.rows[0]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Database connection test failed:\", error);\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to connect to database: ${(error as Error).message}`,\n\t\t\t);\n\t\t} finally {\n\t\t\tif (client) client.release();\n\t\t}\n\t}\n\n\t/**\n\t * Sets up event listeners to handle pool cleanup on SIGINT, SIGTERM, and beforeExit events.\n\t */\n\tprivate setupPoolErrorHandling() {\n\t\tprocess.on(\"SIGINT\", async () => {\n\t\t\tawait this.cleanup();\n\t\t\tprocess.exit(0);\n\t\t});\n\n\t\tprocess.on(\"SIGTERM\", async () => {\n\t\t\tawait this.cleanup();\n\t\t\tprocess.exit(0);\n\t\t});\n\n\t\tprocess.on(\"beforeExit\", async () => {\n\t\t\tawait this.cleanup();\n\t\t});\n\t}\n\n\t/**\n\t * Get the connection pool.\n\t * @returns {PgPool} The connection pool\n\t * @throws {Error} If the connection manager is shutting down or an error occurs when trying to get the connection from the pool\n\t */\n\tpublic getConnection(): PgPool {\n\t\tif (this.isShuttingDown) {\n\t\t\tthrow new Error(\"Connection manager is shutting down\");\n\t\t}\n\n\t\ttry {\n\t\t\treturn this.pool;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to get connection from pool:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously acquires a database client from the connection pool.\n\t *\n\t * @returns {Promise<pkg.PoolClient>} A Promise that resolves with the acquired database client.\n\t * @throws {Error} If an error occurs while acquiring the database client.\n\t */\n\tpublic async getClient(): Promise<pkg.PoolClient> {\n\t\ttry {\n\t\t\treturn await this.pool.connect();\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to acquire a database client:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the PostgreSQL connection manager by testing the connection and logging the result.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves once the manager is successfully initialized\n\t * @throws {Error} If there is an error initializing the connection manager\n\t */\n\tpublic async initialize(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.testConnection();\n\t\t\tlogger.info(\"PostgreSQL connection manager initialized successfully\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to initialize connection manager:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously close the current process by executing a cleanup function.\n\t * @returns A promise that resolves once the cleanup is complete.\n\t */\n\tpublic async close(): Promise<void> {\n\t\tawait this.cleanup();\n\t}\n\n\t/**\n\t * Asynchronously checks if migrations exist in the database.\n\t * @returns {Promise<boolean>} A Promise that resolves to true if migrations exist, otherwise false.\n\t */\n\tprivate async hasMigrations(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst result = await this.pool.query(\n\t\t\t\t\"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '__drizzle_migrations')\"\n\t\t\t);\n\t\t\treturn result.rows[0].exists;\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to check migrations:\", error);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Cleans up and closes the database pool.\n\t * @returns {Promise<void>} A Promise that resolves when the database pool is closed.\n\t */\n\tasync cleanup(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.pool.end();\n\t\t\tlogger.info(\"Database pool closed\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Error closing database pool:\", error);\n\t\t}\n\t}\n\n\t/**\n\t * Asynchronously runs database migrations using the Drizzle library.\n\t *\n\t * @returns {Promise<void>} A Promise that resolves once the migrations are completed successfully.\n\t */\n\tasync runMigrations(): Promise<void> {\n\t\ttry {\n\t\t\tconst db = drizzle(this.pool);\n\t\t\tif (await this.hasMigrations()) {\n\t\t\t\tlogger.info(\"Migrations already exist, skipping...\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait migrate(db, {\n\t\t\t\tmigrationsFolder: path.resolve(__dirname, \"../drizzle/migrations\"),\n\t\t\t});\n\t\t\tlogger.info(\"Migrations completed successfully!\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to run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,QACjB,kBAAkBH,MAAK,QAAQD,YAAW,uBAAuB;AAAA,MAClE,CAAC;AACD,MAAAE,QAAO,KAAK,oCAAoC;AAAA,IACjD,SAAS,OAAO;AACf,MAAAA,QAAO,MAAM,2CAA2C,KAAK;AAAA,IAE9D;AAAA,EACD;AACD;","names":["path","fileURLToPath","logger","drizzle","migrate","__filename","fileURLToPath","__dirname","path","logger","drizzle","migrate"]}
|