@base44-preview/cli 0.1.6-pr.555.61021b6 → 0.1.6-pr.555.a30aaa5

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
@@ -239133,6 +239133,9 @@ function getAppConfigPath(projectRoot) {
239133
239133
  function getTypesOutputPath(projectRoot) {
239134
239134
  return join2(projectRoot, PROJECT_SUBDIR, TYPES_OUTPUT_SUBDIR, TYPES_FILENAME);
239135
239135
  }
239136
+ function getActorRuntimeTypesPath(projectRoot) {
239137
+ return join2(projectRoot, PROJECT_SUBDIR, TYPES_OUTPUT_SUBDIR, "runtime.d.ts");
239138
+ }
239136
239139
  function getBase44ApiUrl() {
239137
239140
  return process.env.BASE44_API_URL || "https://app.base44.com";
239138
239141
  }
@@ -254927,6 +254930,23 @@ async function detectSdkPackageName(projectRoot) {
254927
254930
  async function generateTypesFile(input) {
254928
254931
  const content = await generateContent(input);
254929
254932
  await writeFile(getTypesOutputPath(input.projectRoot), content);
254933
+ const runtimePath = getActorRuntimeTypesPath(input.projectRoot);
254934
+ if (input.actors.length) {
254935
+ const sdkPackage = await detectSdkPackageName(input.projectRoot);
254936
+ await writeFile(runtimePath, actorRuntimeDeclaration(sdkPackage));
254937
+ } else if (await pathExists(runtimePath)) {
254938
+ await deleteFile(runtimePath);
254939
+ }
254940
+ }
254941
+ function actorRuntimeDeclaration(sdkPackage) {
254942
+ return `${HEADER2}
254943
+
254944
+ ${import_common_tags.source`
254945
+ declare module 'base44:runtime/actors' {
254946
+ export { Actor } from '${sdkPackage}';
254947
+ }
254948
+ `}
254949
+ `;
254930
254950
  }
254931
254951
  async function generateContent(input) {
254932
254952
  const { entities, functions, agents, connectors, actors } = input;
@@ -254957,11 +254977,6 @@ async function generateContent(input) {
254957
254977
  ];
254958
254978
  const registries2 = registryEntries.filter(([, entries]) => entries.length > 0).map(([name2, entries]) => registry2(name2, entries));
254959
254979
  const actorInterfaces = actorResults.map((r5) => r5.decls).filter(Boolean);
254960
- const actorRuntimeModule = actors.length ? import_common_tags.source`
254961
- declare module 'base44:runtime/actors' {
254962
- export { Actor } from '${sdkPackage}';
254963
- }
254964
- ` : "";
254965
254980
  return [
254966
254981
  HEADER2,
254967
254982
  "export {};",
@@ -254977,8 +254992,7 @@ async function generateContent(input) {
254977
254992
 
254978
254993
  `)}
254979
254994
  }
254980
- `,
254981
- actorRuntimeModule
254995
+ `
254982
254996
  ].filter(Boolean).join(`
254983
254997
 
254984
254998
  `);
@@ -255090,6 +255104,7 @@ function toPascalCase(name2) {
255090
255104
  // src/core/types/update-project.ts
255091
255105
  import { join as join18 } from "node:path";
255092
255106
  var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
255107
+ var ACTORS_INCLUDE_PATH = `${PROJECT_SUBDIR}/actors/**/*.ts`;
255093
255108
  async function updateProjectConfig(projectRoot) {
255094
255109
  const tsconfigPath = join18(projectRoot, "tsconfig.json");
255095
255110
  if (!await pathExists(tsconfigPath)) {
@@ -255100,12 +255115,17 @@ async function updateProjectConfig(projectRoot) {
255100
255115
  if (!tsconfig.include) {
255101
255116
  tsconfig.include = [];
255102
255117
  }
255103
- if (tsconfig.include.includes(TYPES_INCLUDE_PATH)) {
255104
- return false;
255118
+ let changed = false;
255119
+ for (const path17 of [TYPES_INCLUDE_PATH, ACTORS_INCLUDE_PATH]) {
255120
+ if (!tsconfig.include.includes(path17)) {
255121
+ tsconfig.include.push(path17);
255122
+ changed = true;
255123
+ }
255105
255124
  }
255106
- tsconfig.include.push(TYPES_INCLUDE_PATH);
255107
- await writeJsonFile(tsconfigPath, tsconfig);
255108
- return true;
255125
+ if (changed) {
255126
+ await writeJsonFile(tsconfigPath, tsconfig);
255127
+ }
255128
+ return changed;
255109
255129
  } catch {
255110
255130
  return false;
255111
255131
  }
@@ -255113,17 +255133,16 @@ async function updateProjectConfig(projectRoot) {
255113
255133
  // src/cli/commands/actor/new.ts
255114
255134
  function buildActorScaffold(actorName) {
255115
255135
  return `import { Actor } from "base44:runtime/actors";
255116
- import type { Conn } from "@base44/sdk";
255136
+ import type { ActorRegistry, Conn } from "@base44/sdk";
255117
255137
 
255118
- interface Incoming {
255119
- // messages clients send to this actor (schema toServer)
255120
- }
255121
-
255122
- interface Outgoing {
255123
- // messages this actor sends to clients (schema toClient)
255124
- }
255138
+ // Message types are generated from ./schema.jsonc by \`base44 types generate\` —
255139
+ // the same source the client is typed from, so the two can't drift.
255140
+ type Messages = ActorRegistry["${actorName}"];
255141
+ type Incoming = Messages["toServer"];
255142
+ type Outgoing = Messages["toClient"];
255125
255143
 
255126
- export class ${actorName} extends Actor<Incoming, Outgoing> {
255144
+ // The deploy bundler imports the actor as the entry's default export.
255145
+ export default class ${actorName} extends Actor<Incoming, Outgoing> {
255127
255146
  handleConnect(conn: Conn<Outgoing>) {
255128
255147
  console.log("Connected:", conn.id);
255129
255148
  }
@@ -255135,6 +255154,26 @@ export class ${actorName} extends Actor<Incoming, Outgoing> {
255135
255154
  }
255136
255155
  `;
255137
255156
  }
255157
+ function buildActorSchema() {
255158
+ return `{
255159
+ "types": {},
255160
+ // Messages this actor sends to clients (server → client).
255161
+ "toClient": {
255162
+ "welcome": {
255163
+ "properties": { "message": { "type": "string" } },
255164
+ "required": ["message"]
255165
+ }
255166
+ },
255167
+ // Messages clients send to this actor (client → server).
255168
+ "toServer": {
255169
+ "hello": {
255170
+ "properties": { "name": { "type": "string" } },
255171
+ "required": ["name"]
255172
+ }
255173
+ }
255174
+ }
255175
+ `;
255176
+ }
255138
255177
  async function newActorAction(_ctx, actorName) {
255139
255178
  const { project: project2 } = await readProjectConfig();
255140
255179
  const actorsDir = join19(dirname14(project2.configPath), project2.actorsDir);
@@ -255144,6 +255183,7 @@ async function newActorAction(_ctx, actorName) {
255144
255183
  }
255145
255184
  const entryPath = join19(actorDir, "entry.ts");
255146
255185
  await writeFile(entryPath, buildActorScaffold(actorName));
255186
+ await writeFile(join19(actorDir, "schema.jsonc"), buildActorSchema());
255147
255187
  const { entities, functions, agents, connectors, actors } = await readProjectConfig();
255148
255188
  await generateTypesFile({
255149
255189
  projectRoot: project2.root,
@@ -255155,7 +255195,7 @@ async function newActorAction(_ctx, actorName) {
255155
255195
  });
255156
255196
  await updateProjectConfig(project2.root);
255157
255197
  return {
255158
- outroMessage: `Created actor "${actorName}" at ${entryPath}`
255198
+ outroMessage: `Created actor "${actorName}" at ${entryPath} — define its messages in schema.jsonc`
255159
255199
  };
255160
255200
  }
255161
255201
  function getNewCommand() {
@@ -266863,4 +266903,4 @@ export {
266863
266903
  CLIExitError
266864
266904
  };
266865
266905
 
266866
- //# debugId=4CCC3CA8963106DE64756E2164756E21
266906
+ //# debugId=7652A3EF7C371DA564756E2164756E21