miniflare 0.0.0-ecef68635 → 0.0.0-ee305dd67
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/README.md +23 -0
- package/dist/src/index.d.ts +252 -82
- package/dist/src/index.js +284 -141
- package/dist/src/index.js.map +3 -3
- package/dist/src/workers/assets/assets.worker.js +87 -5
- package/dist/src/workers/assets/assets.worker.js.map +2 -2
- package/dist/src/workers/assets/router.worker.js +73 -4
- package/dist/src/workers/assets/router.worker.js.map +2 -2
- package/dist/src/workers/cache/cache.worker.js +6 -5
- package/dist/src/workers/cache/cache.worker.js.map +2 -2
- package/dist/src/workers/queues/broker.worker.js +4 -2
- package/dist/src/workers/queues/broker.worker.js.map +1 -1
- package/dist/src/workers/workflows/binding.worker.js +1927 -0
- package/dist/src/workers/workflows/binding.worker.js.map +6 -0
- package/package.json +8 -6
package/dist/src/index.js
CHANGED
|
@@ -95,11 +95,11 @@ var require_Mime = __commonJS({
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
Mime.prototype.getType = function(
|
|
99
|
-
|
|
100
|
-
let last =
|
|
98
|
+
Mime.prototype.getType = function(path28) {
|
|
99
|
+
path28 = String(path28);
|
|
100
|
+
let last = path28.replace(/^.*[/\\]/, "").toLowerCase();
|
|
101
101
|
let ext = last.replace(/^.*\./, "").toLowerCase();
|
|
102
|
-
let hasPath = last.length <
|
|
102
|
+
let hasPath = last.length < path28.length;
|
|
103
103
|
let hasDot = ext.length < last.length - 1;
|
|
104
104
|
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
105
105
|
};
|
|
@@ -2535,10 +2535,15 @@ __export(src_exports, {
|
|
|
2535
2535
|
TlsOptions_Version: () => import_workerd_capnp.TlsOptions_Version,
|
|
2536
2536
|
TypedEventTarget: () => TypedEventTarget,
|
|
2537
2537
|
WORKER_BINDING_SERVICE_LOOPBACK: () => WORKER_BINDING_SERVICE_LOOPBACK,
|
|
2538
|
+
WORKFLOWS_PLUGIN: () => WORKFLOWS_PLUGIN,
|
|
2539
|
+
WORKFLOWS_PLUGIN_NAME: () => WORKFLOWS_PLUGIN_NAME,
|
|
2540
|
+
WORKFLOWS_STORAGE_SERVICE_NAME: () => WORKFLOWS_STORAGE_SERVICE_NAME,
|
|
2538
2541
|
WaitGroup: () => WaitGroup,
|
|
2539
2542
|
WebSocket: () => WebSocket,
|
|
2540
2543
|
WebSocketPair: () => WebSocketPair,
|
|
2541
2544
|
Worker_Binding_CryptoKey_Usage: () => import_workerd_capnp.Worker_Binding_CryptoKey_Usage,
|
|
2545
|
+
WorkflowsOptionsSchema: () => WorkflowsOptionsSchema,
|
|
2546
|
+
WorkflowsSharedOptionsSchema: () => WorkflowsSharedOptionsSchema,
|
|
2542
2547
|
__MiniflareFunctionWrapper: () => __MiniflareFunctionWrapper,
|
|
2543
2548
|
_enableControlEndpoints: () => _enableControlEndpoints,
|
|
2544
2549
|
_forceColour: () => _forceColour,
|
|
@@ -2612,11 +2617,11 @@ __export(src_exports, {
|
|
|
2612
2617
|
module.exports = __toCommonJS(src_exports);
|
|
2613
2618
|
var import_assert12 = __toESM(require("assert"));
|
|
2614
2619
|
var import_crypto3 = __toESM(require("crypto"));
|
|
2615
|
-
var
|
|
2620
|
+
var import_fs22 = __toESM(require("fs"));
|
|
2616
2621
|
var import_http6 = __toESM(require("http"));
|
|
2617
2622
|
var import_net = __toESM(require("net"));
|
|
2618
2623
|
var import_os2 = __toESM(require("os"));
|
|
2619
|
-
var
|
|
2624
|
+
var import_path26 = __toESM(require("path"));
|
|
2620
2625
|
var import_web5 = require("stream/web");
|
|
2621
2626
|
var import_util5 = __toESM(require("util"));
|
|
2622
2627
|
var import_zlib = __toESM(require("zlib"));
|
|
@@ -2703,7 +2708,7 @@ function zod_worker_default() {
|
|
|
2703
2708
|
|
|
2704
2709
|
// src/index.ts
|
|
2705
2710
|
var import_ws3 = require("ws");
|
|
2706
|
-
var
|
|
2711
|
+
var import_zod22 = require("zod");
|
|
2707
2712
|
|
|
2708
2713
|
// src/cf.ts
|
|
2709
2714
|
var import_assert = __toESM(require("assert"));
|
|
@@ -3311,12 +3316,12 @@ function createHTTPRevivers(impl) {
|
|
|
3311
3316
|
},
|
|
3312
3317
|
Request(value) {
|
|
3313
3318
|
(0, import_node_assert.default)(Array.isArray(value));
|
|
3314
|
-
const [method,
|
|
3319
|
+
const [method, url18, headers, cf, body] = value;
|
|
3315
3320
|
(0, import_node_assert.default)(typeof method === "string");
|
|
3316
|
-
(0, import_node_assert.default)(typeof
|
|
3321
|
+
(0, import_node_assert.default)(typeof url18 === "string");
|
|
3317
3322
|
(0, import_node_assert.default)(headers instanceof impl.Headers);
|
|
3318
3323
|
(0, import_node_assert.default)(body === null || impl.isReadableStream(body));
|
|
3319
|
-
return new impl.Request(
|
|
3324
|
+
return new impl.Request(url18, {
|
|
3320
3325
|
method,
|
|
3321
3326
|
headers,
|
|
3322
3327
|
cf,
|
|
@@ -3445,23 +3450,23 @@ function parseWithReadableStreams(impl, stringified, revivers2) {
|
|
|
3445
3450
|
}
|
|
3446
3451
|
|
|
3447
3452
|
// src/workers/core/routing.ts
|
|
3448
|
-
function matchRoutes(routes,
|
|
3453
|
+
function matchRoutes(routes, url18) {
|
|
3449
3454
|
for (const route of routes) {
|
|
3450
|
-
if (route.protocol && route.protocol !==
|
|
3455
|
+
if (route.protocol && route.protocol !== url18.protocol)
|
|
3451
3456
|
continue;
|
|
3452
3457
|
if (route.allowHostnamePrefix) {
|
|
3453
|
-
if (!
|
|
3458
|
+
if (!url18.hostname.endsWith(route.hostname))
|
|
3454
3459
|
continue;
|
|
3455
3460
|
} else {
|
|
3456
|
-
if (
|
|
3461
|
+
if (url18.hostname !== route.hostname)
|
|
3457
3462
|
continue;
|
|
3458
3463
|
}
|
|
3459
|
-
const
|
|
3464
|
+
const path28 = url18.pathname + url18.search;
|
|
3460
3465
|
if (route.allowPathSuffix) {
|
|
3461
|
-
if (!
|
|
3466
|
+
if (!path28.startsWith(route.path))
|
|
3462
3467
|
continue;
|
|
3463
3468
|
} else {
|
|
3464
|
-
if (
|
|
3469
|
+
if (path28 !== route.path)
|
|
3465
3470
|
continue;
|
|
3466
3471
|
}
|
|
3467
3472
|
return route.target;
|
|
@@ -3706,8 +3711,8 @@ function decodeSitesKey(key) {
|
|
|
3706
3711
|
return key.startsWith(SITES_NO_CACHE_PREFIX) ? decodeURIComponent(key.substring(SITES_NO_CACHE_PREFIX.length)) : key;
|
|
3707
3712
|
}
|
|
3708
3713
|
function isSitesRequest(request) {
|
|
3709
|
-
const
|
|
3710
|
-
return
|
|
3714
|
+
const url18 = new URL(request.url);
|
|
3715
|
+
return url18.pathname.startsWith(`/${SITES_NO_CACHE_PREFIX}`);
|
|
3711
3716
|
}
|
|
3712
3717
|
function serialiseRegExp(regExp) {
|
|
3713
3718
|
const str = regExp.toString();
|
|
@@ -3786,8 +3791,15 @@ var QueueConsumerOptionsSchema = /* @__PURE__ */ import_zod2.z.object({
|
|
|
3786
3791
|
maxBatchTimeout: import_zod2.z.number().min(0).max(30).optional(),
|
|
3787
3792
|
// seconds
|
|
3788
3793
|
maxRetires: import_zod2.z.number().min(0).max(100).optional(),
|
|
3794
|
+
// deprecated
|
|
3795
|
+
maxRetries: import_zod2.z.number().min(0).max(100).optional(),
|
|
3789
3796
|
deadLetterQueue: import_zod2.z.ostring(),
|
|
3790
3797
|
retryDelay: QueueMessageDelaySchema
|
|
3798
|
+
}).transform((queue) => {
|
|
3799
|
+
if (queue.maxRetires !== void 0) {
|
|
3800
|
+
queue.maxRetries = queue.maxRetires;
|
|
3801
|
+
}
|
|
3802
|
+
return queue;
|
|
3791
3803
|
});
|
|
3792
3804
|
var QueueConsumerSchema = /* @__PURE__ */ import_zod2.z.intersection(
|
|
3793
3805
|
QueueConsumerOptionsSchema,
|
|
@@ -3854,8 +3866,8 @@ var Response = class extends import_undici3.Response {
|
|
|
3854
3866
|
Object.setPrototypeOf(response, Response.prototype);
|
|
3855
3867
|
return response;
|
|
3856
3868
|
}
|
|
3857
|
-
static redirect(
|
|
3858
|
-
const response = import_undici3.Response.redirect(
|
|
3869
|
+
static redirect(url18, status) {
|
|
3870
|
+
const response = import_undici3.Response.redirect(url18, status);
|
|
3859
3871
|
Object.setPrototypeOf(response, Response.prototype);
|
|
3860
3872
|
return response;
|
|
3861
3873
|
}
|
|
@@ -4363,14 +4375,14 @@ async function fetch3(input, init2) {
|
|
|
4363
4375
|
const requestInit = init2;
|
|
4364
4376
|
const request = new Request(input, requestInit);
|
|
4365
4377
|
if (request.method === "GET" && request.headers.get("upgrade") === "websocket") {
|
|
4366
|
-
const
|
|
4367
|
-
if (
|
|
4378
|
+
const url18 = new URL(request.url);
|
|
4379
|
+
if (url18.protocol !== "http:" && url18.protocol !== "https:") {
|
|
4368
4380
|
throw new TypeError(
|
|
4369
|
-
`Fetch API cannot load: ${
|
|
4381
|
+
`Fetch API cannot load: ${url18.toString()}.
|
|
4370
4382
|
Make sure you're using http(s):// URLs for WebSocket requests via fetch.`
|
|
4371
4383
|
);
|
|
4372
4384
|
}
|
|
4373
|
-
|
|
4385
|
+
url18.protocol = url18.protocol.replace("http", "ws");
|
|
4374
4386
|
const headers = {};
|
|
4375
4387
|
let protocols;
|
|
4376
4388
|
for (const [key, value] of request.headers.entries()) {
|
|
@@ -4382,10 +4394,10 @@ Make sure you're using http(s):// URLs for WebSocket requests via fetch.`
|
|
|
4382
4394
|
}
|
|
4383
4395
|
let rejectUnauthorized;
|
|
4384
4396
|
if (requestInit.dispatcher instanceof DispatchFetchDispatcher) {
|
|
4385
|
-
requestInit.dispatcher.addHeaders(headers,
|
|
4397
|
+
requestInit.dispatcher.addHeaders(headers, url18.pathname + url18.search);
|
|
4386
4398
|
rejectUnauthorized = { rejectUnauthorized: false };
|
|
4387
4399
|
}
|
|
4388
|
-
const ws = new import_ws2.default(
|
|
4400
|
+
const ws = new import_ws2.default(url18, protocols, {
|
|
4389
4401
|
followRedirects: request.redirect === "follow",
|
|
4390
4402
|
headers,
|
|
4391
4403
|
...rejectUnauthorized
|
|
@@ -4444,8 +4456,8 @@ var DispatchFetchDispatcher = class extends undici.Dispatcher {
|
|
|
4444
4456
|
this.cfBlobJson = JSON.stringify(cfBlob);
|
|
4445
4457
|
}
|
|
4446
4458
|
cfBlobJson;
|
|
4447
|
-
addHeaders(headers,
|
|
4448
|
-
const originalURL = this.userRuntimeOrigin +
|
|
4459
|
+
addHeaders(headers, path28) {
|
|
4460
|
+
const originalURL = this.userRuntimeOrigin + path28;
|
|
4449
4461
|
addHeader(headers, CoreHeaders.ORIGINAL_URL, originalURL);
|
|
4450
4462
|
addHeader(headers, CoreHeaders.DISABLE_PRETTY_ERROR, "true");
|
|
4451
4463
|
if (this.cfBlobJson !== void 0) {
|
|
@@ -4458,16 +4470,16 @@ var DispatchFetchDispatcher = class extends undici.Dispatcher {
|
|
|
4458
4470
|
origin = this.actualRuntimeOrigin;
|
|
4459
4471
|
if (origin === this.actualRuntimeOrigin) {
|
|
4460
4472
|
options.origin = origin;
|
|
4461
|
-
let
|
|
4473
|
+
let path28 = options.path;
|
|
4462
4474
|
if (options.query !== void 0) {
|
|
4463
|
-
const
|
|
4475
|
+
const url18 = new URL(path28, "http://placeholder/");
|
|
4464
4476
|
for (const [key, value] of Object.entries(options.query)) {
|
|
4465
|
-
|
|
4477
|
+
url18.searchParams.append(key, value);
|
|
4466
4478
|
}
|
|
4467
|
-
|
|
4479
|
+
path28 = url18.pathname + url18.search;
|
|
4468
4480
|
}
|
|
4469
4481
|
options.headers ??= {};
|
|
4470
|
-
this.addHeaders(options.headers,
|
|
4482
|
+
this.addHeaders(options.headers, path28);
|
|
4471
4483
|
return this.runtimeDispatcher.dispatch(options, handler);
|
|
4472
4484
|
} else {
|
|
4473
4485
|
return this.globalDispatcher.dispatch(options, handler);
|
|
@@ -5079,12 +5091,12 @@ var kUnsafeEphemeralUniqueKey = Symbol.for(
|
|
|
5079
5091
|
var import_url11 = require("url");
|
|
5080
5092
|
var RouterError = class extends MiniflareError {
|
|
5081
5093
|
};
|
|
5082
|
-
function routeSpecificity(
|
|
5083
|
-
const hostParts =
|
|
5094
|
+
function routeSpecificity(url18) {
|
|
5095
|
+
const hostParts = url18.host.split(".");
|
|
5084
5096
|
let hostScore = hostParts.length;
|
|
5085
5097
|
if (hostParts[0] === "*")
|
|
5086
5098
|
hostScore -= 2;
|
|
5087
|
-
const pathParts =
|
|
5099
|
+
const pathParts = url18.pathname.split("/");
|
|
5088
5100
|
let pathScore = pathParts.length;
|
|
5089
5101
|
if (pathParts[pathParts.length - 1] === "*")
|
|
5090
5102
|
pathScore -= 2;
|
|
@@ -5098,30 +5110,30 @@ function parseRoutes(allRoutes) {
|
|
|
5098
5110
|
let urlInput = route;
|
|
5099
5111
|
if (!hasProtocol)
|
|
5100
5112
|
urlInput = `https://${urlInput}`;
|
|
5101
|
-
const
|
|
5102
|
-
const specificity = routeSpecificity(
|
|
5103
|
-
const protocol = hasProtocol ?
|
|
5104
|
-
const internationalisedAllowHostnamePrefix =
|
|
5105
|
-
const allowHostnamePrefix =
|
|
5106
|
-
const anyHostname =
|
|
5113
|
+
const url18 = new import_url11.URL(urlInput);
|
|
5114
|
+
const specificity = routeSpecificity(url18);
|
|
5115
|
+
const protocol = hasProtocol ? url18.protocol : void 0;
|
|
5116
|
+
const internationalisedAllowHostnamePrefix = url18.hostname.startsWith("xn--*");
|
|
5117
|
+
const allowHostnamePrefix = url18.hostname.startsWith("*") || internationalisedAllowHostnamePrefix;
|
|
5118
|
+
const anyHostname = url18.hostname === "*";
|
|
5107
5119
|
if (allowHostnamePrefix && !anyHostname) {
|
|
5108
|
-
let hostname =
|
|
5120
|
+
let hostname = url18.hostname;
|
|
5109
5121
|
if (internationalisedAllowHostnamePrefix) {
|
|
5110
5122
|
hostname = (0, import_url11.domainToUnicode)(hostname);
|
|
5111
5123
|
}
|
|
5112
|
-
|
|
5124
|
+
url18.hostname = hostname.substring(1);
|
|
5113
5125
|
}
|
|
5114
|
-
const allowPathSuffix =
|
|
5126
|
+
const allowPathSuffix = url18.pathname.endsWith("*");
|
|
5115
5127
|
if (allowPathSuffix) {
|
|
5116
|
-
|
|
5128
|
+
url18.pathname = url18.pathname.substring(0, url18.pathname.length - 1);
|
|
5117
5129
|
}
|
|
5118
|
-
if (
|
|
5130
|
+
if (url18.search) {
|
|
5119
5131
|
throw new RouterError(
|
|
5120
5132
|
"ERR_QUERY_STRING",
|
|
5121
5133
|
`Route "${route}" for "${target}" contains a query string. This is not allowed.`
|
|
5122
5134
|
);
|
|
5123
5135
|
}
|
|
5124
|
-
if (
|
|
5136
|
+
if (url18.toString().includes("*") && !anyHostname) {
|
|
5125
5137
|
throw new RouterError(
|
|
5126
5138
|
"ERR_INFIX_WILDCARD",
|
|
5127
5139
|
`Route "${route}" for "${target}" contains an infix wildcard. This is not allowed.`
|
|
@@ -5133,8 +5145,8 @@ function parseRoutes(allRoutes) {
|
|
|
5133
5145
|
specificity,
|
|
5134
5146
|
protocol,
|
|
5135
5147
|
allowHostnamePrefix,
|
|
5136
|
-
hostname: anyHostname ? "" :
|
|
5137
|
-
path:
|
|
5148
|
+
hostname: anyHostname ? "" : url18.hostname,
|
|
5149
|
+
path: url18.pathname,
|
|
5138
5150
|
allowPathSuffix
|
|
5139
5151
|
});
|
|
5140
5152
|
}
|
|
@@ -5175,11 +5187,11 @@ function namespaceEntries(namespaces) {
|
|
|
5175
5187
|
return [];
|
|
5176
5188
|
}
|
|
5177
5189
|
}
|
|
5178
|
-
function maybeParseURL(
|
|
5179
|
-
if (typeof
|
|
5190
|
+
function maybeParseURL(url18) {
|
|
5191
|
+
if (typeof url18 !== "string" || import_path14.default.isAbsolute(url18))
|
|
5180
5192
|
return;
|
|
5181
5193
|
try {
|
|
5182
|
-
return new URL(
|
|
5194
|
+
return new URL(url18);
|
|
5183
5195
|
} catch {
|
|
5184
5196
|
}
|
|
5185
5197
|
}
|
|
@@ -5188,16 +5200,16 @@ function getPersistPath(pluginName, tmpPath, persist) {
|
|
|
5188
5200
|
if (persist === void 0 || persist === false) {
|
|
5189
5201
|
return memoryishPath;
|
|
5190
5202
|
}
|
|
5191
|
-
const
|
|
5192
|
-
if (
|
|
5193
|
-
if (
|
|
5203
|
+
const url18 = maybeParseURL(persist);
|
|
5204
|
+
if (url18 !== void 0) {
|
|
5205
|
+
if (url18.protocol === "memory:") {
|
|
5194
5206
|
return memoryishPath;
|
|
5195
|
-
} else if (
|
|
5196
|
-
return (0, import_url12.fileURLToPath)(
|
|
5207
|
+
} else if (url18.protocol === "file:") {
|
|
5208
|
+
return (0, import_url12.fileURLToPath)(url18);
|
|
5197
5209
|
}
|
|
5198
5210
|
throw new MiniflareCoreError(
|
|
5199
5211
|
"ERR_PERSIST_UNSUPPORTED",
|
|
5200
|
-
`Unsupported "${
|
|
5212
|
+
`Unsupported "${url18.protocol}" persistence protocol for storage: ${url18.href}`
|
|
5201
5213
|
);
|
|
5202
5214
|
}
|
|
5203
5215
|
return persist === true ? import_path14.default.join(DEFAULT_PERSIST_ROOT, pluginName) : persist;
|
|
@@ -5817,60 +5829,60 @@ function createJavaScriptModule(code, name, modulePath, type) {
|
|
|
5817
5829
|
}
|
|
5818
5830
|
var encoder = new import_util.TextEncoder();
|
|
5819
5831
|
var decoder = new import_util.TextDecoder();
|
|
5820
|
-
function contentsToString(
|
|
5821
|
-
return typeof
|
|
5832
|
+
function contentsToString(contents18) {
|
|
5833
|
+
return typeof contents18 === "string" ? contents18 : decoder.decode(contents18);
|
|
5822
5834
|
}
|
|
5823
|
-
function contentsToArray(
|
|
5824
|
-
return typeof
|
|
5835
|
+
function contentsToArray(contents18) {
|
|
5836
|
+
return typeof contents18 === "string" ? encoder.encode(contents18) : contents18;
|
|
5825
5837
|
}
|
|
5826
5838
|
function convertModuleDefinition(modulesRoot, def) {
|
|
5827
5839
|
const name = moduleName(modulesRoot, def.path);
|
|
5828
|
-
const
|
|
5840
|
+
const contents18 = def.contents ?? (0, import_fs12.readFileSync)(def.path);
|
|
5829
5841
|
switch (def.type) {
|
|
5830
5842
|
case "ESModule":
|
|
5831
5843
|
case "CommonJS":
|
|
5832
5844
|
case "NodeJsCompatModule":
|
|
5833
5845
|
return createJavaScriptModule(
|
|
5834
|
-
contentsToString(
|
|
5846
|
+
contentsToString(contents18),
|
|
5835
5847
|
name,
|
|
5836
5848
|
import_path15.default.resolve(modulesRoot, def.path),
|
|
5837
5849
|
def.type
|
|
5838
5850
|
);
|
|
5839
5851
|
case "Text":
|
|
5840
|
-
return { name, text: contentsToString(
|
|
5852
|
+
return { name, text: contentsToString(contents18) };
|
|
5841
5853
|
case "Data":
|
|
5842
|
-
return { name, data: contentsToArray(
|
|
5854
|
+
return { name, data: contentsToArray(contents18) };
|
|
5843
5855
|
case "CompiledWasm":
|
|
5844
|
-
return { name, wasm: contentsToArray(
|
|
5856
|
+
return { name, wasm: contentsToArray(contents18) };
|
|
5845
5857
|
case "PythonModule":
|
|
5846
|
-
return { name, pythonModule: contentsToString(
|
|
5858
|
+
return { name, pythonModule: contentsToString(contents18) };
|
|
5847
5859
|
case "PythonRequirement":
|
|
5848
|
-
return { name, pythonRequirement: contentsToString(
|
|
5860
|
+
return { name, pythonRequirement: contentsToString(contents18) };
|
|
5849
5861
|
default:
|
|
5850
5862
|
const exhaustive = def.type;
|
|
5851
5863
|
import_assert5.default.fail(`Unreachable: ${exhaustive} modules are unsupported`);
|
|
5852
5864
|
}
|
|
5853
5865
|
}
|
|
5854
5866
|
function convertWorkerModule(mod) {
|
|
5855
|
-
const
|
|
5856
|
-
(0, import_assert5.default)(
|
|
5867
|
+
const path28 = mod.name;
|
|
5868
|
+
(0, import_assert5.default)(path28 !== void 0);
|
|
5857
5869
|
const m = mod;
|
|
5858
5870
|
if ("esModule" in m)
|
|
5859
|
-
return { path:
|
|
5871
|
+
return { path: path28, type: "ESModule" };
|
|
5860
5872
|
else if ("commonJsModule" in m)
|
|
5861
|
-
return { path:
|
|
5873
|
+
return { path: path28, type: "CommonJS" };
|
|
5862
5874
|
else if ("nodeJsCompatModule" in m)
|
|
5863
|
-
return { path:
|
|
5875
|
+
return { path: path28, type: "NodeJsCompatModule" };
|
|
5864
5876
|
else if ("text" in m)
|
|
5865
|
-
return { path:
|
|
5877
|
+
return { path: path28, type: "Text" };
|
|
5866
5878
|
else if ("data" in m)
|
|
5867
|
-
return { path:
|
|
5879
|
+
return { path: path28, type: "Data" };
|
|
5868
5880
|
else if ("wasm" in m)
|
|
5869
|
-
return { path:
|
|
5881
|
+
return { path: path28, type: "CompiledWasm" };
|
|
5870
5882
|
else if ("pythonModule" in m)
|
|
5871
|
-
return { path:
|
|
5883
|
+
return { path: path28, type: "PythonModule" };
|
|
5872
5884
|
else if ("pythonRequirement" in m)
|
|
5873
|
-
return { path:
|
|
5885
|
+
return { path: path28, type: "PythonRequirement" };
|
|
5874
5886
|
(0, import_assert5.default)(
|
|
5875
5887
|
!("json" in m || "fallbackService" in m),
|
|
5876
5888
|
"Unreachable: json or fallbackService modules aren't generated"
|
|
@@ -6073,8 +6085,8 @@ function getSourceMapper() {
|
|
|
6073
6085
|
// src/plugins/core/errors/index.ts
|
|
6074
6086
|
function maybeGetDiskFile(filePath) {
|
|
6075
6087
|
try {
|
|
6076
|
-
const
|
|
6077
|
-
return { path: filePath, contents:
|
|
6088
|
+
const contents18 = import_fs13.default.readFileSync(filePath, "utf8");
|
|
6089
|
+
return { path: filePath, contents: contents18 };
|
|
6078
6090
|
} catch (e) {
|
|
6079
6091
|
if (e.code !== "ENOENT")
|
|
6080
6092
|
throw e;
|
|
@@ -6089,8 +6101,8 @@ function maybeGetFile(workerSrcOpts, fileSpecifier) {
|
|
|
6089
6101
|
const modulesRoot = srcOpts.modulesRoot ?? "";
|
|
6090
6102
|
for (const module2 of srcOpts.modules) {
|
|
6091
6103
|
if (module2.contents !== void 0 && import_path16.default.resolve(modulesRoot, module2.path) === filePath) {
|
|
6092
|
-
const
|
|
6093
|
-
return { path: filePath, contents:
|
|
6104
|
+
const contents18 = contentsToString(module2.contents);
|
|
6105
|
+
return { path: filePath, contents: contents18 };
|
|
6094
6106
|
}
|
|
6095
6107
|
}
|
|
6096
6108
|
} else if ("script" in srcOpts && "scriptPath" in srcOpts && srcOpts.script !== void 0 && srcOpts.scriptPath !== void 0) {
|
|
@@ -6274,7 +6286,7 @@ var SynchronousFetcher = class {
|
|
|
6274
6286
|
transferList: [this.#channel.port2]
|
|
6275
6287
|
});
|
|
6276
6288
|
}
|
|
6277
|
-
fetch(
|
|
6289
|
+
fetch(url18, init2) {
|
|
6278
6290
|
this.#ensureWorker();
|
|
6279
6291
|
Atomics.store(
|
|
6280
6292
|
this.#notifyHandle,
|
|
@@ -6287,7 +6299,7 @@ var SynchronousFetcher = class {
|
|
|
6287
6299
|
this.#channel.port1.postMessage({
|
|
6288
6300
|
id,
|
|
6289
6301
|
method: init2.method,
|
|
6290
|
-
url:
|
|
6302
|
+
url: url18.toString(),
|
|
6291
6303
|
headers: init2.headers,
|
|
6292
6304
|
body: init2.body
|
|
6293
6305
|
});
|
|
@@ -6407,8 +6419,8 @@ var ProxyClient = class {
|
|
|
6407
6419
|
}
|
|
6408
6420
|
};
|
|
6409
6421
|
var ProxyClientBridge = class {
|
|
6410
|
-
constructor(
|
|
6411
|
-
this.url =
|
|
6422
|
+
constructor(url18, dispatchFetch) {
|
|
6423
|
+
this.url = url18;
|
|
6412
6424
|
this.dispatchFetch = dispatchFetch;
|
|
6413
6425
|
this.#finalizationRegistry = new FinalizationRegistry(this.#finalizeProxy);
|
|
6414
6426
|
}
|
|
@@ -7106,7 +7118,7 @@ var CORE_PLUGIN = {
|
|
|
7106
7118
|
if (options.textBlobBindings !== void 0) {
|
|
7107
7119
|
bindings.push(
|
|
7108
7120
|
...Object.entries(options.textBlobBindings).map(
|
|
7109
|
-
([name,
|
|
7121
|
+
([name, path28]) => import_promises6.default.readFile(path28, "utf8").then((text) => ({ name, text }))
|
|
7110
7122
|
)
|
|
7111
7123
|
);
|
|
7112
7124
|
}
|
|
@@ -7179,7 +7191,7 @@ var CORE_PLUGIN = {
|
|
|
7179
7191
|
if (options.textBlobBindings !== void 0) {
|
|
7180
7192
|
bindingEntries2.push(
|
|
7181
7193
|
...Object.entries(options.textBlobBindings).map(
|
|
7182
|
-
([name,
|
|
7194
|
+
([name, path28]) => import_promises6.default.readFile(path28, "utf8").then((text) => [name, text])
|
|
7183
7195
|
)
|
|
7184
7196
|
);
|
|
7185
7197
|
}
|
|
@@ -7752,9 +7764,9 @@ var encodeManifest = (manifest) => {
|
|
|
7752
7764
|
var bytesToHex = (buffer) => {
|
|
7753
7765
|
return [...new Uint8Array(buffer)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7754
7766
|
};
|
|
7755
|
-
var hashPath = async (
|
|
7767
|
+
var hashPath = async (path28) => {
|
|
7756
7768
|
const encoder3 = new TextEncoder();
|
|
7757
|
-
const data = encoder3.encode(
|
|
7769
|
+
const data = encoder3.encode(path28);
|
|
7758
7770
|
const hashBuffer = await import_node_crypto.default.subtle.digest("SHA-256", data.buffer);
|
|
7759
7771
|
return new Uint8Array(hashBuffer, 0, PATH_HASH_SIZE);
|
|
7760
7772
|
};
|
|
@@ -7895,55 +7907,55 @@ var D1_PLUGIN = {
|
|
|
7895
7907
|
var import_node_assert3 = __toESM(require("node:assert"));
|
|
7896
7908
|
var import_zod15 = require("zod");
|
|
7897
7909
|
var HYPERDRIVE_PLUGIN_NAME = "hyperdrive";
|
|
7898
|
-
function hasPostgresProtocol(
|
|
7899
|
-
return
|
|
7910
|
+
function hasPostgresProtocol(url18) {
|
|
7911
|
+
return url18.protocol === "postgresql:" || url18.protocol === "postgres:";
|
|
7900
7912
|
}
|
|
7901
|
-
function getPort(
|
|
7902
|
-
if (
|
|
7903
|
-
return
|
|
7904
|
-
if (hasPostgresProtocol(
|
|
7913
|
+
function getPort(url18) {
|
|
7914
|
+
if (url18.port !== "")
|
|
7915
|
+
return url18.port;
|
|
7916
|
+
if (hasPostgresProtocol(url18))
|
|
7905
7917
|
return "5432";
|
|
7906
|
-
import_node_assert3.default.fail(`Expected known protocol, got ${
|
|
7918
|
+
import_node_assert3.default.fail(`Expected known protocol, got ${url18.protocol}`);
|
|
7907
7919
|
}
|
|
7908
|
-
var HyperdriveSchema = import_zod15.z.union([import_zod15.z.string().url(), import_zod15.z.instanceof(URL)]).transform((
|
|
7909
|
-
if (typeof
|
|
7910
|
-
|
|
7911
|
-
if (
|
|
7920
|
+
var HyperdriveSchema = import_zod15.z.union([import_zod15.z.string().url(), import_zod15.z.instanceof(URL)]).transform((url18, ctx) => {
|
|
7921
|
+
if (typeof url18 === "string")
|
|
7922
|
+
url18 = new URL(url18);
|
|
7923
|
+
if (url18.protocol === "") {
|
|
7912
7924
|
ctx.addIssue({
|
|
7913
7925
|
code: import_zod15.z.ZodIssueCode.custom,
|
|
7914
7926
|
message: "You must specify the database protocol - e.g. 'postgresql'."
|
|
7915
7927
|
});
|
|
7916
|
-
} else if (!hasPostgresProtocol(
|
|
7928
|
+
} else if (!hasPostgresProtocol(url18)) {
|
|
7917
7929
|
ctx.addIssue({
|
|
7918
7930
|
code: import_zod15.z.ZodIssueCode.custom,
|
|
7919
7931
|
message: "Only PostgreSQL or PostgreSQL compatible databases are currently supported."
|
|
7920
7932
|
});
|
|
7921
7933
|
}
|
|
7922
|
-
if (
|
|
7934
|
+
if (url18.host === "") {
|
|
7923
7935
|
ctx.addIssue({
|
|
7924
7936
|
code: import_zod15.z.ZodIssueCode.custom,
|
|
7925
7937
|
message: "You must provide a hostname or IP address in your connection string - e.g. 'user:password@database-hostname.example.com:5432/databasename"
|
|
7926
7938
|
});
|
|
7927
7939
|
}
|
|
7928
|
-
if (
|
|
7940
|
+
if (url18.pathname === "") {
|
|
7929
7941
|
ctx.addIssue({
|
|
7930
7942
|
code: import_zod15.z.ZodIssueCode.custom,
|
|
7931
7943
|
message: "You must provide a database name as the path component - e.g. /postgres"
|
|
7932
7944
|
});
|
|
7933
7945
|
}
|
|
7934
|
-
if (
|
|
7946
|
+
if (url18.username === "") {
|
|
7935
7947
|
ctx.addIssue({
|
|
7936
7948
|
code: import_zod15.z.ZodIssueCode.custom,
|
|
7937
7949
|
message: "You must provide a username - e.g. 'user:password@database.example.com:port/databasename'"
|
|
7938
7950
|
});
|
|
7939
7951
|
}
|
|
7940
|
-
if (
|
|
7952
|
+
if (url18.password === "") {
|
|
7941
7953
|
ctx.addIssue({
|
|
7942
7954
|
code: import_zod15.z.ZodIssueCode.custom,
|
|
7943
7955
|
message: "You must provide a password - e.g. 'user:password@database.example.com:port/databasename' "
|
|
7944
7956
|
});
|
|
7945
7957
|
}
|
|
7946
|
-
return
|
|
7958
|
+
return url18;
|
|
7947
7959
|
});
|
|
7948
7960
|
var HyperdriveInputOptionsSchema = import_zod15.z.object({
|
|
7949
7961
|
hyperdrives: import_zod15.z.record(import_zod15.z.string(), HyperdriveSchema).optional()
|
|
@@ -7952,9 +7964,9 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
7952
7964
|
options: HyperdriveInputOptionsSchema,
|
|
7953
7965
|
getBindings(options) {
|
|
7954
7966
|
return Object.entries(options.hyperdrives ?? {}).map(
|
|
7955
|
-
([name,
|
|
7956
|
-
const database =
|
|
7957
|
-
const scheme =
|
|
7967
|
+
([name, url18]) => {
|
|
7968
|
+
const database = url18.pathname.replace("/", "");
|
|
7969
|
+
const scheme = url18.protocol.replace(":", "");
|
|
7958
7970
|
return {
|
|
7959
7971
|
name,
|
|
7960
7972
|
hyperdrive: {
|
|
@@ -7962,8 +7974,8 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
7962
7974
|
name: `${HYPERDRIVE_PLUGIN_NAME}:${name}`
|
|
7963
7975
|
},
|
|
7964
7976
|
database: decodeURIComponent(database),
|
|
7965
|
-
user: decodeURIComponent(
|
|
7966
|
-
password: decodeURIComponent(
|
|
7977
|
+
user: decodeURIComponent(url18.username),
|
|
7978
|
+
password: decodeURIComponent(url18.password),
|
|
7967
7979
|
scheme
|
|
7968
7980
|
}
|
|
7969
7981
|
};
|
|
@@ -7972,11 +7984,11 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
7972
7984
|
},
|
|
7973
7985
|
getNodeBindings(options) {
|
|
7974
7986
|
return Object.fromEntries(
|
|
7975
|
-
Object.entries(options.hyperdrives ?? {}).map(([name,
|
|
7987
|
+
Object.entries(options.hyperdrives ?? {}).map(([name, url18]) => {
|
|
7976
7988
|
const connectionOverrides = {
|
|
7977
|
-
connectionString: `${
|
|
7978
|
-
port: Number.parseInt(
|
|
7979
|
-
host:
|
|
7989
|
+
connectionString: `${url18}`,
|
|
7990
|
+
port: Number.parseInt(url18.port),
|
|
7991
|
+
host: url18.hostname
|
|
7980
7992
|
};
|
|
7981
7993
|
const proxyNodeBinding = new ProxyNodeBinding({
|
|
7982
7994
|
get(target, prop) {
|
|
@@ -7989,10 +8001,10 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
7989
8001
|
},
|
|
7990
8002
|
async getServices({ options }) {
|
|
7991
8003
|
return Object.entries(options.hyperdrives ?? {}).map(
|
|
7992
|
-
([name,
|
|
8004
|
+
([name, url18]) => ({
|
|
7993
8005
|
name: `${HYPERDRIVE_PLUGIN_NAME}:${name}`,
|
|
7994
8006
|
external: {
|
|
7995
|
-
address: `${
|
|
8007
|
+
address: `${url18.hostname}:${getPort(url18)}`,
|
|
7996
8008
|
tcp: {}
|
|
7997
8009
|
}
|
|
7998
8010
|
})
|
|
@@ -8326,7 +8338,11 @@ var QUEUES_PLUGIN = {
|
|
|
8326
8338
|
{ name: "broker.worker.js", esModule: broker_worker_default() }
|
|
8327
8339
|
],
|
|
8328
8340
|
durableObjectNamespaces: [
|
|
8329
|
-
{
|
|
8341
|
+
{
|
|
8342
|
+
className: QUEUE_BROKER_OBJECT_CLASS_NAME,
|
|
8343
|
+
uniqueKey,
|
|
8344
|
+
preventEviction: true
|
|
8345
|
+
}
|
|
8330
8346
|
],
|
|
8331
8347
|
// Miniflare's Queue broker is in-memory only at the moment
|
|
8332
8348
|
durableObjectStorage: { inMemory: kVoid },
|
|
@@ -8589,6 +8605,122 @@ var RATELIMIT_PLUGIN = {
|
|
|
8589
8605
|
}
|
|
8590
8606
|
};
|
|
8591
8607
|
|
|
8608
|
+
// src/plugins/workflows/index.ts
|
|
8609
|
+
var import_promises12 = __toESM(require("fs/promises"));
|
|
8610
|
+
|
|
8611
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/workflows/binding.worker.ts
|
|
8612
|
+
var import_fs21 = __toESM(require("fs"));
|
|
8613
|
+
var import_path25 = __toESM(require("path"));
|
|
8614
|
+
var import_url21 = __toESM(require("url"));
|
|
8615
|
+
var contents17;
|
|
8616
|
+
function binding_worker_default() {
|
|
8617
|
+
if (contents17 !== void 0)
|
|
8618
|
+
return contents17;
|
|
8619
|
+
const filePath = import_path25.default.join(__dirname, "workers", "workflows/binding.worker.js");
|
|
8620
|
+
contents17 = import_fs21.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url21.default.pathToFileURL(filePath);
|
|
8621
|
+
return contents17;
|
|
8622
|
+
}
|
|
8623
|
+
|
|
8624
|
+
// src/plugins/workflows/index.ts
|
|
8625
|
+
var import_zod20 = require("zod");
|
|
8626
|
+
var WorkflowsOptionsSchema = import_zod20.z.object({
|
|
8627
|
+
workflows: import_zod20.z.record(
|
|
8628
|
+
import_zod20.z.object({
|
|
8629
|
+
name: import_zod20.z.string(),
|
|
8630
|
+
className: import_zod20.z.string(),
|
|
8631
|
+
scriptName: import_zod20.z.string().optional()
|
|
8632
|
+
})
|
|
8633
|
+
).optional()
|
|
8634
|
+
});
|
|
8635
|
+
var WorkflowsSharedOptionsSchema = import_zod20.z.object({
|
|
8636
|
+
workflowsPersist: PersistenceSchema
|
|
8637
|
+
});
|
|
8638
|
+
var WORKFLOWS_PLUGIN_NAME = "workflows";
|
|
8639
|
+
var WORKFLOWS_STORAGE_SERVICE_NAME = `${WORKFLOWS_PLUGIN_NAME}:storage`;
|
|
8640
|
+
var WORKFLOWS_PLUGIN = {
|
|
8641
|
+
options: WorkflowsOptionsSchema,
|
|
8642
|
+
sharedOptions: WorkflowsSharedOptionsSchema,
|
|
8643
|
+
async getBindings(options) {
|
|
8644
|
+
return Object.entries(options.workflows ?? {}).map(
|
|
8645
|
+
([bindingName, workflow]) => ({
|
|
8646
|
+
name: bindingName,
|
|
8647
|
+
service: {
|
|
8648
|
+
name: `${WORKFLOWS_PLUGIN_NAME}:${workflow.name}`,
|
|
8649
|
+
entrypoint: "WorkflowBinding"
|
|
8650
|
+
}
|
|
8651
|
+
})
|
|
8652
|
+
);
|
|
8653
|
+
},
|
|
8654
|
+
async getNodeBindings(options) {
|
|
8655
|
+
return Object.fromEntries(
|
|
8656
|
+
Object.keys(options.workflows ?? {}).map((bindingName) => [
|
|
8657
|
+
bindingName,
|
|
8658
|
+
new ProxyNodeBinding()
|
|
8659
|
+
])
|
|
8660
|
+
);
|
|
8661
|
+
},
|
|
8662
|
+
async getServices({ options, sharedOptions, tmpPath }) {
|
|
8663
|
+
const persistPath = getPersistPath(
|
|
8664
|
+
WORKFLOWS_PLUGIN_NAME,
|
|
8665
|
+
tmpPath,
|
|
8666
|
+
sharedOptions.workflowsPersist
|
|
8667
|
+
);
|
|
8668
|
+
await import_promises12.default.mkdir(persistPath, { recursive: true });
|
|
8669
|
+
const storageService = {
|
|
8670
|
+
name: WORKFLOWS_STORAGE_SERVICE_NAME,
|
|
8671
|
+
disk: { path: persistPath, writable: true }
|
|
8672
|
+
};
|
|
8673
|
+
const services = Object.entries(options.workflows ?? {}).map(
|
|
8674
|
+
([_bindingName, workflow]) => {
|
|
8675
|
+
const uniqueKey = `miniflare-workflows`;
|
|
8676
|
+
const workflowsBinding = {
|
|
8677
|
+
name: `${WORKFLOWS_PLUGIN_NAME}:${workflow.name}`,
|
|
8678
|
+
worker: {
|
|
8679
|
+
compatibilityDate: "2024-10-22",
|
|
8680
|
+
modules: [
|
|
8681
|
+
{
|
|
8682
|
+
name: "workflows.mjs",
|
|
8683
|
+
esModule: binding_worker_default()
|
|
8684
|
+
}
|
|
8685
|
+
],
|
|
8686
|
+
durableObjectNamespaces: [
|
|
8687
|
+
{
|
|
8688
|
+
className: "Engine",
|
|
8689
|
+
enableSql: true,
|
|
8690
|
+
uniqueKey,
|
|
8691
|
+
preventEviction: true
|
|
8692
|
+
}
|
|
8693
|
+
],
|
|
8694
|
+
// this might conflict between workflows
|
|
8695
|
+
durableObjectStorage: { localDisk: WORKFLOWS_STORAGE_SERVICE_NAME },
|
|
8696
|
+
bindings: [
|
|
8697
|
+
{
|
|
8698
|
+
name: "ENGINE",
|
|
8699
|
+
durableObjectNamespace: { className: "Engine" }
|
|
8700
|
+
},
|
|
8701
|
+
{
|
|
8702
|
+
name: "USER_WORKFLOW",
|
|
8703
|
+
service: {
|
|
8704
|
+
name: getUserServiceName(workflow.scriptName),
|
|
8705
|
+
entrypoint: workflow.className
|
|
8706
|
+
}
|
|
8707
|
+
}
|
|
8708
|
+
]
|
|
8709
|
+
}
|
|
8710
|
+
};
|
|
8711
|
+
return workflowsBinding;
|
|
8712
|
+
}
|
|
8713
|
+
);
|
|
8714
|
+
if (services.length === 0) {
|
|
8715
|
+
return [];
|
|
8716
|
+
}
|
|
8717
|
+
return [storageService, ...services];
|
|
8718
|
+
},
|
|
8719
|
+
getPersistPath({ workflowsPersist }, tmpPath) {
|
|
8720
|
+
return getPersistPath(WORKFLOWS_PLUGIN_NAME, tmpPath, workflowsPersist);
|
|
8721
|
+
}
|
|
8722
|
+
};
|
|
8723
|
+
|
|
8592
8724
|
// src/plugins/index.ts
|
|
8593
8725
|
var PLUGINS = {
|
|
8594
8726
|
[CORE_PLUGIN_NAME2]: CORE_PLUGIN,
|
|
@@ -8600,7 +8732,8 @@ var PLUGINS = {
|
|
|
8600
8732
|
[R2_PLUGIN_NAME]: R2_PLUGIN,
|
|
8601
8733
|
[HYPERDRIVE_PLUGIN_NAME]: HYPERDRIVE_PLUGIN,
|
|
8602
8734
|
[RATELIMIT_PLUGIN_NAME]: RATELIMIT_PLUGIN,
|
|
8603
|
-
[ASSETS_PLUGIN_NAME]: ASSETS_PLUGIN
|
|
8735
|
+
[ASSETS_PLUGIN_NAME]: ASSETS_PLUGIN,
|
|
8736
|
+
[WORKFLOWS_PLUGIN_NAME]: WORKFLOWS_PLUGIN
|
|
8604
8737
|
};
|
|
8605
8738
|
var PLUGIN_ENTRIES = Object.entries(PLUGINS);
|
|
8606
8739
|
|
|
@@ -8706,8 +8839,8 @@ function hasMultipleDistinctMessages(issues, atDepth) {
|
|
|
8706
8839
|
}
|
|
8707
8840
|
return false;
|
|
8708
8841
|
}
|
|
8709
|
-
function annotate(groupCounts, annotated, input, issue,
|
|
8710
|
-
if (
|
|
8842
|
+
function annotate(groupCounts, annotated, input, issue, path28, groupId) {
|
|
8843
|
+
if (path28.length === 0) {
|
|
8711
8844
|
if (issue.code === "invalid_union") {
|
|
8712
8845
|
const unionIssues = issue.unionErrors.flatMap(({ issues }) => issues);
|
|
8713
8846
|
let newGroupId;
|
|
@@ -8754,7 +8887,7 @@ function annotate(groupCounts, annotated, input, issue, path27, groupId) {
|
|
|
8754
8887
|
[kGroupId]: groupId
|
|
8755
8888
|
};
|
|
8756
8889
|
}
|
|
8757
|
-
const [head, ...tail] =
|
|
8890
|
+
const [head, ...tail] = path28;
|
|
8758
8891
|
(0, import_assert11.default)(isRecord(input), "Expected object/array input for nested issue");
|
|
8759
8892
|
if (annotated === void 0) {
|
|
8760
8893
|
if (Array.isArray(input)) {
|
|
@@ -8964,7 +9097,7 @@ function validateOptions(opts) {
|
|
|
8964
9097
|
);
|
|
8965
9098
|
const sharedRootPath = multipleWorkers ? getRootPath(sharedOpts) : "";
|
|
8966
9099
|
const workerRootPaths = workerOpts.map(
|
|
8967
|
-
(opts2) =>
|
|
9100
|
+
(opts2) => import_path26.default.resolve(sharedRootPath, getRootPath(opts2))
|
|
8968
9101
|
);
|
|
8969
9102
|
try {
|
|
8970
9103
|
for (const [key, plugin] of PLUGIN_ENTRIES) {
|
|
@@ -8980,7 +9113,7 @@ function validateOptions(opts) {
|
|
|
8980
9113
|
}
|
|
8981
9114
|
}
|
|
8982
9115
|
} catch (e) {
|
|
8983
|
-
if (e instanceof
|
|
9116
|
+
if (e instanceof import_zod22.z.ZodError) {
|
|
8984
9117
|
let formatted;
|
|
8985
9118
|
try {
|
|
8986
9119
|
formatted = formatZodError(e, opts);
|
|
@@ -9392,7 +9525,7 @@ var Miniflare2 = class {
|
|
|
9392
9525
|
}
|
|
9393
9526
|
}
|
|
9394
9527
|
});
|
|
9395
|
-
this.#tmpPath =
|
|
9528
|
+
this.#tmpPath = import_path26.default.join(
|
|
9396
9529
|
import_os2.default.tmpdir(),
|
|
9397
9530
|
`miniflare-${import_crypto3.default.randomBytes(16).toString("hex")}`
|
|
9398
9531
|
);
|
|
@@ -9400,7 +9533,7 @@ var Miniflare2 = class {
|
|
|
9400
9533
|
this.#removeExitHook = (0, import_exit_hook.default)(() => {
|
|
9401
9534
|
void this.#runtime?.dispose();
|
|
9402
9535
|
try {
|
|
9403
|
-
|
|
9536
|
+
import_fs22.default.rmSync(this.#tmpPath, { force: true, recursive: true });
|
|
9404
9537
|
} catch (e) {
|
|
9405
9538
|
this.#log.debug(`Unable to remove temporary directory: ${String(e)}`);
|
|
9406
9539
|
}
|
|
@@ -9437,7 +9570,7 @@ var Miniflare2 = class {
|
|
|
9437
9570
|
if (!(response instanceof Response)) {
|
|
9438
9571
|
response = new Response(response.body, response);
|
|
9439
9572
|
}
|
|
9440
|
-
return
|
|
9573
|
+
return import_zod22.z.instanceof(Response).parse(response);
|
|
9441
9574
|
} catch (e) {
|
|
9442
9575
|
return new Response(e?.stack ?? e, { status: 500 });
|
|
9443
9576
|
}
|
|
@@ -9462,11 +9595,11 @@ var Miniflare2 = class {
|
|
|
9462
9595
|
(0, import_assert12.default)(!Array.isArray(cfBlob));
|
|
9463
9596
|
const cf = cfBlob ? JSON.parse(cfBlob) : void 0;
|
|
9464
9597
|
const originalUrl = headers.get(CoreHeaders.ORIGINAL_URL);
|
|
9465
|
-
const
|
|
9598
|
+
const url18 = new URL(originalUrl ?? req.url ?? "", "http://localhost");
|
|
9466
9599
|
headers.delete(CoreHeaders.ORIGINAL_URL);
|
|
9467
9600
|
const noBody = req.method === "GET" || req.method === "HEAD";
|
|
9468
9601
|
const body = noBody ? void 0 : safeReadableStreamFrom(req);
|
|
9469
|
-
const request = new Request(
|
|
9602
|
+
const request = new Request(url18, {
|
|
9470
9603
|
method: req.method,
|
|
9471
9604
|
headers,
|
|
9472
9605
|
body,
|
|
@@ -9487,13 +9620,13 @@ var Miniflare2 = class {
|
|
|
9487
9620
|
request,
|
|
9488
9621
|
this
|
|
9489
9622
|
);
|
|
9490
|
-
} else if (
|
|
9623
|
+
} else if (url18.pathname === "/core/error") {
|
|
9491
9624
|
response = await handlePrettyErrorRequest(
|
|
9492
9625
|
this.#log,
|
|
9493
9626
|
this.#workerSrcOpts,
|
|
9494
9627
|
request
|
|
9495
9628
|
);
|
|
9496
|
-
} else if (
|
|
9629
|
+
} else if (url18.pathname === "/core/log") {
|
|
9497
9630
|
const level = parseInt(request.headers.get(SharedHeaders.LOG_LEVEL));
|
|
9498
9631
|
(0, import_assert12.default)(
|
|
9499
9632
|
0 /* NONE */ <= level && level <= 5 /* VERBOSE */,
|
|
@@ -9643,6 +9776,11 @@ var Miniflare2 = class {
|
|
|
9643
9776
|
const workerOpts = allWorkerOpts[i];
|
|
9644
9777
|
const workerName = workerOpts.core.name ?? "";
|
|
9645
9778
|
const isModulesWorker = Boolean(workerOpts.core.modules);
|
|
9779
|
+
if (workerOpts.workflows.workflows) {
|
|
9780
|
+
for (const workflow of Object.values(workerOpts.workflows.workflows)) {
|
|
9781
|
+
workflow.scriptName ??= workerOpts.core.name;
|
|
9782
|
+
}
|
|
9783
|
+
}
|
|
9646
9784
|
const workerBindings = [];
|
|
9647
9785
|
allWorkerBindings.set(workerName, workerBindings);
|
|
9648
9786
|
const additionalModules = [];
|
|
@@ -9975,11 +10113,11 @@ var Miniflare2 = class {
|
|
|
9975
10113
|
(0, import_assert12.default)(this.#runtimeEntryURL !== void 0);
|
|
9976
10114
|
(0, import_assert12.default)(this.#runtimeDispatcher !== void 0);
|
|
9977
10115
|
const forward = new Request(input, init2);
|
|
9978
|
-
const
|
|
10116
|
+
const url18 = new URL(forward.url);
|
|
9979
10117
|
const actualRuntimeOrigin = this.#runtimeEntryURL.origin;
|
|
9980
|
-
const userRuntimeOrigin =
|
|
9981
|
-
|
|
9982
|
-
|
|
10118
|
+
const userRuntimeOrigin = url18.origin;
|
|
10119
|
+
url18.protocol = this.#runtimeEntryURL.protocol;
|
|
10120
|
+
url18.host = this.#runtimeEntryURL.host;
|
|
9983
10121
|
if (forward.body !== null && forward.headers.get("Content-Length") === "0") {
|
|
9984
10122
|
forward.headers.delete("Content-Length");
|
|
9985
10123
|
}
|
|
@@ -9993,7 +10131,7 @@ var Miniflare2 = class {
|
|
|
9993
10131
|
);
|
|
9994
10132
|
const forwardInit = forward;
|
|
9995
10133
|
forwardInit.dispatcher = dispatcher;
|
|
9996
|
-
const response = await fetch3(
|
|
10134
|
+
const response = await fetch3(url18, forwardInit);
|
|
9997
10135
|
const stack = response.headers.get(CoreHeaders.ERROR_STACK);
|
|
9998
10136
|
if (response.status === 500 && stack !== null) {
|
|
9999
10137
|
const caught = JsonErrorSchema.parse(await response.json());
|
|
@@ -10143,7 +10281,7 @@ var Miniflare2 = class {
|
|
|
10143
10281
|
await this.#proxyClient?.dispose();
|
|
10144
10282
|
await this.#runtime?.dispose();
|
|
10145
10283
|
await this.#stopLoopbackServer();
|
|
10146
|
-
await
|
|
10284
|
+
await import_fs22.default.promises.rm(this.#tmpPath, { force: true, recursive: true });
|
|
10147
10285
|
maybeInstanceRegistry?.delete(this);
|
|
10148
10286
|
}
|
|
10149
10287
|
}
|
|
@@ -10256,10 +10394,15 @@ var Miniflare2 = class {
|
|
|
10256
10394
|
TlsOptions_Version,
|
|
10257
10395
|
TypedEventTarget,
|
|
10258
10396
|
WORKER_BINDING_SERVICE_LOOPBACK,
|
|
10397
|
+
WORKFLOWS_PLUGIN,
|
|
10398
|
+
WORKFLOWS_PLUGIN_NAME,
|
|
10399
|
+
WORKFLOWS_STORAGE_SERVICE_NAME,
|
|
10259
10400
|
WaitGroup,
|
|
10260
10401
|
WebSocket,
|
|
10261
10402
|
WebSocketPair,
|
|
10262
10403
|
Worker_Binding_CryptoKey_Usage,
|
|
10404
|
+
WorkflowsOptionsSchema,
|
|
10405
|
+
WorkflowsSharedOptionsSchema,
|
|
10263
10406
|
__MiniflareFunctionWrapper,
|
|
10264
10407
|
_enableControlEndpoints,
|
|
10265
10408
|
_forceColour,
|