digitalsee-ai-flow-cli 0.2.1 → 0.6.15-beta
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/.github/workflows/publish.yml +1 -0
- package/README.md +285 -17
- package/dist/api/link.d.ts.map +1 -1
- package/dist/api/link.js +4 -0
- package/dist/api/link.js.map +1 -1
- package/dist/api/mapping.d.ts.map +1 -0
- package/dist/api/mapping.js +95 -0
- package/dist/api/mapping.js.map +1 -0
- package/dist/api/node.d.ts.map +1 -1
- package/dist/api/node.js +4 -0
- package/dist/api/node.js.map +1 -1
- package/dist/api/org.d.ts.map +1 -0
- package/dist/api/org.js +21 -0
- package/dist/api/org.js.map +1 -0
- package/dist/commands/flow/list.d.ts.map +1 -1
- package/dist/commands/flow/list.js +13 -1
- package/dist/commands/flow/list.js.map +1 -1
- package/dist/commands/flow/mapping.d.ts.map +1 -0
- package/dist/commands/flow/mapping.js +734 -0
- package/dist/commands/flow/mapping.js.map +1 -0
- package/dist/commands/flow/node.d.ts.map +1 -1
- package/dist/commands/flow/node.js +108 -8
- package/dist/commands/flow/node.js.map +1 -1
- package/dist/commands/flow/test.d.ts.map +1 -1
- package/dist/commands/flow/test.js +0 -30
- package/dist/commands/flow/test.js.map +1 -1
- package/dist/commands/flow/update.d.ts.map +1 -1
- package/dist/commands/flow/update.js +31 -5
- package/dist/commands/flow/update.js.map +1 -1
- package/dist/commands/flow.d.ts.map +1 -1
- package/dist/commands/flow.js +2 -0
- package/dist/commands/flow.js.map +1 -1
- package/dist/commands/link/account-linking.d.ts.map +1 -0
- package/dist/commands/link/account-linking.js +123 -0
- package/dist/commands/link/account-linking.js.map +1 -0
- package/dist/commands/link/check-mapping.d.ts.map +1 -0
- package/dist/commands/link/check-mapping.js +37 -0
- package/dist/commands/link/check-mapping.js.map +1 -0
- package/dist/commands/link/create.d.ts.map +1 -1
- package/dist/commands/link/create.js +22 -4
- package/dist/commands/link/create.js.map +1 -1
- package/dist/commands/link.d.ts.map +1 -1
- package/dist/commands/link.js +4 -0
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/org.d.ts.map +1 -0
- package/dist/commands/org.js +248 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/sync/check-mapping.d.ts.map +1 -0
- package/dist/commands/sync/check-mapping.js +37 -0
- package/dist/commands/sync/check-mapping.js.map +1 -0
- package/dist/commands/sync/create.d.ts.map +1 -1
- package/dist/commands/sync/create.js +22 -4
- package/dist/commands/sync/create.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +2 -0
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/org.d.ts.map +1 -0
- package/dist/types/org.js +5 -0
- package/dist/types/org.js.map +1 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +23 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +4 -0
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/updateCheck.d.ts.map +1 -1
- package/dist/utils/updateCheck.js +9 -0
- package/dist/utils/updateCheck.js.map +1 -1
- package/package.json +1 -1
- package/dist/api/dip.d.ts.map +0 -1
- package/dist/api/dip.js +0 -14
- package/dist/api/dip.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerLinkAccountLinking = registerLinkAccountLinking;
|
|
4
|
+
const mapping_1 = require("@/api/mapping");
|
|
5
|
+
const link_1 = require("@/api/link");
|
|
6
|
+
const output_1 = require("@/utils/output");
|
|
7
|
+
function extractUpstreamFields(profile) {
|
|
8
|
+
const orgAndUser = profile.org_and_user_profile || {};
|
|
9
|
+
const userProfile = orgAndUser.user_profile || {};
|
|
10
|
+
return {
|
|
11
|
+
name: userProfile.name || '',
|
|
12
|
+
fields: userProfile.sub_params || [],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function extractIdaaFields(profile) {
|
|
16
|
+
return {
|
|
17
|
+
name: profile.name || '',
|
|
18
|
+
fields: profile.sub_params || [],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function cleanFieldForJson(field) {
|
|
22
|
+
const out = { name: field.name };
|
|
23
|
+
if (field.display_name)
|
|
24
|
+
out.display_name = field.display_name;
|
|
25
|
+
if (field.type)
|
|
26
|
+
out.type = field.type;
|
|
27
|
+
if (field.value_type)
|
|
28
|
+
out.value_type = field.value_type;
|
|
29
|
+
if (field.source_exp)
|
|
30
|
+
out.source_exp = field.source_exp;
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
function formatQualifiedName(field, name) {
|
|
34
|
+
if (field.source_exp)
|
|
35
|
+
return field.source_exp;
|
|
36
|
+
if (field.value_type === 'JS_EXP' && field.name)
|
|
37
|
+
return `${name}.${field.name}`;
|
|
38
|
+
return field.name || '-';
|
|
39
|
+
}
|
|
40
|
+
function renderUpstreamTable(name, fields) {
|
|
41
|
+
if (fields.length === 0) {
|
|
42
|
+
(0, output_1.printWarning)('上游连接器字段: 无可用字段');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const label = name
|
|
46
|
+
? `上游连接器字段: ${name} (${fields.length} 个字段)`
|
|
47
|
+
: `上游连接器字段 (${fields.length} 个字段)`;
|
|
48
|
+
(0, output_1.printSubHeader)(label);
|
|
49
|
+
const headers = ['字段名', '显示名', 'EXP', '类型'];
|
|
50
|
+
const rows = fields.map((f) => [
|
|
51
|
+
f.name || '-',
|
|
52
|
+
f.display_name || f.name || '-',
|
|
53
|
+
formatQualifiedName(f, name),
|
|
54
|
+
String(f.type || f.value_type || '-'),
|
|
55
|
+
]);
|
|
56
|
+
(0, output_1.printTable)(headers, rows);
|
|
57
|
+
}
|
|
58
|
+
function renderIdaaTable(name, fields) {
|
|
59
|
+
if (fields.length === 0) {
|
|
60
|
+
(0, output_1.printWarning)('IDAAS 账号关联字段: 无可用字段');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const label = name
|
|
64
|
+
? `IDAAS 账号关联字段: ${name} (${fields.length} 个字段)`
|
|
65
|
+
: `IDAAS 账号关联字段 (${fields.length} 个字段)`;
|
|
66
|
+
(0, output_1.printSubHeader)(label);
|
|
67
|
+
const headers = ['字段名', '显示名', '类型'];
|
|
68
|
+
const rows = fields.map((f) => [
|
|
69
|
+
f.name || '-',
|
|
70
|
+
f.display_name || f.name || '-',
|
|
71
|
+
String(f.type || f.value_type || '-'),
|
|
72
|
+
]);
|
|
73
|
+
(0, output_1.printTable)(headers, rows);
|
|
74
|
+
}
|
|
75
|
+
function registerLinkAccountLinking(linkCmd) {
|
|
76
|
+
const accountCmd = linkCmd.command('account-linking').description('账号关联设置');
|
|
77
|
+
accountCmd
|
|
78
|
+
.command('show <flowId>')
|
|
79
|
+
.description('展示账号关联可选配置')
|
|
80
|
+
.option('--json', '以 JSON 格式输出')
|
|
81
|
+
.action(async (flowId, options) => {
|
|
82
|
+
try {
|
|
83
|
+
if (options.json)
|
|
84
|
+
(0, output_1.setJsonMode)(true);
|
|
85
|
+
const [upstreamProfile, idaasProfile] = await Promise.all([
|
|
86
|
+
(0, mapping_1.fetchProfileData)(flowId, 'CONNECTOR'),
|
|
87
|
+
(0, link_1.getUserLinkingProfile)(),
|
|
88
|
+
]);
|
|
89
|
+
const upstream = extractUpstreamFields(upstreamProfile);
|
|
90
|
+
const idaas = extractIdaaFields(idaasProfile);
|
|
91
|
+
if (options.json) {
|
|
92
|
+
(0, output_1.printStructuredResult)({
|
|
93
|
+
ok: true,
|
|
94
|
+
flowId,
|
|
95
|
+
upstream: {
|
|
96
|
+
name: upstream.name,
|
|
97
|
+
fields: upstream.fields.map((f) => ({
|
|
98
|
+
...cleanFieldForJson(f),
|
|
99
|
+
exp: formatQualifiedName(f, upstream.name),
|
|
100
|
+
})),
|
|
101
|
+
},
|
|
102
|
+
idaas: {
|
|
103
|
+
name: idaas.name,
|
|
104
|
+
fields: idaas.fields.map(cleanFieldForJson),
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
(0, output_1.printHeader)(`账号关联配置 (Flow: ${flowId})`);
|
|
110
|
+
renderUpstreamTable(upstream.name, upstream.fields);
|
|
111
|
+
renderIdaaTable(idaas.name, idaas.fields);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (options.json) {
|
|
115
|
+
(0, output_1.printStructuredResult)({ ok: false, message: error.message });
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
(0, output_1.printError)(`获取账号关联配置失败: ${error.message}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=account-linking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-linking.js","sourceRoot":"","sources":["../../../src/commands/link/account-linking.ts"],"names":[],"mappings":";;AA+FA,gEAiDC;AA/ID,2CAAiD;AACjD,qCAAmD;AACnD,2CAQwB;AAUxB,SAAS,qBAAqB,CAAC,OAAgC;IAI7D,MAAM,UAAU,GAAI,OAAO,CAAC,oBAAgD,IAAI,EAAE,CAAC;IACnF,MAAM,WAAW,GAAI,UAAU,CAAC,YAAwC,IAAI,EAAE,CAAC;IAC/E,OAAO;QACL,IAAI,EAAG,WAAW,CAAC,IAAe,IAAI,EAAE;QACxC,MAAM,EAAG,WAAW,CAAC,UAA0B,IAAI,EAAE;KACtD,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAgC;IAIzD,OAAO;QACL,IAAI,EAAG,OAAO,CAAC,IAAe,IAAI,EAAE;QACpC,MAAM,EAAG,OAAO,CAAC,UAA0B,IAAI,EAAE;KAClD,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAgB;IACzC,M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EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpD,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,IAAA,8BAAqB,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,IAAA,mBAAU,EAAC,eAAgB,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-mapping.d.ts","sourceRoot":"","sources":["../../../src/commands/link/check-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6B/D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerLinkCheckMapping = registerLinkCheckMapping;
|
|
4
|
+
const mapping_1 = require("@/api/mapping");
|
|
5
|
+
const output_1 = require("@/utils/output");
|
|
6
|
+
function registerLinkCheckMapping(linkCmd) {
|
|
7
|
+
linkCmd
|
|
8
|
+
.command('check-mapping <flowId>')
|
|
9
|
+
.description('检查映射是否已配置')
|
|
10
|
+
.option('--json', '以 JSON 格式输出')
|
|
11
|
+
.action(async (flowId, options) => {
|
|
12
|
+
try {
|
|
13
|
+
if (options.json)
|
|
14
|
+
(0, output_1.setJsonMode)(true);
|
|
15
|
+
const configured = await (0, mapping_1.checkMappingStatus)(flowId);
|
|
16
|
+
if (options.json) {
|
|
17
|
+
(0, output_1.printStructuredResult)({ ok: true, configured, flowId });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (configured) {
|
|
21
|
+
(0, output_1.printSuccess)(`Flow ${flowId}: 映射已配置`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
(0, output_1.printWarning)(`Flow ${flowId}: 映射未配置`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (options.json) {
|
|
29
|
+
(0, output_1.printStructuredResult)({ ok: false, message: error.message });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
(0, output_1.printError)(`检查映射状态失败: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=check-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-mapping.js","sourceRoot":"","sources":["../../../src/commands/link/check-mapping.ts"],"names":[],"mappings":";;AAUA,4DA6BC;AAtCD,2CAAmD;AACnD,2CAMwB;AAExB,SAAgB,wBAAwB,CAAC,OAAgB;IACvD,OAAO;SACJ,OAAO,CAAC,wBAAwB,CAAC;SACjC,WAAW,CAAC,WAAW,CAAC;SACxB,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC;SAC/B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAChC,IAAI,CAAC;YACH,IAAI,OAAO,CAAC,IAAI;gBAAE,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;YAEpC,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAkB,EAAC,MAAM,CAAC,CAAC;YAEpD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,IAAA,8BAAqB,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;gBACxD,OAAO;YACT,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,IAAA,qBAAY,EAAC,QAAQ,MAAM,SAAS,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,IAAA,qBAAY,EAAC,QAAQ,MAAM,SAAS,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,IAAA,8BAAqB,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,IAAA,mBAAU,EAAC,aAAc,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/link/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/link/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoDzD"}
|
|
@@ -11,19 +11,32 @@ function registerLinkCreate(linkCmd) {
|
|
|
11
11
|
.requiredOption('--type <ds_type>', '连接器类型,可通过 link list 查看可选值')
|
|
12
12
|
.option('--name <name>', '连接器名称')
|
|
13
13
|
.option('--reset', '创建后自动套用预设模板')
|
|
14
|
+
.option('--json', '以 JSON 格式输出')
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
try {
|
|
17
|
+
if (options.json)
|
|
18
|
+
(0, output_1.setJsonMode)(true);
|
|
16
19
|
const { type, name, reset } = options;
|
|
17
20
|
const tpl = templates_1.LINK_FLOW_TEMPLATES.find((t) => t.ds_type === type);
|
|
18
21
|
if (!tpl) {
|
|
19
|
-
(
|
|
20
|
-
|
|
22
|
+
if (options.json) {
|
|
23
|
+
(0, output_1.printStructuredResult)({ ok: false, message: `无效的连接器类型: ${type}` });
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
(0, output_1.printError)(`无效的连接器类型: ${type}`);
|
|
27
|
+
(0, output_1.printInfo)('使用 ai-flow link list 查看可选类型');
|
|
28
|
+
}
|
|
21
29
|
return;
|
|
22
30
|
}
|
|
23
31
|
(0, output_1.printInfo)(`正在创建上游连接器: ${tpl.name} (${type})`);
|
|
24
32
|
const result = (await (0, link_1.createLinkConnector)({ flow: 1, ds_type: type, name }));
|
|
25
33
|
const id = typeof result === 'object' && result !== null ? result.id || '-' : result;
|
|
26
|
-
(
|
|
34
|
+
if (options.json) {
|
|
35
|
+
(0, output_1.printStructuredResult)({ ok: true, id: String(id), message: `上游连接器创建成功` });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
(0, output_1.printSuccess)(`上游连接器创建成功,ID: ${id}`);
|
|
39
|
+
}
|
|
27
40
|
if (reset && id !== '-') {
|
|
28
41
|
(0, output_1.printInfo)('正在套用预设模板...');
|
|
29
42
|
await (0, link_1.resetLinkFlow)(String(id));
|
|
@@ -31,7 +44,12 @@ function registerLinkCreate(linkCmd) {
|
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
catch (error) {
|
|
34
|
-
(
|
|
47
|
+
if (options.json) {
|
|
48
|
+
(0, output_1.printStructuredResult)({ ok: false, message: error.message });
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
(0, output_1.printError)(`创建上游连接器失败: ${error.message}`);
|
|
52
|
+
}
|
|
35
53
|
}
|
|
36
54
|
});
|
|
37
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/link/create.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../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ot":"","sources":["../../src/commands/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAU1D"}
|
package/dist/commands/link.js
CHANGED
|
@@ -6,6 +6,8 @@ const templates_cmd_1 = require("@/commands/link/templates-cmd");
|
|
|
6
6
|
const create_1 = require("@/commands/link/create");
|
|
7
7
|
const reset_1 = require("@/commands/link/reset");
|
|
8
8
|
const log_1 = require("@/commands/link/log");
|
|
9
|
+
const account_linking_1 = require("@/commands/link/account-linking");
|
|
10
|
+
const check_mapping_1 = require("@/commands/link/check-mapping");
|
|
9
11
|
function registerLinkCommand(program) {
|
|
10
12
|
const linkCmd = program.command('link').description('身份上游自动化(通讯录集成)');
|
|
11
13
|
(0, list_1.registerLinkList)(linkCmd);
|
|
@@ -13,5 +15,7 @@ function registerLinkCommand(program) {
|
|
|
13
15
|
(0, create_1.registerLinkCreate)(linkCmd);
|
|
14
16
|
(0, reset_1.registerLinkReset)(linkCmd);
|
|
15
17
|
(0, log_1.registerLinkLog)(linkCmd);
|
|
18
|
+
(0, account_linking_1.registerLinkAccountLinking)(linkCmd);
|
|
19
|
+
(0, check_mapping_1.registerLinkCheckMapping)(linkCmd);
|
|
16
20
|
}
|
|
17
21
|
//# sourceMappingURL=link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../src/commands/link.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../src/commands/link.ts"],"names":[],"mappings":";;AASA,kDAUC;AAlBD,+CAAwD;AACxD,iEAAsE;AACtE,mDAA4D;AAC5D,iDAA0D;AAC1D,6CAAsD;AACtD,qEAA6E;AAC7E,iEAAyE;AAEzE,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAEtE,IAAA,uBAAgB,EAAC,OAAO,CAAC,CAAC;IAC1B,IAAA,qCAAqB,EAAC,OAAO,CAAC,CAAC;IAC/B,IAAA,2BAAkB,EAAC,OAAO,CAAC,CAAC;IAC5B,IAAA,yBAAiB,EAAC,OAAO,CAAC,CAAC;IAC3B,IAAA,qBAAe,EAAC,OAAO,CAAC,CAAC;IACzB,IAAA,4CAA0B,EAAC,OAAO,CAAC,CAAC;IACpC,IAAA,wCAAwB,EAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.d.ts","sourceRoot":"","sources":["../../src/commands/org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoDpC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+MzD"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.registerOrgCommand = registerOrgCommand;
|
|
40
|
+
const readline = __importStar(require("readline"));
|
|
41
|
+
const org_1 = require("@/api/org");
|
|
42
|
+
const org_2 = require("@/types/org");
|
|
43
|
+
const output_1 = require("@/utils/output");
|
|
44
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
+
function flattenNodes(nodes, depth) {
|
|
46
|
+
const result = [];
|
|
47
|
+
for (const n of nodes) {
|
|
48
|
+
result.push({
|
|
49
|
+
id: n.id,
|
|
50
|
+
name: n.name,
|
|
51
|
+
hasChildren: !!n.has_children,
|
|
52
|
+
depth,
|
|
53
|
+
readonly: !!n.readonly,
|
|
54
|
+
entitled: !!n.entitled,
|
|
55
|
+
description: n.description,
|
|
56
|
+
});
|
|
57
|
+
if (n.children && n.children.length > 0) {
|
|
58
|
+
result.push(...flattenNodes(n.children, depth + 1));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
async function question(rl, query) {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
rl.question(query, (answer) => {
|
|
66
|
+
resolve(answer);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function registerOrgCommand(program) {
|
|
71
|
+
const orgCmd = program.command('org').description('组织架构操作');
|
|
72
|
+
const treeCmd = orgCmd.command('tree').description('组织树操作');
|
|
73
|
+
// ---- list ----
|
|
74
|
+
treeCmd
|
|
75
|
+
.command('list')
|
|
76
|
+
.description('列出组织树节点(默认从根节点开始)')
|
|
77
|
+
.option('--id <orgId>', '起始组织 ID,默认为根节点')
|
|
78
|
+
.option('--depth <number>', '递归深度,0=全部,1=仅直接子节点', '1')
|
|
79
|
+
.option('--json', '以 JSON 格式输出')
|
|
80
|
+
.action(async (options) => {
|
|
81
|
+
try {
|
|
82
|
+
if (options.json)
|
|
83
|
+
(0, output_1.setJsonMode)(true);
|
|
84
|
+
const orgId = options.id || org_2.ROOT_ORG_ID;
|
|
85
|
+
const depth = Number(options.depth);
|
|
86
|
+
const nodes = await (0, org_1.getOrgSubs)(orgId, { depth });
|
|
87
|
+
if (options.json) {
|
|
88
|
+
(0, output_1.printJson)(nodes);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
(0, output_1.printHeader)(`组织节点 (orgId: ${orgId}, depth: ${depth})`);
|
|
92
|
+
if (!nodes || nodes.length === 0) {
|
|
93
|
+
(0, output_1.printInfo)('无子节点');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const rows = flattenNodes(nodes, 0);
|
|
97
|
+
const headers = ['ID', '名称', '描述', '子节点', '只读'];
|
|
98
|
+
const tableRows = rows.map((n) => [
|
|
99
|
+
n.id,
|
|
100
|
+
' '.repeat(n.depth) + n.name,
|
|
101
|
+
(n.description || '-').substring(0, 40),
|
|
102
|
+
n.hasChildren ? '有' : '无',
|
|
103
|
+
n.readonly ? '是' : '否',
|
|
104
|
+
]);
|
|
105
|
+
(0, output_1.printTable)(headers, tableRows);
|
|
106
|
+
(0, output_1.printInfo)(`共 ${rows.length} 个节点`);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (options.json) {
|
|
110
|
+
(0, output_1.printStructuredResult)({ ok: false, message: error.message });
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
(0, output_1.printError)(`获取组织树失败: ${error.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
// ---- search ----
|
|
118
|
+
treeCmd
|
|
119
|
+
.command('search <keyword>')
|
|
120
|
+
.description('按名称搜索组织节点')
|
|
121
|
+
.option('--json', '以 JSON 格式输出')
|
|
122
|
+
.action(async (keyword, options) => {
|
|
123
|
+
try {
|
|
124
|
+
if (options.json)
|
|
125
|
+
(0, output_1.setJsonMode)(true);
|
|
126
|
+
const nodes = await (0, org_1.getOrgSubs)(org_2.ROOT_ORG_ID, { depth: 0, orgName: keyword });
|
|
127
|
+
if (options.json) {
|
|
128
|
+
(0, output_1.printJson)(nodes);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!nodes || nodes.length === 0) {
|
|
132
|
+
(0, output_1.printInfo)(`未找到匹配 "${keyword}" 的组织`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
(0, output_1.printHeader)(`搜索结果: "${keyword}" (共 ${nodes.length} 个)`);
|
|
136
|
+
const headers = ['ID', '名称', '描述'];
|
|
137
|
+
const rows = nodes.map((n) => [n.id, n.name, (n.description || '-').substring(0, 60)]);
|
|
138
|
+
(0, output_1.printTable)(headers, rows);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (options.json) {
|
|
142
|
+
(0, output_1.printStructuredResult)({ ok: false, message: error.message });
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
(0, output_1.printError)(`搜索组织失败: ${error.message}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
// ---- select (interactive, human-only) ----
|
|
150
|
+
treeCmd
|
|
151
|
+
.command('select')
|
|
152
|
+
.description('交互式浏览并选择组织节点')
|
|
153
|
+
.option('--id <orgId>', '起始组织 ID,默认为根节点')
|
|
154
|
+
.action(async (options) => {
|
|
155
|
+
const startId = options.id || org_2.ROOT_ORG_ID;
|
|
156
|
+
const state = {
|
|
157
|
+
currentId: startId,
|
|
158
|
+
breadcrumb: [],
|
|
159
|
+
};
|
|
160
|
+
const rl = readline.createInterface({
|
|
161
|
+
input: process.stdin,
|
|
162
|
+
output: process.stderr,
|
|
163
|
+
});
|
|
164
|
+
try {
|
|
165
|
+
while (true) {
|
|
166
|
+
const nodes = await (0, org_1.getOrgSubs)(state.currentId, { depth: 1 });
|
|
167
|
+
// Use stderr for navigation UI
|
|
168
|
+
console.error(chalk_1.default.bold.cyan('\n========================================'));
|
|
169
|
+
console.error(chalk_1.default.bold.cyan(' 组织树选择器'));
|
|
170
|
+
console.error(chalk_1.default.bold.cyan('========================================\n'));
|
|
171
|
+
const crumbPath = state.breadcrumb.map((b) => b.name).join(' / ');
|
|
172
|
+
console.error(` 当前位置: ${chalk_1.default.bold(state.currentId === org_2.ROOT_ORG_ID ? '[根节点]' : crumbPath || state.currentId)} (${chalk_1.default.gray(state.currentId)})\n`);
|
|
173
|
+
if (!nodes || nodes.length === 0) {
|
|
174
|
+
console.error(chalk_1.default.yellow(' (此节点下无子节点)'));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
nodes.forEach((node, i) => {
|
|
178
|
+
const icon = node.has_children ? chalk_1.default.blue('[+]') : chalk_1.default.green(' * ');
|
|
179
|
+
const readonlyTag = node.readonly ? chalk_1.default.gray(' [只读]') : '';
|
|
180
|
+
console.error(` ${chalk_1.default.cyan(String(i + 1).padStart(3))}. ${icon} ${chalk_1.default.white(node.name)}${readonlyTag}`);
|
|
181
|
+
if (node.description) {
|
|
182
|
+
console.error(` ${chalk_1.default.gray(node.description)}`);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const prompt = state.breadcrumb.length > 0
|
|
187
|
+
? `\n 路径: ${chalk_1.default.cyan(state.breadcrumb.map((b) => b.name).join(' / '))}\n`
|
|
188
|
+
: '';
|
|
189
|
+
const answer = await question(rl, `${prompt} 输入编号选择/进入, 直接回车选中当前, 'b' 返回上级, 'q' 退出: `);
|
|
190
|
+
const trimmed = answer.trim().toLowerCase();
|
|
191
|
+
if (trimmed === 'q') {
|
|
192
|
+
console.error(chalk_1.default.yellow('已取消选择'));
|
|
193
|
+
process.exit(0);
|
|
194
|
+
}
|
|
195
|
+
if (trimmed === 'b') {
|
|
196
|
+
if (state.breadcrumb.length === 0) {
|
|
197
|
+
console.error(chalk_1.default.yellow('已在根节点'));
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const prev = state.breadcrumb.pop();
|
|
201
|
+
state.currentId = prev.id;
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
// Empty input = select current node
|
|
205
|
+
if (trimmed === '') {
|
|
206
|
+
const metaResult = await (0, org_1.getOrgMeta)([state.currentId]);
|
|
207
|
+
const meta = metaResult[0];
|
|
208
|
+
const fullPath = state.breadcrumb.map((b) => b.name).join(' / ');
|
|
209
|
+
const result = {
|
|
210
|
+
id: state.currentId,
|
|
211
|
+
name: meta?.name || state.currentId,
|
|
212
|
+
path: fullPath || meta?.name || state.currentId,
|
|
213
|
+
};
|
|
214
|
+
console.log(JSON.stringify(result));
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const idx = parseInt(trimmed, 10);
|
|
218
|
+
if (isNaN(idx) || idx < 1 || idx > (nodes?.length ?? 0)) {
|
|
219
|
+
console.error(chalk_1.default.red(` 无效输入,请输入 1-${nodes?.length ?? 0} 之间的数字`));
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const selected = nodes[idx - 1];
|
|
223
|
+
if (selected.has_children) {
|
|
224
|
+
state.breadcrumb.push({ id: state.currentId, name: selected.name });
|
|
225
|
+
state.currentId = selected.id;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
const fullPath = [...state.breadcrumb.map((b) => b.name), selected.name].join(' / ');
|
|
229
|
+
const result = {
|
|
230
|
+
id: selected.id,
|
|
231
|
+
name: selected.name,
|
|
232
|
+
path: fullPath,
|
|
233
|
+
};
|
|
234
|
+
console.log(JSON.stringify(result));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
(0, output_1.printError)(`选择组织失败: ${error.message}`);
|
|
241
|
+
process.exitCode = 1;
|
|
242
|
+
}
|
|
243
|
+
finally {
|
|
244
|
+
rl.close();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=org.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.js","sourceRoot":"","sources":["../../src/commands/org.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,gDA+MC;AAlQD,mDAAqC;AACrC,mCAAmD;AACnD,qCAAqE;AACrE,2CAQwB;AACxB,kDAA0B;AAY1B,SAAS,YAAY,CAAC,KAAoB,EAAE,KAAa;IACvD,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY;YAC7B,KAAK;YACL,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ;YACtB,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ;YACtB,WAAW,EAAE,CAAC,CAAC,WAAW;SAC3B,CAAC,CAAC;QACH,IAAI,CA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AC,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;oBACpE,KAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,EAAE,CAAC;gBAChC,CAAC;qBAAM,CAAC;oBACN,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACrF,MAAM,MAAM,GAAiB;wBAC3B,EAAE,EAAE,QAAQ,CAAC,EAAE;wBACf,IAAI,EAAE,QAAQ,CAAC,IAAI;wBACnB,IAAI,EAAE,QAAQ;qBACf,CAAC;oBACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;oBACpC,OAAO;gBACT,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAA,mBAAU,EAAC,WAAY,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAClD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-mapping.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/check-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6B/D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSyncCheckMapping = registerSyncCheckMapping;
|
|
4
|
+
const mapping_1 = require("@/api/mapping");
|
|
5
|
+
const output_1 = require("@/utils/output");
|
|
6
|
+
function registerSyncCheckMapping(syncCmd) {
|
|
7
|
+
syncCmd
|
|
8
|
+
.command('check-mapping <flowId>')
|
|
9
|
+
.description('检查映射是否已配置')
|
|
10
|
+
.option('--json', '以 JSON 格式输出')
|
|
11
|
+
.action(async (flowId, options) => {
|
|
12
|
+
try {
|
|
13
|
+
if (options.json)
|
|
14
|
+
(0, output_1.setJsonMode)(true);
|
|
15
|
+
const configured = await (0, mapping_1.checkMappingStatus)(flowId);
|
|
16
|
+
if (options.json) {
|
|
17
|
+
(0, output_1.printStructuredResult)({ ok: true, configured, flowId });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (configured) {
|
|
21
|
+
(0, output_1.printSuccess)(`Flow ${flowId}: 映射已配置`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
(0, output_1.printWarning)(`Flow ${flowId}: 映射未配置`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (options.json) {
|
|
29
|
+
(0, output_1.printStructuredResult)({ ok: false, message: error.message });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
(0, output_1.printError)(`检查映射状态失败: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=check-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-mapping.js","sourceRoot":"","sources":["../../../src/commands/sync/check-mapping.ts"],"names":[],"mappings":";;AAUA,4DA6BC;AAtCD,2CAAmD;AACnD,2CAMwB;AAExB,SAAgB,wBAAwB,CAAC,OAAgB;IACvD,OAAO;SACJ,OAAO,CAAC,wBAAwB,CAAC;SACjC,WAAW,CAAC,WAAW,CAAC;SACxB,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC;SAC/B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAChC,IAAI,CAAC;YACH,IAAI,OAAO,CAAC,IAAI;gBAAE,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;YAEpC,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAkB,EAAC,MAAM,CAAC,CAAC;YAEpD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,IAAA,8BAAqB,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;gBACxD,OAAO;YACT,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,IAAA,qBAAY,EAAC,QAAQ,MAAM,SAAS,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,IAAA,qBAAY,EAAC,QAAQ,MAAM,SAAS,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,IAAA,8BAAqB,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,IAAA,mBAAU,EAAC,aAAc,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoDzD"}
|
|
@@ -11,19 +11,32 @@ function registerSyncCreate(syncCmd) {
|
|
|
11
11
|
.requiredOption('--type <ds_type>', '连接器类型,可通过 sync list 查看可选值')
|
|
12
12
|
.option('--name <name>', '连接器名称')
|
|
13
13
|
.option('--reset', '创建后自动套用预设模板')
|
|
14
|
+
.option('--json', '以 JSON 格式输出')
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
try {
|
|
17
|
+
if (options.json)
|
|
18
|
+
(0, output_1.setJsonMode)(true);
|
|
16
19
|
const { type, name, reset } = options;
|
|
17
20
|
const tpl = templates_1.SYNC_FLOW_TEMPLATES.find((t) => t.ds_type === type);
|
|
18
21
|
if (!tpl) {
|
|
19
|
-
(
|
|
20
|
-
|
|
22
|
+
if (options.json) {
|
|
23
|
+
(0, output_1.printStructuredResult)({ ok: false, message: `无效的连接器类型: ${type}` });
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
(0, output_1.printError)(`无效的连接器类型: ${type}`);
|
|
27
|
+
(0, output_1.printInfo)('使用 ai-flow sync list 查看可选类型');
|
|
28
|
+
}
|
|
21
29
|
return;
|
|
22
30
|
}
|
|
23
31
|
(0, output_1.printInfo)(`正在创建下游连接器: ${tpl.name} (${type})`);
|
|
24
32
|
const result = (await (0, sync_1.createSyncConnector)({ ds_type: type, name }));
|
|
25
33
|
const id = typeof result === 'object' && result !== null ? result.id || '-' : result;
|
|
26
|
-
(
|
|
34
|
+
if (options.json) {
|
|
35
|
+
(0, output_1.printStructuredResult)({ ok: true, id: String(id), message: `下游连接器创建成功` });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
(0, output_1.printSuccess)(`下游连接器创建成功,ID: ${id}`);
|
|
39
|
+
}
|
|
27
40
|
if (reset && id !== '-') {
|
|
28
41
|
(0, output_1.printInfo)('正在套用预设模板...');
|
|
29
42
|
await (0, sync_1.resetSyncFlow)(String(id));
|
|
@@ -31,7 +44,12 @@ function registerSyncCreate(syncCmd) {
|
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
catch (error) {
|
|
34
|
-
(
|
|
47
|
+
if (options.json) {
|
|
48
|
+
(0, output_1.printStructuredResult)({ ok: false, message: error.message });
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
(0, output_1.printError)(`创建下游连接器失败: ${error.message}`);
|
|
52
|
+
}
|
|
35
53
|
}
|
|
36
54
|
});
|
|
37
55
|
}
|