@base44-preview/cli 0.1.5-pr.577.1701370 → 0.1.5-pr.578.bad1ac7
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/assets/templates/backend-and-client/package.json +2 -1
- package/dist/assets/templates/backend-and-client/src/api/base44Client.js +14 -0
- package/dist/assets/templates/backend-and-client/src/lib/app-params.js +54 -0
- package/dist/assets/templates/backend-and-client/vite.config.js +3 -8
- package/package.json +1 -1
- package/dist/assets/templates/backend-and-client/src/api/base44Client.js.ejs +0 -5
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createClient } from '@base44/sdk';
|
|
2
|
+
import { appParams } from '@/lib/app-params';
|
|
3
|
+
|
|
4
|
+
const { appId, token, functionsVersion, appBaseUrl } = appParams;
|
|
5
|
+
|
|
6
|
+
//Create a client with authentication required
|
|
7
|
+
export const base44 = createClient({
|
|
8
|
+
appId,
|
|
9
|
+
token,
|
|
10
|
+
functionsVersion,
|
|
11
|
+
serverUrl: '',
|
|
12
|
+
requiresAuth: false,
|
|
13
|
+
appBaseUrl
|
|
14
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const isNode = typeof window === 'undefined';
|
|
2
|
+
const windowObj = isNode ? { localStorage: new Map() } : window;
|
|
3
|
+
const storage = windowObj.localStorage;
|
|
4
|
+
|
|
5
|
+
const toSnakeCase = (str) => {
|
|
6
|
+
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const getAppParamValue = (paramName, { defaultValue = undefined, removeFromUrl = false } = {}) => {
|
|
10
|
+
if (isNode) {
|
|
11
|
+
return defaultValue;
|
|
12
|
+
}
|
|
13
|
+
const storageKey = `base44_${toSnakeCase(paramName)}`;
|
|
14
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
15
|
+
const searchParam = urlParams.get(paramName);
|
|
16
|
+
if (removeFromUrl) {
|
|
17
|
+
urlParams.delete(paramName);
|
|
18
|
+
const newUrl = `${window.location.pathname}${urlParams.toString() ? `?${urlParams.toString()}` : ""
|
|
19
|
+
}${window.location.hash}`;
|
|
20
|
+
window.history.replaceState({}, document.title, newUrl);
|
|
21
|
+
}
|
|
22
|
+
if (searchParam) {
|
|
23
|
+
storage.setItem(storageKey, searchParam);
|
|
24
|
+
return searchParam;
|
|
25
|
+
}
|
|
26
|
+
if (defaultValue) {
|
|
27
|
+
storage.setItem(storageKey, defaultValue);
|
|
28
|
+
return defaultValue;
|
|
29
|
+
}
|
|
30
|
+
const storedValue = storage.getItem(storageKey);
|
|
31
|
+
if (storedValue) {
|
|
32
|
+
return storedValue;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const getAppParams = () => {
|
|
38
|
+
if (getAppParamValue("clear_access_token") === 'true') {
|
|
39
|
+
storage.removeItem('base44_access_token');
|
|
40
|
+
storage.removeItem('token');
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
appId: getAppParamValue("app_id", { defaultValue: import.meta.env.VITE_BASE44_APP_ID }),
|
|
44
|
+
token: getAppParamValue("access_token", { removeFromUrl: true }),
|
|
45
|
+
fromUrl: getAppParamValue("from_url", { defaultValue: window.location.href }),
|
|
46
|
+
functionsVersion: getAppParamValue("functions_version", { defaultValue: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION }),
|
|
47
|
+
appBaseUrl: getAppParamValue("app_base_url", { defaultValue: import.meta.env.VITE_BASE44_APP_BASE_URL }),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
export const appParams = {
|
|
53
|
+
...getAppParams()
|
|
54
|
+
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import base44 from '@base44/vite-plugin';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
|
-
import
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
4
|
|
|
5
5
|
export default defineConfig({
|
|
6
|
-
plugins: [react()],
|
|
7
|
-
resolve: {
|
|
8
|
-
alias: {
|
|
9
|
-
'@': path.resolve(__dirname, './src'),
|
|
10
|
-
},
|
|
11
|
-
},
|
|
6
|
+
plugins: [base44(), react()],
|
|
12
7
|
});
|
package/package.json
CHANGED