Skip to content
File

Blob: src/cloudflare/internal/workers.d.ts

typescript71 lines
1// Copyright (c) 2026 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5export class DurableObject {
6 constructor(ctx: unknown, env: unknown);
7 
8 ctx: unknown;
9 env: unknown;
10}
11 
12export class WorkerEntrypoint {
13 constructor(ctx: unknown, env: unknown);
14 
15 ctx: unknown;
16 env: unknown;
17}
18 
19export class WorkflowEntrypoint {
20 constructor(ctx: unknown, env: unknown);
21 
22 ctx: unknown;
23 env: unknown;
24}
25 
26export class RpcStub {
27 constructor(server: object);
28}
29 
30export class RpcPromise {}
31 
32export class RpcProperty {}
33 
34export class RpcTarget {}
35 
36export class ServiceStub {}
37 
38export function waitUntil(promise: Promise<unknown>): void;
39 
40// Stubs for the C++ CacheContext types (see src/workerd/api/global-scope.h).
41// The full interface is also generated in types/generated-snapshot/ from C++ RTTI.
42// If you change the C++ types, update these to match.
43export interface CachePurgeError {
44 code: number;
45 message: string;
46}
47 
48export interface CachePurgeResult {
49 success: boolean;
50 errors: CachePurgeError[];
51}
52 
53export interface CachePurgeOptions {
54 tags?: string[];
55 pathPrefixes?: string[];
56 purgeEverything?: boolean;
57}
58 
59export interface CacheContext {
60 purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
61}
62 
63export function getCtxCache(): CacheContext | undefined;
64 
65export function abortIsolate(reason?: string): never;
66 
67// True when the workerd_experimental compat flag is enabled. Use this for gating experimental
68// re-exports in user-facing wrappers; Cloudflare.compatibilityFlags filters out experimental
69// flags themselves so it cannot be used to detect this.
70export const isExperimental: boolean;