alchemy 0.55.3 → 0.56.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/bin/alchemy.js +46 -246
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +7 -0
- package/lib/alchemy.js.map +1 -1
- package/lib/cloudflare/bundle/plugin-hot-reload.d.ts +1 -3
- package/lib/cloudflare/bundle/plugin-hot-reload.d.ts.map +1 -1
- package/lib/cloudflare/bundle/plugin-hot-reload.js +4 -1
- package/lib/cloudflare/bundle/plugin-hot-reload.js.map +1 -1
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/compatibility-presets.d.ts +1 -1
- package/lib/cloudflare/compatibility-presets.js +1 -1
- package/lib/cloudflare/compatibility-presets.js.map +1 -1
- package/lib/cloudflare/local-dev-cloudflare-shim.d.ts +3 -1
- package/lib/cloudflare/local-dev-cloudflare-shim.d.ts.map +1 -1
- package/lib/cloudflare/local-dev-cloudflare-shim.js +10 -5
- package/lib/cloudflare/local-dev-cloudflare-shim.js.map +1 -1
- package/lib/cloudflare/miniflare/build-worker-options.d.ts +22 -0
- package/lib/cloudflare/miniflare/build-worker-options.d.ts.map +1 -0
- package/lib/cloudflare/miniflare/build-worker-options.js +394 -0
- package/lib/cloudflare/miniflare/build-worker-options.js.map +1 -0
- package/lib/cloudflare/miniflare/miniflare-controller.d.ts +23 -0
- package/lib/cloudflare/miniflare/miniflare-controller.d.ts.map +1 -0
- package/lib/cloudflare/miniflare/miniflare-controller.js +110 -0
- package/lib/cloudflare/miniflare/miniflare-controller.js.map +1 -0
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +5 -15
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
- package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts +1 -5
- package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/remote-binding-proxy.js +17 -22
- package/lib/cloudflare/miniflare/remote-binding-proxy.js.map +1 -1
- package/lib/cloudflare/website.js +4 -4
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-bundle.d.ts +2 -0
- package/lib/cloudflare/worker-bundle.d.ts.map +1 -1
- package/lib/cloudflare/worker-bundle.js +19 -3
- package/lib/cloudflare/worker-bundle.js.map +1 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +76 -97
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/context.d.ts +11 -0
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js +8 -0
- package/lib/context.js.map +1 -1
- package/lib/scope.d.ts +12 -0
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +25 -0
- package/lib/scope.js.map +1 -1
- package/package.json +3 -2
- package/src/alchemy.ts +7 -0
- package/src/cloudflare/bundle/plugin-hot-reload.ts +4 -3
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/compatibility-presets.ts +1 -1
- package/src/cloudflare/local-dev-cloudflare-shim.ts +11 -5
- package/src/cloudflare/miniflare/build-worker-options.ts +454 -0
- package/src/cloudflare/miniflare/miniflare-controller.ts +128 -0
- package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +6 -15
- package/src/cloudflare/miniflare/remote-binding-proxy.ts +18 -23
- package/src/cloudflare/website.ts +4 -4
- package/src/cloudflare/worker-bundle.ts +28 -3
- package/src/cloudflare/worker.ts +90 -125
- package/src/context.ts +19 -0
- package/src/scope.ts +27 -0
- package/lib/cloudflare/miniflare/miniflare-worker-options.d.ts +0 -14
- package/lib/cloudflare/miniflare/miniflare-worker-options.d.ts.map +0 -1
- package/lib/cloudflare/miniflare/miniflare-worker-options.js +0 -468
- package/lib/cloudflare/miniflare/miniflare-worker-options.js.map +0 -1
- package/lib/cloudflare/miniflare/miniflare.d.ts +0 -40
- package/lib/cloudflare/miniflare/miniflare.d.ts.map +0 -1
- package/lib/cloudflare/miniflare/miniflare.js +0 -142
- package/lib/cloudflare/miniflare/miniflare.js.map +0 -1
- package/src/cloudflare/miniflare/miniflare-worker-options.ts +0 -599
- package/src/cloudflare/miniflare/miniflare.ts +0 -183
package/src/context.ts
CHANGED
|
@@ -67,6 +67,17 @@ export interface BaseContext<Out extends Resource> {
|
|
|
67
67
|
* "return undefined" so that `await MyResource()` always returns a value.
|
|
68
68
|
*/
|
|
69
69
|
destroy(): never;
|
|
70
|
+
/**
|
|
71
|
+
* Register a cleanup function that will be called when the process exits.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const proc = spawn('my-command', ['arg1', 'arg2']);
|
|
75
|
+
* this.onCleanup(async () => {
|
|
76
|
+
* proc.kill();
|
|
77
|
+
* await waitForExit(proc);
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
80
|
+
onCleanup(fn: () => void | Promise<void>): void;
|
|
70
81
|
/**
|
|
71
82
|
* Create the Resource envelope (with Alchemy + User properties)
|
|
72
83
|
*/
|
|
@@ -153,6 +164,14 @@ export function context<
|
|
|
153
164
|
destroy: () => {
|
|
154
165
|
throw new DestroyedSignal();
|
|
155
166
|
},
|
|
167
|
+
onCleanup: (fn: () => void | Promise<void>) => {
|
|
168
|
+
// make the function idempotent so repeated calls don't cause the process to hang
|
|
169
|
+
let promise: Promise<void> | undefined;
|
|
170
|
+
scope.root.onCleanup(async () => {
|
|
171
|
+
promise ??= Promise.resolve(fn());
|
|
172
|
+
await promise;
|
|
173
|
+
});
|
|
174
|
+
},
|
|
156
175
|
create,
|
|
157
176
|
}) as unknown as Context<Out>;
|
|
158
177
|
}
|
package/src/scope.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import kleur from "kleur";
|
|
1
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
3
|
import util from "node:util";
|
|
3
4
|
import type { Phase } from "./alchemy.ts";
|
|
@@ -99,6 +100,8 @@ export class Scope {
|
|
|
99
100
|
new AsyncLocalStorage<Scope>());
|
|
100
101
|
public static globals: Scope[] = (globalThis.__ALCHEMY_GLOBALS__ ??= []);
|
|
101
102
|
|
|
103
|
+
private static exitHandlerInstalled = false;
|
|
104
|
+
|
|
102
105
|
public static getScope(): Scope | undefined {
|
|
103
106
|
const scope = Scope.storage.getStore();
|
|
104
107
|
if (!scope) {
|
|
@@ -144,6 +147,7 @@ export class Scope {
|
|
|
144
147
|
private finalized = false;
|
|
145
148
|
private startedAt = performance.now();
|
|
146
149
|
private deferred: (() => Promise<any>)[] = [];
|
|
150
|
+
private cleanups: (() => Promise<void>)[] = [];
|
|
147
151
|
|
|
148
152
|
public get appName(): string {
|
|
149
153
|
if (this.parent) {
|
|
@@ -466,6 +470,7 @@ export class Scope {
|
|
|
466
470
|
});
|
|
467
471
|
|
|
468
472
|
if (!this.parent && process.env.ALCHEMY_TEST_KILL_ON_FINALIZE) {
|
|
473
|
+
await this.cleanup();
|
|
469
474
|
process.exit(0);
|
|
470
475
|
}
|
|
471
476
|
}
|
|
@@ -537,6 +542,28 @@ export class Scope {
|
|
|
537
542
|
return promise;
|
|
538
543
|
}
|
|
539
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Run all cleanup functions registered with `onCleanup`.
|
|
547
|
+
* This should only be called on the root scope.
|
|
548
|
+
*/
|
|
549
|
+
public async cleanup() {
|
|
550
|
+
if (this.parent) return;
|
|
551
|
+
this.logger.log(kleur.gray("Exiting..."));
|
|
552
|
+
await Promise.allSettled(this.cleanups.map((cleanup) => cleanup()));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Register a cleanup function that will be called when the process exits.
|
|
557
|
+
* This should only be called on the root scope.
|
|
558
|
+
*/
|
|
559
|
+
public onCleanup(fn: () => Promise<void>) {
|
|
560
|
+
if (this.parent) {
|
|
561
|
+
this.root.onCleanup(fn);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
this.cleanups.push(fn);
|
|
565
|
+
}
|
|
566
|
+
|
|
540
567
|
/**
|
|
541
568
|
* Returns a string representation of the scope.
|
|
542
569
|
*/
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type RemoteProxyConnectionString, type WorkerOptions } from "miniflare";
|
|
2
|
-
import { type WorkerBindingSpec } from "../bindings.ts";
|
|
3
|
-
import type { WorkerBundle } from "../worker-bundle.ts";
|
|
4
|
-
import type { WorkerProps } from "../worker.ts";
|
|
5
|
-
export type MiniflareWorkerOptions = Pick<WorkerProps, "bindings" | "eventSources" | "compatibilityDate" | "compatibilityFlags" | "format" | "assets"> & {
|
|
6
|
-
name: string;
|
|
7
|
-
bundle: WorkerBundle;
|
|
8
|
-
port?: number;
|
|
9
|
-
};
|
|
10
|
-
export declare function buildRemoteBindings(input: Pick<MiniflareWorkerOptions, "bindings">): WorkerBindingSpec[];
|
|
11
|
-
export declare function buildMiniflareWorkerOptions({ name: workerName, assets, bundle, bindings, eventSources, compatibilityDate, compatibilityFlags, remoteProxyConnectionString, }: MiniflareWorkerOptions & {
|
|
12
|
-
remoteProxyConnectionString: RemoteProxyConnectionString | undefined;
|
|
13
|
-
}): WorkerOptions;
|
|
14
|
-
//# sourceMappingURL=miniflare-worker-options.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"miniflare-worker-options.d.ts","sourceRoot":"","sources":["../../../src/cloudflare/miniflare/miniflare-worker-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,WAAW,EACT,UAAU,GACV,cAAc,GACd,mBAAmB,GACnB,oBAAoB,GACpB,QAAQ,GACR,QAAQ,CACX,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA4BF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,uBAWhD;AAwKD,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EAAE,UAAU,EAChB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,GAC5B,EAAE,sBAAsB,GAAG;IAC1B,2BAA2B,EAAE,2BAA2B,GAAG,SAAS,CAAC;CACtE,GAAG,aAAa,CAmWhB"}
|
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
import { kCurrentWorker, } from "miniflare";
|
|
2
|
-
import assert from "node:assert";
|
|
3
|
-
import { assertNever } from "../../util/assert-never.js";
|
|
4
|
-
import { logger } from "../../util/logger.js";
|
|
5
|
-
import { Self } from "../bindings.js";
|
|
6
|
-
const REMOTE_ONLY_BINDING_TYPES = [
|
|
7
|
-
"ai",
|
|
8
|
-
"ai_gateway",
|
|
9
|
-
"browser",
|
|
10
|
-
"dispatch_namespace",
|
|
11
|
-
"vectorize",
|
|
12
|
-
];
|
|
13
|
-
const REMOTE_OPTIONAL_BINDING_TYPES = [
|
|
14
|
-
"d1",
|
|
15
|
-
// "durable_object_namespace", This is supported in Miniflare but needs some wrangling to make it work with a remote proxy.
|
|
16
|
-
"images",
|
|
17
|
-
"kv_namespace",
|
|
18
|
-
"r2_bucket",
|
|
19
|
-
"queue",
|
|
20
|
-
"service",
|
|
21
|
-
// "workflow", same thing
|
|
22
|
-
];
|
|
23
|
-
export function buildRemoteBindings(input) {
|
|
24
|
-
const bindings = [];
|
|
25
|
-
for (const [name, binding] of Object.entries(input.bindings ?? {})) {
|
|
26
|
-
if (isRemoteOnlyBinding(binding)) {
|
|
27
|
-
bindings.push(buildRemoteBinding(name, binding));
|
|
28
|
-
}
|
|
29
|
-
else if (isRemoteOptionalBinding(binding) && isRemoteEnabled(binding)) {
|
|
30
|
-
bindings.push(buildRemoteBinding(name, binding));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return bindings;
|
|
34
|
-
}
|
|
35
|
-
function isRemoteOptionalBinding(binding) {
|
|
36
|
-
return (typeof binding !== "string" &&
|
|
37
|
-
binding !== Self &&
|
|
38
|
-
typeof binding === "object" &&
|
|
39
|
-
"type" in binding &&
|
|
40
|
-
REMOTE_OPTIONAL_BINDING_TYPES.includes(binding.type));
|
|
41
|
-
}
|
|
42
|
-
function isRemoteOnlyBinding(binding) {
|
|
43
|
-
return (typeof binding !== "string" &&
|
|
44
|
-
binding !== Self &&
|
|
45
|
-
typeof binding === "object" &&
|
|
46
|
-
"type" in binding &&
|
|
47
|
-
REMOTE_ONLY_BINDING_TYPES.includes(binding.type));
|
|
48
|
-
}
|
|
49
|
-
function isRemoteEnabled(binding) {
|
|
50
|
-
return ("dev" in binding &&
|
|
51
|
-
typeof binding.dev === "object" &&
|
|
52
|
-
"remote" in binding.dev &&
|
|
53
|
-
!!binding.dev.remote);
|
|
54
|
-
}
|
|
55
|
-
function buildRemoteBinding(name, binding) {
|
|
56
|
-
switch (binding.type) {
|
|
57
|
-
case "ai": {
|
|
58
|
-
return {
|
|
59
|
-
type: "ai",
|
|
60
|
-
name,
|
|
61
|
-
raw: true,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
case "ai_gateway": {
|
|
65
|
-
return {
|
|
66
|
-
type: "ai",
|
|
67
|
-
name,
|
|
68
|
-
raw: true,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
case "browser": {
|
|
72
|
-
return {
|
|
73
|
-
type: "browser",
|
|
74
|
-
name,
|
|
75
|
-
raw: true,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
case "d1": {
|
|
79
|
-
return {
|
|
80
|
-
type: "d1",
|
|
81
|
-
name,
|
|
82
|
-
id: binding.id,
|
|
83
|
-
raw: true,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
case "dispatch_namespace": {
|
|
87
|
-
return {
|
|
88
|
-
type: "dispatch_namespace",
|
|
89
|
-
name,
|
|
90
|
-
namespace: binding.namespace,
|
|
91
|
-
raw: true,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
// case "durable_object_namespace": {
|
|
95
|
-
// return {
|
|
96
|
-
// type: "durable_object_namespace",
|
|
97
|
-
// name,
|
|
98
|
-
// class_name: binding.className,
|
|
99
|
-
// script_name: binding.scriptName,
|
|
100
|
-
// raw: true,
|
|
101
|
-
// };
|
|
102
|
-
// }
|
|
103
|
-
case "images": {
|
|
104
|
-
return {
|
|
105
|
-
type: "images",
|
|
106
|
-
name,
|
|
107
|
-
raw: true,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
case "kv_namespace": {
|
|
111
|
-
return {
|
|
112
|
-
type: "kv_namespace",
|
|
113
|
-
name,
|
|
114
|
-
namespace_id: "namespaceId" in binding ? binding.namespaceId : binding.id,
|
|
115
|
-
raw: true,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
case "queue": {
|
|
119
|
-
return {
|
|
120
|
-
type: "queue",
|
|
121
|
-
name,
|
|
122
|
-
queue_name: binding.name,
|
|
123
|
-
raw: true,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
case "r2_bucket": {
|
|
127
|
-
return {
|
|
128
|
-
type: "r2_bucket",
|
|
129
|
-
name,
|
|
130
|
-
bucket_name: binding.name,
|
|
131
|
-
raw: true,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
case "service": {
|
|
135
|
-
return {
|
|
136
|
-
type: "service",
|
|
137
|
-
name,
|
|
138
|
-
service: "service" in binding ? binding.service : binding.name,
|
|
139
|
-
environment: "environment" in binding ? binding.environment : undefined,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
case "vectorize": {
|
|
143
|
-
return {
|
|
144
|
-
type: "vectorize",
|
|
145
|
-
name,
|
|
146
|
-
index_name: binding.name,
|
|
147
|
-
raw: true,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
// case "workflow": {
|
|
151
|
-
// return {
|
|
152
|
-
// type: "workflow",
|
|
153
|
-
// name,
|
|
154
|
-
// workflow_name: binding.workflowName,
|
|
155
|
-
// class_name: binding.className,
|
|
156
|
-
// script_name: binding.scriptName,
|
|
157
|
-
// raw: true,
|
|
158
|
-
// };
|
|
159
|
-
// }
|
|
160
|
-
default: {
|
|
161
|
-
assertNever(binding);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const moduleTypes = {
|
|
166
|
-
esm: "ESModule",
|
|
167
|
-
cjs: "CommonJS",
|
|
168
|
-
text: "Text",
|
|
169
|
-
data: "Data",
|
|
170
|
-
wasm: "CompiledWasm",
|
|
171
|
-
sourcemap: "Text",
|
|
172
|
-
};
|
|
173
|
-
function parseModules(bundle) {
|
|
174
|
-
const modules = bundle.modules.map((module) => ({
|
|
175
|
-
type: moduleTypes[module.type],
|
|
176
|
-
path: module.path,
|
|
177
|
-
contents: module.content,
|
|
178
|
-
}));
|
|
179
|
-
const entry = modules.find((module) => module.path === bundle.entrypoint);
|
|
180
|
-
if (!entry) {
|
|
181
|
-
throw new Error(`Entrypoint "${bundle.entrypoint}" not found in bundle.`);
|
|
182
|
-
}
|
|
183
|
-
return [entry, ...modules.filter((module) => module.path !== entry.path)];
|
|
184
|
-
}
|
|
185
|
-
export function buildMiniflareWorkerOptions({ name: workerName, assets, bundle, bindings, eventSources, compatibilityDate, compatibilityFlags, remoteProxyConnectionString, }) {
|
|
186
|
-
const options = {
|
|
187
|
-
name: workerName,
|
|
188
|
-
modules: parseModules(bundle),
|
|
189
|
-
rootPath: bundle.root,
|
|
190
|
-
compatibilityDate,
|
|
191
|
-
compatibilityFlags,
|
|
192
|
-
// TODO: Setting `proxy: true` here causes the following error when connecting via a websocket:
|
|
193
|
-
// workerd/io/worker.c++:2164: info: uncaught exception; source = Uncaught (in promise); stack = TypeError: Invalid URL string.
|
|
194
|
-
unsafeDirectSockets: [{ proxy: false }],
|
|
195
|
-
containerEngine: {
|
|
196
|
-
localDocker: {
|
|
197
|
-
socketPath: process.platform === "win32"
|
|
198
|
-
? "//./pipe/docker_engine"
|
|
199
|
-
: "unix:///var/run/docker.sock",
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
for (const [name, binding] of Object.entries(bindings ?? {})) {
|
|
204
|
-
if (typeof binding === "string") {
|
|
205
|
-
options.bindings = {
|
|
206
|
-
...options.bindings,
|
|
207
|
-
[name]: binding,
|
|
208
|
-
};
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
if (binding === Self) {
|
|
212
|
-
options.serviceBindings = {
|
|
213
|
-
...(options.serviceBindings ??
|
|
214
|
-
{}),
|
|
215
|
-
[name]: kCurrentWorker,
|
|
216
|
-
};
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
switch (binding.type) {
|
|
220
|
-
case "ai": {
|
|
221
|
-
assert(remoteProxyConnectionString, `Binding "${name}" of type "${binding.type}" requires a remoteProxyConnectionString, but none was provided.`);
|
|
222
|
-
options.ai = {
|
|
223
|
-
binding: name,
|
|
224
|
-
remoteProxyConnectionString,
|
|
225
|
-
};
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
case "ai_gateway": {
|
|
229
|
-
assert(remoteProxyConnectionString, `Binding "${name}" of type "${binding.type}" requires a remoteProxyConnectionString, but none was provided.`);
|
|
230
|
-
options.ai = {
|
|
231
|
-
binding: name,
|
|
232
|
-
remoteProxyConnectionString,
|
|
233
|
-
};
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
case "analytics_engine": {
|
|
237
|
-
(options.analyticsEngineDatasets ??= {})[name] = {
|
|
238
|
-
dataset: binding.dataset,
|
|
239
|
-
};
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
case "assets": {
|
|
243
|
-
options.assets = {
|
|
244
|
-
binding: name,
|
|
245
|
-
directory: binding.path,
|
|
246
|
-
routerConfig: {
|
|
247
|
-
invoke_user_worker_ahead_of_assets: assets?.run_worker_first === true,
|
|
248
|
-
},
|
|
249
|
-
assetConfig: {
|
|
250
|
-
html_handling: assets?.html_handling,
|
|
251
|
-
not_found_handling: assets?.not_found_handling,
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
case "browser": {
|
|
257
|
-
assert(remoteProxyConnectionString, `Binding "${name}" of type "${binding.type}" requires a remoteProxyConnectionString, but none was provided.`);
|
|
258
|
-
options.browserRendering = {
|
|
259
|
-
binding: name,
|
|
260
|
-
remoteProxyConnectionString,
|
|
261
|
-
};
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
case "d1": {
|
|
265
|
-
(options.d1Databases ??= {})[name] = {
|
|
266
|
-
id: binding.id,
|
|
267
|
-
remoteProxyConnectionString: binding.dev?.remote
|
|
268
|
-
? remoteProxyConnectionString
|
|
269
|
-
: undefined,
|
|
270
|
-
};
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
case "dispatch_namespace": {
|
|
274
|
-
assert(remoteProxyConnectionString, `Binding "${name}" of type "${binding.type}" requires a remoteProxyConnectionString, but none was provided.`);
|
|
275
|
-
(options.dispatchNamespaces ??= {})[name] = {
|
|
276
|
-
namespace: binding.namespace,
|
|
277
|
-
remoteProxyConnectionString,
|
|
278
|
-
};
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
case "durable_object_namespace": {
|
|
282
|
-
(options.durableObjects ??= {})[name] = {
|
|
283
|
-
className: binding.className,
|
|
284
|
-
scriptName: binding.scriptName,
|
|
285
|
-
useSQLite: binding.sqlite,
|
|
286
|
-
// namespaceId: binding.namespaceId,
|
|
287
|
-
// unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
|
|
288
|
-
// unsafePreventEviction?: boolean | undefined;
|
|
289
|
-
// remoteProxyConnectionString: binding.local
|
|
290
|
-
// ? undefined
|
|
291
|
-
// : remoteProxyConnectionString,
|
|
292
|
-
};
|
|
293
|
-
if (!binding.scriptName || binding.scriptName === workerName) {
|
|
294
|
-
options.unsafeDirectSockets.push({
|
|
295
|
-
entrypoint: binding.className,
|
|
296
|
-
proxy: true,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
case "hyperdrive": {
|
|
302
|
-
if ("access_client_id" in binding.origin) {
|
|
303
|
-
throw new Error(`Hyperdrive with Cloudflare Access is not supported for locally emulated workers. Worker "${name}" is locally emulated but is bound to Hyperdrive "${name}", which has Cloudflare Access enabled.`);
|
|
304
|
-
}
|
|
305
|
-
logger.warnOnce(`Hyperdrive bindings in locally emulated workers are experimental and may not work as expected. Worker "${name}" is locally emulated and bound to Hyperdrive "${name}".`);
|
|
306
|
-
const { scheme = "postgres", port = 5432, password, database, host, user, } = binding.origin;
|
|
307
|
-
const connectionString = new URL(`${scheme}://${user}:${password.unencrypted}@${host}:${port}/${database}?sslmode=${binding.mtls?.sslmode ?? "verify-full"}`);
|
|
308
|
-
(options.bindings ??= {})[name] = {
|
|
309
|
-
connectionString: connectionString.toString(),
|
|
310
|
-
database,
|
|
311
|
-
host,
|
|
312
|
-
password: password.unencrypted,
|
|
313
|
-
port,
|
|
314
|
-
scheme,
|
|
315
|
-
user,
|
|
316
|
-
};
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
case "images": {
|
|
320
|
-
options.images = {
|
|
321
|
-
binding: name,
|
|
322
|
-
remoteProxyConnectionString: binding.dev?.remote
|
|
323
|
-
? remoteProxyConnectionString
|
|
324
|
-
: undefined,
|
|
325
|
-
};
|
|
326
|
-
break;
|
|
327
|
-
}
|
|
328
|
-
case "json": {
|
|
329
|
-
(options.bindings ??= {})[name] = binding.json;
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
case "kv_namespace": {
|
|
333
|
-
const normalized = "id" in binding
|
|
334
|
-
? { id: binding.id }
|
|
335
|
-
: { id: binding.namespaceId, dev: binding.dev };
|
|
336
|
-
(options.kvNamespaces ??= {})[name] = {
|
|
337
|
-
id: normalized.id,
|
|
338
|
-
remoteProxyConnectionString: normalized.dev?.remote
|
|
339
|
-
? remoteProxyConnectionString
|
|
340
|
-
: undefined,
|
|
341
|
-
};
|
|
342
|
-
break;
|
|
343
|
-
}
|
|
344
|
-
case "pipeline": {
|
|
345
|
-
(options.pipelines ??= {})[name] =
|
|
346
|
-
binding.id;
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
case "queue": {
|
|
350
|
-
(options.queueProducers ??= {})[name] = {
|
|
351
|
-
queueName: binding.name,
|
|
352
|
-
deliveryDelay: binding.settings?.deliveryDelay,
|
|
353
|
-
remoteProxyConnectionString: binding.dev?.remote
|
|
354
|
-
? remoteProxyConnectionString
|
|
355
|
-
: undefined,
|
|
356
|
-
};
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
case "r2_bucket": {
|
|
360
|
-
(options.r2Buckets ??= {})[name] = {
|
|
361
|
-
id: binding.name,
|
|
362
|
-
remoteProxyConnectionString: binding.dev?.remote
|
|
363
|
-
? remoteProxyConnectionString
|
|
364
|
-
: undefined,
|
|
365
|
-
};
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
case "secret": {
|
|
369
|
-
(options.bindings ??= {})[name] = binding.unencrypted;
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
case "secrets_store_secret": {
|
|
373
|
-
options.secretsStoreSecrets = {
|
|
374
|
-
...(options.secretsStoreSecrets ?? {}),
|
|
375
|
-
[name]: {
|
|
376
|
-
store_id: binding.storeId,
|
|
377
|
-
secret_name: binding.name,
|
|
378
|
-
},
|
|
379
|
-
};
|
|
380
|
-
break;
|
|
381
|
-
}
|
|
382
|
-
case "secret_key": {
|
|
383
|
-
throw new Error(`Secret key bindings are not supported for locally emulated workers. Worker "${name}" is locally emulated but is bound to secret key "${name}".`);
|
|
384
|
-
}
|
|
385
|
-
case "service": {
|
|
386
|
-
if (!("id" in binding)) {
|
|
387
|
-
throw new Error(`Service bindings must have an id. Worker "${name}" is bound to service "${name}" but does not have an id.`);
|
|
388
|
-
}
|
|
389
|
-
if (isRemoteEnabled(binding)) {
|
|
390
|
-
(options.serviceBindings ??= {})[name] = {
|
|
391
|
-
name: binding.name,
|
|
392
|
-
remoteProxyConnectionString,
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
(options.serviceBindings ??= {})[name] = binding.name;
|
|
397
|
-
}
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
case "vectorize": {
|
|
401
|
-
assert(remoteProxyConnectionString, `Binding "${name}" of type "${binding.type}" requires a remoteProxyConnectionString, but none was provided.`);
|
|
402
|
-
(options.vectorize ??= {})[name] = {
|
|
403
|
-
index_name: binding.name,
|
|
404
|
-
remoteProxyConnectionString,
|
|
405
|
-
};
|
|
406
|
-
break;
|
|
407
|
-
}
|
|
408
|
-
case "version_metadata": {
|
|
409
|
-
// This is how Wrangler does it:
|
|
410
|
-
// https://github.com/cloudflare/workers-sdk/blob/70ba9fbf905a9ba5fe158d0bc8d48f6bf31712a2/packages/wrangler/src/dev/miniflare.ts#L881
|
|
411
|
-
(options.bindings ??= {})[name] = {
|
|
412
|
-
id: crypto.randomUUID(),
|
|
413
|
-
tag: "",
|
|
414
|
-
timestamp: "0",
|
|
415
|
-
};
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
case "workflow": {
|
|
419
|
-
(options.workflows ??= {})[name] = {
|
|
420
|
-
name: binding.workflowName,
|
|
421
|
-
className: binding.className,
|
|
422
|
-
scriptName: binding.scriptName,
|
|
423
|
-
// remoteProxyConnectionString:
|
|
424
|
-
// "local" in binding && binding.local
|
|
425
|
-
// ? undefined
|
|
426
|
-
// : remoteProxyConnectionString,
|
|
427
|
-
};
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
case "container": {
|
|
431
|
-
if (binding.dev?.remote) {
|
|
432
|
-
throw new Error(`Container bindings with remote: true are not supported for locally emulated workers. Worker "${name}" is locally emulated but is bound to container "${name}" with remote: true.`);
|
|
433
|
-
}
|
|
434
|
-
(options.durableObjects ??= {})[name] = {
|
|
435
|
-
className: binding.className,
|
|
436
|
-
scriptName: binding.scriptName,
|
|
437
|
-
useSQLite: binding.sqlite,
|
|
438
|
-
container: {
|
|
439
|
-
imageName: binding.image.imageRef,
|
|
440
|
-
},
|
|
441
|
-
};
|
|
442
|
-
if (!binding.scriptName || binding.scriptName === workerName) {
|
|
443
|
-
options.unsafeDirectSockets.push({
|
|
444
|
-
entrypoint: binding.className,
|
|
445
|
-
proxy: true,
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
case "ratelimit": {
|
|
451
|
-
(options.ratelimits ??= {})[name] = binding;
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
default: {
|
|
455
|
-
assertNever(binding);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
for (const eventSource of eventSources ?? []) {
|
|
460
|
-
const queue = "queue" in eventSource ? eventSource.queue : eventSource;
|
|
461
|
-
if (queue.dev?.remote !== false) {
|
|
462
|
-
throw new Error(`Locally emulated workers cannot consume remote queues. Worker "${workerName}" is locally emulated but is consuming remote queue "${queue.name}".`);
|
|
463
|
-
}
|
|
464
|
-
(options.queueConsumers ??= []).push(queue.name);
|
|
465
|
-
}
|
|
466
|
-
return options;
|
|
467
|
-
}
|
|
468
|
-
//# sourceMappingURL=miniflare-worker-options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"miniflare-worker-options.js","sourceRoot":"","sources":["../../../src/cloudflare/miniflare/miniflare-worker-options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,WAAW,CAAC;AACnB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAwC,MAAM,gBAAgB,CAAC;AAoB5E,MAAM,yBAAyB,GAAG;IAChC,IAAI;IACJ,YAAY;IACZ,SAAS;IACT,oBAAoB;IACpB,WAAW;CACY,CAAC;AAC1B,MAAM,6BAA6B,GAAG;IACpC,IAAI;IACJ,2HAA2H;IAC3H,QAAQ;IACR,cAAc;IACd,WAAW;IACX,OAAO;IACP,SAAS;IACT,yBAAyB;CACF,CAAC;AAQ1B,MAAM,UAAU,mBAAmB,CACjC,KAA+C;IAE/C,MAAM,QAAQ,GAAwB,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;QACnE,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;YACxE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAgB;IAC/C,OAAO,CACL,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAA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AC,QAAQ;qBAClC;iBACF,CAAC;gBACF,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;oBAC7D,OAAO,CAAC,mBAAoB,CAAC,IAAI,CAAC;wBAChC,UAAU,EAAE,OAAO,CAAC,SAAS;wBAC7B,KAAK,EAAE,IAAI;qBACZ,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,WAAW,CAAC,CAAC,CAAC;gBACjB,CAAC,OAAO,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;gBAC5C,MAAM;YACR,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,WAAW,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,MAAM,WAAW,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC;QACvE,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,kEAAkE,UAAU,wDAAwD,KAAK,CAAC,IAAI,IAAI,CACnJ,CAAC;QACJ,CAAC;QACA,CAAC,OAAO,CAAC,cAAc,KAAK,EAAE,CAAc,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as miniflare from "miniflare";
|
|
2
|
-
import { type PromiseWithResolvers } from "../../util/promise-with-resolvers.ts";
|
|
3
|
-
import { type MiniflareWorkerOptions } from "./miniflare-worker-options.ts";
|
|
4
|
-
import { MiniflareWorkerProxy } from "./miniflare-worker-proxy.ts";
|
|
5
|
-
import { type RemoteBindingProxy } from "./remote-binding-proxy.ts";
|
|
6
|
-
declare class MiniflareServer {
|
|
7
|
-
miniflare?: miniflare.Miniflare;
|
|
8
|
-
workers: Map<string, miniflare.WorkerOptions>;
|
|
9
|
-
workerProxies: Map<string, MiniflareWorkerProxy>;
|
|
10
|
-
remoteBindingProxies: Map<string, RemoteBindingProxy>;
|
|
11
|
-
stream: WritableStream<{
|
|
12
|
-
worker: MiniflareWorkerOptions;
|
|
13
|
-
promise: PromiseWithResolvers<{
|
|
14
|
-
url: string;
|
|
15
|
-
}>;
|
|
16
|
-
}>;
|
|
17
|
-
writer: WritableStreamDefaultWriter<{
|
|
18
|
-
worker: MiniflareWorkerOptions;
|
|
19
|
-
promise: PromiseWithResolvers<{
|
|
20
|
-
url: string;
|
|
21
|
-
}>;
|
|
22
|
-
}>;
|
|
23
|
-
push(worker: MiniflareWorkerOptions): Promise<{
|
|
24
|
-
url: string;
|
|
25
|
-
}>;
|
|
26
|
-
close(): Promise<void>;
|
|
27
|
-
private set;
|
|
28
|
-
private dispose;
|
|
29
|
-
private maybeCreateRemoteProxy;
|
|
30
|
-
private miniflareOptions;
|
|
31
|
-
}
|
|
32
|
-
export declare class ExternalDependencyError extends Error {
|
|
33
|
-
constructor();
|
|
34
|
-
}
|
|
35
|
-
declare global {
|
|
36
|
-
var _ALCHEMY_MINIFLARE_SERVER: MiniflareServer | undefined;
|
|
37
|
-
}
|
|
38
|
-
export declare const miniflareServer: MiniflareServer;
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=miniflare.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"miniflare.d.ts","sourceRoot":"","sources":["../../../src/cloudflare/miniflare/miniflare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAGvC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,cAAM,eAAe;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC;IAChC,OAAO,uCAA8C;IACrD,aAAa,oCAA2C;IACxD,oBAAoB,kCAAyC;IAE7D,MAAM;gBACI,sBAAsB;iBACrB,oBAAoB,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;OAa7C;IACH,MAAM;gBAfI,sBAAsB;iBACrB,oBAAoB,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;OAcf;IAE3B,IAAI,CAAC,MAAM,EAAE,sBAAsB;aACK,MAAM;;IAQ9C,KAAK;YAIG,GAAG;YAmCH,OAAO;YAeP,sBAAsB;YAyBtB,gBAAgB;CAkB/B;AAED,qBAAa,uBAAwB,SAAQ,KAAK;;CAMjD;AAiBD,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,yBAAyB,EAAE,eAAe,GAAG,SAAS,CAAC;CAC5D;AAED,eAAO,MAAM,eAAe,iBAK1B,CAAC"}
|