@base44-preview/sdk 0.8.35-pr.214.6a78f1b → 0.8.35-pr.214.a1658ed

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
@@ -151,7 +151,7 @@ export function createClient(config) {
151
151
  serverUrl,
152
152
  token,
153
153
  }),
154
- aiGateway: createAiGatewayModule({ serverUrl, token }),
154
+ aiGateway: createAiGatewayModule({ serverUrl, appBaseUrl: normalizedAppBaseUrl, token }),
155
155
  appLogs: createAppLogsModule(axiosClient, appId),
156
156
  users: createUsersModule(axiosClient, appId),
157
157
  analytics: createAnalyticsModule({
@@ -194,7 +194,7 @@ export function createClient(config) {
194
194
  serverUrl,
195
195
  token,
196
196
  }),
197
- aiGateway: createAiGatewayModule({ serverUrl, token: serviceToken }),
197
+ aiGateway: createAiGatewayModule({ serverUrl, appBaseUrl: normalizedAppBaseUrl, token: serviceToken }),
198
198
  appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
199
199
  cleanup: () => {
200
200
  if (socket) {
@@ -344,6 +344,7 @@ export function createClientFromRequest(request) {
344
344
  const serviceRoleAuthHeader = request.headers.get("Base44-Service-Authorization");
345
345
  const appId = request.headers.get("Base44-App-Id");
346
346
  const serverUrlHeader = request.headers.get("Base44-Api-Url");
347
+ const appBaseUrlHeader = request.headers.get("Base44-App-Base-Url");
347
348
  const functionsVersion = request.headers.get("Base44-Functions-Version");
348
349
  const stateHeader = request.headers.get("Base44-State");
349
350
  if (!appId) {
@@ -375,6 +376,7 @@ export function createClientFromRequest(request) {
375
376
  }
376
377
  return createClient({
377
378
  serverUrl: serverUrlHeader || "https://base44.app",
379
+ appBaseUrl: appBaseUrlHeader !== null && appBaseUrlHeader !== void 0 ? appBaseUrlHeader : undefined,
378
380
  appId,
379
381
  token: userToken,
380
382
  serviceToken: serviceRoleToken,
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, Change
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";
11
11
  export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
12
- export type { AiGatewayModule, GatewayConnection, } from "./modules/ai-gateway.types.js";
12
+ export type { AiGatewayModule, AiGatewayConnection, } from "./modules/ai-gateway.types.js";
13
13
  export type { AppLogsModule } from "./modules/app-logs.types.js";
14
14
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
15
15
  export type { ConnectorsModule, UserConnectorsModule, } from "./modules/connectors.types.js";
@@ -1,2 +1,2 @@
1
1
  import { AiGatewayModule, AiGatewayModuleConfig } from "./ai-gateway.types.js";
2
- export declare function createAiGatewayModule({ serverUrl, token, }: AiGatewayModuleConfig): AiGatewayModule;
2
+ export declare function createAiGatewayModule({ serverUrl, appBaseUrl, token, }: AiGatewayModuleConfig): AiGatewayModule;
@@ -1,9 +1,10 @@
1
1
  import { getAccessToken } from "../utils/auth-utils.js";
2
- export function createAiGatewayModule({ serverUrl, token, }) {
2
+ export function createAiGatewayModule({ serverUrl, appBaseUrl, token, }) {
3
+ const gatewayOrigin = appBaseUrl || serverUrl;
3
4
  const connection = () => {
4
5
  var _a;
5
6
  return ({
6
- baseURL: `${serverUrl}/api/ai/unified/v1`,
7
+ baseURL: `${gatewayOrigin}/api/ai/openai/v1`,
7
8
  token: (_a = token !== null && token !== void 0 ? token : getAccessToken()) !== null && _a !== void 0 ? _a : "",
8
9
  });
9
10
  };
@@ -4,7 +4,7 @@
4
4
  * Contains the base URL and bearer token to use with any OpenAI-compatible client
5
5
  * (the OpenAI SDK, Mastra, and others) pointed at the Base44 AI Gateway.
6
6
  */
7
- export interface GatewayConnection {
7
+ export interface AiGatewayConnection {
8
8
  /** Base URL of the gateway's OpenAI-compatible endpoint. */
9
9
  baseURL: string;
10
10
  /** Bearer token used to authenticate requests to the gateway. */
@@ -17,6 +17,9 @@ export interface GatewayConnection {
17
17
  export interface AiGatewayModuleConfig {
18
18
  /** Server URL */
19
19
  serverUrl?: string;
20
+ /** The app's own public base URL (e.g. https://my-app.base44.app). Preferred over
21
+ * serverUrl for the gateway URL, since the gateway resolves the app by domain. */
22
+ appBaseUrl?: string;
20
23
  /** Authentication token */
21
24
  token?: string;
22
25
  }
@@ -37,8 +40,10 @@ export interface AiGatewayModule {
37
40
  *
38
41
  * The `token` is the current caller's bearer token: the app user's token for
39
42
  * `base44.aiGateway`, or the service-role token for `base44.asServiceRole.aiGateway`.
43
+ * When the caller is unauthenticated, `token` is an empty string and gateway
44
+ * requests will be rejected.
40
45
  *
41
- * @returns The gateway {@linkcode GatewayConnection | connection} (`baseURL` and `token`).
46
+ * @returns The gateway {@linkcode AiGatewayConnection | connection} (`baseURL` and `token`).
42
47
  *
43
48
  * @example
44
49
  * ```typescript
@@ -59,5 +64,5 @@ export interface AiGatewayModule {
59
64
  * });
60
65
  * ```
61
66
  */
62
- connection(): GatewayConnection;
67
+ connection(): AiGatewayConnection;
63
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.35-pr.214.6a78f1b",
3
+ "version": "0.8.35-pr.214.a1658ed",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",