@mastra/spanner 1.4.0 → 1.5.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/CHANGELOG.md +64 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-spanner.md +8 -8
- package/dist/index.cjs +193 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +194 -8
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/workflow-definitions/index.d.ts +22 -0
- package/dist/storage/domains/workflow-definitions/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +3 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -5
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_SNAPSHOT, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, TraceStatus, WORKSPACES_SCHEMA, WORKSPACE_VERSIONS_SCHEMA, WorkflowsStorage, WorkspacesStorage, calculatePagination, createStorageErrorId, getDefaultValue, hasErrorCode, listMetricsArgsSchema, listTracesArgsSchema, normalizePerPage, normalizeScheduleTarget, 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, getDefaultValue, hasErrorCode, listMetricsArgsSchema, listTracesArgsSchema, normalizePerPage, normalizeScheduleTarget, 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";
|
|
@@ -2787,6 +2787,7 @@ function rowToItem(row) {
|
|
|
2787
2787
|
groundTruth: t.groundTruth ?? void 0,
|
|
2788
2788
|
expectedTrajectory: t.expectedTrajectory ?? void 0,
|
|
2789
2789
|
toolMocks: t.toolMocks ?? void 0,
|
|
2790
|
+
unmockedToolPolicy: t.unmockedToolPolicy ?? void 0,
|
|
2790
2791
|
requestContext: t.requestContext ?? void 0,
|
|
2791
2792
|
metadata: t.metadata ?? void 0,
|
|
2792
2793
|
source: t.source ?? void 0,
|
|
@@ -2884,7 +2885,8 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
2884
2885
|
ifNotExists: [
|
|
2885
2886
|
"organizationId",
|
|
2886
2887
|
"projectId",
|
|
2887
|
-
"externalId"
|
|
2888
|
+
"externalId",
|
|
2889
|
+
"unmockedToolPolicy"
|
|
2888
2890
|
]
|
|
2889
2891
|
});
|
|
2890
2892
|
await this.createDefaultIndexes();
|
|
@@ -3349,6 +3351,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3349
3351
|
groundTruth: args.groundTruth ?? null,
|
|
3350
3352
|
expectedTrajectory: args.expectedTrajectory ?? null,
|
|
3351
3353
|
toolMocks: args.toolMocks ?? null,
|
|
3354
|
+
unmockedToolPolicy: args.unmockedToolPolicy ?? null,
|
|
3352
3355
|
requestContext: args.requestContext ?? null,
|
|
3353
3356
|
metadata: args.metadata ?? null,
|
|
3354
3357
|
source: args.source ?? null,
|
|
@@ -3369,6 +3372,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3369
3372
|
groundTruth: args.groundTruth,
|
|
3370
3373
|
expectedTrajectory: args.expectedTrajectory,
|
|
3371
3374
|
toolMocks: args.toolMocks,
|
|
3375
|
+
unmockedToolPolicy: args.unmockedToolPolicy,
|
|
3372
3376
|
requestContext: args.requestContext,
|
|
3373
3377
|
metadata: args.metadata,
|
|
3374
3378
|
source: args.source,
|
|
@@ -3418,6 +3422,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3418
3422
|
groundTruth: args.groundTruth !== void 0 ? args.groundTruth : existing.groundTruth,
|
|
3419
3423
|
expectedTrajectory: args.expectedTrajectory !== void 0 ? args.expectedTrajectory : existing.expectedTrajectory,
|
|
3420
3424
|
toolMocks: args.toolMocks !== void 0 ? args.toolMocks : existing.toolMocks,
|
|
3425
|
+
unmockedToolPolicy: args.unmockedToolPolicy !== void 0 ? args.unmockedToolPolicy : existing.unmockedToolPolicy,
|
|
3421
3426
|
requestContext: args.requestContext !== void 0 ? args.requestContext : existing.requestContext,
|
|
3422
3427
|
metadata: args.metadata !== void 0 ? args.metadata : existing.metadata,
|
|
3423
3428
|
source: args.source !== void 0 ? args.source : existing.source
|
|
@@ -3443,6 +3448,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3443
3448
|
groundTruth: merged.groundTruth ?? null,
|
|
3444
3449
|
expectedTrajectory: merged.expectedTrajectory ?? null,
|
|
3445
3450
|
toolMocks: merged.toolMocks ?? null,
|
|
3451
|
+
unmockedToolPolicy: merged.unmockedToolPolicy ?? null,
|
|
3446
3452
|
requestContext: merged.requestContext ?? null,
|
|
3447
3453
|
metadata: merged.metadata ?? null,
|
|
3448
3454
|
source: merged.source ?? null,
|
|
@@ -3464,6 +3470,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3464
3470
|
groundTruth: merged.groundTruth,
|
|
3465
3471
|
expectedTrajectory: merged.expectedTrajectory,
|
|
3466
3472
|
toolMocks: merged.toolMocks,
|
|
3473
|
+
unmockedToolPolicy: merged.unmockedToolPolicy,
|
|
3467
3474
|
requestContext: merged.requestContext,
|
|
3468
3475
|
metadata: merged.metadata,
|
|
3469
3476
|
source: merged.source,
|
|
@@ -3522,6 +3529,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3522
3529
|
groundTruth: existing.groundTruth ?? null,
|
|
3523
3530
|
expectedTrajectory: existing.expectedTrajectory ?? null,
|
|
3524
3531
|
toolMocks: existing.toolMocks ?? null,
|
|
3532
|
+
unmockedToolPolicy: existing.unmockedToolPolicy ?? null,
|
|
3525
3533
|
requestContext: existing.requestContext ?? null,
|
|
3526
3534
|
metadata: existing.metadata ?? null,
|
|
3527
3535
|
source: existing.source ?? null,
|
|
@@ -3838,6 +3846,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3838
3846
|
groundTruth: insert.item.groundTruth,
|
|
3839
3847
|
expectedTrajectory: insert.item.expectedTrajectory,
|
|
3840
3848
|
toolMocks: insert.item.toolMocks,
|
|
3849
|
+
unmockedToolPolicy: insert.item.unmockedToolPolicy,
|
|
3841
3850
|
requestContext: insert.item.requestContext,
|
|
3842
3851
|
metadata: insert.item.metadata,
|
|
3843
3852
|
source: insert.item.source,
|
|
@@ -3906,6 +3915,7 @@ var DatasetsSpanner = class DatasetsSpanner extends DatasetsStorage {
|
|
|
3906
3915
|
groundTruth: existing.groundTruth ?? null,
|
|
3907
3916
|
expectedTrajectory: existing.expectedTrajectory ?? null,
|
|
3908
3917
|
toolMocks: existing.toolMocks ?? null,
|
|
3918
|
+
unmockedToolPolicy: existing.unmockedToolPolicy ?? null,
|
|
3909
3919
|
requestContext: existing.requestContext ?? null,
|
|
3910
3920
|
metadata: existing.metadata ?? null,
|
|
3911
3921
|
source: existing.source ?? null,
|
|
@@ -3990,6 +4000,7 @@ function rowToExperimentResult(row) {
|
|
|
3990
4000
|
traceId: t.traceId ?? null,
|
|
3991
4001
|
status: t.status ?? null,
|
|
3992
4002
|
tags: t.tags ?? null,
|
|
4003
|
+
comment: t.comment ?? null,
|
|
3993
4004
|
toolMockReport: t.toolMockReport ?? null,
|
|
3994
4005
|
createdAt: toDate(t.createdAt)
|
|
3995
4006
|
};
|
|
@@ -4034,7 +4045,11 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
|
|
|
4034
4045
|
await this.db.alterTable({
|
|
4035
4046
|
tableName: TABLE_EXPERIMENT_RESULTS,
|
|
4036
4047
|
schema: TABLE_SCHEMAS[TABLE_EXPERIMENT_RESULTS],
|
|
4037
|
-
ifNotExists: [
|
|
4048
|
+
ifNotExists: [
|
|
4049
|
+
"comment",
|
|
4050
|
+
"organizationId",
|
|
4051
|
+
"projectId"
|
|
4052
|
+
]
|
|
4038
4053
|
});
|
|
4039
4054
|
await this.createDefaultIndexes();
|
|
4040
4055
|
await this.createCustomIndexes();
|
|
@@ -4427,7 +4442,7 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
|
|
|
4427
4442
|
}
|
|
4428
4443
|
async updateExperimentResult(input) {
|
|
4429
4444
|
try {
|
|
4430
|
-
if (input.status === void 0 && input.tags === void 0) {
|
|
4445
|
+
if (input.status === void 0 && input.tags === void 0 && input.comment === void 0) {
|
|
4431
4446
|
const existing = await this.getExperimentResultById({ id: input.id });
|
|
4432
4447
|
if (!existing || input.experimentId !== void 0 && existing.experimentId !== input.experimentId) throw new MastraError({
|
|
4433
4448
|
id: createStorageErrorId("SPANNER", "UPDATE_EXPERIMENT_RESULT", "NOT_FOUND"),
|
|
@@ -4451,6 +4466,11 @@ var ExperimentsSpanner = class ExperimentsSpanner extends ExperimentsStorage {
|
|
|
4451
4466
|
params.tags = input.tags === null ? null : JSON.stringify(input.tags);
|
|
4452
4467
|
types.tags = "json";
|
|
4453
4468
|
}
|
|
4469
|
+
if (input.comment !== void 0) {
|
|
4470
|
+
setClauses.push(`${quoteIdent("comment", "column name")} = @comment`);
|
|
4471
|
+
params.comment = input.comment;
|
|
4472
|
+
if (input.comment === null) types.comment = "string";
|
|
4473
|
+
}
|
|
4454
4474
|
const whereClauses = [`${quoteIdent("id", "column name")} = @id`];
|
|
4455
4475
|
if (input.experimentId !== void 0) {
|
|
4456
4476
|
whereClauses.push(`${quoteIdent("experimentId", "column name")} = @experimentId`);
|
|
@@ -11480,6 +11500,169 @@ var SkillsSpanner = class SkillsSpanner extends SkillsStorage {
|
|
|
11480
11500
|
}
|
|
11481
11501
|
};
|
|
11482
11502
|
//#endregion
|
|
11503
|
+
//#region src/storage/domains/workflow-definitions/index.ts
|
|
11504
|
+
function rowToDefinition(row) {
|
|
11505
|
+
const parsed = transformFromSpannerRow({
|
|
11506
|
+
tableName: TABLE_WORKFLOW_DEFINITIONS,
|
|
11507
|
+
row
|
|
11508
|
+
});
|
|
11509
|
+
if (parsed.inputSchema == null || parsed.outputSchema == null || parsed.graph == null) throw new Error(`Workflow definition row "${String(parsed.id)}" is missing required JSON columns.`);
|
|
11510
|
+
const def = {
|
|
11511
|
+
id: String(parsed.id),
|
|
11512
|
+
inputSchema: parsed.inputSchema,
|
|
11513
|
+
outputSchema: parsed.outputSchema,
|
|
11514
|
+
graph: parsed.graph,
|
|
11515
|
+
status: parsed.status,
|
|
11516
|
+
source: parsed.source,
|
|
11517
|
+
createdAt: parsed.createdAt instanceof Date ? parsed.createdAt : new Date(parsed.createdAt),
|
|
11518
|
+
updatedAt: parsed.updatedAt instanceof Date ? parsed.updatedAt : new Date(parsed.updatedAt)
|
|
11519
|
+
};
|
|
11520
|
+
if (parsed.description != null) def.description = parsed.description;
|
|
11521
|
+
if (parsed.metadata != null) def.metadata = parsed.metadata;
|
|
11522
|
+
if (parsed.stateSchema != null) def.stateSchema = parsed.stateSchema;
|
|
11523
|
+
if (parsed.requestContextSchema != null) def.requestContextSchema = parsed.requestContextSchema;
|
|
11524
|
+
if (parsed.authorId != null) def.authorId = parsed.authorId;
|
|
11525
|
+
return def;
|
|
11526
|
+
}
|
|
11527
|
+
var WorkflowDefinitionsSpanner = class WorkflowDefinitionsSpanner extends WorkflowDefinitionsStorage {
|
|
11528
|
+
database;
|
|
11529
|
+
db;
|
|
11530
|
+
skipDefaultIndexes;
|
|
11531
|
+
indexes;
|
|
11532
|
+
static MANAGED_TABLES = [TABLE_WORKFLOW_DEFINITIONS];
|
|
11533
|
+
constructor(config) {
|
|
11534
|
+
super();
|
|
11535
|
+
const { database, indexes, skipDefaultIndexes, initMode } = resolveSpannerConfig(config);
|
|
11536
|
+
this.database = database;
|
|
11537
|
+
this.db = new SpannerDB({
|
|
11538
|
+
database,
|
|
11539
|
+
skipDefaultIndexes,
|
|
11540
|
+
initMode
|
|
11541
|
+
});
|
|
11542
|
+
this.skipDefaultIndexes = skipDefaultIndexes;
|
|
11543
|
+
this.indexes = indexes?.filter((idx) => WorkflowDefinitionsSpanner.MANAGED_TABLES.includes(idx.table));
|
|
11544
|
+
}
|
|
11545
|
+
async init() {
|
|
11546
|
+
await this.db.createTable({
|
|
11547
|
+
tableName: TABLE_WORKFLOW_DEFINITIONS,
|
|
11548
|
+
schema: WORKFLOW_DEFINITIONS_SCHEMA
|
|
11549
|
+
});
|
|
11550
|
+
await this.createDefaultIndexes();
|
|
11551
|
+
await this.createCustomIndexes();
|
|
11552
|
+
}
|
|
11553
|
+
getDefaultIndexDefinitions() {
|
|
11554
|
+
return [{
|
|
11555
|
+
name: "mastra_workflow_definitions_status_idx",
|
|
11556
|
+
table: TABLE_WORKFLOW_DEFINITIONS,
|
|
11557
|
+
columns: ["status"]
|
|
11558
|
+
}];
|
|
11559
|
+
}
|
|
11560
|
+
async createDefaultIndexes() {
|
|
11561
|
+
if (this.skipDefaultIndexes) return;
|
|
11562
|
+
await this.db.createIndexes(this.getDefaultIndexDefinitions());
|
|
11563
|
+
}
|
|
11564
|
+
async createCustomIndexes() {
|
|
11565
|
+
if (!this.indexes || this.indexes.length === 0) return;
|
|
11566
|
+
await this.db.createIndexes(this.indexes);
|
|
11567
|
+
}
|
|
11568
|
+
async dangerouslyClearAll() {
|
|
11569
|
+
await this.db.clearTable({ tableName: TABLE_WORKFLOW_DEFINITIONS });
|
|
11570
|
+
}
|
|
11571
|
+
async upsert(input) {
|
|
11572
|
+
const now = /* @__PURE__ */ new Date();
|
|
11573
|
+
if (!await this.get(input.id)) {
|
|
11574
|
+
if (!("inputSchema" in input) || input.inputSchema === void 0) throw new Error(`Cannot create workflow definition "${input.id}": inputSchema is required.`);
|
|
11575
|
+
if (!("outputSchema" in input) || input.outputSchema === void 0) throw new Error(`Cannot create workflow definition "${input.id}": outputSchema is required.`);
|
|
11576
|
+
if (!("graph" in input) || input.graph === void 0) throw new Error(`Cannot create workflow definition "${input.id}": graph is required.`);
|
|
11577
|
+
const record = {
|
|
11578
|
+
id: input.id,
|
|
11579
|
+
description: input.description ?? null,
|
|
11580
|
+
metadata: input.metadata ?? null,
|
|
11581
|
+
inputSchema: input.inputSchema,
|
|
11582
|
+
outputSchema: input.outputSchema,
|
|
11583
|
+
stateSchema: input.stateSchema ?? null,
|
|
11584
|
+
requestContextSchema: input.requestContextSchema ?? null,
|
|
11585
|
+
graph: input.graph,
|
|
11586
|
+
status: "active",
|
|
11587
|
+
source: "storage",
|
|
11588
|
+
authorId: "authorId" in input ? input.authorId ?? null : null,
|
|
11589
|
+
createdAt: now,
|
|
11590
|
+
updatedAt: now
|
|
11591
|
+
};
|
|
11592
|
+
try {
|
|
11593
|
+
await this.db.insert({
|
|
11594
|
+
tableName: TABLE_WORKFLOW_DEFINITIONS,
|
|
11595
|
+
record
|
|
11596
|
+
});
|
|
11597
|
+
} catch (error) {
|
|
11598
|
+
if (!await this.get(input.id)) throw error;
|
|
11599
|
+
return this.applyUpdate(input, now);
|
|
11600
|
+
}
|
|
11601
|
+
const created = await this.get(input.id);
|
|
11602
|
+
if (!created) throw new Error(`Failed to persist workflow definition "${input.id}".`);
|
|
11603
|
+
return created;
|
|
11604
|
+
}
|
|
11605
|
+
return this.applyUpdate(input, now);
|
|
11606
|
+
}
|
|
11607
|
+
async applyUpdate(input, now) {
|
|
11608
|
+
const data = { updatedAt: now };
|
|
11609
|
+
if ("description" in input && input.description !== void 0) data.description = input.description;
|
|
11610
|
+
if ("metadata" in input && input.metadata !== void 0) data.metadata = input.metadata;
|
|
11611
|
+
if ("inputSchema" in input && input.inputSchema !== void 0) data.inputSchema = input.inputSchema;
|
|
11612
|
+
if ("outputSchema" in input && input.outputSchema !== void 0) data.outputSchema = input.outputSchema;
|
|
11613
|
+
if ("stateSchema" in input && input.stateSchema !== void 0) data.stateSchema = input.stateSchema;
|
|
11614
|
+
if ("requestContextSchema" in input && input.requestContextSchema !== void 0) data.requestContextSchema = input.requestContextSchema;
|
|
11615
|
+
if ("graph" in input && input.graph !== void 0) data.graph = input.graph;
|
|
11616
|
+
if ("status" in input && input.status !== void 0) data.status = input.status;
|
|
11617
|
+
if ("authorId" in input && input.authorId !== void 0) data.authorId = input.authorId;
|
|
11618
|
+
await this.db.update({
|
|
11619
|
+
tableName: TABLE_WORKFLOW_DEFINITIONS,
|
|
11620
|
+
keys: { id: input.id },
|
|
11621
|
+
data
|
|
11622
|
+
});
|
|
11623
|
+
const updated = await this.get(input.id);
|
|
11624
|
+
if (!updated) throw new Error(`Failed to update workflow definition "${input.id}".`);
|
|
11625
|
+
return updated;
|
|
11626
|
+
}
|
|
11627
|
+
async get(id) {
|
|
11628
|
+
const row = await this.db.load({
|
|
11629
|
+
tableName: TABLE_WORKFLOW_DEFINITIONS,
|
|
11630
|
+
keys: { id }
|
|
11631
|
+
});
|
|
11632
|
+
return row ? rowToDefinition(row) : null;
|
|
11633
|
+
}
|
|
11634
|
+
async list(args) {
|
|
11635
|
+
const params = {};
|
|
11636
|
+
const conditions = [];
|
|
11637
|
+
if (args?.status) {
|
|
11638
|
+
params.status = args.status;
|
|
11639
|
+
conditions.push(`${quoteIdent("status", "column name")} = @status`);
|
|
11640
|
+
}
|
|
11641
|
+
if (args?.authorId !== void 0) {
|
|
11642
|
+
params.authorId = args.authorId;
|
|
11643
|
+
conditions.push(`${quoteIdent("authorId", "column name")} = @authorId`);
|
|
11644
|
+
}
|
|
11645
|
+
const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
11646
|
+
const sql = `SELECT * FROM ${quoteIdent(TABLE_WORKFLOW_DEFINITIONS, "table name")} ${where} ORDER BY ${quoteIdent("updatedAt", "column name")} DESC`;
|
|
11647
|
+
const [rows] = await this.database.run({
|
|
11648
|
+
sql,
|
|
11649
|
+
params,
|
|
11650
|
+
json: true
|
|
11651
|
+
});
|
|
11652
|
+
const definitions = rows.map(rowToDefinition);
|
|
11653
|
+
return {
|
|
11654
|
+
definitions,
|
|
11655
|
+
total: definitions.length
|
|
11656
|
+
};
|
|
11657
|
+
}
|
|
11658
|
+
async delete(id) {
|
|
11659
|
+
await this.db.runDml({
|
|
11660
|
+
sql: `DELETE FROM ${quoteIdent(TABLE_WORKFLOW_DEFINITIONS, "table name")} WHERE id = @id`,
|
|
11661
|
+
params: { id }
|
|
11662
|
+
});
|
|
11663
|
+
}
|
|
11664
|
+
};
|
|
11665
|
+
//#endregion
|
|
11483
11666
|
//#region src/storage/domains/workflows/index.ts
|
|
11484
11667
|
/**
|
|
11485
11668
|
* Spanner-backed storage for workflow run snapshots, including persistence,
|
|
@@ -12648,7 +12831,8 @@ const SPANNER_DOMAIN_KEYS = [
|
|
|
12648
12831
|
"datasets",
|
|
12649
12832
|
"experiments",
|
|
12650
12833
|
"favorites",
|
|
12651
|
-
"workspaces"
|
|
12834
|
+
"workspaces",
|
|
12835
|
+
"workflowDefinitions"
|
|
12652
12836
|
];
|
|
12653
12837
|
const isPreConfiguredDatabase = (config) => "database" in config && !!config.database;
|
|
12654
12838
|
/**
|
|
@@ -12736,7 +12920,8 @@ var SpannerStore = class extends MastraCompositeStore {
|
|
|
12736
12920
|
...wants("datasets") && { datasets: new DatasetsSpanner(domainConfig) },
|
|
12737
12921
|
...wants("experiments") && { experiments: new ExperimentsSpanner(domainConfig) },
|
|
12738
12922
|
...wants("favorites") && { favorites: new FavoritesSpanner(domainConfig) },
|
|
12739
|
-
...wants("workspaces") && { workspaces: new WorkspacesSpanner(domainConfig) }
|
|
12923
|
+
...wants("workspaces") && { workspaces: new WorkspacesSpanner(domainConfig) },
|
|
12924
|
+
...wants("workflowDefinitions") && { workflowDefinitions: new WorkflowDefinitionsSpanner(domainConfig) }
|
|
12740
12925
|
};
|
|
12741
12926
|
} catch (e) {
|
|
12742
12927
|
throw new MastraError({
|
|
@@ -12792,7 +12977,8 @@ var SpannerStore = class extends MastraCompositeStore {
|
|
|
12792
12977
|
"datasets",
|
|
12793
12978
|
"experiments",
|
|
12794
12979
|
"workspaces",
|
|
12795
|
-
"favorites"
|
|
12980
|
+
"favorites",
|
|
12981
|
+
"workflowDefinitions"
|
|
12796
12982
|
]) {
|
|
12797
12983
|
const store = this.stores?.[key];
|
|
12798
12984
|
if (store) await store.init();
|
|
@@ -12824,6 +13010,6 @@ var SpannerStore = class extends MastraCompositeStore {
|
|
|
12824
13010
|
}
|
|
12825
13011
|
};
|
|
12826
13012
|
//#endregion
|
|
12827
|
-
export { AgentsSpanner, BackgroundTasksSpanner, BlobsSpanner, ChannelsSpanner, DatasetsSpanner, ExperimentsSpanner, FavoritesSpanner, MCPClientsSpanner, MCPServersSpanner, MemorySpanner, ObservabilitySpanner, PromptBlocksSpanner, SPANNER_DOMAIN_KEYS, SchedulesSpanner, ScorerDefinitionsSpanner, ScoresSpanner, SkillsSpanner, SpannerStore, WorkflowsSpanner, WorkspacesSpanner };
|
|
13013
|
+
export { AgentsSpanner, BackgroundTasksSpanner, BlobsSpanner, ChannelsSpanner, DatasetsSpanner, ExperimentsSpanner, FavoritesSpanner, MCPClientsSpanner, MCPServersSpanner, MemorySpanner, ObservabilitySpanner, PromptBlocksSpanner, SPANNER_DOMAIN_KEYS, SchedulesSpanner, ScorerDefinitionsSpanner, ScoresSpanner, SkillsSpanner, SpannerStore, WorkflowDefinitionsSpanner, WorkflowsSpanner, WorkspacesSpanner };
|
|
12828
13014
|
|
|
12829
13015
|
//# sourceMappingURL=index.js.map
|