@base44-preview/sdk 0.8.18-pr.117.84e1a4f → 0.8.18-pr.117.d56cb92
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 +25 -16
- package/dist/index.d.ts +1 -1
- package/dist/modules/entities.types.d.ts +28 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,31 +9,32 @@ You can use it in two ways:
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
|
|
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)**:
|
|
31
|
+
- **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Access pre-built and third-party integrations.
|
|
31
32
|
|
|
32
|
-
##
|
|
33
|
+
## Quickstarts
|
|
33
34
|
|
|
34
|
-
How you get started depends on your
|
|
35
|
+
How you get started depends on whether you're working inside a Base44-generated app or building your own.
|
|
35
36
|
|
|
36
|
-
### Inside
|
|
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,
|
|
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
|
|
65
|
+
import { createClient } from "@base44/sdk";
|
|
65
66
|
|
|
66
67
|
// Create a client for your Base44 app
|
|
67
68
|
const base44 = createClient({
|
|
68
|
-
appId:
|
|
69
|
+
appId: "your-app-id", // Find this in the Base44 editor URL
|
|
69
70
|
});
|
|
70
71
|
|
|
71
|
-
// Read public data
|
|
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(
|
|
76
|
+
await base44.auth.loginViaEmailPassword("user@example.com", "password");
|
|
76
77
|
|
|
77
|
-
//
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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,7 +4,7 @@ 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, EntityRecord, EntityTypeRegistry, 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
10
|
export type { FunctionsModule, FunctionNameRegistry, } from "./modules/functions.types.js";
|
|
@@ -70,12 +70,36 @@ export interface ImportResult<T = any> {
|
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
export type SortField<T> = (keyof T & string) | `+${keyof T & string}` | `-${keyof T & string}`;
|
|
73
|
+
/**
|
|
74
|
+
* Fields added by the server to every entity record (id, dates, created_by, etc.).
|
|
75
|
+
*/
|
|
76
|
+
export interface ServerEntityFields {
|
|
77
|
+
/** Unique identifier of the record */
|
|
78
|
+
id: string;
|
|
79
|
+
/** ISO 8601 timestamp when the record was created */
|
|
80
|
+
created_date: string;
|
|
81
|
+
/** ISO 8601 timestamp when the record was last updated */
|
|
82
|
+
updated_date: string;
|
|
83
|
+
/** Email of the user who created the record (may be hidden in some responses) */
|
|
84
|
+
created_by?: string | null;
|
|
85
|
+
/** ID of the user who created the record */
|
|
86
|
+
created_by_id?: string | null;
|
|
87
|
+
/** Whether the record is sample/seed data */
|
|
88
|
+
is_sample?: boolean;
|
|
89
|
+
}
|
|
73
90
|
/**
|
|
74
91
|
* Registry mapping entity names to their TypeScript types.
|
|
75
|
-
* Augment this interface
|
|
92
|
+
* Augment this interface with your entity schema (user-defined fields only).
|
|
76
93
|
*/
|
|
77
94
|
export interface EntityTypeRegistry {
|
|
78
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Full record type for each entity: schema fields + server-injected fields (id, created_date, etc.).
|
|
98
|
+
* Use for state that holds results of list()/get(), e.g. `useState<EntityRecord['Task']>([])`.
|
|
99
|
+
*/
|
|
100
|
+
export type EntityRecord = {
|
|
101
|
+
[K in keyof EntityTypeRegistry]: EntityTypeRegistry[K] & ServerEntityFields;
|
|
102
|
+
};
|
|
79
103
|
/**
|
|
80
104
|
* Entity handler providing CRUD operations for a specific entity type.
|
|
81
105
|
*
|
|
@@ -323,7 +347,7 @@ export interface EntityHandler<T = any> {
|
|
|
323
347
|
* if (file) {
|
|
324
348
|
* const result = await base44.entities.MyEntity.importEntities(file);
|
|
325
349
|
* if (result.status === 'success' && result.output) {
|
|
326
|
-
* console.log(`Imported ${result.output
|
|
350
|
+
* console.log(`Imported ${result.output.length} records`);
|
|
327
351
|
* }
|
|
328
352
|
* }
|
|
329
353
|
* };
|
|
@@ -358,10 +382,10 @@ export interface EntityHandler<T = any> {
|
|
|
358
382
|
subscribe(callback: RealtimeCallback<T>): () => void;
|
|
359
383
|
}
|
|
360
384
|
/**
|
|
361
|
-
* Typed entities module - maps registry keys to typed handlers.
|
|
385
|
+
* Typed entities module - maps registry keys to typed handlers (full record type).
|
|
362
386
|
*/
|
|
363
387
|
type TypedEntitiesModule = {
|
|
364
|
-
[K in keyof EntityTypeRegistry]: EntityHandler<
|
|
388
|
+
[K in keyof EntityTypeRegistry]: EntityHandler<EntityRecord[K]>;
|
|
365
389
|
};
|
|
366
390
|
/**
|
|
367
391
|
* Dynamic entities module - allows any entity name with untyped handler.
|