Skip to content
Draft
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
8 changes: 7 additions & 1 deletion skills/base44-sdk/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ Base44 SDK has unique method names. Do NOT assume patterns from Firebase, Supaba

For client setup and authentication modes, see [client.md](references/client.md).

**TypeScript Support:** Each reference file includes a "Type Definitions" section with TypeScript interfaces and types for the module's methods, parameters, and return values.
### TypeScript and type registries

Each reference file includes a "Type Definitions" section with TypeScript interfaces and types for the module's methods, parameters, and return values.

**Getting typed entities, functions, and agents:** The Base44 CLI generates types from your project resources (entities, functions, agents), including augmentations to `EntityTypeRegistry`, `FunctionNameRegistry`, and `AgentNameRegistry`, and wires them into your project so you get autocomplete and type checking without manual setup. For how to generate types, use the **base44-cli** skill.

**Manual augmentation:** You can instead augment the registries yourself in a `.d.ts` file; see the Type Definitions sections in [entities.md](references/entities.md), [functions.md](references/functions.md), and [base44-agents.md](references/base44-agents.md).

## Installation

Expand Down
32 changes: 19 additions & 13 deletions skills/base44-sdk/references/QUICK_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ setToken(token, saveToStorage?) → void
## Entities (`base44.entities.EntityName.*`)

```
create(data) → Promise<any>
bulkCreate(dataArray) → Promise<any[]>
list(sort?, limit?, skip?, fields?) → Promise<any[]>
filter(query, sort?, limit?, skip?, fields?) → Promise<any[]>
get(id) → Promise<any>
update(id, data) → Promise<any>
delete(id) → Promise<any>
deleteMany(query) → Promise<any>
importEntities(file) → Promise<any> // frontend only
subscribe(callback) → () => void // returns unsubscribe fn
create(data) → Promise<T>
bulkCreate(dataArray) → Promise<T[]>
list(sort?, limit?, skip?, fields?) → Promise<Pick<T, K>[]>
filter(query, sort?, limit?, skip?, fields?) → Promise<Pick<T, K>[]>
get(id) → Promise<T>
update(id, data) → Promise<T>
delete(id) → Promise<DeleteResult>
deleteMany(query) → Promise<DeleteManyResult>
importEntities(file) → Promise<ImportResult<T>> // frontend only
subscribe(callback) → () => void // returns unsubscribe fn
```

**Sort:** Use `-fieldName` for descending (e.g., `-created_date`)
**Sort:** Use `SortField<T>`: `-fieldName` for descending (e.g., `-created_date`). Max 5,000 per request for list/filter.

---

## Functions (`base44.functions.*`)

```
invoke(functionName, data) → Promise<any>
invoke(functionName, data?) → Promise<any>
```

**Backend:** Use `base44.asServiceRole.functions.invoke()` for admin access.
Expand All @@ -70,7 +70,7 @@ ExtractDataFromUploadedFile({file_url, json_schema}) → Promise<object>
### Custom Integrations (`base44.integrations.custom.*`)

```
call(slug, operationId, {payload?, pathParams?, queryParams?, headers?}?) → Promise<{success, status_code, data}>
call(slug, operationId, {payload?, pathParams?, queryParams?}?) → Promise<{success, status_code, data}>
```

**operationId format:** `"method:/path"` (e.g., `"get:/contacts"`, `"post:/users/{id}"`)
Expand Down Expand Up @@ -153,3 +153,9 @@ import { createClient } from "@base44/sdk";

const base44 = createClient({ appId: "your-app-id" }); // MUST use 'appId'
```

---

## TypeScript type registries

For typed entities, function names, and agent names (autocomplete and type checking), the Base44 CLI generates types and wires them into your project. Use the **base44-cli** skill for how to generate types.
19 changes: 14 additions & 5 deletions skills/base44-sdk/references/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ interface AuthModule {
|--------|-----------|-------------|-------------|
| `register()` | `params: RegisterParams` | `Promise<any>` | Create new user account |
| `loginViaEmailPassword()` | `email: string, password: string, turnstileToken?: string` | `Promise<LoginResponse>` | Authenticate with email/password |
| `loginWithProvider()` | `provider: Provider, fromUrl?: string` | `void` | Initiate OAuth login flow |
| `loginWithProvider()` | `provider: Provider, fromUrl?: string` | `void` | Initiate OAuth login flow. Providers: `'google'` (default), `'microsoft'`, `'facebook'` (enable in app settings) |
| `me()` | None | `Promise<User>` | Get current authenticated user |
| `updateMe()` | `data: Partial<User>` | `Promise<User>` | Update current user's profile |
| `logout()` | `redirectUrl?: string` | `void` | Clear session, optionally redirect |
| `logout()` | `redirectUrl?: string` | `void` | Redirect to server-side logout (clears HTTP-only cookies and session), then to redirectUrl or current URL |
| `redirectToLogin()` | `nextUrl: string` | `void` | ⚠️ **Avoid** - Prefer custom login UI with `loginViaEmailPassword()` or `loginWithProvider()` |
| `isAuthenticated()` | None | `Promise<boolean>` | Check if user is logged in |
| `setToken()` | `token: string, saveToStorage?: boolean` | `void` | Manually set auth token |
Expand Down Expand Up @@ -215,15 +215,18 @@ try {

### Login with OAuth Provider

Supported providers: `'google'` (enabled by default), `'microsoft'`, and `'facebook'`. Enable Microsoft or Facebook in your app's authentication settings before using them.

```javascript
// Redirect to Google OAuth
base44.auth.loginWithProvider('google');

// Redirect to Google OAuth and return to current page after
base44.auth.loginWithProvider('google', window.location.href);

// Supported providers: 'google', 'microsoft', 'facebook'
// Microsoft or Facebook (enable in app settings first)
base44.auth.loginWithProvider('microsoft');
base44.auth.loginWithProvider('facebook', '/dashboard');
```

### Get Current User
Expand Down Expand Up @@ -297,11 +300,13 @@ try {

### Logout

Logout redirects the user to the server-side logout endpoint (`/api/apps/auth/logout`) to clear HTTP-only cookies and the session, then redirects to the given URL (or the current page if omitted). Requires a browser environment.

```javascript
// Simple logout
// Logout: clears session via server, then redirects to current page
base44.auth.logout();

// Logout and redirect to goodbye page
// Logout and redirect to goodbye page after
base44.auth.logout("/goodbye");

// Logout and redirect to homepage
Expand Down Expand Up @@ -592,6 +597,10 @@ Configure authentication providers in your app dashboard:

### Using OAuth Providers

- **Google** – enabled by default.
- **Microsoft** – enable in your app's authentication settings before use.
- **Facebook** – enable in your app's authentication settings before use.

```javascript
// Initiate OAuth login flow
base44.auth.loginWithProvider('google');
Expand Down
36 changes: 29 additions & 7 deletions skills/base44-sdk/references/base44-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ AI agent conversations and messages via `base44.agents`.
|--------|-----------|-------------|
| `createConversation(params)` | `Promise<Conversation>` | Create a new conversation with an agent |
| `getConversations()` | `Promise<Conversation[]>` | Get all user's conversations |
| `getConversation(id)` | `Promise<Conversation>` | Get conversation with messages |
| `getConversation(id)` | `Promise<Conversation>` | Get conversation with messages (includes full tool call results) |
| `listConversations(filterParams)` | `Promise<Conversation[]>` | Filter/sort/paginate conversations |
| `subscribeToConversation(id, onUpdate?)` | `() => void` | Real-time updates via WebSocket (returns unsubscribe function) |
| `subscribeToConversation(id, onUpdate?)` | `() => void` | Realtime updates via WebSocket; tool call data truncated (returns unsubscribe function) |
| `addMessage(conversation, message)` | `Promise<Message>` | Send a message |
| `getWhatsAppConnectURL(agentName)` | `string` | Get WhatsApp connection URL for agent |

Expand Down Expand Up @@ -57,6 +57,8 @@ conversations.forEach(conv => {

### Get Single Conversation (with messages)

Returns the complete stored conversation including full tool call results (unlike the realtime subscription, which truncates tool call data).

```javascript
const conversation = await base44.agents.getConversation("conv-id-123");

Expand Down Expand Up @@ -85,7 +87,9 @@ const highPriority = await base44.agents.listConversations({
});
```

### Subscribe to Updates (Real-time)
### Subscribe to Updates (Realtime)

When receiving messages through this subscription, tool call data is truncated for efficiency (`arguments_string` limited to 500 characters, `results` to 50). Use `getConversation()` after the message completes to retrieve full tool call data.

```javascript
const unsubscribe = base44.agents.subscribeToConversation(
Expand Down Expand Up @@ -189,6 +193,24 @@ return () => unsubscribe();

## Type Definitions

### AgentNameRegistry and AgentName

**How to get typed agent names:** The Base44 CLI can generate an augmentation of `AgentNameRegistry` from your project. For how to run it, use the **base44-cli** skill.

```typescript
/**
* Registry of agent names.
* Augment this interface to enable autocomplete for agent names.
* Typically populated by the Base44 CLI type generator.
*/
interface AgentNameRegistry {}

/**
* Agent name type - uses registry keys if augmented, otherwise string.
*/
type AgentName = keyof AgentNameRegistry extends never ? string : keyof AgentNameRegistry;
```

### AgentConversation

```typescript
Expand Down Expand Up @@ -311,7 +333,7 @@ interface AgentMessageMetadata {
/** Parameters for creating a new conversation. */
interface CreateConversationParams {
/** The name of the agent to create a conversation with. */
agent_name: string;
agent_name: AgentName;
/** Optional metadata to attach to the conversation. */
metadata?: Record<string, any>;
}
Expand Down Expand Up @@ -343,7 +365,7 @@ interface AgentsModule {
/** Gets all conversations from all agents in the app. */
getConversations(): Promise<AgentConversation[]>;

/** Gets a specific conversation by ID. */
/** Gets a specific conversation by ID. Returns complete stored conversation including full tool call results. */
getConversation(conversationId: string): Promise<AgentConversation | undefined>;

/** Lists conversations with filtering, sorting, and pagination. */
Expand All @@ -355,10 +377,10 @@ interface AgentsModule {
/** Adds a message to a conversation. */
addMessage(conversation: AgentConversation, message: Partial<AgentMessage>): Promise<AgentMessage>;

/** Subscribes to real-time updates for a conversation. Returns unsubscribe function. */
/** Subscribes to realtime updates for a conversation. Returns unsubscribe function. */
subscribeToConversation(conversationId: string, onUpdate?: (conversation: AgentConversation) => void): () => void;

/** Gets WhatsApp connection URL for an agent. */
getWhatsAppConnectURL(agentName: string): string;
getWhatsAppConnectURL(agentName: AgentName): string;
}
```
50 changes: 25 additions & 25 deletions skills/base44-sdk/references/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ How to create and configure the Base44 client.

## In Base44-Generated Apps

The client is pre-configured and available as `base44`. Just use it:
Inside a Base44 app, the client is automatically created and configured. Import it from `@/api/base44Client` and use it as `base44`:

```javascript
const tasks = await base44.entities.Task.list();
```

## In External Apps

Install the SDK and create a client:
When using Base44 as a backend from an external app, install the SDK and create a client by calling `createClient()` directly:

```bash
npm install @base44/sdk
Expand Down Expand Up @@ -52,7 +52,7 @@ const base44 = createClient({

## In Backend Functions

Use `createClientFromRequest` to get a client with the caller's auth context:
`createClientFromRequest()` is designed for Base44-hosted backend functions. It extracts auth from request headers that Base44 injects and returns a client that includes service role access (`base44.asServiceRole`). For frontends and external backends, use `createClient()` instead.

```javascript
import { createClientFromRequest } from "@base44/sdk";
Expand Down Expand Up @@ -127,22 +127,22 @@ Deno.serve(async (req) => {
The client exposes these modules:

```javascript
base44.entities // CRUD operations
base44.auth // Authentication
base44.agents // AI conversations
base44.functions // Backend function invocation
base44.integrations // Third-party services
base44.analytics // Event tracking
base44.appLogs // App usage logging
base44.auth // Authentication
base44.entities // CRUD operations
base44.functions // Backend function invocation
base44.integrations // Third-party services
base44.users // User invitations

// Service role only (backend)
base44.asServiceRole.entities
base44.asServiceRole.agents
base44.asServiceRole.functions
base44.asServiceRole.integrations
base44.asServiceRole.appLogs
base44.asServiceRole.connectors
base44.asServiceRole.entities
base44.asServiceRole.functions
base44.asServiceRole.integrations
```

## Client Methods
Expand Down Expand Up @@ -204,7 +204,7 @@ interface CreateClientConfig {
appId: string;
/** User authentication token. Used to authenticate as a specific user. */
token?: string;
/** Service role authentication token (backend only). */
/** @internal Service role token; only set automatically in Base44-hosted backend functions. */
serviceToken?: string;
/** Additional client options. */
options?: CreateClientOptions;
Expand All @@ -222,20 +222,20 @@ interface CreateClientOptions {
```typescript
/** The Base44 client instance. */
interface Base44Client {
/** Entities module for CRUD operations on your data models. */
entities: EntitiesModule;
/** Integrations module for calling pre-built integration endpoints. */
integrations: IntegrationsModule;
/** Auth module for user authentication and management. */
auth: AuthModule;
/** Functions module for invoking custom backend functions. */
functions: FunctionsModule;
/** Agents module for managing AI agent conversations. */
agents: AgentsModule;
/** App logs module for tracking app usage. */
appLogs: AppLogsModule;
/** Analytics module for tracking custom events. */
analytics: AnalyticsModule;
/** App logs module for tracking app usage. */
appLogs: AppLogsModule;
/** Auth module for user authentication and management. */
auth: AuthModule;
/** Entities module for CRUD operations on your data models. */
entities: EntitiesModule;
/** Functions module for invoking custom backend functions. */
functions: FunctionsModule;
/** Integrations module for calling pre-built integration methods. */
integrations: IntegrationsModule;

/** Cleanup function to disconnect WebSocket connections. */
cleanup(): void;
Expand All @@ -245,12 +245,12 @@ interface Base44Client {

/** Provides access to modules with elevated service role permissions (backend only). */
readonly asServiceRole: {
entities: EntitiesModule;
integrations: IntegrationsModule;
connectors: ConnectorsModule;
functions: FunctionsModule;
agents: AgentsModule;
appLogs: AppLogsModule;
connectors: ConnectorsModule;
entities: EntitiesModule;
functions: FunctionsModule;
integrations: IntegrationsModule;
cleanup(): void;
};
}
Expand Down
Loading