@lark-apaas/client-toolkit-lite 1.1.8-alpha.6 → 1.1.8
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 +73 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -72
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -706,11 +706,7 @@ function batchLogInfo(level, message, source) {
|
|
|
706
706
|
defaultBatchLogger.batchLog(level, message, source);
|
|
707
707
|
}
|
|
708
708
|
__name(batchLogInfo, "batchLogInfo");
|
|
709
|
-
|
|
710
|
-
return process.env.NODE_ENV !== "production" && typeof window !== "undefined" && !!process.env.MIAODA_APP_TYPE;
|
|
711
|
-
}
|
|
712
|
-
__name(shouldEnableBatchLogger, "shouldEnableBatchLogger");
|
|
713
|
-
if (shouldEnableBatchLogger()) {
|
|
709
|
+
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
714
710
|
defaultBatchLogger = new BatchLogger(console);
|
|
715
711
|
}
|
|
716
712
|
|
|
@@ -1359,6 +1355,7 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
|
|
|
1359
1355
|
|
|
1360
1356
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1361
1357
|
var import_react2 = require("react");
|
|
1358
|
+
var import_auth_sdk = require("@lark-apaas/auth-sdk");
|
|
1362
1359
|
|
|
1363
1360
|
// src/integrations/getCurrentUserProfile.ts
|
|
1364
1361
|
function getCurrentUserProfile() {
|
|
@@ -1366,69 +1363,6 @@ function getCurrentUserProfile() {
|
|
|
1366
1363
|
}
|
|
1367
1364
|
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
1368
1365
|
|
|
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
|
-
|
|
1432
1366
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1433
1367
|
function getNameFromArray(nameArray) {
|
|
1434
1368
|
if (!nameArray || nameArray.length === 0) {
|
|
@@ -1453,8 +1387,7 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
|
|
|
1453
1387
|
(0, import_react2.useEffect)(() => {
|
|
1454
1388
|
let cancelled = false;
|
|
1455
1389
|
const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
|
|
1456
|
-
const
|
|
1457
|
-
const result = await dataloom2?.service?.session?.getUserInfo();
|
|
1390
|
+
const result = await import_auth_sdk.authClient.session.getUserInfo();
|
|
1458
1391
|
if (cancelled) return;
|
|
1459
1392
|
const info = result?.data?.user_info;
|
|
1460
1393
|
const userName = getNameFromArray(info?.name);
|
|
@@ -1518,6 +1451,7 @@ __name(useIsMobile, "useIsMobile");
|
|
|
1518
1451
|
|
|
1519
1452
|
// src/hooks/useLogout.ts
|
|
1520
1453
|
var import_react4 = require("react");
|
|
1454
|
+
var import_auth_sdk2 = require("@lark-apaas/auth-sdk");
|
|
1521
1455
|
function useLogout() {
|
|
1522
1456
|
const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
|
|
1523
1457
|
async function handlerLogout() {
|
|
@@ -1527,8 +1461,7 @@ function useLogout() {
|
|
|
1527
1461
|
}
|
|
1528
1462
|
setIsLoading(true);
|
|
1529
1463
|
try {
|
|
1530
|
-
|
|
1531
|
-
await dataloom2.service.session.signOut();
|
|
1464
|
+
await import_auth_sdk2.authClient.session.signOut();
|
|
1532
1465
|
} catch (error) {
|
|
1533
1466
|
console.error("\u767B\u51FA\u5931\u8D25", error);
|
|
1534
1467
|
} finally {
|
|
@@ -2877,6 +2810,74 @@ function getAxiosForBackend() {
|
|
|
2877
2810
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
2878
2811
|
var axiosForBackend = getAxiosForBackend();
|
|
2879
2812
|
|
|
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
|
+
|
|
2880
2881
|
// src/integrations/capabilityClient.ts
|
|
2881
2882
|
var import_client_capability = require("@lark-apaas/client-capability");
|
|
2882
2883
|
|