@lark-apaas/client-toolkit 1.2.28-alpha.10 → 1.2.28-alpha.12

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,12 +1,14 @@
1
- import type { BatchGetUsersResponse, SearchUsersParams, SearchUsersResponse } from './types';
1
+ import type { BatchGetUsersResponse, ConvertExternalContactResponse, SearchUsersParams, SearchUsersResponse } from './types';
2
2
  export type UserServiceConfig = {
3
3
  getAppId?: () => string | null | undefined;
4
4
  searchUserUrl?: (appId: string) => string;
5
5
  listUsersUrl?: (appId: string) => string;
6
+ convertExternalContactUrl?: (appId: string) => string;
6
7
  };
7
8
  export declare class UserService {
8
9
  private config;
9
10
  constructor(config?: UserServiceConfig);
10
11
  searchUsers(params: SearchUsersParams): Promise<SearchUsersResponse>;
11
12
  listUsersByIds(userIds: string[]): Promise<BatchGetUsersResponse>;
13
+ convertExternalContact(larkUserID: string): Promise<ConvertExternalContactResponse>;
12
14
  }
@@ -3,7 +3,8 @@ import { isNewPathEnabled } from "../../utils/apiPath.js";
3
3
  const DEFAULT_CONFIG = {
4
4
  getAppId: ()=>getAppId(),
5
5
  searchUserUrl: (appId)=>isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/account/search_user` : `/af/app/${appId}/runtime/api/v1/account/search_user`,
6
- listUsersUrl: (appId)=>isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/account/list_users` : `/af/app/${appId}/runtime/api/v1/account/list_users`
6
+ listUsersUrl: (appId)=>isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/account/list_users` : `/af/app/${appId}/runtime/api/v1/account/list_users`,
7
+ convertExternalContactUrl: (appId)=>isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/account/convert_lark_user` : `/af/app/${appId}/runtime/api/v1/account/convert_lark_user`
7
8
  };
8
9
  class UserService {
9
10
  config;
@@ -43,5 +44,23 @@ class UserService {
43
44
  if (!response.ok) throw new Error('Failed to fetch users by ids');
44
45
  return response.json();
45
46
  }
47
+ async convertExternalContact(larkUserID) {
48
+ const appId = this.config.getAppId();
49
+ if (!appId) throw new Error('Failed to get appId');
50
+ const response = await fetch(this.config.convertExternalContactUrl(appId), {
51
+ method: 'POST',
52
+ headers: {
53
+ 'Content-Type': 'application/json'
54
+ },
55
+ body: JSON.stringify({
56
+ larkUserID
57
+ }),
58
+ credentials: 'include'
59
+ });
60
+ if (!response.ok) throw new Error('Failed to convert external contact');
61
+ const data = await response.json();
62
+ if (!data?.data?.userInfo?.userID) throw new Error('Invalid response from convert external contact');
63
+ return data;
64
+ }
46
65
  }
47
66
  export { UserService };
@@ -15,6 +15,7 @@ export type UserInfo = {
15
15
  userType: '_employee' | '_externalUser' | '_anonymousUser';
16
16
  department: DepartmentBasic;
17
17
  email?: string;
18
+ tenantName?: string;
18
19
  };
19
20
  export type DepartmentInfo = {
20
21
  departmentID: string;
@@ -33,6 +34,7 @@ export type SearchUsersParams = {
33
34
  query?: string;
34
35
  offset?: number;
35
36
  pageSize?: number;
37
+ searchExternalContact?: boolean;
36
38
  };
37
39
  export type SearchUsersResponse = {
38
40
  data: {
@@ -41,6 +43,14 @@ export type SearchUsersResponse = {
41
43
  };
42
44
  status_code: string;
43
45
  };
46
+ export type ConvertExternalContactResponse = {
47
+ data: {
48
+ userInfo: {
49
+ tenantID: number;
50
+ userID: number;
51
+ };
52
+ };
53
+ };
44
54
  export type BatchGetUsersResponse = {
45
55
  data: {
46
56
  userInfoMap: Record<string, UserInfo & SearchAvatar>;
@@ -9,12 +9,6 @@
9
9
  * @see docs/RFC_HMR_API.md
10
10
  */
11
11
  export interface HmrApi {
12
- /**
13
- * 注册 HMR 更新前回调(模块替换之前触发)
14
- * @param callback 回调函数
15
- * @returns cleanup 函数,用于取消注册
16
- */
17
- onBeforeApply?(callback: () => void): () => void;
18
12
  /**
19
13
  * 注册 HMR 成功回调
20
14
  * @param callback 成功回调函数
@@ -30,7 +24,7 @@ export interface HmrApi {
30
24
  }
31
25
  declare global {
32
26
  interface Window {
33
- __VITE_HMR__?: Required<HmrApi>;
27
+ __VITE_HMR__?: HmrApi;
34
28
  }
35
29
  }
36
30
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.28-alpha.10",
3
+ "version": "1.2.28-alpha.12",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -103,7 +103,7 @@
103
103
  "@lark-apaas/auth-sdk": "^0.1.2",
104
104
  "@lark-apaas/client-capability": "^0.1.6",
105
105
  "@lark-apaas/internal-slardar": "^0.0.3",
106
- "@lark-apaas/miaoda-inspector": "1.0.14-alpha.31",
106
+ "@lark-apaas/miaoda-inspector": "^1.0.20",
107
107
  "@lark-apaas/observable-web": "^1.0.5",
108
108
  "@radix-ui/react-avatar": "^1.1.10",
109
109
  "@radix-ui/react-popover": "^1.1.15",