@lark-apaas/client-toolkit-lite 1.1.7-alpha.0 → 1.1.7-alpha.2
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 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +72 -67
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -340,6 +340,7 @@ var useAppInfo = /* @__PURE__ */ __name(() => {
|
|
|
340
340
|
|
|
341
341
|
// src/hooks/useCurrentUserProfile.tsx
|
|
342
342
|
var import_react2 = require("react");
|
|
343
|
+
var import_auth_sdk = require("@lark-apaas/auth-sdk");
|
|
343
344
|
|
|
344
345
|
// src/integrations/getCurrentUserProfile.ts
|
|
345
346
|
function getCurrentUserProfile() {
|
|
@@ -347,69 +348,6 @@ function getCurrentUserProfile() {
|
|
|
347
348
|
}
|
|
348
349
|
__name(getCurrentUserProfile, "getCurrentUserProfile");
|
|
349
350
|
|
|
350
|
-
// src/utils/url.ts
|
|
351
|
-
function splitWorkspaceUrl(fullUrl) {
|
|
352
|
-
try {
|
|
353
|
-
const url = new URL(fullUrl);
|
|
354
|
-
const pathParts = url.pathname.split("/");
|
|
355
|
-
const workspacesIndex = pathParts.findIndex((part) => part === "workspaces");
|
|
356
|
-
if (workspacesIndex === -1) {
|
|
357
|
-
throw new Error("Invalid workspace URL format");
|
|
358
|
-
}
|
|
359
|
-
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
360
|
-
const workspace = pathParts[workspacesIndex + 1];
|
|
361
|
-
return {
|
|
362
|
-
baseUrl: `${url.origin}${basePathParts.join("/")}`,
|
|
363
|
-
workspace
|
|
364
|
-
};
|
|
365
|
-
} catch (error) {
|
|
366
|
-
console.error("Error splitting workspace URL:", error);
|
|
367
|
-
}
|
|
368
|
-
return {
|
|
369
|
-
baseUrl: fullUrl,
|
|
370
|
-
// 兜底给一个,不要给空字符串,不然 createClient 都直接挂了,页面会白屏,体感不太好
|
|
371
|
-
workspace: "workspace"
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
__name(splitWorkspaceUrl, "splitWorkspaceUrl");
|
|
375
|
-
|
|
376
|
-
// src/integrations/dataloom.ts
|
|
377
|
-
var import_dataloom = require("@lark-apaas/dataloom");
|
|
378
|
-
var createDataLoomClient = /* @__PURE__ */ __name((url, pat) => {
|
|
379
|
-
const { baseUrl } = url ? splitWorkspaceUrl(url) : {
|
|
380
|
-
baseUrl: ""
|
|
381
|
-
};
|
|
382
|
-
const appId = getAppId() ?? "";
|
|
383
|
-
return (0, import_dataloom.createClient)(baseUrl, pat ?? "", {
|
|
384
|
-
global: {
|
|
385
|
-
enableDataloomLog: process.env.NODE_ENV !== "production",
|
|
386
|
-
requestRateLimit: process.env.NODE_ENV !== "production" ? 100 : void 0,
|
|
387
|
-
brandName: "miaoda",
|
|
388
|
-
appId
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}, "createDataLoomClient");
|
|
392
|
-
var dataloom = null;
|
|
393
|
-
var pendingPromise2 = null;
|
|
394
|
-
function getDataloom() {
|
|
395
|
-
if (dataloom) {
|
|
396
|
-
return Promise.resolve(dataloom);
|
|
397
|
-
}
|
|
398
|
-
if (pendingPromise2) {
|
|
399
|
-
return pendingPromise2;
|
|
400
|
-
}
|
|
401
|
-
pendingPromise2 = getInitialInfo().then((info) => {
|
|
402
|
-
const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
|
|
403
|
-
const DATALOOM_PAT = info?.app_runtime_extra?.token;
|
|
404
|
-
dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
|
|
405
|
-
return dataloom;
|
|
406
|
-
}).finally(() => {
|
|
407
|
-
pendingPromise2 = null;
|
|
408
|
-
});
|
|
409
|
-
return pendingPromise2;
|
|
410
|
-
}
|
|
411
|
-
__name(getDataloom, "getDataloom");
|
|
412
|
-
|
|
413
351
|
// src/hooks/useCurrentUserProfile.tsx
|
|
414
352
|
function getNameFromArray(nameArray) {
|
|
415
353
|
if (!nameArray || nameArray.length === 0) {
|
|
@@ -434,8 +372,7 @@ var useCurrentUserProfile = /* @__PURE__ */ __name(() => {
|
|
|
434
372
|
(0, import_react2.useEffect)(() => {
|
|
435
373
|
let cancelled = false;
|
|
436
374
|
const fetchAndSetUserInfo = /* @__PURE__ */ __name(async () => {
|
|
437
|
-
const
|
|
438
|
-
const result = await dataloom2?.service?.session?.getUserInfo();
|
|
375
|
+
const result = await import_auth_sdk.authClient.session.getUserInfo();
|
|
439
376
|
if (cancelled) return;
|
|
440
377
|
const info = result?.data?.user_info;
|
|
441
378
|
const userName = getNameFromArray(info?.name);
|
|
@@ -499,6 +436,7 @@ __name(useIsMobile, "useIsMobile");
|
|
|
499
436
|
|
|
500
437
|
// src/hooks/useLogout.ts
|
|
501
438
|
var import_react4 = require("react");
|
|
439
|
+
var import_auth_sdk2 = require("@lark-apaas/auth-sdk");
|
|
502
440
|
function useLogout() {
|
|
503
441
|
const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
|
|
504
442
|
async function handlerLogout() {
|
|
@@ -508,8 +446,7 @@ function useLogout() {
|
|
|
508
446
|
}
|
|
509
447
|
setIsLoading(true);
|
|
510
448
|
try {
|
|
511
|
-
|
|
512
|
-
await dataloom2.service.session.signOut();
|
|
449
|
+
await import_auth_sdk2.authClient.session.signOut();
|
|
513
450
|
} catch (error) {
|
|
514
451
|
console.error("\u767B\u51FA\u5931\u8D25", error);
|
|
515
452
|
} finally {
|
|
@@ -1762,6 +1699,74 @@ function getAxiosForBackend() {
|
|
|
1762
1699
|
__name(getAxiosForBackend, "getAxiosForBackend");
|
|
1763
1700
|
var axiosForBackend = getAxiosForBackend();
|
|
1764
1701
|
|
|
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
|
+
|
|
1765
1770
|
// src/constants/img-resources/avatar.ts
|
|
1766
1771
|
var avatar_exports = {};
|
|
1767
1772
|
__export(avatar_exports, {
|