@lark-apaas/miaoda-cli 0.1.3 → 0.1.4
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/api/app/api.js +3 -3
- package/dist/api/app/schemas.js +43 -43
- package/dist/api/db/api.js +398 -55
- package/dist/api/db/client.js +155 -28
- package/dist/api/db/index.js +12 -1
- package/dist/api/db/parsers.js +20 -20
- package/dist/api/db/sql-keywords.js +87 -87
- package/dist/api/deploy/api.js +5 -5
- package/dist/api/deploy/schemas.js +32 -32
- package/dist/api/file/api.js +89 -87
- package/dist/api/file/client.js +62 -22
- package/dist/api/file/detect.js +3 -3
- package/dist/api/file/index.js +2 -1
- package/dist/api/file/parsers.js +18 -7
- package/dist/api/observability/api.js +6 -6
- package/dist/api/observability/schemas.js +14 -14
- package/dist/api/plugin/api.js +31 -31
- package/dist/cli/commands/app/index.js +12 -12
- package/dist/cli/commands/db/index.js +602 -54
- package/dist/cli/commands/deploy/index.js +28 -28
- package/dist/cli/commands/file/index.js +85 -58
- package/dist/cli/commands/observability/index.js +69 -69
- package/dist/cli/commands/plugin/index.js +27 -27
- package/dist/cli/commands/shared.js +10 -10
- package/dist/cli/handlers/app/update.js +2 -2
- package/dist/cli/handlers/db/_destructive.js +67 -0
- package/dist/cli/handlers/db/_env.js +26 -0
- package/dist/cli/handlers/db/_operator.js +35 -0
- package/dist/cli/handlers/db/audit.js +383 -0
- package/dist/cli/handlers/db/changelog.js +160 -0
- package/dist/cli/handlers/db/data.js +32 -31
- package/dist/cli/handlers/db/index.js +17 -1
- package/dist/cli/handlers/db/migration.js +234 -0
- package/dist/cli/handlers/db/quota.js +68 -0
- package/dist/cli/handlers/db/recovery.js +413 -0
- package/dist/cli/handlers/db/schema.js +33 -33
- package/dist/cli/handlers/db/sql.js +69 -69
- package/dist/cli/handlers/deploy/deploy.js +4 -4
- package/dist/cli/handlers/deploy/error-log.js +1 -1
- package/dist/cli/handlers/deploy/get.js +3 -3
- package/dist/cli/handlers/deploy/polling.js +11 -11
- package/dist/cli/handlers/file/cp.js +30 -30
- package/dist/cli/handlers/file/index.js +3 -1
- package/dist/cli/handlers/file/ls.js +5 -5
- package/dist/cli/handlers/file/quota.js +66 -0
- package/dist/cli/handlers/file/rm.js +32 -30
- package/dist/cli/handlers/file/sign.js +3 -3
- package/dist/cli/handlers/file/stat.js +10 -9
- package/dist/cli/handlers/observability/analytics.js +47 -47
- package/dist/cli/handlers/observability/helpers.js +2 -2
- package/dist/cli/handlers/observability/log.js +9 -9
- package/dist/cli/handlers/observability/metric.js +26 -26
- package/dist/cli/handlers/observability/trace.js +5 -5
- package/dist/cli/handlers/plugin/plugin-local.js +53 -53
- package/dist/cli/handlers/plugin/plugin.js +15 -15
- package/dist/cli/help.js +16 -16
- package/dist/main.js +12 -12
- package/dist/utils/args.js +1 -1
- package/dist/utils/colors.js +2 -2
- package/dist/utils/config.js +2 -2
- package/dist/utils/devops-error.js +9 -9
- package/dist/utils/error.js +2 -2
- package/dist/utils/git.js +4 -4
- package/dist/utils/http.js +19 -19
- package/dist/utils/index.js +3 -1
- package/dist/utils/output.js +67 -45
- package/dist/utils/poll.js +35 -0
- package/dist/utils/render.js +27 -27
- package/dist/utils/spinner.js +46 -0
- package/dist/utils/time.js +47 -42
- package/package.json +1 -1
package/dist/cli/help.js
CHANGED
|
@@ -35,7 +35,7 @@ class MiaodaHelp extends commander_1.Help {
|
|
|
35
35
|
const usage = cmd.usage();
|
|
36
36
|
if (usage) {
|
|
37
37
|
// 去掉末尾的 [flags] / [options],对齐 spec 的 "name <args>" 形态
|
|
38
|
-
const argsOnly = usage.replace(/\s*\[(?:flags|options)\]\s*$/i,
|
|
38
|
+
const argsOnly = usage.replace(/\s*\[(?:flags|options)\]\s*$/i, '').trim();
|
|
39
39
|
return argsOnly ? `${cmd.name()} ${argsOnly}` : cmd.name();
|
|
40
40
|
}
|
|
41
41
|
return super.subcommandTerm(cmd);
|
|
@@ -51,7 +51,7 @@ class MiaodaHelp extends commander_1.Help {
|
|
|
51
51
|
if (summary)
|
|
52
52
|
return summary;
|
|
53
53
|
const desc = super.subcommandDescription(cmd);
|
|
54
|
-
const idx = desc.indexOf(
|
|
54
|
+
const idx = desc.indexOf('\n');
|
|
55
55
|
return idx === -1 ? desc : desc.slice(0, idx);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -81,7 +81,7 @@ class MiaodaHelp extends commander_1.Help {
|
|
|
81
81
|
visibleGlobalOptions(cmd) {
|
|
82
82
|
const opts = super.visibleGlobalOptions(cmd);
|
|
83
83
|
if (cmd.parent) {
|
|
84
|
-
return opts.filter((o) => o.long !==
|
|
84
|
+
return opts.filter((o) => o.long !== '--version' && o.short !== '-v');
|
|
85
85
|
}
|
|
86
86
|
return opts;
|
|
87
87
|
}
|
|
@@ -90,7 +90,7 @@ class MiaodaHelp extends commander_1.Help {
|
|
|
90
90
|
* spec 不展示这一条,过滤掉。
|
|
91
91
|
*/
|
|
92
92
|
visibleCommands(cmd) {
|
|
93
|
-
return super.visibleCommands(cmd).filter((c) => c.name() !==
|
|
93
|
+
return super.visibleCommands(cmd).filter((c) => c.name() !== 'help');
|
|
94
94
|
}
|
|
95
95
|
formatHelp(cmd, helper) {
|
|
96
96
|
const isRoot = cmd.parent == null;
|
|
@@ -98,28 +98,28 @@ class MiaodaHelp extends commander_1.Help {
|
|
|
98
98
|
const helpWidth = helper.helpWidth ?? 80;
|
|
99
99
|
const formatItem = (term, description) => {
|
|
100
100
|
if (description) {
|
|
101
|
-
const padding =
|
|
101
|
+
const padding = ' '.repeat(Math.max(termWidth - term.length, 0) + 2);
|
|
102
102
|
return `${term}${padding}${description}`;
|
|
103
103
|
}
|
|
104
104
|
return term;
|
|
105
105
|
};
|
|
106
|
-
const formatList = (lines) => lines.map((l) =>
|
|
106
|
+
const formatList = (lines) => lines.map((l) => ' ' + l).join('\n');
|
|
107
107
|
void helpWidth; // 保留以备后续按宽度自动 wrap,当前直接透传 description
|
|
108
108
|
const out = [];
|
|
109
109
|
// 1. 描述
|
|
110
110
|
const desc = helper.commandDescription(cmd);
|
|
111
111
|
if (desc) {
|
|
112
|
-
out.push(desc,
|
|
112
|
+
out.push(desc, '');
|
|
113
113
|
}
|
|
114
114
|
// 2. Usage:独立 heading + 缩进
|
|
115
|
-
out.push(
|
|
115
|
+
out.push('Usage:', ` ${helper.commandUsage(cmd)}`, '');
|
|
116
116
|
// 3. Commands(仅父级命令组有,spec 要求 Commands 在 Flags 前)
|
|
117
117
|
// spec 不展示 Arguments 段,参数说明放在 description 文本里
|
|
118
118
|
const subs = helper
|
|
119
119
|
.visibleCommands(cmd)
|
|
120
120
|
.map((c) => formatItem(helper.subcommandTerm(c), helper.subcommandDescription(c)));
|
|
121
121
|
if (subs.length) {
|
|
122
|
-
out.push(
|
|
122
|
+
out.push('Commands:', formatList(subs), '');
|
|
123
123
|
}
|
|
124
124
|
// 5. Flags(叶子命令专属 options)
|
|
125
125
|
// - Root / 父命令组:local options 都视作"会被子命令继承的 globals",渲染到 Global Flags 段
|
|
@@ -132,7 +132,7 @@ class MiaodaHelp extends commander_1.Help {
|
|
|
132
132
|
.filter((o) => !isHelpOption(o))
|
|
133
133
|
.map((o) => formatItem(helper.optionTerm(o), helper.optionDescription(o)));
|
|
134
134
|
if (opts.length) {
|
|
135
|
-
out.push(
|
|
135
|
+
out.push('Flags:', formatList(opts), '');
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
// 6. Global Flags
|
|
@@ -162,22 +162,22 @@ class MiaodaHelp extends commander_1.Help {
|
|
|
162
162
|
}
|
|
163
163
|
if (globals.length) {
|
|
164
164
|
const lines = globals.map((o) => formatItem(helper.optionTerm(o), helper.optionDescription(o)));
|
|
165
|
-
out.push(
|
|
165
|
+
out.push('Global Flags:', formatList(lines), '');
|
|
166
166
|
}
|
|
167
167
|
// 7. 父命令底部追加 "Use <cmd> <subcommand> --help" 提示,对齐 spec
|
|
168
168
|
if (subs.length > 0) {
|
|
169
|
-
const path = cmd.name() ===
|
|
170
|
-
out.push(`Use "${path} <command> --help" for more information about a command.`,
|
|
169
|
+
const path = cmd.name() === 'miaoda' ? 'miaoda' : commandPath(cmd);
|
|
170
|
+
out.push(`Use "${path} <command> --help" for more information about a command.`, '');
|
|
171
171
|
}
|
|
172
172
|
// 保留末尾换行:commander 用 join('\n') 拼 addHelpText('after') 段,
|
|
173
173
|
// 这里多留一个 \n,让 Notes / Examples 段与上面段落之间空一行。
|
|
174
|
-
return out.join(
|
|
174
|
+
return out.join('\n').replace(/\n+$/, '\n');
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
exports.MiaodaHelp = MiaodaHelp;
|
|
178
178
|
/** 判断是否为 -h / --help 选项。 */
|
|
179
179
|
function isHelpOption(o) {
|
|
180
|
-
return o.long ===
|
|
180
|
+
return o.long === '--help' || o.short === '-h';
|
|
181
181
|
}
|
|
182
182
|
/** 拼接命令完整路径,例如 db schema -> "miaoda db schema"。 */
|
|
183
183
|
function commandPath(cmd) {
|
|
@@ -187,5 +187,5 @@ function commandPath(cmd) {
|
|
|
187
187
|
names.unshift(cur.name());
|
|
188
188
|
cur = cur.parent;
|
|
189
189
|
}
|
|
190
|
-
return names.join(
|
|
190
|
+
return names.join(' ');
|
|
191
191
|
}
|
package/dist/main.js
CHANGED
|
@@ -20,18 +20,18 @@ commander_1.Command.prototype.createHelp = function () {
|
|
|
20
20
|
const program = new commander_1.Command();
|
|
21
21
|
const { version } = package_json_1.default;
|
|
22
22
|
program
|
|
23
|
-
.name(
|
|
24
|
-
.description(
|
|
25
|
-
.usage(
|
|
26
|
-
.version(version,
|
|
27
|
-
.option(
|
|
28
|
-
.addOption(new commander_1.Option(
|
|
29
|
-
.choices([
|
|
30
|
-
.argParser((0, shared_1.caseInsensitiveChoice)([
|
|
31
|
-
.default(
|
|
32
|
-
.option(
|
|
33
|
-
.helpOption(
|
|
34
|
-
.hook(
|
|
23
|
+
.name('miaoda')
|
|
24
|
+
.description('妙搭平台 CLI,提供数据服务、文件存储等命令行操作。')
|
|
25
|
+
.usage('<command> [flags]')
|
|
26
|
+
.version(version, '-v, --version', '显示版本号')
|
|
27
|
+
.option('--json [fields]', 'JSON 输出,可选字段级选择')
|
|
28
|
+
.addOption(new commander_1.Option('--output <format>', '输出格式(pretty | json,大小写不敏感)')
|
|
29
|
+
.choices(['pretty', 'json'])
|
|
30
|
+
.argParser((0, shared_1.caseInsensitiveChoice)(['pretty', 'json']))
|
|
31
|
+
.default('pretty'))
|
|
32
|
+
.option('--verbose', 'debug 日志到 stderr')
|
|
33
|
+
.helpOption('-h, --help', '显示帮助信息')
|
|
34
|
+
.hook('preAction', (_thisCmd, actionCmd) => {
|
|
35
35
|
(0, log_id_1.generateLogId)();
|
|
36
36
|
const opts = actionCmd.optsWithGlobals();
|
|
37
37
|
(0, config_1.initConfigFromOpts)(opts);
|
package/dist/utils/args.js
CHANGED
package/dist/utils/colors.js
CHANGED
|
@@ -46,8 +46,8 @@ const picocolors_1 = require("picocolors");
|
|
|
46
46
|
*/
|
|
47
47
|
function shouldColorize() {
|
|
48
48
|
const env = process.env;
|
|
49
|
-
const noColor = env.NO_COLOR != null && env.NO_COLOR !==
|
|
50
|
-
const forceColor = env.FORCE_COLOR != null && env.FORCE_COLOR !==
|
|
49
|
+
const noColor = env.NO_COLOR != null && env.NO_COLOR !== '';
|
|
50
|
+
const forceColor = env.FORCE_COLOR != null && env.FORCE_COLOR !== '';
|
|
51
51
|
const isTTY = process.stdout.isTTY === true;
|
|
52
52
|
return forceColor || (!noColor && isTTY);
|
|
53
53
|
}
|
package/dist/utils/config.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.resetConfig = resetConfig;
|
|
|
6
6
|
exports.initConfigFromOpts = initConfigFromOpts;
|
|
7
7
|
const defaults = {
|
|
8
8
|
json: false,
|
|
9
|
-
output:
|
|
9
|
+
output: 'pretty',
|
|
10
10
|
verbose: false,
|
|
11
11
|
};
|
|
12
12
|
let config = { ...defaults };
|
|
@@ -25,7 +25,7 @@ function initConfigFromOpts(opts) {
|
|
|
25
25
|
const output = opts.output;
|
|
26
26
|
setConfig({
|
|
27
27
|
json: json ?? defaults.json,
|
|
28
|
-
output: output ===
|
|
28
|
+
output: output === 'json' || json ? 'json' : defaults.output,
|
|
29
29
|
verbose: opts.verbose ?? defaults.verbose,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -11,16 +11,16 @@ const error_1 = require("./error");
|
|
|
11
11
|
*/
|
|
12
12
|
function mapDevopsError(bizCode, message) {
|
|
13
13
|
switch (bizCode) {
|
|
14
|
-
case
|
|
15
|
-
case
|
|
16
|
-
return new error_1.AppError(
|
|
17
|
-
next_actions: [
|
|
14
|
+
case '400002577':
|
|
15
|
+
case '400002569':
|
|
16
|
+
return new error_1.AppError('APP_NOT_FOUND', message, {
|
|
17
|
+
next_actions: ['Run `miaoda app list` to see available apps'],
|
|
18
18
|
});
|
|
19
|
-
case
|
|
20
|
-
return new error_1.AppError(
|
|
21
|
-
case
|
|
22
|
-
return new error_1.AppError(
|
|
23
|
-
next_actions: [
|
|
19
|
+
case '400002579':
|
|
20
|
+
return new error_1.AppError('APP_PERMISSION_DENIED', message);
|
|
21
|
+
case '400002575':
|
|
22
|
+
return new error_1.AppError('INVALID_ARG_VALUE', message, {
|
|
23
|
+
next_actions: ['缩短 --name / --description 后重试(后端有长度限制)'],
|
|
24
24
|
});
|
|
25
25
|
default:
|
|
26
26
|
return undefined;
|
package/dist/utils/error.js
CHANGED
|
@@ -16,7 +16,7 @@ class AppError extends Error {
|
|
|
16
16
|
rolled_back;
|
|
17
17
|
constructor(code, message, opts) {
|
|
18
18
|
super(message);
|
|
19
|
-
this.name =
|
|
19
|
+
this.name = 'AppError';
|
|
20
20
|
this.code = code;
|
|
21
21
|
this.retryable = opts?.retryable ?? false;
|
|
22
22
|
this.next_actions = opts?.next_actions ?? [];
|
|
@@ -41,7 +41,7 @@ class HttpError extends AppError {
|
|
|
41
41
|
url;
|
|
42
42
|
constructor(status, url, message, opts) {
|
|
43
43
|
super(`HTTP_${String(status)}`, message, opts ?? { retryable: status >= 500 || status === 429 });
|
|
44
|
-
this.name =
|
|
44
|
+
this.name = 'HttpError';
|
|
45
45
|
this.status = status;
|
|
46
46
|
this.url = url;
|
|
47
47
|
}
|
package/dist/utils/git.js
CHANGED
|
@@ -11,10 +11,10 @@ const node_child_process_1 = require("node:child_process");
|
|
|
11
11
|
function getCurrentGitBranch(cwd = process.cwd()) {
|
|
12
12
|
let result;
|
|
13
13
|
try {
|
|
14
|
-
result = (0, node_child_process_1.spawnSync)(
|
|
14
|
+
result = (0, node_child_process_1.spawnSync)('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
15
15
|
cwd,
|
|
16
|
-
encoding:
|
|
17
|
-
stdio: [
|
|
16
|
+
encoding: 'utf8',
|
|
17
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
catch {
|
|
@@ -23,7 +23,7 @@ function getCurrentGitBranch(cwd = process.cwd()) {
|
|
|
23
23
|
if (result.status !== 0)
|
|
24
24
|
return undefined;
|
|
25
25
|
const branch = result.stdout.trim();
|
|
26
|
-
if (!branch || branch ===
|
|
26
|
+
if (!branch || branch === 'HEAD')
|
|
27
27
|
return undefined;
|
|
28
28
|
return branch;
|
|
29
29
|
}
|
package/dist/utils/http.js
CHANGED
|
@@ -66,36 +66,36 @@ function applyCanaryHeader(reqConfig) {
|
|
|
66
66
|
if (!canary)
|
|
67
67
|
return reqConfig;
|
|
68
68
|
const headers = new Headers(reqConfig.headers);
|
|
69
|
-
headers.set(
|
|
69
|
+
headers.set('x-tt-env', canary);
|
|
70
70
|
reqConfig.headers = headers;
|
|
71
71
|
return reqConfig;
|
|
72
72
|
}
|
|
73
73
|
/** 走管理端 innerapi 的 POST + 信封解析 */
|
|
74
74
|
async function postInnerApi(url, body, opts) {
|
|
75
|
-
const startMs = logRequestStart(
|
|
75
|
+
const startMs = logRequestStart('POST', url, body);
|
|
76
76
|
let response;
|
|
77
77
|
try {
|
|
78
78
|
response = await getHttpClient().post(url, body);
|
|
79
79
|
}
|
|
80
80
|
catch (err) {
|
|
81
|
-
logResponseFailure(
|
|
81
|
+
logResponseFailure('POST', url, err, startMs);
|
|
82
82
|
throw err;
|
|
83
83
|
}
|
|
84
|
-
logResponseEnd(
|
|
84
|
+
logResponseEnd('POST', url, response, startMs);
|
|
85
85
|
return handleInnerEnvelope(response, url, opts);
|
|
86
86
|
}
|
|
87
87
|
/** 走管理端 innerapi 的 GET + 信封解析 */
|
|
88
88
|
async function getInnerApi(url, opts) {
|
|
89
|
-
const startMs = logRequestStart(
|
|
89
|
+
const startMs = logRequestStart('GET', url);
|
|
90
90
|
let response;
|
|
91
91
|
try {
|
|
92
92
|
response = await getHttpClient().get(url);
|
|
93
93
|
}
|
|
94
94
|
catch (err) {
|
|
95
|
-
logResponseFailure(
|
|
95
|
+
logResponseFailure('GET', url, err, startMs);
|
|
96
96
|
throw err;
|
|
97
97
|
}
|
|
98
|
-
logResponseEnd(
|
|
98
|
+
logResponseEnd('GET', url, response, startMs);
|
|
99
99
|
return handleInnerEnvelope(response, url, opts);
|
|
100
100
|
}
|
|
101
101
|
async function handleInnerEnvelope(response, url, opts) {
|
|
@@ -103,10 +103,10 @@ async function handleInnerEnvelope(response, url, opts) {
|
|
|
103
103
|
throw new error_1.HttpError(response.status, url, `${opts.errPrefix}: ${String(response.status)} ${response.statusText}`);
|
|
104
104
|
}
|
|
105
105
|
const result = await response.json();
|
|
106
|
-
if (typeof result ===
|
|
106
|
+
if (typeof result === 'object' && result !== null && 'status_code' in result) {
|
|
107
107
|
const env = result;
|
|
108
|
-
if (env.status_code !== undefined && env.status_code !==
|
|
109
|
-
const msg = env.message ?? env.error_msg ??
|
|
108
|
+
if (env.status_code !== undefined && env.status_code !== '0') {
|
|
109
|
+
const msg = env.message ?? env.error_msg ?? 'unknown error';
|
|
110
110
|
// verbose: 把完整业务错误信封打到 stderr,便于追溯
|
|
111
111
|
if ((0, config_1.getConfig)().verbose) {
|
|
112
112
|
(0, logger_1.debug)(` envelope: ${truncateForLog(safeStringify(env), 1000)}`);
|
|
@@ -114,7 +114,7 @@ async function handleInnerEnvelope(response, url, opts) {
|
|
|
114
114
|
const mapped = opts.mapErr?.(env.status_code, msg);
|
|
115
115
|
if (mapped)
|
|
116
116
|
throw mapped;
|
|
117
|
-
throw new error_1.AppError(opts.defaultErrCode ??
|
|
117
|
+
throw new error_1.AppError(opts.defaultErrCode ?? 'INTERNAL_API_ERROR', `${opts.errPrefix}: ${msg}`);
|
|
118
118
|
}
|
|
119
119
|
// status_code = "0":data 存在则解封;否则 envelope 自身就是业务体
|
|
120
120
|
if (env.data)
|
|
@@ -142,7 +142,7 @@ function logResponseEnd(method, url, response, startMs) {
|
|
|
142
142
|
return;
|
|
143
143
|
const elapsedMs = Date.now() - startMs;
|
|
144
144
|
const logid = pickLogid(response.headers);
|
|
145
|
-
const tail = logid ? ` logid=${logid}` :
|
|
145
|
+
const tail = logid ? ` logid=${logid}` : '';
|
|
146
146
|
(0, logger_1.debug)(`← ${method} ${url} ${String(response.status)} ${String(elapsedMs)}ms${tail}`);
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
@@ -158,17 +158,17 @@ function logResponseFailure(method, url, err, startMs) {
|
|
|
158
158
|
const e = err;
|
|
159
159
|
const status = e.response?.status;
|
|
160
160
|
const logid = e.response?.headers ? pickLogid(e.response.headers) : null;
|
|
161
|
-
const statusPart = status !== undefined ? String(status) :
|
|
162
|
-
const logidPart = logid ? ` logid=${logid}` :
|
|
163
|
-
const msgPart = e.message ? ` (${e.message})` :
|
|
161
|
+
const statusPart = status !== undefined ? String(status) : 'ERR';
|
|
162
|
+
const logidPart = logid ? ` logid=${logid}` : '';
|
|
163
|
+
const msgPart = e.message ? ` (${e.message})` : '';
|
|
164
164
|
(0, logger_1.debug)(`✗ ${method} ${url} ${statusPart} ${String(elapsedMs)}ms${logidPart}${msgPart}`);
|
|
165
165
|
}
|
|
166
166
|
/** BAM gateway 在不同 PSM/版本上 logid 落在不同 header;按命中顺序取第一个非空。 */
|
|
167
167
|
function pickLogid(headers) {
|
|
168
|
-
return (headers.get(
|
|
169
|
-
headers.get(
|
|
170
|
-
headers.get(
|
|
171
|
-
headers.get(
|
|
168
|
+
return (headers.get('x-tt-logid') ??
|
|
169
|
+
headers.get('x-logid') ??
|
|
170
|
+
headers.get('logid') ??
|
|
171
|
+
headers.get('x-tt-trace-tag'));
|
|
172
172
|
}
|
|
173
173
|
function safeStringify(v) {
|
|
174
174
|
try {
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.msToSec = exports.msToNs = exports.parseToSec = exports.parseToNs = exports.parseToMs = exports.parseTimeToMs = exports.getInnerApi = exports.postInnerApi = exports.setRuntimeHttpClient = exports.setHttpClient = exports.resetHttpClient = exports.getRuntimeHttpClient = exports.getHttpClient = exports.log = exports.debug = exports.fmt = exports.isJsonMode = exports.emitPaged = exports.emitOk = exports.emitError = exports.emit = exports.getLogId = exports.generateLogId = exports.initConfigFromOpts = exports.resetConfig = exports.setConfig = exports.getConfig = exports.HttpError = exports.AppError = void 0;
|
|
3
|
+
exports.pollUntilDone = exports.msToSec = exports.msToNs = exports.parseToSec = exports.parseToNs = exports.parseToMs = exports.parseTimeToMs = exports.getInnerApi = exports.postInnerApi = exports.setRuntimeHttpClient = exports.setHttpClient = exports.resetHttpClient = exports.getRuntimeHttpClient = exports.getHttpClient = exports.log = exports.debug = exports.fmt = exports.isJsonMode = exports.emitPaged = exports.emitOk = exports.emitError = exports.emit = exports.getLogId = exports.generateLogId = exports.initConfigFromOpts = exports.resetConfig = exports.setConfig = exports.getConfig = exports.HttpError = exports.AppError = void 0;
|
|
4
4
|
var error_1 = require("./error");
|
|
5
5
|
Object.defineProperty(exports, "AppError", { enumerable: true, get: function () { return error_1.AppError; } });
|
|
6
6
|
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return error_1.HttpError; } });
|
|
@@ -37,3 +37,5 @@ Object.defineProperty(exports, "parseToNs", { enumerable: true, get: function ()
|
|
|
37
37
|
Object.defineProperty(exports, "parseToSec", { enumerable: true, get: function () { return time_1.parseToSec; } });
|
|
38
38
|
Object.defineProperty(exports, "msToNs", { enumerable: true, get: function () { return time_1.msToNs; } });
|
|
39
39
|
Object.defineProperty(exports, "msToSec", { enumerable: true, get: function () { return time_1.msToSec; } });
|
|
40
|
+
var poll_1 = require("./poll");
|
|
41
|
+
Object.defineProperty(exports, "pollUntilDone", { enumerable: true, get: function () { return poll_1.pollUntilDone; } });
|