@lark-apaas/client-toolkit-lite 1.1.8 → 1.1.9
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 +72 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +72 -73
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
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
|
|
|
@@ -1284,7 +1288,6 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
|
|
|
1284
1288
|
|
|
1285
1289
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1286
1290
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
1287
|
-
import { authClient } from "@lark-apaas/auth-sdk";
|
|
1288
1291
|
|
|
1289
1292
|
// src/integrations/getCurrentUserProfile.ts
|
|
1290
1293
|
function getCurrentUserProfile() {
|
|
@@ -1292,6 +1295,69 @@ function getCurrentUserProfile() {
|
|
|
1292
1295
|
}
|
|
1293
1296
|
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
1294
1297
|
|
|
1298
|
+
// src/utils/url.ts
|
|
1299
|
+
function splitWorkspaceUrl(fullUrl) {
|
|
1300
|
+
try {
|
|
1301
|
+
const url = new URL(fullUrl);
|
|
1302
|
+
const pathParts = url.pathname.split("/");
|
|
1303
|
+
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
1304
|
+
if (workspacesIndex === -1) {
|
|
1305
|
+
throw new Error("Invalid workspace URL format");
|
|
1306
|
+
}
|
|
1307
|
+
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
1308
|
+
const workspace = pathParts[workspacesIndex + 1];
|
|
1309
|
+
return {
|
|
1310
|
+
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
1311
|
+
workspace
|
|
1312
|
+
};
|
|
1313
|
+
} catch (error) {
|
|
1314
|
+
console.error("Error splitting workspace URL:", error);
|
|
1315
|
+
}
|
|
1316
|
+
return {
|
|
1317
|
+
baseUrl: fullUrl,
|
|
1318
|
+
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
1319
|
+
workspace: "workspace"
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
1323
|
+
|
|
1324
|
+
// src/integrations/dataloom.ts
|
|
1325
|
+
import { createClient } from "@lark-apaas/dataloom";
|
|
1326
|
+
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
1327
|
+
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
1328
|
+
baseUrl: ""
|
|
1329
|
+
};
|
|
1330
|
+
const appId = getAppId() ?? "";
|
|
1331
|
+
return createClient(baseUrl, pat ?? "", {
|
|
1332
|
+
global: {
|
|
1333
|
+
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
1334
|
+
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
1335
|
+
brandName: "miaoda",
|
|
1336
|
+
appId
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
}, "createDataLoomClient");
|
|
1340
|
+
var dataloom = null;
|
|
1341
|
+
var pendingPromise3 = null;
|
|
1342
|
+
function getDataloom() {
|
|
1343
|
+
if (dataloom) {
|
|
1344
|
+
return Promise.resolve(dataloom);
|
|
1345
|
+
}
|
|
1346
|
+
if (pendingPromise3) {
|
|
1347
|
+
return pendingPromise3;
|
|
1348
|
+
}
|
|
1349
|
+
pendingPromise3 = getInitialInfo().then((info) => {
|
|
1350
|
+
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
1351
|
+
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
1352
|
+
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
1353
|
+
return dataloom;
|
|
1354
|
+
}).finally(() => {
|
|
1355
|
+
pendingPromise3 = null;
|
|
1356
|
+
});
|
|
1357
|
+
return pendingPromise3;
|
|
1358
|
+
}
|
|
1359
|
+
__name(getDataloom, "getDataloom");
|
|
1360
|
+
|
|
1295
1361
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1296
1362
|
function getNameFromArray(nameArray) {
|
|
1297
1363
|
if (!nameArray || nameArray.length === 0) {
|
|
@@ -1316,7 +1382,8 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
|
|
|
1316
1382
|
useEffect2(() => {
|
|
1317
1383
|
let cancelled = false;
|
|
1318
1384
|
const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
|
|
1319
|
-
const
|
|
1385
|
+
const dataloom2 = await getDataloom();
|
|
1386
|
+
const result = await dataloom2?.service?.session?.getUserInfo();
|
|
1320
1387
|
if (cancelled) return;
|
|
1321
1388
|
const info = result?.data?.user_info;
|
|
1322
1389
|
const userName = getNameFromArray(info?.name);
|
|
@@ -1380,7 +1447,6 @@ __name(useIsMobile, "useIsMobile");
|
|
|
1380
1447
|
|
|
1381
1448
|
// src/hooks/useLogout.ts
|
|
1382
1449
|
import { useState as useState3 } from "react";
|
|
1383
|
-
import { authClient as authClient2 } from "@lark-apaas/auth-sdk";
|
|
1384
1450
|
function useLogout() {
|
|
1385
1451
|
const [isLoading, setIsLoading] = useState3(false);
|
|
1386
1452
|
async function handlerLogout() {
|
|
@@ -1390,7 +1456,8 @@ function useLogout() {
|
|
|
1390
1456
|
}
|
|
1391
1457
|
setIsLoading(true);
|
|
1392
1458
|
try {
|
|
1393
|
-
await
|
|
1459
|
+
const dataloom2 = await getDataloom();
|
|
1460
|
+
await dataloom2.service.session.signOut();
|
|
1394
1461
|
} catch (error) {
|
|
1395
1462
|
console.error("\u767B\u51FA\u5931\u8D25", error);
|
|
1396
1463
|
} finally {
|
|
@@ -2739,74 +2806,6 @@ function getAxiosForBackend() {
|
|
|
2739
2806
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
2740
2807
|
var axiosForBackend = getAxiosForBackend();
|
|
2741
2808
|
|
|
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
|
-
// src/integrations/dataloom.ts
|
|
2769
|
-
import { createClient } from "@lark-apaas/dataloom";
|
|
2770
|
-
import { authClient as authClient3 } from "@lark-apaas/auth-sdk";
|
|
2771
|
-
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
2772
|
-
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
2773
|
-
baseUrl: ""
|
|
2774
|
-
};
|
|
2775
|
-
const appId = getAppId() ?? "";
|
|
2776
|
-
return createClient(baseUrl, pat ?? "", {
|
|
2777
|
-
global: {
|
|
2778
|
-
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
2779
|
-
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
2780
|
-
brandName: "miaoda",
|
|
2781
|
-
appId,
|
|
2782
|
-
accountServices: {
|
|
2783
|
-
user: authClient3.user,
|
|
2784
|
-
session: authClient3.session
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
});
|
|
2788
|
-
}, "createDataLoomClient");
|
|
2789
|
-
var dataloom = null;
|
|
2790
|
-
var pendingPromise3 = null;
|
|
2791
|
-
function getDataloom() {
|
|
2792
|
-
if (dataloom) {
|
|
2793
|
-
return Promise.resolve(dataloom);
|
|
2794
|
-
}
|
|
2795
|
-
if (pendingPromise3) {
|
|
2796
|
-
return pendingPromise3;
|
|
2797
|
-
}
|
|
2798
|
-
pendingPromise3 = getInitialInfo().then((info) => {
|
|
2799
|
-
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
2800
|
-
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
2801
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
2802
|
-
return dataloom;
|
|
2803
|
-
}).finally(() => {
|
|
2804
|
-
pendingPromise3 = null;
|
|
2805
|
-
});
|
|
2806
|
-
return pendingPromise3;
|
|
2807
|
-
}
|
|
2808
|
-
__name(getDataloom, "getDataloom");
|
|
2809
|
-
|
|
2810
2809
|
// src/integrations/capabilityClient.ts
|
|
2811
2810
|
import { createClient as createClient2 } from "@lark-apaas/client-capability";
|
|
2812
2811
|
|