@base44-preview/cli 0.2.2-pr.676.83d8553 → 0.2.2-pr.677.e0cc2a5
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 +117 -79
- package/dist/cli/index.js.map +8 -7
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -255175,40 +255175,8 @@ function isExcludedHostname(hostname4, excludedHosts) {
|
|
|
255175
255175
|
}
|
|
255176
255176
|
return false;
|
|
255177
255177
|
}
|
|
255178
|
-
var STRIPE_CLIENT_USER_AGENT_HEADER = "X-Stripe-Client-User-Agent";
|
|
255179
|
-
function withoutLangVersion(value) {
|
|
255180
|
-
if (value === null) return null;
|
|
255181
|
-
try {
|
|
255182
|
-
const parsed = JSON.parse(value);
|
|
255183
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed) || !("lang_version" in parsed)) {
|
|
255184
|
-
return null;
|
|
255185
|
-
}
|
|
255186
|
-
delete parsed.lang_version;
|
|
255187
|
-
return JSON.stringify(parsed);
|
|
255188
|
-
} catch {
|
|
255189
|
-
return null;
|
|
255190
|
-
}
|
|
255191
|
-
}
|
|
255192
|
-
function stripStripeLangVersion(input, init) {
|
|
255193
|
-
if (init?.headers !== void 0) {
|
|
255194
|
-
const headers = new Headers(init.headers);
|
|
255195
|
-
const value = withoutLangVersion(headers.get(STRIPE_CLIENT_USER_AGENT_HEADER));
|
|
255196
|
-
if (value === null) return [input, init];
|
|
255197
|
-
headers.set(STRIPE_CLIENT_USER_AGENT_HEADER, value);
|
|
255198
|
-
return [input, { ...init, headers }];
|
|
255199
|
-
}
|
|
255200
|
-
if (input instanceof Request) {
|
|
255201
|
-
const value = withoutLangVersion(input.headers.get(STRIPE_CLIENT_USER_AGENT_HEADER));
|
|
255202
|
-
if (value === null) return [input, init];
|
|
255203
|
-
const headers = new Headers(input.headers);
|
|
255204
|
-
headers.set(STRIPE_CLIENT_USER_AGENT_HEADER, value);
|
|
255205
|
-
return [new Request(input, { headers }), init];
|
|
255206
|
-
}
|
|
255207
|
-
return [input, init];
|
|
255208
|
-
}
|
|
255209
255178
|
function createRequestScopedStaticEgressFetch(originalFetch, readEnvironment) {
|
|
255210
|
-
return (
|
|
255211
|
-
const [input, init] = stripStripeLangVersion(rawInput, rawInit);
|
|
255179
|
+
return (input, init) => {
|
|
255212
255180
|
const env2 = readEnvironment();
|
|
255213
255181
|
const binding = env2[STATIC_EGRESS_BINDING_NAME];
|
|
255214
255182
|
const enableSecret = env2[STATIC_EGRESS_ENABLED_ENV];
|
|
@@ -262883,25 +262851,30 @@ var pipelineType = ZodPipeline.create;
|
|
|
262883
262851
|
var fileMapSchema = recordType(stringType().min(1), stringType()).refine((files) => Object.keys(files).length > 0, {
|
|
262884
262852
|
message: "must contain at least one file"
|
|
262885
262853
|
});
|
|
262854
|
+
var entryPathSchema = stringType().min(1).max(200);
|
|
262886
262855
|
var bundleRequestSchema = objectType({
|
|
262887
262856
|
entry: stringType().min(1),
|
|
262888
262857
|
files: fileMapSchema,
|
|
262858
|
+
entryPath: entryPathSchema.optional(),
|
|
262889
262859
|
postResponseTelemetry: booleanType().optional(),
|
|
262890
|
-
runtimeSecrets: booleanType().optional()
|
|
262860
|
+
runtimeSecrets: booleanType().optional(),
|
|
262861
|
+
sourceMap: booleanType().optional()
|
|
262891
262862
|
}).refine((body) => (body.entry in body.files), {
|
|
262892
262863
|
message: "`entry` must be a key in `files`"
|
|
262893
262864
|
});
|
|
262894
262865
|
var appFunctionSchema = objectType({
|
|
262895
262866
|
name: stringType().min(1),
|
|
262896
262867
|
entry: stringType().min(1),
|
|
262897
|
-
files: fileMapSchema
|
|
262868
|
+
files: fileMapSchema,
|
|
262869
|
+
entryPath: entryPathSchema.optional()
|
|
262898
262870
|
}).refine((fn) => (fn.entry in fn.files), {
|
|
262899
262871
|
message: "`entry` must be a key in `files`"
|
|
262900
262872
|
});
|
|
262901
262873
|
var bundleAppRequestSchema = objectType({
|
|
262902
262874
|
functions: arrayType(appFunctionSchema).min(1),
|
|
262903
262875
|
postResponseTelemetry: booleanType().optional(),
|
|
262904
|
-
runtimeSecrets: booleanType().optional()
|
|
262876
|
+
runtimeSecrets: booleanType().optional(),
|
|
262877
|
+
sourceMap: booleanType().optional()
|
|
262905
262878
|
}).refine((body) => new Set(body.functions.map((fn) => fn.name)).size === body.functions.length, { message: "function names must be unique" });
|
|
262906
262879
|
var ACTIVATION_MODE = "pull";
|
|
262907
262880
|
|
|
@@ -263466,7 +263439,8 @@ function wsNativeVirtualPlugin() {
|
|
|
263466
263439
|
}
|
|
263467
263440
|
|
|
263468
263441
|
// ../functions-compiler/src/deno-bundle.ts
|
|
263469
|
-
|
|
263442
|
+
var MAIN_MODULE = "_bundled.mjs";
|
|
263443
|
+
async function bundleToModule(prepared, nodeModulesDir = "none", sourceMap = false) {
|
|
263470
263444
|
const dir = await mkdtemp(path21.join(tmpdir2(), "b44-bundle-"));
|
|
263471
263445
|
try {
|
|
263472
263446
|
await writeFile2(path21.join(dir, "deno.json"), JSON.stringify({ nodeModulesDir }));
|
|
@@ -263485,7 +263459,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
263485
263459
|
define: { __dirname: '"/"', __filename: '"/index.js"' },
|
|
263486
263460
|
minify: true,
|
|
263487
263461
|
...prepared.banner ? { banner: { js: prepared.banner } } : {},
|
|
263488
|
-
sourcemap: false,
|
|
263462
|
+
...sourceMap ? { sourcemap: "linked", sourcesContent: false, outfile: MAIN_MODULE } : { sourcemap: false },
|
|
263489
263463
|
logLevel: "silent",
|
|
263490
263464
|
plugins: [
|
|
263491
263465
|
wsNativeVirtualPlugin(),
|
|
@@ -263504,14 +263478,19 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
263504
263478
|
throw e;
|
|
263505
263479
|
}
|
|
263506
263480
|
const outputs = result.outputFiles ?? [];
|
|
263507
|
-
|
|
263508
|
-
|
|
263481
|
+
const warnings = result.warnings.map((w) => w.text);
|
|
263482
|
+
if (!sourceMap) {
|
|
263483
|
+
if (outputs.length !== 1) {
|
|
263484
|
+
throw new Error(`expected single-module output, got ${outputs.length} file(s)`);
|
|
263485
|
+
}
|
|
263486
|
+
return { ok: true, module: outputs[0].text, warnings };
|
|
263509
263487
|
}
|
|
263510
|
-
|
|
263511
|
-
|
|
263512
|
-
|
|
263513
|
-
|
|
263514
|
-
}
|
|
263488
|
+
const module = outputs.find((o) => o.path.endsWith(".mjs"));
|
|
263489
|
+
const map = outputs.find((o) => o.path.endsWith(".map"));
|
|
263490
|
+
if (outputs.length !== 2 || !module || !map) {
|
|
263491
|
+
throw new Error(`expected a module and its source map, got ${outputs.map((o) => path21.basename(o.path)).join(", ") || "no files"}`);
|
|
263492
|
+
}
|
|
263493
|
+
return { ok: true, module: module.text, map: map.text, warnings };
|
|
263515
263494
|
} finally {
|
|
263516
263495
|
await rm2(dir, { recursive: true, force: true });
|
|
263517
263496
|
}
|
|
@@ -263557,6 +263536,36 @@ function relativizeFile(file, dir) {
|
|
|
263557
263536
|
return file.startsWith(prefix) ? file.slice(prefix.length) : file;
|
|
263558
263537
|
}
|
|
263559
263538
|
|
|
263539
|
+
// ../functions-compiler/src/source-map.ts
|
|
263540
|
+
var INTERNAL_SOURCE_PREFIX = "base44-internal:";
|
|
263541
|
+
var USER_PREFIX = `${USER_NAMESPACE}:`;
|
|
263542
|
+
var APP_FUNCTION_PATH = /^fn_(\d+)\/(.*)$/;
|
|
263543
|
+
function functionSourceMap(raw, fn) {
|
|
263544
|
+
return rewriteSources(raw, (key) => appPath(fn, key));
|
|
263545
|
+
}
|
|
263546
|
+
function appSourceMap(raw, functions) {
|
|
263547
|
+
return rewriteSources(raw, (key) => {
|
|
263548
|
+
const match = key.match(APP_FUNCTION_PATH);
|
|
263549
|
+
const fn = match ? functions[Number(match[1])] : undefined;
|
|
263550
|
+
return fn && match ? appPath(fn, match[2]) : undefined;
|
|
263551
|
+
});
|
|
263552
|
+
}
|
|
263553
|
+
function appPath(fn, key) {
|
|
263554
|
+
if (!Object.hasOwn(fn.files, key))
|
|
263555
|
+
return;
|
|
263556
|
+
return key === fn.entry && fn.entryPath ? fn.entryPath : key;
|
|
263557
|
+
}
|
|
263558
|
+
function rewriteSources(raw, appPathOf) {
|
|
263559
|
+
const map = JSON.parse(raw);
|
|
263560
|
+
map.sources = (map.sources ?? []).map((source) => {
|
|
263561
|
+
const app = source.startsWith(USER_PREFIX) ? appPathOf(source.slice(USER_PREFIX.length)) : undefined;
|
|
263562
|
+
return app ?? `${INTERNAL_SOURCE_PREFIX}${source}`;
|
|
263563
|
+
});
|
|
263564
|
+
delete map.sourceRoot;
|
|
263565
|
+
delete map.sourcesContent;
|
|
263566
|
+
return JSON.stringify(map);
|
|
263567
|
+
}
|
|
263568
|
+
|
|
263560
263569
|
// ../functions-compiler/src/tracing.ts
|
|
263561
263570
|
var noopTracer = {
|
|
263562
263571
|
withSpan: (_name, fn) => fn(),
|
|
@@ -263571,7 +263580,6 @@ function setSpanTags(tags) {
|
|
|
263571
263580
|
}
|
|
263572
263581
|
|
|
263573
263582
|
// ../functions-compiler/src/bundler.ts
|
|
263574
|
-
var NORMALIZED_MAIN_MODULE = "_bundled.mjs";
|
|
263575
263583
|
var MAX_PARALLEL_COMPILES = 4;
|
|
263576
263584
|
async function bundle(req) {
|
|
263577
263585
|
let actor;
|
|
@@ -263592,7 +263600,7 @@ async function bundle(req) {
|
|
|
263592
263600
|
return {
|
|
263593
263601
|
ok: true,
|
|
263594
263602
|
module: outcome.module,
|
|
263595
|
-
main_module:
|
|
263603
|
+
main_module: MAIN_MODULE,
|
|
263596
263604
|
warnings: outcome.warnings,
|
|
263597
263605
|
handler_name: actor.handlerName,
|
|
263598
263606
|
do_class_name: actor.doClassName
|
|
@@ -263606,12 +263614,13 @@ async function bundle(req) {
|
|
|
263606
263614
|
} catch (e) {
|
|
263607
263615
|
return denoCompatErrorOrThrow(e);
|
|
263608
263616
|
}
|
|
263609
|
-
const outcome = await installAndCompile(prepared);
|
|
263617
|
+
const outcome = await installAndCompile(prepared, req.sourceMap ?? false);
|
|
263610
263618
|
if (outcome.ok) {
|
|
263611
263619
|
return {
|
|
263612
263620
|
ok: true,
|
|
263613
263621
|
module: outcome.module,
|
|
263614
|
-
|
|
263622
|
+
...outcome.map ? { source_map: functionSourceMap(outcome.map, req) } : {},
|
|
263623
|
+
main_module: MAIN_MODULE,
|
|
263615
263624
|
warnings: outcome.warnings,
|
|
263616
263625
|
...activationField(req.runtimeSecrets ?? false)
|
|
263617
263626
|
};
|
|
@@ -263626,26 +263635,29 @@ async function bundleApp(req) {
|
|
|
263626
263635
|
return result.ok ? { ...result, ...activationField(req.runtimeSecrets ?? false) } : result;
|
|
263627
263636
|
}
|
|
263628
263637
|
async function assembleApp(req) {
|
|
263629
|
-
const
|
|
263630
|
-
|
|
263638
|
+
const build = {
|
|
263639
|
+
telemetry: req.postResponseTelemetry ?? false,
|
|
263640
|
+
runtimeSecrets: req.runtimeSecrets ?? false,
|
|
263641
|
+
sourceMap: req.sourceMap ?? false
|
|
263642
|
+
};
|
|
263631
263643
|
const entries = req.functions.map((fn, index) => ({
|
|
263632
263644
|
index,
|
|
263633
263645
|
fn
|
|
263634
263646
|
}));
|
|
263635
263647
|
let combined;
|
|
263636
263648
|
try {
|
|
263637
|
-
combined = await compileApp(entries,
|
|
263649
|
+
combined = await compileApp(entries, build);
|
|
263638
263650
|
} catch (e) {
|
|
263639
263651
|
if (e instanceof DenoCompatError)
|
|
263640
|
-
return bundleAppPerFunction(entries,
|
|
263652
|
+
return bundleAppPerFunction(entries, build);
|
|
263641
263653
|
throw e;
|
|
263642
263654
|
}
|
|
263643
263655
|
if (combined.ok) {
|
|
263644
|
-
return appResponse(combined
|
|
263656
|
+
return appResponse(combined, allOk(entries));
|
|
263645
263657
|
}
|
|
263646
263658
|
const { byIndex, unattributable } = classifyAppErrors(combined.errors);
|
|
263647
263659
|
if (unattributable.length > 0) {
|
|
263648
|
-
return bundleAppPerFunction(entries,
|
|
263660
|
+
return bundleAppPerFunction(entries, build);
|
|
263649
263661
|
}
|
|
263650
263662
|
const functions = entries.map((e) => byIndex.has(e.index) ? { name: e.fn.name, ok: false, errors: byIndex.get(e.index) } : { name: e.fn.name, ok: true });
|
|
263651
263663
|
const survivors = entries.filter((e) => !byIndex.has(e.index));
|
|
@@ -263654,25 +263666,42 @@ async function assembleApp(req) {
|
|
|
263654
263666
|
}
|
|
263655
263667
|
let rebuilt;
|
|
263656
263668
|
try {
|
|
263657
|
-
rebuilt = await compileApp(survivors,
|
|
263669
|
+
rebuilt = await compileApp(survivors, build);
|
|
263658
263670
|
} catch (e) {
|
|
263659
263671
|
if (e instanceof DenoCompatError)
|
|
263660
|
-
return bundleAppPerFunction(entries,
|
|
263672
|
+
return bundleAppPerFunction(entries, build);
|
|
263661
263673
|
throw e;
|
|
263662
263674
|
}
|
|
263663
263675
|
if (rebuilt.ok)
|
|
263664
|
-
return appResponse(rebuilt
|
|
263665
|
-
return bundleAppPerFunction(entries,
|
|
263666
|
-
}
|
|
263667
|
-
async function compileApp(entries,
|
|
263668
|
-
const outcome = await installAndCompile(prepareApp(entries, telemetry, runtimeSecrets));
|
|
263669
|
-
|
|
263676
|
+
return appResponse(rebuilt, functions);
|
|
263677
|
+
return bundleAppPerFunction(entries, build);
|
|
263678
|
+
}
|
|
263679
|
+
async function compileApp(entries, build) {
|
|
263680
|
+
const outcome = await installAndCompile(prepareApp(entries, build.telemetry, build.runtimeSecrets), build.sourceMap);
|
|
263681
|
+
if (!outcome.ok)
|
|
263682
|
+
return { ok: false, errors: outcome.errors };
|
|
263683
|
+
if (!outcome.map)
|
|
263684
|
+
return { ok: true, module: outcome.module };
|
|
263685
|
+
const functions = [];
|
|
263686
|
+
for (const { index, fn } of entries)
|
|
263687
|
+
functions[index] = fn;
|
|
263688
|
+
return {
|
|
263689
|
+
ok: true,
|
|
263690
|
+
module: outcome.module,
|
|
263691
|
+
map: appSourceMap(outcome.map, functions)
|
|
263692
|
+
};
|
|
263670
263693
|
}
|
|
263671
263694
|
function allOk(entries) {
|
|
263672
263695
|
return entries.map((e) => ({ name: e.fn.name, ok: true }));
|
|
263673
263696
|
}
|
|
263674
|
-
function appResponse(
|
|
263675
|
-
return {
|
|
263697
|
+
function appResponse(built, functions) {
|
|
263698
|
+
return {
|
|
263699
|
+
ok: true,
|
|
263700
|
+
module: built.module,
|
|
263701
|
+
...built.map ? { source_map: built.map } : {},
|
|
263702
|
+
main_module: MAIN_MODULE,
|
|
263703
|
+
functions
|
|
263704
|
+
};
|
|
263676
263705
|
}
|
|
263677
263706
|
function classifyAppErrors(errors) {
|
|
263678
263707
|
const byIndex = new Map;
|
|
@@ -263690,19 +263719,19 @@ function classifyAppErrors(errors) {
|
|
|
263690
263719
|
}
|
|
263691
263720
|
return { byIndex, unattributable };
|
|
263692
263721
|
}
|
|
263693
|
-
async function bundleAppPerFunction(entries,
|
|
263694
|
-
const probes = await mapWithConcurrency(entries, MAX_PARALLEL_COMPILES, (entry) => probeFunction(entry, runtimeSecrets));
|
|
263722
|
+
async function bundleAppPerFunction(entries, build) {
|
|
263723
|
+
const probes = await mapWithConcurrency(entries, MAX_PARALLEL_COMPILES, (entry) => probeFunction(entry, build.runtimeSecrets));
|
|
263695
263724
|
const functions = probes.map((p) => p.ok ? { name: p.entry.fn.name, ok: true } : { name: p.entry.fn.name, ok: false, errors: p.errors });
|
|
263696
263725
|
const survivors = probes.filter((p) => p.ok).map((p) => p.entry);
|
|
263697
263726
|
if (survivors.length === 0) {
|
|
263698
263727
|
return { ok: false, module: null, functions };
|
|
263699
263728
|
}
|
|
263700
|
-
const combined = await compileApp(survivors,
|
|
263729
|
+
const combined = await compileApp(survivors, build);
|
|
263701
263730
|
if (combined.ok)
|
|
263702
|
-
return appResponse(combined
|
|
263703
|
-
return assembleWithoutConflicting(survivors, functions, combined.errors,
|
|
263731
|
+
return appResponse(combined, functions);
|
|
263732
|
+
return assembleWithoutConflicting(survivors, functions, combined.errors, build);
|
|
263704
263733
|
}
|
|
263705
|
-
async function assembleWithoutConflicting(survivors, functions, errors,
|
|
263734
|
+
async function assembleWithoutConflicting(survivors, functions, errors, build) {
|
|
263706
263735
|
const failWith = (entries, items) => {
|
|
263707
263736
|
for (const e of entries) {
|
|
263708
263737
|
functions[e.index] = { name: e.fn.name, ok: false, errors: items };
|
|
@@ -263717,10 +263746,10 @@ async function assembleWithoutConflicting(survivors, functions, errors, telemetr
|
|
|
263717
263746
|
const blamed = survivors.filter((e) => importsConflictingPackage(e, errors));
|
|
263718
263747
|
const rest = survivors.filter((e) => !blamed.includes(e));
|
|
263719
263748
|
if (blamed.length > 0 && rest.length > 0) {
|
|
263720
|
-
const rebuilt = await compileApp(rest,
|
|
263749
|
+
const rebuilt = await compileApp(rest, build);
|
|
263721
263750
|
if (rebuilt.ok) {
|
|
263722
263751
|
failWith(blamed, conflictErrors);
|
|
263723
|
-
return appResponse(rebuilt
|
|
263752
|
+
return appResponse(rebuilt, functions);
|
|
263724
263753
|
}
|
|
263725
263754
|
failWith(blamed, conflictErrors);
|
|
263726
263755
|
failWith(rest, [conflictErrors[0], ...rebuilt.errors]);
|
|
@@ -263757,7 +263786,11 @@ function escapeRegExp(s) {
|
|
|
263757
263786
|
async function probeFunction(entry, runtimeSecrets = false) {
|
|
263758
263787
|
let outcome;
|
|
263759
263788
|
try {
|
|
263760
|
-
outcome = await compileApp([entry],
|
|
263789
|
+
outcome = await compileApp([entry], {
|
|
263790
|
+
telemetry: false,
|
|
263791
|
+
runtimeSecrets,
|
|
263792
|
+
sourceMap: false
|
|
263793
|
+
});
|
|
263761
263794
|
} catch (e) {
|
|
263762
263795
|
if (e instanceof DenoCompatError) {
|
|
263763
263796
|
return { ok: false, entry, errors: [denoCompatErrorItem(e)] };
|
|
@@ -263787,20 +263820,25 @@ async function mapWithConcurrency(items, limit, fn) {
|
|
|
263787
263820
|
return results;
|
|
263788
263821
|
}
|
|
263789
263822
|
var NODE_MODULES_FALLBACK = /ERR_MODULE_NOT_FOUND|Could not find referrer npm package/;
|
|
263790
|
-
async function installAndCompile(prepared) {
|
|
263823
|
+
async function installAndCompile(prepared, sourceMap = false) {
|
|
263791
263824
|
return withSpan("base44.bundler.compile", async () => {
|
|
263792
263825
|
let mode = "none";
|
|
263793
|
-
let result = await bundleToModule(prepared, mode);
|
|
263826
|
+
let result = await bundleToModule(prepared, mode, sourceMap);
|
|
263794
263827
|
if (!result.ok && result.errors.some((e) => NODE_MODULES_FALLBACK.test(e.message))) {
|
|
263795
263828
|
mode = "auto";
|
|
263796
|
-
result = await bundleToModule(prepared, mode);
|
|
263829
|
+
result = await bundleToModule(prepared, mode, sourceMap);
|
|
263797
263830
|
}
|
|
263798
263831
|
await setSpanTags({
|
|
263799
263832
|
node_modules_mode: mode,
|
|
263800
263833
|
outcome: result.ok ? "ok" : "failed"
|
|
263801
263834
|
});
|
|
263802
263835
|
if (result.ok) {
|
|
263803
|
-
return {
|
|
263836
|
+
return {
|
|
263837
|
+
ok: true,
|
|
263838
|
+
module: result.module,
|
|
263839
|
+
...result.map ? { map: result.map } : {},
|
|
263840
|
+
warnings: result.warnings
|
|
263841
|
+
};
|
|
263804
263842
|
}
|
|
263805
263843
|
return { ok: false, stage: "esbuild", errors: result.errors };
|
|
263806
263844
|
});
|
|
@@ -274027,4 +274065,4 @@ export {
|
|
|
274027
274065
|
runCLI
|
|
274028
274066
|
};
|
|
274029
274067
|
|
|
274030
|
-
//# debugId=
|
|
274068
|
+
//# debugId=3CA0B8062C899A1564756E2164756E21
|