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

main
ts 42 lines 1.65 KB
Raw
1 import * as Binding from "alchemy/Binding";
2 import type { RuntimeContext } from "alchemy/RuntimeContext";
3 import * as Effect from "effect/Effect";
4 import type { Scope } from "effect/Scope";
5 import type { CronEvent } from "./FunctionTriggerEvent.ts";
6
7 export interface CronEventSourceProps {
8 /** Numeric five-field UTC cron expression. */ cron: string;
9 /** Enable future delivery. @default true */ enabled?: boolean;
10 }
11 export type CronEventSourceService = <R = never>(
12 name: string,
13 props: CronEventSourceProps,
14 handler: (event: CronEvent) => Effect.Effect<void, unknown, R>,
15 ) => Effect.Effect<void, never, Exclude<R, RuntimeContext | Scope>>;
16 /**
17 * Register a typed POST handler and create its tracked FunctionTrigger automatically.
18 * Provide CronEventSourceHttp on the Function initialization Effect. Handler failures
19 * remain non-success HTTP responses; delivery is not a native `scheduled` event
20 * or an exactly-once guarantee. Local development does not run a cron scheduler.
21 *
22 * ### Register a Schedule
23 * **Example:** Process a scheduled occurrence
24 * ```typescript
25 * yield* Neon.CronEventSource("Nightly", { cron: "0 2 * * *" }, event => Effect.log(event.invocationId));
26 * ```
27 *
28 * @binding
29 * @product Function
30 */
31 export interface CronEventSource extends Binding.Service<
32 CronEventSource,
33 "Neon.CronEventSource",
34 CronEventSourceService
35 > {
36 <R = never>(
37 name: string,
38 props: CronEventSourceProps,
39 handler: (event: CronEvent) => Effect.Effect<void, unknown, R>,
40 ): Effect.Effect<void, never, CronEventSource | Exclude<R, RuntimeContext | Scope>>;
41 }
42 export const CronEventSource = Binding.Service<CronEventSource>("Neon.CronEventSource");