@mastra/spanner 1.8.0-alpha.0 → 1.8.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
@@ -1,6 +1,6 @@
1
1
  import { Spanner } from "@google-cloud/spanner";
2
2
  import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
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, resolveRetentionTargets, retentionCutoffMs, toTraceSpans, transformScoreRow, validateStorageMetadataFilter } from "@mastra/core/storage";
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
6
  import { randomUUID } from "crypto";
@@ -3173,6 +3173,14 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3173
3173
  }
3174
3174
  }
3175
3175
  async listDatasets(args) {
3176
+ const orderBy = resolveListOrderBy(args.orderBy, [
3177
+ "createdAt",
3178
+ "updatedAt",
3179
+ "name"
3180
+ ], {
3181
+ field: "createdAt",
3182
+ direction: "DESC"
3183
+ });
3176
3184
  const { page = 0, perPage: perPageInput } = args.pagination;
3177
3185
  const perPage = normalizePerPage(perPageInput, 100);
3178
3186
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
@@ -3232,7 +3240,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3232
3240
  const limit = perPageInput === false ? total : perPage;
3233
3241
  const [rows] = await this.database.run({
3234
3242
  sql: `SELECT * FROM ${tableName} ${whereClause}
3235
- ORDER BY ${quoteIdent("createdAt", "column name")} DESC, ${quoteIdent("id", "column name")} ASC
3243
+ ORDER BY ${quoteIdent(orderBy.field, "column name")} ${orderBy.direction}, ${quoteIdent("id", "column name")} ASC
3236
3244
  LIMIT @limit OFFSET @offset`,
3237
3245
  params: {
3238
3246
  ...filterParams,
@@ -3670,6 +3678,10 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3670
3678
  }
3671
3679
  }
3672
3680
  async listItems(args) {
3681
+ const orderBy = resolveListOrderBy(args.orderBy, ["createdAt", "updatedAt"], {
3682
+ field: "createdAt",
3683
+ direction: "DESC"
3684
+ });
3673
3685
  const { page = 0, perPage: perPageInput } = args.pagination;
3674
3686
  const perPage = normalizePerPage(perPageInput, 100);
3675
3687
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
@@ -3717,7 +3729,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
3717
3729
  const limit = perPageInput === false ? total : perPage;
3718
3730
  const [rows] = await this.database.run({
3719
3731
  sql: `SELECT * FROM ${tableName} ${whereSql}
3720
- ORDER BY ${quoteIdent("createdAt", "column name")} DESC, ${quoteIdent("id", "column name")} ASC
3732
+ ORDER BY ${quoteIdent(orderBy.field, "column name")} ${orderBy.direction}, ${quoteIdent("id", "column name")} ASC
3721
3733
  LIMIT @limit OFFSET @offset`,
3722
3734
  params: {
3723
3735
  ...params,
@@ -4450,6 +4462,10 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
4450
4462
  }
4451
4463
  }
4452
4464
  async listExperiments(args) {
4465
+ const orderBy = resolveListOrderBy(args.orderBy, ["createdAt", "status"], {
4466
+ field: "createdAt",
4467
+ direction: "DESC"
4468
+ });
4453
4469
  const { page = 0, perPage: perPageInput } = args.pagination;
4454
4470
  const perPage = normalizePerPage(perPageInput, 100);
4455
4471
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
@@ -4523,7 +4539,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
4523
4539
  const limit = perPageInput === false ? total : perPage;
4524
4540
  const [rows] = await this.database.run({
4525
4541
  sql: `SELECT * FROM ${tableName} ${whereSql}
4526
- ORDER BY ${quoteIdent("createdAt", "column name")} DESC
4542
+ ORDER BY ${quoteIdent(orderBy.field, "column name")} ${orderBy.direction}, ${quoteIdent("id", "column name")} ASC
4527
4543
  LIMIT @limit OFFSET @offset`,
4528
4544
  params: {
4529
4545
  ...params,
@@ -4911,6 +4927,10 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
4911
4927
  }
4912
4928
  }
4913
4929
  async listExperimentResults(args) {
4930
+ const orderBy = resolveListOrderBy(args.orderBy, ["startedAt", "createdAt"], {
4931
+ field: "startedAt",
4932
+ direction: "ASC"
4933
+ });
4914
4934
  const { page = 0, perPage: perPageInput } = args.pagination;
4915
4935
  const perPage = normalizePerPage(perPageInput, 100);
4916
4936
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
@@ -4962,7 +4982,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
4962
4982
  const limit = perPageInput === false ? total : perPage;
4963
4983
  const [rows] = await this.database.run({
4964
4984
  sql: `SELECT * FROM ${tableName} ${whereSql}
4965
- ORDER BY ${quoteIdent("startedAt", "column name")} ASC
4985
+ ORDER BY ${quoteIdent(orderBy.field, "column name")} ${orderBy.direction}, ${quoteIdent("id", "column name")} ASC
4966
4986
  LIMIT @limit OFFSET @offset`,
4967
4987
  params: {
4968
4988
  ...params,