Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Add ScheduledEvent #61

Merged
merged 2 commits into from
Oct 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ interface FetchEvent {
passThroughOnException: () => void;
}

interface ScheduledEvent {
/**
* The type of event. This will always return `"scheduled"`.
*/
type: string;
/**
* The time the `ScheduledEvent` was scheduled to be executed in
* milliseconds since January 1, 1970, UTC.
* It can be parsed as `new Date(event.scheduledTime)`
*/
scheduledTime: number;
/**
* Use this method to notify the runtime to wait for asynchronous tasks
* (e.g. logging, analytics to third-party services, streaming and caching).
* The first `event.waitUntil` to fail will be observed and recorded as the
* status in the Cron Trigger Past Events table. Otherwise, it will be
* reported as a Success.
*/
waitUntil(promise: Promise<any>): void;
}

interface BasicImageTransformations {
/**
* Maximum width in image pixels. The value must be an integer.
Expand Down Expand Up @@ -286,6 +307,7 @@ interface RequestInit {
}

declare function addEventListener(type: 'fetch', handler: (event: FetchEvent) => void): void;
declare function addEventListener(type: 'scheduled', handler: (event: ScheduledEvent) => void): void;

interface Request {
cf: IncomingRequestCfProperties;
Expand Down