@axiom-lattice/pg-stores 1.0.82 → 1.0.84
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +124 -44
- package/dist/index.d.ts +124 -44
- package/dist/index.js +472 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +472 -162
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/scripts/check-migration-versions.mjs +42 -9
- package/src/createPgStoreConfig.ts +97 -3
- package/src/migrations/migration.ts +91 -60
- package/src/stores/ChannelBindingStore.ts +21 -3
- package/src/stores/ChannelIdentityMappingStore.ts +21 -3
- package/src/stores/MenuStore.ts +21 -3
- package/src/stores/PostgreSQLA2AApiKeyStore.ts +21 -3
- package/src/stores/PostgreSQLAssistantStore.ts +19 -3
- package/src/stores/PostgreSQLChannelInstallationStore.ts +21 -3
- package/src/stores/PostgreSQLDatabaseConfigStore.ts +23 -4
- package/src/stores/PostgreSQLEvalStore.ts +15 -3
- package/src/stores/PostgreSQLMcpServerConfigStore.ts +23 -4
- package/src/stores/PostgreSQLMetricsServerConfigStore.ts +23 -4
- package/src/stores/PostgreSQLProjectStore.ts +19 -3
- package/src/stores/PostgreSQLScheduleStorage.ts +21 -4
- package/src/stores/PostgreSQLSkillStore.ts +14 -3
- package/src/stores/PostgreSQLTaskStore.ts +14 -3
- package/src/stores/PostgreSQLTenantStore.ts +19 -3
- package/src/stores/PostgreSQLThreadStore.ts +19 -3
- package/src/stores/PostgreSQLUserStore.ts +18 -4
- package/src/stores/PostgreSQLUserTenantLinkStore.ts +18 -4
- package/src/stores/PostgreSQLWorkflowTrackingStore.ts +18 -4
- package/src/stores/PostgreSQLWorkspaceStore.ts +19 -3
- package/src/stores/PostgresSharedResourceStore.ts +21 -3
- package/src/stores/ThreadMessageQueueStore.ts +14 -3
|
@@ -12,7 +12,8 @@ import { encrypt, decrypt } from "@axiom-lattice/core";
|
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
13
|
|
|
14
14
|
export interface PostgreSQLA2AApiKeyStoreOptions {
|
|
15
|
-
|
|
15
|
+
pool?: Pool;
|
|
16
|
+
poolConfig?: string | PoolConfig;
|
|
16
17
|
autoMigrate?: boolean;
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -48,15 +49,26 @@ function mapRowToRecord(row: KeyRow): A2AApiKeyRecord {
|
|
|
48
49
|
|
|
49
50
|
export class PostgreSQLA2AApiKeyStore implements A2AApiKeyStore {
|
|
50
51
|
private pool: Pool;
|
|
51
|
-
private migrationManager
|
|
52
|
+
private migrationManager!: MigrationManager;
|
|
52
53
|
private initialized = false;
|
|
54
|
+
private ownsPool: boolean = true;
|
|
53
55
|
private initPromise: Promise<void> | null = null;
|
|
54
56
|
|
|
55
57
|
constructor(options: PostgreSQLA2AApiKeyStoreOptions) {
|
|
58
|
+
// Use externally-managed pool if provided
|
|
59
|
+
if (options.pool) {
|
|
60
|
+
this.pool = options.pool;
|
|
61
|
+
this.ownsPool = false;
|
|
62
|
+
this.initialized = true;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
this.pool =
|
|
57
67
|
typeof options.poolConfig === "string"
|
|
58
68
|
? new Pool({ connectionString: options.poolConfig })
|
|
59
|
-
:
|
|
69
|
+
: options.poolConfig
|
|
70
|
+
? new Pool(options.poolConfig as PoolConfig)
|
|
71
|
+
: (() => { throw new Error("Either pool or poolConfig must be provided"); })();
|
|
60
72
|
|
|
61
73
|
this.migrationManager = new MigrationManager(this.pool);
|
|
62
74
|
this.migrationManager.register(createA2AApiKeysTable);
|
|
@@ -83,6 +95,12 @@ export class PostgreSQLA2AApiKeyStore implements A2AApiKeyStore {
|
|
|
83
95
|
return this.initPromise;
|
|
84
96
|
}
|
|
85
97
|
|
|
98
|
+
async dispose(): Promise<void> {
|
|
99
|
+
if (this.ownsPool && this.pool) {
|
|
100
|
+
await this.pool.end();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
86
104
|
private async ensureInitialized(): Promise<void> {
|
|
87
105
|
if (!this.initialized) await this.initialize();
|
|
88
106
|
}
|
|
@@ -19,11 +19,17 @@ import { addAssistantOwnerUserId } from "../migrations/assistant_owner_user_migr
|
|
|
19
19
|
* PostgreSQL AssistantStore options
|
|
20
20
|
*/
|
|
21
21
|
export interface PostgreSQLAssistantStoreOptions {
|
|
22
|
+
/**
|
|
23
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
24
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
25
|
+
*/
|
|
26
|
+
pool?: Pool;
|
|
27
|
+
|
|
22
28
|
/**
|
|
23
29
|
* PostgreSQL connection pool configuration
|
|
24
30
|
* Can be a connection string or PoolConfig object
|
|
25
31
|
*/
|
|
26
|
-
poolConfig
|
|
32
|
+
poolConfig?: string | PoolConfig;
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* Whether to run migrations automatically on initialization
|
|
@@ -40,17 +46,27 @@ export interface PostgreSQLAssistantStoreOptions {
|
|
|
40
46
|
*/
|
|
41
47
|
export class PostgreSQLAssistantStore implements AssistantStore {
|
|
42
48
|
private pool: Pool;
|
|
43
|
-
private migrationManager
|
|
49
|
+
private migrationManager!: MigrationManager;
|
|
44
50
|
private initialized: boolean = false;
|
|
45
51
|
private ownsPool: boolean = true;
|
|
46
52
|
private initPromise: Promise<void> | null = null;
|
|
47
53
|
|
|
48
54
|
constructor(options: PostgreSQLAssistantStoreOptions) {
|
|
55
|
+
// Use externally-managed pool if provided
|
|
56
|
+
if (options.pool) {
|
|
57
|
+
this.pool = options.pool;
|
|
58
|
+
this.ownsPool = false;
|
|
59
|
+
this.initialized = true;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
49
63
|
// Create Pool from config
|
|
50
64
|
if (typeof options.poolConfig === "string") {
|
|
51
65
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
66
|
+
} else if (options.poolConfig) {
|
|
67
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
52
68
|
} else {
|
|
53
|
-
|
|
69
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
54
70
|
}
|
|
55
71
|
|
|
56
72
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -14,7 +14,8 @@ import { alterChannelInstallationsTable } from "../migrations/channel_installati
|
|
|
14
14
|
import { decrypt, encrypt } from "@axiom-lattice/core";
|
|
15
15
|
|
|
16
16
|
export interface PostgreSQLChannelInstallationStoreOptions {
|
|
17
|
-
|
|
17
|
+
pool?: Pool;
|
|
18
|
+
poolConfig?: string | PoolConfig;
|
|
18
19
|
autoMigrate?: boolean;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -35,15 +36,26 @@ export class PostgreSQLChannelInstallationStore
|
|
|
35
36
|
implements ChannelInstallationStore
|
|
36
37
|
{
|
|
37
38
|
private pool: Pool;
|
|
38
|
-
private migrationManager
|
|
39
|
+
private migrationManager!: MigrationManager;
|
|
39
40
|
private initialized = false;
|
|
41
|
+
private ownsPool: boolean = true;
|
|
40
42
|
private initPromise: Promise<void> | null = null;
|
|
41
43
|
|
|
42
44
|
constructor(options: PostgreSQLChannelInstallationStoreOptions) {
|
|
45
|
+
// Use externally-managed pool if provided
|
|
46
|
+
if (options.pool) {
|
|
47
|
+
this.pool = options.pool;
|
|
48
|
+
this.ownsPool = false;
|
|
49
|
+
this.initialized = true;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
this.pool =
|
|
44
54
|
typeof options.poolConfig === "string"
|
|
45
55
|
? new Pool({ connectionString: options.poolConfig })
|
|
46
|
-
:
|
|
56
|
+
: options.poolConfig
|
|
57
|
+
? new Pool(options.poolConfig as PoolConfig)
|
|
58
|
+
: (() => { throw new Error("Either pool or poolConfig must be provided"); })();
|
|
47
59
|
|
|
48
60
|
this.migrationManager = new MigrationManager(this.pool);
|
|
49
61
|
this.migrationManager.register(createChannelInstallationsTable);
|
|
@@ -81,6 +93,12 @@ export class PostgreSQLChannelInstallationStore
|
|
|
81
93
|
return this.initPromise;
|
|
82
94
|
}
|
|
83
95
|
|
|
96
|
+
async dispose(): Promise<void> {
|
|
97
|
+
if (this.ownsPool && this.pool) {
|
|
98
|
+
await this.pool.end();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
async getInstallationById(
|
|
85
103
|
installationId: string,
|
|
86
104
|
): Promise<ChannelInstallation | null> {
|
|
@@ -19,11 +19,17 @@ import { encrypt, decrypt } from '@axiom-lattice/core';
|
|
|
19
19
|
* PostgreSQL DatabaseConfigStore options
|
|
20
20
|
*/
|
|
21
21
|
export interface PostgreSQLDatabaseConfigStoreOptions {
|
|
22
|
+
/**
|
|
23
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
24
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
25
|
+
*/
|
|
26
|
+
pool?: Pool;
|
|
27
|
+
|
|
22
28
|
/**
|
|
23
29
|
* PostgreSQL connection pool configuration
|
|
24
30
|
* Can be a connection string or PoolConfig object
|
|
25
31
|
*/
|
|
26
|
-
poolConfig
|
|
32
|
+
poolConfig?: string | PoolConfig;
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* Whether to run migrations automatically on initialization
|
|
@@ -42,16 +48,27 @@ export interface PostgreSQLDatabaseConfigStoreOptions {
|
|
|
42
48
|
*/
|
|
43
49
|
export class PostgreSQLDatabaseConfigStore implements DatabaseConfigStore {
|
|
44
50
|
private pool: Pool;
|
|
45
|
-
private migrationManager
|
|
51
|
+
private migrationManager!: MigrationManager;
|
|
46
52
|
private initialized: boolean = false;
|
|
53
|
+
private ownsPool: boolean = true;
|
|
47
54
|
private initPromise: Promise<void> | null = null;
|
|
48
55
|
|
|
49
56
|
constructor(options: PostgreSQLDatabaseConfigStoreOptions) {
|
|
57
|
+
// Use externally-managed pool if provided
|
|
58
|
+
if (options.pool) {
|
|
59
|
+
this.pool = options.pool;
|
|
60
|
+
this.ownsPool = false;
|
|
61
|
+
this.initialized = true;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
// Create Pool from config
|
|
51
66
|
if (typeof options.poolConfig === 'string') {
|
|
52
67
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
68
|
+
} else if (options.poolConfig) {
|
|
69
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
53
70
|
} else {
|
|
54
|
-
|
|
71
|
+
throw new Error('Either pool or poolConfig must be provided');
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -368,7 +385,9 @@ export class PostgreSQLDatabaseConfigStore implements DatabaseConfigStore {
|
|
|
368
385
|
* Dispose resources and close the connection pool
|
|
369
386
|
*/
|
|
370
387
|
async dispose(): Promise<void> {
|
|
371
|
-
|
|
388
|
+
if (this.ownsPool && this.pool) {
|
|
389
|
+
await this.pool.end();
|
|
390
|
+
}
|
|
372
391
|
}
|
|
373
392
|
|
|
374
393
|
/**
|
|
@@ -23,8 +23,10 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
23
23
|
|
|
24
24
|
/** PostgreSQL EvalStore options */
|
|
25
25
|
export interface PostgreSQLEvalStoreOptions {
|
|
26
|
+
/** External pool instance. When provided, poolConfig is not required. */
|
|
27
|
+
pool?: Pool;
|
|
26
28
|
/** PostgreSQL connection pool configuration */
|
|
27
|
-
poolConfig
|
|
29
|
+
poolConfig?: string | PoolConfig;
|
|
28
30
|
/** Whether to run migrations automatically on initialization @default true */
|
|
29
31
|
autoMigrate?: boolean;
|
|
30
32
|
}
|
|
@@ -39,17 +41,27 @@ export interface PostgreSQLEvalStoreOptions {
|
|
|
39
41
|
*/
|
|
40
42
|
export class PostgreSQLEvalStore implements EvalStore {
|
|
41
43
|
private pool: Pool;
|
|
42
|
-
private migrationManager
|
|
44
|
+
private migrationManager!: MigrationManager;
|
|
43
45
|
private initialized: boolean = false;
|
|
44
46
|
private ownsPool: boolean = true;
|
|
45
47
|
private initPromise: Promise<void> | null = null;
|
|
46
48
|
|
|
47
49
|
constructor(options: PostgreSQLEvalStoreOptions) {
|
|
50
|
+
// Use externally-managed pool if provided
|
|
51
|
+
if (options.pool) {
|
|
52
|
+
this.pool = options.pool;
|
|
53
|
+
this.ownsPool = false;
|
|
54
|
+
this.initialized = true;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
// Create Pool from config
|
|
49
59
|
if (typeof options.poolConfig === "string") {
|
|
50
60
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
61
|
+
} else if (options.poolConfig) {
|
|
62
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
51
63
|
} else {
|
|
52
|
-
|
|
64
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -19,11 +19,17 @@ import { encrypt, decrypt } from '@axiom-lattice/core';
|
|
|
19
19
|
* PostgreSQL McpServerConfigStore options
|
|
20
20
|
*/
|
|
21
21
|
export interface PostgreSQLMcpServerConfigStoreOptions {
|
|
22
|
+
/**
|
|
23
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
24
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
25
|
+
*/
|
|
26
|
+
pool?: Pool;
|
|
27
|
+
|
|
22
28
|
/**
|
|
23
29
|
* PostgreSQL connection pool configuration
|
|
24
30
|
* Can be a connection string or PoolConfig object
|
|
25
31
|
*/
|
|
26
|
-
poolConfig
|
|
32
|
+
poolConfig?: string | PoolConfig;
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* Whether to run migrations automatically on initialization
|
|
@@ -42,16 +48,27 @@ export interface PostgreSQLMcpServerConfigStoreOptions {
|
|
|
42
48
|
*/
|
|
43
49
|
export class PostgreSQLMcpServerConfigStore implements McpServerConfigStore {
|
|
44
50
|
private pool: Pool;
|
|
45
|
-
private migrationManager
|
|
51
|
+
private migrationManager!: MigrationManager;
|
|
46
52
|
private initialized: boolean = false;
|
|
53
|
+
private ownsPool: boolean = true;
|
|
47
54
|
private initPromise: Promise<void> | null = null;
|
|
48
55
|
|
|
49
56
|
constructor(options: PostgreSQLMcpServerConfigStoreOptions) {
|
|
57
|
+
// Use externally-managed pool if provided
|
|
58
|
+
if (options.pool) {
|
|
59
|
+
this.pool = options.pool;
|
|
60
|
+
this.ownsPool = false;
|
|
61
|
+
this.initialized = true;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
// Create Pool from config
|
|
51
66
|
if (typeof options.poolConfig === 'string') {
|
|
52
67
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
68
|
+
} else if (options.poolConfig) {
|
|
69
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
53
70
|
} else {
|
|
54
|
-
|
|
71
|
+
throw new Error('Either pool or poolConfig must be provided');
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -398,7 +415,9 @@ export class PostgreSQLMcpServerConfigStore implements McpServerConfigStore {
|
|
|
398
415
|
* Dispose resources and close the connection pool
|
|
399
416
|
*/
|
|
400
417
|
async dispose(): Promise<void> {
|
|
401
|
-
|
|
418
|
+
if (this.ownsPool && this.pool) {
|
|
419
|
+
await this.pool.end();
|
|
420
|
+
}
|
|
402
421
|
}
|
|
403
422
|
|
|
404
423
|
/**
|
|
@@ -19,11 +19,17 @@ import { encrypt, decrypt } from '@axiom-lattice/core';
|
|
|
19
19
|
* PostgreSQL MetricsServerConfigStore options
|
|
20
20
|
*/
|
|
21
21
|
export interface PostgreSQLMetricsServerConfigStoreOptions {
|
|
22
|
+
/**
|
|
23
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
24
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
25
|
+
*/
|
|
26
|
+
pool?: Pool;
|
|
27
|
+
|
|
22
28
|
/**
|
|
23
29
|
* PostgreSQL connection pool configuration
|
|
24
30
|
* Can be a connection string or PoolConfig object
|
|
25
31
|
*/
|
|
26
|
-
poolConfig
|
|
32
|
+
poolConfig?: string | PoolConfig;
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* Whether to run migrations automatically on initialization
|
|
@@ -42,16 +48,27 @@ export interface PostgreSQLMetricsServerConfigStoreOptions {
|
|
|
42
48
|
*/
|
|
43
49
|
export class PostgreSQLMetricsServerConfigStore implements MetricsServerConfigStore {
|
|
44
50
|
private pool: Pool;
|
|
45
|
-
private migrationManager
|
|
51
|
+
private migrationManager!: MigrationManager;
|
|
46
52
|
private initialized: boolean = false;
|
|
53
|
+
private ownsPool: boolean = true;
|
|
47
54
|
private initPromise: Promise<void> | null = null;
|
|
48
55
|
|
|
49
56
|
constructor(options: PostgreSQLMetricsServerConfigStoreOptions) {
|
|
57
|
+
// Use externally-managed pool if provided
|
|
58
|
+
if (options.pool) {
|
|
59
|
+
this.pool = options.pool;
|
|
60
|
+
this.ownsPool = false;
|
|
61
|
+
this.initialized = true;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
// Create Pool from config
|
|
51
66
|
if (typeof options.poolConfig === 'string') {
|
|
52
67
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
68
|
+
} else if (options.poolConfig) {
|
|
69
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
53
70
|
} else {
|
|
54
|
-
|
|
71
|
+
throw new Error('Either pool or poolConfig must be provided');
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -368,7 +385,9 @@ export class PostgreSQLMetricsServerConfigStore implements MetricsServerConfigSt
|
|
|
368
385
|
* Dispose resources and close the connection pool
|
|
369
386
|
*/
|
|
370
387
|
async dispose(): Promise<void> {
|
|
371
|
-
|
|
388
|
+
if (this.ownsPool && this.pool) {
|
|
389
|
+
await this.pool.end();
|
|
390
|
+
}
|
|
372
391
|
}
|
|
373
392
|
|
|
374
393
|
/**
|
|
@@ -18,11 +18,17 @@ import { addProjectConfigColumn } from "../migrations/add_project_config_column"
|
|
|
18
18
|
* PostgreSQL ProjectStore options
|
|
19
19
|
*/
|
|
20
20
|
export interface PostgreSQLProjectStoreOptions {
|
|
21
|
+
/**
|
|
22
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
23
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
24
|
+
*/
|
|
25
|
+
pool?: Pool;
|
|
26
|
+
|
|
21
27
|
/**
|
|
22
28
|
* PostgreSQL connection pool configuration
|
|
23
29
|
* Can be a connection string or PoolConfig object
|
|
24
30
|
*/
|
|
25
|
-
poolConfig
|
|
31
|
+
poolConfig?: string | PoolConfig;
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
34
|
* Whether to run migrations automatically on initialization
|
|
@@ -36,16 +42,26 @@ export interface PostgreSQLProjectStoreOptions {
|
|
|
36
42
|
*/
|
|
37
43
|
export class PostgreSQLProjectStore implements ProjectStore {
|
|
38
44
|
private pool: Pool;
|
|
39
|
-
private migrationManager
|
|
45
|
+
private migrationManager!: MigrationManager;
|
|
40
46
|
private initialized: boolean = false;
|
|
41
47
|
private ownsPool: boolean = true;
|
|
42
48
|
|
|
43
49
|
constructor(options: PostgreSQLProjectStoreOptions) {
|
|
50
|
+
// Use externally-managed pool if provided
|
|
51
|
+
if (options.pool) {
|
|
52
|
+
this.pool = options.pool;
|
|
53
|
+
this.ownsPool = false;
|
|
54
|
+
this.initialized = true;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
// Create Pool from config
|
|
45
59
|
if (typeof options.poolConfig === "string") {
|
|
46
60
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
61
|
+
} else if (options.poolConfig) {
|
|
62
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
47
63
|
} else {
|
|
48
|
-
|
|
64
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -21,11 +21,17 @@ import { addScheduleTenantId } from "../migrations/schedule_tenant_migration";
|
|
|
21
21
|
* PostgreSQL ScheduleStorage options
|
|
22
22
|
*/
|
|
23
23
|
export interface PostgreSQLScheduleStorageOptions {
|
|
24
|
+
/**
|
|
25
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
26
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
27
|
+
*/
|
|
28
|
+
pool?: Pool;
|
|
29
|
+
|
|
24
30
|
/**
|
|
25
31
|
* PostgreSQL connection pool configuration
|
|
26
32
|
* Can be a connection string or PoolConfig object
|
|
27
33
|
*/
|
|
28
|
-
poolConfig
|
|
34
|
+
poolConfig?: string | PoolConfig;
|
|
29
35
|
|
|
30
36
|
/**
|
|
31
37
|
* Whether to run migrations automatically on initialization
|
|
@@ -68,15 +74,26 @@ interface ScheduledTaskRow {
|
|
|
68
74
|
*/
|
|
69
75
|
export class PostgreSQLScheduleStorage implements ScheduleStorage {
|
|
70
76
|
private pool: Pool;
|
|
71
|
-
private migrationManager
|
|
77
|
+
private migrationManager!: MigrationManager;
|
|
72
78
|
private initialized: boolean = false;
|
|
79
|
+
private ownsPool: boolean = true;
|
|
73
80
|
|
|
74
81
|
constructor(options: PostgreSQLScheduleStorageOptions) {
|
|
82
|
+
// Use externally-managed pool if provided
|
|
83
|
+
if (options.pool) {
|
|
84
|
+
this.pool = options.pool;
|
|
85
|
+
this.ownsPool = false;
|
|
86
|
+
this.initialized = true;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
// Create Pool from config
|
|
76
91
|
if (typeof options.poolConfig === "string") {
|
|
77
92
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
93
|
+
} else if (options.poolConfig) {
|
|
94
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
78
95
|
} else {
|
|
79
|
-
|
|
96
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
80
97
|
}
|
|
81
98
|
|
|
82
99
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -96,7 +113,7 @@ export class PostgreSQLScheduleStorage implements ScheduleStorage {
|
|
|
96
113
|
* Dispose resources and close the connection pool
|
|
97
114
|
*/
|
|
98
115
|
async dispose(): Promise<void> {
|
|
99
|
-
if (this.pool) {
|
|
116
|
+
if (this.ownsPool && this.pool) {
|
|
100
117
|
await this.pool.end();
|
|
101
118
|
}
|
|
102
119
|
}
|
|
@@ -15,7 +15,8 @@ import { addSkillTenantId } from "../migrations/skill_tenant_migration";
|
|
|
15
15
|
import { changeSkillPrimaryKey } from "../migrations/skill_pk_migration";
|
|
16
16
|
|
|
17
17
|
export interface PostgreSQLSkillStoreOptions {
|
|
18
|
-
|
|
18
|
+
pool?: Pool;
|
|
19
|
+
poolConfig?: string | PoolConfig;
|
|
19
20
|
autoMigrate?: boolean;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -27,16 +28,26 @@ export interface PostgreSQLSkillStoreOptions {
|
|
|
27
28
|
*/
|
|
28
29
|
export class PostgreSQLSkillStore implements SkillStore {
|
|
29
30
|
private pool: Pool;
|
|
30
|
-
private migrationManager
|
|
31
|
+
private migrationManager!: MigrationManager;
|
|
31
32
|
private initialized: boolean = false;
|
|
32
33
|
private ownsPool: boolean = true;
|
|
33
34
|
private initPromise: Promise<void> | null = null;
|
|
34
35
|
|
|
35
36
|
constructor(options: PostgreSQLSkillStoreOptions) {
|
|
37
|
+
// Use externally-managed pool if provided
|
|
38
|
+
if (options.pool) {
|
|
39
|
+
this.pool = options.pool;
|
|
40
|
+
this.ownsPool = false;
|
|
41
|
+
this.initialized = true;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
if (typeof options.poolConfig === "string") {
|
|
37
46
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
47
|
+
} else if (options.poolConfig) {
|
|
48
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
38
49
|
} else {
|
|
39
|
-
|
|
50
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
40
51
|
}
|
|
41
52
|
|
|
42
53
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -54,22 +54,33 @@ function mapRowToTask(row: TaskRow): TaskItem {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export interface PostgreSQLTaskStoreOptions {
|
|
57
|
-
|
|
57
|
+
pool?: Pool;
|
|
58
|
+
poolConfig?: string | PoolConfig;
|
|
58
59
|
autoMigrate?: boolean;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export class PostgreSQLTaskStore implements TaskStore {
|
|
62
63
|
private pool: Pool;
|
|
63
|
-
private migrationManager
|
|
64
|
+
private migrationManager!: MigrationManager;
|
|
64
65
|
private initialized: boolean = false;
|
|
65
66
|
private ownsPool: boolean = true;
|
|
66
67
|
private initPromise: Promise<void> | null = null;
|
|
67
68
|
|
|
68
69
|
constructor(options: PostgreSQLTaskStoreOptions) {
|
|
70
|
+
// Use externally-managed pool if provided
|
|
71
|
+
if (options.pool) {
|
|
72
|
+
this.pool = options.pool;
|
|
73
|
+
this.ownsPool = false;
|
|
74
|
+
this.initialized = true;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
69
78
|
if (typeof options.poolConfig === "string") {
|
|
70
79
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
80
|
+
} else if (options.poolConfig) {
|
|
81
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
71
82
|
} else {
|
|
72
|
-
|
|
83
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
73
84
|
}
|
|
74
85
|
|
|
75
86
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -18,11 +18,17 @@ import { createTenantsTable } from "../migrations/tenant_migrations";
|
|
|
18
18
|
* PostgreSQL TenantStore options
|
|
19
19
|
*/
|
|
20
20
|
export interface PostgreSQLTenantStoreOptions {
|
|
21
|
+
/**
|
|
22
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
23
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
24
|
+
*/
|
|
25
|
+
pool?: Pool;
|
|
26
|
+
|
|
21
27
|
/**
|
|
22
28
|
* PostgreSQL connection pool configuration
|
|
23
29
|
* Can be a connection string or PoolConfig object
|
|
24
30
|
*/
|
|
25
|
-
poolConfig
|
|
31
|
+
poolConfig?: string | PoolConfig;
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
34
|
* Whether to run migrations automatically on initialization
|
|
@@ -37,16 +43,26 @@ export interface PostgreSQLTenantStoreOptions {
|
|
|
37
43
|
*/
|
|
38
44
|
export class PostgreSQLTenantStore implements TenantStore {
|
|
39
45
|
private pool: Pool;
|
|
40
|
-
private migrationManager
|
|
46
|
+
private migrationManager!: MigrationManager;
|
|
41
47
|
private initialized: boolean = false;
|
|
42
48
|
private ownsPool: boolean = true;
|
|
43
49
|
|
|
44
50
|
constructor(options: PostgreSQLTenantStoreOptions) {
|
|
51
|
+
// Use externally-managed pool if provided
|
|
52
|
+
if (options.pool) {
|
|
53
|
+
this.pool = options.pool;
|
|
54
|
+
this.ownsPool = false;
|
|
55
|
+
this.initialized = true;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
45
59
|
// Create Pool from config
|
|
46
60
|
if (typeof options.poolConfig === "string") {
|
|
47
61
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
62
|
+
} else if (options.poolConfig) {
|
|
63
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
48
64
|
} else {
|
|
49
|
-
|
|
65
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
50
66
|
}
|
|
51
67
|
|
|
52
68
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -18,11 +18,17 @@ import { changeThreadPrimaryKey } from "../migrations/thread_pk_migration";
|
|
|
18
18
|
* PostgreSQL ThreadStore options
|
|
19
19
|
*/
|
|
20
20
|
export interface PostgreSQLThreadStoreOptions {
|
|
21
|
+
/**
|
|
22
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
23
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
24
|
+
*/
|
|
25
|
+
pool?: Pool;
|
|
26
|
+
|
|
21
27
|
/**
|
|
22
28
|
* PostgreSQL connection pool configuration
|
|
23
29
|
* Can be a connection string or PoolConfig object
|
|
24
30
|
*/
|
|
25
|
-
poolConfig
|
|
31
|
+
poolConfig?: string | PoolConfig;
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
34
|
* Whether to run migrations automatically on initialization
|
|
@@ -39,17 +45,27 @@ export interface PostgreSQLThreadStoreOptions {
|
|
|
39
45
|
*/
|
|
40
46
|
export class PostgreSQLThreadStore implements ThreadStore {
|
|
41
47
|
private pool: Pool;
|
|
42
|
-
private migrationManager
|
|
48
|
+
private migrationManager!: MigrationManager;
|
|
43
49
|
private initialized: boolean = false;
|
|
44
50
|
private ownsPool: boolean = true;
|
|
45
51
|
private initPromise: Promise<void> | null = null;
|
|
46
52
|
|
|
47
53
|
constructor(options: PostgreSQLThreadStoreOptions) {
|
|
54
|
+
// Use externally-managed pool if provided
|
|
55
|
+
if (options.pool) {
|
|
56
|
+
this.pool = options.pool;
|
|
57
|
+
this.ownsPool = false;
|
|
58
|
+
this.initialized = true;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
// Create Pool from config
|
|
49
63
|
if (typeof options.poolConfig === "string") {
|
|
50
64
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
65
|
+
} else if (options.poolConfig) {
|
|
66
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
51
67
|
} else {
|
|
52
|
-
|
|
68
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
53
69
|
}
|
|
54
70
|
|
|
55
71
|
this.migrationManager = new MigrationManager(this.pool);
|