@lark-apaas/client-toolkit 1.2.28-alpha.7 → 1.2.28-alpha.71
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/lib/apis/udt-types.d.ts +4 -0
- package/lib/auth.d.ts +2 -1
- package/lib/auth.js +2 -2
- package/lib/components/AppContainer/index.js +61 -45
- package/lib/components/AppContainer/safety.js +24 -52
- package/lib/hooks/useCurrentUserProfile.d.ts +18 -3
- package/lib/hooks/useCurrentUserProfile.js +16 -0
- package/lib/integrations/getCurrentUserProfile.d.ts +7 -1
- package/lib/integrations/services/UserService.d.ts +3 -1
- package/lib/integrations/services/UserService.js +20 -1
- package/lib/integrations/services/types.d.ts +10 -0
- package/lib/locales/index.d.ts +15 -0
- package/lib/locales/index.js +10 -0
- package/lib/locales/messages.d.ts +12 -0
- package/lib/locales/messages.js +36 -0
- package/lib/utils/axiosConfig.js +25 -2
- package/lib/utils/getInitialInfo.js +14 -0
- package/lib/utils/hmr-api.d.ts +7 -1
- package/lib/utils/locale.d.ts +9 -0
- package/lib/utils/locale.js +5 -0
- package/lib/utils/safeStringify.js +5 -0
- package/lib/utils/safeStringify.spec.d.ts +1 -0
- package/lib/utils/safeStringify.spec.js +125 -0
- package/package.json +6 -6
package/lib/apis/udt-types.d.ts
CHANGED
package/lib/auth.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { CanRole, AbilityContext, ROLE_SUBJECT } from '@lark-apaas/auth-sdk';
|
|
1
|
+
export { AuthProvider, useAuth, Can, CanRole, useCan, AbilityContext, useUserPermissions, PermissionClient, ROLE_SUBJECT, } from '@lark-apaas/auth-sdk';
|
|
2
|
+
export type { AuthProviderProps, PermissionApiResponse, PermissionApiConfig, PermissionPointData, AuthSdkConfig, } from '@lark-apaas/auth-sdk';
|
package/lib/auth.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AbilityContext, CanRole, ROLE_SUBJECT } from "@lark-apaas/auth-sdk";
|
|
2
|
-
export { AbilityContext, CanRole, ROLE_SUBJECT };
|
|
1
|
+
import { AbilityContext, AuthProvider, Can, CanRole, PermissionClient, ROLE_SUBJECT, useAuth, useCan, useUserPermissions } from "@lark-apaas/auth-sdk";
|
|
2
|
+
export { AbilityContext, AuthProvider, Can, CanRole, PermissionClient, ROLE_SUBJECT, useAuth, useCan, useUserPermissions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import react, { Suspense, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { ConfigProvider } from "antd";
|
|
4
4
|
import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
|
|
5
5
|
import zh_CN from "antd/locale/zh_CN";
|
|
@@ -9,20 +9,34 @@ import { PageHoc } from "./PageHoc.js";
|
|
|
9
9
|
import { reportTeaEvent } from "./utils/tea.js";
|
|
10
10
|
import { useAppInfo } from "../../hooks/index.js";
|
|
11
11
|
import { TrackKey } from "../../types/tea.js";
|
|
12
|
-
import
|
|
12
|
+
import { slardar } from "@lark-apaas/internal-slardar";
|
|
13
13
|
import { getAppId } from "../../utils/getAppId.js";
|
|
14
14
|
import { isNewPathEnabled } from "../../utils/apiPath.js";
|
|
15
15
|
import QueryProvider from "../QueryProvider/index.js";
|
|
16
16
|
import { AuthProvider } from "@lark-apaas/auth-sdk";
|
|
17
17
|
import "../../runtime/index.js";
|
|
18
|
+
const Safety = /*#__PURE__*/ react.lazy(()=>import("./safety.js"));
|
|
18
19
|
const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
|
|
19
|
-
const
|
|
20
|
+
const readAllCssVarColors = ()=>{
|
|
20
21
|
try {
|
|
21
|
-
if ('undefined' == typeof document) return
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
if ('undefined' == typeof document) return {};
|
|
23
|
+
const styles = getComputedStyle(document.documentElement);
|
|
24
|
+
const read = (name)=>styles.getPropertyValue(name).trim() || void 0;
|
|
25
|
+
return {
|
|
26
|
+
background: read('--background'),
|
|
27
|
+
destructive: read('--destructive'),
|
|
28
|
+
primary: read('--primary'),
|
|
29
|
+
foreground: read('--foreground'),
|
|
30
|
+
warning: read('--warning'),
|
|
31
|
+
success: read('--success'),
|
|
32
|
+
muted: read('--muted'),
|
|
33
|
+
mutedForeground: read('--muted-foreground'),
|
|
34
|
+
border: read('--border'),
|
|
35
|
+
popover: read('--popover'),
|
|
36
|
+
accent: read('--accent')
|
|
37
|
+
};
|
|
24
38
|
} catch {
|
|
25
|
-
return
|
|
39
|
+
return {};
|
|
26
40
|
}
|
|
27
41
|
};
|
|
28
42
|
const appFlags = process.env.APP_FLAGS || {};
|
|
@@ -38,24 +52,47 @@ const App = (props)=>{
|
|
|
38
52
|
});
|
|
39
53
|
}, []);
|
|
40
54
|
useEffect(()=>{
|
|
41
|
-
if ('production' === process.env.NODE_ENV)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
if ('production' === process.env.NODE_ENV) {
|
|
56
|
+
reportTeaEvent({
|
|
57
|
+
trackKey: TrackKey.VIEW,
|
|
58
|
+
trackParams: {
|
|
59
|
+
artifact_uid: getAppId(),
|
|
60
|
+
agent_id: 'agent_miaoda',
|
|
61
|
+
url: window.location.href
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const appId = getAppId();
|
|
65
|
+
const firstRenderTime = Math.round(performance.now());
|
|
66
|
+
const navEntry = performance.getEntriesByType('navigation')[0];
|
|
67
|
+
const pageLoadTime = navEntry && navEntry.loadEventEnd > 0 ? Math.round(navEntry.loadEventEnd - navEntry.startTime) : void 0;
|
|
68
|
+
slardar.sendEvent({
|
|
69
|
+
name: 'app-first-render',
|
|
70
|
+
metrics: {
|
|
71
|
+
firstRenderTime,
|
|
72
|
+
...null != pageLoadTime ? {
|
|
73
|
+
pageLoadTime
|
|
74
|
+
} : {}
|
|
75
|
+
},
|
|
76
|
+
categories: {
|
|
77
|
+
appId: appId ?? 'unknown',
|
|
78
|
+
mode: isMiaodaPreview ? 'preview' : 'runtime'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
49
82
|
}, []);
|
|
50
83
|
const appId = getAppId();
|
|
51
84
|
const permissionApiUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/permissions/roles` : `/spark/app/${appId}/runtime/api/v1/permissions/roles`;
|
|
52
|
-
|
|
53
|
-
config: {
|
|
85
|
+
const authConfig = useMemo(()=>({
|
|
54
86
|
enable: enableAuth,
|
|
55
87
|
permissionApi: {
|
|
56
88
|
url: permissionApiUrl
|
|
57
89
|
}
|
|
58
|
-
},
|
|
90
|
+
}), [
|
|
91
|
+
enableAuth,
|
|
92
|
+
permissionApiUrl
|
|
93
|
+
]);
|
|
94
|
+
return /*#__PURE__*/ jsxs(AuthProvider, {
|
|
95
|
+
config: authConfig,
|
|
59
96
|
children: [
|
|
60
97
|
!disableToaster && true !== appFlags.customToaster && /*#__PURE__*/ jsx(Toaster, {}),
|
|
61
98
|
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {}),
|
|
@@ -68,19 +105,7 @@ const App = (props)=>{
|
|
|
68
105
|
};
|
|
69
106
|
const AppContainer_AppContainer = (props)=>{
|
|
70
107
|
const { children } = props;
|
|
71
|
-
const [cssColors, setCssColors] = useState(
|
|
72
|
-
background: readCssVarColor('--background'),
|
|
73
|
-
destructive: readCssVarColor('--destructive'),
|
|
74
|
-
primary: readCssVarColor('--primary'),
|
|
75
|
-
foreground: readCssVarColor('--foreground'),
|
|
76
|
-
warning: readCssVarColor('--warning'),
|
|
77
|
-
success: readCssVarColor('--success'),
|
|
78
|
-
muted: readCssVarColor('--muted'),
|
|
79
|
-
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
80
|
-
border: readCssVarColor('--border'),
|
|
81
|
-
popover: readCssVarColor('--popover'),
|
|
82
|
-
accent: readCssVarColor('--accent')
|
|
83
|
-
}));
|
|
108
|
+
const [cssColors, setCssColors] = useState(readAllCssVarColors);
|
|
84
109
|
useEffect(()=>{
|
|
85
110
|
if ('production' === process.env.NODE_ENV) return ()=>{};
|
|
86
111
|
const observer = new MutationObserver((mutations)=>{
|
|
@@ -99,19 +124,7 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
99
124
|
const maxRetries = 10;
|
|
100
125
|
const retryDelay = 400;
|
|
101
126
|
const updateColors = ()=>{
|
|
102
|
-
const newColors =
|
|
103
|
-
background: readCssVarColor('--background'),
|
|
104
|
-
destructive: readCssVarColor('--destructive'),
|
|
105
|
-
primary: readCssVarColor('--primary'),
|
|
106
|
-
foreground: readCssVarColor('--foreground'),
|
|
107
|
-
warning: readCssVarColor('--warning'),
|
|
108
|
-
success: readCssVarColor('--success'),
|
|
109
|
-
muted: readCssVarColor('--muted'),
|
|
110
|
-
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
111
|
-
border: readCssVarColor('--border'),
|
|
112
|
-
popover: readCssVarColor('--popover'),
|
|
113
|
-
accent: readCssVarColor('--accent')
|
|
114
|
-
};
|
|
127
|
+
const newColors = readAllCssVarColors();
|
|
115
128
|
setCssColors((currentColors)=>{
|
|
116
129
|
if (JSON.stringify(currentColors) !== JSON.stringify(newColors)) {
|
|
117
130
|
retryCount = 0;
|
|
@@ -183,7 +196,10 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
183
196
|
};
|
|
184
197
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
185
198
|
children: [
|
|
186
|
-
/*#__PURE__*/ jsx(
|
|
199
|
+
/*#__PURE__*/ jsx(Suspense, {
|
|
200
|
+
fallback: null,
|
|
201
|
+
children: /*#__PURE__*/ jsx(Safety, {})
|
|
202
|
+
}),
|
|
187
203
|
/*#__PURE__*/ jsx(QueryProvider, {
|
|
188
204
|
children: /*#__PURE__*/ jsx(ConfigProvider, {
|
|
189
205
|
locale: zh_CN,
|
|
@@ -1,59 +1,33 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
|
|
4
|
-
import { getCsrfToken } from "../../utils/getCsrfToken.js";
|
|
5
4
|
import { getAppId } from "../../utils/getAppId.js";
|
|
6
|
-
import { isNewPathEnabled } from "../../utils/apiPath.js";
|
|
7
5
|
import { useIsMobile } from "../../hooks/index.js";
|
|
8
6
|
import { X } from "lucide-react";
|
|
9
7
|
import { Sheet, SheetContent, SheetTrigger } from "../ui/drawer.js";
|
|
8
|
+
import { t } from "../../locales/index.js";
|
|
10
9
|
const Component = ()=>{
|
|
11
10
|
const HasClosedKey = `miaoda-creatByMiaoda-has-closed-${getAppId()}`;
|
|
12
11
|
const [visible, setVisible] = useState(!window.localStorage?.getItem(HasClosedKey));
|
|
13
12
|
const [open, setOpen] = useState(false);
|
|
14
13
|
const isMobile = useIsMobile();
|
|
15
|
-
const [userinfo, setUserinfo] = useState(null);
|
|
16
|
-
const [isInternetVisible, setIsInternetVisible] = useState(false);
|
|
17
|
-
const [showBadge, setShowBadge] = useState(true);
|
|
18
|
-
const [badgeLoaded, setBadgeLoaded] = useState(false);
|
|
19
14
|
const timeoutRef = useRef(null);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
const tenantInfoUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/tenant_info` : `/spark/b/${appId}/tenant_info`;
|
|
26
|
-
fetch(tenantInfoUrl, {
|
|
27
|
-
headers: csrfHeaders
|
|
28
|
-
}).then((res)=>res.json()).then((data)=>{
|
|
29
|
-
setUserinfo(data?.data?.tenant_info);
|
|
30
|
-
setIsInternetVisible(data?.data?.is_internet_visible);
|
|
31
|
-
}).catch(()=>{});
|
|
32
|
-
const getPublishedUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/get_published` : `/spark/b/${appId}/get_published`;
|
|
33
|
-
fetch(getPublishedUrl, {
|
|
34
|
-
headers: csrfHeaders
|
|
35
|
-
}).then((res)=>res.json()).then((data)=>{
|
|
36
|
-
const badge = data?.data?.app_info?.show_badge;
|
|
37
|
-
setShowBadge(false !== badge);
|
|
38
|
-
}).catch(()=>{
|
|
39
|
-
setShowBadge(true);
|
|
40
|
-
}).finally(()=>{
|
|
41
|
-
setBadgeLoaded(true);
|
|
42
|
-
});
|
|
43
|
-
}, []);
|
|
15
|
+
const platformData = window.__platform__ ?? {};
|
|
16
|
+
const tenantName = platformData.tenantName ?? '';
|
|
17
|
+
const isInternetVisible = platformData.isInternetVisible ?? false;
|
|
18
|
+
const showBadge = false !== platformData.showBadge;
|
|
44
19
|
useEffect(()=>{
|
|
45
20
|
if (isMobile) {
|
|
46
21
|
const link = document.createElement('link');
|
|
47
22
|
link.rel = 'preload';
|
|
48
23
|
link.as = 'image';
|
|
49
|
-
link.href = '
|
|
24
|
+
link.href = t('safety.cover.mobile');
|
|
50
25
|
document.head.appendChild(link);
|
|
51
26
|
}
|
|
52
27
|
}, [
|
|
53
28
|
isMobile
|
|
54
29
|
]);
|
|
55
30
|
if ('production' !== process.env.NODE_ENV) return null;
|
|
56
|
-
if (!badgeLoaded) return null;
|
|
57
31
|
if (!showBadge) return null;
|
|
58
32
|
if (!visible) return null;
|
|
59
33
|
if (isMobile) return /*#__PURE__*/ jsxs(Sheet, {
|
|
@@ -74,7 +48,7 @@ const Component = ()=>{
|
|
|
74
48
|
}),
|
|
75
49
|
/*#__PURE__*/ jsx("p", {
|
|
76
50
|
className: "shrink-0 min-w-[28px] m-0! text-[#EBEBEB]",
|
|
77
|
-
children:
|
|
51
|
+
children: t('safety.badge.label')
|
|
78
52
|
})
|
|
79
53
|
]
|
|
80
54
|
})
|
|
@@ -90,7 +64,7 @@ const Component = ()=>{
|
|
|
90
64
|
onClick: ()=>setOpen(false)
|
|
91
65
|
}),
|
|
92
66
|
/*#__PURE__*/ jsx("img", {
|
|
93
|
-
src:
|
|
67
|
+
src: t('safety.cover.mobile'),
|
|
94
68
|
alt: "",
|
|
95
69
|
className: "w-full h-full",
|
|
96
70
|
onClick: ()=>{
|
|
@@ -110,12 +84,11 @@ const Component = ()=>{
|
|
|
110
84
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/icon_company_outlined.svg",
|
|
111
85
|
className: "shrink-0 w-[14px] h-[14px]"
|
|
112
86
|
}),
|
|
113
|
-
/*#__PURE__*/
|
|
87
|
+
/*#__PURE__*/ jsx("p", {
|
|
114
88
|
className: "shrink-0 min-w-[96px] m-0! text-[#646A73] text-sm",
|
|
115
|
-
children:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
]
|
|
89
|
+
children: t('safety.tenant.operated', {
|
|
90
|
+
name: tenantName
|
|
91
|
+
})
|
|
119
92
|
})
|
|
120
93
|
]
|
|
121
94
|
}),
|
|
@@ -128,7 +101,7 @@ const Component = ()=>{
|
|
|
128
101
|
}),
|
|
129
102
|
/*#__PURE__*/ jsx("p", {
|
|
130
103
|
className: "shrink-0 min-w-[163px] m-0! text-[#646A73] text-sm",
|
|
131
|
-
children:
|
|
104
|
+
children: t('safety.ai.disclaimer')
|
|
132
105
|
})
|
|
133
106
|
]
|
|
134
107
|
})
|
|
@@ -146,14 +119,14 @@ const Component = ()=>{
|
|
|
146
119
|
setTimeout(()=>setVisible(false), 200);
|
|
147
120
|
window.localStorage?.setItem(HasClosedKey, 'true');
|
|
148
121
|
},
|
|
149
|
-
children:
|
|
122
|
+
children: t('safety.button.dontShowAgain')
|
|
150
123
|
}),
|
|
151
124
|
/*#__PURE__*/ jsx("div", {
|
|
152
125
|
className: "flex-1 flex rounded-[99px] items-center justify-center border-[0.5px] border-black bg-black text-white cursor-pointer text-lg py-[12px]",
|
|
153
126
|
onClick: ()=>{
|
|
154
127
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
155
128
|
},
|
|
156
|
-
children:
|
|
129
|
+
children: t('safety.button.learnMore')
|
|
157
130
|
})
|
|
158
131
|
]
|
|
159
132
|
})
|
|
@@ -186,7 +159,7 @@ const Component = ()=>{
|
|
|
186
159
|
}),
|
|
187
160
|
/*#__PURE__*/ jsx("p", {
|
|
188
161
|
className: "shrink-0 min-w-[60px] m-0! text-[#EBEBEB]",
|
|
189
|
-
children:
|
|
162
|
+
children: t('safety.badge.builtWith')
|
|
190
163
|
})
|
|
191
164
|
]
|
|
192
165
|
})
|
|
@@ -210,7 +183,7 @@ const Component = ()=>{
|
|
|
210
183
|
className: "flex flex-col bg-[#1A1A1A]",
|
|
211
184
|
children: [
|
|
212
185
|
/*#__PURE__*/ jsx("img", {
|
|
213
|
-
src:
|
|
186
|
+
src: t('safety.cover.pc'),
|
|
214
187
|
alt: "",
|
|
215
188
|
className: "w-[286px] h-[128px] cursor-pointer",
|
|
216
189
|
onClick: ()=>{
|
|
@@ -230,12 +203,11 @@ const Component = ()=>{
|
|
|
230
203
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/icon/icon_company_outlined.svg",
|
|
231
204
|
className: "shrink-0 w-[12px] h-[12px]"
|
|
232
205
|
}),
|
|
233
|
-
/*#__PURE__*/
|
|
206
|
+
/*#__PURE__*/ jsx("p", {
|
|
234
207
|
className: "shrink-0 min-w-[96px] m-0! text-[#a6a6a6]",
|
|
235
|
-
children:
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
]
|
|
208
|
+
children: t('safety.tenant.operated', {
|
|
209
|
+
name: tenantName
|
|
210
|
+
})
|
|
239
211
|
})
|
|
240
212
|
]
|
|
241
213
|
}),
|
|
@@ -248,7 +220,7 @@ const Component = ()=>{
|
|
|
248
220
|
}),
|
|
249
221
|
/*#__PURE__*/ jsx("p", {
|
|
250
222
|
className: "shrink-0 min-w-[163px] m-0! text-[#a6a6a6]",
|
|
251
|
-
children:
|
|
223
|
+
children: t('safety.ai.disclaimer')
|
|
252
224
|
})
|
|
253
225
|
]
|
|
254
226
|
})
|
|
@@ -266,7 +238,7 @@ const Component = ()=>{
|
|
|
266
238
|
setVisible(false);
|
|
267
239
|
window.localStorage?.setItem(HasClosedKey, 'true');
|
|
268
240
|
},
|
|
269
|
-
children:
|
|
241
|
+
children: t('safety.button.dontShowAgain')
|
|
270
242
|
}),
|
|
271
243
|
/*#__PURE__*/ jsx("div", {
|
|
272
244
|
className: "flex-1 flex rounded-[8px] items-center justify-center h-[34px] border-[0.5px] border-solid border-[#ffffff1c] hover:border-[#ffffff33] bg-[#ffffff08] hover:bg-[#ffffff14] cursor-pointer text-[#ebebeb]",
|
|
@@ -274,7 +246,7 @@ const Component = ()=>{
|
|
|
274
246
|
onClick: ()=>{
|
|
275
247
|
window.open('https://miaoda.feishu.cn/landing', '_blank');
|
|
276
248
|
},
|
|
277
|
-
children:
|
|
249
|
+
children: t('safety.button.learnMore')
|
|
278
250
|
})
|
|
279
251
|
]
|
|
280
252
|
})
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { IUserProfile } from '../apis/udt-types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* useCurrentUserProfile 的返回类型。
|
|
4
|
+
* 初始状态为空对象 `{}`(所有字段均为 undefined),异步获取用户信息后字段才会被填充。
|
|
5
|
+
* 使用时必须通过可选链或空值合并进行安全访问,如 `userInfo?.user_id`。
|
|
6
|
+
* 判断是否已加载完成应使用 `if (!userInfo?.user_id)` 而非 `if (!userInfo)`(因为空对象是 truthy)。
|
|
7
|
+
*/
|
|
8
|
+
export type ICompatibilityUserProfile = Partial<IUserProfile & {
|
|
3
9
|
/**
|
|
4
10
|
* @deprecated please use `name`
|
|
5
11
|
*/
|
|
@@ -8,5 +14,14 @@ export interface ICompatibilityUserProfile extends IUserProfile {
|
|
|
8
14
|
* @deprecated please use `avatar`
|
|
9
15
|
*/
|
|
10
16
|
userAvatar: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const useCurrentUserProfile: () =>
|
|
17
|
+
}>;
|
|
18
|
+
export declare const useCurrentUserProfile: () => Partial<IUserProfile & {
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated please use `name`
|
|
21
|
+
*/
|
|
22
|
+
userName: string;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated please use `avatar`
|
|
25
|
+
*/
|
|
26
|
+
userAvatar: string;
|
|
27
|
+
}>;
|
|
@@ -3,11 +3,25 @@ import { logger } from "../logger/index.js";
|
|
|
3
3
|
import { getCurrentUserProfile } from "../integrations/getCurrentUserProfile.js";
|
|
4
4
|
import { getDataloom } from "../integrations/dataloom.js";
|
|
5
5
|
import { isSparkRuntime } from "../utils/utils.js";
|
|
6
|
+
import { getAxiosForBackend } from "../utils/getAxiosForBackend.js";
|
|
6
7
|
function getNameFromArray(nameArray) {
|
|
7
8
|
if (!nameArray || 0 === nameArray.length) return;
|
|
8
9
|
const chineseName = nameArray.find((item)=>2052 === item.language_code);
|
|
9
10
|
return chineseName?.text ?? nameArray[0]?.text;
|
|
10
11
|
}
|
|
12
|
+
let _larkUserIdCache = null;
|
|
13
|
+
let _larkUserIdPromise = null;
|
|
14
|
+
function fetchLarkUserId() {
|
|
15
|
+
if (null !== _larkUserIdCache) return Promise.resolve(_larkUserIdCache);
|
|
16
|
+
if (_larkUserIdPromise) return _larkUserIdPromise;
|
|
17
|
+
_larkUserIdPromise = getAxiosForBackend().get('/api/authnpaas/lark-user-id').then(({ data })=>{
|
|
18
|
+
_larkUserIdCache = data?.lark_user_id || null;
|
|
19
|
+
return _larkUserIdCache;
|
|
20
|
+
}).catch(()=>null).finally(()=>{
|
|
21
|
+
_larkUserIdPromise = null;
|
|
22
|
+
});
|
|
23
|
+
return _larkUserIdPromise;
|
|
24
|
+
}
|
|
11
25
|
function getCompatibilityUserProfile() {
|
|
12
26
|
const userInfo = getCurrentUserProfile();
|
|
13
27
|
return {
|
|
@@ -34,6 +48,8 @@ const useCurrentUserProfile = ()=>{
|
|
|
34
48
|
userName: userName,
|
|
35
49
|
userAvatar: info?.avatar?.image?.large
|
|
36
50
|
};
|
|
51
|
+
const larkUserId = await fetchLarkUserId();
|
|
52
|
+
if (larkUserId) newUserInfo.lark_user_id = larkUserId;
|
|
37
53
|
if ('development' === process.env.NODE_ENV) logger.info('MiaoDaMetaInfoChanged', newUserInfo);
|
|
38
54
|
setUserInfo(newUserInfo);
|
|
39
55
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { IUserProfile } from '../apis/udt-types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* 获取当前用户信息。
|
|
4
|
+
* 返回 Partial<IUserProfile>,因为初始值来自 window._userInfo,
|
|
5
|
+
* 该值在运行时始终为空对象 {},所有字段均为 undefined。
|
|
6
|
+
* 异步获取用户信息后才会被填充为完整的 IUserProfile。
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCurrentUserProfile(): Partial<IUserProfile>;
|
|
3
9
|
/**
|
|
4
10
|
* @deprecated 请使用 getCurrentUserProfile 代替
|
|
5
11
|
*/
|
|
@@ -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>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取当前语言环境下的翻译文案。
|
|
3
|
+
*
|
|
4
|
+
* 支持 `{key}` 形式的变量替换:
|
|
5
|
+
* ```ts
|
|
6
|
+
* t('safety.tenant.operated', { name: '字节' })
|
|
7
|
+
* // zh → "字节运营"
|
|
8
|
+
* // en → "Operated by 字节"
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* 如果 key 不存在,fallback 到中文;中文也没有则返回 key 本身。
|
|
12
|
+
*/
|
|
13
|
+
export declare function t(key: string, params?: Record<string, string>): string;
|
|
14
|
+
export { getLocale } from '../utils/locale';
|
|
15
|
+
export type { Locale } from '../utils/locale';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import messages from "./messages.js";
|
|
2
|
+
import { getLocale } from "../utils/locale.js";
|
|
3
|
+
function t(key, params) {
|
|
4
|
+
const locale = getLocale();
|
|
5
|
+
const entry = messages[key];
|
|
6
|
+
let text = entry?.[locale] ?? entry?.zh ?? key;
|
|
7
|
+
if (params) for (const [k, v] of Object.entries(params))text = text.replace(`{${k}}`, v);
|
|
8
|
+
return text;
|
|
9
|
+
}
|
|
10
|
+
export { getLocale, t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 中英文文案源(统一管理)。
|
|
3
|
+
*
|
|
4
|
+
* 每条文案同时包含 zh 和 en,方便对照和维护。
|
|
5
|
+
* Key 规则:`{组件}.{区域}.{标识}`
|
|
6
|
+
* 文案来源:https://bytedance.larkoffice.com/wiki/BJCQwv9auiP9erkudMfcVIIGnRg
|
|
7
|
+
*/
|
|
8
|
+
declare const messages: Record<string, {
|
|
9
|
+
zh: string;
|
|
10
|
+
en: string;
|
|
11
|
+
}>;
|
|
12
|
+
export default messages;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const messages_messages = {
|
|
2
|
+
'safety.badge.label': {
|
|
3
|
+
zh: '妙搭',
|
|
4
|
+
en: 'Spark'
|
|
5
|
+
},
|
|
6
|
+
'safety.badge.builtWith': {
|
|
7
|
+
zh: '由妙搭搭建',
|
|
8
|
+
en: 'Built with Spark'
|
|
9
|
+
},
|
|
10
|
+
'safety.ai.disclaimer': {
|
|
11
|
+
zh: '包含 AI 生成内容,请注意甄别',
|
|
12
|
+
en: 'AI-generated content. Use with care.'
|
|
13
|
+
},
|
|
14
|
+
'safety.tenant.operated': {
|
|
15
|
+
zh: '{name}运营',
|
|
16
|
+
en: 'Operated by {name}'
|
|
17
|
+
},
|
|
18
|
+
'safety.button.dontShowAgain': {
|
|
19
|
+
zh: '不再展示',
|
|
20
|
+
en: "Don't show again"
|
|
21
|
+
},
|
|
22
|
+
'safety.button.learnMore': {
|
|
23
|
+
zh: '了解更多',
|
|
24
|
+
en: 'Learn more'
|
|
25
|
+
},
|
|
26
|
+
'safety.cover.pc': {
|
|
27
|
+
zh: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover.png',
|
|
28
|
+
en: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-pcen.png'
|
|
29
|
+
},
|
|
30
|
+
'safety.cover.mobile': {
|
|
31
|
+
zh: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-mobile.png',
|
|
32
|
+
en: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-weben.png'
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const messages = messages_messages;
|
|
36
|
+
export { messages as default };
|
package/lib/utils/axiosConfig.js
CHANGED
|
@@ -372,7 +372,18 @@ function initAxiosConfig(axiosInstance) {
|
|
|
372
372
|
name: 'toolkit_axios_403_downgrade',
|
|
373
373
|
categories: {
|
|
374
374
|
url: String(error.config?.url || ''),
|
|
375
|
-
method: String(error.config?.method || '')
|
|
375
|
+
method: String(error.config?.method || ''),
|
|
376
|
+
...'production' !== process.env.NODE_ENV && {
|
|
377
|
+
responseData: (()=>{
|
|
378
|
+
try {
|
|
379
|
+
const data = error.response?.data;
|
|
380
|
+
if (!data) return '';
|
|
381
|
+
return 'string' == typeof data ? data.slice(0, 512) : JSON.stringify(data).slice(0, 512);
|
|
382
|
+
} catch {
|
|
383
|
+
return '';
|
|
384
|
+
}
|
|
385
|
+
})()
|
|
386
|
+
}
|
|
376
387
|
}
|
|
377
388
|
});
|
|
378
389
|
return error.response;
|
|
@@ -383,7 +394,19 @@ function initAxiosConfig(axiosInstance) {
|
|
|
383
394
|
categories: {
|
|
384
395
|
url: String(error.config?.url || ''),
|
|
385
396
|
method: String(error.config?.method || ''),
|
|
386
|
-
status: String(error.response?.status || '')
|
|
397
|
+
status: String(error.response?.status || ''),
|
|
398
|
+
...'production' !== process.env.NODE_ENV && {
|
|
399
|
+
errorMessage: String(error.message || ''),
|
|
400
|
+
responseData: (()=>{
|
|
401
|
+
try {
|
|
402
|
+
const data = error.response?.data;
|
|
403
|
+
if (!data) return '';
|
|
404
|
+
return 'string' == typeof data ? data.slice(0, 512) : JSON.stringify(data).slice(0, 512);
|
|
405
|
+
} catch {
|
|
406
|
+
return '';
|
|
407
|
+
}
|
|
408
|
+
})()
|
|
409
|
+
}
|
|
387
410
|
}
|
|
388
411
|
});
|
|
389
412
|
return Promise.reject(error);
|
|
@@ -24,10 +24,24 @@ async function getAppPublished() {
|
|
|
24
24
|
console.error('Error fetching published app info:', error);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
function getPreloadedInfo() {
|
|
28
|
+
try {
|
|
29
|
+
const platformData = window.__platform__?.appPublished;
|
|
30
|
+
if (platformData && 'object' == typeof platformData) return platformData;
|
|
31
|
+
} catch {}
|
|
32
|
+
}
|
|
27
33
|
let initialInfo;
|
|
28
34
|
let pendingPromise = null;
|
|
29
35
|
function getInitialInfo(refresh = false) {
|
|
30
36
|
if (initialInfo && !refresh) return Promise.resolve(initialInfo);
|
|
37
|
+
if (!initialInfo && !refresh) {
|
|
38
|
+
const preloaded = getPreloadedInfo();
|
|
39
|
+
if (preloaded) {
|
|
40
|
+
initialInfo = preloaded;
|
|
41
|
+
if (initialInfo) window._bucket_id = initialInfo.app_runtime_extra?.bucket?.default_bucket_id;
|
|
42
|
+
return Promise.resolve(initialInfo);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
31
45
|
if (pendingPromise && !refresh) return pendingPromise;
|
|
32
46
|
pendingPromise = getAppPublished().then((info)=>{
|
|
33
47
|
initialInfo = info;
|
package/lib/utils/hmr-api.d.ts
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
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;
|
|
12
18
|
/**
|
|
13
19
|
* 注册 HMR 成功回调
|
|
14
20
|
* @param callback 成功回调函数
|
|
@@ -24,7 +30,7 @@ export interface HmrApi {
|
|
|
24
30
|
}
|
|
25
31
|
declare global {
|
|
26
32
|
interface Window {
|
|
27
|
-
__VITE_HMR__?: HmrApi
|
|
33
|
+
__VITE_HMR__?: Required<HmrApi>;
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
@@ -12,6 +12,11 @@ function safeStringify(obj) {
|
|
|
12
12
|
if (value instanceof Set) return Array.from(value);
|
|
13
13
|
if (void 0 === value) return 'undefined';
|
|
14
14
|
if ('symbol' == typeof value) return value.toString();
|
|
15
|
+
if (value instanceof Error) return {
|
|
16
|
+
name: value.name,
|
|
17
|
+
message: value.message,
|
|
18
|
+
stack: value.stack
|
|
19
|
+
};
|
|
15
20
|
return value;
|
|
16
21
|
});
|
|
17
22
|
} catch {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { mapLogLevel, processLogParams, safeStringify } from "./safeStringify.js";
|
|
3
|
+
describe('safeStringify', ()=>{
|
|
4
|
+
it('should serialize a plain string', ()=>{
|
|
5
|
+
expect(safeStringify('hello')).toBe('"hello"');
|
|
6
|
+
});
|
|
7
|
+
it('should serialize a plain object', ()=>{
|
|
8
|
+
expect(safeStringify({
|
|
9
|
+
a: 1
|
|
10
|
+
})).toBe('{"a":1}');
|
|
11
|
+
});
|
|
12
|
+
it('should handle circular references', ()=>{
|
|
13
|
+
const obj = {
|
|
14
|
+
a: 1
|
|
15
|
+
};
|
|
16
|
+
obj.self = obj;
|
|
17
|
+
expect(safeStringify(obj)).toBe('{"a":1,"self":"[Circular]"}');
|
|
18
|
+
});
|
|
19
|
+
it('should serialize BigInt as string', ()=>{
|
|
20
|
+
expect(safeStringify(BigInt(123))).toBe('"123"');
|
|
21
|
+
});
|
|
22
|
+
it('should serialize Date as ISO string', ()=>{
|
|
23
|
+
const date = new Date('2024-01-01T00:00:00.000Z');
|
|
24
|
+
expect(safeStringify(date)).toBe('"2024-01-01T00:00:00.000Z"');
|
|
25
|
+
});
|
|
26
|
+
it('should serialize Map as object', ()=>{
|
|
27
|
+
const map = new Map([
|
|
28
|
+
[
|
|
29
|
+
'key',
|
|
30
|
+
'value'
|
|
31
|
+
]
|
|
32
|
+
]);
|
|
33
|
+
expect(safeStringify(map)).toBe('{"key":"value"}');
|
|
34
|
+
});
|
|
35
|
+
it('should serialize Set as array', ()=>{
|
|
36
|
+
const set = new Set([
|
|
37
|
+
1,
|
|
38
|
+
2,
|
|
39
|
+
3
|
|
40
|
+
]);
|
|
41
|
+
expect(safeStringify(set)).toBe('[1,2,3]');
|
|
42
|
+
});
|
|
43
|
+
it('should serialize undefined as string', ()=>{
|
|
44
|
+
expect(safeStringify({
|
|
45
|
+
a: void 0
|
|
46
|
+
})).toBe('{"a":"undefined"}');
|
|
47
|
+
});
|
|
48
|
+
it('should serialize Symbol as string', ()=>{
|
|
49
|
+
expect(safeStringify({
|
|
50
|
+
s: Symbol('test')
|
|
51
|
+
})).toBe('{"s":"Symbol(test)"}');
|
|
52
|
+
});
|
|
53
|
+
it('should serialize Error with name, message and stack', ()=>{
|
|
54
|
+
const err = new Error('something went wrong');
|
|
55
|
+
const result = JSON.parse(safeStringify(err));
|
|
56
|
+
expect(result.name).toBe('Error');
|
|
57
|
+
expect(result.message).toBe('something went wrong');
|
|
58
|
+
expect(result.stack).toContain('something went wrong');
|
|
59
|
+
});
|
|
60
|
+
it('should serialize Error subclass with correct name', ()=>{
|
|
61
|
+
const err = new TypeError('bad type');
|
|
62
|
+
const result = JSON.parse(safeStringify(err));
|
|
63
|
+
expect(result.name).toBe('TypeError');
|
|
64
|
+
expect(result.message).toBe('bad type');
|
|
65
|
+
});
|
|
66
|
+
it('should serialize Error nested in object', ()=>{
|
|
67
|
+
const err = new Error('inner error');
|
|
68
|
+
const result = JSON.parse(safeStringify({
|
|
69
|
+
err
|
|
70
|
+
}));
|
|
71
|
+
expect(result.err.name).toBe('Error');
|
|
72
|
+
expect(result.err.message).toBe('inner error');
|
|
73
|
+
});
|
|
74
|
+
it('should return empty string on unexpected failure', ()=>{
|
|
75
|
+
const bad = {
|
|
76
|
+
toJSON () {
|
|
77
|
+
throw new Error('fail');
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
expect(safeStringify(bad)).toBe('');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe('processLogParams', ()=>{
|
|
84
|
+
it('should serialize single argument directly', ()=>{
|
|
85
|
+
expect(processLogParams([
|
|
86
|
+
'hello'
|
|
87
|
+
])).toBe('"hello"');
|
|
88
|
+
});
|
|
89
|
+
it('should serialize single object argument', ()=>{
|
|
90
|
+
expect(processLogParams([
|
|
91
|
+
{
|
|
92
|
+
a: 1
|
|
93
|
+
}
|
|
94
|
+
])).toBe('{"a":1}');
|
|
95
|
+
});
|
|
96
|
+
it('should serialize multiple arguments as indexed object', ()=>{
|
|
97
|
+
const result = JSON.parse(processLogParams([
|
|
98
|
+
'msg',
|
|
99
|
+
{
|
|
100
|
+
key: 'val'
|
|
101
|
+
}
|
|
102
|
+
]));
|
|
103
|
+
expect(result['0']).toBe('msg');
|
|
104
|
+
expect(result['1']).toEqual({
|
|
105
|
+
key: 'val'
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('mapLogLevel', ()=>{
|
|
110
|
+
it('should map error to ERROR', ()=>{
|
|
111
|
+
expect(mapLogLevel('error')).toBe('ERROR');
|
|
112
|
+
});
|
|
113
|
+
it('should map info to INFO', ()=>{
|
|
114
|
+
expect(mapLogLevel('info')).toBe('INFO');
|
|
115
|
+
});
|
|
116
|
+
it('should map success to INFO', ()=>{
|
|
117
|
+
expect(mapLogLevel('success')).toBe('INFO');
|
|
118
|
+
});
|
|
119
|
+
it('should map warn to WARN', ()=>{
|
|
120
|
+
expect(mapLogLevel('warn')).toBe('WARN');
|
|
121
|
+
});
|
|
122
|
+
it('should default unknown level to INFO', ()=>{
|
|
123
|
+
expect(mapLogLevel('debug')).toBe('INFO');
|
|
124
|
+
});
|
|
125
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.2.28-alpha.
|
|
3
|
+
"version": "1.2.28-alpha.71",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -98,13 +98,13 @@
|
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"@ant-design/colors": "^7.2.1",
|
|
100
100
|
"@ant-design/cssinjs": "^1.24.0",
|
|
101
|
-
"@data-loom/js": "0.4.
|
|
102
|
-
"@lark-apaas/aily-web-sdk": "^0.0.
|
|
103
|
-
"@lark-apaas/auth-sdk": "^0.1.
|
|
101
|
+
"@data-loom/js": "0.4.13",
|
|
102
|
+
"@lark-apaas/aily-web-sdk": "^0.0.9",
|
|
103
|
+
"@lark-apaas/auth-sdk": "^0.1.4",
|
|
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.
|
|
107
|
-
"@lark-apaas/observable-web": "^1.0.
|
|
106
|
+
"@lark-apaas/miaoda-inspector": "^1.0.23",
|
|
107
|
+
"@lark-apaas/observable-web": "^1.0.6",
|
|
108
108
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
109
109
|
"@radix-ui/react-popover": "^1.1.15",
|
|
110
110
|
"@radix-ui/react-slot": "^1.2.3",
|