@lark-apaas/miaoda-cli 0.1.3 → 0.1.4-alpha.abaa17f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/app/api.js +3 -3
- package/dist/api/app/schemas.js +43 -43
- package/dist/api/db/api.js +398 -55
- package/dist/api/db/client.js +155 -28
- package/dist/api/db/index.js +12 -1
- package/dist/api/db/parsers.js +20 -20
- package/dist/api/db/sql-keywords.js +87 -87
- package/dist/api/deploy/api.js +5 -5
- package/dist/api/deploy/index.js +12 -1
- package/dist/api/deploy/modern-types.js +23 -0
- package/dist/api/deploy/modern.js +70 -0
- package/dist/api/deploy/plugin-instances-types.js +6 -0
- package/dist/api/deploy/plugin-instances.js +30 -0
- package/dist/api/deploy/schemas.js +32 -32
- package/dist/api/file/api.js +89 -87
- package/dist/api/file/client.js +62 -22
- package/dist/api/file/detect.js +3 -3
- package/dist/api/file/index.js +2 -1
- package/dist/api/file/parsers.js +18 -7
- package/dist/api/observability/api.js +6 -6
- package/dist/api/observability/schemas.js +14 -14
- package/dist/api/plugin/api.js +31 -31
- package/dist/cli/commands/app/index.js +94 -13
- package/dist/cli/commands/db/index.js +602 -54
- package/dist/cli/commands/deploy/index.js +28 -28
- package/dist/cli/commands/deploy/modern.js +48 -0
- package/dist/cli/commands/file/index.js +85 -58
- package/dist/cli/commands/index.js +31 -5
- package/dist/cli/commands/observability/index.js +69 -69
- package/dist/cli/commands/plugin/index.js +27 -27
- package/dist/cli/commands/shared.js +10 -10
- package/dist/cli/handlers/app/index.js +6 -1
- package/dist/cli/handlers/app/init.js +86 -0
- package/dist/cli/handlers/app/update.js +2 -2
- package/dist/cli/handlers/db/_destructive.js +67 -0
- package/dist/cli/handlers/db/_env.js +26 -0
- package/dist/cli/handlers/db/_operator.js +35 -0
- package/dist/cli/handlers/db/audit.js +383 -0
- package/dist/cli/handlers/db/changelog.js +160 -0
- package/dist/cli/handlers/db/data.js +32 -31
- package/dist/cli/handlers/db/index.js +17 -1
- package/dist/cli/handlers/db/migration.js +234 -0
- package/dist/cli/handlers/db/quota.js +68 -0
- package/dist/cli/handlers/db/recovery.js +413 -0
- package/dist/cli/handlers/db/schema.js +33 -33
- package/dist/cli/handlers/db/sql.js +69 -69
- package/dist/cli/handlers/deploy/deploy.js +4 -4
- package/dist/cli/handlers/deploy/error-log.js +1 -1
- package/dist/cli/handlers/deploy/get.js +3 -3
- package/dist/cli/handlers/deploy/modern.js +32 -0
- package/dist/cli/handlers/deploy/polling.js +11 -11
- package/dist/cli/handlers/file/cp.js +30 -30
- package/dist/cli/handlers/file/index.js +3 -1
- package/dist/cli/handlers/file/ls.js +5 -5
- package/dist/cli/handlers/file/quota.js +66 -0
- package/dist/cli/handlers/file/rm.js +32 -30
- package/dist/cli/handlers/file/sign.js +3 -3
- package/dist/cli/handlers/file/stat.js +10 -9
- package/dist/cli/handlers/observability/analytics.js +47 -47
- package/dist/cli/handlers/observability/helpers.js +2 -2
- package/dist/cli/handlers/observability/log.js +9 -9
- package/dist/cli/handlers/observability/metric.js +26 -26
- package/dist/cli/handlers/observability/trace.js +5 -5
- package/dist/cli/handlers/plugin/plugin-local.js +53 -53
- package/dist/cli/handlers/plugin/plugin.js +15 -15
- package/dist/cli/help.js +16 -16
- package/dist/main.js +12 -12
- package/dist/services/app/init/index.js +14 -0
- package/dist/services/app/init/install.js +101 -0
- package/dist/services/app/init/steering.js +74 -0
- package/dist/services/app/init/template.js +85 -0
- package/dist/services/deploy/modern/atoms/build.js +54 -0
- package/dist/services/deploy/modern/atoms/context.js +30 -0
- package/dist/services/deploy/modern/atoms/index.js +17 -0
- package/dist/services/deploy/modern/atoms/local-release.js +27 -0
- package/dist/services/deploy/modern/atoms/pre-release.js +13 -0
- package/dist/services/deploy/modern/atoms/save-plugin-instances.js +72 -0
- package/dist/services/deploy/modern/atoms/upload.js +192 -0
- package/dist/services/deploy/modern/check.js +58 -0
- package/dist/services/deploy/modern/constants.js +13 -0
- package/dist/services/deploy/modern/index.js +16 -0
- package/dist/services/deploy/modern/pipelines/index.js +5 -0
- package/dist/services/deploy/modern/pipelines/local.js +75 -0
- package/dist/services/deploy/modern/protocol.js +43 -0
- package/dist/services/deploy/modern/run-types.js +4 -0
- package/dist/services/deploy/modern/run.js +13 -0
- package/dist/services/deploy/modern/template-key-map.js +29 -0
- package/dist/utils/args.js +1 -1
- package/dist/utils/colors.js +2 -2
- package/dist/utils/config.js +2 -2
- package/dist/utils/devops-error.js +9 -9
- package/dist/utils/error.js +2 -2
- package/dist/utils/git.js +4 -4
- package/dist/utils/http.js +27 -21
- package/dist/utils/index.js +3 -1
- package/dist/utils/npm-pack.js +55 -0
- package/dist/utils/output.js +67 -45
- package/dist/utils/poll.js +35 -0
- package/dist/utils/render.js +27 -27
- package/dist/utils/spark-meta.js +48 -0
- package/dist/utils/spinner.js +46 -0
- package/dist/utils/time.js +47 -42
- package/package.json +1 -1
package/dist/api/deploy/index.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
|
|
3
|
+
exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.batchSavePluginInstances = exports.LocalReleaseStatus = exports.getModernLastPublishedVersion = exports.getModernReleaseStatus = exports.createModernRelease = exports.updateLocalRelease = exports.createLocalRelease = exports.preRelease = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
|
|
4
4
|
var api_1 = require("./api");
|
|
5
5
|
Object.defineProperty(exports, "createRelease", { enumerable: true, get: function () { return api_1.createRelease; } });
|
|
6
6
|
Object.defineProperty(exports, "listPipelineInstances", { enumerable: true, get: function () { return api_1.listPipelineInstances; } });
|
|
7
7
|
Object.defineProperty(exports, "getErrorLog", { enumerable: true, get: function () { return api_1.getErrorLog; } });
|
|
8
8
|
Object.defineProperty(exports, "queryPipelineInstance", { enumerable: true, get: function () { return api_1.queryPipelineInstance; } });
|
|
9
|
+
var modern_1 = require("./modern");
|
|
10
|
+
Object.defineProperty(exports, "preRelease", { enumerable: true, get: function () { return modern_1.preRelease; } });
|
|
11
|
+
Object.defineProperty(exports, "createLocalRelease", { enumerable: true, get: function () { return modern_1.createLocalRelease; } });
|
|
12
|
+
Object.defineProperty(exports, "updateLocalRelease", { enumerable: true, get: function () { return modern_1.updateLocalRelease; } });
|
|
13
|
+
Object.defineProperty(exports, "createModernRelease", { enumerable: true, get: function () { return modern_1.createRelease; } });
|
|
14
|
+
Object.defineProperty(exports, "getModernReleaseStatus", { enumerable: true, get: function () { return modern_1.getReleaseStatus; } });
|
|
15
|
+
Object.defineProperty(exports, "getModernLastPublishedVersion", { enumerable: true, get: function () { return modern_1.getLastPublishedVersion; } });
|
|
16
|
+
var modern_types_1 = require("./modern-types");
|
|
17
|
+
Object.defineProperty(exports, "LocalReleaseStatus", { enumerable: true, get: function () { return modern_types_1.LocalReleaseStatus; } });
|
|
18
|
+
var plugin_instances_1 = require("./plugin-instances");
|
|
19
|
+
Object.defineProperty(exports, "batchSavePluginInstances", { enumerable: true, get: function () { return plugin_instances_1.batchSavePluginInstances; } });
|
|
9
20
|
var schemas_1 = require("./schemas");
|
|
10
21
|
Object.defineProperty(exports, "deployHistorySchema", { enumerable: true, get: function () { return schemas_1.deployHistorySchema; } });
|
|
11
22
|
Object.defineProperty(exports, "deployGetSchema", { enumerable: true, get: function () { return schemas_1.deployGetSchema; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// modern deploy 接口的请求 / 响应类型(与服务端发布编排接口对齐)。
|
|
3
|
+
// 第一期落地的链路:本地构建 + 本地部署。
|
|
4
|
+
//
|
|
5
|
+
// 接口分两类:
|
|
6
|
+
// - preRelease:所有"本地构建"链路共用,签发动态配置(含 pre-signed TOS upload URL)
|
|
7
|
+
// - localPublish:本地构建 + 本地部署专用(createReleaseLocalPublish + updateReleaseLocalPublish)
|
|
8
|
+
//
|
|
9
|
+
// 远端部署链路(B/C)所需的 release 接口先预留类型骨架,待 B/C 落地时启用。
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.LocalReleaseStatus = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* localPublish 状态枚举(数值,与服务端 IDL 对齐)。
|
|
14
|
+
* CLI updateLocalRelease 只翻 Finished / Failed 两个终态;其它由后端流转。
|
|
15
|
+
*/
|
|
16
|
+
exports.LocalReleaseStatus = {
|
|
17
|
+
Unspecified: 0,
|
|
18
|
+
Publishing: 1,
|
|
19
|
+
Finished: 2,
|
|
20
|
+
Failed: 3,
|
|
21
|
+
Canceled: 4,
|
|
22
|
+
Rollback: 5,
|
|
23
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// modern deploy 接口客户端。统一走管理端 innerapi(postInnerApi 信封解析)。
|
|
3
|
+
//
|
|
4
|
+
// 第一期落地(本地构建 + 本地部署):
|
|
5
|
+
// - preRelease:拿 pre_release_id + version + 动态配置 data
|
|
6
|
+
// - createLocalRelease / updateLocalRelease:完整本地部署生命周期
|
|
7
|
+
//
|
|
8
|
+
// 远端部署(本地构建+远端部署、远端构建+远端部署)需要 createRelease + getReleaseStatus,
|
|
9
|
+
// 后续 commit 接入;本文件已预留 endpoint 骨架但暂不导出。
|
|
10
|
+
//
|
|
11
|
+
// 约定:所有接口的 appID 走 URL :appID 路径参数,body 不再冗余携带 appID。
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.preRelease = preRelease;
|
|
14
|
+
exports.createLocalRelease = createLocalRelease;
|
|
15
|
+
exports.updateLocalRelease = updateLocalRelease;
|
|
16
|
+
exports.createRelease = createRelease;
|
|
17
|
+
exports.getReleaseStatus = getReleaseStatus;
|
|
18
|
+
exports.getLastPublishedVersion = getLastPublishedVersion;
|
|
19
|
+
const http_1 = require("../../utils/http");
|
|
20
|
+
const devops_error_1 = require("../../utils/devops-error");
|
|
21
|
+
const DEFAULT_ERR_CODE = 'INTERNAL_DEVOPS_ERROR';
|
|
22
|
+
function envelopeOpts(errPrefix) {
|
|
23
|
+
// modern deploy 接口与 default deploy / app 走同一个 lark.apaas.devops PSM,
|
|
24
|
+
// 业务错误码命名空间共享,直接复用 mapDevopsError 把 BAM 码翻为 AppError。
|
|
25
|
+
return {
|
|
26
|
+
errPrefix,
|
|
27
|
+
defaultErrCode: DEFAULT_ERR_CODE,
|
|
28
|
+
mapErr: devops_error_1.mapDevopsError,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// ── preRelease ──
|
|
32
|
+
/** POST /v1/devops/app/:appID/pre_release */
|
|
33
|
+
async function preRelease(req) {
|
|
34
|
+
const { appID, ...body } = req;
|
|
35
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/pre_release`;
|
|
36
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to pre-release'));
|
|
37
|
+
}
|
|
38
|
+
// ── localPublish ──
|
|
39
|
+
/** POST /v1/devops/app/:appID/local_publish/release */
|
|
40
|
+
async function createLocalRelease(req) {
|
|
41
|
+
const { appID, ...body } = req;
|
|
42
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/local_publish/release`;
|
|
43
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to create local release'));
|
|
44
|
+
}
|
|
45
|
+
/** POST /v1/devops/app/:appID/local_publish/update_release */
|
|
46
|
+
async function updateLocalRelease(req) {
|
|
47
|
+
const { appID, ...body } = req;
|
|
48
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/local_publish/update_release`;
|
|
49
|
+
await (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to update local release'));
|
|
50
|
+
}
|
|
51
|
+
// ── release(远端部署,B / C 链路;本期不导出,类型骨架已就绪) ──
|
|
52
|
+
/** POST /v1/devops/app/:appID/remote_publish/release */
|
|
53
|
+
async function createRelease(req) {
|
|
54
|
+
const { appID, ...body } = req;
|
|
55
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/remote_publish/release`;
|
|
56
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to create release'));
|
|
57
|
+
}
|
|
58
|
+
/** POST /v1/devops/app/:appID/release/status */
|
|
59
|
+
async function getReleaseStatus(req) {
|
|
60
|
+
const { appID, ...body } = req;
|
|
61
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/release/status`;
|
|
62
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to query release status'));
|
|
63
|
+
}
|
|
64
|
+
// ── getLastPublishedVersion(URL path 待文档补充) ──
|
|
65
|
+
/** POST /v1/devops/app/:appID/last_published_version(path 待后端确认) */
|
|
66
|
+
async function getLastPublishedVersion(req) {
|
|
67
|
+
const { appID } = req;
|
|
68
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/last_published_version`;
|
|
69
|
+
return (0, http_1.postInnerApi)(url, {}, envelopeOpts('Failed to get last published version'));
|
|
70
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// studio_server 的 plugin_instances 批量保存接口。
|
|
3
|
+
// 与 modern deploy 其余接口(走 devops PSM、InnerEnvelope)信封不同,
|
|
4
|
+
// 这里走 studio_server PSM、BaseResp 信封,故自行解析。
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.batchSavePluginInstances = batchSavePluginInstances;
|
|
7
|
+
const http_1 = require("../../utils/http");
|
|
8
|
+
const error_1 = require("../../utils/error");
|
|
9
|
+
const URL_PATH = '/api/v1/studio/innerapi/plugin_instances/batch_save';
|
|
10
|
+
/**
|
|
11
|
+
* POST /api/v1/studio/innerapi/plugin_instances/batch_save
|
|
12
|
+
*
|
|
13
|
+
* 把发布版本的 capability 集合注册到 studio_server。
|
|
14
|
+
* 失败时抛 AppError("DEPLOY_PLUGIN_BATCH_SAVE_FAILED"),带 BaseResp 错误信息。
|
|
15
|
+
*/
|
|
16
|
+
async function batchSavePluginInstances(req) {
|
|
17
|
+
const response = await (0, http_1.getHttpClient)().post(URL_PATH, req);
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new error_1.HttpError(response.status, URL_PATH, `Failed to save plugin instances: ${String(response.status)} ${response.statusText}`);
|
|
20
|
+
}
|
|
21
|
+
const body = (await response.json());
|
|
22
|
+
const baseResp = body.BaseResp;
|
|
23
|
+
if (baseResp?.StatusCode !== 0) {
|
|
24
|
+
const msg = baseResp?.StatusMessage ?? baseResp?.KStatusMessage ?? 'unknown error';
|
|
25
|
+
const code = baseResp?.KStatusCode !== undefined && baseResp.KStatusCode !== ''
|
|
26
|
+
? baseResp.KStatusCode
|
|
27
|
+
: String(baseResp?.StatusCode ?? 'unknown');
|
|
28
|
+
throw new error_1.AppError('DEPLOY_PLUGIN_BATCH_SAVE_FAILED', `Failed to save plugin instances: status_code=${code} message=${msg}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -6,18 +6,18 @@ exports.nodeStatusFromText = nodeStatusFromText;
|
|
|
6
6
|
const output_1 = require("../../utils/output");
|
|
7
7
|
const types_1 = require("./types");
|
|
8
8
|
const NODE_STATUS_TEXT = {
|
|
9
|
-
[types_1.NodeStatus.UNSPECIFIED]:
|
|
10
|
-
[types_1.NodeStatus.TODO]:
|
|
11
|
-
[types_1.NodeStatus.RUNNING]:
|
|
12
|
-
[types_1.NodeStatus.SUCCESS]:
|
|
13
|
-
[types_1.NodeStatus.FAILED]:
|
|
14
|
-
[types_1.NodeStatus.CANCELED]:
|
|
15
|
-
[types_1.NodeStatus.HOLD_ON]:
|
|
9
|
+
[types_1.NodeStatus.UNSPECIFIED]: 'unknown',
|
|
10
|
+
[types_1.NodeStatus.TODO]: 'todo',
|
|
11
|
+
[types_1.NodeStatus.RUNNING]: 'running',
|
|
12
|
+
[types_1.NodeStatus.SUCCESS]: 'success',
|
|
13
|
+
[types_1.NodeStatus.FAILED]: 'failed',
|
|
14
|
+
[types_1.NodeStatus.CANCELED]: 'canceled',
|
|
15
|
+
[types_1.NodeStatus.HOLD_ON]: 'hold_on',
|
|
16
16
|
};
|
|
17
17
|
function nodeStatusText(v) {
|
|
18
|
-
if (typeof v ===
|
|
18
|
+
if (typeof v === 'string')
|
|
19
19
|
return v;
|
|
20
|
-
if (typeof v !==
|
|
20
|
+
if (typeof v !== 'number')
|
|
21
21
|
return undefined;
|
|
22
22
|
return NODE_STATUS_TEXT[v];
|
|
23
23
|
}
|
|
@@ -46,17 +46,17 @@ function pipelineDurationMs(row) {
|
|
|
46
46
|
*/
|
|
47
47
|
exports.deployHistorySchema = {
|
|
48
48
|
columns: [
|
|
49
|
-
{ key:
|
|
49
|
+
{ key: 'ID', label: 'deploy-id' },
|
|
50
50
|
{
|
|
51
|
-
key:
|
|
52
|
-
label:
|
|
51
|
+
key: 'status_text',
|
|
52
|
+
label: 'status',
|
|
53
53
|
derive: (row) => nodeStatusText(row.status),
|
|
54
54
|
},
|
|
55
|
-
{ key:
|
|
56
|
-
{ key:
|
|
55
|
+
{ key: 'creator', label: 'creator' },
|
|
56
|
+
{ key: 'createdAt', label: 'created-at', format: output_1.fmt.ms() },
|
|
57
57
|
{
|
|
58
|
-
key:
|
|
59
|
-
label:
|
|
58
|
+
key: 'duration',
|
|
59
|
+
label: 'duration',
|
|
60
60
|
format: output_1.fmt.durationMs(),
|
|
61
61
|
derive: pipelineDurationMs,
|
|
62
62
|
},
|
|
@@ -71,35 +71,35 @@ exports.deployHistorySchema = {
|
|
|
71
71
|
*/
|
|
72
72
|
exports.deployGetSchema = {
|
|
73
73
|
columns: [
|
|
74
|
-
{ key:
|
|
74
|
+
{ key: 'ID', label: 'deploy-id' },
|
|
75
75
|
{
|
|
76
|
-
key:
|
|
77
|
-
label:
|
|
76
|
+
key: 'status_text',
|
|
77
|
+
label: 'status',
|
|
78
78
|
derive: (row) => nodeStatusText(row.status),
|
|
79
79
|
},
|
|
80
|
-
{ key:
|
|
81
|
-
{ key:
|
|
82
|
-
{ key:
|
|
83
|
-
{ key:
|
|
80
|
+
{ key: 'creator', label: 'creator' },
|
|
81
|
+
{ key: 'updater', label: 'updater' },
|
|
82
|
+
{ key: 'createdAt', label: 'created-at', format: output_1.fmt.ms() },
|
|
83
|
+
{ key: 'updatedAt', label: 'updated-at', format: output_1.fmt.ms() },
|
|
84
84
|
{
|
|
85
|
-
key:
|
|
86
|
-
label:
|
|
85
|
+
key: 'duration',
|
|
86
|
+
label: 'duration',
|
|
87
87
|
format: output_1.fmt.durationMs(),
|
|
88
88
|
derive: pipelineDurationMs,
|
|
89
89
|
},
|
|
90
|
-
{ key:
|
|
91
|
-
{ key:
|
|
92
|
-
{ key:
|
|
93
|
-
{ key:
|
|
90
|
+
{ key: 'templateID', label: 'template' },
|
|
91
|
+
{ key: 'description' },
|
|
92
|
+
{ key: 'parameters' },
|
|
93
|
+
{ key: 'envVariables', label: 'env-vars' },
|
|
94
94
|
],
|
|
95
95
|
strict: true,
|
|
96
96
|
};
|
|
97
97
|
/** deploy error-log 表格渲染契约 */
|
|
98
98
|
exports.errorJobSchema = {
|
|
99
99
|
columns: [
|
|
100
|
-
{ key:
|
|
101
|
-
{ key:
|
|
102
|
-
{ key:
|
|
100
|
+
{ key: 'jobID', label: 'job-id' },
|
|
101
|
+
{ key: 'componentName', label: 'component' },
|
|
102
|
+
{ key: 'errorMsg', label: 'error' },
|
|
103
103
|
],
|
|
104
104
|
strict: true,
|
|
105
105
|
};
|