mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-20 15:25:50 +00:00
fix(cloud-artifacts): add type stubs so tsc passes without worker-configuration.d.ts
The wrangler-generated worker-configuration.d.ts is gitignored, causing CI to fail with missing ExportedHandler/Env/R2Bucket types. This file provides minimal stubs for all Cloudflare Workers types used by the artifact upload Worker. Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
This commit is contained in:
102
packages/cloud-artifacts/src/types.d.ts
vendored
Normal file
102
packages/cloud-artifacts/src/types.d.ts
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Minimal Cloudflare Workers type stubs for cloud-artifacts Worker.
|
||||
*
|
||||
* The canonical types are in worker-configuration.d.ts (generated by `wrangler types`,
|
||||
* gitignored). This file provides just enough so `tsc --noEmit` passes even when that
|
||||
* generated file is absent (e.g. CI, fresh clone).
|
||||
*/
|
||||
|
||||
// -- R2 types ---------------------------------------------------------------
|
||||
|
||||
interface R2Checksums {
|
||||
readonly md5?: ArrayBuffer
|
||||
readonly sha1?: ArrayBuffer
|
||||
readonly sha256?: ArrayBuffer
|
||||
readonly sha384?: ArrayBuffer
|
||||
readonly sha512?: ArrayBuffer
|
||||
}
|
||||
|
||||
interface R2HTTPMetadata {
|
||||
contentType?: string
|
||||
contentLanguage?: string
|
||||
contentDisposition?: string
|
||||
contentEncoding?: string
|
||||
cacheControl?: string
|
||||
cacheExpiry?: Date
|
||||
}
|
||||
|
||||
interface R2Range {
|
||||
offset: number
|
||||
length?: number
|
||||
}
|
||||
|
||||
declare abstract class R2Object {
|
||||
readonly key: string
|
||||
readonly version: string
|
||||
readonly size: number
|
||||
readonly etag: string
|
||||
readonly httpEtag: string
|
||||
readonly checksums: R2Checksums
|
||||
readonly uploaded: Date
|
||||
readonly httpMetadata?: R2HTTPMetadata
|
||||
readonly customMetadata?: Record<string, string>
|
||||
readonly range?: R2Range
|
||||
readonly storageClass: string
|
||||
readonly ssecKeyMd5?: string
|
||||
writeHttpMetadata(headers: Headers): void
|
||||
}
|
||||
|
||||
interface R2ObjectBody extends R2Object {
|
||||
get body(): ReadableStream
|
||||
get bodyUsed(): boolean
|
||||
}
|
||||
|
||||
interface R2PutOptions {
|
||||
httpMetadata?: R2HTTPMetadata | Headers
|
||||
customMetadata?: Record<string, string>
|
||||
}
|
||||
|
||||
interface R2Bucket {
|
||||
head(key: string): Promise<R2Object | null>
|
||||
get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>
|
||||
put(
|
||||
key: string,
|
||||
value:
|
||||
| ReadableStream
|
||||
| ArrayBuffer
|
||||
| ArrayBufferView
|
||||
| string
|
||||
| null
|
||||
| Blob,
|
||||
options?: R2PutOptions,
|
||||
): Promise<R2Object>
|
||||
delete(keys: string | string[]): Promise<void>
|
||||
}
|
||||
|
||||
// Empty placeholder — R2GetOptions is unused beyond an optional parameter
|
||||
type R2GetOptions = {}
|
||||
|
||||
// -- ExportedHandler -------------------------------------------------------
|
||||
|
||||
interface ExportedHandler<Env = unknown> {
|
||||
fetch?: (
|
||||
request: Request,
|
||||
env: Env,
|
||||
ctx: ExecutionContext,
|
||||
) => Response | Promise<Response>
|
||||
}
|
||||
|
||||
// -- Env -------------------------------------------------------------------
|
||||
// Wrangler-generated worker-configuration.d.ts supplies TOKEN via `wrangler secret put`.
|
||||
// This declaration provides the R2 binding + wrangler vars so the Worker compiles
|
||||
// without the generated file.
|
||||
|
||||
declare global {
|
||||
interface Env {
|
||||
BUCKET: R2Bucket
|
||||
TOKEN: string
|
||||
MAX_BYTES: string
|
||||
DEFAULT_TTL_DAYS: string
|
||||
PUBLIC_URL: string
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user