@base44-preview/sdk 0.8.20-pr.141.620d2a2 → 0.8.20-pr.141.94d96d2

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 CHANGED
@@ -49,6 +49,7 @@ import { createAnalyticsModule } from "./modules/analytics.js";
49
49
  * ```
50
50
  */
51
51
  export function createClient(config) {
52
+ var _a, _b;
52
53
  const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, appBaseUrl, options, functionsVersion, headers: optionalHeaders, } = config;
53
54
  // Normalize appBaseUrl to always be a string (empty if not provided or invalid)
54
55
  const normalizedAppBaseUrl = typeof appBaseUrl === "string" ? appBaseUrl : "";
@@ -115,7 +116,18 @@ export function createClient(config) {
115
116
  }),
116
117
  integrations: createIntegrationsModule(axiosClient, appId),
117
118
  auth: userAuthModule,
118
- functions: createFunctionsModule(functionsAxiosClient, appId),
119
+ functions: createFunctionsModule(functionsAxiosClient, appId, {
120
+ getAuthHeaders: () => {
121
+ const headers = {};
122
+ // Get current token from storage or initial config
123
+ const currentToken = token || getAccessToken();
124
+ if (currentToken) {
125
+ headers["Authorization"] = `Bearer ${currentToken}`;
126
+ }
127
+ return headers;
128
+ },
129
+ baseURL: (_a = functionsAxiosClient.defaults) === null || _a === void 0 ? void 0 : _a.baseURL,
130
+ }),
119
131
  agents: createAgentsModule({
120
132
  axios: axiosClient,
121
133
  getSocket,
@@ -147,7 +159,17 @@ export function createClient(config) {
147
159
  integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
148
160
  sso: createSsoModule(serviceRoleAxiosClient, appId, token),
149
161
  connectors: createConnectorsModule(serviceRoleAxiosClient, appId),
150
- functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
162
+ functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId, {
163
+ getAuthHeaders: () => {
164
+ const headers = {};
165
+ // Use service token for authorization
166
+ if (serviceToken) {
167
+ headers["Authorization"] = `Bearer ${serviceToken}`;
168
+ }
169
+ return headers;
170
+ },
171
+ baseURL: (_b = serviceRoleFunctionsAxiosClient.defaults) === null || _b === void 0 ? void 0 : _b.baseURL,
172
+ }),
151
173
  agents: createAgentsModule({
152
174
  axios: serviceRoleAxiosClient,
153
175
  getSocket,
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";
@@ -48,30 +48,42 @@ export interface ConnectorConnectionResponse {
48
48
  *
49
49
  * | Service | Type identifier |
50
50
  * |---|---|
51
+ * | Airtable | `airtable` |
51
52
  * | Box | `box` |
52
53
  * | ClickUp | `clickup` |
53
54
  * | Discord | `discord` |
55
+ * | Dropbox | `dropbox` |
54
56
  * | GitHub | `github` |
55
57
  * | Gmail | `gmail` |
56
58
  * | Google Analytics | `google_analytics` |
57
59
  * | Google BigQuery | `googlebigquery` |
58
60
  * | Google Calendar | `googlecalendar` |
61
+ * | Google Classroom | `google_classroom` |
59
62
  * | Google Docs | `googledocs` |
60
63
  * | Google Drive | `googledrive` |
64
+ * | Google Search Console | `google_search_console` |
61
65
  * | Google Sheets | `googlesheets` |
62
66
  * | Google Slides | `googleslides` |
63
67
  * | HubSpot | `hubspot` |
68
+ * | Linear | `linear` |
64
69
  * | LinkedIn | `linkedin` |
70
+ * | Microsoft Teams | `microsoft_teams` |
71
+ * | Microsoft OneDrive | `one_drive` |
65
72
  * | Notion | `notion` |
73
+ * | Outlook | `outlook` |
66
74
  * | Salesforce | `salesforce` |
75
+ * | SharePoint | `share_point` |
67
76
  * | Slack User | `slack` |
68
77
  * | Slack Bot | `slackbot` |
78
+ * | Splitwise | `splitwise` |
69
79
  * | TikTok | `tiktok` |
80
+ * | Typeform | `typeform` |
81
+ * | Wix | `wix` |
70
82
  * | Wrike | `wrike` |
71
83
  *
72
84
  * See the integration guides for more details:
73
85
  *
74
- * - **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}
75
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`
76
88
  *
77
89
  * ## Authentication Modes
@@ -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
  *
@@ -1,11 +1,16 @@
1
1
  import { AxiosInstance } from "axios";
2
2
  import { FunctionsModule } from "./functions.types";
3
+ export interface FunctionsModuleConfig {
4
+ getAuthHeaders?: () => Record<string, string>;
5
+ baseURL?: string;
6
+ }
3
7
  /**
4
8
  * Creates the functions module for the Base44 SDK.
5
9
  *
6
10
  * @param axios - Axios instance
7
11
  * @param appId - Application ID
12
+ * @param config - Optional configuration for fetch functionality
8
13
  * @returns Functions module with methods to invoke custom backend functions
9
14
  * @internal
10
15
  */
11
- export declare function createFunctionsModule(axios: AxiosInstance, appId: string): FunctionsModule;
16
+ export declare function createFunctionsModule(axios: AxiosInstance, appId: string, config?: FunctionsModuleConfig): FunctionsModule;
@@ -3,29 +3,27 @@
3
3
  *
4
4
  * @param axios - Axios instance
5
5
  * @param appId - Application ID
6
+ * @param config - Optional configuration for fetch functionality
6
7
  * @returns Functions module with methods to invoke custom backend functions
7
8
  * @internal
8
9
  */
9
- export function createFunctionsModule(axios, appId) {
10
+ export function createFunctionsModule(axios, appId, config) {
10
11
  const joinBaseUrl = (base, path) => {
11
12
  if (!base)
12
13
  return path;
13
14
  return `${String(base).replace(/\/$/, "")}${path}`;
14
15
  };
15
16
  const toHeaders = (inputHeaders) => {
16
- var _a;
17
17
  const headers = new Headers();
18
- const appendHeaders = (source) => {
19
- if (!source)
20
- return;
21
- Object.entries(source).forEach(([key, value]) => {
18
+ // Get auth headers from the getter function if provided
19
+ if (config === null || config === void 0 ? void 0 : config.getAuthHeaders) {
20
+ const authHeaders = config.getAuthHeaders();
21
+ Object.entries(authHeaders).forEach(([key, value]) => {
22
22
  if (value !== undefined && value !== null) {
23
23
  headers.set(key, String(value));
24
24
  }
25
25
  });
26
- };
27
- // Append common headers from axios defaults
28
- appendHeaders((_a = axios.defaults.headers) === null || _a === void 0 ? void 0 : _a.common);
26
+ }
29
27
  if (inputHeaders) {
30
28
  new Headers(inputHeaders).forEach((value, key) => {
31
29
  headers.set(key, value);
@@ -65,7 +63,7 @@ export function createFunctionsModule(axios, appId) {
65
63
  }
66
64
  return axios.post(`/apps/${appId}/functions/${functionName}`, formData || data, { headers: { "Content-Type": contentType } });
67
65
  },
68
- // Fetch a backend function endpoint directly (supports streaming).
66
+ // Fetch a backend function endpoint directly.
69
67
  async fetch(path, init = {}) {
70
68
  const normalizedPath = path.startsWith("/") ? path : `/${path}`;
71
69
  const primaryPath = `/functions${normalizedPath}`;
@@ -74,7 +72,7 @@ export function createFunctionsModule(axios, appId) {
74
72
  ...init,
75
73
  headers,
76
74
  };
77
- const response = await fetch(joinBaseUrl(axios.defaults.baseURL, primaryPath), requestInit);
75
+ const response = await fetch(joinBaseUrl(config === null || config === void 0 ? void 0 : config.baseURL, primaryPath), requestInit);
78
76
  return response;
79
77
  },
80
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.20-pr.141.620d2a2",
3
+ "version": "0.8.20-pr.141.94d96d2",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",