@mastra/pg 1.22.3-alpha.3 → 1.22.3

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/index.js CHANGED
@@ -14049,6 +14049,11 @@ const FEEDBACK_EVENT_COLUMNS = [
14049
14049
  type: "text",
14050
14050
  nullable: true
14051
14051
  },
14052
+ {
14053
+ name: "reviewStatus",
14054
+ type: "text",
14055
+ defaultSql: "'needs-review'"
14056
+ },
14052
14057
  ...COMMON_CONTEXT_COLUMNS,
14053
14058
  {
14054
14059
  name: "tags",
@@ -14489,6 +14494,10 @@ function additiveColumns(schema) {
14489
14494
  table: TABLE_SPAN_EVENTS,
14490
14495
  column: "isPending",
14491
14496
  ddl: `ALTER TABLE ${qualifiedTable(schema, TABLE_SPAN_EVENTS)} ADD COLUMN IF NOT EXISTS "isPending" boolean NOT NULL DEFAULT false`
14497
+ }, {
14498
+ table: TABLE_FEEDBACK_EVENTS,
14499
+ column: "reviewStatus",
14500
+ ddl: `ALTER TABLE ${qualifiedTable(schema, TABLE_FEEDBACK_EVENTS)} ADD COLUMN IF NOT EXISTS "reviewStatus" text NOT NULL DEFAULT 'needs-review'`
14492
14501
  }];
14493
14502
  }
14494
14503
  /** Existence probe for an additive column. Params: schema, table, column. */
@@ -14811,6 +14820,31 @@ function whereOrEmpty(acc) {
14811
14820
  return acc.conditions.length ? `WHERE ${acc.conditions.join(" AND ")}` : "";
14812
14821
  }
14813
14822
  //#endregion
14823
+ //#region src/storage/domains/observability/v-next/review-status.ts
14824
+ const FEEDBACK_REVIEW_STATUSES = ["needs-review", "reviewed"];
14825
+ function isFeedbackReviewStatus(value) {
14826
+ return FEEDBACK_REVIEW_STATUSES.some((status) => status === value);
14827
+ }
14828
+ /** Normalize a stored value to a review status, defaulting legacy/unknown values to `needs-review`. */
14829
+ function coerceFeedbackReviewStatus(value) {
14830
+ return isFeedbackReviewStatus(value) ? value : "needs-review";
14831
+ }
14832
+ function parseUpdateFeedbackReviewStatusArgs(args) {
14833
+ const invalid = (text) => new MastraError({
14834
+ id: "OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_INVALID_ARGS",
14835
+ domain: ErrorDomain.STORAGE,
14836
+ category: ErrorCategory.USER,
14837
+ text
14838
+ });
14839
+ if (typeof args !== "object" || args === null) throw invalid("args must be an object");
14840
+ if (typeof args.feedbackId !== "string" || args.feedbackId.length === 0) throw invalid("feedbackId is required");
14841
+ if (!isFeedbackReviewStatus(args.reviewStatus)) throw invalid(`reviewStatus must be one of: ${FEEDBACK_REVIEW_STATUSES.join(", ")}`);
14842
+ return {
14843
+ feedbackId: args.feedbackId,
14844
+ reviewStatus: args.reviewStatus
14845
+ };
14846
+ }
14847
+ //#endregion
14814
14848
  //#region src/storage/domains/observability/v-next/helpers.ts
14815
14849
  const PROMOTED_KEYS = /* @__PURE__ */ new Set([
14816
14850
  "experimentId",
@@ -15175,6 +15209,7 @@ function feedbackRecordToRow(feedback) {
15175
15209
  spanId: feedback.spanId ?? null,
15176
15210
  feedbackUserId: feedback.feedbackUserId ?? null,
15177
15211
  sourceId: feedback.sourceId ?? null,
15212
+ reviewStatus: feedback.reviewStatus ?? "needs-review",
15178
15213
  feedbackSource,
15179
15214
  feedbackType: feedback.feedbackType,
15180
15215
  valueString: typeof feedback.value === "string" ? feedback.value : null,
@@ -15196,6 +15231,7 @@ function rowToFeedbackRecord(row) {
15196
15231
  spanId: nullableString(row.spanId),
15197
15232
  feedbackUserId: nullableString(row.feedbackUserId),
15198
15233
  sourceId: nullableString(row.sourceId),
15234
+ reviewStatus: coerceFeedbackReviewStatus(row.reviewStatus),
15199
15235
  feedbackSource,
15200
15236
  feedbackType: row.feedbackType,
15201
15237
  value: hasNumber ? Number(row.valueNumber) : nullableString(row.valueString) ?? "",
@@ -15715,6 +15751,10 @@ function applyFeedbackFilters(acc, filters) {
15715
15751
  acc.conditions.push(`"feedbackUserId" = $${acc.next++}`);
15716
15752
  acc.params.push(filters.feedbackUserId);
15717
15753
  }
15754
+ if (filters?.reviewStatus) {
15755
+ acc.conditions.push(`"reviewStatus" = $${acc.next++}`);
15756
+ acc.params.push(filters.reviewStatus);
15757
+ }
15718
15758
  }
15719
15759
  /**
15720
15760
  * OLAP queries take an explicit feedbackType / feedbackSource pair as
@@ -15738,6 +15778,21 @@ async function batchCreateFeedback(client, schema, args) {
15738
15778
  const insert = buildInsert(schema, TABLE_FEEDBACK_EVENTS, args.feedbacks.map(feedbackRecordToRow));
15739
15779
  if (insert) await client.query(insert.text, insert.values);
15740
15780
  }
15781
+ async function updateFeedbackReviewStatus(client, schema, args) {
15782
+ const { feedbackId, reviewStatus } = parseUpdateFeedbackReviewStatusArgs(args);
15783
+ const row = await client.oneOrNone(`UPDATE ${qualifiedTable(schema, TABLE_FEEDBACK_EVENTS)}
15784
+ SET "reviewStatus" = $2
15785
+ WHERE "feedbackId" = $1
15786
+ RETURNING ${FEEDBACK_SELECT_COLUMNS}`, [feedbackId, reviewStatus]);
15787
+ if (!row) throw new MastraError({
15788
+ id: "OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_NOT_FOUND",
15789
+ domain: ErrorDomain.MASTRA_OBSERVABILITY,
15790
+ category: ErrorCategory.USER,
15791
+ text: "Feedback record not found",
15792
+ details: { feedbackId }
15793
+ });
15794
+ return rowToFeedbackRecord(row);
15795
+ }
15741
15796
  async function listFeedback(client, schema, args) {
15742
15797
  const { mode, filters, pagination, orderBy, after, limit } = listFeedbackArgsSchema.parse(args);
15743
15798
  const table = qualifiedTable(schema, TABLE_FEEDBACK_EVENTS);
@@ -17601,6 +17656,9 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
17601
17656
  async listFeedback(args) {
17602
17657
  return this.#run("LIST_FEEDBACK", () => listFeedback(this.#client, this.#schema, args));
17603
17658
  }
17659
+ async updateFeedbackReviewStatus(args) {
17660
+ return this.#run("UPDATE_FEEDBACK_REVIEW_STATUS", () => updateFeedbackReviewStatus(this.#client, this.#schema, args), { feedbackId: args.feedbackId });
17661
+ }
17604
17662
  async getMetricAggregate(args) {
17605
17663
  return this.#run("GET_METRIC_AGGREGATE", () => getMetricAggregate(this.#client, this.#schema, args));
17606
17664
  }