@senguoyunnpm/producer-cli 0.0.0-stage → 0.0.1
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/README.md +108 -2
- package/dist/config.d.ts +12 -0
- package/dist/config.js +88 -0
- package/dist/config.js.map +1 -0
- package/dist/download.d.ts +8 -0
- package/dist/download.js +88 -0
- package/dist/download.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +224 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/catalog-revision.d.ts +1 -0
- package/dist/generated/catalog-revision.js +2 -0
- package/dist/generated/catalog-revision.js.map +1 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.js +1183 -0
- package/dist/main.js.map +1 -0
- package/dist/main.mjs +122 -0
- package/dist/next-step.d.ts +1 -0
- package/dist/next-step.js +34 -0
- package/dist/next-step.js.map +1 -0
- package/dist/output.d.ts +5 -0
- package/dist/output.js +126 -0
- package/dist/output.js.map +1 -0
- package/dist/parameters.d.ts +90 -0
- package/dist/parameters.js +502 -0
- package/dist/parameters.js.map +1 -0
- package/dist/schema.d.ts +11 -0
- package/dist/schema.js +158 -0
- package/dist/schema.js.map +1 -0
- package/dist/update/engine.d.ts +36 -0
- package/dist/update/engine.js +197 -0
- package/dist/update/engine.js.map +1 -0
- package/dist/update/launcher.d.ts +13 -0
- package/dist/update/launcher.js +104 -0
- package/dist/update/launcher.js.map +1 -0
- package/dist/update/layout.d.ts +10 -0
- package/dist/update/layout.js +79 -0
- package/dist/update/layout.js.map +1 -0
- package/dist/update/registry.d.ts +12 -0
- package/dist/update/registry.js +48 -0
- package/dist/update/registry.js.map +1 -0
- package/dist/update/tar.d.ts +5 -0
- package/dist/update/tar.js +94 -0
- package/dist/update/tar.js.map +1 -0
- package/dist/update/version.d.ts +3 -0
- package/dist/update/version.js +51 -0
- package/dist/update/version.js.map +1 -0
- package/dist/upgrade.d.ts +11 -0
- package/dist/upgrade.js +50 -0
- package/dist/upgrade.js.map +1 -0
- package/dist/upload.d.ts +23 -0
- package/dist/upload.js +57 -0
- package/dist/upload.js.map +1 -0
- package/package.json +28 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cliNextStep(nextStep: string | undefined, operationId?: string): string | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { catalog } from '@senguoyunnpm/producersdk';
|
|
2
|
+
function commandRoot(action) {
|
|
3
|
+
return action.contract.cli_example.replace(/^producer\s+/, '').split(/\s+/)[0] ?? '';
|
|
4
|
+
}
|
|
5
|
+
// 一个 operation 对应多个可见命令时无法确定具体业务类型,退到能力级帮助。
|
|
6
|
+
function capabilityHelp(actions) {
|
|
7
|
+
const roots = new Set(actions.map(commandRoot));
|
|
8
|
+
return roots.size === 1 ? `producer ${[...roots][0]} --help` : undefined;
|
|
9
|
+
}
|
|
10
|
+
// ai-platform 的 next_step 是 MCP 工具名,CLI 调用方需要的是可直接执行的 CLI 命令。
|
|
11
|
+
// 只转换产地业务已知的取值;其余(retry_same_execute、report_failure、其它域)原样保留。
|
|
12
|
+
export function cliNextStep(nextStep, operationId) {
|
|
13
|
+
switch (nextStep) {
|
|
14
|
+
case 'producer_query_capabilities_search':
|
|
15
|
+
return 'producer --help';
|
|
16
|
+
case 'producer_query_capability_describe': {
|
|
17
|
+
const actions = operationId ? catalog.actionsForOperation(operationId) : [];
|
|
18
|
+
if (actions.length > 1)
|
|
19
|
+
return capabilityHelp(actions) ?? 'producer schema';
|
|
20
|
+
if (actions.length === 0)
|
|
21
|
+
return 'producer schema';
|
|
22
|
+
return `producer schema ${actions[0].contract.cli_example.replace(/^producer\s+/, '')}`;
|
|
23
|
+
}
|
|
24
|
+
case 'producer_query_execute': {
|
|
25
|
+
const actions = operationId ? catalog.actionsForOperation(operationId) : [];
|
|
26
|
+
if (actions.length > 1)
|
|
27
|
+
return capabilityHelp(actions) ?? 'producer --help';
|
|
28
|
+
return actions[0]?.contract.cli_example ?? 'producer --help';
|
|
29
|
+
}
|
|
30
|
+
default:
|
|
31
|
+
return nextStep;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=next-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-step.js","sourceRoot":"","sources":["../src/next-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,2BAA2B,CAAC;AAExE,SAAS,WAAW,CAAC,MAAqB;IACxC,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACvF,CAAC;AAED,4CAA4C;AAC5C,SAAS,cAAc,CAAC,OAAwB;IAC9C,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED,8DAA8D;AAC9D,8DAA8D;AAC9D,MAAM,UAAU,WAAW,CACzB,QAA4B,EAC5B,WAAoB;IAEpB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,oCAAoC;YACvC,OAAO,iBAAiB,CAAC;QAC3B,KAAK,oCAAoC,EAAE,CAAC;YAC1C,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,cAAc,CAAC,OAAO,CAAC,IAAI,iBAAiB,CAAC;YAC5E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,iBAAiB,CAAC;YACnD,OAAO,mBAAmB,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,EAAE,CAAC;QAC1F,CAAC;QACD,KAAK,wBAAwB,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,cAAc,CAAC,OAAO,CAAC,IAAI,iBAAiB,CAAC;YAC5E,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,IAAI,iBAAiB,CAAC;QAC/D,CAAC;QACD;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type OutputFormat = 'json' | 'raw' | 'pretty' | 'ndjson' | 'table' | 'csv';
|
|
2
|
+
export declare function parseOutputFormat(value: string): OutputFormat;
|
|
3
|
+
export declare function formatOutput(value: unknown, format: OutputFormat): string;
|
|
4
|
+
export declare function applyFields(value: unknown, fields: string | undefined): unknown;
|
|
5
|
+
export declare function applyJq(value: unknown, expr: string): string;
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { loadJq } from 'jq-wasm/inline';
|
|
2
|
+
import { CliError } from './errors.js';
|
|
3
|
+
export function parseOutputFormat(value) {
|
|
4
|
+
if (['json', 'raw', 'pretty', 'ndjson', 'table', 'csv'].includes(value))
|
|
5
|
+
return value;
|
|
6
|
+
throw new CliError(`不支持的输出格式: ${value}(可选 json|table|raw|pretty|ndjson|csv)`, 'validation', 'invalid_output_format');
|
|
7
|
+
}
|
|
8
|
+
const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
9
|
+
// 业务叶子命令返回 QueryResult 信封;记录列表位于 data.records。
|
|
10
|
+
function recordsOf(value) {
|
|
11
|
+
if (!isObject(value) || !isObject(value.data))
|
|
12
|
+
return undefined;
|
|
13
|
+
const records = value.data.records;
|
|
14
|
+
return Array.isArray(records) ? records : undefined;
|
|
15
|
+
}
|
|
16
|
+
export function formatOutput(value, format) {
|
|
17
|
+
switch (format) {
|
|
18
|
+
case 'raw':
|
|
19
|
+
return typeof value === 'string' ? `${value}\n` : `${JSON.stringify(value)}\n`;
|
|
20
|
+
case 'ndjson': {
|
|
21
|
+
const records = recordsOf(value);
|
|
22
|
+
const list = records ?? (Array.isArray(value) ? value : [value]);
|
|
23
|
+
return `${list.map((x) => JSON.stringify(x)).join('\n')}\n`;
|
|
24
|
+
}
|
|
25
|
+
case 'table': {
|
|
26
|
+
const records = recordsOf(value);
|
|
27
|
+
if (!records?.length)
|
|
28
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
29
|
+
return `${renderTable(records)}\n`;
|
|
30
|
+
}
|
|
31
|
+
case 'csv': {
|
|
32
|
+
const records = recordsOf(value);
|
|
33
|
+
if (!records?.length)
|
|
34
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
35
|
+
return `${renderCsv(records)}\n`;
|
|
36
|
+
}
|
|
37
|
+
case 'json':
|
|
38
|
+
case 'pretty':
|
|
39
|
+
default:
|
|
40
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function cellText(value) {
|
|
44
|
+
if (value === null || value === undefined)
|
|
45
|
+
return '';
|
|
46
|
+
return typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
47
|
+
}
|
|
48
|
+
function renderTable(records) {
|
|
49
|
+
const rows = records.filter(isObject);
|
|
50
|
+
const keys = collectKeys(rows);
|
|
51
|
+
const widths = keys.map((k) => Math.max(k.length, ...rows.map((r) => cellText(r[k]).length)));
|
|
52
|
+
const line = (cols) => cols
|
|
53
|
+
.map((c, i) => c.padEnd(widths[i] ?? 0, ' '))
|
|
54
|
+
.join(' ')
|
|
55
|
+
.trimEnd();
|
|
56
|
+
const header = line(keys);
|
|
57
|
+
const separator = keys.map((_, i) => '-'.repeat(widths[i] ?? 0)).join(' ');
|
|
58
|
+
return [header, separator, ...rows.map((r) => line(keys.map((k) => cellText(r[k]))))].join('\n');
|
|
59
|
+
}
|
|
60
|
+
function csvEscape(value) {
|
|
61
|
+
const s = cellText(value);
|
|
62
|
+
return /[",\n]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
63
|
+
}
|
|
64
|
+
function renderCsv(records) {
|
|
65
|
+
const rows = records.filter(isObject);
|
|
66
|
+
const keys = collectKeys(rows);
|
|
67
|
+
return [
|
|
68
|
+
keys.map(csvEscape).join(','),
|
|
69
|
+
...rows.map((r) => keys.map((k) => csvEscape(r[k])).join(',')),
|
|
70
|
+
].join('\n');
|
|
71
|
+
}
|
|
72
|
+
function collectKeys(rows) {
|
|
73
|
+
const keys = [];
|
|
74
|
+
for (const row of rows)
|
|
75
|
+
for (const k of Object.keys(row))
|
|
76
|
+
if (!keys.includes(k))
|
|
77
|
+
keys.push(k);
|
|
78
|
+
return keys;
|
|
79
|
+
}
|
|
80
|
+
// --fields:对齐 dws:顶层数组逐元素投影且保留信封其余键;信封内记录列表(data.records)
|
|
81
|
+
// 同样只投影元素;都没有时投影对象本身,缺失键即丢弃(可能得到 {})。不支持嵌套路径。
|
|
82
|
+
export function applyFields(value, fields) {
|
|
83
|
+
if (!fields)
|
|
84
|
+
return value;
|
|
85
|
+
const keys = fields
|
|
86
|
+
.split(',')
|
|
87
|
+
.map((s) => s.trim())
|
|
88
|
+
.filter(Boolean);
|
|
89
|
+
if (!keys.length)
|
|
90
|
+
return value;
|
|
91
|
+
if (Array.isArray(value))
|
|
92
|
+
return value.map((r) => pickFields(r, keys));
|
|
93
|
+
if (!isObject(value))
|
|
94
|
+
return value;
|
|
95
|
+
const listKey = Object.keys(value).find((k) => Array.isArray(value[k]));
|
|
96
|
+
if (listKey)
|
|
97
|
+
return {
|
|
98
|
+
...value,
|
|
99
|
+
[listKey]: value[listKey].map((r) => pickFields(r, keys)),
|
|
100
|
+
};
|
|
101
|
+
const records = recordsOf(value);
|
|
102
|
+
if (records)
|
|
103
|
+
return {
|
|
104
|
+
...value,
|
|
105
|
+
data: { ...value.data, records: records.map((r) => pickFields(r, keys)) },
|
|
106
|
+
};
|
|
107
|
+
return pickFields(value, keys);
|
|
108
|
+
}
|
|
109
|
+
function pickFields(record, keys) {
|
|
110
|
+
if (!isObject(record))
|
|
111
|
+
return record;
|
|
112
|
+
const out = {};
|
|
113
|
+
for (const k of keys)
|
|
114
|
+
if (k in record)
|
|
115
|
+
out[k] = record[k];
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
// --jq:内嵌 jq(WebAssembly)过滤,不依赖本机安装 jq;字符串保留 JSON 引号。
|
|
119
|
+
const jq = await loadJq();
|
|
120
|
+
export function applyJq(value, expr) {
|
|
121
|
+
const result = jq.raw(value, expr);
|
|
122
|
+
if (result.exitCode !== 0)
|
|
123
|
+
throw new Error(`jq 表达式错误: ${result.stderr.trim()}`);
|
|
124
|
+
return result.stdout && !result.stdout.endsWith('\n') ? `${result.stdout}\n` : result.stdout;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAyB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrE,OAAO,KAAqB,CAAC;IAC/B,MAAM,IAAI,QAAQ,CA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EAAE,CAAC;AAE9B,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,IAAY;IAClD,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,KAAgB,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { PaginationMeta } from '@senguoyunnpm/producersdk';
|
|
2
|
+
export type InputProperty = {
|
|
3
|
+
type?: string;
|
|
4
|
+
properties?: Record<string, InputProperty>;
|
|
5
|
+
required?: string[];
|
|
6
|
+
items?: {
|
|
7
|
+
type?: string;
|
|
8
|
+
properties?: Record<string, InputProperty>;
|
|
9
|
+
required?: string[];
|
|
10
|
+
enum?: (string | number)[];
|
|
11
|
+
choices?: {
|
|
12
|
+
value: string | number;
|
|
13
|
+
label: string;
|
|
14
|
+
}[];
|
|
15
|
+
format?: string;
|
|
16
|
+
minimum?: number;
|
|
17
|
+
maximum?: number;
|
|
18
|
+
};
|
|
19
|
+
description?: string;
|
|
20
|
+
enum?: (string | number)[];
|
|
21
|
+
choices?: {
|
|
22
|
+
value: string | number;
|
|
23
|
+
label: string;
|
|
24
|
+
}[];
|
|
25
|
+
default?: string | number | boolean | Array<string | number>;
|
|
26
|
+
format?: string;
|
|
27
|
+
minimum?: number;
|
|
28
|
+
maximum?: number;
|
|
29
|
+
minItems?: number;
|
|
30
|
+
maxItems?: number;
|
|
31
|
+
reference?: {
|
|
32
|
+
entity: string;
|
|
33
|
+
label: string;
|
|
34
|
+
command: string;
|
|
35
|
+
resultPath: string;
|
|
36
|
+
scopeArgument?: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type InputSchema = {
|
|
40
|
+
required?: string[];
|
|
41
|
+
properties?: Record<string, InputProperty>;
|
|
42
|
+
};
|
|
43
|
+
export declare function exampleObject(properties: Record<string, InputProperty> | undefined, required: string[] | undefined): Record<string, unknown>;
|
|
44
|
+
export declare function exampleJson(input: InputSchema, context: {
|
|
45
|
+
planner?: string;
|
|
46
|
+
operationId: string;
|
|
47
|
+
intent?: boolean;
|
|
48
|
+
}): string;
|
|
49
|
+
export interface CliParameterContract {
|
|
50
|
+
input_name?: string;
|
|
51
|
+
flag: string;
|
|
52
|
+
type: string;
|
|
53
|
+
value_hint: string;
|
|
54
|
+
required: boolean;
|
|
55
|
+
source: 'operation' | 'pagination';
|
|
56
|
+
description: string;
|
|
57
|
+
help: string;
|
|
58
|
+
default?: string | number | boolean | Array<string | number>;
|
|
59
|
+
enum?: Array<string | number>;
|
|
60
|
+
choices?: Array<{
|
|
61
|
+
value: string | number;
|
|
62
|
+
label: string;
|
|
63
|
+
}>;
|
|
64
|
+
format?: string;
|
|
65
|
+
minimum?: number;
|
|
66
|
+
maximum?: number;
|
|
67
|
+
min_items?: number;
|
|
68
|
+
max_items?: number;
|
|
69
|
+
comma_separated?: boolean;
|
|
70
|
+
reference?: InputProperty['reference'];
|
|
71
|
+
}
|
|
72
|
+
export declare function compileCommandParameters(input: InputSchema, pagination: PaginationMeta | null | undefined, effect: string, hasIntent: boolean): CliParameterContract[];
|
|
73
|
+
export declare const flagName: (name: string) => string;
|
|
74
|
+
export declare function isBooleanEnum(schema: InputProperty): boolean;
|
|
75
|
+
export declare function enumChoices(schema: InputProperty): {
|
|
76
|
+
value: string | number;
|
|
77
|
+
label: string;
|
|
78
|
+
}[];
|
|
79
|
+
export declare function enumValues(schema: InputProperty): (string | number)[] | undefined;
|
|
80
|
+
export declare function cliType(schema: InputProperty): string;
|
|
81
|
+
export declare function typeHint(schema: InputProperty): string;
|
|
82
|
+
export declare function coerceFlagValue(schema: InputProperty, raw: string): unknown;
|
|
83
|
+
export declare function exampleValue(schema: InputProperty): string;
|
|
84
|
+
export declare function defaultLabel(schema: InputProperty): string | number | boolean | Array<string | number> | undefined;
|
|
85
|
+
export declare function compileCliParameters(input: InputSchema, pagination?: PaginationMeta | null): CliParameterContract[];
|
|
86
|
+
export declare function exampleCommand(commandPath: string, input: InputSchema): string;
|
|
87
|
+
export declare function lastWindow(spec: string, now?: Date): {
|
|
88
|
+
from_date: string;
|
|
89
|
+
to_date: string;
|
|
90
|
+
};
|