@base44-preview/sdk 0.7.3-pr.30.196c2fc → 0.7.4-dev.34c1532
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/utils/axios-client.js +41 -1
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.js +2 -0
- package/package.json +3 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import { isInIFrame } from "./common";
|
|
3
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
4
|
export class Base44Error extends Error {
|
|
3
5
|
constructor(message, status, code, data, originalError) {
|
|
4
6
|
super(message);
|
|
@@ -82,11 +84,49 @@ export function createAxiosClient({ baseURL, headers = {}, token, requiresAuth =
|
|
|
82
84
|
if (typeof window !== "undefined") {
|
|
83
85
|
config.headers.set("X-Origin-URL", window.location.href);
|
|
84
86
|
}
|
|
87
|
+
if (isInIFrame) {
|
|
88
|
+
const requestId = uuidv4();
|
|
89
|
+
try {
|
|
90
|
+
window.parent.postMessage({
|
|
91
|
+
type: "api-request-start",
|
|
92
|
+
requestId,
|
|
93
|
+
data: {
|
|
94
|
+
url: baseURL + config.url,
|
|
95
|
+
method: config.method,
|
|
96
|
+
body: config.data instanceof FormData
|
|
97
|
+
? "[FormData object]"
|
|
98
|
+
: config.data,
|
|
99
|
+
},
|
|
100
|
+
}, "*");
|
|
101
|
+
}
|
|
102
|
+
catch (_a) {
|
|
103
|
+
/* skip the logging */
|
|
104
|
+
}
|
|
105
|
+
}
|
|
85
106
|
return config;
|
|
86
107
|
});
|
|
87
108
|
// Handle responses
|
|
88
109
|
if (interceptResponses) {
|
|
89
|
-
client.interceptors.response.use((response) =>
|
|
110
|
+
client.interceptors.response.use((response) => {
|
|
111
|
+
var _a;
|
|
112
|
+
const requestId = (_a = response.config) === null || _a === void 0 ? void 0 : _a.requestId;
|
|
113
|
+
try {
|
|
114
|
+
if (isInIFrame && requestId) {
|
|
115
|
+
window.parent.postMessage({
|
|
116
|
+
type: "api-request-end",
|
|
117
|
+
requestId,
|
|
118
|
+
data: {
|
|
119
|
+
statusCode: response.status,
|
|
120
|
+
response: response.data,
|
|
121
|
+
},
|
|
122
|
+
}, "*");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (_b) {
|
|
126
|
+
/* do nothing */
|
|
127
|
+
}
|
|
128
|
+
return response.data;
|
|
129
|
+
}, (error) => {
|
|
90
130
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
91
131
|
const message = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
92
132
|
((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.detail) ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4-dev.34c1532",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"axios": "^1.6.2",
|
|
23
|
-
"socket.io-client": "^4.7.5"
|
|
23
|
+
"socket.io-client": "^4.7.5",
|
|
24
|
+
"uuid": "^13.0.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@vitest/coverage-istanbul": "^1.0.0",
|