eutaxy 0.15.1 → 0.16.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.
Files changed (34) hide show
  1. package/README.md +6 -6
  2. package/dist/aws.d.mts +2 -2
  3. package/dist/aws.d.mts.map +1 -1
  4. package/dist/aws.mjs +53 -79
  5. package/dist/aws.mjs.map +1 -1
  6. package/dist/bin.mjs +1 -1
  7. package/dist/{cli-DT4lxaPK.mjs → cli-KACykdzJ.mjs} +206 -169
  8. package/dist/cli-KACykdzJ.mjs.map +1 -0
  9. package/dist/cli.mjs +1 -1
  10. package/dist/cloudflare.d.mts +9 -7
  11. package/dist/cloudflare.d.mts.map +1 -1
  12. package/dist/cloudflare.mjs +2 -2
  13. package/dist/{delivery-invariants-DzMy3iPs.d.mts → delivery-invariants-B8ZZnCZg.d.mts} +2 -2
  14. package/dist/{delivery-invariants-DzMy3iPs.d.mts.map → delivery-invariants-B8ZZnCZg.d.mts.map} +1 -1
  15. package/dist/delivery-invariants-BfRnb9yR.mjs +44 -0
  16. package/dist/delivery-invariants-BfRnb9yR.mjs.map +1 -0
  17. package/dist/{explore-B52m-wmk.d.mts → explore-DlwIUowm.d.mts} +2 -2
  18. package/dist/{explore-B52m-wmk.d.mts.map → explore-DlwIUowm.d.mts.map} +1 -1
  19. package/dist/index.d.mts +2 -2
  20. package/dist/index.mjs +2 -2
  21. package/dist/{platform-Ba1Kvdza.d.mts → platform-DPJTjpSr.d.mts} +56 -4
  22. package/dist/{platform-Ba1Kvdza.d.mts.map → platform-DPJTjpSr.d.mts.map} +1 -1
  23. package/dist/{src-wa0JZa-T.mjs → src-DWRaG5aV.mjs} +2 -2
  24. package/dist/{src-wa0JZa-T.mjs.map → src-DWRaG5aV.mjs.map} +1 -1
  25. package/dist/{src-CPuihHZh.mjs → src-dkn6Illb.mjs} +1145 -165
  26. package/dist/src-dkn6Illb.mjs.map +1 -0
  27. package/dist/{workerd-DvhVDnQW.mjs → workerd-9Tt0BV-3.mjs} +848 -673
  28. package/dist/workerd-9Tt0BV-3.mjs.map +1 -0
  29. package/package.json +1 -1
  30. package/dist/cli-DT4lxaPK.mjs.map +0 -1
  31. package/dist/delivery-invariants-Dr658H1W.mjs +0 -67
  32. package/dist/delivery-invariants-Dr658H1W.mjs.map +0 -1
  33. package/dist/src-CPuihHZh.mjs.map +0 -1
  34. package/dist/workerd-DvhVDnQW.mjs.map +0 -1
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as main } from "./cli-DT4lxaPK.mjs";
2
+ import { t as main } from "./cli-KACykdzJ.mjs";
3
3
  // packages/eutaxy/src/bin.ts
4
4
  process.stdout.on("error", (err) => {
5
5
  if (err.code === "EPIPE") process.exit(process.exitCode ?? 0);
@@ -1,8 +1,8 @@
1
- import { L as canonicalJson } from "./src-CPuihHZh.mjs";
2
- import { _ as render, a as renderText, c as checkSpecModule, d as shrinkRefutation, g as endpointNumber, h as endpointBigInt, i as renderSpecs, m as conforms, n as renderSpecReport, p as evaluate, r as renderSpecReportJson, v as describeType } from "./src-wa0JZa-T.mjs";
1
+ import { R as canonicalJson } from "./src-dkn6Illb.mjs";
2
+ import { _ as render, a as renderText, c as checkSpecModule, d as shrinkRefutation, g as endpointNumber, h as endpointBigInt, i as renderSpecs, m as conforms, n as renderSpecReport, p as evaluate, r as renderSpecReportJson, v as describeType } from "./src-DWRaG5aV.mjs";
3
3
  import { n as isSpec } from "./combinators-CLfsPfhT.mjs";
4
4
  import { t as aggregate } from "./provers-DS44OeEm.mjs";
5
- import { G as cloudflareRegressionTest, n as globKey, r as specKey } from "./workerd-DvhVDnQW.mjs";
5
+ import { G as cloudflareRegressionTest, n as globKey, r as specKey } from "./workerd-9Tt0BV-3.mjs";
6
6
  import { createRequire, registerHooks } from "node:module";
7
7
  import { Readable } from "node:stream";
8
8
  import { createHash, randomBytes } from "node:crypto";
@@ -6077,6 +6077,152 @@ function resolveAsTypeScript() {
6077
6077
  }
6078
6078
  } });
6079
6079
  }
6080
+ // packages/cli/src/wrangler.ts
6081
+ /**
6082
+ * Wrangler config reading, one copy for `check` and `draft`: JSON and JSONC
6083
+ * parsing, the bindings a config declares, and the rules that name their
6084
+ * resources (a D1 database's id, an R2 bucket's name, a KV namespace's id,
6085
+ * which Durable Object classes are SQLite-backed). Only JSON and JSONC are
6086
+ * read; a TOML config is refused.
6087
+ */
6088
+ /**
6089
+ * JSON with comments and trailing commas, as wrangler.jsonc allows: comments
6090
+ * are removed outside strings, a comma before `}` or `]` dropped, and the
6091
+ * rest is JSON.
6092
+ */
6093
+ function parseJsonc(text) {
6094
+ let out = "";
6095
+ let i = 0;
6096
+ /** The index of the next character that is neither whitespace nor inside a comment, from `from`. */
6097
+ const nextToken = (from) => {
6098
+ let k = from;
6099
+ for (;;) {
6100
+ while (k < text.length && /\s/.test(text[k])) k++;
6101
+ if (text[k] === "/" && text[k + 1] === "/") while (k < text.length && text[k] !== "\n") k++;
6102
+ else if (text[k] === "/" && text[k + 1] === "*") {
6103
+ const end = text.indexOf("*/", k + 2);
6104
+ k = end < 0 ? text.length : end + 2;
6105
+ } else return k;
6106
+ }
6107
+ };
6108
+ while (i < text.length) {
6109
+ const c = text[i];
6110
+ if (c === "\"") {
6111
+ let j = i + 1;
6112
+ while (j < text.length && text[j] !== "\"") j += text[j] === "\\" ? 2 : 1;
6113
+ out += text.slice(i, j + 1);
6114
+ i = j + 1;
6115
+ } else if (c === "/" && text[i + 1] === "/") while (i < text.length && text[i] !== "\n") i++;
6116
+ else if (c === "/" && text[i + 1] === "*") {
6117
+ const end = text.indexOf("*/", i + 2);
6118
+ i = end < 0 ? text.length : end + 2;
6119
+ } else if (c === ",") {
6120
+ const next = text[nextToken(i + 1)];
6121
+ if (next !== "}" && next !== "]") out += c;
6122
+ i++;
6123
+ } else {
6124
+ out += c;
6125
+ i++;
6126
+ }
6127
+ }
6128
+ return JSON.parse(out);
6129
+ }
6130
+ /** Read a wrangler config as an object; only JSON and JSONC are read. */
6131
+ function readWranglerConfig(path) {
6132
+ const ext = extname(path);
6133
+ if (ext !== ".json" && ext !== ".jsonc") throw new Error(`${basename(path)}: eutaxy reads a wrangler config as JSON or JSONC; a TOML config is not read`);
6134
+ const parsed = parseJsonc(readFileSync(path, "utf8"));
6135
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${basename(path)}: not a wrangler config object`);
6136
+ return parsed;
6137
+ }
6138
+ /** The `name` of a wrangler config, when the config can be read and names one. */
6139
+ function workerName(path) {
6140
+ try {
6141
+ const name = readWranglerConfig(path)["name"];
6142
+ return typeof name === "string" && name ? name : void 0;
6143
+ } catch {
6144
+ return;
6145
+ }
6146
+ }
6147
+ /** The object entries of a config list; anything else is no entry. */
6148
+ const list = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "object" && x) : [];
6149
+ const str$1 = (v, fallback = "") => typeof v === "string" ? v : fallback;
6150
+ const strings$1 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
6151
+ /** A D1 binding's database: its id, else its name, else the binding (the same database in two configs is one). */
6152
+ const d1Id = (db) => str$1(db["database_id"], str$1(db["database_name"], str$1(db["binding"])));
6153
+ /** An R2 binding's bucket: its name, else the binding. */
6154
+ const r2Bucket = (b) => str$1(b["bucket_name"], str$1(b["binding"]));
6155
+ /** A KV binding's namespace: its id, else the binding. */
6156
+ const kvId = (k) => str$1(k["id"], str$1(k["binding"]));
6157
+ /**
6158
+ * The SQLite-backed Durable Object classes of a config, with its migrations applied in order as
6159
+ * wrangler applies them: a class is SQLite-backed from the migration that created it so, through
6160
+ * renames, until one deletes it.
6161
+ */
6162
+ function sqliteClasses(config) {
6163
+ const sqlite = /* @__PURE__ */ new Set();
6164
+ for (const m of list(config["migrations"])) {
6165
+ for (const c of strings$1(m["new_sqlite_classes"])) sqlite.add(c);
6166
+ for (const r of list(m["renamed_classes"])) {
6167
+ const from = str$1(r["from"]);
6168
+ if (sqlite.delete(from)) sqlite.add(str$1(r["to"]));
6169
+ }
6170
+ for (const c of strings$1(m["deleted_classes"])) sqlite.delete(c);
6171
+ }
6172
+ return sqlite;
6173
+ }
6174
+ /** Read a config's bindings. */
6175
+ function readBindings(config) {
6176
+ const sqlite = sqliteClasses(config);
6177
+ const dos = config["durable_objects"];
6178
+ const queues = config["queues"];
6179
+ const vars = {};
6180
+ const rawVars = config["vars"];
6181
+ if (typeof rawVars === "object" && rawVars !== null) for (const [k, v] of Object.entries(rawVars)) vars[k] = v;
6182
+ return {
6183
+ name: str$1(config["name"]) || void 0,
6184
+ main: str$1(config["main"]) || void 0,
6185
+ d1: list(config["d1_databases"]).map((d) => ({
6186
+ binding: str$1(d["binding"]),
6187
+ id: d1Id(d)
6188
+ })),
6189
+ r2: list(config["r2_buckets"]).map((b) => ({
6190
+ binding: str$1(b["binding"]),
6191
+ bucket: r2Bucket(b)
6192
+ })),
6193
+ kv: list(config["kv_namespaces"]).map((k) => ({
6194
+ binding: str$1(k["binding"]),
6195
+ id: kvId(k)
6196
+ })),
6197
+ durableObjects: list(dos?.bindings).map((b) => {
6198
+ const className = str$1(b["class_name"]);
6199
+ return {
6200
+ binding: str$1(b["name"]),
6201
+ className,
6202
+ sqlite: sqlite.has(className),
6203
+ ...b["script_name"] === void 0 ? {} : { scriptName: str$1(b["script_name"]) }
6204
+ };
6205
+ }),
6206
+ workflows: list(config["workflows"]).map((w) => ({
6207
+ binding: str$1(w["binding"]),
6208
+ className: str$1(w["class_name"]),
6209
+ name: str$1(w["name"], str$1(w["binding"]))
6210
+ })),
6211
+ services: list(config["services"]).map((s) => ({
6212
+ binding: str$1(s["binding"]),
6213
+ service: str$1(s["service"]),
6214
+ ...typeof s["entrypoint"] === "string" ? { entrypoint: s["entrypoint"] } : {},
6215
+ ...typeof s["props"] === "object" && s["props"] !== null ? { props: s["props"] } : {}
6216
+ })),
6217
+ queues: list(queues?.producers).map((p) => ({
6218
+ binding: str$1(p["binding"]),
6219
+ queue: str$1(p["queue"])
6220
+ })),
6221
+ vars,
6222
+ sqliteClasses: [...sqlite],
6223
+ keys: Object.keys(config)
6224
+ };
6225
+ }
6080
6226
  // packages/cli/src/callees.ts
6081
6227
  /**
6082
6228
  * The callees a scenario names (`callee()` steps), read on the Node side for
@@ -6199,58 +6345,6 @@ function isolateBindings(callees) {
6199
6345
  }
6200
6346
  return names;
6201
6347
  }
6202
- /**
6203
- * JSON with comments and trailing commas, as wrangler.jsonc allows: comments
6204
- * are removed outside strings, a comma before `}` or `]` dropped, and the
6205
- * rest is JSON.
6206
- */
6207
- function parseJsonc(text) {
6208
- let out = "";
6209
- let i = 0;
6210
- /** The index of the next character that is neither whitespace nor inside a comment, from `from`. */
6211
- const nextToken = (from) => {
6212
- let k = from;
6213
- for (;;) {
6214
- while (k < text.length && /\s/.test(text[k])) k++;
6215
- if (text[k] === "/" && text[k + 1] === "/") while (k < text.length && text[k] !== "\n") k++;
6216
- else if (text[k] === "/" && text[k + 1] === "*") {
6217
- const end = text.indexOf("*/", k + 2);
6218
- k = end < 0 ? text.length : end + 2;
6219
- } else return k;
6220
- }
6221
- };
6222
- while (i < text.length) {
6223
- const c = text[i];
6224
- if (c === "\"") {
6225
- let j = i + 1;
6226
- while (j < text.length && text[j] !== "\"") j += text[j] === "\\" ? 2 : 1;
6227
- out += text.slice(i, j + 1);
6228
- i = j + 1;
6229
- } else if (c === "/" && text[i + 1] === "/") while (i < text.length && text[i] !== "\n") i++;
6230
- else if (c === "/" && text[i + 1] === "*") {
6231
- const end = text.indexOf("*/", i + 2);
6232
- i = end < 0 ? text.length : end + 2;
6233
- } else if (c === ",") {
6234
- const next = text[nextToken(i + 1)];
6235
- if (next !== "}" && next !== "]") out += c;
6236
- i++;
6237
- } else {
6238
- out += c;
6239
- i++;
6240
- }
6241
- }
6242
- return JSON.parse(out);
6243
- }
6244
- /** Read a wrangler config as an object; only JSON and JSONC are read here. */
6245
- function readWranglerConfig(path) {
6246
- const ext = extname(path);
6247
- if (ext !== ".json" && ext !== ".jsonc") throw new Error(`${basename(path)}: eutaxy check reads a callee's wrangler config as JSON or JSONC; a TOML config is not read`);
6248
- const parsed = parseJsonc(readFileSync(path, "utf8"));
6249
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${basename(path)}: not a wrangler config object`);
6250
- return parsed;
6251
- }
6252
- const list$1 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "object" && x) : [];
6253
- const str$1 = (v, fallback = "") => typeof v === "string" ? v : fallback;
6254
6348
  /** The keys of a wrangler config whose bindings the command carries into the isolate. */
6255
6349
  const carried = /* @__PURE__ */ new Set([
6256
6350
  "name",
@@ -6283,67 +6377,27 @@ const carried = /* @__PURE__ */ new Set([
6283
6377
  /** Read a callee's wrangler config into what the isolate needs; `scenarioDir` resolves the step's paths. */
6284
6378
  function readCalleeConfig(step, scenarioDir) {
6285
6379
  const path = resolve(scenarioDir, step.config);
6286
- const config = readWranglerConfig(path);
6287
- const name = str$1(config["name"]);
6288
- if (!name) throw new Error(`${basename(path)}: the callee's wrangler config has no name, which qualifies its bindings`);
6289
- const notAdded = [];
6290
- const sqlite = /* @__PURE__ */ new Set();
6291
- const strings = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
6292
- for (const m of list$1(config["migrations"])) {
6293
- for (const c of strings(m["new_sqlite_classes"])) sqlite.add(c);
6294
- for (const r of list$1(m["renamed_classes"])) {
6295
- const from = str$1(r["from"]);
6296
- if (sqlite.delete(from)) sqlite.add(str$1(r["to"]));
6297
- }
6298
- for (const c of strings(m["deleted_classes"])) sqlite.delete(c);
6299
- }
6300
- const durableObjects = [];
6301
- const dos = config["durable_objects"];
6302
- for (const b of list$1(dos?.bindings)) {
6303
- const className = str$1(b["class_name"]);
6304
- const scriptName = b["script_name"] === void 0 ? void 0 : str$1(b["script_name"]);
6305
- durableObjects.push({
6306
- binding: str$1(b["name"]),
6307
- className,
6308
- sqlite: sqlite.has(className),
6309
- ...scriptName === void 0 ? {} : { scriptName }
6310
- });
6311
- }
6312
- const queues = config["queues"];
6313
- for (const key of Object.keys(config)) if (!carried.has(key)) notAdded.push(key);
6314
- const vars = {};
6315
- const rawVars = config["vars"];
6316
- if (typeof rawVars === "object" && rawVars !== null) for (const [k, v] of Object.entries(rawVars)) vars[k] = v;
6380
+ const bindings = readBindings(readWranglerConfig(path));
6381
+ if (bindings.name === void 0) throw new Error(`${basename(path)}: the callee's wrangler config has no name, which qualifies its bindings`);
6317
6382
  return {
6318
6383
  binding: step.binding,
6319
- name,
6384
+ name: bindings.name,
6320
6385
  entry: resolve(scenarioDir, step.entry),
6321
- d1: list$1(config["d1_databases"]).map((d) => ({
6322
- binding: str$1(d["binding"]),
6323
- id: str$1(d["database_id"], str$1(d["database_name"], str$1(d["binding"])))
6324
- })),
6325
- r2: list$1(config["r2_buckets"]).map((b) => ({
6326
- binding: str$1(b["binding"]),
6327
- bucket: str$1(b["bucket_name"], str$1(b["binding"]))
6328
- })),
6329
- kv: list$1(config["kv_namespaces"]).map((k) => ({
6330
- binding: str$1(k["binding"]),
6331
- id: str$1(k["id"], str$1(k["binding"]))
6332
- })),
6333
- durableObjects,
6334
- workflows: list$1(config["workflows"]).map((w) => ({
6335
- binding: str$1(w["binding"]),
6336
- className: str$1(w["class_name"]),
6337
- name: str$1(w["name"], str$1(w["binding"]))
6338
- })),
6339
- services: list$1(config["services"]).map((s) => str$1(s["binding"])),
6340
- queues: list$1(queues?.producers).map((p) => ({
6341
- binding: str$1(p["binding"]),
6342
- queue: str$1(p["queue"])
6386
+ d1: bindings.d1,
6387
+ r2: bindings.r2,
6388
+ kv: bindings.kv,
6389
+ durableObjects: bindings.durableObjects,
6390
+ workflows: bindings.workflows,
6391
+ services: bindings.services.map((s) => s.binding),
6392
+ carries: bindings.services.map(({ binding, entrypoint, props }) => ({
6393
+ binding,
6394
+ ...entrypoint === void 0 ? {} : { entrypoint },
6395
+ ...props === void 0 ? {} : { props }
6343
6396
  })),
6344
- vars,
6345
- sqliteClasses: [...sqlite],
6346
- notAdded
6397
+ queues: bindings.queues,
6398
+ vars: bindings.vars,
6399
+ sqliteClasses: bindings.sqliteClasses,
6400
+ notAdded: bindings.keys.filter((key) => !carried.has(key))
6347
6401
  };
6348
6402
  }
6349
6403
  /** A Worker's name as an identifier prefix (`my-worker` → `my_worker`, `1st` → `_1st`). */
@@ -6463,40 +6517,28 @@ function miniflareOptionsSource(callees, isolate = noIsolate, callerServices = [
6463
6517
  /** The caller's resources from its wrangler config, when the config can be read (JSON or JSONC); none otherwise. */
6464
6518
  function readCallerResources(wranglerPath) {
6465
6519
  try {
6466
- const config = readWranglerConfig(wranglerPath);
6467
- const dos = config["durable_objects"];
6520
+ const bindings = readBindings(readWranglerConfig(wranglerPath));
6468
6521
  return {
6469
- name: str$1(config["name"]) || void 0,
6470
- d1: list$1(config["d1_databases"]).map((d) => ({
6471
- binding: str$1(d["binding"]),
6472
- id: str$1(d["database_id"], str$1(d["database_name"], str$1(d["binding"])))
6473
- })),
6474
- r2: list$1(config["r2_buckets"]).map((b) => ({
6475
- binding: str$1(b["binding"]),
6476
- bucket: str$1(b["bucket_name"], str$1(b["binding"]))
6477
- })),
6478
- kv: list$1(config["kv_namespaces"]).map((k) => ({
6479
- binding: str$1(k["binding"]),
6480
- id: str$1(k["id"], str$1(k["binding"]))
6481
- })),
6482
- durableObjects: list$1(dos?.bindings).map((b) => ({
6483
- binding: str$1(b["name"]),
6484
- className: str$1(b["class_name"]),
6485
- ...b["script_name"] === void 0 ? {} : { scriptName: str$1(b["script_name"]) }
6486
- })),
6487
- services: list$1(config["services"]).map((b) => ({
6488
- binding: str$1(b["binding"]),
6489
- ...typeof b["entrypoint"] === "string" ? { entrypoint: b["entrypoint"] } : {},
6490
- ...typeof b["props"] === "object" && b["props"] !== null ? { props: b["props"] } : {}
6491
- }))
6522
+ name: bindings.name,
6523
+ d1: bindings.d1,
6524
+ r2: bindings.r2,
6525
+ kv: bindings.kv,
6526
+ durableObjects: bindings.durableObjects,
6527
+ services: bindings.services
6492
6528
  };
6493
6529
  } catch {
6494
6530
  return;
6495
6531
  }
6496
6532
  }
6497
- /** What the caller's binding to a callee carries (its entrypoint and props), for the test to pass with the module. */
6498
- function bindingCarries(caller, binding) {
6499
- const s = caller?.services.find((x) => x.binding === binding);
6533
+ /**
6534
+ * What the binding to a callee carries (its entrypoint and props), for the
6535
+ * test to pass with the module: from the caller's config, or for a callee's
6536
+ * own callee (`<callee>/<binding>`) from that callee's config, where the
6537
+ * binding is declared.
6538
+ */
6539
+ function bindingCarries(caller, binding, callees = []) {
6540
+ const owner = callees.find((c) => binding.startsWith(`${c.name}/`));
6541
+ const s = caller?.services.find((x) => x.binding === binding) ?? owner?.carries.find((x) => qualified(owner.name, x.binding) === binding);
6500
6542
  return {
6501
6543
  ...s?.entrypoint === void 0 ? {} : { entrypoint: s.entrypoint },
6502
6544
  ...s?.props === void 0 ? {} : { props: s.props }
@@ -6596,6 +6638,8 @@ function checkTestSource(g) {
6596
6638
  const sqlImports = g.sqlImports ?? [];
6597
6639
  const calleeImports = callees.map((c, i) => `import * as callee_${i} from ${JSON.stringify(c.importPath)};\n`);
6598
6640
  const sqlImportLines = sqlImports.map((f, i) => `import sql_${i} from ${JSON.stringify(`${f.importPath}?raw`)};\n`);
6641
+ const workerImportLine = g.workerImport === void 0 ? "" : `import * as workerModule from ${JSON.stringify(g.workerImport)};\n`;
6642
+ const workerOption = g.workerImport === void 0 ? "" : ", worker: workerModule";
6599
6643
  const calleesOption = callees.length === 0 ? "" : `, callees: { ${callees.map((c, i) => `${JSON.stringify(c.binding)}: { name: ${JSON.stringify(c.name)}, exports: callee_${i}${c.entrypoint === void 0 ? "" : `, entrypoint: ${JSON.stringify(c.entrypoint)}`}${c.props === void 0 ? "" : `, props: ${JSON.stringify(c.props)}`} }`).join(", ")} }`;
6600
6644
  const extraSql = sqlImports.length === 0 ? "" : `, extraSql: { ${sqlImports.map((f, i) => `${JSON.stringify(f.key)}: sql_${i}`).join(", ")} }`;
6601
6645
  const aliases = g.aliases === void 0 || Object.keys(g.aliases).length === 0 ? "" : `, aliases: ${JSON.stringify(g.aliases)}`;
@@ -6605,13 +6649,13 @@ import { env } from "cloudflare:workers";
6605
6649
  import * as durableObjects from "cloudflare:test";
6606
6650
  import { test } from "vitest";
6607
6651
  import scenario from ${JSON.stringify(g.scenarioImport)};
6608
- ${calleeImports.join("")}${sqlImportLines.join("")}import { specEntries } from "./specs.ts";
6652
+ ${workerImportLine}${calleeImports.join("")}${sqlImportLines.join("")}import { specEntries } from "./specs.ts";
6609
6653
 
6610
6654
  const sqlFiles = import.meta.glob("../**/*.sql", { query: "?raw", import: "default", eager: true }) as Record<string, string>;
6611
6655
  const modules = import.meta.glob(["../**/*.ts", "!../**/*.test.ts", "!../**/*.sim.ts", "!../**/node_modules/**", "!../**/.eutaxy/**"]);
6612
6656
 
6613
6657
  test("eutaxy check", async ({ task }) => {
6614
- task.meta[${JSON.stringify(metaKey)}] = await checkInWorkerd({ scenario, env, durableObjects, sqlFiles, modules, specEntries${calleesOption}${extraSql}${aliases}, ${options} });
6658
+ task.meta[${JSON.stringify(metaKey)}] = await checkInWorkerd({ scenario, env, durableObjects, sqlFiles, modules, specEntries${workerOption}${calleesOption}${extraSql}${aliases}, ${options} });
6615
6659
  });
6616
6660
  `;
6617
6661
  }
@@ -6622,6 +6666,9 @@ import { cloudflareTest } from "@cloudflare/vitest-plugin";
6622
6666
  import { defineConfig } from "vitest/config";
6623
6667
 
6624
6668
  ${isolate?.miniflare === void 0 ? "" : `const ${neverCalled} = () => new Response("eutaxy: a service binding the scenario scripts or runs as a callee is never called", { status: 500 });\n\n`}export default defineConfig({
6669
+ // Vite's cache, kept with the generated files so it goes when they do (its default is the
6670
+ // project's node_modules/.vite, which a check would leave behind in the scenario's directory).
6671
+ cacheDir: ${JSON.stringify(join(dirname(testPath), ".vite"))},
6625
6672
  plugins: [${plugin}],
6626
6673
  test: {
6627
6674
  include: [${JSON.stringify(testPath)}],
@@ -6875,10 +6922,12 @@ async function runCheck(o) {
6875
6922
  mkdirSync(workDir, { recursive: true });
6876
6923
  try {
6877
6924
  const sqlImports = [];
6878
- if (callees.length > 0 && loaded) for (const step of loaded.setup) {
6925
+ /** Whether a path the scenario names lies outside its directory, where the test's globs do not reach. */
6926
+ const outside = (file) => relative(dir, resolve(dir, file)).startsWith("..");
6927
+ if (loaded) for (const step of loaded.setup) {
6879
6928
  if (step.kind !== "d1") continue;
6880
6929
  const file = String(step["schemaFile"]);
6881
- if (!relative(dir, resolve(dir, file)).startsWith("..")) continue;
6930
+ if (!outside(file)) continue;
6882
6931
  sqlImports.push({
6883
6932
  key: globKey(file),
6884
6933
  importPath: toPosix(relative(workDir, resolve(dir, file)))
@@ -6890,11 +6939,12 @@ async function runCheck(o) {
6890
6939
  ...o.budgetMs === void 0 ? {} : { budgetMs: o.budgetMs },
6891
6940
  ...o.exhaustive ? { exhaustive: true } : {},
6892
6941
  scenarioImport: `../${basename(scenarioPath)}`,
6942
+ ...loaded && outside(loaded.worker.entry) ? { workerImport: toPosix(relative(workDir, resolve(dir, loaded.worker.entry))) } : {},
6893
6943
  ...callees.length === 0 ? {} : { callees: callees.map((c) => ({
6894
6944
  binding: c.binding,
6895
6945
  name: c.name,
6896
6946
  importPath: toPosix(relative(workDir, c.entry)),
6897
- ...bindingCarries(callerResources, c.binding)
6947
+ ...bindingCarries(callerResources, c.binding, callees)
6898
6948
  })) },
6899
6949
  ...sqlImports.length === 0 ? {} : { sqlImports },
6900
6950
  ...Object.keys(isolate.aliases).length === 0 ? {} : { aliases: isolate.aliases }
@@ -7017,7 +7067,6 @@ function cleanUp(workDir, stamp) {
7017
7067
  * imported or run: the config is read as JSON or JSONC and the module's
7018
7068
  * source (with the modules it imports relatively) is scanned as text.
7019
7069
  */
7020
- const list = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "object" && x) : [];
7021
7070
  const text$1 = (v) => typeof v === "string" ? v : "";
7022
7071
  const record = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : {};
7023
7072
  /** A path relative to `from`, with forward slashes and a leading `./`. */
@@ -7025,11 +7074,6 @@ function ref(from, to) {
7025
7074
  const p = relative(from, to).split("\\").join("/");
7026
7075
  return p.startsWith(".") ? p : `./${p}`;
7027
7076
  }
7028
- /** Read a wrangler config as JSON or JSONC; TOML is not read. */
7029
- function readConfig(path) {
7030
- if (extname(path) !== ".json" && extname(path) !== ".jsonc") throw new Error(`${basename(path)}: eutaxy draft reads a wrangler config as JSON or JSONC; a TOML config is not read`);
7031
- return readWranglerConfig(path);
7032
- }
7033
7077
  /** Binding kinds the simulation does not proxy: a run that touches one is UNSUPPORTED. */
7034
7078
  const unmodelled = {
7035
7079
  kv_namespaces: "KV namespace",
@@ -7046,12 +7090,6 @@ const unmodelled = {
7046
7090
  version_metadata: "version metadata",
7047
7091
  pipelines: "pipeline"
7048
7092
  };
7049
- /** The SQLite-backed classes of a config's migrations (the ones created so, as wrangler applies them). */
7050
- function sqliteClasses(config) {
7051
- const out = /* @__PURE__ */ new Set();
7052
- for (const m of list(config["migrations"])) for (const c of Array.isArray(m["new_sqlite_classes"]) ? m["new_sqlite_classes"] : []) if (typeof c === "string") out.add(c);
7053
- return out;
7054
- }
7055
7093
  /**
7056
7094
  * The schema file of a D1 binding, beside its config: `schema.sql`, else `<database_name>.sql`, else the
7057
7095
  * only `.sql` file there; `found` false when none is, and the step names `schema.sql` to create.
@@ -7109,10 +7147,10 @@ function configsByName(root, depth = 3) {
7109
7147
  const path = join(dir, e.name);
7110
7148
  if (e.isDirectory()) {
7111
7149
  if (left > 0 && e.name !== "node_modules" && !e.name.startsWith(".")) walk(path, left - 1);
7112
- } else if (e.name === "wrangler.jsonc" || e.name === "wrangler.json") try {
7113
- const name = text$1(readConfig(path)["name"]);
7114
- if (name && !out.has(name)) out.set(name, path);
7115
- } catch {}
7150
+ } else if (e.name === "wrangler.jsonc" || e.name === "wrangler.json") {
7151
+ const name = workerName(path);
7152
+ if (name !== void 0 && !out.has(name)) out.set(name, path);
7153
+ }
7116
7154
  }
7117
7155
  };
7118
7156
  walk(root, depth);
@@ -7173,7 +7211,7 @@ function agentSegment(binding) {
7173
7211
  return (kebab.startsWith("-") ? kebab.slice(1) : kebab).replaceAll("_", "-").replace(/-$/, "");
7174
7212
  }
7175
7213
  function draftScenario(input) {
7176
- const config = readConfig(input.config);
7214
+ const config = readWranglerConfig(input.config);
7177
7215
  const configDir = dirname(input.config);
7178
7216
  const scenarioDir = input.scenarioDir ?? configDir;
7179
7217
  const name = text$1(config["name"]) || basename(configDir);
@@ -7192,9 +7230,8 @@ function draftScenario(input) {
7192
7230
  const found = service && service !== name ? others.get(service) : void 0;
7193
7231
  if (found !== void 0) callees.set(service, found);
7194
7232
  }
7195
- const d1Id = (db) => text$1(db["database_id"]) || text$1(db["database_name"]) || text$1(db["binding"]);
7196
7233
  const callerDatabases = new Map(list(config["d1_databases"]).map((db) => [d1Id(db), text$1(db["binding"])]));
7197
- const callerBuckets = new Map(list(config["r2_buckets"]).map((b) => [text$1(b["bucket_name"]) || text$1(b["binding"]), text$1(b["binding"])]));
7234
+ const callerBuckets = new Map(list(config["r2_buckets"]).map((b) => [r2Bucket(b), text$1(b["binding"])]));
7198
7235
  /** Classes of a callee's script the caller binds itself: one namespace, set up under the caller's name. */
7199
7236
  const sharedClasses = new Set(list(record(config["durable_objects"])["bindings"]).filter((b) => callees.has(text$1(b["script_name"]))).map((b) => `${text$1(b["script_name"])}:${text$1(b["class_name"])}`));
7200
7237
  /** The setup steps of one Worker's own resources: the caller's (prefix ""), or a callee's (`<name>/`). */
@@ -7236,7 +7273,7 @@ function draftScenario(input) {
7236
7273
  if (!prefix && callees.has(script)) setup.push({
7237
7274
  kind: "durable_object",
7238
7275
  binding,
7239
- sqlite: sqliteClasses(readConfig(callees.get(script))).has(className)
7276
+ sqlite: sqliteClasses(readWranglerConfig(callees.get(script))).has(className)
7240
7277
  });
7241
7278
  else notes.push(`Durable Object ${prefix}${binding} is ${script}'s class ${className}: name ${script} with callee() to run it`);
7242
7279
  continue;
@@ -7254,7 +7291,7 @@ function draftScenario(input) {
7254
7291
  for (const b of list(cfg["r2_buckets"])) {
7255
7292
  const binding = text$1(b["binding"]);
7256
7293
  if (!binding) continue;
7257
- const shared = prefix ? callerBuckets.get(text$1(b["bucket_name"]) || binding) : void 0;
7294
+ const shared = prefix ? callerBuckets.get(r2Bucket(b)) : void 0;
7258
7295
  if (shared !== void 0) {
7259
7296
  notes.push(`R2 ${prefix}${binding} is the caller's bucket ${shared}: set it up and read it as ${shared}`);
7260
7297
  continue;
@@ -7302,7 +7339,7 @@ function draftScenario(input) {
7302
7339
  notes.push(`service binding ${binding}: no wrangler config named ${service || "(none)"} under the scenario's directory, so its answers are scripted; script them with service(), or run that Worker with callee()`);
7303
7340
  continue;
7304
7341
  }
7305
- const callee = readConfig(calleeConfig);
7342
+ const callee = readWranglerConfig(calleeConfig);
7306
7343
  const calleeDir = dirname(calleeConfig);
7307
7344
  const calleeMain = resolve(calleeDir, text$1(callee["main"]));
7308
7345
  setup.push({
@@ -8285,7 +8322,7 @@ async function runReport(o) {
8285
8322
  }
8286
8323
  // packages/cli/src/version.ts
8287
8324
  /** The published package's version, as the MCP server reports it; the release tooling keeps it in step. */
8288
- const eutaxyVersion = "0.15.1";
8325
+ const eutaxyVersion = "0.16.1";
8289
8326
  // packages/cli/src/mcp.ts
8290
8327
  /**
8291
8328
  * `eutaxy mcp`: a Model Context Protocol server over stdio, so a coding
@@ -9043,4 +9080,4 @@ async function main(argv, io) {
9043
9080
  }
9044
9081
  export { main as t };
9045
9082
 
9046
- //# sourceMappingURL=cli-DT4lxaPK.mjs.map
9083
+ //# sourceMappingURL=cli-KACykdzJ.mjs.map