@mastra/pg 1.36.0-alpha.0 → 1.36.0-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/dist/index.js CHANGED
@@ -18314,6 +18314,11 @@ async function batchCreateFeedback(client, schema, args, partitioning) {
18314
18314
  const rows = [...new Map(args.feedbacks.map((feedback) => [feedback.feedbackId, feedback])).values()].map(feedbackRecordToRow);
18315
18315
  await insertRows(client, schema, TABLE_FEEDBACK_EVENTS, rows, partitioning, FEEDBACK_UPSERT_CLAUSE);
18316
18316
  }
18317
+ async function getFeedbackById(client, schema, feedbackId) {
18318
+ const row = await client.oneOrNone(`SELECT ${FEEDBACK_SELECT_COLUMNS} FROM ${qualifiedTable(schema, TABLE_FEEDBACK_EVENTS)}
18319
+ WHERE "feedbackId" = $1 ORDER BY "cursorId" DESC LIMIT 1`, [feedbackId]);
18320
+ return row ? rowToFeedbackRecord(row) : null;
18321
+ }
18317
18322
  async function updateFeedbackReviewStatus(client, schema, args) {
18318
18323
  const { feedbackId, reviewStatus } = parseUpdateFeedbackReviewStatusArgs(args);
18319
18324
  const row = await client.oneOrNone(`UPDATE ${qualifiedTable(schema, TABLE_FEEDBACK_EVENTS)}
@@ -22149,6 +22154,9 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
22149
22154
  async getScoreById(scoreId) {
22150
22155
  return this.#run("GET_SCORE_BY_ID", () => getScoreById(this.#readClient, this.#schema, scoreId), { scoreId });
22151
22156
  }
22157
+ async getFeedbackById(feedbackId) {
22158
+ return this.#run("GET_FEEDBACK_BY_ID", () => getFeedbackById(this.#readClient, this.#schema, feedbackId), { feedbackId });
22159
+ }
22152
22160
  async listFeedback(args) {
22153
22161
  return this.#run("LIST_FEEDBACK", () => listFeedback(this.#readClient, this.#schema, args));
22154
22162
  }
@@ -26989,18 +26997,9 @@ var WorkflowsPG = class WorkflowsPG extends WorkflowsStorage {
26989
26997
  }
26990
26998
  const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
26991
26999
  const v2WhereClause = v2Conditions.length > 0 ? `WHERE ${v2Conditions.join(" AND ")}` : "";
26992
- let total = 0;
26993
27000
  const usePagination = typeof perPage === "number" && typeof page === "number";
26994
- if (usePagination) {
26995
- const countResult = await this.#db.client.one(`SELECT (SELECT COUNT(*) FROM ${getTableName({
26996
- indexName: TABLE_WORKFLOW_SNAPSHOT,
26997
- schemaName: getSchemaName(this.#schema)
26998
- })} ${whereClause})
26999
- + (SELECT COUNT(*) FROM ${this.#runsTable()} ${v2WhereClause}) AS count`, values);
27000
- total = Number(countResult.count);
27001
- }
27002
27001
  const normalizedPerPage = usePagination ? normalizePerPage(perPage, Number.MAX_SAFE_INTEGER) : 0;
27003
- const offset = usePagination ? page * normalizedPerPage : void 0;
27002
+ const offset = usePagination ? page * normalizedPerPage : 0;
27004
27003
  let v1Snapshot = "snapshot";
27005
27004
  if (summary) {
27006
27005
  const snapshotJson = await this.#db.getColumnType(TABLE_WORKFLOW_SNAPSHOT, "snapshot") === "jsonb" ? "snapshot" : `regexp_replace(snapshot::text, '\\\\u(0000|[Dd][89A-Fa-f][0-9A-Fa-f]{2})', '', 'g')::jsonb`;
@@ -27020,6 +27019,18 @@ var WorkflowsPG = class WorkflowsPG extends WorkflowsStorage {
27020
27019
  ] : values;
27021
27020
  const result = await this.#db.client.manyOrNone(query, queryValues);
27022
27021
  const runs = await Promise.all((result || []).map((row) => this.#parseRun(this.#db.client, row)));
27022
+ let total = 0;
27023
+ if (usePagination) {
27024
+ total = offset + runs.length;
27025
+ if (runs.length === normalizedPerPage || runs.length === 0 && offset > 0) {
27026
+ const countResult = await this.#db.client.one(`SELECT (SELECT COUNT(*) FROM ${getTableName({
27027
+ indexName: TABLE_WORKFLOW_SNAPSHOT,
27028
+ schemaName: getSchemaName(this.#schema)
27029
+ })} ${whereClause})
27030
+ + (SELECT COUNT(*) FROM ${this.#runsTable()} ${v2WhereClause}) AS count`, values);
27031
+ total = Number(countResult.count);
27032
+ }
27033
+ }
27023
27034
  return {
27024
27035
  runs,
27025
27036
  total: total || runs.length