@mastra/clickhouse 1.0.0-beta.4 → 1.0.0-beta.6
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 +57 -0
- package/README.md +3 -1
- package/dist/index.cjs +35 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/utils.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +6 -8
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +6 -8
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +4 -5
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",
|
|
@@ -1213,14 +1214,18 @@ var StoreOperationsClickhouse = class extends StoreOperations {
|
|
|
1213
1214
|
getSqlType(type) {
|
|
1214
1215
|
switch (type) {
|
|
1215
1216
|
case "text":
|
|
1217
|
+
case "uuid":
|
|
1218
|
+
case "jsonb":
|
|
1216
1219
|
return "String";
|
|
1217
1220
|
case "timestamp":
|
|
1218
1221
|
return "DateTime64(3)";
|
|
1219
1222
|
case "integer":
|
|
1220
1223
|
case "bigint":
|
|
1221
1224
|
return "Int64";
|
|
1222
|
-
case "
|
|
1223
|
-
return "
|
|
1225
|
+
case "float":
|
|
1226
|
+
return "Float64";
|
|
1227
|
+
case "boolean":
|
|
1228
|
+
return "Bool";
|
|
1224
1229
|
default:
|
|
1225
1230
|
return super.getSqlType(type);
|
|
1226
1231
|
}
|
|
@@ -1237,7 +1242,7 @@ var StoreOperationsClickhouse = class extends StoreOperations {
|
|
|
1237
1242
|
constraints.push("DEFAULT '{}'");
|
|
1238
1243
|
}
|
|
1239
1244
|
const columnTtl = this.ttl?.[tableName]?.columns?.[name];
|
|
1240
|
-
return `"${name}" ${
|
|
1245
|
+
return `"${name}" ${this.getSqlType(def.type)} ${constraints.join(" ")} ${columnTtl ? `TTL toDateTime(${columnTtl.ttlKey ?? "createdAt"}) + INTERVAL ${columnTtl.interval} ${columnTtl.unit}` : ""}`;
|
|
1241
1246
|
}).join(",\n");
|
|
1242
1247
|
const rowTtl = this.ttl?.[tableName]?.row;
|
|
1243
1248
|
const sql = tableName === TABLE_WORKFLOW_SNAPSHOT ? `
|
|
@@ -1421,7 +1426,7 @@ var StoreOperationsClickhouse = class extends StoreOperations {
|
|
|
1421
1426
|
const engine = TABLE_ENGINES[tableName] ?? "MergeTree()";
|
|
1422
1427
|
const keyEntries = Object.entries(keys);
|
|
1423
1428
|
const conditions = keyEntries.map(
|
|
1424
|
-
([key]) => `"${key}" = {var_${key}:${
|
|
1429
|
+
([key]) => `"${key}" = {var_${key}:${this.getSqlType(TABLE_SCHEMAS[tableName]?.[key]?.type ?? "text")}}`
|
|
1425
1430
|
).join(" AND ");
|
|
1426
1431
|
const values = keyEntries.reduce((acc, [key, value]) => {
|
|
1427
1432
|
return { ...acc, [`var_${key}`]: value };
|
|
@@ -2154,6 +2159,28 @@ var WorkflowsStorageClickhouse = class extends WorkflowsStorage {
|
|
|
2154
2159
|
);
|
|
2155
2160
|
}
|
|
2156
2161
|
}
|
|
2162
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
2163
|
+
try {
|
|
2164
|
+
const values = {
|
|
2165
|
+
var_runId: runId,
|
|
2166
|
+
var_workflow_name: workflowName
|
|
2167
|
+
};
|
|
2168
|
+
await this.client.command({
|
|
2169
|
+
query: `DELETE FROM ${TABLE_WORKFLOW_SNAPSHOT} WHERE run_id = {var_runId:String} AND workflow_name = {var_workflow_name:String}`,
|
|
2170
|
+
query_params: values
|
|
2171
|
+
});
|
|
2172
|
+
} catch (error) {
|
|
2173
|
+
throw new MastraError(
|
|
2174
|
+
{
|
|
2175
|
+
id: createStorageErrorId("CLICKHOUSE", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
2176
|
+
domain: ErrorDomain.STORAGE,
|
|
2177
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
2178
|
+
details: { runId, workflowName }
|
|
2179
|
+
},
|
|
2180
|
+
error
|
|
2181
|
+
);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2157
2184
|
};
|
|
2158
2185
|
|
|
2159
2186
|
// src/storage/index.ts
|
|
@@ -2298,6 +2325,9 @@ var ClickhouseStore = class extends MastraStorage {
|
|
|
2298
2325
|
}) {
|
|
2299
2326
|
return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
|
|
2300
2327
|
}
|
|
2328
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
2329
|
+
return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
|
|
2330
|
+
}
|
|
2301
2331
|
async getThreadById({ threadId }) {
|
|
2302
2332
|
return this.stores.memory.getThreadById({ threadId });
|
|
2303
2333
|
}
|