eutaxy 0.14.0 → 0.15.1
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 +10 -6
- package/dist/aws.d.mts +28 -2
- package/dist/aws.d.mts.map +1 -1
- package/dist/aws.mjs +13 -2
- package/dist/aws.mjs.map +1 -1
- package/dist/bin.mjs +1 -1
- package/dist/{cli-BppjMaqL.mjs → cli-DT4lxaPK.mjs} +863 -89
- package/dist/cli-DT4lxaPK.mjs.map +1 -0
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cloudflare.d.mts +79 -8
- package/dist/cloudflare.d.mts.map +1 -1
- package/dist/cloudflare.mjs +2 -2
- package/dist/{combinators-Bsd9HKtw.d.mts → combinators-BecOKcmi.d.mts} +7 -1
- package/dist/combinators-BecOKcmi.d.mts.map +1 -0
- package/dist/{combinators-CVjxodAJ.mjs → combinators-CLfsPfhT.mjs} +6 -1
- package/dist/combinators-CLfsPfhT.mjs.map +1 -0
- package/dist/{delivery-invariants-_T9ZMwOJ.mjs → delivery-invariants-Dr658H1W.mjs} +7 -2
- package/dist/delivery-invariants-Dr658H1W.mjs.map +1 -0
- package/dist/delivery-invariants-DzMy3iPs.d.mts +10 -0
- package/dist/delivery-invariants-DzMy3iPs.d.mts.map +1 -0
- package/dist/{explore-B7aR_5Hy.d.mts → explore-B52m-wmk.d.mts} +13 -2
- package/dist/explore-B52m-wmk.d.mts.map +1 -0
- package/dist/index.d.mts +25 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{platform-CCz48WF9.d.mts → platform-Ba1Kvdza.d.mts} +18 -1
- package/dist/platform-Ba1Kvdza.d.mts.map +1 -0
- package/dist/provers-DS44OeEm.mjs.map +1 -1
- package/dist/spec.d.mts +1 -1
- package/dist/spec.mjs +1 -1
- package/dist/{src-DPCF2XGv.mjs → src-CPuihHZh.mjs} +225 -238
- package/dist/src-CPuihHZh.mjs.map +1 -0
- package/dist/{src-ClXnIi6O.mjs → src-wa0JZa-T.mjs} +9 -3
- package/dist/src-wa0JZa-T.mjs.map +1 -0
- package/dist/{workerd-DVJ8eCLI.mjs → workerd-DvhVDnQW.mjs} +170 -42
- package/dist/workerd-DvhVDnQW.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/cli-BppjMaqL.mjs.map +0 -1
- package/dist/combinators-Bsd9HKtw.d.mts.map +0 -1
- package/dist/combinators-CVjxodAJ.mjs.map +0 -1
- package/dist/delivery-invariants-DZOBkCMR.d.mts +0 -5
- package/dist/delivery-invariants-DZOBkCMR.d.mts.map +0 -1
- package/dist/delivery-invariants-_T9ZMwOJ.mjs.map +0 -1
- package/dist/explore-B7aR_5Hy.d.mts.map +0 -1
- package/dist/platform-CCz48WF9.d.mts.map +0 -1
- package/dist/src-ClXnIi6O.mjs.map +0 -1
- package/dist/src-DPCF2XGv.mjs.map +0 -1
- package/dist/workerd-DVJ8eCLI.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as readFaults, E as validateScenario, I as getPath, L as canonicalJson, S as virtualEpoch, T as defaultBounds, _ as toResponse, a as explore, b as realTick, c as hostInvocation, d as InjectedEffectError, f as findResponse, g as replyOf, h as parseBody, i as proxiedSide, j as writeFaults, k as decisionFaults, l as runInvocation, m as isRedirect, n as DifferentialStuck, p as installScriptedFetch, r as compareSides, t as observeCore, u as CrashSignal, v as withoutNetwork, w as toJson, x as settleOn, y as patchGlobals } from "./src-
|
|
2
|
-
import { a as redelivery, i as invocationOf, n as atLeastOncePerMessage$1 } from "./delivery-invariants-
|
|
3
|
-
import { c as checkSpecModule, s as emitRegressionTest, t as renderJson, y as describeVerdict } from "./src-
|
|
1
|
+
import { A as readFaults, E as validateScenario, I as getPath, L as canonicalJson, S as virtualEpoch, T as defaultBounds, _ as toResponse, a as explore, b as realTick, c as hostInvocation, d as InjectedEffectError, f as findResponse, g as replyOf, h as parseBody, i as proxiedSide, j as writeFaults, k as decisionFaults, l as runInvocation, m as isRedirect, n as DifferentialStuck, p as installScriptedFetch, r as compareSides, t as observeCore, u as CrashSignal, v as withoutNetwork, w as toJson, x as settleOn, y as patchGlobals } from "./src-CPuihHZh.mjs";
|
|
2
|
+
import { a as redelivery, i as invocationOf, n as atLeastOncePerMessage$1 } from "./delivery-invariants-Dr658H1W.mjs";
|
|
3
|
+
import { c as checkSpecModule, s as emitRegressionTest, t as renderJson, y as describeVerdict } from "./src-wa0JZa-T.mjs";
|
|
4
4
|
// packages/cli/src/regression.ts
|
|
5
5
|
/**
|
|
6
6
|
* Identifiers for binding names: a qualified name (`orders/DB`) becomes
|
|
@@ -25,9 +25,26 @@ const key = (binding) => /^[A-Za-z_$][\w$]*$/.test(binding) ? binding : JSON.str
|
|
|
25
25
|
function cloudflareRegressionTest(verdict, options) {
|
|
26
26
|
const bindings = Object.keys(options.schemaPaths).sort();
|
|
27
27
|
const callees = Object.keys(options.callees ?? {}).sort();
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Each binding's files, in setup order, each with an identifier of its own: the binding's name for the
|
|
30
|
+
* first, a count after it for the later ones, made unique across all files as `identifiers` does.
|
|
31
|
+
*/
|
|
32
|
+
const taken = /* @__PURE__ */ new Set();
|
|
33
|
+
const files = bindings.flatMap((b) => {
|
|
34
|
+
const paths = options.schemaPaths[b] ?? [];
|
|
35
|
+
return (typeof paths === "string" ? [paths] : paths).map((path, i) => {
|
|
36
|
+
const base = (i === 0 ? b : `${b}_${i + 1}`).replace(/[^A-Za-z0-9_$]/g, "_");
|
|
37
|
+
let id = base;
|
|
38
|
+
for (let n = 2; taken.has(id); n++) id = `${base}_${n}`;
|
|
39
|
+
taken.add(id);
|
|
40
|
+
return {
|
|
41
|
+
binding: b,
|
|
42
|
+
path,
|
|
43
|
+
id
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
});
|
|
29
47
|
const calleeIds = identifiers(callees);
|
|
30
|
-
const ident = (binding) => schemaIds.get(binding) ?? calleeIds.get(binding) ?? binding;
|
|
31
48
|
const withExports = options.exports === true || options.workflows === true;
|
|
32
49
|
const imports = [
|
|
33
50
|
...callees.length === 0 || (options.calleeBindings ?? []).length === 0 ? [] : [`// Needs the callees' bindings in this test's isolate under their qualified names: ${(options.calleeBindings ?? []).join(", ")}.`, "// Declare them in the wrangler config, or run this test under the config eutaxy check --keep leaves in .eutaxy/."],
|
|
@@ -35,12 +52,16 @@ function cloudflareRegressionTest(verdict, options) {
|
|
|
35
52
|
"import { env } from \"cloudflare:workers\";",
|
|
36
53
|
...options.durableObjects ? ["import * as cloudflareTest from \"cloudflare:test\";"] : [],
|
|
37
54
|
`import scenario from ${JSON.stringify(options.scenarioPath)};`,
|
|
38
|
-
...
|
|
55
|
+
...files.map((f) => `import schema_${f.id} from ${JSON.stringify(`${f.path}?raw`)};`),
|
|
39
56
|
...callees.map((b) => `import * as callee_${calleeIds.get(b)} from ${JSON.stringify(options.callees?.[b]?.path)};`),
|
|
40
57
|
withExports ? `import * as worker from ${JSON.stringify(options.workerPath)};` : `import handler from ${JSON.stringify(options.workerPath)};`,
|
|
41
58
|
...(options.specModules ?? []).map((m, i) => `import * as core_${i} from ${JSON.stringify(m.path)};`)
|
|
42
59
|
];
|
|
43
|
-
const
|
|
60
|
+
const schemaOf = (b) => {
|
|
61
|
+
const own = files.filter((f) => f.binding === b).map((f) => `schema_${f.id}`);
|
|
62
|
+
return own.length === 1 ? own[0] : `[${own.join(", ")}].join("\\n;\\n")`;
|
|
63
|
+
};
|
|
64
|
+
const schemas = `{ ${bindings.map((b) => `${key(b)}: ${schemaOf(b)}`).join(", ")} }`;
|
|
44
65
|
const calleeOption = callees.length === 0 ? "" : `, callees: { ${callees.map((b) => `${key(b)}: { name: ${JSON.stringify(options.callees?.[b]?.name)}, exports: callee_${calleeIds.get(b)}${options.callees?.[b]?.entrypoint === void 0 ? "" : `, entrypoint: ${JSON.stringify(options.callees?.[b]?.entrypoint)}`}${options.callees?.[b]?.props === void 0 ? "" : `, props: ${JSON.stringify(options.callees?.[b]?.props)}`} }`).join(", ")} }`;
|
|
45
66
|
const retries = options.maxRetries === void 0 ? "" : `, maxRetries: ${options.maxRetries}`;
|
|
46
67
|
const aliases = options.aliases === void 0 || Object.keys(options.aliases).length === 0 ? "" : `, aliases: ${JSON.stringify(options.aliases)}`;
|
|
@@ -92,7 +113,7 @@ async function drainBackground(hooks, inv, invocation, target, background) {
|
|
|
92
113
|
allowed: CUT_OFF
|
|
93
114
|
}, () => null, () => null);
|
|
94
115
|
await Promise.race([hooks.settle(Promise.all(background), invocation), inv.crashed]);
|
|
95
|
-
return
|
|
116
|
+
return inv.isCrashed();
|
|
96
117
|
} catch (err) {
|
|
97
118
|
if (!(err instanceof CrashSignal)) throw err;
|
|
98
119
|
return true;
|
|
@@ -619,8 +640,11 @@ function proxyNamespace(real, binding, ctx, state, helpers, isReset) {
|
|
|
619
640
|
case "idFromName": return idFromName;
|
|
620
641
|
case "idFromString": return (hex) => target.idFromString(hex);
|
|
621
642
|
case "newUniqueId": return (options) => {
|
|
622
|
-
|
|
623
|
-
|
|
643
|
+
if (options?.jurisdiction !== void 0) {
|
|
644
|
+
ctx.hooks.unsupported(`${binding}.newUniqueId({ jurisdiction }) ids are not proxied or reset; use newUniqueId() without one`);
|
|
645
|
+
return target.newUniqueId(options);
|
|
646
|
+
}
|
|
647
|
+
return idFromName(`eutaxy:unique:${crypto.randomUUID()}`);
|
|
624
648
|
};
|
|
625
649
|
case "get": return (id, options) => stubFor(target.get(id, options), id.toString(), nameOf(id));
|
|
626
650
|
case "getByName": return (name) => {
|
|
@@ -824,6 +848,25 @@ function constructEntrypoint(cls, base, ctx, env) {
|
|
|
824
848
|
Object.setPrototypeOf(direct, original);
|
|
825
849
|
}
|
|
826
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* The handler object a `WorkerEntrypoint` class stands for when it is the Worker's default export: each
|
|
853
|
+
* of `fetch`, `queue` and `scheduled` the class defines constructs it anew with the invocation's env and
|
|
854
|
+
* ctx, as workerd does per event, and calls the method with the event alone (its env and ctx are on the
|
|
855
|
+
* instance) (developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/).
|
|
856
|
+
*/
|
|
857
|
+
function entrypointHandler(cls) {
|
|
858
|
+
const proto = typeof cls === "function" ? cls.prototype : void 0;
|
|
859
|
+
const out = {};
|
|
860
|
+
for (const name of [
|
|
861
|
+
"fetch",
|
|
862
|
+
"queue",
|
|
863
|
+
"scheduled"
|
|
864
|
+
]) if (typeof proto?.[name] === "function") out[name] = (event, env, ctx) => {
|
|
865
|
+
const instance = constructEntrypoint(cls, "WorkerEntrypoint", ctx, env);
|
|
866
|
+
return instance[name].call(instance, event);
|
|
867
|
+
};
|
|
868
|
+
return out;
|
|
869
|
+
}
|
|
827
870
|
// packages/cloudflare/src/caller.ts
|
|
828
871
|
/**
|
|
829
872
|
* The caller of an inbound request or RPC call. Cloudflare retries neither,
|
|
@@ -1038,6 +1081,10 @@ function cronTicks(expression, from, count) {
|
|
|
1038
1081
|
* Cloudflare shapes (queues, D1 bindings) and the effect conventions the
|
|
1039
1082
|
* proxies follow.
|
|
1040
1083
|
*/
|
|
1084
|
+
/**
|
|
1085
|
+
* Drive the Worker's `fetch()` handler with these requests, each resent as `options` say. A request's
|
|
1086
|
+
* method defaults to POST with a body and GET without; its id to `req-<n>`, by position.
|
|
1087
|
+
*/
|
|
1041
1088
|
function http(requests, options = {}) {
|
|
1042
1089
|
return {
|
|
1043
1090
|
kind: "http",
|
|
@@ -1054,6 +1101,10 @@ function http(requests, options = {}) {
|
|
|
1054
1101
|
...options.deadlineMs === void 0 ? {} : { deadlineMs: options.deadlineMs }
|
|
1055
1102
|
};
|
|
1056
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Drive the Worker over these WebSocket connections: each opened through its `fetch()` and handed to a
|
|
1106
|
+
* Durable Object, its messages delivered in order to the object's `webSocketMessage` handler.
|
|
1107
|
+
*/
|
|
1057
1108
|
function websocket(connections) {
|
|
1058
1109
|
return {
|
|
1059
1110
|
kind: "websocket",
|
|
@@ -1071,6 +1122,7 @@ function websocket(connections) {
|
|
|
1071
1122
|
})
|
|
1072
1123
|
};
|
|
1073
1124
|
}
|
|
1125
|
+
/** Drive a `WorkerEntrypoint` of the Worker with these method calls; a call's id defaults to `call-<n>`. */
|
|
1074
1126
|
function rpc(calls, options = {}) {
|
|
1075
1127
|
return {
|
|
1076
1128
|
kind: "rpc",
|
|
@@ -1089,6 +1141,10 @@ function rpc(calls, options = {}) {
|
|
|
1089
1141
|
function rpcTarget(drive, method) {
|
|
1090
1142
|
return `Rpc:${drive.entrypoint === void 0 ? method : `${drive.entrypoint}.${method}`}`;
|
|
1091
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Drive the Worker's `scheduled()` handler with the ticks of a Cron Trigger expression, in Cloudflare's
|
|
1146
|
+
* dialect: one tick by default, re-run 0 times by default.
|
|
1147
|
+
*/
|
|
1092
1148
|
function cron(expression, options = {}) {
|
|
1093
1149
|
const count = options.ticks ?? 1;
|
|
1094
1150
|
return {
|
|
@@ -1188,6 +1244,11 @@ function restrictDrive(drive, keepIds) {
|
|
|
1188
1244
|
};
|
|
1189
1245
|
}
|
|
1190
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
* A Durable Object namespace the scenario uses: cleared before each run, the named objects seeded with
|
|
1249
|
+
* key-value entries (and with `sql`, a SQLite-backed object's tables and rows), and its storage snapshotted
|
|
1250
|
+
* after the run. `alarmsPerObject` caps an object's alarm firings per run (default 3).
|
|
1251
|
+
*/
|
|
1191
1252
|
function durableObject(binding, objects = {}, options = {}) {
|
|
1192
1253
|
return {
|
|
1193
1254
|
kind: "durable_object",
|
|
@@ -1197,6 +1258,7 @@ function durableObject(binding, objects = {}, options = {}) {
|
|
|
1197
1258
|
...options.sql === void 0 ? {} : { sql: options.sql }
|
|
1198
1259
|
};
|
|
1199
1260
|
}
|
|
1261
|
+
/** An R2 bucket the scenario uses: emptied before each run, then seeded with these objects by key. */
|
|
1200
1262
|
function r2Bucket(binding, objects = {}) {
|
|
1201
1263
|
return {
|
|
1202
1264
|
kind: "r2",
|
|
@@ -1248,6 +1310,10 @@ function references(name, query, path, inQuery, column) {
|
|
|
1248
1310
|
column
|
|
1249
1311
|
};
|
|
1250
1312
|
}
|
|
1313
|
+
/**
|
|
1314
|
+
* A Workflow binding and the class its instances run, an export of the Worker module; `name` is the
|
|
1315
|
+
* Workflow's name in the wrangler config, which instances read as `event.workflowName`.
|
|
1316
|
+
*/
|
|
1251
1317
|
function workflow(binding, className, options = {}) {
|
|
1252
1318
|
return {
|
|
1253
1319
|
kind: "workflow",
|
|
@@ -1256,6 +1322,10 @@ function workflow(binding, className, options = {}) {
|
|
|
1256
1322
|
...options.name === void 0 ? {} : { name: options.name }
|
|
1257
1323
|
};
|
|
1258
1324
|
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Script the Worker behind a service binding: its RPC methods answer from `methods` and its `fetch()` from
|
|
1327
|
+
* `fetch`, and the real binding is never called. See `ServiceSetup`.
|
|
1328
|
+
*/
|
|
1259
1329
|
function service(binding, options = {}) {
|
|
1260
1330
|
return {
|
|
1261
1331
|
kind: "service",
|
|
@@ -1264,6 +1334,10 @@ function service(binding, options = {}) {
|
|
|
1264
1334
|
...options.fetch === void 0 ? {} : { fetch: [...options.fetch] }
|
|
1265
1335
|
};
|
|
1266
1336
|
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Run the Worker behind a service binding for real, named by its module and its wrangler config, relative
|
|
1339
|
+
* to the scenario; `entrypoint` names the export the binding reaches. See `CalleeSetup`.
|
|
1340
|
+
*/
|
|
1267
1341
|
function callee(binding, worker) {
|
|
1268
1342
|
return {
|
|
1269
1343
|
kind: "callee",
|
|
@@ -1351,6 +1425,7 @@ function durableObjectTable(binding, object, table, where) {
|
|
|
1351
1425
|
table: name
|
|
1352
1426
|
};
|
|
1353
1427
|
}
|
|
1428
|
+
/** Drive the Worker's `queue()` handler with these messages from the named queue; an id defaults to `msg-<n>`. */
|
|
1354
1429
|
function queue(name, messages) {
|
|
1355
1430
|
return {
|
|
1356
1431
|
kind: "queue",
|
|
@@ -1361,6 +1436,10 @@ function queue(name, messages) {
|
|
|
1361
1436
|
}))
|
|
1362
1437
|
};
|
|
1363
1438
|
}
|
|
1439
|
+
/**
|
|
1440
|
+
* A D1 binding the scenario uses: its tables dropped before each run and the schema file applied, relative
|
|
1441
|
+
* to the scenario. Several steps on one binding apply their files in order, a migration per file.
|
|
1442
|
+
*/
|
|
1364
1443
|
function d1Schema(binding, schemaFile) {
|
|
1365
1444
|
return {
|
|
1366
1445
|
kind: "d1",
|
|
@@ -2362,6 +2441,7 @@ function splitSql(sql) {
|
|
|
2362
2441
|
if (c === "/" && next === "*") {
|
|
2363
2442
|
const end = sql.indexOf("*/", i + 2);
|
|
2364
2443
|
i = end === -1 ? sql.length : end + 2;
|
|
2444
|
+
cur += " ";
|
|
2365
2445
|
continue;
|
|
2366
2446
|
}
|
|
2367
2447
|
if (c === "'" || c === "\"" || c === "`" || c === "[") {
|
|
@@ -2412,7 +2492,28 @@ function splitSql(sql) {
|
|
|
2412
2492
|
/** Drop every user table and re-apply the schema, using the real binding (not an effect). */
|
|
2413
2493
|
async function resetD1(real, schema) {
|
|
2414
2494
|
const tables = await real.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '\\_cf\\_%' ESCAPE '\\'").all();
|
|
2415
|
-
|
|
2495
|
+
const quote = (n) => `"${n.replace(/"/g, "\"\"")}"`;
|
|
2496
|
+
const triggers = await real.prepare("SELECT name FROM sqlite_master WHERE type = 'trigger'").all();
|
|
2497
|
+
for (const { name } of triggers.results) await real.prepare(`DROP TRIGGER IF EXISTS ${quote(name)}`).run();
|
|
2498
|
+
const parents = /* @__PURE__ */ new Map();
|
|
2499
|
+
for (const { name } of tables.results) {
|
|
2500
|
+
const keys = await real.prepare(`PRAGMA foreign_key_list(${quote(name)})`).all();
|
|
2501
|
+
parents.set(name, new Set(keys.results.map((k) => k.table).filter((t) => t !== name)));
|
|
2502
|
+
}
|
|
2503
|
+
const left = new Set(parents.keys());
|
|
2504
|
+
for (;;) {
|
|
2505
|
+
const leaves = [...left].filter((t) => ![...left].some((o) => parents.get(o)?.has(t)));
|
|
2506
|
+
if (leaves.length === 0) break;
|
|
2507
|
+
for (const t of leaves) {
|
|
2508
|
+
await real.prepare(`DROP TABLE IF EXISTS ${quote(t)}`).run();
|
|
2509
|
+
left.delete(t);
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
if (left.size > 0) {
|
|
2513
|
+
const cycle = [...left];
|
|
2514
|
+
await real.batch([real.prepare("PRAGMA defer_foreign_keys = on"), ...cycle.map((t) => real.prepare(`DELETE FROM ${quote(t)}`))]);
|
|
2515
|
+
await real.batch([real.prepare("PRAGMA defer_foreign_keys = on"), ...cycle.map((t) => real.prepare(`DROP TABLE IF EXISTS ${quote(t)}`))]);
|
|
2516
|
+
}
|
|
2416
2517
|
for (const statement of splitSql(schema)) await real.prepare(statement).run();
|
|
2417
2518
|
}
|
|
2418
2519
|
/** Every user table's rows, sorted canonically, read through the real binding (not an effect). */
|
|
@@ -2892,13 +2993,12 @@ function validEventType(type) {
|
|
|
2892
2993
|
if (typeof type === "string" && type.length <= 100 && /^[a-zA-Z0-9_][a-zA-Z0-9-_]*$/.test(type)) return type;
|
|
2893
2994
|
throw new Error(`(workflow.invalid_event_type) event type must be up to 100 letters, digits, - or _, got ${JSON.stringify(type)}`);
|
|
2894
2995
|
}
|
|
2895
|
-
/**
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
};
|
|
2996
|
+
/**
|
|
2997
|
+
* A promise that never settles: what a step call gives once its instance hibernated. The engine stops a
|
|
2998
|
+
* waiting instance's code where it is, so nothing after the wait runs, caught or not, until a wake re-runs
|
|
2999
|
+
* `run()` from the start.
|
|
3000
|
+
*/
|
|
3001
|
+
const hibernated = () => new Promise(() => {});
|
|
2902
3002
|
/**
|
|
2903
3003
|
* Whether a run event wakes the instance: not a wake at all, the restart of a
|
|
2904
3004
|
* run a wake began (its first delivery resumed the instance), or the wake of
|
|
@@ -3039,7 +3139,7 @@ async function deliverWorkflow(event, hooks, d) {
|
|
|
3039
3139
|
b,
|
|
3040
3140
|
c
|
|
3041
3141
|
];
|
|
3042
|
-
if (suspending !== void 0)
|
|
3142
|
+
if (suspending !== void 0) return alongsideWait("step.do");
|
|
3043
3143
|
if (options?.rollback !== void 0) {
|
|
3044
3144
|
hooks.unsupported(`Workflow ${d.binding}: rollback handlers are not modelled`);
|
|
3045
3145
|
throw new Error("eutaxy: rollback handlers are not modelled");
|
|
@@ -3204,7 +3304,7 @@ async function deliverWorkflow(event, hooks, d) {
|
|
|
3204
3304
|
await sleepStep(k, name, Math.max(0, at - Date.now()), at);
|
|
3205
3305
|
},
|
|
3206
3306
|
waitForEvent: async (name, options = {}) => {
|
|
3207
|
-
if (suspending !== void 0)
|
|
3307
|
+
if (suspending !== void 0) return alongsideWait("step.waitForEvent");
|
|
3208
3308
|
const type = validEventType(options.type);
|
|
3209
3309
|
const timeoutMs = durationMs(options.timeout ?? "24 hours");
|
|
3210
3310
|
if (!(timeoutMs >= 1e3 && timeoutMs <= 31536e6)) {
|
|
@@ -3278,18 +3378,24 @@ async function deliverWorkflow(event, hooks, d) {
|
|
|
3278
3378
|
gen,
|
|
3279
3379
|
deadline
|
|
3280
3380
|
};
|
|
3281
|
-
|
|
3381
|
+
hibernate();
|
|
3382
|
+
return hibernated();
|
|
3282
3383
|
}
|
|
3283
3384
|
};
|
|
3284
|
-
/** Set once a wait
|
|
3385
|
+
/** Set once a wait hibernated this run; the run then ends with the wait, wherever its code was. */
|
|
3285
3386
|
let suspending;
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3387
|
+
/**
|
|
3388
|
+
* A step call once a wait hibernated the run. Code after the wait never runs (its promise never
|
|
3389
|
+
* settles), so the call comes from code running in parallel with the wait (`Promise.all` of a wait and
|
|
3390
|
+
* a step), which the engine would run while the wait is pending: not modelled, so reported, and the
|
|
3391
|
+
* call never settles, as the hibernated run's other calls.
|
|
3392
|
+
*/
|
|
3393
|
+
const alongsideWait = (what) => {
|
|
3394
|
+
hooks.unsupported(`Workflow ${d.binding}: ${what} started alongside step.waitForEvent; steps running in parallel with a wait are not modelled`);
|
|
3395
|
+
return hibernated();
|
|
3290
3396
|
};
|
|
3291
3397
|
async function sleepStep(k, name, ms, until) {
|
|
3292
|
-
if (suspending !== void 0)
|
|
3398
|
+
if (suspending !== void 0) return alongsideWait("step.sleep");
|
|
3293
3399
|
if (instance.persisted.has(k)) return;
|
|
3294
3400
|
const pending = instance.deadlines.get(k);
|
|
3295
3401
|
if (pending !== void 0) {
|
|
@@ -3319,6 +3425,10 @@ async function deliverWorkflow(event, hooks, d) {
|
|
|
3319
3425
|
value: null
|
|
3320
3426
|
});
|
|
3321
3427
|
}
|
|
3428
|
+
let hibernate = () => {};
|
|
3429
|
+
const hibernation = new Promise((resolve) => {
|
|
3430
|
+
hibernate = () => resolve(void 0);
|
|
3431
|
+
});
|
|
3322
3432
|
const ran = await runInvocation(hooks, inv, () => {
|
|
3323
3433
|
const flow = constructWorkflow(d.cls, executionContext(background), d.env);
|
|
3324
3434
|
const workflowEvent = {
|
|
@@ -3333,7 +3443,7 @@ async function deliverWorkflow(event, hooks, d) {
|
|
|
3333
3443
|
hooks.unsupported(`Workflow ${d.binding}: event.workflowName needs the Workflow's name, workflow(binding, className, { name })`);
|
|
3334
3444
|
}
|
|
3335
3445
|
});
|
|
3336
|
-
return flow.run(workflowEvent, step);
|
|
3446
|
+
return Promise.race([flow.run(workflowEvent, step), hibernation]);
|
|
3337
3447
|
});
|
|
3338
3448
|
const serialised = (value) => {
|
|
3339
3449
|
try {
|
|
@@ -3350,13 +3460,10 @@ async function deliverWorkflow(event, hooks, d) {
|
|
|
3350
3460
|
}
|
|
3351
3461
|
};
|
|
3352
3462
|
let result = ran.status === "completed" ? serialised(ran.value) : ran;
|
|
3353
|
-
if (suspending !== void 0) {
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
value: void 0
|
|
3358
|
-
};
|
|
3359
|
-
}
|
|
3463
|
+
if (suspending !== void 0 && ran.status !== "crashed") result = {
|
|
3464
|
+
status: "completed",
|
|
3465
|
+
value: void 0
|
|
3466
|
+
};
|
|
3360
3467
|
let status = result.status;
|
|
3361
3468
|
if (suspending !== void 0 && result.status === "completed") {
|
|
3362
3469
|
instance.status = "waiting";
|
|
@@ -3685,7 +3792,7 @@ function calleeBinding(deps) {
|
|
|
3685
3792
|
if (!p) {
|
|
3686
3793
|
const module = deps.callees?.[name];
|
|
3687
3794
|
if (!module) {
|
|
3688
|
-
ctx.hooks.unsupported(`callee ${name}: the platform was not given its module; pass createCloudflarePlatform({ ..., callees: { ${name}: { name, exports } } })
|
|
3795
|
+
ctx.hooks.unsupported(`callee ${name}: the platform was not given its module; pass createCloudflarePlatform({ ..., callees: { ${name}: { name, exports } } }), as eutaxy check does from the callee() step`);
|
|
3689
3796
|
return proxyService(name, ctx, {
|
|
3690
3797
|
kind: "service",
|
|
3691
3798
|
binding: name,
|
|
@@ -3760,9 +3867,16 @@ function serviceBinding() {
|
|
|
3760
3867
|
*/
|
|
3761
3868
|
function ownedSetups(setup, bindings) {
|
|
3762
3869
|
const out = [];
|
|
3870
|
+
const databases = /* @__PURE__ */ new Set();
|
|
3763
3871
|
for (const step of setup) {
|
|
3764
3872
|
const binding = bindings.find((b) => b.kind === step.kind);
|
|
3765
|
-
if (binding)
|
|
3873
|
+
if (!binding) continue;
|
|
3874
|
+
if (step.kind === "d1") {
|
|
3875
|
+
const name = String(step["binding"]);
|
|
3876
|
+
if (databases.has(name)) continue;
|
|
3877
|
+
databases.add(name);
|
|
3878
|
+
}
|
|
3879
|
+
out.push([binding, step]);
|
|
3766
3880
|
}
|
|
3767
3881
|
return out;
|
|
3768
3882
|
}
|
|
@@ -3816,7 +3930,11 @@ async function deliverRequest(event, hooks, spec, drive, invocation, worker) {
|
|
|
3816
3930
|
requestId: event.id,
|
|
3817
3931
|
attempts: event.attempt
|
|
3818
3932
|
});
|
|
3819
|
-
const handled = await runInvocation(hooks, inv, () =>
|
|
3933
|
+
const handled = await runInvocation(hooks, inv, async () => {
|
|
3934
|
+
const value = await handler.call(worker.handler, requestFor(req), worker.env, executionContext(background));
|
|
3935
|
+
if (!(value instanceof Response)) throw new TypeError("the fetch handler returned something that is not a Response");
|
|
3936
|
+
return value;
|
|
3937
|
+
});
|
|
3820
3938
|
const response = handled.status === "completed" ? handled.value : void 0;
|
|
3821
3939
|
let status = handled.status;
|
|
3822
3940
|
let summary = null;
|
|
@@ -4553,6 +4671,11 @@ const assumptions = [
|
|
|
4553
4671
|
"cron triggers: each tick of the drive's expression is one invocation of scheduled(), with scheduledTime the tick's virtual time (UTC, the expression's matches from the virtual epoch on, in Cloudflare's dialect where weekdays run 1 = Sunday to 7 = Saturday; L, W and # are not modelled) and cron the expression (developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/, /workers/configuration/cron-triggers/); Cloudflare documents noRetry() but no retry count, so the drive declares how many times a tick whose handler failed is re-run, and none after noRetry()",
|
|
4554
4672
|
"inbound RPC: one invocation per call attempt, the entrypoint constructed anew for each with a fresh ExecutionContext (developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/); the return value is the response effect, and an exception reaches the caller as a new error with its name and message (developers.cloudflare.com/workers/runtime-apis/rpc/error-handling/); Cloudflare does not retry a call, so the drive's caller resends a call that threw or got no answer as the http drive's caller does; a result that is not plain data (a stub, a function, a stream) makes the run UNSUPPORTED"
|
|
4555
4673
|
];
|
|
4674
|
+
/**
|
|
4675
|
+
* The Cloudflare platform for `check`, run inside workerd under the Cloudflare Vitest plugin: the scenario's
|
|
4676
|
+
* drive delivered to the Worker's handlers, its bindings proxied so every call is an effect that faults can
|
|
4677
|
+
* hit, and the setup's resources reset before each run and snapshotted after it.
|
|
4678
|
+
*/
|
|
4556
4679
|
function createCloudflarePlatform(options) {
|
|
4557
4680
|
const env = options.env;
|
|
4558
4681
|
const aliases = options.aliases ?? {};
|
|
@@ -4629,7 +4752,7 @@ function createCloudflarePlatform(options) {
|
|
|
4629
4752
|
}
|
|
4630
4753
|
});
|
|
4631
4754
|
const worker = {
|
|
4632
|
-
handler: typeof options.handler === "function" ?
|
|
4755
|
+
handler: typeof options.handler === "function" ? entrypointHandler(options.handler) : options.handler,
|
|
4633
4756
|
env: proxiedEnv
|
|
4634
4757
|
};
|
|
4635
4758
|
return {
|
|
@@ -5064,7 +5187,10 @@ function globKey(path) {
|
|
|
5064
5187
|
* meta, which the CLI reads back. It imports nothing that needs Node, so
|
|
5065
5188
|
* the Cloudflare Vitest plugin can load it.
|
|
5066
5189
|
*/
|
|
5067
|
-
/**
|
|
5190
|
+
/**
|
|
5191
|
+
* Each D1 binding's schema, read from the `.sql` files next to the scenario. Several `d1Schema` steps
|
|
5192
|
+
* on one binding (a migration per file) are joined in setup order, each file its own statements.
|
|
5193
|
+
*/
|
|
5068
5194
|
function schemasFor(scenario, sqlFiles) {
|
|
5069
5195
|
const schemas = {};
|
|
5070
5196
|
for (const step of scenario.setup) {
|
|
@@ -5072,7 +5198,9 @@ function schemasFor(scenario, sqlFiles) {
|
|
|
5072
5198
|
const file = String(step["schemaFile"]);
|
|
5073
5199
|
const sql = sqlFiles[globKey(file)];
|
|
5074
5200
|
if (sql === void 0) throw new Error(`schema file ${file} not found next to the scenario`);
|
|
5075
|
-
|
|
5201
|
+
const binding = String(step["binding"]);
|
|
5202
|
+
const earlier = schemas[binding];
|
|
5203
|
+
schemas[binding] = earlier === void 0 ? sql : `${earlier}\n;\n${sql}`;
|
|
5076
5204
|
}
|
|
5077
5205
|
return schemas;
|
|
5078
5206
|
}
|
|
@@ -5197,4 +5325,4 @@ async function checkInWorkerd(input) {
|
|
|
5197
5325
|
}
|
|
5198
5326
|
export { r2Bucket as A, webSocketReceived as B, external as C, implies as D, httpResponse as E, rpc as F, cloudflareRegressionTest as G, workflow as H, rpcResponse as I, service as L, r2Rows as M, references as N, queue as O, refines as P, serviceCall as R, everyRow as S, http as T, workflowRows as U, websocket as V, workflowStep as W, d1Write as _, createCloudflarePlatform as a, durableObjectRows as b, expectHolds as c, callee as d, cron as f, d1Schema as g, d1Rows as h, runDifferential as i, r2Op as j, queueAck as k, calleeEnv as l, d1Read as m, globKey as n, snapshotD1 as o, d1Param as p, specKey as r, check as s, checkInWorkerd as t, atLeastOncePerMessage as u, defineScenario as v, fetchCall as w, durableObjectTable as x, durableObject as y, unique as z };
|
|
5199
5327
|
|
|
5200
|
-
//# sourceMappingURL=workerd-
|
|
5328
|
+
//# sourceMappingURL=workerd-DvhVDnQW.mjs.map
|