-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtypes.ts
More file actions
172 lines (163 loc) · 3.54 KB
/
Copy pathtypes.ts
File metadata and controls
172 lines (163 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/**
* Wrangler configuration schema
* Represents the structure of wrangler.jsonc file
*/
export interface WranglerConfig {
name: string;
main: string;
compatibility_date: string;
compatibility_flags?: string[];
no_bundle?: boolean;
assets?: {
directory?: string;
not_found_handling?: string;
run_worker_first?: boolean | string[];
binding?: string;
};
observability?: {
enabled: boolean;
};
vars?: Record<string, string>;
durable_objects?: {
bindings?: Array<{
name: string;
class_name: string;
}>;
};
kv_namespaces?: Array<{
binding: string;
id: string;
preview_id?: string;
}>;
d1_databases?: Array<{
binding: string;
database_name: string;
database_id: string;
}>;
r2_buckets?: Array<{
binding: string;
bucket_name: string;
}>;
migrations?: Array<{
tag: string;
new_classes?: string[];
new_sqlite_classes?: string[];
renamed_classes?: Array<{
from: string;
to: string;
}>;
deleted_classes?: string[];
}>;
services?: Array<{
binding: string;
service: string;
}>;
}
/**
* Asset configuration for Worker deployment
*/
export interface AssetConfig {
html_handling?:
| 'auto-trailing-slash'
| 'drop-trailing-slash'
| 'force-trailing-slash'
| 'none';
not_found_handling?: 'single-page-application' | '404-page' | 'none';
serve_directly?: boolean;
run_worker_first?: boolean | string[];
binding?: string;
}
/**
* Worker deployment metadata
* Used in the multipart form data when deploying
*/
export interface WorkerObservability {
enabled: boolean;
head_sampling_rate: number;
logs: {
enabled: boolean;
head_sampling_rate: number;
persist: boolean;
invocation_logs: boolean;
};
traces: {
enabled: boolean;
persist: boolean;
head_sampling_rate: number;
};
}
export interface WorkerMetadata {
main_module: string;
compatibility_date: string;
compatibility_flags?: string[];
assets?: {
jwt: string;
config?: AssetConfig;
};
bindings?: WorkerBinding[];
vars?: Record<string, string>;
migrations?: DurableObjectMigration;
exported_handlers?: string[]; // For Durable Object class exports
observability?: WorkerObservability;
}
/**
* Durable Object migration configuration
* Matches Cloudflare API structure
*/
export interface DurableObjectMigration {
tag: string;
new_classes?: string[];
new_sqlite_classes?: string[];
renamed_classes?: Array<{
from: string;
to: string;
}>;
deleted_classes?: string[];
}
/**
* Worker binding configuration
*/
export interface WorkerBinding {
name: string;
type: string;
class_name?: string; // For Durable Objects
namespace_id?: string; // For KV namespaces
database_id?: string; // For D1 databases
bucket_name?: string; // For R2 buckets
}
/**
* Asset upload session response from Cloudflare
*/
export interface UploadAssetSession {
jwt: string; // JWT token for authenticating asset uploads
buckets: string[][]; // Arrays of file hashes grouped for batch upload
}
/**
* Asset manifest mapping file paths to their metadata
*/
export interface AssetManifest {
[path: string]: {
hash: string; // SHA256 hash (first 32 chars)
size: number; // File size in bytes
};
}
/**
* Base deployment configuration
*/
export interface DeployConfig {
accountId: string;
apiToken: string;
scriptName: string;
compatibilityDate: string;
compatibilityFlags?: string[];
workerContent: string;
assets?: AssetManifest;
bindings?: WorkerBinding[];
vars?: Record<string, string>;
}
/**
* Deployment configuration for Workers for Platforms
*/
export interface DispatchDeployConfig extends DeployConfig {
dispatchNamespace: string;
}