@base44-preview/cli 0.1.1-pr.555.8c33067 → 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 CHANGED
@@ -20114,7 +20114,7 @@ var require_lodash8 = __commonJS((exports, module) => {
20114
20114
  }
20115
20115
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
20116
20116
  });
20117
- function join14(array2, separator) {
20117
+ function join15(array2, separator) {
20118
20118
  return array2 == null ? "" : nativeJoin.call(array2, separator);
20119
20119
  }
20120
20120
  function last(array2) {
@@ -22046,7 +22046,7 @@ __p += '`;
22046
22046
  lodash.isUndefined = isUndefined;
22047
22047
  lodash.isWeakMap = isWeakMap;
22048
22048
  lodash.isWeakSet = isWeakSet;
22049
- lodash.join = join14;
22049
+ lodash.join = join15;
22050
22050
  lodash.kebabCase = kebabCase;
22051
22051
  lodash.last = last;
22052
22052
  lodash.lastIndexOf = lastIndexOf;
@@ -31158,7 +31158,7 @@ function cleanDoc(doc2) {
31158
31158
  return mapDoc(doc2, (currentDoc) => cleanDocFn(currentDoc));
31159
31159
  }
31160
31160
  function replaceEndOfLine(doc2, replacement = literalline) {
31161
- return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join23(replacement, currentDoc.split(`
31161
+ return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join24(replacement, currentDoc.split(`
31162
31162
  `)) : currentDoc);
31163
31163
  }
31164
31164
  function canBreakFn(doc2) {
@@ -31238,7 +31238,7 @@ function indentIfBreak(contents, options) {
31238
31238
  negate: options.negate
31239
31239
  };
31240
31240
  }
31241
- function join23(separator, docs) {
31241
+ function join24(separator, docs) {
31242
31242
  assertDoc(separator);
31243
31243
  assertDocArray(docs);
31244
31244
  const parts = [];
@@ -31949,7 +31949,7 @@ var init_doc = __esm(() => {
31949
31949
  MODE_FLAT = Symbol("MODE_FLAT");
31950
31950
  DOC_FILL_PRINTED_LENGTH = Symbol("DOC_FILL_PRINTED_LENGTH");
31951
31951
  builders = {
31952
- join: join23,
31952
+ join: join24,
31953
31953
  line,
31954
31954
  softline,
31955
31955
  hardline,
@@ -136863,7 +136863,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
136863
136863
  return mapDoc2(doc2, (currentDoc) => cleanDocFn2(currentDoc));
136864
136864
  }
136865
136865
  function replaceEndOfLine2(doc2, replacement = literalline2) {
136866
- return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join25(replacement, currentDoc.split(`
136866
+ return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join26(replacement, currentDoc.split(`
136867
136867
  `)) : currentDoc);
136868
136868
  }
136869
136869
  function canBreakFn2(doc2) {
@@ -136949,7 +136949,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
136949
136949
  negate: options8.negate
136950
136950
  };
136951
136951
  }
136952
- function join25(separator, docs) {
136952
+ function join26(separator, docs) {
136953
136953
  assertDoc2(separator);
136954
136954
  assertDocArray2(docs);
136955
136955
  const parts = [];
@@ -137614,7 +137614,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
137614
137614
  }
137615
137615
  }
137616
137616
  var builders2 = {
137617
- join: join25,
137617
+ join: join26,
137618
137618
  line: line3,
137619
137619
  softline: softline2,
137620
137620
  hardline: hardline4,
@@ -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 join26 = path18.join;
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 = join26(dir, file2);
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 = join26(dir, basename7(file2, ext), "index" + ext);
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 join26 = path18.join;
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(join26(root2, path19));
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 = join26(path19, self2._index[i5]);
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 join26(s5) {
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 join29 } from "node:path";
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
@@ -235226,7 +235226,7 @@ var {
235226
235226
  } = import__.default;
235227
235227
 
235228
235228
  // src/cli/commands/agents/pull.ts
235229
- import { dirname as dirname12, join as join14 } from "node:path";
235229
+ import { dirname as dirname12, join as join15 } from "node:path";
235230
235230
  // ../../node_modules/chalk/source/vendor/ansi-styles/index.js
235231
235231
  var ANSI_BACKGROUND_OFFSET = 10;
235232
235232
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
@@ -241895,7 +241895,7 @@ async function getSiteUrl() {
241895
241895
  return result.data.url;
241896
241896
  }
241897
241897
  // src/core/project/config.ts
241898
- import { dirname as dirname10, join as join10 } from "node:path";
241898
+ import { dirname as dirname10, join as join11 } from "node:path";
241899
241899
 
241900
241900
  // src/core/project/plugins.ts
241901
241901
  import { createRequire as createRequire2 } from "node:module";
@@ -243757,6 +243757,11 @@ var RealtimeHandlerConfigSchema = exports_external.object({
243757
243757
  name: exports_external.string().min(1),
243758
243758
  entry: exports_external.string().min(1)
243759
243759
  });
243760
+ var RealtimeHandlerSchemaFileSchema = exports_external.object({
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()
243764
+ });
243760
243765
  var DeployRealtimeHandlerResponseSchema = exports_external.object({
243761
243766
  status: exports_external.enum(["deployed", "unchanged"]),
243762
243767
  handler_name: exports_external.string().optional()
@@ -243764,7 +243769,8 @@ var DeployRealtimeHandlerResponseSchema = exports_external.object({
243764
243769
  var RealtimeHandlerSchema = RealtimeHandlerConfigSchema.extend({
243765
243770
  entryPath: exports_external.string().min(1),
243766
243771
  filePaths: exports_external.array(exports_external.string()).min(1),
243767
- source: ResourceSourceSchema
243772
+ source: ResourceSourceSchema,
243773
+ messageSchema: exports_external.unknown().optional()
243768
243774
  });
243769
243775
 
243770
243776
  // src/core/resources/realtime-handler/api.ts
@@ -243772,7 +243778,7 @@ async function deploySingleRealtimeHandler(name2, payload) {
243772
243778
  const appClient = getAppClient();
243773
243779
  let response;
243774
243780
  try {
243775
- response = await appClient.put(`backend-functions/${encodeURIComponent(name2)}`, { json: payload, timeout: false });
243781
+ response = await appClient.put(`realtime-handlers/${encodeURIComponent(name2)}`, { json: payload, timeout: false });
243776
243782
  } catch (error48) {
243777
243783
  throw await ApiError.fromHttpError(error48, `deploying realtime handler "${name2}"`);
243778
243784
  }
@@ -243783,7 +243789,7 @@ async function deploySingleRealtimeHandler(name2, payload) {
243783
243789
  return result.data;
243784
243790
  }
243785
243791
  // src/core/resources/realtime-handler/config.ts
243786
- import { basename as basename4, dirname as dirname8, relative as relative3 } from "node:path";
243792
+ import { basename as basename4, dirname as dirname8, join as join10, relative as relative3 } from "node:path";
243787
243793
  async function readRealtimeHandler(entryFile, realtimeDir) {
243788
243794
  const handlerDir = dirname8(entryFile);
243789
243795
  const filePaths = await globby("**/*.ts", {
@@ -243801,12 +243807,26 @@ async function readRealtimeHandler(entryFile, realtimeDir) {
243801
243807
  });
243802
243808
  }
243803
243809
  const entry = basename4(entryFile);
243810
+ const schemaPath = join10(handlerDir, "schema.jsonc");
243811
+ let messageSchema;
243812
+ if (await pathExists(schemaPath)) {
243813
+ const parsed = await readJsonFile(schemaPath);
243814
+ const result = RealtimeHandlerSchemaFileSchema.safeParse(parsed);
243815
+ if (result.success) {
243816
+ messageSchema = {
243817
+ types: result.data.types,
243818
+ inbound: result.data.inbound,
243819
+ outbound: result.data.outbound
243820
+ };
243821
+ }
243822
+ }
243804
243823
  return {
243805
243824
  name: name2,
243806
243825
  entry,
243807
243826
  entryPath: entryFile,
243808
243827
  filePaths,
243809
- source: { type: "project" }
243828
+ source: { type: "project" },
243829
+ messageSchema
243810
243830
  };
243811
243831
  }
243812
243832
  async function readAllRealtimeHandlers(realtimeDir) {
@@ -243933,12 +243953,12 @@ class ProjectConfigReader {
243933
243953
  connectors,
243934
243954
  authConfig
243935
243955
  ] = await Promise.all([
243936
- entityResource.readAll(join10(configDir, project.entitiesDir)),
243937
- functionResource.readAll(join10(configDir, project.functionsDir)),
243938
- realtimeHandlerResource.readAll(join10(configDir, project.realtimeDir)),
243939
- agentResource.readAll(join10(configDir, project.agentsDir)),
243940
- connectorResource.readAll(join10(configDir, project.connectorsDir)),
243941
- authConfigResource.readAll(join10(configDir, project.authDir))
243956
+ entityResource.readAll(join11(configDir, project.entitiesDir)),
243957
+ functionResource.readAll(join11(configDir, project.functionsDir)),
243958
+ realtimeHandlerResource.readAll(join11(configDir, project.realtimeDir)),
243959
+ agentResource.readAll(join11(configDir, project.agentsDir)),
243960
+ connectorResource.readAll(join11(configDir, project.connectorsDir)),
243961
+ authConfigResource.readAll(join11(configDir, project.authDir))
243942
243962
  ]);
243943
243963
  return {
243944
243964
  entities,
@@ -244048,12 +244068,12 @@ async function readProjectConfig(projectRoot) {
244048
244068
  // src/core/project/template.ts
244049
244069
  var import_ejs = __toESM(require_ejs(), 1);
244050
244070
  var import_front_matter = __toESM(require_front_matter(), 1);
244051
- import { dirname as dirname11, join as join12 } from "node:path";
244071
+ import { dirname as dirname11, join as join13 } from "node:path";
244052
244072
 
244053
244073
  // src/core/assets.ts
244054
244074
  import { cpSync, existsSync } from "node:fs";
244055
244075
  import { homedir as homedir2 } from "node:os";
244056
- import { join as join11 } from "node:path";
244076
+ import { join as join12 } from "node:path";
244057
244077
  // package.json
244058
244078
  var package_default = {
244059
244079
  name: "base44",
@@ -244154,18 +244174,18 @@ var package_default = {
244154
244174
  };
244155
244175
 
244156
244176
  // src/core/assets.ts
244157
- var ASSETS_DIR = join11(homedir2(), ".base44", "assets", package_default.version);
244177
+ var ASSETS_DIR = join12(homedir2(), ".base44", "assets", package_default.version);
244158
244178
  function getTemplatesDir() {
244159
- return join11(ASSETS_DIR, "templates");
244179
+ return join12(ASSETS_DIR, "templates");
244160
244180
  }
244161
244181
  function getTemplatesIndexPath() {
244162
- return join11(ASSETS_DIR, "templates", "templates.json");
244182
+ return join12(ASSETS_DIR, "templates", "templates.json");
244163
244183
  }
244164
244184
  function getDenoWrapperPath() {
244165
- return join11(ASSETS_DIR, "deno-runtime", "main.ts");
244185
+ return join12(ASSETS_DIR, "deno-runtime", "main.ts");
244166
244186
  }
244167
244187
  function getExecWrapperPath() {
244168
- return join11(ASSETS_DIR, "deno-runtime", "exec.ts");
244188
+ return join12(ASSETS_DIR, "deno-runtime", "exec.ts");
244169
244189
  }
244170
244190
  function ensureNpmAssets(sourceDir) {
244171
244191
  if (existsSync(ASSETS_DIR))
@@ -244187,7 +244207,7 @@ async function listTemplates() {
244187
244207
  }
244188
244208
  async function renderTemplate(template, destPath, data, options = {}) {
244189
244209
  const { skipExisting = false } = options;
244190
- const templateDir = join12(getTemplatesDir(), template.path);
244210
+ const templateDir = join13(getTemplatesDir(), template.path);
244191
244211
  const files = await globby("**/*", {
244192
244212
  cwd: templateDir,
244193
244213
  dot: true,
@@ -244195,20 +244215,20 @@ async function renderTemplate(template, destPath, data, options = {}) {
244195
244215
  });
244196
244216
  const skipped = [];
244197
244217
  for (const file2 of files) {
244198
- const srcPath = join12(templateDir, file2);
244218
+ const srcPath = join13(templateDir, file2);
244199
244219
  try {
244200
244220
  if (file2.endsWith(".ejs")) {
244201
244221
  const rendered = await import_ejs.default.renderFile(srcPath, data);
244202
244222
  const { attributes, body } = import_front_matter.default(rendered);
244203
- const destFile = attributes.outputFileName ? join12(dirname11(file2), attributes.outputFileName) : file2.replace(/\.ejs$/, "");
244204
- const destFilePath = join12(destPath, destFile);
244223
+ const destFile = attributes.outputFileName ? join13(dirname11(file2), attributes.outputFileName) : file2.replace(/\.ejs$/, "");
244224
+ const destFilePath = join13(destPath, destFile);
244205
244225
  if (skipExisting && await pathExists(destFilePath)) {
244206
244226
  skipped.push(destFile);
244207
244227
  continue;
244208
244228
  }
244209
244229
  await writeFile(destFilePath, body);
244210
244230
  } else {
244211
- const destFilePath = join12(destPath, file2);
244231
+ const destFilePath = join13(destPath, file2);
244212
244232
  if (skipExisting && await pathExists(destFilePath)) {
244213
244233
  skipped.push(file2);
244214
244234
  continue;
@@ -244302,7 +244322,7 @@ async function getSiteFilePaths(outputDir) {
244302
244322
  // src/core/site/deploy.ts
244303
244323
  import { randomUUID } from "node:crypto";
244304
244324
  import { tmpdir } from "node:os";
244305
- import { join as join13 } from "node:path";
244325
+ import { join as join14 } from "node:path";
244306
244326
  async function deploySite(siteOutputDir) {
244307
244327
  if (!await pathExists(siteOutputDir)) {
244308
244328
  throw new InvalidInputError(`Output directory does not exist: ${siteOutputDir}. Make sure to build your project first.`, {
@@ -244319,7 +244339,7 @@ async function deploySite(siteOutputDir) {
244319
244339
  ]
244320
244340
  });
244321
244341
  }
244322
- const archivePath = join13(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
244342
+ const archivePath = join14(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
244323
244343
  try {
244324
244344
  await createArchive(siteOutputDir, archivePath);
244325
244345
  return await uploadSite(archivePath);
@@ -251567,7 +251587,7 @@ async function pullAgentsAction({
251567
251587
  }) {
251568
251588
  const { project: project2 } = await readProjectConfig();
251569
251589
  const configDir = dirname12(project2.configPath);
251570
- const agentsDir = join14(configDir, project2.agentsDir);
251590
+ const agentsDir = join15(configDir, project2.agentsDir);
251571
251591
  const remoteAgents = await runTask2("Fetching agents from Base44", async () => {
251572
251592
  return await fetchAgents();
251573
251593
  }, {
@@ -251631,12 +251651,12 @@ function getAgentsCommand() {
251631
251651
  }
251632
251652
 
251633
251653
  // src/cli/commands/auth/password-login.ts
251634
- import { dirname as dirname13, join as join15 } from "node:path";
251654
+ import { dirname as dirname13, join as join16 } from "node:path";
251635
251655
  async function passwordLoginAction({ log, runTask: runTask2 }, action) {
251636
251656
  const shouldEnable = action === "enable";
251637
251657
  const { project: project2 } = await readProjectConfig();
251638
251658
  const configDir = dirname13(project2.configPath);
251639
- const authDir = join15(configDir, project2.authDir);
251659
+ const authDir = join16(configDir, project2.authDir);
251640
251660
  const updated = await runTask2("Updating local auth config", async () => {
251641
251661
  const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
251642
251662
  const merged = { ...current, enableUsernamePassword: shouldEnable };
@@ -251656,14 +251676,14 @@ function getPasswordLoginCommand() {
251656
251676
  }
251657
251677
 
251658
251678
  // src/cli/commands/auth/pull.ts
251659
- import { dirname as dirname14, join as join16 } from "node:path";
251679
+ import { dirname as dirname14, join as join17 } from "node:path";
251660
251680
  async function pullAuthAction({
251661
251681
  log,
251662
251682
  runTask: runTask2
251663
251683
  }) {
251664
251684
  const { project: project2 } = await readProjectConfig();
251665
251685
  const configDir = dirname14(project2.configPath);
251666
- const authDir = join16(configDir, project2.authDir);
251686
+ const authDir = join17(configDir, project2.authDir);
251667
251687
  const remoteConfig = await runTask2("Fetching auth config from Base44", async () => {
251668
251688
  return await pullAuthConfig();
251669
251689
  }, {
@@ -251727,7 +251747,7 @@ function getAuthPushCommand() {
251727
251747
  }
251728
251748
 
251729
251749
  // src/cli/commands/auth/social-login.ts
251730
- import { dirname as dirname15, join as join17, resolve as resolve3 } from "node:path";
251750
+ import { dirname as dirname15, join as join18, resolve as resolve3 } from "node:path";
251731
251751
  var PROVIDER_LABELS = {
251732
251752
  google: "Google",
251733
251753
  microsoft: "Microsoft",
@@ -251798,7 +251818,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask: runTask2 }, p
251798
251818
  }
251799
251819
  const { project: project2 } = await readProjectConfig();
251800
251820
  const configDir = dirname15(project2.configPath);
251801
- const authDir = join17(configDir, project2.authDir);
251821
+ const authDir = join18(configDir, project2.authDir);
251802
251822
  const { config: updated } = await runTask2("Updating local auth config", async () => updateSocialLoginConfig(authDir, provider, shouldEnable, useCustomOAuth && options.clientId ? { clientId: options.clientId } : undefined));
251803
251823
  if (clientSecret) {
251804
251824
  await runTask2("Saving client secret", async () => pushCustomOAuthSecret(provider, clientSecret));
@@ -251823,7 +251843,7 @@ function getSocialLoginCommand() {
251823
251843
  }
251824
251844
 
251825
251845
  // src/cli/commands/auth/sso.ts
251826
- import { dirname as dirname16, join as join18, resolve as resolve4 } from "node:path";
251846
+ import { dirname as dirname16, join as join19, resolve as resolve4 } from "node:path";
251827
251847
  var SSOConfigFileSchema = exports_external.object({
251828
251848
  provider: exports_external.enum(Object.values(KNOWN_SSO_PROVIDERS)),
251829
251849
  clientId: exports_external.string(),
@@ -251987,7 +252007,7 @@ async function ssoEnableAction({ isNonInteractive, runTask: runTask2 }, options)
251987
252007
  }
251988
252008
  const { project: project2 } = await readProjectConfig();
251989
252009
  const configDir = dirname16(project2.configPath);
251990
- const authDir = join18(configDir, project2.authDir);
252010
+ const authDir = join19(configDir, project2.authDir);
251991
252011
  await runTask2("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
251992
252012
  await runTask2("Saving SSO credentials", async () => pushSSOSecrets(secrets));
251993
252013
  return {
@@ -252003,7 +252023,7 @@ async function ssoDisableAction({ log, runTask: runTask2 }, options) {
252003
252023
  }
252004
252024
  const { project: project2 } = await readProjectConfig();
252005
252025
  const configDir = dirname16(project2.configPath);
252006
- const authDir = join18(configDir, project2.authDir);
252026
+ const authDir = join19(configDir, project2.authDir);
252007
252027
  const updated = await runTask2("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
252008
252028
  await runTask2("Removing SSO credentials", async () => deleteSSOSecrets());
252009
252029
  if (!hasAnyLoginMethod(updated)) {
@@ -252854,13 +252874,13 @@ function getConnectorsListAvailableCommand() {
252854
252874
  }
252855
252875
 
252856
252876
  // src/cli/commands/connectors/pull.ts
252857
- import { dirname as dirname17, join as join19, resolve as resolve5 } from "node:path";
252877
+ import { dirname as dirname17, join as join20, resolve as resolve5 } from "node:path";
252858
252878
  async function resolveConnectorsDir(options) {
252859
252879
  if (!getAppContext().projectRoot) {
252860
252880
  return resolve5(options.dir ?? "connectors");
252861
252881
  }
252862
252882
  const { project: project2 } = await readProjectConfig();
252863
- return join19(dirname17(project2.configPath), project2.connectorsDir);
252883
+ return join20(dirname17(project2.configPath), project2.connectorsDir);
252864
252884
  }
252865
252885
  async function pullConnectorsAction({ log, runTask: runTask2, jsonMode }, options) {
252866
252886
  const connectorsDir = await resolveConnectorsDir(options);
@@ -253253,11 +253273,11 @@ function getListCommand() {
253253
253273
  }
253254
253274
 
253255
253275
  // src/cli/commands/functions/pull.ts
253256
- import { dirname as dirname18, join as join20 } from "node:path";
253276
+ import { dirname as dirname18, join as join21 } from "node:path";
253257
253277
  async function pullFunctionsAction({ log, runTask: runTask2 }, name2) {
253258
253278
  const { project: project2, functions } = await readProjectConfig();
253259
253279
  const configDir = dirname18(project2.configPath);
253260
- const functionsDir = join20(configDir, project2.functionsDir);
253280
+ const functionsDir = join21(configDir, project2.functionsDir);
253261
253281
  const pluginFunctionNames = new Set(functions.filter((fn) => fn.source.type === "plugin").map((fn) => fn.name));
253262
253282
  const remoteFunctions = await runTask2("Fetching functions from Base44", async () => {
253263
253283
  const { functions: functions2 } = await listDeployedFunctions();
@@ -253320,7 +253340,7 @@ import { basename as basename5, resolve as resolve7 } from "node:path";
253320
253340
  var import_kebabCase = __toESM(require_kebabCase(), 1);
253321
253341
 
253322
253342
  // src/cli/commands/project/scaffold-shared.ts
253323
- import { join as join21 } from "node:path";
253343
+ import { join as join22 } from "node:path";
253324
253344
  var DEFAULT_TEMPLATE_ID = "backend-only";
253325
253345
  async function getTemplateById(templateId) {
253326
253346
  const templates = await listTemplates();
@@ -253379,7 +253399,7 @@ async function completeProjectSetup({
253379
253399
  updateMessage("Building project...");
253380
253400
  await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
253381
253401
  updateMessage("Deploying site...");
253382
- return await deploySite(join21(resolvedPath, outputDirectory));
253402
+ return await deploySite(join22(resolvedPath, outputDirectory));
253383
253403
  }, {
253384
253404
  successMessage: theme.colors.base44Orange("Site deployed successfully"),
253385
253405
  errorMessage: "Failed to deploy site"
@@ -254138,15 +254158,23 @@ function getDeployCommand3() {
254138
254158
  }
254139
254159
 
254140
254160
  // src/cli/commands/realtime/new.ts
254141
- import { dirname as dirname19, join as join22 } from "node:path";
254161
+ import { dirname as dirname19, join as join23 } from "node:path";
254142
254162
  function buildHandlerScaffold(handlerName) {
254143
254163
  return `import { RealtimeHandler, type Conn } from "@base44/sdk";
254144
254164
 
254145
- export class ${handlerName} extends RealtimeHandler {
254165
+ interface State {
254166
+ // shared state broadcast to all clients
254167
+ }
254168
+
254169
+ interface Message {
254170
+ // messages sent from clients
254171
+ }
254172
+
254173
+ export class ${handlerName} extends RealtimeHandler<State, Message> {
254146
254174
  handleConnect(conn: Conn) {
254147
254175
  console.log("Connected:", conn.userId);
254148
254176
  }
254149
- handleMessage(conn: Conn, msg: unknown) {
254177
+ handleMessage(conn: Conn, msg: Message) {
254150
254178
  console.log("Message:", msg);
254151
254179
  }
254152
254180
  handleTick() {}
@@ -254156,12 +254184,12 @@ export class ${handlerName} extends RealtimeHandler {
254156
254184
  }
254157
254185
  async function newRealtimeHandlerAction(_ctx, handlerName) {
254158
254186
  const { project: project2 } = await readProjectConfig();
254159
- const realtimeDir = join22(dirname19(project2.configPath), project2.realtimeDir);
254160
- const handlerDir = join22(realtimeDir, handlerName);
254187
+ const realtimeDir = join23(dirname19(project2.configPath), project2.realtimeDir);
254188
+ const handlerDir = join23(realtimeDir, handlerName);
254161
254189
  if (await pathExists(handlerDir)) {
254162
254190
  throw new InvalidInputError(`Realtime handler "${handlerName}" already exists at ${handlerDir}`);
254163
254191
  }
254164
- const entryPath = join22(handlerDir, "entry.ts");
254192
+ const entryPath = join23(handlerDir, "entry.ts");
254165
254193
  await writeFile(entryPath, buildHandlerScaffold(handlerName));
254166
254194
  return {
254167
254195
  outroMessage: `Created realtime handler "${handlerName}" at ${entryPath}`
@@ -254649,6 +254677,7 @@ function getSiteCommand() {
254649
254677
  // src/core/types/generator.ts
254650
254678
  var import_common_tags = __toESM(require_lib2(), 1);
254651
254679
  var import_json_schema_to_typescript = __toESM(require_src3(), 1);
254680
+ import { join as join26 } from "node:path";
254652
254681
  var HEADER2 = import_common_tags.stripIndent`
254653
254682
  // Auto-generated by Base44 CLI - DO NOT EDIT
254654
254683
  // Regenerate with: base44 types generate
@@ -254657,24 +254686,43 @@ var EMPTY_TEMPLATE = import_common_tags.stripIndent`
254657
254686
  // Auto-generated by Base44 CLI - DO NOT EDIT
254658
254687
  // Regenerate with: base44 types
254659
254688
  //
254660
- // No entities, functions, agents, or connectors found in project.
254661
- // Add resources to base44/entities/, base44/functions/, base44/agents/, or base44/connectors/
254689
+ // No entities, functions, agents, connectors, or realtime handlers found in project.
254690
+ // Add resources to base44/entities/, base44/functions/, base44/agents/, base44/connectors/, or base44/realtime/
254662
254691
  // and run \`base44 types generate\` again.
254663
254692
 
254664
254693
  declare module '@base44/sdk' {
254665
254694
  // No types to augment - add resources and regenerate
254666
254695
  }
254667
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
+ }
254668
254712
  async function generateTypesFile(input) {
254669
254713
  const content = await generateContent(input);
254670
254714
  await writeFile(getTypesOutputPath(input.projectRoot), content);
254671
254715
  }
254672
254716
  async function generateContent(input) {
254673
- const { entities, functions, agents, connectors } = input;
254674
- if (!entities.length && !functions.length && !agents.length && !connectors.length) {
254717
+ const { entities, functions, agents, connectors, realtimeHandlers } = input;
254718
+ const sdkPackage = await detectSdkPackageName(input.projectRoot);
254719
+ if (!entities.length && !functions.length && !agents.length && !connectors.length && !realtimeHandlers.length) {
254675
254720
  return EMPTY_TEMPLATE;
254676
254721
  }
254677
- const entityInterfaces = await Promise.all(entities.map((e8) => compileEntity(e8)));
254722
+ const [entityInterfaces, realtimeResults] = await Promise.all([
254723
+ Promise.all(entities.map((e8) => compileEntity(e8))),
254724
+ Promise.all(realtimeHandlers.map((h5) => compileRealtimeHandler(h5)))
254725
+ ]);
254678
254726
  const registryEntries = [
254679
254727
  [
254680
254728
  "EntityTypeRegistry",
@@ -254682,16 +254730,32 @@ async function generateContent(input) {
254682
254730
  ],
254683
254731
  ["FunctionNameRegistry", functions.map((f7) => `"${f7.name}": true;`)],
254684
254732
  ["AgentNameRegistry", agents.map((a5) => `"${a5.name}": true;`)],
254685
- ["ConnectorTypeRegistry", connectors.map((c8) => `"${c8.type}": true;`)]
254733
+ ["ConnectorTypeRegistry", connectors.map((c8) => `"${c8.type}": true;`)],
254734
+ [
254735
+ "RealtimeHandlerNameRegistry",
254736
+ realtimeHandlers.map((h5) => `"${h5.name}": true;`)
254737
+ ],
254738
+ [
254739
+ "RealtimeHandlerRegistry",
254740
+ realtimeHandlers.filter((h5) => h5.messageSchema).map((h5) => {
254741
+ const idx = realtimeHandlers.indexOf(h5);
254742
+ return `"${h5.name}": ${realtimeResults[idx].entry};`;
254743
+ })
254744
+ ]
254686
254745
  ];
254687
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);
254688
254748
  return [
254689
254749
  HEADER2,
254750
+ "export {};",
254690
254751
  entityInterfaces.join(`
254691
254752
 
254753
+ `),
254754
+ realtimeInterfaces.join(`
254755
+
254692
254756
  `),
254693
254757
  import_common_tags.source`
254694
- declare module '@base44/sdk' {
254758
+ declare module '${sdkPackage}' {
254695
254759
  ${registries2.join(`
254696
254760
 
254697
254761
  `)}
@@ -254719,6 +254783,78 @@ async function compileEntity(entity2) {
254719
254783
  throw new TypeGenerationError(`Failed to generate types for entity "${name2}"`, name2, error48);
254720
254784
  }
254721
254785
  }
254786
+ async function compileRealtimeHandler(handler) {
254787
+ const { messageSchema } = handler;
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}` }))
254827
+ };
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;
254857
+ }
254722
254858
  function registry2(name2, entries) {
254723
254859
  return import_common_tags.source`
254724
254860
  interface ${name2} {
@@ -254731,10 +254867,10 @@ function toPascalCase(name2) {
254731
254867
  return name2.split(/[-_\s]+/).map((w8) => w8.charAt(0).toUpperCase() + w8.slice(1)).join("");
254732
254868
  }
254733
254869
  // src/core/types/update-project.ts
254734
- import { join as join25 } from "node:path";
254870
+ import { join as join27 } from "node:path";
254735
254871
  var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
254736
254872
  async function updateProjectConfig(projectRoot) {
254737
- const tsconfigPath = join25(projectRoot, "tsconfig.json");
254873
+ const tsconfigPath = join27(projectRoot, "tsconfig.json");
254738
254874
  if (!await pathExists(tsconfigPath)) {
254739
254875
  return false;
254740
254876
  }
@@ -254758,14 +254894,15 @@ var TYPES_FILE_PATH = "base44/.types/types.d.ts";
254758
254894
  async function generateTypesAction({
254759
254895
  runTask: runTask2
254760
254896
  }) {
254761
- const { entities, functions, agents, connectors, project: project2 } = await readProjectConfig();
254897
+ const { entities, functions, agents, connectors, realtimeHandlers, project: project2 } = await readProjectConfig();
254762
254898
  await runTask2("Generating types", async () => {
254763
254899
  await generateTypesFile({
254764
254900
  projectRoot: project2.root,
254765
254901
  entities,
254766
254902
  functions,
254767
254903
  agents,
254768
- connectors
254904
+ connectors,
254905
+ realtimeHandlers
254769
254906
  });
254770
254907
  });
254771
254908
  const tsconfigUpdated = await updateProjectConfig(project2.root);
@@ -254785,7 +254922,7 @@ function getTypesCommand() {
254785
254922
  // src/cli/dev/dev-server/main.ts
254786
254923
  var import_cors = __toESM(require_lib4(), 1);
254787
254924
  var import_express6 = __toESM(require_express(), 1);
254788
- import { dirname as dirname24, join as join28 } from "node:path";
254925
+ import { dirname as dirname24, join as join30 } from "node:path";
254789
254926
 
254790
254927
  // ../../node_modules/get-port/index.js
254791
254928
  import net from "node:net";
@@ -258205,8 +258342,8 @@ async function createDevServer(options8) {
258205
258342
  broadcastEntityEvent(io6, appId, entityName, event);
258206
258343
  };
258207
258344
  const base44ConfigWatcher = new WatchBase44({
258208
- functions: join28(dirname24(project2.configPath), project2.functionsDir),
258209
- entities: join28(dirname24(project2.configPath), project2.entitiesDir)
258345
+ functions: join30(dirname24(project2.configPath), project2.functionsDir),
258346
+ entities: join30(dirname24(project2.configPath), project2.entitiesDir)
258210
258347
  }, devLogger);
258211
258348
  base44ConfigWatcher.on("change", async (name2) => {
258212
258349
  try {
@@ -262772,7 +262909,7 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
262772
262909
  // src/cli/index.ts
262773
262910
  var __dirname4 = dirname26(fileURLToPath6(import.meta.url));
262774
262911
  async function runCLI(options8) {
262775
- ensureNpmAssets(join29(__dirname4, "../assets"));
262912
+ ensureNpmAssets(join31(__dirname4, "../assets"));
262776
262913
  const errorReporter = new ErrorReporter;
262777
262914
  errorReporter.registerProcessErrorHandlers();
262778
262915
  const jsonMode = process.argv.includes("--json");
@@ -262811,4 +262948,4 @@ export {
262811
262948
  CLIExitError
262812
262949
  };
262813
262950
 
262814
- //# debugId=5B2B311D5BF1EFDE64756E2164756E21
262951
+ //# debugId=844227E4524139FD64756E2164756E21