@lark-apaas/client-toolkit-lite 1.1.7-alpha.2 → 1.1.7-alpha.4

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
@@ -72,6 +72,7 @@ module.exports = __toCommonJS(index_exports);
72
72
 
73
73
  // src/components/AppContainer/index.tsx
74
74
  var import_react7 = __toESM(require("react"), 1);
75
+ var import_miaoda_inspector = require("@lark-apaas/miaoda-inspector");
75
76
 
76
77
  // src/runtime/react-devtools-hook.ts
77
78
  if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
@@ -340,7 +341,6 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
340
341
 
341
342
  // src/hooks/useCurrentUserProfile.tsx
342
343
  var import_react2 = require("react");
343
- var import_auth_sdk = require("@lark-apaas/auth-sdk");
344
344
 
345
345
  // src/integrations/getCurrentUserProfile.ts
346
346
  function getCurrentUserProfile() {
@@ -348,6 +348,69 @@ function getCurrentUserProfile() {
348
348
  }
349
349
  __name(getCurrentUserProfile, "getCurrentUserProfile");
350
350
 
351
+ // src/utils/url.ts
352
+ function splitWorkspaceUrl(fullUrl) {
353
+ try {
354
+ const url = new URL(fullUrl);
355
+ const pathParts = url.pathname.split("/");
356
+ const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
357
+ if (workspacesIndex === -1) {
358
+ throw new Error("Invalid workspace URL format");
359
+ }
360
+ const basePathParts = pathParts.slice(0, workspacesIndex);
361
+ const workspace = pathParts[workspacesIndex + 1];
362
+ return {
363
+ baseUrl: `${url.origin}${basePathParts.join("/")}`,
364
+ workspace
365
+ };
366
+ } catch (error) {
367
+ console.error("Error splitting workspace URL:", error);
368
+ }
369
+ return {
370
+ baseUrl: fullUrl,
371
+ // 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
372
+ workspace: "workspace"
373
+ };
374
+ }
375
+ __name(splitWorkspaceUrl, "splitWorkspaceUrl");
376
+
377
+ // src/integrations/dataloom.ts
378
+ var import_dataloom = require("@lark-apaas/dataloom");
379
+ var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
380
+ const { baseUrl } = url ? splitWorkspaceUrl(url) : {
381
+ baseUrl: ""
382
+ };
383
+ const appId = getAppId() ?? "";
384
+ return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
385
+ global: {
386
+ enableDataloomLog: process.env.NODE_ENV !== "production",
387
+ requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
388
+ brandName: "miaoda",
389
+ appId
390
+ }
391
+ });
392
+ }, "createDataLoomClient");
393
+ var dataloom = null;
394
+ var pendingPromise2 = null;
395
+ function getDataloom() {
396
+ if (dataloom) {
397
+ return Promise.resolve(dataloom);
398
+ }
399
+ if (pendingPromise2) {
400
+ return pendingPromise2;
401
+ }
402
+ pendingPromise2 = getInitialInfo().then((info) => {
403
+ const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
404
+ const DATALOOM_PAT = info?.app_runtime_extra?.token;
405
+ dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
406
+ return dataloom;
407
+ }).finally(() => {
408
+ pendingPromise2 = null;
409
+ });
410
+ return pendingPromise2;
411
+ }
412
+ __name(getDataloom, "getDataloom");
413
+
351
414
  // src/hooks/useCurrentUserProfile.tsx
352
415
  function getNameFromArray(nameArray) {
353
416
  if (!nameArray || nameArray.length === 0) {
@@ -372,7 +435,8 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
372
435
  (0, import_react2.useEffect)(() => {
373
436
  let cancelled = false;
374
437
  const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
375
- const result = await import_auth_sdk.authClient.session.getUserInfo();
438
+ const dataloom2 = await getDataloom();
439
+ const result = await dataloom2?.service?.session?.getUserInfo();
376
440
  if (cancelled) return;
377
441
  const info = result?.data?.user_info;
378
442
  const userName = getNameFromArray(info?.name);
@@ -436,7 +500,6 @@ __name(useIsMobile, "useIsMobile");
436
500
 
437
501
  // src/hooks/useLogout.ts
438
502
  var import_react4 = require("react");
439
- var import_auth_sdk2 = require("@lark-apaas/auth-sdk");
440
503
  function useLogout() {
441
504
  const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
442
505
  async function handlerLogout() {
@@ -446,7 +509,8 @@ function useLogout() {
446
509
  }
447
510
  setIsLoading(true);
448
511
  try {
449
- await import_auth_sdk2.authClient.session.signOut();
512
+ const dataloom2 = await getDataloom();
513
+ await dataloom2.service.session.signOut();
450
514
  } catch (error) {
451
515
  console.error("\u767B\u51FA\u5931\u8D25", error);
452
516
  } finally {
@@ -1205,7 +1269,7 @@ var AppContainer = /* @__PURE__ */ __name(({ children }) => {
1205
1269
  });
1206
1270
  }
1207
1271
  }, []);
1208
- return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(safety_default, null), /* @__PURE__ */ import_react7.default.createElement(QueryProvider_default, null, children));
1272
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(safety_default, null), process.env.NODE_ENV !== "production" && /* @__PURE__ */ import_react7.default.createElement(import_miaoda_inspector.MiaodaInspector, null), /* @__PURE__ */ import_react7.default.createElement(QueryProvider_default, null, children));
1209
1273
  }, "AppContainer");
1210
1274
  var AppContainer_default = AppContainer;
1211
1275
 
@@ -1699,74 +1763,6 @@ function getAxiosForBackend() {
1699
1763
  __name(getAxiosForBackend, "getAxiosForBackend");
1700
1764
  var axiosForBackend = getAxiosForBackend();
1701
1765
 
1702
- // src/utils/url.ts
1703
- function splitWorkspaceUrl(fullUrl) {
1704
- try {
1705
- const url = new URL(fullUrl);
1706
- const pathParts = url.pathname.split("/");
1707
- const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
1708
- if (workspacesIndex === -1) {
1709
- throw new Error("Invalid workspace URL format");
1710
- }
1711
- const basePathParts = pathParts.slice(0, workspacesIndex);
1712
- const workspace = pathParts[workspacesIndex + 1];
1713
- return {
1714
- baseUrl: `${url.origin}${basePathParts.join("/")}`,
1715
- workspace
1716
- };
1717
- } catch (error) {
1718
- console.error("Error splitting workspace URL:", error);
1719
- }
1720
- return {
1721
- baseUrl: fullUrl,
1722
- // 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
1723
- workspace: "workspace"
1724
- };
1725
- }
1726
- __name(splitWorkspaceUrl, "splitWorkspaceUrl");
1727
-
1728
- // src/integrations/dataloom.ts
1729
- var import_dataloom = require("@lark-apaas/dataloom");
1730
- var import_auth_sdk3 = require("@lark-apaas/auth-sdk");
1731
- var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
1732
- const { baseUrl } = url ? splitWorkspaceUrl(url) : {
1733
- baseUrl: ""
1734
- };
1735
- const appId = getAppId() ?? "";
1736
- return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
1737
- global: {
1738
- enableDataloomLog: process.env.NODE_ENV !== "production",
1739
- requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
1740
- brandName: "miaoda",
1741
- appId,
1742
- accountServices: {
1743
- user: import_auth_sdk3.authClient.user,
1744
- session: import_auth_sdk3.authClient.session
1745
- }
1746
- }
1747
- });
1748
- }, "createDataLoomClient");
1749
- var dataloom = null;
1750
- var pendingPromise2 = null;
1751
- function getDataloom() {
1752
- if (dataloom) {
1753
- return Promise.resolve(dataloom);
1754
- }
1755
- if (pendingPromise2) {
1756
- return pendingPromise2;
1757
- }
1758
- pendingPromise2 = getInitialInfo().then((info) => {
1759
- const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
1760
- const DATALOOM_PAT = info?.app_runtime_extra?.token;
1761
- dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
1762
- return dataloom;
1763
- }).finally(() => {
1764
- pendingPromise2 = null;
1765
- });
1766
- return pendingPromise2;
1767
- }
1768
- __name(getDataloom, "getDataloom");
1769
-
1770
1766
  // src/constants/img-resources/avatar.ts
1771
1767
  var avatar_exports = {};
1772
1768
  __export(avatar_exports, {