@base44-preview/sdk 0.8.18-pr.117.7c9cdfc → 0.8.18-pr.119.d115eb9

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/README.md CHANGED
@@ -9,31 +9,32 @@ You can use it in two ways:
9
9
 
10
10
  ## Installation
11
11
 
12
- Install the SDK via npm:
12
+ **Inside Base44 apps**: The SDK is already available. No installation needed.
13
+
14
+ **External apps**: Install the SDK via npm:
13
15
 
14
16
  ```bash
15
17
  npm install @base44/sdk
16
18
  ```
17
19
 
18
- > **Note**: In Base44-generated apps, the SDK is already installed for you.
19
-
20
20
  ## Modules
21
21
 
22
22
  The SDK provides access to Base44's functionality through the following modules:
23
23
 
24
24
  - **[`agents`](https://docs.base44.com/developers/references/sdk/docs/interfaces/agents)**: Interact with AI agents and manage conversations.
25
+ - **[`analytics`](https://docs.base44.com/developers/references/sdk/docs/interfaces/analytics)**: Track custom events in your app.
25
26
  - **[`app-logs`](https://docs.base44.com/developers/references/sdk/docs/interfaces/app-logs)**: Access and query app logs.
26
27
  - **[`auth`](https://docs.base44.com/developers/references/sdk/docs/interfaces/auth)**: Manage user authentication, registration, and session handling.
27
28
  - **[`connectors`](https://docs.base44.com/developers/references/sdk/docs/interfaces/connectors)**: Manage OAuth connections and access tokens for third-party services.
28
29
  - **[`entities`](https://docs.base44.com/developers/references/sdk/docs/interfaces/entities)**: Work with your app's data entities using CRUD operations.
29
30
  - **[`functions`](https://docs.base44.com/developers/references/sdk/docs/interfaces/functions)**: Execute backend functions.
30
- - **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Pre-built integrations for external services.
31
+ - **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Access pre-built and third-party integrations.
31
32
 
32
- ## Quick starts
33
+ ## Quickstarts
33
34
 
34
- How you get started depends on your context:
35
+ How you get started depends on whether you're working inside a Base44-generated app or building your own.
35
36
 
36
- ### Inside a Base44 app
37
+ ### Inside Base44 apps
37
38
 
38
39
  In Base44-generated apps, the client is pre-configured. Just import and use it:
39
40
 
@@ -58,32 +59,32 @@ const tasks = await base44.entities.Task.list();
58
59
 
59
60
  ### External apps
60
61
 
61
- When using Base44 as a backend for your own app, create and configure the client yourself:
62
+ When using Base44 as a backend for your own app, install the SDK and create the client yourself:
62
63
 
63
64
  ```typescript
64
- import { createClient } from '@base44/sdk';
65
+ import { createClient } from "@base44/sdk";
65
66
 
66
67
  // Create a client for your Base44 app
67
68
  const base44 = createClient({
68
- appId: 'your-app-id' // Find this in the Base44 editor URL
69
+ appId: "your-app-id", // Find this in the Base44 editor URL
69
70
  });
70
71
 
71
- // Read public data (anonymous access)
72
+ // Read public data
72
73
  const products = await base44.entities.Products.list();
73
74
 
74
75
  // Authenticate a user (token is automatically set)
75
- await base44.auth.loginViaEmailPassword('user@example.com', 'password');
76
+ await base44.auth.loginViaEmailPassword("user@example.com", "password");
76
77
 
77
- // Now operations use the authenticated user's permissions
78
+ // Access user's data
78
79
  const userOrders = await base44.entities.Orders.list();
79
80
  ```
80
81
 
81
82
  ### Service role
82
83
 
83
- For backend code that needs admin-level access, use the service role. Service role is only available in Base44-hosted backend functions:
84
+ By default, the client operates with user-level permissions, limiting access to what the current user can see and do. The service role provides elevated permissions for backend operations and is only available in Base44-hosted backend functions. External backends can't use service role permissions.
84
85
 
85
86
  ```typescript
86
- import { createClientFromRequest } from 'npm:@base44/sdk';
87
+ import { createClientFromRequest } from "npm:@base44/sdk";
87
88
 
88
89
  Deno.serve(async (req) => {
89
90
  const base44 = createClientFromRequest(req);
@@ -97,7 +98,15 @@ Deno.serve(async (req) => {
97
98
 
98
99
  ## Learn more
99
100
 
100
- For complete documentation, guides, and API reference, visit the **[Base44 SDK Documentation](https://docs.base44.com/developers/landing)**.
101
+ The best way to get started with the JavaScript SDK is to have Base44 build an app for you. Once you have an app, you can explore the generated code and experiment with the SDK to see how it works in practice. You can also ask Base44 to demonstrate specific features of the SDK.
102
+
103
+ For a deeper understanding, check out these guides:
104
+
105
+ 1. [Base44 client](https://docs.base44.com/developers/references/sdk/getting-started/client) - Work with the client in frontend, backend, and external app contexts.
106
+ 2. [Work with data](https://docs.base44.com/developers/references/sdk/getting-started/work-with-data) - Create, read, update, and delete data.
107
+ 3. [Common SDK patterns](https://docs.base44.com/developers/references/sdk/getting-started/work-with-sdk) - Authentication, integrations, functions, and error handling.
108
+
109
+ For the complete documentation and API reference, visit the **[Base44 Developer Docs](https://docs.base44.com/developers/home)**.
101
110
 
102
111
  ## Development
103
112
 
package/dist/index.d.ts CHANGED
@@ -4,11 +4,11 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
4
4
  export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
5
5
  export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
6
6
  export * from "./types.js";
7
- export type { EntitiesModule, EntityHandler, EntityTypeRegistry, RealtimeEventType, RealtimeEvent, RealtimeCallback, } from "./modules/entities.types.js";
7
+ export type { EntitiesModule, EntityHandler, RealtimeEventType, RealtimeEvent, RealtimeCallback, } from "./modules/entities.types.js";
8
8
  export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
9
9
  export type { IntegrationsModule, IntegrationPackage, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
10
- export type { FunctionsModule, FunctionNameRegistry, } from "./modules/functions.types.js";
11
- export type { AgentsModule, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
10
+ export type { FunctionsModule } from "./modules/functions.types.js";
11
+ export type { AgentsModule, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
12
12
  export type { AppLogsModule } from "./modules/app-logs.types.js";
13
13
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
14
14
  export type { ConnectorsModule } from "./modules/connectors.types.js";
@@ -1,16 +1,6 @@
1
1
  import { AxiosInstance } from "axios";
2
2
  import { RoomsSocket } from "../utils/socket-utils.js";
3
3
  import { ModelFilterParams } from "../types.js";
4
- /**
5
- * Registry of agent names.
6
- * Augment this interface to enable autocomplete for agent names.
7
- */
8
- export interface AgentNameRegistry {
9
- }
10
- /**
11
- * Agent name type - uses registry keys if augmented, otherwise string.
12
- */
13
- export type AgentName = keyof AgentNameRegistry extends never ? string : keyof AgentNameRegistry;
14
4
  /**
15
5
  * Reasoning information for an agent message.
16
6
  *
@@ -137,7 +127,7 @@ export interface AgentMessage {
137
127
  */
138
128
  export interface CreateConversationParams {
139
129
  /** The name of the agent to create a conversation with. */
140
- agent_name: AgentName;
130
+ agent_name: string;
141
131
  /** Optional metadata to attach to the conversation. */
142
132
  metadata?: Record<string, any>;
143
133
  }
@@ -352,5 +342,5 @@ export interface AgentsModule {
352
342
  * // User can open this URL to start a WhatsApp conversation
353
343
  * ```
354
344
  */
355
- getWhatsAppConnectURL(agentName: AgentName): string;
345
+ getWhatsAppConnectURL(agentName: string): string;
356
346
  }
@@ -4,6 +4,8 @@
4
4
  export type RealtimeEventType = "create" | "update" | "delete";
5
5
  /**
6
6
  * Payload received when a realtime event occurs.
7
+ *
8
+ * @typeParam T - The entity type for the data field. Defaults to `any`.
7
9
  */
8
10
  export interface RealtimeEvent<T = any> {
9
11
  /** The type of change that occurred */
@@ -17,6 +19,8 @@ export interface RealtimeEvent<T = any> {
17
19
  }
18
20
  /**
19
21
  * Callback function invoked when a realtime event occurs.
22
+ *
23
+ * @typeParam T - The entity type for the event data. Defaults to `any`.
20
24
  */
21
25
  export type RealtimeCallback<T = any> = (event: RealtimeEvent<T>) => void;
22
26
  /**
@@ -37,11 +41,13 @@ export interface DeleteManyResult {
37
41
  }
38
42
  /**
39
43
  * Result returned when importing entities from a file.
44
+ *
45
+ * @typeParam T - The entity type for imported records. Defaults to `any`.
40
46
  */
41
47
  export interface ImportResult<T = any> {
42
48
  /** Status of the import operation */
43
49
  status: "success" | "error";
44
- /** Details message */
50
+ /** Details message, e.g., "Successfully imported 3 entities with RLS enforcement" */
45
51
  details: string | null;
46
52
  /** Array of created entity objects when successful, or null on error */
47
53
  output: T[] | null;
@@ -51,6 +57,8 @@ export interface ImportResult<T = any> {
51
57
  *
52
58
  * Supports ascending (no prefix or `'+'`) and descending (`'-'`) sorting.
53
59
  *
60
+ * @typeParam T - The entity type to derive sortable fields from.
61
+ *
54
62
  * @example
55
63
  * ```typescript
56
64
  * // Ascending sort (default)
@@ -62,16 +70,12 @@ export interface ImportResult<T = any> {
62
70
  * ```
63
71
  */
64
72
  export type SortField<T> = (keyof T & string) | `+${keyof T & string}` | `-${keyof T & string}`;
65
- /**
66
- * Registry mapping entity names to their TypeScript types.
67
- * Augment this interface to enable type-safe entity access.
68
- */
69
- export interface EntityTypeRegistry {
70
- }
71
73
  /**
72
74
  * Entity handler providing CRUD operations for a specific entity type.
73
75
  *
74
76
  * Each entity in the app gets a handler with these methods for managing data.
77
+ *
78
+ * @typeParam T - The entity type. Defaults to `any` for backward compatibility.
75
79
  */
76
80
  export interface EntityHandler<T = any> {
77
81
  /**
@@ -82,11 +86,12 @@ export interface EntityHandler<T = any> {
82
86
  *
83
87
  * **Note:** The maximum limit is 5,000 items per request.
84
88
  *
89
+ * @typeParam K - The fields to include in the response. Defaults to all fields.
85
90
  * @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
86
91
  * @param limit - Maximum number of results to return. Defaults to `50`.
87
92
  * @param skip - Number of results to skip for pagination. Defaults to `0`.
88
93
  * @param fields - Array of field names to include in the response. Defaults to all fields.
89
- * @returns Promise resolving to an array of records.
94
+ * @returns Promise resolving to an array of records with selected fields.
90
95
  *
91
96
  * @example
92
97
  * ```typescript
@@ -122,6 +127,7 @@ export interface EntityHandler<T = any> {
122
127
  *
123
128
  * **Note:** The maximum limit is 5,000 items per request.
124
129
  *
130
+ * @typeParam K - The fields to include in the response. Defaults to all fields.
125
131
  * @param query - Query object with field-value pairs. Each key should be a field name
126
132
  * from your entity schema, and each value is the criteria to match. Records matching all
127
133
  * specified criteria are returned. Field names are case-sensitive.
@@ -129,7 +135,7 @@ export interface EntityHandler<T = any> {
129
135
  * @param limit - Maximum number of results to return. Defaults to `50`.
130
136
  * @param skip - Number of results to skip for pagination. Defaults to `0`.
131
137
  * @param fields - Array of field names to include in the response. Defaults to all fields.
132
- * @returns Promise resolving to an array of filtered records.
138
+ * @returns Promise resolving to an array of filtered records with selected fields.
133
139
  *
134
140
  * @example
135
141
  * ```typescript
@@ -270,7 +276,7 @@ export interface EntityHandler<T = any> {
270
276
  * status: 'completed',
271
277
  * priority: 'low'
272
278
  * });
273
- * console.log('Deleted:', result.deleted);
279
+ * console.log('Deleted:', result);
274
280
  * ```
275
281
  */
276
282
  deleteMany(query: Partial<T>): Promise<DeleteManyResult>;
@@ -301,7 +307,7 @@ export interface EntityHandler<T = any> {
301
307
  * The file format should match your entity structure. Requires a browser environment and can't be used in the backend.
302
308
  *
303
309
  * @param file - File object to import.
304
- * @returns Promise resolving to the import result.
310
+ * @returns Promise resolving to the import result containing status, details, and created records.
305
311
  *
306
312
  * @example
307
313
  * ```typescript
@@ -310,8 +316,8 @@ export interface EntityHandler<T = any> {
310
316
  * const file = event.target.files?.[0];
311
317
  * if (file) {
312
318
  * const result = await base44.entities.MyEntity.importEntities(file);
313
- * if (result.status === 'success') {
314
- * console.log(`Imported ${result.output?.length} records`);
319
+ * if (result.status === 'success' && result.output) {
320
+ * console.log(`Imported ${result.output.length} records`);
315
321
  * }
316
322
  * }
317
323
  * };
@@ -345,18 +351,6 @@ export interface EntityHandler<T = any> {
345
351
  */
346
352
  subscribe(callback: RealtimeCallback<T>): () => void;
347
353
  }
348
- /**
349
- * Typed entities module - maps registry keys to typed handlers.
350
- */
351
- type TypedEntitiesModule = {
352
- [K in keyof EntityTypeRegistry]: EntityHandler<EntityTypeRegistry[K]>;
353
- };
354
- /**
355
- * Dynamic entities module - allows any entity name with untyped handler.
356
- */
357
- type DynamicEntitiesModule = {
358
- [entityName: string]: EntityHandler<any>;
359
- };
360
354
  /**
361
355
  * Entities module for managing app data.
362
356
  *
@@ -390,5 +384,18 @@ type DynamicEntitiesModule = {
390
384
  * const allUsers = await base44.asServiceRole.entities.User.list();
391
385
  * ```
392
386
  */
393
- export type EntitiesModule = TypedEntitiesModule & DynamicEntitiesModule;
394
- export {};
387
+ export interface EntitiesModule {
388
+ /**
389
+ * Access any entity by name.
390
+ *
391
+ * Use this to access entities defined in the app.
392
+ *
393
+ * @example
394
+ * ```typescript
395
+ * // Access entities dynamically
396
+ * base44.entities.MyEntity
397
+ * base44.entities.AnotherEntity
398
+ * ```
399
+ */
400
+ [entityName: string]: EntityHandler<any>;
401
+ }
@@ -1,13 +1,3 @@
1
- /**
2
- * Registry of function names.
3
- * Augment this interface to enable autocomplete for function names.
4
- */
5
- export interface FunctionNameRegistry {
6
- }
7
- /**
8
- * Function name type - uses registry keys if augmented, otherwise string.
9
- */
10
- export type FunctionName = keyof FunctionNameRegistry extends never ? string : keyof FunctionNameRegistry;
11
1
  /**
12
2
  * Functions module for invoking custom backend functions.
13
3
  *
@@ -56,5 +46,5 @@ export interface FunctionsModule {
56
46
  * };
57
47
  * ```
58
48
  */
59
- invoke(functionName: FunctionName, data?: Record<string, any>): Promise<any>;
49
+ invoke(functionName: string, data: Record<string, any>): Promise<any>;
60
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.18-pr.117.7c9cdfc",
3
+ "version": "0.8.18-pr.119.d115eb9",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",