@@ -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+ */
911export 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 */
2327export 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 */
4652export 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 */
5878export 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 */
6787export 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 */
7496export 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.
0 commit comments