@depup/base44__sdk 0.8.22-depup.0
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/LICENSE +21 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist/client.d.ts +96 -0
- package/dist/client.js +375 -0
- package/dist/client.types.d.ts +144 -0
- package/dist/client.types.js +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +5 -0
- package/dist/modules/agents.d.ts +2 -0
- package/dist/modules/agents.js +77 -0
- package/dist/modules/agents.types.d.ts +377 -0
- package/dist/modules/agents.types.js +1 -0
- package/dist/modules/analytics.d.ts +20 -0
- package/dist/modules/analytics.js +277 -0
- package/dist/modules/analytics.types.d.ts +122 -0
- package/dist/modules/analytics.types.js +1 -0
- package/dist/modules/app-logs.d.ts +11 -0
- package/dist/modules/app-logs.js +27 -0
- package/dist/modules/app-logs.types.d.ts +46 -0
- package/dist/modules/app-logs.types.js +1 -0
- package/dist/modules/app.types.d.ts +142 -0
- package/dist/modules/app.types.js +1 -0
- package/dist/modules/auth.d.ts +13 -0
- package/dist/modules/auth.js +180 -0
- package/dist/modules/auth.types.d.ts +481 -0
- package/dist/modules/auth.types.js +1 -0
- package/dist/modules/connectors.d.ts +20 -0
- package/dist/modules/connectors.js +71 -0
- package/dist/modules/connectors.types.d.ts +296 -0
- package/dist/modules/connectors.types.js +1 -0
- package/dist/modules/custom-integrations.d.ts +11 -0
- package/dist/modules/custom-integrations.js +32 -0
- package/dist/modules/custom-integrations.types.d.ts +89 -0
- package/dist/modules/custom-integrations.types.js +1 -0
- package/dist/modules/entities.d.ts +20 -0
- package/dist/modules/entities.js +149 -0
- package/dist/modules/entities.types.d.ts +552 -0
- package/dist/modules/entities.types.js +1 -0
- package/dist/modules/functions.d.ts +12 -0
- package/dist/modules/functions.js +79 -0
- package/dist/modules/functions.types.d.ts +103 -0
- package/dist/modules/functions.types.js +1 -0
- package/dist/modules/integrations.d.ts +11 -0
- package/dist/modules/integrations.js +77 -0
- package/dist/modules/integrations.types.d.ts +413 -0
- package/dist/modules/integrations.types.js +1 -0
- package/dist/modules/sso.d.ts +12 -0
- package/dist/modules/sso.js +23 -0
- package/dist/modules/sso.types.d.ts +44 -0
- package/dist/modules/sso.types.js +1 -0
- package/dist/modules/types.d.ts +4 -0
- package/dist/modules/types.js +4 -0
- package/dist/modules/users.d.ts +16 -0
- package/dist/modules/users.js +23 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.js +1 -0
- package/dist/utils/auth-utils.d.ts +117 -0
- package/dist/utils/auth-utils.js +189 -0
- package/dist/utils/auth-utils.types.d.ts +146 -0
- package/dist/utils/auth-utils.types.js +1 -0
- package/dist/utils/axios-client.d.ts +100 -0
- package/dist/utils/axios-client.js +193 -0
- package/dist/utils/axios-client.types.d.ts +28 -0
- package/dist/utils/axios-client.types.js +1 -0
- package/dist/utils/common.d.ts +3 -0
- package/dist/utils/common.js +6 -0
- package/dist/utils/sharedInstance.d.ts +1 -0
- package/dist/utils/sharedInstance.js +15 -0
- package/dist/utils/socket-utils.d.ts +47 -0
- package/dist/utils/socket-utils.js +115 -0
- package/package.json +87 -0
|
@@ -0,0 +1,103 @@
|
|
|
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;
|
|
17
|
+
/**
|
|
18
|
+
* Options for {@linkcode FunctionsModule.fetch}.
|
|
19
|
+
*
|
|
20
|
+
* Uses native `fetch` options directly.
|
|
21
|
+
*/
|
|
22
|
+
export type FunctionsFetchInit = RequestInit;
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for the functions module.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export interface FunctionsModuleConfig {
|
|
28
|
+
getAuthHeaders?: () => Record<string, string>;
|
|
29
|
+
baseURL?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Functions module for invoking custom backend functions.
|
|
33
|
+
*
|
|
34
|
+
* This module allows you to invoke the custom backend functions defined in the app.
|
|
35
|
+
*
|
|
36
|
+
* ## Authentication Modes
|
|
37
|
+
*
|
|
38
|
+
* This module is available to use with a client in all authentication modes:
|
|
39
|
+
*
|
|
40
|
+
* - **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.
|
|
41
|
+
* - **Service role authentication** (`base44.asServiceRole.functions`): Functions are invoked with elevated admin-level permissions. The function code receives a request with admin authentication context.
|
|
42
|
+
*
|
|
43
|
+
* ## Generated Types
|
|
44
|
+
*
|
|
45
|
+
* 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.
|
|
46
|
+
*/
|
|
47
|
+
export interface FunctionsModule {
|
|
48
|
+
/**
|
|
49
|
+
* Invokes a custom backend function by name.
|
|
50
|
+
*
|
|
51
|
+
* Calls a custom backend function deployed to the app.
|
|
52
|
+
* The function receives the provided data as named parameters and returns
|
|
53
|
+
* the result. If any parameter is a `File` object, the request will automatically be
|
|
54
|
+
* sent as `multipart/form-data`. Otherwise, it will be sent as JSON.
|
|
55
|
+
*
|
|
56
|
+
* @param functionName - The name of the function to invoke.
|
|
57
|
+
* @param data - An object containing named parameters for the function.
|
|
58
|
+
* @returns Promise resolving to the function's response. The `data` property contains the data returned by the function, if there is any.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Basic function call
|
|
63
|
+
* const result = await base44.functions.invoke('calculateTotal', {
|
|
64
|
+
* items: ['item1', 'item2'],
|
|
65
|
+
* });
|
|
66
|
+
* console.log(result.data.total);
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // Function with file upload in React
|
|
72
|
+
* const handleFileUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
73
|
+
* const file = event.target.files?.[0];
|
|
74
|
+
* if (file) {
|
|
75
|
+
* const processedImage = await base44.functions.invoke('processImage', {
|
|
76
|
+
* image: file,
|
|
77
|
+
* filter: 'grayscale',
|
|
78
|
+
* quality: 80
|
|
79
|
+
* });
|
|
80
|
+
* }
|
|
81
|
+
* };
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
invoke(functionName: FunctionName, data?: Record<string, any>): Promise<any>;
|
|
85
|
+
/**
|
|
86
|
+
* Performs a direct HTTP request to a backend function path and returns the native `Response`.
|
|
87
|
+
*
|
|
88
|
+
* Use this method when you need low-level control over the request/response that the higher-level
|
|
89
|
+
* `invoke()` abstraction doesn't provide, such as:
|
|
90
|
+
* - Streaming responses (SSE, chunked text, NDJSON)
|
|
91
|
+
* - Custom HTTP methods (PUT, PATCH, DELETE, etc.)
|
|
92
|
+
* - Custom headers or request configuration
|
|
93
|
+
* - Access to raw response metadata (status, headers)
|
|
94
|
+
* - Direct control over request/response bodies
|
|
95
|
+
*
|
|
96
|
+
* Requests are sent to `/api/functions/<path>`.
|
|
97
|
+
*
|
|
98
|
+
* @param path - Function path, e.g. `/streaming_demo` or `/streaming_demo/deep/path`
|
|
99
|
+
* @param init - Native fetch options.
|
|
100
|
+
* @returns Promise resolving to a native fetch `Response`
|
|
101
|
+
*/
|
|
102
|
+
fetch(path: string, init?: FunctionsFetchInit): Promise<Response>;
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { IntegrationsModule } from "./integrations.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the integrations module for the Base44 SDK.
|
|
5
|
+
*
|
|
6
|
+
* @param axios - Axios instance
|
|
7
|
+
* @param appId - Application ID
|
|
8
|
+
* @returns Integrations module with dynamic access to integration endpoints
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function createIntegrationsModule(axios: AxiosInstance, appId: string): IntegrationsModule;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createCustomIntegrationsModule } from "./custom-integrations.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the integrations module for the Base44 SDK.
|
|
4
|
+
*
|
|
5
|
+
* @param axios - Axios instance
|
|
6
|
+
* @param appId - Application ID
|
|
7
|
+
* @returns Integrations module with dynamic access to integration endpoints
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export function createIntegrationsModule(axios, appId) {
|
|
11
|
+
// Create the custom integrations module once
|
|
12
|
+
const customModule = createCustomIntegrationsModule(axios, appId);
|
|
13
|
+
return new Proxy({}, {
|
|
14
|
+
get(target, packageName) {
|
|
15
|
+
// Skip internal properties
|
|
16
|
+
if (typeof packageName !== "string" ||
|
|
17
|
+
packageName === "then" ||
|
|
18
|
+
packageName.startsWith("_")) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
// Handle 'custom' specially - return the custom integrations module
|
|
22
|
+
if (packageName === "custom") {
|
|
23
|
+
return customModule;
|
|
24
|
+
}
|
|
25
|
+
// Create a proxy for integration endpoints
|
|
26
|
+
return new Proxy({}, {
|
|
27
|
+
get(target, endpointName) {
|
|
28
|
+
// Skip internal properties
|
|
29
|
+
if (typeof endpointName !== "string" ||
|
|
30
|
+
endpointName === "then" ||
|
|
31
|
+
endpointName.startsWith("_")) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
// Return a function that calls the integration endpoint
|
|
35
|
+
// This allows: client.integrations.PackageName.EndpointName(data)
|
|
36
|
+
return async (data) => {
|
|
37
|
+
// Validate input
|
|
38
|
+
if (typeof data === "string") {
|
|
39
|
+
throw new Error(`Integration ${endpointName} must receive an object with named parameters, received: ${data}`);
|
|
40
|
+
}
|
|
41
|
+
let formData;
|
|
42
|
+
let contentType;
|
|
43
|
+
// Handle file uploads with FormData
|
|
44
|
+
if (data instanceof FormData ||
|
|
45
|
+
(data &&
|
|
46
|
+
Object.values(data).some((value) => value instanceof File))) {
|
|
47
|
+
formData = new FormData();
|
|
48
|
+
Object.keys(data).forEach((key) => {
|
|
49
|
+
if (data[key] instanceof File) {
|
|
50
|
+
formData.append(key, data[key], data[key].name);
|
|
51
|
+
}
|
|
52
|
+
else if (typeof data[key] === "object" &&
|
|
53
|
+
data[key] !== null) {
|
|
54
|
+
formData.append(key, JSON.stringify(data[key]));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
formData.append(key, data[key]);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
contentType = "multipart/form-data";
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
formData = data;
|
|
64
|
+
contentType = "application/json";
|
|
65
|
+
}
|
|
66
|
+
// For Core package
|
|
67
|
+
if (packageName === "Core") {
|
|
68
|
+
return axios.post(`/apps/${appId}/integration-endpoints/Core/${endpointName}`, formData || data, { headers: { "Content-Type": contentType } });
|
|
69
|
+
}
|
|
70
|
+
// For other packages
|
|
71
|
+
return axios.post(`/apps/${appId}/integration-endpoints/installable/${packageName}/integration-endpoints/${endpointName}`, formData || data, { headers: { "Content-Type": contentType } });
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { CustomIntegrationsModule } from "./custom-integrations.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Function signature for calling an integration endpoint.
|
|
4
|
+
*
|
|
5
|
+
* If any parameter is a `File` object, the request will automatically be
|
|
6
|
+
* sent as `multipart/form-data`. Otherwise, it will be sent as JSON.
|
|
7
|
+
*
|
|
8
|
+
* @param data - An object containing named parameters for the integration endpoint.
|
|
9
|
+
* @returns Promise resolving to the integration endpoint's response.
|
|
10
|
+
*/
|
|
11
|
+
export type IntegrationEndpointFunction = (data: Record<string, any>) => Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* A package containing integration endpoints.
|
|
14
|
+
*
|
|
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
|
+
*
|
|
18
|
+
* @example **Core package**
|
|
19
|
+
* ```typescript
|
|
20
|
+
* await base44.integrations.Core.InvokeLLM({
|
|
21
|
+
* prompt: 'Explain quantum computing',
|
|
22
|
+
* model: 'gpt_5'
|
|
23
|
+
* });
|
|
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
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export type IntegrationPackage = {
|
|
36
|
+
[endpointName: string]: IntegrationEndpointFunction;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Parameters for the InvokeLLM function.
|
|
40
|
+
*/
|
|
41
|
+
export interface InvokeLLMParams {
|
|
42
|
+
/** The prompt text to send to the model */
|
|
43
|
+
prompt: string;
|
|
44
|
+
/** Optionally specify a model to override the app-level model setting for this specific call.
|
|
45
|
+
*
|
|
46
|
+
* Options: `"gpt_5_mini"`, `"gemini_3_flash"`, `"gpt_5"`, `"gemini_3_pro"`, `"claude_sonnet_4_6"`, `"claude_opus_4_6"`
|
|
47
|
+
*/
|
|
48
|
+
model?: 'gpt_5_mini' | 'gemini_3_flash' | 'gpt_5' | 'gemini_3_pro' | 'claude_sonnet_4_6' | 'claude_opus_4_6';
|
|
49
|
+
/** If set to `true`, the LLM will use Google Search, Maps, and News to gather real-time context before answering.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
add_context_from_internet?: boolean;
|
|
53
|
+
/** 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. */
|
|
54
|
+
response_json_schema?: object;
|
|
55
|
+
/** 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`. */
|
|
56
|
+
file_urls?: string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parameters for the GenerateImage function.
|
|
60
|
+
*/
|
|
61
|
+
export interface GenerateImageParams {
|
|
62
|
+
/** Description of the image to generate. */
|
|
63
|
+
prompt: string;
|
|
64
|
+
}
|
|
65
|
+
export interface GenerateImageResult {
|
|
66
|
+
/** URL of the generated image. */
|
|
67
|
+
url: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parameters for the UploadFile function.
|
|
71
|
+
*/
|
|
72
|
+
export interface UploadFileParams {
|
|
73
|
+
/** The file object to upload. */
|
|
74
|
+
file: File;
|
|
75
|
+
}
|
|
76
|
+
export interface UploadFileResult {
|
|
77
|
+
/** URL of the uploaded file. */
|
|
78
|
+
file_url: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parameters for the SendEmail function.
|
|
82
|
+
*/
|
|
83
|
+
export interface SendEmailParams {
|
|
84
|
+
/** Recipient email address. */
|
|
85
|
+
to: string;
|
|
86
|
+
/** Email subject line. */
|
|
87
|
+
subject: string;
|
|
88
|
+
/** Plain text email body content. */
|
|
89
|
+
body: string;
|
|
90
|
+
/** The name of the sender. If omitted, the app's name will be used. */
|
|
91
|
+
from_name?: string;
|
|
92
|
+
}
|
|
93
|
+
export type SendEmailResult = any;
|
|
94
|
+
/**
|
|
95
|
+
* Parameters for the ExtractDataFromUploadedFile function.
|
|
96
|
+
*/
|
|
97
|
+
export interface ExtractDataFromUploadedFileParams {
|
|
98
|
+
/** The URL of the uploaded file to extract data from. */
|
|
99
|
+
file_url: string;
|
|
100
|
+
/** A [JSON schema object](https://json-schema.org/understanding-json-schema/reference/object) defining what data fields you want to extract. */
|
|
101
|
+
json_schema: object;
|
|
102
|
+
}
|
|
103
|
+
export type ExtractDataFromUploadedFileResult = object;
|
|
104
|
+
/**
|
|
105
|
+
* Parameters for the UploadPrivateFile function.
|
|
106
|
+
*/
|
|
107
|
+
export interface UploadPrivateFileParams {
|
|
108
|
+
/** The file object to upload. */
|
|
109
|
+
file: File;
|
|
110
|
+
}
|
|
111
|
+
export interface UploadPrivateFileResult {
|
|
112
|
+
/** URI of the uploaded private file, used to create a signed URL. */
|
|
113
|
+
file_uri: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Parameters for the CreateFileSignedUrl function.
|
|
117
|
+
*/
|
|
118
|
+
export interface CreateFileSignedUrlParams {
|
|
119
|
+
/** URI of the uploaded private file. */
|
|
120
|
+
file_uri: string;
|
|
121
|
+
/** How long the signed URL should be valid for, in seconds.
|
|
122
|
+
* @default 300 (5 minutes)
|
|
123
|
+
*/
|
|
124
|
+
expires_in?: number;
|
|
125
|
+
}
|
|
126
|
+
export interface CreateFileSignedUrlResult {
|
|
127
|
+
/** Temporary signed URL to access the private file. */
|
|
128
|
+
signed_url: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Core package containing built-in Base44 integration functions.
|
|
132
|
+
*/
|
|
133
|
+
export interface CoreIntegrations {
|
|
134
|
+
/**
|
|
135
|
+
* Generate text or structured JSON data using AI models.
|
|
136
|
+
*
|
|
137
|
+
* @param params - Parameters for the LLM invocation
|
|
138
|
+
* @returns Promise resolving to a string (when no schema provided) or an object (when schema provided).
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Basic prompt
|
|
143
|
+
* const response = await base44.integrations.Core.InvokeLLM({
|
|
144
|
+
* prompt: "Write a haiku about coding."
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* // Prompt with internet context
|
|
151
|
+
* const response = await base44.integrations.Core.InvokeLLM({
|
|
152
|
+
* prompt: "What is the current stock price of Wix and what was the latest major news about it?",
|
|
153
|
+
* add_context_from_internet: true
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* // Structured JSON response
|
|
160
|
+
* const response = await base44.integrations.Core.InvokeLLM({
|
|
161
|
+
* prompt: "Analyze the sentiment of this review: 'The service was slow but the food was amazing.'",
|
|
162
|
+
* response_json_schema: {
|
|
163
|
+
* type: "object",
|
|
164
|
+
* properties: {
|
|
165
|
+
* sentiment: { type: "string", enum: ["positive", "negative", "mixed"] },
|
|
166
|
+
* score: { type: "number", description: "Score from 1-10" },
|
|
167
|
+
* key_points: { type: "array", items: { type: "string" } }
|
|
168
|
+
* }
|
|
169
|
+
* }
|
|
170
|
+
* });
|
|
171
|
+
* // Returns object: { sentiment: "mixed", score: 7, key_points: ["slow service", "amazing food"] }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
InvokeLLM(params: InvokeLLMParams): Promise<string | object>;
|
|
175
|
+
/**
|
|
176
|
+
* Create AI-generated images from text prompts.
|
|
177
|
+
*
|
|
178
|
+
* @param params - Parameters for image generation
|
|
179
|
+
* @returns Promise resolving to the generated image URL.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* // Generate an image from a text prompt
|
|
184
|
+
* const {url} = await base44.integrations.Core.GenerateImage({
|
|
185
|
+
* prompt: "A serene mountain landscape with a lake in the foreground"
|
|
186
|
+
* });
|
|
187
|
+
* console.log(url); // https://...generated_image.png
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
GenerateImage(params: GenerateImageParams): Promise<GenerateImageResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Upload files to public storage and get a URL.
|
|
193
|
+
*
|
|
194
|
+
* @param params - Parameters for file upload
|
|
195
|
+
* @returns Promise resolving to an object containing the uploaded file URL.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* // Upload a file in React
|
|
200
|
+
* const handleFileUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
201
|
+
* const file = event.target.files?.[0];
|
|
202
|
+
* if (!file) return;
|
|
203
|
+
*
|
|
204
|
+
* const { file_url } = await base44.integrations.Core.UploadFile({ file });
|
|
205
|
+
* console.log(file_url); // https://...uploaded_file.pdf
|
|
206
|
+
* };
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
UploadFile(params: UploadFileParams): Promise<UploadFileResult>;
|
|
210
|
+
/**
|
|
211
|
+
* Send emails to registered users of your app.
|
|
212
|
+
*
|
|
213
|
+
* @param params - Parameters for sending email
|
|
214
|
+
* @returns Promise resolving when the email is sent.
|
|
215
|
+
*/
|
|
216
|
+
SendEmail(params: SendEmailParams): Promise<SendEmailResult>;
|
|
217
|
+
/**
|
|
218
|
+
* Extract structured data from uploaded files based on the specified schema.
|
|
219
|
+
*
|
|
220
|
+
* 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.
|
|
221
|
+
*
|
|
222
|
+
* @param params - Parameters for data extraction
|
|
223
|
+
* @returns Promise resolving to the extracted data.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* // Extract data from an already uploaded file
|
|
228
|
+
* const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
|
|
229
|
+
* file_url: "https://example.com/files/invoice.pdf",
|
|
230
|
+
* json_schema: {
|
|
231
|
+
* type: "object",
|
|
232
|
+
* properties: {
|
|
233
|
+
* invoice_number: { type: "string" },
|
|
234
|
+
* total_amount: { type: "number" },
|
|
235
|
+
* date: { type: "string" },
|
|
236
|
+
* vendor_name: { type: "string" }
|
|
237
|
+
* }
|
|
238
|
+
* }
|
|
239
|
+
* });
|
|
240
|
+
* console.log(result); // { invoice_number: "INV-12345", total_amount: 1250.00, ... }
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* // Upload a file and extract data in React
|
|
246
|
+
* const handleFileExtraction = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
247
|
+
* const file = event.target.files?.[0];
|
|
248
|
+
* if (!file) return;
|
|
249
|
+
*
|
|
250
|
+
* // First, upload the file
|
|
251
|
+
* const { file_url } = await base44.integrations.Core.UploadFile({ file });
|
|
252
|
+
*
|
|
253
|
+
* // Then extract structured data from it
|
|
254
|
+
* const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
|
|
255
|
+
* file_url,
|
|
256
|
+
* json_schema: {
|
|
257
|
+
* type: "object",
|
|
258
|
+
* properties: {
|
|
259
|
+
* summary: {
|
|
260
|
+
* type: "string",
|
|
261
|
+
* description: "A brief summary of the file content"
|
|
262
|
+
* },
|
|
263
|
+
* keywords: {
|
|
264
|
+
* type: "array",
|
|
265
|
+
* items: { type: "string" }
|
|
266
|
+
* },
|
|
267
|
+
* document_type: {
|
|
268
|
+
* type: "string"
|
|
269
|
+
* }
|
|
270
|
+
* }
|
|
271
|
+
* }
|
|
272
|
+
* });
|
|
273
|
+
* console.log(result); // { summary: "...", keywords: [...], document_type: "..." }
|
|
274
|
+
* };
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
ExtractDataFromUploadedFile(params: ExtractDataFromUploadedFileParams): Promise<ExtractDataFromUploadedFileResult>;
|
|
278
|
+
/**
|
|
279
|
+
* Upload files to private storage that requires a signed URL to access.
|
|
280
|
+
*
|
|
281
|
+
* Create a signed URL to access uploaded files using the {@linkcode CreateFileSignedUrl | CreateFileSignedUrl()} function.
|
|
282
|
+
*
|
|
283
|
+
* @param params - Parameters for private file upload
|
|
284
|
+
* @returns Promise resolving to an object with a `file_uri` used to create a signed URL to access the uploaded file.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* // Upload a private file
|
|
289
|
+
* const { file_uri } = await base44.integrations.Core.UploadPrivateFile({ file });
|
|
290
|
+
* console.log(file_uri); // "private/user123/document.pdf"
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* // Upload a private file and create a signed URL
|
|
296
|
+
* const handlePrivateUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
297
|
+
* const file = event.target.files?.[0];
|
|
298
|
+
* if (!file) return;
|
|
299
|
+
*
|
|
300
|
+
* // Upload to private storage
|
|
301
|
+
* const { file_uri } = await base44.integrations.Core.UploadPrivateFile({ file });
|
|
302
|
+
*
|
|
303
|
+
* // Create a signed URL that expires in 1 hour (3600 seconds)
|
|
304
|
+
* const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
|
|
305
|
+
* file_uri,
|
|
306
|
+
* expires_in: 3600
|
|
307
|
+
* });
|
|
308
|
+
*
|
|
309
|
+
* console.log(signed_url); // Temporary URL to access the private file
|
|
310
|
+
* };
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
UploadPrivateFile(params: UploadPrivateFileParams): Promise<UploadPrivateFileResult>;
|
|
314
|
+
/**
|
|
315
|
+
* Generate temporary access links for private files.
|
|
316
|
+
*
|
|
317
|
+
* 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.
|
|
318
|
+
*
|
|
319
|
+
* @param params - Parameters for creating signed URL
|
|
320
|
+
* @returns Promise resolving to an object with a temporary `signed_url`.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* // Create a signed URL for a private file
|
|
325
|
+
* const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
|
|
326
|
+
* file_uri: "private/user123/document.pdf",
|
|
327
|
+
* expires_in: 7200 // URL expires in 2 hours
|
|
328
|
+
* });
|
|
329
|
+
* console.log(signed_url); // https://...?signature=...
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
CreateFileSignedUrl(params: CreateFileSignedUrlParams): Promise<CreateFileSignedUrlResult>;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Integrations module for calling integration methods.
|
|
336
|
+
*
|
|
337
|
+
* 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.
|
|
338
|
+
*
|
|
339
|
+
* ## Integration Types
|
|
340
|
+
*
|
|
341
|
+
* There are two types of integrations:
|
|
342
|
+
*
|
|
343
|
+
* - **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:
|
|
344
|
+
* ```
|
|
345
|
+
* base44.integrations.Core.FunctionName(params)
|
|
346
|
+
* ```
|
|
347
|
+
*
|
|
348
|
+
* - **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:
|
|
349
|
+
* ```
|
|
350
|
+
* base44.integrations.custom.call(slug, operationId, params)
|
|
351
|
+
* ```
|
|
352
|
+
*
|
|
353
|
+
* <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>
|
|
354
|
+
*
|
|
355
|
+
* ## Authentication Modes
|
|
356
|
+
*
|
|
357
|
+
* This module is available to use with a client in all authentication modes:
|
|
358
|
+
*
|
|
359
|
+
* - **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.
|
|
360
|
+
* - **Service role authentication** (`base44.asServiceRole.integrations`): Integration methods are invoked with elevated admin-level permissions. The methods execute with admin authentication context.
|
|
361
|
+
*/
|
|
362
|
+
export type IntegrationsModule = {
|
|
363
|
+
/**
|
|
364
|
+
* Core package containing built-in Base44 integration functions.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const response = await base44.integrations.Core.InvokeLLM({
|
|
369
|
+
* prompt: 'Explain quantum computing',
|
|
370
|
+
* model: 'gpt_5'
|
|
371
|
+
* });
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
Core: CoreIntegrations;
|
|
375
|
+
/**
|
|
376
|
+
* Workspace integrations module for calling pre-configured external APIs.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const result = await base44.integrations.custom.call(
|
|
381
|
+
* 'github',
|
|
382
|
+
* 'get:/repos/{owner}/{repo}',
|
|
383
|
+
* { pathParams: { owner: 'myorg', repo: 'myrepo' } }
|
|
384
|
+
* );
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
custom: CustomIntegrationsModule;
|
|
388
|
+
} & {
|
|
389
|
+
/**
|
|
390
|
+
* Access to additional integration packages.
|
|
391
|
+
*
|
|
392
|
+
* Allows accessing integration packages as properties. This enables both `Core` and `custom` packages,
|
|
393
|
+
* as well as any future integration packages that may be added.
|
|
394
|
+
*
|
|
395
|
+
* @example **Use Core integrations**
|
|
396
|
+
* ```typescript
|
|
397
|
+
* const response = await base44.integrations.Core.InvokeLLM({
|
|
398
|
+
* prompt: 'Explain quantum computing',
|
|
399
|
+
* model: 'gpt_5'
|
|
400
|
+
* });
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @example **Use custom integrations**
|
|
404
|
+
* ```typescript
|
|
405
|
+
* const result = await base44.integrations.custom.call(
|
|
406
|
+
* 'github',
|
|
407
|
+
* 'get:/repos/{owner}/{repo}',
|
|
408
|
+
* { pathParams: { owner: 'myorg', repo: 'myrepo' } }
|
|
409
|
+
* );
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
[packageName: string]: IntegrationPackage;
|
|
413
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { SsoModule } from "./sso.types";
|
|
3
|
+
/**
|
|
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
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSsoModule(axios: AxiosInstance, appId: string, userToken?: string): SsoModule;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
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
|
|
9
|
+
*/
|
|
10
|
+
export function createSsoModule(axios, appId, userToken) {
|
|
11
|
+
return {
|
|
12
|
+
// Get SSO access token for a specific user
|
|
13
|
+
async getAccessToken(userid) {
|
|
14
|
+
const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
|
|
15
|
+
// Prepare headers with both tokens if available
|
|
16
|
+
const headers = {};
|
|
17
|
+
if (userToken) {
|
|
18
|
+
headers["on-behalf-of"] = `Bearer ${userToken}`;
|
|
19
|
+
}
|
|
20
|
+
return axios.get(url, { headers });
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|