@lark-apaas/client-toolkit-lite 1.1.9 → 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 CHANGED
@@ -1359,6 +1359,7 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
1359
1359
 
1360
1360
  // src/hooks/useCurrentUserProfile.tsx
1361
1361
  var import_react2 = require("react");
1362
+ var import_auth_sdk = require("@lark-apaas/auth-sdk");
1362
1363
 
1363
1364
  // src/integrations/getCurrentUserProfile.ts
1364
1365
  function getCurrentUserProfile() {
@@ -1366,69 +1367,6 @@ function getCurrentUserProfile() {
1366
1367
  }
1367
1368
  __name(getCurrentUserProfile, "getCurrentUserProfile");
1368
1369
 
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
1370
  // src/hooks/useCurrentUserProfile.tsx
1433
1371
  function getNameFromArray(nameArray) {
1434
1372
  if (!nameArray || nameArray.length === 0) {
@@ -1453,8 +1391,7 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
1453
1391
  (0, import_react2.useEffect)(() => {
1454
1392
  let cancelled = false;
1455
1393
  const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
1456
- const dataloom2 = await getDataloom();
1457
- const result = await dataloom2?.service?.session?.getUserInfo();
1394
+ const result = await import_auth_sdk.authClient.session.getUserInfo();
1458
1395
  if (cancelled) return;
1459
1396
  const info = result?.data?.user_info;
1460
1397
  const userName = getNameFromArray(info?.name);
@@ -1518,6 +1455,7 @@ __name(useIsMobile, "useIsMobile");
1518
1455
 
1519
1456
  // src/hooks/useLogout.ts
1520
1457
  var import_react4 = require("react");
1458
+ var import_auth_sdk2 = require("@lark-apaas/auth-sdk");
1521
1459
  function useLogout() {
1522
1460
  const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
1523
1461
  async function handlerLogout() {
@@ -1527,8 +1465,7 @@ function useLogout() {
1527
1465
  }
1528
1466
  setIsLoading(true);
1529
1467
  try {
1530
- const dataloom2 = await getDataloom();
1531
- await dataloom2.service.session.signOut();
1468
+ await import_auth_sdk2.authClient.session.signOut();
1532
1469
  } catch (error) {
1533
1470
  console.error("\u767B\u51FA\u5931\u8D25", error);
1534
1471
  } finally {
@@ -2877,6 +2814,47 @@ function getAxiosForBackend() {
2877
2814
  __name(getAxiosForBackend, "getAxiosForBackend");
2878
2815
  var axiosForBackend = getAxiosForBackend();
2879
2816
 
2817
+ // src/integrations/dataloom.ts
2818
+ var import_dataloom = require("@lark-apaas/dataloom");
2819
+ var import_auth_sdk3 = require("@lark-apaas/auth-sdk");
2820
+ var createDataLoomClient = /* @__PURE__ */ __name(() => {
2821
+ const appId = getAppId() ?? "";
2822
+ return (0, import_dataloom.createClient)({
2823
+ global: {
2824
+ enableDataloomLog: process.env.NODE_ENV !== "production",
2825
+ requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
2826
+ brandName: "miaoda",
2827
+ appId,
2828
+ // 同源网关下不会触发预检;CSRF token 仅用于 POST/PUT/DELETE 防护。
2829
+ headers: {
2830
+ "X-Suda-Csrf-Token": getCsrfToken() ?? ""
2831
+ },
2832
+ accountServices: {
2833
+ user: import_auth_sdk3.authClient.user,
2834
+ session: import_auth_sdk3.authClient.session
2835
+ }
2836
+ }
2837
+ });
2838
+ }, "createDataLoomClient");
2839
+ var dataloom = null;
2840
+ var pendingPromise3 = null;
2841
+ function getDataloom() {
2842
+ if (dataloom) {
2843
+ return Promise.resolve(dataloom);
2844
+ }
2845
+ if (pendingPromise3) {
2846
+ return pendingPromise3;
2847
+ }
2848
+ pendingPromise3 = getInitialInfo().then(() => {
2849
+ dataloom = createDataLoomClient();
2850
+ return dataloom;
2851
+ }).finally(() => {
2852
+ pendingPromise3 = null;
2853
+ });
2854
+ return pendingPromise3;
2855
+ }
2856
+ __name(getDataloom, "getDataloom");
2857
+
2880
2858
  // src/integrations/capabilityClient.ts
2881
2859
  var import_client_capability = require("@lark-apaas/client-capability");
2882
2860