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
4 changes: 2 additions & 2 deletions src/cli/commands/types/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { generateTypesFile, updateProjectConfig } from "@/core/types/index.js";
const TYPES_FILE_PATH = "base44/.types/types.d.ts";

async function generateTypesAction(): Promise<RunCommandResult> {
const { entities, functions, agents, project } = await readProjectConfig();
const { entities, functions, agents, connectors, project } = await readProjectConfig();

await runTask("Generating types", async () => {
await generateTypesFile({ entities, functions, agents });
await generateTypesFile({ entities, functions, agents, connectors });
});

const tsconfigUpdated = await updateProjectConfig(project.root);
Expand Down
11 changes: 7 additions & 4 deletions src/core/types/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { getAppConfig } from "@/core/project/app-config.js";
import type { AgentConfig } from "@/core/resources/agent/index.js";
import type { Entity } from "@/core/resources/entity/index.js";
import type { BackendFunction } from "@/core/resources/function/index.js";
import type { ConnectorResource } from "@/core/resources/connector/index.js";
import { writeFile } from "@/core/utils/fs.js";

interface GenerateTypesInput {
entities: Entity[];
functions: BackendFunction[];
agents: AgentConfig[];
connectors: ConnectorResource[];
}

const HEADER = stripIndent`
Expand All @@ -24,8 +26,8 @@ const EMPTY_TEMPLATE = stripIndent`
// Auto-generated by Base44 CLI - DO NOT EDIT
// Regenerate with: base44 types
//
// No entities, functions, or agents found in project.
// Add resources to base44/entities/, base44/functions/, or base44/agents/
// No entities, functions, agents, or connectors found in project.
// Add resources to base44/entities/, base44/functions/, base44/agents/, or base44/connectors/
// and run \`base44 types generate\` again.

declare module '@base44/sdk' {
Expand All @@ -45,9 +47,9 @@ export async function generateTypesFile(
}

async function generateContent(input: GenerateTypesInput): Promise<string> {
const { entities, functions, agents } = input;
const { entities, functions, agents, connectors } = input;

if (!entities.length && !functions.length && !agents.length) {
if (!entities.length && !functions.length && !agents.length && !connectors.length) {
return EMPTY_TEMPLATE;
}

Expand All @@ -63,6 +65,7 @@ async function generateContent(input: GenerateTypesInput): Promise<string> {
],
["FunctionNameRegistry", functions.map((f) => `"${f.name}": true;`)],
["AgentNameRegistry", agents.map((a) => `"${a.name}": true;`)],
["ConnectorTypeRegistry", connectors.map((c) => `"${c.type}": true;`)],
];

// Generate registries (only for non-empty entries)
Expand Down
6 changes: 5 additions & 1 deletion tests/cli/types_generate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ describe("types generate command", () => {
// Contains the AgentNameRegistry with the agent name
expect(typesContent).toContain("AgentNameRegistry");
expect(typesContent).toContain(`"assistant": true`);

// Contains the ConnectorTypeRegistry with the connector type
expect(typesContent).toContain("ConnectorTypeRegistry");
expect(typesContent).toContain(`"slack": true`);
});

it("updates tsconfig.json to include types path", async () => {
Expand Down Expand Up @@ -79,7 +83,7 @@ describe("types generate command", () => {
// And an empty template is generated
const typesContent = await t.readProjectFile("base44/.types/types.d.ts");
expect(typesContent).not.toBeNull();
expect(typesContent).toContain("No entities, functions, or agents found");
expect(typesContent).toContain("No entities, functions, agents, or connectors found");
});

it("skips tsconfig update if types path already included", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "slack",
"scopes": ["chat:write"]
}
Loading