@lark-apaas/client-toolkit-lite 1.1.8 → 1.1.10-alpha.0
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/index.cjs +13 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -36
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -706,7 +706,11 @@ function batchLogInfo(level, message, source) {
|
|
|
706
706
|
defaultBatchLogger.batchLog(level, message, source);
|
|
707
707
|
}
|
|
708
708
|
__name(batchLogInfo, "batchLogInfo");
|
|
709
|
-
|
|
709
|
+
function shouldEnableBatchLogger() {
|
|
710
|
+
return process.env.NODE_ENV !== "production" && typeof window !== "undefined" && !!process.env.MIAODA_APP_TYPE;
|
|
711
|
+
}
|
|
712
|
+
__name(shouldEnableBatchLogger, "shouldEnableBatchLogger");
|
|
713
|
+
if (shouldEnableBatchLogger()) {
|
|
710
714
|
defaultBatchLogger = new BatchLogger(console);
|
|
711
715
|
}
|
|
712
716
|
|
|
@@ -2810,46 +2814,21 @@ function getAxiosForBackend() {
|
|
|
2810
2814
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
2811
2815
|
var axiosForBackend = getAxiosForBackend();
|
|
2812
2816
|
|
|
2813
|
-
// src/utils/url.ts
|
|
2814
|
-
function splitWorkspaceUrl(fullUrl) {
|
|
2815
|
-
try {
|
|
2816
|
-
const url = new URL(fullUrl);
|
|
2817
|
-
const pathParts = url.pathname.split("/");
|
|
2818
|
-
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
2819
|
-
if (workspacesIndex === -1) {
|
|
2820
|
-
throw new Error("Invalid workspace URL format");
|
|
2821
|
-
}
|
|
2822
|
-
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
2823
|
-
const workspace = pathParts[workspacesIndex + 1];
|
|
2824
|
-
return {
|
|
2825
|
-
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
2826
|
-
workspace
|
|
2827
|
-
};
|
|
2828
|
-
} catch (error) {
|
|
2829
|
-
console.error("Error splitting workspace URL:", error);
|
|
2830
|
-
}
|
|
2831
|
-
return {
|
|
2832
|
-
baseUrl: fullUrl,
|
|
2833
|
-
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
2834
|
-
workspace: "workspace"
|
|
2835
|
-
};
|
|
2836
|
-
}
|
|
2837
|
-
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
2838
|
-
|
|
2839
2817
|
// src/integrations/dataloom.ts
|
|
2840
2818
|
var import_dataloom = require("@lark-apaas/dataloom");
|
|
2841
2819
|
var import_auth_sdk3 = require("@lark-apaas/auth-sdk");
|
|
2842
|
-
var createDataLoomClient = /* @__PURE__ */ __name((
|
|
2843
|
-
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
2844
|
-
baseUrl: ""
|
|
2845
|
-
};
|
|
2820
|
+
var createDataLoomClient = /* @__PURE__ */ __name(() => {
|
|
2846
2821
|
const appId = getAppId() ?? "";
|
|
2847
|
-
return (0, import_dataloom.createClient)(
|
|
2822
|
+
return (0, import_dataloom.createClient)({
|
|
2848
2823
|
global: {
|
|
2849
2824
|
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
2850
2825
|
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
2851
2826
|
brandName: "miaoda",
|
|
2852
2827
|
appId,
|
|
2828
|
+
// 同源网关下不会触发预检;CSRF token 仅用于 POST/PUT/DELETE 防护。
|
|
2829
|
+
headers: {
|
|
2830
|
+
"X-Suda-Csrf-Token": getCsrfToken() ?? ""
|
|
2831
|
+
},
|
|
2853
2832
|
accountServices: {
|
|
2854
2833
|
user: import_auth_sdk3.authClient.user,
|
|
2855
2834
|
session: import_auth_sdk3.authClient.session
|
|
@@ -2866,10 +2845,8 @@ function getDataloom() {
|
|
|
2866
2845
|
if (pendingPromise3) {
|
|
2867
2846
|
return pendingPromise3;
|
|
2868
2847
|
}
|
|
2869
|
-
pendingPromise3 = getInitialInfo().then((
|
|
2870
|
-
|
|
2871
|
-
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
2872
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
2848
|
+
pendingPromise3 = getInitialInfo().then(() => {
|
|
2849
|
+
dataloom = createDataLoomClient();
|
|
2873
2850
|
return dataloom;
|
|
2874
2851
|
}).finally(() => {
|
|
2875
2852
|
pendingPromise3 = null;
|