@elizaos/plugin-sql 1.7.2 → 2.0.0-alpha.2
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/browser/index.browser.js +4736 -23196
- package/dist/browser/index.browser.js.map +42 -59
- package/dist/node/index.node.js +8150 -16943
- package/dist/node/index.node.js.map +58 -95
- package/package.json +29 -44
- package/README.md +0 -355
- package/dist/browser/tsconfig.build.tsbuildinfo +0 -1
- package/dist/node/tsconfig.build.node.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-sql",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/node/index.node.js",
|
|
6
6
|
"module": "dist/node/index.node.js",
|
|
@@ -16,32 +16,22 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
"./package.json": "./package.json",
|
|
18
18
|
".": {
|
|
19
|
-
"types": "./
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
20
|
"browser": {
|
|
21
|
-
"types": "./dist/
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
22
|
"import": "./dist/browser/index.browser.js",
|
|
23
23
|
"default": "./dist/browser/index.browser.js"
|
|
24
24
|
},
|
|
25
25
|
"node": {
|
|
26
|
-
"types": "./dist/
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
27
|
"import": "./dist/node/index.node.js",
|
|
28
28
|
"default": "./dist/node/index.node.js"
|
|
29
29
|
},
|
|
30
30
|
"bun": {
|
|
31
|
-
"types": "./dist/
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
32
|
"default": "./dist/node/index.node.js"
|
|
33
33
|
},
|
|
34
34
|
"default": "./dist/node/index.node.js"
|
|
35
|
-
},
|
|
36
|
-
"./node": {
|
|
37
|
-
"types": "./dist/node/index.d.ts",
|
|
38
|
-
"import": "./dist/node/index.node.js",
|
|
39
|
-
"default": "./dist/node/index.node.js"
|
|
40
|
-
},
|
|
41
|
-
"./browser": {
|
|
42
|
-
"types": "./dist/browser/index.d.ts",
|
|
43
|
-
"import": "./dist/browser/index.browser.js",
|
|
44
|
-
"default": "./dist/browser/index.browser.js"
|
|
45
35
|
}
|
|
46
36
|
},
|
|
47
37
|
"sideEffects": false,
|
|
@@ -52,46 +42,41 @@
|
|
|
52
42
|
],
|
|
53
43
|
"dependencies": {
|
|
54
44
|
"@electric-sql/pglite": "^0.3.3",
|
|
55
|
-
"@elizaos/core": "
|
|
56
|
-
"@neondatabase/serverless": "^1.0.2",
|
|
45
|
+
"@elizaos/core": "2.0.0-alpha.2",
|
|
57
46
|
"dotenv": "^17.2.3",
|
|
58
|
-
"drizzle-kit": "^0.31.
|
|
59
|
-
"drizzle-orm": "^0.45.
|
|
60
|
-
"pg": "^8.
|
|
61
|
-
"uuid": "^13.0.0"
|
|
62
|
-
"ws": "^8.19.0"
|
|
47
|
+
"drizzle-kit": "^0.31.8",
|
|
48
|
+
"drizzle-orm": "^0.45.1",
|
|
49
|
+
"pg": "^8.16.3",
|
|
50
|
+
"uuid": "^13.0.0"
|
|
63
51
|
},
|
|
64
52
|
"devDependencies": {
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@types/node": "^25.0.9",
|
|
53
|
+
"@biomejs/biome": "^2.3.11",
|
|
54
|
+
"@types/node": "^25.0.3",
|
|
68
55
|
"@types/pg": "^8.15.6",
|
|
69
|
-
"
|
|
70
|
-
"prettier": "^3.7.4",
|
|
71
|
-
"typescript": "^5.9.3",
|
|
72
|
-
"typescript-eslint": "^8.48.1"
|
|
56
|
+
"typescript": "^5.9.3"
|
|
73
57
|
},
|
|
74
58
|
"scripts": {
|
|
75
|
-
"build": "bun run build.ts && tsc -p tsconfig.build.json && tsc -p tsconfig.build.node.json",
|
|
76
59
|
"dev": "bun run build.ts --watch",
|
|
77
60
|
"migrate:generate": "drizzle-kit generate",
|
|
78
61
|
"migrate": "drizzle-kit migrate",
|
|
79
|
-
"
|
|
80
|
-
"lint:check": "eslint .",
|
|
62
|
+
"typecheck": "tsc --noEmit -p tsconfig.json || true",
|
|
81
63
|
"clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json *.tsbuildinfo",
|
|
82
|
-
"format": "
|
|
83
|
-
"format:check": "
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"test
|
|
64
|
+
"format": "bunx @biomejs/biome format --write .",
|
|
65
|
+
"format:check": "bunx @biomejs/biome format .",
|
|
66
|
+
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
67
|
+
"lint:check": "bunx @biomejs/biome check .",
|
|
68
|
+
"test": "vitest run __tests__/unit/",
|
|
69
|
+
"test:unit": "vitest run __tests__/unit/",
|
|
70
|
+
"test:integration": "echo 'Integration tests require scripts/run-integration-tests.sh - skipping'",
|
|
87
71
|
"test:integration:postgres": "bash scripts/run-integration-tests.sh --postgres",
|
|
88
|
-
"test:migration": "
|
|
89
|
-
"test:migration:postgres": "
|
|
90
|
-
"test:e2e:upgrade": "bash
|
|
91
|
-
"test:watch": "
|
|
92
|
-
"test:coverage": "
|
|
72
|
+
"test:migration": "vitest run __tests__/migration/",
|
|
73
|
+
"test:migration:postgres": "vitest run __tests__/migration/",
|
|
74
|
+
"test:e2e:upgrade": "bash __tests__/migration/e2e/run-upgrade-test.sh",
|
|
75
|
+
"test:watch": "vitest",
|
|
76
|
+
"test:coverage": "vitest run --coverage",
|
|
93
77
|
"build:clean": "rm -rf dist",
|
|
94
|
-
"
|
|
78
|
+
"build": "bun run build.ts",
|
|
79
|
+
"build:ts": "bun run build.ts"
|
|
95
80
|
},
|
|
96
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "bc6cac8d36845d7cbde51a64307c6a57c16378ad"
|
|
97
82
|
}
|
package/README.md
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
# DrizzleDatabaseAdapter
|
|
2
|
-
|
|
3
|
-
A PostgreSQL database adapter built with Drizzle ORM for the ElizaOS ecosystem.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Using bun
|
|
9
|
-
bun add @elizaos/plugin-sql
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Vector Dimensions
|
|
13
|
-
|
|
14
|
-
The adapter supports the following vector dimensions:
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
VECTOR_DIMS = {
|
|
18
|
-
SMALL: 384,
|
|
19
|
-
MEDIUM: 512,
|
|
20
|
-
LARGE: 768,
|
|
21
|
-
XL: 1024,
|
|
22
|
-
XXL: 1536,
|
|
23
|
-
XXXL: 3072,
|
|
24
|
-
};
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Important Note: Once an agent is initialized with a specific embedding dimension, it cannot be changed. Attempting to change the dimension will result in an error: "Cannot change embedding dimension for agent"
|
|
28
|
-
|
|
29
|
-
## Features
|
|
30
|
-
|
|
31
|
-
- Circuit breaker pattern for database failures
|
|
32
|
-
- Automatic retries with exponential backoff
|
|
33
|
-
- Connection pooling
|
|
34
|
-
- Vector search capabilities
|
|
35
|
-
- Memory management
|
|
36
|
-
- Caching system
|
|
37
|
-
- Room and participant management
|
|
38
|
-
- Goal tracking system
|
|
39
|
-
|
|
40
|
-
## Database Schema
|
|
41
|
-
|
|
42
|
-
The plugin uses a structured schema with the following main tables:
|
|
43
|
-
|
|
44
|
-
### Core Tables
|
|
45
|
-
|
|
46
|
-
- **Agent**: Stores agent information and configurations
|
|
47
|
-
- **Room**: Manages conversation rooms and their settings
|
|
48
|
-
- **Participant**: Tracks participants in rooms
|
|
49
|
-
- **Memory**: Stores agent memories with vector embeddings for semantic search
|
|
50
|
-
- **Embedding**: Manages vector embeddings for various entities
|
|
51
|
-
- **Entity**: Represents entities that agents can interact with
|
|
52
|
-
- **Relationship**: Tracks relationships between entities
|
|
53
|
-
- **Component**: Stores agent components and their configurations
|
|
54
|
-
- **Tasks**: Manages tasks and goals for agents
|
|
55
|
-
- **Log**: Stores system logs
|
|
56
|
-
- **Cache**: Provides a caching mechanism for frequently accessed data
|
|
57
|
-
- **World**: Manages world settings and configurations
|
|
58
|
-
|
|
59
|
-
Each table is defined using Drizzle ORM schema definitions in the `src/schema` directory. The schema is designed to support the ElizaOS ecosystem's requirements for agent-based systems.
|
|
60
|
-
|
|
61
|
-
## Usage
|
|
62
|
-
|
|
63
|
-
The adapter is typically used as part of the ElizaOS runtime:
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
async function findDatabaseAdapter(runtime: IAgentRuntime) {
|
|
67
|
-
let adapter = runtime;
|
|
68
|
-
|
|
69
|
-
if (!adapter) {
|
|
70
|
-
const drizzleAdapterPlugin = await import('@elizaos/plugin-sql');
|
|
71
|
-
const drizzleAdapterPluginDefault = drizzleAdapterPlugin.default;
|
|
72
|
-
adapter = drizzleAdapterPluginDefault.adapter;
|
|
73
|
-
if (!adapter) {
|
|
74
|
-
throw new Error('Internal error: No database adapter found for default plugin-sql');
|
|
75
|
-
}
|
|
76
|
-
} else if (!adapter) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
'Multiple database adapters found. You must have no more than one. Adjust your plugins configuration.'
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const adapterInterface = await adapter?.init(runtime);
|
|
83
|
-
return adapterInterface;
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Error Handling Configuration
|
|
88
|
-
|
|
89
|
-
The adapter implements the following error handling configurations:
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
{
|
|
93
|
-
failureThreshold: 5,
|
|
94
|
-
resetTimeout: 60000,
|
|
95
|
-
halfOpenMaxAttempts: 3,
|
|
96
|
-
maxRetries: 3,
|
|
97
|
-
baseDelay: 1000, // 1 second
|
|
98
|
-
maxDelay: 10000, // 10 seconds
|
|
99
|
-
jitterMax: 1000, // 1 second
|
|
100
|
-
connectionTimeout: 5000 // 5 seconds
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Requirements
|
|
105
|
-
|
|
106
|
-
- PostgreSQL with vector extension installed
|
|
107
|
-
- Node.js or Bun (≥1.2.2)
|
|
108
|
-
|
|
109
|
-
## Environment Variables
|
|
110
|
-
|
|
111
|
-
The plugin uses the following environment variables:
|
|
112
|
-
|
|
113
|
-
- `POSTGRES_URL`: Connection string for PostgreSQL database (e.g., `postgresql://user:password@localhost:5432/dbname`)
|
|
114
|
-
- If not provided, the plugin will use PGlite as a fallback
|
|
115
|
-
- `PGLITE_DATA_DIR`: (Optional) Directory for PGlite data storage (default: `./pglite`)
|
|
116
|
-
|
|
117
|
-
These variables should be defined in a `.env` file at the root of your project.
|
|
118
|
-
|
|
119
|
-
## Database Pool Configuration
|
|
120
|
-
|
|
121
|
-
Default pool configuration:
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
{
|
|
125
|
-
max: 20,
|
|
126
|
-
idleTimeoutMillis: 30000,
|
|
127
|
-
connectionTimeoutMillis: 5000
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Migration Support
|
|
132
|
-
|
|
133
|
-
ElizaOS v1.0.0 introduces **dynamic runtime migrations** - automatic schema management that runs at startup without manual intervention. Plugins can define their schemas and the system handles all migrations automatically.
|
|
134
|
-
|
|
135
|
-
### TLDR: What Changed?
|
|
136
|
-
|
|
137
|
-
**Before (v0.x):** Manual migrations with `drizzle-kit generate` → `drizzle-kit push` → restart
|
|
138
|
-
**Now (v1.0.0):** Define schema in plugin → Start agent → Migrations run automatically ✨
|
|
139
|
-
|
|
140
|
-
### Key Features
|
|
141
|
-
|
|
142
|
-
- **Zero-Config Migrations**: No more manual migration commands
|
|
143
|
-
- **Plugin Isolation**: Each plugin gets its own schema namespace
|
|
144
|
-
- **Safety First**: Destructive changes blocked by default in production
|
|
145
|
-
- **Concurrent Safety**: Built-in locks prevent race conditions
|
|
146
|
-
- **Rollback Protection**: All migrations run in transactions
|
|
147
|
-
|
|
148
|
-
### How It Works
|
|
149
|
-
|
|
150
|
-
1. **Plugin defines schema** using Drizzle ORM:
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
// In your plugin's schema.ts
|
|
154
|
-
import { pgTable, text, uuid } from 'drizzle-orm/pg-core';
|
|
155
|
-
|
|
156
|
-
export const myTable = pgTable('my_table', {
|
|
157
|
-
id: uuid('id').primaryKey(),
|
|
158
|
-
name: text('name').notNull(),
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Export schema in your plugin
|
|
162
|
-
export const plugin = {
|
|
163
|
-
name: '@your-org/plugin-name',
|
|
164
|
-
schema: schema, // Your Drizzle schema object
|
|
165
|
-
// ... rest of plugin
|
|
166
|
-
};
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
2. **Runtime detects changes** at startup:
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
[RuntimeMigrator] Starting migration for plugin: @your-org/plugin-name
|
|
173
|
-
[RuntimeMigrator] Executing 2 SQL statements...
|
|
174
|
-
[RuntimeMigrator] Migration completed successfully
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
3. **Automatic safety checks**:
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
# Destructive changes are blocked
|
|
181
|
-
[RuntimeMigrator] Destructive migration blocked
|
|
182
|
-
[RuntimeMigrator] Destructive operations detected:
|
|
183
|
-
[RuntimeMigrator] - Column "email" will be dropped from table "users"
|
|
184
|
-
[RuntimeMigrator] To proceed:
|
|
185
|
-
[RuntimeMigrator] 1. Set ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true
|
|
186
|
-
[RuntimeMigrator] 2. Or use { force: true } option
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Migration Controls
|
|
190
|
-
|
|
191
|
-
Control migration behavior via environment variables:
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
# Allow destructive migrations (drops, type changes)
|
|
195
|
-
ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true
|
|
196
|
-
|
|
197
|
-
# Development vs Production
|
|
198
|
-
NODE_ENV=production # Stricter checks, verbose off by default
|
|
199
|
-
NODE_ENV=development # More permissive, verbose on
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
Or programmatically:
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
await databaseAdapter.runPluginMigrations(plugins, {
|
|
206
|
-
verbose: true, // Show SQL statements
|
|
207
|
-
force: true, // Allow destructive changes
|
|
208
|
-
dryRun: true, // Preview without applying
|
|
209
|
-
});
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Transitioning from Manual Migrations
|
|
213
|
-
|
|
214
|
-
If you have existing manual Drizzle migrations:
|
|
215
|
-
|
|
216
|
-
1. **Keep existing migrations** - They remain compatible
|
|
217
|
-
2. **Add schema to plugin** - Export your Drizzle schema
|
|
218
|
-
3. **First run** - Runtime migrator detects current state
|
|
219
|
-
4. **Future changes** - Just update schema and restart
|
|
220
|
-
|
|
221
|
-
Example transition:
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
// Before: Manual migrations
|
|
225
|
-
// 1. Edit schema
|
|
226
|
-
// 2. Run: bunx drizzle-kit generate
|
|
227
|
-
// 3. Run: bunx drizzle-kit push
|
|
228
|
-
// 4. Restart agent
|
|
229
|
-
|
|
230
|
-
// After: Runtime migrations
|
|
231
|
-
// 1. Edit schema in plugin
|
|
232
|
-
// 2. Restart agent (migrations run automatically)
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Schema Namespacing
|
|
236
|
-
|
|
237
|
-
Plugins automatically get namespaced schemas for isolation:
|
|
238
|
-
|
|
239
|
-
- `@elizaos/plugin-sql` → Uses `public` schema (core tables)
|
|
240
|
-
- `@your-org/plugin-name` → Uses `your_org_plugin_name` schema
|
|
241
|
-
- Prevents table name conflicts between plugins
|
|
242
|
-
- Clean separation of concerns
|
|
243
|
-
|
|
244
|
-
To use a custom schema:
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
import { pgSchema } from 'drizzle-orm/pg-core';
|
|
248
|
-
|
|
249
|
-
const mySchema = pgSchema('my_custom_schema');
|
|
250
|
-
export const myTable = mySchema.table('my_table', {
|
|
251
|
-
// ... columns
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Debugging Migrations
|
|
256
|
-
|
|
257
|
-
Check migration status:
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
const migrator = migrationService.getMigrator();
|
|
261
|
-
const status = await migrator.getStatus('@your-org/plugin-name');
|
|
262
|
-
console.log(status);
|
|
263
|
-
// {
|
|
264
|
-
// hasRun: true,
|
|
265
|
-
// lastMigration: { hash: "...", timestamp: ... },
|
|
266
|
-
// journal: [...],
|
|
267
|
-
// snapshots: 3
|
|
268
|
-
// }
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
Preview changes without applying:
|
|
272
|
-
|
|
273
|
-
```typescript
|
|
274
|
-
const check = await migrator.checkMigration('@your-org/plugin-name', schema);
|
|
275
|
-
if (check?.hasDataLoss) {
|
|
276
|
-
console.log('Warning: Destructive changes:', check.warnings);
|
|
277
|
-
}
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Database Support
|
|
281
|
-
|
|
282
|
-
The plugin supports two database backends with automatic migration support:
|
|
283
|
-
|
|
284
|
-
1. **PostgreSQL**: Production-ready with full feature support
|
|
285
|
-
2. **PGlite**: Embedded database for development/testing
|
|
286
|
-
|
|
287
|
-
Both use identical migration systems - develop locally with PGlite, deploy to PostgreSQL.
|
|
288
|
-
|
|
289
|
-
### Troubleshooting
|
|
290
|
-
|
|
291
|
-
**"Destructive migration blocked"**
|
|
292
|
-
|
|
293
|
-
- Set `ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true` for development
|
|
294
|
-
- For production, review changes carefully before enabling
|
|
295
|
-
|
|
296
|
-
**"Migration already in progress"**
|
|
297
|
-
|
|
298
|
-
- Another instance is running migrations
|
|
299
|
-
- System will wait for lock automatically
|
|
300
|
-
|
|
301
|
-
**"No changes detected"**
|
|
302
|
-
|
|
303
|
-
- Schema matches database state
|
|
304
|
-
- No migration needed
|
|
305
|
-
|
|
306
|
-
**Manual migration needed?**
|
|
307
|
-
|
|
308
|
-
- Use standard Drizzle Kit for complex scenarios:
|
|
309
|
-
```bash
|
|
310
|
-
bunx drizzle-kit generate
|
|
311
|
-
bunx drizzle-kit migrate
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
## Clean Shutdown
|
|
315
|
-
|
|
316
|
-
The adapter implements cleanup handlers for:
|
|
317
|
-
|
|
318
|
-
- SIGINT
|
|
319
|
-
- SIGTERM
|
|
320
|
-
- beforeExit
|
|
321
|
-
|
|
322
|
-
These ensure proper closing of database connections when the application shuts down.
|
|
323
|
-
|
|
324
|
-
## Implementation Details
|
|
325
|
-
|
|
326
|
-
### Connection Management
|
|
327
|
-
|
|
328
|
-
The plugin uses a global singleton pattern to manage database connections. This approach ensures that:
|
|
329
|
-
|
|
330
|
-
1. **Single Connection Per Process**: Only one connection manager instance exists per Node.js process, regardless of how many times the package is imported or initialized.
|
|
331
|
-
|
|
332
|
-
2. **Resource Efficiency**: Prevents multiple connection pools to the same database, which could lead to resource exhaustion.
|
|
333
|
-
|
|
334
|
-
3. **Consistent State**: Ensures all parts of the application share the same database connection state.
|
|
335
|
-
|
|
336
|
-
4. **Proper Cleanup**: Facilitates proper cleanup of database connections during application shutdown, preventing connection leaks.
|
|
337
|
-
|
|
338
|
-
This pattern is particularly important in monorepo setups or when the package is used by multiple modules within the same process. The implementation uses JavaScript Symbols to create a global registry that persists across module boundaries.
|
|
339
|
-
|
|
340
|
-
```typescript
|
|
341
|
-
// Example of the singleton pattern implementation
|
|
342
|
-
const GLOBAL_SINGLETONS = Symbol.for('@elizaos/plugin-sql/global-singletons');
|
|
343
|
-
|
|
344
|
-
// Store managers in a global symbol registry
|
|
345
|
-
if (!globalSymbols[GLOBAL_SINGLETONS]) {
|
|
346
|
-
globalSymbols[GLOBAL_SINGLETONS] = {};
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Reuse existing managers or create new ones when needed
|
|
350
|
-
if (!globalSingletons.postgresConnectionManager) {
|
|
351
|
-
globalSingletons.postgresConnectionManager = new PostgresConnectionManager(config.postgresUrl);
|
|
352
|
-
}
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
This approach is especially critical for PGlite connections, which require careful management to ensure proper shutdown and prevent resource leaks.
|