@base44-preview/sdk 0.8.32-pr.201.be55f9b → 0.8.32-pr.202.0f8275d
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.
|
@@ -76,14 +76,6 @@ export declare class Base44Error extends Error {
|
|
|
76
76
|
*/
|
|
77
77
|
toJSON(): Base44ErrorJSON;
|
|
78
78
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Convert an arbitrary value into something the structured clone algorithm
|
|
81
|
-
* (used by `postMessage`) can always serialize. Request/response bodies may
|
|
82
|
-
* contain functions, streams, or other host objects that make `postMessage`
|
|
83
|
-
* throw a `DataCloneError`; a JSON round-trip drops those, and a string
|
|
84
|
-
* fallback covers circular references.
|
|
85
|
-
*/
|
|
86
|
-
export declare function toSerializable(value: unknown): unknown;
|
|
87
79
|
/**
|
|
88
80
|
* Creates an axios client with default configuration and interceptors.
|
|
89
81
|
*
|
|
@@ -100,60 +100,6 @@ function safeErrorLog(prefix, error) {
|
|
|
100
100
|
console.error(`${prefix} ${error instanceof Error ? error.message : String(error)}`);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Convert an arbitrary value into something the structured clone algorithm
|
|
105
|
-
* (used by `postMessage`) can always serialize. Request/response bodies may
|
|
106
|
-
* contain functions, streams, or other host objects that make `postMessage`
|
|
107
|
-
* throw a `DataCloneError`; a JSON round-trip drops those, and a string
|
|
108
|
-
* fallback covers circular references.
|
|
109
|
-
*/
|
|
110
|
-
export function toSerializable(value) {
|
|
111
|
-
if (value === null || value === undefined)
|
|
112
|
-
return value;
|
|
113
|
-
const type = typeof value;
|
|
114
|
-
if (type === "string" || type === "number" || type === "boolean")
|
|
115
|
-
return value;
|
|
116
|
-
try {
|
|
117
|
-
return JSON.parse(JSON.stringify(value));
|
|
118
|
-
}
|
|
119
|
-
catch (_a) {
|
|
120
|
-
try {
|
|
121
|
-
return String(value);
|
|
122
|
-
}
|
|
123
|
-
catch (_b) {
|
|
124
|
-
return "[unserializable]";
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Post a request-activity message to the parent window (the host builder's
|
|
130
|
-
* Activity Monitor). Posting the raw bodies can throw a `DataCloneError` when
|
|
131
|
-
* they aren't structured-cloneable; if that happens we retry with a sanitized
|
|
132
|
-
* payload so the start/end status is never lost. A dropped `api-request-end`
|
|
133
|
-
* leaves the Activity Monitor stuck on "Pending" for a request that actually
|
|
134
|
-
* completed (e.g. a backend function returning 200).
|
|
135
|
-
*/
|
|
136
|
-
function postActivityMessage(message) {
|
|
137
|
-
var _a;
|
|
138
|
-
if (!isInIFrame)
|
|
139
|
-
return;
|
|
140
|
-
try {
|
|
141
|
-
window.parent.postMessage(message, "*");
|
|
142
|
-
}
|
|
143
|
-
catch (_b) {
|
|
144
|
-
try {
|
|
145
|
-
window.parent.postMessage({ ...message, data: toSerializable(message.data) }, "*");
|
|
146
|
-
}
|
|
147
|
-
catch (_c) {
|
|
148
|
-
// Drop the bodies entirely but still deliver the status signal.
|
|
149
|
-
window.parent.postMessage({
|
|
150
|
-
type: message.type,
|
|
151
|
-
requestId: message.requestId,
|
|
152
|
-
data: { statusCode: (_a = message.data) === null || _a === void 0 ? void 0 : _a.statusCode },
|
|
153
|
-
}, "*");
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
103
|
/**
|
|
158
104
|
* Creates an axios client with default configuration and interceptors.
|
|
159
105
|
*
|
|
@@ -188,15 +134,24 @@ export function createAxiosClient({ baseURL, headers = {}, token, interceptRespo
|
|
|
188
134
|
}
|
|
189
135
|
const requestId = uuidv4();
|
|
190
136
|
config.requestId = requestId;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
137
|
+
if (isInIFrame) {
|
|
138
|
+
try {
|
|
139
|
+
window.parent.postMessage({
|
|
140
|
+
type: "api-request-start",
|
|
141
|
+
requestId,
|
|
142
|
+
data: {
|
|
143
|
+
url: baseURL + config.url,
|
|
144
|
+
method: config.method,
|
|
145
|
+
body: config.data instanceof FormData
|
|
146
|
+
? "[FormData object]"
|
|
147
|
+
: config.data,
|
|
148
|
+
},
|
|
149
|
+
}, "*");
|
|
150
|
+
}
|
|
151
|
+
catch (_a) {
|
|
152
|
+
/* skip the logging */
|
|
153
|
+
}
|
|
154
|
+
}
|
|
200
155
|
return config;
|
|
201
156
|
});
|
|
202
157
|
// Handle responses
|
|
@@ -204,36 +159,28 @@ export function createAxiosClient({ baseURL, headers = {}, token, interceptRespo
|
|
|
204
159
|
client.interceptors.response.use((response) => {
|
|
205
160
|
var _a;
|
|
206
161
|
const requestId = (_a = response.config) === null || _a === void 0 ? void 0 : _a.requestId;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
162
|
+
try {
|
|
163
|
+
if (isInIFrame && requestId) {
|
|
164
|
+
window.parent.postMessage({
|
|
165
|
+
type: "api-request-end",
|
|
166
|
+
requestId,
|
|
167
|
+
data: {
|
|
168
|
+
statusCode: response.status,
|
|
169
|
+
response: response.data,
|
|
170
|
+
},
|
|
171
|
+
}, "*");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (_b) {
|
|
175
|
+
/* do nothing */
|
|
216
176
|
}
|
|
217
177
|
return response.data;
|
|
218
178
|
}, (error) => {
|
|
219
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const requestId = (_a = error.config) === null || _a === void 0 ? void 0 : _a.requestId;
|
|
223
|
-
if (requestId) {
|
|
224
|
-
postActivityMessage({
|
|
225
|
-
type: "api-request-end",
|
|
226
|
-
requestId,
|
|
227
|
-
data: {
|
|
228
|
-
statusCode: (_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.status) !== null && _c !== void 0 ? _c : 0,
|
|
229
|
-
response: (_e = (_d = error.response) === null || _d === void 0 ? void 0 : _d.data) !== null && _e !== void 0 ? _e : { error: error.message },
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
const message = ((_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.message) ||
|
|
234
|
-
((_j = (_h = error.response) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.detail) ||
|
|
179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
180
|
+
const message = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
181
|
+
((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.detail) ||
|
|
235
182
|
error.message;
|
|
236
|
-
const base44Error = new Base44Error(message, (
|
|
183
|
+
const base44Error = new Base44Error(message, (_e = error.response) === null || _e === void 0 ? void 0 : _e.status, (_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.code, (_h = error.response) === null || _h === void 0 ? void 0 : _h.data, error);
|
|
237
184
|
// Log errors in development
|
|
238
185
|
if (process.env.NODE_ENV !== "production") {
|
|
239
186
|
safeErrorLog("[Base44 SDK Error]", base44Error);
|