@base44/sdk 0.8.19 → 0.8.20

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/index.d.ts CHANGED
@@ -4,11 +4,11 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
4
4
  export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
5
5
  export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
6
6
  export * from "./types.js";
7
- export type { EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, RealtimeEventType, RealtimeEvent, RealtimeCallback, } from "./modules/entities.types.js";
7
+ export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, } from "./modules/entities.types.js";
8
8
  export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
9
- export type { IntegrationsModule, IntegrationPackage, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
10
- export type { FunctionsModule, FunctionNameRegistry, } from "./modules/functions.types.js";
11
- export type { AgentsModule, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
9
+ export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
10
+ export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
11
+ export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
12
12
  export type { AppLogsModule } from "./modules/app-logs.types.js";
13
13
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
14
14
  export type { ConnectorsModule } from "./modules/connectors.types.js";
@@ -2,13 +2,19 @@ import { AxiosInstance } from "axios";
2
2
  import { RoomsSocket } from "../utils/socket-utils.js";
3
3
  import { ModelFilterParams } from "../types.js";
4
4
  /**
5
- * Registry of agent names.
6
- * Augment this interface to enable autocomplete for agent names.
5
+ * Registry of agent names. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`AgentName`](#agentname) resolves to a union of the keys.
7
6
  */
8
7
  export interface AgentNameRegistry {
9
8
  }
10
9
  /**
11
- * Agent name type - uses registry keys if augmented, otherwise string.
10
+ * Union of all agent names from the [`AgentNameRegistry`](#agentnameregistry). Defaults to `string` when no types have been generated.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Using generated agent name types
15
+ * // With generated types, you get autocomplete on agent names
16
+ * const conversation = await base44.agents.createConversation({ agent_name: 'SupportBot' });
17
+ * ```
12
18
  */
13
19
  export type AgentName = keyof AgentNameRegistry extends never ? string : keyof AgentNameRegistry;
14
20
  /**
@@ -164,6 +170,8 @@ export interface AgentsModuleConfig {
164
170
  * send messages, and subscribe to realtime updates. Conversations can be used
165
171
  * for chat interfaces, support systems, or any interactive AI app.
166
172
  *
173
+ * ## Key Features
174
+ *
167
175
  * The agents module enables you to:
168
176
  *
169
177
  * - **Create conversations** with agents defined in the app.
@@ -173,17 +181,24 @@ export interface AgentsModuleConfig {
173
181
  * - **Attach metadata** to conversations for tracking context, categories, priorities, or linking to external systems.
174
182
  * - **Generate WhatsApp connection URLs** for users to interact with agents through WhatsApp.
175
183
  *
184
+ * ## Conversation Structure
185
+ *
176
186
  * The agents module operates with a two-level hierarchy:
177
187
  *
178
188
  * 1. **Conversations**: Top-level containers that represent a dialogue with a specific agent. Each conversation has a unique ID, is associated with an agent by name, and belongs to the user who created it. Conversations can include optional metadata for tracking app-specific context like ticket IDs, categories, or custom fields.
179
189
  *
180
190
  * 2. **Messages**: Individual exchanges within a conversation. Each message has a role, content, and optional metadata like token usage, tool calls, file attachments, and reasoning information. Messages are stored as an array within their parent conversation.
181
191
  *
192
+ * ## Authentication Modes
193
+ *
182
194
  * This module is available to use with a client in all authentication modes:
183
195
  *
184
196
  * - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations.
185
197
  * - **Service role authentication** (`base44.asServiceRole.agents`): Operations have elevated admin-level permissions. Can access all conversations that the app's admin role has access to.
186
198
  *
199
+ * ## Generated Types
200
+ *
201
+ * If you're working in a TypeScript project, you can generate types from your agents to get autocomplete on agent names when creating conversations or subscribing to updates. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
187
202
  */
188
203
  export interface AgentsModule {
189
204
  /**
@@ -208,7 +223,7 @@ export interface AgentsModule {
208
223
  * Gets a specific conversation by ID.
209
224
  *
210
225
  * Retrieves a single conversation using its unique identifier. To retrieve
211
- * all conversations, use {@linkcode getConversations | getConversations()} To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
226
+ * all conversations, use {@linkcode getConversations | getConversations()}. To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
212
227
  *
213
228
  * This function returns the complete stored conversation including full tool call results, even for large responses.
214
229
  *
@@ -312,8 +327,8 @@ export interface AgentsModule {
312
327
  * to clean up the connection.
313
328
  *
314
329
  * <Note>
315
- When receiving messages through this function, tool call data is truncated for efficiency. The `arguments_string` is limited to 500 characters and `results` to 50 characters. The complete tool call data is always saved in storage and can be retrieved by calling {@linkcode getConversation | getConversation()} after the message completes.
316
- </Note>
330
+ * When receiving messages through this function, tool call data is truncated for efficiency. The `arguments_string` is limited to 500 characters and `results` to 50 characters. The complete tool call data is always saved in storage and can be retrieved by calling {@linkcode getConversation | getConversation()} after the message completes.
331
+ * </Note>
317
332
  *
318
333
  * @param conversationId - The conversation ID to subscribe to.
319
334
  * @param onUpdate - Callback function called when the conversation is updated. The callback receives a conversation object with the following properties:
@@ -74,11 +74,15 @@ export type AnalyticsModuleOptions = {
74
74
  *
75
75
  * <Note> Analytics events tracked with this module appear as custom event cards in the [Analytics dashboard](/documentation/performance-and-seo/app-analytics).</Note>
76
76
  *
77
+ * ## Best Practices
78
+ *
77
79
  * When tracking events:
78
80
  *
79
81
  * - Choose clear, descriptive event names in snake_case like `signup_button_click` or `purchase_completed` rather than generic names like `click`.
80
82
  * - Include relevant context in your properties such as identifiers like `product_id`, measurements like `price`, and flags like `is_first_purchase`.
81
83
  *
84
+ * ## Authentication Modes
85
+ *
82
86
  * This module is only available in user authentication mode (`base44.analytics`).
83
87
  */
84
88
  export interface AnalyticsModule {
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This module provides a method to log user activity. The logs are reflected in the Analytics page in the app dashboard.
5
5
  *
6
+ * ## Authentication Modes
7
+ *
6
8
  * This module is available to use with a client in all authentication modes.
7
9
  */
8
10
  export interface AppLogsModule {
@@ -37,9 +37,18 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
37
37
  loginWithProvider(provider, fromUrl = "/") {
38
38
  // Build the full redirect URL
39
39
  const redirectUrl = new URL(fromUrl, window.location.origin).toString();
40
- // Build the provider login URL (google is the default, so no provider path needed)
41
- const providerPath = provider === "google" ? "" : `/${provider}`;
42
- const loginUrl = `${options.appBaseUrl}/api/apps/auth${providerPath}/login?app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
40
+ const queryParams = `app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
41
+ // SSO uses a different URL structure with appId in the path
42
+ let authPath;
43
+ if (provider === "sso") {
44
+ authPath = `/apps/${appId}/auth/sso/login`;
45
+ }
46
+ else {
47
+ // Google is the default provider, so no provider path segment needed
48
+ const providerPath = provider === "google" ? "" : `/${provider}`;
49
+ authPath = `/apps/auth${providerPath}/login`;
50
+ }
51
+ const loginUrl = `${options.appBaseUrl}/api${authPath}?${queryParams}`;
43
52
  // Redirect to the provider login page
44
53
  window.location.href = loginUrl;
45
54
  },
@@ -96,6 +96,8 @@ export interface AuthModuleOptions {
96
96
  /**
97
97
  * Authentication module for managing user authentication and authorization. The module automatically stores tokens in local storage when available and manages authorization headers for API requests.
98
98
  *
99
+ * ## Features
100
+ *
99
101
  * This module provides comprehensive authentication functionality including:
100
102
  * - Email/password login and registration
101
103
  * - Token management
@@ -104,6 +106,8 @@ export interface AuthModuleOptions {
104
106
  * - OTP verification
105
107
  * - User invitations
106
108
  *
109
+ * ## Authentication Modes
110
+ *
107
111
  * The auth module is only available in user authentication mode (`base44.auth`).
108
112
  */
109
113
  export interface AuthModule {
@@ -179,22 +183,36 @@ export interface AuthModule {
179
183
  * Supported providers:
180
184
  * - `'google'` - {@link https://developers.google.com/identity/protocols/oauth2 | Google OAuth}. Enabled by default.
181
185
  * - `'microsoft'` - {@link https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow | Microsoft OAuth}. Enable Microsoft in your app's authentication settings before specifying this provider.
182
- * - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable this in your app's authentication settings before using.
186
+ * - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
187
+ * - `'apple'` - {@link https://developer.apple.com/sign-in-with-apple/ | Sign in with Apple}. Enable Apple in your app's authentication settings before using this provider.
188
+ * - `'sso'` - Enterprise SSO. Enable SSO in your app's authentication settings before using this provider.
183
189
  *
184
- * @param provider - The authentication provider to use: `'google'`, `'microsoft'`, or `'facebook'`.
190
+ * @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, `'apple'`, or `'sso'`.
185
191
  * @param fromUrl - URL to redirect to after successful authentication. Defaults to `'/'`.
186
192
  *
187
193
  * @example
188
194
  * ```typescript
189
- * // Login with Google and return to current page
195
+ * // Google
190
196
  * base44.auth.loginWithProvider('google', window.location.pathname);
191
197
  * ```
192
198
  *
193
199
  * @example
194
200
  * ```typescript
195
- * // Login with Microsoft and redirect to dashboard
201
+ * // Microsoft
196
202
  * base44.auth.loginWithProvider('microsoft', '/dashboard');
197
203
  * ```
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * // Apple
208
+ * base44.auth.loginWithProvider('apple', '/dashboard');
209
+ * ```
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * // SSO
214
+ * base44.auth.loginWithProvider('sso', '/dashboard');
215
+ * ```
198
216
  */
199
217
  loginWithProvider(provider: string, fromUrl?: string): void;
200
218
  /**
@@ -8,8 +8,11 @@
8
8
  */
9
9
  export function createConnectorsModule(axios, appId) {
10
10
  return {
11
- // Retrieve an OAuth access token for a specific external integration type
12
- // @ts-expect-error Return type mismatch with interface - implementation returns object, interface expects string
11
+ /**
12
+ * Retrieve an OAuth access token for a specific external integration type.
13
+ * @deprecated Use getConnection(integrationType) and use the returned accessToken (and connectionConfig when needed) instead.
14
+ */
15
+ // @ts-expect-error Return type mismatch with interface - implementation returns string, interface expects string but implementation is typed as ConnectorAccessTokenResponse
13
16
  async getAccessToken(integrationType) {
14
17
  if (!integrationType || typeof integrationType !== "string") {
15
18
  throw new Error("Integration type is required and must be a string");
@@ -18,5 +21,17 @@ export function createConnectorsModule(axios, appId) {
18
21
  // @ts-expect-error
19
22
  return response.access_token;
20
23
  },
24
+ async getConnection(integrationType) {
25
+ var _a;
26
+ if (!integrationType || typeof integrationType !== "string") {
27
+ throw new Error("Integration type is required and must be a string");
28
+ }
29
+ const response = await axios.get(`/apps/${appId}/external-auth/tokens/${integrationType}`);
30
+ const data = response;
31
+ return {
32
+ accessToken: data.access_token,
33
+ connectionConfig: (_a = data.connection_config) !== null && _a !== void 0 ? _a : null,
34
+ };
35
+ },
21
36
  };
22
37
  }
@@ -1,12 +1,18 @@
1
1
  /**
2
- * Registry of connector integration types.
3
- * Augment this interface to enable autocomplete for connector integration types.
2
+ * Registry of connector integration type names. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`ConnectorIntegrationType`](#connectorintegrationtype) resolves to a union of the keys.
4
3
  */
5
4
  export interface ConnectorIntegrationTypeRegistry {
6
5
  }
7
6
  /**
8
- * The type of external integration/connector, such as `'googlecalendar'`, `'slack'`, or `'github'`.
9
- * Uses registry keys if augmented, otherwise falls back to string.
7
+ * Union of all connector integration type names from the [`ConnectorIntegrationTypeRegistry`](#connectorintegrationtyperegistry). Defaults to `string` when no types have been generated.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Using generated connector type names
12
+ * // With generated types, you get autocomplete on integration types
13
+ * const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
14
+ * const token = connection.accessToken;
15
+ * ```
10
16
  */
11
17
  export type ConnectorIntegrationType = keyof ConnectorIntegrationTypeRegistry extends never ? string : keyof ConnectorIntegrationTypeRegistry;
12
18
  /**
@@ -14,6 +20,17 @@ export type ConnectorIntegrationType = keyof ConnectorIntegrationTypeRegistry ex
14
20
  */
15
21
  export interface ConnectorAccessTokenResponse {
16
22
  access_token: string;
23
+ integration_type: string;
24
+ connection_config: Record<string, string> | null;
25
+ }
26
+ /**
27
+ * Camel-cased connection details returned by {@linkcode ConnectorsModule.getConnection | getConnection()}.
28
+ */
29
+ export interface ConnectorConnectionResponse {
30
+ /** The OAuth access token for the external service. */
31
+ accessToken: string;
32
+ /** Key-value configuration for the connection, or `null` if the connector does not provide one. */
33
+ connectionConfig: Record<string, string> | null;
17
34
  }
18
35
  /**
19
36
  * Connectors module for managing OAuth tokens for external services.
@@ -25,12 +42,20 @@ export interface ConnectorAccessTokenResponse {
25
42
  * the API calls you make. This is useful when you need custom API interactions that aren't
26
43
  * covered by Base44's pre-built integrations.
27
44
  *
45
+ * ## Authentication Modes
46
+ *
28
47
  * This module is only available to use with a client in service role authentication mode, which means it can only be used in backend environments.
48
+ *
49
+ * ## Dynamic Types
50
+ *
51
+ * If you're working in a TypeScript project, you can generate types from your app's connector configurations to get autocomplete on integration type names when calling `getConnection()`. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
29
52
  */
30
53
  export interface ConnectorsModule {
31
54
  /**
32
55
  * Retrieves an OAuth access token for a specific external integration type.
33
56
  *
57
+ * @deprecated Use {@link getConnection} and use the returned `accessToken` (and `connectionConfig` when needed) instead.
58
+ *
34
59
  * Returns the OAuth token string for an external service that an app builder
35
60
  * has connected to. This token represents the connected app builder's account
36
61
  * and can be used to make authenticated API calls to that external service on behalf of the app.
@@ -72,4 +97,41 @@ export interface ConnectorsModule {
72
97
  * ```
73
98
  */
74
99
  getAccessToken(integrationType: ConnectorIntegrationType): Promise<string>;
100
+ /**
101
+ * Retrieves the OAuth access token and connection configuration for a specific external integration type.
102
+ *
103
+ * Returns both the OAuth token and any additional connection configuration
104
+ * that the connector provides. This is useful when the external service requires
105
+ * extra parameters beyond the access token (e.g., a shop domain, account ID, or API base URL).
106
+ *
107
+ * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`.
108
+ * @returns Promise resolving to a {@link ConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * // Basic usage
113
+ * const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
114
+ * console.log(connection.accessToken);
115
+ * console.log(connection.connectionConfig);
116
+ * ```
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // Shopify: connectionConfig has subdomain (e.g. "my-store" for my-store.myshopify.com)
121
+ * const connection = await base44.asServiceRole.connectors.getConnection('shopify');
122
+ * const { accessToken, connectionConfig } = connection;
123
+ * const shop = connectionConfig?.subdomain
124
+ * ? `https://${connectionConfig.subdomain}.myshopify.com`
125
+ * : null;
126
+ *
127
+ * if (shop) {
128
+ * const response = await fetch(
129
+ * `${shop}/admin/api/2024-01/products.json?limit=10`,
130
+ * { headers: { 'X-Shopify-Access-Token': accessToken } }
131
+ * );
132
+ * const { products } = await response.json();
133
+ * }
134
+ * ```
135
+ */
136
+ getConnection(integrationType: ConnectorIntegrationType): Promise<ConnectorConnectionResponse>;
75
137
  }
@@ -27,16 +27,16 @@ export type RealtimeCallback<T = any> = (event: RealtimeEvent<T>) => void;
27
27
  * Result returned when deleting a single entity.
28
28
  */
29
29
  export interface DeleteResult {
30
- /** Whether the deletion was successful */
30
+ /** Whether the deletion was successful. */
31
31
  success: boolean;
32
32
  }
33
33
  /**
34
34
  * Result returned when deleting multiple entities.
35
35
  */
36
36
  export interface DeleteManyResult {
37
- /** Whether the deletion was successful */
37
+ /** Whether the deletion was successful. */
38
38
  success: boolean;
39
- /** Number of entities that were deleted */
39
+ /** Number of entities that were deleted. */
40
40
  deleted: number;
41
41
  }
42
42
  /**
@@ -45,23 +45,26 @@ export interface DeleteManyResult {
45
45
  * @typeParam T - The entity type for imported records. Defaults to `any`.
46
46
  */
47
47
  export interface ImportResult<T = any> {
48
- /** Status of the import operation */
48
+ /** Status of the import operation. */
49
49
  status: "success" | "error";
50
- /** Details message, e.g., "Successfully imported 3 entities with RLS enforcement" */
50
+ /** Details message, e.g., "Successfully imported 3 entities with RLS enforcement". */
51
51
  details: string | null;
52
- /** Array of created entity objects when successful, or null on error */
52
+ /** Array of created entity objects when successful, or null on error. */
53
53
  output: T[] | null;
54
54
  }
55
55
  /**
56
56
  * Sort field type for entity queries.
57
57
  *
58
- * Supports ascending (no prefix or `'+'`) and descending (`'-'`) sorting.
58
+ * Accepts any field name from the entity type with an optional prefix:
59
+ * - `'+'` prefix or no prefix: ascending sort
60
+ * - `'-'` prefix: descending sort
59
61
  *
60
62
  * @typeParam T - The entity type to derive sortable fields from.
61
63
  *
62
64
  * @example
63
65
  * ```typescript
64
- * // Ascending sort (default)
66
+ * // Specify sort direction by prefixing field names with + or -
67
+ * // Ascending sort
65
68
  * 'created_date'
66
69
  * '+created_date'
67
70
  *
@@ -71,7 +74,7 @@ export interface ImportResult<T = any> {
71
74
  */
72
75
  export type SortField<T> = (keyof T & string) | `+${keyof T & string}` | `-${keyof T & string}`;
73
76
  /**
74
- * Fields added by the server to every entity record (id, dates, created_by, etc.).
77
+ * Fields added by the server to every entity record, such as `id`, `created_date`, `updated_date`, and `created_by`.
75
78
  */
76
79
  interface ServerEntityFields {
77
80
  /** Unique identifier of the record */
@@ -88,13 +91,29 @@ interface ServerEntityFields {
88
91
  is_sample?: boolean;
89
92
  }
90
93
  /**
91
- * Registry mapping entity names to their TypeScript types.
92
- * Augment this interface with your entity schema (user-defined fields only).
94
+ * Registry mapping entity names to their TypeScript types. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`EntityRecord`](#entityrecord) adds server fields.
93
95
  */
94
96
  export interface EntityTypeRegistry {
95
97
  }
96
98
  /**
97
- * Full record type for each entity: schema fields + server-injected fields (id, created_date, etc.).
99
+ * Combines the [`EntityTypeRegistry`](#entitytyperegistry) schemas with server fields like `id`, `created_date`, and `updated_date` to give the complete record type for each entity. Use this when you need to type variables holding entity data.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * // Using EntityRecord to get the complete type for an entity
104
+ * // Combine your schema with server fields (id, created_date, etc.)
105
+ * type TaskRecord = EntityRecord['Task'];
106
+ *
107
+ * const task: TaskRecord = await base44.entities.Task.create({
108
+ * title: 'My task',
109
+ * status: 'pending'
110
+ * });
111
+ *
112
+ * // Task now includes both your fields and server fields:
113
+ * console.log(task.id); // Server field
114
+ * console.log(task.created_date); // Server field
115
+ * console.log(task.title); // Your field
116
+ * ```
98
117
  */
99
118
  export type EntityRecord = {
100
119
  [K in keyof EntityTypeRegistry]: EntityTypeRegistry[K] & ServerEntityFields;
@@ -401,17 +420,29 @@ type DynamicEntitiesModule = {
401
420
  * Entities are accessed dynamically using the pattern:
402
421
  * `base44.entities.EntityName.method()`
403
422
  *
404
- * This module is available to use with a client in all three authentication modes:
423
+ * This module is available to use with a client in all authentication modes:
405
424
  *
406
425
  * - **Anonymous or User authentication** (`base44.entities`): Access is scoped to the current user's permissions. Anonymous users can only access public entities, while authenticated users can access entities they have permission to view or modify.
407
426
  * - **Service role authentication** (`base44.asServiceRole.entities`): Operations have elevated admin-level permissions. Can access all entities that the app's admin role has access to.
408
427
  *
428
+ * ## Entity Handlers
429
+ *
430
+ * An entity handler is the object you get when you access an entity through `base44.entities.EntityName`. Every entity in your app automatically gets a handler with CRUD methods for managing records.
431
+ *
432
+ * For example, `base44.entities.Task` is an entity handler for Task records, and `base44.entities.User` is an entity handler for User records. Each handler provides methods like `list()`, `create()`, `update()`, and `delete()`.
433
+ *
434
+ * You don't need to instantiate or import entity handlers. They're automatically available for every entity you create in your app.
435
+ *
409
436
  * ## Built-in User Entity
410
437
  *
411
438
  * Every app includes a built-in `User` entity that stores user account information. This entity has special security rules that can't be changed.
412
439
  *
413
440
  * Regular users can only read and update their own user record. With service role authentication, you can read, update, and delete any user. You can't create users using the entities module. Instead, use the functions of the {@link AuthModule | auth module} to invite or register new users.
414
441
  *
442
+ * ## Generated Types
443
+ *
444
+ * If you're working in a TypeScript project, you can generate types from your entity schemas to get autocomplete and type checking on all entity methods. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
445
+ *
415
446
  * @example
416
447
  * ```typescript
417
448
  * // Get all records from the MyEntity entity
@@ -1,11 +1,17 @@
1
1
  /**
2
- * Registry of function names.
3
- * Augment this interface to enable autocomplete for function names.
2
+ * Registry of function names. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`FunctionName`](#functionname) resolves to a union of the keys.
4
3
  */
5
4
  export interface FunctionNameRegistry {
6
5
  }
7
6
  /**
8
- * Function name type - uses registry keys if augmented, otherwise string.
7
+ * Union of all function names from the [`FunctionNameRegistry`](#functionnameregistry). Defaults to `string` when no types have been generated.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Using generated function name types
12
+ * // With generated types, you get autocomplete on function names
13
+ * await base44.functions.invoke('calculateTotal', { items: ['item1', 'item2'] });
14
+ * ```
9
15
  */
10
16
  export type FunctionName = keyof FunctionNameRegistry extends never ? string : keyof FunctionNameRegistry;
11
17
  /**
@@ -13,10 +19,16 @@ export type FunctionName = keyof FunctionNameRegistry extends never ? string : k
13
19
  *
14
20
  * This module allows you to invoke the custom backend functions defined in the app.
15
21
  *
22
+ * ## Authentication Modes
23
+ *
16
24
  * This module is available to use with a client in all authentication modes:
17
25
  *
18
26
  * - **Anonymous or User authentication** (`base44.functions`): Functions are invoked with the current user's permissions. Anonymous users invoke functions without authentication, while authenticated users invoke functions with their authentication context.
19
27
  * - **Service role authentication** (`base44.asServiceRole.functions`): Functions are invoked with elevated admin-level permissions. The function code receives a request with admin authentication context.
28
+ *
29
+ * ## Generated Types
30
+ *
31
+ * If you're working in a TypeScript project, you can generate types from your backend functions to get autocomplete on function names when calling `invoke()`. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
20
32
  */
21
33
  export interface FunctionsModule {
22
34
  /**
@@ -36,7 +48,6 @@ export interface FunctionsModule {
36
48
  * // Basic function call
37
49
  * const result = await base44.functions.invoke('calculateTotal', {
38
50
  * items: ['item1', 'item2'],
39
- * discount: 0.1
40
51
  * });
41
52
  * console.log(result.data.total);
42
53
  * ```
@@ -12,18 +12,25 @@ export type IntegrationEndpointFunction = (data: Record<string, any>) => Promise
12
12
  /**
13
13
  * A package containing integration endpoints.
14
14
  *
15
- * Provides dynamic access to integration endpoints within a package.
16
- * Each endpoint is accessed as a property that returns a function to invoke it.
15
+ * An integration package is a collection of endpoint functions indexed by endpoint name.
16
+ * Both `Core` and `custom` are integration packages that implement this structure.
17
17
  *
18
- * @example
18
+ * @example **Core package**
19
19
  * ```typescript
20
- * // Access endpoints dynamically
21
- * const result = await integrations.Core.SendEmail({
22
- * to: 'user@example.com',
23
- * subject: 'Hello',
24
- * body: 'Message'
20
+ * await base44.integrations.Core.InvokeLLM({
21
+ * prompt: 'Explain quantum computing',
22
+ * model: 'gpt-4'
25
23
  * });
26
24
  * ```
25
+ *
26
+ * @example **custom package**
27
+ * ```typescript
28
+ * await base44.integrations.custom.call(
29
+ * 'github',
30
+ * 'get:/repos/{owner}/{repo}',
31
+ * { pathParams: { owner: 'myorg', repo: 'myrepo' } }
32
+ * );
33
+ * ```
27
34
  */
28
35
  export type IntegrationPackage = {
29
36
  [endpointName: string]: IntegrationEndpointFunction;
@@ -324,6 +331,8 @@ export interface CoreIntegrations {
324
331
  *
325
332
  * This module provides access to integration methods for interacting with external services. Unlike the connectors module that gives you raw OAuth tokens, integrations provide pre-built functions that Base44 executes on your behalf.
326
333
  *
334
+ * ## Integration Types
335
+ *
327
336
  * There are two types of integrations:
328
337
  *
329
338
  * - **Built-in integrations** (`Core`): Pre-built functions provided by Base44 for common tasks such as AI-powered text generation, image creation, file uploads, and email. Access core integration methods using:
@@ -331,12 +340,14 @@ export interface CoreIntegrations {
331
340
  * base44.integrations.Core.FunctionName(params)
332
341
  * ```
333
342
  *
334
- * - **Custom integrations** (`custom`): Pre-configured external APIs. Custom integration calls are proxied through Base44's backend, so credentials are never exposed to the frontend. Access custom integration methods using:
343
+ * - **Custom workspace integrations** (`custom`): Pre-configured external APIs set up by workspace administrators. Workspace integration calls are proxied through Base44's backend, so credentials are never exposed to the frontend. Access custom workspace integration methods using:
335
344
  * ```
336
345
  * base44.integrations.custom.call(slug, operationId, params)
337
346
  * ```
338
347
  *
339
- * <Info>To call a custom integration, it must be pre-configured by a workspace administrator who imports an OpenAPI specification.</Info>
348
+ * <Info>To call a custom workspace integration, it must be pre-configured by a workspace administrator who imports an OpenAPI specification. Learn more about [custom workspace integrations](/documentation/integrations/managing-workspace-integrations).</Info>
349
+ *
350
+ * ## Authentication Modes
340
351
  *
341
352
  * This module is available to use with a client in all authentication modes:
342
353
  *
@@ -346,18 +357,52 @@ export interface CoreIntegrations {
346
357
  export type IntegrationsModule = {
347
358
  /**
348
359
  * Core package containing built-in Base44 integration functions.
360
+ *
361
+ * @example
362
+ * ```typescript
363
+ * const response = await base44.integrations.Core.InvokeLLM({
364
+ * prompt: 'Explain quantum computing',
365
+ * model: 'gpt-4'
366
+ * });
367
+ * ```
349
368
  */
350
369
  Core: CoreIntegrations;
351
370
  /**
352
- * Custom integrations module for calling pre-configured external APIs.
371
+ * Workspace integrations module for calling pre-configured external APIs.
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * const result = await base44.integrations.custom.call(
376
+ * 'github',
377
+ * 'get:/repos/{owner}/{repo}',
378
+ * { pathParams: { owner: 'myorg', repo: 'myrepo' } }
379
+ * );
380
+ * ```
353
381
  */
354
382
  custom: CustomIntegrationsModule;
355
383
  } & {
356
384
  /**
357
385
  * Access to additional integration packages.
358
386
  *
359
- * Additional integration packages may be added in the future and will be
360
- * accessible using the same pattern as Core.
387
+ * Allows accessing integration packages as properties. This enables both `Core` and `custom` packages,
388
+ * as well as any future integration packages that may be added.
389
+ *
390
+ * @example **Use Core integrations**
391
+ * ```typescript
392
+ * const response = await base44.integrations.Core.InvokeLLM({
393
+ * prompt: 'Explain quantum computing',
394
+ * model: 'gpt-4'
395
+ * });
396
+ * ```
397
+ *
398
+ * @example **Use custom integrations**
399
+ * ```typescript
400
+ * const result = await base44.integrations.custom.call(
401
+ * 'github',
402
+ * 'get:/repos/{owner}/{repo}',
403
+ * { pathParams: { owner: 'myorg', repo: 'myrepo' } }
404
+ * );
405
+ * ```
361
406
  */
362
407
  [packageName: string]: IntegrationPackage;
363
408
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44/sdk",
3
- "version": "0.8.19",
3
+ "version": "0.8.20",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",