@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.
- package/dist/client.d.ts +90 -237
- package/dist/client.js +141 -25
- package/dist/client.types.d.ts +131 -0
- package/dist/client.types.js +1 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.js +2 -3
- package/dist/modules/agents.d.ts +2 -23
- package/dist/modules/agents.js +3 -1
- package/dist/modules/agents.types.d.ts +330 -34
- package/dist/modules/app-logs.d.ts +8 -24
- package/dist/modules/app-logs.js +9 -19
- package/dist/modules/app-logs.types.d.ts +44 -0
- package/dist/modules/app-logs.types.js +1 -0
- package/dist/modules/app.types.d.ts +27 -0
- package/dist/modules/auth.d.ts +10 -78
- package/dist/modules/auth.js +24 -42
- package/dist/modules/auth.types.d.ts +436 -0
- package/dist/modules/auth.types.js +1 -0
- package/dist/modules/connectors.d.ts +6 -11
- package/dist/modules/connectors.js +6 -7
- package/dist/modules/connectors.types.d.ts +68 -2
- package/dist/modules/entities.d.ts +8 -5
- package/dist/modules/entities.js +22 -62
- package/dist/modules/entities.types.d.ts +293 -0
- package/dist/modules/entities.types.js +1 -0
- package/dist/modules/functions.d.ts +8 -7
- package/dist/modules/functions.js +7 -5
- package/dist/modules/functions.types.d.ts +50 -0
- package/dist/modules/functions.types.js +1 -0
- package/dist/modules/integrations.d.ts +8 -5
- package/dist/modules/integrations.js +7 -5
- package/dist/modules/integrations.types.d.ts +352 -0
- package/dist/modules/integrations.types.js +1 -0
- package/dist/modules/sso.d.ts +9 -14
- package/dist/modules/sso.js +9 -12
- package/dist/modules/sso.types.d.ts +44 -0
- package/dist/modules/sso.types.js +1 -0
- package/dist/types.d.ts +65 -2
- package/dist/utils/auth-utils.d.ts +107 -45
- package/dist/utils/auth-utils.js +107 -33
- package/dist/utils/auth-utils.types.d.ts +146 -0
- package/dist/utils/auth-utils.types.js +1 -0
- package/dist/utils/axios-client.d.ts +84 -16
- package/dist/utils/axios-client.js +74 -13
- package/dist/utils/axios-client.types.d.ts +28 -0
- package/dist/utils/axios-client.types.js +1 -0
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.js +1 -2
- package/dist/utils/socket-utils.d.ts +2 -2
- package/package.json +12 -3
- package/dist/utils/app-params.d.ts +0 -11
- package/dist/utils/app-params.js +0 -43
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { isInIFrame } from "./common.js";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
|
4
|
+
/**
|
|
5
|
+
* Custom error class for Base44 SDK errors.
|
|
6
|
+
*
|
|
7
|
+
* 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.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* try {
|
|
12
|
+
* await client.entities.Todo.get('invalid-id');
|
|
13
|
+
* } catch (error) {
|
|
14
|
+
* if (error instanceof Base44Error) {
|
|
15
|
+
* console.error('Status:', error.status); // 404
|
|
16
|
+
* console.error('Message:', error.message); // "Not found"
|
|
17
|
+
* console.error('Code:', error.code); // "NOT_FOUND"
|
|
18
|
+
* console.error('Data:', error.data); // Full response data
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
4
24
|
export class Base44Error extends Error {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new Base44Error instance.
|
|
27
|
+
*
|
|
28
|
+
* @param message - Human-readable error message
|
|
29
|
+
* @param status - HTTP status code
|
|
30
|
+
* @param code - Error code from the API
|
|
31
|
+
* @param data - Full response data from the server
|
|
32
|
+
* @param originalError - Original axios error object
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
5
35
|
constructor(message, status, code, data, originalError) {
|
|
6
36
|
super(message);
|
|
7
37
|
this.name = "Base44Error";
|
|
@@ -10,7 +40,33 @@ export class Base44Error extends Error {
|
|
|
10
40
|
this.data = data;
|
|
11
41
|
this.originalError = originalError;
|
|
12
42
|
}
|
|
13
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Serializes the error to a JSON-safe object.
|
|
45
|
+
*
|
|
46
|
+
* Useful for logging or sending error information to external services
|
|
47
|
+
* without circular reference issues.
|
|
48
|
+
*
|
|
49
|
+
* @returns JSON-safe representation of the error.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* try {
|
|
54
|
+
* await client.entities.Todo.get('invalid-id');
|
|
55
|
+
* } catch (error) {
|
|
56
|
+
* if (error instanceof Base44Error) {
|
|
57
|
+
* const json = error.toJSON();
|
|
58
|
+
* console.log(json);
|
|
59
|
+
* // {
|
|
60
|
+
* // name: "Base44Error",
|
|
61
|
+
* // message: "Not found",
|
|
62
|
+
* // status: 404,
|
|
63
|
+
* // code: "NOT_FOUND",
|
|
64
|
+
* // data: { ... }
|
|
65
|
+
* // }
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
14
70
|
toJSON() {
|
|
15
71
|
return {
|
|
16
72
|
name: this.name,
|
|
@@ -22,9 +78,11 @@ export class Base44Error extends Error {
|
|
|
22
78
|
}
|
|
23
79
|
}
|
|
24
80
|
/**
|
|
25
|
-
* Safely logs error information without circular references
|
|
26
|
-
*
|
|
27
|
-
* @param
|
|
81
|
+
* Safely logs error information without circular references.
|
|
82
|
+
*
|
|
83
|
+
* @param prefix - Prefix for the log message
|
|
84
|
+
* @param error - The error to log
|
|
85
|
+
* @internal
|
|
28
86
|
*/
|
|
29
87
|
function safeErrorLog(prefix, error) {
|
|
30
88
|
if (error instanceof Base44Error) {
|
|
@@ -43,15 +101,18 @@ function safeErrorLog(prefix, error) {
|
|
|
43
101
|
}
|
|
44
102
|
}
|
|
45
103
|
/**
|
|
46
|
-
* Creates an axios client with default configuration and interceptors
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
104
|
+
* Creates an axios client with default configuration and interceptors.
|
|
105
|
+
*
|
|
106
|
+
* Sets up an axios instance with:
|
|
107
|
+
* - Default headers
|
|
108
|
+
* - Authentication token injection
|
|
109
|
+
* - Response data unwrapping
|
|
110
|
+
* - Error transformation to Base44Error
|
|
111
|
+
* - iframe messaging support
|
|
112
|
+
*
|
|
113
|
+
* @param options - Client configuration options
|
|
114
|
+
* @returns Configured axios instance
|
|
115
|
+
* @internal
|
|
55
116
|
*/
|
|
56
117
|
export function createAxiosClient({ baseURL, headers = {}, token, interceptResponses = true, onError, }) {
|
|
57
118
|
const client = axios.create({
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON representation of a Base44Error.
|
|
3
|
+
*
|
|
4
|
+
* This is the structure returned by {@linkcode Base44Error.toJSON | Base44Error.toJSON()}.
|
|
5
|
+
* Useful for logging or sending error information to external services.
|
|
6
|
+
*/
|
|
7
|
+
export interface Base44ErrorJSON {
|
|
8
|
+
/**
|
|
9
|
+
* The error name, always "Base44Error".
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Human-readable error message.
|
|
14
|
+
*/
|
|
15
|
+
message: string;
|
|
16
|
+
/**
|
|
17
|
+
* HTTP status code of the error.
|
|
18
|
+
*/
|
|
19
|
+
status: number;
|
|
20
|
+
/**
|
|
21
|
+
* Error code from the API.
|
|
22
|
+
*/
|
|
23
|
+
code: string;
|
|
24
|
+
/**
|
|
25
|
+
* Full response data from the server containing error details.
|
|
26
|
+
*/
|
|
27
|
+
data: any;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/common.d.ts
CHANGED
package/dist/utils/common.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Socket } from "socket.io-client";
|
|
2
|
-
export
|
|
2
|
+
export interface RoomsSocketConfig {
|
|
3
3
|
serverUrl: string;
|
|
4
4
|
mountPath: string;
|
|
5
5
|
transports: string[];
|
|
6
6
|
appId: string;
|
|
7
7
|
token?: string;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export type TSocketRoom = string;
|
|
10
10
|
export type TJsonStr = string;
|
|
11
11
|
type RoomsSocketEventsMap = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6-pr.48.d625f02",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
"test:e2e": "vitest run tests/e2e",
|
|
17
17
|
"test:watch": "vitest",
|
|
18
18
|
"test:coverage": "vitest run --coverage",
|
|
19
|
-
"
|
|
19
|
+
"docs": "typedoc",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"create-docs": "npm run create-docs:generate && npm run create-docs:process",
|
|
22
|
+
"push-docs": "node scripts/mintlify-post-processing/push-to-docs-repo.js",
|
|
23
|
+
"create-docs:generate": "typedoc",
|
|
24
|
+
"create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
|
|
20
25
|
},
|
|
21
26
|
"dependencies": {
|
|
22
27
|
"axios": "^1.6.2",
|
|
@@ -24,15 +29,19 @@
|
|
|
24
29
|
"uuid": "^13.0.0"
|
|
25
30
|
},
|
|
26
31
|
"devDependencies": {
|
|
32
|
+
"@types/hast": "^3.0.4",
|
|
27
33
|
"@types/node": "^25.0.1",
|
|
34
|
+
"@types/unist": "^3.0.3",
|
|
28
35
|
"@vitest/coverage-istanbul": "^1.0.0",
|
|
29
36
|
"@vitest/coverage-v8": "^1.0.0",
|
|
30
37
|
"@vitest/ui": "^1.0.0",
|
|
31
38
|
"dotenv": "^16.3.1",
|
|
32
39
|
"eslint": "^8.54.0",
|
|
33
40
|
"nock": "^13.4.0",
|
|
41
|
+
"typedoc": "^0.28.14",
|
|
42
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
34
43
|
"typescript": "^5.3.2",
|
|
35
|
-
"vitest": "^1.
|
|
44
|
+
"vitest": "^1.6.1"
|
|
36
45
|
},
|
|
37
46
|
"keywords": [
|
|
38
47
|
"base44",
|
package/dist/utils/app-params.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from './common';
|
|
2
|
-
const toSnakeCase = (str) => {
|
|
3
|
-
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
4
|
-
};
|
|
5
|
-
const getAppParamValue = (paramName, { defaultValue = undefined, removeFromUrl = false } = {}) => {
|
|
6
|
-
const storageKey = `base44_${toSnakeCase(paramName)}`;
|
|
7
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
8
|
-
const searchParam = urlParams.get(paramName);
|
|
9
|
-
if (removeFromUrl) {
|
|
10
|
-
urlParams.delete(paramName);
|
|
11
|
-
const newUrl = `${window.location.pathname}${urlParams.toString() ? `?${urlParams.toString()}` : ""}${window.location.hash}`;
|
|
12
|
-
window.history.replaceState({}, document.title, newUrl);
|
|
13
|
-
}
|
|
14
|
-
if (searchParam) {
|
|
15
|
-
localStorage.setItem(storageKey, searchParam);
|
|
16
|
-
return searchParam;
|
|
17
|
-
}
|
|
18
|
-
if (defaultValue) {
|
|
19
|
-
localStorage.setItem(storageKey, defaultValue);
|
|
20
|
-
return defaultValue;
|
|
21
|
-
}
|
|
22
|
-
const storedValue = localStorage.getItem(storageKey);
|
|
23
|
-
if (storedValue) {
|
|
24
|
-
return storedValue;
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
};
|
|
28
|
-
const getAppParams = () => {
|
|
29
|
-
if (!isBrowser) {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
if (getAppParamValue("clear_access_token") === 'true') {
|
|
33
|
-
localStorage.removeItem('base44_access_token');
|
|
34
|
-
localStorage.removeItem('token');
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
appId: getAppParamValue("app_id", { defaultValue: import.meta.env.VITE_BASE44_APP_ID }),
|
|
38
|
-
token: getAppParamValue("access_token", { removeFromUrl: true }),
|
|
39
|
-
fromUrl: getAppParamValue("from_url", { defaultValue: window.location.href }),
|
|
40
|
-
functionsVersion: getAppParamValue("functions_version", { defaultValue: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION }),
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export const appParams = getAppParams();
|