@orthograph/host-cloudflare 0.0.0-stage → 0.1.0-next.2
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 +202 -0
- package/README.md +2 -2
- package/dist/index.d.ts +21 -0
- package/dist/index.js +12 -0
- package/dist/modules/actors/internal/tables.d.ts +1 -0
- package/dist/modules/actors/internal/tables.js +5 -0
- package/dist/modules/actors/service.d.ts +18 -0
- package/dist/modules/actors/service.js +51 -0
- package/dist/modules/actors/types.d.ts +35 -0
- package/dist/modules/actors/types.js +1 -0
- package/dist/modules/auth/internal/instance.d.ts +4462 -0
- package/dist/modules/auth/internal/instance.js +36 -0
- package/dist/modules/auth/internal/oauth.d.ts +20 -0
- package/dist/modules/auth/internal/oauth.js +70 -0
- package/dist/modules/auth/internal/options.d.ts +4886 -0
- package/dist/modules/auth/internal/options.js +75 -0
- package/dist/modules/auth/internal/schema.d.ts +2 -0
- package/dist/modules/auth/internal/schema.js +41 -0
- package/dist/modules/auth/internal/world-token.d.ts +15 -0
- package/dist/modules/auth/internal/world-token.js +40 -0
- package/dist/modules/auth/service.d.ts +9 -0
- package/dist/modules/auth/service.js +96 -0
- package/dist/modules/auth/types.d.ts +75 -0
- package/dist/modules/auth/types.js +1 -0
- package/dist/modules/clock/internal/date.d.ts +17 -0
- package/dist/modules/clock/internal/date.js +45 -0
- package/dist/modules/clock/internal/door.d.ts +2 -0
- package/dist/modules/clock/internal/door.js +49 -0
- package/dist/modules/clock/internal/state.d.ts +5 -0
- package/dist/modules/clock/internal/state.js +78 -0
- package/dist/modules/clock/service.d.ts +2 -0
- package/dist/modules/clock/service.js +36 -0
- package/dist/modules/clock/types.d.ts +152 -0
- package/dist/modules/clock/types.js +1 -0
- package/dist/modules/database/service.d.ts +2 -0
- package/dist/modules/database/service.js +6 -0
- package/dist/modules/database/types.d.ts +7 -0
- package/dist/modules/database/types.js +1 -0
- package/dist/modules/follower/internal/entries.d.ts +9 -0
- package/dist/modules/follower/internal/entries.js +20 -0
- package/dist/modules/follower/internal/health.d.ts +18 -0
- package/dist/modules/follower/internal/health.js +27 -0
- package/dist/modules/follower/internal/outbox.d.ts +26 -0
- package/dist/modules/follower/internal/outbox.js +35 -0
- package/dist/modules/follower/internal/poll.d.ts +21 -0
- package/dist/modules/follower/internal/poll.js +23 -0
- package/dist/modules/follower/service.d.ts +31 -0
- package/dist/modules/follower/service.js +87 -0
- package/dist/modules/follower/types.d.ts +71 -0
- package/dist/modules/follower/types.js +4 -0
- package/dist/modules/inbound/internal/accept.d.ts +26 -0
- package/dist/modules/inbound/internal/accept.js +10 -0
- package/dist/modules/inbound/internal/read.d.ts +10 -0
- package/dist/modules/inbound/internal/read.js +26 -0
- package/dist/modules/inbound/internal/same.d.ts +1 -0
- package/dist/modules/inbound/internal/same.js +12 -0
- package/dist/modules/inbound/internal/verify.d.ts +6 -0
- package/dist/modules/inbound/internal/verify.js +57 -0
- package/dist/modules/inbound/service.d.ts +2 -0
- package/dist/modules/inbound/service.js +110 -0
- package/dist/modules/inbound/types.d.ts +28 -0
- package/dist/modules/inbound/types.js +1 -0
- package/dist/modules/journal/service.d.ts +2 -0
- package/dist/modules/journal/service.js +23 -0
- package/dist/modules/journal/types.d.ts +8 -0
- package/dist/modules/journal/types.js +1 -0
- package/dist/modules/relayer/internal/adopt.d.ts +19 -0
- package/dist/modules/relayer/internal/adopt.js +34 -0
- package/dist/modules/relayer/internal/check.d.ts +16 -0
- package/dist/modules/relayer/internal/check.js +141 -0
- package/dist/modules/relayer/internal/health.d.ts +5 -0
- package/dist/modules/relayer/internal/health.js +7 -0
- package/dist/modules/relayer/internal/live.d.ts +26 -0
- package/dist/modules/relayer/internal/live.js +25 -0
- package/dist/modules/relayer/internal/relay.d.ts +22 -0
- package/dist/modules/relayer/internal/relay.js +44 -0
- package/dist/modules/relayer/internal/store.d.ts +41 -0
- package/dist/modules/relayer/internal/store.js +44 -0
- package/dist/modules/relayer/service.d.ts +58 -0
- package/dist/modules/relayer/service.js +124 -0
- package/dist/modules/relayer/types.d.ts +75 -0
- package/dist/modules/relayer/types.js +1 -0
- package/dist/modules/store/internal/actors.d.ts +6 -0
- package/dist/modules/store/internal/actors.js +24 -0
- package/dist/modules/store/internal/commit.d.ts +10 -0
- package/dist/modules/store/internal/commit.js +57 -0
- package/dist/modules/store/internal/list.d.ts +10 -0
- package/dist/modules/store/internal/list.js +28 -0
- package/dist/modules/store/internal/rows.d.ts +14 -0
- package/dist/modules/store/internal/rows.js +29 -0
- package/dist/modules/store/internal/unique.d.ts +3 -0
- package/dist/modules/store/internal/unique.js +17 -0
- package/dist/modules/store/service.d.ts +2 -0
- package/dist/modules/store/service.js +71 -0
- package/dist/modules/store/types.d.ts +36 -0
- package/dist/modules/store/types.js +1 -0
- package/dist/modules/telemetry/internal/exporters.d.ts +21 -0
- package/dist/modules/telemetry/internal/exporters.js +66 -0
- package/dist/modules/telemetry/service.d.ts +2 -0
- package/dist/modules/telemetry/service.js +52 -0
- package/dist/modules/telemetry/types.d.ts +36 -0
- package/dist/modules/telemetry/types.js +1 -0
- package/dist/modules/timers/internal/controller.d.ts +13 -0
- package/dist/modules/timers/internal/controller.js +63 -0
- package/dist/modules/timers/internal/count.d.ts +39 -0
- package/dist/modules/timers/internal/count.js +105 -0
- package/dist/modules/timers/internal/limits.d.ts +4 -0
- package/dist/modules/timers/internal/limits.js +8 -0
- package/dist/modules/timers/internal/table.d.ts +52 -0
- package/dist/modules/timers/internal/table.js +181 -0
- package/dist/modules/timers/service.d.ts +12 -0
- package/dist/modules/timers/service.js +136 -0
- package/dist/modules/timers/types.d.ts +82 -0
- package/dist/modules/timers/types.js +1 -0
- package/dist/modules/world/internal/entry.d.ts +34 -0
- package/dist/modules/world/internal/entry.js +69 -0
- package/dist/modules/world/internal/facts.d.ts +5 -0
- package/dist/modules/world/internal/facts.js +31 -0
- package/dist/modules/world/internal/fence.d.ts +9 -0
- package/dist/modules/world/internal/fence.js +90 -0
- package/dist/modules/world/internal/front-door.d.ts +5 -0
- package/dist/modules/world/internal/front-door.js +50 -0
- package/dist/modules/world/internal/leases.d.ts +33 -0
- package/dist/modules/world/internal/leases.js +79 -0
- package/dist/modules/world/internal/reset.d.ts +6 -0
- package/dist/modules/world/internal/reset.js +24 -0
- package/dist/modules/world/internal/work.d.ts +11 -0
- package/dist/modules/world/internal/work.js +73 -0
- package/dist/modules/world/internal/worlds.d.ts +7 -0
- package/dist/modules/world/internal/worlds.js +48 -0
- package/dist/modules/world/service.d.ts +80 -0
- package/dist/modules/world/service.js +209 -0
- package/dist/modules/world/types.d.ts +47 -0
- package/dist/modules/world/types.js +1 -0
- package/package.json +46 -3
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// What a request that belongs to a run the world has reset may not do (M8.07, I2): every statement it runs, and every write it makes through a
|
|
2
|
+
// door of its own (the auth routes), is a write section of its token, which the reset waits for; a request the world no longer holds is refused
|
|
3
|
+
// before it runs anything.
|
|
4
|
+
import { genOf } from "@orthograph/language-effect";
|
|
5
|
+
import { WorldClock } from "#modules/clock/service.js";
|
|
6
|
+
import { keeperOf } from "./entry.js";
|
|
7
|
+
const closing = () => Promise.reject(new Error("the world is being reset: this write is refused, and the request keeps its place"));
|
|
8
|
+
const refused = () => Promise.reject(new Error("this request belongs to a run the world has reset: nothing it does is written"));
|
|
9
|
+
/**
|
|
10
|
+
* Run `f` as a write section of the request in progress. Outside a request (the world's own work) and in a real world it is run as it is. A
|
|
11
|
+
* request whose token is lent out (a fiber of it outside the box, say a statement made while every other fiber sleeps) takes a token of its own
|
|
12
|
+
* for the statement, so the section is still the world's to count and to close; a stale one is refused.
|
|
13
|
+
*/
|
|
14
|
+
export const section = (env, f) => {
|
|
15
|
+
if (WorldClock.declared(env).kind === "real")
|
|
16
|
+
return f();
|
|
17
|
+
const box = WorldClock.box();
|
|
18
|
+
if (box === undefined)
|
|
19
|
+
return f();
|
|
20
|
+
if (box.stale)
|
|
21
|
+
return refused();
|
|
22
|
+
return keeperOf(env).then((keeper) => {
|
|
23
|
+
const held = box.id;
|
|
24
|
+
// The box's own token when it has one; otherwise one for the length of the statement, which the world closes to like any other.
|
|
25
|
+
const own = held === undefined ? Promise.resolve(keeper.countEnter(`${box.owner}`)) : Promise.resolve(held);
|
|
26
|
+
return own.then((id) => {
|
|
27
|
+
const release = () => Promise.resolve(held === undefined ? keeper.countLeave(id) : undefined);
|
|
28
|
+
// A token of another generation than the box's first is of a run that came after: the box is stale, and nothing it does is written.
|
|
29
|
+
if (held === undefined && box.gen !== undefined && box.gen !== genOf(id)) {
|
|
30
|
+
box.stale = true;
|
|
31
|
+
return Promise.resolve(keeper.countLeave(id)).then(refused);
|
|
32
|
+
}
|
|
33
|
+
if (box.gen === undefined)
|
|
34
|
+
box.gen = genOf(id);
|
|
35
|
+
// A section the world cannot answer must not leave the token it was taken for.
|
|
36
|
+
return Promise.resolve(keeper.countSection(id)).catch((failure) => release().then(() => Promise.reject(failure))).then((open) => {
|
|
37
|
+
const done = () => Promise.resolve(held === undefined ? keeper.countLeave(id) : undefined);
|
|
38
|
+
if (open !== true) {
|
|
39
|
+
// Stale (the world does not hold the token): the box is of a run that is over. Closed (it does, and a reset is draining): refused, and the
|
|
40
|
+
// box keeps its id so its own cleanup releases the token, which a reset that fails leaves in the count.
|
|
41
|
+
if (open === false && held !== undefined) {
|
|
42
|
+
box.stale = true;
|
|
43
|
+
box.id = undefined;
|
|
44
|
+
}
|
|
45
|
+
return done().then(open === "closed" ? closing : refused);
|
|
46
|
+
}
|
|
47
|
+
return f().finally(() => Promise.resolve(keeper.countSectionEnd(id)).then(done));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
/** A database whose every statement is a write section: the handler's `SqlClient`, the store, the journal and the identity run on it. */
|
|
53
|
+
export const fenced = (env, db) => {
|
|
54
|
+
if (WorldClock.declared(env).kind === "real")
|
|
55
|
+
return db;
|
|
56
|
+
const raws = new WeakMap();
|
|
57
|
+
const guard = (statement) => {
|
|
58
|
+
const proxy = new Proxy(statement, {
|
|
59
|
+
get: (target, key) => {
|
|
60
|
+
if (key === "bind")
|
|
61
|
+
return (...values) => guard(target.bind(...values));
|
|
62
|
+
if (key === "run" || key === "all" || key === "first" || key === "raw") {
|
|
63
|
+
const call = Reflect.get(target, key, target);
|
|
64
|
+
return (...args) => section(env, () => call.apply(target, args));
|
|
65
|
+
}
|
|
66
|
+
return Reflect.get(target, key, target);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
raws.set(proxy, statement);
|
|
70
|
+
return proxy;
|
|
71
|
+
};
|
|
72
|
+
// The database itself and a session of it (`withSession`) are the same door: a session's statements and batches are sections too.
|
|
73
|
+
const wrap = (target) => new Proxy(target, {
|
|
74
|
+
get: (self, key) => {
|
|
75
|
+
if (key === "prepare")
|
|
76
|
+
return (sql) => guard(self.prepare(sql));
|
|
77
|
+
if (key === "batch")
|
|
78
|
+
return (statements) => section(env, () => self.batch(statements.map((s) => raws.get(s) ?? s)));
|
|
79
|
+
if (key === "exec" && "exec" in self)
|
|
80
|
+
return (sql) => section(env, () => self.exec(sql));
|
|
81
|
+
if (key === "dump" && "dump" in self)
|
|
82
|
+
return () => section(env, () => self.dump());
|
|
83
|
+
if (key === "withSession" && "withSession" in self)
|
|
84
|
+
return (...args) => wrap(self.withSession(...args));
|
|
85
|
+
const value = Reflect.get(self, key, self);
|
|
86
|
+
return typeof value === "function" ? value.bind(self) : value;
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
return wrap(db);
|
|
90
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { AuthInstance } from "#modules/auth/types.js";
|
|
3
|
+
/** The world's front door, over its own SQLite storage. */
|
|
4
|
+
export declare const RESET_HEADER = "x-ortho-world";
|
|
5
|
+
export declare const frontDoor: (sql: SqlStorage, auth: AuthInstance, request: Request, nonce?: string) => Effect.Effect<Response>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { AuthD1 } from "#modules/auth/service.js";
|
|
3
|
+
const json = (body, status = 200) => new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
|
|
4
|
+
const strings = (v) => (Array.isArray(v) ? v.filter((n) => typeof n === "string") : []);
|
|
5
|
+
/** The world's front door, over its own SQLite storage. */
|
|
6
|
+
export const RESET_HEADER = "x-ortho-world";
|
|
7
|
+
export const frontDoor = (sql, auth, request, nonce) => Effect.gen(function* () {
|
|
8
|
+
const path = new URL(request.url).pathname;
|
|
9
|
+
if (path === "/_world/health")
|
|
10
|
+
return json({ ok: true, ...(nonce ? { nonce } : {}) });
|
|
11
|
+
if (path === "/_world/cast" && request.method === "POST") {
|
|
12
|
+
const body = (yield* Effect.promise(() => request.json().catch(() => ({}))));
|
|
13
|
+
const anonymous = new Set(strings(body.anonymous));
|
|
14
|
+
const cast = {};
|
|
15
|
+
for (const name of [...strings(body.names), ...anonymous]) {
|
|
16
|
+
const row = sql.exec("SELECT person, email, password FROM cast WHERE name = ?", name).toArray()[0];
|
|
17
|
+
const stored = row ? { email: row.email, password: row.password, ...(row.person ? { person: row.person } : {}) } : undefined;
|
|
18
|
+
const member = yield* AuthD1.castMember(auth, name, anonymous.has(name), stored);
|
|
19
|
+
sql.exec("INSERT OR REPLACE INTO cast (name, person, email, password) VALUES (?, ?, ?, ?)", name, member.person ?? null, member.email, member.password);
|
|
20
|
+
cast[name] = member;
|
|
21
|
+
}
|
|
22
|
+
return json(cast);
|
|
23
|
+
}
|
|
24
|
+
if (path === "/_world/credential" && request.method === "POST") {
|
|
25
|
+
// A credential for one cast member's way in, or for the system or a service: `{ name, via }`, `{ system: true }` or `{ service }`.
|
|
26
|
+
const body = (yield* Effect.promise(() => request.json().catch(() => ({}))));
|
|
27
|
+
if (body.system === true)
|
|
28
|
+
return json(yield* AuthD1.credential(auth, { kind: "system" }));
|
|
29
|
+
if (typeof body.service === "string")
|
|
30
|
+
return json(yield* AuthD1.credential(auth, { kind: "service", mount: body.service }));
|
|
31
|
+
const name = typeof body.name === "string" ? body.name : "";
|
|
32
|
+
const row = sql.exec("SELECT person, email, password FROM cast WHERE name = ?", name).toArray()[0];
|
|
33
|
+
if (!row?.person)
|
|
34
|
+
return json({ error: `${name || "no one"} is not a signed-up member of this world's cast` }, 404);
|
|
35
|
+
if (body.via === "session") {
|
|
36
|
+
const member = yield* AuthD1.castMember(auth, name, false, { email: row.email, password: row.password, person: row.person });
|
|
37
|
+
return json({ token: member.token });
|
|
38
|
+
}
|
|
39
|
+
if (body.via === "key" || body.via === "agent")
|
|
40
|
+
return json(yield* AuthD1.credential(auth, { kind: body.via, person: row.person }));
|
|
41
|
+
return json({ error: `a world mints no credential for the way in ${JSON.stringify(body.via ?? null)}` }, 400);
|
|
42
|
+
}
|
|
43
|
+
if (path === "/_world/reset" && request.method === "POST") {
|
|
44
|
+
if (nonce && request.headers.get(RESET_HEADER) !== nonce)
|
|
45
|
+
return json({ error: "not this world's reset" }, 403);
|
|
46
|
+
// The cast stays (a warm world's population); the Worker empties the databases around the people it names.
|
|
47
|
+
return json({ people: sql.exec("SELECT person FROM cast WHERE person IS NOT NULL").toArray().map((r) => r.person) });
|
|
48
|
+
}
|
|
49
|
+
return json({ error: "not a door the world has" }, 404);
|
|
50
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export interface Lease {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly created: number;
|
|
5
|
+
readonly expires: number;
|
|
6
|
+
readonly marks: Readonly<Record<string, number>>;
|
|
7
|
+
}
|
|
8
|
+
/** Every live world: not yet destroyed. */
|
|
9
|
+
export declare const live: (db: D1Database) => Effect.Effect<Lease[], never, never>;
|
|
10
|
+
/** Take the single-live slot atomically. A losing caller receives the owner from the same transaction. */
|
|
11
|
+
export declare const begin: (db: D1Database, world: {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly now: number;
|
|
14
|
+
readonly lifetimeMs: number;
|
|
15
|
+
}) => Effect.Effect<{
|
|
16
|
+
readonly kind: "created";
|
|
17
|
+
readonly lease: Lease;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "live";
|
|
20
|
+
readonly lease: Lease;
|
|
21
|
+
} | {
|
|
22
|
+
readonly lease?: never;
|
|
23
|
+
readonly kind: "used";
|
|
24
|
+
}, never, never>;
|
|
25
|
+
/**
|
|
26
|
+
* Delete what the world made (every row above its marks) and mark it ended with why. `false` when it was already
|
|
27
|
+
* ended, so the alarm, a reap and an explicit destroy can all arrive and only the first counts.
|
|
28
|
+
*/
|
|
29
|
+
export declare const end: (db: D1Database, id: string, reason: "destroyed" | "expired", now: number) => Effect.Effect<boolean, never, never>;
|
|
30
|
+
/** Worlds whose lifetime has run out and that nothing has destroyed yet. */
|
|
31
|
+
export declare const overdue: (db: D1Database, now: number) => Effect.Effect<Lease[], never, never>;
|
|
32
|
+
/** How many worlds ended by expiry that nobody has been told about, now told: `reaped <n>` reports each once. */
|
|
33
|
+
export declare const reportReaped: (db: D1Database) => Effect.Effect<number, never, never>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// The worlds a long-lived environment holds: one row each in `_worlds`, with the high-water mark of every table taken
|
|
2
|
+
// when the world was made. A world's data is what is above those marks, so destroying it deletes exactly that (D3 #50).
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
const CREATE = `CREATE TABLE IF NOT EXISTS "_worlds" ("id" TEXT PRIMARY KEY, "created" INTEGER NOT NULL, "expires" INTEGER NOT NULL, "marks" TEXT NOT NULL, "ended" INTEGER, "reason" TEXT, "reported" INTEGER NOT NULL DEFAULT 0)`;
|
|
5
|
+
const ONE_LIVE = `CREATE UNIQUE INDEX IF NOT EXISTS "_worlds_one_live" ON "_worlds" ((1)) WHERE "ended" IS NULL`;
|
|
6
|
+
/** The tables a world fills: everything but SQLite's, Cloudflare's, the migrations' and this registry. */
|
|
7
|
+
const WORLD_TABLES = `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite\\_%' ESCAPE '\\' AND name NOT LIKE '\\_cf\\_%' ESCAPE '\\' AND name NOT IN ('d1_migrations', '_worlds')`;
|
|
8
|
+
// Additive only: an already-corrupt registry fails closed instead of choosing a world or deleting its data.
|
|
9
|
+
const ready = (db) => Effect.promise(() => db.batch([db.prepare(CREATE), db.prepare(ONE_LIVE)]));
|
|
10
|
+
const toLease = (row) => ({ id: row.id, created: row.created, expires: row.expires, marks: JSON.parse(row.marks) });
|
|
11
|
+
/** Every live world: not yet destroyed. */
|
|
12
|
+
export const live = (db) => Effect.gen(function* () {
|
|
13
|
+
yield* ready(db);
|
|
14
|
+
const { results } = yield* Effect.promise(() => db.prepare(`SELECT * FROM "_worlds" WHERE "ended" IS NULL ORDER BY "created"`).all());
|
|
15
|
+
return results.map(toLease);
|
|
16
|
+
});
|
|
17
|
+
/** Bounded JSON functions keep the snapshot in one INSERT without a compound SELECT. */
|
|
18
|
+
const markExpression = (tables) => {
|
|
19
|
+
let parts = [];
|
|
20
|
+
for (let i = 0; i < tables.length; i += 8) {
|
|
21
|
+
const fields = tables.slice(i, i + 8).flatMap(({ name }) => [
|
|
22
|
+
`'${name.replaceAll("'", "''")}'`, `(SELECT COALESCE(MAX(rowid), 0) FROM "${name.replaceAll('"', '""')}")`,
|
|
23
|
+
]);
|
|
24
|
+
parts.push(`json_object(${fields.join(", ")})`);
|
|
25
|
+
}
|
|
26
|
+
while (parts.length > 1) {
|
|
27
|
+
const next = [];
|
|
28
|
+
for (let i = 0; i < parts.length; i += 2)
|
|
29
|
+
next.push(parts[i + 1] ? `json_patch(${parts[i]}, ${parts[i + 1]})` : parts[i]);
|
|
30
|
+
parts = next;
|
|
31
|
+
}
|
|
32
|
+
return parts[0] ?? "'{}'";
|
|
33
|
+
};
|
|
34
|
+
/** Take the single-live slot atomically. A losing caller receives the owner from the same transaction. */
|
|
35
|
+
export const begin = (db, world) => Effect.gen(function* () {
|
|
36
|
+
yield* ready(db);
|
|
37
|
+
const { results: tables } = yield* Effect.promise(() => db.prepare(WORLD_TABLES).all());
|
|
38
|
+
// Marks are evaluated inside the guarded INSERT, never before another world's teardown can commit.
|
|
39
|
+
const marks = markExpression(tables);
|
|
40
|
+
const [inserted, held] = yield* Effect.promise(() => db.batch([
|
|
41
|
+
db.prepare(`INSERT INTO "_worlds" ("id", "created", "expires", "marks")
|
|
42
|
+
SELECT ?, ?, ?, ${marks} WHERE NOT EXISTS (SELECT 1 FROM "_worlds" WHERE "ended" IS NULL)
|
|
43
|
+
ON CONFLICT ("id") DO NOTHING`).bind(world.id, world.now, world.now + world.lifetimeMs),
|
|
44
|
+
db.prepare(`SELECT * FROM "_worlds" WHERE "ended" IS NULL ORDER BY "created" LIMIT 1`),
|
|
45
|
+
]));
|
|
46
|
+
const owner = held.results[0];
|
|
47
|
+
if (inserted.meta.changes > 0)
|
|
48
|
+
return { kind: "created", lease: toLease(owner) };
|
|
49
|
+
return owner ? { kind: "live", lease: toLease(owner) } : { kind: "used" };
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Delete what the world made (every row above its marks) and mark it ended with why. `false` when it was already
|
|
53
|
+
* ended, so the alarm, a reap and an explicit destroy can all arrive and only the first counts.
|
|
54
|
+
*/
|
|
55
|
+
export const end = (db, id, reason, now) => Effect.gen(function* () {
|
|
56
|
+
yield* ready(db);
|
|
57
|
+
const row = yield* Effect.promise(() => db.prepare(`SELECT * FROM "_worlds" WHERE "id" = ?`).bind(id).first());
|
|
58
|
+
if (!row || row.ended !== null)
|
|
59
|
+
return false;
|
|
60
|
+
const marks = toLease(row).marks;
|
|
61
|
+
// A table made since (Better Auth makes its own on first use) was empty when the world began: its mark is 0.
|
|
62
|
+
const { results: tables } = yield* Effect.promise(() => db.prepare(WORLD_TABLES).all());
|
|
63
|
+
const changes = yield* Effect.promise(() => db.batch([
|
|
64
|
+
db.prepare("PRAGMA defer_foreign_keys = on"),
|
|
65
|
+
// The reads above may interleave. Every deletion and the ending transition share this transaction guard.
|
|
66
|
+
...tables.map((t) => db.prepare(`DELETE FROM "${t.name.replaceAll('"', '""')}" WHERE rowid > ?
|
|
67
|
+
AND EXISTS (SELECT 1 FROM "_worlds" WHERE "id" = ? AND "ended" IS NULL)`).bind(marks[t.name] ?? 0, id)),
|
|
68
|
+
db.prepare(`UPDATE "_worlds" SET "ended" = ?, "reason" = ? WHERE "id" = ? AND "ended" IS NULL`).bind(now, reason, id),
|
|
69
|
+
]));
|
|
70
|
+
return changes.at(-1).meta.changes > 0;
|
|
71
|
+
});
|
|
72
|
+
/** Worlds whose lifetime has run out and that nothing has destroyed yet. */
|
|
73
|
+
export const overdue = (db, now) => live(db).pipe(Effect.map((all) => all.filter((l) => l.expires <= now)));
|
|
74
|
+
/** How many worlds ended by expiry that nobody has been told about, now told: `reaped <n>` reports each once. */
|
|
75
|
+
export const reportReaped = (db) => Effect.gen(function* () {
|
|
76
|
+
yield* ready(db);
|
|
77
|
+
const done = yield* Effect.promise(() => db.prepare(`UPDATE "_worlds" SET "reported" = 1 WHERE "reason" = 'expired' AND "reported" = 0`).run());
|
|
78
|
+
return done.meta.changes;
|
|
79
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { WorldHost } from "../types.ts";
|
|
3
|
+
type Where = Pick<WorldHost, "db" | "stores">;
|
|
4
|
+
/** Empty every table of the default database and of each store; `people` are the cast's persons, whose identity rows stay. */
|
|
5
|
+
export declare const resetDatabases: ({ db, stores }: Where, people: ReadonlyArray<string>) => Effect.Effect<void, never, never>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// `POST /_world/reset`: empty the world's databases (the default and each declared store), so a warm world (`ortho dev`) starts a
|
|
2
|
+
// prove run with none of the last run's records (ST1.24). The tables stay; migrations' own bookkeeping is kept. The world's cast
|
|
3
|
+
// is kept too, with the people it signed up: they are the world's population, not a run's records, and signing one up again
|
|
4
|
+
// costs a password hash each (a cast of twenty is three seconds). Whatever else a person had, sessions and keys and the rest of
|
|
5
|
+
// the identity tables included, goes. The cast is the Durable Object's own: its front door answers who is in it.
|
|
6
|
+
import { Effect } from "effect";
|
|
7
|
+
const TABLES = "SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_cf_%' AND name <> 'd1_migrations'";
|
|
8
|
+
/** The identity tables whose rows of the cast's people survive a reset, and the column holding the person. */
|
|
9
|
+
const KEPT = { auth_user: "id", auth_account: "userId" };
|
|
10
|
+
const emptied = (db, people) => Effect.gen(function* () {
|
|
11
|
+
const found = yield* Effect.promise(() => db.prepare(TABLES).all());
|
|
12
|
+
const names = found.results.map((r) => r.name);
|
|
13
|
+
if (names.length === 0)
|
|
14
|
+
return;
|
|
15
|
+
const keep = JSON.stringify(people);
|
|
16
|
+
yield* Effect.promise(() => db.batch([
|
|
17
|
+
db.prepare("PRAGMA defer_foreign_keys = true"),
|
|
18
|
+
...names.map((name) => KEPT[name] === undefined
|
|
19
|
+
? db.prepare(`DELETE FROM "${name}"`)
|
|
20
|
+
: db.prepare(`DELETE FROM "${name}" WHERE "${KEPT[name]}" NOT IN (SELECT value FROM json_each(?))`).bind(keep)),
|
|
21
|
+
]));
|
|
22
|
+
});
|
|
23
|
+
/** Empty every table of the default database and of each store; `people` are the cast's persons, whose identity rows stay. */
|
|
24
|
+
export const resetDatabases = ({ db, stores = [] }, people) => Effect.forEach([db, ...stores.map((s) => s.db)], (d) => emptied(d, people), { discard: true });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import { type Busy, type DurableTimers, type Timers } from "@orthograph/language-effect";
|
|
3
|
+
import type { WorldWakes } from "#modules/timers/types.js";
|
|
4
|
+
import type { EntryEnv } from "../types.ts";
|
|
5
|
+
/**
|
|
6
|
+
* The one way a request takes up the world's clock after it has been without it: it asks the world for its source now and points its
|
|
7
|
+
* own cell at it. A request parked at day 0 whose wait ends at day +1 reads day +1, whichever side of the race won. A real world
|
|
8
|
+
* has no source to ask for.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resumed: (env: EntryEnv) => Effect.Effect<void>;
|
|
11
|
+
export declare const work: (env: EntryEnv, kinds?: WorldWakes) => Layer.Layer<Busy | Timers | DurableTimers>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Counted work and timers for a process that is not the world's Durable Object (M8.07): the generated Worker's runtime.
|
|
2
|
+
// Each token it takes is reported to the world's count, each wait is a row in the world's table, and a sleeper that wakes
|
|
3
|
+
// reads the instant the world fired it at, so a request that outlives a move of the clock sees the move.
|
|
4
|
+
import { Effect, Layer } from "effect";
|
|
5
|
+
import { BusyReporting, TimersWorld, WorldCount, WorldTable, wakesByKind } from "@orthograph/language-effect";
|
|
6
|
+
import { WorldClock } from "#modules/clock/service.js";
|
|
7
|
+
import { keeperOf } from "./entry.js";
|
|
8
|
+
/** Each call finds the world's stub afresh: a stub lives only as long as the request that made it. */
|
|
9
|
+
const call = (env, f) => Effect.promise(() => keeperOf(env).then(f));
|
|
10
|
+
/**
|
|
11
|
+
* The one way a request takes up the world's clock after it has been without it: it asks the world for its source now and points its
|
|
12
|
+
* own cell at it. A request parked at day 0 whose wait ends at day +1 reads day +1, whichever side of the race won. A real world
|
|
13
|
+
* has no source to ask for.
|
|
14
|
+
*/
|
|
15
|
+
export const resumed = (env) => WorldClock.declared(env).kind === "real"
|
|
16
|
+
? Effect.void
|
|
17
|
+
: call(env, (keeper) => keeper.source()).pipe(Effect.flatMap((source) => Effect.sync(() => void (source !== undefined && WorldClock.refresh(source)))));
|
|
18
|
+
export const work = (env, kinds) => {
|
|
19
|
+
// A real world has no controller to tell: nobody waits for it to be quiet.
|
|
20
|
+
const counted = WorldClock.declared(env).kind !== "real";
|
|
21
|
+
const count = Layer.succeed(WorldCount, WorldCount.of({
|
|
22
|
+
// Tokens have identity: the id the world gave carries its generation, and releases exactly that token.
|
|
23
|
+
enter: (owner) => (counted ? call(env, (keeper) => keeper.countEnter(owner)) : Effect.succeed("real")),
|
|
24
|
+
leave: (id) => (counted ? call(env, (keeper) => keeper.countLeave(id)) : Effect.void),
|
|
25
|
+
name: (id, owner) => (counted ? call(env, (keeper) => keeper.countName(id, owner)) : Effect.void),
|
|
26
|
+
// A box that holds an id the world no longer knows (a reset since) takes a fresh token.
|
|
27
|
+
valid: (id) => (counted ? call(env, (keeper) => keeper.countHas(id)) : Effect.succeed(true)),
|
|
28
|
+
// A write section: the world holds the request's token, and waits for the section to end before it wipes anything.
|
|
29
|
+
section: (id) => (counted ? call(env, (keeper) => keeper.countSection(id)) : Effect.succeed(true)),
|
|
30
|
+
sectionEnd: (id) => (counted ? call(env, (keeper) => keeper.countSectionEnd(id)) : Effect.void),
|
|
31
|
+
// The box of the request this fiber runs in, taken at its entry: the work counts under it instead of taking another token.
|
|
32
|
+
request: Effect.sync(() => WorldClock.box()),
|
|
33
|
+
}));
|
|
34
|
+
const table = Layer.succeed(WorldTable, WorldTable.of({
|
|
35
|
+
// A call carries the request's own token: one the world no longer holds is from a run a reset ended, and is refused.
|
|
36
|
+
add: (owner, name, at, holder) => Effect.suspend(() => {
|
|
37
|
+
const box = WorldClock.box();
|
|
38
|
+
// A request the world no longer holds is stale: it sets nothing in the new run's table, before any call is made.
|
|
39
|
+
if (box?.stale === true)
|
|
40
|
+
return Effect.interrupt;
|
|
41
|
+
const token = box?.id;
|
|
42
|
+
return call(env, (keeper) => keeper.timerAdd(owner, name, at, holder, token));
|
|
43
|
+
}),
|
|
44
|
+
// The wake is the instant the world fired the row at: this request's own clock is pointed at it before the code goes on.
|
|
45
|
+
// A row a reset forgot ends its sleeper: the request belongs to a run that is over, so it is interrupted, never resumed to commit into
|
|
46
|
+
// what the reset is wiping. The sleep's own cleanup (reclaim, acknowledge) still runs.
|
|
47
|
+
wait: (id) => call(env, (keeper) => keeper.timerWait(id)).pipe(Effect.flatMap(({ source, forgotten }) => forgotten ? Effect.interrupt : Effect.sync(() => void (source !== undefined && WorldClock.refresh(source))))),
|
|
48
|
+
// Giving a row up is where a request that parked takes its token back: it resumes on the world's clock as it is now.
|
|
49
|
+
cancel: (id) => call(env, (keeper) => keeper.timerCancel(id)).pipe(Effect.tap(() => resumed(env))),
|
|
50
|
+
sleeping: call(env, (keeper) => keeper.timersSleeping()),
|
|
51
|
+
set: (at, owner, name, wake) => Effect.suspend(() => {
|
|
52
|
+
const box = WorldClock.box();
|
|
53
|
+
if (box?.stale === true)
|
|
54
|
+
return Effect.interrupt;
|
|
55
|
+
const token = box?.id;
|
|
56
|
+
return call(env, (keeper) => keeper.timerSet(at, owner, name, wake, token));
|
|
57
|
+
}),
|
|
58
|
+
// A stale request must not delete a row of the new run that has the same owner and name.
|
|
59
|
+
clear: (owner, name) => Effect.suspend(() => {
|
|
60
|
+
const box = WorldClock.box();
|
|
61
|
+
if (box?.stale === true)
|
|
62
|
+
return Effect.interrupt;
|
|
63
|
+
const token = box?.id;
|
|
64
|
+
return call(env, (keeper) => keeper.timerClear(owner, name, token));
|
|
65
|
+
}),
|
|
66
|
+
durable: call(env, (keeper) => keeper.timersDurable()),
|
|
67
|
+
}));
|
|
68
|
+
const busy = BusyReporting.pipe(Layer.provide(count));
|
|
69
|
+
// One Busy for the handlers and the timers alike: the layer is built once and shared.
|
|
70
|
+
// With a wake route a durable timer can be set; without one setting it is a defect (M8-timers-shape rule 6).
|
|
71
|
+
const wakes = kinds === undefined ? Layer.empty : wakesByKind(kinds);
|
|
72
|
+
return TimersWorld.pipe(Layer.provide(table), Layer.provide(wakes), Layer.provideMerge(busy));
|
|
73
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export interface Leases {
|
|
3
|
+
readonly worlds: DurableObjectNamespace;
|
|
4
|
+
readonly db: D1Database;
|
|
5
|
+
}
|
|
6
|
+
/** `/_world/worlds`: the environment's worlds. */
|
|
7
|
+
export declare const worldsDoor: (l: Leases, request: Request) => Effect.Effect<Response>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// The routes a long-lived environment answers for its worlds: make one with a lifetime, list them, destroy one, reap
|
|
2
|
+
// the overdue. Creation and teardown commit through D1 guards: one live lease, and only its first ending deletes data.
|
|
3
|
+
import { Clock, Effect } from "effect";
|
|
4
|
+
import { begin, live, overdue, reportReaped } from "./leases.js";
|
|
5
|
+
const json = (body, status = 200) => new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
|
|
6
|
+
const ID = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
7
|
+
const tell = (l, id, path, body) => Effect.promise(() => l.worlds.get(l.worlds.idFromName(id)).fetch(new Request(`http://world${path}`, { method: "POST", body: JSON.stringify({ id, ...body }) })));
|
|
8
|
+
/** Destroy every world past its lifetime, and say how many were reaped since someone last asked. */
|
|
9
|
+
const reap = (l) => Effect.gen(function* () {
|
|
10
|
+
const now = yield* Clock.currentTimeMillis;
|
|
11
|
+
for (const world of yield* overdue(l.db, now))
|
|
12
|
+
yield* tell(l, world.id, "/_world/end", { reason: "expired" });
|
|
13
|
+
return yield* reportReaped(l.db);
|
|
14
|
+
});
|
|
15
|
+
const create = (l, request) => Effect.gen(function* () {
|
|
16
|
+
const body = (yield* Effect.promise(() => request.json().catch(() => ({}))));
|
|
17
|
+
if (typeof body.id !== "string" || !ID.test(body.id))
|
|
18
|
+
return json({ error: "id must be a lowercase name" }, 400);
|
|
19
|
+
if (typeof body.lifetimeMs !== "number" || !(body.lifetimeMs > 0))
|
|
20
|
+
return json({ error: "lifetimeMs must be a positive number" }, 400);
|
|
21
|
+
// A world past its lifetime is not in the way. (Nothing reports it: this is not the reap a person asked for.)
|
|
22
|
+
for (const world of yield* overdue(l.db, yield* Clock.currentTimeMillis))
|
|
23
|
+
yield* tell(l, world.id, "/_world/end", { reason: "expired" });
|
|
24
|
+
const begun = yield* begin(l.db, { id: body.id, now: yield* Clock.currentTimeMillis, lifetimeMs: body.lifetimeMs });
|
|
25
|
+
if (begun.kind === "live")
|
|
26
|
+
return json({ error: "WorldLive", id: begun.lease.id, expires: begun.lease.expires }, 409);
|
|
27
|
+
if (begun.kind === "used")
|
|
28
|
+
return json({ error: "WorldUsed", id: body.id }, 409);
|
|
29
|
+
yield* tell(l, begun.lease.id, "/_world/arm", { id: begun.lease.id, expires: begun.lease.expires });
|
|
30
|
+
return json({ id: begun.lease.id, expires: begun.lease.expires }, 201);
|
|
31
|
+
});
|
|
32
|
+
/** `/_world/worlds`: the environment's worlds. */
|
|
33
|
+
export const worldsDoor = (l, request) => Effect.gen(function* () {
|
|
34
|
+
const { pathname } = new URL(request.url);
|
|
35
|
+
if (pathname === "/_world/worlds" && request.method === "POST")
|
|
36
|
+
return yield* create(l, request);
|
|
37
|
+
if (pathname === "/_world/worlds" && request.method === "GET") {
|
|
38
|
+
return json({ worlds: (yield* live(l.db)).map(({ id, created, expires }) => ({ id, created, expires })) });
|
|
39
|
+
}
|
|
40
|
+
if (pathname === "/_world/worlds/reap" && request.method === "POST")
|
|
41
|
+
return json({ reaped: yield* reap(l) });
|
|
42
|
+
const one = /^\/_world\/worlds\/([a-z0-9-]+)$/.exec(pathname);
|
|
43
|
+
if (one && request.method === "DELETE") {
|
|
44
|
+
yield* tell(l, one[1], "/_world/end", { reason: "destroyed" });
|
|
45
|
+
return json({ destroyed: one[1] });
|
|
46
|
+
}
|
|
47
|
+
return json({ error: "not a door the world has" }, 404);
|
|
48
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { DurableObject } from "cloudflare:workers";
|
|
2
|
+
import type { WorldEnv, WorldHost } from "./types.ts";
|
|
3
|
+
import type { ClockSource } from "#modules/clock/types.js";
|
|
4
|
+
import type { WorldTimersRpc, WorldWakes } from "#modules/timers/types.js";
|
|
5
|
+
import { entry, within, withinNow } from "./internal/entry.ts";
|
|
6
|
+
import { fenced, section } from "./internal/fence.ts";
|
|
7
|
+
import { work } from "./internal/work.ts";
|
|
8
|
+
/**
|
|
9
|
+
* The world's Durable Object. Export it from the Worker's entry; bind it as `WORLD`. In a long-lived environment each
|
|
10
|
+
* world is its own instance, named by the world's id: it holds the cast, and an alarm at the world's expiry that
|
|
11
|
+
* destroys it (D3 #7, #50). Under `ortho dev` and a local prove there is the one, named `world`, and no alarm.
|
|
12
|
+
*/
|
|
13
|
+
export declare class World extends DurableObject<WorldEnv> {
|
|
14
|
+
private readonly auth;
|
|
15
|
+
/** The world's instant (M8.06): the wall clock, or the one it keeps in its own storage. */
|
|
16
|
+
private readonly clock;
|
|
17
|
+
/** The world's timer table and count of work in flight (M8.07). */
|
|
18
|
+
private readonly timers;
|
|
19
|
+
constructor(ctx: DurableObjectState, env: WorldEnv);
|
|
20
|
+
/**
|
|
21
|
+
* Which code wakes each kind of durable timer (M8.07). The generated Worker for a blueprint with a stepped or scaled clock
|
|
22
|
+
* extends this class and answers its wake map, empty until a feature registers a kind; no map, no route, and a due row fails.
|
|
23
|
+
*/
|
|
24
|
+
protected wakeKinds(): WorldWakes | undefined;
|
|
25
|
+
fetch(request: Request): Promise<Response>;
|
|
26
|
+
/** The world's instant now. */
|
|
27
|
+
now(): number;
|
|
28
|
+
/** An entry begins (M8.07): the world takes a token for it under `owner` (`entry:<path>`) and answers it with the source its request reads time from. */
|
|
29
|
+
begin(owner: string): {
|
|
30
|
+
readonly source: ClockSource | undefined;
|
|
31
|
+
readonly token: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
/** What to read the world's time from. Every other entry (the Worker, the actors) asks this over RPC, once, to run in this world's time. */
|
|
34
|
+
source(): ClockSource | undefined;
|
|
35
|
+
private inTime;
|
|
36
|
+
/** Remember the world's id and wake at its expiry. */
|
|
37
|
+
private arm;
|
|
38
|
+
/**
|
|
39
|
+
* The one alarm a Durable Object has: the world's lifetime, or in a real world the earliest timer, whichever is first.
|
|
40
|
+
* A stepped or scaled world sets no alarm for timers: its controller fires them (M8.07).
|
|
41
|
+
*/
|
|
42
|
+
private schedule;
|
|
43
|
+
/** Delete what the world made, then everything the world itself holds, alarm included. */
|
|
44
|
+
private finish;
|
|
45
|
+
/** The world's own lifetime: real time, never the world's (K23 section 1), so it is the one entry that is not wrapped. */
|
|
46
|
+
alarm(): Promise<void>;
|
|
47
|
+
countEnter(owner: string): string;
|
|
48
|
+
countLeave(id: string): void;
|
|
49
|
+
countName(id: string, owner: string): void;
|
|
50
|
+
countHas(id: string): boolean;
|
|
51
|
+
countSection(id: string): boolean | "closed";
|
|
52
|
+
countSectionEnd(id: string): void;
|
|
53
|
+
timerAdd(...args: Parameters<WorldTimersRpc["timerAdd"]>): number;
|
|
54
|
+
timerWait(id: number): ReturnType<WorldTimersRpc["timerWait"]>;
|
|
55
|
+
timerCancel(id: number): void;
|
|
56
|
+
timerSet(...args: Parameters<WorldTimersRpc["timerSet"]>): number;
|
|
57
|
+
timerClear(...args: Parameters<WorldTimersRpc["timerClear"]>): boolean;
|
|
58
|
+
timersSleeping(): ReturnType<WorldTimersRpc["timersSleeping"]>;
|
|
59
|
+
timersDurable(): ReturnType<WorldTimersRpc["timersDurable"]>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Every entry that runs app code wraps itself in its world's time (M8.06). `entry` wraps a Worker's `fetch`, `scheduled`
|
|
63
|
+
* and `queue`; `within` wraps any other promise-returning entry (a Workflows step), and `withinNow` an RPC method that
|
|
64
|
+
* answers at once. A real world runs each as it is.
|
|
65
|
+
*/
|
|
66
|
+
export declare const WorldEntry: {
|
|
67
|
+
entry: typeof entry;
|
|
68
|
+
within: typeof within;
|
|
69
|
+
withinNow: typeof withinNow;
|
|
70
|
+
work: typeof work;
|
|
71
|
+
fenced: typeof fenced;
|
|
72
|
+
section: typeof section;
|
|
73
|
+
};
|
|
74
|
+
export type { WorldWakes };
|
|
75
|
+
/**
|
|
76
|
+
* A `/_world/*` request. Facts come straight from the database. `/_world/worlds` is the environment's registry of worlds,
|
|
77
|
+
* which only an environment that hosts worlds (`leases`) has. Anything else goes to the live world's own Durable Object
|
|
78
|
+
* in such an environment, and otherwise to the one world of this deployment.
|
|
79
|
+
*/
|
|
80
|
+
export declare const toWorld: (world: WorldHost, request: Request) => Promise<Response>;
|