@mastra/clickhouse 1.5.1 → 1.5.2
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 +22 -0
- package/README.md +3 -2
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-clickhouse.md +274 -0
- package/dist/docs/references/reference-storage-composite.md +5 -3
- package/dist/index.cjs +17 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -19
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -514,16 +514,11 @@ var ClickhouseDB = class extends MastraBase {
|
|
|
514
514
|
}
|
|
515
515
|
async clearTable({ tableName }) {
|
|
516
516
|
try {
|
|
517
|
-
await this.client.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
// Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
|
|
521
|
-
date_time_input_format: "best_effort",
|
|
522
|
-
date_time_output_format: "iso",
|
|
523
|
-
use_client_time_zone: 1,
|
|
524
|
-
output_format_json_quote_64bit_integers: 0
|
|
525
|
-
}
|
|
517
|
+
await this.client.command({ query: `SYSTEM STOP MERGES ${tableName}` });
|
|
518
|
+
await this.client.command({
|
|
519
|
+
query: `TRUNCATE TABLE ${tableName}`
|
|
526
520
|
});
|
|
521
|
+
await this.client.command({ query: `SYSTEM START MERGES ${tableName}` });
|
|
527
522
|
} catch (error) {
|
|
528
523
|
throw new MastraError(
|
|
529
524
|
{
|
|
@@ -785,7 +780,7 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
785
780
|
const rows = await result.json();
|
|
786
781
|
return rows.length > 0 ? rowToTask(rows[0]) : null;
|
|
787
782
|
}
|
|
788
|
-
|
|
783
|
+
buildFilterClause(filter) {
|
|
789
784
|
const conditions = [];
|
|
790
785
|
const params = {};
|
|
791
786
|
if (filter.status) {
|
|
@@ -819,6 +814,10 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
819
814
|
params.var_to_date = filter.toDate.toISOString();
|
|
820
815
|
}
|
|
821
816
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
817
|
+
return { where, params };
|
|
818
|
+
}
|
|
819
|
+
async listTasks(filter) {
|
|
820
|
+
const { where, params } = this.buildFilterClause(filter);
|
|
822
821
|
const countResult = await this.client.query({
|
|
823
822
|
query: `SELECT count() as count FROM ${TABLE_BACKGROUND_TASKS} FINAL ${where}`,
|
|
824
823
|
query_params: params,
|
|
@@ -848,19 +847,18 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
848
847
|
return { tasks, total };
|
|
849
848
|
}
|
|
850
849
|
async deleteTask(taskId) {
|
|
851
|
-
await this.client.
|
|
852
|
-
query: `
|
|
850
|
+
await this.client.command({
|
|
851
|
+
query: `DELETE FROM ${TABLE_BACKGROUND_TASKS} WHERE id = {var_id:String}`,
|
|
853
852
|
query_params: { var_id: taskId }
|
|
854
853
|
});
|
|
855
854
|
}
|
|
856
855
|
async deleteTasks(filter) {
|
|
857
|
-
const {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
}
|
|
856
|
+
const { where, params } = this.buildFilterClause(filter);
|
|
857
|
+
if (!where) return;
|
|
858
|
+
await this.client.command({
|
|
859
|
+
query: `DELETE FROM ${TABLE_BACKGROUND_TASKS} ${where}`,
|
|
860
|
+
query_params: params
|
|
861
|
+
});
|
|
864
862
|
}
|
|
865
863
|
async getRunningCount() {
|
|
866
864
|
const result = await this.client.query({
|