@mastra/spanner 1.10.0 → 1.10.1-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.
@@ -3,7 +3,7 @@ name: mastra-spanner
3
3
  description: Documentation for @mastra/spanner. Use when working with @mastra/spanner APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/spanner"
6
- version: "1.10.0"
6
+ version: "1.10.1-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.10.0",
2
+ "version": "1.10.1-alpha.1",
3
3
  "package": "@mastra/spanner",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -294,7 +294,7 @@ const storage = new MongoDBStore({
294
294
 
295
295
  ## Reclaiming disk
296
296
 
297
- `prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist and are reused by future writes, so the file stops growing: for most users this alone solves the unbounded-growth problem.
297
+ `prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist for reuse by future writes. Reusing these pages prevents unbounded file growth for most users.
298
298
 
299
299
  Handing that free space back to the OS is a separate concern that Mastra doesn't manage. If you specifically need to shrink the file, run the underlying database's compaction (for example `VACUUM` on self-hosted libSQL) yourself in a maintenance window. A full `VACUUM` locks the file and needs roughly twice the file size in free disk. On PostgreSQL, autovacuum reclaims dead tuples for reuse automatically. A manual `VACUUM FULL` is only needed if you must return disk to the OS.
300
300
 
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@ let _mastra_core_base = require("@mastra/core/base");
6
6
  let _mastra_core_utils = require("@mastra/core/utils");
7
7
  let _mastra_core_agent = require("@mastra/core/agent");
8
8
  let _mastra_core_evals = require("@mastra/core/evals");
9
- //#region src/storage/db/utils.ts
9
+ // src/storage/db/utils.ts
10
10
  /**
11
11
  * Quote a Spanner identifier with backticks. GoogleSQL uses backticks for
12
12
  * identifiers that may collide with reserved keywords.
@@ -58,8 +58,7 @@ function getColumnDef(table, column) {
58
58
  function isInOperator(value) {
59
59
  return typeof value === "object" && value !== null && "$in" in value && Array.isArray(value.$in);
60
60
  }
61
- //#endregion
62
- //#region src/storage/db/index.ts
61
+ // src/storage/db/index.ts
63
62
  /**
64
63
  * Resolves a SpannerDomainConfig into a concrete Database handle plus options.
65
64
  */
@@ -1142,8 +1141,7 @@ var SpannerDB = class extends _mastra_core_base.MastraBase {
1142
1141
  }
1143
1142
  }
1144
1143
  };
1145
- //#endregion
1146
- //#region src/storage/domains/utils.ts
1144
+ // src/storage/domains/utils.ts
1147
1145
  /**
1148
1146
  * Build storage filter entries for a date range, using the operator suffixes
1149
1147
  * understood by `SpannerDB.prepareWhereClause`.
@@ -1196,8 +1194,7 @@ function transformFromSpannerRow({ tableName, row }) {
1196
1194
  }
1197
1195
  return result;
1198
1196
  }
1199
- //#endregion
1200
- //#region src/storage/domains/agents/index.ts
1197
+ // src/storage/domains/agents/index.ts
1201
1198
  const VERSION_CONFIG_KEYS = [
1202
1199
  "name",
1203
1200
  "description",
@@ -1857,8 +1854,7 @@ var AgentsSpanner = class AgentsSpanner extends _mastra_core_storage.AgentsStora
1857
1854
  }
1858
1855
  }
1859
1856
  };
1860
- //#endregion
1861
- //#region src/storage/domains/background-tasks/index.ts
1857
+ // src/storage/domains/background-tasks/index.ts
1862
1858
  function buildStatusCondition(filter, params, startIdx) {
1863
1859
  if (filter.status === void 0) return { kind: "no-filter" };
1864
1860
  const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
@@ -2270,8 +2266,7 @@ var BackgroundTasksSpanner = class BackgroundTasksSpanner extends _mastra_core_s
2270
2266
  return Number(rows[0]?.count ?? 0);
2271
2267
  }
2272
2268
  };
2273
- //#endregion
2274
- //#region src/storage/domains/blobs/index.ts
2269
+ // src/storage/domains/blobs/index.ts
2275
2270
  /**
2276
2271
  * Content-addressable blob store backed by Spanner. Blobs are keyed by their
2277
2272
  * SHA-256 hash; duplicate puts are no-ops thanks to `INSERT OR IGNORE`.
@@ -2489,8 +2484,7 @@ var BlobsSpanner = class BlobsSpanner extends _mastra_core_storage.BlobStore {
2489
2484
  }
2490
2485
  }
2491
2486
  };
2492
- //#endregion
2493
- //#region src/storage/domains/channels/index.ts
2487
+ // src/storage/domains/channels/index.ts
2494
2488
  const INSTALLATIONS = _mastra_core_storage.TABLE_CHANNEL_INSTALLATIONS;
2495
2489
  const CONFIG = _mastra_core_storage.TABLE_CHANNEL_CONFIG;
2496
2490
  const WEBHOOK_INDEX = "mastra_channel_installations_webhookid_idx";
@@ -2834,8 +2828,7 @@ var ChannelsSpanner = class ChannelsSpanner extends _mastra_core_storage.Channel
2834
2828
  }
2835
2829
  }
2836
2830
  };
2837
- //#endregion
2838
- //#region src/storage/domains/datasets/index.ts
2831
+ // src/storage/domains/datasets/index.ts
2839
2832
  function toDate$1(value) {
2840
2833
  return value instanceof Date ? value : new Date(value);
2841
2834
  }
@@ -4185,8 +4178,7 @@ var DatasetsSpanner = class DatasetsSpanner extends _mastra_core_storage.Dataset
4185
4178
  }
4186
4179
  }
4187
4180
  };
4188
- //#endregion
4189
- //#region src/storage/domains/experiments/index.ts
4181
+ // src/storage/domains/experiments/index.ts
4190
4182
  function toDate(value) {
4191
4183
  return value instanceof Date ? value : new Date(value);
4192
4184
  }
@@ -5180,8 +5172,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends _mastra_core_storage.E
5180
5172
  }
5181
5173
  }
5182
5174
  };
5183
- //#endregion
5184
- //#region src/storage/domains/favorites/index.ts
5175
+ // src/storage/domains/favorites/index.ts
5185
5176
  /**
5186
5177
  * Maps a favorite entity type to the parent table whose denormalized
5187
5178
  * `favoriteCount` column the favorites domain keeps in sync.
@@ -5526,8 +5517,7 @@ var FavoritesSpanner = class FavoritesSpanner extends _mastra_core_storage.Favor
5526
5517
  } catch {}
5527
5518
  }
5528
5519
  };
5529
- //#endregion
5530
- //#region src/storage/domains/mcp-clients/index.ts
5520
+ // src/storage/domains/mcp-clients/index.ts
5531
5521
  /**
5532
5522
  * Spanner-backed storage for MCP-client definitions and their immutable versions.
5533
5523
  * Mirrors the thin-record + versions pattern used by agents/skills/prompt-blocks.
@@ -6111,8 +6101,7 @@ var MCPClientsSpanner = class MCPClientsSpanner extends _mastra_core_storage.MCP
6111
6101
  }
6112
6102
  }
6113
6103
  };
6114
- //#endregion
6115
- //#region src/storage/domains/mcp-servers/index.ts
6104
+ // src/storage/domains/mcp-servers/index.ts
6116
6105
  /**
6117
6106
  * Spanner-backed storage for MCP-server definitions and their immutable versions.
6118
6107
  * Mirrors the thin-record + versions pattern used by agents/skills/prompt-blocks.
@@ -6720,8 +6709,7 @@ var MCPServersSpanner = class MCPServersSpanner extends _mastra_core_storage.MCP
6720
6709
  }
6721
6710
  }
6722
6711
  };
6723
- //#endregion
6724
- //#region src/storage/db/run-fencing.ts
6712
+ // src/storage/db/run-fencing.ts
6725
6713
  /** Epoch milliseconds on the database clock, read when the statement runs. */
6726
6714
  const DB_NOW_MS = "UNIX_MILLIS(CURRENT_TIMESTAMP())";
6727
6715
  /**
@@ -6774,8 +6762,7 @@ function withRunFence(db, claimsTable, fence, operation, write) {
6774
6762
  return write(tx);
6775
6763
  });
6776
6764
  }
6777
- //#endregion
6778
- //#region src/storage/domains/memory/index.ts
6765
+ // src/storage/domains/memory/index.ts
6779
6766
  function buildSpannerMessageMetadataFilter(metadataFilter) {
6780
6767
  if (!metadataFilter) return {
6781
6768
  clauses: [],
@@ -8045,8 +8032,7 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
8045
8032
  }
8046
8033
  }
8047
8034
  };
8048
- //#endregion
8049
- //#region src/storage/domains/observability/metrics.ts
8035
+ // src/storage/domains/observability/metrics.ts
8050
8036
  /** Physical table name. Not exposed by `@mastra/core/storage` (no TABLE_METRICS
8051
8037
  * constant exists), so the Spanner adapter owns the name itself. Follows the
8052
8038
  * same `mastra_ai_*` convention as `TABLE_SPANS = 'mastra_ai_spans'`. */
@@ -9153,8 +9139,7 @@ async function clearMetrics(database) {
9153
9139
  }
9154
9140
  });
9155
9141
  }
9156
- //#endregion
9157
- //#region src/storage/domains/observability/index.ts
9142
+ // src/storage/domains/observability/index.ts
9158
9143
  function invalidTraceFilterKey(kind, key) {
9159
9144
  return new _mastra_core_error.MastraError({
9160
9145
  id: (0, _mastra_core_storage.createStorageErrorId)("SPANNER", "LIST_TRACES", "VALIDATE_FAILED"),
@@ -9770,8 +9755,7 @@ var ObservabilitySpanner = class ObservabilitySpanner extends _mastra_core_stora
9770
9755
  return getMetricLabelValues(this.database, args, this.readOptions());
9771
9756
  }
9772
9757
  };
9773
- //#endregion
9774
- //#region src/storage/domains/prompt-blocks/index.ts
9758
+ // src/storage/domains/prompt-blocks/index.ts
9775
9759
  /**
9776
9760
  * Spanner-backed storage for prompt blocks and their immutable versions.
9777
9761
  * Mirrors the thin-record + versions pattern used by agents/skills/scorer-definitions.
@@ -10362,8 +10346,7 @@ var PromptBlocksSpanner = class PromptBlocksSpanner extends _mastra_core_storage
10362
10346
  }
10363
10347
  }
10364
10348
  };
10365
- //#endregion
10366
- //#region src/storage/domains/schedules/index.ts
10349
+ // src/storage/domains/schedules/index.ts
10367
10350
  function rowToSchedule(row) {
10368
10351
  const transformed = transformFromSpannerRow({
10369
10352
  tableName: _mastra_core_storage.TABLE_SCHEDULES,
@@ -10861,8 +10844,7 @@ var SchedulesSpanner = class SchedulesSpanner extends _mastra_core_storage.Sched
10861
10844
  }
10862
10845
  }
10863
10846
  };
10864
- //#endregion
10865
- //#region src/storage/domains/scorer-definitions/index.ts
10847
+ // src/storage/domains/scorer-definitions/index.ts
10866
10848
  /**
10867
10849
  * Spanner-backed storage for scorer definitions and their immutable versions.
10868
10850
  * Mirrors the thin-record + versions pattern used by agents/skills/prompt-blocks.
@@ -11461,8 +11443,7 @@ var ScorerDefinitionsSpanner = class ScorerDefinitionsSpanner extends _mastra_co
11461
11443
  }
11462
11444
  }
11463
11445
  };
11464
- //#endregion
11465
- //#region src/storage/domains/scores/index.ts
11446
+ // src/storage/domains/scores/index.ts
11466
11447
  function transformScoreRow(row) {
11467
11448
  const normalized = transformFromSpannerRow({
11468
11449
  tableName: _mastra_core_storage.TABLE_SCORERS,
@@ -11744,8 +11725,7 @@ var ScoresSpanner = class ScoresSpanner extends _mastra_core_storage.ScoresStora
11744
11725
  }
11745
11726
  }
11746
11727
  };
11747
- //#endregion
11748
- //#region src/storage/domains/skills/index.ts
11728
+ // src/storage/domains/skills/index.ts
11749
11729
  /**
11750
11730
  * Spanner-backed storage for skills and their immutable versions.
11751
11731
  * Mirrors the thin-record + versions pattern used by agents/prompt-blocks/scorer-definitions.
@@ -12369,8 +12349,7 @@ var SkillsSpanner = class SkillsSpanner extends _mastra_core_storage.SkillsStora
12369
12349
  }
12370
12350
  }
12371
12351
  };
12372
- //#endregion
12373
- //#region src/storage/domains/workflow-definitions/index.ts
12352
+ // src/storage/domains/workflow-definitions/index.ts
12374
12353
  function rowToDefinition(row) {
12375
12354
  const parsed = transformFromSpannerRow({
12376
12355
  tableName: _mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS,
@@ -12540,8 +12519,7 @@ var WorkflowDefinitionsSpanner = class WorkflowDefinitionsSpanner extends _mastr
12540
12519
  });
12541
12520
  }
12542
12521
  };
12543
- //#endregion
12544
- //#region src/storage/domains/workflows/index.ts
12522
+ // src/storage/domains/workflows/index.ts
12545
12523
  const RUN_OWNERS_TABLE = quoteIdent(_mastra_core_storage.TABLE_WORKFLOW_RUN_OWNERS, "table name");
12546
12524
  const RUN_ID = quoteIdent("runId", "column name");
12547
12525
  const OWNER_ID = quoteIdent("ownerId", "column name");
@@ -13247,8 +13225,7 @@ var WorkflowsSpanner = class WorkflowsSpanner extends _mastra_core_storage.Workf
13247
13225
  }
13248
13226
  }
13249
13227
  };
13250
- //#endregion
13251
- //#region src/storage/domains/workspaces/index.ts
13228
+ // src/storage/domains/workspaces/index.ts
13252
13229
  /** Snapshot config fields that live exclusively on version rows. */
13253
13230
  const SNAPSHOT_FIELDS = [
13254
13231
  "name",
@@ -13877,8 +13854,7 @@ var WorkspacesSpanner = class WorkspacesSpanner extends _mastra_core_storage.Wor
13877
13854
  }
13878
13855
  }
13879
13856
  };
13880
- //#endregion
13881
- //#region src/storage/index.ts
13857
+ // src/storage/index.ts
13882
13858
  /** Domain keys this adapter implements; the only valid values for `enabledDomains`. */
13883
13859
  const SPANNER_DOMAIN_KEYS = [
13884
13860
  "scores",
@@ -14069,15 +14045,10 @@ var SpannerStore = class extends _mastra_core_storage.MastraCompositeStore {
14069
14045
  */
14070
14046
  async close() {
14071
14047
  if (!this.ownsClient) return;
14072
- try {
14073
- await this.database.close();
14074
- if (this.spanner) this.spanner.close();
14075
- } catch (error) {
14076
- throw error;
14077
- }
14048
+ await this.database.close();
14049
+ if (this.spanner) this.spanner.close();
14078
14050
  }
14079
14051
  };
14080
- //#endregion
14081
14052
  exports.AgentsSpanner = AgentsSpanner;
14082
14053
  exports.BackgroundTasksSpanner = BackgroundTasksSpanner;
14083
14054
  exports.BlobsSpanner = BlobsSpanner;