@mastra/oracledb 0.2.3 → 0.2.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/index.js CHANGED
@@ -6082,6 +6082,34 @@ async function batchCreateScores(db, _schemaName, args) {
6082
6082
  throw storageError("BATCH_CREATE_SCORES", "FAILED", { count: args.scores.length }, error, ErrorCategory.USER);
6083
6083
  }
6084
6084
  }
6085
+ /**
6086
+ * Delete scores by scoreId, optionally scoped to a tenant (`organizationId` /
6087
+ * `resourceId` are ANDed into the predicate so a scoped caller can never
6088
+ * delete another tenant's rows).
6089
+ */
6090
+ async function deleteScores(db, schemaName, args) {
6091
+ if (args.scoreIds.length === 0) return;
6092
+ const binds = {};
6093
+ const placeholders = args.scoreIds.map((scoreId, index) => {
6094
+ binds[`scoreId${index}`] = scoreId;
6095
+ return `:scoreId${index}`;
6096
+ });
6097
+ const conditions = [`${scoreQcol(void 0, "id")} IN (${placeholders.join(", ")})`];
6098
+ if (args.organizationId !== void 0) {
6099
+ binds.organizationId = args.organizationId;
6100
+ const organizationIdColumn = scoreQcol(void 0, "organizationId");
6101
+ conditions.push(`(${organizationIdColumn} = :organizationId OR (${organizationIdColumn} IS NULL AND JSON_VALUE(${scoreQcol(void 0, "metadata")}, '$.organizationId' RETURNING VARCHAR2(4000) NULL ON ERROR) = :organizationId))`);
6102
+ }
6103
+ if (args.resourceId !== void 0) {
6104
+ binds.resourceId = args.resourceId;
6105
+ conditions.push(`${scoreQcol(void 0, "resourceId")} = :resourceId`);
6106
+ }
6107
+ try {
6108
+ await db.none(`DELETE FROM ${qualifyName(TABLE_SCORERS, schemaName)} WHERE ${conditions.join(" AND ")}`, binds);
6109
+ } catch (error) {
6110
+ throw storageError("DELETE_SCORES", "FAILED", { count: args.scoreIds.length }, error, ErrorCategory.USER);
6111
+ }
6112
+ }
6085
6113
  async function getScoreById(db, schemaName, scoreId) {
6086
6114
  try {
6087
6115
  const row = await db.oneOrNone(`${scoreSelect("s")} FROM ${qualifyName(TABLE_SCORERS, schemaName)} s WHERE ${scoreQcol("s", "id")} = :scoreId`, { scoreId });
@@ -6121,7 +6149,7 @@ function transformObservabilityScoreRow(row) {
6121
6149
  rootEntityId: optionalString$1(metadata?.rootEntityId),
6122
6150
  rootEntityName: optionalString$1(metadata?.rootEntityName),
6123
6151
  userId: optionalString$1(metadata?.userId),
6124
- organizationId: optionalString$1(metadata?.organizationId),
6152
+ organizationId: optionalString$1(row.organizationId) ?? optionalString$1(metadata?.organizationId),
6125
6153
  resourceId: optionalString$1(row.resourceId),
6126
6154
  runId: optionalString$1(row.runId),
6127
6155
  sessionId: optionalString$1(metadata?.sessionId),
@@ -6209,6 +6237,7 @@ function scoreRecordToTableRecord(score) {
6209
6237
  entityId: score.entityId,
6210
6238
  source,
6211
6239
  resourceId: score.resourceId,
6240
+ organizationId: score.organizationId,
6212
6241
  threadId: score.threadId,
6213
6242
  createdAt: timestamp,
6214
6243
  updatedAt: timestamp
@@ -6731,6 +6760,9 @@ var ObservabilityOracle = class ObservabilityOracle extends ObservabilityStorage
6731
6760
  async batchCreateScores(args) {
6732
6761
  return batchCreateScores(this.db, this.schemaName, args);
6733
6762
  }
6763
+ async deleteScores(args) {
6764
+ return deleteScores(this.db, this.schemaName, args);
6765
+ }
6734
6766
  async getScoreById(scoreId) {
6735
6767
  return getScoreById(this.db, this.schemaName, scoreId);
6736
6768
  }