Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/cli/src/cli/commands/entities/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Command } from "commander";
import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command } from "@/cli/utils/index.js";
import { listEntitySchemas } from "@/core/resources/entity/index.js";

async function listEntitiesAction({ jsonMode }: CLIContext): Promise<RunCommandResult> {
const catalog = await listEntitySchemas();
return { stdout: jsonMode ? `${JSON.stringify(catalog)}\n` : undefined, outroMessage: jsonMode ? undefined : JSON.stringify(catalog, null, 2) };
}

export function getEntitiesListCommand(): Command {
return new Base44Command("list")
.description("List remote entity schemas (read-only)")
.action(listEntitiesAction);
}
4 changes: 3 additions & 1 deletion packages/cli/src/cli/commands/entities/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { CLIContext, RunCommandResult } from "@/cli/types.js";
import { Base44Command, confirmPush } from "@/cli/utils/index.js";
import { readProjectConfig } from "@/core/index.js";
import { pushEntities } from "@/core/resources/entity/index.js";
import { getEntitiesListCommand } from "@/cli/commands/entities/list.js";

interface PushOptions {
yes?: boolean;
Expand Down Expand Up @@ -65,5 +66,6 @@ export function getEntitiesPushCommand(): Command {
.description("Push local entities to Base44")
.option("-y, --yes", "Skip confirmation prompt")
.action(pushEntitiesAction),
);
)
.addCommand(getEntitiesListCommand());
}
11 changes: 11 additions & 0 deletions packages/cli/src/core/resources/entity/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import type {
} from "@/core/resources/entity/schema.js";
import { SyncEntitiesResponseSchema } from "@/core/resources/entity/schema.js";

/** Read the remote entity catalog without touching records or mutating resources. */
export async function listEntitySchemas(): Promise<unknown> {
const appClient = getAppClient();
try {
const response = await appClient.get("entity-schemas");
return await response.json();
} catch (error) {
throw await ApiError.fromHttpError(error, "listing entity schemas");
}
}

export async function syncEntities(
entities: Entity[],
): Promise<SyncEntitiesResponse> {
Expand Down