@mastra/duckdb 1.6.4-alpha.1 → 1.6.4
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 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/{observability-DKGgFpq7.js → observability-CT5eidI9.js} +55 -6
- package/dist/observability-CT5eidI9.js.map +1 -0
- package/dist/{observability-CRajwPel.cjs → observability-CYOty2wB.cjs} +54 -5
- package/dist/observability-CYOty2wB.cjs.map +1 -0
- package/dist/storage/domains/observability/ddl.d.ts +1 -1
- package/dist/storage/domains/observability/ddl.d.ts.map +1 -1
- package/dist/storage/domains/observability/feedback.d.ts +3 -1
- package/dist/storage/domains/observability/feedback.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +2 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/review-status.d.ts +5 -0
- package/dist/storage/domains/observability/review-status.d.ts.map +1 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/observability-CRajwPel.cjs.map +0 -1
- package/dist/observability-DKGgFpq7.js.map +0 -1
|
@@ -279,6 +279,9 @@ CREATE TABLE IF NOT EXISTS feedback_events (
|
|
|
279
279
|
feedbackUserId VARCHAR,
|
|
280
280
|
sourceId VARCHAR,
|
|
281
281
|
|
|
282
|
+
-- Review workflow
|
|
283
|
+
reviewStatus VARCHAR NOT NULL DEFAULT 'needs-review',
|
|
284
|
+
|
|
282
285
|
-- Feedback-specific scalars
|
|
283
286
|
source VARCHAR,
|
|
284
287
|
feedbackSource VARCHAR NOT NULL,
|
|
@@ -417,6 +420,7 @@ const ALL_MIGRATIONS = [
|
|
|
417
420
|
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS scope JSON`,
|
|
418
421
|
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS source VARCHAR`,
|
|
419
422
|
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS feedbackSource VARCHAR`,
|
|
423
|
+
`ALTER TABLE feedback_events ADD COLUMN IF NOT EXISTS reviewStatus VARCHAR DEFAULT 'needs-review'`,
|
|
420
424
|
`ALTER TABLE feedback_events ALTER COLUMN traceId DROP NOT NULL`
|
|
421
425
|
];
|
|
422
426
|
//#endregion
|
|
@@ -710,6 +714,31 @@ function extendWhereClause(baseClause, extraConditions) {
|
|
|
710
714
|
return `${baseClause} AND ${conditions.join(" AND ")}`;
|
|
711
715
|
}
|
|
712
716
|
//#endregion
|
|
717
|
+
//#region src/storage/domains/observability/review-status.ts
|
|
718
|
+
const FEEDBACK_REVIEW_STATUSES = ["needs-review", "reviewed"];
|
|
719
|
+
function isFeedbackReviewStatus(value) {
|
|
720
|
+
return FEEDBACK_REVIEW_STATUSES.some((status) => status === value);
|
|
721
|
+
}
|
|
722
|
+
/** Normalize a stored value to a review status, defaulting legacy/unknown values to `needs-review`. */
|
|
723
|
+
function coerceFeedbackReviewStatus(value) {
|
|
724
|
+
return isFeedbackReviewStatus(value) ? value : "needs-review";
|
|
725
|
+
}
|
|
726
|
+
function parseUpdateFeedbackReviewStatusArgs(args) {
|
|
727
|
+
const invalid = (text) => new _mastra_core_error.MastraError({
|
|
728
|
+
id: "OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_INVALID_ARGS",
|
|
729
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
730
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
731
|
+
text
|
|
732
|
+
});
|
|
733
|
+
if (typeof args !== "object" || args === null) throw invalid("args must be an object");
|
|
734
|
+
if (typeof args.feedbackId !== "string" || args.feedbackId.length === 0) throw invalid("feedbackId is required");
|
|
735
|
+
if (!isFeedbackReviewStatus(args.reviewStatus)) throw invalid(`reviewStatus must be one of: ${FEEDBACK_REVIEW_STATUSES.join(", ")}`);
|
|
736
|
+
return {
|
|
737
|
+
feedbackId: args.feedbackId,
|
|
738
|
+
reviewStatus: args.reviewStatus
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
//#endregion
|
|
713
742
|
//#region src/storage/domains/observability/feedback.ts
|
|
714
743
|
const FEEDBACK_GROUP_BY_COLUMNS = /* @__PURE__ */ new Set([
|
|
715
744
|
"timestamp",
|
|
@@ -811,7 +840,7 @@ function rowToFeedbackRecord(row) {
|
|
|
811
840
|
let value = rawValue;
|
|
812
841
|
const numValue = Number(rawValue);
|
|
813
842
|
if (!isNaN(numValue)) value = numValue;
|
|
814
|
-
return {
|
|
843
|
+
return _mastra_core_storage.feedbackRecordSchema.parse({
|
|
815
844
|
feedbackId: row.feedbackId,
|
|
816
845
|
timestamp: toDate(row.timestamp),
|
|
817
846
|
traceId: row.traceId ?? null,
|
|
@@ -841,6 +870,7 @@ function rowToFeedbackRecord(row) {
|
|
|
841
870
|
serviceName: row.serviceName ?? null,
|
|
842
871
|
feedbackUserId: row.feedbackUserId ?? null,
|
|
843
872
|
sourceId: row.sourceId ?? null,
|
|
873
|
+
reviewStatus: coerceFeedbackReviewStatus(row.reviewStatus),
|
|
844
874
|
source: row.feedbackSource,
|
|
845
875
|
feedbackSource: row.feedbackSource,
|
|
846
876
|
feedbackType: row.feedbackType,
|
|
@@ -849,7 +879,7 @@ function rowToFeedbackRecord(row) {
|
|
|
849
879
|
tags: parseJsonArray(row.tags),
|
|
850
880
|
metadata: parseJson(row.metadata),
|
|
851
881
|
scope: parseJson(row.scope)
|
|
852
|
-
};
|
|
882
|
+
});
|
|
853
883
|
}
|
|
854
884
|
function getComparisonDateRange$1(comparePeriod, timestamp) {
|
|
855
885
|
if (!timestamp.start || !timestamp.end) return null;
|
|
@@ -884,7 +914,7 @@ async function createFeedback(db, args) {
|
|
|
884
914
|
feedbackId, timestamp, cursorId, traceId, spanId, experimentId,
|
|
885
915
|
entityType, entityId, entityName, entityVersionId, parentEntityVersionId, parentEntityType, parentEntityId, parentEntityName, rootEntityVersionId, rootEntityType, rootEntityId, rootEntityName,
|
|
886
916
|
userId, organizationId, resourceId, runId, sessionId, threadId, requestId, environment, executionSource, serviceName,
|
|
887
|
-
feedbackUserId, sourceId, feedbackSource, feedbackType, value, comment, tags, metadata, scope
|
|
917
|
+
feedbackUserId, sourceId, reviewStatus, feedbackSource, feedbackType, value, comment, tags, metadata, scope
|
|
888
918
|
)
|
|
889
919
|
VALUES (${[
|
|
890
920
|
v(f.feedbackId),
|
|
@@ -917,6 +947,7 @@ async function createFeedback(db, args) {
|
|
|
917
947
|
v(f.serviceName ?? null),
|
|
918
948
|
v(feedbackUserId),
|
|
919
949
|
v(f.sourceId ?? null),
|
|
950
|
+
v(f.reviewStatus ?? "needs-review"),
|
|
920
951
|
v(feedbackSource),
|
|
921
952
|
v(f.feedbackType),
|
|
922
953
|
v(String(f.value)),
|
|
@@ -965,6 +996,7 @@ async function batchCreateFeedback(db, args) {
|
|
|
965
996
|
v(legacyFeedback.serviceName ?? null),
|
|
966
997
|
v(feedbackUserId),
|
|
967
998
|
v(legacyFeedback.sourceId ?? null),
|
|
999
|
+
v(legacyFeedback.reviewStatus ?? "needs-review"),
|
|
968
1000
|
v(feedbackSource),
|
|
969
1001
|
v(legacyFeedback.feedbackType),
|
|
970
1002
|
v(String(legacyFeedback.value)),
|
|
@@ -978,11 +1010,25 @@ async function batchCreateFeedback(db, args) {
|
|
|
978
1010
|
feedbackId, timestamp, cursorId, traceId, spanId, experimentId,
|
|
979
1011
|
entityType, entityId, entityName, entityVersionId, parentEntityVersionId, parentEntityType, parentEntityId, parentEntityName, rootEntityVersionId, rootEntityType, rootEntityId, rootEntityName,
|
|
980
1012
|
userId, organizationId, resourceId, runId, sessionId, threadId, requestId, environment, executionSource, serviceName,
|
|
981
|
-
feedbackUserId, sourceId, feedbackSource, feedbackType, value, comment, tags, metadata, scope
|
|
1013
|
+
feedbackUserId, sourceId, reviewStatus, feedbackSource, feedbackType, value, comment, tags, metadata, scope
|
|
982
1014
|
)
|
|
983
1015
|
VALUES ${tuples.join(",\n ")}
|
|
984
1016
|
ON CONFLICT DO NOTHING`);
|
|
985
1017
|
}
|
|
1018
|
+
/** Update the review workflow status of a single feedback event. */
|
|
1019
|
+
async function updateFeedbackReviewStatus(db, args) {
|
|
1020
|
+
const { feedbackId, reviewStatus } = parseUpdateFeedbackReviewStatusArgs(args);
|
|
1021
|
+
await db.execute(`UPDATE feedback_events SET reviewStatus = ? WHERE feedbackId = ?`, [reviewStatus, feedbackId]);
|
|
1022
|
+
const row = (await db.query(`SELECT * FROM feedback_events WHERE feedbackId = ? ORDER BY timestamp DESC LIMIT 1`, [feedbackId]))[0];
|
|
1023
|
+
if (!row) throw new _mastra_core_error.MastraError({
|
|
1024
|
+
id: "OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_NOT_FOUND",
|
|
1025
|
+
domain: _mastra_core_error.ErrorDomain.MASTRA_OBSERVABILITY,
|
|
1026
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
1027
|
+
text: "Feedback record not found",
|
|
1028
|
+
details: { feedbackId }
|
|
1029
|
+
});
|
|
1030
|
+
return rowToFeedbackRecord(row);
|
|
1031
|
+
}
|
|
986
1032
|
/** Query feedback events with filtering, ordering, and pagination. */
|
|
987
1033
|
async function listFeedback(db, args) {
|
|
988
1034
|
const { mode, filters, pagination, orderBy, after, limit } = _mastra_core_storage.listFeedbackArgsSchema.parse(args);
|
|
@@ -3793,6 +3839,9 @@ var ObservabilityStorageDuckDB = class extends _mastra_core_storage.Observabilit
|
|
|
3793
3839
|
async listFeedback(args) {
|
|
3794
3840
|
return listFeedback(this.db, args);
|
|
3795
3841
|
}
|
|
3842
|
+
async updateFeedbackReviewStatus(args) {
|
|
3843
|
+
return updateFeedbackReviewStatus(this.db, args);
|
|
3844
|
+
}
|
|
3796
3845
|
async getFeedbackAggregate(args) {
|
|
3797
3846
|
return getFeedbackAggregate(this.db, args);
|
|
3798
3847
|
}
|
|
@@ -3809,4 +3858,4 @@ var ObservabilityStorageDuckDB = class extends _mastra_core_storage.Observabilit
|
|
|
3809
3858
|
//#endregion
|
|
3810
3859
|
exports.ObservabilityStorageDuckDB = ObservabilityStorageDuckDB;
|
|
3811
3860
|
|
|
3812
|
-
//# sourceMappingURL=observability-
|
|
3861
|
+
//# sourceMappingURL=observability-CYOty2wB.cjs.map
|