@axiom-lattice/pg-stores 1.0.21 → 1.0.23

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/pg-stores@1.0.21 build /home/runner/work/agentic/agentic/packages/pg-stores
2
+ > @axiom-lattice/pg-stores@1.0.23 build /home/runner/work/agentic/agentic/packages/pg-stores
3
3
  > tsup src/index.ts --format cjs,esm --dts --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,13 +8,13 @@
8
8
  CLI Target: es2020
9
9
  CJS Build start
10
10
  ESM Build start
11
- ESM dist/index.mjs 104.07 KB
12
- ESM dist/index.mjs.map 197.62 KB
13
- ESM ⚡️ Build success in 296ms
14
- CJS dist/index.js 106.73 KB
15
- CJS dist/index.js.map 201.23 KB
16
- CJS ⚡️ Build success in 298ms
11
+ CJS dist/index.js 120.19 KB
12
+ CJS dist/index.js.map 226.47 KB
13
+ CJS ⚡️ Build success in 295ms
14
+ ESM dist/index.mjs 117.18 KB
15
+ ESM dist/index.mjs.map 222.45 KB
16
+ ESM ⚡️ Build success in 295ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 11190ms
19
- DTS dist/index.d.ts 29.57 KB
20
- DTS dist/index.d.mts 29.57 KB
18
+ DTS ⚡️ Build success in 12376ms
19
+ DTS dist/index.d.ts 31.85 KB
20
+ DTS dist/index.d.mts 31.85 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @axiom-lattice/pg-stores
2
2
 
3
+ ## 1.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - 99f4b77: add tenantid for all lattice
8
+ - Updated dependencies [99f4b77]
9
+ - @axiom-lattice/core@2.1.33
10
+ - @axiom-lattice/protocols@2.1.20
11
+
12
+ ## 1.0.22
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [cea3047]
17
+ - @axiom-lattice/protocols@2.1.19
18
+ - @axiom-lattice/core@2.1.32
19
+
3
20
  ## 1.0.21
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -23,6 +23,9 @@ interface PostgreSQLThreadStoreOptions {
23
23
  }
24
24
  /**
25
25
  * PostgreSQL implementation of ThreadStore
26
+ *
27
+ * Features:
28
+ * - Multi-tenant isolation via tenant_id
26
29
  */
27
30
  declare class PostgreSQLThreadStore implements ThreadStore {
28
31
  private pool;
@@ -42,29 +45,29 @@ declare class PostgreSQLThreadStore implements ThreadStore {
42
45
  */
43
46
  initialize(): Promise<void>;
44
47
  /**
45
- * Get all threads for a specific assistant
48
+ * Get all threads for a specific tenant and assistant
46
49
  */
47
- getThreadsByAssistantId(assistantId: string): Promise<Thread[]>;
50
+ getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
48
51
  /**
49
- * Get a thread by ID for a specific assistant
52
+ * Get a thread by ID for a specific tenant
50
53
  */
51
- getThreadById(assistantId: string, threadId: string): Promise<Thread | undefined>;
54
+ getThreadById(tenantId: string, threadId: string): Promise<Thread | undefined>;
52
55
  /**
53
- * Create a new thread for an assistant
56
+ * Create a new thread for a tenant and assistant
54
57
  */
55
- createThread(assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
58
+ createThread(tenantId: string, assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
56
59
  /**
57
60
  * Update an existing thread
58
61
  */
59
- updateThread(assistantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
62
+ updateThread(tenantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
60
63
  /**
61
64
  * Delete a thread by ID
62
65
  */
63
- deleteThread(assistantId: string, threadId: string): Promise<boolean>;
66
+ deleteThread(tenantId: string, threadId: string): Promise<boolean>;
64
67
  /**
65
68
  * Check if thread exists
66
69
  */
67
- hasThread(assistantId: string, threadId: string): Promise<boolean>;
70
+ hasThread(tenantId: string, threadId: string): Promise<boolean>;
68
71
  /**
69
72
  * Ensure store is initialized
70
73
  */
@@ -96,41 +99,46 @@ interface PostgreSQLAssistantStoreOptions {
96
99
  }
97
100
  /**
98
101
  * PostgreSQL implementation of AssistantStore
102
+ *
103
+ * Features:
104
+ * - Multi-tenant isolation via tenant_id
99
105
  */
100
106
  declare class PostgreSQLAssistantStore implements AssistantStore {
101
107
  private pool;
102
108
  private migrationManager;
103
109
  private initialized;
104
110
  private ownsPool;
111
+ private initPromise;
105
112
  constructor(options: PostgreSQLAssistantStoreOptions);
106
113
  /**
107
114
  * Initialize the store and run migrations
115
+ * Uses a promise-based lock to prevent concurrent initialization
108
116
  */
109
117
  initialize(): Promise<void>;
110
118
  /**
111
- * Get all assistants
119
+ * Get all assistants for a tenant
112
120
  */
113
- getAllAssistants(): Promise<Assistant[]>;
121
+ getAllAssistants(tenantId: string): Promise<Assistant[]>;
114
122
  /**
115
123
  * Get assistant by ID
116
124
  */
117
- getAssistantById(id: string): Promise<Assistant | null>;
125
+ getAssistantById(tenantId: string, id: string): Promise<Assistant | null>;
118
126
  /**
119
127
  * Create a new assistant
120
128
  */
121
- createAssistant(id: string, data: CreateAssistantRequest): Promise<Assistant>;
129
+ createAssistant(tenantId: string, id: string, data: CreateAssistantRequest): Promise<Assistant>;
122
130
  /**
123
131
  * Update an existing assistant
124
132
  */
125
- updateAssistant(id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
133
+ updateAssistant(tenantId: string, id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
126
134
  /**
127
135
  * Delete an assistant by ID
128
136
  */
129
- deleteAssistant(id: string): Promise<boolean>;
137
+ deleteAssistant(tenantId: string, id: string): Promise<boolean>;
130
138
  /**
131
139
  * Check if assistant exists
132
140
  */
133
- hasAssistant(id: string): Promise<boolean>;
141
+ hasAssistant(tenantId: string, id: string): Promise<boolean>;
134
142
  /**
135
143
  * Dispose resources and close the connection pool
136
144
  * Should be called when the store is no longer needed
@@ -232,6 +240,7 @@ declare class PostgreSQLScheduleStorage implements ScheduleStorage {
232
240
  * Get all tasks with optional filters
233
241
  */
234
242
  getAllTasks(filters?: {
243
+ tenantId?: string;
235
244
  status?: ScheduledTaskStatus;
236
245
  executionType?: ScheduleExecutionType;
237
246
  taskType?: string;
@@ -244,6 +253,7 @@ declare class PostgreSQLScheduleStorage implements ScheduleStorage {
244
253
  * Count tasks with optional filters
245
254
  */
246
255
  countTasks(filters?: {
256
+ tenantId?: string;
247
257
  status?: ScheduledTaskStatus;
248
258
  executionType?: ScheduleExecutionType;
249
259
  taskType?: string;
@@ -261,90 +271,78 @@ declare class PostgreSQLScheduleStorage implements ScheduleStorage {
261
271
  }
262
272
 
263
273
  /**
264
- * PostgreSQL implementation of SkillStore
274
+ * PostgreSQL implementation of SkillStore with tenant isolation
265
275
  */
266
276
 
267
- /**
268
- * PostgreSQL SkillStore options
269
- */
270
277
  interface PostgreSQLSkillStoreOptions {
271
- /**
272
- * PostgreSQL connection pool configuration
273
- * Can be a connection string or PoolConfig object
274
- */
275
278
  poolConfig: string | PoolConfig;
276
- /**
277
- * Whether to run migrations automatically on initialization
278
- * @default true
279
- */
280
279
  autoMigrate?: boolean;
281
280
  }
282
281
  /**
283
- * PostgreSQL implementation of SkillStore
282
+ * PostgreSQL implementation of SkillStore with tenant isolation
283
+ *
284
+ * Features:
285
+ * - Multi-tenant isolation via tenant_id
284
286
  */
285
287
  declare class PostgreSQLSkillStore implements SkillStore {
286
288
  private pool;
287
289
  private migrationManager;
288
290
  private initialized;
289
291
  private ownsPool;
292
+ private initPromise;
290
293
  constructor(options: PostgreSQLSkillStoreOptions);
291
- /**
292
- * Dispose resources and close the connection pool
293
- * Should be called when the store is no longer needed
294
- */
295
- dispose(): Promise<void>;
296
294
  /**
297
295
  * Initialize the store and run migrations
296
+ * Uses a promise-based lock to prevent concurrent initialization
298
297
  */
299
298
  initialize(): Promise<void>;
300
- /**
301
- * Ensure store is initialized
302
- */
299
+ dispose(): Promise<void>;
303
300
  private ensureInitialized;
304
301
  /**
305
302
  * Map database row to Skill object
306
303
  */
307
304
  private mapRowToSkill;
308
305
  /**
309
- * Get all skills
306
+ * Get all skills for a tenant
310
307
  */
311
- getAllSkills(): Promise<Skill[]>;
308
+ getAllSkills(tenantId: string): Promise<Skill[]>;
312
309
  /**
313
- * Get skill by ID
310
+ * Get skill by ID for a tenant
314
311
  */
315
- getSkillById(id: string): Promise<Skill | null>;
312
+ getSkillById(tenantId: string, id: string): Promise<Skill | null>;
316
313
  /**
317
- * Create a new skill
314
+ * Create a new skill for a tenant
318
315
  */
319
- createSkill(id: string, data: CreateSkillRequest): Promise<Skill>;
316
+ createSkill(tenantId: string, id: string, data: CreateSkillRequest): Promise<Skill>;
320
317
  /**
321
- * Update an existing skill
318
+ * Update an existing skill for a tenant
322
319
  */
323
- updateSkill(id: string, updates: Partial<CreateSkillRequest>): Promise<Skill | null>;
320
+ updateSkill(tenantId: string, id: string, updates: Partial<CreateSkillRequest>): Promise<Skill | null>;
324
321
  /**
325
- * Delete a skill by ID
322
+ * Delete a skill by ID for a tenant
326
323
  */
327
- deleteSkill(id: string): Promise<boolean>;
324
+ deleteSkill(tenantId: string, id: string): Promise<boolean>;
328
325
  /**
329
- * Check if skill exists
326
+ * Check if skill exists for a tenant
330
327
  */
331
- hasSkill(id: string): Promise<boolean>;
328
+ hasSkill(tenantId: string, id: string): Promise<boolean>;
332
329
  /**
333
- * Search skills by metadata
330
+ * Search skills by metadata within a tenant
334
331
  */
335
- searchByMetadata(metadataKey: string, metadataValue: string): Promise<Skill[]>;
332
+ searchByMetadata(tenantId: string, metadataKey: string, metadataValue: string): Promise<Skill[]>;
336
333
  /**
337
- * Filter skills by compatibility
334
+ * Filter skills by compatibility within a tenant
338
335
  */
339
- filterByCompatibility(compatibility: string): Promise<Skill[]>;
336
+ filterByCompatibility(tenantId: string, compatibility: string): Promise<Skill[]>;
340
337
  /**
341
- * Filter skills by license
338
+ * Filter skills by license within a tenant
342
339
  */
343
- filterByLicense(license: string): Promise<Skill[]>;
340
+ filterByLicense(tenantId: string, license: string): Promise<Skill[]>;
344
341
  /**
345
- * Get sub-skills of a parent skill
342
+ * Get sub-skills of a parent skill within a tenant
343
+ * Note: This searches for skills that have the parent skill name in their subSkills array
346
344
  */
347
- getSubSkills(parentSkillName: string): Promise<Skill[]>;
345
+ getSubSkills(tenantId: string, parentSkillName: string): Promise<Skill[]>;
348
346
  }
349
347
 
350
348
  /**
@@ -915,6 +913,26 @@ declare class MigrationManager {
915
913
  */
916
914
  declare const createThreadsTable: Migration;
917
915
 
916
+ /**
917
+ * Thread table tenant isolation migration
918
+ * Adds tenant_id column to lattice_threads table
919
+ */
920
+
921
+ /**
922
+ * Migration: Add tenant_id column to threads table
923
+ */
924
+ declare const addThreadTenantId: Migration;
925
+
926
+ /**
927
+ * Thread table primary key migration
928
+ * Changes primary key from (id, assistant_id) to (id, tenant_id) for multi-tenancy
929
+ */
930
+
931
+ /**
932
+ * Migration: Change primary key to support multi-tenancy
933
+ */
934
+ declare const changeThreadPrimaryKey: Migration;
935
+
918
936
  /**
919
937
  * Assistant table migrations
920
938
  */
@@ -924,6 +942,26 @@ declare const createThreadsTable: Migration;
924
942
  */
925
943
  declare const createAssistantsTable: Migration;
926
944
 
945
+ /**
946
+ * Assistant table tenant isolation migration
947
+ * Adds tenant_id column to lattice_assistants table
948
+ */
949
+
950
+ /**
951
+ * Migration: Add tenant_id column to assistants table
952
+ */
953
+ declare const addAssistantTenantId: Migration;
954
+
955
+ /**
956
+ * Assistant table primary key migration
957
+ * Changes primary key from (id) to (tenant_id, id) for multi-tenancy
958
+ */
959
+
960
+ /**
961
+ * Migration: Change primary key to support multi-tenancy
962
+ */
963
+ declare const changeAssistantPrimaryKey: Migration;
964
+
927
965
  /**
928
966
  * PostgreSQL migrations for scheduled tasks table
929
967
  */
@@ -933,6 +971,16 @@ declare const createAssistantsTable: Migration;
933
971
  */
934
972
  declare const createScheduledTasksTable: Migration;
935
973
 
974
+ /**
975
+ * Schedule table tenant isolation migration
976
+ * Adds tenant_id column to lattice_scheduled_tasks table
977
+ */
978
+
979
+ /**
980
+ * Migration: Add tenant_id column to scheduled tasks table
981
+ */
982
+ declare const addScheduleTenantId: Migration;
983
+
936
984
  /**
937
985
  * Skill table migrations
938
986
  */
@@ -942,6 +990,26 @@ declare const createScheduledTasksTable: Migration;
942
990
  */
943
991
  declare const createSkillsTable: Migration;
944
992
 
993
+ /**
994
+ * Skill table tenant isolation migration
995
+ * Adds tenant_id column to lattice_skills table
996
+ */
997
+
998
+ /**
999
+ * Migration: Add tenant_id column to skills table
1000
+ */
1001
+ declare const addSkillTenantId: Migration;
1002
+
1003
+ /**
1004
+ * Skill table primary key migration
1005
+ * Changes primary key from (id) to (tenant_id, id) for multi-tenancy
1006
+ */
1007
+
1008
+ /**
1009
+ * Migration: Change skill table primary key to support multi-tenancy
1010
+ */
1011
+ declare const changeSkillPrimaryKey: Migration;
1012
+
945
1013
  /**
946
1014
  * Database configuration table migrations
947
1015
  */
@@ -1006,4 +1074,4 @@ declare const createUsersTable: Migration;
1006
1074
  */
1007
1075
  declare const createTenantsTable: Migration;
1008
1076
 
1009
- export { type Migration, MigrationManager, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLDatabaseConfigStore, type PostgreSQLDatabaseConfigStoreOptions, PostgreSQLMcpServerConfigStore, type PostgreSQLMcpServerConfigStoreOptions, PostgreSQLMetricsServerConfigStore, type PostgreSQLMetricsServerConfigStoreOptions, PostgreSQLProjectStore, type PostgreSQLProjectStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLSkillStore, type PostgreSQLSkillStoreOptions, PostgreSQLTenantStore, type PostgreSQLTenantStoreOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, PostgreSQLUserStore, type PostgreSQLUserStoreOptions, PostgreSQLUserTenantLinkStore, type PostgreSQLUserTenantLinkStoreOptions, PostgreSQLWorkspaceStore, type PostgreSQLWorkspaceStoreOptions, createAssistantsTable, createDatabaseConfigsTable, createMcpServerConfigsTable, createMetricsConfigsTable, createProjectsTable, createScheduledTasksTable, createSkillsTable, createTenantsTable, createThreadsTable, createUsersTable, createWorkspacesTable };
1077
+ export { type Migration, MigrationManager, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLDatabaseConfigStore, type PostgreSQLDatabaseConfigStoreOptions, PostgreSQLMcpServerConfigStore, type PostgreSQLMcpServerConfigStoreOptions, PostgreSQLMetricsServerConfigStore, type PostgreSQLMetricsServerConfigStoreOptions, PostgreSQLProjectStore, type PostgreSQLProjectStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLSkillStore, type PostgreSQLSkillStoreOptions, PostgreSQLTenantStore, type PostgreSQLTenantStoreOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, PostgreSQLUserStore, type PostgreSQLUserStoreOptions, PostgreSQLUserTenantLinkStore, type PostgreSQLUserTenantLinkStoreOptions, PostgreSQLWorkspaceStore, type PostgreSQLWorkspaceStoreOptions, addAssistantTenantId, addScheduleTenantId, addSkillTenantId, addThreadTenantId, changeAssistantPrimaryKey, changeSkillPrimaryKey, changeThreadPrimaryKey, createAssistantsTable, createDatabaseConfigsTable, createMcpServerConfigsTable, createMetricsConfigsTable, createProjectsTable, createScheduledTasksTable, createSkillsTable, createTenantsTable, createThreadsTable, createUsersTable, createWorkspacesTable };