@base44-preview/cli 0.1.1-pr.555.5e8fb00 → 0.1.1-pr.555.77b65cb
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 -47
- package/dist/cli/index.js.map +6 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -163947,7 +163947,7 @@ var require_view = __commonJS((exports, module) => {
|
|
|
163947
163947
|
var dirname22 = path18.dirname;
|
|
163948
163948
|
var basename7 = path18.basename;
|
|
163949
163949
|
var extname2 = path18.extname;
|
|
163950
|
-
var
|
|
163950
|
+
var join28 = path18.join;
|
|
163951
163951
|
var resolve12 = path18.resolve;
|
|
163952
163952
|
module.exports = View;
|
|
163953
163953
|
function View(name2, options8) {
|
|
@@ -164009,12 +164009,12 @@ var require_view = __commonJS((exports, module) => {
|
|
|
164009
164009
|
};
|
|
164010
164010
|
View.prototype.resolve = function resolve13(dir, file2) {
|
|
164011
164011
|
var ext = this.ext;
|
|
164012
|
-
var path19 =
|
|
164012
|
+
var path19 = join28(dir, file2);
|
|
164013
164013
|
var stat2 = tryStat(path19);
|
|
164014
164014
|
if (stat2 && stat2.isFile()) {
|
|
164015
164015
|
return path19;
|
|
164016
164016
|
}
|
|
164017
|
-
path19 =
|
|
164017
|
+
path19 = join28(dir, basename7(file2, ext), "index" + ext);
|
|
164018
164018
|
stat2 = tryStat(path19);
|
|
164019
164019
|
if (stat2 && stat2.isFile()) {
|
|
164020
164020
|
return path19;
|
|
@@ -167709,7 +167709,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
167709
167709
|
var Stream2 = __require("stream");
|
|
167710
167710
|
var util2 = __require("util");
|
|
167711
167711
|
var extname2 = path18.extname;
|
|
167712
|
-
var
|
|
167712
|
+
var join28 = path18.join;
|
|
167713
167713
|
var normalize2 = path18.normalize;
|
|
167714
167714
|
var resolve12 = path18.resolve;
|
|
167715
167715
|
var sep = path18.sep;
|
|
@@ -167881,7 +167881,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
167881
167881
|
return res;
|
|
167882
167882
|
}
|
|
167883
167883
|
parts = path19.split(sep);
|
|
167884
|
-
path19 = normalize2(
|
|
167884
|
+
path19 = normalize2(join28(root2, path19));
|
|
167885
167885
|
} else {
|
|
167886
167886
|
if (UP_PATH_REGEXP.test(path19)) {
|
|
167887
167887
|
debug('malicious path "%s"', path19);
|
|
@@ -168021,7 +168021,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
168021
168021
|
return self2.onStatError(err);
|
|
168022
168022
|
return self2.error(404);
|
|
168023
168023
|
}
|
|
168024
|
-
var p4 =
|
|
168024
|
+
var p4 = join28(path19, self2._index[i5]);
|
|
168025
168025
|
debug('stat "%s"', p4);
|
|
168026
168026
|
fs28.stat(p4, function(err2, stat2) {
|
|
168027
168027
|
if (err2)
|
|
@@ -214616,7 +214616,7 @@ var require_buffer_list = __commonJS((exports, module) => {
|
|
|
214616
214616
|
}
|
|
214617
214617
|
}, {
|
|
214618
214618
|
key: "join",
|
|
214619
|
-
value: function
|
|
214619
|
+
value: function join28(s5) {
|
|
214620
214620
|
if (this.length === 0)
|
|
214621
214621
|
return "";
|
|
214622
214622
|
var p4 = this.head;
|
|
@@ -234018,7 +234018,7 @@ function normalizeBase44Env() {
|
|
|
234018
234018
|
loadProjectEnvFiles();
|
|
234019
234019
|
|
|
234020
234020
|
// src/cli/index.ts
|
|
234021
|
-
import { dirname as dirname26, join as
|
|
234021
|
+
import { dirname as dirname26, join as join31 } from "node:path";
|
|
234022
234022
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
234023
234023
|
|
|
234024
234024
|
// ../../node_modules/@clack/core/dist/index.mjs
|
|
@@ -243758,8 +243758,9 @@ var RealtimeHandlerConfigSchema = exports_external.object({
|
|
|
243758
243758
|
entry: exports_external.string().min(1)
|
|
243759
243759
|
});
|
|
243760
243760
|
var RealtimeHandlerSchemaFileSchema = exports_external.object({
|
|
243761
|
-
|
|
243762
|
-
|
|
243761
|
+
types: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
243762
|
+
toClient: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
243763
|
+
toServer: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
243763
243764
|
});
|
|
243764
243765
|
var DeployRealtimeHandlerResponseSchema = exports_external.object({
|
|
243765
243766
|
status: exports_external.enum(["deployed", "unchanged"]),
|
|
@@ -243777,7 +243778,7 @@ async function deploySingleRealtimeHandler(name2, payload) {
|
|
|
243777
243778
|
const appClient = getAppClient();
|
|
243778
243779
|
let response;
|
|
243779
243780
|
try {
|
|
243780
|
-
response = await appClient.put(`
|
|
243781
|
+
response = await appClient.put(`realtime-handlers/${encodeURIComponent(name2)}`, { json: payload, timeout: false });
|
|
243781
243782
|
} catch (error48) {
|
|
243782
243783
|
throw await ApiError.fromHttpError(error48, `deploying realtime handler "${name2}"`);
|
|
243783
243784
|
}
|
|
@@ -243807,14 +243808,15 @@ async function readRealtimeHandler(entryFile, realtimeDir) {
|
|
|
243807
243808
|
}
|
|
243808
243809
|
const entry = basename4(entryFile);
|
|
243809
243810
|
const schemaPath = join10(handlerDir, "schema.jsonc");
|
|
243810
|
-
let messageSchema
|
|
243811
|
+
let messageSchema;
|
|
243811
243812
|
if (await pathExists(schemaPath)) {
|
|
243812
243813
|
const parsed = await readJsonFile(schemaPath);
|
|
243813
243814
|
const result = RealtimeHandlerSchemaFileSchema.safeParse(parsed);
|
|
243814
243815
|
if (result.success) {
|
|
243815
243816
|
messageSchema = {
|
|
243816
|
-
|
|
243817
|
-
|
|
243817
|
+
types: result.data.types,
|
|
243818
|
+
toClient: result.data.toClient,
|
|
243819
|
+
toServer: result.data.toServer
|
|
243818
243820
|
};
|
|
243819
243821
|
}
|
|
243820
243822
|
}
|
|
@@ -254675,6 +254677,7 @@ function getSiteCommand() {
|
|
|
254675
254677
|
// src/core/types/generator.ts
|
|
254676
254678
|
var import_common_tags = __toESM(require_lib2(), 1);
|
|
254677
254679
|
var import_json_schema_to_typescript = __toESM(require_src3(), 1);
|
|
254680
|
+
import { join as join26 } from "node:path";
|
|
254678
254681
|
var HEADER2 = import_common_tags.stripIndent`
|
|
254679
254682
|
// Auto-generated by Base44 CLI - DO NOT EDIT
|
|
254680
254683
|
// Regenerate with: base44 types generate
|
|
@@ -254691,16 +254694,32 @@ var EMPTY_TEMPLATE = import_common_tags.stripIndent`
|
|
|
254691
254694
|
// No types to augment - add resources and regenerate
|
|
254692
254695
|
}
|
|
254693
254696
|
`;
|
|
254697
|
+
var SDK_PACKAGE_NAMES = ["@base44/sdk", "@base44-preview/sdk"];
|
|
254698
|
+
async function detectSdkPackageName(projectRoot) {
|
|
254699
|
+
try {
|
|
254700
|
+
const pkg = await readJsonFile(join26(projectRoot, "package.json"));
|
|
254701
|
+
const deps = {
|
|
254702
|
+
...pkg.dependencies,
|
|
254703
|
+
...pkg.devDependencies
|
|
254704
|
+
};
|
|
254705
|
+
for (const name2 of SDK_PACKAGE_NAMES) {
|
|
254706
|
+
if (name2 in deps)
|
|
254707
|
+
return name2;
|
|
254708
|
+
}
|
|
254709
|
+
} catch {}
|
|
254710
|
+
return "@base44/sdk";
|
|
254711
|
+
}
|
|
254694
254712
|
async function generateTypesFile(input) {
|
|
254695
254713
|
const content = await generateContent(input);
|
|
254696
254714
|
await writeFile(getTypesOutputPath(input.projectRoot), content);
|
|
254697
254715
|
}
|
|
254698
254716
|
async function generateContent(input) {
|
|
254699
254717
|
const { entities, functions, agents, connectors, realtimeHandlers } = input;
|
|
254718
|
+
const sdkPackage = await detectSdkPackageName(input.projectRoot);
|
|
254700
254719
|
if (!entities.length && !functions.length && !agents.length && !connectors.length && !realtimeHandlers.length) {
|
|
254701
254720
|
return EMPTY_TEMPLATE;
|
|
254702
254721
|
}
|
|
254703
|
-
const [entityInterfaces,
|
|
254722
|
+
const [entityInterfaces, realtimeResults] = await Promise.all([
|
|
254704
254723
|
Promise.all(entities.map((e8) => compileEntity(e8))),
|
|
254705
254724
|
Promise.all(realtimeHandlers.map((h5) => compileRealtimeHandler(h5)))
|
|
254706
254725
|
]);
|
|
@@ -254718,20 +254737,25 @@ async function generateContent(input) {
|
|
|
254718
254737
|
],
|
|
254719
254738
|
[
|
|
254720
254739
|
"RealtimeHandlerRegistry",
|
|
254721
|
-
realtimeHandlers.filter((h5) => h5.messageSchema).map((h5
|
|
254740
|
+
realtimeHandlers.filter((h5) => h5.messageSchema).map((h5) => {
|
|
254722
254741
|
const idx = realtimeHandlers.indexOf(h5);
|
|
254723
|
-
return `"${h5.name}": ${
|
|
254742
|
+
return `"${h5.name}": ${realtimeResults[idx].entry};`;
|
|
254724
254743
|
})
|
|
254725
254744
|
]
|
|
254726
254745
|
];
|
|
254727
254746
|
const registries2 = registryEntries.filter(([, entries]) => entries.length > 0).map(([name2, entries]) => registry2(name2, entries));
|
|
254747
|
+
const realtimeInterfaces = realtimeResults.map((r5) => r5.decls).filter(Boolean);
|
|
254728
254748
|
return [
|
|
254729
254749
|
HEADER2,
|
|
254750
|
+
"export {};",
|
|
254730
254751
|
entityInterfaces.join(`
|
|
254731
254752
|
|
|
254753
|
+
`),
|
|
254754
|
+
realtimeInterfaces.join(`
|
|
254755
|
+
|
|
254732
254756
|
`),
|
|
254733
254757
|
import_common_tags.source`
|
|
254734
|
-
declare module '
|
|
254758
|
+
declare module '${sdkPackage}' {
|
|
254735
254759
|
${registries2.join(`
|
|
254736
254760
|
|
|
254737
254761
|
`)}
|
|
@@ -254761,29 +254785,75 @@ async function compileEntity(entity2) {
|
|
|
254761
254785
|
}
|
|
254762
254786
|
async function compileRealtimeHandler(handler) {
|
|
254763
254787
|
const { messageSchema } = handler;
|
|
254764
|
-
if (!messageSchema)
|
|
254765
|
-
return "{
|
|
254766
|
-
|
|
254767
|
-
|
|
254768
|
-
|
|
254769
|
-
|
|
254770
|
-
|
|
254771
|
-
|
|
254772
|
-
|
|
254773
|
-
|
|
254774
|
-
|
|
254775
|
-
|
|
254776
|
-
|
|
254777
|
-
|
|
254778
|
-
|
|
254779
|
-
|
|
254780
|
-
|
|
254788
|
+
if (!messageSchema) {
|
|
254789
|
+
return { decls: "", entry: "{ toClient: unknown; toServer: unknown }" };
|
|
254790
|
+
}
|
|
254791
|
+
const prefix = toPascalCase(handler.name);
|
|
254792
|
+
const types = messageSchema.types ?? {};
|
|
254793
|
+
const toClient = messageSchema.toClient ?? {};
|
|
254794
|
+
const toServer = messageSchema.toServer ?? {};
|
|
254795
|
+
const typeName = (key2) => `${prefix}${toPascalCase(key2)}`;
|
|
254796
|
+
const msgName = (dir, key2) => `${prefix}${dir}${toPascalCase(key2)}`;
|
|
254797
|
+
const defs = {};
|
|
254798
|
+
const add = (name2, schema11) => {
|
|
254799
|
+
if (name2 in defs) {
|
|
254800
|
+
throw new TypeGenerationError(`Duplicate generated type "${name2}" in realtime handler "${handler.name}" — a shared type and a message resolve to the same name.`, handler.name);
|
|
254801
|
+
}
|
|
254802
|
+
defs[name2] = { ...schema11, title: name2 };
|
|
254803
|
+
};
|
|
254804
|
+
for (const [key2, schema11] of Object.entries(types)) {
|
|
254805
|
+
add(typeName(key2), rewriteTypeRefs(schema11, typeName));
|
|
254806
|
+
}
|
|
254807
|
+
const compileMessages = (msgs, dir) => Object.entries(msgs).map(([key2, schema11]) => {
|
|
254808
|
+
const name2 = msgName(dir, key2);
|
|
254809
|
+
const rewritten = rewriteTypeRefs(schema11, typeName);
|
|
254810
|
+
add(name2, {
|
|
254811
|
+
type: "object",
|
|
254812
|
+
...rewritten,
|
|
254813
|
+
properties: { type: { const: key2 }, ...rewritten.properties ?? {} },
|
|
254814
|
+
required: ["type", ...rewritten.required ?? []],
|
|
254815
|
+
additionalProperties: false
|
|
254816
|
+
});
|
|
254817
|
+
return name2;
|
|
254818
|
+
});
|
|
254819
|
+
const toClientNames = compileMessages(toClient, "ToClient");
|
|
254820
|
+
const toServerNames = compileMessages(toServer, "ToServer");
|
|
254821
|
+
const allNames = [...toClientNames, ...toServerNames];
|
|
254822
|
+
const rootName = `${prefix}Message`;
|
|
254823
|
+
const rootSchema = {
|
|
254824
|
+
title: rootName,
|
|
254825
|
+
$defs: defs,
|
|
254826
|
+
oneOf: allNames.map((n5) => ({ $ref: `#/$defs/${n5}` }))
|
|
254781
254827
|
};
|
|
254782
|
-
|
|
254783
|
-
|
|
254784
|
-
|
|
254785
|
-
|
|
254786
|
-
|
|
254828
|
+
let decls = "";
|
|
254829
|
+
try {
|
|
254830
|
+
decls = (await import_json_schema_to_typescript.compile(rootSchema, rootName, {
|
|
254831
|
+
bannerComment: "",
|
|
254832
|
+
additionalProperties: false,
|
|
254833
|
+
strictIndexSignatures: true
|
|
254834
|
+
})).trim();
|
|
254835
|
+
} catch (error48) {
|
|
254836
|
+
throw new TypeGenerationError(`Failed to generate types for realtime handler "${handler.name}"`, handler.name, error48);
|
|
254837
|
+
}
|
|
254838
|
+
const union2 = (names) => names.length ? names.join(" | ") : "never";
|
|
254839
|
+
return {
|
|
254840
|
+
decls,
|
|
254841
|
+
entry: `{ toClient: ${union2(toClientNames)}; toServer: ${union2(toServerNames)} }`
|
|
254842
|
+
};
|
|
254843
|
+
}
|
|
254844
|
+
function rewriteTypeRefs(node, defName) {
|
|
254845
|
+
if (Array.isArray(node)) {
|
|
254846
|
+
return node.map((n5) => rewriteTypeRefs(n5, defName));
|
|
254847
|
+
}
|
|
254848
|
+
if (node && typeof node === "object") {
|
|
254849
|
+
const out = {};
|
|
254850
|
+
for (const [key2, value] of Object.entries(node)) {
|
|
254851
|
+
const match = key2 === "$ref" && typeof value === "string" ? value.match(/^#\/types\/(.+)$/) : null;
|
|
254852
|
+
out[key2] = match ? `#/$defs/${defName(match[1])}` : rewriteTypeRefs(value, defName);
|
|
254853
|
+
}
|
|
254854
|
+
return out;
|
|
254855
|
+
}
|
|
254856
|
+
return node;
|
|
254787
254857
|
}
|
|
254788
254858
|
function registry2(name2, entries) {
|
|
254789
254859
|
return import_common_tags.source`
|
|
@@ -254797,10 +254867,10 @@ function toPascalCase(name2) {
|
|
|
254797
254867
|
return name2.split(/[-_\s]+/).map((w8) => w8.charAt(0).toUpperCase() + w8.slice(1)).join("");
|
|
254798
254868
|
}
|
|
254799
254869
|
// src/core/types/update-project.ts
|
|
254800
|
-
import { join as
|
|
254870
|
+
import { join as join27 } from "node:path";
|
|
254801
254871
|
var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
|
|
254802
254872
|
async function updateProjectConfig(projectRoot) {
|
|
254803
|
-
const tsconfigPath =
|
|
254873
|
+
const tsconfigPath = join27(projectRoot, "tsconfig.json");
|
|
254804
254874
|
if (!await pathExists(tsconfigPath)) {
|
|
254805
254875
|
return false;
|
|
254806
254876
|
}
|
|
@@ -254852,7 +254922,7 @@ function getTypesCommand() {
|
|
|
254852
254922
|
// src/cli/dev/dev-server/main.ts
|
|
254853
254923
|
var import_cors = __toESM(require_lib4(), 1);
|
|
254854
254924
|
var import_express6 = __toESM(require_express(), 1);
|
|
254855
|
-
import { dirname as dirname24, join as
|
|
254925
|
+
import { dirname as dirname24, join as join30 } from "node:path";
|
|
254856
254926
|
|
|
254857
254927
|
// ../../node_modules/get-port/index.js
|
|
254858
254928
|
import net from "node:net";
|
|
@@ -258272,8 +258342,8 @@ async function createDevServer(options8) {
|
|
|
258272
258342
|
broadcastEntityEvent(io6, appId, entityName, event);
|
|
258273
258343
|
};
|
|
258274
258344
|
const base44ConfigWatcher = new WatchBase44({
|
|
258275
|
-
functions:
|
|
258276
|
-
entities:
|
|
258345
|
+
functions: join30(dirname24(project2.configPath), project2.functionsDir),
|
|
258346
|
+
entities: join30(dirname24(project2.configPath), project2.entitiesDir)
|
|
258277
258347
|
}, devLogger);
|
|
258278
258348
|
base44ConfigWatcher.on("change", async (name2) => {
|
|
258279
258349
|
try {
|
|
@@ -262839,7 +262909,7 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
|
|
|
262839
262909
|
// src/cli/index.ts
|
|
262840
262910
|
var __dirname4 = dirname26(fileURLToPath6(import.meta.url));
|
|
262841
262911
|
async function runCLI(options8) {
|
|
262842
|
-
ensureNpmAssets(
|
|
262912
|
+
ensureNpmAssets(join31(__dirname4, "../assets"));
|
|
262843
262913
|
const errorReporter = new ErrorReporter;
|
|
262844
262914
|
errorReporter.registerProcessErrorHandlers();
|
|
262845
262915
|
const jsonMode = process.argv.includes("--json");
|
|
@@ -262878,4 +262948,4 @@ export {
|
|
|
262878
262948
|
CLIExitError
|
|
262879
262949
|
};
|
|
262880
262950
|
|
|
262881
|
-
//# debugId=
|
|
262951
|
+
//# debugId=89497C2C2C3F39A664756E2164756E21
|