@mastra/clickhouse 1.30.0-alpha.0 → 1.30.0-alpha.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/dist/docs/SKILL.md +1 -6
- package/dist/docs/assets/SOURCE_MAP.json +7 -7
- package/dist/index.cjs +34 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/observability/v-next/feedback.d.ts +2 -0
- package/dist/storage/domains/observability/v-next/feedback.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts +2 -1
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/docs/references/reference-storage-composite.md +0 -433
- package/dist/docs/references/reference-storage-retention.md +0 -310
package/dist/index.js
CHANGED
|
@@ -5070,7 +5070,7 @@ async function queryJson$2(client, query, params, settings = {}) {
|
|
|
5070
5070
|
}
|
|
5071
5071
|
})).json();
|
|
5072
5072
|
}
|
|
5073
|
-
async function feedbackRowsWithWriteVersions(client, feedbacks) {
|
|
5073
|
+
async function feedbackRowsWithWriteVersions(client, feedbacks, onConflict) {
|
|
5074
5074
|
const identifiedFeedback = feedbacks.map((feedback) => ({
|
|
5075
5075
|
...feedback,
|
|
5076
5076
|
feedbackId: feedback.feedbackId ?? ""
|
|
@@ -5081,23 +5081,29 @@ async function feedbackRowsWithWriteVersions(client, feedbacks) {
|
|
|
5081
5081
|
WHERE feedbackId IN ({feedbackIds:Array(String)})
|
|
5082
5082
|
GROUP BY feedbackId`, { feedbackIds });
|
|
5083
5083
|
const versions = new Map(existingVersions.map((row) => [row.feedbackId, BigInt(row.writeVersion)]));
|
|
5084
|
-
return identifiedFeedback.
|
|
5084
|
+
return identifiedFeedback.flatMap((feedback) => {
|
|
5085
|
+
if (onConflict === "ignore" && versions.has(feedback.feedbackId)) return [];
|
|
5085
5086
|
const writeVersion = (versions.get(feedback.feedbackId) ?? 0n) + 1n;
|
|
5086
5087
|
versions.set(feedback.feedbackId, writeVersion);
|
|
5087
|
-
return {
|
|
5088
|
+
return [{
|
|
5088
5089
|
...feedbackRecordToRow(feedback),
|
|
5089
5090
|
writeVersion: writeVersion.toString()
|
|
5090
|
-
};
|
|
5091
|
+
}];
|
|
5091
5092
|
});
|
|
5092
5093
|
}
|
|
5093
5094
|
async function createFeedback(client, args) {
|
|
5094
|
-
await batchCreateFeedback(client, {
|
|
5095
|
+
await batchCreateFeedback(client, {
|
|
5096
|
+
feedbacks: [args.feedback],
|
|
5097
|
+
onConflict: args.onConflict
|
|
5098
|
+
});
|
|
5095
5099
|
}
|
|
5096
5100
|
async function batchCreateFeedback(client, args) {
|
|
5097
5101
|
if (args.feedbacks.length === 0) return;
|
|
5102
|
+
const values = await feedbackRowsWithWriteVersions(client, args.feedbacks, args.onConflict);
|
|
5103
|
+
if (values.length === 0) return;
|
|
5098
5104
|
await client.insert({
|
|
5099
5105
|
table: TABLE_FEEDBACK_EVENTS,
|
|
5100
|
-
values
|
|
5106
|
+
values,
|
|
5101
5107
|
format: "JSONEachRow",
|
|
5102
5108
|
clickhouse_settings: CH_INSERT_SETTINGS
|
|
5103
5109
|
});
|
|
@@ -5178,6 +5184,13 @@ async function hasFeedbackDeletionRequest(client, feedbackId, organizationId, re
|
|
|
5178
5184
|
resourceId: resourceId ?? ""
|
|
5179
5185
|
}, FINAL_SKIP_INDEX_SETTINGS)).length > 0;
|
|
5180
5186
|
}
|
|
5187
|
+
/** Retrieves the latest feedback record with this ID, or null when missing. */
|
|
5188
|
+
async function getFeedbackById(client, feedbackId) {
|
|
5189
|
+
const rows = await queryJson$2(client, `SELECT * FROM ${TABLE_FEEDBACK_EVENTS} FINAL
|
|
5190
|
+
WHERE feedbackId = {feedbackId:String}
|
|
5191
|
+
ORDER BY writeVersion DESC, timestamp DESC LIMIT 1`, { feedbackId }, FINAL_SKIP_INDEX_SETTINGS);
|
|
5192
|
+
return rows[0] ? rowToFeedbackRecord(rows[0]) : null;
|
|
5193
|
+
}
|
|
5181
5194
|
/**
|
|
5182
5195
|
* Review updates insert a replacement row, so they need only `INSERT` and the
|
|
5183
5196
|
* insert materialized view publishes the delta cursor.
|
|
@@ -10468,6 +10481,7 @@ var ObservabilityStorageClickhouseVNext = class extends ObservabilityStorage {
|
|
|
10468
10481
|
"thread-query",
|
|
10469
10482
|
"trace-query-tenant-scope",
|
|
10470
10483
|
"feedback",
|
|
10484
|
+
"feedback-replacement",
|
|
10471
10485
|
"trace-query-context-ids",
|
|
10472
10486
|
...contextFieldFeatures,
|
|
10473
10487
|
...timingFeatures,
|
|
@@ -10496,6 +10510,7 @@ var ObservabilityStorageClickhouseVNext = class extends ObservabilityStorage {
|
|
|
10496
10510
|
"thread-query",
|
|
10497
10511
|
"trace-query-tenant-scope",
|
|
10498
10512
|
"feedback",
|
|
10513
|
+
"feedback-replacement",
|
|
10499
10514
|
"trace-query-context-ids",
|
|
10500
10515
|
...contextFieldFeatures,
|
|
10501
10516
|
...timingFeatures,
|
|
@@ -10843,6 +10858,19 @@ var ObservabilityStorageClickhouseVNext = class extends ObservabilityStorage {
|
|
|
10843
10858
|
}, error);
|
|
10844
10859
|
}
|
|
10845
10860
|
}
|
|
10861
|
+
async getFeedbackById(feedbackId) {
|
|
10862
|
+
try {
|
|
10863
|
+
return await getFeedbackById(this.#client, feedbackId);
|
|
10864
|
+
} catch (error) {
|
|
10865
|
+
if (error instanceof MastraError) throw error;
|
|
10866
|
+
throw new MastraError({
|
|
10867
|
+
id: createStorageErrorId("CLICKHOUSE", "GET_FEEDBACK_BY_ID", "FAILED"),
|
|
10868
|
+
domain: ErrorDomain.STORAGE,
|
|
10869
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
10870
|
+
details: { feedbackId }
|
|
10871
|
+
}, error);
|
|
10872
|
+
}
|
|
10873
|
+
}
|
|
10846
10874
|
async createFeedback(args) {
|
|
10847
10875
|
try {
|
|
10848
10876
|
await createFeedback(this.#client, args);
|