@base44/sdk 0.8.18 → 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/README.md +83 -11
- package/dist/client.d.ts +9 -5
- package/dist/client.js +13 -7
- package/dist/client.types.d.ts +22 -19
- package/dist/index.d.ts +4 -4
- package/dist/modules/agents.types.d.ts +50 -13
- package/dist/modules/analytics.types.d.ts +83 -3
- package/dist/modules/app-logs.types.d.ts +2 -0
- package/dist/modules/auth.js +30 -24
- package/dist/modules/auth.types.d.ts +30 -7
- package/dist/modules/connectors.js +17 -2
- package/dist/modules/connectors.types.d.ts +75 -8
- package/dist/modules/custom-integrations.types.d.ts +38 -54
- package/dist/modules/entities.types.d.ts +164 -42
- package/dist/modules/functions.types.d.ts +23 -2
- package/dist/modules/integrations.types.d.ts +67 -31
- package/package.json +3 -2
|
@@ -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,29 +19,127 @@ 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`.
|
|
46
|
+
*/
|
|
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
|
+
* Accepts any field name from the entity type with an optional prefix:
|
|
59
|
+
* - `'+'` prefix or no prefix: ascending sort
|
|
60
|
+
* - `'-'` prefix: descending sort
|
|
61
|
+
*
|
|
62
|
+
* @typeParam T - The entity type to derive sortable fields from.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // Specify sort direction by prefixing field names with + or -
|
|
67
|
+
* // Ascending sort
|
|
68
|
+
* 'created_date'
|
|
69
|
+
* '+created_date'
|
|
70
|
+
*
|
|
71
|
+
* // Descending sort
|
|
72
|
+
* '-created_date'
|
|
73
|
+
* ```
|
|
20
74
|
*/
|
|
21
|
-
export type
|
|
75
|
+
export type SortField<T> = (keyof T & string) | `+${keyof T & string}` | `-${keyof T & string}`;
|
|
22
76
|
/**
|
|
23
|
-
*
|
|
77
|
+
* Fields added by the server to every entity record, such as `id`, `created_date`, `updated_date`, and `created_by`.
|
|
24
78
|
*/
|
|
25
|
-
|
|
79
|
+
interface ServerEntityFields {
|
|
80
|
+
/** Unique identifier of the record */
|
|
81
|
+
id: string;
|
|
82
|
+
/** ISO 8601 timestamp when the record was created */
|
|
83
|
+
created_date: string;
|
|
84
|
+
/** ISO 8601 timestamp when the record was last updated */
|
|
85
|
+
updated_date: string;
|
|
86
|
+
/** Email of the user who created the record (may be hidden in some responses) */
|
|
87
|
+
created_by?: string | null;
|
|
88
|
+
/** ID of the user who created the record */
|
|
89
|
+
created_by_id?: string | null;
|
|
90
|
+
/** Whether the record is sample/seed data */
|
|
91
|
+
is_sample?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
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.
|
|
95
|
+
*/
|
|
96
|
+
export interface EntityTypeRegistry {
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
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
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export type EntityRecord = {
|
|
119
|
+
[K in keyof EntityTypeRegistry]: EntityTypeRegistry[K] & ServerEntityFields;
|
|
120
|
+
};
|
|
26
121
|
/**
|
|
27
122
|
* Entity handler providing CRUD operations for a specific entity type.
|
|
28
123
|
*
|
|
29
124
|
* Each entity in the app gets a handler with these methods for managing data.
|
|
125
|
+
*
|
|
126
|
+
* @typeParam T - The entity type. Defaults to `any` for backward compatibility.
|
|
30
127
|
*/
|
|
31
|
-
export interface EntityHandler {
|
|
128
|
+
export interface EntityHandler<T = any> {
|
|
32
129
|
/**
|
|
33
130
|
* Lists records with optional pagination and sorting.
|
|
34
131
|
*
|
|
35
132
|
* Retrieves all records of this type with support for sorting,
|
|
36
133
|
* pagination, and field selection.
|
|
37
134
|
*
|
|
135
|
+
* **Note:** The maximum limit is 5,000 items per request.
|
|
136
|
+
*
|
|
137
|
+
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
38
138
|
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
|
|
39
139
|
* @param limit - Maximum number of results to return. Defaults to `50`.
|
|
40
140
|
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
41
141
|
* @param fields - Array of field names to include in the response. Defaults to all fields.
|
|
42
|
-
* @returns Promise resolving to an array of records.
|
|
142
|
+
* @returns Promise resolving to an array of records with selected fields.
|
|
43
143
|
*
|
|
44
144
|
* @example
|
|
45
145
|
* ```typescript
|
|
@@ -66,13 +166,16 @@ export interface EntityHandler {
|
|
|
66
166
|
* const fields = await base44.entities.MyEntity.list('-created_date', 10, 0, ['name', 'status']);
|
|
67
167
|
* ```
|
|
68
168
|
*/
|
|
69
|
-
list(sort?:
|
|
169
|
+
list<K extends keyof T = keyof T>(sort?: SortField<T>, limit?: number, skip?: number, fields?: K[]): Promise<Pick<T, K>[]>;
|
|
70
170
|
/**
|
|
71
171
|
* Filters records based on a query.
|
|
72
172
|
*
|
|
73
173
|
* Retrieves records that match specific criteria with support for
|
|
74
174
|
* sorting, pagination, and field selection.
|
|
75
175
|
*
|
|
176
|
+
* **Note:** The maximum limit is 5,000 items per request.
|
|
177
|
+
*
|
|
178
|
+
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
76
179
|
* @param query - Query object with field-value pairs. Each key should be a field name
|
|
77
180
|
* from your entity schema, and each value is the criteria to match. Records matching all
|
|
78
181
|
* specified criteria are returned. Field names are case-sensitive.
|
|
@@ -80,7 +183,7 @@ export interface EntityHandler {
|
|
|
80
183
|
* @param limit - Maximum number of results to return. Defaults to `50`.
|
|
81
184
|
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
82
185
|
* @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.
|
|
186
|
+
* @returns Promise resolving to an array of filtered records with selected fields.
|
|
84
187
|
*
|
|
85
188
|
* @example
|
|
86
189
|
* ```typescript
|
|
@@ -122,7 +225,7 @@ export interface EntityHandler {
|
|
|
122
225
|
* );
|
|
123
226
|
* ```
|
|
124
227
|
*/
|
|
125
|
-
filter(query:
|
|
228
|
+
filter<K extends keyof T = keyof T>(query: Partial<T>, sort?: SortField<T>, limit?: number, skip?: number, fields?: K[]): Promise<Pick<T, K>[]>;
|
|
126
229
|
/**
|
|
127
230
|
* Gets a single record by ID.
|
|
128
231
|
*
|
|
@@ -138,7 +241,7 @@ export interface EntityHandler {
|
|
|
138
241
|
* console.log(record.name);
|
|
139
242
|
* ```
|
|
140
243
|
*/
|
|
141
|
-
get(id: string): Promise<
|
|
244
|
+
get(id: string): Promise<T>;
|
|
142
245
|
/**
|
|
143
246
|
* Creates a new record.
|
|
144
247
|
*
|
|
@@ -158,7 +261,7 @@ export interface EntityHandler {
|
|
|
158
261
|
* console.log('Created record with ID:', newRecord.id);
|
|
159
262
|
* ```
|
|
160
263
|
*/
|
|
161
|
-
create(data:
|
|
264
|
+
create(data: Partial<T>): Promise<T>;
|
|
162
265
|
/**
|
|
163
266
|
* Updates an existing record.
|
|
164
267
|
*
|
|
@@ -187,7 +290,7 @@ export interface EntityHandler {
|
|
|
187
290
|
* });
|
|
188
291
|
* ```
|
|
189
292
|
*/
|
|
190
|
-
update(id: string, data:
|
|
293
|
+
update(id: string, data: Partial<T>): Promise<T>;
|
|
191
294
|
/**
|
|
192
295
|
* Deletes a single record by ID.
|
|
193
296
|
*
|
|
@@ -200,10 +303,10 @@ export interface EntityHandler {
|
|
|
200
303
|
* ```typescript
|
|
201
304
|
* // Delete a record
|
|
202
305
|
* const result = await base44.entities.MyEntity.delete('entity-123');
|
|
203
|
-
* console.log('Deleted:', result);
|
|
306
|
+
* console.log('Deleted:', result.success);
|
|
204
307
|
* ```
|
|
205
308
|
*/
|
|
206
|
-
delete(id: string): Promise<
|
|
309
|
+
delete(id: string): Promise<DeleteResult>;
|
|
207
310
|
/**
|
|
208
311
|
* Deletes multiple records matching a query.
|
|
209
312
|
*
|
|
@@ -221,10 +324,10 @@ export interface EntityHandler {
|
|
|
221
324
|
* status: 'completed',
|
|
222
325
|
* priority: 'low'
|
|
223
326
|
* });
|
|
224
|
-
* console.log('Deleted:', result);
|
|
327
|
+
* console.log('Deleted:', result.deleted);
|
|
225
328
|
* ```
|
|
226
329
|
*/
|
|
227
|
-
deleteMany(query:
|
|
330
|
+
deleteMany(query: Partial<T>): Promise<DeleteManyResult>;
|
|
228
331
|
/**
|
|
229
332
|
* Creates multiple records in a single request.
|
|
230
333
|
*
|
|
@@ -244,7 +347,7 @@ export interface EntityHandler {
|
|
|
244
347
|
* ]);
|
|
245
348
|
* ```
|
|
246
349
|
*/
|
|
247
|
-
bulkCreate(data:
|
|
350
|
+
bulkCreate(data: Partial<T>[]): Promise<T[]>;
|
|
248
351
|
/**
|
|
249
352
|
* Imports records from a file.
|
|
250
353
|
*
|
|
@@ -252,7 +355,7 @@ export interface EntityHandler {
|
|
|
252
355
|
* The file format should match your entity structure. Requires a browser environment and can't be used in the backend.
|
|
253
356
|
*
|
|
254
357
|
* @param file - File object to import.
|
|
255
|
-
* @returns Promise resolving to the import result.
|
|
358
|
+
* @returns Promise resolving to the import result containing status, details, and created records.
|
|
256
359
|
*
|
|
257
360
|
* @example
|
|
258
361
|
* ```typescript
|
|
@@ -261,19 +364,27 @@ export interface EntityHandler {
|
|
|
261
364
|
* const file = event.target.files?.[0];
|
|
262
365
|
* if (file) {
|
|
263
366
|
* const result = await base44.entities.MyEntity.importEntities(file);
|
|
264
|
-
*
|
|
367
|
+
* if (result.status === 'success' && result.output) {
|
|
368
|
+
* console.log(`Imported ${result.output.length} records`);
|
|
369
|
+
* }
|
|
265
370
|
* }
|
|
266
371
|
* };
|
|
267
372
|
* ```
|
|
268
373
|
*/
|
|
269
|
-
importEntities(file: File): Promise<
|
|
374
|
+
importEntities(file: File): Promise<ImportResult<T>>;
|
|
270
375
|
/**
|
|
271
376
|
* Subscribes to realtime updates for all records of this entity type.
|
|
272
377
|
*
|
|
273
|
-
*
|
|
378
|
+
* Establishes a WebSocket connection to receive instant updates when any
|
|
379
|
+
* record is created, updated, or deleted. Returns an unsubscribe function
|
|
380
|
+
* to clean up the connection.
|
|
274
381
|
*
|
|
275
|
-
* @param callback -
|
|
276
|
-
*
|
|
382
|
+
* @param callback - Callback function called when an entity changes. The callback receives an event object with the following properties:
|
|
383
|
+
* - `type`: The type of change that occurred - `'create'`, `'update'`, or `'delete'`.
|
|
384
|
+
* - `data`: The entity data after the change.
|
|
385
|
+
* - `id`: The unique identifier of the affected entity.
|
|
386
|
+
* - `timestamp`: ISO 8601 timestamp of when the event occurred.
|
|
387
|
+
* @returns Unsubscribe function to stop receiving updates.
|
|
277
388
|
*
|
|
278
389
|
* @example
|
|
279
390
|
* ```typescript
|
|
@@ -282,12 +393,24 @@ export interface EntityHandler {
|
|
|
282
393
|
* console.log(`Task ${event.id} was ${event.type}d:`, event.data);
|
|
283
394
|
* });
|
|
284
395
|
*
|
|
285
|
-
* // Later,
|
|
396
|
+
* // Later, clean up the subscription
|
|
286
397
|
* unsubscribe();
|
|
287
398
|
* ```
|
|
288
399
|
*/
|
|
289
|
-
subscribe(callback: RealtimeCallback):
|
|
400
|
+
subscribe(callback: RealtimeCallback<T>): () => void;
|
|
290
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Typed entities module - maps registry keys to typed handlers (full record type).
|
|
404
|
+
*/
|
|
405
|
+
type TypedEntitiesModule = {
|
|
406
|
+
[K in keyof EntityTypeRegistry]: EntityHandler<EntityRecord[K]>;
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* Dynamic entities module - allows any entity name with untyped handler.
|
|
410
|
+
*/
|
|
411
|
+
type DynamicEntitiesModule = {
|
|
412
|
+
[entityName: string]: EntityHandler<any>;
|
|
413
|
+
};
|
|
291
414
|
/**
|
|
292
415
|
* Entities module for managing app data.
|
|
293
416
|
*
|
|
@@ -297,17 +420,29 @@ export interface EntityHandler {
|
|
|
297
420
|
* Entities are accessed dynamically using the pattern:
|
|
298
421
|
* `base44.entities.EntityName.method()`
|
|
299
422
|
*
|
|
300
|
-
* This module is available to use with a client in all
|
|
423
|
+
* This module is available to use with a client in all authentication modes:
|
|
301
424
|
*
|
|
302
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.
|
|
303
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.
|
|
304
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
|
+
*
|
|
305
436
|
* ## Built-in User Entity
|
|
306
437
|
*
|
|
307
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.
|
|
308
439
|
*
|
|
309
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.
|
|
310
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
|
+
*
|
|
311
446
|
* @example
|
|
312
447
|
* ```typescript
|
|
313
448
|
* // Get all records from the MyEntity entity
|
|
@@ -321,18 +456,5 @@ export interface EntityHandler {
|
|
|
321
456
|
* const allUsers = await base44.asServiceRole.entities.User.list();
|
|
322
457
|
* ```
|
|
323
458
|
*/
|
|
324
|
-
export
|
|
325
|
-
|
|
326
|
-
* Access any entity by name.
|
|
327
|
-
*
|
|
328
|
-
* Use this to access entities defined in the app.
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ```typescript
|
|
332
|
-
* // Access entities dynamically
|
|
333
|
-
* base44.entities.MyEntity
|
|
334
|
-
* base44.entities.AnotherEntity
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
[entityName: string]: EntityHandler;
|
|
338
|
-
}
|
|
459
|
+
export type EntitiesModule = TypedEntitiesModule & DynamicEntitiesModule;
|
|
460
|
+
export {};
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
3
|
+
*/
|
|
4
|
+
export interface FunctionNameRegistry {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
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
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type FunctionName = keyof FunctionNameRegistry extends never ? string : keyof FunctionNameRegistry;
|
|
1
17
|
/**
|
|
2
18
|
* Functions module for invoking custom backend functions.
|
|
3
19
|
*
|
|
4
20
|
* This module allows you to invoke the custom backend functions defined in the app.
|
|
5
21
|
*
|
|
22
|
+
* ## Authentication Modes
|
|
23
|
+
*
|
|
6
24
|
* This module is available to use with a client in all authentication modes:
|
|
7
25
|
*
|
|
8
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.
|
|
9
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.
|
|
10
32
|
*/
|
|
11
33
|
export interface FunctionsModule {
|
|
12
34
|
/**
|
|
@@ -26,7 +48,6 @@ export interface FunctionsModule {
|
|
|
26
48
|
* // Basic function call
|
|
27
49
|
* const result = await base44.functions.invoke('calculateTotal', {
|
|
28
50
|
* items: ['item1', 'item2'],
|
|
29
|
-
* discount: 0.1
|
|
30
51
|
* });
|
|
31
52
|
* console.log(result.data.total);
|
|
32
53
|
* ```
|
|
@@ -46,5 +67,5 @@ export interface FunctionsModule {
|
|
|
46
67
|
* };
|
|
47
68
|
* ```
|
|
48
69
|
*/
|
|
49
|
-
invoke(functionName:
|
|
70
|
+
invoke(functionName: FunctionName, data?: Record<string, any>): Promise<any>;
|
|
50
71
|
}
|
|
@@ -12,18 +12,25 @@ export type IntegrationEndpointFunction = (data: Record<string, any>) => Promise
|
|
|
12
12
|
/**
|
|
13
13
|
* A package containing integration endpoints.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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;
|
|
@@ -320,43 +327,55 @@ export interface CoreIntegrations {
|
|
|
320
327
|
CreateFileSignedUrl(params: CreateFileSignedUrlParams): Promise<CreateFileSignedUrlResult>;
|
|
321
328
|
}
|
|
322
329
|
/**
|
|
323
|
-
* Integrations module for calling integration
|
|
330
|
+
* Integrations module for calling integration methods.
|
|
331
|
+
*
|
|
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.
|
|
333
|
+
*
|
|
334
|
+
* ## Integration Types
|
|
335
|
+
*
|
|
336
|
+
* There are two types of integrations:
|
|
324
337
|
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
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:
|
|
339
|
+
* ```
|
|
340
|
+
* base44.integrations.Core.FunctionName(params)
|
|
341
|
+
* ```
|
|
328
342
|
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
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:
|
|
344
|
+
* ```
|
|
345
|
+
* base44.integrations.custom.call(slug, operationId, params)
|
|
346
|
+
* ```
|
|
331
347
|
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
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
|
|
334
351
|
*
|
|
335
352
|
* This module is available to use with a client in all authentication modes:
|
|
336
353
|
*
|
|
337
|
-
* - **Anonymous or User authentication** (`base44.integrations`): Integration
|
|
338
|
-
* - **Service role authentication** (`base44.asServiceRole.integrations`): Integration
|
|
354
|
+
* - **Anonymous or User authentication** (`base44.integrations`): Integration methods are invoked with the current user's permissions. Anonymous users invoke methods without authentication, while authenticated users invoke methods with their authentication context.
|
|
355
|
+
* - **Service role authentication** (`base44.asServiceRole.integrations`): Integration methods are invoked with elevated admin-level permissions. The methods execute with admin authentication context.
|
|
339
356
|
*/
|
|
340
357
|
export type IntegrationsModule = {
|
|
341
358
|
/**
|
|
342
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
|
+
* ```
|
|
343
368
|
*/
|
|
344
369
|
Core: CoreIntegrations;
|
|
345
370
|
/**
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* Allows calling external APIs that workspace admins have configured
|
|
349
|
-
* by importing OpenAPI specifications.
|
|
371
|
+
* Workspace integrations module for calling pre-configured external APIs.
|
|
350
372
|
*
|
|
351
373
|
* @example
|
|
352
374
|
* ```typescript
|
|
353
|
-
* const
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* {
|
|
357
|
-
* pathParams: { owner: "myorg", repo: "myrepo" },
|
|
358
|
-
* queryParams: { state: "open" }
|
|
359
|
-
* }
|
|
375
|
+
* const result = await base44.integrations.custom.call(
|
|
376
|
+
* 'github',
|
|
377
|
+
* 'get:/repos/{owner}/{repo}',
|
|
378
|
+
* { pathParams: { owner: 'myorg', repo: 'myrepo' } }
|
|
360
379
|
* );
|
|
361
380
|
* ```
|
|
362
381
|
*/
|
|
@@ -365,8 +384,25 @@ export type IntegrationsModule = {
|
|
|
365
384
|
/**
|
|
366
385
|
* Access to additional integration packages.
|
|
367
386
|
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
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
|
+
* ```
|
|
370
406
|
*/
|
|
371
407
|
[packageName: string]: IntegrationPackage;
|
|
372
408
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44/sdk",
|
|
3
|
-
"version": "0.8.
|
|
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",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"docs": "typedoc",
|
|
20
20
|
"prepublishOnly": "npm run build",
|
|
21
21
|
"create-docs": "npm run create-docs:generate && npm run create-docs:process",
|
|
22
|
-
"
|
|
22
|
+
"create-docs-local": "npm run create-docs && npm run copy-docs-local",
|
|
23
|
+
"copy-docs-local": "node scripts/mintlify-post-processing/copy-to-local-docs.js",
|
|
23
24
|
"create-docs:generate": "typedoc",
|
|
24
25
|
"create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
|
|
25
26
|
},
|