@mastra/mongodb 1.0.0-beta.4 → 1.0.0-beta.6

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
@@ -11,7 +11,7 @@ import { saveScorePayloadSchema } from '@mastra/core/evals';
11
11
 
12
12
  // package.json
13
13
  var package_default = {
14
- version: "1.0.0-beta.4"};
14
+ version: "1.0.0-beta.6"};
15
15
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
16
16
  getSupportedOperators() {
17
17
  return {
@@ -1937,14 +1937,21 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
1937
1937
  {
1938
1938
  id: createStorageErrorId("MONGODB", "SAVE_SCORE", "VALIDATION_FAILED"),
1939
1939
  domain: ErrorDomain.STORAGE,
1940
- category: ErrorCategory.THIRD_PARTY
1940
+ category: ErrorCategory.USER,
1941
+ details: {
1942
+ scorer: score.scorer?.id ?? "unknown",
1943
+ entityId: score.entityId ?? "unknown",
1944
+ entityType: score.entityType ?? "unknown",
1945
+ traceId: score.traceId ?? "",
1946
+ spanId: score.spanId ?? ""
1947
+ }
1941
1948
  },
1942
1949
  error
1943
1950
  );
1944
1951
  }
1945
1952
  try {
1946
1953
  const now = /* @__PURE__ */ new Date();
1947
- const scoreId = `score-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
1954
+ const scoreId = crypto.randomUUID();
1948
1955
  const scorer = typeof validatedScore.scorer === "string" ? safelyParseJSON(validatedScore.scorer) : validatedScore.scorer;
1949
1956
  const preprocessStepResult = typeof validatedScore.preprocessStepResult === "string" ? safelyParseJSON(validatedScore.preprocessStepResult) : validatedScore.preprocessStepResult;
1950
1957
  const analyzeStepResult = typeof validatedScore.analyzeStepResult === "string" ? safelyParseJSON(validatedScore.analyzeStepResult) : validatedScore.analyzeStepResult;
@@ -1956,6 +1963,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
1956
1963
  const updatedAt = now;
1957
1964
  const dataToSave = {
1958
1965
  ...validatedScore,
1966
+ id: scoreId,
1959
1967
  scorer,
1960
1968
  preprocessStepResult,
1961
1969
  analyzeStepResult,
@@ -1968,13 +1976,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
1968
1976
  };
1969
1977
  const collection = await this.operations.getCollection(TABLE_SCORERS);
1970
1978
  await collection.insertOne(dataToSave);
1971
- const savedScore = {
1972
- ...score,
1973
- id: scoreId,
1974
- createdAt: now,
1975
- updatedAt: now
1976
- };
1977
- return { score: savedScore };
1979
+ return { score: dataToSave };
1978
1980
  } catch (error) {
1979
1981
  throw new MastraError(
1980
1982
  {
@@ -2376,6 +2378,22 @@ var WorkflowsStorageMongoDB = class extends WorkflowsStorage {
2376
2378
  );
2377
2379
  }
2378
2380
  }
2381
+ async deleteWorkflowRunById({ runId, workflowName }) {
2382
+ try {
2383
+ const collection = await this.operations.getCollection(TABLE_WORKFLOW_SNAPSHOT);
2384
+ await collection.deleteOne({ workflow_name: workflowName, run_id: runId });
2385
+ } catch (error) {
2386
+ throw new MastraError(
2387
+ {
2388
+ id: createStorageErrorId("MONGODB", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
2389
+ domain: ErrorDomain.STORAGE,
2390
+ category: ErrorCategory.THIRD_PARTY,
2391
+ details: { runId, workflowName }
2392
+ },
2393
+ error
2394
+ );
2395
+ }
2396
+ }
2379
2397
  parseWorkflowRun(row) {
2380
2398
  let parsedSnapshot = row.snapshot;
2381
2399
  if (typeof parsedSnapshot === "string") {
@@ -2560,6 +2578,9 @@ var MongoDBStore = class extends MastraStorage {
2560
2578
  }) {
2561
2579
  return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
2562
2580
  }
2581
+ async deleteWorkflowRunById({ runId, workflowName }) {
2582
+ return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
2583
+ }
2563
2584
  async close() {
2564
2585
  try {
2565
2586
  await this.#connector.close();