@base44-preview/sdk 0.8.19-pr.126.c537ed8 → 0.8.19-pr.127.7353bb5
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 +3 -3
- package/dist/modules/agents.js +0 -61
- package/dist/modules/agents.types.d.ts +16 -106
- package/dist/modules/entities.types.d.ts +34 -10
- package/dist/modules/functions.types.d.ts +13 -3
- package/package.json +1 -1
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, } from "./modules/entities.types.js";
|
|
8
8
|
export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
|
|
9
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";
|
|
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";
|
package/dist/modules/agents.js
CHANGED
|
@@ -3,8 +3,6 @@ export function createAgentsModule({ axios, getSocket, appId, serverUrl, token,
|
|
|
3
3
|
const baseURL = `/apps/${appId}/agents`;
|
|
4
4
|
// Track active conversations
|
|
5
5
|
const currentConversations = {};
|
|
6
|
-
// Stores client tool handlers keyed by conversation ID
|
|
7
|
-
const clientToolHandlers = {};
|
|
8
6
|
const getConversations = () => {
|
|
9
7
|
return axios.get(`${baseURL}/conversations`);
|
|
10
8
|
};
|
|
@@ -22,60 +20,6 @@ export function createAgentsModule({ axios, getSocket, appId, serverUrl, token,
|
|
|
22
20
|
const addMessage = async (conversation, message) => {
|
|
23
21
|
return axios.post(`${baseURL}/conversations/v2/${conversation.id}/messages`, message);
|
|
24
22
|
};
|
|
25
|
-
const registerClientToolHandlers = (conversationId, handlers) => {
|
|
26
|
-
clientToolHandlers[conversationId] = {
|
|
27
|
-
...(clientToolHandlers[conversationId] || {}),
|
|
28
|
-
...handlers,
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const submitToolResults = (conversationId, results) => {
|
|
32
|
-
return axios.post(`${baseURL}/conversations/${conversationId}/client-tool-results`, { results });
|
|
33
|
-
};
|
|
34
|
-
const handlePendingClientTools = async (conversationId, message) => {
|
|
35
|
-
var _a;
|
|
36
|
-
if (!(message === null || message === void 0 ? void 0 : message.tool_calls))
|
|
37
|
-
return false;
|
|
38
|
-
const pendingCalls = message.tool_calls.filter((tc) => tc.status === "pending_client_execution");
|
|
39
|
-
if (pendingCalls.length === 0)
|
|
40
|
-
return false;
|
|
41
|
-
const handlers = clientToolHandlers[conversationId];
|
|
42
|
-
if (!handlers)
|
|
43
|
-
return false;
|
|
44
|
-
const results = [];
|
|
45
|
-
for (const tc of pendingCalls) {
|
|
46
|
-
const handler = handlers[tc.name];
|
|
47
|
-
if (!handler) {
|
|
48
|
-
results.push({
|
|
49
|
-
tool_call_id: tc.id,
|
|
50
|
-
result: `Error: No handler registered for client tool '${tc.name}'`,
|
|
51
|
-
});
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const args = JSON.parse(tc.arguments_string);
|
|
56
|
-
const context = {
|
|
57
|
-
appId,
|
|
58
|
-
conversationId,
|
|
59
|
-
toolCallId: tc.id,
|
|
60
|
-
toolName: tc.name,
|
|
61
|
-
messages: ((_a = currentConversations[conversationId]) === null || _a === void 0 ? void 0 : _a.messages) || [],
|
|
62
|
-
};
|
|
63
|
-
const result = await handler(args, context);
|
|
64
|
-
results.push({
|
|
65
|
-
tool_call_id: tc.id,
|
|
66
|
-
result: typeof result === "string" ? result : JSON.stringify(result),
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
results.push({
|
|
71
|
-
tool_call_id: tc.id,
|
|
72
|
-
result: `Error executing client tool '${tc.name}': ${error.message}`,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
await submitToolResults(conversationId, results);
|
|
77
|
-
return true;
|
|
78
|
-
};
|
|
79
23
|
const subscribeToConversation = (conversationId, onUpdate) => {
|
|
80
24
|
const room = `/agent-conversations/${conversationId}`;
|
|
81
25
|
const socket = getSocket();
|
|
@@ -105,8 +49,6 @@ export function createAgentsModule({ axios, getSocket, appId, serverUrl, token,
|
|
|
105
49
|
messages: updatedMessages,
|
|
106
50
|
};
|
|
107
51
|
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(currentConversations[conversationId]);
|
|
108
|
-
// Automatically handle pending client tool calls
|
|
109
|
-
await handlePendingClientTools(conversationId, message);
|
|
110
52
|
}
|
|
111
53
|
}
|
|
112
54
|
},
|
|
@@ -129,9 +71,6 @@ export function createAgentsModule({ axios, getSocket, appId, serverUrl, token,
|
|
|
129
71
|
listConversations,
|
|
130
72
|
createConversation,
|
|
131
73
|
addMessage,
|
|
132
|
-
registerClientToolHandlers,
|
|
133
|
-
submitToolResults,
|
|
134
|
-
handlePendingClientTools,
|
|
135
74
|
subscribeToConversation,
|
|
136
75
|
getWhatsAppConnectURL,
|
|
137
76
|
};
|
|
@@ -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
|
-
*
|
|
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
|
/**
|
|
@@ -37,7 +43,7 @@ export interface AgentMessageToolCall {
|
|
|
37
43
|
/** Arguments passed to the tool as JSON string. */
|
|
38
44
|
arguments_string: string;
|
|
39
45
|
/** Status of the tool call. */
|
|
40
|
-
status: "running" | "success" | "error" | "stopped"
|
|
46
|
+
status: "running" | "success" | "error" | "stopped";
|
|
41
47
|
/** Results from the tool call. */
|
|
42
48
|
results?: string;
|
|
43
49
|
}
|
|
@@ -141,37 +147,6 @@ export interface CreateConversationParams {
|
|
|
141
147
|
/** Optional metadata to attach to the conversation. */
|
|
142
148
|
metadata?: Record<string, any>;
|
|
143
149
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Context passed to client tool handlers during execution.
|
|
146
|
-
*/
|
|
147
|
-
export interface ClientToolContext {
|
|
148
|
-
/** The app ID. */
|
|
149
|
-
appId: string;
|
|
150
|
-
/** The conversation ID. */
|
|
151
|
-
conversationId: string;
|
|
152
|
-
/** The unique tool call ID. */
|
|
153
|
-
toolCallId: string;
|
|
154
|
-
/** The tool name. */
|
|
155
|
-
toolName: string;
|
|
156
|
-
/** The conversation messages so far. */
|
|
157
|
-
messages: AgentMessage[];
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* A client tool handler function.
|
|
161
|
-
*
|
|
162
|
-
* Receives parsed arguments and execution context, returns a string result
|
|
163
|
-
* (or an object that will be JSON.stringified).
|
|
164
|
-
*/
|
|
165
|
-
export type ClientToolHandler = (args: Record<string, any>, context: ClientToolContext) => Promise<string | Record<string, any>> | string | Record<string, any>;
|
|
166
|
-
/**
|
|
167
|
-
* Result of a client tool execution, to be submitted back to the server.
|
|
168
|
-
*/
|
|
169
|
-
export interface ClientToolResult {
|
|
170
|
-
/** The tool call ID this result corresponds to. */
|
|
171
|
-
tool_call_id: string;
|
|
172
|
-
/** The result string. */
|
|
173
|
-
result: string;
|
|
174
|
-
}
|
|
175
150
|
/**
|
|
176
151
|
* Configuration for creating the agents module.
|
|
177
152
|
* @internal
|
|
@@ -215,6 +190,9 @@ export interface AgentsModuleConfig {
|
|
|
215
190
|
* - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations.
|
|
216
191
|
* - **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.
|
|
217
192
|
*
|
|
193
|
+
* ## Generated Types
|
|
194
|
+
*
|
|
195
|
+
* 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 [Generated Types](/developers/references/sdk/getting-started/generated-types) guide to get started.
|
|
218
196
|
*/
|
|
219
197
|
export interface AgentsModule {
|
|
220
198
|
/**
|
|
@@ -239,7 +217,7 @@ export interface AgentsModule {
|
|
|
239
217
|
* Gets a specific conversation by ID.
|
|
240
218
|
*
|
|
241
219
|
* Retrieves a single conversation using its unique identifier. To retrieve
|
|
242
|
-
* all conversations, use {@linkcode getConversations | getConversations()} To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
|
|
220
|
+
* all conversations, use {@linkcode getConversations | getConversations()}. To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
|
|
243
221
|
*
|
|
244
222
|
* This function returns the complete stored conversation including full tool call results, even for large responses.
|
|
245
223
|
*
|
|
@@ -335,71 +313,6 @@ export interface AgentsModule {
|
|
|
335
313
|
* ```
|
|
336
314
|
*/
|
|
337
315
|
addMessage(conversation: AgentConversation, message: Partial<AgentMessage>): Promise<AgentMessage>;
|
|
338
|
-
/**
|
|
339
|
-
* Registers handler functions for client-side tools defined in the agent configuration.
|
|
340
|
-
*
|
|
341
|
-
* Client tools are tools that execute in the browser rather than on the server.
|
|
342
|
-
* They are defined by the app builder in the agent configuration (name, description,
|
|
343
|
-
* parameters). The SDK caller provides the handler functions that run locally when
|
|
344
|
-
* the agent invokes these tools.
|
|
345
|
-
*
|
|
346
|
-
* When subscribed to the conversation via {@linkcode subscribeToConversation | subscribeToConversation()},
|
|
347
|
-
* client tool calls are handled automatically — the SDK detects pending client tool calls,
|
|
348
|
-
* executes the registered handlers, and submits results back to the server.
|
|
349
|
-
*
|
|
350
|
-
* For user info inside a handler, call `base44.auth.me()` from the handler body.
|
|
351
|
-
*
|
|
352
|
-
* @param conversationId - The conversation ID to register handlers for.
|
|
353
|
-
* @param handlers - Map of tool name to handler function. Each handler receives
|
|
354
|
-
* `(args, context)` where `args` are the parsed tool arguments and `context`
|
|
355
|
-
* includes `appId`, `conversationId`, `toolCallId`, `toolName`, and `messages`.
|
|
356
|
-
*
|
|
357
|
-
* @example
|
|
358
|
-
* ```typescript
|
|
359
|
-
* base44.agents.registerClientToolHandlers(conversation.id, {
|
|
360
|
-
* get_current_location: async ({ accuracy }, { conversationId, messages }) => {
|
|
361
|
-
* const pos = await new Promise((resolve, reject) =>
|
|
362
|
-
* navigator.geolocation.getCurrentPosition(resolve, reject, {
|
|
363
|
-
* enableHighAccuracy: accuracy === 'high'
|
|
364
|
-
* })
|
|
365
|
-
* );
|
|
366
|
-
* return JSON.stringify({
|
|
367
|
-
* lat: pos.coords.latitude,
|
|
368
|
-
* lng: pos.coords.longitude
|
|
369
|
-
* });
|
|
370
|
-
* },
|
|
371
|
-
* get_clipboard_text: async () => {
|
|
372
|
-
* return await navigator.clipboard.readText();
|
|
373
|
-
* }
|
|
374
|
-
* });
|
|
375
|
-
* ```
|
|
376
|
-
*/
|
|
377
|
-
registerClientToolHandlers(conversationId: string, handlers: Record<string, ClientToolHandler>): void;
|
|
378
|
-
/**
|
|
379
|
-
* Submits results for client-side tool calls.
|
|
380
|
-
*
|
|
381
|
-
* This is called automatically when using {@linkcode subscribeToConversation | subscribeToConversation()}
|
|
382
|
-
* with registered handlers. You only need to call this directly if you are
|
|
383
|
-
* implementing custom tool call handling logic outside of the subscription flow.
|
|
384
|
-
*
|
|
385
|
-
* @param conversationId - The conversation ID.
|
|
386
|
-
* @param results - Array of tool call results.
|
|
387
|
-
*/
|
|
388
|
-
submitToolResults(conversationId: string, results: ClientToolResult[]): Promise<any>;
|
|
389
|
-
/**
|
|
390
|
-
* Processes pending client-side tool calls from a message.
|
|
391
|
-
*
|
|
392
|
-
* Finds tool calls with `pending_client_execution` status, executes their
|
|
393
|
-
* registered handlers, and submits the results back to the server.
|
|
394
|
-
*
|
|
395
|
-
* This is called automatically by {@linkcode subscribeToConversation | subscribeToConversation()}.
|
|
396
|
-
* You only need to call this directly for custom handling flows.
|
|
397
|
-
*
|
|
398
|
-
* @param conversationId - The conversation ID.
|
|
399
|
-
* @param message - The message containing tool calls.
|
|
400
|
-
* @returns `true` if client tool calls were processed, `false` otherwise.
|
|
401
|
-
*/
|
|
402
|
-
handlePendingClientTools(conversationId: string, message: AgentMessage): Promise<boolean>;
|
|
403
316
|
/**
|
|
404
317
|
* Subscribes to realtime updates for a conversation.
|
|
405
318
|
*
|
|
@@ -407,12 +320,9 @@ export interface AgentsModule {
|
|
|
407
320
|
* messages are added to the conversation. Returns an unsubscribe function
|
|
408
321
|
* to clean up the connection.
|
|
409
322
|
*
|
|
410
|
-
* Client tool handlers registered via {@linkcode registerClientToolHandlers | registerClientToolHandlers()}
|
|
411
|
-
* are automatically executed when tool calls with `pending_client_execution` status arrive.
|
|
412
|
-
*
|
|
413
323
|
* <Note>
|
|
414
|
-
|
|
415
|
-
|
|
324
|
+
* 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.
|
|
325
|
+
* </Note>
|
|
416
326
|
*
|
|
417
327
|
* @param conversationId - The conversation ID to subscribe to.
|
|
418
328
|
* @param onUpdate - Callback function called when the conversation is updated. The callback receives a conversation object with the following properties:
|
|
@@ -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,11 +45,11 @@ 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
|
/**
|
|
@@ -88,13 +88,33 @@ interface ServerEntityFields {
|
|
|
88
88
|
is_sample?: boolean;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
* Registry mapping entity names to their TypeScript types.
|
|
92
|
-
* Augment this interface with your entity schema (user-defined fields only).
|
|
91
|
+
* 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
92
|
*/
|
|
94
93
|
export interface EntityTypeRegistry {
|
|
95
94
|
}
|
|
96
95
|
/**
|
|
97
|
-
*
|
|
96
|
+
* 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.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Type-safe entity records
|
|
101
|
+
* import type { EntityRecord } from '@base44/sdk';
|
|
102
|
+
* // Import your generated entity schema
|
|
103
|
+
* import type { Task } from '@/base44/.types/types';
|
|
104
|
+
*
|
|
105
|
+
* // Combine your schema with server fields (id, created_date, etc.)
|
|
106
|
+
* type TaskRecord = EntityRecord['Task'];
|
|
107
|
+
*
|
|
108
|
+
* const task: TaskRecord = await base44.entities.Task.create({
|
|
109
|
+
* title: 'My task',
|
|
110
|
+
* status: 'pending'
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* // Task now includes both your fields and server fields:
|
|
114
|
+
* console.log(task.id); // Server field
|
|
115
|
+
* console.log(task.created_date); // Server field
|
|
116
|
+
* console.log(task.title); // Your field
|
|
117
|
+
* ```
|
|
98
118
|
*/
|
|
99
119
|
export type EntityRecord = {
|
|
100
120
|
[K in keyof EntityTypeRegistry]: EntityTypeRegistry[K] & ServerEntityFields;
|
|
@@ -401,7 +421,7 @@ type DynamicEntitiesModule = {
|
|
|
401
421
|
* Entities are accessed dynamically using the pattern:
|
|
402
422
|
* `base44.entities.EntityName.method()`
|
|
403
423
|
*
|
|
404
|
-
* This module is available to use with a client in all
|
|
424
|
+
* This module is available to use with a client in all authentication modes:
|
|
405
425
|
*
|
|
406
426
|
* - **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
427
|
* - **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.
|
|
@@ -412,6 +432,10 @@ type DynamicEntitiesModule = {
|
|
|
412
432
|
*
|
|
413
433
|
* 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
434
|
*
|
|
435
|
+
* ## Generated Types
|
|
436
|
+
*
|
|
437
|
+
* 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 [Generated Types](/developers/references/sdk/getting-started/generated-types) guide to get started.
|
|
438
|
+
*
|
|
415
439
|
* @example
|
|
416
440
|
* ```typescript
|
|
417
441
|
* // 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
|
-
*
|
|
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
|
/**
|
|
@@ -17,6 +23,10 @@ export type FunctionName = keyof FunctionNameRegistry extends never ? string : k
|
|
|
17
23
|
*
|
|
18
24
|
* - **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
25
|
* - **Service role authentication** (`base44.asServiceRole.functions`): Functions are invoked with elevated admin-level permissions. The function code receives a request with admin authentication context.
|
|
26
|
+
*
|
|
27
|
+
* ## Generated Types
|
|
28
|
+
*
|
|
29
|
+
* 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 [Generated Types](/developers/references/sdk/getting-started/generated-types) guide to get started.
|
|
20
30
|
*/
|
|
21
31
|
export interface FunctionsModule {
|
|
22
32
|
/**
|