@mastra/spanner 1.9.0-alpha.0 → 1.9.1-alpha.0

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
@@ -3,7 +3,6 @@ import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
3
3
  import { AGENTS_SCHEMA, AGENT_VERSIONS_SCHEMA, AgentsStorage, BackgroundTasksStorage, BlobStore, ChannelsStorage, DatasetsStorage, ExperimentsStorage, FavoritesStorage, MCPClientsStorage, MCPServersStorage, MCP_CLIENTS_SCHEMA, MCP_CLIENT_VERSIONS_SCHEMA, MCP_SERVERS_SCHEMA, MCP_SERVER_VERSIONS_SCHEMA, METRIC_DISTINCT_COLUMNS, MastraCompositeStore, MemoryStorage, ObservabilityStorage, PROMPT_BLOCKS_SCHEMA, PROMPT_BLOCK_VERSIONS_SCHEMA, PromptBlocksStorage, SCORER_DEFINITIONS_SCHEMA, SCORER_DEFINITION_VERSIONS_SCHEMA, SKILLS_SCHEMA, SKILL_BLOBS_SCHEMA, SKILL_VERSIONS_SCHEMA, SchedulesStorage, ScorerDefinitionsStorage, ScoresStorage, SkillsStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_BACKGROUND_TASKS, TABLE_CHANNEL_CONFIG, TABLE_CHANNEL_INSTALLATIONS, TABLE_CONFIGS, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, TABLE_FAVORITES, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, TABLE_MESSAGES, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCHEMAS, TABLE_SCORERS, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, TABLE_SKILLS, TABLE_SKILL_BLOBS, TABLE_SKILL_VERSIONS, TABLE_SPANS, TABLE_THREADS, TABLE_WORKFLOW_DEFINITIONS, TABLE_WORKFLOW_SNAPSHOT, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, TraceStatus, WORKFLOW_DEFINITIONS_SCHEMA, WORKSPACES_SCHEMA, WORKSPACE_VERSIONS_SCHEMA, WorkflowDefinitionsStorage, WorkflowsStorage, WorkspacesStorage, calculatePagination, createStorageErrorId, executeRetentionPrune, getDefaultValue, hasErrorCode, listMetricsArgsSchema, listTracesArgsSchema, matchesExpectedWorkflowStatus, normalizePerPage, normalizeScheduleTarget, resolveListOrderBy, resolveRetentionTargets, retentionCutoffMs, toTraceSpans, transformScoreRow, validateStorageMetadataFilter } from "@mastra/core/storage";
4
4
  import { MastraBase } from "@mastra/core/base";
5
5
  import { parseSqlIdentifier } from "@mastra/core/utils";
6
- import { randomUUID } from "crypto";
7
6
  import { MessageList } from "@mastra/core/agent";
8
7
  import { saveScorePayloadSchema } from "@mastra/core/evals";
9
8
  //#region src/storage/db/utils.ts
@@ -3003,7 +3002,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3003
3002
  async createDataset(input) {
3004
3003
  try {
3005
3004
  const now = /* @__PURE__ */ new Date();
3006
- const id = input.id ?? randomUUID();
3005
+ const id = input.id ?? globalThis.crypto.randomUUID();
3007
3006
  if (input.id !== void 0) this.validateCallerDefinedDatasetId(input.id);
3008
3007
  const record = {
3009
3008
  id,
@@ -3351,7 +3350,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3351
3350
  await this.db.insert({
3352
3351
  tableName: TABLE_DATASET_VERSIONS,
3353
3352
  record: {
3354
- id: randomUUID(),
3353
+ id: globalThis.crypto.randomUUID(),
3355
3354
  datasetId,
3356
3355
  version,
3357
3356
  createdAt: now
@@ -3389,7 +3388,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3389
3388
  async _doAddItem(args) {
3390
3389
  try {
3391
3390
  const now = /* @__PURE__ */ new Date();
3392
- const itemId = randomUUID();
3391
+ const itemId = globalThis.crypto.randomUUID();
3393
3392
  let created = null;
3394
3393
  await this.db.runWithAbortRetry(() => this.database.runTransactionAsync(async (tx) => {
3395
3394
  try {
@@ -3883,7 +3882,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3883
3882
  async createDatasetVersion(datasetId, version) {
3884
3883
  try {
3885
3884
  const now = /* @__PURE__ */ new Date();
3886
- const id = randomUUID();
3885
+ const id = globalThis.crypto.randomUUID();
3887
3886
  await this.db.insert({
3888
3887
  tableName: TABLE_DATASET_VERSIONS,
3889
3888
  record: {
@@ -3997,7 +3996,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3997
3996
  });
3998
3997
  historyRows = rows.map(rowToItemRow);
3999
3998
  }
4000
- const plan = this.planDatasetItemBatch(input.items, historyRows, randomUUID);
3999
+ const plan = this.planDatasetItemBatch(input.items, historyRows, () => globalThis.crypto.randomUUID());
4001
4000
  const resolved = new Map([...plan.existingCurrentItems].map(([id, row]) => [id, this.datasetItemFromRow(row)]));
4002
4001
  if (plan.inserts.length > 0) {
4003
4002
  const now = /* @__PURE__ */ new Date();
@@ -4354,7 +4353,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
4354
4353
  async createExperiment(input) {
4355
4354
  try {
4356
4355
  const now = /* @__PURE__ */ new Date();
4357
- const id = input.id ?? randomUUID();
4356
+ const id = input.id ?? globalThis.crypto.randomUUID();
4358
4357
  const experiment = {
4359
4358
  id,
4360
4359
  name: input.name ?? void 0,
@@ -4672,7 +4671,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
4672
4671
  async addExperimentResult(input) {
4673
4672
  try {
4674
4673
  const now = /* @__PURE__ */ new Date();
4675
- const id = input.id ?? randomUUID();
4674
+ const id = input.id ?? globalThis.crypto.randomUUID();
4676
4675
  return await this.#withPurgeBarrier(input.experimentId, input.itemId, async (tx, marker) => {
4677
4676
  const result = {
4678
4677
  id,
@@ -4799,7 +4798,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
4799
4798
  };
4800
4799
  if (!existingRow) {
4801
4800
  const result = {
4802
- id: randomUUID(),
4801
+ id: globalThis.crypto.randomUUID(),
4803
4802
  experimentId: input.experimentId,
4804
4803
  itemId: input.itemId,
4805
4804
  ...values,
@@ -8375,7 +8374,7 @@ async function batchCreateMetrics(database, args) {
8375
8374
  const now = /* @__PURE__ */ new Date();
8376
8375
  const encodeJson = (v) => v == null ? null : JSON.stringify(v);
8377
8376
  const rows = args.metrics.map((m) => ({
8378
- metricId: m.metricId ?? randomUUID(),
8377
+ metricId: m.metricId ?? globalThis.crypto.randomUUID(),
8379
8378
  timestamp: m.timestamp instanceof Date ? m.timestamp : new Date(m.timestamp),
8380
8379
  name: m.name,
8381
8380
  value: Spanner.float(Number(m.value)),
@@ -10542,7 +10541,7 @@ var SchedulesSpanner = class SchedulesSpanner extends SchedulesStorage {
10542
10541
  await this.db.insert({
10543
10542
  tableName: TABLE_SCHEDULE_TRIGGERS,
10544
10543
  record: {
10545
- id: trigger.id ?? randomUUID(),
10544
+ id: trigger.id ?? globalThis.crypto.randomUUID(),
10546
10545
  schedule_id: trigger.scheduleId,
10547
10546
  run_id: trigger.runId ?? null,
10548
10547
  scheduled_fire_at: trigger.scheduledFireAt,
@@ -11328,7 +11327,7 @@ var ScoresSpanner = class ScoresSpanner extends ScoresStorage {
11328
11327
  }
11329
11328
  try {
11330
11329
  const suppliedId = validatedScore.id;
11331
- const scoreId = suppliedId ?? randomUUID();
11330
+ const scoreId = suppliedId ?? globalThis.crypto.randomUUID();
11332
11331
  const now = /* @__PURE__ */ new Date();
11333
11332
  const { id: _suppliedId, scorer, preprocessStepResult, analyzeStepResult, metadata, input, output, additionalContext, requestContext, entity, ...rest } = validatedScore;
11334
11333
  const insertedRecord = {