@mastra/clickhouse 1.7.0 → 1.7.1-alpha.1
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 +28 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +30 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mastra/clickhouse
|
|
2
2
|
|
|
3
|
+
## 1.7.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Respect optional `resourceId` in `getThreadById` so scoped thread lookups return `null` when the thread belongs to a different resource. ([#14237](https://github.com/mastra-ai/mastra/pull/14237))
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const thread = await memory.getThreadById({
|
|
13
|
+
threadId: 'my-thread-id',
|
|
14
|
+
resourceId: 'my-user-id',
|
|
15
|
+
});
|
|
16
|
+
// Returns null if the thread does not belong to 'my-user-id'.
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`7c275a8`](https://github.com/mastra-ai/mastra/commit/7c275a810595e1a6c41ccc39720531ab65734700), [`890b24c`](https://github.com/mastra-ai/mastra/commit/890b24cc7d32ed6aa4dfe253e54dc6bf4099f690), [`0f48ebf`](https://github.com/mastra-ai/mastra/commit/0f48ebfc7ac7897b2092a189f45751924cf56d1c), [`f180e49`](https://github.com/mastra-ai/mastra/commit/f180e4990e71b04c9a475b523584071712f0048f), [`9260e01`](https://github.com/mastra-ai/mastra/commit/9260e015276fb1b500f7878ee452b47476bf1583), [`2f6c54e`](https://github.com/mastra-ai/mastra/commit/2f6c54e17c041cac1def54baaa6b771647836414), [`e06a159`](https://github.com/mastra-ai/mastra/commit/e06a1598ca07a6c3778aefc2a2d288363c6294ff), [`db34bc6`](https://github.com/mastra-ai/mastra/commit/db34bc6fb36cf125bda0c46be4d3fdc774b70cc4)]:
|
|
20
|
+
- @mastra/core@1.33.0-alpha.8
|
|
21
|
+
|
|
22
|
+
## 1.7.1-alpha.0
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Track `suspendedAt` and `suspendPayload` on background tasks. SQL adapters auto-migrate the new columns via `alterTable`. ([#16260](https://github.com/mastra-ai/mastra/pull/16260))
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`9f17410`](https://github.com/mastra-ai/mastra/commit/9f1741080def23d42ee50b39887a385ae316a3c6), [`c6eb39e`](https://github.com/mastra-ai/mastra/commit/c6eb39ea6dca381c6563cb240237fbe608e02f93), [`900d086`](https://github.com/mastra-ai/mastra/commit/900d086bb737b9cf2fcf68f11b0389b801a2738c), [`4c0e286`](https://github.com/mastra-ai/mastra/commit/4c0e28637c9cfb4f416549b55e97ebfa13319dfc), [`25184ff`](https://github.com/mastra-ai/mastra/commit/25184ffaf1293ec95119426eb1a1f8d38831b96c), [`aebde9c`](https://github.com/mastra-ai/mastra/commit/aebde9cfacf56592c6b6350cae721740fe090b8a)]:
|
|
29
|
+
- @mastra/core@1.33.0-alpha.4
|
|
30
|
+
|
|
3
31
|
## 1.7.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-clickhouse
|
|
|
3
3
|
description: Documentation for @mastra/clickhouse. Use when working with @mastra/clickhouse APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/clickhouse"
|
|
6
|
-
version: "1.7.
|
|
6
|
+
version: "1.7.1-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -689,6 +689,12 @@ function serializeJson(v) {
|
|
|
689
689
|
if (typeof v === "object" && v != null) return JSON.stringify(v);
|
|
690
690
|
return v ?? "";
|
|
691
691
|
}
|
|
692
|
+
function readNullableDate(val) {
|
|
693
|
+
if (val == null || val === "") return void 0;
|
|
694
|
+
const d = new Date(val);
|
|
695
|
+
if (Number.isNaN(d.getTime()) || d.getTime() === 0) return void 0;
|
|
696
|
+
return d;
|
|
697
|
+
}
|
|
692
698
|
function rowToTask(row) {
|
|
693
699
|
const parseJson2 = (val) => {
|
|
694
700
|
if (val == null || val === "") return void 0;
|
|
@@ -713,12 +719,14 @@ function rowToTask(row) {
|
|
|
713
719
|
runId: row.run_id ?? "",
|
|
714
720
|
result: parseJson2(row.result),
|
|
715
721
|
error: parseJson2(row.error),
|
|
722
|
+
suspendPayload: parseJson2(row.suspend_payload),
|
|
716
723
|
retryCount: Number(row.retry_count ?? 0),
|
|
717
724
|
maxRetries: Number(row.max_retries ?? 0),
|
|
718
725
|
timeoutMs: Number(row.timeout_ms ?? 3e5),
|
|
719
726
|
createdAt: new Date(row.createdAt),
|
|
720
|
-
startedAt:
|
|
721
|
-
|
|
727
|
+
startedAt: readNullableDate(row.startedAt),
|
|
728
|
+
suspendedAt: readNullableDate(row.suspendedAt),
|
|
729
|
+
completedAt: readNullableDate(row.completedAt)
|
|
722
730
|
};
|
|
723
731
|
}
|
|
724
732
|
var BackgroundTasksStorageClickhouse = class extends storage.BackgroundTasksStorage {
|
|
@@ -732,6 +740,11 @@ var BackgroundTasksStorageClickhouse = class extends storage.BackgroundTasksStor
|
|
|
732
740
|
}
|
|
733
741
|
async init() {
|
|
734
742
|
await this.#db.createTable({ tableName: storage.TABLE_BACKGROUND_TASKS, schema: storage.TABLE_SCHEMAS[storage.TABLE_BACKGROUND_TASKS] });
|
|
743
|
+
await this.#db.alterTable({
|
|
744
|
+
tableName: storage.TABLE_BACKGROUND_TASKS,
|
|
745
|
+
schema: storage.TABLE_SCHEMAS[storage.TABLE_BACKGROUND_TASKS],
|
|
746
|
+
ifNotExists: ["suspend_payload", "suspendedAt"]
|
|
747
|
+
});
|
|
735
748
|
}
|
|
736
749
|
async dangerouslyClearAll() {
|
|
737
750
|
await this.#db.clearTable({ tableName: storage.TABLE_BACKGROUND_TASKS });
|
|
@@ -752,11 +765,13 @@ var BackgroundTasksStorageClickhouse = class extends storage.BackgroundTasksStor
|
|
|
752
765
|
args: serializeJson(task.args),
|
|
753
766
|
result: serializeJson(task.result),
|
|
754
767
|
error: serializeJson(task.error),
|
|
768
|
+
suspend_payload: serializeJson(task.suspendPayload),
|
|
755
769
|
retry_count: task.retryCount,
|
|
756
770
|
max_retries: task.maxRetries,
|
|
757
771
|
timeout_ms: task.timeoutMs,
|
|
758
772
|
createdAt: task.createdAt.toISOString(),
|
|
759
773
|
startedAt: task.startedAt?.toISOString() ?? "1970-01-01T00:00:00.000Z",
|
|
774
|
+
suspendedAt: task.suspendedAt?.toISOString() ?? "1970-01-01T00:00:00.000Z",
|
|
760
775
|
completedAt: task.completedAt?.toISOString() ?? "1970-01-01T00:00:00.000Z"
|
|
761
776
|
}
|
|
762
777
|
],
|
|
@@ -771,8 +786,10 @@ var BackgroundTasksStorageClickhouse = class extends storage.BackgroundTasksStor
|
|
|
771
786
|
if ("status" in update) merged.status = update.status;
|
|
772
787
|
if ("result" in update) merged.result = update.result;
|
|
773
788
|
if ("error" in update) merged.error = update.error;
|
|
789
|
+
if ("suspendPayload" in update) merged.suspendPayload = update.suspendPayload;
|
|
774
790
|
if ("retryCount" in update) merged.retryCount = update.retryCount;
|
|
775
791
|
if ("startedAt" in update) merged.startedAt = update.startedAt;
|
|
792
|
+
if ("suspendedAt" in update) merged.suspendedAt = update.suspendedAt;
|
|
776
793
|
if ("completedAt" in update) merged.completedAt = update.completedAt;
|
|
777
794
|
await this.createTask(merged);
|
|
778
795
|
}
|
|
@@ -810,7 +827,11 @@ var BackgroundTasksStorageClickhouse = class extends storage.BackgroundTasksStor
|
|
|
810
827
|
conditions.push(`tool_name = {var_tool:String}`);
|
|
811
828
|
params.var_tool = filter.toolName;
|
|
812
829
|
}
|
|
813
|
-
|
|
830
|
+
if (filter.toolCallId) {
|
|
831
|
+
conditions.push(`tool_call_id = {var_tool_call:String}`);
|
|
832
|
+
params.var_tool_call = filter.toolCallId;
|
|
833
|
+
}
|
|
834
|
+
const dateCol = filter.dateFilterBy === "startedAt" ? "startedAt" : filter.dateFilterBy === "suspendedAt" ? "suspendedAt" : filter.dateFilterBy === "completedAt" ? "completedAt" : "createdAt";
|
|
814
835
|
if (filter.fromDate) {
|
|
815
836
|
conditions.push(`${dateCol} >= parseDateTimeBestEffort({var_from_date:String})`);
|
|
816
837
|
params.var_from_date = filter.fromDate.toISOString();
|
|
@@ -832,7 +853,7 @@ var BackgroundTasksStorageClickhouse = class extends storage.BackgroundTasksStor
|
|
|
832
853
|
});
|
|
833
854
|
const countRows = await countResult.json();
|
|
834
855
|
const total = Number(countRows[0]?.count ?? 0);
|
|
835
|
-
const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
|
|
856
|
+
const orderCol = filter.orderBy === "startedAt" ? "startedAt" : filter.orderBy === "suspendedAt" ? "suspendedAt" : filter.orderBy === "completedAt" ? "completedAt" : "createdAt";
|
|
836
857
|
const direction = filter.orderDirection === "desc" ? "DESC" : "ASC";
|
|
837
858
|
let sql = `SELECT * FROM ${storage.TABLE_BACKGROUND_TASKS} FINAL ${where} ORDER BY ${orderCol} ${direction}`;
|
|
838
859
|
if (filter.perPage != null) {
|
|
@@ -1437,7 +1458,10 @@ var MemoryStorageClickhouse = class extends storage.MemoryStorage {
|
|
|
1437
1458
|
);
|
|
1438
1459
|
}
|
|
1439
1460
|
}
|
|
1440
|
-
async getThreadById({
|
|
1461
|
+
async getThreadById({
|
|
1462
|
+
threadId,
|
|
1463
|
+
resourceId
|
|
1464
|
+
}) {
|
|
1441
1465
|
try {
|
|
1442
1466
|
const result = await this.client.query({
|
|
1443
1467
|
query: `SELECT
|
|
@@ -1462,7 +1486,7 @@ var MemoryStorageClickhouse = class extends storage.MemoryStorage {
|
|
|
1462
1486
|
});
|
|
1463
1487
|
const rows = await result.json();
|
|
1464
1488
|
const thread = transformRow(rows.data[0]);
|
|
1465
|
-
if (!thread) {
|
|
1489
|
+
if (!thread || resourceId !== void 0 && thread.resourceId !== resourceId) {
|
|
1466
1490
|
return null;
|
|
1467
1491
|
}
|
|
1468
1492
|
return {
|