@cloudflare/deploy-helpers 0.27.2 → 0.29.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.
@@ -0,0 +1,579 @@
1
+ import "./rolldown-runtime-BMUeFane.mjs";
2
+ import assert from "node:assert";
3
+ import { readFileSync } from "node:fs";
4
+ import path, { resolve } from "node:path";
5
+ import { INHERIT_SYMBOL, UserError } from "@cloudflare/workers-utils";
6
+ import { extractBindingsOfType, isUnsafeBindingType } from "@cloudflare/workers-utils/config";
7
+ import { FormData } from "undici";
8
+ import { spawnSync } from "node:child_process";
9
+ import { sync } from "command-exists";
10
+ //#region src/deploy/helpers/capnp.ts
11
+ function handleUnsafeCapnp(capnp) {
12
+ if (capnp.compiled_schema) return readFileSync(resolve(capnp.compiled_schema));
13
+ const { base_path, source_schemas } = capnp;
14
+ const capnpSchemas = (source_schemas ?? []).map((x) => resolve(base_path, x));
15
+ if (!sync("capnp")) throw new UserError("The capnp compiler is required to upload capnp schemas, but is not present.", { telemetryMessage: "capnp compiler missing" });
16
+ const srcPrefix = resolve(base_path ?? ".");
17
+ const capnpProcess = spawnSync("capnp", [
18
+ "compile",
19
+ "-o-",
20
+ `--src-prefix=${srcPrefix}`,
21
+ ...capnpSchemas
22
+ ], { maxBuffer: 3145728 });
23
+ if (capnpProcess.error) throw capnpProcess.error;
24
+ if (capnpProcess.stderr.length) throw new Error(capnpProcess.stderr.toString());
25
+ return capnpProcess.stdout;
26
+ }
27
+ //#endregion
28
+ //#region src/deploy/helpers/create-worker-upload-form.ts
29
+ const moduleTypeMimeType = {
30
+ esm: "application/javascript+module",
31
+ commonjs: "application/javascript",
32
+ "compiled-wasm": "application/wasm",
33
+ buffer: "application/octet-stream",
34
+ text: "text/plain",
35
+ python: "text/x-python",
36
+ "python-requirement": "text/x-python-requirement"
37
+ };
38
+ function toMimeType(type) {
39
+ const mimeType = moduleTypeMimeType[type];
40
+ if (mimeType === void 0) throw new TypeError("Unsupported module: " + type);
41
+ return mimeType;
42
+ }
43
+ function fromMimeType(mimeType) {
44
+ const moduleType = Object.keys(moduleTypeMimeType).find((type) => moduleTypeMimeType[type] === mimeType);
45
+ if (moduleType === void 0) throw new TypeError("Unsupported mime type: " + mimeType);
46
+ return moduleType;
47
+ }
48
+ /**
49
+ * Creates a `FormData` upload from Worker data and bindings
50
+ */
51
+ function createWorkerUploadForm(worker, bindings, options) {
52
+ const formData = new FormData();
53
+ const { main, sourceMaps, migrations, code_update_strategy, exports: configuredExports, compatibility_date, compatibility_flags, keepVars, keepSecrets, keepBindings, logpush, placement, tail_consumers, streaming_tail_consumers, limits, annotations, keep_assets, assets, observability, cache, package_dependencies } = worker;
54
+ const assetConfig = {
55
+ html_handling: assets?.assetConfig?.html_handling,
56
+ not_found_handling: assets?.assetConfig?.not_found_handling,
57
+ base_path: assets?.assetConfig?.base_path,
58
+ run_worker_first: assets?.run_worker_first,
59
+ _redirects: assets?._redirects,
60
+ _headers: assets?._headers
61
+ };
62
+ if (assets && !assets.routerConfig.has_user_worker) {
63
+ formData.set("metadata", JSON.stringify({
64
+ assets: {
65
+ jwt: assets.jwt,
66
+ config: assetConfig
67
+ },
68
+ ...annotations && { annotations },
69
+ ...compatibility_date && { compatibility_date },
70
+ ...compatibility_flags && { compatibility_flags }
71
+ }));
72
+ return formData;
73
+ }
74
+ let { modules } = worker;
75
+ const metadataBindings = [];
76
+ const plain_text = extractBindingsOfType("plain_text", bindings);
77
+ const json_bindings = extractBindingsOfType("json", bindings);
78
+ const secret_text = extractBindingsOfType("secret_text", bindings);
79
+ const kv_namespaces = extractBindingsOfType("kv_namespace", bindings);
80
+ const send_email = extractBindingsOfType("send_email", bindings);
81
+ const durable_objects = extractBindingsOfType("durable_object_namespace", bindings);
82
+ const workflows = extractBindingsOfType("workflow", bindings);
83
+ const queues = extractBindingsOfType("queue", bindings);
84
+ const r2_buckets = extractBindingsOfType("r2_bucket", bindings);
85
+ const d1_databases = extractBindingsOfType("d1", bindings);
86
+ const vectorize = extractBindingsOfType("vectorize", bindings);
87
+ const ai_search_namespaces = extractBindingsOfType("ai_search_namespace", bindings);
88
+ const ai_search = extractBindingsOfType("ai_search", bindings);
89
+ const agent_memory = extractBindingsOfType("agent_memory", bindings);
90
+ const hyperdrive = extractBindingsOfType("hyperdrive", bindings);
91
+ const secrets_store_secrets = extractBindingsOfType("secrets_store_secret", bindings);
92
+ const artifacts = extractBindingsOfType("artifacts", bindings);
93
+ const unsafe_hello_world = extractBindingsOfType("unsafe_hello_world", bindings);
94
+ const flagship = extractBindingsOfType("flagship", bindings);
95
+ const ratelimits = extractBindingsOfType("ratelimit", bindings);
96
+ const vpc_services = extractBindingsOfType("vpc_service", bindings);
97
+ const vpc_networks = extractBindingsOfType("vpc_network", bindings);
98
+ const services = extractBindingsOfType("service", bindings);
99
+ const analytics_engine_datasets = extractBindingsOfType("analytics_engine", bindings);
100
+ const dispatch_namespaces = extractBindingsOfType("dispatch_namespace", bindings);
101
+ const mtls_certificates = extractBindingsOfType("mtls_certificate", bindings);
102
+ const pipelines = extractBindingsOfType("pipeline", bindings);
103
+ const k2 = extractBindingsOfType("k2", bindings);
104
+ const worker_loaders = extractBindingsOfType("worker_loader", bindings);
105
+ const logfwdr = extractBindingsOfType("logfwdr", bindings);
106
+ const wasm_modules = extractBindingsOfType("wasm_module", bindings);
107
+ const browser = extractBindingsOfType("browser", bindings)[0];
108
+ const analytics = extractBindingsOfType("analytics", bindings)[0];
109
+ const ai = extractBindingsOfType("ai", bindings)[0];
110
+ const images = extractBindingsOfType("images", bindings)[0];
111
+ const stream = extractBindingsOfType("stream", bindings)[0];
112
+ const media = extractBindingsOfType("media", bindings)[0];
113
+ const version_metadata = extractBindingsOfType("version_metadata", bindings)[0];
114
+ const assetsBinding = extractBindingsOfType("assets", bindings)[0];
115
+ const text_blobs = extractBindingsOfType("text_blob", bindings);
116
+ const data_blobs = extractBindingsOfType("data_blob", bindings);
117
+ extractBindingsOfType("inherit", bindings).forEach(({ binding }) => {
118
+ metadataBindings.push({
119
+ name: binding,
120
+ type: "inherit"
121
+ });
122
+ });
123
+ plain_text.forEach(({ binding, value }) => {
124
+ metadataBindings.push({
125
+ name: binding,
126
+ type: "plain_text",
127
+ text: value
128
+ });
129
+ });
130
+ json_bindings.forEach(({ binding, value }) => {
131
+ metadataBindings.push({
132
+ name: binding,
133
+ type: "json",
134
+ json: value
135
+ });
136
+ });
137
+ secret_text.forEach(({ binding, value }) => {
138
+ metadataBindings.push({
139
+ name: binding,
140
+ type: "secret_text",
141
+ text: value
142
+ });
143
+ });
144
+ kv_namespaces.forEach(({ id, binding, raw }) => {
145
+ if (options?.dryRun) id ??= INHERIT_SYMBOL;
146
+ if (id === void 0) throw new UserError(`${binding} bindings must have an "id" field`, { telemetryMessage: "kv namespace binding missing id" });
147
+ if (id === INHERIT_SYMBOL) metadataBindings.push({
148
+ name: binding,
149
+ type: "inherit"
150
+ });
151
+ else metadataBindings.push({
152
+ name: binding,
153
+ type: "kv_namespace",
154
+ namespace_id: id,
155
+ raw
156
+ });
157
+ });
158
+ send_email.forEach((emailBinding) => {
159
+ const shared = {
160
+ name: emailBinding.name,
161
+ type: "send_email",
162
+ allowed_sender_addresses: emailBinding.allowed_sender_addresses
163
+ };
164
+ if (emailBinding.destination_address !== void 0) metadataBindings.push({
165
+ ...shared,
166
+ destination_address: emailBinding.destination_address
167
+ });
168
+ else if (emailBinding.allowed_destination_addresses !== void 0) metadataBindings.push({
169
+ ...shared,
170
+ allowed_destination_addresses: emailBinding.allowed_destination_addresses
171
+ });
172
+ else metadataBindings.push(shared);
173
+ });
174
+ durable_objects.forEach(({ name, class_name, script_name, environment }) => {
175
+ metadataBindings.push({
176
+ name,
177
+ type: "durable_object_namespace",
178
+ class_name,
179
+ ...script_name && { script_name },
180
+ ...environment && { environment }
181
+ });
182
+ });
183
+ workflows.forEach(({ binding, name, class_name, script_name, raw }) => {
184
+ metadataBindings.push({
185
+ type: "workflow",
186
+ name: binding,
187
+ workflow_name: name,
188
+ class_name,
189
+ script_name,
190
+ raw
191
+ });
192
+ });
193
+ queues.forEach(({ binding, queue_name, delivery_delay, raw }) => {
194
+ if (options?.dryRun) queue_name ??= INHERIT_SYMBOL;
195
+ if (queue_name === void 0) throw new UserError(`${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.`, { telemetryMessage: "queue binding missing name" });
196
+ if (queue_name === INHERIT_SYMBOL) metadataBindings.push({
197
+ name: binding,
198
+ type: "inherit"
199
+ });
200
+ else metadataBindings.push({
201
+ type: "queue",
202
+ name: binding,
203
+ queue_name,
204
+ delivery_delay,
205
+ raw
206
+ });
207
+ });
208
+ r2_buckets.forEach(({ binding, bucket_name, jurisdiction, raw }) => {
209
+ if (options?.dryRun) bucket_name ??= INHERIT_SYMBOL;
210
+ if (bucket_name === void 0) throw new UserError(`${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.`, { telemetryMessage: "r2 bucket binding missing bucket_name" });
211
+ if (bucket_name === INHERIT_SYMBOL) metadataBindings.push({
212
+ name: binding,
213
+ type: "inherit"
214
+ });
215
+ else metadataBindings.push({
216
+ name: binding,
217
+ type: "r2_bucket",
218
+ bucket_name,
219
+ jurisdiction,
220
+ raw
221
+ });
222
+ });
223
+ d1_databases.forEach(({ binding, database_id, database_internal_env, raw }) => {
224
+ if (options?.dryRun) database_id ??= INHERIT_SYMBOL;
225
+ if (database_id === void 0) throw new UserError(`${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.`, { telemetryMessage: "d1 database binding missing database_id" });
226
+ if (database_id === INHERIT_SYMBOL) metadataBindings.push({
227
+ name: binding,
228
+ type: "inherit"
229
+ });
230
+ else metadataBindings.push({
231
+ name: binding,
232
+ type: "d1",
233
+ id: database_id,
234
+ internalEnv: database_internal_env,
235
+ raw
236
+ });
237
+ });
238
+ vectorize.forEach(({ binding, index_name, raw }) => {
239
+ metadataBindings.push({
240
+ name: binding,
241
+ type: "vectorize",
242
+ index_name,
243
+ raw
244
+ });
245
+ });
246
+ ai_search_namespaces.forEach(({ binding, namespace }) => {
247
+ if (options?.dryRun) namespace ??= INHERIT_SYMBOL;
248
+ if (namespace === void 0) throw new UserError(`${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.`, { telemetryMessage: "ai search namespace binding missing namespace" });
249
+ if (namespace === INHERIT_SYMBOL) metadataBindings.push({
250
+ name: binding,
251
+ type: "inherit"
252
+ });
253
+ else metadataBindings.push({
254
+ name: binding,
255
+ type: "ai_search_namespace",
256
+ namespace
257
+ });
258
+ });
259
+ ai_search.forEach(({ binding, instance_name }) => {
260
+ metadataBindings.push({
261
+ name: binding,
262
+ type: "ai_search",
263
+ instance_name
264
+ });
265
+ });
266
+ agent_memory.forEach(({ binding, namespace }) => {
267
+ if (options?.dryRun) namespace ??= INHERIT_SYMBOL;
268
+ if (namespace === void 0) throw new UserError(`${binding} bindings must have a "namespace" field. Add a "namespace" field to the binding in your Worker configuration specifying the namespace to bind to.`, { telemetryMessage: false });
269
+ if (namespace === INHERIT_SYMBOL) metadataBindings.push({
270
+ name: binding,
271
+ type: "inherit"
272
+ });
273
+ else metadataBindings.push({
274
+ name: binding,
275
+ type: "agent_memory",
276
+ namespace
277
+ });
278
+ });
279
+ hyperdrive.forEach(({ binding, id }) => {
280
+ metadataBindings.push({
281
+ name: binding,
282
+ type: "hyperdrive",
283
+ id
284
+ });
285
+ });
286
+ secrets_store_secrets.forEach(({ binding, store_id, secret_name }) => {
287
+ metadataBindings.push({
288
+ name: binding,
289
+ type: "secrets_store_secret",
290
+ store_id,
291
+ secret_name
292
+ });
293
+ });
294
+ artifacts.forEach(({ binding, namespace }) => {
295
+ metadataBindings.push({
296
+ name: binding,
297
+ type: "artifacts",
298
+ namespace
299
+ });
300
+ });
301
+ unsafe_hello_world.forEach(({ binding, enable_timer }) => {
302
+ metadataBindings.push({
303
+ name: binding,
304
+ type: "unsafe_hello_world",
305
+ enable_timer
306
+ });
307
+ });
308
+ flagship.forEach(({ binding, app_id }) => {
309
+ if (options?.dryRun) app_id ??= INHERIT_SYMBOL;
310
+ if (app_id === void 0) throw new UserError(`${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.`, { telemetryMessage: "flagship binding missing app id" });
311
+ metadataBindings.push(app_id === INHERIT_SYMBOL ? {
312
+ name: binding,
313
+ type: "inherit"
314
+ } : {
315
+ name: binding,
316
+ type: "flagship",
317
+ app_id
318
+ });
319
+ });
320
+ ratelimits.forEach(({ name, namespace_id, simple }) => {
321
+ metadataBindings.push({
322
+ name,
323
+ type: "ratelimit",
324
+ namespace_id,
325
+ simple
326
+ });
327
+ });
328
+ vpc_services.forEach(({ binding, service_id }) => {
329
+ metadataBindings.push({
330
+ name: binding,
331
+ type: "vpc_service",
332
+ service_id
333
+ });
334
+ });
335
+ vpc_networks.forEach(({ binding, tunnel_id, network_id }) => {
336
+ metadataBindings.push({
337
+ name: binding,
338
+ type: "vpc_network",
339
+ ...tunnel_id !== void 0 ? { tunnel_id } : { network_id }
340
+ });
341
+ });
342
+ services.forEach(({ binding, service, environment, entrypoint, props, cross_account_grant }) => {
343
+ metadataBindings.push({
344
+ name: binding,
345
+ type: "service",
346
+ service,
347
+ cross_account_grant,
348
+ ...environment && { environment },
349
+ ...entrypoint && { entrypoint },
350
+ ...props && { props }
351
+ });
352
+ });
353
+ analytics_engine_datasets.forEach(({ binding, dataset }) => {
354
+ metadataBindings.push({
355
+ name: binding,
356
+ type: "analytics_engine",
357
+ dataset
358
+ });
359
+ });
360
+ dispatch_namespaces.forEach(({ binding, namespace, outbound }) => {
361
+ if (options?.dryRun) namespace ??= INHERIT_SYMBOL;
362
+ if (namespace === void 0) throw new UserError(`${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.`, { telemetryMessage: "dispatch namespace binding missing namespace" });
363
+ if (namespace === INHERIT_SYMBOL) metadataBindings.push({
364
+ name: binding,
365
+ type: "inherit"
366
+ });
367
+ else metadataBindings.push({
368
+ name: binding,
369
+ type: "dispatch_namespace",
370
+ namespace,
371
+ ...outbound && { outbound: {
372
+ worker: {
373
+ service: outbound.service,
374
+ environment: outbound.environment
375
+ },
376
+ params: outbound.parameters?.map((p) => ({ name: p }))
377
+ } }
378
+ });
379
+ });
380
+ mtls_certificates.forEach(({ binding, certificate_id }) => {
381
+ metadataBindings.push({
382
+ name: binding,
383
+ type: "mtls_certificate",
384
+ certificate_id
385
+ });
386
+ });
387
+ pipelines.forEach(({ binding, stream: pipelineStream, pipeline }) => {
388
+ if (pipelineStream) metadataBindings.push({
389
+ name: binding,
390
+ type: "pipelines",
391
+ stream: pipelineStream
392
+ });
393
+ else if (pipeline) metadataBindings.push({
394
+ name: binding,
395
+ type: "pipelines",
396
+ pipeline
397
+ });
398
+ else throw new Error("Pipeline binding must specify a stream or pipeline");
399
+ });
400
+ k2.forEach(({ binding, stream: k2Stream }) => {
401
+ metadataBindings.push({
402
+ name: binding,
403
+ type: "k2",
404
+ stream: k2Stream
405
+ });
406
+ });
407
+ worker_loaders.forEach(({ binding }) => {
408
+ metadataBindings.push({
409
+ name: binding,
410
+ type: "worker_loader"
411
+ });
412
+ });
413
+ logfwdr.forEach(({ name, destination }) => {
414
+ metadataBindings.push({
415
+ name,
416
+ type: "logfwdr",
417
+ destination
418
+ });
419
+ });
420
+ wasm_modules.forEach(({ binding: name, source }) => {
421
+ metadataBindings.push({
422
+ name,
423
+ type: "wasm_module",
424
+ part: name
425
+ });
426
+ formData.set(name, new File(["contents" in source ? source.contents : readFileSync(source.path)], "path" in source ? source.path ?? name : name, { type: "application/wasm" }));
427
+ });
428
+ if (browser !== void 0) metadataBindings.push({
429
+ name: browser.binding,
430
+ type: "browser",
431
+ raw: browser.raw
432
+ });
433
+ if (analytics !== void 0) metadataBindings.push({
434
+ name: analytics.binding,
435
+ type: "analytics"
436
+ });
437
+ if (ai !== void 0) metadataBindings.push({
438
+ name: ai.binding,
439
+ staging: ai.staging,
440
+ type: "ai",
441
+ raw: ai.raw
442
+ });
443
+ if (images !== void 0) metadataBindings.push({
444
+ name: images.binding,
445
+ type: "images",
446
+ raw: images.raw
447
+ });
448
+ if (stream !== void 0) metadataBindings.push({
449
+ name: stream.binding,
450
+ type: "stream"
451
+ });
452
+ if (media !== void 0) metadataBindings.push({
453
+ name: media.binding,
454
+ type: "media"
455
+ });
456
+ if (version_metadata !== void 0) metadataBindings.push({
457
+ name: version_metadata.binding,
458
+ type: "version_metadata"
459
+ });
460
+ if (assetsBinding !== void 0) metadataBindings.push({
461
+ name: assetsBinding.binding,
462
+ type: "assets"
463
+ });
464
+ text_blobs.forEach(({ binding: name, source }) => {
465
+ metadataBindings.push({
466
+ name,
467
+ type: "text_blob",
468
+ part: name
469
+ });
470
+ if (name !== "__STATIC_CONTENT_MANIFEST") {
471
+ if ("contents" in source) formData.set(name, new File([source.contents], source.path ?? name, { type: "text/plain" }));
472
+ else formData.set(name, new File([readFileSync(source.path)], source.path, { type: "text/plain" }));
473
+ }
474
+ });
475
+ data_blobs.forEach(({ binding: name, source }) => {
476
+ metadataBindings.push({
477
+ name,
478
+ type: "data_blob",
479
+ part: name
480
+ });
481
+ formData.set(name, new File(["contents" in source ? source.contents : readFileSync(source.path)], "path" in source ? source.path ?? name : name, { type: "application/octet-stream" }));
482
+ });
483
+ for (const [bindingName, config] of Object.entries(bindings ?? {})) if (isUnsafeBindingType(config.type) && config.type !== "unsafe_hello_world") {
484
+ const { type, ...data } = config;
485
+ metadataBindings.push({
486
+ name: bindingName,
487
+ type: type.slice(7),
488
+ ...data
489
+ });
490
+ }
491
+ const manifestModuleName = "__STATIC_CONTENT_MANIFEST";
492
+ if (modules?.some(({ name }) => name === manifestModuleName) && main.type === "esm") {
493
+ assert(modules !== void 0);
494
+ const subDirs = new Set(modules.map((module) => path.posix.dirname(module.name)));
495
+ for (const subDir of subDirs) {
496
+ if (subDir === ".") continue;
497
+ const relativePath = path.posix.relative(subDir, manifestModuleName);
498
+ const filePath = path.posix.join(subDir, manifestModuleName);
499
+ modules.push({
500
+ name: filePath,
501
+ filePath,
502
+ content: `export { default } from ${JSON.stringify(relativePath)};`,
503
+ type: "esm"
504
+ });
505
+ }
506
+ }
507
+ if (main.type === "commonjs") {
508
+ for (const module of Object.values([...modules || []])) if (module.name === "__STATIC_CONTENT_MANIFEST") {
509
+ formData.set(module.name, new File([module.content], module.name, { type: "text/plain" }));
510
+ modules = modules?.filter((m) => m !== module);
511
+ } else if (module.type === "compiled-wasm" || module.type === "text" || module.type === "buffer") {
512
+ const name = module.name.replace(/[^a-zA-Z0-9_$]/g, "_");
513
+ metadataBindings.push({
514
+ name,
515
+ type: module.type === "compiled-wasm" ? "wasm_module" : module.type === "text" ? "text_blob" : "data_blob",
516
+ part: name
517
+ });
518
+ formData.set(name, new File([module.content], module.name, { type: module.type === "compiled-wasm" ? "application/wasm" : module.type === "text" ? "text/plain" : "application/octet-stream" }));
519
+ modules = modules?.filter((m) => m !== module);
520
+ }
521
+ }
522
+ let capnpSchemaOutputFile;
523
+ if (options?.unsafe?.capnp) {
524
+ const capnpOutput = handleUnsafeCapnp(options.unsafe.capnp);
525
+ capnpSchemaOutputFile = `./capnp-${Date.now()}.compiled`;
526
+ formData.set(capnpSchemaOutputFile, new File([capnpOutput], capnpSchemaOutputFile, { type: "application/octet-stream" }));
527
+ }
528
+ let keep_bindings = void 0;
529
+ if (keepVars) {
530
+ keep_bindings ??= [];
531
+ keep_bindings.push("plain_text", "json");
532
+ }
533
+ if (keepSecrets) {
534
+ keep_bindings ??= [];
535
+ keep_bindings.push("secret_text", "secret_key");
536
+ }
537
+ if (keepBindings) {
538
+ keep_bindings ??= [];
539
+ keep_bindings.push(...keepBindings);
540
+ }
541
+ const metadata = {
542
+ ...main.type !== "commonjs" ? { main_module: main.name } : { body_part: main.name },
543
+ bindings: metadataBindings,
544
+ containers: worker.containers === void 0 ? void 0 : worker.containers.map((c) => ({
545
+ ...c.name !== void 0 && { name: c.name },
546
+ ...c.class_name !== void 0 && { class_name: c.class_name },
547
+ ...c.images !== void 0 && { images: c.images }
548
+ })),
549
+ ...compatibility_date && { compatibility_date },
550
+ ...compatibility_flags && { compatibility_flags },
551
+ ...migrations && { migrations },
552
+ ...code_update_strategy && { code_update_strategy },
553
+ ...configuredExports && Object.keys(configuredExports).length > 0 && { exports: configuredExports },
554
+ capnp_schema: capnpSchemaOutputFile,
555
+ ...keep_bindings && { keep_bindings },
556
+ ...logpush !== void 0 && { logpush },
557
+ ...placement && { placement },
558
+ ...tail_consumers && { tail_consumers },
559
+ ...streaming_tail_consumers && { streaming_tail_consumers },
560
+ ...limits && { limits },
561
+ ...annotations && { annotations },
562
+ ...keep_assets !== void 0 && { keep_assets },
563
+ ...assets && { assets: {
564
+ jwt: assets.jwt,
565
+ config: assetConfig
566
+ } },
567
+ ...observability && { observability },
568
+ ...cache && { cache_options: cache },
569
+ ...package_dependencies?.length && { package_dependencies }
570
+ };
571
+ if (options?.unsafe?.metadata !== void 0) for (const key of Object.keys(options.unsafe.metadata)) metadata[key] = options.unsafe.metadata[key];
572
+ formData.set("metadata", JSON.stringify(metadata));
573
+ if (main.type === "commonjs" && modules && modules.length > 0) throw new TypeError("More than one module can only be specified when type = 'esm'");
574
+ for (const module of [main].concat(modules || [])) formData.set(module.name, new File([module.content], module.name, { type: toMimeType(module.type ?? main.type ?? "esm") }));
575
+ for (const sourceMap of sourceMaps || []) formData.set(sourceMap.name, new File([sourceMap.content], sourceMap.name, { type: "application/source-map" }));
576
+ return formData;
577
+ }
578
+ //#endregion
579
+ export { handleUnsafeCapnp as i, fromMimeType as n, moduleTypeMimeType as r, createWorkerUploadForm as t };
@@ -1,19 +1,17 @@
1
- import { FormData } from 'undici';
2
- import { CfWorkerInit, Binding, CfCapnp, CfModuleType } from '@cloudflare/workers-utils';
3
-
4
- declare const moduleTypeMimeType: {
5
- [type in CfModuleType]: string | undefined;
6
- };
1
+ import { Binding, CfCapnp, CfModuleType, CfWorkerInit } from "@cloudflare/workers-utils";
2
+ import { FormData } from "undici";
3
+ //#region src/deploy/helpers/create-worker-upload-form.d.ts
4
+ declare const moduleTypeMimeType: { [type in CfModuleType]: string | undefined; };
7
5
  declare function fromMimeType(mimeType: string): CfModuleType;
8
6
  /**
9
7
  * Creates a `FormData` upload from Worker data and bindings
10
8
  */
11
9
  declare function createWorkerUploadForm(worker: Omit<CfWorkerInit, "bindings" | "rawBindings">, bindings: Record<string, Binding> | undefined, options?: {
12
- dryRun?: true;
13
- unsafe?: {
14
- metadata?: Record<string, unknown>;
15
- capnp?: CfCapnp;
16
- };
10
+ dryRun?: true;
11
+ unsafe?: {
12
+ metadata?: Record<string, unknown>;
13
+ capnp?: CfCapnp;
14
+ };
17
15
  }): FormData;
18
-
19
- export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType };
16
+ //#endregion
17
+ export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType };
@@ -1,5 +1 @@
1
- import { createRequire } from 'node:module';
2
- export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType } from './chunk-DSGVRFIS.mjs';
3
- import './chunk-U6NEESU5.mjs';
4
-
5
- createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
1
+ export { t as createWorkerUploadForm, n as fromMimeType, r as moduleTypeMimeType } from "./create-worker-upload-form-DhzLEfNO.mjs";