@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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @mastra/pg@0.13.1-alpha.0 build /home/runner/work/mastra/mastra/stores/pg
2
+ > @mastra/pg@0.13.2-alpha.1 build /home/runner/work/mastra/mastra/stores/pg
3
3
  > tsup --silent --config tsup.config.ts
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 0.13.2-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2871020: update safelyParseJSON to check for value of param when handling parse
8
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
9
+ - Updated dependencies [cb36de0]
10
+ - Updated dependencies [a82b851]
11
+ - Updated dependencies [41a0a0e]
12
+ - Updated dependencies [2871020]
13
+ - Updated dependencies [4a406ec]
14
+ - Updated dependencies [5d377e5]
15
+ - @mastra/core@0.13.0-alpha.2
16
+
17
+ ## 0.13.2-alpha.0
18
+
19
+ ### Patch Changes
20
+
21
+ - a780fcd: ensure score id is generated for postgres store
22
+ - Updated dependencies [94f4812]
23
+ - Updated dependencies [e202b82]
24
+ - Updated dependencies [e00f6a0]
25
+ - @mastra/core@0.12.2-alpha.0
26
+
3
27
  ## 0.13.1
4
28
 
5
29
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -2156,8 +2156,6 @@ var StoreOperationsPG = class extends storage.StoreOperations {
2156
2156
  ` : ""}
2157
2157
  `;
2158
2158
  await this.client.none(sql);
2159
- console.log("Alter Table SQL", tableName);
2160
- console.log("timeZColumnNames", timeZColumnNames);
2161
2159
  await this.alterTable({
2162
2160
  tableName,
2163
2161
  schema,
@@ -2298,17 +2296,17 @@ var StoreOperationsPG = class extends storage.StoreOperations {
2298
2296
  }
2299
2297
  };
2300
2298
  function transformScoreRow(row) {
2301
- let input = void 0;
2302
- if (row.input) {
2303
- try {
2304
- input = JSON.parse(row.input);
2305
- } catch {
2306
- input = row.input;
2307
- }
2308
- }
2309
2299
  return {
2310
2300
  ...row,
2311
- input,
2301
+ input: storage.safelyParseJSON(row.input),
2302
+ scorer: storage.safelyParseJSON(row.scorer),
2303
+ preprocessStepResult: storage.safelyParseJSON(row.preprocessStepResult),
2304
+ analyzeStepResult: storage.safelyParseJSON(row.analyzeStepResult),
2305
+ metadata: storage.safelyParseJSON(row.metadata),
2306
+ output: storage.safelyParseJSON(row.output),
2307
+ additionalContext: storage.safelyParseJSON(row.additionalContext),
2308
+ runtimeContext: storage.safelyParseJSON(row.runtimeContext),
2309
+ entity: storage.safelyParseJSON(row.entity),
2312
2310
  createdAt: row.createdAtZ || row.createdAt,
2313
2311
  updatedAt: row.updatedAtZ || row.updatedAt
2314
2312
  };
@@ -2376,7 +2374,7 @@ var ScoresPG = class extends storage.ScoresStorage {
2376
2374
  perPage: pagination.perPage,
2377
2375
  hasMore: Number(total?.count) > (pagination.page + 1) * pagination.perPage
2378
2376
  },
2379
- scores: result
2377
+ scores: result.map(transformScoreRow)
2380
2378
  };
2381
2379
  } catch (error$1) {
2382
2380
  throw new error.MastraError(
@@ -2391,17 +2389,38 @@ var ScoresPG = class extends storage.ScoresStorage {
2391
2389
  }
2392
2390
  async saveScore(score) {
2393
2391
  try {
2394
- const { input, ...rest } = score;
2392
+ const scoreId = crypto.randomUUID();
2393
+ const {
2394
+ scorer,
2395
+ preprocessStepResult,
2396
+ analyzeStepResult,
2397
+ metadata,
2398
+ input,
2399
+ output,
2400
+ additionalContext,
2401
+ runtimeContext,
2402
+ entity,
2403
+ ...rest
2404
+ } = score;
2395
2405
  await this.operations.insert({
2396
2406
  tableName: storage.TABLE_SCORERS,
2397
2407
  record: {
2408
+ id: scoreId,
2398
2409
  ...rest,
2399
- input: JSON.stringify(input),
2410
+ input: JSON.stringify(input) || "",
2411
+ output: JSON.stringify(output) || "",
2412
+ scorer: scorer ? JSON.stringify(scorer) : null,
2413
+ preprocessStepResult: preprocessStepResult ? JSON.stringify(preprocessStepResult) : null,
2414
+ analyzeStepResult: analyzeStepResult ? JSON.stringify(analyzeStepResult) : null,
2415
+ metadata: metadata ? JSON.stringify(metadata) : null,
2416
+ additionalContext: additionalContext ? JSON.stringify(additionalContext) : null,
2417
+ runtimeContext: runtimeContext ? JSON.stringify(runtimeContext) : null,
2418
+ entity: entity ? JSON.stringify(entity) : null,
2400
2419
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2401
2420
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2402
2421
  }
2403
2422
  });
2404
- const scoreFromDb = await this.getScoreById({ id: score.id });
2423
+ const scoreFromDb = await this.getScoreById({ id: scoreId });
2405
2424
  return { score: scoreFromDb };
2406
2425
  } catch (error$1) {
2407
2426
  throw new error.MastraError(
@@ -2423,8 +2442,6 @@ var ScoresPG = class extends storage.ScoresStorage {
2423
2442
  `SELECT COUNT(*) FROM ${getTableName({ indexName: storage.TABLE_SCORERS, schemaName: this.schema })} WHERE "runId" = $1`,
2424
2443
  [runId]
2425
2444
  );
2426
- console.log(`total: ${total?.count}`);
2427
- console.log(`typeof total: ${typeof total?.count}`);
2428
2445
  if (total?.count === "0" || !total?.count) {
2429
2446
  return {
2430
2447
  pagination: {
@@ -2447,7 +2464,7 @@ var ScoresPG = class extends storage.ScoresStorage {
2447
2464
  perPage: pagination.perPage,
2448
2465
  hasMore: Number(total?.count) > (pagination.page + 1) * pagination.perPage
2449
2466
  },
2450
- scores: result
2467
+ scores: result.map(transformScoreRow)
2451
2468
  };
2452
2469
  } catch (error$1) {
2453
2470
  throw new error.MastraError(
@@ -2492,7 +2509,7 @@ var ScoresPG = class extends storage.ScoresStorage {
2492
2509
  perPage: pagination.perPage,
2493
2510
  hasMore: Number(total?.count) > (pagination.page + 1) * pagination.perPage
2494
2511
  },
2495
- scores: result
2512
+ scores: result.map(transformScoreRow)
2496
2513
  };
2497
2514
  } catch (error$1) {
2498
2515
  throw new error.MastraError(