test: add 'cloudflare:test' module to export same typings as 'cloudflare:workers'

This commit is contained in:
2025-12-17 06:33:00 -05:00
parent 80a6f67ead
commit fb7990b274

View File

@@ -2,32 +2,32 @@
// Generated by Wrangler by running `wrangler types` (hash: df24977940a31745cb42d562b6645de2) // Generated by Wrangler by running `wrangler types` (hash: df24977940a31745cb42d562b6645de2)
// Runtime types generated with workerd@1.20251210.0 2025-11-28 nodejs_compat // Runtime types generated with workerd@1.20251210.0 2025-11-28 nodejs_compat
declare namespace Cloudflare { declare namespace Cloudflare {
interface GlobalProps { interface GlobalProps {
mainModule: typeof import("./src/index"); mainModule: typeof import("./src/index");
durableNamespaces: "AnilistDo"; durableNamespaces: "AnilistDo";
} }
interface Env { interface Env {
DELAYED_TASKS: KVNamespace; DELAYED_TASKS: KVNamespace;
ADMIN_SDK_JSON: string; ADMIN_SDK_JSON: string;
CLOUDFLARE_TOKEN: string; CLOUDFLARE_TOKEN: string;
CLOUDFLARE_D1_TOKEN: string; CLOUDFLARE_D1_TOKEN: string;
CLOUDFLARE_ACCOUNT_ID: string; CLOUDFLARE_ACCOUNT_ID: string;
CLOUDFLARE_DATABASE_ID: string; CLOUDFLARE_DATABASE_ID: string;
PROXY_URL: string; PROXY_URL: string;
USE_MOCK_DATA: string; USE_MOCK_DATA: string;
LOG_DB_QUERIES: string; LOG_DB_QUERIES: string;
ANILIST_DO: DurableObjectNamespace<import("./src/index").AnilistDo>; ANILIST_DO: DurableObjectNamespace<import("./src/index").AnilistDo>;
DB: D1Database; DB: D1Database;
ANILIST_UPDATES: Queue; ANILIST_UPDATES: Queue;
NEW_EPISODE: Queue; NEW_EPISODE: Queue;
} }
} }
interface Env extends Cloudflare.Env {} interface Env extends Cloudflare.Env { }
type StringifyValues<EnvType extends Record<string, unknown>> = { type StringifyValues<EnvType extends Record<string, unknown>> = {
[Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string; [Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string;
}; };
declare namespace NodeJS { declare namespace NodeJS {
interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "ADMIN_SDK_JSON" | "CLOUDFLARE_TOKEN" | "CLOUDFLARE_D1_TOKEN" | "CLOUDFLARE_ACCOUNT_ID" | "CLOUDFLARE_DATABASE_ID" | "PROXY_URL" | "USE_MOCK_DATA" | "LOG_DB_QUERIES">> {} interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "ADMIN_SDK_JSON" | "CLOUDFLARE_TOKEN" | "CLOUDFLARE_D1_TOKEN" | "CLOUDFLARE_ACCOUNT_ID" | "CLOUDFLARE_DATABASE_ID" | "PROXY_URL" | "USE_MOCK_DATA" | "LOG_DB_QUERIES">> { }
} }
// Begin runtime types // Begin runtime types
@@ -1644,7 +1644,7 @@ declare abstract class Body {
*/ */
declare var Response: { declare var Response: {
prototype: Response; prototype: Response;
new (body?: BodyInit | null, init?: ResponseInit): Response; new(body?: BodyInit | null, init?: ResponseInit): Response;
error(): Response; error(): Response;
redirect(url: string, status?: number): Response; redirect(url: string, status?: number): Response;
json(any: any, maybeInit?: (ResponseInit | Response)): Response; json(any: any, maybeInit?: (ResponseInit | Response)): Response;
@@ -2192,7 +2192,7 @@ interface ReadableStream<R = any> {
*/ */
declare const ReadableStream: { declare const ReadableStream: {
prototype: ReadableStream; prototype: ReadableStream;
new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>; new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>; new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
}; };
/** /**
@@ -3034,7 +3034,7 @@ type WebSocketEventMap = {
*/ */
declare var WebSocket: { declare var WebSocket: {
prototype: WebSocket; prototype: WebSocket;
new (url: string, protocols?: (string[] | string)): WebSocket; new(url: string, protocols?: (string[] | string)): WebSocket;
readonly READY_STATE_CONNECTING: number; readonly READY_STATE_CONNECTING: number;
readonly CONNECTING: number; readonly CONNECTING: number;
readonly READY_STATE_OPEN: number; readonly READY_STATE_OPEN: number;
@@ -3091,7 +3091,7 @@ interface WebSocket extends EventTarget<WebSocketEventMap> {
extensions: string | null; extensions: string | null;
} }
declare const WebSocketPair: { declare const WebSocketPair: {
new (): { new(): {
0: WebSocket; 0: WebSocket;
1: WebSocket; 1: WebSocket;
}; };
@@ -9413,21 +9413,21 @@ interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
certNotAfter: ""; certNotAfter: "";
} }
/** Possible outcomes of TLS verification */ /** Possible outcomes of TLS verification */
declare type CertVerificationStatus = declare type CertVerificationStatus =
/** Authentication succeeded */ /** Authentication succeeded */
"SUCCESS" "SUCCESS"
/** No certificate was presented */ /** No certificate was presented */
| "NONE" | "NONE"
/** Failed because the certificate was self-signed */ /** Failed because the certificate was self-signed */
| "FAILED:self signed certificate" | "FAILED:self signed certificate"
/** Failed because the certificate failed a trust chain check */ /** Failed because the certificate failed a trust chain check */
| "FAILED:unable to verify the first certificate" | "FAILED:unable to verify the first certificate"
/** Failed because the certificate not yet valid */ /** Failed because the certificate not yet valid */
| "FAILED:certificate is not yet valid" | "FAILED:certificate is not yet valid"
/** Failed because the certificate is expired */ /** Failed because the certificate is expired */
| "FAILED:certificate has expired" | "FAILED:certificate has expired"
/** Failed for another unspecified reason */ /** Failed for another unspecified reason */
| "FAILED"; | "FAILED";
/** /**
* An upstream endpoint's response to a TCP `keepalive` message from Cloudflare. * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
*/ */
@@ -9477,15 +9477,15 @@ interface D1ExecResult {
count: number; count: number;
duration: number; duration: number;
} }
type D1SessionConstraint = type D1SessionConstraint =
// Indicates that the first query should go to the primary, and the rest queries // Indicates that the first query should go to the primary, and the rest queries
// using the same D1DatabaseSession will go to any replica that is consistent with // using the same D1DatabaseSession will go to any replica that is consistent with
// the bookmark maintained by the session (returned by the first query). // the bookmark maintained by the session (returned by the first query).
'first-primary' 'first-primary'
// Indicates that the first query can go anywhere (primary or replica), and the rest queries // Indicates that the first query can go anywhere (primary or replica), and the rest queries
// using the same D1DatabaseSession will go to any replica that is consistent with // using the same D1DatabaseSession will go to any replica that is consistent with
// the bookmark maintained by the session (returned by the first query). // the bookmark maintained by the session (returned by the first query).
| 'first-unconstrained'; | 'first-unconstrained';
type D1SessionBookmark = string; type D1SessionBookmark = string;
declare abstract class D1Database { declare abstract class D1Database {
prepare(query: string): D1PreparedStatement; prepare(query: string): D1PreparedStatement;
@@ -9599,7 +9599,7 @@ declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMes
declare module "cloudflare:email" { declare module "cloudflare:email" {
let _EmailMessage: { let _EmailMessage: {
prototype: EmailMessage; prototype: EmailMessage;
new (from: string, to: string, raw: ReadableStream | string): EmailMessage; new(from: string, to: string, raw: ReadableStream | string): EmailMessage;
}; };
export { _EmailMessage as EmailMessage }; export { _EmailMessage as EmailMessage };
} }
@@ -10058,17 +10058,17 @@ declare namespace Rpc {
// The reason for using a generic type here is to build a serializable subset of structured // The reason for using a generic type here is to build a serializable subset of structured
// cloneable composite types. This allows types defined with the "interface" keyword to pass the // cloneable composite types. This allows types defined with the "interface" keyword to pass the
// serializable check as well. Otherwise, only types defined with the "type" keyword would pass. // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
type Serializable<T> = type Serializable<T> =
// Structured cloneables // Structured cloneables
BaseType BaseType
// Structured cloneable composites // Structured cloneable composites
| Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | { | Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | {
[K in keyof T]: K extends number | string ? Serializable<T[K]> : never; [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
} }
// Special types // Special types
| Stub<Stubable> | Stub<Stubable>
// Serialized as stubs, see `Stubify` // Serialized as stubs, see `Stubify`
| Stubable; | Stubable;
// Base type for all RPC stubs, including common memory management methods. // Base type for all RPC stubs, including common memory management methods.
// `T` is used as a marker type for unwrapping `Stub`s later. // `T` is used as a marker type for unwrapping `Stub`s later.
interface StubBase<T extends Stubable> extends Disposable { interface StubBase<T extends Stubable> extends Disposable {
@@ -10083,8 +10083,8 @@ declare namespace Rpc {
type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends { type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends {
[key: string | number]: any; [key: string | number]: any;
} ? { } ? {
[K in keyof T]: Stubify<T[K]>; [K in keyof T]: Stubify<T[K]>;
} : T; } : T;
// Recursively rewrite all `Stub<T>`s with the corresponding `T`s. // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
// Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
// `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
@@ -10092,8 +10092,8 @@ declare namespace Rpc {
type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends { type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends {
[key: string | number]: unknown; [key: string | number]: unknown;
} ? { } ? {
[K in keyof T]: Unstubify<T[K]>; [K in keyof T]: Unstubify<T[K]>;
} : T; } : T;
type UnstubifyAll<A extends any[]> = { type UnstubifyAll<A extends any[]> = {
[I in keyof A]: Unstubify<A[I]>; [I in keyof A]: Unstubify<A[I]>;
}; };
@@ -10166,7 +10166,7 @@ declare namespace Cloudflare {
[K in keyof MainModule]: LoopbackForExport<MainModule[K]> [K in keyof MainModule]: LoopbackForExport<MainModule[K]>
// If the export is listed in `durableNamespaces`, then it is also a // If the export is listed in `durableNamespaces`, then it is also a
// DurableObjectNamespace. // DurableObjectNamespace.
& (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {}); & (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {});
}; };
} }
declare namespace CloudflareWorkersModule { declare namespace CloudflareWorkersModule {
@@ -10251,6 +10251,9 @@ declare namespace CloudflareWorkersModule {
export const env: Cloudflare.Env; export const env: Cloudflare.Env;
export const exports: Cloudflare.Exports; export const exports: Cloudflare.Exports;
} }
declare module 'cloudflare:test' {
export = CloudflareWorkersModule;
}
declare module 'cloudflare:workers' { declare module 'cloudflare:workers' {
export = CloudflareWorkersModule; export = CloudflareWorkersModule;
} }
@@ -10822,10 +10825,10 @@ interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
} }
type InstanceStatus = { type InstanceStatus = {
status: 'queued' // means that instance is waiting to be started (see concurrency limits) status: 'queued' // means that instance is waiting to be started (see concurrency limits)
| 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running
| 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish
| 'waitingForPause' // instance is finishing the current work to pause | 'waitingForPause' // instance is finishing the current work to pause
| 'unknown'; | 'unknown';
error?: { error?: {
name: string; name: string;
message: string; message: string;