@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 +29 -0
- package/dist/index.cjs +48 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -8
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +2 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/utils.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +4 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +6 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,7 +13,8 @@ var TABLE_ENGINES = {
|
|
|
13
13
|
[TABLE_SCORERS]: `MergeTree()`,
|
|
14
14
|
[TABLE_RESOURCES]: `ReplacingMergeTree()`,
|
|
15
15
|
// TODO: verify this is the correct engine for Spans when implementing clickhouse storage
|
|
16
|
-
[TABLE_SPANS]: `ReplacingMergeTree()
|
|
16
|
+
[TABLE_SPANS]: `ReplacingMergeTree()`,
|
|
17
|
+
mastra_agents: `ReplacingMergeTree()`
|
|
17
18
|
};
|
|
18
19
|
var COLUMN_TYPES = {
|
|
19
20
|
text: "String",
|
|
@@ -1527,19 +1528,33 @@ var ScoresStorageClickhouse = class extends ScoresStorage {
|
|
|
1527
1528
|
id: createStorageErrorId("CLICKHOUSE", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1528
1529
|
domain: ErrorDomain.STORAGE,
|
|
1529
1530
|
category: ErrorCategory.USER,
|
|
1530
|
-
details: {
|
|
1531
|
+
details: {
|
|
1532
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
1533
|
+
entityId: score.entityId ?? "unknown",
|
|
1534
|
+
entityType: score.entityType ?? "unknown",
|
|
1535
|
+
traceId: score.traceId ?? "",
|
|
1536
|
+
spanId: score.spanId ?? ""
|
|
1537
|
+
}
|
|
1531
1538
|
},
|
|
1532
1539
|
error
|
|
1533
1540
|
);
|
|
1534
1541
|
}
|
|
1542
|
+
const now = /* @__PURE__ */ new Date();
|
|
1543
|
+
const id = crypto.randomUUID();
|
|
1544
|
+
const createdAt = now;
|
|
1545
|
+
const updatedAt = now;
|
|
1535
1546
|
try {
|
|
1536
1547
|
const record = {};
|
|
1537
1548
|
for (const key of Object.keys(SCORERS_SCHEMA)) {
|
|
1538
|
-
|
|
1549
|
+
if (key === "id") {
|
|
1550
|
+
record[key] = id;
|
|
1551
|
+
continue;
|
|
1552
|
+
}
|
|
1539
1553
|
if (key === "createdAt" || key === "updatedAt") {
|
|
1540
|
-
record[key] =
|
|
1554
|
+
record[key] = now.toISOString();
|
|
1541
1555
|
continue;
|
|
1542
1556
|
}
|
|
1557
|
+
const value = parsedScore[key];
|
|
1543
1558
|
record[key] = value === void 0 || value === null ? "_null_" : value;
|
|
1544
1559
|
}
|
|
1545
1560
|
await this.client.insert({
|
|
@@ -1552,14 +1567,14 @@ var ScoresStorageClickhouse = class extends ScoresStorage {
|
|
|
1552
1567
|
output_format_json_quote_64bit_integers: 0
|
|
1553
1568
|
}
|
|
1554
1569
|
});
|
|
1555
|
-
return { score };
|
|
1570
|
+
return { score: { ...parsedScore, id, createdAt, updatedAt } };
|
|
1556
1571
|
} catch (error) {
|
|
1557
1572
|
throw new MastraError(
|
|
1558
1573
|
{
|
|
1559
1574
|
id: createStorageErrorId("CLICKHOUSE", "SAVE_SCORE", "FAILED"),
|
|
1560
1575
|
domain: ErrorDomain.STORAGE,
|
|
1561
1576
|
category: ErrorCategory.THIRD_PARTY,
|
|
1562
|
-
details: { scoreId:
|
|
1577
|
+
details: { scoreId: id }
|
|
1563
1578
|
},
|
|
1564
1579
|
error
|
|
1565
1580
|
);
|
|
@@ -2140,6 +2155,28 @@ var WorkflowsStorageClickhouse = class extends WorkflowsStorage {
|
|
|
2140
2155
|
);
|
|
2141
2156
|
}
|
|
2142
2157
|
}
|
|
2158
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
2159
|
+
try {
|
|
2160
|
+
const values = {
|
|
2161
|
+
var_runId: runId,
|
|
2162
|
+
var_workflow_name: workflowName
|
|
2163
|
+
};
|
|
2164
|
+
await this.client.command({
|
|
2165
|
+
query: `DELETE FROM ${TABLE_WORKFLOW_SNAPSHOT} WHERE run_id = {var_runId:String} AND workflow_name = {var_workflow_name:String}`,
|
|
2166
|
+
query_params: values
|
|
2167
|
+
});
|
|
2168
|
+
} catch (error) {
|
|
2169
|
+
throw new MastraError(
|
|
2170
|
+
{
|
|
2171
|
+
id: createStorageErrorId("CLICKHOUSE", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
2172
|
+
domain: ErrorDomain.STORAGE,
|
|
2173
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
2174
|
+
details: { runId, workflowName }
|
|
2175
|
+
},
|
|
2176
|
+
error
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2143
2180
|
};
|
|
2144
2181
|
|
|
2145
2182
|
// src/storage/index.ts
|
|
@@ -2284,6 +2321,9 @@ var ClickhouseStore = class extends MastraStorage {
|
|
|
2284
2321
|
}) {
|
|
2285
2322
|
return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
|
|
2286
2323
|
}
|
|
2324
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
2325
|
+
return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
|
|
2326
|
+
}
|
|
2287
2327
|
async getThreadById({ threadId }) {
|
|
2288
2328
|
return this.stores.memory.getThreadById({ threadId });
|
|
2289
2329
|
}
|
|
@@ -2322,8 +2362,8 @@ var ClickhouseStore = class extends MastraStorage {
|
|
|
2322
2362
|
async getScoreById({ id }) {
|
|
2323
2363
|
return this.stores.scores.getScoreById({ id });
|
|
2324
2364
|
}
|
|
2325
|
-
async saveScore(
|
|
2326
|
-
return this.stores.scores.saveScore(
|
|
2365
|
+
async saveScore(score) {
|
|
2366
|
+
return this.stores.scores.saveScore(score);
|
|
2327
2367
|
}
|
|
2328
2368
|
async listScoresByRunId({
|
|
2329
2369
|
runId,
|