@base44-preview/sdk 0.8.18-pr.116.3508d64 → 0.8.18-pr.117.1fc9d15
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, RealtimeEventType, RealtimeEvent, RealtimeCallback, } from "./modules/entities.types.js";
|
|
7
|
+
export type { EntitiesModule, EntityHandler, EntityTypeRegistry, 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 } from "./modules/functions.types.js";
|
|
11
|
-
export type { AgentsModule, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.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";
|
|
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";
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { RoomsSocket } from "../utils/socket-utils.js";
|
|
3
3
|
import { ModelFilterParams } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Registry of agent names.
|
|
6
|
+
*
|
|
7
|
+
* This interface is designed to be augmented by generated type declaration files.
|
|
8
|
+
* When augmented, it enables autocomplete for agent names in methods like `createConversation`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // In your generated types.d.ts file:
|
|
13
|
+
* declare module '@base44/sdk' {
|
|
14
|
+
* interface AgentNameRegistry {
|
|
15
|
+
* support_agent: true;
|
|
16
|
+
* sales_bot: true;
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // Then in your code:
|
|
21
|
+
* await base44.agents.createConversation({
|
|
22
|
+
* agent_name: 'support_agent' // ✅ Autocomplete shows: 'support_agent' | 'sales_bot'
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface AgentNameRegistry {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Agent name type - uses registry keys if augmented, otherwise falls back to string.
|
|
30
|
+
*/
|
|
31
|
+
export type AgentName = keyof AgentNameRegistry extends never ? string : keyof AgentNameRegistry;
|
|
4
32
|
/**
|
|
5
33
|
* Reasoning information for an agent message.
|
|
6
34
|
*
|
|
@@ -126,8 +154,8 @@ export interface AgentMessage {
|
|
|
126
154
|
* Parameters for creating a new conversation.
|
|
127
155
|
*/
|
|
128
156
|
export interface CreateConversationParams {
|
|
129
|
-
/** The name of the agent to create a conversation with. */
|
|
130
|
-
agent_name:
|
|
157
|
+
/** The name of the agent to create a conversation with. When AgentNameRegistry is augmented, provides autocomplete. */
|
|
158
|
+
agent_name: AgentName;
|
|
131
159
|
/** Optional metadata to attach to the conversation. */
|
|
132
160
|
metadata?: Record<string, any>;
|
|
133
161
|
}
|
|
@@ -331,7 +359,7 @@ export interface AgentsModule {
|
|
|
331
359
|
* Generates a URL that users can use to connect with the agent through WhatsApp.
|
|
332
360
|
* The URL includes authentication if a token is available.
|
|
333
361
|
*
|
|
334
|
-
* @param agentName - The name of the agent.
|
|
362
|
+
* @param agentName - The name of the agent. When AgentNameRegistry is augmented, provides autocomplete.
|
|
335
363
|
* @returns WhatsApp connection URL.
|
|
336
364
|
*
|
|
337
365
|
* @example
|
|
@@ -342,5 +370,5 @@ export interface AgentsModule {
|
|
|
342
370
|
* // User can open this URL to start a WhatsApp conversation
|
|
343
371
|
* ```
|
|
344
372
|
*/
|
|
345
|
-
getWhatsAppConnectURL(agentName:
|
|
373
|
+
getWhatsAppConnectURL(agentName: AgentName): string;
|
|
346
374
|
}
|
package/dist/modules/auth.js
CHANGED
|
@@ -26,23 +26,9 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
26
26
|
throw new Error("Login method can only be used in a browser environment");
|
|
27
27
|
}
|
|
28
28
|
// If nextUrl is not provided, use the current URL
|
|
29
|
-
|
|
29
|
+
const redirectUrl = nextUrl
|
|
30
30
|
? new URL(nextUrl, window.location.origin).toString()
|
|
31
31
|
: window.location.href;
|
|
32
|
-
// Prevent redirect loops: if redirectUrl is already a login URL, extract the original from_url
|
|
33
|
-
try {
|
|
34
|
-
const parsedUrl = new URL(redirectUrl);
|
|
35
|
-
if (parsedUrl.pathname.endsWith("/login")) {
|
|
36
|
-
const originalFromUrl = parsedUrl.searchParams.get("from_url");
|
|
37
|
-
if (originalFromUrl) {
|
|
38
|
-
// Use the original destination instead of nesting login URLs
|
|
39
|
-
redirectUrl = originalFromUrl;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (_b) {
|
|
44
|
-
// If URL parsing fails, continue with the original redirectUrl
|
|
45
|
-
}
|
|
46
32
|
// Build the login URL
|
|
47
33
|
const loginUrl = `${(_a = options.appBaseUrl) !== null && _a !== void 0 ? _a : ""}/login?from_url=${encodeURIComponent(redirectUrl)}`;
|
|
48
34
|
// Redirect to the login page
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
export type RealtimeEventType = "create" | "update" | "delete";
|
|
5
5
|
/**
|
|
6
6
|
* Payload received when a realtime event occurs.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam T - The entity type for the data field. Defaults to `any`.
|
|
7
9
|
*/
|
|
8
|
-
export interface RealtimeEvent {
|
|
10
|
+
export interface RealtimeEvent<T = any> {
|
|
9
11
|
/** The type of change that occurred */
|
|
10
12
|
type: RealtimeEventType;
|
|
11
13
|
/** The entity data */
|
|
12
|
-
data:
|
|
14
|
+
data: T;
|
|
13
15
|
/** The unique identifier of the affected entity */
|
|
14
16
|
id: string;
|
|
15
17
|
/** ISO 8601 timestamp of when the event occurred */
|
|
@@ -17,14 +19,90 @@ export interface RealtimeEvent {
|
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Callback function invoked when a realtime event occurs.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam T - The entity type for the event data. Defaults to `any`.
|
|
24
|
+
*/
|
|
25
|
+
export type RealtimeCallback<T = any> = (event: RealtimeEvent<T>) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Result returned when deleting a single entity.
|
|
28
|
+
*/
|
|
29
|
+
export interface DeleteResult {
|
|
30
|
+
/** Whether the deletion was successful */
|
|
31
|
+
success: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result returned when deleting multiple entities.
|
|
35
|
+
*/
|
|
36
|
+
export interface DeleteManyResult {
|
|
37
|
+
/** Whether the deletion was successful */
|
|
38
|
+
success: boolean;
|
|
39
|
+
/** Number of entities that were deleted */
|
|
40
|
+
deleted: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Result returned when importing entities from a file.
|
|
44
|
+
*
|
|
45
|
+
* @typeParam T - The entity type for imported records. Defaults to `any`.
|
|
20
46
|
*/
|
|
21
|
-
export
|
|
47
|
+
export interface ImportResult<T = any> {
|
|
48
|
+
/** Status of the import operation */
|
|
49
|
+
status: "success" | "error";
|
|
50
|
+
/** Details message, e.g., "Successfully imported 3 entities with RLS enforcement" */
|
|
51
|
+
details: string | null;
|
|
52
|
+
/** Array of created entity objects when successful, or null on error */
|
|
53
|
+
output: T[] | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sort field type for entity queries.
|
|
57
|
+
*
|
|
58
|
+
* Supports ascending (no prefix or `'+'`) and descending (`'-'`) sorting.
|
|
59
|
+
*
|
|
60
|
+
* @typeParam T - The entity type to derive sortable fields from.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // Ascending sort (default)
|
|
65
|
+
* 'created_date'
|
|
66
|
+
* '+created_date'
|
|
67
|
+
*
|
|
68
|
+
* // Descending sort
|
|
69
|
+
* '-created_date'
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export type SortField<T> = (keyof T & string) | `+${keyof T & string}` | `-${keyof T & string}`;
|
|
73
|
+
/**
|
|
74
|
+
* Registry mapping entity names to their TypeScript types.
|
|
75
|
+
*
|
|
76
|
+
* This interface is designed to be augmented by generated type declaration files.
|
|
77
|
+
* When augmented, it enables type-safe entity access throughout your application.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // In your generated types.d.ts file:
|
|
82
|
+
* declare module '@base44/sdk' {
|
|
83
|
+
* interface EntityTypeRegistry {
|
|
84
|
+
* Task: { title: string; completed: boolean };
|
|
85
|
+
* User: { email: string; name: string };
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* // Then in your code:
|
|
90
|
+
* const task = await base44.entities.Task.create({
|
|
91
|
+
* title: 'Buy groceries', // ✅ Type-checked
|
|
92
|
+
* completed: false
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export interface EntityTypeRegistry {
|
|
97
|
+
}
|
|
22
98
|
/**
|
|
23
99
|
* Entity handler providing CRUD operations for a specific entity type.
|
|
24
100
|
*
|
|
25
101
|
* Each entity in the app gets a handler with these methods for managing data.
|
|
102
|
+
*
|
|
103
|
+
* @typeParam T - The entity type. Defaults to `any` for backward compatibility.
|
|
26
104
|
*/
|
|
27
|
-
export interface EntityHandler {
|
|
105
|
+
export interface EntityHandler<T = any> {
|
|
28
106
|
/**
|
|
29
107
|
* Lists records with optional pagination and sorting.
|
|
30
108
|
*
|
|
@@ -33,11 +111,12 @@ export interface EntityHandler {
|
|
|
33
111
|
*
|
|
34
112
|
* **Note:** The maximum limit is 5,000 items per request.
|
|
35
113
|
*
|
|
114
|
+
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
36
115
|
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
|
|
37
116
|
* @param limit - Maximum number of results to return. Defaults to `50`.
|
|
38
117
|
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
39
118
|
* @param fields - Array of field names to include in the response. Defaults to all fields.
|
|
40
|
-
* @returns Promise resolving to an array of records.
|
|
119
|
+
* @returns Promise resolving to an array of records with selected fields.
|
|
41
120
|
*
|
|
42
121
|
* @example
|
|
43
122
|
* ```typescript
|
|
@@ -64,7 +143,7 @@ export interface EntityHandler {
|
|
|
64
143
|
* const fields = await base44.entities.MyEntity.list('-created_date', 10, 0, ['name', 'status']);
|
|
65
144
|
* ```
|
|
66
145
|
*/
|
|
67
|
-
list(sort?:
|
|
146
|
+
list<K extends keyof T = keyof T>(sort?: SortField<T>, limit?: number, skip?: number, fields?: K[]): Promise<Pick<T, K>[]>;
|
|
68
147
|
/**
|
|
69
148
|
* Filters records based on a query.
|
|
70
149
|
*
|
|
@@ -73,6 +152,7 @@ export interface EntityHandler {
|
|
|
73
152
|
*
|
|
74
153
|
* **Note:** The maximum limit is 5,000 items per request.
|
|
75
154
|
*
|
|
155
|
+
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
76
156
|
* @param query - Query object with field-value pairs. Each key should be a field name
|
|
77
157
|
* from your entity schema, and each value is the criteria to match. Records matching all
|
|
78
158
|
* specified criteria are returned. Field names are case-sensitive.
|
|
@@ -80,7 +160,7 @@ export interface EntityHandler {
|
|
|
80
160
|
* @param limit - Maximum number of results to return. Defaults to `50`.
|
|
81
161
|
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
82
162
|
* @param fields - Array of field names to include in the response. Defaults to all fields.
|
|
83
|
-
* @returns Promise resolving to an array of filtered records.
|
|
163
|
+
* @returns Promise resolving to an array of filtered records with selected fields.
|
|
84
164
|
*
|
|
85
165
|
* @example
|
|
86
166
|
* ```typescript
|
|
@@ -122,7 +202,7 @@ export interface EntityHandler {
|
|
|
122
202
|
* );
|
|
123
203
|
* ```
|
|
124
204
|
*/
|
|
125
|
-
filter(query:
|
|
205
|
+
filter<K extends keyof T = keyof T>(query: Partial<T>, sort?: SortField<T>, limit?: number, skip?: number, fields?: K[]): Promise<Pick<T, K>[]>;
|
|
126
206
|
/**
|
|
127
207
|
* Gets a single record by ID.
|
|
128
208
|
*
|
|
@@ -138,7 +218,7 @@ export interface EntityHandler {
|
|
|
138
218
|
* console.log(record.name);
|
|
139
219
|
* ```
|
|
140
220
|
*/
|
|
141
|
-
get(id: string): Promise<
|
|
221
|
+
get(id: string): Promise<T>;
|
|
142
222
|
/**
|
|
143
223
|
* Creates a new record.
|
|
144
224
|
*
|
|
@@ -158,7 +238,7 @@ export interface EntityHandler {
|
|
|
158
238
|
* console.log('Created record with ID:', newRecord.id);
|
|
159
239
|
* ```
|
|
160
240
|
*/
|
|
161
|
-
create(data:
|
|
241
|
+
create(data: Partial<T>): Promise<T>;
|
|
162
242
|
/**
|
|
163
243
|
* Updates an existing record.
|
|
164
244
|
*
|
|
@@ -187,7 +267,7 @@ export interface EntityHandler {
|
|
|
187
267
|
* });
|
|
188
268
|
* ```
|
|
189
269
|
*/
|
|
190
|
-
update(id: string, data:
|
|
270
|
+
update(id: string, data: Partial<T>): Promise<T>;
|
|
191
271
|
/**
|
|
192
272
|
* Deletes a single record by ID.
|
|
193
273
|
*
|
|
@@ -200,10 +280,10 @@ export interface EntityHandler {
|
|
|
200
280
|
* ```typescript
|
|
201
281
|
* // Delete a record
|
|
202
282
|
* const result = await base44.entities.MyEntity.delete('entity-123');
|
|
203
|
-
* console.log('Deleted:', result);
|
|
283
|
+
* console.log('Deleted:', result.success);
|
|
204
284
|
* ```
|
|
205
285
|
*/
|
|
206
|
-
delete(id: string): Promise<
|
|
286
|
+
delete(id: string): Promise<DeleteResult>;
|
|
207
287
|
/**
|
|
208
288
|
* Deletes multiple records matching a query.
|
|
209
289
|
*
|
|
@@ -224,7 +304,7 @@ export interface EntityHandler {
|
|
|
224
304
|
* console.log('Deleted:', result);
|
|
225
305
|
* ```
|
|
226
306
|
*/
|
|
227
|
-
deleteMany(query:
|
|
307
|
+
deleteMany(query: Partial<T>): Promise<DeleteManyResult>;
|
|
228
308
|
/**
|
|
229
309
|
* Creates multiple records in a single request.
|
|
230
310
|
*
|
|
@@ -244,7 +324,7 @@ export interface EntityHandler {
|
|
|
244
324
|
* ]);
|
|
245
325
|
* ```
|
|
246
326
|
*/
|
|
247
|
-
bulkCreate(data:
|
|
327
|
+
bulkCreate(data: Partial<T>[]): Promise<T[]>;
|
|
248
328
|
/**
|
|
249
329
|
* Imports records from a file.
|
|
250
330
|
*
|
|
@@ -252,7 +332,7 @@ export interface EntityHandler {
|
|
|
252
332
|
* The file format should match your entity structure. Requires a browser environment and can't be used in the backend.
|
|
253
333
|
*
|
|
254
334
|
* @param file - File object to import.
|
|
255
|
-
* @returns Promise resolving to the import result.
|
|
335
|
+
* @returns Promise resolving to the import result containing status, details, and created records.
|
|
256
336
|
*
|
|
257
337
|
* @example
|
|
258
338
|
* ```typescript
|
|
@@ -261,12 +341,14 @@ export interface EntityHandler {
|
|
|
261
341
|
* const file = event.target.files?.[0];
|
|
262
342
|
* if (file) {
|
|
263
343
|
* const result = await base44.entities.MyEntity.importEntities(file);
|
|
264
|
-
*
|
|
344
|
+
* if (result.status === 'success' && result.output) {
|
|
345
|
+
* console.log(`Imported ${result.output.length} records`);
|
|
346
|
+
* }
|
|
265
347
|
* }
|
|
266
348
|
* };
|
|
267
349
|
* ```
|
|
268
350
|
*/
|
|
269
|
-
importEntities(file: File): Promise<
|
|
351
|
+
importEntities(file: File): Promise<ImportResult<T>>;
|
|
270
352
|
/**
|
|
271
353
|
* Subscribes to realtime updates for all records of this entity type.
|
|
272
354
|
*
|
|
@@ -292,8 +374,22 @@ export interface EntityHandler {
|
|
|
292
374
|
* unsubscribe();
|
|
293
375
|
* ```
|
|
294
376
|
*/
|
|
295
|
-
subscribe(callback: RealtimeCallback): () => void;
|
|
377
|
+
subscribe(callback: RealtimeCallback<T>): () => void;
|
|
296
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Typed entities module - maps registry keys to typed handlers.
|
|
381
|
+
* Only used when EntityTypeRegistry is augmented.
|
|
382
|
+
*/
|
|
383
|
+
type TypedEntitiesModule = {
|
|
384
|
+
[K in keyof EntityTypeRegistry]: EntityHandler<EntityTypeRegistry[K]>;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Dynamic entities module - allows any entity name with untyped handler.
|
|
388
|
+
* Used as fallback and for entities not in the registry.
|
|
389
|
+
*/
|
|
390
|
+
type DynamicEntitiesModule = {
|
|
391
|
+
[entityName: string]: EntityHandler<any>;
|
|
392
|
+
};
|
|
297
393
|
/**
|
|
298
394
|
* Entities module for managing app data.
|
|
299
395
|
*
|
|
@@ -303,6 +399,9 @@ export interface EntityHandler {
|
|
|
303
399
|
* Entities are accessed dynamically using the pattern:
|
|
304
400
|
* `base44.entities.EntityName.method()`
|
|
305
401
|
*
|
|
402
|
+
* When {@link EntityTypeRegistry} is augmented (via generated types.d.ts),
|
|
403
|
+
* entity access becomes type-safe with autocomplete and type checking.
|
|
404
|
+
*
|
|
306
405
|
* This module is available to use with a client in all three authentication modes:
|
|
307
406
|
*
|
|
308
407
|
* - **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.
|
|
@@ -327,18 +426,5 @@ export interface EntityHandler {
|
|
|
327
426
|
* const allUsers = await base44.asServiceRole.entities.User.list();
|
|
328
427
|
* ```
|
|
329
428
|
*/
|
|
330
|
-
export
|
|
331
|
-
|
|
332
|
-
* Access any entity by name.
|
|
333
|
-
*
|
|
334
|
-
* Use this to access entities defined in the app.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```typescript
|
|
338
|
-
* // Access entities dynamically
|
|
339
|
-
* base44.entities.MyEntity
|
|
340
|
-
* base44.entities.AnotherEntity
|
|
341
|
-
* ```
|
|
342
|
-
*/
|
|
343
|
-
[entityName: string]: EntityHandler;
|
|
344
|
-
}
|
|
429
|
+
export type EntitiesModule = TypedEntitiesModule & DynamicEntitiesModule;
|
|
430
|
+
export {};
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of function names.
|
|
3
|
+
*
|
|
4
|
+
* This interface is designed to be augmented by generated type declaration files.
|
|
5
|
+
* When augmented, it enables autocomplete for function names in the `invoke` method.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // In your generated types.d.ts file:
|
|
10
|
+
* declare module '@base44/sdk' {
|
|
11
|
+
* interface FunctionNameRegistry {
|
|
12
|
+
* calculateTotal: true;
|
|
13
|
+
* processImage: true;
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* // Then in your code:
|
|
18
|
+
* await base44.functions.invoke('calculateTotal', { ... });
|
|
19
|
+
* // ^^^^^^^^^^^^^^^^
|
|
20
|
+
* // ✅ Autocomplete shows: 'calculateTotal' | 'processImage'
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export interface FunctionNameRegistry {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Function name type - uses registry keys if augmented, otherwise falls back to string.
|
|
27
|
+
*/
|
|
28
|
+
export type FunctionName = keyof FunctionNameRegistry extends never ? string : keyof FunctionNameRegistry;
|
|
1
29
|
/**
|
|
2
30
|
* Functions module for invoking custom backend functions.
|
|
3
31
|
*
|
|
@@ -17,7 +45,7 @@ export interface FunctionsModule {
|
|
|
17
45
|
* the result. If any parameter is a `File` object, the request will automatically be
|
|
18
46
|
* sent as `multipart/form-data`. Otherwise, it will be sent as JSON.
|
|
19
47
|
*
|
|
20
|
-
* @param functionName - The name of the function to invoke.
|
|
48
|
+
* @param functionName - The name of the function to invoke. When FunctionNameRegistry is augmented, provides autocomplete.
|
|
21
49
|
* @param data - An object containing named parameters for the function.
|
|
22
50
|
* @returns Promise resolving to the function's response. The `data` property contains the data returned by the function, if there is any.
|
|
23
51
|
*
|
|
@@ -46,5 +74,5 @@ export interface FunctionsModule {
|
|
|
46
74
|
* };
|
|
47
75
|
* ```
|
|
48
76
|
*/
|
|
49
|
-
invoke(functionName:
|
|
77
|
+
invoke(functionName: FunctionName, data?: Record<string, any>): Promise<any>;
|
|
50
78
|
}
|