@mastra/clickhouse 1.7.0 → 1.7.1-alpha.0
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 +9 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +25 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -687,6 +687,12 @@ function serializeJson(v) {
|
|
|
687
687
|
if (typeof v === "object" && v != null) return JSON.stringify(v);
|
|
688
688
|
return v ?? "";
|
|
689
689
|
}
|
|
690
|
+
function readNullableDate(val) {
|
|
691
|
+
if (val == null || val === "") return void 0;
|
|
692
|
+
const d = new Date(val);
|
|
693
|
+
if (Number.isNaN(d.getTime()) || d.getTime() === 0) return void 0;
|
|
694
|
+
return d;
|
|
695
|
+
}
|
|
690
696
|
function rowToTask(row) {
|
|
691
697
|
const parseJson2 = (val) => {
|
|
692
698
|
if (val == null || val === "") return void 0;
|
|
@@ -711,12 +717,14 @@ function rowToTask(row) {
|
|
|
711
717
|
runId: row.run_id ?? "",
|
|
712
718
|
result: parseJson2(row.result),
|
|
713
719
|
error: parseJson2(row.error),
|
|
720
|
+
suspendPayload: parseJson2(row.suspend_payload),
|
|
714
721
|
retryCount: Number(row.retry_count ?? 0),
|
|
715
722
|
maxRetries: Number(row.max_retries ?? 0),
|
|
716
723
|
timeoutMs: Number(row.timeout_ms ?? 3e5),
|
|
717
724
|
createdAt: new Date(row.createdAt),
|
|
718
|
-
startedAt:
|
|
719
|
-
|
|
725
|
+
startedAt: readNullableDate(row.startedAt),
|
|
726
|
+
suspendedAt: readNullableDate(row.suspendedAt),
|
|
727
|
+
completedAt: readNullableDate(row.completedAt)
|
|
720
728
|
};
|
|
721
729
|
}
|
|
722
730
|
var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
@@ -730,6 +738,11 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
730
738
|
}
|
|
731
739
|
async init() {
|
|
732
740
|
await this.#db.createTable({ tableName: TABLE_BACKGROUND_TASKS, schema: TABLE_SCHEMAS[TABLE_BACKGROUND_TASKS] });
|
|
741
|
+
await this.#db.alterTable({
|
|
742
|
+
tableName: TABLE_BACKGROUND_TASKS,
|
|
743
|
+
schema: TABLE_SCHEMAS[TABLE_BACKGROUND_TASKS],
|
|
744
|
+
ifNotExists: ["suspend_payload", "suspendedAt"]
|
|
745
|
+
});
|
|
733
746
|
}
|
|
734
747
|
async dangerouslyClearAll() {
|
|
735
748
|
await this.#db.clearTable({ tableName: TABLE_BACKGROUND_TASKS });
|
|
@@ -750,11 +763,13 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
750
763
|
args: serializeJson(task.args),
|
|
751
764
|
result: serializeJson(task.result),
|
|
752
765
|
error: serializeJson(task.error),
|
|
766
|
+
suspend_payload: serializeJson(task.suspendPayload),
|
|
753
767
|
retry_count: task.retryCount,
|
|
754
768
|
max_retries: task.maxRetries,
|
|
755
769
|
timeout_ms: task.timeoutMs,
|
|
756
770
|
createdAt: task.createdAt.toISOString(),
|
|
757
771
|
startedAt: task.startedAt?.toISOString() ?? "1970-01-01T00:00:00.000Z",
|
|
772
|
+
suspendedAt: task.suspendedAt?.toISOString() ?? "1970-01-01T00:00:00.000Z",
|
|
758
773
|
completedAt: task.completedAt?.toISOString() ?? "1970-01-01T00:00:00.000Z"
|
|
759
774
|
}
|
|
760
775
|
],
|
|
@@ -769,8 +784,10 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
769
784
|
if ("status" in update) merged.status = update.status;
|
|
770
785
|
if ("result" in update) merged.result = update.result;
|
|
771
786
|
if ("error" in update) merged.error = update.error;
|
|
787
|
+
if ("suspendPayload" in update) merged.suspendPayload = update.suspendPayload;
|
|
772
788
|
if ("retryCount" in update) merged.retryCount = update.retryCount;
|
|
773
789
|
if ("startedAt" in update) merged.startedAt = update.startedAt;
|
|
790
|
+
if ("suspendedAt" in update) merged.suspendedAt = update.suspendedAt;
|
|
774
791
|
if ("completedAt" in update) merged.completedAt = update.completedAt;
|
|
775
792
|
await this.createTask(merged);
|
|
776
793
|
}
|
|
@@ -808,7 +825,11 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
808
825
|
conditions.push(`tool_name = {var_tool:String}`);
|
|
809
826
|
params.var_tool = filter.toolName;
|
|
810
827
|
}
|
|
811
|
-
|
|
828
|
+
if (filter.toolCallId) {
|
|
829
|
+
conditions.push(`tool_call_id = {var_tool_call:String}`);
|
|
830
|
+
params.var_tool_call = filter.toolCallId;
|
|
831
|
+
}
|
|
832
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
|
|
812
833
|
if (filter.fromDate) {
|
|
813
834
|
conditions.push(`${dateCol} >= parseDateTimeBestEffort({var_from_date:String})`);
|
|
814
835
|
params.var_from_date = filter.fromDate.toISOString();
|
|
@@ -830,7 +851,7 @@ var BackgroundTasksStorageClickhouse = class extends BackgroundTasksStorage {
|
|
|
830
851
|
});
|
|
831
852
|
const countRows = await countResult.json();
|
|
832
853
|
const total = Number(countRows[0]?.count ?? 0);
|
|
833
|
-
const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
|
|
854
|
+
const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "suspendedAt" ? "suspendedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
|
|
834
855
|
const direction = filter.orderDirection === "desc" ? "DESC" : "ASC";
|
|
835
856
|
let sql = `SELECT * FROM ${TABLE_BACKGROUND_TASKS} FINAL ${where} ORDER BY ${orderCol} ${direction}`;
|
|
836
857
|
if (filter.perPage != null) {
|