@coze/cli 0.1.0-alpha.5aabeb → 0.1.0-alpha.f2dd23
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/LICENSE.md +21 -0
- package/README.md +299 -37
- package/THIRD-PARTY-LICENSES.md +31 -0
- package/lib/cli.js +2010 -1659
- package/lib/{index-DhC0nL6S.js → index-SwtgDxQR.js} +7116 -7110
- package/lib/send-message.worker.js +1 -1
- package/package.json +11 -14
package/lib/cli.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const index = require('./index-
|
|
4
|
+
const index = require('./index-SwtgDxQR.js');
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
const node_child_process = require('node:child_process');
|
|
5
7
|
const fs = require('node:fs/promises');
|
|
6
8
|
const os = require('node:os');
|
|
7
9
|
const path = require('node:path');
|
|
10
|
+
const undici = require('undici');
|
|
8
11
|
const node_fs = require('node:fs');
|
|
9
|
-
const chalk = require('chalk');
|
|
10
12
|
const path$1 = require('path');
|
|
11
13
|
const promises = require('fs/promises');
|
|
12
14
|
const require$$0 = require('fs');
|
|
@@ -28,7 +30,6 @@ require('tty');
|
|
|
28
30
|
require('os');
|
|
29
31
|
require('zlib');
|
|
30
32
|
require('events');
|
|
31
|
-
require('undici');
|
|
32
33
|
|
|
33
34
|
function _interopNamespaceDefault(e) {
|
|
34
35
|
const n = Object.create(null);
|
|
@@ -65,6 +66,24 @@ const handleCliError = (error, ctx) => {
|
|
|
65
66
|
|
|
66
67
|
if (error instanceof index.CozeError) {
|
|
67
68
|
cozeError = error;
|
|
69
|
+
} else if (error instanceof index.ChatCoreError) {
|
|
70
|
+
// 将 ChatCoreError 转换为 CozeError,保留原始错误信息
|
|
71
|
+
const { ext } = error;
|
|
72
|
+
const message = ext.logId
|
|
73
|
+
? `${error.message}\n LogID: ${ext.logId}`
|
|
74
|
+
: error.message;
|
|
75
|
+
|
|
76
|
+
// 根据错误码映射退出码
|
|
77
|
+
let exitCode = index.ExitCode.GENERAL_ERROR;
|
|
78
|
+
if (typeof ext.code === 'number') {
|
|
79
|
+
if (ext.code === 700012006) {
|
|
80
|
+
exitCode = index.ExitCode.AUTH_FAILED;
|
|
81
|
+
} else if (ext.code >= 500) {
|
|
82
|
+
exitCode = index.ExitCode.SERVER_ERROR;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
cozeError = new index.CozeError(message, exitCode, ext.rawError || ext);
|
|
68
87
|
} else if (index.isHttpError(error)) {
|
|
69
88
|
const details = error.toJSON();
|
|
70
89
|
const message = [
|
|
@@ -103,6 +122,372 @@ const handleCliError = (error, ctx) => {
|
|
|
103
122
|
process.exit(cozeError.code);
|
|
104
123
|
};
|
|
105
124
|
|
|
125
|
+
function _nullishCoalesce$l(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
const GLOBAL_CONFIG_DIR = path__namespace.join(os__namespace.homedir(), '.coze');
|
|
151
|
+
const GLOBAL_CONFIG_FILE = path__namespace.join(GLOBAL_CONFIG_DIR, 'config.json');
|
|
152
|
+
const LOCAL_CONFIG_FILE = path__namespace.join(process.cwd(), '.cozerc.json');
|
|
153
|
+
|
|
154
|
+
const DEFAULT_CONFIG = {
|
|
155
|
+
apiBaseUrl: 'https://code.coze.cn/',
|
|
156
|
+
openApiBaseUrl: 'https://api.coze.cn',
|
|
157
|
+
integrationApiBaseUrl: 'https://integration.coze.cn',
|
|
158
|
+
clientId: '95438868623436343239609434490626.app.coze',
|
|
159
|
+
defaultOutputFormat: 'json',
|
|
160
|
+
// 当前测试使用,后续会根据环境变量动态切换
|
|
161
|
+
xTTEnv: 'ppe_coze_cli',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
async function readJsonIfExists(file) {
|
|
165
|
+
try {
|
|
166
|
+
const content = await fs__namespace.readFile(file, 'utf8');
|
|
167
|
+
return JSON.parse(content) ;
|
|
168
|
+
} catch (e) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 从环境变量中获取配置
|
|
175
|
+
* 环境变量的优先级最高,会覆盖配置文件中的设置
|
|
176
|
+
*
|
|
177
|
+
* 支持的环境变量:
|
|
178
|
+
* - COZE_API_TOKEN -> accessToken
|
|
179
|
+
* - COZE_ORG_ID -> organizationId
|
|
180
|
+
* - COZE_ENTERPRISE_ID -> enterpriseId
|
|
181
|
+
* - COZE_SPACE_ID -> spaceId
|
|
182
|
+
* - COZE_CONFIG_SCOPE -> configScope ('global' | 'local')
|
|
183
|
+
*/
|
|
184
|
+
function getEnvConfig() {
|
|
185
|
+
const envConfig = {};
|
|
186
|
+
if (process.env.COZE_API_TOKEN) {
|
|
187
|
+
envConfig.accessToken = process.env.COZE_API_TOKEN;
|
|
188
|
+
}
|
|
189
|
+
if (process.env.COZE_ORG_ID) {
|
|
190
|
+
envConfig.organizationId = process.env.COZE_ORG_ID;
|
|
191
|
+
}
|
|
192
|
+
if (process.env.COZE_ENTERPRISE_ID) {
|
|
193
|
+
envConfig.enterpriseId = process.env.COZE_ENTERPRISE_ID;
|
|
194
|
+
}
|
|
195
|
+
if (process.env.COZE_SPACE_ID) {
|
|
196
|
+
envConfig.spaceId = process.env.COZE_SPACE_ID;
|
|
197
|
+
}
|
|
198
|
+
if (
|
|
199
|
+
process.env.COZE_CONFIG_SCOPE === 'global' ||
|
|
200
|
+
process.env.COZE_CONFIG_SCOPE === 'local'
|
|
201
|
+
) {
|
|
202
|
+
envConfig.configScope = process.env.COZE_CONFIG_SCOPE;
|
|
203
|
+
}
|
|
204
|
+
return envConfig;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 加载 CLI 配置
|
|
209
|
+
* 配置加载优先级(从高到低):
|
|
210
|
+
* 1. 环境变量 (Environment Variables)
|
|
211
|
+
* 2. 命令行指定的配置文件 (Custom Config)
|
|
212
|
+
* 3. 项目级配置文件 (.cozerc.json)
|
|
213
|
+
* 4. 全局配置文件 (~/.coze/config.json)
|
|
214
|
+
* 5. 默认配置 (DEFAULT_CONFIG)
|
|
215
|
+
*
|
|
216
|
+
* @param configPath 自定义配置文件路径
|
|
217
|
+
*/
|
|
218
|
+
async function loadConfig(configPath) {
|
|
219
|
+
const [globalConfig, localConfig, customConfig] = await Promise.all([
|
|
220
|
+
readJsonIfExists(GLOBAL_CONFIG_FILE),
|
|
221
|
+
readJsonIfExists(LOCAL_CONFIG_FILE),
|
|
222
|
+
configPath ? readJsonIfExists(configPath) : undefined,
|
|
223
|
+
]);
|
|
224
|
+
|
|
225
|
+
const envConfig = getEnvConfig();
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
...DEFAULT_CONFIG,
|
|
229
|
+
...globalConfig,
|
|
230
|
+
...localConfig,
|
|
231
|
+
...customConfig,
|
|
232
|
+
...envConfig,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 保存配置到文件
|
|
238
|
+
*
|
|
239
|
+
* @param config 要保存的配置项(支持部分更新)
|
|
240
|
+
* @param scope 配置作用域:
|
|
241
|
+
* - 'global': 保存到用户主目录 (~/.coze/config.json)
|
|
242
|
+
* - 'local': 保存到当前工作目录 (.cozerc.json)
|
|
243
|
+
*/
|
|
244
|
+
async function saveConfig(
|
|
245
|
+
config,
|
|
246
|
+
scope = _nullishCoalesce$l(getEnvConfig().configScope, () => ( 'global')),
|
|
247
|
+
) {
|
|
248
|
+
const targetFile =
|
|
249
|
+
scope === 'global' ? GLOBAL_CONFIG_FILE : LOCAL_CONFIG_FILE;
|
|
250
|
+
const targetDir = path__namespace.dirname(targetFile);
|
|
251
|
+
|
|
252
|
+
try {
|
|
253
|
+
await fs__namespace.mkdir(targetDir, { recursive: true });
|
|
254
|
+
|
|
255
|
+
const existingConfig =
|
|
256
|
+
(await readJsonIfExists(targetFile)) || {};
|
|
257
|
+
const newConfig = { ...existingConfig, ...config };
|
|
258
|
+
|
|
259
|
+
await fs__namespace.writeFile(targetFile, JSON.stringify(newConfig, null, 2), 'utf8');
|
|
260
|
+
} catch (error) {
|
|
261
|
+
throw new Error(`Failed to save config to ${targetFile}: ${error}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 删除指定的配置项
|
|
267
|
+
* 优先从 local 删除,如果 local 中没有,则从 global 删除
|
|
268
|
+
*
|
|
269
|
+
* @param key 要删除的配置键
|
|
270
|
+
*/
|
|
271
|
+
async function deleteConfig(key) {
|
|
272
|
+
let targetFile = LOCAL_CONFIG_FILE;
|
|
273
|
+
let existingConfig = await readJsonIfExists(targetFile);
|
|
274
|
+
|
|
275
|
+
if (!existingConfig || !(key in existingConfig)) {
|
|
276
|
+
targetFile = GLOBAL_CONFIG_FILE;
|
|
277
|
+
existingConfig = await readJsonIfExists(targetFile);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (!existingConfig || !(key in existingConfig)) {
|
|
281
|
+
return; // Config doesn't exist in local or global, nothing to delete
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
try {
|
|
285
|
+
delete existingConfig[key];
|
|
286
|
+
await fs__namespace.writeFile(
|
|
287
|
+
targetFile,
|
|
288
|
+
JSON.stringify(existingConfig, null, 2),
|
|
289
|
+
'utf8',
|
|
290
|
+
);
|
|
291
|
+
} catch (error) {
|
|
292
|
+
throw new Error(`Failed to delete config from ${targetFile}: ${error}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 获取所有配置项的详细信息(包含来源)
|
|
304
|
+
*/
|
|
305
|
+
async function listConfigs() {
|
|
306
|
+
const [globalConfig, localConfig] = await Promise.all([
|
|
307
|
+
readJsonIfExists(GLOBAL_CONFIG_FILE),
|
|
308
|
+
readJsonIfExists(LOCAL_CONFIG_FILE),
|
|
309
|
+
]);
|
|
310
|
+
|
|
311
|
+
const envConfig = getEnvConfig();
|
|
312
|
+
const allKeys = new Set([
|
|
313
|
+
...Object.keys(DEFAULT_CONFIG),
|
|
314
|
+
...Object.keys(globalConfig || {}),
|
|
315
|
+
...Object.keys(localConfig || {}),
|
|
316
|
+
...Object.keys(envConfig),
|
|
317
|
+
]);
|
|
318
|
+
|
|
319
|
+
const result = [];
|
|
320
|
+
|
|
321
|
+
for (const key of Array.from(allKeys)) {
|
|
322
|
+
const k = key ;
|
|
323
|
+
let value;
|
|
324
|
+
let source = 'default';
|
|
325
|
+
|
|
326
|
+
if (k in envConfig && envConfig[k ] !== undefined) {
|
|
327
|
+
value = envConfig[k ];
|
|
328
|
+
source = 'env';
|
|
329
|
+
} else if (
|
|
330
|
+
localConfig &&
|
|
331
|
+
k in localConfig &&
|
|
332
|
+
localConfig[k] !== undefined
|
|
333
|
+
) {
|
|
334
|
+
value = String(localConfig[k]);
|
|
335
|
+
source = 'local';
|
|
336
|
+
} else if (
|
|
337
|
+
globalConfig &&
|
|
338
|
+
k in globalConfig &&
|
|
339
|
+
globalConfig[k] !== undefined
|
|
340
|
+
) {
|
|
341
|
+
value = String(globalConfig[k]);
|
|
342
|
+
source = 'global';
|
|
343
|
+
} else if (k in DEFAULT_CONFIG) {
|
|
344
|
+
value = String(DEFAULT_CONFIG[k ]);
|
|
345
|
+
source = 'default';
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
result.push({ key, value, source });
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return result;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
var name = "@coze/cli";
|
|
355
|
+
var version = "0.1.0-alpha.f2dd23";
|
|
356
|
+
const packageJson = {
|
|
357
|
+
name: name,
|
|
358
|
+
version: version};
|
|
359
|
+
|
|
360
|
+
const PACKAGE_NAME = packageJson.name;
|
|
361
|
+
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
362
|
+
const HOURS_PER_DAY = 24;
|
|
363
|
+
const MINUTES_PER_HOUR = 60;
|
|
364
|
+
const SECONDS_PER_MINUTE = 60;
|
|
365
|
+
const MS_PER_SECOND = 1000;
|
|
366
|
+
const CHECK_INTERVAL_MS =
|
|
367
|
+
HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
function getCurrentVersion() {
|
|
376
|
+
return packageJson.version;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function compareVersions(current, latest) {
|
|
380
|
+
const parseSemver = (v) => {
|
|
381
|
+
const parts = v.replace(/^v/, '').split('.');
|
|
382
|
+
return {
|
|
383
|
+
major: parseInt(parts[0] || '0', 10),
|
|
384
|
+
minor: parseInt(parts[1] || '0', 10),
|
|
385
|
+
patch: parseInt(parts[2] || '0', 10),
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const c = parseSemver(current);
|
|
390
|
+
const l = parseSemver(latest);
|
|
391
|
+
|
|
392
|
+
if (l.major !== c.major) {
|
|
393
|
+
return l.major > c.major;
|
|
394
|
+
}
|
|
395
|
+
if (l.minor !== c.minor) {
|
|
396
|
+
return l.minor > c.minor;
|
|
397
|
+
}
|
|
398
|
+
return l.patch > c.patch;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function getNpmRegistry() {
|
|
402
|
+
try {
|
|
403
|
+
return node_child_process.execSync('npm config get registry', {
|
|
404
|
+
encoding: 'utf8',
|
|
405
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
406
|
+
})
|
|
407
|
+
.trim()
|
|
408
|
+
.replace(/\/+$/, '');
|
|
409
|
+
} catch (e) {
|
|
410
|
+
return DEFAULT_REGISTRY;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
async function fetchLatestVersion(
|
|
415
|
+
registryUrl,
|
|
416
|
+
tag = 'latest',
|
|
417
|
+
) {
|
|
418
|
+
const url = `${registryUrl}/${PACKAGE_NAME}/${tag}`;
|
|
419
|
+
const response = await index.customFetch.fetch(url, {
|
|
420
|
+
headers: { accept: 'application/json' },
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
if (!response.ok) {
|
|
424
|
+
throw new Error(
|
|
425
|
+
`Failed to fetch latest version: ${response.status} ${response.statusText}`,
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const data = (await response.json()) ;
|
|
430
|
+
return data.version;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
async function checkForUpdates(
|
|
434
|
+
context,
|
|
435
|
+
forceCheck = false,
|
|
436
|
+
tag = 'latest',
|
|
437
|
+
) {
|
|
438
|
+
const currentVersion = getCurrentVersion();
|
|
439
|
+
const { config } = context;
|
|
440
|
+
|
|
441
|
+
if (!forceCheck) {
|
|
442
|
+
if (
|
|
443
|
+
config.latestVersion &&
|
|
444
|
+
config.lastCheckTime &&
|
|
445
|
+
Date.now() - config.lastCheckTime < CHECK_INTERVAL_MS
|
|
446
|
+
) {
|
|
447
|
+
return {
|
|
448
|
+
currentVersion,
|
|
449
|
+
latestVersion: config.latestVersion,
|
|
450
|
+
hasUpdate: compareVersions(currentVersion, config.latestVersion),
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const registryUrl = getNpmRegistry();
|
|
456
|
+
const latestVersion = await fetchLatestVersion(registryUrl, tag);
|
|
457
|
+
|
|
458
|
+
await saveConfig(
|
|
459
|
+
{ latestVersion, lastCheckTime: Date.now() },
|
|
460
|
+
config.configScope,
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
return {
|
|
464
|
+
currentVersion,
|
|
465
|
+
latestVersion,
|
|
466
|
+
hasUpdate: compareVersions(currentVersion, latestVersion),
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async function updateCheckMiddleware(
|
|
471
|
+
context,
|
|
472
|
+
next,
|
|
473
|
+
) {
|
|
474
|
+
await next();
|
|
475
|
+
|
|
476
|
+
try {
|
|
477
|
+
const result = await checkForUpdates(context);
|
|
478
|
+
|
|
479
|
+
if (result.hasUpdate) {
|
|
480
|
+
const message =
|
|
481
|
+
`\nUpdate available: ${chalk.gray(result.currentVersion)} → ${chalk.green(result.latestVersion)}` +
|
|
482
|
+
`\nRun ${chalk.cyan('coze upgrade')} to update\n`;
|
|
483
|
+
context.ui.info(message);
|
|
484
|
+
}
|
|
485
|
+
// eslint-disable-next-line @coze-arch/no-empty-catch -- update check failure is non-critical
|
|
486
|
+
} catch (_error) {
|
|
487
|
+
/* noop */
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
106
491
|
async function requestMiddleware(
|
|
107
492
|
context,
|
|
108
493
|
next,
|
|
@@ -111,10 +496,18 @@ async function requestMiddleware(
|
|
|
111
496
|
|
|
112
497
|
index.axiosInstance.defaults.baseURL = context.config.apiBaseUrl;
|
|
113
498
|
// axiosInstance.defaults.headers.cookie = token || '';
|
|
114
|
-
|
|
499
|
+
const tokenInHeader = `Bearer ${token}`;
|
|
500
|
+
index.axiosInstance.defaults.headers.Authorization = tokenInHeader;
|
|
501
|
+
index.customFetch.setHeaders({
|
|
502
|
+
Authorization: tokenInHeader,
|
|
503
|
+
});
|
|
115
504
|
if (context.config.xTTEnv) {
|
|
116
505
|
index.axiosInstance.defaults.headers['x-use-ppe'] = '1';
|
|
117
506
|
index.axiosInstance.defaults.headers['x-tt-env'] = context.config.xTTEnv;
|
|
507
|
+
index.customFetch.setHeaders({
|
|
508
|
+
'x-use-ppe': '1',
|
|
509
|
+
'x-tt-env': context.config.xTTEnv,
|
|
510
|
+
});
|
|
118
511
|
}
|
|
119
512
|
|
|
120
513
|
await next();
|
|
@@ -416,8 +809,9 @@ const proxyMiddleware = async (
|
|
|
416
809
|
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
|
417
810
|
|
|
418
811
|
if (httpsProxy || httpProxy) {
|
|
812
|
+
const dispatcher = new undici.EnvHttpProxyAgent();
|
|
813
|
+
index.customFetch.setDispatcher(dispatcher);
|
|
419
814
|
// 动态导入 ESM 模块
|
|
420
|
-
|
|
421
815
|
const [{ HttpProxyAgent }, { HttpsProxyAgent }] = await Promise.all([
|
|
422
816
|
import('http-proxy-agent'),
|
|
423
817
|
import('https-proxy-agent'),
|
|
@@ -440,203 +834,6 @@ const proxyMiddleware = async (
|
|
|
440
834
|
await next();
|
|
441
835
|
};
|
|
442
836
|
|
|
443
|
-
const GLOBAL_CONFIG_DIR = path__namespace.join(os__namespace.homedir(), '.coze');
|
|
444
|
-
const GLOBAL_CONFIG_FILE = path__namespace.join(GLOBAL_CONFIG_DIR, 'config.json');
|
|
445
|
-
const LOCAL_CONFIG_FILE = path__namespace.join(process.cwd(), '.cozerc.json');
|
|
446
|
-
|
|
447
|
-
const DEFAULT_CONFIG = {
|
|
448
|
-
apiBaseUrl: 'https://code.coze.cn/',
|
|
449
|
-
openApiBaseUrl: 'https://api.coze.cn',
|
|
450
|
-
integrationApiBaseUrl: 'https://integration.coze.cn',
|
|
451
|
-
clientId: '95438868623436343239609434490626.app.coze',
|
|
452
|
-
defaultOutputFormat: 'json',
|
|
453
|
-
// 当前测试使用,后续会根据环境变量动态切换
|
|
454
|
-
xTTEnv: 'ppe_coze_cli',
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
async function readJsonIfExists(file) {
|
|
458
|
-
try {
|
|
459
|
-
const content = await fs__namespace.readFile(file, 'utf8');
|
|
460
|
-
return JSON.parse(content) ;
|
|
461
|
-
} catch (e) {
|
|
462
|
-
return undefined;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* 从环境变量中获取配置
|
|
468
|
-
* 环境变量的优先级最高,会覆盖配置文件中的设置
|
|
469
|
-
*
|
|
470
|
-
* 支持的环境变量:
|
|
471
|
-
* - COZE_API_TOKEN -> accessToken
|
|
472
|
-
* - COZE_ORG_ID -> organizationId
|
|
473
|
-
* - COZE_ENTERPRISE_ID -> enterpriseId
|
|
474
|
-
* - COZE_SPACE_ID -> spaceId
|
|
475
|
-
*/
|
|
476
|
-
function getEnvConfig() {
|
|
477
|
-
const envConfig = {};
|
|
478
|
-
if (process.env.COZE_API_TOKEN) {
|
|
479
|
-
envConfig.accessToken = process.env.COZE_API_TOKEN;
|
|
480
|
-
}
|
|
481
|
-
if (process.env.COZE_ORG_ID) {
|
|
482
|
-
envConfig.organizationId = process.env.COZE_ORG_ID;
|
|
483
|
-
}
|
|
484
|
-
if (process.env.COZE_ENTERPRISE_ID) {
|
|
485
|
-
envConfig.enterpriseId = process.env.COZE_ENTERPRISE_ID;
|
|
486
|
-
}
|
|
487
|
-
if (process.env.COZE_SPACE_ID) {
|
|
488
|
-
envConfig.spaceId = process.env.COZE_SPACE_ID;
|
|
489
|
-
}
|
|
490
|
-
return envConfig;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* 加载 CLI 配置
|
|
495
|
-
* 配置加载优先级(从高到低):
|
|
496
|
-
* 1. 环境变量 (Environment Variables)
|
|
497
|
-
* 2. 命令行指定的配置文件 (Custom Config)
|
|
498
|
-
* 3. 项目级配置文件 (.cozerc.json)
|
|
499
|
-
* 4. 全局配置文件 (~/.coze/config.json)
|
|
500
|
-
* 5. 默认配置 (DEFAULT_CONFIG)
|
|
501
|
-
*
|
|
502
|
-
* @param configPath 自定义配置文件路径
|
|
503
|
-
*/
|
|
504
|
-
async function loadConfig(configPath) {
|
|
505
|
-
const [globalConfig, localConfig, customConfig] = await Promise.all([
|
|
506
|
-
readJsonIfExists(GLOBAL_CONFIG_FILE),
|
|
507
|
-
readJsonIfExists(LOCAL_CONFIG_FILE),
|
|
508
|
-
configPath ? readJsonIfExists(configPath) : undefined,
|
|
509
|
-
]);
|
|
510
|
-
|
|
511
|
-
const envConfig = getEnvConfig();
|
|
512
|
-
|
|
513
|
-
return {
|
|
514
|
-
...DEFAULT_CONFIG,
|
|
515
|
-
...globalConfig,
|
|
516
|
-
...localConfig,
|
|
517
|
-
...customConfig,
|
|
518
|
-
...envConfig,
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* 保存配置到文件
|
|
524
|
-
*
|
|
525
|
-
* @param config 要保存的配置项(支持部分更新)
|
|
526
|
-
* @param scope 配置作用域:
|
|
527
|
-
* - 'global': 保存到用户主目录 (~/.coze/config.json)
|
|
528
|
-
* - 'local': 保存到当前工作目录 (.cozerc.json)
|
|
529
|
-
*/
|
|
530
|
-
async function saveConfig(
|
|
531
|
-
config,
|
|
532
|
-
scope = 'global',
|
|
533
|
-
) {
|
|
534
|
-
const targetFile =
|
|
535
|
-
scope === 'global' ? GLOBAL_CONFIG_FILE : LOCAL_CONFIG_FILE;
|
|
536
|
-
const targetDir = path__namespace.dirname(targetFile);
|
|
537
|
-
|
|
538
|
-
try {
|
|
539
|
-
await fs__namespace.mkdir(targetDir, { recursive: true });
|
|
540
|
-
|
|
541
|
-
const existingConfig =
|
|
542
|
-
(await readJsonIfExists(targetFile)) || {};
|
|
543
|
-
const newConfig = { ...existingConfig, ...config };
|
|
544
|
-
|
|
545
|
-
await fs__namespace.writeFile(targetFile, JSON.stringify(newConfig, null, 2), 'utf8');
|
|
546
|
-
} catch (error) {
|
|
547
|
-
throw new Error(`Failed to save config to ${targetFile}: ${error}`);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* 删除指定的配置项
|
|
553
|
-
* 优先从 local 删除,如果 local 中没有,则从 global 删除
|
|
554
|
-
*
|
|
555
|
-
* @param key 要删除的配置键
|
|
556
|
-
*/
|
|
557
|
-
async function deleteConfig(key) {
|
|
558
|
-
let targetFile = LOCAL_CONFIG_FILE;
|
|
559
|
-
let existingConfig = await readJsonIfExists(targetFile);
|
|
560
|
-
|
|
561
|
-
if (!existingConfig || !(key in existingConfig)) {
|
|
562
|
-
targetFile = GLOBAL_CONFIG_FILE;
|
|
563
|
-
existingConfig = await readJsonIfExists(targetFile);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
if (!existingConfig || !(key in existingConfig)) {
|
|
567
|
-
return; // Config doesn't exist in local or global, nothing to delete
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
try {
|
|
571
|
-
delete existingConfig[key];
|
|
572
|
-
await fs__namespace.writeFile(
|
|
573
|
-
targetFile,
|
|
574
|
-
JSON.stringify(existingConfig, null, 2),
|
|
575
|
-
'utf8',
|
|
576
|
-
);
|
|
577
|
-
} catch (error) {
|
|
578
|
-
throw new Error(`Failed to delete config from ${targetFile}: ${error}`);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* 获取所有配置项的详细信息(包含来源)
|
|
590
|
-
*/
|
|
591
|
-
async function listConfigs() {
|
|
592
|
-
const [globalConfig, localConfig] = await Promise.all([
|
|
593
|
-
readJsonIfExists(GLOBAL_CONFIG_FILE),
|
|
594
|
-
readJsonIfExists(LOCAL_CONFIG_FILE),
|
|
595
|
-
]);
|
|
596
|
-
|
|
597
|
-
const envConfig = getEnvConfig();
|
|
598
|
-
const allKeys = new Set([
|
|
599
|
-
...Object.keys(DEFAULT_CONFIG),
|
|
600
|
-
...Object.keys(globalConfig || {}),
|
|
601
|
-
...Object.keys(localConfig || {}),
|
|
602
|
-
...Object.keys(envConfig),
|
|
603
|
-
]);
|
|
604
|
-
|
|
605
|
-
const result = [];
|
|
606
|
-
|
|
607
|
-
for (const key of Array.from(allKeys)) {
|
|
608
|
-
const k = key ;
|
|
609
|
-
let value;
|
|
610
|
-
let source = 'default';
|
|
611
|
-
|
|
612
|
-
if (k in envConfig && envConfig[k ] !== undefined) {
|
|
613
|
-
value = envConfig[k ];
|
|
614
|
-
source = 'env';
|
|
615
|
-
} else if (
|
|
616
|
-
localConfig &&
|
|
617
|
-
k in localConfig &&
|
|
618
|
-
localConfig[k] !== undefined
|
|
619
|
-
) {
|
|
620
|
-
value = String(localConfig[k]);
|
|
621
|
-
source = 'local';
|
|
622
|
-
} else if (
|
|
623
|
-
globalConfig &&
|
|
624
|
-
k in globalConfig &&
|
|
625
|
-
globalConfig[k] !== undefined
|
|
626
|
-
) {
|
|
627
|
-
value = String(globalConfig[k]);
|
|
628
|
-
source = 'global';
|
|
629
|
-
} else if (k in DEFAULT_CONFIG) {
|
|
630
|
-
value = String(DEFAULT_CONFIG[k ]);
|
|
631
|
-
source = 'default';
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
result.push({ key, value, source });
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
return result;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
837
|
function compose(middlewares) {
|
|
641
838
|
if (!Array.isArray(middlewares)) {
|
|
642
839
|
throw new TypeError('Middleware stack must be an array!');
|
|
@@ -674,1194 +871,384 @@ function compose(middlewares) {
|
|
|
674
871
|
};
|
|
675
872
|
}
|
|
676
873
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
874
|
+
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
875
|
+
/* eslint-disable */
|
|
876
|
+
/* tslint:disable */
|
|
877
|
+
// @ts-nocheck
|
|
680
878
|
|
|
879
|
+
|
|
681
880
|
|
|
881
|
+
var AppAndPATAuthInfoItemType; (function (AppAndPATAuthInfoItemType) {
|
|
882
|
+
const app = 'app'; AppAndPATAuthInfoItemType["app"] = app;
|
|
883
|
+
const pat = 'pat'; AppAndPATAuthInfoItemType["pat"] = pat;
|
|
884
|
+
})(AppAndPATAuthInfoItemType || (AppAndPATAuthInfoItemType = {}));
|
|
682
885
|
|
|
886
|
+
var ApplicationForEnterpriseMemberStatus; (function (ApplicationForEnterpriseMemberStatus) {
|
|
887
|
+
const can_apply2 = 'CanApply'; ApplicationForEnterpriseMemberStatus["can_apply2"] = can_apply2;
|
|
888
|
+
const already_applied2 = 'AlreadyApplied'; ApplicationForEnterpriseMemberStatus["already_applied2"] = already_applied2;
|
|
889
|
+
const joined4 = 'Joined'; ApplicationForEnterpriseMemberStatus["joined4"] = joined4;
|
|
890
|
+
const deny3 = 'Deny'; ApplicationForEnterpriseMemberStatus["deny3"] = deny3;
|
|
891
|
+
})(ApplicationForEnterpriseMemberStatus || (ApplicationForEnterpriseMemberStatus = {}));
|
|
683
892
|
|
|
893
|
+
var ApplicationStatus; (function (ApplicationStatus) {
|
|
894
|
+
const processing = 'Processing'; ApplicationStatus["processing"] = processing;
|
|
895
|
+
const approved = 'Approved'; ApplicationStatus["approved"] = approved;
|
|
896
|
+
const rejected = 'Rejected'; ApplicationStatus["rejected"] = rejected;
|
|
897
|
+
})(ApplicationStatus || (ApplicationStatus = {}));
|
|
684
898
|
|
|
899
|
+
var AppType; (function (AppType) {
|
|
900
|
+
const normal = 'Normal'; AppType["normal"] = normal;
|
|
901
|
+
const connector = 'Connector'; AppType["connector"] = connector;
|
|
902
|
+
const privilege = 'Privilege'; AppType["privilege"] = privilege;
|
|
903
|
+
})(AppType || (AppType = {}));
|
|
685
904
|
|
|
905
|
+
var AuthorizationType; (function (AuthorizationType) {
|
|
906
|
+
const auth_app = 'AuthApp'; AuthorizationType["auth_app"] = auth_app;
|
|
907
|
+
const on_behalf_of_user = 'OnBehalfOfUser'; AuthorizationType["on_behalf_of_user"] = on_behalf_of_user;
|
|
908
|
+
})(AuthorizationType || (AuthorizationType = {}));
|
|
686
909
|
|
|
910
|
+
var AuthProvider; (function (AuthProvider) {
|
|
911
|
+
const password = 'Password'; AuthProvider["password"] = password;
|
|
912
|
+
const sms = 'Sms'; AuthProvider["sms"] = sms;
|
|
913
|
+
const email = 'Email'; AuthProvider["email"] = email;
|
|
914
|
+
const unknown3 = 'Unknown'; AuthProvider["unknown3"] = unknown3;
|
|
915
|
+
})(AuthProvider || (AuthProvider = {}));
|
|
687
916
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
green: '\x1b[32m',
|
|
694
|
-
yellow: '\x1b[33m',
|
|
695
|
-
cyan: '\x1b[36m',
|
|
696
|
-
silver: '\x1b[90m',
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
const BADGES = {
|
|
700
|
-
PROC: '[PROC]',
|
|
701
|
-
INFO: '[INFO]',
|
|
702
|
-
WARN: '[WARN]',
|
|
703
|
-
ERR: '[ERR]',
|
|
704
|
-
DONE: '[DONE]',
|
|
705
|
-
DBG: '[DBG]',
|
|
706
|
-
};
|
|
707
|
-
const LEVEL_PRIORITY = {
|
|
708
|
-
debug: 0,
|
|
709
|
-
verbose: 1,
|
|
710
|
-
info: 2,
|
|
711
|
-
success: 3,
|
|
712
|
-
warn: 4,
|
|
713
|
-
error: 5,
|
|
714
|
-
};
|
|
715
|
-
function badge(text) {
|
|
716
|
-
return `${C.dim}${C.bold}${text}${C.reset}`;
|
|
717
|
-
}
|
|
718
|
-
class UI {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
constructor(
|
|
726
|
-
log,
|
|
727
|
-
format,
|
|
728
|
-
level = 'info',
|
|
729
|
-
) {
|
|
730
|
-
this.log = log;
|
|
731
|
-
this.silent = format === 'json';
|
|
732
|
-
this.useColor = this.detectColorSupport();
|
|
733
|
-
this.level = level;
|
|
734
|
-
this.levelPriority = _nullishCoalesce$k(LEVEL_PRIORITY[level], () => ( 2));
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
detectColorSupport() {
|
|
738
|
-
return _optionalChain$J([process, 'access', _ => _.stderr, 'optionalAccess', _2 => _2.isTTY]) === true && process.env.NO_COLOR === undefined;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
paint(code, text) {
|
|
742
|
-
return this.useColor ? `${code}${text}${C.reset}` : text;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
shouldOutput(methodLevel) {
|
|
746
|
-
if (this.silent) {
|
|
747
|
-
return false;
|
|
748
|
-
}
|
|
749
|
-
return LEVEL_PRIORITY[methodLevel] >= this.levelPriority;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
verbose(msg, ...args) {
|
|
753
|
-
this.log.verbose(msg, ...args);
|
|
754
|
-
if (!this.shouldOutput('verbose')) {
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
process.stderr.write(`${badge(BADGES.PROC)} ${this.paint(C.cyan, msg)}\n`);
|
|
758
|
-
}
|
|
917
|
+
var AuthStatus; (function (AuthStatus) {
|
|
918
|
+
const authorized = 'authorized'; AuthStatus["authorized"] = authorized;
|
|
919
|
+
const unauthorized = 'unauthorized'; AuthStatus["unauthorized"] = unauthorized;
|
|
920
|
+
const expired4 = 'expired'; AuthStatus["expired4"] = expired4;
|
|
921
|
+
})(AuthStatus || (AuthStatus = {}));
|
|
759
922
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
process.stderr.write(`${badge(BADGES.INFO)} ${this.paint(C.reset, msg)}\n`);
|
|
766
|
-
}
|
|
923
|
+
var AuthType$1; (function (AuthType) {
|
|
924
|
+
const api_key = 'api_key'; AuthType["api_key"] = api_key;
|
|
925
|
+
const wechat_official = 'wechat_official'; AuthType["wechat_official"] = wechat_official;
|
|
926
|
+
const oauth_2 = 'oauth2'; AuthType["oauth_2"] = oauth_2;
|
|
927
|
+
})(AuthType$1 || (AuthType$1 = {}));
|
|
767
928
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
process.stderr.write(
|
|
774
|
-
`${badge(BADGES.WARN)} ${this.paint(C.yellow, msg)}\n`,
|
|
775
|
-
);
|
|
776
|
-
}
|
|
929
|
+
var Certificated; (function (Certificated) {
|
|
930
|
+
const noncertificated = 'Noncertificated'; Certificated["noncertificated"] = noncertificated;
|
|
931
|
+
const certificated = 'Certificated'; Certificated["certificated"] = certificated;
|
|
932
|
+
})(Certificated || (Certificated = {}));
|
|
777
933
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
process.stderr.write(`${badge(BADGES.ERR)} ${this.paint(C.red, msg)}\n`);
|
|
784
|
-
}
|
|
934
|
+
var CertificationType; (function (CertificationType) {
|
|
935
|
+
const uncertified = 'Uncertified'; CertificationType["uncertified"] = uncertified;
|
|
936
|
+
const personal_certification = 'PersonalCertification'; CertificationType["personal_certification"] = personal_certification;
|
|
937
|
+
const enterprise_certification = 'EnterpriseCertification'; CertificationType["enterprise_certification"] = enterprise_certification;
|
|
938
|
+
})(CertificationType || (CertificationType = {}));
|
|
785
939
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
process.stderr.write(`${badge(BADGES.DONE)} ${this.paint(C.green, msg)}\n`);
|
|
792
|
-
}
|
|
940
|
+
var ChecklistItemType; (function (ChecklistItemType) {
|
|
941
|
+
const obo = 'Obo'; ChecklistItemType["obo"] = obo;
|
|
942
|
+
const app_auth = 'AppAuth'; ChecklistItemType["app_auth"] = app_auth;
|
|
943
|
+
const personal_access_token = 'PersonalAccessToken'; ChecklistItemType["personal_access_token"] = personal_access_token;
|
|
944
|
+
})(ChecklistItemType || (ChecklistItemType = {}));
|
|
793
945
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
946
|
+
var ClientType; (function (ClientType) {
|
|
947
|
+
const legacy = 'Legacy'; ClientType["legacy"] = legacy;
|
|
948
|
+
const web_backend = 'WebBackend'; ClientType["web_backend"] = web_backend;
|
|
949
|
+
const single_page_or_native = 'SinglePageOrNative'; ClientType["single_page_or_native"] = single_page_or_native;
|
|
950
|
+
const terminal = 'Terminal'; ClientType["terminal"] = terminal;
|
|
951
|
+
const service = 'Service'; ClientType["service"] = service;
|
|
952
|
+
})(ClientType || (ClientType = {}));
|
|
802
953
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
954
|
+
var CollaboratorType; (function (CollaboratorType) {
|
|
955
|
+
const bot_editor = 'BotEditor'; CollaboratorType["bot_editor"] = bot_editor;
|
|
956
|
+
const bot_developer = 'BotDeveloper'; CollaboratorType["bot_developer"] = bot_developer;
|
|
957
|
+
const bot_operator = 'BotOperator'; CollaboratorType["bot_operator"] = bot_operator;
|
|
958
|
+
})(CollaboratorType || (CollaboratorType = {}));
|
|
808
959
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
}
|
|
960
|
+
var DeleteOrgResourceType; (function (DeleteOrgResourceType) {
|
|
961
|
+
const workspace = 'Workspace'; DeleteOrgResourceType["workspace"] = workspace;
|
|
962
|
+
const o_auth_app = 'OAuthApp'; DeleteOrgResourceType["o_auth_app"] = o_auth_app;
|
|
963
|
+
const authorized_o_auth_app = 'AuthorizedOAuthApp'; DeleteOrgResourceType["authorized_o_auth_app"] = authorized_o_auth_app;
|
|
964
|
+
const service_access_token = 'ServiceAccessToken'; DeleteOrgResourceType["service_access_token"] = service_access_token;
|
|
965
|
+
const personal_access_token2 = 'PersonalAccessToken'; DeleteOrgResourceType["personal_access_token2"] = personal_access_token2;
|
|
966
|
+
const connector2 = 'Connector'; DeleteOrgResourceType["connector2"] = connector2;
|
|
967
|
+
const normal_api_app = 'NormalApiApp'; DeleteOrgResourceType["normal_api_app"] = normal_api_app;
|
|
968
|
+
const connector_api_app = 'ConnectorApiApp'; DeleteOrgResourceType["connector_api_app"] = connector_api_app;
|
|
969
|
+
})(DeleteOrgResourceType || (DeleteOrgResourceType = {}));
|
|
820
970
|
|
|
821
|
-
|
|
971
|
+
var DenyType; (function (DenyType) {
|
|
972
|
+
const visitors_prohibited = 'VisitorsProhibited'; DenyType["visitors_prohibited"] = visitors_prohibited;
|
|
973
|
+
const guest_prohibited_by_invited_user_enterprise2 = 'GuestProhibitedByInvitedUserEnterprise'; DenyType["guest_prohibited_by_invited_user_enterprise2"] = guest_prohibited_by_invited_user_enterprise2;
|
|
974
|
+
const prohibited_by_custom_people_management = 'ProhibitedByCustomPeopleManagement'; DenyType["prohibited_by_custom_people_management"] = prohibited_by_custom_people_management;
|
|
975
|
+
})(DenyType || (DenyType = {}));
|
|
822
976
|
|
|
977
|
+
var DeploymentEnv; (function (DeploymentEnv) {
|
|
978
|
+
const dev2 = 'DEV'; DeploymentEnv["dev2"] = dev2;
|
|
979
|
+
const prod2 = 'PROD'; DeploymentEnv["prod2"] = prod2;
|
|
980
|
+
})(DeploymentEnv || (DeploymentEnv = {}));
|
|
823
981
|
|
|
982
|
+
var DurationDay; (function (DurationDay) {
|
|
983
|
+
const _1 = '1'; DurationDay["_1"] = _1;
|
|
984
|
+
const _30 = '30'; DurationDay["_30"] = _30;
|
|
985
|
+
const _90 = '90'; DurationDay["_90"] = _90;
|
|
986
|
+
const _180 = '180'; DurationDay["_180"] = _180;
|
|
987
|
+
const _365 = '365'; DurationDay["_365"] = _365;
|
|
988
|
+
const customize = 'customize'; DurationDay["customize"] = customize;
|
|
989
|
+
const permanent = 'permanent'; DurationDay["permanent"] = permanent;
|
|
990
|
+
})(DurationDay || (DurationDay = {}));
|
|
824
991
|
|
|
992
|
+
var DurationDay2; (function (DurationDay2) {
|
|
993
|
+
const _12 = '1'; DurationDay2["_12"] = _12;
|
|
994
|
+
const _302 = '30'; DurationDay2["_302"] = _302;
|
|
995
|
+
const _902 = '90'; DurationDay2["_902"] = _902;
|
|
996
|
+
const _1802 = '180'; DurationDay2["_1802"] = _1802;
|
|
997
|
+
const _3652 = '365'; DurationDay2["_3652"] = _3652;
|
|
998
|
+
const customize2 = 'customize'; DurationDay2["customize2"] = customize2;
|
|
999
|
+
const permanent2 = 'permanent'; DurationDay2["permanent2"] = permanent2;
|
|
1000
|
+
})(DurationDay2 || (DurationDay2 = {}));
|
|
825
1001
|
|
|
1002
|
+
var EncryptionAlgorithmType; (function (EncryptionAlgorithmType) {
|
|
1003
|
+
const aes_256_gcm = 'AES-256-GCM'; EncryptionAlgorithmType["aes_256_gcm"] = aes_256_gcm;
|
|
1004
|
+
})(EncryptionAlgorithmType || (EncryptionAlgorithmType = {}));
|
|
826
1005
|
|
|
1006
|
+
var EncryptionConfigurationDataType; (function (EncryptionConfigurationDataType) {
|
|
1007
|
+
const conversation = 'Conversation'; EncryptionConfigurationDataType["conversation"] = conversation;
|
|
1008
|
+
const unknown = 'Unknown'; EncryptionConfigurationDataType["unknown"] = unknown;
|
|
1009
|
+
})(EncryptionConfigurationDataType || (EncryptionConfigurationDataType = {}));
|
|
827
1010
|
|
|
1011
|
+
var EncryptionKeyStatus; (function (EncryptionKeyStatus) {
|
|
1012
|
+
const active3 = 'Active'; EncryptionKeyStatus["active3"] = active3;
|
|
1013
|
+
const inactive = 'Inactive'; EncryptionKeyStatus["inactive"] = inactive;
|
|
1014
|
+
})(EncryptionKeyStatus || (EncryptionKeyStatus = {}));
|
|
828
1015
|
|
|
1016
|
+
var EncryptionKeyType; (function (EncryptionKeyType) {
|
|
1017
|
+
const cloud_kms = 'CloudKMS'; EncryptionKeyType["cloud_kms"] = cloud_kms;
|
|
1018
|
+
EncryptionKeyType["default"] = 'Default';
|
|
1019
|
+
const unknown2 = 'Unknown'; EncryptionKeyType["unknown2"] = unknown2;
|
|
1020
|
+
})(EncryptionKeyType || (EncryptionKeyType = {}));
|
|
829
1021
|
|
|
1022
|
+
var EncryptSecretKeyType; (function (EncryptSecretKeyType) {
|
|
1023
|
+
const user_custom2 = 'user_custom'; EncryptSecretKeyType["user_custom2"] = user_custom2;
|
|
1024
|
+
const consumer3 = 'consumer'; EncryptSecretKeyType["consumer3"] = consumer3;
|
|
1025
|
+
})(EncryptSecretKeyType || (EncryptSecretKeyType = {}));
|
|
830
1026
|
|
|
1027
|
+
var EnterpriseRoleType; (function (EnterpriseRoleType) {
|
|
1028
|
+
const super_admin = 'SuperAdmin'; EnterpriseRoleType["super_admin"] = super_admin;
|
|
1029
|
+
const admin = 'Admin'; EnterpriseRoleType["admin"] = admin;
|
|
1030
|
+
const member = 'Member'; EnterpriseRoleType["member"] = member;
|
|
1031
|
+
const guest = 'Guest'; EnterpriseRoleType["guest"] = guest;
|
|
1032
|
+
})(EnterpriseRoleType || (EnterpriseRoleType = {}));
|
|
831
1033
|
|
|
1034
|
+
var EnterpriseSettingKey; (function (EnterpriseSettingKey) {
|
|
1035
|
+
const join_enterprise_share_link_expiration_time = 'JoinEnterpriseShareLinkExpirationTime'; EnterpriseSettingKey["join_enterprise_share_link_expiration_time"] = join_enterprise_share_link_expiration_time;
|
|
1036
|
+
const sso = 'SSO'; EnterpriseSettingKey["sso"] = sso;
|
|
1037
|
+
const forbid_guest_join_enterprise = 'ForbidGuestJoinEnterprise'; EnterpriseSettingKey["forbid_guest_join_enterprise"] = forbid_guest_join_enterprise;
|
|
1038
|
+
const forbid_member_join_other_enterprise = 'ForbidMemberJoinOtherEnterprise'; EnterpriseSettingKey["forbid_member_join_other_enterprise"] = forbid_member_join_other_enterprise;
|
|
1039
|
+
const replace_enterprise_logo = 'ReplaceEnterpriseLogo'; EnterpriseSettingKey["replace_enterprise_logo"] = replace_enterprise_logo;
|
|
1040
|
+
const forbid_custom_people_management = 'ForbidCustomPeopleManagement'; EnterpriseSettingKey["forbid_custom_people_management"] = forbid_custom_people_management;
|
|
1041
|
+
const forbid_coze_store_plugin_access = 'ForbidCozeStorePluginAccess'; EnterpriseSettingKey["forbid_coze_store_plugin_access"] = forbid_coze_store_plugin_access;
|
|
1042
|
+
const enterprise_member_listing_skill_coze_store = 'EnterpriseMemberListingSkillCozeStore'; EnterpriseSettingKey["enterprise_member_listing_skill_coze_store"] = enterprise_member_listing_skill_coze_store;
|
|
1043
|
+
const listing_skill_enterprise_store_audit = 'ListingSkillEnterpriseStoreAudit'; EnterpriseSettingKey["listing_skill_enterprise_store_audit"] = listing_skill_enterprise_store_audit;
|
|
1044
|
+
})(EnterpriseSettingKey || (EnterpriseSettingKey = {}));
|
|
832
1045
|
|
|
1046
|
+
var EnterpriseSettingValueType; (function (EnterpriseSettingValueType) {
|
|
1047
|
+
const string = 'String'; EnterpriseSettingValueType["string"] = string;
|
|
1048
|
+
const boolean = 'Boolean'; EnterpriseSettingValueType["boolean"] = boolean;
|
|
1049
|
+
const integer = 'Integer'; EnterpriseSettingValueType["integer"] = integer;
|
|
1050
|
+
const string_list = 'StringList'; EnterpriseSettingValueType["string_list"] = string_list;
|
|
1051
|
+
})(EnterpriseSettingValueType || (EnterpriseSettingValueType = {}));
|
|
833
1052
|
|
|
1053
|
+
var HandleLevel; (function (HandleLevel) {
|
|
1054
|
+
const must_handle = 'MustHandle'; HandleLevel["must_handle"] = must_handle;
|
|
1055
|
+
const no_need_handle = 'NoNeedHandle'; HandleLevel["no_need_handle"] = no_need_handle;
|
|
1056
|
+
})(HandleLevel || (HandleLevel = {}));
|
|
834
1057
|
|
|
1058
|
+
var InstallationStatus; (function (InstallationStatus) {
|
|
1059
|
+
const pending_review_app_auth = 'pending_review_app_auth'; InstallationStatus["pending_review_app_auth"] = pending_review_app_auth;
|
|
1060
|
+
const pending_review_app_obo = 'pending_review_app_obo'; InstallationStatus["pending_review_app_obo"] = pending_review_app_obo;
|
|
1061
|
+
const approved_app_auth = 'approved_app_auth'; InstallationStatus["approved_app_auth"] = approved_app_auth;
|
|
1062
|
+
const approved_app_obo = 'approved_app_obo'; InstallationStatus["approved_app_obo"] = approved_app_obo;
|
|
1063
|
+
})(InstallationStatus || (InstallationStatus = {}));
|
|
835
1064
|
|
|
1065
|
+
var InvitationDenyType; (function (InvitationDenyType) {
|
|
1066
|
+
const no_permission = 'NoPermission'; InvitationDenyType["no_permission"] = no_permission;
|
|
1067
|
+
const guest_prohibited_by_enterprise2 = 'GuestProhibitedByEnterprise'; InvitationDenyType["guest_prohibited_by_enterprise2"] = guest_prohibited_by_enterprise2;
|
|
1068
|
+
const guest_prohibited_by_invited_user_enterprise3 = 'GuestProhibitedByInvitedUserEnterprise'; InvitationDenyType["guest_prohibited_by_invited_user_enterprise3"] = guest_prohibited_by_invited_user_enterprise3;
|
|
1069
|
+
const guest_prohibited_by_custom_people_management = 'GuestProhibitedByCustomPeopleManagement'; InvitationDenyType["guest_prohibited_by_custom_people_management"] = guest_prohibited_by_custom_people_management;
|
|
1070
|
+
})(InvitationDenyType || (InvitationDenyType = {}));
|
|
836
1071
|
|
|
1072
|
+
var InvitationInfoStatus; (function (InvitationInfoStatus) {
|
|
1073
|
+
const confirming2 = 'Confirming'; InvitationInfoStatus["confirming2"] = confirming2;
|
|
1074
|
+
const joined3 = 'Joined'; InvitationInfoStatus["joined3"] = joined3;
|
|
1075
|
+
const rejected3 = 'Rejected'; InvitationInfoStatus["rejected3"] = rejected3;
|
|
1076
|
+
const revoked2 = 'Revoked'; InvitationInfoStatus["revoked2"] = revoked2;
|
|
1077
|
+
const expired3 = 'Expired'; InvitationInfoStatus["expired3"] = expired3;
|
|
1078
|
+
const deny2 = 'Deny'; InvitationInfoStatus["deny2"] = deny2;
|
|
1079
|
+
})(InvitationInfoStatus || (InvitationInfoStatus = {}));
|
|
837
1080
|
|
|
1081
|
+
var InvitationStatus; (function (InvitationStatus) {
|
|
1082
|
+
const confirming = 'Confirming'; InvitationStatus["confirming"] = confirming;
|
|
1083
|
+
const joined2 = 'Joined'; InvitationStatus["joined2"] = joined2;
|
|
1084
|
+
const rejected2 = 'Rejected'; InvitationStatus["rejected2"] = rejected2;
|
|
1085
|
+
const revoked = 'Revoked'; InvitationStatus["revoked"] = revoked;
|
|
1086
|
+
const expired2 = 'Expired'; InvitationStatus["expired2"] = expired2;
|
|
1087
|
+
})(InvitationStatus || (InvitationStatus = {}));
|
|
838
1088
|
|
|
1089
|
+
var InvitedUserStatus; (function (InvitedUserStatus) {
|
|
1090
|
+
const can_join = 'CanJoin'; InvitedUserStatus["can_join"] = can_join;
|
|
1091
|
+
const guest_prohibited_by_enterprise = 'GuestProhibitedByEnterprise'; InvitedUserStatus["guest_prohibited_by_enterprise"] = guest_prohibited_by_enterprise;
|
|
1092
|
+
const guest_prohibited_by_invited_user_enterprise = 'GuestProhibitedByInvitedUserEnterprise'; InvitedUserStatus["guest_prohibited_by_invited_user_enterprise"] = guest_prohibited_by_invited_user_enterprise;
|
|
1093
|
+
})(InvitedUserStatus || (InvitedUserStatus = {}));
|
|
839
1094
|
|
|
1095
|
+
var InviteLinkStatus$1; (function (InviteLinkStatus) {
|
|
1096
|
+
const can_apply = 'CanApply'; InviteLinkStatus["can_apply"] = can_apply;
|
|
1097
|
+
const already_applied = 'AlreadyApplied'; InviteLinkStatus["already_applied"] = already_applied;
|
|
1098
|
+
const joined = 'Joined'; InviteLinkStatus["joined"] = joined;
|
|
1099
|
+
const expired = 'Expired'; InviteLinkStatus["expired"] = expired;
|
|
1100
|
+
const deny = 'Deny'; InviteLinkStatus["deny"] = deny;
|
|
1101
|
+
})(InviteLinkStatus$1 || (InviteLinkStatus$1 = {}));
|
|
840
1102
|
|
|
841
|
-
function
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
|
|
1103
|
+
var Level; (function (Level) {
|
|
1104
|
+
const free = 'Free'; Level["free"] = free;
|
|
1105
|
+
const premium_lite = 'PremiumLite'; Level["premium_lite"] = premium_lite;
|
|
1106
|
+
const premium = 'Premium'; Level["premium"] = premium;
|
|
1107
|
+
const premium_plus = 'PremiumPlus'; Level["premium_plus"] = premium_plus;
|
|
1108
|
+
const v_1_pro_instance = 'V1ProInstance'; Level["v_1_pro_instance"] = v_1_pro_instance;
|
|
1109
|
+
const pro_personal = 'ProPersonal'; Level["pro_personal"] = pro_personal;
|
|
1110
|
+
const coze_personal_plus = 'CozePersonalPlus'; Level["coze_personal_plus"] = coze_personal_plus;
|
|
1111
|
+
const coze_personal_advanced = 'CozePersonalAdvanced'; Level["coze_personal_advanced"] = coze_personal_advanced;
|
|
1112
|
+
const coze_personal_pro = 'CozePersonalPro'; Level["coze_personal_pro"] = coze_personal_pro;
|
|
1113
|
+
const team = 'Team'; Level["team"] = team;
|
|
1114
|
+
const enterprise_basic = 'EnterpriseBasic'; Level["enterprise_basic"] = enterprise_basic;
|
|
1115
|
+
const enterprise = 'Enterprise'; Level["enterprise"] = enterprise;
|
|
1116
|
+
const enterprise_pro = 'EnterprisePro'; Level["enterprise_pro"] = enterprise_pro;
|
|
1117
|
+
})(Level || (Level = {}));
|
|
846
1118
|
|
|
847
|
-
function
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (codePoint === 0x2329 || codePoint === 0x232a) {
|
|
852
|
-
return true;
|
|
853
|
-
}
|
|
854
|
-
if (codePoint >= 0x2e80 && codePoint <= 0x303e) {
|
|
855
|
-
return true;
|
|
856
|
-
}
|
|
857
|
-
if (codePoint >= 0x3040 && codePoint <= 0xa4cf) {
|
|
858
|
-
return true;
|
|
859
|
-
}
|
|
860
|
-
if (codePoint >= 0xac00 && codePoint <= 0xd7a3) {
|
|
861
|
-
return true;
|
|
862
|
-
}
|
|
863
|
-
if (codePoint >= 0xf900 && codePoint <= 0xfaff) {
|
|
864
|
-
return true;
|
|
865
|
-
}
|
|
866
|
-
if (codePoint >= 0xfe10 && codePoint <= 0xfe19) {
|
|
867
|
-
return true;
|
|
868
|
-
}
|
|
869
|
-
if (codePoint >= 0xfe30 && codePoint <= 0xfe6f) {
|
|
870
|
-
return true;
|
|
871
|
-
}
|
|
872
|
-
if (codePoint >= 0xff00 && codePoint <= 0xff60) {
|
|
873
|
-
return true;
|
|
874
|
-
}
|
|
875
|
-
if (codePoint >= 0xffe0 && codePoint <= 0xffe6) {
|
|
876
|
-
return true;
|
|
877
|
-
}
|
|
878
|
-
if (codePoint >= 0x1f300 && codePoint <= 0x1fa9f) {
|
|
879
|
-
return true;
|
|
880
|
-
}
|
|
881
|
-
if (codePoint >= 0x20000 && codePoint <= 0x3fffd) {
|
|
882
|
-
return true;
|
|
883
|
-
}
|
|
884
|
-
return false;
|
|
885
|
-
}
|
|
1119
|
+
var ListOption; (function (ListOption) {
|
|
1120
|
+
const user_custom_only = 'user_custom_only'; ListOption["user_custom_only"] = user_custom_only;
|
|
1121
|
+
const all2 = 'all'; ListOption["all2"] = all2;
|
|
1122
|
+
})(ListOption || (ListOption = {}));
|
|
886
1123
|
|
|
887
|
-
function
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
1124
|
+
var OAuth2ProviderType; (function (OAuth2ProviderType) {
|
|
1125
|
+
const system = 'system'; OAuth2ProviderType["system"] = system;
|
|
1126
|
+
const custom = 'custom'; OAuth2ProviderType["custom"] = custom;
|
|
1127
|
+
})(OAuth2ProviderType || (OAuth2ProviderType = {}));
|
|
892
1128
|
|
|
893
|
-
|
|
894
|
-
|
|
1129
|
+
var OrganizationApplicationDenyType; (function (OrganizationApplicationDenyType) {
|
|
1130
|
+
const not_in_enterprise = 'NotInEnterprise'; OrganizationApplicationDenyType["not_in_enterprise"] = not_in_enterprise;
|
|
1131
|
+
const prohibited_by_custom_people_management2 = 'ProhibitedByCustomPeopleManagement'; OrganizationApplicationDenyType["prohibited_by_custom_people_management2"] = prohibited_by_custom_people_management2;
|
|
1132
|
+
})(OrganizationApplicationDenyType || (OrganizationApplicationDenyType = {}));
|
|
895
1133
|
|
|
896
|
-
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
const codePoint = char.codePointAt(0);
|
|
904
|
-
if (codePoint === undefined) {
|
|
905
|
-
continue;
|
|
906
|
-
}
|
|
907
|
-
width += isFullWidthCodePoint(codePoint) ? 2 : 1;
|
|
908
|
-
}
|
|
909
|
-
return width;
|
|
910
|
-
}
|
|
1134
|
+
var OrganizationApplicationForEnterpriseMemberStatus; (function (OrganizationApplicationForEnterpriseMemberStatus) {
|
|
1135
|
+
const can_apply3 = 'CanApply'; OrganizationApplicationForEnterpriseMemberStatus["can_apply3"] = can_apply3;
|
|
1136
|
+
const already_applied3 = 'AlreadyApplied'; OrganizationApplicationForEnterpriseMemberStatus["already_applied3"] = already_applied3;
|
|
1137
|
+
const joined5 = 'Joined'; OrganizationApplicationForEnterpriseMemberStatus["joined5"] = joined5;
|
|
1138
|
+
const deny4 = 'Deny'; OrganizationApplicationForEnterpriseMemberStatus["deny4"] = deny4;
|
|
1139
|
+
})(OrganizationApplicationForEnterpriseMemberStatus || (OrganizationApplicationForEnterpriseMemberStatus = {}));
|
|
911
1140
|
|
|
912
|
-
function
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}
|
|
1141
|
+
var OrganizationRoleType; (function (OrganizationRoleType) {
|
|
1142
|
+
const super_admin2 = 'SuperAdmin'; OrganizationRoleType["super_admin2"] = super_admin2;
|
|
1143
|
+
const admin2 = 'Admin'; OrganizationRoleType["admin2"] = admin2;
|
|
1144
|
+
const member2 = 'Member'; OrganizationRoleType["member2"] = member2;
|
|
1145
|
+
const guest2 = 'Guest'; OrganizationRoleType["guest2"] = guest2;
|
|
1146
|
+
})(OrganizationRoleType || (OrganizationRoleType = {}));
|
|
919
1147
|
|
|
920
|
-
function
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
if (stringWidth(str) <= width) {
|
|
925
|
-
return str;
|
|
926
|
-
}
|
|
927
|
-
if (width === 1) {
|
|
928
|
-
return '…';
|
|
929
|
-
}
|
|
1148
|
+
var Ownership; (function (Ownership) {
|
|
1149
|
+
const developer = 'developer'; Ownership["developer"] = developer;
|
|
1150
|
+
const consumer2 = 'consumer'; Ownership["consumer2"] = consumer2;
|
|
1151
|
+
})(Ownership || (Ownership = {}));
|
|
930
1152
|
|
|
931
|
-
|
|
932
|
-
const
|
|
933
|
-
const
|
|
934
|
-
const
|
|
1153
|
+
var PatSearchOption; (function (PatSearchOption) {
|
|
1154
|
+
const all = 'all'; PatSearchOption["all"] = all;
|
|
1155
|
+
const owned = 'owned'; PatSearchOption["owned"] = owned;
|
|
1156
|
+
const others = 'others'; PatSearchOption["others"] = others;
|
|
1157
|
+
})(PatSearchOption || (PatSearchOption = {}));
|
|
935
1158
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const w = stringWidth(char);
|
|
941
|
-
if (used + w > available) {
|
|
942
|
-
break;
|
|
943
|
-
}
|
|
944
|
-
out += char;
|
|
945
|
-
used += w;
|
|
946
|
-
}
|
|
1159
|
+
var PeopleType; (function (PeopleType) {
|
|
1160
|
+
const enterprise_member = 'EnterpriseMember'; PeopleType["enterprise_member"] = enterprise_member;
|
|
1161
|
+
const enterprise_guest = 'EnterpriseGuest'; PeopleType["enterprise_guest"] = enterprise_guest;
|
|
1162
|
+
})(PeopleType || (PeopleType = {}));
|
|
947
1163
|
|
|
948
|
-
|
|
949
|
-
|
|
1164
|
+
var ProjectAuthIntegrationStatus; (function (ProjectAuthIntegrationStatus) {
|
|
1165
|
+
const not_created = 'NotCreated'; ProjectAuthIntegrationStatus["not_created"] = not_created;
|
|
1166
|
+
const enabled = 'Enabled'; ProjectAuthIntegrationStatus["enabled"] = enabled;
|
|
1167
|
+
const disabled = 'Disabled'; ProjectAuthIntegrationStatus["disabled"] = disabled;
|
|
1168
|
+
})(ProjectAuthIntegrationStatus || (ProjectAuthIntegrationStatus = {}));
|
|
950
1169
|
|
|
951
|
-
function
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1170
|
+
var ProjectEnvironment; (function (ProjectEnvironment) {
|
|
1171
|
+
const production = 'Production'; ProjectEnvironment["production"] = production;
|
|
1172
|
+
const development = 'Development'; ProjectEnvironment["development"] = development;
|
|
1173
|
+
})(ProjectEnvironment || (ProjectEnvironment = {}));
|
|
955
1174
|
|
|
956
|
-
|
|
957
|
-
const
|
|
1175
|
+
var ProjectType$2; (function (ProjectType) {
|
|
1176
|
+
const skill = 'skill'; ProjectType["skill"] = skill;
|
|
1177
|
+
})(ProjectType$2 || (ProjectType$2 = {}));
|
|
958
1178
|
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
orderedKeys.push(key);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
1179
|
+
var SearchEnv; (function (SearchEnv) {
|
|
1180
|
+
const dev = 'dev'; SearchEnv["dev"] = dev;
|
|
1181
|
+
const prod = 'prod'; SearchEnv["prod"] = prod;
|
|
1182
|
+
})(SearchEnv || (SearchEnv = {}));
|
|
966
1183
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
1184
|
+
var SecretKeyType; (function (SecretKeyType) {
|
|
1185
|
+
const user_custom = 'user_custom'; SecretKeyType["user_custom"] = user_custom;
|
|
1186
|
+
const coze_default = 'coze_default'; SecretKeyType["coze_default"] = coze_default;
|
|
1187
|
+
const consumer = 'consumer'; SecretKeyType["consumer"] = consumer;
|
|
1188
|
+
})(SecretKeyType || (SecretKeyType = {}));
|
|
975
1189
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
const value = row[key];
|
|
981
|
-
const valueStr = value === undefined ? '' : String(value);
|
|
982
|
-
maxWidth = Math.max(maxWidth, stringWidth(valueStr));
|
|
983
|
-
}
|
|
984
|
-
columns.push({ key, width: maxWidth });
|
|
985
|
-
}
|
|
1190
|
+
var Status; (function (Status) {
|
|
1191
|
+
const active2 = 'Active'; Status["active2"] = active2;
|
|
1192
|
+
const deactive = 'Deactive'; Status["deactive"] = deactive;
|
|
1193
|
+
})(Status || (Status = {}));
|
|
986
1194
|
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
const
|
|
1195
|
+
var UserStatus$1; (function (UserStatus) {
|
|
1196
|
+
const active = 'active'; UserStatus["active"] = active;
|
|
1197
|
+
const deactivated = 'deactivated'; UserStatus["deactivated"] = deactivated;
|
|
1198
|
+
const offboarded = 'offboarded'; UserStatus["offboarded"] = offboarded;
|
|
1199
|
+
})(UserStatus$1 || (UserStatus$1 = {}));
|
|
990
1200
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1201
|
+
var VisibilityKey; (function (VisibilityKey) {
|
|
1202
|
+
const studio_space_selector = 'studio_space_selector'; VisibilityKey["studio_space_selector"] = studio_space_selector;
|
|
1203
|
+
const studio_create_project_btn = 'studio_create_project_btn'; VisibilityKey["studio_create_project_btn"] = studio_create_project_btn;
|
|
1204
|
+
const studio_home_page = 'studio_home_page'; VisibilityKey["studio_home_page"] = studio_home_page;
|
|
1205
|
+
const studio_develop = 'studio_develop'; VisibilityKey["studio_develop"] = studio_develop;
|
|
1206
|
+
const studio_library = 'studio_library'; VisibilityKey["studio_library"] = studio_library;
|
|
1207
|
+
const studio_tasks = 'studio_tasks'; VisibilityKey["studio_tasks"] = studio_tasks;
|
|
1208
|
+
const studio_evaluate = 'studio_evaluate'; VisibilityKey["studio_evaluate"] = studio_evaluate;
|
|
1209
|
+
const studio_space_manage = 'studio_space_manage'; VisibilityKey["studio_space_manage"] = studio_space_manage;
|
|
1210
|
+
const studio_templates_store = 'studio_templates_store'; VisibilityKey["studio_templates_store"] = studio_templates_store;
|
|
1211
|
+
const studio_plugins_store = 'studio_plugins_store'; VisibilityKey["studio_plugins_store"] = studio_plugins_store;
|
|
1212
|
+
const studio_agents_store = 'studio_agents_store'; VisibilityKey["studio_agents_store"] = studio_agents_store;
|
|
1213
|
+
const studio_playground = 'studio_playground'; VisibilityKey["studio_playground"] = studio_playground;
|
|
1214
|
+
const studio_docs = 'studio_docs'; VisibilityKey["studio_docs"] = studio_docs;
|
|
1215
|
+
const studio_enterprise_agents_store = 'studio_enterprise_agents_store'; VisibilityKey["studio_enterprise_agents_store"] = studio_enterprise_agents_store;
|
|
1216
|
+
const studio_enterprise_plugins_store = 'studio_enterprise_plugins_store'; VisibilityKey["studio_enterprise_plugins_store"] = studio_enterprise_plugins_store;
|
|
1217
|
+
const studio_organization_manage = 'studio_organization_manage'; VisibilityKey["studio_organization_manage"] = studio_organization_manage;
|
|
1218
|
+
const studio_enterprise_card = 'studio_enterprise_card'; VisibilityKey["studio_enterprise_card"] = studio_enterprise_card;
|
|
1219
|
+
const studio_subscription_card = 'studio_subscription_card'; VisibilityKey["studio_subscription_card"] = studio_subscription_card;
|
|
1220
|
+
const studio_personal_menu = 'studio_personal_menu'; VisibilityKey["studio_personal_menu"] = studio_personal_menu;
|
|
1221
|
+
const studio_more_products = 'studio_more_products'; VisibilityKey["studio_more_products"] = studio_more_products;
|
|
1222
|
+
const studio_notice = 'studio_notice'; VisibilityKey["studio_notice"] = studio_notice;
|
|
1223
|
+
const studio_migration_banner = 'studio_migration_banner'; VisibilityKey["studio_migration_banner"] = studio_migration_banner;
|
|
1224
|
+
const coding_space_selector = 'coding_space_selector'; VisibilityKey["coding_space_selector"] = coding_space_selector;
|
|
1225
|
+
const coding_create_project = 'coding_create_project'; VisibilityKey["coding_create_project"] = coding_create_project;
|
|
1226
|
+
const coding_project_manage = 'coding_project_manage'; VisibilityKey["coding_project_manage"] = coding_project_manage;
|
|
1227
|
+
const coding_integrations = 'coding_integrations'; VisibilityKey["coding_integrations"] = coding_integrations;
|
|
1228
|
+
const coding_library = 'coding_library'; VisibilityKey["coding_library"] = coding_library;
|
|
1229
|
+
const coding_tasks = 'coding_tasks'; VisibilityKey["coding_tasks"] = coding_tasks;
|
|
1230
|
+
const coding_playground = 'coding_playground'; VisibilityKey["coding_playground"] = coding_playground;
|
|
1231
|
+
const coding_evaluate = 'coding_evaluate'; VisibilityKey["coding_evaluate"] = coding_evaluate;
|
|
1232
|
+
const coding_coze_redirect = 'coding_coze_redirect'; VisibilityKey["coding_coze_redirect"] = coding_coze_redirect;
|
|
1233
|
+
const coding_docs = 'coding_docs'; VisibilityKey["coding_docs"] = coding_docs;
|
|
1234
|
+
const coding_community = 'coding_community'; VisibilityKey["coding_community"] = coding_community;
|
|
1235
|
+
const coding_enterprise_card = 'coding_enterprise_card'; VisibilityKey["coding_enterprise_card"] = coding_enterprise_card;
|
|
1236
|
+
const coding_subscription_card = 'coding_subscription_card'; VisibilityKey["coding_subscription_card"] = coding_subscription_card;
|
|
1237
|
+
const coding_personal_menu = 'coding_personal_menu'; VisibilityKey["coding_personal_menu"] = coding_personal_menu;
|
|
1238
|
+
const coding_notice = 'coding_notice'; VisibilityKey["coding_notice"] = coding_notice;
|
|
1239
|
+
const admin_organization_manage = 'admin_organization_manage'; VisibilityKey["admin_organization_manage"] = admin_organization_manage;
|
|
1240
|
+
const admin_member_manage = 'admin_member_manage'; VisibilityKey["admin_member_manage"] = admin_member_manage;
|
|
1241
|
+
const admin_enterprise_config = 'admin_enterprise_config'; VisibilityKey["admin_enterprise_config"] = admin_enterprise_config;
|
|
1242
|
+
})(VisibilityKey || (VisibilityKey = {}));
|
|
999
1243
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1244
|
+
var VolcanoUserType$2; (function (VolcanoUserType) {
|
|
1245
|
+
const root_user = 'RootUser'; VolcanoUserType["root_user"] = root_user;
|
|
1246
|
+
const basic_user = 'BasicUser'; VolcanoUserType["basic_user"] = basic_user;
|
|
1247
|
+
})(VolcanoUserType$2 || (VolcanoUserType$2 = {}));
|
|
1003
1248
|
|
|
1004
|
-
const available = Math.max(
|
|
1005
|
-
0,
|
|
1006
|
-
maxWidth - gap * Math.max(0, columns.length - 1),
|
|
1007
|
-
);
|
|
1008
1249
|
|
|
1009
|
-
const sum = () => columns.reduce((acc, col) => acc + col.width, 0);
|
|
1010
1250
|
|
|
1011
|
-
while (sum() > available) {
|
|
1012
|
-
let widestIndex = -1;
|
|
1013
|
-
let widestWidth = -1;
|
|
1014
|
-
for (let i = 0; i < columns.length; i += 1) {
|
|
1015
|
-
const w = _nullishCoalesce$j(_optionalChain$I([columns, 'access', _ => _[i], 'optionalAccess', _2 => _2.width]), () => ( 0));
|
|
1016
|
-
if (w > widestWidth) {
|
|
1017
|
-
widestWidth = w;
|
|
1018
|
-
widestIndex = i;
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
1251
|
|
|
1022
|
-
if (widestIndex === -1) {
|
|
1023
|
-
break;
|
|
1024
|
-
}
|
|
1025
|
-
const current = _nullishCoalesce$j(_optionalChain$I([columns, 'access', _3 => _3[widestIndex], 'optionalAccess', _4 => _4.width]), () => ( 0));
|
|
1026
|
-
if (current <= minColWidth) {
|
|
1027
|
-
break;
|
|
1028
|
-
}
|
|
1029
|
-
columns[widestIndex] = { ...columns[widestIndex], width: current - 1 };
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
for (let i = 0; i < columns.length; i += 1) {
|
|
1033
|
-
const col = columns[i];
|
|
1034
|
-
if (!col) {
|
|
1035
|
-
continue;
|
|
1036
|
-
}
|
|
1037
|
-
columns[i] = { ...col, width: Math.max(minColWidth, col.width) };
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
return columns;
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
function formatTable(rows, options = {}) {
|
|
1044
|
-
if (rows.length === 0) {
|
|
1045
|
-
return '';
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
const columns = calculateColumnWidths(rows, options);
|
|
1049
|
-
if (columns.length === 0) {
|
|
1050
|
-
return '';
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
const gap = _nullishCoalesce$j(options.columnGap, () => ( 2));
|
|
1054
|
-
const gapStr = ' '.repeat(gap);
|
|
1055
|
-
|
|
1056
|
-
const header = columns
|
|
1057
|
-
.map(col => padRightVisible(truncateVisible(col.key, col.width), col.width))
|
|
1058
|
-
.join(gapStr);
|
|
1059
|
-
const separator = columns.map(col => '-'.repeat(col.width)).join(gapStr);
|
|
1060
|
-
|
|
1061
|
-
const bodyRows = [];
|
|
1062
|
-
for (const row of rows) {
|
|
1063
|
-
const cells = columns.map(col => {
|
|
1064
|
-
const value = row[col.key];
|
|
1065
|
-
const valueStr = value === undefined ? '' : String(value);
|
|
1066
|
-
const trimmed = truncateVisible(valueStr, col.width);
|
|
1067
|
-
return padRightVisible(trimmed, col.width);
|
|
1068
|
-
});
|
|
1069
|
-
bodyRows.push(cells.join(gapStr));
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
return `${[header, separator, ...bodyRows].join('\n')}\n`;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
function formatKeyValue(
|
|
1076
|
-
obj,
|
|
1077
|
-
options = {},
|
|
1078
|
-
) {
|
|
1079
|
-
const entries = Object.entries(obj);
|
|
1080
|
-
if (entries.length === 0) {
|
|
1081
|
-
return '';
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
let maxKeyWidth = 0;
|
|
1085
|
-
for (const [key] of entries) {
|
|
1086
|
-
maxKeyWidth = Math.max(maxKeyWidth, stringWidth(key));
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
const maxWidth = _nullishCoalesce$j(_nullishCoalesce$j(options.maxWidth, () => ( process.stdout.columns)), () => ( 120));
|
|
1090
|
-
const gap = _nullishCoalesce$j(options.columnGap, () => ( 2));
|
|
1091
|
-
const minValueWidth = _nullishCoalesce$j(options.minValueWidth, () => ( 12));
|
|
1092
|
-
|
|
1093
|
-
let keyWidth = Math.min(maxKeyWidth, _nullishCoalesce$j(options.keyMaxWidth, () => ( 32)));
|
|
1094
|
-
const maxKeyWidthByTotal = Math.max(6, maxWidth - gap - minValueWidth);
|
|
1095
|
-
keyWidth = Math.min(keyWidth, maxKeyWidthByTotal);
|
|
1096
|
-
|
|
1097
|
-
const valueWidth = Math.max(0, maxWidth - keyWidth - gap);
|
|
1098
|
-
const gapStr = ' '.repeat(gap);
|
|
1099
|
-
|
|
1100
|
-
const lines = entries.map(([key, value]) => {
|
|
1101
|
-
const keyCell = padRightVisible(truncateVisible(key, keyWidth), keyWidth);
|
|
1102
|
-
const valueStr =
|
|
1103
|
-
value === undefined
|
|
1104
|
-
? 'undefined'
|
|
1105
|
-
: value === null
|
|
1106
|
-
? 'null'
|
|
1107
|
-
: String(value);
|
|
1108
|
-
|
|
1109
|
-
const singleLineValue = valueStr.replace(/\s*\n\s*/g, ' ');
|
|
1110
|
-
const valueCell =
|
|
1111
|
-
valueWidth > 0 ? truncateVisible(singleLineValue, valueWidth) : '';
|
|
1112
|
-
|
|
1113
|
-
return `${keyCell}${gapStr}${valueCell}`;
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
return `${lines.join('\n')}\n`;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
function _nullishCoalesce$i(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }const MAX_DEPTH = 5;
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
function isObject$1(value) {
|
|
1128
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
function flattenObject(
|
|
1132
|
-
obj,
|
|
1133
|
-
prefix = '',
|
|
1134
|
-
depth = 0,
|
|
1135
|
-
) {
|
|
1136
|
-
const result = {};
|
|
1137
|
-
|
|
1138
|
-
if (obj === null || obj === undefined) {
|
|
1139
|
-
return result;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
if (!isObject$1(obj)) {
|
|
1143
|
-
return result;
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
1147
|
-
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
1148
|
-
|
|
1149
|
-
if (value === null || value === undefined) {
|
|
1150
|
-
result[newKey] = value ;
|
|
1151
|
-
continue;
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
if (Array.isArray(value)) {
|
|
1155
|
-
if (depth >= MAX_DEPTH) {
|
|
1156
|
-
result[newKey] = '[Array]';
|
|
1157
|
-
} else if (value.length === 0) {
|
|
1158
|
-
result[newKey] = '[]';
|
|
1159
|
-
} else if (
|
|
1160
|
-
value.every(item => typeof item !== 'object' || item === null)
|
|
1161
|
-
) {
|
|
1162
|
-
result[newKey] = value.map(v => String(_nullishCoalesce$i(v, () => ( 'null')))).join(', ');
|
|
1163
|
-
} else {
|
|
1164
|
-
result[newKey] = '[Array]';
|
|
1165
|
-
}
|
|
1166
|
-
continue;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
if (typeof value === 'object') {
|
|
1170
|
-
if (depth >= MAX_DEPTH) {
|
|
1171
|
-
result[newKey] = '[Object]';
|
|
1172
|
-
} else {
|
|
1173
|
-
const nested = flattenObject(value, newKey, depth + 1);
|
|
1174
|
-
Object.assign(result, nested);
|
|
1175
|
-
}
|
|
1176
|
-
continue;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
result[newKey] = value ;
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
return result;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
function _nullishCoalesce$h(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1186
|
-
|
|
1187
|
-
function isObject(value) {
|
|
1188
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
function isArrayOfObjects(value) {
|
|
1192
|
-
return Array.isArray(value) && value.length > 0 && value.every(isObject);
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
function isPrimitiveArray(
|
|
1196
|
-
value,
|
|
1197
|
-
) {
|
|
1198
|
-
return (
|
|
1199
|
-
Array.isArray(value) &&
|
|
1200
|
-
value.length > 0 &&
|
|
1201
|
-
value.every(
|
|
1202
|
-
item => item === null || item === undefined || typeof item !== 'object',
|
|
1203
|
-
)
|
|
1204
|
-
);
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
function formatDetails(details, indent) {
|
|
1208
|
-
if (details === undefined || details === null) {
|
|
1209
|
-
return '';
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
if (typeof details === 'string') {
|
|
1213
|
-
return `${indent}${details}\n`;
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
if (Array.isArray(details)) {
|
|
1217
|
-
if (details.length === 0) {
|
|
1218
|
-
return '';
|
|
1219
|
-
}
|
|
1220
|
-
const items = details.map(item => {
|
|
1221
|
-
if (typeof item === 'object' && item !== null) {
|
|
1222
|
-
return formatKeyValue(flattenObject(item));
|
|
1223
|
-
}
|
|
1224
|
-
return String(item);
|
|
1225
|
-
});
|
|
1226
|
-
return `${items.map(item => `${indent}- ${item.trim()}`).join('\n')}\n`;
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
if (isObject(details)) {
|
|
1230
|
-
const flattened = flattenObject(details);
|
|
1231
|
-
if (Object.keys(flattened).length === 0) {
|
|
1232
|
-
return '';
|
|
1233
|
-
}
|
|
1234
|
-
return `${formatKeyValue(flattened)
|
|
1235
|
-
.split('\n')
|
|
1236
|
-
.filter(line => line.trim())
|
|
1237
|
-
.map(line => `${indent}${line}`)
|
|
1238
|
-
.join('\n')}\n`;
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
return `${indent}${String(details)}\n`;
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
class TextFormatter {
|
|
1245
|
-
format(data) {
|
|
1246
|
-
if (data === null) {
|
|
1247
|
-
return 'null\n';
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
if (data === undefined) {
|
|
1251
|
-
return 'undefined\n';
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
if (Array.isArray(data)) {
|
|
1255
|
-
if (data.length === 0) {
|
|
1256
|
-
return '\n';
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
if (isArrayOfObjects(data)) {
|
|
1260
|
-
const flattenedRows = data.map(row => flattenObject(row));
|
|
1261
|
-
return formatTable(flattenedRows);
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
if (isPrimitiveArray(data)) {
|
|
1265
|
-
return `${data.map(item => String(_nullishCoalesce$h(item, () => ( 'null')))).join('\n')}\n`;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
return '[Array]\n';
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
if (isObject(data)) {
|
|
1272
|
-
const flattened = flattenObject(data);
|
|
1273
|
-
if (Object.keys(flattened).length === 0) {
|
|
1274
|
-
return '{}\n';
|
|
1275
|
-
}
|
|
1276
|
-
return formatKeyValue(flattened);
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
return `${String(data)}\n`;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
formatError(error) {
|
|
1283
|
-
const lines = [];
|
|
1284
|
-
|
|
1285
|
-
lines.push('✖ [ERROR]');
|
|
1286
|
-
lines.push(` Message: ${error.message}`);
|
|
1287
|
-
lines.push(` Code: ${error.code}`);
|
|
1288
|
-
|
|
1289
|
-
if (error.details !== undefined) {
|
|
1290
|
-
lines.push(' Details:');
|
|
1291
|
-
const detailsStr = formatDetails(error.details, ' ');
|
|
1292
|
-
if (detailsStr) {
|
|
1293
|
-
lines.push(detailsStr.trimEnd());
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
return `${lines.join('\n')}\n`;
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
function createFormatter(format) {
|
|
1302
|
-
switch (format) {
|
|
1303
|
-
case 'text':
|
|
1304
|
-
return new TextFormatter();
|
|
1305
|
-
case 'json':
|
|
1306
|
-
default:
|
|
1307
|
-
return new JsonFormatter();
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
class Response {
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
constructor(props) {
|
|
1315
|
-
const { format } = props;
|
|
1316
|
-
this.formatter = createFormatter(format);
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
print(data) {
|
|
1320
|
-
const output = this.formatter.format(data);
|
|
1321
|
-
process.stdout.write(output);
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
eprint(error) {
|
|
1325
|
-
const output = this.formatter.formatError(error);
|
|
1326
|
-
process.stdout.write(output);
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
function _nullishCoalesce$g(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
const LOG_DIR = path.join(os.homedir(), '.coze', 'logs');
|
|
1339
|
-
const MAX_LOG_FILES = 10;
|
|
1340
|
-
|
|
1341
|
-
class DiagnosticLogger {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
__init() {this.fileStream = null;}
|
|
1348
|
-
__init2() {this.writeError = false;}
|
|
1349
|
-
|
|
1350
|
-
constructor(options = {}) {DiagnosticLogger.prototype.__init.call(this);DiagnosticLogger.prototype.__init2.call(this);
|
|
1351
|
-
this.format = _nullishCoalesce$g(options.format, () => ( 'text'));
|
|
1352
|
-
this.printToStderr = _nullishCoalesce$g(options.printToStderr, () => ( false));
|
|
1353
|
-
this.tags = _nullishCoalesce$g(options.tags, () => ( {}));
|
|
1354
|
-
this.startTime = Date.now();
|
|
1355
|
-
|
|
1356
|
-
const logFilePath = _nullishCoalesce$g(options.logFile, () => ( this.getDefaultLogPath()));
|
|
1357
|
-
this.logFile = logFilePath;
|
|
1358
|
-
|
|
1359
|
-
try {
|
|
1360
|
-
this.ensureLogDir();
|
|
1361
|
-
this.rotateLogFiles();
|
|
1362
|
-
this.fileStream = node_fs.createWriteStream(logFilePath, { flags: 'a' });
|
|
1363
|
-
this.fileStream.on('error', () => {
|
|
1364
|
-
this.fileStream = null;
|
|
1365
|
-
});
|
|
1366
|
-
} catch (e) {
|
|
1367
|
-
this.logFile = null;
|
|
1368
|
-
this.fileStream = null;
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
getDefaultLogPath() {
|
|
1373
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
1374
|
-
const { pid } = process;
|
|
1375
|
-
return path.join(LOG_DIR, `${timestamp}-${pid}.log`);
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
ensureLogDir() {
|
|
1379
|
-
if (!node_fs.existsSync(LOG_DIR)) {
|
|
1380
|
-
node_fs.mkdirSync(LOG_DIR, { recursive: true });
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
rotateLogFiles() {
|
|
1385
|
-
try {
|
|
1386
|
-
const files = node_fs.readdirSync(LOG_DIR)
|
|
1387
|
-
.filter(f => f.endsWith('.log'))
|
|
1388
|
-
.map(f => ({
|
|
1389
|
-
name: f,
|
|
1390
|
-
path: path.join(LOG_DIR, f),
|
|
1391
|
-
mtime: node_fs.statSync(path.join(LOG_DIR, f)).mtime.getTime(),
|
|
1392
|
-
}))
|
|
1393
|
-
.sort((a, b) => b.mtime - a.mtime);
|
|
1394
|
-
|
|
1395
|
-
if (files.length >= MAX_LOG_FILES) {
|
|
1396
|
-
files.slice(MAX_LOG_FILES - 1).forEach(f => {
|
|
1397
|
-
try {
|
|
1398
|
-
node_fs.unlinkSync(f.path);
|
|
1399
|
-
// eslint-disable-next-line @coze-arch/no-empty-catch
|
|
1400
|
-
} catch (e2) {
|
|
1401
|
-
// ignore deletion errors
|
|
1402
|
-
}
|
|
1403
|
-
});
|
|
1404
|
-
}
|
|
1405
|
-
// eslint-disable-next-line @coze-arch/no-empty-catch
|
|
1406
|
-
} catch (e3) {
|
|
1407
|
-
// ignore rotation errors
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
verbose(msg, ...args) {
|
|
1412
|
-
this.log('verbose', msg, args);
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
info(msg, ...args) {
|
|
1416
|
-
this.log('info', msg, args);
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
warn(msg, ...args) {
|
|
1420
|
-
this.log('warn', msg, args);
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
error(msg, ...args) {
|
|
1424
|
-
this.log('error', msg, args);
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
success(msg, ...args) {
|
|
1428
|
-
this.log('success', msg, args);
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
debug(msg, ...args) {
|
|
1432
|
-
this.log('debug', msg, args);
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
log(level, msg, args) {
|
|
1436
|
-
const entry = this.formatEntry(level, msg, args);
|
|
1437
|
-
|
|
1438
|
-
if (this.fileStream) {
|
|
1439
|
-
try {
|
|
1440
|
-
this.fileStream.write(`${entry}\n`);
|
|
1441
|
-
} catch (e4) {
|
|
1442
|
-
if (!this.writeError && this.printToStderr) {
|
|
1443
|
-
process.stderr.write('Warning: Log write failed\n');
|
|
1444
|
-
this.writeError = true;
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
if (this.printToStderr) {
|
|
1450
|
-
process.stderr.write(`${entry}\n`);
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
formatEntry(level, msg, args) {
|
|
1455
|
-
const timestamp = new Date().toISOString();
|
|
1456
|
-
const delta = Date.now() - this.startTime;
|
|
1457
|
-
|
|
1458
|
-
if (this.format === 'json') {
|
|
1459
|
-
const entry = {
|
|
1460
|
-
level,
|
|
1461
|
-
timestamp,
|
|
1462
|
-
delta,
|
|
1463
|
-
...this.tags,
|
|
1464
|
-
message: msg,
|
|
1465
|
-
};
|
|
1466
|
-
if (args.length > 0) {
|
|
1467
|
-
entry.args = args;
|
|
1468
|
-
}
|
|
1469
|
-
return JSON.stringify(entry);
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
const tagsStr = Object.entries(this.tags)
|
|
1473
|
-
.map(([k, v]) => `${k}=${v}`)
|
|
1474
|
-
.join(' ');
|
|
1475
|
-
const argsStr = args.length > 0 ? ` ${args.map(String).join(' ')}` : '';
|
|
1476
|
-
return `${level.toUpperCase().padEnd(7)} [${timestamp}] +${delta}ms ${tagsStr} ${msg}${argsStr}`;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
close() {
|
|
1480
|
-
if (this.fileStream) {
|
|
1481
|
-
try {
|
|
1482
|
-
this.fileStream.end();
|
|
1483
|
-
// eslint-disable-next-line @coze-arch/no-empty-catch
|
|
1484
|
-
} catch (e5) {
|
|
1485
|
-
// ignore close errors
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
1492
|
-
/* eslint-disable */
|
|
1493
|
-
/* tslint:disable */
|
|
1494
|
-
// @ts-nocheck
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
var AppAndPATAuthInfoItemType; (function (AppAndPATAuthInfoItemType) {
|
|
1499
|
-
const app = 'app'; AppAndPATAuthInfoItemType["app"] = app;
|
|
1500
|
-
const pat = 'pat'; AppAndPATAuthInfoItemType["pat"] = pat;
|
|
1501
|
-
})(AppAndPATAuthInfoItemType || (AppAndPATAuthInfoItemType = {}));
|
|
1502
|
-
|
|
1503
|
-
var ApplicationForEnterpriseMemberStatus; (function (ApplicationForEnterpriseMemberStatus) {
|
|
1504
|
-
const can_apply2 = 'CanApply'; ApplicationForEnterpriseMemberStatus["can_apply2"] = can_apply2;
|
|
1505
|
-
const already_applied2 = 'AlreadyApplied'; ApplicationForEnterpriseMemberStatus["already_applied2"] = already_applied2;
|
|
1506
|
-
const joined4 = 'Joined'; ApplicationForEnterpriseMemberStatus["joined4"] = joined4;
|
|
1507
|
-
const deny3 = 'Deny'; ApplicationForEnterpriseMemberStatus["deny3"] = deny3;
|
|
1508
|
-
})(ApplicationForEnterpriseMemberStatus || (ApplicationForEnterpriseMemberStatus = {}));
|
|
1509
|
-
|
|
1510
|
-
var ApplicationStatus; (function (ApplicationStatus) {
|
|
1511
|
-
const processing = 'Processing'; ApplicationStatus["processing"] = processing;
|
|
1512
|
-
const approved = 'Approved'; ApplicationStatus["approved"] = approved;
|
|
1513
|
-
const rejected = 'Rejected'; ApplicationStatus["rejected"] = rejected;
|
|
1514
|
-
})(ApplicationStatus || (ApplicationStatus = {}));
|
|
1515
|
-
|
|
1516
|
-
var AppType; (function (AppType) {
|
|
1517
|
-
const normal = 'Normal'; AppType["normal"] = normal;
|
|
1518
|
-
const connector = 'Connector'; AppType["connector"] = connector;
|
|
1519
|
-
const privilege = 'Privilege'; AppType["privilege"] = privilege;
|
|
1520
|
-
})(AppType || (AppType = {}));
|
|
1521
|
-
|
|
1522
|
-
var AuthorizationType; (function (AuthorizationType) {
|
|
1523
|
-
const auth_app = 'AuthApp'; AuthorizationType["auth_app"] = auth_app;
|
|
1524
|
-
const on_behalf_of_user = 'OnBehalfOfUser'; AuthorizationType["on_behalf_of_user"] = on_behalf_of_user;
|
|
1525
|
-
})(AuthorizationType || (AuthorizationType = {}));
|
|
1526
|
-
|
|
1527
|
-
var AuthProvider; (function (AuthProvider) {
|
|
1528
|
-
const password = 'Password'; AuthProvider["password"] = password;
|
|
1529
|
-
const sms = 'Sms'; AuthProvider["sms"] = sms;
|
|
1530
|
-
const email = 'Email'; AuthProvider["email"] = email;
|
|
1531
|
-
const unknown3 = 'Unknown'; AuthProvider["unknown3"] = unknown3;
|
|
1532
|
-
})(AuthProvider || (AuthProvider = {}));
|
|
1533
|
-
|
|
1534
|
-
var AuthStatus; (function (AuthStatus) {
|
|
1535
|
-
const authorized = 'authorized'; AuthStatus["authorized"] = authorized;
|
|
1536
|
-
const unauthorized = 'unauthorized'; AuthStatus["unauthorized"] = unauthorized;
|
|
1537
|
-
const expired4 = 'expired'; AuthStatus["expired4"] = expired4;
|
|
1538
|
-
})(AuthStatus || (AuthStatus = {}));
|
|
1539
|
-
|
|
1540
|
-
var AuthType$1; (function (AuthType) {
|
|
1541
|
-
const api_key = 'api_key'; AuthType["api_key"] = api_key;
|
|
1542
|
-
const wechat_official = 'wechat_official'; AuthType["wechat_official"] = wechat_official;
|
|
1543
|
-
const oauth_2 = 'oauth2'; AuthType["oauth_2"] = oauth_2;
|
|
1544
|
-
})(AuthType$1 || (AuthType$1 = {}));
|
|
1545
|
-
|
|
1546
|
-
var Certificated; (function (Certificated) {
|
|
1547
|
-
const noncertificated = 'Noncertificated'; Certificated["noncertificated"] = noncertificated;
|
|
1548
|
-
const certificated = 'Certificated'; Certificated["certificated"] = certificated;
|
|
1549
|
-
})(Certificated || (Certificated = {}));
|
|
1550
|
-
|
|
1551
|
-
var CertificationType; (function (CertificationType) {
|
|
1552
|
-
const uncertified = 'Uncertified'; CertificationType["uncertified"] = uncertified;
|
|
1553
|
-
const personal_certification = 'PersonalCertification'; CertificationType["personal_certification"] = personal_certification;
|
|
1554
|
-
const enterprise_certification = 'EnterpriseCertification'; CertificationType["enterprise_certification"] = enterprise_certification;
|
|
1555
|
-
})(CertificationType || (CertificationType = {}));
|
|
1556
|
-
|
|
1557
|
-
var ChecklistItemType; (function (ChecklistItemType) {
|
|
1558
|
-
const obo = 'Obo'; ChecklistItemType["obo"] = obo;
|
|
1559
|
-
const app_auth = 'AppAuth'; ChecklistItemType["app_auth"] = app_auth;
|
|
1560
|
-
const personal_access_token = 'PersonalAccessToken'; ChecklistItemType["personal_access_token"] = personal_access_token;
|
|
1561
|
-
})(ChecklistItemType || (ChecklistItemType = {}));
|
|
1562
|
-
|
|
1563
|
-
var ClientType; (function (ClientType) {
|
|
1564
|
-
const legacy = 'Legacy'; ClientType["legacy"] = legacy;
|
|
1565
|
-
const web_backend = 'WebBackend'; ClientType["web_backend"] = web_backend;
|
|
1566
|
-
const single_page_or_native = 'SinglePageOrNative'; ClientType["single_page_or_native"] = single_page_or_native;
|
|
1567
|
-
const terminal = 'Terminal'; ClientType["terminal"] = terminal;
|
|
1568
|
-
const service = 'Service'; ClientType["service"] = service;
|
|
1569
|
-
})(ClientType || (ClientType = {}));
|
|
1570
|
-
|
|
1571
|
-
var CollaboratorType; (function (CollaboratorType) {
|
|
1572
|
-
const bot_editor = 'BotEditor'; CollaboratorType["bot_editor"] = bot_editor;
|
|
1573
|
-
const bot_developer = 'BotDeveloper'; CollaboratorType["bot_developer"] = bot_developer;
|
|
1574
|
-
const bot_operator = 'BotOperator'; CollaboratorType["bot_operator"] = bot_operator;
|
|
1575
|
-
})(CollaboratorType || (CollaboratorType = {}));
|
|
1576
|
-
|
|
1577
|
-
var DeleteOrgResourceType; (function (DeleteOrgResourceType) {
|
|
1578
|
-
const workspace = 'Workspace'; DeleteOrgResourceType["workspace"] = workspace;
|
|
1579
|
-
const o_auth_app = 'OAuthApp'; DeleteOrgResourceType["o_auth_app"] = o_auth_app;
|
|
1580
|
-
const authorized_o_auth_app = 'AuthorizedOAuthApp'; DeleteOrgResourceType["authorized_o_auth_app"] = authorized_o_auth_app;
|
|
1581
|
-
const service_access_token = 'ServiceAccessToken'; DeleteOrgResourceType["service_access_token"] = service_access_token;
|
|
1582
|
-
const personal_access_token2 = 'PersonalAccessToken'; DeleteOrgResourceType["personal_access_token2"] = personal_access_token2;
|
|
1583
|
-
const connector2 = 'Connector'; DeleteOrgResourceType["connector2"] = connector2;
|
|
1584
|
-
const normal_api_app = 'NormalApiApp'; DeleteOrgResourceType["normal_api_app"] = normal_api_app;
|
|
1585
|
-
const connector_api_app = 'ConnectorApiApp'; DeleteOrgResourceType["connector_api_app"] = connector_api_app;
|
|
1586
|
-
})(DeleteOrgResourceType || (DeleteOrgResourceType = {}));
|
|
1587
|
-
|
|
1588
|
-
var DenyType; (function (DenyType) {
|
|
1589
|
-
const visitors_prohibited = 'VisitorsProhibited'; DenyType["visitors_prohibited"] = visitors_prohibited;
|
|
1590
|
-
const guest_prohibited_by_invited_user_enterprise2 = 'GuestProhibitedByInvitedUserEnterprise'; DenyType["guest_prohibited_by_invited_user_enterprise2"] = guest_prohibited_by_invited_user_enterprise2;
|
|
1591
|
-
const prohibited_by_custom_people_management = 'ProhibitedByCustomPeopleManagement'; DenyType["prohibited_by_custom_people_management"] = prohibited_by_custom_people_management;
|
|
1592
|
-
})(DenyType || (DenyType = {}));
|
|
1593
|
-
|
|
1594
|
-
var DeploymentEnv; (function (DeploymentEnv) {
|
|
1595
|
-
const dev2 = 'DEV'; DeploymentEnv["dev2"] = dev2;
|
|
1596
|
-
const prod2 = 'PROD'; DeploymentEnv["prod2"] = prod2;
|
|
1597
|
-
})(DeploymentEnv || (DeploymentEnv = {}));
|
|
1598
|
-
|
|
1599
|
-
var DurationDay; (function (DurationDay) {
|
|
1600
|
-
const _1 = '1'; DurationDay["_1"] = _1;
|
|
1601
|
-
const _30 = '30'; DurationDay["_30"] = _30;
|
|
1602
|
-
const _90 = '90'; DurationDay["_90"] = _90;
|
|
1603
|
-
const _180 = '180'; DurationDay["_180"] = _180;
|
|
1604
|
-
const _365 = '365'; DurationDay["_365"] = _365;
|
|
1605
|
-
const customize = 'customize'; DurationDay["customize"] = customize;
|
|
1606
|
-
const permanent = 'permanent'; DurationDay["permanent"] = permanent;
|
|
1607
|
-
})(DurationDay || (DurationDay = {}));
|
|
1608
|
-
|
|
1609
|
-
var DurationDay2; (function (DurationDay2) {
|
|
1610
|
-
const _12 = '1'; DurationDay2["_12"] = _12;
|
|
1611
|
-
const _302 = '30'; DurationDay2["_302"] = _302;
|
|
1612
|
-
const _902 = '90'; DurationDay2["_902"] = _902;
|
|
1613
|
-
const _1802 = '180'; DurationDay2["_1802"] = _1802;
|
|
1614
|
-
const _3652 = '365'; DurationDay2["_3652"] = _3652;
|
|
1615
|
-
const customize2 = 'customize'; DurationDay2["customize2"] = customize2;
|
|
1616
|
-
const permanent2 = 'permanent'; DurationDay2["permanent2"] = permanent2;
|
|
1617
|
-
})(DurationDay2 || (DurationDay2 = {}));
|
|
1618
|
-
|
|
1619
|
-
var EncryptionAlgorithmType; (function (EncryptionAlgorithmType) {
|
|
1620
|
-
const aes_256_gcm = 'AES-256-GCM'; EncryptionAlgorithmType["aes_256_gcm"] = aes_256_gcm;
|
|
1621
|
-
})(EncryptionAlgorithmType || (EncryptionAlgorithmType = {}));
|
|
1622
|
-
|
|
1623
|
-
var EncryptionConfigurationDataType; (function (EncryptionConfigurationDataType) {
|
|
1624
|
-
const conversation = 'Conversation'; EncryptionConfigurationDataType["conversation"] = conversation;
|
|
1625
|
-
const unknown = 'Unknown'; EncryptionConfigurationDataType["unknown"] = unknown;
|
|
1626
|
-
})(EncryptionConfigurationDataType || (EncryptionConfigurationDataType = {}));
|
|
1627
|
-
|
|
1628
|
-
var EncryptionKeyStatus; (function (EncryptionKeyStatus) {
|
|
1629
|
-
const active3 = 'Active'; EncryptionKeyStatus["active3"] = active3;
|
|
1630
|
-
const inactive = 'Inactive'; EncryptionKeyStatus["inactive"] = inactive;
|
|
1631
|
-
})(EncryptionKeyStatus || (EncryptionKeyStatus = {}));
|
|
1632
|
-
|
|
1633
|
-
var EncryptionKeyType; (function (EncryptionKeyType) {
|
|
1634
|
-
const cloud_kms = 'CloudKMS'; EncryptionKeyType["cloud_kms"] = cloud_kms;
|
|
1635
|
-
EncryptionKeyType["default"] = 'Default';
|
|
1636
|
-
const unknown2 = 'Unknown'; EncryptionKeyType["unknown2"] = unknown2;
|
|
1637
|
-
})(EncryptionKeyType || (EncryptionKeyType = {}));
|
|
1638
|
-
|
|
1639
|
-
var EncryptSecretKeyType; (function (EncryptSecretKeyType) {
|
|
1640
|
-
const user_custom2 = 'user_custom'; EncryptSecretKeyType["user_custom2"] = user_custom2;
|
|
1641
|
-
const consumer3 = 'consumer'; EncryptSecretKeyType["consumer3"] = consumer3;
|
|
1642
|
-
})(EncryptSecretKeyType || (EncryptSecretKeyType = {}));
|
|
1643
|
-
|
|
1644
|
-
var EnterpriseRoleType; (function (EnterpriseRoleType) {
|
|
1645
|
-
const super_admin = 'SuperAdmin'; EnterpriseRoleType["super_admin"] = super_admin;
|
|
1646
|
-
const admin = 'Admin'; EnterpriseRoleType["admin"] = admin;
|
|
1647
|
-
const member = 'Member'; EnterpriseRoleType["member"] = member;
|
|
1648
|
-
const guest = 'Guest'; EnterpriseRoleType["guest"] = guest;
|
|
1649
|
-
})(EnterpriseRoleType || (EnterpriseRoleType = {}));
|
|
1650
|
-
|
|
1651
|
-
var EnterpriseSettingKey; (function (EnterpriseSettingKey) {
|
|
1652
|
-
const join_enterprise_share_link_expiration_time = 'JoinEnterpriseShareLinkExpirationTime'; EnterpriseSettingKey["join_enterprise_share_link_expiration_time"] = join_enterprise_share_link_expiration_time;
|
|
1653
|
-
const sso = 'SSO'; EnterpriseSettingKey["sso"] = sso;
|
|
1654
|
-
const forbid_guest_join_enterprise = 'ForbidGuestJoinEnterprise'; EnterpriseSettingKey["forbid_guest_join_enterprise"] = forbid_guest_join_enterprise;
|
|
1655
|
-
const forbid_member_join_other_enterprise = 'ForbidMemberJoinOtherEnterprise'; EnterpriseSettingKey["forbid_member_join_other_enterprise"] = forbid_member_join_other_enterprise;
|
|
1656
|
-
const replace_enterprise_logo = 'ReplaceEnterpriseLogo'; EnterpriseSettingKey["replace_enterprise_logo"] = replace_enterprise_logo;
|
|
1657
|
-
const forbid_custom_people_management = 'ForbidCustomPeopleManagement'; EnterpriseSettingKey["forbid_custom_people_management"] = forbid_custom_people_management;
|
|
1658
|
-
const forbid_coze_store_plugin_access = 'ForbidCozeStorePluginAccess'; EnterpriseSettingKey["forbid_coze_store_plugin_access"] = forbid_coze_store_plugin_access;
|
|
1659
|
-
const enterprise_member_listing_skill_coze_store = 'EnterpriseMemberListingSkillCozeStore'; EnterpriseSettingKey["enterprise_member_listing_skill_coze_store"] = enterprise_member_listing_skill_coze_store;
|
|
1660
|
-
const listing_skill_enterprise_store_audit = 'ListingSkillEnterpriseStoreAudit'; EnterpriseSettingKey["listing_skill_enterprise_store_audit"] = listing_skill_enterprise_store_audit;
|
|
1661
|
-
})(EnterpriseSettingKey || (EnterpriseSettingKey = {}));
|
|
1662
|
-
|
|
1663
|
-
var EnterpriseSettingValueType; (function (EnterpriseSettingValueType) {
|
|
1664
|
-
const string = 'String'; EnterpriseSettingValueType["string"] = string;
|
|
1665
|
-
const boolean = 'Boolean'; EnterpriseSettingValueType["boolean"] = boolean;
|
|
1666
|
-
const integer = 'Integer'; EnterpriseSettingValueType["integer"] = integer;
|
|
1667
|
-
const string_list = 'StringList'; EnterpriseSettingValueType["string_list"] = string_list;
|
|
1668
|
-
})(EnterpriseSettingValueType || (EnterpriseSettingValueType = {}));
|
|
1669
|
-
|
|
1670
|
-
var HandleLevel; (function (HandleLevel) {
|
|
1671
|
-
const must_handle = 'MustHandle'; HandleLevel["must_handle"] = must_handle;
|
|
1672
|
-
const no_need_handle = 'NoNeedHandle'; HandleLevel["no_need_handle"] = no_need_handle;
|
|
1673
|
-
})(HandleLevel || (HandleLevel = {}));
|
|
1674
|
-
|
|
1675
|
-
var InstallationStatus; (function (InstallationStatus) {
|
|
1676
|
-
const pending_review_app_auth = 'pending_review_app_auth'; InstallationStatus["pending_review_app_auth"] = pending_review_app_auth;
|
|
1677
|
-
const pending_review_app_obo = 'pending_review_app_obo'; InstallationStatus["pending_review_app_obo"] = pending_review_app_obo;
|
|
1678
|
-
const approved_app_auth = 'approved_app_auth'; InstallationStatus["approved_app_auth"] = approved_app_auth;
|
|
1679
|
-
const approved_app_obo = 'approved_app_obo'; InstallationStatus["approved_app_obo"] = approved_app_obo;
|
|
1680
|
-
})(InstallationStatus || (InstallationStatus = {}));
|
|
1681
|
-
|
|
1682
|
-
var InvitationDenyType; (function (InvitationDenyType) {
|
|
1683
|
-
const no_permission = 'NoPermission'; InvitationDenyType["no_permission"] = no_permission;
|
|
1684
|
-
const guest_prohibited_by_enterprise2 = 'GuestProhibitedByEnterprise'; InvitationDenyType["guest_prohibited_by_enterprise2"] = guest_prohibited_by_enterprise2;
|
|
1685
|
-
const guest_prohibited_by_invited_user_enterprise3 = 'GuestProhibitedByInvitedUserEnterprise'; InvitationDenyType["guest_prohibited_by_invited_user_enterprise3"] = guest_prohibited_by_invited_user_enterprise3;
|
|
1686
|
-
const guest_prohibited_by_custom_people_management = 'GuestProhibitedByCustomPeopleManagement'; InvitationDenyType["guest_prohibited_by_custom_people_management"] = guest_prohibited_by_custom_people_management;
|
|
1687
|
-
})(InvitationDenyType || (InvitationDenyType = {}));
|
|
1688
|
-
|
|
1689
|
-
var InvitationInfoStatus; (function (InvitationInfoStatus) {
|
|
1690
|
-
const confirming2 = 'Confirming'; InvitationInfoStatus["confirming2"] = confirming2;
|
|
1691
|
-
const joined3 = 'Joined'; InvitationInfoStatus["joined3"] = joined3;
|
|
1692
|
-
const rejected3 = 'Rejected'; InvitationInfoStatus["rejected3"] = rejected3;
|
|
1693
|
-
const revoked2 = 'Revoked'; InvitationInfoStatus["revoked2"] = revoked2;
|
|
1694
|
-
const expired3 = 'Expired'; InvitationInfoStatus["expired3"] = expired3;
|
|
1695
|
-
const deny2 = 'Deny'; InvitationInfoStatus["deny2"] = deny2;
|
|
1696
|
-
})(InvitationInfoStatus || (InvitationInfoStatus = {}));
|
|
1697
|
-
|
|
1698
|
-
var InvitationStatus; (function (InvitationStatus) {
|
|
1699
|
-
const confirming = 'Confirming'; InvitationStatus["confirming"] = confirming;
|
|
1700
|
-
const joined2 = 'Joined'; InvitationStatus["joined2"] = joined2;
|
|
1701
|
-
const rejected2 = 'Rejected'; InvitationStatus["rejected2"] = rejected2;
|
|
1702
|
-
const revoked = 'Revoked'; InvitationStatus["revoked"] = revoked;
|
|
1703
|
-
const expired2 = 'Expired'; InvitationStatus["expired2"] = expired2;
|
|
1704
|
-
})(InvitationStatus || (InvitationStatus = {}));
|
|
1705
|
-
|
|
1706
|
-
var InvitedUserStatus; (function (InvitedUserStatus) {
|
|
1707
|
-
const can_join = 'CanJoin'; InvitedUserStatus["can_join"] = can_join;
|
|
1708
|
-
const guest_prohibited_by_enterprise = 'GuestProhibitedByEnterprise'; InvitedUserStatus["guest_prohibited_by_enterprise"] = guest_prohibited_by_enterprise;
|
|
1709
|
-
const guest_prohibited_by_invited_user_enterprise = 'GuestProhibitedByInvitedUserEnterprise'; InvitedUserStatus["guest_prohibited_by_invited_user_enterprise"] = guest_prohibited_by_invited_user_enterprise;
|
|
1710
|
-
})(InvitedUserStatus || (InvitedUserStatus = {}));
|
|
1711
|
-
|
|
1712
|
-
var InviteLinkStatus$1; (function (InviteLinkStatus) {
|
|
1713
|
-
const can_apply = 'CanApply'; InviteLinkStatus["can_apply"] = can_apply;
|
|
1714
|
-
const already_applied = 'AlreadyApplied'; InviteLinkStatus["already_applied"] = already_applied;
|
|
1715
|
-
const joined = 'Joined'; InviteLinkStatus["joined"] = joined;
|
|
1716
|
-
const expired = 'Expired'; InviteLinkStatus["expired"] = expired;
|
|
1717
|
-
const deny = 'Deny'; InviteLinkStatus["deny"] = deny;
|
|
1718
|
-
})(InviteLinkStatus$1 || (InviteLinkStatus$1 = {}));
|
|
1719
|
-
|
|
1720
|
-
var Level; (function (Level) {
|
|
1721
|
-
const free = 'Free'; Level["free"] = free;
|
|
1722
|
-
const premium_lite = 'PremiumLite'; Level["premium_lite"] = premium_lite;
|
|
1723
|
-
const premium = 'Premium'; Level["premium"] = premium;
|
|
1724
|
-
const premium_plus = 'PremiumPlus'; Level["premium_plus"] = premium_plus;
|
|
1725
|
-
const v_1_pro_instance = 'V1ProInstance'; Level["v_1_pro_instance"] = v_1_pro_instance;
|
|
1726
|
-
const pro_personal = 'ProPersonal'; Level["pro_personal"] = pro_personal;
|
|
1727
|
-
const coze_personal_plus = 'CozePersonalPlus'; Level["coze_personal_plus"] = coze_personal_plus;
|
|
1728
|
-
const coze_personal_advanced = 'CozePersonalAdvanced'; Level["coze_personal_advanced"] = coze_personal_advanced;
|
|
1729
|
-
const coze_personal_pro = 'CozePersonalPro'; Level["coze_personal_pro"] = coze_personal_pro;
|
|
1730
|
-
const team = 'Team'; Level["team"] = team;
|
|
1731
|
-
const enterprise_basic = 'EnterpriseBasic'; Level["enterprise_basic"] = enterprise_basic;
|
|
1732
|
-
const enterprise = 'Enterprise'; Level["enterprise"] = enterprise;
|
|
1733
|
-
const enterprise_pro = 'EnterprisePro'; Level["enterprise_pro"] = enterprise_pro;
|
|
1734
|
-
})(Level || (Level = {}));
|
|
1735
|
-
|
|
1736
|
-
var ListOption; (function (ListOption) {
|
|
1737
|
-
const user_custom_only = 'user_custom_only'; ListOption["user_custom_only"] = user_custom_only;
|
|
1738
|
-
const all2 = 'all'; ListOption["all2"] = all2;
|
|
1739
|
-
})(ListOption || (ListOption = {}));
|
|
1740
|
-
|
|
1741
|
-
var OAuth2ProviderType; (function (OAuth2ProviderType) {
|
|
1742
|
-
const system = 'system'; OAuth2ProviderType["system"] = system;
|
|
1743
|
-
const custom = 'custom'; OAuth2ProviderType["custom"] = custom;
|
|
1744
|
-
})(OAuth2ProviderType || (OAuth2ProviderType = {}));
|
|
1745
|
-
|
|
1746
|
-
var OrganizationApplicationDenyType; (function (OrganizationApplicationDenyType) {
|
|
1747
|
-
const not_in_enterprise = 'NotInEnterprise'; OrganizationApplicationDenyType["not_in_enterprise"] = not_in_enterprise;
|
|
1748
|
-
const prohibited_by_custom_people_management2 = 'ProhibitedByCustomPeopleManagement'; OrganizationApplicationDenyType["prohibited_by_custom_people_management2"] = prohibited_by_custom_people_management2;
|
|
1749
|
-
})(OrganizationApplicationDenyType || (OrganizationApplicationDenyType = {}));
|
|
1750
|
-
|
|
1751
|
-
var OrganizationApplicationForEnterpriseMemberStatus; (function (OrganizationApplicationForEnterpriseMemberStatus) {
|
|
1752
|
-
const can_apply3 = 'CanApply'; OrganizationApplicationForEnterpriseMemberStatus["can_apply3"] = can_apply3;
|
|
1753
|
-
const already_applied3 = 'AlreadyApplied'; OrganizationApplicationForEnterpriseMemberStatus["already_applied3"] = already_applied3;
|
|
1754
|
-
const joined5 = 'Joined'; OrganizationApplicationForEnterpriseMemberStatus["joined5"] = joined5;
|
|
1755
|
-
const deny4 = 'Deny'; OrganizationApplicationForEnterpriseMemberStatus["deny4"] = deny4;
|
|
1756
|
-
})(OrganizationApplicationForEnterpriseMemberStatus || (OrganizationApplicationForEnterpriseMemberStatus = {}));
|
|
1757
|
-
|
|
1758
|
-
var OrganizationRoleType; (function (OrganizationRoleType) {
|
|
1759
|
-
const super_admin2 = 'SuperAdmin'; OrganizationRoleType["super_admin2"] = super_admin2;
|
|
1760
|
-
const admin2 = 'Admin'; OrganizationRoleType["admin2"] = admin2;
|
|
1761
|
-
const member2 = 'Member'; OrganizationRoleType["member2"] = member2;
|
|
1762
|
-
const guest2 = 'Guest'; OrganizationRoleType["guest2"] = guest2;
|
|
1763
|
-
})(OrganizationRoleType || (OrganizationRoleType = {}));
|
|
1764
|
-
|
|
1765
|
-
var Ownership; (function (Ownership) {
|
|
1766
|
-
const developer = 'developer'; Ownership["developer"] = developer;
|
|
1767
|
-
const consumer2 = 'consumer'; Ownership["consumer2"] = consumer2;
|
|
1768
|
-
})(Ownership || (Ownership = {}));
|
|
1769
|
-
|
|
1770
|
-
var PatSearchOption; (function (PatSearchOption) {
|
|
1771
|
-
const all = 'all'; PatSearchOption["all"] = all;
|
|
1772
|
-
const owned = 'owned'; PatSearchOption["owned"] = owned;
|
|
1773
|
-
const others = 'others'; PatSearchOption["others"] = others;
|
|
1774
|
-
})(PatSearchOption || (PatSearchOption = {}));
|
|
1775
|
-
|
|
1776
|
-
var PeopleType; (function (PeopleType) {
|
|
1777
|
-
const enterprise_member = 'EnterpriseMember'; PeopleType["enterprise_member"] = enterprise_member;
|
|
1778
|
-
const enterprise_guest = 'EnterpriseGuest'; PeopleType["enterprise_guest"] = enterprise_guest;
|
|
1779
|
-
})(PeopleType || (PeopleType = {}));
|
|
1780
|
-
|
|
1781
|
-
var ProjectAuthIntegrationStatus; (function (ProjectAuthIntegrationStatus) {
|
|
1782
|
-
const not_created = 'NotCreated'; ProjectAuthIntegrationStatus["not_created"] = not_created;
|
|
1783
|
-
const enabled = 'Enabled'; ProjectAuthIntegrationStatus["enabled"] = enabled;
|
|
1784
|
-
const disabled = 'Disabled'; ProjectAuthIntegrationStatus["disabled"] = disabled;
|
|
1785
|
-
})(ProjectAuthIntegrationStatus || (ProjectAuthIntegrationStatus = {}));
|
|
1786
|
-
|
|
1787
|
-
var ProjectEnvironment; (function (ProjectEnvironment) {
|
|
1788
|
-
const production = 'Production'; ProjectEnvironment["production"] = production;
|
|
1789
|
-
const development = 'Development'; ProjectEnvironment["development"] = development;
|
|
1790
|
-
})(ProjectEnvironment || (ProjectEnvironment = {}));
|
|
1791
|
-
|
|
1792
|
-
var ProjectType$2; (function (ProjectType) {
|
|
1793
|
-
const skill = 'skill'; ProjectType["skill"] = skill;
|
|
1794
|
-
})(ProjectType$2 || (ProjectType$2 = {}));
|
|
1795
|
-
|
|
1796
|
-
var SearchEnv; (function (SearchEnv) {
|
|
1797
|
-
const dev = 'dev'; SearchEnv["dev"] = dev;
|
|
1798
|
-
const prod = 'prod'; SearchEnv["prod"] = prod;
|
|
1799
|
-
})(SearchEnv || (SearchEnv = {}));
|
|
1800
|
-
|
|
1801
|
-
var SecretKeyType; (function (SecretKeyType) {
|
|
1802
|
-
const user_custom = 'user_custom'; SecretKeyType["user_custom"] = user_custom;
|
|
1803
|
-
const coze_default = 'coze_default'; SecretKeyType["coze_default"] = coze_default;
|
|
1804
|
-
const consumer = 'consumer'; SecretKeyType["consumer"] = consumer;
|
|
1805
|
-
})(SecretKeyType || (SecretKeyType = {}));
|
|
1806
|
-
|
|
1807
|
-
var Status; (function (Status) {
|
|
1808
|
-
const active2 = 'Active'; Status["active2"] = active2;
|
|
1809
|
-
const deactive = 'Deactive'; Status["deactive"] = deactive;
|
|
1810
|
-
})(Status || (Status = {}));
|
|
1811
|
-
|
|
1812
|
-
var UserStatus$1; (function (UserStatus) {
|
|
1813
|
-
const active = 'active'; UserStatus["active"] = active;
|
|
1814
|
-
const deactivated = 'deactivated'; UserStatus["deactivated"] = deactivated;
|
|
1815
|
-
const offboarded = 'offboarded'; UserStatus["offboarded"] = offboarded;
|
|
1816
|
-
})(UserStatus$1 || (UserStatus$1 = {}));
|
|
1817
|
-
|
|
1818
|
-
var VisibilityKey; (function (VisibilityKey) {
|
|
1819
|
-
const studio_space_selector = 'studio_space_selector'; VisibilityKey["studio_space_selector"] = studio_space_selector;
|
|
1820
|
-
const studio_create_project_btn = 'studio_create_project_btn'; VisibilityKey["studio_create_project_btn"] = studio_create_project_btn;
|
|
1821
|
-
const studio_home_page = 'studio_home_page'; VisibilityKey["studio_home_page"] = studio_home_page;
|
|
1822
|
-
const studio_develop = 'studio_develop'; VisibilityKey["studio_develop"] = studio_develop;
|
|
1823
|
-
const studio_library = 'studio_library'; VisibilityKey["studio_library"] = studio_library;
|
|
1824
|
-
const studio_tasks = 'studio_tasks'; VisibilityKey["studio_tasks"] = studio_tasks;
|
|
1825
|
-
const studio_evaluate = 'studio_evaluate'; VisibilityKey["studio_evaluate"] = studio_evaluate;
|
|
1826
|
-
const studio_space_manage = 'studio_space_manage'; VisibilityKey["studio_space_manage"] = studio_space_manage;
|
|
1827
|
-
const studio_templates_store = 'studio_templates_store'; VisibilityKey["studio_templates_store"] = studio_templates_store;
|
|
1828
|
-
const studio_plugins_store = 'studio_plugins_store'; VisibilityKey["studio_plugins_store"] = studio_plugins_store;
|
|
1829
|
-
const studio_agents_store = 'studio_agents_store'; VisibilityKey["studio_agents_store"] = studio_agents_store;
|
|
1830
|
-
const studio_playground = 'studio_playground'; VisibilityKey["studio_playground"] = studio_playground;
|
|
1831
|
-
const studio_docs = 'studio_docs'; VisibilityKey["studio_docs"] = studio_docs;
|
|
1832
|
-
const studio_enterprise_agents_store = 'studio_enterprise_agents_store'; VisibilityKey["studio_enterprise_agents_store"] = studio_enterprise_agents_store;
|
|
1833
|
-
const studio_enterprise_plugins_store = 'studio_enterprise_plugins_store'; VisibilityKey["studio_enterprise_plugins_store"] = studio_enterprise_plugins_store;
|
|
1834
|
-
const studio_organization_manage = 'studio_organization_manage'; VisibilityKey["studio_organization_manage"] = studio_organization_manage;
|
|
1835
|
-
const studio_enterprise_card = 'studio_enterprise_card'; VisibilityKey["studio_enterprise_card"] = studio_enterprise_card;
|
|
1836
|
-
const studio_subscription_card = 'studio_subscription_card'; VisibilityKey["studio_subscription_card"] = studio_subscription_card;
|
|
1837
|
-
const studio_personal_menu = 'studio_personal_menu'; VisibilityKey["studio_personal_menu"] = studio_personal_menu;
|
|
1838
|
-
const studio_more_products = 'studio_more_products'; VisibilityKey["studio_more_products"] = studio_more_products;
|
|
1839
|
-
const studio_notice = 'studio_notice'; VisibilityKey["studio_notice"] = studio_notice;
|
|
1840
|
-
const studio_migration_banner = 'studio_migration_banner'; VisibilityKey["studio_migration_banner"] = studio_migration_banner;
|
|
1841
|
-
const coding_space_selector = 'coding_space_selector'; VisibilityKey["coding_space_selector"] = coding_space_selector;
|
|
1842
|
-
const coding_create_project = 'coding_create_project'; VisibilityKey["coding_create_project"] = coding_create_project;
|
|
1843
|
-
const coding_project_manage = 'coding_project_manage'; VisibilityKey["coding_project_manage"] = coding_project_manage;
|
|
1844
|
-
const coding_integrations = 'coding_integrations'; VisibilityKey["coding_integrations"] = coding_integrations;
|
|
1845
|
-
const coding_library = 'coding_library'; VisibilityKey["coding_library"] = coding_library;
|
|
1846
|
-
const coding_tasks = 'coding_tasks'; VisibilityKey["coding_tasks"] = coding_tasks;
|
|
1847
|
-
const coding_playground = 'coding_playground'; VisibilityKey["coding_playground"] = coding_playground;
|
|
1848
|
-
const coding_evaluate = 'coding_evaluate'; VisibilityKey["coding_evaluate"] = coding_evaluate;
|
|
1849
|
-
const coding_coze_redirect = 'coding_coze_redirect'; VisibilityKey["coding_coze_redirect"] = coding_coze_redirect;
|
|
1850
|
-
const coding_docs = 'coding_docs'; VisibilityKey["coding_docs"] = coding_docs;
|
|
1851
|
-
const coding_community = 'coding_community'; VisibilityKey["coding_community"] = coding_community;
|
|
1852
|
-
const coding_enterprise_card = 'coding_enterprise_card'; VisibilityKey["coding_enterprise_card"] = coding_enterprise_card;
|
|
1853
|
-
const coding_subscription_card = 'coding_subscription_card'; VisibilityKey["coding_subscription_card"] = coding_subscription_card;
|
|
1854
|
-
const coding_personal_menu = 'coding_personal_menu'; VisibilityKey["coding_personal_menu"] = coding_personal_menu;
|
|
1855
|
-
const coding_notice = 'coding_notice'; VisibilityKey["coding_notice"] = coding_notice;
|
|
1856
|
-
const admin_organization_manage = 'admin_organization_manage'; VisibilityKey["admin_organization_manage"] = admin_organization_manage;
|
|
1857
|
-
const admin_member_manage = 'admin_member_manage'; VisibilityKey["admin_member_manage"] = admin_member_manage;
|
|
1858
|
-
const admin_enterprise_config = 'admin_enterprise_config'; VisibilityKey["admin_enterprise_config"] = admin_enterprise_config;
|
|
1859
|
-
})(VisibilityKey || (VisibilityKey = {}));
|
|
1860
|
-
|
|
1861
|
-
var VolcanoUserType$2; (function (VolcanoUserType) {
|
|
1862
|
-
const root_user = 'RootUser'; VolcanoUserType["root_user"] = root_user;
|
|
1863
|
-
const basic_user = 'BasicUser'; VolcanoUserType["basic_user"] = basic_user;
|
|
1864
|
-
})(VolcanoUserType$2 || (VolcanoUserType$2 = {}));
|
|
1865
1252
|
|
|
1866
1253
|
|
|
1867
1254
|
|
|
@@ -2956,15 +2343,11 @@ var VolcanoUserType$2; (function (VolcanoUserType) {
|
|
|
2956
2343
|
|
|
2957
2344
|
|
|
2958
2345
|
|
|
2346
|
+
/* eslint-enable */
|
|
2959
2347
|
|
|
2348
|
+
function _optionalChain$J(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
2960
2349
|
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
/* eslint-enable */
|
|
2964
|
-
|
|
2965
|
-
function _optionalChain$H(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
2966
|
-
|
|
2967
|
-
|
|
2350
|
+
|
|
2968
2351
|
|
|
2969
2352
|
|
|
2970
2353
|
|
|
@@ -4345,8 +3728,8 @@ class PermissionApiService {
|
|
|
4345
3728
|
|
|
4346
3729
|
|
|
4347
3730
|
) {PermissionApiService.prototype.__init.call(this);PermissionApiService.prototype.__init2.call(this);
|
|
4348
|
-
this.request = _optionalChain$
|
|
4349
|
-
this.baseURL = _optionalChain$
|
|
3731
|
+
this.request = _optionalChain$J([options, 'optionalAccess', _ => _.request]) || this.request;
|
|
3732
|
+
this.baseURL = _optionalChain$J([options, 'optionalAccess', _2 => _2.baseURL]) || this.baseURL;
|
|
4350
3733
|
}
|
|
4351
3734
|
|
|
4352
3735
|
genBaseURL(path) {
|
|
@@ -7123,254 +6506,1073 @@ class PermissionApiService {
|
|
|
7123
6506
|
return this.request({ url, method, data }, options);
|
|
7124
6507
|
}
|
|
7125
6508
|
|
|
7126
|
-
/**
|
|
7127
|
-
* GET /api/permission_api/volcano/get_volcano_login_masked_mobile
|
|
7128
|
-
*
|
|
7129
|
-
* [jump to BAM](https://cloud.bytedance.net/bam/rd/flow.permission.api/api_doc/show_doc?version=1.0.392&endpoint_id=3880020)
|
|
7130
|
-
*
|
|
7131
|
-
* get volcano login masked mobile
|
|
7132
|
-
*
|
|
7133
|
-
* get volcano login masked mobile
|
|
7134
|
-
*/
|
|
7135
|
-
GetVolcanoLoginMaskedMobile(
|
|
7136
|
-
req,
|
|
7137
|
-
options,
|
|
7138
|
-
) {
|
|
7139
|
-
const url = this.genBaseURL(
|
|
7140
|
-
'/api/permission_api/volcano/get_volcano_login_masked_mobile',
|
|
7141
|
-
);
|
|
7142
|
-
const method = 'GET';
|
|
7143
|
-
return this.request({ url, method }, options);
|
|
6509
|
+
/**
|
|
6510
|
+
* GET /api/permission_api/volcano/get_volcano_login_masked_mobile
|
|
6511
|
+
*
|
|
6512
|
+
* [jump to BAM](https://cloud.bytedance.net/bam/rd/flow.permission.api/api_doc/show_doc?version=1.0.392&endpoint_id=3880020)
|
|
6513
|
+
*
|
|
6514
|
+
* get volcano login masked mobile
|
|
6515
|
+
*
|
|
6516
|
+
* get volcano login masked mobile
|
|
6517
|
+
*/
|
|
6518
|
+
GetVolcanoLoginMaskedMobile(
|
|
6519
|
+
req,
|
|
6520
|
+
options,
|
|
6521
|
+
) {
|
|
6522
|
+
const url = this.genBaseURL(
|
|
6523
|
+
'/api/permission_api/volcano/get_volcano_login_masked_mobile',
|
|
6524
|
+
);
|
|
6525
|
+
const method = 'GET';
|
|
6526
|
+
return this.request({ url, method }, options);
|
|
6527
|
+
}
|
|
6528
|
+
}
|
|
6529
|
+
const PermissionApi = new PermissionApiService({});
|
|
6530
|
+
/* eslint-enable */
|
|
6531
|
+
|
|
6532
|
+
function _nullishCoalesce$k(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
6533
|
+
|
|
6534
|
+
|
|
6535
|
+
|
|
6536
|
+
|
|
6537
|
+
|
|
6538
|
+
class AuthService {
|
|
6539
|
+
|
|
6540
|
+
|
|
6541
|
+
constructor( ctx) {this.ctx = ctx;
|
|
6542
|
+
this.config = ctx.config;
|
|
6543
|
+
}
|
|
6544
|
+
|
|
6545
|
+
getOAuthConfig() {
|
|
6546
|
+
return {
|
|
6547
|
+
baseURL: _nullishCoalesce$k(this.config.openApiBaseUrl, () => ( DEFAULT_CONFIG.openApiBaseUrl)),
|
|
6548
|
+
clientId: _nullishCoalesce$k(this.config.clientId, () => ( DEFAULT_CONFIG.clientId)),
|
|
6549
|
+
};
|
|
6550
|
+
}
|
|
6551
|
+
|
|
6552
|
+
async clearUserContext() {
|
|
6553
|
+
this.config.organizationId = undefined;
|
|
6554
|
+
this.config.enterpriseId = undefined;
|
|
6555
|
+
this.config.spaceId = undefined;
|
|
6556
|
+
|
|
6557
|
+
await saveConfig({
|
|
6558
|
+
organizationId: undefined,
|
|
6559
|
+
enterpriseId: undefined,
|
|
6560
|
+
spaceId: undefined,
|
|
6561
|
+
});
|
|
6562
|
+
}
|
|
6563
|
+
|
|
6564
|
+
async clearAuthData() {
|
|
6565
|
+
this.config.accessToken = undefined;
|
|
6566
|
+
this.config.refreshToken = undefined;
|
|
6567
|
+
this.config.tokenExpiresAt = undefined;
|
|
6568
|
+
|
|
6569
|
+
await saveConfig({
|
|
6570
|
+
accessToken: undefined,
|
|
6571
|
+
refreshToken: undefined,
|
|
6572
|
+
tokenExpiresAt: undefined,
|
|
6573
|
+
});
|
|
6574
|
+
}
|
|
6575
|
+
|
|
6576
|
+
async login(options) {
|
|
6577
|
+
this.ctx.ui.verbose('Initiating login process...');
|
|
6578
|
+
|
|
6579
|
+
if (options.token) {
|
|
6580
|
+
this.ctx.ui.info('Using Personal Access Token (PAT)...');
|
|
6581
|
+
this.config.accessToken = options.token;
|
|
6582
|
+
await saveConfig({
|
|
6583
|
+
accessToken: options.token,
|
|
6584
|
+
refreshToken: undefined,
|
|
6585
|
+
tokenExpiresAt: undefined,
|
|
6586
|
+
});
|
|
6587
|
+
await this.clearUserContext();
|
|
6588
|
+
this.ctx.ui.info('Authentication successful. Credentials saved.');
|
|
6589
|
+
if (this.ctx.format === 'json') {
|
|
6590
|
+
this.ctx.response.print({ success: true, method: 'PAT' });
|
|
6591
|
+
}
|
|
6592
|
+
return;
|
|
6593
|
+
}
|
|
6594
|
+
|
|
6595
|
+
try {
|
|
6596
|
+
this.ctx.ui.info('Starting OAuth flow...');
|
|
6597
|
+
const { baseURL, clientId } = this.getOAuthConfig();
|
|
6598
|
+
|
|
6599
|
+
this.ctx.ui.verbose('Starting OAuth device flow...');
|
|
6600
|
+
|
|
6601
|
+
const deviceCode = await getDeviceCode({
|
|
6602
|
+
baseURL,
|
|
6603
|
+
clientId,
|
|
6604
|
+
});
|
|
6605
|
+
|
|
6606
|
+
const verificationUri = `${deviceCode.verification_uri}?user_code=${deviceCode.user_code}`;
|
|
6607
|
+
|
|
6608
|
+
this.ctx.ui.info(
|
|
6609
|
+
`Please visit ${chalk.underline(verificationUri)} and authorize the application.`,
|
|
6610
|
+
);
|
|
6611
|
+
|
|
6612
|
+
const deviceToken = await getDeviceToken(
|
|
6613
|
+
{
|
|
6614
|
+
baseURL,
|
|
6615
|
+
clientId,
|
|
6616
|
+
deviceCode: deviceCode.device_code,
|
|
6617
|
+
poll: true,
|
|
6618
|
+
},
|
|
6619
|
+
this.ctx,
|
|
6620
|
+
);
|
|
6621
|
+
|
|
6622
|
+
this.ctx.ui.debug(
|
|
6623
|
+
`Polling for device token success: ${JSON.stringify(deviceToken)}`,
|
|
6624
|
+
);
|
|
6625
|
+
|
|
6626
|
+
await this.saveOAuthToken(deviceToken);
|
|
6627
|
+
|
|
6628
|
+
this.ctx.ui.debug('Saving OAuth token successfully.');
|
|
6629
|
+
|
|
6630
|
+
await this.clearUserContext();
|
|
6631
|
+
|
|
6632
|
+
this.ctx.ui.info('Authentication successful. Credentials saved.');
|
|
6633
|
+
if (this.ctx.format === 'json') {
|
|
6634
|
+
this.ctx.response.print({ success: true, method: 'OAuth' });
|
|
6635
|
+
}
|
|
6636
|
+
} catch (oauthError) {
|
|
6637
|
+
this.ctx.ui.error(
|
|
6638
|
+
`OAuth login failed: ${oauthError.message || oauthError}`,
|
|
6639
|
+
);
|
|
6640
|
+
throw oauthError;
|
|
6641
|
+
}
|
|
6642
|
+
}
|
|
6643
|
+
|
|
6644
|
+
async logout() {
|
|
6645
|
+
await this.clearAuthData();
|
|
6646
|
+
await this.clearUserContext();
|
|
6647
|
+
this.ctx.ui.info('You have been logged out. Credentials cleared.');
|
|
6648
|
+
if (this.ctx.format === 'json') {
|
|
6649
|
+
this.ctx.response.print({ success: true, logged_out: true });
|
|
6650
|
+
}
|
|
6651
|
+
}
|
|
6652
|
+
|
|
6653
|
+
async whoami() {
|
|
6654
|
+
const token = await this.getValidAccessToken();
|
|
6655
|
+
|
|
6656
|
+
if (!token) {
|
|
6657
|
+
this.ctx.response.print({ logged_in: false });
|
|
6658
|
+
return;
|
|
6659
|
+
}
|
|
6660
|
+
|
|
6661
|
+
this.ctx.ui.info('Fetching user information...');
|
|
6662
|
+
|
|
6663
|
+
const info = {
|
|
6664
|
+
user: 'mock-user@coze.io',
|
|
6665
|
+
org: 'mock-org',
|
|
6666
|
+
profile: 'default',
|
|
6667
|
+
};
|
|
6668
|
+
|
|
6669
|
+
this.ctx.response.print({
|
|
6670
|
+
logged_in: true,
|
|
6671
|
+
...info,
|
|
6672
|
+
});
|
|
6673
|
+
}
|
|
6674
|
+
|
|
6675
|
+
async status() {
|
|
6676
|
+
const token = await this.getValidAccessToken();
|
|
6677
|
+
|
|
6678
|
+
this.ctx.ui.info('Checking authentication status...');
|
|
6679
|
+
|
|
6680
|
+
if (!token) {
|
|
6681
|
+
this.ctx.response.print({ logged_in: false });
|
|
6682
|
+
return;
|
|
6683
|
+
}
|
|
6684
|
+
|
|
6685
|
+
const expiresAt = this.config.tokenExpiresAt;
|
|
6686
|
+
const isOAuth = !!this.config.refreshToken;
|
|
6687
|
+
|
|
6688
|
+
const { data: user } = await PermissionApi.GetUserProfile(
|
|
6689
|
+
{},
|
|
6690
|
+
{ baseURL: this.config.openApiBaseUrl },
|
|
6691
|
+
);
|
|
6692
|
+
|
|
6693
|
+
const status = {
|
|
6694
|
+
logged_in: true,
|
|
6695
|
+
user,
|
|
6696
|
+
token_expires_at: expiresAt
|
|
6697
|
+
? new Date(expiresAt).toISOString()
|
|
6698
|
+
: !isOAuth
|
|
6699
|
+
? 'Never (PAT)'
|
|
6700
|
+
: undefined,
|
|
6701
|
+
};
|
|
6702
|
+
|
|
6703
|
+
this.ctx.response.print(status);
|
|
6704
|
+
}
|
|
6705
|
+
|
|
6706
|
+
async getValidAccessToken() {
|
|
6707
|
+
const { accessToken, refreshToken, tokenExpiresAt } = this.config;
|
|
6708
|
+
|
|
6709
|
+
if (!accessToken) {
|
|
6710
|
+
return undefined;
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6713
|
+
// If there is no refresh token, it means it's a PAT, so it doesn't expire
|
|
6714
|
+
if (!refreshToken) {
|
|
6715
|
+
return accessToken;
|
|
6716
|
+
}
|
|
6717
|
+
|
|
6718
|
+
// If the token is not expired (add 5 minutes buffer), return it
|
|
6719
|
+
const bufferTime = 5 * 60 * 1000;
|
|
6720
|
+
if (tokenExpiresAt && Date.now() < tokenExpiresAt - bufferTime) {
|
|
6721
|
+
return accessToken;
|
|
6722
|
+
}
|
|
6723
|
+
|
|
6724
|
+
// Token is expired or about to expire, let's refresh it
|
|
6725
|
+
this.ctx.ui.verbose(
|
|
6726
|
+
'Access token is expired or expiring soon, refreshing...',
|
|
6727
|
+
);
|
|
6728
|
+
|
|
6729
|
+
try {
|
|
6730
|
+
const { baseURL, clientId } = this.getOAuthConfig();
|
|
6731
|
+
|
|
6732
|
+
const newToken = await refreshOAuthToken({
|
|
6733
|
+
baseURL,
|
|
6734
|
+
clientId,
|
|
6735
|
+
refreshToken,
|
|
6736
|
+
});
|
|
6737
|
+
|
|
6738
|
+
await this.saveOAuthToken(newToken);
|
|
6739
|
+
this.ctx.ui.verbose('Token refreshed successfully.');
|
|
6740
|
+
return newToken.access_token;
|
|
6741
|
+
} catch (error) {
|
|
6742
|
+
// Clear token config if refresh fails to require re-login
|
|
6743
|
+
this.ctx.ui.error(`Failed to refresh token: ${error.message || error}`);
|
|
6744
|
+
await this.clearAuthData();
|
|
6745
|
+
return undefined;
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
|
|
6749
|
+
async saveOAuthToken(token) {
|
|
6750
|
+
const tokenExpiresAt = token.expires_in * 1000;
|
|
6751
|
+
|
|
6752
|
+
// Update local config object so we don't have to reload
|
|
6753
|
+
this.config.accessToken = token.access_token;
|
|
6754
|
+
this.config.refreshToken = token.refresh_token;
|
|
6755
|
+
this.config.tokenExpiresAt = tokenExpiresAt;
|
|
6756
|
+
|
|
6757
|
+
await saveConfig({
|
|
6758
|
+
accessToken: token.access_token,
|
|
6759
|
+
refreshToken: token.refresh_token,
|
|
6760
|
+
tokenExpiresAt,
|
|
6761
|
+
});
|
|
6762
|
+
}
|
|
6763
|
+
}
|
|
6764
|
+
|
|
6765
|
+
function _nullishCoalesce$j(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$I(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
6766
|
+
|
|
6767
|
+
|
|
6768
|
+
|
|
6769
|
+
|
|
6770
|
+
|
|
6771
|
+
|
|
6772
|
+
|
|
6773
|
+
|
|
6774
|
+
|
|
6775
|
+
|
|
6776
|
+
const C = {
|
|
6777
|
+
reset: '\x1b[0m',
|
|
6778
|
+
bold: '\x1b[1m',
|
|
6779
|
+
dim: '\x1b[2m',
|
|
6780
|
+
red: '\x1b[31m',
|
|
6781
|
+
green: '\x1b[32m',
|
|
6782
|
+
yellow: '\x1b[33m',
|
|
6783
|
+
cyan: '\x1b[36m',
|
|
6784
|
+
silver: '\x1b[90m',
|
|
6785
|
+
};
|
|
6786
|
+
|
|
6787
|
+
const BADGES = {
|
|
6788
|
+
PROC: '[PROC]',
|
|
6789
|
+
INFO: '[INFO]',
|
|
6790
|
+
WARN: '[WARN]',
|
|
6791
|
+
ERR: '[ERR]',
|
|
6792
|
+
DONE: '[DONE]',
|
|
6793
|
+
DBG: '[DBG]',
|
|
6794
|
+
};
|
|
6795
|
+
const LEVEL_PRIORITY = {
|
|
6796
|
+
debug: 0,
|
|
6797
|
+
verbose: 1,
|
|
6798
|
+
info: 2,
|
|
6799
|
+
success: 3,
|
|
6800
|
+
warn: 4,
|
|
6801
|
+
error: 5,
|
|
6802
|
+
};
|
|
6803
|
+
function badge(text) {
|
|
6804
|
+
return `${C.dim}${C.bold}${text}${C.reset}`;
|
|
6805
|
+
}
|
|
6806
|
+
class UI {
|
|
6807
|
+
|
|
6808
|
+
|
|
6809
|
+
|
|
6810
|
+
|
|
6811
|
+
|
|
6812
|
+
|
|
6813
|
+
constructor(
|
|
6814
|
+
log,
|
|
6815
|
+
format,
|
|
6816
|
+
level = 'info',
|
|
6817
|
+
) {
|
|
6818
|
+
this.log = log;
|
|
6819
|
+
this.silent = format === 'json';
|
|
6820
|
+
this.useColor = this.detectColorSupport();
|
|
6821
|
+
this.level = level;
|
|
6822
|
+
this.levelPriority = _nullishCoalesce$j(LEVEL_PRIORITY[level], () => ( 2));
|
|
6823
|
+
}
|
|
6824
|
+
|
|
6825
|
+
detectColorSupport() {
|
|
6826
|
+
return _optionalChain$I([process, 'access', _ => _.stderr, 'optionalAccess', _2 => _2.isTTY]) === true && process.env.NO_COLOR === undefined;
|
|
6827
|
+
}
|
|
6828
|
+
|
|
6829
|
+
paint(code, text) {
|
|
6830
|
+
return this.useColor ? `${code}${text}${C.reset}` : text;
|
|
6831
|
+
}
|
|
6832
|
+
|
|
6833
|
+
shouldOutput(methodLevel) {
|
|
6834
|
+
if (this.silent) {
|
|
6835
|
+
return false;
|
|
6836
|
+
}
|
|
6837
|
+
return LEVEL_PRIORITY[methodLevel] >= this.levelPriority;
|
|
6838
|
+
}
|
|
6839
|
+
|
|
6840
|
+
verbose(msg, ...args) {
|
|
6841
|
+
this.log.verbose(msg, ...args);
|
|
6842
|
+
if (!this.shouldOutput('verbose')) {
|
|
6843
|
+
return;
|
|
6844
|
+
}
|
|
6845
|
+
process.stderr.write(`${badge(BADGES.PROC)} ${this.paint(C.cyan, msg)}\n`);
|
|
6846
|
+
}
|
|
6847
|
+
|
|
6848
|
+
info(msg, ...args) {
|
|
6849
|
+
this.log.info(msg, ...args);
|
|
6850
|
+
if (!this.shouldOutput('info')) {
|
|
6851
|
+
return;
|
|
6852
|
+
}
|
|
6853
|
+
process.stderr.write(`${badge(BADGES.INFO)} ${this.paint(C.reset, msg)}\n`);
|
|
6854
|
+
}
|
|
6855
|
+
|
|
6856
|
+
warn(msg, ...args) {
|
|
6857
|
+
this.log.warn(msg, ...args);
|
|
6858
|
+
if (!this.shouldOutput('warn')) {
|
|
6859
|
+
return;
|
|
6860
|
+
}
|
|
6861
|
+
process.stderr.write(
|
|
6862
|
+
`${badge(BADGES.WARN)} ${this.paint(C.yellow, msg)}\n`,
|
|
6863
|
+
);
|
|
6864
|
+
}
|
|
6865
|
+
|
|
6866
|
+
error(msg, ...args) {
|
|
6867
|
+
this.log.error(msg, ...args);
|
|
6868
|
+
if (!this.shouldOutput('error')) {
|
|
6869
|
+
return;
|
|
6870
|
+
}
|
|
6871
|
+
process.stderr.write(`${badge(BADGES.ERR)} ${this.paint(C.red, msg)}\n`);
|
|
6872
|
+
}
|
|
6873
|
+
|
|
6874
|
+
success(msg, ...args) {
|
|
6875
|
+
this.log.success(msg, ...args);
|
|
6876
|
+
if (!this.shouldOutput('success')) {
|
|
6877
|
+
return;
|
|
6878
|
+
}
|
|
6879
|
+
process.stderr.write(`${badge(BADGES.DONE)} ${this.paint(C.green, msg)}\n`);
|
|
6880
|
+
}
|
|
6881
|
+
|
|
6882
|
+
debug(msg, ...args) {
|
|
6883
|
+
this.log.debug(msg, ...args);
|
|
6884
|
+
if (!this.shouldOutput('debug')) {
|
|
6885
|
+
return;
|
|
6886
|
+
}
|
|
6887
|
+
process.stderr.write(`${badge(BADGES.DBG)} ${this.paint(C.silver, msg)}\n`);
|
|
6888
|
+
}
|
|
6889
|
+
}
|
|
6890
|
+
|
|
6891
|
+
class JsonFormatter {
|
|
6892
|
+
format(data) {
|
|
6893
|
+
const output = JSON.stringify(data, null, 2);
|
|
6894
|
+
return output.endsWith('\n') ? output : `${output}\n`;
|
|
6895
|
+
}
|
|
6896
|
+
|
|
6897
|
+
formatError(error) {
|
|
6898
|
+
const errorObj = {
|
|
6899
|
+
name: error.name,
|
|
6900
|
+
message: error.message,
|
|
6901
|
+
code: error.code,
|
|
6902
|
+
details: error.details,
|
|
6903
|
+
};
|
|
6904
|
+
const output = JSON.stringify(errorObj, null, 2);
|
|
6905
|
+
return output.endsWith('\n') ? output : `${output}\n`;
|
|
6906
|
+
}
|
|
6907
|
+
}
|
|
6908
|
+
|
|
6909
|
+
function _nullishCoalesce$i(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$H(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
6910
|
+
|
|
6911
|
+
|
|
6912
|
+
|
|
6913
|
+
|
|
6914
|
+
|
|
6915
|
+
|
|
6916
|
+
|
|
6917
|
+
|
|
6918
|
+
|
|
6919
|
+
|
|
6920
|
+
|
|
6921
|
+
|
|
6922
|
+
|
|
6923
|
+
|
|
6924
|
+
|
|
6925
|
+
|
|
6926
|
+
|
|
6927
|
+
|
|
6928
|
+
|
|
6929
|
+
function stripAnsi(input) {
|
|
6930
|
+
// eslint-disable-next-line no-control-regex
|
|
6931
|
+
const ansiPattern = /\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;
|
|
6932
|
+
return input.replace(ansiPattern, '');
|
|
6933
|
+
}
|
|
6934
|
+
|
|
6935
|
+
function isFullWidthCodePoint(codePoint) {
|
|
6936
|
+
if (codePoint >= 0x1100 && codePoint <= 0x115f) {
|
|
6937
|
+
return true;
|
|
6938
|
+
}
|
|
6939
|
+
if (codePoint === 0x2329 || codePoint === 0x232a) {
|
|
6940
|
+
return true;
|
|
6941
|
+
}
|
|
6942
|
+
if (codePoint >= 0x2e80 && codePoint <= 0x303e) {
|
|
6943
|
+
return true;
|
|
6944
|
+
}
|
|
6945
|
+
if (codePoint >= 0x3040 && codePoint <= 0xa4cf) {
|
|
6946
|
+
return true;
|
|
6947
|
+
}
|
|
6948
|
+
if (codePoint >= 0xac00 && codePoint <= 0xd7a3) {
|
|
6949
|
+
return true;
|
|
6950
|
+
}
|
|
6951
|
+
if (codePoint >= 0xf900 && codePoint <= 0xfaff) {
|
|
6952
|
+
return true;
|
|
6953
|
+
}
|
|
6954
|
+
if (codePoint >= 0xfe10 && codePoint <= 0xfe19) {
|
|
6955
|
+
return true;
|
|
6956
|
+
}
|
|
6957
|
+
if (codePoint >= 0xfe30 && codePoint <= 0xfe6f) {
|
|
6958
|
+
return true;
|
|
6959
|
+
}
|
|
6960
|
+
if (codePoint >= 0xff00 && codePoint <= 0xff60) {
|
|
6961
|
+
return true;
|
|
6962
|
+
}
|
|
6963
|
+
if (codePoint >= 0xffe0 && codePoint <= 0xffe6) {
|
|
6964
|
+
return true;
|
|
6965
|
+
}
|
|
6966
|
+
if (codePoint >= 0x1f300 && codePoint <= 0x1fa9f) {
|
|
6967
|
+
return true;
|
|
6968
|
+
}
|
|
6969
|
+
if (codePoint >= 0x20000 && codePoint <= 0x3fffd) {
|
|
6970
|
+
return true;
|
|
6971
|
+
}
|
|
6972
|
+
return false;
|
|
6973
|
+
}
|
|
6974
|
+
|
|
6975
|
+
function stringWidth(input) {
|
|
6976
|
+
const stripped = stripAnsi(input);
|
|
6977
|
+
if (!stripped) {
|
|
6978
|
+
return 0;
|
|
6979
|
+
}
|
|
6980
|
+
|
|
6981
|
+
const combiningMarks =
|
|
6982
|
+
/[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/u;
|
|
6983
|
+
|
|
6984
|
+
let width = 0;
|
|
6985
|
+
const chars = Array.from(stripped);
|
|
6986
|
+
for (let i = 0; i < chars.length; i += 1) {
|
|
6987
|
+
const char = _nullishCoalesce$i(chars[i], () => ( ''));
|
|
6988
|
+
if (combiningMarks.test(char)) {
|
|
6989
|
+
continue;
|
|
6990
|
+
}
|
|
6991
|
+
const codePoint = char.codePointAt(0);
|
|
6992
|
+
if (codePoint === undefined) {
|
|
6993
|
+
continue;
|
|
6994
|
+
}
|
|
6995
|
+
width += isFullWidthCodePoint(codePoint) ? 2 : 1;
|
|
6996
|
+
}
|
|
6997
|
+
return width;
|
|
6998
|
+
}
|
|
6999
|
+
|
|
7000
|
+
function padRightVisible(str, width) {
|
|
7001
|
+
const current = stringWidth(str);
|
|
7002
|
+
if (current >= width) {
|
|
7003
|
+
return str;
|
|
7004
|
+
}
|
|
7005
|
+
return `${str}${' '.repeat(width - current)}`;
|
|
7006
|
+
}
|
|
7007
|
+
|
|
7008
|
+
function truncateVisible(str, width) {
|
|
7009
|
+
if (width <= 0) {
|
|
7010
|
+
return '';
|
|
7011
|
+
}
|
|
7012
|
+
if (stringWidth(str) <= width) {
|
|
7013
|
+
return str;
|
|
7014
|
+
}
|
|
7015
|
+
if (width === 1) {
|
|
7016
|
+
return '…';
|
|
7017
|
+
}
|
|
7018
|
+
|
|
7019
|
+
const stripped = stripAnsi(str);
|
|
7020
|
+
const chars = Array.from(stripped);
|
|
7021
|
+
const ellipsis = '…';
|
|
7022
|
+
const available = Math.max(0, width - stringWidth(ellipsis));
|
|
7023
|
+
|
|
7024
|
+
let out = '';
|
|
7025
|
+
let used = 0;
|
|
7026
|
+
for (let i = 0; i < chars.length; i += 1) {
|
|
7027
|
+
const char = _nullishCoalesce$i(chars[i], () => ( ''));
|
|
7028
|
+
const w = stringWidth(char);
|
|
7029
|
+
if (used + w > available) {
|
|
7030
|
+
break;
|
|
7031
|
+
}
|
|
7032
|
+
out += char;
|
|
7033
|
+
used += w;
|
|
7034
|
+
}
|
|
7035
|
+
|
|
7036
|
+
return `${out}${ellipsis}`;
|
|
7037
|
+
}
|
|
7038
|
+
|
|
7039
|
+
function calculateColumnWidths(rows, options) {
|
|
7040
|
+
if (rows.length === 0) {
|
|
7041
|
+
return [];
|
|
7042
|
+
}
|
|
7043
|
+
|
|
7044
|
+
const keySet = new Set();
|
|
7045
|
+
const orderedKeys = [];
|
|
7046
|
+
|
|
7047
|
+
const seedRow = _nullishCoalesce$i(rows[0], () => ( {}));
|
|
7048
|
+
for (const key of Object.keys(seedRow)) {
|
|
7049
|
+
if (!keySet.has(key)) {
|
|
7050
|
+
keySet.add(key);
|
|
7051
|
+
orderedKeys.push(key);
|
|
7052
|
+
}
|
|
7053
|
+
}
|
|
7054
|
+
|
|
7055
|
+
for (const row of rows) {
|
|
7056
|
+
for (const key of Object.keys(row)) {
|
|
7057
|
+
if (!keySet.has(key)) {
|
|
7058
|
+
keySet.add(key);
|
|
7059
|
+
orderedKeys.push(key);
|
|
7060
|
+
}
|
|
7061
|
+
}
|
|
7062
|
+
}
|
|
7063
|
+
|
|
7064
|
+
const columns = [];
|
|
7065
|
+
for (const key of orderedKeys) {
|
|
7066
|
+
let maxWidth = stringWidth(key);
|
|
7067
|
+
for (const row of rows) {
|
|
7068
|
+
const value = row[key];
|
|
7069
|
+
const valueStr = value === undefined ? '' : String(value);
|
|
7070
|
+
maxWidth = Math.max(maxWidth, stringWidth(valueStr));
|
|
7071
|
+
}
|
|
7072
|
+
columns.push({ key, width: maxWidth });
|
|
7073
|
+
}
|
|
7074
|
+
|
|
7075
|
+
const gap = _nullishCoalesce$i(options.columnGap, () => ( 2));
|
|
7076
|
+
const maxWidth = _nullishCoalesce$i(_nullishCoalesce$i(options.maxWidth, () => ( process.stdout.columns)), () => ( 120));
|
|
7077
|
+
const minColWidth = 6;
|
|
7078
|
+
|
|
7079
|
+
const dynamicMaxColumns = Math.max(
|
|
7080
|
+
1,
|
|
7081
|
+
Math.floor((maxWidth + gap) / (minColWidth + gap)),
|
|
7082
|
+
);
|
|
7083
|
+
const maxColumns = Math.min(
|
|
7084
|
+
_nullishCoalesce$i(options.maxColumns, () => ( dynamicMaxColumns)),
|
|
7085
|
+
dynamicMaxColumns,
|
|
7086
|
+
);
|
|
7087
|
+
|
|
7088
|
+
if (columns.length > maxColumns) {
|
|
7089
|
+
columns.splice(maxColumns);
|
|
7090
|
+
}
|
|
7091
|
+
|
|
7092
|
+
const available = Math.max(
|
|
7093
|
+
0,
|
|
7094
|
+
maxWidth - gap * Math.max(0, columns.length - 1),
|
|
7095
|
+
);
|
|
7096
|
+
|
|
7097
|
+
const sum = () => columns.reduce((acc, col) => acc + col.width, 0);
|
|
7098
|
+
|
|
7099
|
+
while (sum() > available) {
|
|
7100
|
+
let widestIndex = -1;
|
|
7101
|
+
let widestWidth = -1;
|
|
7102
|
+
for (let i = 0; i < columns.length; i += 1) {
|
|
7103
|
+
const w = _nullishCoalesce$i(_optionalChain$H([columns, 'access', _ => _[i], 'optionalAccess', _2 => _2.width]), () => ( 0));
|
|
7104
|
+
if (w > widestWidth) {
|
|
7105
|
+
widestWidth = w;
|
|
7106
|
+
widestIndex = i;
|
|
7107
|
+
}
|
|
7108
|
+
}
|
|
7109
|
+
|
|
7110
|
+
if (widestIndex === -1) {
|
|
7111
|
+
break;
|
|
7112
|
+
}
|
|
7113
|
+
const current = _nullishCoalesce$i(_optionalChain$H([columns, 'access', _3 => _3[widestIndex], 'optionalAccess', _4 => _4.width]), () => ( 0));
|
|
7114
|
+
if (current <= minColWidth) {
|
|
7115
|
+
break;
|
|
7116
|
+
}
|
|
7117
|
+
columns[widestIndex] = { ...columns[widestIndex], width: current - 1 };
|
|
7118
|
+
}
|
|
7119
|
+
|
|
7120
|
+
for (let i = 0; i < columns.length; i += 1) {
|
|
7121
|
+
const col = columns[i];
|
|
7122
|
+
if (!col) {
|
|
7123
|
+
continue;
|
|
7124
|
+
}
|
|
7125
|
+
columns[i] = { ...col, width: Math.max(minColWidth, col.width) };
|
|
7126
|
+
}
|
|
7127
|
+
|
|
7128
|
+
return columns;
|
|
7129
|
+
}
|
|
7130
|
+
|
|
7131
|
+
function formatTable(rows, options = {}) {
|
|
7132
|
+
if (rows.length === 0) {
|
|
7133
|
+
return '';
|
|
7134
|
+
}
|
|
7135
|
+
|
|
7136
|
+
const columns = calculateColumnWidths(rows, options);
|
|
7137
|
+
if (columns.length === 0) {
|
|
7138
|
+
return '';
|
|
7139
|
+
}
|
|
7140
|
+
|
|
7141
|
+
const gap = _nullishCoalesce$i(options.columnGap, () => ( 2));
|
|
7142
|
+
const gapStr = ' '.repeat(gap);
|
|
7143
|
+
|
|
7144
|
+
const header = columns
|
|
7145
|
+
.map(col => padRightVisible(truncateVisible(col.key, col.width), col.width))
|
|
7146
|
+
.join(gapStr);
|
|
7147
|
+
const separator = columns.map(col => '-'.repeat(col.width)).join(gapStr);
|
|
7148
|
+
|
|
7149
|
+
const bodyRows = [];
|
|
7150
|
+
for (const row of rows) {
|
|
7151
|
+
const cells = columns.map(col => {
|
|
7152
|
+
const value = row[col.key];
|
|
7153
|
+
const valueStr = value === undefined ? '' : String(value);
|
|
7154
|
+
const trimmed = truncateVisible(valueStr, col.width);
|
|
7155
|
+
return padRightVisible(trimmed, col.width);
|
|
7156
|
+
});
|
|
7157
|
+
bodyRows.push(cells.join(gapStr));
|
|
7158
|
+
}
|
|
7159
|
+
|
|
7160
|
+
return `${[header, separator, ...bodyRows].join('\n')}\n`;
|
|
7161
|
+
}
|
|
7162
|
+
|
|
7163
|
+
function formatKeyValue(
|
|
7164
|
+
obj,
|
|
7165
|
+
options = {},
|
|
7166
|
+
) {
|
|
7167
|
+
const entries = Object.entries(obj);
|
|
7168
|
+
if (entries.length === 0) {
|
|
7169
|
+
return '';
|
|
7170
|
+
}
|
|
7171
|
+
|
|
7172
|
+
let maxKeyWidth = 0;
|
|
7173
|
+
for (const [key] of entries) {
|
|
7174
|
+
maxKeyWidth = Math.max(maxKeyWidth, stringWidth(key));
|
|
7144
7175
|
}
|
|
7176
|
+
|
|
7177
|
+
const maxWidth = _nullishCoalesce$i(_nullishCoalesce$i(options.maxWidth, () => ( process.stdout.columns)), () => ( 120));
|
|
7178
|
+
const gap = _nullishCoalesce$i(options.columnGap, () => ( 2));
|
|
7179
|
+
const minValueWidth = _nullishCoalesce$i(options.minValueWidth, () => ( 12));
|
|
7180
|
+
|
|
7181
|
+
let keyWidth = Math.min(maxKeyWidth, _nullishCoalesce$i(options.keyMaxWidth, () => ( 32)));
|
|
7182
|
+
const maxKeyWidthByTotal = Math.max(6, maxWidth - gap - minValueWidth);
|
|
7183
|
+
keyWidth = Math.min(keyWidth, maxKeyWidthByTotal);
|
|
7184
|
+
|
|
7185
|
+
const valueWidth = Math.max(0, maxWidth - keyWidth - gap);
|
|
7186
|
+
const gapStr = ' '.repeat(gap);
|
|
7187
|
+
|
|
7188
|
+
const lines = entries.map(([key, value]) => {
|
|
7189
|
+
const keyCell = padRightVisible(truncateVisible(key, keyWidth), keyWidth);
|
|
7190
|
+
const valueStr =
|
|
7191
|
+
value === undefined
|
|
7192
|
+
? 'undefined'
|
|
7193
|
+
: value === null
|
|
7194
|
+
? 'null'
|
|
7195
|
+
: String(value);
|
|
7196
|
+
|
|
7197
|
+
const singleLineValue = valueStr.replace(/\s*\n\s*/g, ' ');
|
|
7198
|
+
const valueCell =
|
|
7199
|
+
valueWidth > 0 ? truncateVisible(singleLineValue, valueWidth) : '';
|
|
7200
|
+
|
|
7201
|
+
return `${keyCell}${gapStr}${valueCell}`;
|
|
7202
|
+
});
|
|
7203
|
+
|
|
7204
|
+
return `${lines.join('\n')}\n`;
|
|
7145
7205
|
}
|
|
7146
|
-
const PermissionApi = new PermissionApiService({});
|
|
7147
|
-
/* eslint-enable */
|
|
7148
7206
|
|
|
7149
|
-
function _nullishCoalesce$
|
|
7207
|
+
function _nullishCoalesce$h(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }const MAX_DEPTH = 5;
|
|
7150
7208
|
|
|
7209
|
+
|
|
7151
7210
|
|
|
7152
7211
|
|
|
7153
7212
|
|
|
7154
7213
|
|
|
7155
|
-
class AuthService {
|
|
7156
|
-
|
|
7157
7214
|
|
|
7158
|
-
|
|
7159
|
-
|
|
7215
|
+
function isObject$1(value) {
|
|
7216
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7217
|
+
}
|
|
7218
|
+
|
|
7219
|
+
function flattenObject(
|
|
7220
|
+
obj,
|
|
7221
|
+
prefix = '',
|
|
7222
|
+
depth = 0,
|
|
7223
|
+
) {
|
|
7224
|
+
const result = {};
|
|
7225
|
+
|
|
7226
|
+
if (obj === null || obj === undefined) {
|
|
7227
|
+
return result;
|
|
7160
7228
|
}
|
|
7161
7229
|
|
|
7162
|
-
|
|
7163
|
-
return
|
|
7164
|
-
baseURL: _nullishCoalesce$f(this.config.openApiBaseUrl, () => ( DEFAULT_CONFIG.openApiBaseUrl)),
|
|
7165
|
-
clientId: _nullishCoalesce$f(this.config.clientId, () => ( DEFAULT_CONFIG.clientId)),
|
|
7166
|
-
};
|
|
7230
|
+
if (!isObject$1(obj)) {
|
|
7231
|
+
return result;
|
|
7167
7232
|
}
|
|
7168
7233
|
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
this.config.enterpriseId = undefined;
|
|
7172
|
-
this.config.spaceId = undefined;
|
|
7234
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
7235
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
7173
7236
|
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7237
|
+
if (value === null || value === undefined) {
|
|
7238
|
+
result[newKey] = value ;
|
|
7239
|
+
continue;
|
|
7240
|
+
}
|
|
7241
|
+
|
|
7242
|
+
if (Array.isArray(value)) {
|
|
7243
|
+
if (depth >= MAX_DEPTH) {
|
|
7244
|
+
result[newKey] = '[Array]';
|
|
7245
|
+
} else if (value.length === 0) {
|
|
7246
|
+
result[newKey] = '[]';
|
|
7247
|
+
} else if (
|
|
7248
|
+
value.every(item => typeof item !== 'object' || item === null)
|
|
7249
|
+
) {
|
|
7250
|
+
result[newKey] = value.map(v => String(_nullishCoalesce$h(v, () => ( 'null')))).join(', ');
|
|
7251
|
+
} else {
|
|
7252
|
+
result[newKey] = '[Array]';
|
|
7253
|
+
}
|
|
7254
|
+
continue;
|
|
7255
|
+
}
|
|
7256
|
+
|
|
7257
|
+
if (typeof value === 'object') {
|
|
7258
|
+
if (depth >= MAX_DEPTH) {
|
|
7259
|
+
result[newKey] = '[Object]';
|
|
7260
|
+
} else {
|
|
7261
|
+
const nested = flattenObject(value, newKey, depth + 1);
|
|
7262
|
+
Object.assign(result, nested);
|
|
7263
|
+
}
|
|
7264
|
+
continue;
|
|
7265
|
+
}
|
|
7266
|
+
|
|
7267
|
+
result[newKey] = value ;
|
|
7179
7268
|
}
|
|
7180
7269
|
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
this.config.refreshToken = undefined;
|
|
7184
|
-
this.config.tokenExpiresAt = undefined;
|
|
7270
|
+
return result;
|
|
7271
|
+
}
|
|
7185
7272
|
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7273
|
+
function _nullishCoalesce$g(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
7274
|
+
|
|
7275
|
+
function isObject(value) {
|
|
7276
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7277
|
+
}
|
|
7278
|
+
|
|
7279
|
+
function isArrayOfObjects(value) {
|
|
7280
|
+
return Array.isArray(value) && value.length > 0 && value.every(isObject);
|
|
7281
|
+
}
|
|
7282
|
+
|
|
7283
|
+
function isPrimitiveArray(
|
|
7284
|
+
value,
|
|
7285
|
+
) {
|
|
7286
|
+
return (
|
|
7287
|
+
Array.isArray(value) &&
|
|
7288
|
+
value.length > 0 &&
|
|
7289
|
+
value.every(
|
|
7290
|
+
item => item === null || item === undefined || typeof item !== 'object',
|
|
7291
|
+
)
|
|
7292
|
+
);
|
|
7293
|
+
}
|
|
7294
|
+
|
|
7295
|
+
function formatDetails(details, indent) {
|
|
7296
|
+
if (details === undefined || details === null) {
|
|
7297
|
+
return '';
|
|
7191
7298
|
}
|
|
7192
7299
|
|
|
7193
|
-
|
|
7194
|
-
|
|
7300
|
+
if (typeof details === 'string') {
|
|
7301
|
+
return `${indent}${details}\n`;
|
|
7302
|
+
}
|
|
7195
7303
|
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
});
|
|
7204
|
-
await this.clearUserContext();
|
|
7205
|
-
this.ctx.ui.info('Authentication successful. Credentials saved.');
|
|
7206
|
-
if (this.ctx.format === 'json') {
|
|
7207
|
-
this.ctx.response.print({ success: true, method: 'PAT' });
|
|
7304
|
+
if (Array.isArray(details)) {
|
|
7305
|
+
if (details.length === 0) {
|
|
7306
|
+
return '';
|
|
7307
|
+
}
|
|
7308
|
+
const items = details.map(item => {
|
|
7309
|
+
if (typeof item === 'object' && item !== null) {
|
|
7310
|
+
return formatKeyValue(flattenObject(item));
|
|
7208
7311
|
}
|
|
7209
|
-
return;
|
|
7312
|
+
return String(item);
|
|
7313
|
+
});
|
|
7314
|
+
return `${items.map(item => `${indent}- ${item.trim()}`).join('\n')}\n`;
|
|
7315
|
+
}
|
|
7316
|
+
|
|
7317
|
+
if (isObject(details)) {
|
|
7318
|
+
const flattened = flattenObject(details);
|
|
7319
|
+
if (Object.keys(flattened).length === 0) {
|
|
7320
|
+
return '';
|
|
7210
7321
|
}
|
|
7322
|
+
return `${formatKeyValue(flattened)
|
|
7323
|
+
.split('\n')
|
|
7324
|
+
.filter(line => line.trim())
|
|
7325
|
+
.map(line => `${indent}${line}`)
|
|
7326
|
+
.join('\n')}\n`;
|
|
7327
|
+
}
|
|
7211
7328
|
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
const { baseURL, clientId } = this.getOAuthConfig();
|
|
7329
|
+
return `${indent}${String(details)}\n`;
|
|
7330
|
+
}
|
|
7215
7331
|
|
|
7216
|
-
|
|
7332
|
+
class TextFormatter {
|
|
7333
|
+
format(data) {
|
|
7334
|
+
if (data === null) {
|
|
7335
|
+
return 'null\n';
|
|
7336
|
+
}
|
|
7217
7337
|
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
});
|
|
7338
|
+
if (data === undefined) {
|
|
7339
|
+
return 'undefined\n';
|
|
7340
|
+
}
|
|
7222
7341
|
|
|
7223
|
-
|
|
7342
|
+
if (Array.isArray(data)) {
|
|
7343
|
+
if (data.length === 0) {
|
|
7344
|
+
return '\n';
|
|
7345
|
+
}
|
|
7224
7346
|
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7347
|
+
if (isArrayOfObjects(data)) {
|
|
7348
|
+
const flattenedRows = data.map(row => flattenObject(row));
|
|
7349
|
+
return formatTable(flattenedRows);
|
|
7350
|
+
}
|
|
7228
7351
|
|
|
7229
|
-
|
|
7230
|
-
{
|
|
7231
|
-
|
|
7232
|
-
clientId,
|
|
7233
|
-
deviceCode: deviceCode.device_code,
|
|
7234
|
-
poll: true,
|
|
7235
|
-
},
|
|
7236
|
-
this.ctx,
|
|
7237
|
-
);
|
|
7352
|
+
if (isPrimitiveArray(data)) {
|
|
7353
|
+
return `${data.map(item => String(_nullishCoalesce$g(item, () => ( 'null')))).join('\n')}\n`;
|
|
7354
|
+
}
|
|
7238
7355
|
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
);
|
|
7356
|
+
return '[Array]\n';
|
|
7357
|
+
}
|
|
7242
7358
|
|
|
7243
|
-
|
|
7359
|
+
if (isObject(data)) {
|
|
7360
|
+
const flattened = flattenObject(data);
|
|
7361
|
+
if (Object.keys(flattened).length === 0) {
|
|
7362
|
+
return '{}\n';
|
|
7363
|
+
}
|
|
7364
|
+
return formatKeyValue(flattened);
|
|
7365
|
+
}
|
|
7244
7366
|
|
|
7245
|
-
|
|
7367
|
+
return `${String(data)}\n`;
|
|
7368
|
+
}
|
|
7246
7369
|
|
|
7247
|
-
|
|
7370
|
+
formatError(error) {
|
|
7371
|
+
const lines = [];
|
|
7248
7372
|
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7373
|
+
lines.push('✖ [ERROR]');
|
|
7374
|
+
lines.push(` Message: ${error.message}`);
|
|
7375
|
+
lines.push(` Code: ${error.code}`);
|
|
7376
|
+
|
|
7377
|
+
if (error.details !== undefined) {
|
|
7378
|
+
lines.push(' Details:');
|
|
7379
|
+
const detailsStr = formatDetails(error.details, ' ');
|
|
7380
|
+
if (detailsStr) {
|
|
7381
|
+
lines.push(detailsStr.trimEnd());
|
|
7252
7382
|
}
|
|
7253
|
-
} catch (oauthError) {
|
|
7254
|
-
this.ctx.ui.error(
|
|
7255
|
-
`OAuth login failed: ${oauthError.message || oauthError}`,
|
|
7256
|
-
);
|
|
7257
|
-
throw oauthError;
|
|
7258
7383
|
}
|
|
7259
|
-
}
|
|
7260
7384
|
|
|
7261
|
-
|
|
7262
|
-
await this.clearAuthData();
|
|
7263
|
-
await this.clearUserContext();
|
|
7264
|
-
this.ctx.ui.info('You have been logged out. Credentials cleared.');
|
|
7265
|
-
if (this.ctx.format === 'json') {
|
|
7266
|
-
this.ctx.response.print({ success: true, logged_out: true });
|
|
7267
|
-
}
|
|
7385
|
+
return `${lines.join('\n')}\n`;
|
|
7268
7386
|
}
|
|
7387
|
+
}
|
|
7269
7388
|
|
|
7270
|
-
|
|
7271
|
-
|
|
7389
|
+
function createFormatter(format) {
|
|
7390
|
+
switch (format) {
|
|
7391
|
+
case 'text':
|
|
7392
|
+
return new TextFormatter();
|
|
7393
|
+
case 'json':
|
|
7394
|
+
default:
|
|
7395
|
+
return new JsonFormatter();
|
|
7396
|
+
}
|
|
7397
|
+
}
|
|
7272
7398
|
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
return;
|
|
7276
|
-
}
|
|
7399
|
+
class Response {
|
|
7400
|
+
|
|
7277
7401
|
|
|
7278
|
-
|
|
7402
|
+
constructor(props) {
|
|
7403
|
+
const { format } = props;
|
|
7404
|
+
this.formatter = createFormatter(format);
|
|
7405
|
+
}
|
|
7279
7406
|
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
};
|
|
7407
|
+
print(data) {
|
|
7408
|
+
const output = this.formatter.format(data);
|
|
7409
|
+
process.stdout.write(output);
|
|
7410
|
+
}
|
|
7285
7411
|
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
});
|
|
7412
|
+
eprint(error) {
|
|
7413
|
+
const output = this.formatter.formatError(error);
|
|
7414
|
+
process.stdout.write(output);
|
|
7290
7415
|
}
|
|
7416
|
+
}
|
|
7291
7417
|
|
|
7292
|
-
|
|
7293
|
-
const token = await this.getValidAccessToken();
|
|
7418
|
+
function _nullishCoalesce$f(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
7294
7419
|
|
|
7295
|
-
this.ctx.ui.info('Checking authentication status...');
|
|
7296
7420
|
|
|
7297
|
-
const expiresAt = this.config.tokenExpiresAt;
|
|
7298
|
-
const isOAuth = !!this.config.refreshToken;
|
|
7299
7421
|
|
|
7300
|
-
const { data: user } = await PermissionApi.GetUserProfile(
|
|
7301
|
-
{},
|
|
7302
|
-
{ baseURL: this.config.openApiBaseUrl },
|
|
7303
|
-
);
|
|
7304
7422
|
|
|
7305
|
-
const status = {
|
|
7306
|
-
logged_in: !!token,
|
|
7307
|
-
user,
|
|
7308
|
-
token_expires_at: expiresAt
|
|
7309
|
-
? new Date(expiresAt).toISOString()
|
|
7310
|
-
: token && !isOAuth
|
|
7311
|
-
? 'Never (PAT)'
|
|
7312
|
-
: undefined,
|
|
7313
|
-
};
|
|
7314
7423
|
|
|
7315
|
-
this.ctx.response.print(status);
|
|
7316
|
-
}
|
|
7317
7424
|
|
|
7318
|
-
async getValidAccessToken() {
|
|
7319
|
-
const { accessToken, refreshToken, tokenExpiresAt } = this.config;
|
|
7320
7425
|
|
|
7321
|
-
|
|
7322
|
-
|
|
7426
|
+
const LOG_DIR = path.join(os.homedir(), '.coze', 'logs');
|
|
7427
|
+
const MAX_LOG_FILES = 10;
|
|
7428
|
+
|
|
7429
|
+
class DiagnosticLogger {
|
|
7430
|
+
|
|
7431
|
+
|
|
7432
|
+
|
|
7433
|
+
|
|
7434
|
+
|
|
7435
|
+
__init() {this.fileStream = null;}
|
|
7436
|
+
__init2() {this.writeError = false;}
|
|
7437
|
+
|
|
7438
|
+
constructor(options = {}) {DiagnosticLogger.prototype.__init.call(this);DiagnosticLogger.prototype.__init2.call(this);
|
|
7439
|
+
this.format = _nullishCoalesce$f(options.format, () => ( 'text'));
|
|
7440
|
+
this.printToStderr = _nullishCoalesce$f(options.printToStderr, () => ( false));
|
|
7441
|
+
this.tags = _nullishCoalesce$f(options.tags, () => ( {}));
|
|
7442
|
+
this.startTime = Date.now();
|
|
7443
|
+
|
|
7444
|
+
const logFilePath = _nullishCoalesce$f(options.logFile, () => ( this.getDefaultLogPath()));
|
|
7445
|
+
this.logFile = logFilePath;
|
|
7446
|
+
|
|
7447
|
+
try {
|
|
7448
|
+
this.ensureLogDir();
|
|
7449
|
+
this.rotateLogFiles();
|
|
7450
|
+
this.fileStream = node_fs.createWriteStream(logFilePath, { flags: 'a' });
|
|
7451
|
+
this.fileStream.on('error', () => {
|
|
7452
|
+
this.fileStream = null;
|
|
7453
|
+
});
|
|
7454
|
+
} catch (e) {
|
|
7455
|
+
this.logFile = null;
|
|
7456
|
+
this.fileStream = null;
|
|
7323
7457
|
}
|
|
7458
|
+
}
|
|
7324
7459
|
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7460
|
+
getDefaultLogPath() {
|
|
7461
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
7462
|
+
const { pid } = process;
|
|
7463
|
+
return path.join(LOG_DIR, `${timestamp}-${pid}.log`);
|
|
7464
|
+
}
|
|
7465
|
+
|
|
7466
|
+
ensureLogDir() {
|
|
7467
|
+
if (!node_fs.existsSync(LOG_DIR)) {
|
|
7468
|
+
node_fs.mkdirSync(LOG_DIR, { recursive: true });
|
|
7328
7469
|
}
|
|
7470
|
+
}
|
|
7329
7471
|
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7472
|
+
rotateLogFiles() {
|
|
7473
|
+
try {
|
|
7474
|
+
const files = node_fs.readdirSync(LOG_DIR)
|
|
7475
|
+
.filter(f => f.endsWith('.log'))
|
|
7476
|
+
.map(f => ({
|
|
7477
|
+
name: f,
|
|
7478
|
+
path: path.join(LOG_DIR, f),
|
|
7479
|
+
mtime: node_fs.statSync(path.join(LOG_DIR, f)).mtime.getTime(),
|
|
7480
|
+
}))
|
|
7481
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
7482
|
+
|
|
7483
|
+
if (files.length >= MAX_LOG_FILES) {
|
|
7484
|
+
files.slice(MAX_LOG_FILES - 1).forEach(f => {
|
|
7485
|
+
try {
|
|
7486
|
+
node_fs.unlinkSync(f.path);
|
|
7487
|
+
// eslint-disable-next-line @coze-arch/no-empty-catch
|
|
7488
|
+
} catch (e2) {
|
|
7489
|
+
// ignore deletion errors
|
|
7490
|
+
}
|
|
7491
|
+
});
|
|
7492
|
+
}
|
|
7493
|
+
// eslint-disable-next-line @coze-arch/no-empty-catch
|
|
7494
|
+
} catch (e3) {
|
|
7495
|
+
// ignore rotation errors
|
|
7334
7496
|
}
|
|
7497
|
+
}
|
|
7335
7498
|
|
|
7336
|
-
|
|
7337
|
-
this.
|
|
7338
|
-
|
|
7339
|
-
);
|
|
7499
|
+
verbose(msg, ...args) {
|
|
7500
|
+
this.log('verbose', msg, args);
|
|
7501
|
+
}
|
|
7340
7502
|
|
|
7341
|
-
|
|
7342
|
-
|
|
7503
|
+
info(msg, ...args) {
|
|
7504
|
+
this.log('info', msg, args);
|
|
7505
|
+
}
|
|
7343
7506
|
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
refreshToken,
|
|
7348
|
-
});
|
|
7507
|
+
warn(msg, ...args) {
|
|
7508
|
+
this.log('warn', msg, args);
|
|
7509
|
+
}
|
|
7349
7510
|
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7511
|
+
error(msg, ...args) {
|
|
7512
|
+
this.log('error', msg, args);
|
|
7513
|
+
}
|
|
7514
|
+
|
|
7515
|
+
success(msg, ...args) {
|
|
7516
|
+
this.log('success', msg, args);
|
|
7517
|
+
}
|
|
7518
|
+
|
|
7519
|
+
debug(msg, ...args) {
|
|
7520
|
+
this.log('debug', msg, args);
|
|
7521
|
+
}
|
|
7522
|
+
|
|
7523
|
+
log(level, msg, args) {
|
|
7524
|
+
const entry = this.formatEntry(level, msg, args);
|
|
7525
|
+
|
|
7526
|
+
if (this.fileStream) {
|
|
7527
|
+
try {
|
|
7528
|
+
this.fileStream.write(`${entry}\n`);
|
|
7529
|
+
} catch (e4) {
|
|
7530
|
+
if (!this.writeError && this.printToStderr) {
|
|
7531
|
+
process.stderr.write('Warning: Log write failed\n');
|
|
7532
|
+
this.writeError = true;
|
|
7533
|
+
}
|
|
7534
|
+
}
|
|
7535
|
+
}
|
|
7536
|
+
|
|
7537
|
+
if (this.printToStderr) {
|
|
7538
|
+
process.stderr.write(`${entry}\n`);
|
|
7358
7539
|
}
|
|
7359
7540
|
}
|
|
7360
7541
|
|
|
7361
|
-
|
|
7362
|
-
const
|
|
7542
|
+
formatEntry(level, msg, args) {
|
|
7543
|
+
const timestamp = new Date().toISOString();
|
|
7544
|
+
const delta = Date.now() - this.startTime;
|
|
7363
7545
|
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7546
|
+
if (this.format === 'json') {
|
|
7547
|
+
const entry = {
|
|
7548
|
+
level,
|
|
7549
|
+
timestamp,
|
|
7550
|
+
delta,
|
|
7551
|
+
...this.tags,
|
|
7552
|
+
message: msg,
|
|
7553
|
+
};
|
|
7554
|
+
if (args.length > 0) {
|
|
7555
|
+
entry.args = args;
|
|
7556
|
+
}
|
|
7557
|
+
return JSON.stringify(entry);
|
|
7558
|
+
}
|
|
7368
7559
|
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
}
|
|
7560
|
+
const tagsStr = Object.entries(this.tags)
|
|
7561
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
7562
|
+
.join(' ');
|
|
7563
|
+
const argsStr = args.length > 0 ? ` ${args.map(String).join(' ')}` : '';
|
|
7564
|
+
return `${level.toUpperCase().padEnd(7)} [${timestamp}] +${delta}ms ${tagsStr} ${msg}${argsStr}`;
|
|
7565
|
+
}
|
|
7566
|
+
|
|
7567
|
+
close() {
|
|
7568
|
+
if (this.fileStream) {
|
|
7569
|
+
try {
|
|
7570
|
+
this.fileStream.end();
|
|
7571
|
+
// eslint-disable-next-line @coze-arch/no-empty-catch
|
|
7572
|
+
} catch (e5) {
|
|
7573
|
+
// ignore close errors
|
|
7574
|
+
}
|
|
7575
|
+
}
|
|
7374
7576
|
}
|
|
7375
7577
|
}
|
|
7376
7578
|
|
|
@@ -7459,78 +7661,6 @@ function createContext(options) {
|
|
|
7459
7661
|
return context;
|
|
7460
7662
|
}
|
|
7461
7663
|
|
|
7462
|
-
function parseArgv(argv) {
|
|
7463
|
-
const globalOptions = {};
|
|
7464
|
-
let commandName;
|
|
7465
|
-
const commandArgs = [];
|
|
7466
|
-
let seenCommand = false;
|
|
7467
|
-
|
|
7468
|
-
for (let i = 0; i < argv.length; i++) {
|
|
7469
|
-
const token = argv[i];
|
|
7470
|
-
|
|
7471
|
-
if (token === '--help' || token === '-h') {
|
|
7472
|
-
globalOptions.help = true;
|
|
7473
|
-
continue;
|
|
7474
|
-
}
|
|
7475
|
-
if (token === '--version' || token === '-v') {
|
|
7476
|
-
globalOptions.version = true;
|
|
7477
|
-
continue;
|
|
7478
|
-
}
|
|
7479
|
-
if (token === '--output') {
|
|
7480
|
-
globalOptions.output = argv[++i];
|
|
7481
|
-
continue;
|
|
7482
|
-
}
|
|
7483
|
-
if (token === '--format') {
|
|
7484
|
-
const format = argv[++i];
|
|
7485
|
-
if (format === 'json' || format === 'text') {
|
|
7486
|
-
globalOptions.format = format;
|
|
7487
|
-
}
|
|
7488
|
-
continue;
|
|
7489
|
-
}
|
|
7490
|
-
if (token === '--no-color') {
|
|
7491
|
-
globalOptions.noColor = true;
|
|
7492
|
-
continue;
|
|
7493
|
-
}
|
|
7494
|
-
if (token === '--config') {
|
|
7495
|
-
globalOptions.config = argv[++i];
|
|
7496
|
-
continue;
|
|
7497
|
-
}
|
|
7498
|
-
if (token === '--org-id') {
|
|
7499
|
-
globalOptions.orgId = argv[++i];
|
|
7500
|
-
continue;
|
|
7501
|
-
}
|
|
7502
|
-
if (token === '--space-id') {
|
|
7503
|
-
globalOptions.spaceId = argv[++i];
|
|
7504
|
-
continue;
|
|
7505
|
-
}
|
|
7506
|
-
if (token === '--verbose') {
|
|
7507
|
-
globalOptions.verbose = true;
|
|
7508
|
-
continue;
|
|
7509
|
-
}
|
|
7510
|
-
if (token === '--debug') {
|
|
7511
|
-
globalOptions.debug = true;
|
|
7512
|
-
continue;
|
|
7513
|
-
}
|
|
7514
|
-
if (token === '--log-file') {
|
|
7515
|
-
globalOptions.logFile = argv[++i];
|
|
7516
|
-
continue;
|
|
7517
|
-
}
|
|
7518
|
-
if (token === '--print-logs') {
|
|
7519
|
-
globalOptions.printLogs = true;
|
|
7520
|
-
continue;
|
|
7521
|
-
}
|
|
7522
|
-
|
|
7523
|
-
if (!seenCommand && !token.startsWith('-')) {
|
|
7524
|
-
commandName = token;
|
|
7525
|
-
seenCommand = true;
|
|
7526
|
-
} else {
|
|
7527
|
-
commandArgs.push(token);
|
|
7528
|
-
}
|
|
7529
|
-
}
|
|
7530
|
-
|
|
7531
|
-
return { globalOptions, commandName, commandArgs };
|
|
7532
|
-
}
|
|
7533
|
-
|
|
7534
7664
|
async function loggerMiddleware(
|
|
7535
7665
|
context,
|
|
7536
7666
|
next,
|
|
@@ -16281,8 +16411,8 @@ async function listSpaces(options
|
|
|
16281
16411
|
});
|
|
16282
16412
|
|
|
16283
16413
|
return (_nullishCoalesce$d(_optionalChain$E([data, 'optionalAccess', _ => _.bot_space_list]), () => ( []))).map(sp => ({
|
|
16284
|
-
id: sp.id,
|
|
16285
|
-
name: sp.name,
|
|
16414
|
+
id: _nullishCoalesce$d(sp.id, () => ( '')),
|
|
16415
|
+
name: _nullishCoalesce$d(sp.name, () => ( '')),
|
|
16286
16416
|
org_id: _nullishCoalesce$d(options.orgId, () => ( '')),
|
|
16287
16417
|
}));
|
|
16288
16418
|
}
|
|
@@ -16301,7 +16431,7 @@ async function useSpace(spaceId) {
|
|
|
16301
16431
|
|
|
16302
16432
|
function _optionalChain$D(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
16303
16433
|
|
|
16304
|
-
const registerCommand$
|
|
16434
|
+
const registerCommand$b = (program) => {
|
|
16305
16435
|
const space = program
|
|
16306
16436
|
.command('space')
|
|
16307
16437
|
.config({
|
|
@@ -16461,7 +16591,7 @@ async function useOrganization(orgId)
|
|
|
16461
16591
|
function _optionalChain$C(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* eslint-disable max-lines-per-function */
|
|
16462
16592
|
|
|
16463
16593
|
|
|
16464
|
-
const registerCommand$
|
|
16594
|
+
const registerCommand$a = (program) => {
|
|
16465
16595
|
const organization = program
|
|
16466
16596
|
.command('organization')
|
|
16467
16597
|
.config({
|
|
@@ -17071,7 +17201,7 @@ const resolvePollingConfig = (
|
|
|
17071
17201
|
};
|
|
17072
17202
|
|
|
17073
17203
|
const downloadToBuffer = async (url) => {
|
|
17074
|
-
const resp = await index.customFetch(url);
|
|
17204
|
+
const resp = await index.customFetch.fetch(url);
|
|
17075
17205
|
if (!resp.ok) {
|
|
17076
17206
|
throw new index.CozeError(
|
|
17077
17207
|
`Failed to download generated resource: ${resp.status} ${resp.statusText}`,
|
|
@@ -19710,7 +19840,7 @@ const registerGenerateImageCommand = (
|
|
|
19710
19840
|
|
|
19711
19841
|
let buffer;
|
|
19712
19842
|
if (responseFormat === 'url') {
|
|
19713
|
-
const resp = await index.customFetch(item.url );
|
|
19843
|
+
const resp = await index.customFetch.fetch(item.url );
|
|
19714
19844
|
if (!resp.ok) {
|
|
19715
19845
|
throw new index.CozeError(
|
|
19716
19846
|
`Failed to download generated image: ${resp.status} ${resp.statusText}`,
|
|
@@ -20067,18 +20197,9 @@ const registerGenerateAudioCommand = (
|
|
|
20067
20197
|
|
|
20068
20198
|
const url = new URL('/api/v3/tts/unidirectional', apiBaseUrl);
|
|
20069
20199
|
url.searchParams.append('is_auth', 'false');
|
|
20070
|
-
|
|
20071
|
-
|
|
20072
|
-
'Content-Type': 'application/json',
|
|
20073
|
-
Accept: 'text/event-stream',
|
|
20074
|
-
};
|
|
20075
|
-
if (_optionalChain$w([ctx, 'optionalAccess', _11 => _11.config, 'access', _12 => _12.xTTEnv])) {
|
|
20076
|
-
headers['x-use-ppe'] = '1';
|
|
20077
|
-
headers['x-tt-env'] = _optionalChain$w([ctx, 'optionalAccess', _13 => _13.config, 'access', _14 => _14.xTTEnv]);
|
|
20078
|
-
}
|
|
20079
|
-
const resp = await index.customFetch(url.toString(), {
|
|
20200
|
+
|
|
20201
|
+
const resp = await index.customFetch.fetch(url.toString(), {
|
|
20080
20202
|
method: 'POST',
|
|
20081
|
-
headers,
|
|
20082
20203
|
body: JSON.stringify(req),
|
|
20083
20204
|
});
|
|
20084
20205
|
|
|
@@ -20183,7 +20304,7 @@ const registerGenerateAudioCommand = (
|
|
|
20183
20304
|
// - 若未拿到分片但有 final url,则下载落盘
|
|
20184
20305
|
if (outputPath) {
|
|
20185
20306
|
const format =
|
|
20186
|
-
_nullishCoalesce$8(_optionalChain$w([req, 'access',
|
|
20307
|
+
_nullishCoalesce$8(_optionalChain$w([req, 'access', _11 => _11.req_params, 'optionalAccess', _12 => _12.audio_params, 'optionalAccess', _13 => _13.format]), () => ( DEFAULT_FORMAT));
|
|
20187
20308
|
const ext =
|
|
20188
20309
|
format === 'pcm'
|
|
20189
20310
|
? '.pcm'
|
|
@@ -20208,7 +20329,7 @@ const registerGenerateAudioCommand = (
|
|
|
20208
20329
|
Buffer.concat(audioChunks),
|
|
20209
20330
|
);
|
|
20210
20331
|
} else if (finalAudioUrl) {
|
|
20211
|
-
const dlResp = await index.customFetch(finalAudioUrl);
|
|
20332
|
+
const dlResp = await index.customFetch.fetch(finalAudioUrl);
|
|
20212
20333
|
if (!dlResp.ok) {
|
|
20213
20334
|
throw new index.CozeError(
|
|
20214
20335
|
`Failed to download synthesized speech: ${dlResp.status} ${dlResp.statusText}`,
|
|
@@ -20235,7 +20356,7 @@ const registerGenerateAudioCommand = (
|
|
|
20235
20356
|
);
|
|
20236
20357
|
}
|
|
20237
20358
|
|
|
20238
|
-
if (_optionalChain$w([ctx, 'optionalAccess',
|
|
20359
|
+
if (_optionalChain$w([ctx, 'optionalAccess', _14 => _14.format]) === 'json') {
|
|
20239
20360
|
writeJsonOutput({
|
|
20240
20361
|
request: req,
|
|
20241
20362
|
url: finalAudioUrl,
|
|
@@ -20249,7 +20370,7 @@ const registerGenerateAudioCommand = (
|
|
|
20249
20370
|
}
|
|
20250
20371
|
|
|
20251
20372
|
// 不保存:默认输出最终 url(若服务端返回)
|
|
20252
|
-
if (_optionalChain$w([ctx, 'optionalAccess',
|
|
20373
|
+
if (_optionalChain$w([ctx, 'optionalAccess', _15 => _15.format]) === 'json') {
|
|
20253
20374
|
writeJsonOutput({ request: req, url: finalAudioUrl });
|
|
20254
20375
|
return;
|
|
20255
20376
|
}
|
|
@@ -20264,7 +20385,7 @@ const registerGenerateAudioCommand = (
|
|
|
20264
20385
|
);
|
|
20265
20386
|
} catch (error) {
|
|
20266
20387
|
if (error instanceof index.CozeError) {
|
|
20267
|
-
_optionalChain$w([ctx, 'optionalAccess',
|
|
20388
|
+
_optionalChain$w([ctx, 'optionalAccess', _16 => _16.ui, 'optionalAccess', _17 => _17.error, 'call', _18 => _18(error.message)]);
|
|
20268
20389
|
process.exit(error.code);
|
|
20269
20390
|
}
|
|
20270
20391
|
|
|
@@ -20612,7 +20733,7 @@ const registerListCommand$4 = (configCmd) => {
|
|
|
20612
20733
|
});
|
|
20613
20734
|
};
|
|
20614
20735
|
|
|
20615
|
-
const registerCommand$
|
|
20736
|
+
const registerCommand$9 = (program) => {
|
|
20616
20737
|
const configCmd = program
|
|
20617
20738
|
.command('config')
|
|
20618
20739
|
.description('Manage Coze CLI configuration')
|
|
@@ -20638,7 +20759,7 @@ const registerCommand$8 = (program) => {
|
|
|
20638
20759
|
|
|
20639
20760
|
let completionInstance;
|
|
20640
20761
|
|
|
20641
|
-
function registerCommand$
|
|
20762
|
+
function registerCommand$8(program) {
|
|
20642
20763
|
completionInstance = omelette('coze');
|
|
20643
20764
|
|
|
20644
20765
|
completionInstance.on('complete', (fragment, data) => {
|
|
@@ -20898,8 +21019,10 @@ function pickSkillIds(projectInfo) {
|
|
|
20898
21019
|
|
|
20899
21020
|
function registerListCommand$3(skill) {
|
|
20900
21021
|
skill
|
|
20901
|
-
.command('list
|
|
21022
|
+
.command('list')
|
|
20902
21023
|
.description('List skills added to the project')
|
|
21024
|
+
.requiredOption('-p, --project-id <projectId>', 'Project ID')
|
|
21025
|
+
.option('--space-id <spaceId>', 'Space ID (optional, reads from config)')
|
|
20903
21026
|
.config({
|
|
20904
21027
|
help: {
|
|
20905
21028
|
brief: 'List configured skills of the project',
|
|
@@ -20908,7 +21031,7 @@ function registerListCommand$3(skill) {
|
|
|
20908
21031
|
examples: [
|
|
20909
21032
|
{
|
|
20910
21033
|
desc: 'List project skills',
|
|
20911
|
-
cmd: 'coze code skill list <projectId>',
|
|
21034
|
+
cmd: 'coze code skill list --project-id <projectId>',
|
|
20912
21035
|
tags: ['[RECOMMENDED]'],
|
|
20913
21036
|
},
|
|
20914
21037
|
],
|
|
@@ -20955,7 +21078,6 @@ function registerListCommand$3(skill) {
|
|
|
20955
21078
|
],
|
|
20956
21079
|
},
|
|
20957
21080
|
})
|
|
20958
|
-
.option('--space-id <spaceId>', 'Space ID (optional, reads from config)')
|
|
20959
21081
|
.action(async function (
|
|
20960
21082
|
projectId,
|
|
20961
21083
|
options,
|
|
@@ -21135,7 +21257,7 @@ function registerAddCommand$2(skill) {
|
|
|
21135
21257
|
}
|
|
21136
21258
|
// end_aigc
|
|
21137
21259
|
|
|
21138
|
-
const registerCommand$
|
|
21260
|
+
const registerCommand$7 = (program) => {
|
|
21139
21261
|
const skill = program
|
|
21140
21262
|
.command('skill')
|
|
21141
21263
|
.config({
|
|
@@ -26303,6 +26425,21 @@ const intelligenceTypeToString = (
|
|
|
26303
26425
|
type,
|
|
26304
26426
|
) => INLLIGENCEIGENCE_TYPE_STRING_MAP[type];
|
|
26305
26427
|
|
|
26428
|
+
const VALID_INTELLIGENCE_TYPES = [
|
|
26429
|
+
IntelligenceType.VibeProjectAgent,
|
|
26430
|
+
IntelligenceType.VibeProjectAutomation,
|
|
26431
|
+
IntelligenceType.VibeProjectWebApp,
|
|
26432
|
+
IntelligenceType.VibeProjectApp,
|
|
26433
|
+
IntelligenceType.VibeProjectSkill,
|
|
26434
|
+
IntelligenceType.VibeProjectGeneralWeb,
|
|
26435
|
+
IntelligenceType.VibeProjectWechatMiniProgram,
|
|
26436
|
+
IntelligenceType.VibeProjectAssistantAgent,
|
|
26437
|
+
];
|
|
26438
|
+
|
|
26439
|
+
const VALID_INTELLIGENCE_TYPES_STRING = VALID_INTELLIGENCE_TYPES.map(
|
|
26440
|
+
intelligenceTypeToString,
|
|
26441
|
+
).filter(Boolean) ;
|
|
26442
|
+
|
|
26306
26443
|
function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$m(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* eslint-disable @coze-arch/max-line-per-function */
|
|
26307
26444
|
|
|
26308
26445
|
|
|
@@ -26371,7 +26508,7 @@ function registerListCommand$2(project) {
|
|
|
26371
26508
|
searchScope: {
|
|
26372
26509
|
type: 'number',
|
|
26373
26510
|
required: false,
|
|
26374
|
-
description: 'Created by',
|
|
26511
|
+
description: 'Created by (All = 0, CreateByMe = 1)',
|
|
26375
26512
|
},
|
|
26376
26513
|
folderId: {
|
|
26377
26514
|
type: 'string',
|
|
@@ -26381,7 +26518,7 @@ function registerListCommand$2(project) {
|
|
|
26381
26518
|
orderType: {
|
|
26382
26519
|
type: 'number',
|
|
26383
26520
|
required: false,
|
|
26384
|
-
description: 'Sort type',
|
|
26521
|
+
description: 'Sort type (0 for descending, 1 for ascending)',
|
|
26385
26522
|
},
|
|
26386
26523
|
isFavFilter: {
|
|
26387
26524
|
type: 'boolean',
|
|
@@ -26413,6 +26550,20 @@ function registerListCommand$2(project) {
|
|
|
26413
26550
|
fix: 'Please use --space-id <spaceId> or run `coze space use <spaceId>` first',
|
|
26414
26551
|
},
|
|
26415
26552
|
],
|
|
26553
|
+
enums: {
|
|
26554
|
+
type: VALID_INTELLIGENCE_TYPES_STRING.reduce((acc, cur) => {
|
|
26555
|
+
acc[cur] = `${cur.toUpperCase()} project`;
|
|
26556
|
+
return acc;
|
|
26557
|
+
}, {}),
|
|
26558
|
+
['search-scope']: {
|
|
26559
|
+
0: 'All',
|
|
26560
|
+
1: 'CreateByMe',
|
|
26561
|
+
},
|
|
26562
|
+
['order-type']: {
|
|
26563
|
+
0: 'Descending',
|
|
26564
|
+
1: 'Ascending',
|
|
26565
|
+
},
|
|
26566
|
+
},
|
|
26416
26567
|
},
|
|
26417
26568
|
})
|
|
26418
26569
|
.option('--size <size>', 'Number of projects to return', parseInt)
|
|
@@ -26424,10 +26575,7 @@ function registerListCommand$2(project) {
|
|
|
26424
26575
|
[],
|
|
26425
26576
|
)
|
|
26426
26577
|
.option('--name <name>', 'Filter by project name')
|
|
26427
|
-
.option(
|
|
26428
|
-
'--has-published <hasPublished>',
|
|
26429
|
-
'Filter by publish status (true | false)',
|
|
26430
|
-
)
|
|
26578
|
+
.option('--has-published', 'Filter by publish status')
|
|
26431
26579
|
.option(
|
|
26432
26580
|
'--search-scope <searchScope>',
|
|
26433
26581
|
'Created by (All = 0, CreateByMe = 1, AllWithCollaborator = 2)',
|
|
@@ -26437,10 +26585,7 @@ function registerListCommand$2(project) {
|
|
|
26437
26585
|
'--order-type <orderType>',
|
|
26438
26586
|
'Sort type (0 for descending, 1 for ascending)',
|
|
26439
26587
|
)
|
|
26440
|
-
.option(
|
|
26441
|
-
'--is-fav-filter <isFavFilter>',
|
|
26442
|
-
'Filter by favorite status (true | false)',
|
|
26443
|
-
)
|
|
26588
|
+
.option('--is-fav-filter', 'Filter by favorite status (true | false)')
|
|
26444
26589
|
.action(async function (options, cmd) {
|
|
26445
26590
|
const ctx = cmd.getContext();
|
|
26446
26591
|
const limit = _nullishCoalesce$5(_optionalChain$m([options, 'optionalAccess', _ => _.size]), () => ( 10));
|
|
@@ -26449,11 +26594,11 @@ function registerListCommand$2(project) {
|
|
|
26449
26594
|
, 'optionalAccess', _4 => _4.map, 'call', _5 => _5(resolveIntelligenceType)
|
|
26450
26595
|
, 'access', _6 => _6.filter, 'call', _7 => _7(Boolean)]) ;
|
|
26451
26596
|
const name = _optionalChain$m([options, 'optionalAccess', _8 => _8.name]);
|
|
26452
|
-
const hasPublished = _optionalChain$m([options, 'optionalAccess', _9 => _9.hasPublished]);
|
|
26453
|
-
const searchScope = _optionalChain$m([options, 'optionalAccess', _10 => _10.searchScope]);
|
|
26597
|
+
const hasPublished = Boolean(_optionalChain$m([options, 'optionalAccess', _9 => _9.hasPublished]));
|
|
26598
|
+
const searchScope = Number(_nullishCoalesce$5(_optionalChain$m([options, 'optionalAccess', _10 => _10.searchScope]), () => ( 0)));
|
|
26454
26599
|
const folderId = _optionalChain$m([options, 'optionalAccess', _11 => _11.folderId]);
|
|
26455
|
-
const orderType = _optionalChain$m([options, 'optionalAccess', _12 => _12.orderType]);
|
|
26456
|
-
const isFavFilter = _optionalChain$m([options, 'optionalAccess', _13 => _13.isFavFilter]);
|
|
26600
|
+
const orderType = Number(_nullishCoalesce$5(_optionalChain$m([options, 'optionalAccess', _12 => _12.orderType]), () => ( 0)));
|
|
26601
|
+
const isFavFilter = Boolean(_optionalChain$m([options, 'optionalAccess', _13 => _13.isFavFilter]));
|
|
26457
26602
|
|
|
26458
26603
|
let projects = [];
|
|
26459
26604
|
_optionalChain$m([ctx, 'optionalAccess', _14 => _14.ui, 'access', _15 => _15.info, 'call', _16 => _16('Fetching project list...')]);
|
|
@@ -26468,6 +26613,11 @@ function registerListCommand$2(project) {
|
|
|
26468
26613
|
folder_id: folderId,
|
|
26469
26614
|
order_type: orderType,
|
|
26470
26615
|
is_fav_filter: isFavFilter,
|
|
26616
|
+
status: [
|
|
26617
|
+
IntelligenceStatus.Using,
|
|
26618
|
+
IntelligenceStatus.Banned,
|
|
26619
|
+
IntelligenceStatus.MoveFailed,
|
|
26620
|
+
],
|
|
26471
26621
|
});
|
|
26472
26622
|
projects = _optionalChain$m([resp, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.intelligences]) || [];
|
|
26473
26623
|
|
|
@@ -26950,7 +27100,7 @@ function registerCreateCommand(projectCmd) {
|
|
|
26950
27100
|
}
|
|
26951
27101
|
// end_aigc
|
|
26952
27102
|
|
|
26953
|
-
const registerCommand$
|
|
27103
|
+
const registerCommand$6 = (program) => {
|
|
26954
27104
|
const project = program
|
|
26955
27105
|
.command('project')
|
|
26956
27106
|
.alias('proj')
|
|
@@ -38795,7 +38945,7 @@ const deployService = DeployService.getInstance();
|
|
|
38795
38945
|
function _optionalChain$f(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// start_aigc
|
|
38796
38946
|
|
|
38797
38947
|
|
|
38798
|
-
function registerCommand$
|
|
38948
|
+
function registerCommand$5(program) {
|
|
38799
38949
|
program
|
|
38800
38950
|
.command('preview <projectId>')
|
|
38801
38951
|
.description('Get deployment preview info for the project')
|
|
@@ -39721,7 +39871,7 @@ function registerRemoveCommand$1(envCmd) {
|
|
|
39721
39871
|
}
|
|
39722
39872
|
// end_aigc
|
|
39723
39873
|
|
|
39724
|
-
const registerCommand$
|
|
39874
|
+
const registerCommand$4 = (program) => {
|
|
39725
39875
|
const env = program
|
|
39726
39876
|
.command('env')
|
|
39727
39877
|
.config({
|
|
@@ -39986,7 +40136,7 @@ function registerAddCommand(domainCmd) {
|
|
|
39986
40136
|
});
|
|
39987
40137
|
}
|
|
39988
40138
|
|
|
39989
|
-
const registerCommand$
|
|
40139
|
+
const registerCommand$3 = (program) => {
|
|
39990
40140
|
const domain = program
|
|
39991
40141
|
.command('domain')
|
|
39992
40142
|
.config({
|
|
@@ -40166,7 +40316,7 @@ function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[
|
|
|
40166
40316
|
|
|
40167
40317
|
|
|
40168
40318
|
|
|
40169
|
-
function registerCommand$
|
|
40319
|
+
function registerCommand$2(program) {
|
|
40170
40320
|
const deploy = program
|
|
40171
40321
|
.command('deploy <projectId>')
|
|
40172
40322
|
.option('--wait', 'Wait for deployment to complete')
|
|
@@ -40414,18 +40564,18 @@ function registerAllCommands$1(program) {
|
|
|
40414
40564
|
});
|
|
40415
40565
|
|
|
40416
40566
|
registerMessageCommand(code);
|
|
40417
|
-
registerCommand$1(code);
|
|
40418
|
-
registerCommand$5(code);
|
|
40419
|
-
registerCommand$3(code);
|
|
40420
40567
|
registerCommand$2(code);
|
|
40421
40568
|
registerCommand$6(code);
|
|
40422
40569
|
registerCommand$4(code);
|
|
40570
|
+
registerCommand$3(code);
|
|
40571
|
+
registerCommand$7(code);
|
|
40572
|
+
registerCommand$5(code);
|
|
40423
40573
|
}
|
|
40424
40574
|
|
|
40425
40575
|
function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* eslint-disable max-lines-per-function */
|
|
40426
40576
|
|
|
40427
40577
|
|
|
40428
|
-
function registerCommand(program) {
|
|
40578
|
+
function registerCommand$1(program) {
|
|
40429
40579
|
const auth = program
|
|
40430
40580
|
.command('auth')
|
|
40431
40581
|
.description('Manage user authentication and credentials')
|
|
@@ -40593,24 +40743,149 @@ function registerCommand(program) {
|
|
|
40593
40743
|
});
|
|
40594
40744
|
}
|
|
40595
40745
|
|
|
40746
|
+
function detectPackageManager() {
|
|
40747
|
+
const checks = [
|
|
40748
|
+
{ pm: 'npm', cmd: 'npm ls -g @coze/cli --json 2>/dev/null' },
|
|
40749
|
+
{ pm: 'pnpm', cmd: 'pnpm ls -g @coze/cli --json 2>/dev/null' },
|
|
40750
|
+
{ pm: 'yarn', cmd: 'yarn global list --json 2>/dev/null' },
|
|
40751
|
+
];
|
|
40752
|
+
|
|
40753
|
+
for (const { pm, cmd } of checks) {
|
|
40754
|
+
try {
|
|
40755
|
+
const output = node_child_process.execSync(cmd, {
|
|
40756
|
+
encoding: 'utf8',
|
|
40757
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
40758
|
+
});
|
|
40759
|
+
if (output.includes('@coze/cli')) {
|
|
40760
|
+
return pm;
|
|
40761
|
+
}
|
|
40762
|
+
// eslint-disable-next-line @coze-arch/no-empty-catch -- package manager detection failure is expected
|
|
40763
|
+
} catch (_error) {
|
|
40764
|
+
/* noop */
|
|
40765
|
+
}
|
|
40766
|
+
}
|
|
40767
|
+
|
|
40768
|
+
return 'npm';
|
|
40769
|
+
}
|
|
40770
|
+
|
|
40771
|
+
function getInstallCommand(
|
|
40772
|
+
packageManager,
|
|
40773
|
+
tag,
|
|
40774
|
+
) {
|
|
40775
|
+
switch (packageManager) {
|
|
40776
|
+
case 'pnpm':
|
|
40777
|
+
return `pnpm add -g @coze/cli@${tag}`;
|
|
40778
|
+
case 'yarn':
|
|
40779
|
+
return `yarn global add @coze/cli@${tag}`;
|
|
40780
|
+
case 'npm':
|
|
40781
|
+
default:
|
|
40782
|
+
return `npm install -g @coze/cli@${tag}`;
|
|
40783
|
+
}
|
|
40784
|
+
}
|
|
40785
|
+
|
|
40786
|
+
function registerCommand(program) {
|
|
40787
|
+
program
|
|
40788
|
+
.command('upgrade')
|
|
40789
|
+
.description('Upgrade Coze CLI to the latest version')
|
|
40790
|
+
.config({
|
|
40791
|
+
skipAuth: true,
|
|
40792
|
+
skipOrgCheck: true,
|
|
40793
|
+
skipSpaceCheck: true,
|
|
40794
|
+
help: {
|
|
40795
|
+
brief: 'Upgrade CLI to latest version',
|
|
40796
|
+
description:
|
|
40797
|
+
'Check for the latest version of Coze CLI and upgrade if a newer version is available. Detects the package manager used for the original installation (npm/pnpm/yarn) and runs the appropriate global install command.',
|
|
40798
|
+
examples: [
|
|
40799
|
+
{
|
|
40800
|
+
desc: 'Upgrade to latest version',
|
|
40801
|
+
cmd: 'coze upgrade',
|
|
40802
|
+
tags: ['[RECOMMENDED]'],
|
|
40803
|
+
},
|
|
40804
|
+
{
|
|
40805
|
+
desc: 'Force check and upgrade',
|
|
40806
|
+
cmd: 'coze upgrade --force',
|
|
40807
|
+
},
|
|
40808
|
+
{
|
|
40809
|
+
desc: 'Upgrade to a specific tag',
|
|
40810
|
+
cmd: 'coze upgrade --tag beta',
|
|
40811
|
+
},
|
|
40812
|
+
],
|
|
40813
|
+
seeAlso: ['coze --version'],
|
|
40814
|
+
},
|
|
40815
|
+
})
|
|
40816
|
+
.option('--force', 'Force upgrade even if already on the latest version')
|
|
40817
|
+
.option('--tag <tag>', 'Specify the dist-tag to upgrade to', 'latest')
|
|
40818
|
+
.action(async (options, cmd) => {
|
|
40819
|
+
const ctx = cmd.getContext();
|
|
40820
|
+
if (!ctx) {
|
|
40821
|
+
process.exit(index.ExitCode.GENERAL_ERROR);
|
|
40822
|
+
}
|
|
40823
|
+
|
|
40824
|
+
ctx.ui.info('Checking for updates...');
|
|
40825
|
+
|
|
40826
|
+
try {
|
|
40827
|
+
const result = await checkForUpdates(ctx, true, options.tag);
|
|
40828
|
+
|
|
40829
|
+
if (!result.hasUpdate && !options.force) {
|
|
40830
|
+
ctx.ui.success(
|
|
40831
|
+
`You are already on the latest version (${result.currentVersion}).`,
|
|
40832
|
+
);
|
|
40833
|
+
return;
|
|
40834
|
+
}
|
|
40835
|
+
|
|
40836
|
+
if (result.hasUpdate) {
|
|
40837
|
+
ctx.ui.info(
|
|
40838
|
+
`New version available: ${chalk.gray(result.currentVersion)} → ${chalk.green(result.latestVersion)}`,
|
|
40839
|
+
);
|
|
40840
|
+
}
|
|
40841
|
+
|
|
40842
|
+
ctx.ui.info('Upgrading Coze CLI...');
|
|
40843
|
+
|
|
40844
|
+
const packageManager = detectPackageManager();
|
|
40845
|
+
const installCmd = getInstallCommand(packageManager, options.tag);
|
|
40846
|
+
|
|
40847
|
+
ctx.ui.verbose(`Using package manager: ${packageManager}`);
|
|
40848
|
+
ctx.ui.verbose(`Running: ${installCmd}`);
|
|
40849
|
+
|
|
40850
|
+
node_child_process.execSync(installCmd, { stdio: 'inherit' });
|
|
40851
|
+
|
|
40852
|
+
const newVersion = getCurrentVersion();
|
|
40853
|
+
ctx.ui.success(
|
|
40854
|
+
`Successfully upgraded Coze CLI to ${result.latestVersion}. (was ${result.currentVersion})`,
|
|
40855
|
+
);
|
|
40856
|
+
|
|
40857
|
+
if (ctx.format === 'json') {
|
|
40858
|
+
ctx.response.print({
|
|
40859
|
+
previousVersion: result.currentVersion,
|
|
40860
|
+
currentVersion: newVersion,
|
|
40861
|
+
latestVersion: result.latestVersion,
|
|
40862
|
+
status: 'upgraded',
|
|
40863
|
+
});
|
|
40864
|
+
}
|
|
40865
|
+
} catch (error) {
|
|
40866
|
+
ctx.ui.error(`Failed to upgrade: ${(error ).message}`);
|
|
40867
|
+
ctx.ui.info(
|
|
40868
|
+
'You can try upgrading manually with: npm install -g @coze/cli',
|
|
40869
|
+
);
|
|
40870
|
+
process.exit(index.ExitCode.GENERAL_ERROR);
|
|
40871
|
+
}
|
|
40872
|
+
});
|
|
40873
|
+
}
|
|
40874
|
+
|
|
40596
40875
|
function registerAllCommands(program) {
|
|
40597
|
-
registerCommand(program);
|
|
40598
|
-
registerCommand$
|
|
40876
|
+
registerCommand$1(program);
|
|
40877
|
+
registerCommand$8(program);
|
|
40599
40878
|
registerAllCommands$1(program);
|
|
40600
40879
|
registerFileCommands(program);
|
|
40880
|
+
registerCommand$b(program);
|
|
40601
40881
|
registerCommand$a(program);
|
|
40602
|
-
registerCommand$9(program);
|
|
40603
40882
|
registerGenerateCommands(program);
|
|
40604
|
-
registerCommand$
|
|
40883
|
+
registerCommand$9(program);
|
|
40884
|
+
registerCommand(program);
|
|
40605
40885
|
|
|
40606
|
-
// Initialize auto-completion after all commands are registered
|
|
40607
40886
|
initCompletion();
|
|
40608
40887
|
}
|
|
40609
40888
|
|
|
40610
|
-
var version = "0.1.0-alpha.5aabeb";
|
|
40611
|
-
const packageJson = {
|
|
40612
|
-
version: version};
|
|
40613
|
-
|
|
40614
40889
|
function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
40615
40890
|
|
|
40616
40891
|
|
|
@@ -41266,6 +41541,78 @@ async function buildAndRunProgram(ctx) {
|
|
|
41266
41541
|
}
|
|
41267
41542
|
}
|
|
41268
41543
|
|
|
41544
|
+
function parseArgv(argv) {
|
|
41545
|
+
const globalOptions = {};
|
|
41546
|
+
let commandName;
|
|
41547
|
+
const commandArgs = [];
|
|
41548
|
+
let seenCommand = false;
|
|
41549
|
+
|
|
41550
|
+
for (let i = 0; i < argv.length; i++) {
|
|
41551
|
+
const token = argv[i];
|
|
41552
|
+
|
|
41553
|
+
if (token === '--help' || token === '-h') {
|
|
41554
|
+
globalOptions.help = true;
|
|
41555
|
+
continue;
|
|
41556
|
+
}
|
|
41557
|
+
if (token === '--version' || token === '-v') {
|
|
41558
|
+
globalOptions.version = true;
|
|
41559
|
+
continue;
|
|
41560
|
+
}
|
|
41561
|
+
if (token === '--output') {
|
|
41562
|
+
globalOptions.output = argv[++i];
|
|
41563
|
+
continue;
|
|
41564
|
+
}
|
|
41565
|
+
if (token === '--format') {
|
|
41566
|
+
const format = argv[++i];
|
|
41567
|
+
if (format === 'json' || format === 'text') {
|
|
41568
|
+
globalOptions.format = format;
|
|
41569
|
+
}
|
|
41570
|
+
continue;
|
|
41571
|
+
}
|
|
41572
|
+
if (token === '--no-color') {
|
|
41573
|
+
globalOptions.noColor = true;
|
|
41574
|
+
continue;
|
|
41575
|
+
}
|
|
41576
|
+
if (token === '--config') {
|
|
41577
|
+
globalOptions.config = argv[++i];
|
|
41578
|
+
continue;
|
|
41579
|
+
}
|
|
41580
|
+
if (token === '--org-id') {
|
|
41581
|
+
globalOptions.orgId = argv[++i];
|
|
41582
|
+
continue;
|
|
41583
|
+
}
|
|
41584
|
+
if (token === '--space-id') {
|
|
41585
|
+
globalOptions.spaceId = argv[++i];
|
|
41586
|
+
continue;
|
|
41587
|
+
}
|
|
41588
|
+
if (token === '--verbose') {
|
|
41589
|
+
globalOptions.verbose = true;
|
|
41590
|
+
continue;
|
|
41591
|
+
}
|
|
41592
|
+
if (token === '--debug') {
|
|
41593
|
+
globalOptions.debug = true;
|
|
41594
|
+
continue;
|
|
41595
|
+
}
|
|
41596
|
+
if (token === '--log-file') {
|
|
41597
|
+
globalOptions.logFile = argv[++i];
|
|
41598
|
+
continue;
|
|
41599
|
+
}
|
|
41600
|
+
if (token === '--print-logs') {
|
|
41601
|
+
globalOptions.printLogs = true;
|
|
41602
|
+
continue;
|
|
41603
|
+
}
|
|
41604
|
+
|
|
41605
|
+
if (!seenCommand && !token.startsWith('-')) {
|
|
41606
|
+
commandName = token;
|
|
41607
|
+
seenCommand = true;
|
|
41608
|
+
} else {
|
|
41609
|
+
commandArgs.push(token);
|
|
41610
|
+
}
|
|
41611
|
+
}
|
|
41612
|
+
|
|
41613
|
+
return { globalOptions, commandName, commandArgs };
|
|
41614
|
+
}
|
|
41615
|
+
|
|
41269
41616
|
async function main() {
|
|
41270
41617
|
const argv = process.argv.slice(2);
|
|
41271
41618
|
const { globalOptions } = parseArgv(argv);
|
|
@@ -41281,7 +41628,11 @@ async function main() {
|
|
|
41281
41628
|
await buildAndRunProgram(context);
|
|
41282
41629
|
};
|
|
41283
41630
|
|
|
41284
|
-
const composed = compose([
|
|
41631
|
+
const composed = compose([
|
|
41632
|
+
proxyMiddleware,
|
|
41633
|
+
requestMiddleware,
|
|
41634
|
+
updateCheckMiddleware,
|
|
41635
|
+
]);
|
|
41285
41636
|
await composed(context, coreHandler);
|
|
41286
41637
|
}
|
|
41287
41638
|
|