@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.d.cts
CHANGED
|
@@ -328,8 +328,8 @@ declare function getAppInfo(refresh?: boolean): Promise<AppInfoPayload>;
|
|
|
328
328
|
|
|
329
329
|
declare function getCurrentUserProfile(): IUserProfile;
|
|
330
330
|
|
|
331
|
-
declare const createDataLoomClient: (
|
|
332
|
-
/** 获取dataloom实例 */
|
|
331
|
+
declare const createDataLoomClient: () => _lark_apaas_dataloom.DataloomClient;
|
|
332
|
+
/** 获取 dataloom 实例 */
|
|
333
333
|
declare function getDataloom(): Promise<ReturnType<typeof createDataLoomClient>>;
|
|
334
334
|
|
|
335
335
|
declare const capabilityClient: _lark_apaas_client_capability.CapabilityClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -328,8 +328,8 @@ declare function getAppInfo(refresh?: boolean): Promise<AppInfoPayload>;
|
|
|
328
328
|
|
|
329
329
|
declare function getCurrentUserProfile(): IUserProfile;
|
|
330
330
|
|
|
331
|
-
declare const createDataLoomClient: (
|
|
332
|
-
/** 获取dataloom实例 */
|
|
331
|
+
declare const createDataLoomClient: () => _lark_apaas_dataloom.DataloomClient;
|
|
332
|
+
/** 获取 dataloom 实例 */
|
|
333
333
|
declare function getDataloom(): Promise<ReturnType<typeof createDataLoomClient>>;
|
|
334
334
|
|
|
335
335
|
declare const capabilityClient: _lark_apaas_client_capability.CapabilityClient;
|
package/dist/index.js
CHANGED
|
@@ -635,7 +635,11 @@ function batchLogInfo(level, message, source) {
|
|
|
635
635
|
defaultBatchLogger.batchLog(level, message, source);
|
|
636
636
|
}
|
|
637
637
|
__name(batchLogInfo, "batchLogInfo");
|
|
638
|
-
|
|
638
|
+
function shouldEnableBatchLogger() {
|
|
639
|
+
return process.env.NODE_ENV !== "production" && typeof window !== "undefined" && !!process.env.MIAODA_APP_TYPE;
|
|
640
|
+
}
|
|
641
|
+
__name(shouldEnableBatchLogger, "shouldEnableBatchLogger");
|
|
642
|
+
if (shouldEnableBatchLogger()) {
|
|
639
643
|
defaultBatchLogger = new BatchLogger(console);
|
|
640
644
|
}
|
|
641
645
|
|
|
@@ -2739,46 +2743,21 @@ function getAxiosForBackend() {
|
|
|
2739
2743
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
2740
2744
|
var axiosForBackend = getAxiosForBackend();
|
|
2741
2745
|
|
|
2742
|
-
// src/utils/url.ts
|
|
2743
|
-
function splitWorkspaceUrl(fullUrl) {
|
|
2744
|
-
try {
|
|
2745
|
-
const url = new URL(fullUrl);
|
|
2746
|
-
const pathParts = url.pathname.split("/");
|
|
2747
|
-
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
2748
|
-
if (workspacesIndex === -1) {
|
|
2749
|
-
throw new Error("Invalid workspace URL format");
|
|
2750
|
-
}
|
|
2751
|
-
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
2752
|
-
const workspace = pathParts[workspacesIndex + 1];
|
|
2753
|
-
return {
|
|
2754
|
-
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
2755
|
-
workspace
|
|
2756
|
-
};
|
|
2757
|
-
} catch (error) {
|
|
2758
|
-
console.error("Error splitting workspace URL:", error);
|
|
2759
|
-
}
|
|
2760
|
-
return {
|
|
2761
|
-
baseUrl: fullUrl,
|
|
2762
|
-
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
2763
|
-
workspace: "workspace"
|
|
2764
|
-
};
|
|
2765
|
-
}
|
|
2766
|
-
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
2767
|
-
|
|
2768
2746
|
// src/integrations/dataloom.ts
|
|
2769
2747
|
import { createClient } from "@lark-apaas/dataloom";
|
|
2770
2748
|
import { authClient as authClient3 } from "@lark-apaas/auth-sdk";
|
|
2771
|
-
var createDataLoomClient = /* @__PURE__ */ __name((
|
|
2772
|
-
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
2773
|
-
baseUrl: ""
|
|
2774
|
-
};
|
|
2749
|
+
var createDataLoomClient = /* @__PURE__ */ __name(() => {
|
|
2775
2750
|
const appId = getAppId() ?? "";
|
|
2776
|
-
return createClient(
|
|
2751
|
+
return createClient({
|
|
2777
2752
|
global: {
|
|
2778
2753
|
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
2779
2754
|
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
2780
2755
|
brandName: "miaoda",
|
|
2781
2756
|
appId,
|
|
2757
|
+
// 同源网关下不会触发预检;CSRF token 仅用于 POST/PUT/DELETE 防护。
|
|
2758
|
+
headers: {
|
|
2759
|
+
"X-Suda-Csrf-Token": getCsrfToken() ?? ""
|
|
2760
|
+
},
|
|
2782
2761
|
accountServices: {
|
|
2783
2762
|
user: authClient3.user,
|
|
2784
2763
|
session: authClient3.session
|
|
@@ -2795,10 +2774,8 @@ function getDataloom() {
|
|
|
2795
2774
|
if (pendingPromise3) {
|
|
2796
2775
|
return pendingPromise3;
|
|
2797
2776
|
}
|
|
2798
|
-
pendingPromise3 = getInitialInfo().then((
|
|
2799
|
-
|
|
2800
|
-
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
2801
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
2777
|
+
pendingPromise3 = getInitialInfo().then(() => {
|
|
2778
|
+
dataloom = createDataLoomClient();
|
|
2802
2779
|
return dataloom;
|
|
2803
2780
|
}).finally(() => {
|
|
2804
2781
|
pendingPromise3 = null;
|