@cardonjs/testing 0.0.0-stage → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +537 -2
- package/THIRD_PARTY_NOTICES.md +72 -0
- package/dist/access-token-contract.d.ts +26 -0
- package/dist/access-token-contract.d.ts.map +1 -0
- package/dist/access-token-contract.js +252 -0
- package/dist/access-token-contract.js.map +1 -0
- package/dist/assertion.d.ts +7 -0
- package/dist/assertion.d.ts.map +1 -0
- package/dist/assertion.js +11 -0
- package/dist/assertion.js.map +1 -0
- package/dist/audit-contract.d.ts +52 -0
- package/dist/audit-contract.d.ts.map +1 -0
- package/dist/audit-contract.js +522 -0
- package/dist/audit-contract.js.map +1 -0
- package/dist/contract.d.ts +14 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +8 -0
- package/dist/contract.js.map +1 -0
- package/dist/envelopes.d.ts +33 -0
- package/dist/envelopes.d.ts.map +1 -0
- package/dist/envelopes.js +121 -0
- package/dist/envelopes.js.map +1 -0
- package/dist/idempotency-contract.d.ts +19 -0
- package/dist/idempotency-contract.d.ts.map +1 -0
- package/dist/idempotency-contract.js +234 -0
- package/dist/idempotency-contract.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/logs.d.ts +18 -0
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +20 -0
- package/dist/logs.js.map +1 -0
- package/dist/miniflare/bindings.d.ts +43 -0
- package/dist/miniflare/bindings.d.ts.map +1 -0
- package/dist/miniflare/bindings.js +90 -0
- package/dist/miniflare/bindings.js.map +1 -0
- package/dist/miniflare/broken.d.ts +12 -0
- package/dist/miniflare/broken.d.ts.map +1 -0
- package/dist/miniflare/broken.js +27 -0
- package/dist/miniflare/broken.js.map +1 -0
- package/dist/miniflare/executor-channel.d.ts +37 -0
- package/dist/miniflare/executor-channel.d.ts.map +1 -0
- package/dist/miniflare/executor-channel.js +144 -0
- package/dist/miniflare/executor-channel.js.map +1 -0
- package/dist/miniflare/executor.d.ts +42 -0
- package/dist/miniflare/executor.d.ts.map +1 -0
- package/dist/miniflare/executor.js +121 -0
- package/dist/miniflare/executor.js.map +1 -0
- package/dist/miniflare/index.d.ts +10 -0
- package/dist/miniflare/index.d.ts.map +1 -0
- package/dist/miniflare/index.js +10 -0
- package/dist/miniflare/index.js.map +1 -0
- package/dist/miniflare/migrations.d.ts +23 -0
- package/dist/miniflare/migrations.d.ts.map +1 -0
- package/dist/miniflare/migrations.js +43 -0
- package/dist/miniflare/migrations.js.map +1 -0
- package/dist/miniflare/one-call-d1.d.ts +12 -0
- package/dist/miniflare/one-call-d1.d.ts.map +1 -0
- package/dist/miniflare/one-call-d1.js +223 -0
- package/dist/miniflare/one-call-d1.js.map +1 -0
- package/dist/miniflare/statements.d.ts +18 -0
- package/dist/miniflare/statements.d.ts.map +1 -0
- package/dist/miniflare/statements.js +175 -0
- package/dist/miniflare/statements.js.map +1 -0
- package/dist/miniflare/storage.d.ts +58 -0
- package/dist/miniflare/storage.d.ts.map +1 -0
- package/dist/miniflare/storage.js +129 -0
- package/dist/miniflare/storage.js.map +1 -0
- package/dist/miniflare/types.d.ts +25 -0
- package/dist/miniflare/types.d.ts.map +1 -0
- package/dist/miniflare/types.js +2 -0
- package/dist/miniflare/types.js.map +1 -0
- package/dist/miniflare/worker.d.ts +70 -0
- package/dist/miniflare/worker.d.ts.map +1 -0
- package/dist/miniflare/worker.js +137 -0
- package/dist/miniflare/worker.js.map +1 -0
- package/dist/push-subscription-contract.d.ts +54 -0
- package/dist/push-subscription-contract.d.ts.map +1 -0
- package/dist/push-subscription-contract.js +735 -0
- package/dist/push-subscription-contract.js.map +1 -0
- package/dist/routes.d.ts +72 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +196 -0
- package/dist/routes.js.map +1 -0
- package/llms.txt +234 -0
- package/package.json +69 -3
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { EXECUTOR_COMPATIBILITY_DATE, EXECUTOR_SCRIPT } from "./executor.js";
|
|
2
|
+
import { EXECUTOR_NAME, EXECUTOR_TOKEN_BINDING, executorChannel, executorSockets, executorToken, } from "./executor-channel.js";
|
|
3
|
+
import { oneCallD1s } from "./one-call-d1.js";
|
|
4
|
+
import { launch } from "./storage.js";
|
|
5
|
+
function poolSize(value, kind) {
|
|
6
|
+
const size = value ?? 0;
|
|
7
|
+
if (!Number.isSafeInteger(size) || size < 0) {
|
|
8
|
+
throw new TypeError(`startBindings: ${kind} must be a whole number of bindings, 0 or more`);
|
|
9
|
+
}
|
|
10
|
+
return size;
|
|
11
|
+
}
|
|
12
|
+
/** The kind of D1 binding asked for, checked (also for callers without TypeScript). */
|
|
13
|
+
export function d1BindingKind(value, where) {
|
|
14
|
+
if (value === undefined)
|
|
15
|
+
return "one-call";
|
|
16
|
+
if (value === "one-call" || value === "direct")
|
|
17
|
+
return value;
|
|
18
|
+
throw new TypeError(`${where}: d1Binding must be "one-call" or "direct"`);
|
|
19
|
+
}
|
|
20
|
+
/** One pool per kind: hands out each binding once, never a used one. */
|
|
21
|
+
function pool(size, prefix, what, option) {
|
|
22
|
+
let next = 0;
|
|
23
|
+
return () => {
|
|
24
|
+
if (next >= size) {
|
|
25
|
+
throw new Error(`startBindings: the pool of ${size} ${what} is used up; ask for more with { ${option}: n }`);
|
|
26
|
+
}
|
|
27
|
+
return `${prefix}${next++}`;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pools of fresh bindings from one Miniflare, running in Node: each call hands out a binding no
|
|
32
|
+
* test used before. Start it once per test file (`beforeAll`) and dispose it in `afterAll`.
|
|
33
|
+
* Miniflare listens on a random port and keeps the storage in a temporary directory of its own,
|
|
34
|
+
* so test files can run in parallel. D1 databases are one-call D1s unless `d1Binding` says
|
|
35
|
+
* `"direct"` (see {@link D1BindingKind}).
|
|
36
|
+
*/
|
|
37
|
+
export async function startBindings(options) {
|
|
38
|
+
const d1Size = poolSize(options.d1, "d1");
|
|
39
|
+
const r2Size = poolSize(options.r2, "r2");
|
|
40
|
+
const kind = d1BindingKind(options.d1Binding, "startBindings");
|
|
41
|
+
if (d1Size + r2Size === 0) {
|
|
42
|
+
throw new TypeError("startBindings: ask for at least one binding ({ d1: n } or { r2: n })");
|
|
43
|
+
}
|
|
44
|
+
const d1Names = Array.from({ length: d1Size }, (_, i) => `DB_${i}`);
|
|
45
|
+
const r2Names = Array.from({ length: r2Size }, (_, i) => `BUCKET_${i}`);
|
|
46
|
+
// Only this harness may call the executor (see `executor-channel.ts`).
|
|
47
|
+
const token = executorToken();
|
|
48
|
+
const started = await launch(() => ({
|
|
49
|
+
name: EXECUTOR_NAME,
|
|
50
|
+
modules: true,
|
|
51
|
+
script: EXECUTOR_SCRIPT,
|
|
52
|
+
compatibilityDate: EXECUTOR_COMPATIBILITY_DATE,
|
|
53
|
+
// `DB_n` and `BUCKET_n`: none is the token's binding.
|
|
54
|
+
bindings: { [EXECUTOR_TOKEN_BINDING]: token },
|
|
55
|
+
d1Databases: Object.fromEntries(d1Names.map((name) => [name, `${name.toLowerCase()}-id`])),
|
|
56
|
+
r2Buckets: Object.fromEntries(r2Names.map((name) => [name, name.toLowerCase()])),
|
|
57
|
+
unsafeDirectSockets: executorSockets(),
|
|
58
|
+
}));
|
|
59
|
+
const { mf } = started;
|
|
60
|
+
const takeD1 = pool(d1Size, "DB_", "D1 databases", "d1");
|
|
61
|
+
const takeR2 = pool(r2Size, "BUCKET_", "R2 buckets", "r2");
|
|
62
|
+
// The executor is reached on its own socket over kept-alive connections (see
|
|
63
|
+
// `executor-channel.ts`), not through `dispatchFetch`, which opens a connection per request.
|
|
64
|
+
let channel;
|
|
65
|
+
try {
|
|
66
|
+
channel = executorChannel(await mf.unsafeGetDirectURL(EXECUTOR_NAME), token, "startBindings");
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
await started.dispose();
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
const oneCall = oneCallD1s(channel.send);
|
|
73
|
+
return {
|
|
74
|
+
directory: started.directory,
|
|
75
|
+
d1: async () => {
|
|
76
|
+
const name = takeD1();
|
|
77
|
+
return kind === "direct"
|
|
78
|
+
? (await mf.getD1Database(name))
|
|
79
|
+
: oneCall(name);
|
|
80
|
+
},
|
|
81
|
+
// Miniflare types its bindings with its own copies of the Workers types: at runtime they are
|
|
82
|
+
// the objects a Worker uses.
|
|
83
|
+
r2: async () => (await mf.getR2Bucket(takeR2())),
|
|
84
|
+
dispose: () => {
|
|
85
|
+
channel.close();
|
|
86
|
+
return started.dispose();
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../src/miniflare/bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EACL,aAAa,EACb,sBAAsB,EAEtB,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAqCtC,SAAS,QAAQ,CAAC,KAAyB,EAAE,IAAY;IACvD,MAAM,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,kBAAkB,IAAI,gDAAgD,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,aAAa,CAAC,KAAc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,CAAC;QACf,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,EAAE,EAAE,KAAK,IAAI,EAAE;YACb,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC;YACtB,OAAO,IAAI,KAAK,QAAQ;gBACtB,CAAC,CAAE,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAA2B;gBAC3D,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,6FAA6F;QAC7F,6BAA6B;QAC7B,EAAE,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAwB;QACvE,OAAO,EAAE,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bindings with the shape of the real ones whose every call fails, like a database or a bucket
|
|
3
|
+
* that lost its connection: for the error paths of code that uses them. (A binding from a
|
|
4
|
+
* disposed Miniflare cannot stand in: it throws on any property access, so it would not even
|
|
5
|
+
* pass an adapter's shape check.)
|
|
6
|
+
*/
|
|
7
|
+
import type { D1Database, R2Bucket } from "./types.js";
|
|
8
|
+
/** A D1 binding whose every query (`first`, `all`, `run`, `raw`, `batch`, `exec`) rejects. */
|
|
9
|
+
export declare function brokenD1(): D1Database;
|
|
10
|
+
/** An R2 binding whose every operation rejects, multipart uploads included. */
|
|
11
|
+
export declare function brokenR2(): R2Bucket;
|
|
12
|
+
//# sourceMappingURL=broken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broken.d.ts","sourceRoot":"","sources":["../../src/miniflare/broken.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD,8FAA8F;AAC9F,wBAAgB,QAAQ,IAAI,UAAU,CAIrC;AAED,+EAA+E;AAC/E,wBAAgB,QAAQ,IAAI,QAAQ,CAkBnC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** A D1 binding whose every query (`first`, `all`, `run`, `raw`, `batch`, `exec`) rejects. */
|
|
2
|
+
export function brokenD1() {
|
|
3
|
+
const lost = () => Promise.reject(new Error("D1_ERROR: Network connection lost."));
|
|
4
|
+
const statement = { bind: () => statement, first: lost, all: lost, run: lost, raw: lost };
|
|
5
|
+
return { prepare: () => statement, batch: lost, exec: lost };
|
|
6
|
+
}
|
|
7
|
+
/** An R2 binding whose every operation rejects, multipart uploads included. */
|
|
8
|
+
export function brokenR2() {
|
|
9
|
+
const lost = () => Promise.reject(new Error("R2_ERROR: Network connection lost."));
|
|
10
|
+
const upload = (key, uploadId) => ({
|
|
11
|
+
key,
|
|
12
|
+
uploadId,
|
|
13
|
+
uploadPart: lost,
|
|
14
|
+
abort: lost,
|
|
15
|
+
complete: lost,
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
head: lost,
|
|
19
|
+
get: lost,
|
|
20
|
+
put: lost,
|
|
21
|
+
delete: lost,
|
|
22
|
+
list: lost,
|
|
23
|
+
createMultipartUpload: lost,
|
|
24
|
+
resumeMultipartUpload: upload,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=broken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broken.js","sourceRoot":"","sources":["../../src/miniflare/broken.ts"],"names":[],"mappings":"AAQA,8FAA8F;AAC9F,MAAM,UAAU,QAAQ;IACtB,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;IACnF,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IAC1F,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAA2B,CAAC;AACxF,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,QAAQ;IACtB,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC;QACjD,GAAG;QACH,QAAQ;QACR,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,IAAI;QACV,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,IAAI;QACT,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,IAAI;QACV,qBAAqB,EAAE,IAAI;QAC3B,qBAAqB,EAAE,MAAM;KACP,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SendToExecutor } from "./one-call-d1.js";
|
|
2
|
+
/** The one-call D1's executor Worker, by name in Miniflare. */
|
|
3
|
+
export declare const EXECUTOR_NAME = "cardon-one-call-d1";
|
|
4
|
+
/**
|
|
5
|
+
* The executor's binding that holds the harness's token. The executor is a Worker of its own:
|
|
6
|
+
* its only other bindings are the D1 databases, whose names `startWorker` checks against this.
|
|
7
|
+
*/
|
|
8
|
+
export declare const EXECUTOR_TOKEN_BINDING = "CARDON_ONE_CALL_D1_TOKEN";
|
|
9
|
+
/** The request header that carries the token. */
|
|
10
|
+
export declare const EXECUTOR_TOKEN_HEADER = "x-cardon-one-call-d1-token";
|
|
11
|
+
/**
|
|
12
|
+
* The executor's own socket: a random port on loopback (Miniflare's `unsafeDirectSockets`). A new
|
|
13
|
+
* array each call, so no harness can change another's.
|
|
14
|
+
*/
|
|
15
|
+
export declare function executorSockets(): {
|
|
16
|
+
host: string;
|
|
17
|
+
port: number;
|
|
18
|
+
}[];
|
|
19
|
+
/** A new random token for one harness: 256 bits, hex. Never logged, never in an error. */
|
|
20
|
+
export declare function executorToken(): string;
|
|
21
|
+
export interface ExecutorChannel {
|
|
22
|
+
/** Sends one request body to the executor; resolves to its whole answer. */
|
|
23
|
+
readonly send: SendToExecutor;
|
|
24
|
+
/** How many connections the channel has opened so far. */
|
|
25
|
+
connections(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Closes the channel: requests in flight reject, and any request sent after it rejects at once
|
|
28
|
+
* without connecting (the port may belong to another harness by then).
|
|
29
|
+
*/
|
|
30
|
+
close(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A channel to the executor listening at `url` (`Miniflare#unsafeGetDirectURL`), sending `token`
|
|
34
|
+
* on every request. `owner` names the harness in errors (`startBindings`, `startWorker`).
|
|
35
|
+
*/
|
|
36
|
+
export declare function executorChannel(url: URL, token: string, owner: string): ExecutorChannel;
|
|
37
|
+
//# sourceMappingURL=executor-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor-channel.d.ts","sourceRoot":"","sources":["../../src/miniflare/executor-channel.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,+DAA+D;AAC/D,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE,iDAAiD;AACjD,eAAO,MAAM,qBAAqB,+BAA+B,CAAC;AAElE;;;GAGG;AACH,wBAAgB,eAAe,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAElE;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,IAAI,MAAM,CAGtC;AAWD,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,0DAA0D;IAC1D,WAAW,IAAI,MAAM,CAAC;IACtB;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,CAuGvF"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Node reaches the one-call D1's executor Worker: plain HTTP to the executor's own socket in
|
|
3
|
+
* workerd (Miniflare's `unsafeDirectSockets`), through a keep-alive agent of the harness, so the
|
|
4
|
+
* requests reuse a few connections instead of opening one each.
|
|
5
|
+
*
|
|
6
|
+
* Not `Miniflare#dispatchFetch` (nor a `Fetcher` from `getWorker`, which goes through it): its
|
|
7
|
+
* dispatcher marks every request to workerd `reset` (undici then sends `connection: close`), so
|
|
8
|
+
* each call opens a TCP connection and closes it, and on Windows the thousands of closed
|
|
9
|
+
* connections a test run leaves in `TIME_WAIT` use up the local ports. And not the global
|
|
10
|
+
* `fetch`: a test may stub it or replace undici's global dispatcher.
|
|
11
|
+
*
|
|
12
|
+
* The executor's socket bypasses Miniflare's entry Worker, so anything on the machine can connect
|
|
13
|
+
* to it, a web page in the developer's browser included. Each harness makes a random token
|
|
14
|
+
* ({@link executorToken}), gives it to the executor Worker as a binding
|
|
15
|
+
* ({@link EXECUTOR_TOKEN_BINDING}) and sends it on every request in a header
|
|
16
|
+
* ({@link EXECUTOR_TOKEN_HEADER}); the executor refuses any request without it (`executor.ts`).
|
|
17
|
+
* A custom header also makes a browser send a CORS preflight first, which the executor refuses.
|
|
18
|
+
*/
|
|
19
|
+
import { Agent, request } from "node:http";
|
|
20
|
+
/** The one-call D1's executor Worker, by name in Miniflare. */
|
|
21
|
+
export const EXECUTOR_NAME = "cardon-one-call-d1";
|
|
22
|
+
/**
|
|
23
|
+
* The executor's binding that holds the harness's token. The executor is a Worker of its own:
|
|
24
|
+
* its only other bindings are the D1 databases, whose names `startWorker` checks against this.
|
|
25
|
+
*/
|
|
26
|
+
export const EXECUTOR_TOKEN_BINDING = "CARDON_ONE_CALL_D1_TOKEN";
|
|
27
|
+
/** The request header that carries the token. */
|
|
28
|
+
export const EXECUTOR_TOKEN_HEADER = "x-cardon-one-call-d1-token";
|
|
29
|
+
/**
|
|
30
|
+
* The executor's own socket: a random port on loopback (Miniflare's `unsafeDirectSockets`). A new
|
|
31
|
+
* array each call, so no harness can change another's.
|
|
32
|
+
*/
|
|
33
|
+
export function executorSockets() {
|
|
34
|
+
return [{ host: "127.0.0.1", port: 0 }];
|
|
35
|
+
}
|
|
36
|
+
/** A new random token for one harness: 256 bits, hex. Never logged, never in an error. */
|
|
37
|
+
export function executorToken() {
|
|
38
|
+
const bytes = crypto.getRandomValues(new Uint8Array(32));
|
|
39
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* How long the channel keeps an idle connection: well under the 5 seconds after which workerd
|
|
43
|
+
* closes one on Miniflare 4 (on Miniflare 5 it was seen not to within 12 seconds).
|
|
44
|
+
*/
|
|
45
|
+
const IDLE_MS = 2_000;
|
|
46
|
+
/** The errors of writing to a connection the other side has closed. */
|
|
47
|
+
const CLOSED_CONNECTION = new Set(["ECONNRESET", "EPIPE"]);
|
|
48
|
+
/**
|
|
49
|
+
* A channel to the executor listening at `url` (`Miniflare#unsafeGetDirectURL`), sending `token`
|
|
50
|
+
* on every request. `owner` names the harness in errors (`startBindings`, `startWorker`).
|
|
51
|
+
*/
|
|
52
|
+
export function executorChannel(url, token, owner) {
|
|
53
|
+
// Connections stay open between requests; as many as there are requests at once (one per
|
|
54
|
+
// database at most, since a database sends one request at a time). workerd on Miniflare 4
|
|
55
|
+
// closes a connection idle for 5 seconds; the agent closes its own after IDLE_MS, so a request
|
|
56
|
+
// is not written to a connection workerd is closing. (The timeout only closes idle connections:
|
|
57
|
+
// a request that takes longer is not cut.)
|
|
58
|
+
const agent = new Agent({ keepAlive: true, timeout: IDLE_MS });
|
|
59
|
+
const seen = new WeakSet();
|
|
60
|
+
const inFlight = new Set();
|
|
61
|
+
let opened = 0;
|
|
62
|
+
let closed = false;
|
|
63
|
+
const disposed = () => new Error(`${owner}: the harness was disposed; a one-call D1 from it cannot be used after dispose()`);
|
|
64
|
+
const send = (body) => new Promise((resolve, reject) => {
|
|
65
|
+
const attempt = (mayRetry) => {
|
|
66
|
+
if (closed) {
|
|
67
|
+
reject(disposed());
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let responded = false;
|
|
71
|
+
const req = request(url.href, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
agent,
|
|
74
|
+
headers: {
|
|
75
|
+
"content-type": "application/json",
|
|
76
|
+
"content-length": Buffer.byteLength(body),
|
|
77
|
+
[EXECUTOR_TOKEN_HEADER]: token,
|
|
78
|
+
},
|
|
79
|
+
}, (res) => {
|
|
80
|
+
responded = true;
|
|
81
|
+
// The whole body is read, so the connection is free for the next request.
|
|
82
|
+
const chunks = [];
|
|
83
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
84
|
+
res.on("error", (error) => reject(closed ? disposed() : error));
|
|
85
|
+
// A connection lost in the middle of the answer: not retried (the statement ran).
|
|
86
|
+
res.on("close", () => {
|
|
87
|
+
if (!res.complete) {
|
|
88
|
+
reject(closed
|
|
89
|
+
? disposed()
|
|
90
|
+
: new Error("one-call D1: the connection to the executor closed mid-answer"));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
res.on("end", () => {
|
|
94
|
+
resolve(new Response(Buffer.concat(chunks), { status: res.statusCode ?? 500 }));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
inFlight.add(req);
|
|
98
|
+
req.on("close", () => inFlight.delete(req));
|
|
99
|
+
req.on("socket", (socket) => {
|
|
100
|
+
if (!seen.has(socket)) {
|
|
101
|
+
seen.add(socket);
|
|
102
|
+
opened++;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
req.on("error", (error) => {
|
|
106
|
+
// One retry, only for a kept connection workerd had already closed for being idle,
|
|
107
|
+
// while Node's event loop was held up longer than IDLE_MS (a breakpoint, the machine
|
|
108
|
+
// asleep, long synchronous work) so the agent never dropped it. workerd does not read
|
|
109
|
+
// a request on a connection it closed for being idle, so that statement has not run.
|
|
110
|
+
// (A reset with no answer can also mean workerd died while running the statement:
|
|
111
|
+
// the retry then finds nothing listening and the call fails as it would have.) The
|
|
112
|
+
// other kept connections are as old, so they are dropped and the retry opens a new
|
|
113
|
+
// one. A new connection's failure, a second failure, or one after an answer arrived
|
|
114
|
+
// (its status line and headers) is not retried: the statement may have run.
|
|
115
|
+
if (mayRetry &&
|
|
116
|
+
!closed &&
|
|
117
|
+
req.reusedSocket &&
|
|
118
|
+
!responded &&
|
|
119
|
+
CLOSED_CONNECTION.has(error.code ?? "")) {
|
|
120
|
+
for (const sockets of Object.values(agent.freeSockets)) {
|
|
121
|
+
for (const socket of [...(sockets ?? [])])
|
|
122
|
+
socket.destroy();
|
|
123
|
+
}
|
|
124
|
+
attempt(false);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
reject(closed ? disposed() : error);
|
|
128
|
+
});
|
|
129
|
+
req.end(body);
|
|
130
|
+
};
|
|
131
|
+
attempt(true);
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
send,
|
|
135
|
+
connections: () => opened,
|
|
136
|
+
close: () => {
|
|
137
|
+
closed = true;
|
|
138
|
+
for (const req of inFlight)
|
|
139
|
+
req.destroy(disposed());
|
|
140
|
+
agent.destroy();
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=executor-channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor-channel.js","sourceRoot":"","sources":["../../src/miniflare/executor-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,EAAsB,OAAO,EAAE,MAAM,WAAW,CAAC;AAI/D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAEjE,iDAAiD;AACjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAElE;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,aAAa;IAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,GAAG,KAAK,CAAC;AAEtB,uEAAuE;AACvE,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;AAc3D;;;GAGG;AACH,MAAM,U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gBACnF,qFAAqF;gBACrF,sFAAsF;gBACtF,qFAAqF;gBACrF,kFAAkF;gBAClF,mFAAmF;gBACnF,mFAAmF;gBACnF,oFAAoF;gBACpF,4EAA4E;gBAC5E,IACE,QAAQ;oBACR,CAAC,MAAM;oBACP,GAAG,CAAC,YAAY;oBAChB,CAAC,SAAS;oBACV,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,EACvC,CAAC;oBACD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;wBACvD,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;4BAAE,MAAM,CAAC,OAAO,EAAE,CAAC;oBAC9D,CAAC;oBACD,OAAO,CAAC,KAAK,CAAC,CAAC;oBACf,OAAO;gBACT,CAAC;gBACD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEL,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM;QACzB,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,GAAG,IAAI,CAAC;YACd,KAAK,MAAM,GAAG,IAAI,QAAQ;gBAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpD,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The executor Worker of the one-call D1 (`one-call-d1.ts`): it runs in the same Miniflare as
|
|
3
|
+
* the databases, with each of them bound under its binding name, and runs one execution per
|
|
4
|
+
* request on the real binding.
|
|
5
|
+
*
|
|
6
|
+
* D1's binding is a JavaScript layer over a fetch to the database: a prepared statement holds
|
|
7
|
+
* `statement` (the SQL as given) and `params` (the values `bind` checked and converted), and an
|
|
8
|
+
* execution sends `JSON.stringify({ sql: statement, params })` (one such object per statement
|
|
9
|
+
* for `batch`). The one-call D1 does what happens before that in Node with the same code, and
|
|
10
|
+
* sends the same two fields; the executor puts them on a statement of the real binding and runs
|
|
11
|
+
* it, so D1 sends the database the same JSON it sends from a Worker.
|
|
12
|
+
*
|
|
13
|
+
* Who may call it: only the harness that started it. Its socket is reachable from anything on
|
|
14
|
+
* the machine (a web page in the developer's browser too), so a request without the harness's
|
|
15
|
+
* token in `EXECUTOR_TOKEN_HEADER` gets a `403` with a fixed text before its body is read, and
|
|
16
|
+
* anything but a POST a `405` (a CORS preflight included: no CORS headers are ever sent).
|
|
17
|
+
*
|
|
18
|
+
* Wire format (JSON both ways; every request is a POST, every answer is 200 unless the request
|
|
19
|
+
* itself is refused or malformed):
|
|
20
|
+
*
|
|
21
|
+
* - Request: `{ database, op, statement?, statements?, sql?, columnNames? }`, where `op` is
|
|
22
|
+
* `all`, `run`, `raw`, `first`, `batch` or `exec`, and a statement is `{ sql, params }`:
|
|
23
|
+
* the statement's `statement` and `params` fields, serialised when the method was called, as
|
|
24
|
+
* D1 serialises them. Serialising and parsing JSON gives back the same JSON, so the database
|
|
25
|
+
* gets what it gets from a Worker (`NaN` and `Infinity` are `null`, a hole in an array is
|
|
26
|
+
* `null`, and so on, in both). `first` runs without a column: the column is looked up in Node,
|
|
27
|
+
* on the row, as D1 looks it up (so a name `Object.prototype` has, such as `constructor`,
|
|
28
|
+
* gives what it gives in a Worker, which no JSON answer could carry).
|
|
29
|
+
* - Answer: `{ result }` with the value the real method resolved to, or `{ error }` with
|
|
30
|
+
* `{ name, message, cause? }` (the cause in the same shape) for what it threw. Results need
|
|
31
|
+
* no encoding of their own: D1 builds them from the database's JSON answer, so every value is
|
|
32
|
+
* already `null`, a number, a string or an array of byte numbers (a BLOB), and comes out of
|
|
33
|
+
* `JSON.stringify` and `JSON.parse` unchanged.
|
|
34
|
+
*/
|
|
35
|
+
export declare const EXECUTOR_SCRIPT: string;
|
|
36
|
+
/**
|
|
37
|
+
* The executor's compatibility date where there is no Worker to take it from (`startBindings`).
|
|
38
|
+
* Fixed, so the executor does not change with the installed workerd; `startWorker`'s executor
|
|
39
|
+
* takes the Worker's own date and flags.
|
|
40
|
+
*/
|
|
41
|
+
export declare const EXECUTOR_COMPATIBILITY_DATE = "2026-07-01";
|
|
42
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/miniflare/executor.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,eAAe,QA8E3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,eAAe,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { EXECUTOR_TOKEN_BINDING, EXECUTOR_TOKEN_HEADER } from "./executor-channel.js";
|
|
2
|
+
/**
|
|
3
|
+
* The executor Worker of the one-call D1 (`one-call-d1.ts`): it runs in the same Miniflare as
|
|
4
|
+
* the databases, with each of them bound under its binding name, and runs one execution per
|
|
5
|
+
* request on the real binding.
|
|
6
|
+
*
|
|
7
|
+
* D1's binding is a JavaScript layer over a fetch to the database: a prepared statement holds
|
|
8
|
+
* `statement` (the SQL as given) and `params` (the values `bind` checked and converted), and an
|
|
9
|
+
* execution sends `JSON.stringify({ sql: statement, params })` (one such object per statement
|
|
10
|
+
* for `batch`). The one-call D1 does what happens before that in Node with the same code, and
|
|
11
|
+
* sends the same two fields; the executor puts them on a statement of the real binding and runs
|
|
12
|
+
* it, so D1 sends the database the same JSON it sends from a Worker.
|
|
13
|
+
*
|
|
14
|
+
* Who may call it: only the harness that started it. Its socket is reachable from anything on
|
|
15
|
+
* the machine (a web page in the developer's browser too), so a request without the harness's
|
|
16
|
+
* token in `EXECUTOR_TOKEN_HEADER` gets a `403` with a fixed text before its body is read, and
|
|
17
|
+
* anything but a POST a `405` (a CORS preflight included: no CORS headers are ever sent).
|
|
18
|
+
*
|
|
19
|
+
* Wire format (JSON both ways; every request is a POST, every answer is 200 unless the request
|
|
20
|
+
* itself is refused or malformed):
|
|
21
|
+
*
|
|
22
|
+
* - Request: `{ database, op, statement?, statements?, sql?, columnNames? }`, where `op` is
|
|
23
|
+
* `all`, `run`, `raw`, `first`, `batch` or `exec`, and a statement is `{ sql, params }`:
|
|
24
|
+
* the statement's `statement` and `params` fields, serialised when the method was called, as
|
|
25
|
+
* D1 serialises them. Serialising and parsing JSON gives back the same JSON, so the database
|
|
26
|
+
* gets what it gets from a Worker (`NaN` and `Infinity` are `null`, a hole in an array is
|
|
27
|
+
* `null`, and so on, in both). `first` runs without a column: the column is looked up in Node,
|
|
28
|
+
* on the row, as D1 looks it up (so a name `Object.prototype` has, such as `constructor`,
|
|
29
|
+
* gives what it gives in a Worker, which no JSON answer could carry).
|
|
30
|
+
* - Answer: `{ result }` with the value the real method resolved to, or `{ error }` with
|
|
31
|
+
* `{ name, message, cause? }` (the cause in the same shape) for what it threw. Results need
|
|
32
|
+
* no encoding of their own: D1 builds them from the database's JSON answer, so every value is
|
|
33
|
+
* already `null`, a number, a string or an array of byte numbers (a BLOB), and comes out of
|
|
34
|
+
* `JSON.stringify` and `JSON.parse` unchanged.
|
|
35
|
+
*/
|
|
36
|
+
export const EXECUTOR_SCRIPT = `
|
|
37
|
+
const TOKEN_BINDING = ${JSON.stringify(EXECUTOR_TOKEN_BINDING)};
|
|
38
|
+
const TOKEN_HEADER = ${JSON.stringify(EXECUTOR_TOKEN_HEADER)};
|
|
39
|
+
|
|
40
|
+
const errorOf = (error) =>
|
|
41
|
+
error instanceof Error
|
|
42
|
+
? {
|
|
43
|
+
name: String(error.name),
|
|
44
|
+
message: String(error.message),
|
|
45
|
+
...(error.cause === undefined ? {} : { cause: errorOf(error.cause) }),
|
|
46
|
+
}
|
|
47
|
+
: { name: "Error", message: String(error) };
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
async fetch(request, env) {
|
|
51
|
+
// The whole token, compared as a string. Not in constant time: a loopback test harness with
|
|
52
|
+
// a fresh 256-bit token per run is not worth defending against timing.
|
|
53
|
+
const token = env[TOKEN_BINDING];
|
|
54
|
+
if (
|
|
55
|
+
typeof token !== "string" ||
|
|
56
|
+
token.length === 0 ||
|
|
57
|
+
request.headers.get(TOKEN_HEADER) !== token
|
|
58
|
+
) {
|
|
59
|
+
return new Response("one-call D1: forbidden", { status: 403 });
|
|
60
|
+
}
|
|
61
|
+
if (request.method !== "POST") {
|
|
62
|
+
return new Response("one-call D1: method not allowed", { status: 405 });
|
|
63
|
+
}
|
|
64
|
+
let call;
|
|
65
|
+
try {
|
|
66
|
+
call = await request.json();
|
|
67
|
+
} catch {
|
|
68
|
+
return new Response("one-call D1: the request is not JSON", { status: 400 });
|
|
69
|
+
}
|
|
70
|
+
const db = env[call?.database];
|
|
71
|
+
if (typeof db?.prepare !== "function") {
|
|
72
|
+
return new Response("one-call D1: no such database", { status: 400 });
|
|
73
|
+
}
|
|
74
|
+
const statement = (s) => {
|
|
75
|
+
const prepared = db.prepare(s.sql);
|
|
76
|
+
if (!Object.hasOwn(prepared, "params")) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"one-call D1: this workerd's D1 statements have no params field; the one-call D1 cannot run on it (use d1Binding: \\"direct\\")",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
prepared.params = s.params;
|
|
82
|
+
return prepared;
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
let result;
|
|
86
|
+
switch (call.op) {
|
|
87
|
+
case "all":
|
|
88
|
+
result = await statement(call.statement).all();
|
|
89
|
+
break;
|
|
90
|
+
case "run":
|
|
91
|
+
result = await statement(call.statement).run();
|
|
92
|
+
break;
|
|
93
|
+
case "raw":
|
|
94
|
+
result = await statement(call.statement).raw({ columnNames: call.columnNames });
|
|
95
|
+
break;
|
|
96
|
+
case "first":
|
|
97
|
+
result = await statement(call.statement).first();
|
|
98
|
+
break;
|
|
99
|
+
case "batch":
|
|
100
|
+
result = await db.batch(call.statements.map(statement));
|
|
101
|
+
break;
|
|
102
|
+
case "exec":
|
|
103
|
+
result = await db.exec(call.sql);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
return new Response("one-call D1: unknown operation", { status: 400 });
|
|
107
|
+
}
|
|
108
|
+
return Response.json({ result });
|
|
109
|
+
} catch (error) {
|
|
110
|
+
return Response.json({ error: errorOf(error) });
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
`;
|
|
115
|
+
/**
|
|
116
|
+
* The executor's compatibility date where there is no Worker to take it from (`startBindings`).
|
|
117
|
+
* Fixed, so the executor does not change with the installed workerd; `startWorker`'s executor
|
|
118
|
+
* takes the Worker's own date and flags.
|
|
119
|
+
*/
|
|
120
|
+
export const EXECUTOR_COMPATIBILITY_DATE = "2026-07-01";
|
|
121
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/miniflare/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;wBACP,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC;uBACvC,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4E3D,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@cardonjs/testing/miniflare`: real Cloudflare bindings in tests, from Miniflare running in
|
|
3
|
+
* Node. Needs the `miniflare` package; `startWorker` with an `entry` also needs `rolldown`.
|
|
4
|
+
*/
|
|
5
|
+
export { type D1BindingKind, type StartBindingsOptions, startBindings, type TestBindings, } from "./bindings.js";
|
|
6
|
+
export { brokenD1, brokenR2 } from "./broken.js";
|
|
7
|
+
export { applyMigrations, type MigrationSource } from "./migrations.js";
|
|
8
|
+
export { statementsOf } from "./statements.js";
|
|
9
|
+
export { type StartWorkerOptions, startWorker, type TestWorker, type WorkerSource, } from "./worker.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/miniflare/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,aAAa,EACb,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EACX,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@cardonjs/testing/miniflare`: real Cloudflare bindings in tests, from Miniflare running in
|
|
3
|
+
* Node. Needs the `miniflare` package; `startWorker` with an `entry` also needs `rolldown`.
|
|
4
|
+
*/
|
|
5
|
+
export { startBindings, } from "./bindings.js";
|
|
6
|
+
export { brokenD1, brokenR2 } from "./broken.js";
|
|
7
|
+
export { applyMigrations } from "./migrations.js";
|
|
8
|
+
export { statementsOf } from "./statements.js";
|
|
9
|
+
export { startWorker, } from "./worker.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/miniflare/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAGL,aAAa,GAEd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAwB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAEL,WAAW,GAGZ,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { D1Database } from "./types.js";
|
|
2
|
+
/** Where the migrations come from: a folder of `.sql` files, or the files' text by name. */
|
|
3
|
+
export type MigrationSource = {
|
|
4
|
+
/** A folder (a path, or a file URL such as `new URL("../migrations/", import.meta.url)`). */
|
|
5
|
+
readonly dir: string | URL;
|
|
6
|
+
} | {
|
|
7
|
+
/** File name (or path) → SQL, e.g. from a bundler's glob import. */
|
|
8
|
+
readonly files: Readonly<Record<string, string>>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Applies migration files to `db` as `wrangler d1 migrations apply` does: in name order, the
|
|
12
|
+
* statements of each file (see {@link statementsOf}) in one batch, so a file applies whole or
|
|
13
|
+
* not at all. On a one-call D1 (what `startBindings` hands out) a file is one request, whatever
|
|
14
|
+
* its number of statements: `prepare` is local and the batch is one execution. (A single `exec`
|
|
15
|
+
* would be one too, but D1 splits its text on line endings, so every statement would have to be
|
|
16
|
+
* rewritten onto one line, strings and triggers included; the batch runs them as written.)
|
|
17
|
+
* Resolves to the names applied, in order. A failing file rejects with an error
|
|
18
|
+
* naming it (the database's own error is its `cause`); the files after it are not applied.
|
|
19
|
+
* Unlike Wrangler it records nothing in `d1_migrations`: it is for a fresh test database,
|
|
20
|
+
* applied once.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyMigrations(db: D1Database, source: MigrationSource): Promise<string[]>;
|
|
23
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/miniflare/migrations.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,4FAA4F;AAC5F,MAAM,MAAM,eAAe,GACvB;IACE,6FAA6F;IAC7F,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CAC5B,GACD;IACE,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAClD,CAAC;AAaN;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBhG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { statementsOf } from "./statements.js";
|
|
5
|
+
async function load(source) {
|
|
6
|
+
if ("files" in source)
|
|
7
|
+
return Object.entries(source.files);
|
|
8
|
+
const dir = source.dir instanceof URL ? fileURLToPath(source.dir.href) : source.dir;
|
|
9
|
+
const names = (await readdir(dir)).filter((name) => name.endsWith(".sql"));
|
|
10
|
+
return Promise.all(names.map(async (name) => [name, await readFile(join(dir, name), "utf8")]));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Applies migration files to `db` as `wrangler d1 migrations apply` does: in name order, the
|
|
14
|
+
* statements of each file (see {@link statementsOf}) in one batch, so a file applies whole or
|
|
15
|
+
* not at all. On a one-call D1 (what `startBindings` hands out) a file is one request, whatever
|
|
16
|
+
* its number of statements: `prepare` is local and the batch is one execution. (A single `exec`
|
|
17
|
+
* would be one too, but D1 splits its text on line endings, so every statement would have to be
|
|
18
|
+
* rewritten onto one line, strings and triggers included; the batch runs them as written.)
|
|
19
|
+
* Resolves to the names applied, in order. A failing file rejects with an error
|
|
20
|
+
* naming it (the database's own error is its `cause`); the files after it are not applied.
|
|
21
|
+
* Unlike Wrangler it records nothing in `d1_migrations`: it is for a fresh test database,
|
|
22
|
+
* applied once.
|
|
23
|
+
*/
|
|
24
|
+
export async function applyMigrations(db, source) {
|
|
25
|
+
const files = (await load(source)).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
26
|
+
if (files.length === 0) {
|
|
27
|
+
throw new Error("applyMigrations: no migration files (.sql) to apply");
|
|
28
|
+
}
|
|
29
|
+
for (const [name, sql] of files) {
|
|
30
|
+
const statements = statementsOf(sql);
|
|
31
|
+
if (statements.length === 0)
|
|
32
|
+
continue;
|
|
33
|
+
try {
|
|
34
|
+
await db.batch(statements.map((statement) => db.prepare(statement)));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
38
|
+
throw new Error(`applyMigrations: ${name} failed: ${reason}`, { cause: error });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return files.map(([name]) => name);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/miniflare/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,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AAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;QAChC,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QACtC,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,YAAY,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { D1Database } from "./types.js";
|
|
2
|
+
/** Sends one request body to the executor Worker. */
|
|
3
|
+
export type SendToExecutor = (body: string) => Promise<Response>;
|
|
4
|
+
/**
|
|
5
|
+
* One-call D1s over the executor Worker that `send` reaches: `d1(name)` is the database bound as
|
|
6
|
+
* `name` there. Synchronous and cheap: nothing is sent until the first execution. Every object
|
|
7
|
+
* for one name shares that database's queue, so executions on it are sent in call order whichever
|
|
8
|
+
* object they come from; different databases do not wait for each other (D1 orders the queries of
|
|
9
|
+
* one database; two databases have no order between them to keep).
|
|
10
|
+
*/
|
|
11
|
+
export declare function oneCallD1s(send: SendToExecutor): (database: string) => D1Database;
|
|
12
|
+
//# sourceMappingURL=one-call-d1.d.ts.map
|