@base44/functions-compiler 0.1.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/README.md +137 -0
- package/lib/dist/activation-shim.mjs +237 -0
- package/lib/dist/actor.mjs +1129 -0
- package/lib/dist/deno-shim.mjs +2347 -0
- package/lib/src/actor-compat.d.ts +24 -0
- package/lib/src/actor-compat.js +302 -0
- package/lib/src/actor-compat.js.map +1 -0
- package/lib/src/bundler.d.ts +51 -0
- package/lib/src/bundler.js +321 -0
- package/lib/src/bundler.js.map +1 -0
- package/lib/src/contracts.d.ts +108 -0
- package/lib/src/contracts.js +39 -0
- package/lib/src/contracts.js.map +1 -0
- package/lib/src/deno-bundle.d.ts +30 -0
- package/lib/src/deno-bundle.js +146 -0
- package/lib/src/deno-bundle.js.map +1 -0
- package/lib/src/errors.d.ts +16 -0
- package/lib/src/errors.js +11 -0
- package/lib/src/errors.js.map +1 -0
- package/lib/src/esbuild/deno-resolver.d.ts +26 -0
- package/lib/src/esbuild/deno-resolver.js +436 -0
- package/lib/src/esbuild/deno-resolver.js.map +1 -0
- package/lib/src/esbuild/node-builtin-require.d.ts +2 -0
- package/lib/src/esbuild/node-builtin-require.js +33 -0
- package/lib/src/esbuild/node-builtin-require.js.map +1 -0
- package/lib/src/esbuild/private-data-sources-virtual.d.ts +3 -0
- package/lib/src/esbuild/private-data-sources-virtual.js +127 -0
- package/lib/src/esbuild/private-data-sources-virtual.js.map +1 -0
- package/lib/src/esbuild/runtime-context-virtual.d.ts +3 -0
- package/lib/src/esbuild/runtime-context-virtual.js +42 -0
- package/lib/src/esbuild/runtime-context-virtual.js.map +1 -0
- package/lib/src/esbuild/runtime-virtual.d.ts +2 -0
- package/lib/src/esbuild/runtime-virtual.js +52 -0
- package/lib/src/esbuild/runtime-virtual.js.map +1 -0
- package/lib/src/esbuild/user-files.d.ts +15 -0
- package/lib/src/esbuild/user-files.js +73 -0
- package/lib/src/esbuild/user-files.js.map +1 -0
- package/lib/src/fetch-guard.d.ts +26 -0
- package/lib/src/fetch-guard.js +67 -0
- package/lib/src/fetch-guard.js.map +1 -0
- package/lib/src/index.d.ts +12 -0
- package/lib/src/index.js +11 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/log.d.ts +7 -0
- package/lib/src/log.js +39 -0
- package/lib/src/log.js.map +1 -0
- package/lib/src/private-data-sources/build-http.ts +51 -0
- package/lib/src/private-data-sources/elasticsearch.ts +8 -0
- package/lib/src/private-data-sources/http-url.ts +23 -0
- package/lib/src/private-data-sources/http.ts +6 -0
- package/lib/src/private-data-sources/hyperdrive.ts +48 -0
- package/lib/src/private-data-sources/ioredis-adapter.ts +229 -0
- package/lib/src/private-data-sources/manifest.ts +150 -0
- package/lib/src/private-data-sources/mariadb.ts +8 -0
- package/lib/src/private-data-sources/mongodb.ts +70 -0
- package/lib/src/private-data-sources/mysql.ts +8 -0
- package/lib/src/private-data-sources/node-net-adapter.ts +244 -0
- package/lib/src/private-data-sources/postgres.ts +8 -0
- package/lib/src/private-data-sources/redis-auth.ts +83 -0
- package/lib/src/private-data-sources/redis.ts +47 -0
- package/lib/src/private-data-sources/runtime-environment.ts +4 -0
- package/lib/src/private-data-sources/runtime-manifest-store.ts +32 -0
- package/lib/src/private-data-sources/sqlserver.ts +22 -0
- package/lib/src/private-data-sources/tcp.ts +86 -0
- package/lib/src/private-data-sources/tedious-adapter.ts +67 -0
- package/lib/src/private-data-sources/types.ts +29 -0
- package/lib/src/runtime/index.ts +30 -0
- package/lib/src/runtime-context.ts +29 -0
- package/lib/src/static-egress-marker.d.ts +1 -0
- package/lib/src/static-egress-marker.js +7 -0
- package/lib/src/static-egress-marker.js.map +1 -0
- package/lib/src/telemetry.d.ts +32 -0
- package/lib/src/telemetry.js +84 -0
- package/lib/src/telemetry.js.map +1 -0
- package/lib/src/tracing.d.ts +9 -0
- package/lib/src/tracing.js +21 -0
- package/lib/src/tracing.js.map +1 -0
- package/lib/src/worker-entry.d.ts +36 -0
- package/lib/src/worker-entry.js +320 -0
- package/lib/src/worker-entry.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FOLDER is the actor's identity: an entry at base44/actors/<Name>/entry.ts
|
|
3
|
+
* IS an actor named <Name> — no source inspection. The generated DO wrapper
|
|
4
|
+
* re-exports the entry's DEFAULT export under the folder name, so the user's
|
|
5
|
+
* class name is cosmetic (a missing default export fails the esbuild compile).
|
|
6
|
+
* A generated prelude installs the shared request-scoped runtime before the
|
|
7
|
+
* user module is evaluated.
|
|
8
|
+
*/
|
|
9
|
+
export interface ActorCompat {
|
|
10
|
+
/** New entry filename (the generated DO wrapper). */
|
|
11
|
+
entry: string;
|
|
12
|
+
/** Files dict with the generated DO wrapper added (user source unchanged). */
|
|
13
|
+
files: Record<string, string>;
|
|
14
|
+
/** PascalCase class name, e.g. "GameRoom". */
|
|
15
|
+
handlerName: string;
|
|
16
|
+
/** Exported DO class name, same as handlerName. */
|
|
17
|
+
doClassName: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* If the entry is a canonical actor path (the folder is the identity), return
|
|
21
|
+
* a bundle input with the partyserver DO entry wrapper generated. Returns
|
|
22
|
+
* `null` for normal (non-realtime) functions.
|
|
23
|
+
*/
|
|
24
|
+
export declare function applyActorCompat(entry: string, files: Record<string, string>): ActorCompat | null;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FOLDER is the actor's identity: an entry at base44/actors/<Name>/entry.ts
|
|
3
|
+
* IS an actor named <Name> — no source inspection. The generated DO wrapper
|
|
4
|
+
* re-exports the entry's DEFAULT export under the folder name, so the user's
|
|
5
|
+
* class name is cosmetic (a missing default export fails the esbuild compile).
|
|
6
|
+
* A generated prelude installs the shared request-scoped runtime before the
|
|
7
|
+
* user module is evaluated.
|
|
8
|
+
*/
|
|
9
|
+
import { RUNTIME_CONTEXT_SPECIFIER } from "./esbuild/runtime-context-virtual.js";
|
|
10
|
+
import { assertNoReservedFilenames, CONSOLE_PATCH, SHIM_FILENAME, workerRuntimeFiles, } from "./worker-entry.js";
|
|
11
|
+
const ACTOR_ENTRY_FILENAME = "__base44_actor_entry.mjs";
|
|
12
|
+
const ACTOR_PRELUDE_FILENAME = "__base44_actor_prelude.mjs";
|
|
13
|
+
const ACTOR_AUTH_FILENAME = "__base44_actor_auth.mjs";
|
|
14
|
+
const ACTORS_PREFIX = "base44/actors/";
|
|
15
|
+
const ENTRY_SUFFIX = "/entry.ts";
|
|
16
|
+
/** The actor (folder) name for a canonical entry path, else null. */
|
|
17
|
+
function actorNameFromEntry(entry) {
|
|
18
|
+
if (!entry.startsWith(ACTORS_PREFIX) || !entry.endsWith(ENTRY_SUFFIX))
|
|
19
|
+
return null;
|
|
20
|
+
const name = entry.slice(ACTORS_PREFIX.length, -ENTRY_SUFFIX.length);
|
|
21
|
+
return name && !name.includes("/") ? name : null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* If the entry is a canonical actor path (the folder is the identity), return
|
|
25
|
+
* a bundle input with the partyserver DO entry wrapper generated. Returns
|
|
26
|
+
* `null` for normal (non-realtime) functions.
|
|
27
|
+
*/
|
|
28
|
+
export function applyActorCompat(entry, files) {
|
|
29
|
+
const actorName = actorNameFromEntry(entry);
|
|
30
|
+
// Key presence, not truthiness: an EMPTY canonical entry is still an actor —
|
|
31
|
+
// falling through would deploy a plain HTTP Worker under the actor identity.
|
|
32
|
+
// The wrapper's default-export import fails the bundle loudly instead.
|
|
33
|
+
if (!actorName || files[entry] === undefined)
|
|
34
|
+
return null;
|
|
35
|
+
// Actor bundles bypass prepareFunction(), so enforce the same complete
|
|
36
|
+
// generated-filename reservation before adding the wrapper and runtime shim.
|
|
37
|
+
assertNoReservedFilenames(files);
|
|
38
|
+
if (ACTOR_PRELUDE_FILENAME in files) {
|
|
39
|
+
throw new Error(`Reserved filename "${ACTOR_PRELUDE_FILENAME}" in actor bundle — ` +
|
|
40
|
+
"it is generated by the bundler. Rename the file.");
|
|
41
|
+
}
|
|
42
|
+
if (ACTOR_AUTH_FILENAME in files) {
|
|
43
|
+
throw new Error(`Reserved filename "${ACTOR_AUTH_FILENAME}" in actor bundle — ` +
|
|
44
|
+
"it is generated by the bundler. Rename the file.");
|
|
45
|
+
}
|
|
46
|
+
const handlerName = actorName;
|
|
47
|
+
const doClassName = handlerName;
|
|
48
|
+
const prelude = buildPrelude();
|
|
49
|
+
const entryWrapper = buildEntryWrapper(doClassName, entry);
|
|
50
|
+
return {
|
|
51
|
+
entry: ACTOR_ENTRY_FILENAME,
|
|
52
|
+
files: {
|
|
53
|
+
...files,
|
|
54
|
+
...workerRuntimeFiles(),
|
|
55
|
+
[ACTOR_AUTH_FILENAME]: buildActorAuth(),
|
|
56
|
+
[ACTOR_PRELUDE_FILENAME]: prelude,
|
|
57
|
+
[ACTOR_ENTRY_FILENAME]: entryWrapper,
|
|
58
|
+
},
|
|
59
|
+
handlerName,
|
|
60
|
+
doClassName,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function buildActorAuth() {
|
|
64
|
+
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
65
|
+
const TOKEN_HEADER = "X-Base44-Actor-Token";
|
|
66
|
+
const IDENTITY_HEADER = "X-Base44-Actor-Identity";
|
|
67
|
+
const CLOCK_SKEW_SECONDS = 30;
|
|
68
|
+
const TOKEN_TTL_SECONDS = 300;
|
|
69
|
+
|
|
70
|
+
const decodeSegment = (segment) => {
|
|
71
|
+
const normalized = segment.replace(/-/g, "+").replace(/_/g, "/");
|
|
72
|
+
const padded = normalized + "=".repeat((4 - normalized.length % 4) % 4);
|
|
73
|
+
const binary = atob(padded);
|
|
74
|
+
return new Uint8Array([...binary].map((character) => character.charCodeAt(0)));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const decodeJsonSegment = (segment) =>
|
|
78
|
+
JSON.parse(new TextDecoder().decode(decodeSegment(segment)));
|
|
79
|
+
|
|
80
|
+
const unauthorized = () => ({
|
|
81
|
+
ok: false,
|
|
82
|
+
response: new Response("Unauthorized", { status: 401 }),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const validPrincipal = (principal) => {
|
|
86
|
+
if (principal === null || typeof principal !== "object" || Array.isArray(principal)) return false;
|
|
87
|
+
if (principal.type === "authenticated") {
|
|
88
|
+
return typeof principal.userId === "string" && principal.userId.length > 0 && principal.userId.length <= 128;
|
|
89
|
+
}
|
|
90
|
+
if (principal.type === "anonymous") {
|
|
91
|
+
return typeof principal.anonymousId === "string" && principal.anonymousId.length > 0 && principal.anonymousId.length <= 128;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export async function verifyActorConnection(request, env, actorName, room) {
|
|
97
|
+
const publicKey = env.BASE44_ACTOR_PUBLIC_KEY;
|
|
98
|
+
const scriptId = env.BASE44_ACTOR_SCRIPT_ID;
|
|
99
|
+
const token = request.headers.get(TOKEN_HEADER) ?? new URL(request.url).searchParams.get("token");
|
|
100
|
+
if (
|
|
101
|
+
typeof publicKey !== "string" || !publicKey ||
|
|
102
|
+
typeof scriptId !== "string" || !scriptId ||
|
|
103
|
+
typeof token !== "string" || token.length > 4096
|
|
104
|
+
) return unauthorized();
|
|
105
|
+
|
|
106
|
+
const parts = token.split(".");
|
|
107
|
+
if (parts.length !== 3) return unauthorized();
|
|
108
|
+
try {
|
|
109
|
+
const header = decodeJsonSegment(parts[0]);
|
|
110
|
+
const claims = decodeJsonSegment(parts[1]);
|
|
111
|
+
if (header?.alg !== "EdDSA" || (header.typ !== undefined && header.typ !== "JWT")) {
|
|
112
|
+
return unauthorized();
|
|
113
|
+
}
|
|
114
|
+
const key = await crypto.subtle.importKey(
|
|
115
|
+
"raw",
|
|
116
|
+
decodeSegment(publicKey),
|
|
117
|
+
{ name: "Ed25519" },
|
|
118
|
+
false,
|
|
119
|
+
["verify"],
|
|
120
|
+
);
|
|
121
|
+
const validSignature = await crypto.subtle.verify(
|
|
122
|
+
{ name: "Ed25519" },
|
|
123
|
+
key,
|
|
124
|
+
decodeSegment(parts[2]),
|
|
125
|
+
new TextEncoder().encode(parts[0] + "." + parts[1]),
|
|
126
|
+
);
|
|
127
|
+
if (!validSignature) return unauthorized();
|
|
128
|
+
|
|
129
|
+
const now = Math.floor(Date.now() / 1000);
|
|
130
|
+
const times = [claims.iat, claims.nbf, claims.exp];
|
|
131
|
+
if (!times.every(Number.isInteger)) return unauthorized();
|
|
132
|
+
if (
|
|
133
|
+
claims.iss !== "base44" ||
|
|
134
|
+
claims.aud !== "base44-actor-connect" ||
|
|
135
|
+
claims.purpose !== "actor-connect" ||
|
|
136
|
+
claims.v !== 1 ||
|
|
137
|
+
typeof claims.jti !== "string" || !claims.jti || claims.jti.length > 64 ||
|
|
138
|
+
claims.iat > now + CLOCK_SKEW_SECONDS ||
|
|
139
|
+
claims.nbf > now + CLOCK_SKEW_SECONDS ||
|
|
140
|
+
claims.exp < now - CLOCK_SKEW_SECONDS ||
|
|
141
|
+
claims.exp <= claims.iat || claims.exp - claims.iat > TOKEN_TTL_SECONDS ||
|
|
142
|
+
claims.app_id !== env.BASE44_APP_ID ||
|
|
143
|
+
claims.actor_name !== actorName ||
|
|
144
|
+
claims.actor_script_id !== scriptId ||
|
|
145
|
+
claims.room !== room ||
|
|
146
|
+
claims.connection_id !== new URL(request.url).searchParams.get("_pk") ||
|
|
147
|
+
claims.runtime_mode !== (env.BASE44_FUNCTIONS_VERSION === "prod" ? "prod" : "preview") ||
|
|
148
|
+
!validPrincipal(claims.principal)
|
|
149
|
+
) return unauthorized();
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
ok: true,
|
|
153
|
+
identity: Object.freeze({ ...claims.principal }),
|
|
154
|
+
runtimeMode: claims.runtime_mode,
|
|
155
|
+
};
|
|
156
|
+
} catch {
|
|
157
|
+
return unauthorized();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function authorizedActorRequest(request, identity, actorName, room, runtimeMode) {
|
|
162
|
+
const url = new URL(request.url);
|
|
163
|
+
url.searchParams.delete("token");
|
|
164
|
+
url.pathname = "/parties/" + encodeURIComponent(actorName) + "/" + encodeURIComponent(room);
|
|
165
|
+
const headers = new Headers(request.headers);
|
|
166
|
+
headers.delete(TOKEN_HEADER);
|
|
167
|
+
headers.set(IDENTITY_HEADER, JSON.stringify(identity));
|
|
168
|
+
headers.set("base44-functions-version", runtimeMode === "prod" ? "prod" : "preview");
|
|
169
|
+
return new Request(new Request(url.toString(), request), { headers });
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
}
|
|
173
|
+
function buildPrelude() {
|
|
174
|
+
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
175
|
+
import { currentWorkerRuntimeContext as _b44Context } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
176
|
+
import { installStaticEgressFetch } from "./${SHIM_FILENAME}";
|
|
177
|
+
|
|
178
|
+
${CONSOLE_PATCH}
|
|
179
|
+
installStaticEgressFetch();
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
function buildEntryWrapper(doClassName, userEntry) {
|
|
183
|
+
const userImport = `./${userEntry.replace(/^\.\//, "")}`;
|
|
184
|
+
// ponytail: skip routePartykitRequest (uses Object.entries(env) which doesn't enumerate
|
|
185
|
+
// DO namespace bindings in WfP dispatch context). Access env["ChatRoom"] directly instead.
|
|
186
|
+
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
187
|
+
// The prelude is intentionally the first dependency: it installs the fetch
|
|
188
|
+
// shim before the user module evaluates while this static default import keeps
|
|
189
|
+
// missing-default actors as bundle-time errors.
|
|
190
|
+
import "./${ACTOR_PRELUDE_FILENAME}";
|
|
191
|
+
import Base44UserActor from ${JSON.stringify(userImport)};
|
|
192
|
+
import { runWithWorkerEnvironment as _b44Run } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
193
|
+
import { authorizedActorRequest as _b44AuthorizedActorRequest, verifyActorConnection as _b44VerifyActorConnection } from "./${ACTOR_AUTH_FILENAME}";
|
|
194
|
+
|
|
195
|
+
const _b44ActorState = new WeakMap();
|
|
196
|
+
const _b44RunWithActorEnvironment = (ctx, env, runtimeEnv, callback) => _b44Run({
|
|
197
|
+
env: runtimeEnv,
|
|
198
|
+
secrets: env,
|
|
199
|
+
workerEnv: env,
|
|
200
|
+
waitUntil: (promise) => ctx.waitUntil(promise),
|
|
201
|
+
}, callback);
|
|
202
|
+
const _b44ConstructActor = (ctx, env, newTarget) => _b44RunWithActorEnvironment(
|
|
203
|
+
ctx,
|
|
204
|
+
env,
|
|
205
|
+
"prod",
|
|
206
|
+
() => {
|
|
207
|
+
// A derived constructor may return an explicitly constructed instance.
|
|
208
|
+
// This keeps the user's constructor and class-field initializers inside the
|
|
209
|
+
// request-scoped Worker environment without changing the exported subclass.
|
|
210
|
+
const actor = Reflect.construct(Base44UserActor, [ctx, env], newTarget);
|
|
211
|
+
_b44ActorState.set(actor, { ctx, env, runtimeEnv: null });
|
|
212
|
+
return actor;
|
|
213
|
+
},
|
|
214
|
+
);
|
|
215
|
+
const _b44RunActor = (actor, request, callback) => {
|
|
216
|
+
const state = _b44ActorState.get(actor);
|
|
217
|
+
const runtimeEnv = request
|
|
218
|
+
? ((request.headers.get("base44-functions-version") ?? "") === "prod" ? "prod" : "preview")
|
|
219
|
+
: (state.runtimeEnv ?? "prod");
|
|
220
|
+
state.runtimeEnv = runtimeEnv;
|
|
221
|
+
return _b44RunWithActorEnvironment(state.ctx, state.env, runtimeEnv, callback);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export class ${doClassName} extends Base44UserActor {
|
|
225
|
+
// Read by the shim's service-token exchange: the assertion's actor_name claim
|
|
226
|
+
// selects the verification key on the platform side. A static (not .name) so
|
|
227
|
+
// minification can't change it.
|
|
228
|
+
static _b44ActorName = ${JSON.stringify(doClassName)};
|
|
229
|
+
|
|
230
|
+
constructor(ctx, env) {
|
|
231
|
+
return _b44ConstructActor(ctx, env, new.target);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
fetch(request) {
|
|
235
|
+
return _b44RunActor(this, request, () => super.fetch(request));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
onConnect(...args) {
|
|
239
|
+
return _b44RunActor(this, null, () => super.onConnect(...args));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
onMessage(...args) {
|
|
243
|
+
return _b44RunActor(this, null, () => super.onMessage(...args));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
onClose(...args) {
|
|
247
|
+
return _b44RunActor(this, null, () => super.onClose(...args));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
onAlarm(...args) {
|
|
251
|
+
return _b44RunActor(this, null, () => super.onAlarm(...args));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
onStart(...args) {
|
|
255
|
+
return _b44RunActor(this, null, () => super.onStart(...args));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
onError(...args) {
|
|
259
|
+
return _b44RunActor(this, null, () => super.onError(...args));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
export default {
|
|
263
|
+
async fetch(request, env, ctx) {
|
|
264
|
+
const url = new URL(request.url);
|
|
265
|
+
const parts = url.pathname.split("/");
|
|
266
|
+
const direct = parts[1] === "rooms" && parts.length === 3;
|
|
267
|
+
const legacy = parts[1] === "parties" && parts.length === 4;
|
|
268
|
+
if (direct || legacy) {
|
|
269
|
+
// Decode the room: the token was verified against the decoded instance id,
|
|
270
|
+
// so an escaped room must map to the same Durable Object.
|
|
271
|
+
const namespace = direct ? "${doClassName}" : parts[2];
|
|
272
|
+
const encodedRoom = direct ? parts[2] : parts[3];
|
|
273
|
+
let room;
|
|
274
|
+
try { room = decodeURIComponent(encodedRoom); } catch { return new Response("Invalid room", { status: 400 }); }
|
|
275
|
+
let actorRequest = request;
|
|
276
|
+
if (direct || typeof env.BASE44_ACTOR_PUBLIC_KEY === "string") {
|
|
277
|
+
const verification = await _b44VerifyActorConnection(request, env, "${doClassName}", room);
|
|
278
|
+
if (!verification.ok) return verification.response;
|
|
279
|
+
actorRequest = _b44AuthorizedActorRequest(
|
|
280
|
+
request,
|
|
281
|
+
verification.identity,
|
|
282
|
+
"${doClassName}",
|
|
283
|
+
room,
|
|
284
|
+
verification.runtimeMode,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
const doNs = env["${doClassName}"];
|
|
288
|
+
if (doNs && typeof doNs.idFromName === "function") {
|
|
289
|
+
const stub = doNs.get(doNs.idFromName(room));
|
|
290
|
+
const req = new Request(actorRequest);
|
|
291
|
+
req.headers.set("x-partykit-room", room);
|
|
292
|
+
req.headers.set("x-partykit-namespace", namespace);
|
|
293
|
+
return stub.fetch(req);
|
|
294
|
+
}
|
|
295
|
+
return new Response("DO binding not found", { status: 503 });
|
|
296
|
+
}
|
|
297
|
+
return new Response("Not found", { status: 404 });
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
`;
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=actor-compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor-compat.js","sourceRoot":"","sources":["../../src/actor-compat.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BundleAppRequest, BundleRequest } from "./contracts.js";
|
|
2
|
+
import { type BundleErrorItem } from "./errors.js";
|
|
3
|
+
import { type AppFunctionEntry } from "./worker-entry.js";
|
|
4
|
+
export type { BundleErrorItem };
|
|
5
|
+
export type BundleErrorStage = "deno_compat" | "esbuild";
|
|
6
|
+
export type BundleResponse = {
|
|
7
|
+
ok: true;
|
|
8
|
+
module: string;
|
|
9
|
+
main_module: string;
|
|
10
|
+
warnings: string[];
|
|
11
|
+
handler_name?: string;
|
|
12
|
+
do_class_name?: string;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
stage: BundleErrorStage;
|
|
16
|
+
errors: BundleErrorItem[];
|
|
17
|
+
};
|
|
18
|
+
export type AppFunctionStatus = {
|
|
19
|
+
name: string;
|
|
20
|
+
ok: true;
|
|
21
|
+
} | {
|
|
22
|
+
name: string;
|
|
23
|
+
ok: false;
|
|
24
|
+
errors: BundleErrorItem[];
|
|
25
|
+
};
|
|
26
|
+
export type BundleAppResponse = {
|
|
27
|
+
ok: true;
|
|
28
|
+
module: string;
|
|
29
|
+
main_module: string;
|
|
30
|
+
functions: AppFunctionStatus[];
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
module: null;
|
|
34
|
+
functions: AppFunctionStatus[];
|
|
35
|
+
};
|
|
36
|
+
export declare function bundle(req: BundleRequest): Promise<BundleResponse>;
|
|
37
|
+
export declare function bundleApp(req: BundleAppRequest): Promise<BundleAppResponse>;
|
|
38
|
+
export interface AppErrorClassification {
|
|
39
|
+
byIndex: Map<number, BundleErrorItem[]>;
|
|
40
|
+
unattributable: BundleErrorItem[];
|
|
41
|
+
}
|
|
42
|
+
/** Map each combined-build error to the function whose `fn_<index>/` subtree it
|
|
43
|
+
* came from, stripping that prefix so the user sees their own path. Errors with
|
|
44
|
+
* no `fn_<index>/` prefix (a shared dep deep in node_modules, or no location)
|
|
45
|
+
* can't be pinned to one function. */
|
|
46
|
+
export declare function classifyAppErrors(errors: BundleErrorItem[]): AppErrorClassification;
|
|
47
|
+
/** Does this function's source import one of the packages the assembly errors
|
|
48
|
+
* originate from, at (or possibly at) the failing major? A specifier pinned to
|
|
49
|
+
* a different major is exonerated — its copy of the package is the one that
|
|
50
|
+
* works; an unpinned specifier stays blamed. */
|
|
51
|
+
export declare function importsConflictingPackage(entry: AppFunctionEntry, errors: BundleErrorItem[]): boolean;
|