MCPcopy Create free account
hub / github.com/ShipSecAI/studio / create

Method create

backend/src/schedules/schedules.service.ts:41–118  ·  view source on GitHub ↗
(auth: AuthContext | null, dto: CreateScheduleRequestDto)

Source from the content-addressed store, hash-verified

39 }
40
41 async create(auth: AuthContext | null, dto: CreateScheduleRequestDto): Promise<WorkflowSchedule> {
42 await this.workflowsService.ensureWorkflowAdminAccess(dto.workflowId, auth);
43 const context = await this.workflowsService.getCompiledWorkflowContext(
44 dto.workflowId,
45 { versionId: dto.workflowVersionId },
46 auth,
47 );
48
49 const normalizedPayload: ScheduleInputPayload = dto.inputPayload ?? {
50 runtimeInputs: {},
51 nodeOverrides: {},
52 };
53
54 this.validateSchedulePayload(context.definition, normalizedPayload);
55
56 const record = await this.repository.create({
57 workflowId: context.workflow.id,
58 workflowVersionId: context.version.id,
59 workflowVersion: context.version.version,
60 name: dto.name,
61 description: dto.description ?? null,
62 cronExpression: dto.cronExpression,
63 timezone: dto.timezone,
64 humanLabel: dto.humanLabel ?? null,
65 overlapPolicy: dto.overlapPolicy ?? 'skip',
66 catchupWindowSeconds: dto.catchupWindowSeconds ?? 0,
67 status: 'active',
68 inputPayload: normalizedPayload,
69 organizationId: context.organizationId,
70 });
71
72 const dispatchArgs = this.buildDispatchArgs({
73 workflowId: record.workflowId,
74 workflowVersionId: record.workflowVersionId,
75 workflowVersion: record.workflowVersion,
76 organizationId: record.organizationId ?? null,
77 scheduleId: record.id,
78 scheduleName: record.name,
79 payload: normalizedPayload,
80 });
81
82 try {
83 await this.temporalService.createSchedule({
84 scheduleId: record.id,
85 organizationId: context.organizationId,
86 cronExpression: record.cronExpression,
87 timezone: record.timezone,
88 overlapPolicy: (record.overlapPolicy as ScheduleOverlapPolicy) ?? 'skip',
89 catchupWindowSeconds: record.catchupWindowSeconds ?? 0,
90 memo: {
91 workflowId: record.workflowId,
92 workflowVersionId: record.workflowVersionId,
93 workflowVersion: record.workflowVersion,
94 inputPayload: record.inputPayload,
95 },
96 dispatchArgs,
97 });
98 } catch (error) {

Callers

nothing calls this directly

Calls 9

buildDispatchArgsMethod · 0.95
mapRecordMethod · 0.95
errorMethod · 0.80
createScheduleMethod · 0.45
deleteMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected