@mastra/pg 0.13.1 → 0.13.2-alpha.1

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,4 +1,4 @@
1
- export * from './vector';
2
- export * from './storage';
3
- export { PGVECTOR_PROMPT } from './vector/prompt';
1
+ export * from './vector/index.js';
2
+ export * from './storage/index.js';
3
+ export { PGVECTOR_PROMPT } from './vector/prompt.js';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2148,8 +2148,6 @@ var StoreOperationsPG = class extends StoreOperations {
2148
2148
  ` : ""}
2149
2149
  `;
2150
2150
  await this.client.none(sql);
2151
- console.log("Alter Table SQL", tableName);
2152
- console.log("timeZColumnNames", timeZColumnNames);
2153
2151
  await this.alterTable({
2154
2152
  tableName,
2155
2153
  schema,
@@ -2290,17 +2288,17 @@ var StoreOperationsPG = class extends StoreOperations {
2290
2288
  }
2291
2289
  };
2292
2290
  function transformScoreRow(row) {
2293
- let input = void 0;
2294
- if (row.input) {
2295
- try {
2296
- input = JSON.parse(row.input);
2297
- } catch {
2298
- input = row.input;
2299
- }
2300
- }
2301
2291
  return {
2302
2292
  ...row,
2303
- input,
2293
+ input: safelyParseJSON(row.input),
2294
+ scorer: safelyParseJSON(row.scorer),
2295
+ preprocessStepResult: safelyParseJSON(row.preprocessStepResult),
2296
+ analyzeStepResult: safelyParseJSON(row.analyzeStepResult),
2297
+ metadata: safelyParseJSON(row.metadata),
2298
+ output: safelyParseJSON(row.output),
2299
+ additionalContext: safelyParseJSON(row.additionalContext),
2300
+ runtimeContext: safelyParseJSON(row.runtimeContext),
2301
+ entity: safelyParseJSON(row.entity),
2304
2302
  createdAt: row.createdAtZ || row.createdAt,
2305
2303
  updatedAt: row.updatedAtZ || row.updatedAt
2306
2304
  };
@@ -2368,7 +2366,7 @@ var ScoresPG = class extends ScoresStorage {
2368
2366
  perPage: pagination.perPage,
2369
2367
  hasMore: Number(total?.count) > (pagination.page + 1) * pagination.perPage
2370
2368
  },
2371
- scores: result
2369
+ scores: result.map(transformScoreRow)
2372
2370
  };
2373
2371
  } catch (error) {
2374
2372
  throw new MastraError(
@@ -2383,17 +2381,38 @@ var ScoresPG = class extends ScoresStorage {
2383
2381
  }
2384
2382
  async saveScore(score) {
2385
2383
  try {
2386
- const { input, ...rest } = score;
2384
+ const scoreId = crypto.randomUUID();
2385
+ const {
2386
+ scorer,
2387
+ preprocessStepResult,
2388
+ analyzeStepResult,
2389
+ metadata,
2390
+ input,
2391
+ output,
2392
+ additionalContext,
2393
+ runtimeContext,
2394
+ entity,
2395
+ ...rest
2396
+ } = score;
2387
2397
  await this.operations.insert({
2388
2398
  tableName: TABLE_SCORERS,
2389
2399
  record: {
2400
+ id: scoreId,
2390
2401
  ...rest,
2391
- input: JSON.stringify(input),
2402
+ input: JSON.stringify(input) || "",
2403
+ output: JSON.stringify(output) || "",
2404
+ scorer: scorer ? JSON.stringify(scorer) : null,
2405
+ preprocessStepResult: preprocessStepResult ? JSON.stringify(preprocessStepResult) : null,
2406
+ analyzeStepResult: analyzeStepResult ? JSON.stringify(analyzeStepResult) : null,
2407
+ metadata: metadata ? JSON.stringify(metadata) : null,
2408
+ additionalContext: additionalContext ? JSON.stringify(additionalContext) : null,
2409
+ runtimeContext: runtimeContext ? JSON.stringify(runtimeContext) : null,
2410
+ entity: entity ? JSON.stringify(entity) : null,
2392
2411
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2393
2412
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2394
2413
  }
2395
2414
  });
2396
- const scoreFromDb = await this.getScoreById({ id: score.id });
2415
+ const scoreFromDb = await this.getScoreById({ id: scoreId });
2397
2416
  return { score: scoreFromDb };
2398
2417
  } catch (error) {
2399
2418
  throw new MastraError(
@@ -2415,8 +2434,6 @@ var ScoresPG = class extends ScoresStorage {
2415
2434
  `SELECT COUNT(*) FROM ${getTableName({ indexName: TABLE_SCORERS, schemaName: this.schema })} WHERE "runId" = $1`,
2416
2435
  [runId]
2417
2436
  );
2418
- console.log(`total: ${total?.count}`);
2419
- console.log(`typeof total: ${typeof total?.count}`);
2420
2437
  if (total?.count === "0" || !total?.count) {
2421
2438
  return {
2422
2439
  pagination: {
@@ -2439,7 +2456,7 @@ var ScoresPG = class extends ScoresStorage {
2439
2456
  perPage: pagination.perPage,
2440
2457
  hasMore: Number(total?.count) > (pagination.page + 1) * pagination.perPage
2441
2458
  },
2442
- scores: result
2459
+ scores: result.map(transformScoreRow)
2443
2460
  };
2444
2461
  } catch (error) {
2445
2462
  throw new MastraError(
@@ -2484,7 +2501,7 @@ var ScoresPG = class extends ScoresStorage {
2484
2501
  perPage: pagination.perPage,
2485
2502
  hasMore: Number(total?.count) > (pagination.page + 1) * pagination.perPage
2486
2503
  },
2487
- scores: result
2504
+ scores: result.map(transformScoreRow)
2488
2505
  };
2489
2506
  } catch (error) {
2490
2507
  throw new MastraError(