@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.js
CHANGED
|
@@ -635,11 +635,7 @@ function batchLogInfo(level, message, source) {
|
|
|
635
635
|
defaultBatchLogger.batchLog(level, message, source);
|
|
636
636
|
}
|
|
637
637
|
__name(batchLogInfo, "batchLogInfo");
|
|
638
|
-
|
|
639
|
-
return process.env.NODE_ENV !== "production" && typeof window !== "undefined" && !!process.env.MIAODA_APP_TYPE;
|
|
640
|
-
}
|
|
641
|
-
__name(shouldEnableBatchLogger, "shouldEnableBatchLogger");
|
|
642
|
-
if (shouldEnableBatchLogger()) {
|
|
638
|
+
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
643
639
|
defaultBatchLogger = new BatchLogger(console);
|
|
644
640
|
}
|
|
645
641
|
|
|
@@ -1288,6 +1284,7 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
|
|
|
1288
1284
|
|
|
1289
1285
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1290
1286
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
1287
|
+
import { authClient } from "@lark-apaas/auth-sdk";
|
|
1291
1288
|
|
|
1292
1289
|
// src/integrations/getCurrentUserProfile.ts
|
|
1293
1290
|
function getCurrentUserProfile() {
|
|
@@ -1295,69 +1292,6 @@ function getCurrentUserProfile() {
|
|
|
1295
1292
|
}
|
|
1296
1293
|
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
1297
1294
|
|
|
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
|
-
|
|
1361
1295
|
// src/hooks/useCurrentUserProfile.tsx
|
|
1362
1296
|
function getNameFromArray(nameArray) {
|
|
1363
1297
|
if (!nameArray || nameArray.length === 0) {
|
|
@@ -1382,8 +1316,7 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
|
|
|
1382
1316
|
useEffect2(() => {
|
|
1383
1317
|
let cancelled = false;
|
|
1384
1318
|
const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
|
|
1385
|
-
const
|
|
1386
|
-
const result = await dataloom2?.service?.session?.getUserInfo();
|
|
1319
|
+
const result = await authClient.session.getUserInfo();
|
|
1387
1320
|
if (cancelled) return;
|
|
1388
1321
|
const info = result?.data?.user_info;
|
|
1389
1322
|
const userName = getNameFromArray(info?.name);
|
|
@@ -1447,6 +1380,7 @@ __name(useIsMobile, "useIsMobile");
|
|
|
1447
1380
|
|
|
1448
1381
|
// src/hooks/useLogout.ts
|
|
1449
1382
|
import { useState as useState3 } from "react";
|
|
1383
|
+
import { authClient as authClient2 } from "@lark-apaas/auth-sdk";
|
|
1450
1384
|
function useLogout() {
|
|
1451
1385
|
const [isLoading, setIsLoading] = useState3(false);
|
|
1452
1386
|
async function handlerLogout() {
|
|
@@ -1456,8 +1390,7 @@ function useLogout() {
|
|
|
1456
1390
|
}
|
|
1457
1391
|
setIsLoading(true);
|
|
1458
1392
|
try {
|
|
1459
|
-
|
|
1460
|
-
await dataloom2.service.session.signOut();
|
|
1393
|
+
await authClient2.session.signOut();
|
|
1461
1394
|
} catch (error) {
|
|
1462
1395
|
console.error("\u767B\u51FA\u5931\u8D25", error);
|
|
1463
1396
|
} finally {
|
|
@@ -2806,6 +2739,74 @@ function getAxiosForBackend() {
|
|
|
2806
2739
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
2807
2740
|
var axiosForBackend = getAxiosForBackend();
|
|
2808
2741
|
|
|
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
|
+
|
|
2809
2810
|
// src/integrations/capabilityClient.ts
|
|
2810
2811
|
import { createClient as createClient2 } from "@lark-apaas/client-capability";
|
|
2811
2812
|
|