@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.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +27 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -56
- package/dist/index.js.map +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { MastraBase } from "@mastra/core/base";
|
|
|
5
5
|
import { parseSqlIdentifier } from "@mastra/core/utils";
|
|
6
6
|
import { MessageList } from "@mastra/core/agent";
|
|
7
7
|
import { saveScorePayloadSchema } from "@mastra/core/evals";
|
|
8
|
-
|
|
8
|
+
// src/storage/db/utils.ts
|
|
9
9
|
/**
|
|
10
10
|
* Quote a Spanner identifier with backticks. GoogleSQL uses backticks for
|
|
11
11
|
* identifiers that may collide with reserved keywords.
|
|
@@ -57,8 +57,7 @@ function getColumnDef(table, column) {
|
|
|
57
57
|
function isInOperator(value) {
|
|
58
58
|
return typeof value === "object" && value !== null && "$in" in value && Array.isArray(value.$in);
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
//#region src/storage/db/index.ts
|
|
60
|
+
// src/storage/db/index.ts
|
|
62
61
|
/**
|
|
63
62
|
* Resolves a SpannerDomainConfig into a concrete Database handle plus options.
|
|
64
63
|
*/
|
|
@@ -1141,8 +1140,7 @@ var SpannerDB = class extends MastraBase {
|
|
|
1141
1140
|
}
|
|
1142
1141
|
}
|
|
1143
1142
|
};
|
|
1144
|
-
|
|
1145
|
-
//#region src/storage/domains/utils.ts
|
|
1143
|
+
// src/storage/domains/utils.ts
|
|
1146
1144
|
/**
|
|
1147
1145
|
* Build storage filter entries for a date range, using the operator suffixes
|
|
1148
1146
|
* understood by `SpannerDB.prepareWhereClause`.
|
|
@@ -1195,8 +1193,7 @@ function transformFromSpannerRow({ tableName, row }) {
|
|
|
1195
1193
|
}
|
|
1196
1194
|
return result;
|
|
1197
1195
|
}
|
|
1198
|
-
|
|
1199
|
-
//#region src/storage/domains/agents/index.ts
|
|
1196
|
+
// src/storage/domains/agents/index.ts
|
|
1200
1197
|
const VERSION_CONFIG_KEYS = [
|
|
1201
1198
|
"name",
|
|
1202
1199
|
"description",
|
|
@@ -1856,8 +1853,7 @@ var AgentsSpanner = class AgentsSpanner extends AgentsStorage {
|
|
|
1856
1853
|
}
|
|
1857
1854
|
}
|
|
1858
1855
|
};
|
|
1859
|
-
|
|
1860
|
-
//#region src/storage/domains/background-tasks/index.ts
|
|
1856
|
+
// src/storage/domains/background-tasks/index.ts
|
|
1861
1857
|
function buildStatusCondition(filter, params, startIdx) {
|
|
1862
1858
|
if (filter.status === void 0) return { kind: "no-filter" };
|
|
1863
1859
|
const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
@@ -2269,8 +2265,7 @@ var BackgroundTasksSpanner = class BackgroundTasksSpanner extends BackgroundTask
|
|
|
2269
2265
|
return Number(rows[0]?.count ?? 0);
|
|
2270
2266
|
}
|
|
2271
2267
|
};
|
|
2272
|
-
|
|
2273
|
-
//#region src/storage/domains/blobs/index.ts
|
|
2268
|
+
// src/storage/domains/blobs/index.ts
|
|
2274
2269
|
/**
|
|
2275
2270
|
* Content-addressable blob store backed by Spanner. Blobs are keyed by their
|
|
2276
2271
|
* SHA-256 hash; duplicate puts are no-ops thanks to `INSERT OR IGNORE`.
|
|
@@ -2488,8 +2483,7 @@ var BlobsSpanner = class BlobsSpanner extends BlobStore {
|
|
|
2488
2483
|
}
|
|
2489
2484
|
}
|
|
2490
2485
|
};
|
|
2491
|
-
|
|
2492
|
-
//#region src/storage/domains/channels/index.ts
|
|
2486
|
+
// src/storage/domains/channels/index.ts
|
|
2493
2487
|
const INSTALLATIONS = TABLE_CHANNEL_INSTALLATIONS;
|
|
2494
2488
|
const CONFIG = TABLE_CHANNEL_CONFIG;
|
|
2495
2489
|
const WEBHOOK_INDEX = "mastra_channel_installations_webhookid_idx";
|
|
@@ -2833,8 +2827,7 @@ var ChannelsSpanner = class ChannelsSpanner extends ChannelsStorage {
|
|
|
2833
2827
|
}
|
|
2834
2828
|
}
|
|
2835
2829
|
};
|
|
2836
|
-
|
|
2837
|
-
//#region src/storage/domains/datasets/index.ts
|
|
2830
|
+
// src/storage/domains/datasets/index.ts
|
|
2838
2831
|
function toDate$1(value) {
|
|
2839
2832
|
return value instanceof Date ? value : new Date(value);
|
|
2840
2833
|
}
|
|
@@ -4184,8 +4177,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
4184
4177
|
}
|
|
4185
4178
|
}
|
|
4186
4179
|
};
|
|
4187
|
-
|
|
4188
|
-
//#region src/storage/domains/experiments/index.ts
|
|
4180
|
+
// src/storage/domains/experiments/index.ts
|
|
4189
4181
|
function toDate(value) {
|
|
4190
4182
|
return value instanceof Date ? value : new Date(value);
|
|
4191
4183
|
}
|
|
@@ -5179,8 +5171,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
|
|
|
5179
5171
|
}
|
|
5180
5172
|
}
|
|
5181
5173
|
};
|
|
5182
|
-
|
|
5183
|
-
//#region src/storage/domains/favorites/index.ts
|
|
5174
|
+
// src/storage/domains/favorites/index.ts
|
|
5184
5175
|
/**
|
|
5185
5176
|
* Maps a favorite entity type to the parent table whose denormalized
|
|
5186
5177
|
* `favoriteCount` column the favorites domain keeps in sync.
|
|
@@ -5525,8 +5516,7 @@ var FavoritesSpanner = class FavoritesSpanner extends FavoritesStorage {
|
|
|
5525
5516
|
} catch {}
|
|
5526
5517
|
}
|
|
5527
5518
|
};
|
|
5528
|
-
|
|
5529
|
-
//#region src/storage/domains/mcp-clients/index.ts
|
|
5519
|
+
// src/storage/domains/mcp-clients/index.ts
|
|
5530
5520
|
/**
|
|
5531
5521
|
* Spanner-backed storage for MCP-client definitions and their immutable versions.
|
|
5532
5522
|
* Mirrors the thin-record + versions pattern used by agents/skills/prompt-blocks.
|
|
@@ -6110,8 +6100,7 @@ var MCPClientsSpanner = class MCPClientsSpanner extends MCPClientsStorage {
|
|
|
6110
6100
|
}
|
|
6111
6101
|
}
|
|
6112
6102
|
};
|
|
6113
|
-
|
|
6114
|
-
//#region src/storage/domains/mcp-servers/index.ts
|
|
6103
|
+
// src/storage/domains/mcp-servers/index.ts
|
|
6115
6104
|
/**
|
|
6116
6105
|
* Spanner-backed storage for MCP-server definitions and their immutable versions.
|
|
6117
6106
|
* Mirrors the thin-record + versions pattern used by agents/skills/prompt-blocks.
|
|
@@ -6719,8 +6708,7 @@ var MCPServersSpanner = class MCPServersSpanner extends MCPServersStorage {
|
|
|
6719
6708
|
}
|
|
6720
6709
|
}
|
|
6721
6710
|
};
|
|
6722
|
-
|
|
6723
|
-
//#region src/storage/db/run-fencing.ts
|
|
6711
|
+
// src/storage/db/run-fencing.ts
|
|
6724
6712
|
/** Epoch milliseconds on the database clock, read when the statement runs. */
|
|
6725
6713
|
const DB_NOW_MS = "UNIX_MILLIS(CURRENT_TIMESTAMP())";
|
|
6726
6714
|
/**
|
|
@@ -6773,8 +6761,7 @@ function withRunFence(db, claimsTable, fence, operation, write) {
|
|
|
6773
6761
|
return write(tx);
|
|
6774
6762
|
});
|
|
6775
6763
|
}
|
|
6776
|
-
|
|
6777
|
-
//#region src/storage/domains/memory/index.ts
|
|
6764
|
+
// src/storage/domains/memory/index.ts
|
|
6778
6765
|
function buildSpannerMessageMetadataFilter(metadataFilter) {
|
|
6779
6766
|
if (!metadataFilter) return {
|
|
6780
6767
|
clauses: [],
|
|
@@ -8044,8 +8031,7 @@ var MemorySpanner = class MemorySpanner extends MemoryStorage {
|
|
|
8044
8031
|
}
|
|
8045
8032
|
}
|
|
8046
8033
|
};
|
|
8047
|
-
|
|
8048
|
-
//#region src/storage/domains/observability/metrics.ts
|
|
8034
|
+
// src/storage/domains/observability/metrics.ts
|
|
8049
8035
|
/** Physical table name. Not exposed by `@mastra/core/storage` (no TABLE_METRICS
|
|
8050
8036
|
* constant exists), so the Spanner adapter owns the name itself. Follows the
|
|
8051
8037
|
* same `mastra_ai_*` convention as `TABLE_SPANS = 'mastra_ai_spans'`. */
|
|
@@ -9152,8 +9138,7 @@ async function clearMetrics(database) {
|
|
|
9152
9138
|
}
|
|
9153
9139
|
});
|
|
9154
9140
|
}
|
|
9155
|
-
|
|
9156
|
-
//#region src/storage/domains/observability/index.ts
|
|
9141
|
+
// src/storage/domains/observability/index.ts
|
|
9157
9142
|
function invalidTraceFilterKey(kind, key) {
|
|
9158
9143
|
return new MastraError({
|
|
9159
9144
|
id: createStorageErrorId("SPANNER", "LIST_TRACES", "VALIDATE_FAILED"),
|
|
@@ -9769,8 +9754,7 @@ var ObservabilitySpanner = class ObservabilitySpanner extends ObservabilityStora
|
|
|
9769
9754
|
return getMetricLabelValues(this.database, args, this.readOptions());
|
|
9770
9755
|
}
|
|
9771
9756
|
};
|
|
9772
|
-
|
|
9773
|
-
//#region src/storage/domains/prompt-blocks/index.ts
|
|
9757
|
+
// src/storage/domains/prompt-blocks/index.ts
|
|
9774
9758
|
/**
|
|
9775
9759
|
* Spanner-backed storage for prompt blocks and their immutable versions.
|
|
9776
9760
|
* Mirrors the thin-record + versions pattern used by agents/skills/scorer-definitions.
|
|
@@ -10361,8 +10345,7 @@ var PromptBlocksSpanner = class PromptBlocksSpanner extends PromptBlocksStorage
|
|
|
10361
10345
|
}
|
|
10362
10346
|
}
|
|
10363
10347
|
};
|
|
10364
|
-
|
|
10365
|
-
//#region src/storage/domains/schedules/index.ts
|
|
10348
|
+
// src/storage/domains/schedules/index.ts
|
|
10366
10349
|
function rowToSchedule(row) {
|
|
10367
10350
|
const transformed = transformFromSpannerRow({
|
|
10368
10351
|
tableName: TABLE_SCHEDULES,
|
|
@@ -10860,8 +10843,7 @@ var SchedulesSpanner = class SchedulesSpanner extends SchedulesStorage {
|
|
|
10860
10843
|
}
|
|
10861
10844
|
}
|
|
10862
10845
|
};
|
|
10863
|
-
|
|
10864
|
-
//#region src/storage/domains/scorer-definitions/index.ts
|
|
10846
|
+
// src/storage/domains/scorer-definitions/index.ts
|
|
10865
10847
|
/**
|
|
10866
10848
|
* Spanner-backed storage for scorer definitions and their immutable versions.
|
|
10867
10849
|
* Mirrors the thin-record + versions pattern used by agents/skills/prompt-blocks.
|
|
@@ -11460,8 +11442,7 @@ var ScorerDefinitionsSpanner = class ScorerDefinitionsSpanner extends ScorerDefi
|
|
|
11460
11442
|
}
|
|
11461
11443
|
}
|
|
11462
11444
|
};
|
|
11463
|
-
|
|
11464
|
-
//#region src/storage/domains/scores/index.ts
|
|
11445
|
+
// src/storage/domains/scores/index.ts
|
|
11465
11446
|
function transformScoreRow$1(row) {
|
|
11466
11447
|
const normalized = transformFromSpannerRow({
|
|
11467
11448
|
tableName: TABLE_SCORERS,
|
|
@@ -11743,8 +11724,7 @@ var ScoresSpanner = class ScoresSpanner extends ScoresStorage {
|
|
|
11743
11724
|
}
|
|
11744
11725
|
}
|
|
11745
11726
|
};
|
|
11746
|
-
|
|
11747
|
-
//#region src/storage/domains/skills/index.ts
|
|
11727
|
+
// src/storage/domains/skills/index.ts
|
|
11748
11728
|
/**
|
|
11749
11729
|
* Spanner-backed storage for skills and their immutable versions.
|
|
11750
11730
|
* Mirrors the thin-record + versions pattern used by agents/prompt-blocks/scorer-definitions.
|
|
@@ -12368,8 +12348,7 @@ var SkillsSpanner = class SkillsSpanner extends SkillsStorage {
|
|
|
12368
12348
|
}
|
|
12369
12349
|
}
|
|
12370
12350
|
};
|
|
12371
|
-
|
|
12372
|
-
//#region src/storage/domains/workflow-definitions/index.ts
|
|
12351
|
+
// src/storage/domains/workflow-definitions/index.ts
|
|
12373
12352
|
function rowToDefinition(row) {
|
|
12374
12353
|
const parsed = transformFromSpannerRow({
|
|
12375
12354
|
tableName: TABLE_WORKFLOW_DEFINITIONS,
|
|
@@ -12539,8 +12518,7 @@ var WorkflowDefinitionsSpanner = class WorkflowDefinitionsSpanner extends Workfl
|
|
|
12539
12518
|
});
|
|
12540
12519
|
}
|
|
12541
12520
|
};
|
|
12542
|
-
|
|
12543
|
-
//#region src/storage/domains/workflows/index.ts
|
|
12521
|
+
// src/storage/domains/workflows/index.ts
|
|
12544
12522
|
const RUN_OWNERS_TABLE = quoteIdent(TABLE_WORKFLOW_RUN_OWNERS, "table name");
|
|
12545
12523
|
const RUN_ID = quoteIdent("runId", "column name");
|
|
12546
12524
|
const OWNER_ID = quoteIdent("ownerId", "column name");
|
|
@@ -13246,8 +13224,7 @@ var WorkflowsSpanner = class WorkflowsSpanner extends WorkflowsStorage {
|
|
|
13246
13224
|
}
|
|
13247
13225
|
}
|
|
13248
13226
|
};
|
|
13249
|
-
|
|
13250
|
-
//#region src/storage/domains/workspaces/index.ts
|
|
13227
|
+
// src/storage/domains/workspaces/index.ts
|
|
13251
13228
|
/** Snapshot config fields that live exclusively on version rows. */
|
|
13252
13229
|
const SNAPSHOT_FIELDS = [
|
|
13253
13230
|
"name",
|
|
@@ -13876,8 +13853,7 @@ var WorkspacesSpanner = class WorkspacesSpanner extends WorkspacesStorage {
|
|
|
13876
13853
|
}
|
|
13877
13854
|
}
|
|
13878
13855
|
};
|
|
13879
|
-
|
|
13880
|
-
//#region src/storage/index.ts
|
|
13856
|
+
// src/storage/index.ts
|
|
13881
13857
|
/** Domain keys this adapter implements; the only valid values for `enabledDomains`. */
|
|
13882
13858
|
const SPANNER_DOMAIN_KEYS = [
|
|
13883
13859
|
"scores",
|
|
@@ -14068,15 +14044,10 @@ var SpannerStore = class extends MastraCompositeStore {
|
|
|
14068
14044
|
*/
|
|
14069
14045
|
async close() {
|
|
14070
14046
|
if (!this.ownsClient) return;
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
if (this.spanner) this.spanner.close();
|
|
14074
|
-
} catch (error) {
|
|
14075
|
-
throw error;
|
|
14076
|
-
}
|
|
14047
|
+
await this.database.close();
|
|
14048
|
+
if (this.spanner) this.spanner.close();
|
|
14077
14049
|
}
|
|
14078
14050
|
};
|
|
14079
|
-
//#endregion
|
|
14080
14051
|
export { AgentsSpanner, BackgroundTasksSpanner, BlobsSpanner, ChannelsSpanner, DatasetsSpanner, ExperimentsSpanner, FavoritesSpanner, MCPClientsSpanner, MCPServersSpanner, MemorySpanner, ObservabilitySpanner, PromptBlocksSpanner, SPANNER_DOMAIN_KEYS, SchedulesSpanner, ScorerDefinitionsSpanner, ScoresSpanner, SkillsSpanner, SpannerStore, WorkflowDefinitionsSpanner, WorkflowsSpanner, WorkspacesSpanner };
|
|
14081
14052
|
|
|
14082
14053
|
//# sourceMappingURL=index.js.map
|