@base44-preview/sdk 0.8.18-pr.108.d1f21b4 → 0.8.18-pr.116.3508d64

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.
@@ -26,9 +26,23 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
26
26
  throw new Error("Login method can only be used in a browser environment");
27
27
  }
28
28
  // If nextUrl is not provided, use the current URL
29
- const redirectUrl = nextUrl
29
+ let redirectUrl = nextUrl
30
30
  ? new URL(nextUrl, window.location.origin).toString()
31
31
  : window.location.href;
32
+ // Prevent redirect loops: if redirectUrl is already a login URL, extract the original from_url
33
+ try {
34
+ const parsedUrl = new URL(redirectUrl);
35
+ if (parsedUrl.pathname.endsWith("/login")) {
36
+ const originalFromUrl = parsedUrl.searchParams.get("from_url");
37
+ if (originalFromUrl) {
38
+ // Use the original destination instead of nesting login URLs
39
+ redirectUrl = originalFromUrl;
40
+ }
41
+ }
42
+ }
43
+ catch (_b) {
44
+ // If URL parsing fails, continue with the original redirectUrl
45
+ }
32
46
  // Build the login URL
33
47
  const loginUrl = `${(_a = options.appBaseUrl) !== null && _a !== void 0 ? _a : ""}/login?from_url=${encodeURIComponent(redirectUrl)}`;
34
48
  // Redirect to the login page
@@ -4,14 +4,12 @@
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`.
9
7
  */
10
- export interface RealtimeEvent<T = any> {
8
+ export interface RealtimeEvent {
11
9
  /** The type of change that occurred */
12
10
  type: RealtimeEventType;
13
11
  /** The entity data */
14
- data: T;
12
+ data: any;
15
13
  /** The unique identifier of the affected entity */
16
14
  id: string;
17
15
  /** ISO 8601 timestamp of when the event occurred */
@@ -19,34 +17,14 @@ export interface RealtimeEvent<T = any> {
19
17
  }
20
18
  /**
21
19
  * Callback function invoked when a realtime event occurs.
22
- *
23
- * @typeParam T - The entity type for the event data. Defaults to `any`.
24
- */
25
- export type RealtimeCallback<T = any> = (event: RealtimeEvent<T>) => void;
26
- /**
27
- * Result returned when deleting a single entity.
28
- */
29
- export interface DeleteResult {
30
- /** Whether the deletion was successful */
31
- success: boolean;
32
- }
33
- /**
34
- * Result returned when deleting multiple entities.
35
20
  */
36
- export interface DeleteManyResult {
37
- /** Whether the deletion was successful */
38
- success: boolean;
39
- /** Number of entities that were deleted */
40
- deleted: number;
41
- }
21
+ export type RealtimeCallback = (event: RealtimeEvent) => void;
42
22
  /**
43
23
  * Entity handler providing CRUD operations for a specific entity type.
44
24
  *
45
25
  * Each entity in the app gets a handler with these methods for managing data.
46
- *
47
- * @typeParam T - The entity type. Defaults to `any` for backward compatibility.
48
26
  */
49
- export interface EntityHandler<T = any> {
27
+ export interface EntityHandler {
50
28
  /**
51
29
  * Lists records with optional pagination and sorting.
52
30
  *
@@ -86,7 +64,7 @@ export interface EntityHandler<T = any> {
86
64
  * const fields = await base44.entities.MyEntity.list('-created_date', 10, 0, ['name', 'status']);
87
65
  * ```
88
66
  */
89
- list(sort?: string, limit?: number, skip?: number, fields?: string[]): Promise<T[]>;
67
+ list(sort?: string, limit?: number, skip?: number, fields?: string[]): Promise<any>;
90
68
  /**
91
69
  * Filters records based on a query.
92
70
  *
@@ -144,7 +122,7 @@ export interface EntityHandler<T = any> {
144
122
  * );
145
123
  * ```
146
124
  */
147
- filter(query: Partial<T>, sort?: string, limit?: number, skip?: number, fields?: string[]): Promise<T[]>;
125
+ filter(query: Record<string, any>, sort?: string, limit?: number, skip?: number, fields?: string[]): Promise<any>;
148
126
  /**
149
127
  * Gets a single record by ID.
150
128
  *
@@ -160,7 +138,7 @@ export interface EntityHandler<T = any> {
160
138
  * console.log(record.name);
161
139
  * ```
162
140
  */
163
- get(id: string): Promise<T>;
141
+ get(id: string): Promise<any>;
164
142
  /**
165
143
  * Creates a new record.
166
144
  *
@@ -180,7 +158,7 @@ export interface EntityHandler<T = any> {
180
158
  * console.log('Created record with ID:', newRecord.id);
181
159
  * ```
182
160
  */
183
- create(data: Partial<T>): Promise<T>;
161
+ create(data: Record<string, any>): Promise<any>;
184
162
  /**
185
163
  * Updates an existing record.
186
164
  *
@@ -209,7 +187,7 @@ export interface EntityHandler<T = any> {
209
187
  * });
210
188
  * ```
211
189
  */
212
- update(id: string, data: Partial<T>): Promise<T>;
190
+ update(id: string, data: Record<string, any>): Promise<any>;
213
191
  /**
214
192
  * Deletes a single record by ID.
215
193
  *
@@ -222,10 +200,10 @@ export interface EntityHandler<T = any> {
222
200
  * ```typescript
223
201
  * // Delete a record
224
202
  * const result = await base44.entities.MyEntity.delete('entity-123');
225
- * console.log('Deleted:', result.success);
203
+ * console.log('Deleted:', result);
226
204
  * ```
227
205
  */
228
- delete(id: string): Promise<DeleteResult>;
206
+ delete(id: string): Promise<any>;
229
207
  /**
230
208
  * Deletes multiple records matching a query.
231
209
  *
@@ -246,7 +224,7 @@ export interface EntityHandler<T = any> {
246
224
  * console.log('Deleted:', result);
247
225
  * ```
248
226
  */
249
- deleteMany(query: Partial<T>): Promise<DeleteManyResult>;
227
+ deleteMany(query: Record<string, any>): Promise<any>;
250
228
  /**
251
229
  * Creates multiple records in a single request.
252
230
  *
@@ -266,7 +244,7 @@ export interface EntityHandler<T = any> {
266
244
  * ]);
267
245
  * ```
268
246
  */
269
- bulkCreate(data: Partial<T>[]): Promise<T[]>;
247
+ bulkCreate(data: Record<string, any>[]): Promise<any>;
270
248
  /**
271
249
  * Imports records from a file.
272
250
  *
@@ -314,7 +292,7 @@ export interface EntityHandler<T = any> {
314
292
  * unsubscribe();
315
293
  * ```
316
294
  */
317
- subscribe(callback: RealtimeCallback<T>): () => void;
295
+ subscribe(callback: RealtimeCallback): () => void;
318
296
  }
319
297
  /**
320
298
  * Entities module for managing app data.
@@ -362,5 +340,5 @@ export interface EntitiesModule {
362
340
  * base44.entities.AnotherEntity
363
341
  * ```
364
342
  */
365
- [entityName: string]: EntityHandler<any>;
343
+ [entityName: string]: EntityHandler;
366
344
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.18-pr.108.d1f21b4",
3
+ "version": "0.8.18-pr.116.3508d64",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",