@lark-apaas/client-toolkit 1.2.84 → 1.2.85-alpha.20261112215423
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/index.js +2 -3
- package/lib/locales/messages.js +0 -4
- package/lib/logger/batch-logger.d.ts +9 -2
- package/lib/logger/batch-logger.js +159 -26
- package/lib/logger/log-payload-budget.d.ts +6 -0
- package/lib/logger/log-payload-budget.js +25 -0
- package/lib/logger/selected-logs.d.ts +0 -3
- package/lib/logger/selected-logs.js +34 -4
- package/lib/logger/source-map-mappings-wasm.d.ts +1 -0
- package/lib/logger/source-map-mappings-wasm.js +3045 -0
- package/package.json +4 -4
- package/lib/locales/__test__/messages.test.d.ts +0 -1
- package/lib/locales/__test__/messages.test.js +0 -40
- package/lib/logger/stack-resolver.d.ts +0 -25
- package/lib/logger/stack-resolver.js +0 -29
- package/lib/utils/rateLimitError.d.ts +0 -6
- package/lib/utils/rateLimitError.js +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.85-alpha.20261112215423",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@ant-design/cssinjs": "^1.24.0",
|
|
102
102
|
"@lark-apaas/aily-web-sdk": "^0.0.12",
|
|
103
103
|
"@lark-apaas/auth-sdk": "^0.1.5",
|
|
104
|
-
"@lark-apaas/client-capability": "^0.1.
|
|
104
|
+
"@lark-apaas/client-capability": "^0.1.7",
|
|
105
105
|
"@lark-apaas/dataloom": "^0.1.6",
|
|
106
106
|
"@lark-apaas/internal-slardar": "^0.0.3",
|
|
107
107
|
"@lark-apaas/miaoda-inspector": "^1.0.25",
|
|
@@ -118,12 +118,12 @@
|
|
|
118
118
|
"crypto-js": "3.1.9-1",
|
|
119
119
|
"dayjs": "^1.11.13",
|
|
120
120
|
"echarts": "^6.0.0",
|
|
121
|
-
"error-stack-parser": "^2.1.4",
|
|
122
121
|
"lodash": "^4.17.21",
|
|
123
122
|
"network-idle": "^0.2.0",
|
|
124
123
|
"penpal": "^6.2.2",
|
|
125
124
|
"sonner": "~2.0.0",
|
|
126
|
-
"
|
|
125
|
+
"source-map": "^0.7.6",
|
|
126
|
+
"stacktrace-js": "^2.0.2",
|
|
127
127
|
"tailwind-merge": "~2.0.0",
|
|
128
128
|
"tailwind-variants": "0.3.1",
|
|
129
129
|
"tailwindcss-animate": "^1.0.7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import messages from "../messages.js";
|
|
3
|
-
import { getRateLimitMessageKey } from "../../utils/rateLimitError.js";
|
|
4
|
-
describe('rate limit locale messages', ()=>{
|
|
5
|
-
it('keeps quota exhaustion and frequency limiting as separate bilingual messages', ()=>{
|
|
6
|
-
expect(messages).toHaveProperty('index.rateLimitError', {
|
|
7
|
-
zh: '应用额度已耗尽,请联系应用开发者',
|
|
8
|
-
en: 'Application quota exhausted, please contact the app developer'
|
|
9
|
-
});
|
|
10
|
-
expect(messages).toHaveProperty('index.frequencyLimitError', {
|
|
11
|
-
zh: '操作过于频繁,请稍后重试',
|
|
12
|
-
en: 'Too many requests. Please try again later'
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
it('selects the correct message and supports older client-capability errors', ()=>{
|
|
16
|
-
expect(getRateLimitMessageKey({
|
|
17
|
-
isFrequencyLimit: false,
|
|
18
|
-
rateLimitCode: 'k_st_ec_400002688'
|
|
19
|
-
})).toBe('index.rateLimitError');
|
|
20
|
-
expect(getRateLimitMessageKey({
|
|
21
|
-
isFrequencyLimit: true,
|
|
22
|
-
rateLimitCode: 'k_st_ec_400002689'
|
|
23
|
-
})).toBe('index.frequencyLimitError');
|
|
24
|
-
for (const rateLimitCode of [
|
|
25
|
-
'k_st_ec_400002689',
|
|
26
|
-
'400002689',
|
|
27
|
-
'2689',
|
|
28
|
-
'rate_limit_exceeded'
|
|
29
|
-
])expect(getRateLimitMessageKey({
|
|
30
|
-
rateLimitCode
|
|
31
|
-
})).toBe('index.frequencyLimitError');
|
|
32
|
-
for (const rateLimitCode of [
|
|
33
|
-
'k_st_ec_400002688',
|
|
34
|
-
'400002688',
|
|
35
|
-
'2688'
|
|
36
|
-
])expect(getRateLimitMessageKey({
|
|
37
|
-
rateLimitCode
|
|
38
|
-
})).toBe('index.rateLimitError');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 开发态日志的调用栈解析:只对业务代码帧做 source map 还原。
|
|
3
|
-
*
|
|
4
|
-
* 依赖帧(Vite 预构建的 `.vite/deps/*`、`node_modules`、Vite 运行时模块)保留原始位置:
|
|
5
|
-
* 这些文件的 source map 动辄数 MB,逐帧还原需要下载并解析,开发预览首屏会因此多出
|
|
6
|
-
* 数百毫秒主线程耗时;而妙搭调试面板与 Agent 只用业务代码帧定位,依赖帧还原与否不影响结果。
|
|
7
|
-
*/
|
|
8
|
-
import type { z } from 'zod';
|
|
9
|
-
import type { logStackFrameSchema } from './log-types';
|
|
10
|
-
type LogStackFrame = z.infer<typeof logStackFrameSchema>;
|
|
11
|
-
/**
|
|
12
|
-
* 判断一帧是否来自依赖或构建工具运行时。没有文件名的帧(原生代码、eval)也视为非业务帧。
|
|
13
|
-
*/
|
|
14
|
-
export declare function isLibraryFrame(fileName: string | undefined): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* 把 Error 的调用栈解析成结构化帧;业务帧尝试 source map 还原,失败时保留原始位置。
|
|
17
|
-
* Error 没有可解析的 stack 时抛错,由调用方处理。
|
|
18
|
-
*/
|
|
19
|
-
export declare function resolveStackFrames(error: Error): Promise<LogStackFrame[]>;
|
|
20
|
-
/**
|
|
21
|
-
* 去掉栈顶的非业务帧(logger 自身、拦截器链等),让第一帧落在业务调用处。
|
|
22
|
-
* 整条栈都没有业务帧时原样返回。
|
|
23
|
-
*/
|
|
24
|
-
export declare function dropLeadingLibraryFrames(frames: LogStackFrame[]): LogStackFrame[];
|
|
25
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import error_stack_parser from "error-stack-parser";
|
|
2
|
-
import stacktrace_gps from "stacktrace-gps";
|
|
3
|
-
const LIBRARY_PATH_PATTERN = /\/node_modules\/|\/@vite\/|\/@react-refresh|\/@id\/|\/(client-toolkit(-lite)?|packages\/client\/toolkit)\/(lib|dist)\//;
|
|
4
|
-
function isLibraryFrame(fileName) {
|
|
5
|
-
return !fileName || LIBRARY_PATH_PATTERN.test(fileName);
|
|
6
|
-
}
|
|
7
|
-
let gps;
|
|
8
|
-
function getGps() {
|
|
9
|
-
if (!gps) gps = new stacktrace_gps();
|
|
10
|
-
return gps;
|
|
11
|
-
}
|
|
12
|
-
function toLogStackFrame(frame) {
|
|
13
|
-
return {
|
|
14
|
-
functionName: frame.functionName || '',
|
|
15
|
-
fileName: frame.fileName || '',
|
|
16
|
-
lineNumber: frame.lineNumber || 0,
|
|
17
|
-
columnNumber: frame.columnNumber || 0
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
async function resolveStackFrames(error) {
|
|
21
|
-
const frames = error_stack_parser.parse(error);
|
|
22
|
-
const resolved = await Promise.all(frames.map((frame)=>isLibraryFrame(frame.fileName) ? frame : getGps().pinpoint(frame).catch(()=>frame)));
|
|
23
|
-
return resolved.map(toLogStackFrame);
|
|
24
|
-
}
|
|
25
|
-
function dropLeadingLibraryFrames(frames) {
|
|
26
|
-
const firstBusinessIndex = frames.findIndex((frame)=>!isLibraryFrame(frame.fileName));
|
|
27
|
-
return firstBusinessIndex <= 0 ? frames : frames.slice(firstBusinessIndex);
|
|
28
|
-
}
|
|
29
|
-
export { dropLeadingLibraryFrames, isLibraryFrame, resolveStackFrames };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const LEGACY_FREQUENCY_LIMIT_CODES = new Set([
|
|
2
|
-
'k_st_ec_400002689',
|
|
3
|
-
'400002689',
|
|
4
|
-
'2689',
|
|
5
|
-
'rate_limit_exceeded'
|
|
6
|
-
]);
|
|
7
|
-
function getRateLimitMessageKey(error) {
|
|
8
|
-
const isFrequencyLimit = error.isFrequencyLimit ?? LEGACY_FREQUENCY_LIMIT_CODES.has(error.rateLimitCode ?? '');
|
|
9
|
-
return isFrequencyLimit ? 'index.frequencyLimitError' : 'index.rateLimitError';
|
|
10
|
-
}
|
|
11
|
-
export { getRateLimitMessageKey };
|