@cloudflare/deploy-helpers 0.27.2 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context-DOE6X8vr.d.mts +212 -0
- package/dist/context.d.mts +2 -3
- package/dist/context.mjs +38 -5
- package/dist/create-worker-upload-form-BlSu1EfR.mjs +578 -0
- package/dist/create-worker-upload-form.d.mts +11 -13
- package/dist/create-worker-upload-form.mjs +1 -5
- package/dist/index.d.mts +717 -613
- package/dist/index.mjs +16035 -33673
- package/dist/rolldown-runtime-BMUeFane.mjs +30 -0
- package/dist/startup-profile.d.mts +13 -13
- package/dist/startup-profile.mjs +492 -610
- package/package.json +10 -10
- package/dist/chunk-DSGVRFIS.mjs +0 -828
- package/dist/chunk-U6NEESU5.mjs +0 -41
- package/dist/chunk-Y4VATABS.mjs +0 -27
- package/dist/context-BY_xpg-t.d.mts +0 -211
- package/dist/metafile-esm.json +0 -1
package/dist/chunk-DSGVRFIS.mjs
DELETED
|
@@ -1,828 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { __name } from './chunk-U6NEESU5.mjs';
|
|
3
|
-
import assert from 'node:assert';
|
|
4
|
-
import { readFileSync } from 'node:fs';
|
|
5
|
-
import path, { resolve } from 'node:path';
|
|
6
|
-
import { UserError, extractBindingsOfType, INHERIT_SYMBOL, isUnsafeBindingType } from '@cloudflare/workers-utils';
|
|
7
|
-
import { FormData } from 'undici';
|
|
8
|
-
import { spawnSync } from 'node:child_process';
|
|
9
|
-
import { sync } from 'command-exists';
|
|
10
|
-
|
|
11
|
-
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
12
|
-
function handleUnsafeCapnp(capnp) {
|
|
13
|
-
if (capnp.compiled_schema) {
|
|
14
|
-
return readFileSync(resolve(capnp.compiled_schema));
|
|
15
|
-
}
|
|
16
|
-
const { base_path, source_schemas } = capnp;
|
|
17
|
-
const capnpSchemas = (source_schemas ?? []).map(
|
|
18
|
-
(x) => resolve(base_path, x)
|
|
19
|
-
);
|
|
20
|
-
if (!sync("capnp")) {
|
|
21
|
-
throw new UserError(
|
|
22
|
-
"The capnp compiler is required to upload capnp schemas, but is not present.",
|
|
23
|
-
{ telemetryMessage: "capnp compiler missing" }
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
const srcPrefix = resolve(base_path ?? ".");
|
|
27
|
-
const capnpProcess = spawnSync(
|
|
28
|
-
"capnp",
|
|
29
|
-
["compile", "-o-", `--src-prefix=${srcPrefix}`, ...capnpSchemas],
|
|
30
|
-
// This number was chosen arbitrarily. If you get ENOBUFS because your compiled schema is still
|
|
31
|
-
// too large, then we may need to bump this again or figure out another approach.
|
|
32
|
-
// https://github.com/cloudflare/workers-sdk/pull/10217
|
|
33
|
-
{ maxBuffer: 3 * 1024 * 1024 }
|
|
34
|
-
);
|
|
35
|
-
if (capnpProcess.error) {
|
|
36
|
-
throw capnpProcess.error;
|
|
37
|
-
}
|
|
38
|
-
if (capnpProcess.stderr.length) {
|
|
39
|
-
throw new Error(capnpProcess.stderr.toString());
|
|
40
|
-
}
|
|
41
|
-
return capnpProcess.stdout;
|
|
42
|
-
}
|
|
43
|
-
__name(handleUnsafeCapnp, "handleUnsafeCapnp");
|
|
44
|
-
|
|
45
|
-
// src/deploy/helpers/create-worker-upload-form.ts
|
|
46
|
-
var moduleTypeMimeType = {
|
|
47
|
-
esm: "application/javascript+module",
|
|
48
|
-
commonjs: "application/javascript",
|
|
49
|
-
"compiled-wasm": "application/wasm",
|
|
50
|
-
buffer: "application/octet-stream",
|
|
51
|
-
text: "text/plain",
|
|
52
|
-
python: "text/x-python",
|
|
53
|
-
"python-requirement": "text/x-python-requirement"
|
|
54
|
-
};
|
|
55
|
-
function toMimeType(type) {
|
|
56
|
-
const mimeType = moduleTypeMimeType[type];
|
|
57
|
-
if (mimeType === void 0) {
|
|
58
|
-
throw new TypeError("Unsupported module: " + type);
|
|
59
|
-
}
|
|
60
|
-
return mimeType;
|
|
61
|
-
}
|
|
62
|
-
__name(toMimeType, "toMimeType");
|
|
63
|
-
function fromMimeType(mimeType) {
|
|
64
|
-
const moduleType = Object.keys(moduleTypeMimeType).find(
|
|
65
|
-
(type) => moduleTypeMimeType[type] === mimeType
|
|
66
|
-
);
|
|
67
|
-
if (moduleType === void 0) {
|
|
68
|
-
throw new TypeError("Unsupported mime type: " + mimeType);
|
|
69
|
-
}
|
|
70
|
-
return moduleType;
|
|
71
|
-
}
|
|
72
|
-
__name(fromMimeType, "fromMimeType");
|
|
73
|
-
function createWorkerUploadForm(worker, bindings, options) {
|
|
74
|
-
const formData = new FormData();
|
|
75
|
-
const {
|
|
76
|
-
main,
|
|
77
|
-
sourceMaps,
|
|
78
|
-
migrations,
|
|
79
|
-
code_update_strategy,
|
|
80
|
-
exports: configuredExports,
|
|
81
|
-
compatibility_date,
|
|
82
|
-
compatibility_flags,
|
|
83
|
-
keepVars,
|
|
84
|
-
keepSecrets,
|
|
85
|
-
keepBindings,
|
|
86
|
-
logpush,
|
|
87
|
-
placement,
|
|
88
|
-
tail_consumers,
|
|
89
|
-
streaming_tail_consumers,
|
|
90
|
-
limits,
|
|
91
|
-
annotations,
|
|
92
|
-
keep_assets,
|
|
93
|
-
assets,
|
|
94
|
-
observability,
|
|
95
|
-
cache,
|
|
96
|
-
package_dependencies
|
|
97
|
-
} = worker;
|
|
98
|
-
const assetConfig = {
|
|
99
|
-
html_handling: assets?.assetConfig?.html_handling,
|
|
100
|
-
not_found_handling: assets?.assetConfig?.not_found_handling,
|
|
101
|
-
base_path: assets?.assetConfig?.base_path,
|
|
102
|
-
run_worker_first: assets?.run_worker_first,
|
|
103
|
-
_redirects: assets?._redirects,
|
|
104
|
-
_headers: assets?._headers
|
|
105
|
-
};
|
|
106
|
-
if (assets && !assets.routerConfig.has_user_worker) {
|
|
107
|
-
formData.set(
|
|
108
|
-
"metadata",
|
|
109
|
-
JSON.stringify({
|
|
110
|
-
assets: {
|
|
111
|
-
jwt: assets.jwt,
|
|
112
|
-
config: assetConfig
|
|
113
|
-
},
|
|
114
|
-
...annotations && { annotations },
|
|
115
|
-
...compatibility_date && { compatibility_date },
|
|
116
|
-
...compatibility_flags && { compatibility_flags }
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
return formData;
|
|
120
|
-
}
|
|
121
|
-
let { modules } = worker;
|
|
122
|
-
const metadataBindings = [];
|
|
123
|
-
const plain_text = extractBindingsOfType("plain_text", bindings);
|
|
124
|
-
const json_bindings = extractBindingsOfType("json", bindings);
|
|
125
|
-
const secret_text = extractBindingsOfType("secret_text", bindings);
|
|
126
|
-
const kv_namespaces = extractBindingsOfType("kv_namespace", bindings);
|
|
127
|
-
const send_email = extractBindingsOfType("send_email", bindings);
|
|
128
|
-
const durable_objects = extractBindingsOfType(
|
|
129
|
-
"durable_object_namespace",
|
|
130
|
-
bindings
|
|
131
|
-
);
|
|
132
|
-
const workflows = extractBindingsOfType("workflow", bindings);
|
|
133
|
-
const queues = extractBindingsOfType("queue", bindings);
|
|
134
|
-
const r2_buckets = extractBindingsOfType("r2_bucket", bindings);
|
|
135
|
-
const d1_databases = extractBindingsOfType("d1", bindings);
|
|
136
|
-
const vectorize = extractBindingsOfType("vectorize", bindings);
|
|
137
|
-
const ai_search_namespaces = extractBindingsOfType(
|
|
138
|
-
"ai_search_namespace",
|
|
139
|
-
bindings
|
|
140
|
-
);
|
|
141
|
-
const ai_search = extractBindingsOfType("ai_search", bindings);
|
|
142
|
-
const agent_memory = extractBindingsOfType("agent_memory", bindings);
|
|
143
|
-
const hyperdrive = extractBindingsOfType("hyperdrive", bindings);
|
|
144
|
-
const secrets_store_secrets = extractBindingsOfType(
|
|
145
|
-
"secrets_store_secret",
|
|
146
|
-
bindings
|
|
147
|
-
);
|
|
148
|
-
const artifacts = extractBindingsOfType("artifacts", bindings);
|
|
149
|
-
const unsafe_hello_world = extractBindingsOfType(
|
|
150
|
-
"unsafe_hello_world",
|
|
151
|
-
bindings
|
|
152
|
-
);
|
|
153
|
-
const flagship = extractBindingsOfType("flagship", bindings);
|
|
154
|
-
const ratelimits = extractBindingsOfType("ratelimit", bindings);
|
|
155
|
-
const vpc_services = extractBindingsOfType("vpc_service", bindings);
|
|
156
|
-
const vpc_networks = extractBindingsOfType("vpc_network", bindings);
|
|
157
|
-
const services = extractBindingsOfType("service", bindings);
|
|
158
|
-
const analytics_engine_datasets = extractBindingsOfType(
|
|
159
|
-
"analytics_engine",
|
|
160
|
-
bindings
|
|
161
|
-
);
|
|
162
|
-
const dispatch_namespaces = extractBindingsOfType(
|
|
163
|
-
"dispatch_namespace",
|
|
164
|
-
bindings
|
|
165
|
-
);
|
|
166
|
-
const mtls_certificates = extractBindingsOfType("mtls_certificate", bindings);
|
|
167
|
-
const pipelines = extractBindingsOfType("pipeline", bindings);
|
|
168
|
-
const k2 = extractBindingsOfType("k2", bindings);
|
|
169
|
-
const worker_loaders = extractBindingsOfType("worker_loader", bindings);
|
|
170
|
-
const logfwdr = extractBindingsOfType("logfwdr", bindings);
|
|
171
|
-
const wasm_modules = extractBindingsOfType("wasm_module", bindings);
|
|
172
|
-
const browser = extractBindingsOfType("browser", bindings)[0];
|
|
173
|
-
const analytics = extractBindingsOfType("analytics", bindings)[0];
|
|
174
|
-
const ai = extractBindingsOfType("ai", bindings)[0];
|
|
175
|
-
const images = extractBindingsOfType("images", bindings)[0];
|
|
176
|
-
const stream = extractBindingsOfType("stream", bindings)[0];
|
|
177
|
-
const media = extractBindingsOfType("media", bindings)[0];
|
|
178
|
-
const version_metadata = extractBindingsOfType(
|
|
179
|
-
"version_metadata",
|
|
180
|
-
bindings
|
|
181
|
-
)[0];
|
|
182
|
-
const assetsBinding = extractBindingsOfType("assets", bindings)[0];
|
|
183
|
-
const text_blobs = extractBindingsOfType("text_blob", bindings);
|
|
184
|
-
const data_blobs = extractBindingsOfType("data_blob", bindings);
|
|
185
|
-
const inherit_bindings = extractBindingsOfType("inherit", bindings);
|
|
186
|
-
inherit_bindings.forEach(({ binding }) => {
|
|
187
|
-
metadataBindings.push({ name: binding, type: "inherit" });
|
|
188
|
-
});
|
|
189
|
-
plain_text.forEach(({ binding, value }) => {
|
|
190
|
-
metadataBindings.push({ name: binding, type: "plain_text", text: value });
|
|
191
|
-
});
|
|
192
|
-
json_bindings.forEach(({ binding, value }) => {
|
|
193
|
-
metadataBindings.push({ name: binding, type: "json", json: value });
|
|
194
|
-
});
|
|
195
|
-
secret_text.forEach(({ binding, value }) => {
|
|
196
|
-
metadataBindings.push({ name: binding, type: "secret_text", text: value });
|
|
197
|
-
});
|
|
198
|
-
kv_namespaces.forEach(({ id, binding, raw }) => {
|
|
199
|
-
if (options?.dryRun) {
|
|
200
|
-
id ??= INHERIT_SYMBOL;
|
|
201
|
-
}
|
|
202
|
-
if (id === void 0) {
|
|
203
|
-
throw new UserError(`${binding} bindings must have an "id" field`, {
|
|
204
|
-
telemetryMessage: "kv namespace binding missing id"
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
if (id === INHERIT_SYMBOL) {
|
|
208
|
-
metadataBindings.push({
|
|
209
|
-
name: binding,
|
|
210
|
-
type: "inherit"
|
|
211
|
-
});
|
|
212
|
-
} else {
|
|
213
|
-
metadataBindings.push({
|
|
214
|
-
name: binding,
|
|
215
|
-
type: "kv_namespace",
|
|
216
|
-
namespace_id: id,
|
|
217
|
-
raw
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
send_email.forEach((emailBinding) => {
|
|
222
|
-
const shared = {
|
|
223
|
-
name: emailBinding.name,
|
|
224
|
-
type: "send_email",
|
|
225
|
-
allowed_sender_addresses: emailBinding.allowed_sender_addresses
|
|
226
|
-
};
|
|
227
|
-
if (emailBinding.destination_address !== void 0) {
|
|
228
|
-
metadataBindings.push({
|
|
229
|
-
...shared,
|
|
230
|
-
destination_address: emailBinding.destination_address
|
|
231
|
-
});
|
|
232
|
-
} else if (emailBinding.allowed_destination_addresses !== void 0) {
|
|
233
|
-
metadataBindings.push({
|
|
234
|
-
...shared,
|
|
235
|
-
allowed_destination_addresses: emailBinding.allowed_destination_addresses
|
|
236
|
-
});
|
|
237
|
-
} else {
|
|
238
|
-
metadataBindings.push(shared);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
durable_objects.forEach(({ name, class_name, script_name, environment }) => {
|
|
242
|
-
metadataBindings.push({
|
|
243
|
-
name,
|
|
244
|
-
type: "durable_object_namespace",
|
|
245
|
-
class_name,
|
|
246
|
-
...script_name && { script_name },
|
|
247
|
-
...environment && { environment }
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
workflows.forEach(({ binding, name, class_name, script_name, raw }) => {
|
|
251
|
-
metadataBindings.push({
|
|
252
|
-
type: "workflow",
|
|
253
|
-
name: binding,
|
|
254
|
-
workflow_name: name,
|
|
255
|
-
class_name,
|
|
256
|
-
script_name,
|
|
257
|
-
raw
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
queues.forEach(({ binding, queue_name, delivery_delay, raw }) => {
|
|
261
|
-
if (options?.dryRun) {
|
|
262
|
-
queue_name ??= INHERIT_SYMBOL;
|
|
263
|
-
}
|
|
264
|
-
if (queue_name === void 0) {
|
|
265
|
-
throw new UserError(
|
|
266
|
-
`${binding} bindings must have a "queue" field. Add a "queue" field to the producer in your Worker configuration specifying the name of the Queue to bind to.`,
|
|
267
|
-
{
|
|
268
|
-
telemetryMessage: "queue binding missing name"
|
|
269
|
-
}
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
if (queue_name === INHERIT_SYMBOL) {
|
|
273
|
-
metadataBindings.push({ name: binding, type: "inherit" });
|
|
274
|
-
} else {
|
|
275
|
-
metadataBindings.push({
|
|
276
|
-
type: "queue",
|
|
277
|
-
name: binding,
|
|
278
|
-
queue_name,
|
|
279
|
-
delivery_delay,
|
|
280
|
-
raw
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
r2_buckets.forEach(({ binding, bucket_name, jurisdiction, raw }) => {
|
|
285
|
-
if (options?.dryRun) {
|
|
286
|
-
bucket_name ??= INHERIT_SYMBOL;
|
|
287
|
-
}
|
|
288
|
-
if (bucket_name === void 0) {
|
|
289
|
-
throw new UserError(
|
|
290
|
-
`${binding} bindings must have a "bucket_name" field. Add a "bucket_name" field to the binding in your Worker configuration specifying the name of the R2 bucket to bind to.`,
|
|
291
|
-
{ telemetryMessage: "r2 bucket binding missing bucket_name" }
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
if (bucket_name === INHERIT_SYMBOL) {
|
|
295
|
-
metadataBindings.push({
|
|
296
|
-
name: binding,
|
|
297
|
-
type: "inherit"
|
|
298
|
-
});
|
|
299
|
-
} else {
|
|
300
|
-
metadataBindings.push({
|
|
301
|
-
name: binding,
|
|
302
|
-
type: "r2_bucket",
|
|
303
|
-
bucket_name,
|
|
304
|
-
jurisdiction,
|
|
305
|
-
raw
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
d1_databases.forEach(
|
|
310
|
-
({ binding, database_id, database_internal_env, raw }) => {
|
|
311
|
-
if (options?.dryRun) {
|
|
312
|
-
database_id ??= INHERIT_SYMBOL;
|
|
313
|
-
}
|
|
314
|
-
if (database_id === void 0) {
|
|
315
|
-
throw new UserError(
|
|
316
|
-
`${binding} bindings must have a "database_id" field. Add a "database_id" field to the binding in your Worker configuration specifying the ID of the D1 database to bind to.`,
|
|
317
|
-
{ telemetryMessage: "d1 database binding missing database_id" }
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
if (database_id === INHERIT_SYMBOL) {
|
|
321
|
-
metadataBindings.push({
|
|
322
|
-
name: binding,
|
|
323
|
-
type: "inherit"
|
|
324
|
-
});
|
|
325
|
-
} else {
|
|
326
|
-
metadataBindings.push({
|
|
327
|
-
name: binding,
|
|
328
|
-
type: "d1",
|
|
329
|
-
id: database_id,
|
|
330
|
-
internalEnv: database_internal_env,
|
|
331
|
-
raw
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
);
|
|
336
|
-
vectorize.forEach(({ binding, index_name, raw }) => {
|
|
337
|
-
metadataBindings.push({
|
|
338
|
-
name: binding,
|
|
339
|
-
type: "vectorize",
|
|
340
|
-
index_name,
|
|
341
|
-
raw
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
ai_search_namespaces.forEach(({ binding, namespace }) => {
|
|
345
|
-
if (options?.dryRun) {
|
|
346
|
-
namespace ??= INHERIT_SYMBOL;
|
|
347
|
-
}
|
|
348
|
-
if (namespace === void 0) {
|
|
349
|
-
throw new UserError(
|
|
350
|
-
`${binding} bindings must have a "namespace" field. Add a "namespace" field to the binding in your Worker configuration specifying the AI Search namespace to bind to.`,
|
|
351
|
-
{
|
|
352
|
-
telemetryMessage: "ai search namespace binding missing namespace"
|
|
353
|
-
}
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
if (namespace === INHERIT_SYMBOL) {
|
|
357
|
-
metadataBindings.push({
|
|
358
|
-
name: binding,
|
|
359
|
-
type: "inherit"
|
|
360
|
-
});
|
|
361
|
-
} else {
|
|
362
|
-
metadataBindings.push({
|
|
363
|
-
name: binding,
|
|
364
|
-
type: "ai_search_namespace",
|
|
365
|
-
namespace
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
ai_search.forEach(({ binding, instance_name }) => {
|
|
370
|
-
metadataBindings.push({
|
|
371
|
-
name: binding,
|
|
372
|
-
type: "ai_search",
|
|
373
|
-
instance_name
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
agent_memory.forEach(({ binding, namespace }) => {
|
|
377
|
-
if (options?.dryRun) {
|
|
378
|
-
namespace ??= INHERIT_SYMBOL;
|
|
379
|
-
}
|
|
380
|
-
if (namespace === void 0) {
|
|
381
|
-
throw new UserError(
|
|
382
|
-
`${binding} bindings must have a "namespace" field. Add a "namespace" field to the binding in your Worker configuration specifying the namespace to bind to.`,
|
|
383
|
-
{
|
|
384
|
-
telemetryMessage: false
|
|
385
|
-
}
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
if (namespace === INHERIT_SYMBOL) {
|
|
389
|
-
metadataBindings.push({
|
|
390
|
-
name: binding,
|
|
391
|
-
type: "inherit"
|
|
392
|
-
});
|
|
393
|
-
} else {
|
|
394
|
-
metadataBindings.push({
|
|
395
|
-
name: binding,
|
|
396
|
-
type: "agent_memory",
|
|
397
|
-
namespace
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
hyperdrive.forEach(({ binding, id }) => {
|
|
402
|
-
metadataBindings.push({
|
|
403
|
-
name: binding,
|
|
404
|
-
type: "hyperdrive",
|
|
405
|
-
id
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
secrets_store_secrets.forEach(({ binding, store_id, secret_name }) => {
|
|
409
|
-
metadataBindings.push({
|
|
410
|
-
name: binding,
|
|
411
|
-
type: "secrets_store_secret",
|
|
412
|
-
store_id,
|
|
413
|
-
secret_name
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
artifacts.forEach(({ binding, namespace }) => {
|
|
417
|
-
metadataBindings.push({
|
|
418
|
-
name: binding,
|
|
419
|
-
type: "artifacts",
|
|
420
|
-
namespace
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
unsafe_hello_world.forEach(({ binding, enable_timer }) => {
|
|
424
|
-
metadataBindings.push({
|
|
425
|
-
name: binding,
|
|
426
|
-
type: "unsafe_hello_world",
|
|
427
|
-
enable_timer
|
|
428
|
-
});
|
|
429
|
-
});
|
|
430
|
-
flagship.forEach(({ binding, app_id }) => {
|
|
431
|
-
if (options?.dryRun) {
|
|
432
|
-
app_id ??= INHERIT_SYMBOL;
|
|
433
|
-
}
|
|
434
|
-
if (app_id === void 0) {
|
|
435
|
-
throw new UserError(
|
|
436
|
-
`${binding} bindings must have an "app_id" field. Add an "app_id" field to the binding in your Worker configuration specifying the Flagship app to bind to.`,
|
|
437
|
-
{
|
|
438
|
-
telemetryMessage: "flagship binding missing app id"
|
|
439
|
-
}
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
metadataBindings.push(
|
|
443
|
-
app_id === INHERIT_SYMBOL ? { name: binding, type: "inherit" } : { name: binding, type: "flagship", app_id }
|
|
444
|
-
);
|
|
445
|
-
});
|
|
446
|
-
ratelimits.forEach(({ name, namespace_id, simple }) => {
|
|
447
|
-
metadataBindings.push({
|
|
448
|
-
name,
|
|
449
|
-
type: "ratelimit",
|
|
450
|
-
namespace_id,
|
|
451
|
-
simple
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
vpc_services.forEach(({ binding, service_id }) => {
|
|
455
|
-
metadataBindings.push({
|
|
456
|
-
name: binding,
|
|
457
|
-
type: "vpc_service",
|
|
458
|
-
service_id
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
vpc_networks.forEach(({ binding, tunnel_id, network_id }) => {
|
|
462
|
-
metadataBindings.push({
|
|
463
|
-
name: binding,
|
|
464
|
-
type: "vpc_network",
|
|
465
|
-
...tunnel_id !== void 0 ? { tunnel_id } : { network_id }
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
services.forEach(
|
|
469
|
-
({
|
|
470
|
-
binding,
|
|
471
|
-
service,
|
|
472
|
-
environment,
|
|
473
|
-
entrypoint,
|
|
474
|
-
props,
|
|
475
|
-
cross_account_grant
|
|
476
|
-
}) => {
|
|
477
|
-
metadataBindings.push({
|
|
478
|
-
name: binding,
|
|
479
|
-
type: "service",
|
|
480
|
-
service,
|
|
481
|
-
cross_account_grant,
|
|
482
|
-
...environment && { environment },
|
|
483
|
-
...entrypoint && { entrypoint },
|
|
484
|
-
...props && { props }
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
);
|
|
488
|
-
analytics_engine_datasets.forEach(({ binding, dataset }) => {
|
|
489
|
-
metadataBindings.push({
|
|
490
|
-
name: binding,
|
|
491
|
-
type: "analytics_engine",
|
|
492
|
-
dataset
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
dispatch_namespaces.forEach(({ binding, namespace, outbound }) => {
|
|
496
|
-
if (options?.dryRun) {
|
|
497
|
-
namespace ??= INHERIT_SYMBOL;
|
|
498
|
-
}
|
|
499
|
-
if (namespace === void 0) {
|
|
500
|
-
throw new UserError(
|
|
501
|
-
`${binding} bindings must have a "namespace" field. Add a "namespace" field to the binding in your Worker configuration specifying the dispatch namespace to bind to.`,
|
|
502
|
-
{
|
|
503
|
-
telemetryMessage: "dispatch namespace binding missing namespace"
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
}
|
|
507
|
-
if (namespace === INHERIT_SYMBOL) {
|
|
508
|
-
metadataBindings.push({ name: binding, type: "inherit" });
|
|
509
|
-
} else {
|
|
510
|
-
metadataBindings.push({
|
|
511
|
-
name: binding,
|
|
512
|
-
type: "dispatch_namespace",
|
|
513
|
-
namespace,
|
|
514
|
-
...outbound && {
|
|
515
|
-
outbound: {
|
|
516
|
-
worker: {
|
|
517
|
-
service: outbound.service,
|
|
518
|
-
environment: outbound.environment
|
|
519
|
-
},
|
|
520
|
-
params: outbound.parameters?.map((p) => ({ name: p }))
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
mtls_certificates.forEach(({ binding, certificate_id }) => {
|
|
527
|
-
metadataBindings.push({
|
|
528
|
-
name: binding,
|
|
529
|
-
type: "mtls_certificate",
|
|
530
|
-
certificate_id
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
pipelines.forEach(({ binding, stream: pipelineStream, pipeline }) => {
|
|
534
|
-
if (pipelineStream) {
|
|
535
|
-
metadataBindings.push({
|
|
536
|
-
name: binding,
|
|
537
|
-
type: "pipelines",
|
|
538
|
-
stream: pipelineStream
|
|
539
|
-
});
|
|
540
|
-
} else if (pipeline) {
|
|
541
|
-
metadataBindings.push({
|
|
542
|
-
name: binding,
|
|
543
|
-
type: "pipelines",
|
|
544
|
-
pipeline
|
|
545
|
-
});
|
|
546
|
-
} else {
|
|
547
|
-
throw new Error("Pipeline binding must specify a stream or pipeline");
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
k2.forEach(({ binding, stream: k2Stream }) => {
|
|
551
|
-
metadataBindings.push({ name: binding, type: "k2", stream: k2Stream });
|
|
552
|
-
});
|
|
553
|
-
worker_loaders.forEach(({ binding }) => {
|
|
554
|
-
metadataBindings.push({
|
|
555
|
-
name: binding,
|
|
556
|
-
type: "worker_loader"
|
|
557
|
-
});
|
|
558
|
-
});
|
|
559
|
-
logfwdr.forEach(({ name, destination }) => {
|
|
560
|
-
metadataBindings.push({
|
|
561
|
-
name,
|
|
562
|
-
type: "logfwdr",
|
|
563
|
-
destination
|
|
564
|
-
});
|
|
565
|
-
});
|
|
566
|
-
wasm_modules.forEach(({ binding: name, source }) => {
|
|
567
|
-
metadataBindings.push({
|
|
568
|
-
name,
|
|
569
|
-
type: "wasm_module",
|
|
570
|
-
part: name
|
|
571
|
-
});
|
|
572
|
-
formData.set(
|
|
573
|
-
name,
|
|
574
|
-
new File(
|
|
575
|
-
[
|
|
576
|
-
"contents" in source ? source.contents : readFileSync(source.path)
|
|
577
|
-
],
|
|
578
|
-
"path" in source ? source.path ?? name : name,
|
|
579
|
-
{ type: "application/wasm" }
|
|
580
|
-
)
|
|
581
|
-
);
|
|
582
|
-
});
|
|
583
|
-
if (browser !== void 0) {
|
|
584
|
-
metadataBindings.push({
|
|
585
|
-
name: browser.binding,
|
|
586
|
-
type: "browser",
|
|
587
|
-
raw: browser.raw
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
if (analytics !== void 0) {
|
|
591
|
-
metadataBindings.push({
|
|
592
|
-
name: analytics.binding,
|
|
593
|
-
type: "analytics"
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
if (ai !== void 0) {
|
|
597
|
-
metadataBindings.push({
|
|
598
|
-
name: ai.binding,
|
|
599
|
-
staging: ai.staging,
|
|
600
|
-
type: "ai",
|
|
601
|
-
raw: ai.raw
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
if (images !== void 0) {
|
|
605
|
-
metadataBindings.push({
|
|
606
|
-
name: images.binding,
|
|
607
|
-
type: "images",
|
|
608
|
-
raw: images.raw
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
if (stream !== void 0) {
|
|
612
|
-
metadataBindings.push({
|
|
613
|
-
name: stream.binding,
|
|
614
|
-
type: "stream"
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
if (media !== void 0) {
|
|
618
|
-
metadataBindings.push({
|
|
619
|
-
name: media.binding,
|
|
620
|
-
type: "media"
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
if (version_metadata !== void 0) {
|
|
624
|
-
metadataBindings.push({
|
|
625
|
-
name: version_metadata.binding,
|
|
626
|
-
type: "version_metadata"
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
if (assetsBinding !== void 0) {
|
|
630
|
-
metadataBindings.push({
|
|
631
|
-
name: assetsBinding.binding,
|
|
632
|
-
type: "assets"
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
text_blobs.forEach(({ binding: name, source }) => {
|
|
636
|
-
metadataBindings.push({
|
|
637
|
-
name,
|
|
638
|
-
type: "text_blob",
|
|
639
|
-
part: name
|
|
640
|
-
});
|
|
641
|
-
if (name !== "__STATIC_CONTENT_MANIFEST") {
|
|
642
|
-
if ("contents" in source) {
|
|
643
|
-
formData.set(
|
|
644
|
-
name,
|
|
645
|
-
new File([source.contents], source.path ?? name, {
|
|
646
|
-
type: "text/plain"
|
|
647
|
-
})
|
|
648
|
-
);
|
|
649
|
-
} else {
|
|
650
|
-
formData.set(
|
|
651
|
-
name,
|
|
652
|
-
new File([readFileSync(source.path)], source.path, {
|
|
653
|
-
type: "text/plain"
|
|
654
|
-
})
|
|
655
|
-
);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
data_blobs.forEach(({ binding: name, source }) => {
|
|
660
|
-
metadataBindings.push({
|
|
661
|
-
name,
|
|
662
|
-
type: "data_blob",
|
|
663
|
-
part: name
|
|
664
|
-
});
|
|
665
|
-
formData.set(
|
|
666
|
-
name,
|
|
667
|
-
new File(
|
|
668
|
-
[
|
|
669
|
-
"contents" in source ? source.contents : readFileSync(source.path)
|
|
670
|
-
],
|
|
671
|
-
"path" in source ? source.path ?? name : name,
|
|
672
|
-
{ type: "application/octet-stream" }
|
|
673
|
-
)
|
|
674
|
-
);
|
|
675
|
-
});
|
|
676
|
-
for (const [bindingName, config] of Object.entries(bindings ?? {})) {
|
|
677
|
-
if (isUnsafeBindingType(config.type) && config.type !== "unsafe_hello_world") {
|
|
678
|
-
const { type, ...data } = config;
|
|
679
|
-
metadataBindings.push({
|
|
680
|
-
name: bindingName,
|
|
681
|
-
type: type.slice("unsafe_".length),
|
|
682
|
-
...data
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
const manifestModuleName = "__STATIC_CONTENT_MANIFEST";
|
|
687
|
-
const hasManifest = modules?.some(({ name }) => name === manifestModuleName);
|
|
688
|
-
if (hasManifest && main.type === "esm") {
|
|
689
|
-
assert(modules !== void 0);
|
|
690
|
-
const subDirs = new Set(
|
|
691
|
-
modules.map((module) => path.posix.dirname(module.name))
|
|
692
|
-
);
|
|
693
|
-
for (const subDir of subDirs) {
|
|
694
|
-
if (subDir === ".") {
|
|
695
|
-
continue;
|
|
696
|
-
}
|
|
697
|
-
const relativePath = path.posix.relative(subDir, manifestModuleName);
|
|
698
|
-
const filePath = path.posix.join(subDir, manifestModuleName);
|
|
699
|
-
modules.push({
|
|
700
|
-
name: filePath,
|
|
701
|
-
filePath,
|
|
702
|
-
content: `export { default } from ${JSON.stringify(relativePath)};`,
|
|
703
|
-
type: "esm"
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
if (main.type === "commonjs") {
|
|
708
|
-
for (const module of Object.values([...modules || []])) {
|
|
709
|
-
if (module.name === "__STATIC_CONTENT_MANIFEST") {
|
|
710
|
-
formData.set(
|
|
711
|
-
module.name,
|
|
712
|
-
new File([module.content], module.name, {
|
|
713
|
-
type: "text/plain"
|
|
714
|
-
})
|
|
715
|
-
);
|
|
716
|
-
modules = modules?.filter((m) => m !== module);
|
|
717
|
-
} else if (module.type === "compiled-wasm" || module.type === "text" || module.type === "buffer") {
|
|
718
|
-
const name = module.name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
719
|
-
metadataBindings.push({
|
|
720
|
-
name,
|
|
721
|
-
type: module.type === "compiled-wasm" ? "wasm_module" : module.type === "text" ? "text_blob" : "data_blob",
|
|
722
|
-
part: name
|
|
723
|
-
});
|
|
724
|
-
formData.set(
|
|
725
|
-
name,
|
|
726
|
-
new File([module.content], module.name, {
|
|
727
|
-
type: module.type === "compiled-wasm" ? "application/wasm" : module.type === "text" ? "text/plain" : "application/octet-stream"
|
|
728
|
-
})
|
|
729
|
-
);
|
|
730
|
-
modules = modules?.filter((m) => m !== module);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
let capnpSchemaOutputFile;
|
|
735
|
-
if (options?.unsafe?.capnp) {
|
|
736
|
-
const capnpOutput = handleUnsafeCapnp(options.unsafe.capnp);
|
|
737
|
-
capnpSchemaOutputFile = `./capnp-${Date.now()}.compiled`;
|
|
738
|
-
formData.set(
|
|
739
|
-
capnpSchemaOutputFile,
|
|
740
|
-
new File([capnpOutput], capnpSchemaOutputFile, {
|
|
741
|
-
type: "application/octet-stream"
|
|
742
|
-
})
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
let keep_bindings = void 0;
|
|
746
|
-
if (keepVars) {
|
|
747
|
-
keep_bindings ??= [];
|
|
748
|
-
keep_bindings.push("plain_text", "json");
|
|
749
|
-
}
|
|
750
|
-
if (keepSecrets) {
|
|
751
|
-
keep_bindings ??= [];
|
|
752
|
-
keep_bindings.push("secret_text", "secret_key");
|
|
753
|
-
}
|
|
754
|
-
if (keepBindings) {
|
|
755
|
-
keep_bindings ??= [];
|
|
756
|
-
keep_bindings.push(...keepBindings);
|
|
757
|
-
}
|
|
758
|
-
const metadata = {
|
|
759
|
-
...main.type !== "commonjs" ? { main_module: main.name } : { body_part: main.name },
|
|
760
|
-
bindings: metadataBindings,
|
|
761
|
-
// Both directions of the container/Durable Object link are sent as
|
|
762
|
-
// configured: the API resolves a container's Durable Object from either this
|
|
763
|
-
// `class_name` or an `exports` entry naming the container by `name`.
|
|
764
|
-
containers: worker.containers === void 0 ? void 0 : worker.containers.map((c) => ({
|
|
765
|
-
...c.name !== void 0 && { name: c.name },
|
|
766
|
-
...c.class_name !== void 0 && { class_name: c.class_name },
|
|
767
|
-
...c.images !== void 0 && { images: c.images }
|
|
768
|
-
})),
|
|
769
|
-
...compatibility_date && { compatibility_date },
|
|
770
|
-
...compatibility_flags && {
|
|
771
|
-
compatibility_flags
|
|
772
|
-
},
|
|
773
|
-
...migrations && { migrations },
|
|
774
|
-
...code_update_strategy && { code_update_strategy },
|
|
775
|
-
...configuredExports && Object.keys(configuredExports).length > 0 && {
|
|
776
|
-
exports: configuredExports
|
|
777
|
-
},
|
|
778
|
-
capnp_schema: capnpSchemaOutputFile,
|
|
779
|
-
...keep_bindings && { keep_bindings },
|
|
780
|
-
...logpush !== void 0 && { logpush },
|
|
781
|
-
...placement && { placement },
|
|
782
|
-
...tail_consumers && { tail_consumers },
|
|
783
|
-
...streaming_tail_consumers && { streaming_tail_consumers },
|
|
784
|
-
...limits && { limits },
|
|
785
|
-
...annotations && { annotations },
|
|
786
|
-
...keep_assets !== void 0 && { keep_assets },
|
|
787
|
-
...assets && {
|
|
788
|
-
assets: {
|
|
789
|
-
jwt: assets.jwt,
|
|
790
|
-
config: assetConfig
|
|
791
|
-
}
|
|
792
|
-
},
|
|
793
|
-
...observability && { observability },
|
|
794
|
-
...cache && { cache_options: cache },
|
|
795
|
-
...package_dependencies?.length && { package_dependencies }
|
|
796
|
-
};
|
|
797
|
-
if (options?.unsafe?.metadata !== void 0) {
|
|
798
|
-
for (const key of Object.keys(options.unsafe.metadata)) {
|
|
799
|
-
metadata[key] = options.unsafe.metadata[key];
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
formData.set("metadata", JSON.stringify(metadata));
|
|
803
|
-
if (main.type === "commonjs" && modules && modules.length > 0) {
|
|
804
|
-
throw new TypeError(
|
|
805
|
-
"More than one module can only be specified when type = 'esm'"
|
|
806
|
-
);
|
|
807
|
-
}
|
|
808
|
-
for (const module of [main].concat(modules || [])) {
|
|
809
|
-
formData.set(
|
|
810
|
-
module.name,
|
|
811
|
-
new File([module.content], module.name, {
|
|
812
|
-
type: toMimeType(module.type ?? main.type ?? "esm")
|
|
813
|
-
})
|
|
814
|
-
);
|
|
815
|
-
}
|
|
816
|
-
for (const sourceMap of sourceMaps || []) {
|
|
817
|
-
formData.set(
|
|
818
|
-
sourceMap.name,
|
|
819
|
-
new File([sourceMap.content], sourceMap.name, {
|
|
820
|
-
type: "application/source-map"
|
|
821
|
-
})
|
|
822
|
-
);
|
|
823
|
-
}
|
|
824
|
-
return formData;
|
|
825
|
-
}
|
|
826
|
-
__name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
827
|
-
|
|
828
|
-
export { createWorkerUploadForm, fromMimeType, handleUnsafeCapnp, moduleTypeMimeType };
|