W7-D3: 4 新父命令脚手架 (datasource/report/portal/bigscreen, 共 16 子命令)
This commit is contained in:
1 parent
456059b505
commit
5998e9f885
21 files changed
+1018
No files matched your search
@@ -19,6 +19,10 @@ import { buildDiCommand } from './commands/di/index.ts'
|
||||
import { buildWorkflowCommand } from './commands/workflow/index.ts'
|
||||
import { buildDocCommand } from './commands/doc/index.ts'
|
||||
import { buildApisCommand } from './commands/apis/index.ts'
|
||||
import { buildDatasourceCommand } from './commands/datasource/index.ts'
|
||||
import { buildReportCommand } from './commands/report/index.ts'
|
||||
import { buildPortalCommand } from './commands/portal/index.ts'
|
||||
import { buildBigscreenCommand } from './commands/bigscreen/index.ts'
|
||||
import { maybeInterceptAiHelp } from './core/help.ts'
|
||||
import { log } from './core/log.ts'
|
||||
import { DacliError } from './core/types.ts'
|
||||
@@ -45,6 +49,11 @@ program.addCommand(buildDiCommand())
|
||||
program.addCommand(buildWorkflowCommand())
|
||||
program.addCommand(buildDocCommand())
|
||||
program.addCommand(buildApisCommand())
|
||||
// v0.8 W7-D3 新增 4 父命令
|
||||
program.addCommand(buildDatasourceCommand())
|
||||
program.addCommand(buildReportCommand())
|
||||
program.addCommand(buildPortalCommand())
|
||||
program.addCommand(buildBigscreenCommand())
|
||||
|
||||
// ----- main -----
|
||||
// AI flag 拦截 (在 parse 之前, 避免 requiredOption 校验失败)
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* commands/bigscreen/create.ts — 新建大屏
|
||||
*
|
||||
* 决策 6: 大屏 webType=3-4, 不需要物理表, 走 dataInterfaceId 拉数据
|
||||
*
|
||||
* API: POST /api/extend/BigData
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface CreateOpts {
|
||||
fullName: string
|
||||
enCode: string
|
||||
category: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildBigscreenCreateCommand(): Command {
|
||||
const cmd = new Command('create')
|
||||
.description('新建大屏 (无物理表, 走 dataInterfaceId 拉数据)')
|
||||
.requiredOption('--fullName <name>', '大屏名称')
|
||||
.requiredOption('--enCode <code>', '大屏编码')
|
||||
.requiredOption('--category <cat>', '分类: 1=数据大屏 2=仪表盘')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: CreateOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const body = {
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
category: opts.category,
|
||||
type: 3, // 大屏设计器
|
||||
design: '{}',
|
||||
enabledMark: 1,
|
||||
sortCode: 0,
|
||||
}
|
||||
const r = await c.postJson<{ id: string }>('/extend/BigData', body)
|
||||
if (r.code !== 200) {
|
||||
log.error(`bigscreen create 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const id = r.data?.id
|
||||
log.info(`✓ 大屏创建成功 id=${id}`)
|
||||
if (opts.json) printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '新建大屏 (大屏设计器产物, 走 dataInterface 拉数据)',
|
||||
required: {
|
||||
'--fullName': '大屏名称',
|
||||
'--enCode': '大屏编码',
|
||||
'--category': '分类 1=数据大屏 2=仪表盘',
|
||||
},
|
||||
optional: { '--json': '原始 JSON 输出' },
|
||||
example: 'dacli bigscreen create --fullName=销售大屏 --enCode=salesDash --category=1',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/extend/bigData/Form.vue',
|
||||
api: 'POST /api/extend/BigData',
|
||||
ref: 'doc/v0.8-endpoints.md §1.4',
|
||||
},
|
||||
notes: [
|
||||
'**决策 6**: 大屏不需要物理表, 走 di 拉数据',
|
||||
'**决策 6**: webType 3-4 (大屏设计器)',
|
||||
],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* commands/bigscreen/index.ts — bigscreen 父命令
|
||||
*
|
||||
* 大屏设计器 (extend/bigData)
|
||||
*
|
||||
* 子命令:
|
||||
* list 列表
|
||||
* info 详情
|
||||
* create 新建
|
||||
* release 发布 (state 0→1)
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { buildBigscreenListCommand } from './list.ts'
|
||||
import { buildBigscreenInfoCommand } from './info.ts'
|
||||
import { buildBigscreenCreateCommand } from './create.ts'
|
||||
import { buildBigscreenReleaseCommand } from './release.ts'
|
||||
|
||||
export function buildBigscreenCommand(): Command {
|
||||
const cmd = new Command('bigscreen').description('大屏设计器 CRUD (数据可视化, 走 dataInterface 拉数据)')
|
||||
cmd.addCommand(buildBigscreenListCommand())
|
||||
cmd.addCommand(buildBigscreenInfoCommand())
|
||||
cmd.addCommand(buildBigscreenCreateCommand())
|
||||
cmd.addCommand(buildBigscreenReleaseCommand())
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* commands/bigscreen/info.ts — 大屏详情
|
||||
*
|
||||
* API: GET /api/extend/BigData/{id} (推断, 端点清单见 v0.8-endpoints.md)
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface InfoOpts {
|
||||
id: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildBigscreenInfoCommand(): Command {
|
||||
const cmd = new Command('info')
|
||||
.description('查看大屏详情 (含图表配置)')
|
||||
.requiredOption('--id <id>', '大屏 id')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: InfoOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.get<Record<string, unknown>>(`/extend/BigData/${opts.id}`)
|
||||
if (r.code !== 200) {
|
||||
log.error(`bigscreen info 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
const d = r.data as Record<string, unknown>
|
||||
log.info(`大屏 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`)
|
||||
console.log(`category: ${d.category}`)
|
||||
console.log(`type: ${d.type}`)
|
||||
console.log(`--- 完整 JSON (含 chart 配置) ---`)
|
||||
printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '查看大屏的完整 schema (含图表配置)',
|
||||
required: { '--id': '大屏 id' },
|
||||
example: 'dacli bigscreen info --id=1234567890\ndacli bigscreen info --id=1234567890 --json',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/extend/bigData/Form.vue',
|
||||
api: 'GET /api/extend/BigData/{id}',
|
||||
ref: 'doc/v0.8-endpoints.md §1.4',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* commands/bigscreen/list.ts — 大屏列表
|
||||
*
|
||||
* API: GET /api/extend/BigData
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface ListOpts {
|
||||
keyword?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildBigscreenListCommand(): Command {
|
||||
const cmd = new Command('list')
|
||||
.description('列出大屏 (大屏设计器产物)')
|
||||
.option('--keyword <k>', '按名称/编码模糊搜索')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: ListOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.get<{ list: Record<string, unknown>[] }>(
|
||||
'/extend/BigData',
|
||||
{ keyword: opts.keyword },
|
||||
)
|
||||
if (r.code !== 200) {
|
||||
log.error(`bigscreen list 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const list = r.data?.list || []
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
log.info(`共 ${list.length} 张大屏`)
|
||||
console.log('ID FULL_NAME ENCODE CATEGORY')
|
||||
console.log('-'.repeat(90))
|
||||
for (const d of list) {
|
||||
const id = String(d.id || '').padEnd(30)
|
||||
const name = String(d.fullName || '').padEnd(23)
|
||||
const code = String(d.enCode || '').padEnd(21)
|
||||
const cat = String(d.category || '')
|
||||
console.log(`${id}${name}${code}${cat}`)
|
||||
}
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '列出大屏 (大屏设计器产物)',
|
||||
optional: { '--keyword': '按名称/编码模糊搜索' },
|
||||
example: 'dacli bigscreen list\ndacli bigscreen list --keyword=销售',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/extend/bigData/index.vue',
|
||||
api: 'GET /api/extend/BigData',
|
||||
ref: 'doc/v0.8-endpoints.md §1.4',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* commands/bigscreen/release.ts — 发布大屏
|
||||
*
|
||||
* API: POST /api/extend/BigData/Actions/release (推断)
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log } from '../../core/log.ts'
|
||||
|
||||
interface ReleaseOpts {
|
||||
id: string
|
||||
}
|
||||
|
||||
export function buildBigscreenReleaseCommand(): Command {
|
||||
const cmd = new Command('release')
|
||||
.description('发布大屏 (state 0→1)')
|
||||
.requiredOption('--id <id>', '大屏 id')
|
||||
.action(async (opts: ReleaseOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.postJson(`/extend/BigData/${opts.id}/Actions/release`, {})
|
||||
if (r.code !== 200) {
|
||||
log.error(`bigscreen release 失败: ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
log.info(`✓ 大屏 id=${opts.id} 已发布`)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '发布大屏 (state 0→1, 菜单可挂)',
|
||||
required: { '--id': '大屏 id' },
|
||||
example: 'dacli bigscreen release --id=1234567890',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/extend/bigData/Form.vue',
|
||||
api: 'POST /api/extend/BigData/{id}/Actions/release',
|
||||
ref: 'doc/v0.8-endpoints.md §1.4',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* commands/datasource/create.ts — 新建数据源
|
||||
*
|
||||
* API: POST /api/system/DataSource
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface CreateOpts {
|
||||
fullName: string
|
||||
enCode: string
|
||||
dbType: string
|
||||
host: string
|
||||
port: string
|
||||
user: string
|
||||
password?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildDatasourceCreateCommand(): Command {
|
||||
const cmd = new Command('create')
|
||||
.description('新建数据源 (含连接配置)')
|
||||
.requiredOption('--fullName <name>', '数据源名称')
|
||||
.requiredOption('--enCode <code>', '数据源编码')
|
||||
.requiredOption('--dbType <type>', '数据库类型: MySQL/SQLServer/Oracle/PostgreSQL/DM/Kingbase')
|
||||
.requiredOption('--host <host>', '主机名')
|
||||
.requiredOption('--port <port>', '端口')
|
||||
.requiredOption('--user <user>', '用户名')
|
||||
.option('--password <pwd>', '密码 (不传默认空)')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: CreateOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const body = {
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
dbType: opts.dbType,
|
||||
host: opts.host,
|
||||
port: opts.port,
|
||||
userName: opts.user,
|
||||
password: opts.password || '',
|
||||
enabledMark: 1,
|
||||
sortCode: 0,
|
||||
}
|
||||
const r = await c.postJson<{ id: string }>('/system/DataSource', body)
|
||||
if (r.code !== 200) {
|
||||
log.error(`datasource create 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const id = r.data?.id
|
||||
log.info(`✓ 数据源创建成功 id=${id}`)
|
||||
if (opts.json) printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '新建数据源 (数据库连接配置)',
|
||||
required: {
|
||||
'--fullName': '数据源名称',
|
||||
'--enCode': '数据源编码',
|
||||
'--dbType': '数据库类型 (MySQL/SQLServer/Oracle/PostgreSQL/DM/Kingbase)',
|
||||
'--host': '主机名',
|
||||
'--port': '端口',
|
||||
'--user': '用户名',
|
||||
},
|
||||
optional: { '--password': '密码', '--json': '原始 JSON 输出' },
|
||||
example:
|
||||
'dacli datasource create --fullName=测试库 --enCode=testdb \\\n --dbType=MySQL --host=127.0.0.1 --port=3306 --user=root --password=123456',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/dataCenter/dataSource/Form.vue',
|
||||
api: 'POST /api/system/DataSource',
|
||||
ref: 'doc/v0.8-endpoints.md §1.1',
|
||||
},
|
||||
notes: ['密码可后续用 update 修改', '可立即用 test 子命令验证连接'],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* commands/datasource/delete.ts — 删除数据源
|
||||
*
|
||||
* API: DELETE /api/system/DataSource/{id}
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log } from '../../core/log.ts'
|
||||
|
||||
interface DeleteOpts {
|
||||
id: string
|
||||
yes?: boolean
|
||||
}
|
||||
|
||||
export function buildDatasourceDeleteCommand(): Command {
|
||||
const cmd = new Command('delete')
|
||||
.description('删除数据源')
|
||||
.requiredOption('--id <id>', '数据源 id')
|
||||
.option('--yes', '跳过确认', false)
|
||||
.action(async (opts: DeleteOpts) => {
|
||||
if (!opts.yes) {
|
||||
log.warn(`即将删除数据源 id=${opts.id}, 加 --yes 跳过确认`)
|
||||
process.exit(2)
|
||||
}
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.del(`/system/DataSource/${opts.id}`)
|
||||
if (r.code !== 200) {
|
||||
log.error(`datasource delete 失败: ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
log.info(`✓ 数据源 id=${opts.id} 已删除`)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '删除数据源 (硬删, 无回收)',
|
||||
required: { '--id': '数据源 id', '--yes': '跳过确认' },
|
||||
example: 'dacli datasource delete --id=1234567890 --yes',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/dataCenter/dataSource/index.vue',
|
||||
api: 'DELETE /api/system/DataSource/{id}',
|
||||
ref: 'doc/v0.8-endpoints.md §1.1',
|
||||
},
|
||||
notes: ['删除后该数据源上的所有业务库表无法访问', '谨慎操作'],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* commands/datasource/index.ts — datasource 父命令
|
||||
*
|
||||
* 数据源 (数据连接) CRUD — MySQL/SQLServer/Oracle/PostgreSQL/DM/Kingbase 等
|
||||
*
|
||||
* 子命令:
|
||||
* list 列表
|
||||
* create 新建
|
||||
* test 测试连接
|
||||
* delete 删除
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { buildDatasourceListCommand } from './list.ts'
|
||||
import { buildDatasourceCreateCommand } from './create.ts'
|
||||
import { buildDatasourceTestCommand } from './test.ts'
|
||||
import { buildDatasourceDeleteCommand } from './delete.ts'
|
||||
|
||||
export function buildDatasourceCommand(): Command {
|
||||
const cmd = new Command('datasource').description('数据源 (数据连接) CRUD — 业务库配置')
|
||||
cmd.addCommand(buildDatasourceListCommand())
|
||||
cmd.addCommand(buildDatasourceCreateCommand())
|
||||
cmd.addCommand(buildDatasourceTestCommand())
|
||||
cmd.addCommand(buildDatasourceDeleteCommand())
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* commands/datasource/list.ts — 数据源列表
|
||||
*
|
||||
* API: GET /api/system/DataSource
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface ListOpts {
|
||||
keyword?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildDatasourceListCommand(): Command {
|
||||
const cmd = new Command('list')
|
||||
.description('列出数据源 (数据连接)')
|
||||
.option('--keyword <k>', '按名称/编码模糊搜索')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: ListOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.get<{ list: Record<string, unknown>[] }>(
|
||||
'/system/DataSource',
|
||||
{ keyword: opts.keyword },
|
||||
)
|
||||
if (r.code !== 200) {
|
||||
log.error(`datasource list 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const list = r.data?.list || []
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
log.info(`共 ${list.length} 个数据源`)
|
||||
console.log('ID FULL_NAME ENCODE DB_TYPE')
|
||||
console.log('-'.repeat(90))
|
||||
for (const d of list) {
|
||||
const id = String(d.id || '').padEnd(30)
|
||||
const name = String(d.fullName || '').padEnd(23)
|
||||
const code = String(d.enCode || '').padEnd(21)
|
||||
const type = String(d.dbType || '')
|
||||
console.log(`${id}${name}${code}${type}`)
|
||||
}
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '列出当前应用所有数据源 (MySQL/SQLServer/Oracle/PostgreSQL 等)',
|
||||
optional: { '--keyword': '按名称/编码模糊搜索' },
|
||||
example: 'dacli datasource list\ndacli datasource list --keyword=test',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/dataCenter/dataSource/index.vue',
|
||||
api: 'GET /api/system/DataSource',
|
||||
ref: 'doc/v0.8-endpoints.md §1.1',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* commands/datasource/test.ts — 测试数据源连接
|
||||
*
|
||||
* API: POST /api/system/DataSource/Actions/Test
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface TestOpts {
|
||||
id?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildDatasourceTestCommand(): Command {
|
||||
const cmd = new Command('test')
|
||||
.description('测试数据源连接')
|
||||
.option('--id <id>', '数据源 id (已存在则用其配置; 不传则要 --host/--user/...)')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: TestOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
let body: Record<string, unknown>
|
||||
if (opts.id) {
|
||||
// 按 id: 调 GET 拿配置, 转发
|
||||
const r1 = await c.get<Record<string, unknown>>(`/system/DataSource/${opts.id}`)
|
||||
if (r1.code !== 200) {
|
||||
log.error(`datasource test 失败 (拉配置): ${r1.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
body = { ...(r1.data as Record<string, unknown>), id: undefined } as Record<string, unknown>
|
||||
} else {
|
||||
log.error('请传 --id <数据源 id>')
|
||||
process.exit(2)
|
||||
}
|
||||
const r = await c.postJson<unknown>('/system/DataSource/Actions/Test', body)
|
||||
if (r.code !== 200) {
|
||||
log.error(`datasource test 失败: ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
log.info(`✓ 数据源 id=${opts.id} 连接成功`)
|
||||
if (opts.json) printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '测试已存在数据源的连接',
|
||||
required: { '--id': '数据源 id' },
|
||||
example: 'dacli datasource test --id=1234567890',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/dataCenter/dataSource/Form.vue',
|
||||
api: 'POST /api/system/DataSource/Actions/Test',
|
||||
ref: 'doc/v0.8-endpoints.md §1.1',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* commands/portal/create.ts — 新建门户
|
||||
*
|
||||
* 决策 6: 门户 webType=5-6, 不需要物理表, 走 dataInterfaceId 拉数据
|
||||
*
|
||||
* API: POST /api/visualdev/Portal
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface CreateOpts {
|
||||
fullName: string
|
||||
enCode: string
|
||||
category: string
|
||||
platform?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildPortalCreateCommand(): Command {
|
||||
const cmd = new Command('create')
|
||||
.description('新建门户 (无物理表, 走 dataInterfaceId 拉数据)')
|
||||
.requiredOption('--fullName <name>', '门户名称')
|
||||
.requiredOption('--enCode <code>', '门户编码')
|
||||
.requiredOption('--category <cat>', '分类: 1=经典门户 2=全屏门户')
|
||||
.option('--platform <p>', '平台: Web/App/PC', 'Web')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: CreateOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const body = {
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
category: opts.category,
|
||||
type: 5, // 门户设计器
|
||||
platform: opts.platform,
|
||||
formData: '{}',
|
||||
enabledMark: 1,
|
||||
sortCode: 0,
|
||||
}
|
||||
const r = await c.postJson<{ id: string }>('/visualdev/Portal', body)
|
||||
if (r.code !== 200) {
|
||||
log.error(`portal create 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const id = r.data?.id
|
||||
log.info(`✓ 门户创建成功 id=${id}`)
|
||||
if (opts.json) printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '新建门户 (首页/工作台设计器产物)',
|
||||
required: {
|
||||
'--fullName': '门户名称',
|
||||
'--enCode': '门户编码',
|
||||
'--category': '分类 1=经典门户 2=全屏门户',
|
||||
},
|
||||
optional: { '--platform': '平台 (Web/App/PC)', '--json': '原始 JSON 输出' },
|
||||
example:
|
||||
'dacli portal create --fullName=工作台 --enCode=workbench --category=1',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/visualPortal/Form.vue',
|
||||
api: 'POST /api/visualdev/Portal',
|
||||
ref: 'doc/v0.8-endpoints.md §1.3',
|
||||
},
|
||||
notes: [
|
||||
'**决策 6**: 门户不需要物理表, 走 di 拉数据',
|
||||
'**决策 6**: webType 5-6 (门户设计器)',
|
||||
],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* commands/portal/index.ts — portal 父命令
|
||||
*
|
||||
* 门户设计器 (onlineDev/visualPortal + common/dynamicPortal)
|
||||
*
|
||||
* 子命令:
|
||||
* list 列表
|
||||
* info 详情
|
||||
* create 新建
|
||||
* release 发布 (state 0→1)
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { buildPortalListCommand } from './list.ts'
|
||||
import { buildPortalInfoCommand } from './info.ts'
|
||||
import { buildPortalCreateCommand } from './create.ts'
|
||||
import { buildPortalReleaseCommand } from './release.ts'
|
||||
|
||||
export function buildPortalCommand(): Command {
|
||||
const cmd = new Command('portal').description('门户设计器 CRUD (首页/工作台, 走 dataInterface 拉数据)')
|
||||
cmd.addCommand(buildPortalListCommand())
|
||||
cmd.addCommand(buildPortalInfoCommand())
|
||||
cmd.addCommand(buildPortalCreateCommand())
|
||||
cmd.addCommand(buildPortalReleaseCommand())
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* commands/portal/info.ts — 门户详情
|
||||
*
|
||||
* API: GET /api/visualdev/Portal/{id}
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface InfoOpts {
|
||||
id: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildPortalInfoCommand(): Command {
|
||||
const cmd = new Command('info')
|
||||
.description('查看门户详情 (含布局 schema)')
|
||||
.requiredOption('--id <id>', '门户 id')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: InfoOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.get<Record<string, unknown>>(`/visualdev/Portal/${opts.id}`)
|
||||
if (r.code !== 200) {
|
||||
log.error(`portal info 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
const d = r.data as Record<string, unknown>
|
||||
log.info(`门户 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`)
|
||||
console.log(`category: ${d.category}`)
|
||||
console.log(`type: ${d.type}`)
|
||||
console.log(`platform: ${d.platform || '-'}`)
|
||||
console.log(`--- 完整 JSON (含 formData 布局) ---`)
|
||||
printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '查看门户的完整 schema (含布局/组件)',
|
||||
required: { '--id': '门户 id' },
|
||||
example: 'dacli portal info --id=1234567890\ndacli portal info --id=1234567890 --json',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/visualPortal/Form.vue',
|
||||
api: 'GET /api/visualdev/Portal/{id}',
|
||||
ref: 'doc/v0.8-endpoints.md §1.3',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* commands/portal/list.ts — 门户列表
|
||||
*
|
||||
* API: GET /api/visualdev/Portal
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface ListOpts {
|
||||
keyword?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildPortalListCommand(): Command {
|
||||
const cmd = new Command('list')
|
||||
.description('列出门户 (门户设计器产物)')
|
||||
.option('--keyword <k>', '按名称/编码模糊搜索')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: ListOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.get<{ list: Record<string, unknown>[] }>(
|
||||
'/visualdev/Portal',
|
||||
{ keyword: opts.keyword },
|
||||
)
|
||||
if (r.code !== 200) {
|
||||
log.error(`portal list 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const list = r.data?.list || []
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
log.info(`共 ${list.length} 个门户`)
|
||||
console.log('ID FULL_NAME ENCODE CATEGORY')
|
||||
console.log('-'.repeat(90))
|
||||
for (const d of list) {
|
||||
const id = String(d.id || '').padEnd(30)
|
||||
const name = String(d.fullName || '').padEnd(23)
|
||||
const code = String(d.enCode || '').padEnd(21)
|
||||
const cat = String(d.category || '')
|
||||
console.log(`${id}${name}${code}${cat}`)
|
||||
}
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '列出门户 (首页/工作台设计器产物)',
|
||||
optional: { '--keyword': '按名称/编码模糊搜索' },
|
||||
example: 'dacli portal list\ndacli portal list --keyword=工作台',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/visualPortal/index.vue',
|
||||
api: 'GET /api/visualdev/Portal',
|
||||
ref: 'doc/v0.8-endpoints.md §1.3',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* commands/portal/release.ts — 发布门户
|
||||
*
|
||||
* API: PUT /api/visualdev/Portal/Actions/release/{portalId}
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log } from '../../core/log.ts'
|
||||
|
||||
interface ReleaseOpts {
|
||||
id: string
|
||||
}
|
||||
|
||||
export function buildPortalReleaseCommand(): Command {
|
||||
const cmd = new Command('release')
|
||||
.description('发布门户 (state 0→1)')
|
||||
.requiredOption('--id <id>', '门户 id')
|
||||
.action(async (opts: ReleaseOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.putJson(`/visualdev/Portal/Actions/release/${opts.id}`, {})
|
||||
if (r.code !== 200) {
|
||||
log.error(`portal release 失败: ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
log.info(`✓ 门户 id=${opts.id} 已发布`)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '发布门户 (state 0→1, 菜单可挂)',
|
||||
required: { '--id': '门户 id' },
|
||||
example: 'dacli portal release --id=1234567890',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/visualPortal/Form.vue',
|
||||
api: 'PUT /api/visualdev/Portal/Actions/release/{portalId}',
|
||||
ref: 'doc/v0.8-endpoints.md §1.3',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* commands/report/create.ts — 新建报表
|
||||
*
|
||||
* 决策 6: 报表 webType=1/2, 不需要物理表, 走 dataInterfaceId 拉数据
|
||||
*
|
||||
* API: POST /api/extend/ReportManage
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface CreateOpts {
|
||||
fullName: string
|
||||
enCode: string
|
||||
category: string
|
||||
/** 报表 design JSON, 简化版 */
|
||||
design?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildReportCreateCommand(): Command {
|
||||
const cmd = new Command('create')
|
||||
.description('新建报表 (无物理表, 走 dataInterfaceId 拉数据)')
|
||||
.requiredOption('--fullName <name>', '报表名称')
|
||||
.requiredOption('--enCode <code>', '报表编码')
|
||||
.requiredOption('--category <cat>', '分类: 1=简易报表 2=专业报表')
|
||||
.option('--design <json>', '报表 design JSON 字符串 (简化版)')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: CreateOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
let design: unknown
|
||||
if (opts.design) {
|
||||
try {
|
||||
design = JSON.parse(opts.design)
|
||||
} catch (e) {
|
||||
log.error(`--design JSON 解析失败: ${(e as Error).message}`)
|
||||
process.exit(2)
|
||||
}
|
||||
} else {
|
||||
// 占位 design, 走流程
|
||||
design = {
|
||||
version: 'v1',
|
||||
components: [],
|
||||
}
|
||||
}
|
||||
const body = {
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
category: opts.category,
|
||||
type: 1,
|
||||
design: JSON.stringify(design),
|
||||
enabledMark: 1,
|
||||
sortCode: 0,
|
||||
}
|
||||
const r = await c.postJson<{ id: string }>('/extend/ReportManage', body)
|
||||
if (r.code !== 200) {
|
||||
log.error(`report create 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const id = r.data?.id
|
||||
log.info(`✓ 报表创建成功 id=${id}`)
|
||||
if (opts.json) printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '新建报表 (报表设计器产物, 走 dataInterfaceId 拉数据)',
|
||||
required: {
|
||||
'--fullName': '报表名称',
|
||||
'--enCode': '报表编码',
|
||||
'--category': '分类 1=简易报表 2=专业报表',
|
||||
},
|
||||
optional: {
|
||||
'--design': '报表 design JSON 字符串',
|
||||
'--json': '原始 JSON 输出',
|
||||
},
|
||||
example:
|
||||
'dacli report create --fullName=月销售报表 --enCode=monthSales --category=2',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/report/Form.vue',
|
||||
api: 'POST /api/extend/ReportManage',
|
||||
ref: 'doc/v0.8-endpoints.md §1.2',
|
||||
},
|
||||
notes: [
|
||||
'**决策 6**: 报表不需要物理表, 走 di 拉数据, 不要 dm create',
|
||||
'**决策 6**: webType 1-2 (报表设计器), 不是 form 的 webType',
|
||||
],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* commands/report/index.ts — report 父命令
|
||||
*
|
||||
* 报表设计器 (onlineDev/report + extend/ReportManage)
|
||||
*
|
||||
* 子命令:
|
||||
* list 列表
|
||||
* info 详情
|
||||
* create 新建
|
||||
* release 发布 (state 0→1)
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { buildReportListCommand } from './list.ts'
|
||||
import { buildReportInfoCommand } from './info.ts'
|
||||
import { buildReportCreateCommand } from './create.ts'
|
||||
import { buildReportReleaseCommand } from './release.ts'
|
||||
|
||||
export function buildReportCommand(): Command {
|
||||
const cmd = new Command('report').description('报表设计器 CRUD (报表产物, 走 dataInterface 拉数据)')
|
||||
cmd.addCommand(buildReportListCommand())
|
||||
cmd.addCommand(buildReportInfoCommand())
|
||||
cmd.addCommand(buildReportCreateCommand())
|
||||
cmd.addCommand(buildReportReleaseCommand())
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* commands/report/info.ts — 报表详情
|
||||
*
|
||||
* API: GET /api/extend/ReportManage/{id} (推断; 端点清单见 v0.8-endpoints.md)
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface InfoOpts {
|
||||
id: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildReportInfoCommand(): Command {
|
||||
const cmd = new Command('info')
|
||||
.description('查看报表详情 (含 schema)')
|
||||
.requiredOption('--id <id>', '报表 id')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: InfoOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
// 报表详情端点: 平台统一用 /extend/ReportManage/{id}
|
||||
const r = await c.get<Record<string, unknown>>(`/extend/ReportManage/${opts.id}`)
|
||||
if (r.code !== 200) {
|
||||
log.error(`report info 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
const d = r.data as Record<string, unknown>
|
||||
log.info(`报表 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`)
|
||||
console.log(`category: ${d.category}`)
|
||||
console.log(`type: ${d.type}`)
|
||||
console.log(`dbLinkId: ${d.dbLinkId || '(default)'}`)
|
||||
console.log(`creator: ${d.creatorUserId || '-'}`)
|
||||
console.log(`createTime: ${d.creatorTime || '-'}`)
|
||||
console.log(`--- 完整 JSON (含 design 字段) ---`)
|
||||
printJson(r.data)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '查看报表的完整 schema (含 design 字段)',
|
||||
required: { '--id': '报表 id' },
|
||||
example: 'dacli report info --id=1234567890\ndacli report info --id=1234567890 --json',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/report/Form.vue',
|
||||
api: 'GET /api/extend/ReportManage/{id}',
|
||||
ref: 'doc/v0.8-endpoints.md §1.2',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* commands/report/list.ts — 报表列表
|
||||
*
|
||||
* API: GET /api/extend/ReportManage
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface ListOpts {
|
||||
keyword?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildReportListCommand(): Command {
|
||||
const cmd = new Command('list')
|
||||
.description('列出报表')
|
||||
.option('--keyword <k>', '按名称/编码模糊搜索')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: ListOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const r = await c.get<{ list: Record<string, unknown>[] }>(
|
||||
'/extend/ReportManage',
|
||||
{ keyword: opts.keyword },
|
||||
)
|
||||
if (r.code !== 200) {
|
||||
log.error(`report list 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const list = r.data?.list || []
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
log.info(`共 ${list.length} 张报表`)
|
||||
console.log('ID FULL_NAME ENCODE CATEGORY')
|
||||
console.log('-'.repeat(90))
|
||||
for (const d of list) {
|
||||
const id = String(d.id || '').padEnd(30)
|
||||
const name = String(d.fullName || '').padEnd(23)
|
||||
const code = String(d.enCode || '').padEnd(21)
|
||||
const cat = String(d.category || '')
|
||||
console.log(`${id}${name}${code}${cat}`)
|
||||
}
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '列出当前应用所有报表 (报表设计器产物)',
|
||||
optional: { '--keyword': '按名称/编码模糊搜索' },
|
||||
example: 'dacli report list\ndacli report list --keyword=月报',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/report/index.vue',
|
||||
api: 'GET /api/extend/ReportManage',
|
||||
ref: 'doc/v0.8-endpoints.md §1.2',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* commands/report/release.ts — 发布报表
|
||||
*
|
||||
* API: PUT /api/extend/ReportManage/{id}/Actions/release (推断, 端点清单见 v0.8-endpoints.md)
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log } from '../../core/log.ts'
|
||||
|
||||
interface ReleaseOpts {
|
||||
id: string
|
||||
}
|
||||
|
||||
export function buildReportReleaseCommand(): Command {
|
||||
const cmd = new Command('release')
|
||||
.description('发布报表 (state 0→1)')
|
||||
.requiredOption('--id <id>', '报表 id')
|
||||
.action(async (opts: ReleaseOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
// 报表发布端点 — 平台统一 /Actions/release
|
||||
const r = await c.putJson(`/extend/ReportManage/${opts.id}/Actions/release`, {})
|
||||
if (r.code !== 200) {
|
||||
log.error(`report release 失败: ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
log.info(`✓ 报表 id=${opts.id} 已发布`)
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '发布报表 (state 0→1, 菜单可挂)',
|
||||
required: { '--id': '报表 id' },
|
||||
example: 'dacli report release --id=1234567890',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/report/Form.vue',
|
||||
api: 'PUT /api/extend/ReportManage/{id}/Actions/release',
|
||||
ref: 'doc/v0.8-endpoints.md §1.2',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
Reference in new issue
Block a user