@base44-preview/cli 0.1.32-pr.662.e04bb64 → 0.1.32-pr.664.478a865
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/dist/cli/index.js +100 -139
- package/dist/cli/index.js.map +7 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -253161,10 +253161,6 @@ var STATIC_EGRESS_ENABLED_ENV = "BASE44_STATIC_EGRESS_ENABLED";
|
|
|
253161
253161
|
var STATIC_EGRESS_DIAGNOSTIC_LIMIT = 5;
|
|
253162
253162
|
var staticEgressFetchInstalled = false;
|
|
253163
253163
|
var staticEgressDiagnosticCount = 0;
|
|
253164
|
-
var dedicatedEgressResponses = /* @__PURE__ */ new WeakSet();
|
|
253165
|
-
function isDedicatedEgressResponse(response) {
|
|
253166
|
-
return dedicatedEgressResponses.has(response);
|
|
253167
|
-
}
|
|
253168
253164
|
function inputKind(input) {
|
|
253169
253165
|
if (typeof input === "string") return "string";
|
|
253170
253166
|
return input instanceof URL ? "url" : "request";
|
|
@@ -253266,10 +253262,7 @@ function createRequestScopedStaticEgressFetch(originalFetch, readEnvironment) {
|
|
|
253266
253262
|
return originalFetch(input, init);
|
|
253267
253263
|
}
|
|
253268
253264
|
logStaticEgressDecision("dedicated", input, binding, enableSecret);
|
|
253269
|
-
return binding.fetch(input, init)
|
|
253270
|
-
dedicatedEgressResponses.add(response);
|
|
253271
|
-
return response;
|
|
253272
|
-
});
|
|
253265
|
+
return binding.fetch(input, init);
|
|
253273
253266
|
};
|
|
253274
253267
|
}
|
|
253275
253268
|
function installStaticEgressFetch() {
|
|
@@ -253281,128 +253274,6 @@ function installStaticEgressFetch() {
|
|
|
253281
253274
|
staticEgressFetchInstalled = true;
|
|
253282
253275
|
}
|
|
253283
253276
|
|
|
253284
|
-
// src/edge-errors.ts
|
|
253285
|
-
var EDGE_ERRORS_HEADER = "X-B44-Edge-Errors";
|
|
253286
|
-
var MAX_EDGE_ERRORS = 5;
|
|
253287
|
-
var MAX_INSPECTED_BODY_BYTES = 8192;
|
|
253288
|
-
var BODY_READ_TIMEOUT_MS = 500;
|
|
253289
|
-
var PLAIN_TEXT_EDGE_ERROR = /^error code: (\\d{3,4})\\s*$/;
|
|
253290
|
-
var UNBRANDED_5XX_PAGE = /<center>cloudflare<\\/center>/i;
|
|
253291
|
-
var SAFE_VALUE = /^[\\x20-\\x7e]{1,253}$/;
|
|
253292
|
-
function safe(value) {
|
|
253293
|
-
return typeof value === "string" && SAFE_VALUE.test(value) ? value : void 0;
|
|
253294
|
-
}
|
|
253295
|
-
function parseEdgeErrorBody(body, status) {
|
|
253296
|
-
const plain = PLAIN_TEXT_EDGE_ERROR.exec(body);
|
|
253297
|
-
if (plain) return { code: Number(plain[1]) };
|
|
253298
|
-
if (status >= 500 && UNBRANDED_5XX_PAGE.test(body)) return { code: status };
|
|
253299
|
-
try {
|
|
253300
|
-
const json = JSON.parse(body);
|
|
253301
|
-
if (json === null || typeof json !== "object") return null;
|
|
253302
|
-
const fields = json;
|
|
253303
|
-
if (fields.cloudflare_error !== true || !Number.isInteger(fields.error_code)) return null;
|
|
253304
|
-
return {
|
|
253305
|
-
code: fields.error_code,
|
|
253306
|
-
name: safe(fields.error_name),
|
|
253307
|
-
category: safe(fields.error_category),
|
|
253308
|
-
zone: safe(fields.zone)
|
|
253309
|
-
};
|
|
253310
|
-
} catch {
|
|
253311
|
-
return null;
|
|
253312
|
-
}
|
|
253313
|
-
}
|
|
253314
|
-
async function readBodyPrefix(response) {
|
|
253315
|
-
if (Number(response.headers.get("content-length")) > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253316
|
-
const reader = response.clone().body?.getReader();
|
|
253317
|
-
if (!reader) return "";
|
|
253318
|
-
const timer = setTimeout(() => reader.cancel().catch(() => {
|
|
253319
|
-
}), BODY_READ_TIMEOUT_MS);
|
|
253320
|
-
const decoder = new TextDecoder();
|
|
253321
|
-
let text = "";
|
|
253322
|
-
let size = 0;
|
|
253323
|
-
try {
|
|
253324
|
-
for (; ; ) {
|
|
253325
|
-
const { done, value } = await reader.read();
|
|
253326
|
-
if (done) break;
|
|
253327
|
-
size += value.byteLength;
|
|
253328
|
-
if (size > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253329
|
-
text += decoder.decode(value, { stream: true });
|
|
253330
|
-
}
|
|
253331
|
-
} catch {
|
|
253332
|
-
return null;
|
|
253333
|
-
} finally {
|
|
253334
|
-
clearTimeout(timer);
|
|
253335
|
-
reader.cancel().catch(() => {
|
|
253336
|
-
});
|
|
253337
|
-
}
|
|
253338
|
-
return text + decoder.decode();
|
|
253339
|
-
}
|
|
253340
|
-
async function readEdgeError(response) {
|
|
253341
|
-
if (response.status < 400 || !response.headers.get("cf-ray")) return null;
|
|
253342
|
-
if (response.headers.get("cf-mitigated") === "challenge") {
|
|
253343
|
-
return { code: response.status, name: "challenge" };
|
|
253344
|
-
}
|
|
253345
|
-
const body = await readBodyPrefix(response);
|
|
253346
|
-
return body === null ? null : parseEdgeErrorBody(body, response.status);
|
|
253347
|
-
}
|
|
253348
|
-
function targetOrigin(input) {
|
|
253349
|
-
try {
|
|
253350
|
-
const raw = input instanceof URL ? input.href : typeof input === "string" ? input : input.url;
|
|
253351
|
-
return new URL(raw).origin;
|
|
253352
|
-
} catch {
|
|
253353
|
-
return null;
|
|
253354
|
-
}
|
|
253355
|
-
}
|
|
253356
|
-
async function recordEdgeError(input, response, startedAt) {
|
|
253357
|
-
const store = currentWorkerRuntimeContext();
|
|
253358
|
-
if (!store) return;
|
|
253359
|
-
const body = await readEdgeError(response);
|
|
253360
|
-
const target = targetOrigin(input);
|
|
253361
|
-
if (!body || !target) return;
|
|
253362
|
-
const record = store.edgeErrors ??= { errors: [], dropped: 0 };
|
|
253363
|
-
if (record.errors.length >= MAX_EDGE_ERRORS) {
|
|
253364
|
-
record.dropped += 1;
|
|
253365
|
-
return;
|
|
253366
|
-
}
|
|
253367
|
-
record.errors.push({
|
|
253368
|
-
...body,
|
|
253369
|
-
target,
|
|
253370
|
-
status: response.status,
|
|
253371
|
-
ray: safe(response.headers.get("cf-ray")) ?? "",
|
|
253372
|
-
egress: isDedicatedEgressResponse(response) ? "dedicated" : "shared",
|
|
253373
|
-
elapsed_ms: Date.now() - startedAt
|
|
253374
|
-
});
|
|
253375
|
-
}
|
|
253376
|
-
function createEdgeErrorFetch(innerFetch) {
|
|
253377
|
-
return async (input, init) => {
|
|
253378
|
-
const startedAt = Date.now();
|
|
253379
|
-
const response = await innerFetch(input, init);
|
|
253380
|
-
try {
|
|
253381
|
-
await recordEdgeError(input, response, startedAt);
|
|
253382
|
-
} catch {
|
|
253383
|
-
}
|
|
253384
|
-
return response;
|
|
253385
|
-
};
|
|
253386
|
-
}
|
|
253387
|
-
var edgeErrorFetchInstalled = false;
|
|
253388
|
-
function installEdgeErrorFetch() {
|
|
253389
|
-
if (edgeErrorFetchInstalled) return;
|
|
253390
|
-
globalThis.fetch = createEdgeErrorFetch(globalThis.fetch.bind(globalThis));
|
|
253391
|
-
edgeErrorFetchInstalled = true;
|
|
253392
|
-
}
|
|
253393
|
-
function attachEdgeErrors(response) {
|
|
253394
|
-
const record = currentWorkerRuntimeContext()?.edgeErrors;
|
|
253395
|
-
if (!record || !(response instanceof Response)) return response;
|
|
253396
|
-
if (response.status === 101 || response.webSocket) return response;
|
|
253397
|
-
try {
|
|
253398
|
-
const wrapped = new Response(response.body, response);
|
|
253399
|
-
wrapped.headers.set(EDGE_ERRORS_HEADER, JSON.stringify(record));
|
|
253400
|
-
return wrapped;
|
|
253401
|
-
} catch {
|
|
253402
|
-
return response;
|
|
253403
|
-
}
|
|
253404
|
-
}
|
|
253405
|
-
|
|
253406
253277
|
// src/static-egress-tcp-core.mjs
|
|
253407
253278
|
function normalizeHost(host) {
|
|
253408
253279
|
return host.toLowerCase().replace(/^\\[(.*)\\]$/, "$1").replace(/\\.$/, "");
|
|
@@ -253531,6 +253402,8 @@ var deno2 = Object.freeze({
|
|
|
253531
253402
|
});
|
|
253532
253403
|
globalThis.Deno = deno2;
|
|
253533
253404
|
globalThis.Buffer = Buffer2;
|
|
253405
|
+
AsyncLocalStorage.prototype.enterWith = () => {
|
|
253406
|
+
};
|
|
253534
253407
|
function getRegisteredHandler() {
|
|
253535
253408
|
return registeredHandler;
|
|
253536
253409
|
}
|
|
@@ -253556,9 +253429,7 @@ function resolveHandler(functionName) {
|
|
|
253556
253429
|
return handler;
|
|
253557
253430
|
}
|
|
253558
253431
|
export {
|
|
253559
|
-
attachEdgeErrors,
|
|
253560
253432
|
getRegisteredHandler,
|
|
253561
|
-
installEdgeErrorFetch,
|
|
253562
253433
|
installStaticEgressFetch,
|
|
253563
253434
|
registerLazy,
|
|
253564
253435
|
resolveHandler
|
|
@@ -256603,22 +256474,20 @@ registerLazy(${JSON.stringify(functionName)}, () => import(${JSON.stringify(user
|
|
|
256603
256474
|
function buildAppEntrySource(functionModules, telemetry, runtimeSecrets = false) {
|
|
256604
256475
|
const moduleImports = functionModules.map((file) => `import "./${file}";`).join(`
|
|
256605
256476
|
`);
|
|
256606
|
-
const handlerExpr = `_b44AttachInvocationLogs(
|
|
256477
|
+
const handlerExpr = `_b44AttachInvocationLogs(${telemetry ? "_b44AttachTelemetry(await handler(request, info))" : "await handler(request, info)"})`;
|
|
256607
256478
|
const guard = activationGuard(runtimeSecrets);
|
|
256608
256479
|
const returnExpr = guard(handlerExpr);
|
|
256609
256480
|
return `// Auto-generated by the base44 bundler. Do not edit.
|
|
256610
256481
|
|
|
256611
256482
|
import { currentWorkerRuntimeContext as _b44Context, runWithWorkerEnvironment as _b44Run } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
|
|
256612
|
-
import {
|
|
256483
|
+
import { installStaticEgressFetch, resolveHandler } from "./${SHIM_FILENAME}";${activationImport(runtimeSecrets)}
|
|
256613
256484
|
${moduleImports}
|
|
256614
256485
|
|
|
256615
256486
|
${consolePatch(runtimeSecrets)}
|
|
256616
256487
|
${INVOCATION_LOGS_PATCH}
|
|
256617
|
-
// Static egress reads workerEnv from the active request store. Install it
|
|
256618
|
-
//
|
|
256619
|
-
// fetch wrapper.
|
|
256488
|
+
// Static egress reads workerEnv from the active request store. Install it
|
|
256489
|
+
// before telemetry so telemetry remains the outermost fetch wrapper.
|
|
256620
256490
|
installStaticEgressFetch();
|
|
256621
|
-
installEdgeErrorFetch();
|
|
256622
256491
|
${telemetry ? TELEMETRY_PATCH : ""}
|
|
256623
256492
|
|
|
256624
256493
|
export default {
|
|
@@ -261124,6 +260993,97 @@ function runtimeVirtualPlugin() {
|
|
|
261124
260993
|
};
|
|
261125
260994
|
}
|
|
261126
260995
|
|
|
260996
|
+
// ../functions-compiler/src/esbuild/ws-native-virtual.ts
|
|
260997
|
+
var NAMESPACE4 = "base44-ws-native";
|
|
260998
|
+
var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
|
|
260999
|
+
var ADAPTER = `"use strict";
|
|
261000
|
+
const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
|
|
261001
|
+
class WebSocket {
|
|
261002
|
+
static CONNECTING = 0;
|
|
261003
|
+
static OPEN = 1;
|
|
261004
|
+
static CLOSING = 2;
|
|
261005
|
+
static CLOSED = 3;
|
|
261006
|
+
#socket;
|
|
261007
|
+
#listeners = new Map();
|
|
261008
|
+
constructor(address, protocols) {
|
|
261009
|
+
this.#socket = new globalThis.WebSocket(String(address), typeof protocols === "string" || Array.isArray(protocols) ? protocols : undefined);
|
|
261010
|
+
try { this.#socket.binaryType = "arraybuffer"; } catch {}
|
|
261011
|
+
this.#socket.addEventListener("open", () => this.emit("open"));
|
|
261012
|
+
this.#socket.addEventListener("message", (event) => {
|
|
261013
|
+
const isBinary = typeof event.data !== "string";
|
|
261014
|
+
this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
|
|
261015
|
+
});
|
|
261016
|
+
this.#socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
|
|
261017
|
+
this.#socket.addEventListener("close", (event) => this.emit("close", event.code, toBuffer(event.reason ?? "")));
|
|
261018
|
+
}
|
|
261019
|
+
get readyState() { return this.#socket.readyState; }
|
|
261020
|
+
get url() { return this.#socket.url; }
|
|
261021
|
+
get protocol() { return this.#socket.protocol; }
|
|
261022
|
+
on(name, listener) { return this.#add(name, listener, false); }
|
|
261023
|
+
addListener(name, listener) { return this.#add(name, listener, false); }
|
|
261024
|
+
once(name, listener) { return this.#add(name, listener, true); }
|
|
261025
|
+
off(name, listener) { return this.removeListener(name, listener); }
|
|
261026
|
+
removeListener(name, listener) {
|
|
261027
|
+
const listeners = this.#listeners.get(name);
|
|
261028
|
+
if (listeners) this.#listeners.set(name, listeners.filter((entry) => entry.listener !== listener));
|
|
261029
|
+
return this;
|
|
261030
|
+
}
|
|
261031
|
+
removeAllListeners(name) {
|
|
261032
|
+
if (name === undefined) this.#listeners.clear();
|
|
261033
|
+
else this.#listeners.delete(name);
|
|
261034
|
+
return this;
|
|
261035
|
+
}
|
|
261036
|
+
emit(name, ...args) {
|
|
261037
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
261038
|
+
this.#listeners.set(name, listeners.filter((entry) => !entry.once));
|
|
261039
|
+
for (const entry of listeners) entry.listener.apply(this, args);
|
|
261040
|
+
return listeners.length > 0;
|
|
261041
|
+
}
|
|
261042
|
+
send(data, options, callback) {
|
|
261043
|
+
const done = typeof options === "function" ? options : callback;
|
|
261044
|
+
try {
|
|
261045
|
+
this.#socket.send(data);
|
|
261046
|
+
done?.();
|
|
261047
|
+
} catch (error) {
|
|
261048
|
+
if (!done) throw error;
|
|
261049
|
+
done(error);
|
|
261050
|
+
}
|
|
261051
|
+
}
|
|
261052
|
+
close(code, reason) { this.#socket.close(code, reason); }
|
|
261053
|
+
terminate() { this.#socket.close(); }
|
|
261054
|
+
#add(name, listener, once) {
|
|
261055
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
261056
|
+
listeners.push({ listener, once });
|
|
261057
|
+
this.#listeners.set(name, listeners);
|
|
261058
|
+
return this;
|
|
261059
|
+
}
|
|
261060
|
+
}
|
|
261061
|
+
class WebSocketServer {
|
|
261062
|
+
constructor() {
|
|
261063
|
+
throw new Error("ws WebSocketServer is not available in Base44 functions: a function can open WebSocket connections but cannot listen for them.");
|
|
261064
|
+
}
|
|
261065
|
+
}
|
|
261066
|
+
module.exports = WebSocket;
|
|
261067
|
+
module.exports.WebSocket = WebSocket;
|
|
261068
|
+
module.exports.WebSocketServer = WebSocketServer;
|
|
261069
|
+
module.exports.default = WebSocket;
|
|
261070
|
+
`;
|
|
261071
|
+
function wsNativeVirtualPlugin() {
|
|
261072
|
+
return {
|
|
261073
|
+
name: "base44-ws-native",
|
|
261074
|
+
setup(build) {
|
|
261075
|
+
build.onResolve({ filter: WS_SPECIFIER }, () => ({
|
|
261076
|
+
path: "ws",
|
|
261077
|
+
namespace: NAMESPACE4
|
|
261078
|
+
}));
|
|
261079
|
+
build.onLoad({ filter: /.*/, namespace: NAMESPACE4 }, () => ({
|
|
261080
|
+
contents: ADAPTER,
|
|
261081
|
+
loader: "js"
|
|
261082
|
+
}));
|
|
261083
|
+
}
|
|
261084
|
+
};
|
|
261085
|
+
}
|
|
261086
|
+
|
|
261127
261087
|
// ../functions-compiler/src/deno-bundle.ts
|
|
261128
261088
|
async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
261129
261089
|
const dir = await mkdtemp(path21.join(tmpdir2(), "b44-bundle-"));
|
|
@@ -261147,6 +261107,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
261147
261107
|
sourcemap: false,
|
|
261148
261108
|
logLevel: "silent",
|
|
261149
261109
|
plugins: [
|
|
261110
|
+
wsNativeVirtualPlugin(),
|
|
261150
261111
|
nodeBuiltinRequirePlugin(),
|
|
261151
261112
|
userFilesPlugin(prepared.files, prepared.entry),
|
|
261152
261113
|
privateDataSourcesVirtualPlugin(),
|
|
@@ -271535,4 +271496,4 @@ export {
|
|
|
271535
271496
|
runCLI
|
|
271536
271497
|
};
|
|
271537
271498
|
|
|
271538
|
-
//# debugId=
|
|
271499
|
+
//# debugId=F78FCF622784F43164756E2164756E21
|