@axiom-lattice/local-stores 1.0.15 → 1.0.16

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/local-stores@1.0.15 build /home/runner/work/agentic/agentic/packages/local-stores
2
+ > @axiom-lattice/local-stores@1.0.16 build /home/runner/work/agentic/agentic/packages/local-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
- CJS dist/index.js 116.80 KB
12
- CJS dist/index.js.map 217.12 KB
13
- CJS ⚡️ Build success in 449ms
14
- ESM dist/index.mjs 113.57 KB
15
- ESM dist/index.mjs.map 214.66 KB
16
- ESM ⚡️ Build success in 464ms
11
+ ESM dist/index.mjs 116.68 KB
12
+ ESM dist/index.mjs.map 221.36 KB
13
+ ESM ⚡️ Build success in 429ms
14
+ CJS dist/index.js 119.95 KB
15
+ CJS dist/index.js.map 223.95 KB
16
+ CJS ⚡️ Build success in 433ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 15572ms
19
- DTS dist/index.d.ts 24.92 KB
20
- DTS dist/index.d.mts 24.92 KB
18
+ DTS ⚡️ Build success in 16180ms
19
+ DTS dist/index.d.ts 26.92 KB
20
+ DTS dist/index.d.mts 26.92 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @axiom-lattice/local-stores
2
2
 
3
+ ## 1.0.16
4
+
5
+ ### Patch Changes
6
+
7
+ - 2954442: fix issue
8
+ - Updated dependencies [2954442]
9
+ - @axiom-lattice/core@2.1.94
10
+ - @axiom-lattice/protocols@2.1.48
11
+
3
12
  ## 1.0.15
4
13
 
5
14
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -119,6 +119,74 @@ declare function nowISO(): string;
119
119
  */
120
120
  declare function parseISO(iso: string): Date;
121
121
 
122
+ /**
123
+ * Migration system for SQLite (sql.js) local stores.
124
+ *
125
+ * ## Identity vs Ordering
126
+ *
127
+ * **name = identity** — each migration is uniquely identified by its name
128
+ * within a store. Two stores may use the same name without conflict because
129
+ * the tracking table includes a `store_name` column.
130
+ *
131
+ * **version = ordering** — migrations are applied in ascending version order.
132
+ *
133
+ * ## Usage
134
+ *
135
+ * Each store creates its own MigrationManager with a unique store name:
136
+ *
137
+ * ```ts
138
+ * const mm = new MigrationManager(db, "lt_threads");
139
+ * mm.register({ version: 1, name: "create_table", up: (db) => { db.exec(DDL); } });
140
+ * mm.register({ version: 2, name: "add_column_x", up: (db) => { db.exec(ALTER); } });
141
+ * mm.migrate();
142
+ * ```
143
+ *
144
+ * @remarks
145
+ * - All methods are synchronous (SQLite via sql.js is single-threaded)
146
+ * - Duplicate **names** within the same store are rejected at registration time
147
+ * - Duplicate **versions** are allowed (same positioning, different tables)
148
+ */
149
+
150
+ /**
151
+ * Migration definition
152
+ */
153
+ interface Migration {
154
+ version: number;
155
+ name: string;
156
+ up: (db: DatabaseWrapper) => void;
157
+ down?: (db: DatabaseWrapper) => void;
158
+ }
159
+ /**
160
+ * Migration manager — one per store.
161
+ * Each store manages its own independent migration namespace via `storeName`.
162
+ */
163
+ declare class MigrationManager {
164
+ private db;
165
+ private storeName;
166
+ private migrations;
167
+ constructor(db: DatabaseWrapper, storeName: string);
168
+ /**
169
+ * Register a migration.
170
+ * Duplicate names within this store are rejected immediately.
171
+ * Duplicate versions are allowed.
172
+ */
173
+ register(migration: Migration): void;
174
+ /**
175
+ * Apply all pending migrations in version order.
176
+ */
177
+ migrate(): void;
178
+ /**
179
+ * Rollback the last-applied migration (highest version) for this store.
180
+ */
181
+ rollback(): void;
182
+ /**
183
+ * Get the highest applied migration version for this store.
184
+ */
185
+ getCurrentVersion(): number;
186
+ private ensureTrackingTable;
187
+ private getAppliedNames;
188
+ }
189
+
122
190
  /**
123
191
  * Local SQLite implementation of ThreadStore.
124
192
  */
@@ -566,4 +634,4 @@ declare function createLocalStoreConfig(options?: LocalStoreConfigOptions): Prom
566
634
  checkpoint: SqliteSaver;
567
635
  }>;
568
636
 
569
- export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTaskStore, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
637
+ export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTaskStore, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, type Migration, MigrationManager, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
package/dist/index.d.ts CHANGED
@@ -119,6 +119,74 @@ declare function nowISO(): string;
119
119
  */
120
120
  declare function parseISO(iso: string): Date;
121
121
 
122
+ /**
123
+ * Migration system for SQLite (sql.js) local stores.
124
+ *
125
+ * ## Identity vs Ordering
126
+ *
127
+ * **name = identity** — each migration is uniquely identified by its name
128
+ * within a store. Two stores may use the same name without conflict because
129
+ * the tracking table includes a `store_name` column.
130
+ *
131
+ * **version = ordering** — migrations are applied in ascending version order.
132
+ *
133
+ * ## Usage
134
+ *
135
+ * Each store creates its own MigrationManager with a unique store name:
136
+ *
137
+ * ```ts
138
+ * const mm = new MigrationManager(db, "lt_threads");
139
+ * mm.register({ version: 1, name: "create_table", up: (db) => { db.exec(DDL); } });
140
+ * mm.register({ version: 2, name: "add_column_x", up: (db) => { db.exec(ALTER); } });
141
+ * mm.migrate();
142
+ * ```
143
+ *
144
+ * @remarks
145
+ * - All methods are synchronous (SQLite via sql.js is single-threaded)
146
+ * - Duplicate **names** within the same store are rejected at registration time
147
+ * - Duplicate **versions** are allowed (same positioning, different tables)
148
+ */
149
+
150
+ /**
151
+ * Migration definition
152
+ */
153
+ interface Migration {
154
+ version: number;
155
+ name: string;
156
+ up: (db: DatabaseWrapper) => void;
157
+ down?: (db: DatabaseWrapper) => void;
158
+ }
159
+ /**
160
+ * Migration manager — one per store.
161
+ * Each store manages its own independent migration namespace via `storeName`.
162
+ */
163
+ declare class MigrationManager {
164
+ private db;
165
+ private storeName;
166
+ private migrations;
167
+ constructor(db: DatabaseWrapper, storeName: string);
168
+ /**
169
+ * Register a migration.
170
+ * Duplicate names within this store are rejected immediately.
171
+ * Duplicate versions are allowed.
172
+ */
173
+ register(migration: Migration): void;
174
+ /**
175
+ * Apply all pending migrations in version order.
176
+ */
177
+ migrate(): void;
178
+ /**
179
+ * Rollback the last-applied migration (highest version) for this store.
180
+ */
181
+ rollback(): void;
182
+ /**
183
+ * Get the highest applied migration version for this store.
184
+ */
185
+ getCurrentVersion(): number;
186
+ private ensureTrackingTable;
187
+ private getAppliedNames;
188
+ }
189
+
122
190
  /**
123
191
  * Local SQLite implementation of ThreadStore.
124
192
  */
@@ -566,4 +634,4 @@ declare function createLocalStoreConfig(options?: LocalStoreConfigOptions): Prom
566
634
  checkpoint: SqliteSaver;
567
635
  }>;
568
636
 
569
- export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTaskStore, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
637
+ export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTaskStore, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, type Migration, MigrationManager, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ __export(index_exports, {
50
50
  LocalUserTenantLinkStore: () => LocalUserTenantLinkStore,
51
51
  LocalWorkflowTrackingStore: () => LocalWorkflowTrackingStore,
52
52
  LocalWorkspaceStore: () => LocalWorkspaceStore,
53
+ MigrationManager: () => MigrationManager,
53
54
  RunResult: () => RunResult,
54
55
  StatementWrapper: () => StatementWrapper,
55
56
  closeDatabase: () => closeDatabase,
@@ -232,10 +233,103 @@ function parseISO(iso) {
232
233
  return new Date(iso);
233
234
  }
234
235
 
236
+ // src/migrations/migration.ts
237
+ var MigrationManager = class {
238
+ constructor(db, storeName) {
239
+ this.migrations = [];
240
+ this.db = db;
241
+ this.storeName = storeName;
242
+ this.ensureTrackingTable();
243
+ }
244
+ /**
245
+ * Register a migration.
246
+ * Duplicate names within this store are rejected immediately.
247
+ * Duplicate versions are allowed.
248
+ */
249
+ register(migration) {
250
+ const existing = this.migrations.find((m) => m.name === migration.name);
251
+ if (existing) {
252
+ throw new Error(
253
+ `[${this.storeName}] Migration name conflict: "${migration.name}" v${migration.version} collides with existing registration at v${existing.version}`
254
+ );
255
+ }
256
+ this.migrations.push(migration);
257
+ this.migrations.sort((a, b) => a.version - b.version);
258
+ }
259
+ /**
260
+ * Apply all pending migrations in version order.
261
+ */
262
+ migrate() {
263
+ const appliedNames = this.getAppliedNames();
264
+ const pending = this.migrations.filter((m) => !appliedNames.has(m.name));
265
+ if (pending.length === 0) return;
266
+ for (const m of pending) {
267
+ m.up(this.db);
268
+ this.db.run(
269
+ `INSERT INTO lattice_schema_migrations (store_name, name, version, applied_at)
270
+ VALUES (?, ?, ?, ?)`,
271
+ [this.storeName, m.name, m.version, (/* @__PURE__ */ new Date()).toISOString()]
272
+ );
273
+ }
274
+ }
275
+ /**
276
+ * Rollback the last-applied migration (highest version) for this store.
277
+ */
278
+ rollback() {
279
+ const row = this.db.prepare(
280
+ `SELECT name, version FROM lattice_schema_migrations
281
+ WHERE store_name = ? ORDER BY version DESC LIMIT 1`
282
+ ).get(this.storeName);
283
+ if (!row) {
284
+ throw new Error(`[${this.storeName}] No migrations to rollback`);
285
+ }
286
+ const migration = this.migrations.find((m) => m.name === row.name);
287
+ if (!migration?.down) {
288
+ throw new Error(
289
+ `[${this.storeName}] Migration "${row.name}" (v${row.version}) has no down migration`
290
+ );
291
+ }
292
+ migration.down(this.db);
293
+ this.db.run(
294
+ `DELETE FROM lattice_schema_migrations WHERE store_name = ? AND name = ?`,
295
+ [this.storeName, row.name]
296
+ );
297
+ }
298
+ /**
299
+ * Get the highest applied migration version for this store.
300
+ */
301
+ getCurrentVersion() {
302
+ const row = this.db.prepare(
303
+ `SELECT COALESCE(MAX(version), 0) AS max FROM lattice_schema_migrations
304
+ WHERE store_name = ?`
305
+ ).get(this.storeName);
306
+ return row?.max ?? 0;
307
+ }
308
+ // ── private ────────────────────────────────────────────────
309
+ ensureTrackingTable() {
310
+ this.db.exec(`
311
+ CREATE TABLE IF NOT EXISTS lattice_schema_migrations (
312
+ store_name TEXT NOT NULL,
313
+ name TEXT NOT NULL,
314
+ version INTEGER NOT NULL,
315
+ applied_at TEXT NOT NULL,
316
+ PRIMARY KEY (store_name, name)
317
+ )
318
+ `);
319
+ }
320
+ getAppliedNames() {
321
+ const rows = this.db.prepare(
322
+ `SELECT name FROM lattice_schema_migrations WHERE store_name = ? ORDER BY version`
323
+ ).all(this.storeName);
324
+ return new Set(rows.map((r) => r.name));
325
+ }
326
+ };
327
+
235
328
  // src/createLocalStoreConfig.ts
236
329
  var import_langgraph_checkpoint_sqlite = require("@langchain/langgraph-checkpoint-sqlite");
237
330
 
238
331
  // src/stores/LocalThreadStore.ts
332
+ var STORE_NAME = "lt_threads";
239
333
  var DDL = `
240
334
  CREATE TABLE IF NOT EXISTS lt_threads (
241
335
  id TEXT NOT NULL,
@@ -251,7 +345,15 @@ CREATE INDEX IF NOT EXISTS idx_lt_threads_assistant ON lt_threads(tenant_id, ass
251
345
  var LocalThreadStore = class {
252
346
  constructor(db) {
253
347
  this.db = db;
254
- ensureTable(db, DDL);
348
+ const mm = new MigrationManager(db, STORE_NAME);
349
+ mm.register({
350
+ version: 1,
351
+ name: "create_lt_threads",
352
+ up: (d) => {
353
+ d.exec(DDL);
354
+ }
355
+ });
356
+ mm.migrate();
255
357
  }
256
358
  async getThreadsByAssistantId(tenantId, assistantId, metadataFilter) {
257
359
  const rows = this.db.prepare(
@@ -3613,6 +3715,7 @@ async function createLocalStoreConfig(options = {}) {
3613
3715
  LocalUserTenantLinkStore,
3614
3716
  LocalWorkflowTrackingStore,
3615
3717
  LocalWorkspaceStore,
3718
+ MigrationManager,
3616
3719
  RunResult,
3617
3720
  StatementWrapper,
3618
3721
  closeDatabase,