@lark-apaas/client-toolkit 1.2.53-alpha.2 → 1.2.53-beta.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.
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { IUserProfile } from '../apis/udt-types';
|
|
2
2
|
/**
|
|
3
3
|
* useCurrentUserProfile 的返回类型。
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 判断是否已加载完成应使用 `if (!userInfo?.user_id)` 而非 `if (!userInfo)`(因为空对象是 truthy)。
|
|
4
|
+
* 与 client-toolkit-lite 完全一致:所有字段保证非 undefined(未加载时为空字符串),
|
|
5
|
+
* 使用 `if (!userInfo.user_id)` 判断是否已加载完成。
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
7
|
+
export interface ICompatibilityUserProfile extends IUserProfile {
|
|
9
8
|
/**
|
|
10
9
|
* @deprecated please use `name`
|
|
11
10
|
*/
|
|
@@ -14,14 +13,5 @@ export type ICompatibilityUserProfile = Partial<IUserProfile & {
|
|
|
14
13
|
* @deprecated please use `avatar`
|
|
15
14
|
*/
|
|
16
15
|
userAvatar: string;
|
|
17
|
-
}
|
|
18
|
-
export declare const useCurrentUserProfile: () =>
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated please use `name`
|
|
21
|
-
*/
|
|
22
|
-
userName: string;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated please use `avatar`
|
|
25
|
-
*/
|
|
26
|
-
userAvatar: string;
|
|
27
|
-
}>;
|
|
16
|
+
}
|
|
17
|
+
export declare const useCurrentUserProfile: () => ICompatibilityUserProfile;
|
|
@@ -25,9 +25,14 @@ function fetchLarkUserId() {
|
|
|
25
25
|
function getCompatibilityUserProfile() {
|
|
26
26
|
const userInfo = getCurrentUserProfile();
|
|
27
27
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
user_id: userInfo.user_id ?? '',
|
|
29
|
+
email: userInfo.email ?? '',
|
|
30
|
+
name: userInfo.name ?? '',
|
|
31
|
+
avatar: userInfo.avatar ?? '',
|
|
32
|
+
status: userInfo.status,
|
|
33
|
+
lark_user_id: userInfo.lark_user_id,
|
|
34
|
+
userName: userInfo.name ?? '',
|
|
35
|
+
userAvatar: userInfo.avatar ?? ''
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
const useCurrentUserProfile = ()=>{
|
|
@@ -38,14 +43,15 @@ const useCurrentUserProfile = ()=>{
|
|
|
38
43
|
const result = await authClient.session.getUserInfo();
|
|
39
44
|
if (cancelled) return;
|
|
40
45
|
const info = result?.data?.user_info;
|
|
41
|
-
const userName = getNameFromArray(info?.name);
|
|
46
|
+
const userName = getNameFromArray(info?.name) ?? '';
|
|
47
|
+
const avatar = info?.avatar?.image?.large ?? '';
|
|
42
48
|
const newUserInfo = {
|
|
43
|
-
user_id: info?.user_id?.toString(),
|
|
44
|
-
email: info?.email,
|
|
49
|
+
user_id: info?.user_id?.toString() ?? '',
|
|
50
|
+
email: info?.email ?? '',
|
|
45
51
|
name: userName,
|
|
46
|
-
avatar
|
|
47
|
-
userName
|
|
48
|
-
userAvatar:
|
|
52
|
+
avatar,
|
|
53
|
+
userName,
|
|
54
|
+
userAvatar: avatar
|
|
49
55
|
};
|
|
50
56
|
const larkUserId = await fetchLarkUserId();
|
|
51
57
|
if (larkUserId) newUserInfo.lark_user_id = larkUserId;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
|
+
import { getAppId } from './utils/getAppId';
|
|
2
|
+
import { logger } from './logger';
|
|
1
3
|
export declare const capabilityClient: import("@lark-apaas/client-capability").CapabilityClient;
|
|
2
4
|
export { showConfirm } from './components/ui/confirm';
|
|
3
5
|
export type { ConfirmOptions } from './components/ui/confirm';
|
|
6
|
+
export { default as AppContainer } from './components/AppContainer';
|
|
7
|
+
export { default as QueryProvider } from './components/QueryProvider';
|
|
8
|
+
export { default as PagePlaceholder } from './components/PagePlaceholder';
|
|
9
|
+
export { default as Welcome } from './components/PagePlaceholder';
|
|
10
|
+
export { default as ErrorRender } from './components/ErrorRender';
|
|
11
|
+
export { ActiveLink } from './apis/components/ActiveLink';
|
|
12
|
+
export { NavLink } from './apis/components/NavLink';
|
|
13
|
+
export { UniversalLink } from './apis/components/UniversalLink';
|
|
14
|
+
export { useAppInfo } from './hooks/useAppInfo';
|
|
15
|
+
export { useCurrentUserProfile } from './hooks/useCurrentUserProfile';
|
|
16
|
+
export { useIsMobile } from './hooks/useIsMobile';
|
|
17
|
+
export { useLogout } from './hooks/useLogout';
|
|
18
|
+
export { clsxWithTw, isPreview, normalizeBasePath, getWsPath } from './utils/utils';
|
|
19
|
+
export { getCsrfToken } from './utils/getCsrfToken';
|
|
20
|
+
export { scopedStorage } from './utils/scopedStorage';
|
|
21
|
+
export { copyToClipboard } from './utils/copyToClipboard';
|
|
22
|
+
export { isIpad, isMobile, isIOS } from './utils/deviceType';
|
|
23
|
+
export { resolveAppUrl } from './utils/resolveAppUrl';
|
|
24
|
+
export { getEnvPath } from './utils/getEnvPath';
|
|
25
|
+
export { safeStringify } from './utils/safeStringify';
|
|
26
|
+
export { getAxiosForBackend, axiosForBackend } from './utils/getAxiosForBackend';
|
|
27
|
+
export { initAxiosConfig } from './utils/axiosConfig';
|
|
28
|
+
export { getAppId };
|
|
29
|
+
export { getAppInfo } from './integrations/getAppInfo';
|
|
30
|
+
export { getCurrentUserProfile } from './integrations/getCurrentUserProfile';
|
|
31
|
+
export { getDataloom } from './integrations/dataloom';
|
|
32
|
+
export { logger };
|
|
33
|
+
export type { LogLevel, LogWithMeta } from './logger/log-types';
|
|
34
|
+
export { trace } from './trace';
|
|
35
|
+
export { initObservable } from './runtime/observable';
|
|
36
|
+
export type { AppInfoPayload } from './types/common';
|
|
37
|
+
export type { IUserProfile, IJson, IFileAttachment } from './apis/udt-types';
|
|
38
|
+
export type { TrackParams } from './types/tea';
|
|
39
|
+
export { TrackKey } from './types/tea';
|
|
40
|
+
export { reportTeaEvent } from './components/AppContainer/utils/tea';
|
|
41
|
+
export * as avatarImages from './apis/constants/img-resources/avatar';
|
|
42
|
+
export * as bannerImages from './apis/constants/img-resources/banner';
|
|
43
|
+
export * as coverImages from './apis/constants/img-resources/cover';
|
|
4
44
|
declare const _default: {
|
|
5
45
|
version: string;
|
|
6
46
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createClient } from "@lark-apaas/client-capability";
|
|
2
|
-
import { normalizeBasePath } from "./utils/utils.js";
|
|
2
|
+
import { clsxWithTw, getWsPath, isPreview, normalizeBasePath } from "./utils/utils.js";
|
|
3
3
|
import { getAppId } from "./utils/getAppId.js";
|
|
4
4
|
import { isNewPathEnabled } from "./utils/apiPath.js";
|
|
5
5
|
import { logger } from "./logger/index.js";
|
|
@@ -7,6 +7,36 @@ import { showToast } from "./components/ui/toast.js";
|
|
|
7
7
|
import { t } from "./locales/index.js";
|
|
8
8
|
import { version } from "../package.json";
|
|
9
9
|
import { showConfirm } from "./components/ui/confirm.js";
|
|
10
|
+
import AppContainer from "./components/AppContainer/index.js";
|
|
11
|
+
import QueryProvider from "./components/QueryProvider/index.js";
|
|
12
|
+
import PagePlaceholder from "./components/PagePlaceholder/index.js";
|
|
13
|
+
import ErrorRender from "./components/ErrorRender/index.js";
|
|
14
|
+
import { ActiveLink } from "./apis/components/ActiveLink.js";
|
|
15
|
+
import { NavLink } from "./apis/components/NavLink.js";
|
|
16
|
+
import { UniversalLink } from "./apis/components/UniversalLink.js";
|
|
17
|
+
import { useAppInfo } from "./hooks/useAppInfo.js";
|
|
18
|
+
import { useCurrentUserProfile } from "./hooks/useCurrentUserProfile.js";
|
|
19
|
+
import { useIsMobile } from "./hooks/useIsMobile.js";
|
|
20
|
+
import { useLogout } from "./hooks/useLogout.js";
|
|
21
|
+
import { getCsrfToken } from "./utils/getCsrfToken.js";
|
|
22
|
+
import { scopedStorage } from "./utils/scopedStorage.js";
|
|
23
|
+
import { copyToClipboard } from "./utils/copyToClipboard.js";
|
|
24
|
+
import { isIOS, isIpad, isMobile } from "./utils/deviceType.js";
|
|
25
|
+
import { resolveAppUrl } from "./utils/resolveAppUrl.js";
|
|
26
|
+
import { getEnvPath } from "./utils/getEnvPath.js";
|
|
27
|
+
import { safeStringify } from "./utils/safeStringify.js";
|
|
28
|
+
import { axiosForBackend, getAxiosForBackend } from "./utils/getAxiosForBackend.js";
|
|
29
|
+
import { initAxiosConfig } from "./utils/axiosConfig.js";
|
|
30
|
+
import { getAppInfo } from "./integrations/getAppInfo.js";
|
|
31
|
+
import { getCurrentUserProfile } from "./integrations/getCurrentUserProfile.js";
|
|
32
|
+
import { getDataloom } from "./integrations/dataloom.js";
|
|
33
|
+
import { trace } from "./trace/index.js";
|
|
34
|
+
import { initObservable } from "./runtime/observable.js";
|
|
35
|
+
import { TrackKey } from "./types/tea.js";
|
|
36
|
+
import { reportTeaEvent } from "./components/AppContainer/utils/tea.js";
|
|
37
|
+
import * as __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_avatar_js_2c154035__ from "./apis/constants/img-resources/avatar.js";
|
|
38
|
+
import * as __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_banner_js_72c990bf__ from "./apis/constants/img-resources/banner.js";
|
|
39
|
+
import * as __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_cover_js_90a812c2__ from "./apis/constants/img-resources/cover.js";
|
|
10
40
|
const _appId = getAppId();
|
|
11
41
|
const _acquireUploadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_upload_url` : "/af/api/v1/studio/plugins/tmp_files/acquire_upload_url";
|
|
12
42
|
const _acquireDownloadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_download_url` : "/af/api/v1/studio/plugins/tmp_files/acquire_download_url";
|
|
@@ -27,4 +57,4 @@ const capabilityClient = createClient({
|
|
|
27
57
|
const src = {
|
|
28
58
|
version: version
|
|
29
59
|
};
|
|
30
|
-
export { capabilityClient, src as default, showConfirm };
|
|
60
|
+
export { ActiveLink, AppContainer, ErrorRender, NavLink, PagePlaceholder, QueryProvider, TrackKey, UniversalLink, PagePlaceholder as Welcome, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_avatar_js_2c154035__ as avatarImages, axiosForBackend, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_banner_js_72c990bf__ as bannerImages, capabilityClient, clsxWithTw, copyToClipboard, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_cover_js_90a812c2__ as coverImages, src as default, getAppId, getAppInfo, getAxiosForBackend, getCsrfToken, getCurrentUserProfile, getDataloom, getEnvPath, getWsPath, initAxiosConfig, initObservable, isIOS, isIpad, isMobile, isPreview, logger, normalizeBasePath, reportTeaEvent, resolveAppUrl, safeStringify, scopedStorage, showConfirm, trace, useAppInfo, useCurrentUserProfile, useIsMobile, useLogout };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { IUserProfile } from '../apis/udt-types';
|
|
2
2
|
/**
|
|
3
3
|
* 获取当前用户信息。
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 异步获取用户信息后才会被填充为完整的 IUserProfile。
|
|
4
|
+
* 与 client-toolkit-lite 一致返回 IUserProfile(非 Partial);
|
|
5
|
+
* 调用方需自行处理 window._userInfo 未就绪时空对象的情况。
|
|
7
6
|
*/
|
|
8
|
-
export declare function getCurrentUserProfile():
|
|
7
|
+
export declare function getCurrentUserProfile(): IUserProfile;
|
|
9
8
|
/**
|
|
10
9
|
* @deprecated 请使用 getCurrentUserProfile 代替
|
|
11
10
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.2.53-
|
|
3
|
+
"version": "1.2.53-beta.0",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"types": "./lib/antd-table.d.ts"
|
|
27
27
|
},
|
|
28
28
|
"./lib/index.css": "./lib/index.css",
|
|
29
|
+
"./styles.css": "./lib/index.css",
|
|
29
30
|
"./dataloom": {
|
|
30
31
|
"import": "./lib/apis/dataloom.js",
|
|
31
32
|
"require": "./lib/apis/dataloom.js",
|