@axiom-lattice/pg-stores 1.0.13 → 1.0.14

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PoolConfig, PoolClient, Pool } from 'pg';
2
- import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType, SkillStore, Skill, CreateSkillRequest } from '@axiom-lattice/protocols';
3
- export { Assistant, AssistantStore, CreateAssistantRequest, CreateSkillRequest, CreateThreadRequest, ScheduleExecutionType, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, Skill, SkillStore, Thread, ThreadStore } from '@axiom-lattice/protocols';
2
+ import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType, SkillStore, Skill, CreateSkillRequest, DatabaseConfigStore, DatabaseConfigEntry, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, WorkspaceStore, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, ProjectStore, Project, CreateProjectRequest, UpdateProjectRequest } from '@axiom-lattice/protocols';
3
+ export { Assistant, AssistantStore, CreateAssistantRequest, CreateDatabaseConfigRequest, CreateProjectRequest, CreateSkillRequest, CreateThreadRequest, CreateWorkspaceRequest, DatabaseConfig, DatabaseConfigEntry, DatabaseConfigStore, DatabaseType, Project, ProjectStore, ScheduleExecutionType, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, Skill, SkillStore, StorageType, Thread, ThreadStore, UpdateDatabaseConfigRequest, UpdateProjectRequest, UpdateWorkspaceRequest, Workspace, WorkspaceStore } from '@axiom-lattice/protocols';
4
4
 
5
5
  /**
6
6
  * PostgreSQL implementation of ThreadStore
@@ -347,6 +347,229 @@ declare class PostgreSQLSkillStore implements SkillStore {
347
347
  getSubSkills(parentSkillName: string): Promise<Skill[]>;
348
348
  }
349
349
 
350
+ /**
351
+ * PostgreSQL implementation of DatabaseConfigStore
352
+ */
353
+
354
+ /**
355
+ * PostgreSQL DatabaseConfigStore options
356
+ */
357
+ interface PostgreSQLDatabaseConfigStoreOptions {
358
+ /**
359
+ * PostgreSQL connection pool configuration
360
+ * Can be a connection string or PoolConfig object
361
+ */
362
+ poolConfig: string | PoolConfig;
363
+ /**
364
+ * Whether to run migrations automatically on initialization
365
+ * @default true
366
+ */
367
+ autoMigrate?: boolean;
368
+ }
369
+ /**
370
+ * PostgreSQL implementation of DatabaseConfigStore
371
+ *
372
+ * Features:
373
+ * - Multi-tenant isolation via tenant_id
374
+ * - Automatic password encryption/decryption
375
+ * - Unique constraint on (tenant_id, key)
376
+ */
377
+ declare class PostgreSQLDatabaseConfigStore implements DatabaseConfigStore {
378
+ private pool;
379
+ private migrationManager;
380
+ private initialized;
381
+ private initPromise;
382
+ constructor(options: PostgreSQLDatabaseConfigStoreOptions);
383
+ /**
384
+ * Initialize the store and run migrations
385
+ * Uses a promise-based lock to prevent concurrent initialization
386
+ */
387
+ initialize(): Promise<void>;
388
+ /**
389
+ * Get all database configurations for a tenant
390
+ */
391
+ getAllConfigs(tenantId: string): Promise<DatabaseConfigEntry[]>;
392
+ /**
393
+ * Get all database configurations across all tenants
394
+ */
395
+ getAllConfigsWithoutTenant(): Promise<DatabaseConfigEntry[]>;
396
+ /**
397
+ * Get database configuration by ID
398
+ */
399
+ getConfigById(tenantId: string, id: string): Promise<DatabaseConfigEntry | null>;
400
+ /**
401
+ * Get database configuration by business key
402
+ */
403
+ getConfigByKey(tenantId: string, key: string): Promise<DatabaseConfigEntry | null>;
404
+ /**
405
+ * Create a new database configuration
406
+ */
407
+ createConfig(tenantId: string, id: string, data: CreateDatabaseConfigRequest): Promise<DatabaseConfigEntry>;
408
+ /**
409
+ * Update an existing database configuration
410
+ */
411
+ updateConfig(tenantId: string, id: string, updates: Partial<UpdateDatabaseConfigRequest>): Promise<DatabaseConfigEntry | null>;
412
+ /**
413
+ * Delete a database configuration by ID
414
+ */
415
+ deleteConfig(tenantId: string, id: string): Promise<boolean>;
416
+ /**
417
+ * Check if configuration exists
418
+ */
419
+ hasConfig(tenantId: string, id: string): Promise<boolean>;
420
+ /**
421
+ * Dispose resources and close the connection pool
422
+ */
423
+ dispose(): Promise<void>;
424
+ /**
425
+ * Ensure store is initialized
426
+ */
427
+ private ensureInitialized;
428
+ /**
429
+ * Map database row to DatabaseConfigEntry object
430
+ * Automatically decrypts password if present
431
+ */
432
+ private mapRowToEntry;
433
+ /**
434
+ * Encrypt password in config before storing
435
+ */
436
+ private encryptPasswordInConfig;
437
+ }
438
+
439
+ /**
440
+ * PostgreSQL implementation of WorkspaceStore
441
+ */
442
+
443
+ /**
444
+ * PostgreSQL WorkspaceStore options
445
+ */
446
+ interface PostgreSQLWorkspaceStoreOptions {
447
+ /**
448
+ * PostgreSQL connection pool configuration
449
+ * Can be a connection string or PoolConfig object
450
+ */
451
+ poolConfig: string | PoolConfig;
452
+ /**
453
+ * Whether to run migrations automatically on initialization
454
+ * @default true
455
+ */
456
+ autoMigrate?: boolean;
457
+ }
458
+ /**
459
+ * PostgreSQL implementation of WorkspaceStore
460
+ */
461
+ declare class PostgreSQLWorkspaceStore implements WorkspaceStore {
462
+ private pool;
463
+ private migrationManager;
464
+ private initialized;
465
+ private ownsPool;
466
+ constructor(options: PostgreSQLWorkspaceStoreOptions);
467
+ /**
468
+ * Dispose resources and close the connection pool
469
+ * Should be called when the store is no longer needed
470
+ */
471
+ dispose(): Promise<void>;
472
+ /**
473
+ * Initialize the store and run migrations
474
+ */
475
+ initialize(): Promise<void>;
476
+ /**
477
+ * Ensure store is initialized
478
+ */
479
+ private ensureInitialized;
480
+ /**
481
+ * Map database row to Workspace object
482
+ */
483
+ private mapRowToWorkspace;
484
+ /**
485
+ * Get all workspaces for a tenant
486
+ */
487
+ getAllWorkspaces(tenantId: string): Promise<Workspace[]>;
488
+ /**
489
+ * Get a workspace by ID for a specific tenant
490
+ */
491
+ getWorkspaceById(tenantId: string, id: string): Promise<Workspace | null>;
492
+ /**
493
+ * Create a new workspace
494
+ */
495
+ createWorkspace(tenantId: string, id: string, data: CreateWorkspaceRequest): Promise<Workspace>;
496
+ /**
497
+ * Update an existing workspace
498
+ */
499
+ updateWorkspace(tenantId: string, id: string, updates: UpdateWorkspaceRequest): Promise<Workspace | null>;
500
+ /**
501
+ * Delete a workspace by ID
502
+ */
503
+ deleteWorkspace(tenantId: string, id: string): Promise<boolean>;
504
+ }
505
+
506
+ /**
507
+ * PostgreSQL implementation of ProjectStore
508
+ */
509
+
510
+ /**
511
+ * PostgreSQL ProjectStore options
512
+ */
513
+ interface PostgreSQLProjectStoreOptions {
514
+ /**
515
+ * PostgreSQL connection pool configuration
516
+ * Can be a connection string or PoolConfig object
517
+ */
518
+ poolConfig: string | PoolConfig;
519
+ /**
520
+ * Whether to run migrations automatically on initialization
521
+ * @default true
522
+ */
523
+ autoMigrate?: boolean;
524
+ }
525
+ /**
526
+ * PostgreSQL implementation of ProjectStore
527
+ */
528
+ declare class PostgreSQLProjectStore implements ProjectStore {
529
+ private pool;
530
+ private migrationManager;
531
+ private initialized;
532
+ private ownsPool;
533
+ constructor(options: PostgreSQLProjectStoreOptions);
534
+ /**
535
+ * Dispose resources and close the connection pool
536
+ * Should be called when the store is no longer needed
537
+ */
538
+ dispose(): Promise<void>;
539
+ /**
540
+ * Initialize the store and run migrations
541
+ */
542
+ initialize(): Promise<void>;
543
+ /**
544
+ * Ensure store is initialized
545
+ */
546
+ private ensureInitialized;
547
+ /**
548
+ * Map database row to Project object
549
+ */
550
+ private mapRowToProject;
551
+ /**
552
+ * Get all projects for a specific workspace
553
+ */
554
+ getProjectsByWorkspace(tenantId: string, workspaceId: string): Promise<Project[]>;
555
+ /**
556
+ * Get a project by ID for a specific tenant
557
+ */
558
+ getProjectById(tenantId: string, id: string): Promise<Project | null>;
559
+ /**
560
+ * Create a new project
561
+ */
562
+ createProject(tenantId: string, workspaceId: string, id: string, data: CreateProjectRequest): Promise<Project>;
563
+ /**
564
+ * Update an existing project
565
+ */
566
+ updateProject(tenantId: string, id: string, updates: UpdateProjectRequest): Promise<Project | null>;
567
+ /**
568
+ * Delete a project by ID
569
+ */
570
+ deleteProject(tenantId: string, id: string): Promise<boolean>;
571
+ }
572
+
350
573
  /**
351
574
  * Migration system for database schema management
352
575
  */
@@ -430,4 +653,31 @@ declare const createScheduledTasksTable: Migration;
430
653
  */
431
654
  declare const createSkillsTable: Migration;
432
655
 
433
- export { type Migration, MigrationManager, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLSkillStore, type PostgreSQLSkillStoreOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, createAssistantsTable, createScheduledTasksTable, createSkillsTable, createThreadsTable };
656
+ /**
657
+ * Database configuration table migrations
658
+ */
659
+
660
+ /**
661
+ * Initial migration: Create database configs table
662
+ */
663
+ declare const createDatabaseConfigsTable: Migration;
664
+
665
+ /**
666
+ * Workspace table migrations
667
+ */
668
+
669
+ /**
670
+ * Initial migration: Create workspaces table
671
+ */
672
+ declare const createWorkspacesTable: Migration;
673
+
674
+ /**
675
+ * Project table migrations
676
+ */
677
+
678
+ /**
679
+ * Initial migration: Create projects table
680
+ */
681
+ declare const createProjectsTable: Migration;
682
+
683
+ export { type Migration, MigrationManager, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLDatabaseConfigStore, type PostgreSQLDatabaseConfigStoreOptions, PostgreSQLProjectStore, type PostgreSQLProjectStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLSkillStore, type PostgreSQLSkillStoreOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, PostgreSQLWorkspaceStore, type PostgreSQLWorkspaceStoreOptions, createAssistantsTable, createDatabaseConfigsTable, createProjectsTable, createScheduledTasksTable, createSkillsTable, createThreadsTable, createWorkspacesTable };