Skip to content

Commit e606f6d

Browse files
committed
cleanups
1 parent 375a874 commit e606f6d

File tree

3 files changed

+18
-99
lines changed

3 files changed

+18
-99
lines changed

src/modules/agents.types.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,12 @@ import { ModelFilterParams } from "../types.js";
44

55
/**
66
* Registry of agent names.
7-
*
8-
* This interface is designed to be augmented by generated type declaration files.
9-
* When augmented, it enables autocomplete for agent names in methods like `createConversation`.
10-
*
11-
* @example
12-
* ```typescript
13-
* // In your generated types.d.ts file:
14-
* declare module '@base44/sdk' {
15-
* interface AgentNameRegistry {
16-
* support_agent: true;
17-
* sales_bot: true;
18-
* }
19-
* }
20-
*
21-
* // Then in your code:
22-
* await base44.agents.createConversation({
23-
* agent_name: 'support_agent' // ✅ Autocomplete shows: 'support_agent' | 'sales_bot'
24-
* });
25-
* ```
7+
* Augmented by `base44 types generate` to enable autocomplete for agent names.
268
*/
279
export interface AgentNameRegistry {}
2810

2911
/**
30-
* Agent name type - uses registry keys if augmented, otherwise falls back to string.
12+
* Agent name type - uses registry keys if augmented, otherwise string.
3113
*/
3214
export type AgentName = keyof AgentNameRegistry extends never
3315
? string
@@ -165,7 +147,7 @@ export interface AgentMessage {
165147
* Parameters for creating a new conversation.
166148
*/
167149
export interface CreateConversationParams {
168-
/** The name of the agent to create a conversation with. When AgentNameRegistry is augmented, provides autocomplete. */
150+
/** The name of the agent to create a conversation with. */
169151
agent_name: AgentName;
170152
/** Optional metadata to attach to the conversation. */
171153
metadata?: Record<string, any>;
@@ -390,7 +372,7 @@ export interface AgentsModule {
390372
* Generates a URL that users can use to connect with the agent through WhatsApp.
391373
* The URL includes authentication if a token is available.
392374
*
393-
* @param agentName - The name of the agent. When AgentNameRegistry is augmented, provides autocomplete.
375+
* @param agentName - The name of the agent.
394376
* @returns WhatsApp connection URL.
395377
*
396378
* @example

src/modules/entities.types.ts

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export type RealtimeEventType = "create" | "update" | "delete";
55

66
/**
77
* Payload received when a realtime event occurs.
8-
*
9-
* @typeParam T - The entity type for the data field. Defaults to `any`.
10-
*/
8+
g */
119
export interface RealtimeEvent<T = any> {
1210
/** The type of change that occurred */
1311
type: RealtimeEventType;
@@ -21,8 +19,6 @@ export interface RealtimeEvent<T = any> {
2119

2220
/**
2321
* Callback function invoked when a realtime event occurs.
24-
*
25-
* @typeParam T - The entity type for the event data. Defaults to `any`.
2622
*/
2723
export type RealtimeCallback<T = any> = (event: RealtimeEvent<T>) => void;
2824

@@ -46,34 +42,18 @@ export interface DeleteManyResult {
4642

4743
/**
4844
* Result returned when importing entities from a file.
49-
*
50-
* @typeParam T - The entity type for imported records. Defaults to `any`.
5145
*/
5246
export interface ImportResult<T = any> {
5347
/** Status of the import operation */
5448
status: "success" | "error";
55-
/** Details message, e.g., "Successfully imported 3 entities with RLS enforcement" */
49+
/** Details message */
5650
details: string | null;
5751
/** Array of created entity objects when successful, or null on error */
5852
output: T[] | null;
5953
}
6054

6155
/**
62-
* Sort field type for entity queries.
63-
*
64-
* Supports ascending (no prefix or `'+'`) and descending (`'-'`) sorting.
65-
*
66-
* @typeParam T - The entity type to derive sortable fields from.
67-
*
68-
* @example
69-
* ```typescript
70-
* // Ascending sort (default)
71-
* 'created_date'
72-
* '+created_date'
73-
*
74-
* // Descending sort
75-
* '-created_date'
76-
* ```
56+
* Sort field for entity queries. Prefix with `-` for descending order.
7757
*/
7858
export type SortField<T> =
7959
| (keyof T & string)
@@ -82,35 +62,14 @@ export type SortField<T> =
8262

8363
/**
8464
* Registry mapping entity names to their TypeScript types.
85-
*
86-
* This interface is designed to be augmented by generated type declaration files.
87-
* When augmented, it enables type-safe entity access throughout your application.
88-
*
89-
* @example
90-
* ```typescript
91-
* // In your generated types.d.ts file:
92-
* declare module '@base44/sdk' {
93-
* interface EntityTypeRegistry {
94-
* Task: { title: string; completed: boolean };
95-
* User: { email: string; name: string };
96-
* }
97-
* }
98-
*
99-
* // Then in your code:
100-
* const task = await base44.entities.Task.create({
101-
* title: 'Buy groceries', // ✅ Type-checked
102-
* completed: false
103-
* });
104-
* ```
65+
* Augmented by `base44 types generate` to enable type-safe entity access.
10566
*/
10667
export interface EntityTypeRegistry {}
10768

10869
/**
10970
* Entity handler providing CRUD operations for a specific entity type.
11071
*
11172
* Each entity in the app gets a handler with these methods for managing data.
112-
*
113-
* @typeParam T - The entity type. Defaults to `any` for backward compatibility.
11473
*/
11574
export interface EntityHandler<T = any> {
11675
/**
@@ -121,12 +80,11 @@ export interface EntityHandler<T = any> {
12180
*
12281
* **Note:** The maximum limit is 5,000 items per request.
12382
*
124-
* @typeParam K - The fields to include in the response. Defaults to all fields.
12583
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
12684
* @param limit - Maximum number of results to return. Defaults to `50`.
12785
* @param skip - Number of results to skip for pagination. Defaults to `0`.
12886
* @param fields - Array of field names to include in the response. Defaults to all fields.
129-
* @returns Promise resolving to an array of records with selected fields.
87+
* @returns Promise resolving to an array of records.
13088
*
13189
* @example
13290
* ```typescript
@@ -168,15 +126,14 @@ export interface EntityHandler<T = any> {
168126
*
169127
* **Note:** The maximum limit is 5,000 items per request.
170128
*
171-
* @typeParam K - The fields to include in the response. Defaults to all fields.
172129
* @param query - Query object with field-value pairs. Each key should be a field name
173130
* from your entity schema, and each value is the criteria to match. Records matching all
174131
* specified criteria are returned. Field names are case-sensitive.
175132
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
176133
* @param limit - Maximum number of results to return. Defaults to `50`.
177134
* @param skip - Number of results to skip for pagination. Defaults to `0`.
178135
* @param fields - Array of field names to include in the response. Defaults to all fields.
179-
* @returns Promise resolving to an array of filtered records with selected fields.
136+
* @returns Promise resolving to an array of filtered records.
180137
*
181138
* @example
182139
* ```typescript
@@ -328,7 +285,7 @@ export interface EntityHandler<T = any> {
328285
* status: 'completed',
329286
* priority: 'low'
330287
* });
331-
* console.log('Deleted:', result);
288+
* console.log('Deleted:', result.deleted);
332289
* ```
333290
*/
334291
deleteMany(query: Partial<T>): Promise<DeleteManyResult>;
@@ -361,7 +318,7 @@ export interface EntityHandler<T = any> {
361318
* The file format should match your entity structure. Requires a browser environment and can't be used in the backend.
362319
*
363320
* @param file - File object to import.
364-
* @returns Promise resolving to the import result containing status, details, and created records.
321+
* @returns Promise resolving to the import result.
365322
*
366323
* @example
367324
* ```typescript
@@ -370,8 +327,8 @@ export interface EntityHandler<T = any> {
370327
* const file = event.target.files?.[0];
371328
* if (file) {
372329
* const result = await base44.entities.MyEntity.importEntities(file);
373-
* if (result.status === 'success' && result.output) {
374-
* console.log(`Imported ${result.output.length} records`);
330+
* if (result.status === 'success') {
331+
* console.log(`Imported ${result.output?.length} records`);
375332
* }
376333
* }
377334
* };
@@ -409,15 +366,13 @@ export interface EntityHandler<T = any> {
409366

410367
/**
411368
* Typed entities module - maps registry keys to typed handlers.
412-
* Only used when EntityTypeRegistry is augmented.
413369
*/
414370
type TypedEntitiesModule = {
415371
[K in keyof EntityTypeRegistry]: EntityHandler<EntityTypeRegistry[K]>;
416372
};
417373

418374
/**
419375
* Dynamic entities module - allows any entity name with untyped handler.
420-
* Used as fallback and for entities not in the registry.
421376
*/
422377
type DynamicEntitiesModule = {
423378
[entityName: string]: EntityHandler<any>;
@@ -432,7 +387,7 @@ type DynamicEntitiesModule = {
432387
* Entities are accessed dynamically using the pattern:
433388
* `base44.entities.EntityName.method()`
434389
*
435-
* When {@link EntityTypeRegistry} is augmented (via generated types.d.ts),
390+
* When {@link EntityTypeRegistry} is augmented (via `base44 types generate`),
436391
* entity access becomes type-safe with autocomplete and type checking.
437392
*
438393
* This module is available to use with a client in all three authentication modes:

src/modules/functions.types.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,11 @@
11
/**
22
* Registry of function names.
3-
*
4-
* This interface is designed to be augmented by generated type declaration files.
5-
* When augmented, it enables autocomplete for function names in the `invoke` method.
6-
*
7-
* @example
8-
* ```typescript
9-
* // In your generated types.d.ts file:
10-
* declare module '@base44/sdk' {
11-
* interface FunctionNameRegistry {
12-
* calculateTotal: true;
13-
* processImage: true;
14-
* }
15-
* }
16-
*
17-
* // Then in your code:
18-
* await base44.functions.invoke('calculateTotal', { ... });
19-
* // ^^^^^^^^^^^^^^^^
20-
* // ✅ Autocomplete shows: 'calculateTotal' | 'processImage'
21-
* ```
3+
* Augmented by `base44 types generate` to enable autocomplete for function names.
224
*/
235
export interface FunctionNameRegistry {}
246

257
/**
26-
* Function name type - uses registry keys if augmented, otherwise falls back to string.
8+
* Function name type - uses registry keys if augmented, otherwise string.
279
*/
2810
export type FunctionName = keyof FunctionNameRegistry extends never
2911
? string
@@ -48,7 +30,7 @@ export interface FunctionsModule {
4830
* the result. If any parameter is a `File` object, the request will automatically be
4931
* sent as `multipart/form-data`. Otherwise, it will be sent as JSON.
5032
*
51-
* @param functionName - The name of the function to invoke. When FunctionNameRegistry is augmented, provides autocomplete.
33+
* @param functionName - The name of the function to invoke.
5234
* @param data - An object containing named parameters for the function.
5335
* @returns Promise resolving to the function's response. The `data` property contains the data returned by the function, if there is any.
5436
*

0 commit comments

Comments
 (0)