@mastra/clickhouse 1.11.0 → 1.11.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 +40 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-clickhouse.md +2 -0
- package/dist/docs/references/reference-storage-composite.md +2 -0
- package/dist/index.cjs +46 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -18
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +9 -5
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @mastra/clickhouse
|
|
2
2
|
|
|
3
|
+
## 1.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
11
|
+
|
|
12
|
+
const result = await storage.listScoresByScorerId({
|
|
13
|
+
scorerId,
|
|
14
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`700619b`](https://github.com/mastra-ai/mastra/commit/700619b61d572e592cbaaf758121d168844ca4d2), [`0f69865`](https://github.com/mastra-ai/mastra/commit/0f69865aced225d98eac812e22699dc445ee18cb), [`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`0c3d4bc`](https://github.com/mastra-ai/mastra/commit/0c3d4bcae13ea3699d379403e6f350d5cf4efe9f), [`cc440a3`](https://github.com/mastra-ai/mastra/commit/cc440a39400d8ce06655462b26c1666a1b3d4320), [`6a61846`](https://github.com/mastra-ai/mastra/commit/6a61846eeda29fb714549b70f1bee2bf6b141c44), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`17369b2`](https://github.com/mastra-ai/mastra/commit/17369b25250561e9ed994ae509be1d15bfb33bcb), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`bcae929`](https://github.com/mastra-ai/mastra/commit/bcae929945cbf265bd9f327cc715ecafa072b5b9), [`ea6327b`](https://github.com/mastra-ai/mastra/commit/ea6327ba2d63ca647804bc97b347e03a58617162), [`3439fa8`](https://github.com/mastra-ai/mastra/commit/3439fa836ecfcaa257b40c20b30ac2a8be22e9ea), [`85107f2`](https://github.com/mastra-ai/mastra/commit/85107f2758b527147fccbedff962961927c2d3b8), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`06ff9e0`](https://github.com/mastra-ai/mastra/commit/06ff9e0befd1d642ab87ff749285ee4091205c7e), [`d5c11e3`](https://github.com/mastra-ai/mastra/commit/d5c11e3ba5045969caa7272a7bd1fd141c93ab6c), [`7f5e1ff`](https://github.com/mastra-ai/mastra/commit/7f5e1ff695a92f672bb3976363925d1e9136b54a), [`ff80671`](https://github.com/mastra-ai/mastra/commit/ff8067185e208b27198b4e5b71803013175c3643), [`b8375c1`](https://github.com/mastra-ai/mastra/commit/b8375c1f8fe905df8ae2ae9a893bb365f17aec4e), [`dab1257`](https://github.com/mastra-ai/mastra/commit/dab1257b64e4ed576dc5038bb7a3f7072338bc9f), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`705ff39`](https://github.com/mastra-ai/mastra/commit/705ff3969e57214ff2fdaf3815d751dd558886ed), [`e6fbd5b`](https://github.com/mastra-ai/mastra/commit/e6fbd5bfdc28e92c0c0433f29aa1bc152d3430f6), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`6f2026c`](https://github.com/mastra-ai/mastra/commit/6f2026cdf114ff1e21e49133ca774ec7d5085059), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`003f35d`](https://github.com/mastra-ai/mastra/commit/003f35d19e07b23b4bacc591c8bc0c59b42124ae), [`f890eda`](https://github.com/mastra-ai/mastra/commit/f890eda2c8a2ae83d9b30bc6d85842f93b6c266b), [`1340fb7`](https://github.com/mastra-ai/mastra/commit/1340fb76262a3ca062130aa71859f07257a0a5a4)]:
|
|
21
|
+
- @mastra/core@1.49.0
|
|
22
|
+
|
|
23
|
+
## 1.11.1-alpha.0
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
31
|
+
|
|
32
|
+
const result = await storage.listScoresByScorerId({
|
|
33
|
+
scorerId,
|
|
34
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748)]:
|
|
41
|
+
- @mastra/core@1.49.0-alpha.5
|
|
42
|
+
|
|
3
43
|
## 1.11.0
|
|
4
44
|
|
|
5
45
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# ClickHouse storage
|
|
2
4
|
|
|
3
5
|
[ClickHouse](https://clickhouse.com/) is a columnar database designed for analytical workloads. The `@mastra/clickhouse` package provides storage adapters for several Mastra storage domains and is the recommended backend for production observability.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Composite storage
|
|
2
4
|
|
|
3
5
|
`MastraCompositeStore` can compose storage domains from different providers. Use it when you need different databases for different purposes. For example, use LibSQL for memory and PostgreSQL for workflows.
|
package/dist/index.cjs
CHANGED
|
@@ -8107,6 +8107,19 @@ var ObservabilityStorageClickhouseVNext = class extends storage.ObservabilitySto
|
|
|
8107
8107
|
}
|
|
8108
8108
|
}
|
|
8109
8109
|
};
|
|
8110
|
+
function buildTenancyFilter(filters) {
|
|
8111
|
+
const clauses = [];
|
|
8112
|
+
const params = {};
|
|
8113
|
+
if (filters?.organizationId !== void 0) {
|
|
8114
|
+
clauses.push("organizationId = {var_organizationId:String}");
|
|
8115
|
+
params.var_organizationId = filters.organizationId;
|
|
8116
|
+
}
|
|
8117
|
+
if (filters?.projectId !== void 0) {
|
|
8118
|
+
clauses.push("projectId = {var_projectId:String}");
|
|
8119
|
+
params.var_projectId = filters.projectId;
|
|
8120
|
+
}
|
|
8121
|
+
return { sql: clauses.length > 0 ? ` AND ${clauses.join(" AND ")}` : "", params };
|
|
8122
|
+
}
|
|
8110
8123
|
var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
8111
8124
|
client;
|
|
8112
8125
|
#db;
|
|
@@ -8227,12 +8240,14 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8227
8240
|
}
|
|
8228
8241
|
async listScoresByRunId({
|
|
8229
8242
|
runId,
|
|
8230
|
-
pagination
|
|
8243
|
+
pagination,
|
|
8244
|
+
filters
|
|
8231
8245
|
}) {
|
|
8246
|
+
const tenancy = buildTenancyFilter(filters);
|
|
8232
8247
|
try {
|
|
8233
8248
|
const countResult = await this.client.query({
|
|
8234
|
-
query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE runId = {var_runId:String}`,
|
|
8235
|
-
query_params: { var_runId: runId },
|
|
8249
|
+
query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE runId = {var_runId:String}${tenancy.sql}`,
|
|
8250
|
+
query_params: { var_runId: runId, ...tenancy.params },
|
|
8236
8251
|
format: "JSONEachRow"
|
|
8237
8252
|
});
|
|
8238
8253
|
const countRows = await countResult.json();
|
|
@@ -8258,11 +8273,12 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8258
8273
|
const limitValue = perPageInput === false ? total : perPage;
|
|
8259
8274
|
const end = perPageInput === false ? total : start + perPage;
|
|
8260
8275
|
const result = await this.client.query({
|
|
8261
|
-
query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE runId = {var_runId:String} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
|
|
8276
|
+
query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE runId = {var_runId:String}${tenancy.sql} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
|
|
8262
8277
|
query_params: {
|
|
8263
8278
|
var_runId: runId,
|
|
8264
8279
|
var_limit: limitValue,
|
|
8265
|
-
var_offset: start
|
|
8280
|
+
var_offset: start,
|
|
8281
|
+
...tenancy.params
|
|
8266
8282
|
},
|
|
8267
8283
|
format: "JSONEachRow",
|
|
8268
8284
|
clickhouse_settings: {
|
|
@@ -8300,8 +8316,10 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8300
8316
|
entityId,
|
|
8301
8317
|
entityType,
|
|
8302
8318
|
source,
|
|
8303
|
-
pagination
|
|
8319
|
+
pagination,
|
|
8320
|
+
filters
|
|
8304
8321
|
}) {
|
|
8322
|
+
const tenancy = buildTenancyFilter(filters);
|
|
8305
8323
|
let whereClause = `scorerId = {var_scorerId:String}`;
|
|
8306
8324
|
if (entityId) {
|
|
8307
8325
|
whereClause += ` AND entityId = {var_entityId:String}`;
|
|
@@ -8312,6 +8330,7 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8312
8330
|
if (source) {
|
|
8313
8331
|
whereClause += ` AND source = {var_source:String}`;
|
|
8314
8332
|
}
|
|
8333
|
+
whereClause += tenancy.sql;
|
|
8315
8334
|
try {
|
|
8316
8335
|
const countResult = await this.client.query({
|
|
8317
8336
|
query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE ${whereClause}`,
|
|
@@ -8319,7 +8338,8 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8319
8338
|
var_scorerId: scorerId,
|
|
8320
8339
|
var_entityId: entityId,
|
|
8321
8340
|
var_entityType: entityType,
|
|
8322
|
-
var_source: source
|
|
8341
|
+
var_source: source,
|
|
8342
|
+
...tenancy.params
|
|
8323
8343
|
},
|
|
8324
8344
|
format: "JSONEachRow"
|
|
8325
8345
|
});
|
|
@@ -8353,7 +8373,8 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8353
8373
|
var_offset: start,
|
|
8354
8374
|
var_entityId: entityId,
|
|
8355
8375
|
var_entityType: entityType,
|
|
8356
|
-
var_source: source
|
|
8376
|
+
var_source: source,
|
|
8377
|
+
...tenancy.params
|
|
8357
8378
|
},
|
|
8358
8379
|
format: "JSONEachRow",
|
|
8359
8380
|
clickhouse_settings: {
|
|
@@ -8389,12 +8410,14 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8389
8410
|
async listScoresByEntityId({
|
|
8390
8411
|
entityId,
|
|
8391
8412
|
entityType,
|
|
8392
|
-
pagination
|
|
8413
|
+
pagination,
|
|
8414
|
+
filters
|
|
8393
8415
|
}) {
|
|
8416
|
+
const tenancy = buildTenancyFilter(filters);
|
|
8394
8417
|
try {
|
|
8395
8418
|
const countResult = await this.client.query({
|
|
8396
|
-
query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE entityId = {var_entityId:String} AND entityType = {var_entityType:String}`,
|
|
8397
|
-
query_params: { var_entityId: entityId, var_entityType: entityType },
|
|
8419
|
+
query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE entityId = {var_entityId:String} AND entityType = {var_entityType:String}${tenancy.sql}`,
|
|
8420
|
+
query_params: { var_entityId: entityId, var_entityType: entityType, ...tenancy.params },
|
|
8398
8421
|
format: "JSONEachRow"
|
|
8399
8422
|
});
|
|
8400
8423
|
const countRows = await countResult.json();
|
|
@@ -8420,12 +8443,13 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8420
8443
|
const limitValue = perPageInput === false ? total : perPage;
|
|
8421
8444
|
const end = perPageInput === false ? total : start + perPage;
|
|
8422
8445
|
const result = await this.client.query({
|
|
8423
|
-
query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE entityId = {var_entityId:String} AND entityType = {var_entityType:String} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
|
|
8446
|
+
query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE entityId = {var_entityId:String} AND entityType = {var_entityType:String}${tenancy.sql} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
|
|
8424
8447
|
query_params: {
|
|
8425
8448
|
var_entityId: entityId,
|
|
8426
8449
|
var_entityType: entityType,
|
|
8427
8450
|
var_limit: limitValue,
|
|
8428
|
-
var_offset: start
|
|
8451
|
+
var_offset: start,
|
|
8452
|
+
...tenancy.params
|
|
8429
8453
|
},
|
|
8430
8454
|
format: "JSONEachRow",
|
|
8431
8455
|
clickhouse_settings: {
|
|
@@ -8461,14 +8485,17 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8461
8485
|
async listScoresBySpan({
|
|
8462
8486
|
traceId,
|
|
8463
8487
|
spanId,
|
|
8464
|
-
pagination
|
|
8488
|
+
pagination,
|
|
8489
|
+
filters
|
|
8465
8490
|
}) {
|
|
8491
|
+
const tenancy = buildTenancyFilter(filters);
|
|
8466
8492
|
try {
|
|
8467
8493
|
const countResult = await this.client.query({
|
|
8468
|
-
query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE traceId = {var_traceId:String} AND spanId = {var_spanId:String}`,
|
|
8494
|
+
query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE traceId = {var_traceId:String} AND spanId = {var_spanId:String}${tenancy.sql}`,
|
|
8469
8495
|
query_params: {
|
|
8470
8496
|
var_traceId: traceId,
|
|
8471
|
-
var_spanId: spanId
|
|
8497
|
+
var_spanId: spanId,
|
|
8498
|
+
...tenancy.params
|
|
8472
8499
|
},
|
|
8473
8500
|
format: "JSONEachRow"
|
|
8474
8501
|
});
|
|
@@ -8495,12 +8522,13 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
|
|
|
8495
8522
|
const limitValue = perPageInput === false ? total : perPage;
|
|
8496
8523
|
const end = perPageInput === false ? total : start + perPage;
|
|
8497
8524
|
const result = await this.client.query({
|
|
8498
|
-
query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE traceId = {var_traceId:String} AND spanId = {var_spanId:String} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
|
|
8525
|
+
query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE traceId = {var_traceId:String} AND spanId = {var_spanId:String}${tenancy.sql} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
|
|
8499
8526
|
query_params: {
|
|
8500
8527
|
var_traceId: traceId,
|
|
8501
8528
|
var_spanId: spanId,
|
|
8502
8529
|
var_limit: limitValue,
|
|
8503
|
-
var_offset: start
|
|
8530
|
+
var_offset: start,
|
|
8531
|
+
...tenancy.params
|
|
8504
8532
|
},
|
|
8505
8533
|
format: "JSONEachRow",
|
|
8506
8534
|
clickhouse_settings: {
|