@base44-preview/sdk 0.8.5-pr.52.e60528e → 0.8.6-pr.48.d625f02

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.
Files changed (52) hide show
  1. package/dist/client.d.ts +90 -237
  2. package/dist/client.js +141 -25
  3. package/dist/client.types.d.ts +131 -0
  4. package/dist/client.types.js +1 -0
  5. package/dist/index.d.ts +13 -5
  6. package/dist/index.js +2 -3
  7. package/dist/modules/agents.d.ts +2 -23
  8. package/dist/modules/agents.js +3 -1
  9. package/dist/modules/agents.types.d.ts +330 -34
  10. package/dist/modules/app-logs.d.ts +8 -24
  11. package/dist/modules/app-logs.js +9 -19
  12. package/dist/modules/app-logs.types.d.ts +44 -0
  13. package/dist/modules/app-logs.types.js +1 -0
  14. package/dist/modules/app.types.d.ts +27 -0
  15. package/dist/modules/auth.d.ts +10 -78
  16. package/dist/modules/auth.js +24 -42
  17. package/dist/modules/auth.types.d.ts +436 -0
  18. package/dist/modules/auth.types.js +1 -0
  19. package/dist/modules/connectors.d.ts +6 -11
  20. package/dist/modules/connectors.js +6 -7
  21. package/dist/modules/connectors.types.d.ts +68 -2
  22. package/dist/modules/entities.d.ts +8 -5
  23. package/dist/modules/entities.js +22 -62
  24. package/dist/modules/entities.types.d.ts +293 -0
  25. package/dist/modules/entities.types.js +1 -0
  26. package/dist/modules/functions.d.ts +8 -7
  27. package/dist/modules/functions.js +7 -5
  28. package/dist/modules/functions.types.d.ts +50 -0
  29. package/dist/modules/functions.types.js +1 -0
  30. package/dist/modules/integrations.d.ts +8 -5
  31. package/dist/modules/integrations.js +7 -5
  32. package/dist/modules/integrations.types.d.ts +352 -0
  33. package/dist/modules/integrations.types.js +1 -0
  34. package/dist/modules/sso.d.ts +9 -14
  35. package/dist/modules/sso.js +9 -12
  36. package/dist/modules/sso.types.d.ts +44 -0
  37. package/dist/modules/sso.types.js +1 -0
  38. package/dist/types.d.ts +65 -2
  39. package/dist/utils/auth-utils.d.ts +107 -45
  40. package/dist/utils/auth-utils.js +107 -33
  41. package/dist/utils/auth-utils.types.d.ts +146 -0
  42. package/dist/utils/auth-utils.types.js +1 -0
  43. package/dist/utils/axios-client.d.ts +84 -16
  44. package/dist/utils/axios-client.js +74 -13
  45. package/dist/utils/axios-client.types.d.ts +28 -0
  46. package/dist/utils/axios-client.types.js +1 -0
  47. package/dist/utils/common.d.ts +0 -1
  48. package/dist/utils/common.js +1 -2
  49. package/dist/utils/socket-utils.d.ts +2 -2
  50. package/package.json +12 -3
  51. package/dist/utils/app-params.d.ts +0 -11
  52. package/dist/utils/app-params.js +0 -43
@@ -1,55 +1,117 @@
1
+ import { GetAccessTokenOptions, SaveAccessTokenOptions, RemoveAccessTokenOptions, GetLoginUrlOptions } from "./auth-utils.types.js";
1
2
  /**
2
- * Utility functions for authentication and token handling
3
- */
4
- /**
5
- * Retrieves an access token from either localStorage or URL parameters
6
- *
7
- * @param {Object} options - Configuration options
8
- * @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
9
- * @param {string} [options.paramName='access_token'] - The URL parameter name
10
- * @param {boolean} [options.saveToStorage=true] - Whether to save the token to localStorage if found in URL
11
- * @param {boolean} [options.removeFromUrl=true] - Whether to remove the token from URL after retrieval
12
- * @returns {string|null} The access token or null if not found
3
+ * Retrieves an access token from URL parameters or local storage.
4
+ *
5
+ * Low-level utility for manually retrieving tokens. In most cases, the Base44 client handles
6
+ * token management automatically. This function is useful for custom authentication flows or when you need direct access to stored tokens. Requires a browser environment and can't be used in the backend.
7
+ *
8
+ * @internal
9
+ *
10
+ * @param options - Configuration options for token retrieval.
11
+ * @returns The access token string if found, null otherwise.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Get access token from URL or local storage
16
+ * const token = getAccessToken();
17
+ *
18
+ * if (token) {
19
+ * console.log('User is authenticated');
20
+ * } else {
21
+ * console.log('No token found, redirect to login');
22
+ * }
23
+ * ```
24
+ * @example
25
+ * ```typescript
26
+ * // Get access token from custom local storage key
27
+ * const token = getAccessToken({ storageKey: 'my_app_token' });
28
+ * ```
29
+ * @example
30
+ * ```typescript
31
+ * // Get access token from URL but don't save or remove it
32
+ * const token = getAccessToken({
33
+ * saveToStorage: false,
34
+ * removeFromUrl: false
35
+ * });
36
+ * ```
13
37
  */
14
- export declare function getAccessToken(options?: {
15
- storageKey?: string;
16
- paramName?: string;
17
- saveToStorage?: boolean;
18
- removeFromUrl?: boolean;
19
- }): string | null;
38
+ export declare function getAccessToken(options?: GetAccessTokenOptions): string | null;
20
39
  /**
21
- * Saves an access token to localStorage
40
+ * Saves an access token to local storage.
41
+ *
42
+ * Low-level utility for manually saving tokens. In most cases, the Base44 client handles token management automatically. This function is useful for custom authentication flows or managing custom tokens. Requires a browser environment and can't be used in the backend.
43
+ *
44
+ * @internal
45
+ *
46
+ * @param token - The access token string to save.
47
+ * @param options - Configuration options for saving the token.
48
+ * @returns Returns`true` if the token was saved successfully, `false` otherwise.
22
49
  *
23
- * @param {string} token - The access token to save
24
- * @param {Object} options - Configuration options
25
- * @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
26
- * @returns {boolean} Success status
50
+ * @example
51
+ * ```typescript
52
+ * // Save access token after login
53
+ * const response = await base44.auth.loginViaEmailPassword(email, password);
54
+ * const success = saveAccessToken(response.access_token, {});
55
+ *
56
+ * if (success) {
57
+ * console.log('User is now authenticated');
58
+ * // Token is now available for future page loads
59
+ * }
60
+ * ```
61
+ * @example
62
+ * ```typescript
63
+ * // Save access token to local storage using custom key
64
+ * const success = saveAccessToken(token, {
65
+ * storageKey: `my_custom_token_key`
66
+ * });
67
+ * ```
27
68
  */
28
- export declare function saveAccessToken(token: string, options: {
29
- storageKey?: string;
30
- }): boolean;
69
+ export declare function saveAccessToken(token: string, options: SaveAccessTokenOptions): boolean;
31
70
  /**
32
- * Removes the access token from localStorage
71
+ * Removes the access token from local storage.
72
+ *
73
+ * Low-level utility for manually removing tokens from the browser's local storage. In most cases, the Base44 client handles token management automatically. For standard logout flows, use {@linkcode AuthModule.logout | base44.auth.logout()} instead, which handles token removal and redirects automatically. This function is useful for custom authentication flows or when you need to manually remove tokens. Requires a browser environment and can't be used in the backend.
74
+ *
75
+ * @internal
76
+ *
77
+ * @param options - Configuration options for token removal.
78
+ * @returns Returns `true` if the token was removed successfully, `false` otherwise.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * // Remove custom token key
83
+ * const success = removeAccessToken({
84
+ * storageKey: 'my_custom_token_key'
85
+ * });
86
+ * ```
33
87
  *
34
- * @param {Object} options - Configuration options
35
- * @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
36
- * @returns {boolean} Success status
88
+ * @example
89
+ * ```typescript
90
+ * // Standard logout flow with token removal and redirect
91
+ * base44.auth.logout('/login');
92
+ * ```
37
93
  */
38
- export declare function removeAccessToken(options: {
39
- storageKey?: string;
40
- }): boolean;
94
+ export declare function removeAccessToken(options: RemoveAccessTokenOptions): boolean;
41
95
  /**
42
- * Constructs the absolute URL for the login page
43
- *
44
- * @param {string} nextUrl - URL to redirect back to after login
45
- * @param {Object} options - Configuration options
46
- * @param {string} options.serverUrl - Server URL (e.g., 'https://base44.app')
47
- * @param {string|number} options.appId - Application ID
48
- * @param {string} [options.loginPath='/login'] - Path to the login endpoint
49
- * @returns {string} The complete login URL
96
+ * Constructs the absolute URL for the login page with a redirect parameter.
97
+ *
98
+ * Low-level utility for building login URLs. For standard login redirects, use {@linkcode AuthModule.redirectToLogin | base44.auth.redirectToLogin()} instead, which handles this automatically. This function is useful when you need to construct login URLs without a client instance or for custom authentication flows.
99
+ *
100
+ * @internal
101
+ *
102
+ * @param nextUrl - The URL to redirect to after successful login.
103
+ * @param options - Configuration options.
104
+ * @returns The complete login URL with encoded redirect parameters.
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Redirect to login page
109
+ * const loginUrl = getLoginUrl('/dashboard', {
110
+ * serverUrl: 'https://base44.app',
111
+ * appId: 'my-app-123'
112
+ * });
113
+ * window.location.href = loginUrl;
114
+ * // User will be redirected back to /dashboard after login
115
+ * ```
50
116
  */
51
- export declare function getLoginUrl(nextUrl: string, options: {
52
- serverUrl: string;
53
- appId: string;
54
- loginPath?: string;
55
- }): string;
117
+ export declare function getLoginUrl(nextUrl: string, options: GetLoginUrlOptions): string;
@@ -1,15 +1,38 @@
1
1
  /**
2
- * Utility functions for authentication and token handling
3
- */
4
- /**
5
- * Retrieves an access token from either localStorage or URL parameters
6
- *
7
- * @param {Object} options - Configuration options
8
- * @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
9
- * @param {string} [options.paramName='access_token'] - The URL parameter name
10
- * @param {boolean} [options.saveToStorage=true] - Whether to save the token to localStorage if found in URL
11
- * @param {boolean} [options.removeFromUrl=true] - Whether to remove the token from URL after retrieval
12
- * @returns {string|null} The access token or null if not found
2
+ * Retrieves an access token from URL parameters or local storage.
3
+ *
4
+ * Low-level utility for manually retrieving tokens. In most cases, the Base44 client handles
5
+ * token management automatically. This function is useful for custom authentication flows or when you need direct access to stored tokens. Requires a browser environment and can't be used in the backend.
6
+ *
7
+ * @internal
8
+ *
9
+ * @param options - Configuration options for token retrieval.
10
+ * @returns The access token string if found, null otherwise.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Get access token from URL or local storage
15
+ * const token = getAccessToken();
16
+ *
17
+ * if (token) {
18
+ * console.log('User is authenticated');
19
+ * } else {
20
+ * console.log('No token found, redirect to login');
21
+ * }
22
+ * ```
23
+ * @example
24
+ * ```typescript
25
+ * // Get access token from custom local storage key
26
+ * const token = getAccessToken({ storageKey: 'my_app_token' });
27
+ * ```
28
+ * @example
29
+ * ```typescript
30
+ * // Get access token from URL but don't save or remove it
31
+ * const token = getAccessToken({
32
+ * saveToStorage: false,
33
+ * removeFromUrl: false
34
+ * });
35
+ * ```
13
36
  */
14
37
  export function getAccessToken(options = {}) {
15
38
  const { storageKey = "base44_access_token", paramName = "access_token", saveToStorage = true, removeFromUrl = true, } = options;
@@ -21,7 +44,7 @@ export function getAccessToken(options = {}) {
21
44
  token = urlParams.get(paramName);
22
45
  // If token found in URL
23
46
  if (token) {
24
- // Save token to localStorage if requested
47
+ // Save token to local storage if requested
25
48
  if (saveToStorage) {
26
49
  saveAccessToken(token, { storageKey });
27
50
  }
@@ -38,25 +61,47 @@ export function getAccessToken(options = {}) {
38
61
  console.error("Error retrieving token from URL:", e);
39
62
  }
40
63
  }
41
- // If no token in URL, try localStorage
64
+ // If no token in URL, try local storage
42
65
  if (typeof window !== "undefined" && window.localStorage) {
43
66
  try {
44
67
  token = window.localStorage.getItem(storageKey);
45
68
  return token;
46
69
  }
47
70
  catch (e) {
48
- console.error("Error retrieving token from localStorage:", e);
71
+ console.error("Error retrieving token from local storage:", e);
49
72
  }
50
73
  }
51
74
  return null;
52
75
  }
53
76
  /**
54
- * Saves an access token to localStorage
77
+ * Saves an access token to local storage.
78
+ *
79
+ * Low-level utility for manually saving tokens. In most cases, the Base44 client handles token management automatically. This function is useful for custom authentication flows or managing custom tokens. Requires a browser environment and can't be used in the backend.
80
+ *
81
+ * @internal
82
+ *
83
+ * @param token - The access token string to save.
84
+ * @param options - Configuration options for saving the token.
85
+ * @returns Returns`true` if the token was saved successfully, `false` otherwise.
55
86
  *
56
- * @param {string} token - The access token to save
57
- * @param {Object} options - Configuration options
58
- * @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
59
- * @returns {boolean} Success status
87
+ * @example
88
+ * ```typescript
89
+ * // Save access token after login
90
+ * const response = await base44.auth.loginViaEmailPassword(email, password);
91
+ * const success = saveAccessToken(response.access_token, {});
92
+ *
93
+ * if (success) {
94
+ * console.log('User is now authenticated');
95
+ * // Token is now available for future page loads
96
+ * }
97
+ * ```
98
+ * @example
99
+ * ```typescript
100
+ * // Save access token to local storage using custom key
101
+ * const success = saveAccessToken(token, {
102
+ * storageKey: `my_custom_token_key`
103
+ * });
104
+ * ```
60
105
  */
61
106
  export function saveAccessToken(token, options) {
62
107
  const { storageKey = "base44_access_token" } = options;
@@ -70,16 +115,33 @@ export function saveAccessToken(token, options) {
70
115
  return true;
71
116
  }
72
117
  catch (e) {
73
- console.error("Error saving token to localStorage:", e);
118
+ console.error("Error saving token to local storage:", e);
74
119
  return false;
75
120
  }
76
121
  }
77
122
  /**
78
- * Removes the access token from localStorage
123
+ * Removes the access token from local storage.
124
+ *
125
+ * Low-level utility for manually removing tokens from the browser's local storage. In most cases, the Base44 client handles token management automatically. For standard logout flows, use {@linkcode AuthModule.logout | base44.auth.logout()} instead, which handles token removal and redirects automatically. This function is useful for custom authentication flows or when you need to manually remove tokens. Requires a browser environment and can't be used in the backend.
126
+ *
127
+ * @internal
128
+ *
129
+ * @param options - Configuration options for token removal.
130
+ * @returns Returns `true` if the token was removed successfully, `false` otherwise.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * // Remove custom token key
135
+ * const success = removeAccessToken({
136
+ * storageKey: 'my_custom_token_key'
137
+ * });
138
+ * ```
79
139
  *
80
- * @param {Object} options - Configuration options
81
- * @param {string} [options.storageKey='base44_access_token'] - The key to use in localStorage
82
- * @returns {boolean} Success status
140
+ * @example
141
+ * ```typescript
142
+ * // Standard logout flow with token removal and redirect
143
+ * base44.auth.logout('/login');
144
+ * ```
83
145
  */
84
146
  export function removeAccessToken(options) {
85
147
  const { storageKey = "base44_access_token" } = options;
@@ -91,19 +153,31 @@ export function removeAccessToken(options) {
91
153
  return true;
92
154
  }
93
155
  catch (e) {
94
- console.error("Error removing token from localStorage:", e);
156
+ console.error("Error removing token from local storage:", e);
95
157
  return false;
96
158
  }
97
159
  }
98
160
  /**
99
- * Constructs the absolute URL for the login page
100
- *
101
- * @param {string} nextUrl - URL to redirect back to after login
102
- * @param {Object} options - Configuration options
103
- * @param {string} options.serverUrl - Server URL (e.g., 'https://base44.app')
104
- * @param {string|number} options.appId - Application ID
105
- * @param {string} [options.loginPath='/login'] - Path to the login endpoint
106
- * @returns {string} The complete login URL
161
+ * Constructs the absolute URL for the login page with a redirect parameter.
162
+ *
163
+ * Low-level utility for building login URLs. For standard login redirects, use {@linkcode AuthModule.redirectToLogin | base44.auth.redirectToLogin()} instead, which handles this automatically. This function is useful when you need to construct login URLs without a client instance or for custom authentication flows.
164
+ *
165
+ * @internal
166
+ *
167
+ * @param nextUrl - The URL to redirect to after successful login.
168
+ * @param options - Configuration options.
169
+ * @returns The complete login URL with encoded redirect parameters.
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * // Redirect to login page
174
+ * const loginUrl = getLoginUrl('/dashboard', {
175
+ * serverUrl: 'https://base44.app',
176
+ * appId: 'my-app-123'
177
+ * });
178
+ * window.location.href = loginUrl;
179
+ * // User will be redirected back to /dashboard after login
180
+ * ```
107
181
  */
108
182
  export function getLoginUrl(nextUrl, options) {
109
183
  const { serverUrl, appId, loginPath = "/login" } = options;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Configuration options for retrieving an access token.
3
+ *
4
+ * @internal
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // Get access token from URL or local storage using default options
9
+ * const token = getAccessToken();
10
+ * ```
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Get access token from custom local storage key
15
+ * const token = getAccessToken({ storageKey: 'my_app_token' });
16
+ * ```
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Get token from URL but don't save or remove from URL
21
+ * const token = getAccessToken({
22
+ * saveToStorage: false,
23
+ * removeFromUrl: false
24
+ * });
25
+ * ```
26
+ */
27
+ export interface GetAccessTokenOptions {
28
+ /**
29
+ * The key to use when storing or retrieving the token in local storage.
30
+ * @default 'base44_access_token'
31
+ */
32
+ storageKey?: string;
33
+ /**
34
+ * The URL parameter name to check for the access token.
35
+ * @default 'access_token'
36
+ */
37
+ paramName?: string;
38
+ /**
39
+ * Whether to save the token to local storage if found in the URL.
40
+ * @default true
41
+ */
42
+ saveToStorage?: boolean;
43
+ /**
44
+ * Whether to remove the token from the URL after retrieval for security.
45
+ * @default true
46
+ */
47
+ removeFromUrl?: boolean;
48
+ }
49
+ /**
50
+ * Configuration options for saving an access token.
51
+ *
52
+ * @internal
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // Use default storage key
57
+ * saveAccessToken('my-token-123', {});
58
+ *
59
+ * // Use custom storage key
60
+ * saveAccessToken('my-token-123', { storageKey: 'my_app_token' });
61
+ * ```
62
+ */
63
+ export interface SaveAccessTokenOptions {
64
+ /**
65
+ * The key to use when storing the token in local storage.
66
+ * @default 'base44_access_token'
67
+ */
68
+ storageKey?: string;
69
+ }
70
+ /**
71
+ * Configuration options for removing an access token.
72
+ *
73
+ * @internal
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // Remove token from default storage key
78
+ * removeAccessToken({});
79
+ *
80
+ * // Remove token from custom storage key
81
+ * removeAccessToken({ storageKey: 'my_app_token' });
82
+ * ```
83
+ */
84
+ export interface RemoveAccessTokenOptions {
85
+ /**
86
+ * The key to use when removing the token from local storage.
87
+ * @default 'base44_access_token'
88
+ */
89
+ storageKey?: string;
90
+ }
91
+ /**
92
+ * Configuration options for constructing a login URL.
93
+ *
94
+ * @internal
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const loginUrl = getLoginUrl('/dashboard', {
99
+ * serverUrl: 'https://base44.app',
100
+ * appId: 'my-app-123'
101
+ * });
102
+ * // Returns: 'https://base44.app/login?from_url=%2Fdashboard&app_id=my-app-123'
103
+ *
104
+ * // Custom login path
105
+ * const loginUrl = getLoginUrl('/dashboard', {
106
+ * serverUrl: 'https://base44.app',
107
+ * appId: 'my-app-123',
108
+ * loginPath: '/auth/login'
109
+ * });
110
+ * ```
111
+ */
112
+ export interface GetLoginUrlOptions {
113
+ /**
114
+ * The base server URL (e.g., 'https://base44.app').
115
+ */
116
+ serverUrl: string;
117
+ /**
118
+ * The app ID.
119
+ */
120
+ appId: string;
121
+ /**
122
+ * The path to the login endpoint.
123
+ * @default '/login'
124
+ */
125
+ loginPath?: string;
126
+ }
127
+ /**
128
+ * Type definition for getAccessToken function.
129
+ * @internal
130
+ */
131
+ export type GetAccessTokenFunction = (options?: GetAccessTokenOptions) => string | null;
132
+ /**
133
+ * Type definition for saveAccessToken function.
134
+ * @internal
135
+ */
136
+ export type SaveAccessTokenFunction = (token: string, options: SaveAccessTokenOptions) => boolean;
137
+ /**
138
+ * Type definition for removeAccessToken function.
139
+ * @internal
140
+ */
141
+ export type RemoveAccessTokenFunction = (options: RemoveAccessTokenOptions) => boolean;
142
+ /**
143
+ * Type definition for getLoginUrl function.
144
+ * @internal
145
+ */
146
+ export type GetLoginUrlFunction = (nextUrl: string, options: GetLoginUrlOptions) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,27 +1,94 @@
1
+ import type { Base44ErrorJSON } from "./axios-client.types.js";
2
+ /**
3
+ * Custom error class for Base44 SDK errors.
4
+ *
5
+ * This error is thrown when API requests fail. It extends the standard `Error` class and includes additional information about the HTTP status, error code, and response data from the server.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * try {
10
+ * await client.entities.Todo.get('invalid-id');
11
+ * } catch (error) {
12
+ * if (error instanceof Base44Error) {
13
+ * console.error('Status:', error.status); // 404
14
+ * console.error('Message:', error.message); // "Not found"
15
+ * console.error('Code:', error.code); // "NOT_FOUND"
16
+ * console.error('Data:', error.data); // Full response data
17
+ * }
18
+ * }
19
+ * ```
20
+ *
21
+ */
1
22
  export declare class Base44Error extends Error {
23
+ /**
24
+ * HTTP status code of the error.
25
+ */
2
26
  status: number;
27
+ /**
28
+ * Error code from the API.
29
+ */
3
30
  code: string;
31
+ /**
32
+ * Full response data from the server containing error details.
33
+ */
4
34
  data: any;
35
+ /**
36
+ * The original error object from Axios.
37
+ */
5
38
  originalError: unknown;
39
+ /**
40
+ * Creates a new Base44Error instance.
41
+ *
42
+ * @param message - Human-readable error message
43
+ * @param status - HTTP status code
44
+ * @param code - Error code from the API
45
+ * @param data - Full response data from the server
46
+ * @param originalError - Original axios error object
47
+ * @internal
48
+ */
6
49
  constructor(message: string, status: number, code: string, data: any, originalError: unknown);
7
- toJSON(): {
8
- name: string;
9
- message: string;
10
- status: number;
11
- code: string;
12
- data: any;
13
- };
50
+ /**
51
+ * Serializes the error to a JSON-safe object.
52
+ *
53
+ * Useful for logging or sending error information to external services
54
+ * without circular reference issues.
55
+ *
56
+ * @returns JSON-safe representation of the error.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * try {
61
+ * await client.entities.Todo.get('invalid-id');
62
+ * } catch (error) {
63
+ * if (error instanceof Base44Error) {
64
+ * const json = error.toJSON();
65
+ * console.log(json);
66
+ * // {
67
+ * // name: "Base44Error",
68
+ * // message: "Not found",
69
+ * // status: 404,
70
+ * // code: "NOT_FOUND",
71
+ * // data: { ... }
72
+ * // }
73
+ * }
74
+ * }
75
+ * ```
76
+ */
77
+ toJSON(): Base44ErrorJSON;
14
78
  }
15
79
  /**
16
- * Creates an axios client with default configuration and interceptors
17
- * @param {Object} options - Client configuration options
18
- * @param {string} options.baseURL - Base URL for all requests
19
- * @param {Object} options.headers - Additional headers
20
- * @param {string} options.token - Auth token
21
- * @param {boolean} options.requiresAuth - Whether the application requires authentication
22
- * @param {string|number} options.appId - Application ID (needed for login redirect)
23
- * @param {string} options.serverUrl - Server URL (needed for login redirect)
24
- * @returns {import('axios').AxiosInstance} Configured axios instance
80
+ * Creates an axios client with default configuration and interceptors.
81
+ *
82
+ * Sets up an axios instance with:
83
+ * - Default headers
84
+ * - Authentication token injection
85
+ * - Response data unwrapping
86
+ * - Error transformation to Base44Error
87
+ * - iframe messaging support
88
+ *
89
+ * @param options - Client configuration options
90
+ * @returns Configured axios instance
91
+ * @internal
25
92
  */
26
93
  export declare function createAxiosClient({ baseURL, headers, token, interceptResponses, onError, }: {
27
94
  baseURL: string;
@@ -30,3 +97,4 @@ export declare function createAxiosClient({ baseURL, headers, token, interceptRe
30
97
  interceptResponses?: boolean;
31
98
  onError?: (error: Error) => void;
32
99
  }): import("axios").AxiosInstance;
100
+ export type { Base44ErrorJSON } from "./axios-client.types.js";