@base44-preview/sdk 0.8.18-pr.117.7c9cdfc → 0.8.18-pr.117.84e1a4f
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.
|
@@ -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)
|
|
@@ -72,6 +80,8 @@ export interface EntityTypeRegistry {
|
|
|
72
80
|
* Entity handler providing CRUD operations for a specific entity type.
|
|
73
81
|
*
|
|
74
82
|
* Each entity in the app gets a handler with these methods for managing data.
|
|
83
|
+
*
|
|
84
|
+
* @typeParam T - The entity type. Defaults to `any` for backward compatibility.
|
|
75
85
|
*/
|
|
76
86
|
export interface EntityHandler<T = any> {
|
|
77
87
|
/**
|
|
@@ -82,11 +92,12 @@ export interface EntityHandler<T = any> {
|
|
|
82
92
|
*
|
|
83
93
|
* **Note:** The maximum limit is 5,000 items per request.
|
|
84
94
|
*
|
|
95
|
+
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
85
96
|
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
|
|
86
97
|
* @param limit - Maximum number of results to return. Defaults to `50`.
|
|
87
98
|
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
88
99
|
* @param fields - Array of field names to include in the response. Defaults to all fields.
|
|
89
|
-
* @returns Promise resolving to an array of records.
|
|
100
|
+
* @returns Promise resolving to an array of records with selected fields.
|
|
90
101
|
*
|
|
91
102
|
* @example
|
|
92
103
|
* ```typescript
|
|
@@ -122,6 +133,7 @@ export interface EntityHandler<T = any> {
|
|
|
122
133
|
*
|
|
123
134
|
* **Note:** The maximum limit is 5,000 items per request.
|
|
124
135
|
*
|
|
136
|
+
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
125
137
|
* @param query - Query object with field-value pairs. Each key should be a field name
|
|
126
138
|
* from your entity schema, and each value is the criteria to match. Records matching all
|
|
127
139
|
* specified criteria are returned. Field names are case-sensitive.
|
|
@@ -129,7 +141,7 @@ export interface EntityHandler<T = any> {
|
|
|
129
141
|
* @param limit - Maximum number of results to return. Defaults to `50`.
|
|
130
142
|
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
131
143
|
* @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.
|
|
144
|
+
* @returns Promise resolving to an array of filtered records with selected fields.
|
|
133
145
|
*
|
|
134
146
|
* @example
|
|
135
147
|
* ```typescript
|
|
@@ -301,7 +313,7 @@ export interface EntityHandler<T = any> {
|
|
|
301
313
|
* The file format should match your entity structure. Requires a browser environment and can't be used in the backend.
|
|
302
314
|
*
|
|
303
315
|
* @param file - File object to import.
|
|
304
|
-
* @returns Promise resolving to the import result.
|
|
316
|
+
* @returns Promise resolving to the import result containing status, details, and created records.
|
|
305
317
|
*
|
|
306
318
|
* @example
|
|
307
319
|
* ```typescript
|
|
@@ -310,7 +322,7 @@ export interface EntityHandler<T = any> {
|
|
|
310
322
|
* const file = event.target.files?.[0];
|
|
311
323
|
* if (file) {
|
|
312
324
|
* const result = await base44.entities.MyEntity.importEntities(file);
|
|
313
|
-
* if (result.status === 'success') {
|
|
325
|
+
* if (result.status === 'success' && result.output) {
|
|
314
326
|
* console.log(`Imported ${result.output?.length} records`);
|
|
315
327
|
* }
|
|
316
328
|
* }
|