New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@base44/sdk

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@base44/sdk - npm Package Compare versions

Comparing version
0.8.19
to
0.8.20
+4
-4
dist/index.d.ts

@@ -7,7 +7,7 @@ import { createClient, createClientFromRequest, type Base44Client, type CreateClientConfig, type CreateClientOptions } from "./client.js";

export * from "./types.js";
export type { EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, RealtimeEventType, RealtimeEvent, RealtimeCallback, } from "./modules/entities.types.js";
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, } from "./modules/entities.types.js";
export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
export type { IntegrationsModule, IntegrationPackage, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
export type { FunctionsModule, FunctionNameRegistry, } from "./modules/functions.types.js";
export type { AgentsModule, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
export type { AppLogsModule } from "./modules/app-logs.types.js";

@@ -14,0 +14,0 @@ export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";

@@ -5,4 +5,3 @@ import { AxiosInstance } from "axios";

/**
* Registry of agent names.
* Augment this interface to enable autocomplete for agent names.
* Registry of agent names. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`AgentName`](#agentname) resolves to a union of the keys.
*/

@@ -12,3 +11,10 @@ export interface AgentNameRegistry {

/**
* Agent name type - uses registry keys if augmented, otherwise string.
* Union of all agent names from the [`AgentNameRegistry`](#agentnameregistry). Defaults to `string` when no types have been generated.
*
* @example
* ```typescript
* // Using generated agent name types
* // With generated types, you get autocomplete on agent names
* const conversation = await base44.agents.createConversation({ agent_name: 'SupportBot' });
* ```
*/

@@ -169,2 +175,4 @@ export type AgentName = keyof AgentNameRegistry extends never ? string : keyof AgentNameRegistry;

*
* ## Key Features
*
* The agents module enables you to:

@@ -179,2 +187,4 @@ *

*
* ## Conversation Structure
*
* The agents module operates with a two-level hierarchy:

@@ -186,2 +196,4 @@ *

*
* ## Authentication Modes
*
* This module is available to use with a client in all authentication modes:

@@ -192,2 +204,5 @@ *

*
* ## Generated Types
*
* If you're working in a TypeScript project, you can generate types from your agents to get autocomplete on agent names when creating conversations or subscribing to updates. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
*/

@@ -217,3 +232,3 @@ export interface AgentsModule {

* Retrieves a single conversation using its unique identifier. To retrieve
* all conversations, use {@linkcode getConversations | getConversations()} To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
* all conversations, use {@linkcode getConversations | getConversations()}. To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
*

@@ -322,4 +337,4 @@ * This function returns the complete stored conversation including full tool call results, even for large responses.

* <Note>
When receiving messages through this function, tool call data is truncated for efficiency. The `arguments_string` is limited to 500 characters and `results` to 50 characters. The complete tool call data is always saved in storage and can be retrieved by calling {@linkcode getConversation | getConversation()} after the message completes.
</Note>
* When receiving messages through this function, tool call data is truncated for efficiency. The `arguments_string` is limited to 500 characters and `results` to 50 characters. The complete tool call data is always saved in storage and can be retrieved by calling {@linkcode getConversation | getConversation()} after the message completes.
* </Note>
*

@@ -326,0 +341,0 @@ * @param conversationId - The conversation ID to subscribe to.

@@ -77,2 +77,4 @@ /**

*
* ## Best Practices
*
* When tracking events:

@@ -83,2 +85,4 @@ *

*
* ## Authentication Modes
*
* This module is only available in user authentication mode (`base44.analytics`).

@@ -85,0 +89,0 @@ */

@@ -6,2 +6,4 @@ /**

*
* ## Authentication Modes
*
* This module is available to use with a client in all authentication modes.

@@ -8,0 +10,0 @@ */

@@ -40,5 +40,14 @@ /**

const redirectUrl = new URL(fromUrl, window.location.origin).toString();
// Build the provider login URL (google is the default, so no provider path needed)
const providerPath = provider === "google" ? "" : `/${provider}`;
const loginUrl = `${options.appBaseUrl}/api/apps/auth${providerPath}/login?app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
const queryParams = `app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
// SSO uses a different URL structure with appId in the path
let authPath;
if (provider === "sso") {
authPath = `/apps/${appId}/auth/sso/login`;
}
else {
// Google is the default provider, so no provider path segment needed
const providerPath = provider === "google" ? "" : `/${provider}`;
authPath = `/apps/auth${providerPath}/login`;
}
const loginUrl = `${options.appBaseUrl}/api${authPath}?${queryParams}`;
// Redirect to the provider login page

@@ -45,0 +54,0 @@ window.location.href = loginUrl;

@@ -99,2 +99,4 @@ /**

*
* ## Features
*
* This module provides comprehensive authentication functionality including:

@@ -108,2 +110,4 @@ * - Email/password login and registration

*
* ## Authentication Modes
*
* The auth module is only available in user authentication mode (`base44.auth`).

@@ -184,5 +188,7 @@ */

* - `'microsoft'` - {@link https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow | Microsoft OAuth}. Enable Microsoft in your app's authentication settings before specifying this provider.
* - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable this in your app's authentication settings before using.
* - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
* - `'apple'` - {@link https://developer.apple.com/sign-in-with-apple/ | Sign in with Apple}. Enable Apple in your app's authentication settings before using this provider.
* - `'sso'` - Enterprise SSO. Enable SSO in your app's authentication settings before using this provider.
*
* @param provider - The authentication provider to use: `'google'`, `'microsoft'`, or `'facebook'`.
* @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, `'apple'`, or `'sso'`.
* @param fromUrl - URL to redirect to after successful authentication. Defaults to `'/'`.

@@ -192,3 +198,3 @@ *

* ```typescript
* // Login with Google and return to current page
* // Google
* base44.auth.loginWithProvider('google', window.location.pathname);

@@ -199,5 +205,17 @@ * ```

* ```typescript
* // Login with Microsoft and redirect to dashboard
* // Microsoft
* base44.auth.loginWithProvider('microsoft', '/dashboard');
* ```
*
* @example
* ```typescript
* // Apple
* base44.auth.loginWithProvider('apple', '/dashboard');
* ```
*
* @example
* ```typescript
* // SSO
* base44.auth.loginWithProvider('sso', '/dashboard');
* ```
*/

@@ -204,0 +222,0 @@ loginWithProvider(provider: string, fromUrl?: string): void;

@@ -11,4 +11,7 @@ /**

return {
// Retrieve an OAuth access token for a specific external integration type
// @ts-expect-error Return type mismatch with interface - implementation returns object, interface expects string
/**
* Retrieve an OAuth access token for a specific external integration type.
* @deprecated Use getConnection(integrationType) and use the returned accessToken (and connectionConfig when needed) instead.
*/
// @ts-expect-error Return type mismatch with interface - implementation returns string, interface expects string but implementation is typed as ConnectorAccessTokenResponse
async getAccessToken(integrationType) {

@@ -22,3 +25,15 @@ if (!integrationType || typeof integrationType !== "string") {

},
async getConnection(integrationType) {
var _a;
if (!integrationType || typeof integrationType !== "string") {
throw new Error("Integration type is required and must be a string");
}
const response = await axios.get(`/apps/${appId}/external-auth/tokens/${integrationType}`);
const data = response;
return {
accessToken: data.access_token,
connectionConfig: (_a = data.connection_config) !== null && _a !== void 0 ? _a : null,
};
},
};
}
/**
* Registry of connector integration types.
* Augment this interface to enable autocomplete for connector integration types.
* Registry of connector integration type names. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`ConnectorIntegrationType`](#connectorintegrationtype) resolves to a union of the keys.
*/

@@ -8,4 +7,11 @@ export interface ConnectorIntegrationTypeRegistry {

/**
* The type of external integration/connector, such as `'googlecalendar'`, `'slack'`, or `'github'`.
* Uses registry keys if augmented, otherwise falls back to string.
* Union of all connector integration type names from the [`ConnectorIntegrationTypeRegistry`](#connectorintegrationtyperegistry). Defaults to `string` when no types have been generated.
*
* @example
* ```typescript
* // Using generated connector type names
* // With generated types, you get autocomplete on integration types
* const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
* const token = connection.accessToken;
* ```
*/

@@ -18,4 +24,15 @@ export type ConnectorIntegrationType = keyof ConnectorIntegrationTypeRegistry extends never ? string : keyof ConnectorIntegrationTypeRegistry;

access_token: string;
integration_type: string;
connection_config: Record<string, string> | null;
}
/**
* Camel-cased connection details returned by {@linkcode ConnectorsModule.getConnection | getConnection()}.
*/
export interface ConnectorConnectionResponse {
/** The OAuth access token for the external service. */
accessToken: string;
/** Key-value configuration for the connection, or `null` if the connector does not provide one. */
connectionConfig: Record<string, string> | null;
}
/**
* Connectors module for managing OAuth tokens for external services.

@@ -30,3 +47,9 @@ *

*
* ## Authentication Modes
*
* 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.
*
* ## Dynamic Types
*
* If you're working in a TypeScript project, you can generate types from your app's connector configurations to get autocomplete on integration type names when calling `getConnection()`. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
*/

@@ -37,2 +60,4 @@ export interface ConnectorsModule {

*
* @deprecated Use {@link getConnection} and use the returned `accessToken` (and `connectionConfig` when needed) instead.
*
* Returns the OAuth token string for an external service that an app builder

@@ -79,2 +104,39 @@ * has connected to. This token represents the connected app builder's account

getAccessToken(integrationType: ConnectorIntegrationType): Promise<string>;
/**
* Retrieves the OAuth access token and connection configuration for a specific external integration type.
*
* Returns both the OAuth token and any additional connection configuration
* that the connector provides. This is useful when the external service requires
* extra parameters beyond the access token (e.g., a shop domain, account ID, or API base URL).
*
* @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`.
* @returns Promise resolving to a {@link ConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
*
* @example
* ```typescript
* // Basic usage
* const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
* console.log(connection.accessToken);
* console.log(connection.connectionConfig);
* ```
*
* @example
* ```typescript
* // Shopify: connectionConfig has subdomain (e.g. "my-store" for my-store.myshopify.com)
* const connection = await base44.asServiceRole.connectors.getConnection('shopify');
* const { accessToken, connectionConfig } = connection;
* const shop = connectionConfig?.subdomain
* ? `https://${connectionConfig.subdomain}.myshopify.com`
* : null;
*
* if (shop) {
* const response = await fetch(
* `${shop}/admin/api/2024-01/products.json?limit=10`,
* { headers: { 'X-Shopify-Access-Token': accessToken } }
* );
* const { products } = await response.json();
* }
* ```
*/
getConnection(integrationType: ConnectorIntegrationType): Promise<ConnectorConnectionResponse>;
}

@@ -30,3 +30,3 @@ /**

export interface DeleteResult {
/** Whether the deletion was successful */
/** Whether the deletion was successful. */
success: boolean;

@@ -38,5 +38,5 @@ }

export interface DeleteManyResult {
/** Whether the deletion was successful */
/** Whether the deletion was successful. */
success: boolean;
/** Number of entities that were deleted */
/** Number of entities that were deleted. */
deleted: number;

@@ -50,7 +50,7 @@ }

export interface ImportResult<T = any> {
/** Status of the import operation */
/** Status of the import operation. */
status: "success" | "error";
/** Details message, e.g., "Successfully imported 3 entities with RLS enforcement" */
/** Details message, e.g., "Successfully imported 3 entities with RLS enforcement". */
details: string | null;
/** Array of created entity objects when successful, or null on error */
/** Array of created entity objects when successful, or null on error. */
output: T[] | null;

@@ -61,3 +61,5 @@ }

*
* Supports ascending (no prefix or `'+'`) and descending (`'-'`) sorting.
* Accepts any field name from the entity type with an optional prefix:
* - `'+'` prefix or no prefix: ascending sort
* - `'-'` prefix: descending sort
*

@@ -68,3 +70,4 @@ * @typeParam T - The entity type to derive sortable fields from.

* ```typescript
* // Ascending sort (default)
* // Specify sort direction by prefixing field names with + or -
* // Ascending sort
* 'created_date'

@@ -79,3 +82,3 @@ * '+created_date'

/**
* Fields added by the server to every entity record (id, dates, created_by, etc.).
* Fields added by the server to every entity record, such as `id`, `created_date`, `updated_date`, and `created_by`.
*/

@@ -97,4 +100,3 @@ interface ServerEntityFields {

/**
* Registry mapping entity names to their TypeScript types.
* Augment this interface with your entity schema (user-defined fields only).
* Registry mapping entity names to their TypeScript types. The [`types generate`](/developers/references/cli/commands/types-generate) command fills this registry, then [`EntityRecord`](#entityrecord) adds server fields.
*/

@@ -104,3 +106,20 @@ export interface EntityTypeRegistry {

/**
* Full record type for each entity: schema fields + server-injected fields (id, created_date, etc.).
* Combines the [`EntityTypeRegistry`](#entitytyperegistry) schemas with server fields like `id`, `created_date`, and `updated_date` to give the complete record type for each entity. Use this when you need to type variables holding entity data.
*
* @example
* ```typescript
* // Using EntityRecord to get the complete type for an entity
* // Combine your schema with server fields (id, created_date, etc.)
* type TaskRecord = EntityRecord['Task'];
*
* const task: TaskRecord = await base44.entities.Task.create({
* title: 'My task',
* status: 'pending'
* });
*
* // Task now includes both your fields and server fields:
* console.log(task.id); // Server field
* console.log(task.created_date); // Server field
* console.log(task.title); // Your field
* ```
*/

@@ -412,3 +431,3 @@ export type EntityRecord = {

*
* This module is available to use with a client in all three authentication modes:
* This module is available to use with a client in all authentication modes:
*

@@ -418,2 +437,10 @@ * - **Anonymous or User authentication** (`base44.entities`): Access is scoped to the current user's permissions. Anonymous users can only access public entities, while authenticated users can access entities they have permission to view or modify.

*
* ## Entity Handlers
*
* An entity handler is the object you get when you access an entity through `base44.entities.EntityName`. Every entity in your app automatically gets a handler with CRUD methods for managing records.
*
* For example, `base44.entities.Task` is an entity handler for Task records, and `base44.entities.User` is an entity handler for User records. Each handler provides methods like `list()`, `create()`, `update()`, and `delete()`.
*
* You don't need to instantiate or import entity handlers. They're automatically available for every entity you create in your app.
*
* ## Built-in User Entity

@@ -425,2 +452,6 @@ *

*
* ## Generated Types
*
* If you're working in a TypeScript project, you can generate types from your entity schemas to get autocomplete and type checking on all entity methods. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
*
* @example

@@ -427,0 +458,0 @@ * ```typescript

/**
* Registry of function names.
* Augment this interface to enable autocomplete for function names.
* 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.
*/

@@ -8,3 +7,10 @@ export interface FunctionNameRegistry {

/**
* Function name type - uses registry keys if augmented, otherwise string.
* Union of all function names from the [`FunctionNameRegistry`](#functionnameregistry). Defaults to `string` when no types have been generated.
*
* @example
* ```typescript
* // Using generated function name types
* // With generated types, you get autocomplete on function names
* await base44.functions.invoke('calculateTotal', { items: ['item1', 'item2'] });
* ```
*/

@@ -17,2 +23,4 @@ export type FunctionName = keyof FunctionNameRegistry extends never ? string : keyof FunctionNameRegistry;

*
* ## Authentication Modes
*
* This module is available to use with a client in all authentication modes:

@@ -22,2 +30,6 @@ *

* - **Service role authentication** (`base44.asServiceRole.functions`): Functions are invoked with elevated admin-level permissions. The function code receives a request with admin authentication context.
*
* ## Generated Types
*
* 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.
*/

@@ -42,3 +54,2 @@ export interface FunctionsModule {

* items: ['item1', 'item2'],
* discount: 0.1
* });

@@ -45,0 +56,0 @@ * console.log(result.data.total);

@@ -15,14 +15,21 @@ import { CustomIntegrationsModule } from "./custom-integrations.types.js";

*
* Provides dynamic access to integration endpoints within a package.
* Each endpoint is accessed as a property that returns a function to invoke it.
* An integration package is a collection of endpoint functions indexed by endpoint name.
* Both `Core` and `custom` are integration packages that implement this structure.
*
* @example
* @example **Core package**
* ```typescript
* // Access endpoints dynamically
* const result = await integrations.Core.SendEmail({
* to: 'user@example.com',
* subject: 'Hello',
* body: 'Message'
* await base44.integrations.Core.InvokeLLM({
* prompt: 'Explain quantum computing',
* model: 'gpt-4'
* });
* ```
*
* @example **custom package**
* ```typescript
* await base44.integrations.custom.call(
* 'github',
* 'get:/repos/{owner}/{repo}',
* { pathParams: { owner: 'myorg', repo: 'myrepo' } }
* );
* ```
*/

@@ -328,2 +335,4 @@ export type IntegrationPackage = {

*
* ## Integration Types
*
* There are two types of integrations:

@@ -336,3 +345,3 @@ *

*
* - **Custom integrations** (`custom`): Pre-configured external APIs. Custom integration calls are proxied through Base44's backend, so credentials are never exposed to the frontend. Access custom integration methods using:
* - **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:
* ```

@@ -342,4 +351,6 @@ * base44.integrations.custom.call(slug, operationId, params)

*
* <Info>To call a custom integration, it must be pre-configured by a workspace administrator who imports an OpenAPI specification.</Info>
* <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>
*
* ## Authentication Modes
*
* This module is available to use with a client in all authentication modes:

@@ -353,6 +364,23 @@ *

* Core package containing built-in Base44 integration functions.
*
* @example
* ```typescript
* const response = await base44.integrations.Core.InvokeLLM({
* prompt: 'Explain quantum computing',
* model: 'gpt-4'
* });
* ```
*/
Core: CoreIntegrations;
/**
* Custom integrations module for calling pre-configured external APIs.
* Workspace integrations module for calling pre-configured external APIs.
*
* @example
* ```typescript
* const result = await base44.integrations.custom.call(
* 'github',
* 'get:/repos/{owner}/{repo}',
* { pathParams: { owner: 'myorg', repo: 'myrepo' } }
* );
* ```
*/

@@ -364,6 +392,23 @@ custom: CustomIntegrationsModule;

*
* Additional integration packages may be added in the future and will be
* accessible using the same pattern as Core.
* Allows accessing integration packages as properties. This enables both `Core` and `custom` packages,
* as well as any future integration packages that may be added.
*
* @example **Use Core integrations**
* ```typescript
* const response = await base44.integrations.Core.InvokeLLM({
* prompt: 'Explain quantum computing',
* model: 'gpt-4'
* });
* ```
*
* @example **Use custom integrations**
* ```typescript
* const result = await base44.integrations.custom.call(
* 'github',
* 'get:/repos/{owner}/{repo}',
* { pathParams: { owner: 'myorg', repo: 'myrepo' } }
* );
* ```
*/
[packageName: string]: IntegrationPackage;
};
{
"name": "@base44/sdk",
"version": "0.8.19",
"version": "0.8.20",
"description": "JavaScript SDK for Base44 API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",