@base44-preview/sdk 0.8.5-pr.52.f01053f → 0.8.6-pr.48.9e4e306

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.
Files changed (52) hide show
  1. package/dist/client.d.ts +90 -237
  2. package/dist/client.js +141 -25
  3. package/dist/client.types.d.ts +131 -0
  4. package/dist/client.types.js +1 -0
  5. package/dist/index.d.ts +13 -5
  6. package/dist/index.js +2 -3
  7. package/dist/modules/agents.d.ts +2 -23
  8. package/dist/modules/agents.js +3 -1
  9. package/dist/modules/agents.types.d.ts +330 -34
  10. package/dist/modules/app-logs.d.ts +8 -24
  11. package/dist/modules/app-logs.js +9 -19
  12. package/dist/modules/app-logs.types.d.ts +44 -0
  13. package/dist/modules/app-logs.types.js +1 -0
  14. package/dist/modules/app.types.d.ts +27 -0
  15. package/dist/modules/auth.d.ts +10 -78
  16. package/dist/modules/auth.js +24 -42
  17. package/dist/modules/auth.types.d.ts +436 -0
  18. package/dist/modules/auth.types.js +1 -0
  19. package/dist/modules/connectors.d.ts +6 -11
  20. package/dist/modules/connectors.js +6 -7
  21. package/dist/modules/connectors.types.d.ts +68 -2
  22. package/dist/modules/entities.d.ts +8 -5
  23. package/dist/modules/entities.js +22 -62
  24. package/dist/modules/entities.types.d.ts +293 -0
  25. package/dist/modules/entities.types.js +1 -0
  26. package/dist/modules/functions.d.ts +8 -7
  27. package/dist/modules/functions.js +7 -5
  28. package/dist/modules/functions.types.d.ts +50 -0
  29. package/dist/modules/functions.types.js +1 -0
  30. package/dist/modules/integrations.d.ts +8 -5
  31. package/dist/modules/integrations.js +7 -5
  32. package/dist/modules/integrations.types.d.ts +352 -0
  33. package/dist/modules/integrations.types.js +1 -0
  34. package/dist/modules/sso.d.ts +9 -14
  35. package/dist/modules/sso.js +9 -12
  36. package/dist/modules/sso.types.d.ts +44 -0
  37. package/dist/modules/sso.types.js +1 -0
  38. package/dist/types.d.ts +65 -2
  39. package/dist/utils/auth-utils.d.ts +107 -45
  40. package/dist/utils/auth-utils.js +107 -33
  41. package/dist/utils/auth-utils.types.d.ts +146 -0
  42. package/dist/utils/auth-utils.types.js +1 -0
  43. package/dist/utils/axios-client.d.ts +84 -16
  44. package/dist/utils/axios-client.js +74 -13
  45. package/dist/utils/axios-client.types.d.ts +28 -0
  46. package/dist/utils/axios-client.types.js +1 -0
  47. package/dist/utils/common.d.ts +0 -1
  48. package/dist/utils/common.js +1 -2
  49. package/dist/utils/socket-utils.d.ts +2 -2
  50. package/package.json +12 -3
  51. package/dist/utils/app-params.d.ts +0 -13
  52. package/dist/utils/app-params.js +0 -44
@@ -0,0 +1,352 @@
1
+ /**
2
+ * Function signature for calling an integration endpoint.
3
+ *
4
+ * If any parameter is a `File` object, the request will automatically be
5
+ * sent as `multipart/form-data`. Otherwise, it will be sent as JSON.
6
+ *
7
+ * @param data - An object containing named parameters for the integration endpoint.
8
+ * @returns Promise resolving to the integration endpoint's response.
9
+ */
10
+ export type IntegrationEndpointFunction = (data: Record<string, any>) => Promise<any>;
11
+ /**
12
+ * A package containing integration endpoints.
13
+ *
14
+ * Provides dynamic access to integration endpoints within a package.
15
+ * Each endpoint is accessed as a property that returns a function to invoke it.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Access endpoints dynamically
20
+ * const result = await integrations.Core.SendEmail({
21
+ * to: 'user@example.com',
22
+ * subject: 'Hello',
23
+ * body: 'Message'
24
+ * });
25
+ * ```
26
+ */
27
+ export type IntegrationPackage = {
28
+ [endpointName: string]: IntegrationEndpointFunction;
29
+ };
30
+ /**
31
+ * Parameters for the InvokeLLM function.
32
+ */
33
+ export interface InvokeLLMParams {
34
+ /** The prompt text to send to the model */
35
+ prompt: string;
36
+ /** If set to `true`, the LLM will use Google Search, Maps, and News to gather real-time context before answering.
37
+ * @default false
38
+ */
39
+ add_context_from_internet?: boolean;
40
+ /** If you want structured data back, provide a [JSON schema object](https://json-schema.org/understanding-json-schema/reference/object) here. If provided, the function returns a JSON object; otherwise, it returns a string. */
41
+ response_json_schema?: object;
42
+ /** A list of file URLs (uploaded via UploadFile) to provide as context/attachments to the LLM. Do not use this together with `add_context_from_internet`. */
43
+ file_urls?: string[];
44
+ }
45
+ /**
46
+ * Parameters for the GenerateImage function.
47
+ */
48
+ export interface GenerateImageParams {
49
+ /** Description of the image to generate. */
50
+ prompt: string;
51
+ }
52
+ export interface GenerateImageResult {
53
+ /** URL of the generated image. */
54
+ url: string;
55
+ }
56
+ /**
57
+ * Parameters for the UploadFile function.
58
+ */
59
+ export interface UploadFileParams {
60
+ /** The file object to upload. */
61
+ file: File;
62
+ }
63
+ export interface UploadFileResult {
64
+ /** URL of the uploaded file. */
65
+ file_url: string;
66
+ }
67
+ /**
68
+ * Parameters for the SendEmail function.
69
+ */
70
+ export interface SendEmailParams {
71
+ /** Recipient email address. */
72
+ to: string;
73
+ /** Email subject line. */
74
+ subject: string;
75
+ /** Plain text email body content. */
76
+ body: string;
77
+ /** The name of the sender. If omitted, the app's name will be used. */
78
+ from_name?: string;
79
+ }
80
+ export type SendEmailResult = any;
81
+ /**
82
+ * Parameters for the ExtractDataFromUploadedFile function.
83
+ */
84
+ export interface ExtractDataFromUploadedFileParams {
85
+ /** The URL of the uploaded file to extract data from. */
86
+ file_url: string;
87
+ /** A [JSON schema object](https://json-schema.org/understanding-json-schema/reference/object) defining what data fields you want to extract. */
88
+ json_schema: object;
89
+ }
90
+ export type ExtractDataFromUploadedFileResult = object;
91
+ /**
92
+ * Parameters for the UploadPrivateFile function.
93
+ */
94
+ export interface UploadPrivateFileParams {
95
+ /** The file object to upload. */
96
+ file: File;
97
+ }
98
+ export interface UploadPrivateFileResult {
99
+ /** URI of the uploaded private file, used to create a signed URL. */
100
+ file_uri: string;
101
+ }
102
+ /**
103
+ * Parameters for the CreateFileSignedUrl function.
104
+ */
105
+ export interface CreateFileSignedUrlParams {
106
+ /** URI of the uploaded private file. */
107
+ file_uri: string;
108
+ /** How long the signed URL should be valid for, in seconds.
109
+ * @default 300 (5 minutes)
110
+ */
111
+ expires_in?: number;
112
+ }
113
+ export interface CreateFileSignedUrlResult {
114
+ /** Temporary signed URL to access the private file. */
115
+ signed_url: string;
116
+ }
117
+ /**
118
+ * Core package containing built-in Base44 integration functions.
119
+ */
120
+ export interface CoreIntegrations {
121
+ /**
122
+ * Generate text or structured JSON data using AI models.
123
+ *
124
+ * @param params - Parameters for the LLM invocation
125
+ * @returns Promise resolving to a string (when no schema provided) or an object (when schema provided).
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * // Basic prompt
130
+ * const response = await base44.integrations.Core.InvokeLLM({
131
+ * prompt: "Write a haiku about coding."
132
+ * });
133
+ * ```
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * // Prompt with internet context
138
+ * const response = await base44.integrations.Core.InvokeLLM({
139
+ * prompt: "What is the current stock price of Wix and what was the latest major news about it?",
140
+ * add_context_from_internet: true
141
+ * });
142
+ * ```
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * // Structured JSON response
147
+ * const response = await base44.integrations.Core.InvokeLLM({
148
+ * prompt: "Analyze the sentiment of this review: 'The service was slow but the food was amazing.'",
149
+ * response_json_schema: {
150
+ * type: "object",
151
+ * properties: {
152
+ * sentiment: { type: "string", enum: ["positive", "negative", "mixed"] },
153
+ * score: { type: "number", description: "Score from 1-10" },
154
+ * key_points: { type: "array", items: { type: "string" } }
155
+ * }
156
+ * }
157
+ * });
158
+ * // Returns object: { sentiment: "mixed", score: 7, key_points: ["slow service", "amazing food"] }
159
+ * ```
160
+ */
161
+ InvokeLLM(params: InvokeLLMParams): Promise<string | object>;
162
+ /**
163
+ * Create AI-generated images from text prompts.
164
+ *
165
+ * @param params - Parameters for image generation
166
+ * @returns Promise resolving to the generated image URL.
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * // Generate an image from a text prompt
171
+ * const {url} = await base44.integrations.Core.GenerateImage({
172
+ * prompt: "A serene mountain landscape with a lake in the foreground"
173
+ * });
174
+ * console.log(url); // https://...generated_image.png
175
+ * ```
176
+ */
177
+ GenerateImage(params: GenerateImageParams): Promise<GenerateImageResult>;
178
+ /**
179
+ * Upload files to public storage and get a URL.
180
+ *
181
+ * @param params - Parameters for file upload
182
+ * @returns Promise resolving to an object containing the uploaded file URL.
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * // Upload a file in React
187
+ * const handleFileUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
188
+ * const file = event.target.files?.[0];
189
+ * if (!file) return;
190
+ *
191
+ * const { file_url } = await base44.integrations.Core.UploadFile({ file });
192
+ * console.log(file_url); // https://...uploaded_file.pdf
193
+ * };
194
+ * ```
195
+ */
196
+ UploadFile(params: UploadFileParams): Promise<UploadFileResult>;
197
+ /**
198
+ * Send emails to registered users of your app.
199
+ *
200
+ * @param params - Parameters for sending email
201
+ * @returns Promise resolving when the email is sent.
202
+ */
203
+ SendEmail(params: SendEmailParams): Promise<SendEmailResult>;
204
+ /**
205
+ * Extract structured data from uploaded files based on the specified schema.
206
+ *
207
+ * Start by uploading the file to public storage using the {@linkcode UploadFile | UploadFile()} function. Then, use the `file_url` parameter to extract structured data from the uploaded file.
208
+ *
209
+ * @param params - Parameters for data extraction
210
+ * @returns Promise resolving to the extracted data.
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * // Extract data from an already uploaded file
215
+ * const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
216
+ * file_url: "https://example.com/files/invoice.pdf",
217
+ * json_schema: {
218
+ * type: "object",
219
+ * properties: {
220
+ * invoice_number: { type: "string" },
221
+ * total_amount: { type: "number" },
222
+ * date: { type: "string" },
223
+ * vendor_name: { type: "string" }
224
+ * }
225
+ * }
226
+ * });
227
+ * console.log(result); // { invoice_number: "INV-12345", total_amount: 1250.00, ... }
228
+ * ```
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * // Upload a file and extract data in React
233
+ * const handleFileExtraction = async (event: React.ChangeEvent<HTMLInputElement>) => {
234
+ * const file = event.target.files?.[0];
235
+ * if (!file) return;
236
+ *
237
+ * // First, upload the file
238
+ * const { file_url } = await base44.integrations.Core.UploadFile({ file });
239
+ *
240
+ * // Then extract structured data from it
241
+ * const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
242
+ * file_url,
243
+ * json_schema: {
244
+ * type: "object",
245
+ * properties: {
246
+ * summary: {
247
+ * type: "string",
248
+ * description: "A brief summary of the file content"
249
+ * },
250
+ * keywords: {
251
+ * type: "array",
252
+ * items: { type: "string" }
253
+ * },
254
+ * document_type: {
255
+ * type: "string"
256
+ * }
257
+ * }
258
+ * }
259
+ * });
260
+ * console.log(result); // { summary: "...", keywords: [...], document_type: "..." }
261
+ * };
262
+ * ```
263
+ */
264
+ ExtractDataFromUploadedFile(params: ExtractDataFromUploadedFileParams): Promise<ExtractDataFromUploadedFileResult>;
265
+ /**
266
+ * Upload files to private storage that requires a signed URL to access.
267
+ *
268
+ * Create a signed URL to access uploaded files using the {@linkcode CreateFileSignedUrl | CreateFileSignedUrl()} function.
269
+ *
270
+ * @param params - Parameters for private file upload
271
+ * @returns Promise resolving to an object with a `file_uri` used to create a signed URL to access the uploaded file.
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * // Upload a private file
276
+ * const { file_uri } = await base44.integrations.Core.UploadPrivateFile({ file });
277
+ * console.log(file_uri); // "private/user123/document.pdf"
278
+ * ```
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * // Upload a private file and create a signed URL
283
+ * const handlePrivateUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
284
+ * const file = event.target.files?.[0];
285
+ * if (!file) return;
286
+ *
287
+ * // Upload to private storage
288
+ * const { file_uri } = await base44.integrations.Core.UploadPrivateFile({ file });
289
+ *
290
+ * // Create a signed URL that expires in 1 hour (3600 seconds)
291
+ * const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
292
+ * file_uri,
293
+ * expires_in: 3600
294
+ * });
295
+ *
296
+ * console.log(signed_url); // Temporary URL to access the private file
297
+ * };
298
+ * ```
299
+ */
300
+ UploadPrivateFile(params: UploadPrivateFileParams): Promise<UploadPrivateFileResult>;
301
+ /**
302
+ * Generate temporary access links for private files.
303
+ *
304
+ * Start by uploading the file to private storage using the {@linkcode UploadPrivateFile | UploadPrivateFile()} function. Then, use the `file_uri` parameter to create a signed URL to access the uploaded file.
305
+ *
306
+ * @param params - Parameters for creating signed URL
307
+ * @returns Promise resolving to an object with a temporary `signed_url`.
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * // Create a signed URL for a private file
312
+ * const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
313
+ * file_uri: "private/user123/document.pdf",
314
+ * expires_in: 7200 // URL expires in 2 hours
315
+ * });
316
+ * console.log(signed_url); // https://...?signature=...
317
+ * ```
318
+ */
319
+ CreateFileSignedUrl(params: CreateFileSignedUrlParams): Promise<CreateFileSignedUrlResult>;
320
+ }
321
+ /**
322
+ * Integrations module for calling integration endpoints.
323
+ *
324
+ * This module provides access to integration endpoints for interacting with external
325
+ * services. Integrations are organized into packages. Base44 provides built-in integrations
326
+ * in the `Core` package.
327
+ *
328
+ * Unlike the connectors module that gives you raw OAuth tokens, integrations provide
329
+ * pre-built functions that Base44 executes on your behalf.
330
+ *
331
+ * Integration endpoints are accessed dynamically using the pattern:
332
+ * `base44.integrations.PackageName.EndpointName(params)`
333
+ *
334
+ * This module is available to use with a client in all authentication modes:
335
+ *
336
+ * - **Anonymous or User authentication** (`base44.integrations`): Integration endpoints are invoked with the current user's permissions. Anonymous users invoke endpoints without authentication, while authenticated users invoke endpoints with their authentication context.
337
+ * - **Service role authentication** (`base44.asServiceRole.integrations`): Integration endpoints are invoked with elevated admin-level permissions. The endpoints execute with admin authentication context.
338
+ */
339
+ export type IntegrationsModule = {
340
+ /**
341
+ * Core package containing built-in Base44 integration functions.
342
+ */
343
+ Core: CoreIntegrations;
344
+ } & {
345
+ /**
346
+ * Access to additional integration packages.
347
+ *
348
+ * Additional integration packages may be added in the future and will be
349
+ * accessible using the same pattern as Core.
350
+ */
351
+ [packageName: string]: IntegrationPackage;
352
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,17 +1,12 @@
1
1
  import { AxiosInstance } from "axios";
2
+ import { SsoModule } from "./sso.types";
2
3
  /**
3
- * Creates the SSO module for the Base44 SDK
4
- * @param {import('axios').AxiosInstance} axios - Axios instance
5
- * @param {string} appId - Application ID
6
- * @param {string} [userToken] - User authentication token
7
- * @param {string} [serviceToken] - Service role authentication token
8
- * @returns {Object} SSO module with SSO authentication methods
4
+ * Creates the SSO module for the Base44 SDK.
5
+ *
6
+ * @param axios - Axios instance
7
+ * @param appId - Application ID
8
+ * @param userToken - User authentication token
9
+ * @returns SSO module with authentication methods
10
+ * @internal
9
11
  */
10
- export declare function createSsoModule(axios: AxiosInstance, appId: string, userToken?: string): {
11
- /**
12
- * Get current user sso access token
13
- * @param {string} userid - User ID to include as path parameter
14
- * @returns {Promise<Object>} Current user sso access_token
15
- */
16
- getAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
17
- };
12
+ export declare function createSsoModule(axios: AxiosInstance, appId: string, userToken?: string): SsoModule;
@@ -1,24 +1,21 @@
1
1
  /**
2
- * Creates the SSO module for the Base44 SDK
3
- * @param {import('axios').AxiosInstance} axios - Axios instance
4
- * @param {string} appId - Application ID
5
- * @param {string} [userToken] - User authentication token
6
- * @param {string} [serviceToken] - Service role authentication token
7
- * @returns {Object} SSO module with SSO authentication methods
2
+ * Creates the SSO module for the Base44 SDK.
3
+ *
4
+ * @param axios - Axios instance
5
+ * @param appId - Application ID
6
+ * @param userToken - User authentication token
7
+ * @returns SSO module with authentication methods
8
+ * @internal
8
9
  */
9
10
  export function createSsoModule(axios, appId, userToken) {
10
11
  return {
11
- /**
12
- * Get current user sso access token
13
- * @param {string} userid - User ID to include as path parameter
14
- * @returns {Promise<Object>} Current user sso access_token
15
- */
12
+ // Get SSO access token for a specific user
16
13
  async getAccessToken(userid) {
17
14
  const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
18
15
  // Prepare headers with both tokens if available
19
16
  const headers = {};
20
17
  if (userToken) {
21
- headers['on-behalf-of'] = `Bearer ${userToken}`;
18
+ headers["on-behalf-of"] = `Bearer ${userToken}`;
22
19
  }
23
20
  return axios.get(url, { headers });
24
21
  },
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Response from SSO access token endpoint.
3
+ * @internal
4
+ */
5
+ export interface SsoAccessTokenResponse {
6
+ access_token: string;
7
+ }
8
+ /**
9
+ * SSO (Single Sign-On) module for managing SSO authentication.
10
+ *
11
+ * This module provides methods for retrieving SSO access tokens for users.
12
+ * These tokens allow you to authenticate Base44 users with external
13
+ * systems or services.
14
+ *
15
+ * This module is only available to use with a client in service role authentication mode, which means it can only be used in backend environments.
16
+ *
17
+ * @internal
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Access SSO module with service role
22
+ * const response = await base44.asServiceRole.sso.getAccessToken('user_123');
23
+ * console.log(response.data.access_token);
24
+ * ```
25
+ */
26
+ export interface SsoModule {
27
+ /**
28
+ * Gets SSO access token for a specific user.
29
+ *
30
+ * Retrieves a Single Sign-On access token that can be used to authenticate
31
+ * a user with external services or systems.
32
+ *
33
+ * @param userid - The user ID to get the access token for.
34
+ * @returns Promise resolving to the SSO access token response.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Get SSO access token for a user
39
+ * const response = await base44.asServiceRole.sso.getAccessToken('user_123');
40
+ * console.log(response.access_token);
41
+ * ```
42
+ */
43
+ getAccessToken(userid: string): Promise<SsoAccessTokenResponse>;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -1,9 +1,72 @@
1
1
  export * from "./modules/types.js";
2
- export type ModelFilterParams = {
2
+ /**
3
+ * Parameters for filtering, sorting, and paginating agent model data.
4
+ *
5
+ * Used in the agents module for querying agent conversations. Provides a structured way to specify query criteria, sorting, pagination, and field selection.
6
+ *
7
+ * @property q - Query object with field-value pairs for filtering.
8
+ * @property sort - Sort parameter. For example, "-created_date" for descending order.
9
+ * @property sort_by - Alternative sort parameter. Use either `sort` or `sort_by`.
10
+ * @property limit - Maximum number of results to return.
11
+ * @property skip - Number of results to skip. Used for pagination.
12
+ * @property fields - Array of field names to include in the response.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Filter conversations by agent name
17
+ * const conversations = await base44.agents.listConversations({
18
+ * q: { agent_name: 'support-bot' }
19
+ * });
20
+ * ```
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Filter conversations with sorting
25
+ * const conversations = await base44.agents.listConversations({
26
+ * q: { status: 'active' },
27
+ * sort: '-created_at' // Sort by created_at descending
28
+ * });
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // Filter conversations with pagination
34
+ * const conversations = await base44.agents.listConversations({
35
+ * q: { agent_name: 'support-bot' },
36
+ * limit: 20, // Get 20 results
37
+ * skip: 40 // Skip first 40 (page 3)
38
+ * });
39
+ * ```
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Filter conversations with field selection
44
+ * const conversations = await base44.agents.listConversations({
45
+ * q: { status: 'active' },
46
+ * fields: ['id', 'agent_name', 'created_at']
47
+ * });
48
+ * ```
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // Filter conversations with multiple filters
53
+ * const conversations = await base44.agents.listConversations({
54
+ * q: {
55
+ * agent_name: 'support-bot',
56
+ * 'metadata.priority': 'high',
57
+ * status: 'active'
58
+ * },
59
+ * sort: '-updated_at',
60
+ * limit: 50,
61
+ * skip: 0
62
+ * });
63
+ * ```
64
+ */
65
+ export interface ModelFilterParams {
3
66
  q?: Record<string, any>;
4
67
  sort?: string | null;
5
68
  sort_by?: string | null;
6
69
  limit?: number | null;
7
70
  skip?: number | null;
8
71
  fields?: string[] | null;
9
- };
72
+ }