@base44-preview/sdk 0.7.0-pr.29.2474cce → 0.7.0-pr.29.7a5b54e
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { extractSnapshotIdFromHost } from "../utils/extract-snapshot-id-from-host.js";
|
|
2
1
|
/**
|
|
3
2
|
* Creates the functions module for the Base44 SDK
|
|
4
3
|
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
@@ -36,14 +35,7 @@ export function createFunctionsModule(axios, appId) {
|
|
|
36
35
|
formData = data;
|
|
37
36
|
contentType = "application/json";
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
const functionsVersion = extractSnapshotIdFromHost();
|
|
41
|
-
return axios.post(`/apps/${appId}/functions/${functionName}`, formData || data, {
|
|
42
|
-
headers: {
|
|
43
|
-
"Content-Type": contentType,
|
|
44
|
-
"X-Functions-Version": functionsVersion
|
|
45
|
-
}
|
|
46
|
-
});
|
|
38
|
+
return axios.post(`/apps/${appId}/functions/${functionName}`, formData || data, { headers: { "Content-Type": contentType } });
|
|
47
39
|
},
|
|
48
40
|
};
|
|
49
41
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the snapshot ID or environment type from the current hostname
|
|
3
|
-
* Used to determine which backend function deployment to call
|
|
4
|
-
*
|
|
5
|
-
* @returns {string} The snapshot ID for checkpoints, 'preview' for preview URLs, or 'prod' for production
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractSnapshotIdFromHost(): string;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the snapshot ID or environment type from the current hostname
|
|
3
|
-
* Used to determine which backend function deployment to call
|
|
4
|
-
*
|
|
5
|
-
* @returns {string} The snapshot ID for checkpoints, 'preview' for preview URLs, or 'prod' for production
|
|
6
|
-
*/
|
|
7
|
-
export function extractSnapshotIdFromHost() {
|
|
8
|
-
if (typeof window === "undefined") {
|
|
9
|
-
return "prod";
|
|
10
|
-
}
|
|
11
|
-
const hostname = window.location.hostname;
|
|
12
|
-
// Check if it's a checkpoint URL
|
|
13
|
-
if (hostname.startsWith("checkpoint--")) {
|
|
14
|
-
// Format: checkpoint--{app_id}--{snapshot_id}.domain
|
|
15
|
-
const parts = hostname.split("--");
|
|
16
|
-
if (parts.length >= 3) {
|
|
17
|
-
// Extract snapshot_id (last part before the domain)
|
|
18
|
-
const snapshotPart = parts[2];
|
|
19
|
-
// Remove domain extension if present
|
|
20
|
-
const snapshotId = snapshotPart.split(".")[0];
|
|
21
|
-
return snapshotId;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// Check if it's a preview URL
|
|
25
|
-
if (hostname.startsWith("preview--")) {
|
|
26
|
-
return "preview";
|
|
27
|
-
}
|
|
28
|
-
// Production URLs - return "prod"
|
|
29
|
-
return "prod";
|
|
30
|
-
}
|