Skip to content

Commit f22dde7

Browse files
committed
align comments
1 parent e606f6d commit f22dde7

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

src/modules/agents.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ModelFilterParams } from "../types.js";
44

55
/**
66
* Registry of agent names.
7-
* Augmented by `base44 types generate` to enable autocomplete for agent names.
7+
* Augment this interface to enable autocomplete for agent names.
88
*/
99
export interface AgentNameRegistry {}
1010

src/modules/entities.types.ts

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

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

2022
/**
2123
* Callback function invoked when a realtime event occurs.
24+
*
25+
* @typeParam T - The entity type for the event data. Defaults to `any`.
2226
*/
2327
export type RealtimeCallback<T = any> = (event: RealtimeEvent<T>) => void;
2428

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

4347
/**
4448
* Result returned when importing entities from a file.
49+
*
50+
* @typeParam T - The entity type for imported records. Defaults to `any`.
4551
*/
4652
export interface ImportResult<T = any> {
4753
/** Status of the import operation */
4854
status: "success" | "error";
49-
/** Details message */
55+
/** Details message, e.g., "Successfully imported 3 entities with RLS enforcement" */
5056
details: string | null;
5157
/** Array of created entity objects when successful, or null on error */
5258
output: T[] | null;
5359
}
5460

5561
/**
56-
* Sort field for entity queries. Prefix with `-` for descending order.
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+
* ```
5777
*/
5878
export type SortField<T> =
5979
| (keyof T & string)
@@ -62,14 +82,16 @@ export type SortField<T> =
6282

6383
/**
6484
* Registry mapping entity names to their TypeScript types.
65-
* Augmented by `base44 types generate` to enable type-safe entity access.
85+
* Augment this interface to enable type-safe entity access.
6686
*/
6787
export interface EntityTypeRegistry {}
6888

6989
/**
7090
* Entity handler providing CRUD operations for a specific entity type.
7191
*
7292
* Each entity in the app gets a handler with these methods for managing data.
93+
*
94+
* @typeParam T - The entity type. Defaults to `any` for backward compatibility.
7395
*/
7496
export interface EntityHandler<T = any> {
7597
/**
@@ -80,11 +102,12 @@ export interface EntityHandler<T = any> {
80102
*
81103
* **Note:** The maximum limit is 5,000 items per request.
82104
*
105+
* @typeParam K - The fields to include in the response. Defaults to all fields.
83106
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
84107
* @param limit - Maximum number of results to return. Defaults to `50`.
85108
* @param skip - Number of results to skip for pagination. Defaults to `0`.
86109
* @param fields - Array of field names to include in the response. Defaults to all fields.
87-
* @returns Promise resolving to an array of records.
110+
* @returns Promise resolving to an array of records with selected fields.
88111
*
89112
* @example
90113
* ```typescript
@@ -126,14 +149,15 @@ export interface EntityHandler<T = any> {
126149
*
127150
* **Note:** The maximum limit is 5,000 items per request.
128151
*
152+
* @typeParam K - The fields to include in the response. Defaults to all fields.
129153
* @param query - Query object with field-value pairs. Each key should be a field name
130154
* from your entity schema, and each value is the criteria to match. Records matching all
131155
* specified criteria are returned. Field names are case-sensitive.
132156
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
133157
* @param limit - Maximum number of results to return. Defaults to `50`.
134158
* @param skip - Number of results to skip for pagination. Defaults to `0`.
135159
* @param fields - Array of field names to include in the response. Defaults to all fields.
136-
* @returns Promise resolving to an array of filtered records.
160+
* @returns Promise resolving to an array of filtered records with selected fields.
137161
*
138162
* @example
139163
* ```typescript
@@ -318,7 +342,7 @@ export interface EntityHandler<T = any> {
318342
* The file format should match your entity structure. Requires a browser environment and can't be used in the backend.
319343
*
320344
* @param file - File object to import.
321-
* @returns Promise resolving to the import result.
345+
* @returns Promise resolving to the import result containing status, details, and created records.
322346
*
323347
* @example
324348
* ```typescript
@@ -327,7 +351,7 @@ export interface EntityHandler<T = any> {
327351
* const file = event.target.files?.[0];
328352
* if (file) {
329353
* const result = await base44.entities.MyEntity.importEntities(file);
330-
* if (result.status === 'success') {
354+
* if (result.status === 'success' && result.output) {
331355
* console.log(`Imported ${result.output?.length} records`);
332356
* }
333357
* }
@@ -387,9 +411,6 @@ type DynamicEntitiesModule = {
387411
* Entities are accessed dynamically using the pattern:
388412
* `base44.entities.EntityName.method()`
389413
*
390-
* When {@link EntityTypeRegistry} is augmented (via `base44 types generate`),
391-
* entity access becomes type-safe with autocomplete and type checking.
392-
*
393414
* This module is available to use with a client in all three authentication modes:
394415
*
395416
* - **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.

src/modules/functions.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Registry of function names.
3-
* Augmented by `base44 types generate` to enable autocomplete for function names.
3+
* Augment this interface to enable autocomplete for function names.
44
*/
55
export interface FunctionNameRegistry {}
66

0 commit comments

Comments
 (0)