@axiom-lattice/pg-stores 1.0.73 → 1.0.75

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.mjs CHANGED
@@ -3156,7 +3156,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3156
3156
  [runId]
3157
3157
  );
3158
3158
  if (result.rows.length === 0) return null;
3159
- return this.mapRowToWorkflowRun(result.rows[0]);
3159
+ return mapRowToWorkflowRun(result.rows[0]);
3160
3160
  }
3161
3161
  async updateWorkflowRun(runId, updates) {
3162
3162
  await this.ensureInitialized();
@@ -3198,7 +3198,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3198
3198
  `SELECT * FROM lattice_workflow_runs WHERE tenant_id = $1 AND thread_id = $2 ORDER BY created_at DESC`,
3199
3199
  [tenantId, threadId]
3200
3200
  );
3201
- return result.rows.map(this.mapRowToWorkflowRun);
3201
+ return result.rows.map(mapRowToWorkflowRun);
3202
3202
  }
3203
3203
  async getWorkflowRunsByAssistantId(tenantId, assistantId) {
3204
3204
  await this.ensureInitialized();
@@ -3206,7 +3206,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3206
3206
  `SELECT * FROM lattice_workflow_runs WHERE tenant_id = $1 AND assistant_id = $2 ORDER BY created_at DESC`,
3207
3207
  [tenantId, assistantId]
3208
3208
  );
3209
- return result.rows.map(this.mapRowToWorkflowRun);
3209
+ return result.rows.map(mapRowToWorkflowRun);
3210
3210
  }
3211
3211
  async getWorkflowRunsByTenantId(tenantId) {
3212
3212
  await this.ensureInitialized();
@@ -3214,7 +3214,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3214
3214
  `SELECT * FROM lattice_workflow_runs WHERE tenant_id = $1 ORDER BY created_at DESC`,
3215
3215
  [tenantId]
3216
3216
  );
3217
- return result.rows.map(this.mapRowToWorkflowRun);
3217
+ return result.rows.map(mapRowToWorkflowRun);
3218
3218
  }
3219
3219
  async createRunStep(request) {
3220
3220
  await this.ensureInitialized();
@@ -3264,7 +3264,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3264
3264
  [request.runId, request.stepType, request.stepName]
3265
3265
  );
3266
3266
  if (result.rows.length > 0) {
3267
- const existing = this.mapRowToRunStep(result.rows[0]);
3267
+ const existing = mapRowToRunStep(result.rows[0]);
3268
3268
  if (!existing.threadId && request.threadId) {
3269
3269
  await this.pool.query(
3270
3270
  `UPDATE lattice_workflow_steps SET thread_id = $1, updated_at = $2 WHERE run_id = $3 AND id = $4`,
@@ -3309,7 +3309,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3309
3309
  `SELECT * FROM lattice_workflow_steps WHERE run_id = $1 AND id = $2`,
3310
3310
  [runId, stepId]
3311
3311
  );
3312
- return row.rows.length > 0 ? this.mapRowToRunStep(row.rows[0]) : null;
3312
+ return row.rows.length > 0 ? mapRowToRunStep(row.rows[0]) : null;
3313
3313
  }
3314
3314
  async getRunSteps(runId) {
3315
3315
  await this.ensureInitialized();
@@ -3317,7 +3317,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3317
3317
  `SELECT * FROM lattice_workflow_steps WHERE run_id = $1 ORDER BY created_at ASC`,
3318
3318
  [runId]
3319
3319
  );
3320
- return result.rows.map(this.mapRowToRunStep);
3320
+ return result.rows.map(mapRowToRunStep);
3321
3321
  }
3322
3322
  async getRunStepsByType(runId, stepType) {
3323
3323
  await this.ensureInitialized();
@@ -3325,7 +3325,7 @@ var PostgreSQLWorkflowTrackingStore = class {
3325
3325
  `SELECT * FROM lattice_workflow_steps WHERE run_id = $1 AND step_type = $2 ORDER BY created_at ASC`,
3326
3326
  [runId, stepType]
3327
3327
  );
3328
- return result.rows.map(this.mapRowToRunStep);
3328
+ return result.rows.map(mapRowToRunStep);
3329
3329
  }
3330
3330
  async getInterruptedSteps(runId) {
3331
3331
  await this.ensureInitialized();
@@ -3333,49 +3333,58 @@ var PostgreSQLWorkflowTrackingStore = class {
3333
3333
  `SELECT * FROM lattice_workflow_steps WHERE run_id = $1 AND status = 'interrupted' ORDER BY created_at ASC`,
3334
3334
  [runId]
3335
3335
  );
3336
- return result.rows.map(this.mapRowToRunStep);
3337
- }
3338
- mapRowToWorkflowRun(row) {
3339
- return {
3340
- id: row.id,
3341
- tenantId: row.tenant_id,
3342
- assistantId: row.assistant_id,
3343
- threadId: row.thread_id,
3344
- status: row.status,
3345
- topologyEdges: typeof row.topology_edges === "string" ? JSON.parse(row.topology_edges) : row.topology_edges || [],
3346
- totalEdges: row.total_edges,
3347
- completedEdges: row.completed_edges,
3348
- errorMessage: row.error_message,
3349
- metadata: typeof row.metadata === "string" ? JSON.parse(row.metadata) : row.metadata || {},
3350
- startedAt: row.started_at,
3351
- completedAt: row.completed_at,
3352
- createdAt: row.created_at,
3353
- updatedAt: row.updated_at
3354
- };
3355
- }
3356
- mapRowToRunStep(row) {
3357
- return {
3358
- id: row.id,
3359
- runId: row.run_id,
3360
- tenantId: row.tenant_id,
3361
- stepType: row.step_type,
3362
- stepName: row.step_name,
3363
- threadId: row.thread_id,
3364
- edgeFrom: row.edge_from,
3365
- edgeTo: row.edge_to,
3366
- edgePurpose: row.edge_purpose,
3367
- input: typeof row.input === "string" ? JSON.parse(row.input) : row.input,
3368
- output: typeof row.output === "string" ? JSON.parse(row.output) : row.output,
3369
- status: row.status,
3370
- errorMessage: row.error_message,
3371
- startedAt: row.started_at,
3372
- completedAt: row.completed_at,
3373
- durationMs: row.duration_ms,
3374
- createdAt: row.created_at,
3375
- updatedAt: row.updated_at
3376
- };
3336
+ return result.rows.map(mapRowToRunStep);
3377
3337
  }
3378
3338
  };
3339
+ function safeParse(value, fallback) {
3340
+ if (value === null || value === void 0) return fallback;
3341
+ if (typeof value !== "string") return value;
3342
+ try {
3343
+ return JSON.parse(value);
3344
+ } catch {
3345
+ return fallback;
3346
+ }
3347
+ }
3348
+ function mapRowToWorkflowRun(row) {
3349
+ return {
3350
+ id: row.id,
3351
+ tenantId: row.tenant_id,
3352
+ assistantId: row.assistant_id,
3353
+ threadId: row.thread_id,
3354
+ status: row.status,
3355
+ topologyEdges: safeParse(row.topology_edges, []),
3356
+ totalEdges: row.total_edges,
3357
+ completedEdges: row.completed_edges,
3358
+ errorMessage: row.error_message,
3359
+ metadata: safeParse(row.metadata, {}),
3360
+ startedAt: row.started_at,
3361
+ completedAt: row.completed_at,
3362
+ createdAt: row.created_at,
3363
+ updatedAt: row.updated_at
3364
+ };
3365
+ }
3366
+ function mapRowToRunStep(row) {
3367
+ return {
3368
+ id: row.id,
3369
+ runId: row.run_id,
3370
+ tenantId: row.tenant_id,
3371
+ stepType: row.step_type,
3372
+ stepName: row.step_name,
3373
+ threadId: row.thread_id,
3374
+ edgeFrom: row.edge_from,
3375
+ edgeTo: row.edge_to,
3376
+ edgePurpose: row.edge_purpose,
3377
+ input: safeParse(row.input, void 0),
3378
+ output: safeParse(row.output, void 0),
3379
+ status: row.status,
3380
+ errorMessage: row.error_message,
3381
+ startedAt: row.started_at,
3382
+ completedAt: row.completed_at,
3383
+ durationMs: row.duration_ms,
3384
+ createdAt: row.created_at,
3385
+ updatedAt: row.updated_at
3386
+ };
3387
+ }
3379
3388
 
3380
3389
  // src/stores/PostgreSQLEvalStore.ts
3381
3390
  import { Pool as Pool12 } from "pg";
@@ -7220,6 +7229,9 @@ export {
7220
7229
  createUsersTable,
7221
7230
  createWorkflowTrackingTables,
7222
7231
  createWorkspacesTable,
7223
- evalMigrations
7232
+ evalMigrations,
7233
+ mapRowToRunStep,
7234
+ mapRowToWorkflowRun,
7235
+ safeParse
7224
7236
  };
7225
7237
  //# sourceMappingURL=index.mjs.map