@agentuity/postgres 2.0.8 → 2.0.9-v3.820f98a
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/registry.d.ts +2 -2
- package/dist/registry.js +14 -24
- package/dist/registry.js.map +1 -1
- package/package.json +52 -56
- package/src/registry.ts +15 -27
package/dist/registry.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* The runtime can use `shutdownAll()` to close all registered clients/pools
|
|
8
8
|
* during graceful shutdown.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Automatically registers process shutdown hooks (beforeExit, SIGTERM, SIGINT)
|
|
11
|
+
* so all postgres clients/pools are closed during graceful shutdown.
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
14
|
* Common interface for registrable PostgreSQL connections.
|
package/dist/registry.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* The runtime can use `shutdownAll()` to close all registered clients/pools
|
|
8
8
|
* during graceful shutdown.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Automatically registers process shutdown hooks (beforeExit, SIGTERM, SIGINT)
|
|
11
|
+
* so all postgres clients/pools are closed during graceful shutdown.
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
14
|
* Symbol used to store the registry in globalThis to avoid conflicts.
|
|
@@ -141,35 +141,25 @@ export function hasActiveClients() {
|
|
|
141
141
|
return false;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
144
|
+
* Registers a process shutdown hook to gracefully close all connections.
|
|
145
|
+
* Uses standard Node.js/Bun process events instead of framework-specific hooks.
|
|
146
146
|
*
|
|
147
147
|
* @internal
|
|
148
148
|
*/
|
|
149
|
-
function
|
|
149
|
+
function registerProcessShutdownHook() {
|
|
150
150
|
const global = globalThis;
|
|
151
|
-
// Only
|
|
151
|
+
// Only register once
|
|
152
152
|
if (global[RUNTIME_HOOK_REGISTERED]) {
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
global[RUNTIME_HOOK_REGISTERED] = true;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
.then((runtime) => {
|
|
163
|
-
if (typeof runtime.registerShutdownHook === 'function') {
|
|
164
|
-
runtime.registerShutdownHook(async () => {
|
|
165
|
-
await shutdownAll(5000); // 5 second timeout for graceful shutdown
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
.catch(() => {
|
|
170
|
-
// Runtime not available - that's fine, user can call shutdownAll manually
|
|
171
|
-
});
|
|
156
|
+
const shutdown = () => {
|
|
157
|
+
shutdownAll(5000).catch(() => { });
|
|
158
|
+
};
|
|
159
|
+
process.on('beforeExit', shutdown);
|
|
160
|
+
process.on('SIGTERM', shutdown);
|
|
161
|
+
process.on('SIGINT', shutdown);
|
|
172
162
|
}
|
|
173
|
-
//
|
|
174
|
-
|
|
163
|
+
// Register shutdown hook when this module is first loaded
|
|
164
|
+
registerProcessShutdownHook();
|
|
175
165
|
//# sourceMappingURL=registry.js.map
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuBH;;GAEG;AACH,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;AAE1F;;GAEG;AACH,SAAS,WAAW;IACnB,MAAM,MAAM,GAAG,UAA8C,CAAC;IAC9D,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,EA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AC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAChC,CAAC;AAED,0DAA0D;AAC1D,2BAA2B,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,58 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"publishConfig": {
|
|
55
|
-
"access": "public"
|
|
56
|
-
},
|
|
57
|
-
"sideEffects": false
|
|
2
|
+
"name": "@agentuity/postgres",
|
|
3
|
+
"version": "2.0.9-v3.820f98a",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"author": "Agentuity employees and contributors",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"description": "Resilient PostgreSQL client with automatic reconnection for Agentuity projects",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"AGENTS.md",
|
|
13
|
+
"README.md",
|
|
14
|
+
"src",
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
".": [
|
|
23
|
+
"./dist/index.d.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
29
|
+
"build": "bunx tsc --build --force",
|
|
30
|
+
"typecheck": "bunx tsc --noEmit",
|
|
31
|
+
"prepublishOnly": "bun run clean && bun run build"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@agentuity/core": "2.0.9-v3.820f98a",
|
|
35
|
+
"pg": "^8.13.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@agentuity/test-utils": "2.0.9-v3.820f98a",
|
|
39
|
+
"@types/bun": "latest",
|
|
40
|
+
"@types/pg": "^8.11.14",
|
|
41
|
+
"bun-types": "latest",
|
|
42
|
+
"kysely": "^0.27.6",
|
|
43
|
+
"typescript": "^5.9.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/agentuity/sdk.git",
|
|
52
|
+
"directory": "packages/postgres"
|
|
53
|
+
}
|
|
58
54
|
}
|
package/src/registry.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* The runtime can use `shutdownAll()` to close all registered clients/pools
|
|
8
8
|
* during graceful shutdown.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Automatically registers process shutdown hooks (beforeExit, SIGTERM, SIGINT)
|
|
11
|
+
* so all postgres clients/pools are closed during graceful shutdown.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -174,40 +174,28 @@ export function hasActiveClients(): boolean {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
177
|
+
* Registers a process shutdown hook to gracefully close all connections.
|
|
178
|
+
* Uses standard Node.js/Bun process events instead of framework-specific hooks.
|
|
179
179
|
*
|
|
180
180
|
* @internal
|
|
181
181
|
*/
|
|
182
|
-
function
|
|
182
|
+
function registerProcessShutdownHook(): void {
|
|
183
183
|
const global = globalThis as Record<symbol, boolean>;
|
|
184
184
|
|
|
185
|
-
// Only
|
|
185
|
+
// Only register once
|
|
186
186
|
if (global[RUNTIME_HOOK_REGISTERED]) {
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
global[RUNTIME_HOOK_REGISTERED] = true;
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
dynamicImport('@agentuity/runtime')
|
|
200
|
-
.then((runtime) => {
|
|
201
|
-
if (typeof runtime.registerShutdownHook === 'function') {
|
|
202
|
-
runtime.registerShutdownHook(async () => {
|
|
203
|
-
await shutdownAll(5000); // 5 second timeout for graceful shutdown
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
.catch(() => {
|
|
208
|
-
// Runtime not available - that's fine, user can call shutdownAll manually
|
|
209
|
-
});
|
|
191
|
+
const shutdown = () => {
|
|
192
|
+
shutdownAll(5000).catch(() => {});
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
process.on('beforeExit', shutdown);
|
|
196
|
+
process.on('SIGTERM', shutdown);
|
|
197
|
+
process.on('SIGINT', shutdown);
|
|
210
198
|
}
|
|
211
199
|
|
|
212
|
-
//
|
|
213
|
-
|
|
200
|
+
// Register shutdown hook when this module is first loaded
|
|
201
|
+
registerProcessShutdownHook();
|