import type { VoyantRuntimeHostPrimitives } from "@voyant-travel/core"; import type { VoyantGraphProvisionedJob } from "./deployment-graph.js"; import { type CreateVoyantNodeJobHostOptions, VOYANT_PRODUCT_JOB_ROUTE, type VoyantNodeJobExecutionReport, type VoyantNodeJobHealth } from "./node-job-host.js"; import type { VoyantGraphRuntimePorts } from "./runtime-composition.js"; import type { VoyantGraphRuntime } from "./runtime-lowering.js"; export { VOYANT_PRODUCT_JOB_ROUTE }; export interface VoyantWorkerExecutionContext { waitUntil(promise: Promise): void; } export interface VoyantWorkerScheduledEvent { cron: string; } export interface VoyantCloudflareProductJobSchedule { jobId: string; owner: "cloudflare-cron" | "managed-http"; cron?: string; reason?: string; } export type CreateVoyantWorkerJobHostOptions = Omit & { /** Explicitly prevents Cloudflare Cron and managed HTTP from both owning cadence. */ scheduleAuthority: "cloudflare-cron" | "managed-http"; }; export interface VoyantWorkerJobHost { inventory: readonly VoyantGraphProvisionedJob[]; schedules: readonly VoyantCloudflareProductJobSchedule[]; fetch(request: Request, context: VoyantWorkerExecutionContext): Promise; scheduled(event: VoyantWorkerScheduledEvent, context: VoyantWorkerExecutionContext): Promise; health(): readonly VoyantNodeJobHealth[]; } export interface VoyantGeneratedProjectJobRuntime { graphRuntime: VoyantGraphRuntime; productJobs: readonly VoyantGraphProvisionedJob[]; createRuntimePorts(host: { primitives: VoyantRuntimeHostPrimitives; runtimePorts?: VoyantGraphRuntimePorts; }): VoyantGraphRuntimePorts; } export type CreateVoyantWorkerJobHostFromProjectRuntimeOptions = Omit & { primitives: VoyantRuntimeHostPrimitives; providerPorts?: VoyantGraphRuntimePorts; }; /** Bind the standard generated project runtime without authoring job IDs locally. */ export declare function createVoyantWorkerJobHostFromProjectRuntime(projectRuntime: VoyantGeneratedProjectJobRuntime, options: CreateVoyantWorkerJobHostFromProjectRuntimeOptions): VoyantWorkerJobHost; export interface CreateVoyantWorkerRuntimeHostPrimitivesOptions { bindings: TBindings; resolveDatabase(bindings: TBindings): unknown; databaseFromContext?(context: unknown, bindings: TBindings): unknown; transaction?(bindings: TBindings, operation: (database: unknown) => Promise): Promise; resolveStorage?(bindings: TBindings, name: string): unknown; readStorage?(bindings: TBindings, key: string): Promise; resolveDownloadUrl?(bindings: TBindings, key: string): Promise; deliverEvent?(event: unknown, bindings: TBindings): Promise; readConfig?(bindings: TBindings, key: string): unknown; } export declare class VoyantWorkerHostRequirementError extends Error { readonly requirement: string; readonly code = "VOYANT_WORKER_HOST_REQUIREMENT_MISSING"; constructor(requirement: string); } /** * Adapt one Worker's bindings to the domain-neutral primitives captured by * graph runtime contributors. Create/cache these once per bindings object. */ export declare function createVoyantWorkerRuntimeHostPrimitives(options: CreateVoyantWorkerRuntimeHostPrimitivesOptions): VoyantRuntimeHostPrimitives; /** Unique Cron Trigger values suitable for a generated Wrangler configuration. */ export declare function cloudflareCronTriggersForProductJobs(jobs: readonly VoyantGraphProvisionedJob[]): readonly string[]; /** * Host a resolved graph's fixed product-job projection in a Cloudflare Worker. * * The bridge intentionally reuses the platform-neutral invocation core used by * the Node host. It does not start an in-isolate timer, retain payloads, or own * domain progress. Worker lifetime is extended only around accepted executions. */ export declare function createVoyantWorkerJobHost(options: CreateVoyantWorkerJobHostOptions): VoyantWorkerJobHost; /** * Project graph schedules onto Cloudflare Cron Triggers when their cadence is * exact in UTC. The remaining jobs stay callable through the fixed HTTP route * so the managed scheduler can own their cadence. */ export declare function compileCloudflareProductJobSchedules(jobs: readonly VoyantGraphProvisionedJob[]): readonly VoyantCloudflareProductJobSchedule[]; export interface VoyantManagedProductJobHealthEnv { ORIGIN_TRUST_SECRET?: string; VOYANT_CLOUD_PRODUCT_JOB_HEALTH_URL?: string; VOYANT_CLOUD_WORKLOAD_ENVIRONMENT_ID?: string; } /** Create the same best-effort terminal callback used by managed Node hosts. */ export declare function createVoyantWorkerJobHealthReporter(env: VoyantManagedProductJobHealthEnv, fetchImplementation?: typeof fetch): ((report: VoyantNodeJobExecutionReport) => Promise) | undefined;