@mastra/spanner 1.12.0-alpha.1 → 1.12.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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +5 -5
- package/dist/index.cjs +44 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -7
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +9 -3
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.12.
|
|
6
|
+
version: "1.12.1-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.12.
|
|
2
|
+
"version": "1.12.1-alpha.0",
|
|
3
3
|
"package": "@mastra/spanner",
|
|
4
4
|
"exports": {
|
|
5
5
|
"AgentsSpanner": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"SPANNER_DOMAIN_KEYS": {
|
|
66
66
|
"types": "dist/storage/index.d.ts",
|
|
67
67
|
"implementation": "dist/index.js",
|
|
68
|
-
"line":
|
|
68
|
+
"line": 13937
|
|
69
69
|
},
|
|
70
70
|
"SchedulesSpanner": {
|
|
71
71
|
"types": "dist/storage/domains/schedules/index.d.ts",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"SpannerStore": {
|
|
91
91
|
"types": "dist/storage/index.d.ts",
|
|
92
92
|
"implementation": "dist/index.js",
|
|
93
|
-
"line":
|
|
93
|
+
"line": 13976
|
|
94
94
|
},
|
|
95
95
|
"WorkflowDefinitionsSpanner": {
|
|
96
96
|
"types": "dist/storage/domains/workflow-definitions/index.d.ts",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"WorkflowsSpanner": {
|
|
101
101
|
"types": "dist/storage/domains/workflows/index.d.ts",
|
|
102
102
|
"implementation": "dist/index.js",
|
|
103
|
-
"line":
|
|
103
|
+
"line": 12623
|
|
104
104
|
},
|
|
105
105
|
"WorkspacesSpanner": {
|
|
106
106
|
"types": "dist/storage/domains/workspaces/index.d.ts",
|
|
107
107
|
"implementation": "dist/index.js",
|
|
108
|
-
"line":
|
|
108
|
+
"line": 13326
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
"modules": {}
|
package/dist/index.cjs
CHANGED
|
@@ -12567,6 +12567,37 @@ const RUN_ID = quoteIdent("runId", "column name");
|
|
|
12567
12567
|
const OWNER_ID = quoteIdent("ownerId", "column name");
|
|
12568
12568
|
const LEASE_EXPIRES_AT = quoteIdent("leaseExpiresAt", "column name");
|
|
12569
12569
|
const UPDATED_AT = quoteIdent("updatedAt", "column name");
|
|
12570
|
+
const SNAPSHOT = quoteIdent("snapshot", "column name");
|
|
12571
|
+
/**
|
|
12572
|
+
* Columns of a `listWorkflowRuns({ summary: true })` row: the snapshot fields a summary returns
|
|
12573
|
+
* are read in SQL, so the snapshot itself is never sent.
|
|
12574
|
+
*/
|
|
12575
|
+
const WORKFLOW_SUMMARY_COLUMNS = [
|
|
12576
|
+
quoteIdent("workflow_name", "column name"),
|
|
12577
|
+
quoteIdent("run_id", "column name"),
|
|
12578
|
+
quoteIdent("resourceId", "column name"),
|
|
12579
|
+
quoteIdent("createdAt", "column name"),
|
|
12580
|
+
quoteIdent("updatedAt", "column name"),
|
|
12581
|
+
`JSON_VALUE(${SNAPSHOT}, '$.status') AS summaryStatus`,
|
|
12582
|
+
`JSON_VALUE(${SNAPSHOT}, '$.timestamp') AS summaryTimestamp`,
|
|
12583
|
+
`JSON_VALUE(${SNAPSHOT}, '$.parentWorkflow.workflowId') AS summaryParentWorkflowId`,
|
|
12584
|
+
`JSON_VALUE(${SNAPSHOT}, '$.parentWorkflow.runId') AS summaryParentRunId`
|
|
12585
|
+
].join(", ");
|
|
12586
|
+
/**
|
|
12587
|
+
* The reduced snapshot of a summary row: `status` and `timestamp` when set, and `parentWorkflow`
|
|
12588
|
+
* only when both of its IDs are non-empty strings.
|
|
12589
|
+
*/
|
|
12590
|
+
function summarySnapshot(row) {
|
|
12591
|
+
const snapshot = {};
|
|
12592
|
+
if (row.summaryStatus !== null && row.summaryStatus !== void 0) snapshot.status = row.summaryStatus;
|
|
12593
|
+
if (row.summaryTimestamp !== null && row.summaryTimestamp !== void 0) snapshot.timestamp = Number(row.summaryTimestamp);
|
|
12594
|
+
const { summaryParentWorkflowId: workflowId, summaryParentRunId: runId } = row;
|
|
12595
|
+
if (typeof workflowId === "string" && workflowId !== "" && typeof runId === "string" && runId !== "") snapshot.parentWorkflow = {
|
|
12596
|
+
workflowId,
|
|
12597
|
+
runId
|
|
12598
|
+
};
|
|
12599
|
+
return snapshot;
|
|
12600
|
+
}
|
|
12570
12601
|
/** Reads a run's ownership record, judging the lease against the database clock. */
|
|
12571
12602
|
async function readRunOwner(q, runId) {
|
|
12572
12603
|
const [rows] = await q.run({
|
|
@@ -12873,13 +12904,16 @@ var WorkflowsSpanner = class WorkflowsSpanner extends _mastra_core_storage.Workf
|
|
|
12873
12904
|
throw this.#ownershipError("GET_RUN_OWNERSHIP", runId, error);
|
|
12874
12905
|
}
|
|
12875
12906
|
}
|
|
12876
|
-
/**
|
|
12877
|
-
|
|
12907
|
+
/**
|
|
12908
|
+
* Decodes a raw Spanner snapshot row into the public `WorkflowRun` shape. With `summary`, the
|
|
12909
|
+
* row has the `WORKFLOW_SUMMARY_COLUMNS` columns instead of the snapshot.
|
|
12910
|
+
*/
|
|
12911
|
+
parseWorkflowRun(row, { summary } = {}) {
|
|
12878
12912
|
const transformed = transformFromSpannerRow({
|
|
12879
12913
|
tableName: _mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT,
|
|
12880
12914
|
row
|
|
12881
12915
|
});
|
|
12882
|
-
let snapshot = transformed.snapshot;
|
|
12916
|
+
let snapshot = summary ? summarySnapshot(transformed) : transformed.snapshot;
|
|
12883
12917
|
if (typeof snapshot === "string") try {
|
|
12884
12918
|
snapshot = JSON.parse(snapshot);
|
|
12885
12919
|
} catch (e) {
|
|
@@ -13196,8 +13230,11 @@ var WorkflowsSpanner = class WorkflowsSpanner extends _mastra_core_storage.Workf
|
|
|
13196
13230
|
}, error);
|
|
13197
13231
|
}
|
|
13198
13232
|
}
|
|
13199
|
-
/**
|
|
13200
|
-
|
|
13233
|
+
/**
|
|
13234
|
+
* Paginated listing with optional workflowName, status, resourceId, and date-range filters.
|
|
13235
|
+
* With `summary`, each run's snapshot holds only `status`, `timestamp` and `parentWorkflow`.
|
|
13236
|
+
*/
|
|
13237
|
+
async listWorkflowRuns({ workflowName, fromDate, toDate, page, perPage, resourceId, status, summary } = {}) {
|
|
13201
13238
|
try {
|
|
13202
13239
|
const conditions = [];
|
|
13203
13240
|
const params = {};
|
|
@@ -13238,7 +13275,7 @@ var WorkflowsSpanner = class WorkflowsSpanner extends _mastra_core_storage.Workf
|
|
|
13238
13275
|
});
|
|
13239
13276
|
total = Number(countRows[0]?.count ?? 0);
|
|
13240
13277
|
}
|
|
13241
|
-
let sql = `SELECT * FROM ${tableName} ${whereSql} ORDER BY ${quoteIdent("createdAt", "column name")} DESC, ${quoteIdent("run_id", "column name")} DESC`;
|
|
13278
|
+
let sql = `SELECT ${summary ? WORKFLOW_SUMMARY_COLUMNS : "*"} FROM ${tableName} ${whereSql} ORDER BY ${quoteIdent("createdAt", "column name")} DESC, ${quoteIdent("run_id", "column name")} DESC`;
|
|
13242
13279
|
if (usePagination) {
|
|
13243
13280
|
const normalized = (0, _mastra_core_storage.normalizePerPage)(perPage, Number.MAX_SAFE_INTEGER);
|
|
13244
13281
|
const offset = page * normalized;
|
|
@@ -13252,7 +13289,7 @@ var WorkflowsSpanner = class WorkflowsSpanner extends _mastra_core_storage.Workf
|
|
|
13252
13289
|
types,
|
|
13253
13290
|
json: true
|
|
13254
13291
|
});
|
|
13255
|
-
const runs = rows.map((r) => this.parseWorkflowRun(r));
|
|
13292
|
+
const runs = rows.map((r) => this.parseWorkflowRun(r, { summary }));
|
|
13256
13293
|
return {
|
|
13257
13294
|
runs,
|
|
13258
13295
|
total: total || runs.length
|