@base44-preview/cli 0.1.1-pr.555.9853704 → 0.1.1-pr.555.9975160
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 +86 -31
- package/dist/cli/index.js.map +6 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -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
|
+
inbound: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
243763
|
+
outbound: 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,12 +243808,13 @@ 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 = {
|
|
243817
|
+
types: result.data.types,
|
|
243816
243818
|
inbound: result.data.inbound,
|
|
243817
243819
|
outbound: result.data.outbound
|
|
243818
243820
|
};
|
|
@@ -254696,7 +254698,10 @@ var SDK_PACKAGE_NAMES = ["@base44/sdk", "@base44-preview/sdk"];
|
|
|
254696
254698
|
async function detectSdkPackageName(projectRoot) {
|
|
254697
254699
|
try {
|
|
254698
254700
|
const pkg = await readJsonFile(join26(projectRoot, "package.json"));
|
|
254699
|
-
const deps = {
|
|
254701
|
+
const deps = {
|
|
254702
|
+
...pkg.dependencies,
|
|
254703
|
+
...pkg.devDependencies
|
|
254704
|
+
};
|
|
254700
254705
|
for (const name2 of SDK_PACKAGE_NAMES) {
|
|
254701
254706
|
if (name2 in deps)
|
|
254702
254707
|
return name2;
|
|
@@ -254714,7 +254719,7 @@ async function generateContent(input) {
|
|
|
254714
254719
|
if (!entities.length && !functions.length && !agents.length && !connectors.length && !realtimeHandlers.length) {
|
|
254715
254720
|
return EMPTY_TEMPLATE;
|
|
254716
254721
|
}
|
|
254717
|
-
const [entityInterfaces,
|
|
254722
|
+
const [entityInterfaces, realtimeResults] = await Promise.all([
|
|
254718
254723
|
Promise.all(entities.map((e8) => compileEntity(e8))),
|
|
254719
254724
|
Promise.all(realtimeHandlers.map((h5) => compileRealtimeHandler(h5)))
|
|
254720
254725
|
]);
|
|
@@ -254732,18 +254737,22 @@ async function generateContent(input) {
|
|
|
254732
254737
|
],
|
|
254733
254738
|
[
|
|
254734
254739
|
"RealtimeHandlerRegistry",
|
|
254735
|
-
realtimeHandlers.filter((h5) => h5.messageSchema).map((h5
|
|
254740
|
+
realtimeHandlers.filter((h5) => h5.messageSchema).map((h5) => {
|
|
254736
254741
|
const idx = realtimeHandlers.indexOf(h5);
|
|
254737
|
-
return `"${h5.name}": ${
|
|
254742
|
+
return `"${h5.name}": ${realtimeResults[idx].entry};`;
|
|
254738
254743
|
})
|
|
254739
254744
|
]
|
|
254740
254745
|
];
|
|
254741
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);
|
|
254742
254748
|
return [
|
|
254743
254749
|
HEADER2,
|
|
254744
254750
|
"export {};",
|
|
254745
254751
|
entityInterfaces.join(`
|
|
254746
254752
|
|
|
254753
|
+
`),
|
|
254754
|
+
realtimeInterfaces.join(`
|
|
254755
|
+
|
|
254747
254756
|
`),
|
|
254748
254757
|
import_common_tags.source`
|
|
254749
254758
|
declare module '${sdkPackage}' {
|
|
@@ -254776,29 +254785,75 @@ async function compileEntity(entity2) {
|
|
|
254776
254785
|
}
|
|
254777
254786
|
async function compileRealtimeHandler(handler) {
|
|
254778
254787
|
const { messageSchema } = handler;
|
|
254779
|
-
if (!messageSchema)
|
|
254780
|
-
return "{ inbound: unknown; outbound: unknown }";
|
|
254781
|
-
|
|
254782
|
-
|
|
254783
|
-
|
|
254784
|
-
|
|
254785
|
-
|
|
254786
|
-
|
|
254787
|
-
|
|
254788
|
-
|
|
254789
|
-
|
|
254790
|
-
|
|
254791
|
-
|
|
254792
|
-
|
|
254793
|
-
|
|
254794
|
-
|
|
254795
|
-
|
|
254788
|
+
if (!messageSchema) {
|
|
254789
|
+
return { decls: "", entry: "{ inbound: unknown; outbound: unknown }" };
|
|
254790
|
+
}
|
|
254791
|
+
const prefix = toPascalCase(handler.name);
|
|
254792
|
+
const types = messageSchema.types ?? {};
|
|
254793
|
+
const inbound = messageSchema.inbound ?? {};
|
|
254794
|
+
const outbound = messageSchema.outbound ?? {};
|
|
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 inboundNames = compileMessages(inbound, "Inbound");
|
|
254820
|
+
const outboundNames = compileMessages(outbound, "Outbound");
|
|
254821
|
+
const allNames = [...inboundNames, ...outboundNames];
|
|
254822
|
+
const rootName = `${prefix}Message`;
|
|
254823
|
+
const rootSchema = {
|
|
254824
|
+
title: rootName,
|
|
254825
|
+
$defs: defs,
|
|
254826
|
+
oneOf: allNames.map((n5) => ({ $ref: `#/$defs/${n5}` }))
|
|
254796
254827
|
};
|
|
254797
|
-
|
|
254798
|
-
|
|
254799
|
-
|
|
254800
|
-
|
|
254801
|
-
|
|
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: `{ inbound: ${union2(inboundNames)}; outbound: ${union2(outboundNames)} }`
|
|
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;
|
|
254802
254857
|
}
|
|
254803
254858
|
function registry2(name2, entries) {
|
|
254804
254859
|
return import_common_tags.source`
|
|
@@ -262893,4 +262948,4 @@ export {
|
|
|
262893
262948
|
CLIExitError
|
|
262894
262949
|
};
|
|
262895
262950
|
|
|
262896
|
-
//# debugId=
|
|
262951
|
+
//# debugId=844227E4524139FD64756E2164756E21
|