@mastra/clickhouse 1.0.0-beta.3 → 1.0.0-beta.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 1.0.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Add delete workflow run API ([#10991](https://github.com/mastra-ai/mastra/pull/10991))
8
+
9
+ ```typescript
10
+ await workflow.deleteWorkflowRunById(runId);
11
+ ```
12
+
13
+ - Updated dependencies [[`edb07e4`](https://github.com/mastra-ai/mastra/commit/edb07e49283e0c28bd094a60e03439bf6ecf0221), [`b7e17d3`](https://github.com/mastra-ai/mastra/commit/b7e17d3f5390bb5a71efc112204413656fcdc18d), [`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d), [`5d7000f`](https://github.com/mastra-ai/mastra/commit/5d7000f757cd65ea9dc5b05e662fd83dfd44e932), [`4f0331a`](https://github.com/mastra-ai/mastra/commit/4f0331a79bf6eb5ee598a5086e55de4b5a0ada03), [`8a000da`](https://github.com/mastra-ai/mastra/commit/8a000da0c09c679a2312f6b3aa05b2ca78ca7393)]:
14
+ - @mastra/core@1.0.0-beta.10
15
+
16
+ ## 1.0.0-beta.4
17
+
18
+ ### Patch Changes
19
+
20
+ - Fix saveScore not persisting ID correctly, breaking getScoreById retrieval ([#10915](https://github.com/mastra-ai/mastra/pull/10915))
21
+
22
+ **What Changed**
23
+ - saveScore now correctly returns scores that can be retrieved with getScoreById
24
+ - Validation errors now include contextual information (scorer, entity, trace details) for easier debugging
25
+
26
+ **Impact**
27
+ Previously, calling getScoreById after saveScore would return null because the generated ID wasn't persisted to the database. This is now fixed across all store implementations, ensuring consistent behavior and data integrity.
28
+
29
+ - Updated dependencies [[`0d41fe2`](https://github.com/mastra-ai/mastra/commit/0d41fe245355dfc66d61a0d9c85d9400aac351ff), [`6b3ba91`](https://github.com/mastra-ai/mastra/commit/6b3ba91494cc10394df96782f349a4f7b1e152cc), [`7907fd1`](https://github.com/mastra-ai/mastra/commit/7907fd1c5059813b7b870b81ca71041dc807331b)]:
30
+ - @mastra/core@1.0.0-beta.8
31
+
3
32
  ## 1.0.0-beta.3
4
33
 
5
34
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -15,7 +15,8 @@ var TABLE_ENGINES = {
15
15
  [storage.TABLE_SCORERS]: `MergeTree()`,
16
16
  [storage.TABLE_RESOURCES]: `ReplacingMergeTree()`,
17
17
  // TODO: verify this is the correct engine for Spans when implementing clickhouse storage
18
- [storage.TABLE_SPANS]: `ReplacingMergeTree()`
18
+ [storage.TABLE_SPANS]: `ReplacingMergeTree()`,
19
+ mastra_agents: `ReplacingMergeTree()`
19
20
  };
20
21
  var COLUMN_TYPES = {
21
22
  text: "String",
@@ -1529,19 +1530,33 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1529
1530
  id: storage.createStorageErrorId("CLICKHOUSE", "SAVE_SCORE", "VALIDATION_FAILED"),
1530
1531
  domain: error.ErrorDomain.STORAGE,
1531
1532
  category: error.ErrorCategory.USER,
1532
- details: { scoreId: score.id }
1533
+ details: {
1534
+ scorer: score.scorer?.id ?? "unknown",
1535
+ entityId: score.entityId ?? "unknown",
1536
+ entityType: score.entityType ?? "unknown",
1537
+ traceId: score.traceId ?? "",
1538
+ spanId: score.spanId ?? ""
1539
+ }
1533
1540
  },
1534
1541
  error$1
1535
1542
  );
1536
1543
  }
1544
+ const now = /* @__PURE__ */ new Date();
1545
+ const id = crypto.randomUUID();
1546
+ const createdAt = now;
1547
+ const updatedAt = now;
1537
1548
  try {
1538
1549
  const record = {};
1539
1550
  for (const key of Object.keys(storage.SCORERS_SCHEMA)) {
1540
- const value = parsedScore[key];
1551
+ if (key === "id") {
1552
+ record[key] = id;
1553
+ continue;
1554
+ }
1541
1555
  if (key === "createdAt" || key === "updatedAt") {
1542
- record[key] = (/* @__PURE__ */ new Date()).toISOString();
1556
+ record[key] = now.toISOString();
1543
1557
  continue;
1544
1558
  }
1559
+ const value = parsedScore[key];
1545
1560
  record[key] = value === void 0 || value === null ? "_null_" : value;
1546
1561
  }
1547
1562
  await this.client.insert({
@@ -1554,14 +1569,14 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1554
1569
  output_format_json_quote_64bit_integers: 0
1555
1570
  }
1556
1571
  });
1557
- return { score };
1572
+ return { score: { ...parsedScore, id, createdAt, updatedAt } };
1558
1573
  } catch (error$1) {
1559
1574
  throw new error.MastraError(
1560
1575
  {
1561
1576
  id: storage.createStorageErrorId("CLICKHOUSE", "SAVE_SCORE", "FAILED"),
1562
1577
  domain: error.ErrorDomain.STORAGE,
1563
1578
  category: error.ErrorCategory.THIRD_PARTY,
1564
- details: { scoreId: score.id }
1579
+ details: { scoreId: id }
1565
1580
  },
1566
1581
  error$1
1567
1582
  );
@@ -2142,6 +2157,28 @@ var WorkflowsStorageClickhouse = class extends storage.WorkflowsStorage {
2142
2157
  );
2143
2158
  }
2144
2159
  }
2160
+ async deleteWorkflowRunById({ runId, workflowName }) {
2161
+ try {
2162
+ const values = {
2163
+ var_runId: runId,
2164
+ var_workflow_name: workflowName
2165
+ };
2166
+ await this.client.command({
2167
+ query: `DELETE FROM ${storage.TABLE_WORKFLOW_SNAPSHOT} WHERE run_id = {var_runId:String} AND workflow_name = {var_workflow_name:String}`,
2168
+ query_params: values
2169
+ });
2170
+ } catch (error$1) {
2171
+ throw new error.MastraError(
2172
+ {
2173
+ id: storage.createStorageErrorId("CLICKHOUSE", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
2174
+ domain: error.ErrorDomain.STORAGE,
2175
+ category: error.ErrorCategory.THIRD_PARTY,
2176
+ details: { runId, workflowName }
2177
+ },
2178
+ error$1
2179
+ );
2180
+ }
2181
+ }
2145
2182
  };
2146
2183
 
2147
2184
  // src/storage/index.ts
@@ -2286,6 +2323,9 @@ var ClickhouseStore = class extends storage.MastraStorage {
2286
2323
  }) {
2287
2324
  return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
2288
2325
  }
2326
+ async deleteWorkflowRunById({ runId, workflowName }) {
2327
+ return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
2328
+ }
2289
2329
  async getThreadById({ threadId }) {
2290
2330
  return this.stores.memory.getThreadById({ threadId });
2291
2331
  }
@@ -2324,8 +2364,8 @@ var ClickhouseStore = class extends storage.MastraStorage {
2324
2364
  async getScoreById({ id }) {
2325
2365
  return this.stores.scores.getScoreById({ id });
2326
2366
  }
2327
- async saveScore(_score) {
2328
- return this.stores.scores.saveScore(_score);
2367
+ async saveScore(score) {
2368
+ return this.stores.scores.saveScore(score);
2329
2369
  }
2330
2370
  async listScoresByRunId({
2331
2371
  runId,