@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 84 lines 2.83 KB
Raw
1 import type * as scheduler from "@distilled.cloud/aws/scheduler";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { Role } from "../IAM/Role.ts";
5 import type { ScheduleGroup } from "./ScheduleGroup.ts";
6
7 /**
8 * The schedule target passed at runtime. `RoleArn` defaults to the execution
9 * role the binding was constructed with, so callers normally omit it.
10 */
11 export interface UpdateScheduleTarget extends Omit<scheduler.Target, "RoleArn"> {
12 /**
13 * Execution role EventBridge Scheduler assumes to invoke the target.
14 * @default the execution role bound via `UpdateSchedule(role)`
15 */
16 RoleArn?: string;
17 }
18
19 export interface UpdateScheduleRequest extends Omit<
20 scheduler.UpdateScheduleInput,
21 "GroupName" | "Target" | "FlexibleTimeWindow"
22 > {
23 /**
24 * Target the schedule invokes when it fires. The bound execution role is
25 * injected as `RoleArn` unless the request overrides it.
26 */
27 Target: UpdateScheduleTarget;
28 /**
29 * Flexible time window configuration.
30 * @default { Mode: "OFF" }
31 */
32 FlexibleTimeWindow?: scheduler.FlexibleTimeWindow;
33 }
34
35 /**
36 * Runtime binding for `scheduler:UpdateSchedule`.
37 *
38 * Pairs with {@link CreateSchedule} for the dynamic-scheduling pattern: a
39 * deployed Lambda reschedules or pauses schedules it minted at runtime (push
40 * a reminder back, disable a recurring job). `UpdateSchedule` is a full PUT —
41 * unspecified fields are reset to their defaults, so send the complete
42 * desired configuration.
43 *
44 * Like {@link CreateSchedule}, the binding is constructed with the schedule
45 * **execution role** and optionally a scoping `ScheduleGroup`; it contributes
46 * both `scheduler:UpdateSchedule` on the group's schedule ARN pattern and
47 * `iam:PassRole` on the execution role.
48 * ### Updating Schedules At Runtime
49 * **Example:** Reschedule A Reminder
50 * ```typescript
51 * const updateSchedule = yield* AWS.Scheduler.UpdateSchedule(role);
52 *
53 * // runtime: push the reminder back a day (full PUT — resend the target)
54 * yield* updateSchedule({
55 * Name: `reminder-${userId}`,
56 * ScheduleExpression: "at(2026-01-02T00:00:00)",
57 * ActionAfterCompletion: "DELETE",
58 * Target: {
59 * Arn: yield* queueArn,
60 * Input: JSON.stringify({ userId }),
61 * },
62 * });
63 * ```
64 *
65 * **Example:** Scope Updates To A Schedule Group
66 * ```typescript
67 * const updateSchedule = yield* AWS.Scheduler.UpdateSchedule(role, group);
68 * ```
69 *
70 * @binding
71 */
72 export interface UpdateSchedule extends Binding.Service<
73 UpdateSchedule,
74 "AWS.Scheduler.UpdateSchedule",
75 <R extends Role>(
76 executionRole: R,
77 group?: ScheduleGroup,
78 ) => Effect.Effect<
79 (
80 request: UpdateScheduleRequest,
81 ) => Effect.Effect<scheduler.UpdateScheduleOutput, scheduler.UpdateScheduleError>
82 >
83 > {}
84 export const UpdateSchedule = Binding.Service<UpdateSchedule>("AWS.Scheduler.UpdateSchedule");