@base44-preview/sdk 0.8.59-pr.369.5281fd5 → 0.8.59-pr.370.a3fc0ae
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/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { Base44Client, CreateClientAnalyticsConfig, CreateClientConfig, Cre
|
|
|
6
6
|
export * from "./types.js";
|
|
7
7
|
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityAggregateResult, EntityAggregateSpec, EntityDateBucket, EntityDistinctOptions, EntityFilterOperators, EntityFilterQuery, EntityFilterValue, EntityHandler, EntityListOptions, EntityPage, EntityRecord, EntityTypeRegistry, EntityUpsertOptions, EntityUpsertResult, 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
|
-
export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
|
|
9
|
+
export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, EmailAttachment, 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";
|
|
11
11
|
export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
|
|
12
12
|
export type { AiGatewayModule, AiGatewayConnection, AiGatewayConnectionOptions, } from "./modules/ai-gateway.types.js";
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface BrowserSessionOptions {
|
|
5
5
|
/**
|
|
6
|
-
* Whether
|
|
6
|
+
* Whether Base44's browser provider records the session and keeps its diagnostic logs.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* You can't retrieve the recordings or logs through the SDK. Set this to `false` when the session shows sensitive data that shouldn't be recorded. Defaults to `true`.
|
|
9
9
|
*/
|
|
10
10
|
captureDebugArtifacts?: boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Maximum lifetime of the session, in whole seconds.
|
|
13
13
|
*
|
|
14
|
-
* The session ends when the timeout expires, even if it's still in use. Base44
|
|
14
|
+
* The session ends when the timeout expires, even if it's still in use. Base44 clamps the value to between `60` and `900` seconds. Defaults to `300`.
|
|
15
15
|
*/
|
|
16
16
|
sessionTimeoutSeconds?: number;
|
|
17
17
|
}
|
|
@@ -22,7 +22,7 @@ export interface BrowserSession {
|
|
|
22
22
|
/**
|
|
23
23
|
* Opaque session identifier issued to your app.
|
|
24
24
|
*
|
|
25
|
-
* Pass it unchanged to
|
|
25
|
+
* Pass it unchanged to [`endSession()`](#endsession) to end the session from a different request.
|
|
26
26
|
*/
|
|
27
27
|
sessionId: string;
|
|
28
28
|
/**
|
|
@@ -43,25 +43,30 @@ export interface BrowserSession {
|
|
|
43
43
|
/** ISO 8601 timestamp when the browser session expires. Omitted when the provider doesn't expose it. */
|
|
44
44
|
sessionExpiresAt?: string;
|
|
45
45
|
/**
|
|
46
|
-
* Ends the session. Equivalent to calling
|
|
46
|
+
* Ends the session. Equivalent to calling [`endSession()`](#endsession) with this session's ID.
|
|
47
47
|
*/
|
|
48
48
|
end: () => Promise<void>;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Browser module for running browser automation from your backend.
|
|
52
52
|
*
|
|
53
|
-
* This module creates remote browser sessions that you can control with a CDP client library such as Playwright or Puppeteer. Base44 doesn't store browser state, so each session is independent.
|
|
53
|
+
* This module creates remote browser sessions that you can control with a [Chrome DevTools Protocol (CDP)](https://chromedevtools.github.io/devtools-protocol/) client library such as [Playwright](https://playwright.dev/docs/api/class-browsertype#browser-type-connect-over-cdp) or [Puppeteer](https://pptr.dev/api/puppeteer.puppeteer.connect). Base44 doesn't store browser state, so each session is independent.
|
|
54
54
|
*
|
|
55
|
-
*
|
|
55
|
+
* ## Authentication modes
|
|
56
|
+
*
|
|
57
|
+
* This module is only available to use with a client in [service role authentication mode](/developers/references/sdk/getting-started/client#service-role) (`base44.asServiceRole.browser`), which means it can only be used in backend environments.
|
|
56
58
|
*/
|
|
57
59
|
export interface BrowserModule {
|
|
58
60
|
/**
|
|
59
61
|
* Creates a new remote browser session and returns its connection details.
|
|
60
62
|
*
|
|
61
|
-
* Each call creates a fresh session.
|
|
63
|
+
* Each call creates a fresh session, which uses credits from the workspace that owns the app. Each session is billed by the minute until it ends. An open session keeps running until its timeout expires. When you're done, call `end()` on the session. To end it from a different request, use {@linkcode endSession | endSession()}.
|
|
62
64
|
*
|
|
63
65
|
* @param options - Optional session settings.
|
|
64
|
-
* @returns Promise resolving to the new browser session.
|
|
66
|
+
* @returns Promise resolving to the new browser session. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws).
|
|
67
|
+
* @throws `insufficient_credits`: The workspace is out of credits.
|
|
68
|
+
* @throws `rate_limited`: You created more than 100 sessions in the last minute.
|
|
69
|
+
* @throws `browser_capacity_exceeded`: Browser capacity is temporarily unavailable.
|
|
65
70
|
*
|
|
66
71
|
* @example
|
|
67
72
|
* ```typescript
|
|
@@ -93,28 +98,27 @@ export interface BrowserModule {
|
|
|
93
98
|
* const session = await base44.asServiceRole.browser.getSession({
|
|
94
99
|
* captureDebugArtifacts: false,
|
|
95
100
|
* });
|
|
96
|
-
* ```
|
|
97
101
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* });
|
|
102
|
+
* try {
|
|
103
|
+
* // Connect to session.connectionUrl and run your automation
|
|
104
|
+
* } finally {
|
|
105
|
+
* await session.end();
|
|
106
|
+
* }
|
|
104
107
|
* ```
|
|
105
108
|
*/
|
|
106
109
|
getSession(options?: BrowserSessionOptions): Promise<BrowserSession>;
|
|
107
110
|
/**
|
|
108
111
|
* Ends a browser session created by your app.
|
|
109
112
|
*
|
|
110
|
-
* Use this when the session was created in a different request. Otherwise call `end()` on the session returned by {@linkcode getSession | getSession()}. Ending a session that has already ended succeeds, so it's safe to call more than once.
|
|
113
|
+
* Use this when the session was created in a different request. Otherwise call `end()` on the session returned by {@linkcode getSession | getSession()}. Ending a session that has already ended succeeds, so it's safe to call more than once.
|
|
111
114
|
*
|
|
112
|
-
* @param sessionId - The `sessionId` returned by {@linkcode getSession | getSession()}
|
|
113
|
-
* @returns Promise that resolves when the session has ended.
|
|
115
|
+
* @param sessionId - The `sessionId` returned by {@linkcode getSession | getSession()}.
|
|
116
|
+
* @returns Promise that resolves when the session has ended. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws-2).
|
|
117
|
+
* @throws `browser_session_not_found`: The session ID wasn't issued to your app.
|
|
114
118
|
*
|
|
115
119
|
* @example
|
|
116
120
|
* ```typescript
|
|
117
|
-
* // End a session
|
|
121
|
+
* // End a session from a later request, using the ID sent in the request body
|
|
118
122
|
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
119
123
|
*
|
|
120
124
|
* Deno.serve(async (req) => {
|
|
@@ -86,6 +86,21 @@ export interface UploadFileResult {
|
|
|
86
86
|
/** URL of the uploaded file. */
|
|
87
87
|
file_url: string;
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* A file to attach to an email.
|
|
91
|
+
*/
|
|
92
|
+
export interface EmailAttachment {
|
|
93
|
+
/**
|
|
94
|
+
* File name the recipient sees, including the extension. The supported extensions are `csv`, `docx`, `gif`, `ics`, `jpeg`, `jpg`, `md`, `pdf`, `png`, `txt`, `webp`, and `xlsx`.
|
|
95
|
+
*/
|
|
96
|
+
filename: string;
|
|
97
|
+
/**
|
|
98
|
+
* A file your app already uploaded, such as the `file_url` returned by [`UploadFile()`](#uploadfile) or the `file_uri` returned by [`UploadPrivateFile()`](#uploadprivatefile). Files uploaded by other apps are rejected.
|
|
99
|
+
*/
|
|
100
|
+
file_url?: string;
|
|
101
|
+
/** Base64-encoded file contents, for a file your code generated. */
|
|
102
|
+
content?: string;
|
|
103
|
+
}
|
|
89
104
|
/**
|
|
90
105
|
* Parameters for the SendEmail function.
|
|
91
106
|
*/
|
|
@@ -94,10 +109,18 @@ export interface SendEmailParams {
|
|
|
94
109
|
to: string;
|
|
95
110
|
/** Email subject line. */
|
|
96
111
|
subject: string;
|
|
97
|
-
/**
|
|
98
|
-
body
|
|
99
|
-
/** The
|
|
112
|
+
/** HTML email body. The same as `html`, so set one or the other, not both. */
|
|
113
|
+
body?: string;
|
|
114
|
+
/** HTML email body. The same as `body`, so set one or the other, not both. */
|
|
115
|
+
html?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Plain-text email body. On its own, it sends a plain-text email. Set it together with `body` or `html` to send both versions in one email, and the recipient's mail client shows whichever it prefers. Make sure both versions say the same thing.
|
|
118
|
+
*/
|
|
119
|
+
text?: string;
|
|
120
|
+
/** The name of the sender. If omitted, the app's name is used. */
|
|
100
121
|
from_name?: string;
|
|
122
|
+
/** Files to attach. You can attach up to 5 files, up to 5 MB each and 10 MB in total. Set `filename` and exactly one of `file_url` or `content` on each file. */
|
|
123
|
+
attachments?: EmailAttachment[];
|
|
101
124
|
}
|
|
102
125
|
export type SendEmailResult = any;
|
|
103
126
|
/**
|
|
@@ -236,10 +259,35 @@ export interface CoreIntegrations {
|
|
|
236
259
|
*/
|
|
237
260
|
UploadFile(params: UploadFileParams): Promise<UploadFileResult>;
|
|
238
261
|
/**
|
|
239
|
-
* Send
|
|
262
|
+
* Send an email from your app.
|
|
263
|
+
*
|
|
264
|
+
* You can always email registered users of your app. To email anyone else, the app needs a paid plan and a connected custom domain.
|
|
240
265
|
*
|
|
241
|
-
* @param params - Parameters for sending email
|
|
266
|
+
* @param params - Parameters for sending email. Set at least one of `body`, `html`, or `text`.
|
|
242
267
|
* @returns Promise resolving when the email is sent.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* // Send an HTML email with a plain-text version
|
|
272
|
+
* await base44.integrations.Core.SendEmail({
|
|
273
|
+
* to: "user@example.com",
|
|
274
|
+
* subject: "Your order has shipped",
|
|
275
|
+
* html: "<p>Your order <strong>#1234</strong> is on its way.</p>",
|
|
276
|
+
* text: "Your order #1234 is on its way.",
|
|
277
|
+
* });
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* // Attach a file your app uploaded
|
|
283
|
+
* const { file_url } = await base44.integrations.Core.UploadFile({ file });
|
|
284
|
+
* await base44.integrations.Core.SendEmail({
|
|
285
|
+
* to: "user@example.com",
|
|
286
|
+
* subject: "Your invoice",
|
|
287
|
+
* html: "<p>Your invoice is attached.</p>",
|
|
288
|
+
* attachments: [{ filename: "invoice.pdf", file_url }],
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
243
291
|
*/
|
|
244
292
|
SendEmail(params: SendEmailParams): Promise<SendEmailResult>;
|
|
245
293
|
/**
|
|
@@ -361,7 +361,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
361
361
|
/** Whether the checkout is a one-time payment or a subscription. */
|
|
362
362
|
intent: "capture" | "subscription";
|
|
363
363
|
/**
|
|
364
|
-
* Creates the checkout when the buyer clicks, usually by calling the backend function that calls
|
|
364
|
+
* Creates the checkout when the buyer clicks, usually by calling the backend function that calls [`createCheckout()`](#createcheckout). Resolve with its result. It must be an embedded PayPal checkout with the same `currency` and `intent` you set here, or `onError` receives an error. Reject to stop, for example when a required form field is empty. PayPal's window then closes and `onError` receives the error.
|
|
365
365
|
*/
|
|
366
366
|
createCheckout: () => Promise<MountableCheckout>;
|
|
367
367
|
}
|
|
@@ -371,7 +371,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
371
371
|
export interface CheckoutMount {
|
|
372
372
|
/** Removes the checkout from the page. Call it when the component that holds it unmounts. For Stripe, mounting another checkout destroys this one for you. */
|
|
373
373
|
destroy: () => void;
|
|
374
|
-
/**
|
|
374
|
+
/** Grays out PayPal's button and ignores clicks, for example until a required form is filled in. After a payment completes the button stays off, so `setDisabled(false)` can't start a second payment. Stripe ignores it. */
|
|
375
375
|
setDisabled: (disabled: boolean) => void;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
@@ -425,7 +425,7 @@ export interface PaymentsModule {
|
|
|
425
425
|
/**
|
|
426
426
|
* Renders an embedded checkout inside an element on the page.
|
|
427
427
|
*
|
|
428
|
-
* Pass the result of a {@linkcode ServiceRolePaymentsModule.createCheckout | createCheckout()} call made with `presentation: 'embedded'`. Because only the service role can create checkouts, create it in a backend function and return the result to the page.
|
|
428
|
+
* Pass the result of a {@linkcode ServiceRolePaymentsModule.createCheckout | createCheckout()} call made with `presentation: 'embedded'`. Because only the service role can create checkouts, create it in a backend function and return the result to the page. For PayPal, you can instead pass a {@linkcode PayPalCheckoutOnClick} to show the button before any checkout exists. The SDK creates the checkout only when the buyer clicks the button, so visitors who don't buy don't leave unused checkouts behind.
|
|
429
429
|
*
|
|
430
430
|
* The SDK loads the provider's library and renders the checkout for you:
|
|
431
431
|
* - PayPal: Renders a PayPal button. When the buyer approves the payment, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
|
|
@@ -433,8 +433,6 @@ export interface PaymentsModule {
|
|
|
433
433
|
*
|
|
434
434
|
* To make the checkout appear faster, load the library ahead of time with [`preloadCheckout()`](#preloadcheckout) when the page opens.
|
|
435
435
|
*
|
|
436
|
-
* For PayPal, pass a {@linkcode PayPalCheckoutOnClick} instead of a created checkout to show PayPal's button right away and create the checkout only when the buyer clicks it. The buyer clicks once, and page views create no orders.
|
|
437
|
-
*
|
|
438
436
|
* Requires a browser environment and can't be used in the backend. Rejects when the checkout isn't embedded, when an on-click PayPal checkout is mounted before the app's PayPal can take payments, when the payments config can't be fetched or has no valid script URL for the provider, when the provider's library fails to load, or when PayPal isn't available for the checkout's currency.
|
|
439
437
|
*
|
|
440
438
|
* The checkout's callbacks run in the buyer's browser, where they can be faked. Grant access to what the buyer paid for only after your backend confirms the purchase, for example with [`listPurchases()`](#service-role-methods) in a backend function.
|
|
@@ -465,7 +463,7 @@ export interface PaymentsModule {
|
|
|
465
463
|
*
|
|
466
464
|
* @example
|
|
467
465
|
* ```typescript
|
|
468
|
-
* //
|
|
466
|
+
* // Create a PayPal checkout on click
|
|
469
467
|
* const mount = await base44.payments.mountCheckout(
|
|
470
468
|
* document.getElementById('paypal')!,
|
|
471
469
|
* {
|
|
@@ -478,7 +476,7 @@ export interface PaymentsModule {
|
|
|
478
476
|
* { onComplete: ({ checkout_id }) => confirmPurchase(checkout_id) }
|
|
479
477
|
* );
|
|
480
478
|
*
|
|
481
|
-
* //
|
|
479
|
+
* // Gray out the button until the shipping form is valid
|
|
482
480
|
* mount.setDisabled(!formIsValid);
|
|
483
481
|
* ```
|
|
484
482
|
*
|
|
@@ -11,7 +11,9 @@ export interface SsoAccessTokenResponse {
|
|
|
11
11
|
* tokens allow you to authenticate Base44 users with external systems or
|
|
12
12
|
* services.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* ## Authentication modes
|
|
15
|
+
*
|
|
16
|
+
* This module is only available to use with a client in [service role authentication mode](/developers/references/sdk/getting-started/client#service-role) (`base44.asServiceRole.sso`), which means it can only be used in backend environments.
|
|
15
17
|
*/
|
|
16
18
|
export interface SsoModule {
|
|
17
19
|
/**
|