@base44-preview/sdk 0.8.53-pr.327.be55878 → 0.8.53-pr.328.3b9beb7
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
|
@@ -3,6 +3,7 @@ import { createEntitiesModule } from "./modules/entities.js";
|
|
|
3
3
|
import { createIntegrationsModule } from "./modules/integrations.js";
|
|
4
4
|
import { createAuthModule } from "./modules/auth.js";
|
|
5
5
|
import { createSsoModule } from "./modules/sso.js";
|
|
6
|
+
import { createBrowserModule } from "./modules/browser.js";
|
|
6
7
|
import { createConnectorsModule, createUserConnectorsModule, } from "./modules/connectors.js";
|
|
7
8
|
import { getAccessToken } from "./utils/auth-utils.js";
|
|
8
9
|
import { createFetchWithAuth } from "./utils/fetch-with-auth.js";
|
|
@@ -226,6 +227,7 @@ export function createClient(config) {
|
|
|
226
227
|
}),
|
|
227
228
|
integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
|
|
228
229
|
sso: createSsoModule(serviceRoleAxiosClient, appId),
|
|
230
|
+
browser: createBrowserModule(serviceRoleAxiosClient),
|
|
229
231
|
connectors: createConnectorsModule(serviceRoleAxiosClient, appId),
|
|
230
232
|
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId, {
|
|
231
233
|
getAuthHeaders: () => {
|
package/dist/client.types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { EntitiesModule } from "./modules/entities.types.js";
|
|
|
2
2
|
import type { IntegrationsModule } from "./modules/integrations.types.js";
|
|
3
3
|
import type { AuthModule } from "./modules/auth.types.js";
|
|
4
4
|
import type { SsoModule } from "./modules/sso.types.js";
|
|
5
|
+
import type { BrowserModule } from "./modules/browser.types.js";
|
|
5
6
|
import type { ConnectorsModule, UserConnectorsModule } from "./modules/connectors.types.js";
|
|
6
7
|
import type { FunctionsModule } from "./modules/functions.types.js";
|
|
7
8
|
import type { AgentsModule } from "./modules/agents.types.js";
|
|
@@ -225,6 +226,8 @@ export interface Base44Client {
|
|
|
225
226
|
aiGateway: AiGatewayModule;
|
|
226
227
|
/** {@link AppLogsModule | App logs module} with elevated permissions. */
|
|
227
228
|
appLogs: AppLogsModule;
|
|
229
|
+
/** {@link BrowserModule | Browser module} for remote browser sessions. */
|
|
230
|
+
browser: BrowserModule;
|
|
228
231
|
/** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */
|
|
229
232
|
connectors: ConnectorsModule;
|
|
230
233
|
/** {@link EntitiesModule | Entities module} with elevated permissions. */
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
|
14
14
|
export type { AppModule, AppPublicSettings, AppPublicSettingsResponse, } from "./modules/app.types.js";
|
|
15
15
|
export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription, ActorConnectOptions, ActorNameRegistry, ActorRegistry, } from "./modules/actors.types.js";
|
|
16
16
|
export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
|
|
17
|
+
export type { BrowserModule, BrowserSession, BrowserSessionOptions, } from "./modules/browser.types.js";
|
|
17
18
|
export { Actor, type Conn } from "./actor.js";
|
|
18
19
|
export type { ConnectorsModule, UserConnectorsModule, ConnectorApiRequest, ConnectorApiResponse, ConnectorApiResponsePhase, } from "./modules/connectors.types.js";
|
|
19
20
|
export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { BrowserModule } from "./browser.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the Browser module for the Base44 SDK.
|
|
5
|
+
*
|
|
6
|
+
* @param axios - Axios instance (should be service role client)
|
|
7
|
+
* @returns Browser module with methods to create remote browser sessions
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare function createBrowserModule(axios: AxiosInstance): BrowserModule;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the Browser module for the Base44 SDK.
|
|
3
|
+
*
|
|
4
|
+
* @param axios - Axios instance (should be service role client)
|
|
5
|
+
* @returns Browser module with methods to create remote browser sessions
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export function createBrowserModule(axios) {
|
|
9
|
+
return {
|
|
10
|
+
async getSession(options = {}) {
|
|
11
|
+
var _a;
|
|
12
|
+
// The app is derived from the service token, so the route isn't app-scoped.
|
|
13
|
+
const response = await axios.post("/v1/browser-sessions", { capture_debug_artifacts: (_a = options.captureDebugArtifacts) !== null && _a !== void 0 ? _a : true });
|
|
14
|
+
const data = response;
|
|
15
|
+
return {
|
|
16
|
+
sessionId: data.session_id,
|
|
17
|
+
connectionUrl: data.connection_url,
|
|
18
|
+
connectionScope: data.connection_scope,
|
|
19
|
+
...(data.connection_expires_at && {
|
|
20
|
+
connectionExpiresAt: data.connection_expires_at,
|
|
21
|
+
}),
|
|
22
|
+
...(data.session_expires_at && {
|
|
23
|
+
sessionExpiresAt: data.session_expires_at,
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@linkcode BrowserModule.getSession | getSession()}.
|
|
3
|
+
*/
|
|
4
|
+
export interface BrowserSessionOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to capture browser recordings and diagnostic logs for the session.
|
|
7
|
+
*
|
|
8
|
+
* Captured artifacts stay with the remote browser provider and can't be retrieved through the SDK. Defaults to `true`.
|
|
9
|
+
*/
|
|
10
|
+
captureDebugArtifacts?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A remote browser session returned by {@linkcode BrowserModule.getSession | getSession()}.
|
|
14
|
+
*/
|
|
15
|
+
export interface BrowserSession {
|
|
16
|
+
/** Opaque session identifier issued by the remote browser provider. */
|
|
17
|
+
sessionId: string;
|
|
18
|
+
/**
|
|
19
|
+
* Signed WebSocket URL for connecting to the browser over the Chrome DevTools Protocol (CDP).
|
|
20
|
+
*
|
|
21
|
+
* Treat the complete URL as a credential. Don't log it or send it to the frontend.
|
|
22
|
+
*/
|
|
23
|
+
connectionUrl: string;
|
|
24
|
+
/**
|
|
25
|
+
* Scope of the CDP connection.
|
|
26
|
+
*
|
|
27
|
+
* - `'browser'`: The socket controls the whole browser.
|
|
28
|
+
* - `'page'`: The socket controls a single page.
|
|
29
|
+
*/
|
|
30
|
+
connectionScope: "browser" | "page";
|
|
31
|
+
/** ISO 8601 timestamp when the connection URL expires. Omitted when the provider doesn't expose it. */
|
|
32
|
+
connectionExpiresAt?: string;
|
|
33
|
+
/** ISO 8601 timestamp when the browser session expires. Omitted when the provider doesn't expose it. */
|
|
34
|
+
sessionExpiresAt?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Browser module for running browser automation from your backend.
|
|
38
|
+
*
|
|
39
|
+
* 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.
|
|
40
|
+
*
|
|
41
|
+
* 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.
|
|
42
|
+
*/
|
|
43
|
+
export interface BrowserModule {
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new remote browser session and returns its connection details.
|
|
46
|
+
*
|
|
47
|
+
* Each call creates a fresh session. Calls aren't retried automatically, and repeating a failed call doesn't resume a previous session. Session creation is rate limited per app.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Optional session settings.
|
|
50
|
+
* @returns Promise resolving to the new browser session.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Open a page in a remote browser with Playwright
|
|
55
|
+
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
56
|
+
* import { chromium } from 'npm:playwright-core';
|
|
57
|
+
*
|
|
58
|
+
* Deno.serve(async (req) => {
|
|
59
|
+
* const base44 = createClientFromRequest(req);
|
|
60
|
+
* const { connectionUrl } = await base44.asServiceRole.browser.getSession();
|
|
61
|
+
*
|
|
62
|
+
* const browser = await chromium.connectOverCDP(connectionUrl);
|
|
63
|
+
* const page = browser.contexts()[0].pages()[0] ?? (await browser.newPage());
|
|
64
|
+
* await page.goto('https://example.com');
|
|
65
|
+
* const title = await page.title();
|
|
66
|
+
* await browser.close();
|
|
67
|
+
*
|
|
68
|
+
* return Response.json({ title });
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* // Turn off recordings and diagnostic logs
|
|
75
|
+
* const session = await base44.asServiceRole.browser.getSession({
|
|
76
|
+
* captureDebugArtifacts: false,
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
getSession(options?: BrowserSessionOptions): Promise<BrowserSession>;
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|