@base44-preview/sdk 0.8.20-pr.130.5829030 → 0.8.20-pr.130.9ca04bf
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/client.js +0 -2
- package/dist/client.types.d.ts +0 -5
- package/dist/index.d.ts +1 -1
- package/dist/modules/connectors.js +5 -6
- package/dist/modules/connectors.types.d.ts +15 -9
- package/dist/modules/entities.js +8 -0
- package/dist/modules/entities.types.d.ts +92 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -108,7 +108,6 @@ export function createClient(config) {
|
|
|
108
108
|
serverUrl,
|
|
109
109
|
});
|
|
110
110
|
const userModules = {
|
|
111
|
-
axiosClient,
|
|
112
111
|
entities: createEntitiesModule({
|
|
113
112
|
axios: axiosClient,
|
|
114
113
|
appId,
|
|
@@ -141,7 +140,6 @@ export function createClient(config) {
|
|
|
141
140
|
},
|
|
142
141
|
};
|
|
143
142
|
const serviceRoleModules = {
|
|
144
|
-
axiosClient: serviceRoleAxiosClient,
|
|
145
143
|
entities: createEntitiesModule({
|
|
146
144
|
axios: serviceRoleAxiosClient,
|
|
147
145
|
appId,
|
package/dist/client.types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AxiosInstance } from "axios";
|
|
2
1
|
import type { EntitiesModule } from "./modules/entities.types.js";
|
|
3
2
|
import type { IntegrationsModule } from "./modules/integrations.types.js";
|
|
4
3
|
import type { AuthModule } from "./modules/auth.types.js";
|
|
@@ -88,8 +87,6 @@ export interface Base44Client {
|
|
|
88
87
|
appLogs: AppLogsModule;
|
|
89
88
|
/** {@link AuthModule | Auth module} for user authentication and management. */
|
|
90
89
|
auth: AuthModule;
|
|
91
|
-
/** The underlying Axios instance used for API requests. Useful for making custom API calls with the same authentication and configuration as the SDK. */
|
|
92
|
-
axiosClient: AxiosInstance;
|
|
93
90
|
/** {@link UserConnectorsModule | Connectors module} for app-user OAuth flows. */
|
|
94
91
|
connectors: UserConnectorsModule;
|
|
95
92
|
/** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */
|
|
@@ -127,8 +124,6 @@ export interface Base44Client {
|
|
|
127
124
|
readonly asServiceRole: {
|
|
128
125
|
/** {@link AgentsModule | Agents module} with elevated permissions. */
|
|
129
126
|
agents: AgentsModule;
|
|
130
|
-
/** The underlying Axios instance used for service role API requests. Useful for making custom API calls with service role authentication. */
|
|
131
|
-
axiosClient: AxiosInstance;
|
|
132
127
|
/** {@link AppLogsModule | App logs module} with elevated permissions. */
|
|
133
128
|
appLogs: AppLogsModule;
|
|
134
129
|
/** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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 { DeleteManyResult, DeleteResult, EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, } from "./modules/entities.types.js";
|
|
7
|
+
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, UpdateManyResult, } 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, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
|
|
10
10
|
export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
|
|
@@ -45,22 +45,21 @@ export function createConnectorsModule(axios, appId) {
|
|
|
45
45
|
*/
|
|
46
46
|
export function createUserConnectorsModule(axios, appId) {
|
|
47
47
|
return {
|
|
48
|
-
|
|
49
|
-
async getAppUserAccessToken(connectorId) {
|
|
48
|
+
async getCurrentAppUserAccessToken(connectorId) {
|
|
50
49
|
if (!connectorId || typeof connectorId !== "string") {
|
|
51
50
|
throw new Error("Connector ID is required and must be a string");
|
|
52
51
|
}
|
|
53
52
|
const response = await axios.get(`/apps/${appId}/app-user-auth/connectors/${connectorId}/token`);
|
|
54
|
-
|
|
55
|
-
return
|
|
53
|
+
const data = response;
|
|
54
|
+
return data.access_token;
|
|
56
55
|
},
|
|
57
56
|
async connectAppUser(connectorId) {
|
|
58
57
|
if (!connectorId || typeof connectorId !== "string") {
|
|
59
58
|
throw new Error("Connector ID is required and must be a string");
|
|
60
59
|
}
|
|
61
60
|
const response = await axios.post(`/apps/${appId}/app-user-auth/connectors/${connectorId}/initiate`);
|
|
62
|
-
|
|
63
|
-
return
|
|
61
|
+
const data = response;
|
|
62
|
+
return data.redirect_url;
|
|
64
63
|
},
|
|
65
64
|
async disconnectAppUser(connectorId) {
|
|
66
65
|
if (!connectorId || typeof connectorId !== "string") {
|
|
@@ -32,12 +32,6 @@ export interface ConnectorConnectionResponse {
|
|
|
32
32
|
/** Key-value configuration for the connection, or `null` if the connector does not provide one. */
|
|
33
33
|
connectionConfig: Record<string, string> | null;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Response from the connectors initiate endpoint.
|
|
37
|
-
*/
|
|
38
|
-
export interface ConnectorInitiateResponse {
|
|
39
|
-
redirect_url: string;
|
|
40
|
-
}
|
|
41
35
|
/**
|
|
42
36
|
* Connectors module for managing app-scoped OAuth tokens for external services.
|
|
43
37
|
*
|
|
@@ -54,30 +48,42 @@ export interface ConnectorInitiateResponse {
|
|
|
54
48
|
*
|
|
55
49
|
* | Service | Type identifier |
|
|
56
50
|
* |---|---|
|
|
51
|
+
* | Airtable | `airtable` |
|
|
57
52
|
* | Box | `box` |
|
|
58
53
|
* | ClickUp | `clickup` |
|
|
59
54
|
* | Discord | `discord` |
|
|
55
|
+
* | Dropbox | `dropbox` |
|
|
60
56
|
* | GitHub | `github` |
|
|
61
57
|
* | Gmail | `gmail` |
|
|
62
58
|
* | Google Analytics | `google_analytics` |
|
|
63
59
|
* | Google BigQuery | `googlebigquery` |
|
|
64
60
|
* | Google Calendar | `googlecalendar` |
|
|
61
|
+
* | Google Classroom | `google_classroom` |
|
|
65
62
|
* | Google Docs | `googledocs` |
|
|
66
63
|
* | Google Drive | `googledrive` |
|
|
64
|
+
* | Google Search Console | `google_search_console` |
|
|
67
65
|
* | Google Sheets | `googlesheets` |
|
|
68
66
|
* | Google Slides | `googleslides` |
|
|
69
67
|
* | HubSpot | `hubspot` |
|
|
68
|
+
* | Linear | `linear` |
|
|
70
69
|
* | LinkedIn | `linkedin` |
|
|
70
|
+
* | Microsoft Teams | `microsoft_teams` |
|
|
71
|
+
* | Microsoft OneDrive | `one_drive` |
|
|
71
72
|
* | Notion | `notion` |
|
|
73
|
+
* | Outlook | `outlook` |
|
|
72
74
|
* | Salesforce | `salesforce` |
|
|
75
|
+
* | SharePoint | `share_point` |
|
|
73
76
|
* | Slack User | `slack` |
|
|
74
77
|
* | Slack Bot | `slackbot` |
|
|
78
|
+
* | Splitwise | `splitwise` |
|
|
75
79
|
* | TikTok | `tiktok` |
|
|
80
|
+
* | Typeform | `typeform` |
|
|
81
|
+
* | Wix | `wix` |
|
|
76
82
|
* | Wrike | `wrike` |
|
|
77
83
|
*
|
|
78
84
|
* See the integration guides for more details:
|
|
79
85
|
*
|
|
80
|
-
* - **Scopes and permissions**: {@link https://docs.base44.com/Integrations/gmail-connector#gmail-scopes-and-permissions | Gmail}, {@link https://docs.base44.com/Integrations/linkedin-connector#linkedin-scopes-and-permissions | LinkedIn}, {@link https://docs.base44.com/Integrations/slack-connector#slack-scopes-and-permissions | Slack}
|
|
86
|
+
* - **Scopes and permissions**: {@link https://docs.base44.com/Integrations/gmail-connector#gmail-scopes-and-permissions | Gmail}, {@link https://docs.base44.com/Integrations/linkedin-connector#linkedin-scopes-and-permissions | LinkedIn}, {@link https://docs.base44.com/Integrations/slack-connector#slack-scopes-and-permissions | Slack}, {@link https://docs.base44.com/Integrations/github-connector#github-scopes-and-permissions | GitHub}
|
|
81
87
|
* - **Slack connector types**: {@link https://docs.base44.com/Integrations/slack-connector#about-the-slack-connectors | About the Slack connectors} explains the difference between `slack` and `slackbot`
|
|
82
88
|
*
|
|
83
89
|
* ## Authentication Modes
|
|
@@ -243,14 +249,14 @@ export interface UserConnectorsModule {
|
|
|
243
249
|
* @example
|
|
244
250
|
* ```typescript
|
|
245
251
|
* // Get the end user's access token for a connector
|
|
246
|
-
* const token = await base44.connectors.
|
|
252
|
+
* const token = await base44.connectors.getCurrentAppUserAccessToken('abc123def');
|
|
247
253
|
*
|
|
248
254
|
* const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', {
|
|
249
255
|
* headers: { 'Authorization': `Bearer ${token}` }
|
|
250
256
|
* });
|
|
251
257
|
* ```
|
|
252
258
|
*/
|
|
253
|
-
|
|
259
|
+
getCurrentAppUserAccessToken(connectorId: string): Promise<string>;
|
|
254
260
|
/**
|
|
255
261
|
* Initiates the app-user OAuth flow for a specific connector.
|
|
256
262
|
*
|
package/dist/modules/entities.js
CHANGED
|
@@ -106,6 +106,14 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
|
|
|
106
106
|
async bulkCreate(data) {
|
|
107
107
|
return axios.post(`${baseURL}/bulk`, data);
|
|
108
108
|
},
|
|
109
|
+
// Update multiple entities matching a query using a MongoDB update operator
|
|
110
|
+
async updateMany(query, data) {
|
|
111
|
+
return axios.patch(`${baseURL}/update-many`, { query, data });
|
|
112
|
+
},
|
|
113
|
+
// Update multiple entities by ID, each with its own update data
|
|
114
|
+
async bulkUpdate(data) {
|
|
115
|
+
return axios.put(`${baseURL}/bulk`, data);
|
|
116
|
+
},
|
|
109
117
|
// Import entities from a file
|
|
110
118
|
async importEntities(file) {
|
|
111
119
|
const formData = new FormData();
|
|
@@ -39,6 +39,17 @@ export interface DeleteManyResult {
|
|
|
39
39
|
/** Number of entities that were deleted. */
|
|
40
40
|
deleted: number;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Result returned when updating multiple entities via a query.
|
|
44
|
+
*/
|
|
45
|
+
export interface UpdateManyResult {
|
|
46
|
+
/** Whether the operation was successful. */
|
|
47
|
+
success: boolean;
|
|
48
|
+
/** Number of entities that were updated. */
|
|
49
|
+
updated: number;
|
|
50
|
+
/** Whether there are more entities matching the query that were not updated in this batch. When `true`, call `updateMany` again with the same query to update the next batch. */
|
|
51
|
+
has_more: boolean;
|
|
52
|
+
}
|
|
42
53
|
/**
|
|
43
54
|
* Result returned when importing entities from a file.
|
|
44
55
|
*
|
|
@@ -348,6 +359,87 @@ export interface EntityHandler<T = any> {
|
|
|
348
359
|
* ```
|
|
349
360
|
*/
|
|
350
361
|
bulkCreate(data: Partial<T>[]): Promise<T[]>;
|
|
362
|
+
/**
|
|
363
|
+
* Updates multiple records matching a query using a MongoDB update operator.
|
|
364
|
+
*
|
|
365
|
+
* Applies the same update operation to all records matching the query.
|
|
366
|
+
* The `data` parameter must contain one or more MongoDB update operators
|
|
367
|
+
* (e.g., `$set`, `$inc`, `$push`). Multiple operators can be combined in a
|
|
368
|
+
* single call, but each field may only appear in one operator.
|
|
369
|
+
*
|
|
370
|
+
* Results are batched in groups of up to 500 — when `has_more` is `true`
|
|
371
|
+
* in the response, call `updateMany` again with the same query to update
|
|
372
|
+
* the next batch.
|
|
373
|
+
*
|
|
374
|
+
* @param query - Query object to filter which records to update. Records matching all
|
|
375
|
+
* specified criteria will be updated.
|
|
376
|
+
* @param data - Update operation object containing one or more MongoDB update operators.
|
|
377
|
+
* Each field may only appear in one operator per call.
|
|
378
|
+
* Supported operators: `$set`, `$rename`, `$unset`, `$inc`, `$mul`, `$min`, `$max`,
|
|
379
|
+
* `$currentDate`, `$addToSet`, `$push`, `$pull`.
|
|
380
|
+
* @returns Promise resolving to the update result.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* // Set status to 'archived' for all completed records
|
|
385
|
+
* const result = await base44.entities.MyEntity.updateMany(
|
|
386
|
+
* { status: 'completed' },
|
|
387
|
+
* { $set: { status: 'archived' } }
|
|
388
|
+
* );
|
|
389
|
+
* console.log(`Updated ${result.updated} records`);
|
|
390
|
+
* ```
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```typescript
|
|
394
|
+
* // Combine multiple operators in a single call
|
|
395
|
+
* const result = await base44.entities.MyEntity.updateMany(
|
|
396
|
+
* { category: 'sales' },
|
|
397
|
+
* { $set: { status: 'done' }, $inc: { view_count: 1 } }
|
|
398
|
+
* );
|
|
399
|
+
* ```
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```typescript
|
|
403
|
+
* // Handle batched updates for large datasets
|
|
404
|
+
* let hasMore = true;
|
|
405
|
+
* let totalUpdated = 0;
|
|
406
|
+
* while (hasMore) {
|
|
407
|
+
* const result = await base44.entities.MyEntity.updateMany(
|
|
408
|
+
* { status: 'pending' },
|
|
409
|
+
* { $set: { status: 'processed' } }
|
|
410
|
+
* );
|
|
411
|
+
* totalUpdated += result.updated;
|
|
412
|
+
* hasMore = result.has_more;
|
|
413
|
+
* }
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
updateMany(query: Partial<T>, data: Record<string, Record<string, any>>): Promise<UpdateManyResult>;
|
|
417
|
+
/**
|
|
418
|
+
* Updates multiple records in a single request, each with its own update data.
|
|
419
|
+
*
|
|
420
|
+
* Unlike `updateMany` which applies the same update to all matching records,
|
|
421
|
+
* `bulkUpdate` allows different updates for each record. Each item in the
|
|
422
|
+
* array must include an `id` field identifying which record to update.
|
|
423
|
+
*
|
|
424
|
+
* **Note:** Maximum 500 items per request.
|
|
425
|
+
*
|
|
426
|
+
* @param data - Array of update objects (max 500). Each object must have an `id` field
|
|
427
|
+
* and any number of fields to update.
|
|
428
|
+
* @returns Promise resolving to an array of updated records.
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```typescript
|
|
432
|
+
* // Update multiple records with different data
|
|
433
|
+
* const updated = await base44.entities.MyEntity.bulkUpdate([
|
|
434
|
+
* { id: 'entity-1', status: 'paid', amount: 999 },
|
|
435
|
+
* { id: 'entity-2', status: 'cancelled' },
|
|
436
|
+
* { id: 'entity-3', name: 'Renamed Item' }
|
|
437
|
+
* ]);
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
bulkUpdate(data: (Partial<T> & {
|
|
441
|
+
id: string;
|
|
442
|
+
})[]): Promise<T[]>;
|
|
351
443
|
/**
|
|
352
444
|
* Imports records from a file.
|
|
353
445
|
*
|