@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
|
@@ -6,20 +6,32 @@ import { createUsersTable } from "../migrations/user_migrations";
|
|
|
6
6
|
import { addUserStatusColumn } from "../migrations/user_status_migration";
|
|
7
7
|
|
|
8
8
|
export interface PostgreSQLUserStoreOptions {
|
|
9
|
-
|
|
9
|
+
pool?: Pool;
|
|
10
|
+
poolConfig?: string | PoolConfig;
|
|
10
11
|
autoMigrate?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export class PostgreSQLUserStore implements UserStore {
|
|
14
15
|
private pool: Pool;
|
|
15
|
-
private migrationManager
|
|
16
|
+
private migrationManager!: MigrationManager;
|
|
16
17
|
private initialized: boolean = false;
|
|
18
|
+
private ownsPool: boolean = true;
|
|
17
19
|
|
|
18
20
|
constructor(options: PostgreSQLUserStoreOptions) {
|
|
21
|
+
// Use externally-managed pool if provided
|
|
22
|
+
if (options.pool) {
|
|
23
|
+
this.pool = options.pool;
|
|
24
|
+
this.ownsPool = false;
|
|
25
|
+
this.initialized = true;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
if (typeof options.poolConfig === "string") {
|
|
20
30
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
31
|
+
} else if (options.poolConfig) {
|
|
32
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
21
33
|
} else {
|
|
22
|
-
|
|
34
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -35,7 +47,9 @@ export class PostgreSQLUserStore implements UserStore {
|
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
async dispose(): Promise<void> {
|
|
38
|
-
|
|
50
|
+
if (this.ownsPool && this.pool) {
|
|
51
|
+
await this.pool.end();
|
|
52
|
+
}
|
|
39
53
|
}
|
|
40
54
|
|
|
41
55
|
async initialize(): Promise<void> {
|
|
@@ -11,20 +11,32 @@ import { MigrationManager } from "../migrations/migration";
|
|
|
11
11
|
import { createUserTenantLinkTable, migrateRemoveTenantIdFromUsers } from "../migrations/user_tenant_link_migrations";
|
|
12
12
|
|
|
13
13
|
export interface PostgreSQLUserTenantLinkStoreOptions {
|
|
14
|
-
|
|
14
|
+
pool?: Pool;
|
|
15
|
+
poolConfig?: string | PoolConfig;
|
|
15
16
|
autoMigrate?: boolean;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export class PostgreSQLUserTenantLinkStore implements UserTenantLinkStore {
|
|
19
20
|
private pool: Pool;
|
|
20
|
-
private migrationManager
|
|
21
|
+
private migrationManager!: MigrationManager;
|
|
21
22
|
private initialized: boolean = false;
|
|
23
|
+
private ownsPool: boolean = true;
|
|
22
24
|
|
|
23
25
|
constructor(options: PostgreSQLUserTenantLinkStoreOptions) {
|
|
26
|
+
// Use externally-managed pool if provided
|
|
27
|
+
if (options.pool) {
|
|
28
|
+
this.pool = options.pool;
|
|
29
|
+
this.ownsPool = false;
|
|
30
|
+
this.initialized = true;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
if (typeof options.poolConfig === "string") {
|
|
25
35
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
36
|
+
} else if (options.poolConfig) {
|
|
37
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
26
38
|
} else {
|
|
27
|
-
|
|
39
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -40,7 +52,9 @@ export class PostgreSQLUserTenantLinkStore implements UserTenantLinkStore {
|
|
|
40
52
|
}
|
|
41
53
|
|
|
42
54
|
async dispose(): Promise<void> {
|
|
43
|
-
|
|
55
|
+
if (this.ownsPool && this.pool) {
|
|
56
|
+
await this.pool.end();
|
|
57
|
+
}
|
|
44
58
|
}
|
|
45
59
|
|
|
46
60
|
async initialize(): Promise<void> {
|
|
@@ -19,21 +19,33 @@ import { MigrationManager } from "../migrations/migration";
|
|
|
19
19
|
import { createWorkflowTrackingTables, addStepThreadId } from "../migrations/workflow_tracking_migrations";
|
|
20
20
|
|
|
21
21
|
export interface PostgreSQLWorkflowTrackingStoreOptions {
|
|
22
|
-
|
|
22
|
+
pool?: Pool;
|
|
23
|
+
poolConfig?: string | PoolConfig;
|
|
23
24
|
autoMigrate?: boolean;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export class PostgreSQLWorkflowTrackingStore implements WorkflowTrackingStore {
|
|
27
28
|
private pool: Pool;
|
|
28
|
-
private migrationManager
|
|
29
|
+
private migrationManager!: MigrationManager;
|
|
29
30
|
private initialized: boolean = false;
|
|
31
|
+
private ownsPool: boolean = true;
|
|
30
32
|
private initPromise: Promise<void> | null = null;
|
|
31
33
|
|
|
32
34
|
constructor(options: PostgreSQLWorkflowTrackingStoreOptions) {
|
|
35
|
+
// Use externally-managed pool if provided
|
|
36
|
+
if (options.pool) {
|
|
37
|
+
this.pool = options.pool;
|
|
38
|
+
this.ownsPool = false;
|
|
39
|
+
this.initialized = true;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
if (typeof options.poolConfig === "string") {
|
|
34
44
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
45
|
+
} else if (options.poolConfig) {
|
|
46
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
35
47
|
} else {
|
|
36
|
-
|
|
48
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
37
49
|
}
|
|
38
50
|
|
|
39
51
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -49,7 +61,9 @@ export class PostgreSQLWorkflowTrackingStore implements WorkflowTrackingStore {
|
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
async dispose(): Promise<void> {
|
|
52
|
-
|
|
64
|
+
if (this.ownsPool && this.pool) {
|
|
65
|
+
await this.pool.end();
|
|
66
|
+
}
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
async initialize(): Promise<void> {
|
|
@@ -17,11 +17,17 @@ import { createWorkspacesTable } from "../migrations/workspace_migrations";
|
|
|
17
17
|
* PostgreSQL WorkspaceStore options
|
|
18
18
|
*/
|
|
19
19
|
export interface PostgreSQLWorkspaceStoreOptions {
|
|
20
|
+
/**
|
|
21
|
+
* External pool instance. When provided, poolConfig is not required and the
|
|
22
|
+
* caller is responsible for pool lifecycle and migrations.
|
|
23
|
+
*/
|
|
24
|
+
pool?: Pool;
|
|
25
|
+
|
|
20
26
|
/**
|
|
21
27
|
* PostgreSQL connection pool configuration
|
|
22
28
|
* Can be a connection string or PoolConfig object
|
|
23
29
|
*/
|
|
24
|
-
poolConfig
|
|
30
|
+
poolConfig?: string | PoolConfig;
|
|
25
31
|
|
|
26
32
|
/**
|
|
27
33
|
* Whether to run migrations automatically on initialization
|
|
@@ -35,16 +41,26 @@ export interface PostgreSQLWorkspaceStoreOptions {
|
|
|
35
41
|
*/
|
|
36
42
|
export class PostgreSQLWorkspaceStore implements WorkspaceStore {
|
|
37
43
|
private pool: Pool;
|
|
38
|
-
private migrationManager
|
|
44
|
+
private migrationManager!: MigrationManager;
|
|
39
45
|
private initialized: boolean = false;
|
|
40
46
|
private ownsPool: boolean = true;
|
|
41
47
|
|
|
42
48
|
constructor(options: PostgreSQLWorkspaceStoreOptions) {
|
|
49
|
+
// Use externally-managed pool if provided
|
|
50
|
+
if (options.pool) {
|
|
51
|
+
this.pool = options.pool;
|
|
52
|
+
this.ownsPool = false;
|
|
53
|
+
this.initialized = true;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
// Create Pool from config
|
|
44
58
|
if (typeof options.poolConfig === "string") {
|
|
45
59
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
60
|
+
} else if (options.poolConfig) {
|
|
61
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
46
62
|
} else {
|
|
47
|
-
|
|
63
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
this.migrationManager = new MigrationManager(this.pool);
|
|
@@ -6,7 +6,8 @@ import { MigrationManager } from "../migrations/migration";
|
|
|
6
6
|
import { createSharedResourcesTable } from "../migrations/shared_resources_migration";
|
|
7
7
|
|
|
8
8
|
export interface PostgresSharedResourceStoreOptions {
|
|
9
|
-
|
|
9
|
+
pool?: Pool;
|
|
10
|
+
poolConfig?: string | PoolConfig;
|
|
10
11
|
autoMigrate?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -32,15 +33,26 @@ type ShareRow = {
|
|
|
32
33
|
|
|
33
34
|
export class PostgresSharedResourceStore implements SharedResourceStore {
|
|
34
35
|
private pool: Pool;
|
|
35
|
-
private migrationManager
|
|
36
|
+
private migrationManager!: MigrationManager;
|
|
36
37
|
private initialized = false;
|
|
38
|
+
private ownsPool: boolean = true;
|
|
37
39
|
private initPromise: Promise<void> | null = null;
|
|
38
40
|
|
|
39
41
|
constructor(options: PostgresSharedResourceStoreOptions) {
|
|
42
|
+
// Use externally-managed pool if provided
|
|
43
|
+
if (options.pool) {
|
|
44
|
+
this.pool = options.pool;
|
|
45
|
+
this.ownsPool = false;
|
|
46
|
+
this.initialized = true;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
this.pool =
|
|
41
51
|
typeof options.poolConfig === "string"
|
|
42
52
|
? new Pool({ connectionString: options.poolConfig })
|
|
43
|
-
:
|
|
53
|
+
: options.poolConfig
|
|
54
|
+
? new Pool(options.poolConfig as PoolConfig)
|
|
55
|
+
: (() => { throw new Error("Either pool or poolConfig must be provided"); })();
|
|
44
56
|
|
|
45
57
|
this.migrationManager = new MigrationManager(this.pool);
|
|
46
58
|
this.migrationManager.register(createSharedResourcesTable);
|
|
@@ -70,6 +82,12 @@ export class PostgresSharedResourceStore implements SharedResourceStore {
|
|
|
70
82
|
return this.initPromise;
|
|
71
83
|
}
|
|
72
84
|
|
|
85
|
+
async dispose(): Promise<void> {
|
|
86
|
+
if (this.ownsPool && this.pool) {
|
|
87
|
+
await this.pool.end();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
73
91
|
async findByToken(token: string): Promise<ShareRecord | null> {
|
|
74
92
|
await this.ensureInitialized();
|
|
75
93
|
const { rows } = await this.pool.query<ShareRow>(
|
|
@@ -22,7 +22,8 @@ import { addWorkspaceProjectToQueue } from "../migrations/add_workspace_project_
|
|
|
22
22
|
export type { PendingMessage, AddMessageParams, ThreadInfo };
|
|
23
23
|
|
|
24
24
|
export interface PostgreSQLThreadMessageQueueStoreOptions {
|
|
25
|
-
|
|
25
|
+
pool?: Pool;
|
|
26
|
+
poolConfig?: string | PoolConfig;
|
|
26
27
|
autoMigrate?: boolean;
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -31,14 +32,24 @@ export class ThreadMessageQueueStore implements IMessageQueueStore {
|
|
|
31
32
|
private ownsPool: boolean = true;
|
|
32
33
|
private initialized: boolean = false;
|
|
33
34
|
private initPromise: Promise<void> | null = null;
|
|
34
|
-
private migrationManager
|
|
35
|
+
private migrationManager!: MigrationManager;
|
|
35
36
|
|
|
36
37
|
constructor(options: PostgreSQLThreadMessageQueueStoreOptions) {
|
|
38
|
+
// Use externally-managed pool if provided
|
|
39
|
+
if (options.pool) {
|
|
40
|
+
this.pool = options.pool;
|
|
41
|
+
this.ownsPool = false;
|
|
42
|
+
this.initialized = true;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
37
46
|
// Create Pool from config
|
|
38
47
|
if (typeof options.poolConfig === "string") {
|
|
39
48
|
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
49
|
+
} else if (options.poolConfig) {
|
|
50
|
+
this.pool = new Pool(options.poolConfig as PoolConfig);
|
|
40
51
|
} else {
|
|
41
|
-
|
|
52
|
+
throw new Error("Either pool or poolConfig must be provided");
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
this.migrationManager = new MigrationManager(this.pool);
|