@budibase/frontend-core 2.13.40 → 2.13.42
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/package.json +4 -4
- package/src/api/index.js +22 -4
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.42",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
7
|
"svelte": "src/index.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@budibase/bbui": "2.13.
|
|
10
|
-
"@budibase/shared-core": "2.13.
|
|
9
|
+
"@budibase/bbui": "2.13.42",
|
|
10
|
+
"@budibase/shared-core": "2.13.42",
|
|
11
11
|
"dayjs": "^1.10.8",
|
|
12
12
|
"lodash": "4.17.21",
|
|
13
13
|
"socket.io-client": "^4.6.1",
|
|
14
14
|
"svelte": "^3.49.0"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "78673ac375805be3d6262e96ab30c004105e5be0"
|
|
17
17
|
}
|
package/src/api/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Helpers } from "@budibase/bbui"
|
|
2
|
+
import { Header } from "@budibase/shared-core"
|
|
2
3
|
import { ApiVersion } from "../constants"
|
|
3
4
|
import { buildAnalyticsEndpoints } from "./analytics"
|
|
4
5
|
import { buildAppEndpoints } from "./app"
|
|
@@ -62,6 +63,11 @@ const defaultAPIClientConfig = {
|
|
|
62
63
|
* invoked before the actual JS error is thrown up the stack.
|
|
63
64
|
*/
|
|
64
65
|
onError: null,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A function can be passed to be called when an API call returns info about a migration running for a specific app
|
|
69
|
+
*/
|
|
70
|
+
onMigrationDetected: null,
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
/**
|
|
@@ -133,9 +139,9 @@ export const createAPIClient = config => {
|
|
|
133
139
|
|
|
134
140
|
// Build headers
|
|
135
141
|
let headers = { Accept: "application/json" }
|
|
136
|
-
headers[
|
|
142
|
+
headers[Header.SESSION_ID] = APISessionID
|
|
137
143
|
if (!external) {
|
|
138
|
-
headers[
|
|
144
|
+
headers[Header.API_VER] = ApiVersion
|
|
139
145
|
}
|
|
140
146
|
if (json) {
|
|
141
147
|
headers["Content-Type"] = "application/json"
|
|
@@ -170,6 +176,7 @@ export const createAPIClient = config => {
|
|
|
170
176
|
|
|
171
177
|
// Handle response
|
|
172
178
|
if (response.status >= 200 && response.status < 400) {
|
|
179
|
+
handleMigrations(response)
|
|
173
180
|
try {
|
|
174
181
|
if (parseResponse) {
|
|
175
182
|
return await parseResponse(response)
|
|
@@ -186,7 +193,18 @@ export const createAPIClient = config => {
|
|
|
186
193
|
}
|
|
187
194
|
}
|
|
188
195
|
|
|
189
|
-
|
|
196
|
+
const handleMigrations = response => {
|
|
197
|
+
if (!config.onMigrationDetected) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
const migration = response.headers.get(Header.MIGRATING_APP)
|
|
201
|
+
|
|
202
|
+
if (migration) {
|
|
203
|
+
config.onMigrationDetected(migration)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Performs an API call to the server and caches the response.
|
|
190
208
|
// Future invocation for this URL will return the cached result instead of
|
|
191
209
|
// hitting the server again.
|
|
192
210
|
const makeCachedApiCall = async params => {
|
|
@@ -242,7 +260,7 @@ export const createAPIClient = config => {
|
|
|
242
260
|
getAppID: () => {
|
|
243
261
|
let headers = {}
|
|
244
262
|
config?.attachHeaders(headers)
|
|
245
|
-
return headers?.[
|
|
263
|
+
return headers?.[Header.APP_ID]
|
|
246
264
|
},
|
|
247
265
|
}
|
|
248
266
|
|