@lark-apaas/client-toolkit-lite 1.1.8-beta.0 → 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.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
|
|
|
@@ -1355,7 +1359,6 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
|
|
|
1355
1359
|
|
|
1356
1360
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1357
1361
|
var import_react2 = require("react");
|
|
1358
|
-
var import_auth_sdk = require("@lark-apaas/auth-sdk");
|
|
1359
1362
|
|
|
1360
1363
|
// src/integrations/getCurrentUserProfile.ts
|
|
1361
1364
|
function getCurrentUserProfile() {
|
|
@@ -1363,6 +1366,69 @@ function getCurrentUserProfile() {
|
|
|
1363
1366
|
}
|
|
1364
1367
|
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
1365
1368
|
|
|
1369
|
+
// src/utils/url.ts
|
|
1370
|
+
function splitWorkspaceUrl(fullUrl) {
|
|
1371
|
+
try {
|
|
1372
|
+
const url = new URL(fullUrl);
|
|
1373
|
+
const pathParts = url.pathname.split("/");
|
|
1374
|
+
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
1375
|
+
if (workspacesIndex === -1) {
|
|
1376
|
+
throw new Error("Invalid workspace URL format");
|
|
1377
|
+
}
|
|
1378
|
+
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
1379
|
+
const workspace = pathParts[workspacesIndex + 1];
|
|
1380
|
+
return {
|
|
1381
|
+
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
1382
|
+
workspace
|
|
1383
|
+
};
|
|
1384
|
+
} catch (error) {
|
|
1385
|
+
console.error("Error splitting workspace URL:", error);
|
|
1386
|
+
}
|
|
1387
|
+
return {
|
|
1388
|
+
baseUrl: fullUrl,
|
|
1389
|
+
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
1390
|
+
workspace: "workspace"
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
1394
|
+
|
|
1395
|
+
// src/integrations/dataloom.ts
|
|
1396
|
+
var import_dataloom = require("@lark-apaas/dataloom");
|
|
1397
|
+
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
1398
|
+
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
1399
|
+
baseUrl: ""
|
|
1400
|
+
};
|
|
1401
|
+
const appId = getAppId() ?? "";
|
|
1402
|
+
return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
|
|
1403
|
+
global: {
|
|
1404
|
+
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
1405
|
+
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
1406
|
+
brandName: "miaoda",
|
|
1407
|
+
appId
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
}, "createDataLoomClient");
|
|
1411
|
+
var dataloom = null;
|
|
1412
|
+
var pendingPromise3 = null;
|
|
1413
|
+
function getDataloom() {
|
|
1414
|
+
if (dataloom) {
|
|
1415
|
+
return Promise.resolve(dataloom);
|
|
1416
|
+
}
|
|
1417
|
+
if (pendingPromise3) {
|
|
1418
|
+
return pendingPromise3;
|
|
1419
|
+
}
|
|
1420
|
+
pendingPromise3 = getInitialInfo().then((info) => {
|
|
1421
|
+
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
1422
|
+
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
1423
|
+
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
1424
|
+
return dataloom;
|
|
1425
|
+
}).finally(() => {
|
|
1426
|
+
pendingPromise3 = null;
|
|
1427
|
+
});
|
|
1428
|
+
return pendingPromise3;
|
|
1429
|
+
}
|
|
1430
|
+
__name(getDataloom, "getDataloom");
|
|
1431
|
+
|
|
1366
1432
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1367
1433
|
function getNameFromArray(nameArray) {
|
|
1368
1434
|
if (!nameArray || nameArray.length === 0) {
|
|
@@ -1387,7 +1453,8 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
|
|
|
1387
1453
|
(0, import_react2.useEffect)(() => {
|
|
1388
1454
|
let cancelled = false;
|
|
1389
1455
|
const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
|
|
1390
|
-
const
|
|
1456
|
+
const dataloom2 = await getDataloom();
|
|
1457
|
+
const result = await dataloom2?.service?.session?.getUserInfo();
|
|
1391
1458
|
if (cancelled) return;
|
|
1392
1459
|
const info = result?.data?.user_info;
|
|
1393
1460
|
const userName = getNameFromArray(info?.name);
|
|
@@ -1451,7 +1518,6 @@ __name(useIsMobile, "useIsMobile");
|
|
|
1451
1518
|
|
|
1452
1519
|
// src/hooks/useLogout.ts
|
|
1453
1520
|
var import_react4 = require("react");
|
|
1454
|
-
var import_auth_sdk2 = require("@lark-apaas/auth-sdk");
|
|
1455
1521
|
function useLogout() {
|
|
1456
1522
|
const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
|
|
1457
1523
|
async function handlerLogout() {
|
|
@@ -1461,7 +1527,8 @@ function useLogout() {
|
|
|
1461
1527
|
}
|
|
1462
1528
|
setIsLoading(true);
|
|
1463
1529
|
try {
|
|
1464
|
-
await
|
|
1530
|
+
const dataloom2 = await getDataloom();
|
|
1531
|
+
await dataloom2.service.session.signOut();
|
|
1465
1532
|
} catch (error) {
|
|
1466
1533
|
console.error("\u767B\u51FA\u5931\u8D25", error);
|
|
1467
1534
|
} finally {
|
|
@@ -2810,74 +2877,6 @@ function getAxiosForBackend() {
|
|
|
2810
2877
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
2811
2878
|
var axiosForBackend = getAxiosForBackend();
|
|
2812
2879
|
|
|
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
|
-
// src/integrations/dataloom.ts
|
|
2840
|
-
var import_dataloom = require("@lark-apaas/dataloom");
|
|
2841
|
-
var import_auth_sdk3 = require("@lark-apaas/auth-sdk");
|
|
2842
|
-
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
2843
|
-
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
2844
|
-
baseUrl: ""
|
|
2845
|
-
};
|
|
2846
|
-
const appId = getAppId() ?? "";
|
|
2847
|
-
return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
|
|
2848
|
-
global: {
|
|
2849
|
-
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
2850
|
-
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
2851
|
-
brandName: "miaoda",
|
|
2852
|
-
appId,
|
|
2853
|
-
accountServices: {
|
|
2854
|
-
user: import_auth_sdk3.authClient.user,
|
|
2855
|
-
session: import_auth_sdk3.authClient.session
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2858
|
-
});
|
|
2859
|
-
}, "createDataLoomClient");
|
|
2860
|
-
var dataloom = null;
|
|
2861
|
-
var pendingPromise3 = null;
|
|
2862
|
-
function getDataloom() {
|
|
2863
|
-
if (dataloom) {
|
|
2864
|
-
return Promise.resolve(dataloom);
|
|
2865
|
-
}
|
|
2866
|
-
if (pendingPromise3) {
|
|
2867
|
-
return pendingPromise3;
|
|
2868
|
-
}
|
|
2869
|
-
pendingPromise3 = getInitialInfo().then((info) => {
|
|
2870
|
-
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
2871
|
-
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
2872
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
2873
|
-
return dataloom;
|
|
2874
|
-
}).finally(() => {
|
|
2875
|
-
pendingPromise3 = null;
|
|
2876
|
-
});
|
|
2877
|
-
return pendingPromise3;
|
|
2878
|
-
}
|
|
2879
|
-
__name(getDataloom, "getDataloom");
|
|
2880
|
-
|
|
2881
2880
|
// src/integrations/capabilityClient.ts
|
|
2882
2881
|
var import_client_capability = require("@lark-apaas/client-capability");
|
|
2883
2882
|
|