@newpeak/barista-cli 0.1.10 → 0.1.12
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/index.js +1 -1
- package/package.json +7 -3
- package/docs/ARCHITECTURE.md +0 -184
- package/docs/COMMANDS.md +0 -352
- package/docs/COMMAND_DESIGN_SPEC.md +0 -840
- package/docs/INTEGRATION_NOTES.md +0 -270
- package/docs/commands/REFERENCE.md +0 -323
- package/docs/commands/arabica/auth/index.md +0 -296
- package/docs/commands/liberica/auth/index.md +0 -133
- package/docs/commands/liberica/calendar/DESIGN.md +0 -333
- package/docs/commands/liberica/client-contacts/create.md +0 -152
- package/docs/commands/liberica/client-contacts/delete.md +0 -123
- package/docs/commands/liberica/client-contacts/get.md +0 -133
- package/docs/commands/liberica/client-contacts/list.md +0 -143
- package/docs/commands/liberica/client-contacts/update.md +0 -158
- package/docs/commands/liberica/context/index.md +0 -60
- package/docs/commands/liberica/currency/create.md +0 -145
- package/docs/commands/liberica/currency/delete.md +0 -121
- package/docs/commands/liberica/currency/disable.md +0 -119
- package/docs/commands/liberica/currency/enable.md +0 -115
- package/docs/commands/liberica/currency/get.md +0 -118
- package/docs/commands/liberica/currency/list.md +0 -149
- package/docs/commands/liberica/currency/update.md +0 -141
- package/docs/commands/liberica/employees/create.md +0 -185
- package/docs/commands/liberica/employees/disable.md +0 -138
- package/docs/commands/liberica/employees/enable.md +0 -137
- package/docs/commands/liberica/employees/get.md +0 -153
- package/docs/commands/liberica/employees/list.md +0 -168
- package/docs/commands/liberica/employees/update.md +0 -180
- package/docs/commands/liberica/locations/create.md +0 -195
- package/docs/commands/liberica/locations/list.md +0 -171
- package/docs/commands/liberica/materials/create.md +0 -293
- package/docs/commands/liberica/materials/delete.md +0 -240
- package/docs/commands/liberica/materials/disable.md +0 -150
- package/docs/commands/liberica/materials/enable.md +0 -146
- package/docs/commands/liberica/materials/get.md +0 -188
- package/docs/commands/liberica/materials/list.md +0 -198
- package/docs/commands/liberica/materials/update.md +0 -250
- package/docs/commands/liberica/orgs/list.md +0 -62
- package/docs/commands/liberica/positions/list.md +0 -61
- package/docs/commands/liberica/roles/list.md +0 -67
- package/docs/commands/liberica/stock/ledger.md +0 -209
- package/docs/commands/liberica/stock/list.md +0 -165
- package/docs/commands/liberica/supplier-contacts/create.md +0 -152
- package/docs/commands/liberica/supplier-contacts/delete.md +0 -123
- package/docs/commands/liberica/supplier-contacts/get.md +0 -133
- package/docs/commands/liberica/supplier-contacts/list.md +0 -143
- package/docs/commands/liberica/supplier-contacts/update.md +0 -158
- package/docs/commands/liberica/teams/issues/close.md +0 -161
- package/docs/commands/liberica/teams/issues/create.md +0 -212
- package/docs/commands/liberica/teams/issues/delete.md +0 -179
- package/docs/commands/liberica/teams/issues/get.md +0 -167
- package/docs/commands/liberica/teams/issues/list.md +0 -182
- package/docs/commands/liberica/teams/issues/tests-design.md +0 -341
- package/docs/commands/liberica/teams/issues/update.md +0 -202
- package/docs/commands/liberica/teams/projects/create.md +0 -174
- package/docs/commands/liberica/teams/projects/delete.md +0 -180
- package/docs/commands/liberica/teams/projects/get.md +0 -150
- package/docs/commands/liberica/teams/projects/list.md +0 -179
- package/docs/commands/liberica/teams/projects/update.md +0 -175
- package/docs/commands/liberica/teams/tasks/create.md +0 -163
- package/docs/commands/liberica/teams/tasks/delete.md +0 -109
- package/docs/commands/liberica/teams/tasks/get.md +0 -121
- package/docs/commands/liberica/teams/tasks/list.md +0 -148
- package/docs/commands/liberica/teams/tasks/update.md +0 -158
- package/docs/commands/liberica/teams/work-logs/create.md +0 -151
- package/docs/commands/liberica/teams/work-logs/delete.md +0 -130
- package/docs/commands/liberica/teams/work-logs/get.md +0 -131
- package/docs/commands/liberica/teams/work-logs/list.md +0 -153
- package/docs/commands/liberica/teams/work-logs/update.md +0 -150
- package/docs/commands/liberica/transfer-in-forms/batch-delete.md +0 -157
- package/docs/commands/liberica/transfer-in-forms/batch-review.md +0 -157
- package/docs/commands/liberica/transfer-in-forms/batch-unreview.md +0 -157
- package/docs/commands/liberica/transfer-in-forms/create.md +0 -220
- package/docs/commands/liberica/transfer-in-forms/get.md +0 -221
- package/docs/commands/liberica/transfer-in-forms/list.md +0 -242
- package/docs/commands/liberica/transfer-in-forms/update.md +0 -185
- package/docs/commands/liberica/transfer-out-forms/batch-delete.md +0 -187
- package/docs/commands/liberica/transfer-out-forms/batch-review.md +0 -157
- package/docs/commands/liberica/transfer-out-forms/batch-unreview.md +0 -157
- package/docs/commands/liberica/transfer-out-forms/create.md +0 -280
- package/docs/commands/liberica/transfer-out-forms/get.md +0 -211
- package/docs/commands/liberica/transfer-out-forms/list.md +0 -233
- package/docs/commands/liberica/transfer-out-forms/update.md +0 -286
- package/docs/commands/liberica/uoms/create.md +0 -136
- package/docs/commands/liberica/uoms/delete.md +0 -119
- package/docs/commands/liberica/uoms/disable.md +0 -117
- package/docs/commands/liberica/uoms/enable.md +0 -115
- package/docs/commands/liberica/uoms/get.md +0 -119
- package/docs/commands/liberica/uoms/list.md +0 -155
- package/docs/commands/liberica/uoms/update.md +0 -148
- package/docs/commands/liberica/users/create.md +0 -170
- package/docs/commands/liberica/users/get.md +0 -151
- package/docs/commands/liberica/users/list.md +0 -175
- package/docs/commands/liberica/warehouses/create.md +0 -222
- package/docs/commands/liberica/warehouses/list.md +0 -184
- package/src/commands/arabica/auth/index.ts +0 -277
- package/src/commands/arabica/auth/login.ts +0 -5
- package/src/commands/arabica/auth/logout.ts +0 -5
- package/src/commands/arabica/auth/register.ts +0 -5
- package/src/commands/arabica/auth/status.ts +0 -5
- package/src/commands/arabica/index.ts +0 -23
- package/src/commands/auth.ts +0 -107
- package/src/commands/context.ts +0 -60
- package/src/commands/liberica/auth/index.ts +0 -176
- package/src/commands/liberica/calendar/index.ts +0 -13
- package/src/commands/liberica/calendar/list.ts +0 -214
- package/src/commands/liberica/calendar/set.ts +0 -130
- package/src/commands/liberica/client-contacts/create.ts +0 -115
- package/src/commands/liberica/client-contacts/delete.ts +0 -140
- package/src/commands/liberica/client-contacts/get.ts +0 -103
- package/src/commands/liberica/client-contacts/index.ts +0 -19
- package/src/commands/liberica/client-contacts/list.ts +0 -118
- package/src/commands/liberica/client-contacts/update.ts +0 -137
- package/src/commands/liberica/clients/create.ts +0 -122
- package/src/commands/liberica/clients/delete.ts +0 -125
- package/src/commands/liberica/clients/get.ts +0 -88
- package/src/commands/liberica/clients/index.ts +0 -19
- package/src/commands/liberica/clients/list.ts +0 -123
- package/src/commands/liberica/clients/update.ts +0 -103
- package/src/commands/liberica/context/index.ts +0 -43
- package/src/commands/liberica/currency/create.ts +0 -183
- package/src/commands/liberica/currency/delete.ts +0 -124
- package/src/commands/liberica/currency/disable.ts +0 -147
- package/src/commands/liberica/currency/enable.ts +0 -128
- package/src/commands/liberica/currency/get.ts +0 -91
- package/src/commands/liberica/currency/index.ts +0 -23
- package/src/commands/liberica/currency/list.ts +0 -140
- package/src/commands/liberica/currency/update.ts +0 -129
- package/src/commands/liberica/dict-types/get.ts +0 -74
- package/src/commands/liberica/dict-types/index.ts +0 -15
- package/src/commands/liberica/dict-types/list.ts +0 -118
- package/src/commands/liberica/dict-types/update.ts +0 -134
- package/src/commands/liberica/dicts/create.ts +0 -175
- package/src/commands/liberica/dicts/delete.ts +0 -107
- package/src/commands/liberica/dicts/get.ts +0 -80
- package/src/commands/liberica/dicts/index.ts +0 -19
- package/src/commands/liberica/dicts/list.ts +0 -114
- package/src/commands/liberica/dicts/update.ts +0 -116
- package/src/commands/liberica/employees/create.ts +0 -275
- package/src/commands/liberica/employees/delete.ts +0 -122
- package/src/commands/liberica/employees/disable.ts +0 -97
- package/src/commands/liberica/employees/enable.ts +0 -97
- package/src/commands/liberica/employees/get.ts +0 -115
- package/src/commands/liberica/employees/index.ts +0 -23
- package/src/commands/liberica/employees/list.ts +0 -131
- package/src/commands/liberica/employees/update.ts +0 -157
- package/src/commands/liberica/index.ts +0 -81
- package/src/commands/liberica/materials/create.ts +0 -199
- package/src/commands/liberica/materials/delete.ts +0 -105
- package/src/commands/liberica/materials/disable.ts +0 -148
- package/src/commands/liberica/materials/enable.ts +0 -129
- package/src/commands/liberica/materials/get.ts +0 -83
- package/src/commands/liberica/materials/index.ts +0 -23
- package/src/commands/liberica/materials/list.ts +0 -142
- package/src/commands/liberica/materials/update.ts +0 -125
- package/src/commands/liberica/mould/get.ts +0 -111
- package/src/commands/liberica/mould/index.ts +0 -17
- package/src/commands/liberica/mould/list.ts +0 -157
- package/src/commands/liberica/mould/set-status.ts +0 -99
- package/src/commands/liberica/mould/stock-in.ts +0 -165
- package/src/commands/liberica/operations/active.ts +0 -153
- package/src/commands/liberica/operations/batch-delete.ts +0 -131
- package/src/commands/liberica/operations/copy.ts +0 -138
- package/src/commands/liberica/operations/create.ts +0 -223
- package/src/commands/liberica/operations/deactive.ts +0 -152
- package/src/commands/liberica/operations/delete.ts +0 -128
- package/src/commands/liberica/operations/design.md +0 -587
- package/src/commands/liberica/operations/get.ts +0 -112
- package/src/commands/liberica/operations/index.ts +0 -27
- package/src/commands/liberica/operations/list.ts +0 -180
- package/src/commands/liberica/operations/update.ts +0 -218
- package/src/commands/liberica/orgs/index.ts +0 -34
- package/src/commands/liberica/positions/index.ts +0 -30
- package/src/commands/liberica/roles/index.ts +0 -59
- package/src/commands/liberica/stock/index.ts +0 -13
- package/src/commands/liberica/stock/ledger.ts +0 -159
- package/src/commands/liberica/stock/list.ts +0 -128
- package/src/commands/liberica/supplier-contacts/create.ts +0 -120
- package/src/commands/liberica/supplier-contacts/delete.ts +0 -88
- package/src/commands/liberica/supplier-contacts/get.ts +0 -94
- package/src/commands/liberica/supplier-contacts/index.ts +0 -19
- package/src/commands/liberica/supplier-contacts/list.ts +0 -130
- package/src/commands/liberica/supplier-contacts/update.ts +0 -127
- package/src/commands/liberica/suppliers/create.ts +0 -149
- package/src/commands/liberica/suppliers/delete.ts +0 -102
- package/src/commands/liberica/suppliers/disable.ts +0 -145
- package/src/commands/liberica/suppliers/enable.ts +0 -126
- package/src/commands/liberica/suppliers/get.ts +0 -86
- package/src/commands/liberica/suppliers/index.ts +0 -23
- package/src/commands/liberica/suppliers/list.ts +0 -134
- package/src/commands/liberica/suppliers/update.ts +0 -128
- package/src/commands/liberica/teams/index.ts +0 -17
- package/src/commands/liberica/teams/issues/close.ts +0 -104
- package/src/commands/liberica/teams/issues/create.ts +0 -254
- package/src/commands/liberica/teams/issues/delete.ts +0 -58
- package/src/commands/liberica/teams/issues/get.ts +0 -78
- package/src/commands/liberica/teams/issues/index.ts +0 -21
- package/src/commands/liberica/teams/issues/list.ts +0 -144
- package/src/commands/liberica/teams/issues/update.ts +0 -141
- package/src/commands/liberica/teams/projects/create.ts +0 -159
- package/src/commands/liberica/teams/projects/delete.ts +0 -58
- package/src/commands/liberica/teams/projects/get.ts +0 -87
- package/src/commands/liberica/teams/projects/index.ts +0 -19
- package/src/commands/liberica/teams/projects/list.ts +0 -147
- package/src/commands/liberica/teams/projects/update.ts +0 -117
- package/src/commands/liberica/teams/tasks/create.ts +0 -102
- package/src/commands/liberica/teams/tasks/delete.ts +0 -92
- package/src/commands/liberica/teams/tasks/get.ts +0 -64
- package/src/commands/liberica/teams/tasks/index.ts +0 -19
- package/src/commands/liberica/teams/tasks/list.ts +0 -102
- package/src/commands/liberica/teams/tasks/update.ts +0 -122
- package/src/commands/liberica/teams/work-logs/create.ts +0 -204
- package/src/commands/liberica/teams/work-logs/delete.ts +0 -58
- package/src/commands/liberica/teams/work-logs/get.ts +0 -87
- package/src/commands/liberica/teams/work-logs/index.ts +0 -19
- package/src/commands/liberica/teams/work-logs/list.ts +0 -141
- package/src/commands/liberica/teams/work-logs/update.ts +0 -120
- package/src/commands/liberica/transfer-in-forms/batch-delete.ts +0 -152
- package/src/commands/liberica/transfer-in-forms/batch-review.ts +0 -151
- package/src/commands/liberica/transfer-in-forms/batch-unreview.ts +0 -152
- package/src/commands/liberica/transfer-in-forms/create.ts +0 -179
- package/src/commands/liberica/transfer-in-forms/get.ts +0 -107
- package/src/commands/liberica/transfer-in-forms/index.ts +0 -23
- package/src/commands/liberica/transfer-in-forms/list.ts +0 -97
- package/src/commands/liberica/transfer-in-forms/update.ts +0 -213
- package/src/commands/liberica/transfer-out-forms/batch-delete.ts +0 -83
- package/src/commands/liberica/transfer-out-forms/batch-review.ts +0 -148
- package/src/commands/liberica/transfer-out-forms/batch-unreview.ts +0 -56
- package/src/commands/liberica/transfer-out-forms/create.ts +0 -194
- package/src/commands/liberica/transfer-out-forms/get.ts +0 -114
- package/src/commands/liberica/transfer-out-forms/index.ts +0 -23
- package/src/commands/liberica/transfer-out-forms/list.ts +0 -125
- package/src/commands/liberica/transfer-out-forms/update.ts +0 -197
- package/src/commands/liberica/uoms/create.ts +0 -134
- package/src/commands/liberica/uoms/delete.ts +0 -105
- package/src/commands/liberica/uoms/disable.ts +0 -148
- package/src/commands/liberica/uoms/enable.ts +0 -129
- package/src/commands/liberica/uoms/get.ts +0 -83
- package/src/commands/liberica/uoms/index.ts +0 -23
- package/src/commands/liberica/uoms/list.ts +0 -129
- package/src/commands/liberica/uoms/update.ts +0 -124
- package/src/commands/liberica/users/create.ts +0 -133
- package/src/commands/liberica/users/delete.ts +0 -49
- package/src/commands/liberica/users/disable.ts +0 -41
- package/src/commands/liberica/users/enable.ts +0 -30
- package/src/commands/liberica/users/get.ts +0 -46
- package/src/commands/liberica/users/index.ts +0 -27
- package/src/commands/liberica/users/list.ts +0 -68
- package/src/commands/liberica/users/me.ts +0 -42
- package/src/commands/liberica/users/reset-password.ts +0 -42
- package/src/commands/liberica/users/update.ts +0 -48
- package/src/commands/liberica/warehouses/create.ts +0 -204
- package/src/commands/liberica/warehouses/delete.ts +0 -112
- package/src/commands/liberica/warehouses/disable.ts +0 -174
- package/src/commands/liberica/warehouses/enable.ts +0 -174
- package/src/commands/liberica/warehouses/get.ts +0 -101
- package/src/commands/liberica/warehouses/index.ts +0 -25
- package/src/commands/liberica/warehouses/list.ts +0 -136
- package/src/commands/liberica/warehouses/locations/create.ts +0 -209
- package/src/commands/liberica/warehouses/locations/delete.ts +0 -116
- package/src/commands/liberica/warehouses/locations/disable.ts +0 -174
- package/src/commands/liberica/warehouses/locations/enable.ts +0 -174
- package/src/commands/liberica/warehouses/locations/get.ts +0 -84
- package/src/commands/liberica/warehouses/locations/index.ts +0 -23
- package/src/commands/liberica/warehouses/locations/list.ts +0 -140
- package/src/commands/liberica/warehouses/locations/update.ts +0 -135
- package/src/commands/liberica/warehouses/update.ts +0 -142
- package/src/core/api/client.ts +0 -4443
- package/src/core/auth/token-manager.ts +0 -183
- package/src/core/config/manager.ts +0 -164
- package/src/index.ts +0 -35
- package/src/types/calendar.ts +0 -36
- package/src/types/client-contact.ts +0 -78
- package/src/types/client.ts +0 -115
- package/src/types/currency.ts +0 -90
- package/src/types/dict.ts +0 -121
- package/src/types/employee.ts +0 -102
- package/src/types/index.ts +0 -93
- package/src/types/location.ts +0 -66
- package/src/types/material.ts +0 -61
- package/src/types/mould-stock-in.ts +0 -82
- package/src/types/mould.ts +0 -74
- package/src/types/operation.ts +0 -72
- package/src/types/org.ts +0 -25
- package/src/types/position.ts +0 -24
- package/src/types/stock.ts +0 -161
- package/src/types/supplier-contact.ts +0 -78
- package/src/types/supplier.ts +0 -66
- package/src/types/team-issue.ts +0 -94
- package/src/types/team-project.ts +0 -74
- package/src/types/team-task.ts +0 -98
- package/src/types/team-work-log.ts +0 -87
- package/src/types/transfer-in-form.ts +0 -265
- package/src/types/transfer-out-form.ts +0 -290
- package/src/types/uom.ts +0 -60
- package/src/types/user.ts +0 -64
- package/src/types/warehouse.ts +0 -82
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import Table from 'cli-table3';
|
|
4
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
-
import { DictType, DictStatusFlag } from '../../../types/dict.js';
|
|
7
|
-
import { Environment } from '../../../types/index.js';
|
|
8
|
-
|
|
9
|
-
export function createDictTypeListCommand(): Command {
|
|
10
|
-
const listCommand = new Command('list');
|
|
11
|
-
listCommand.description('List dictionary types with pagination');
|
|
12
|
-
|
|
13
|
-
listCommand
|
|
14
|
-
.option('-p, --page <number>', 'Page number', '1')
|
|
15
|
-
.option('-s, --size <number>', 'Page size', '20')
|
|
16
|
-
.option('--status <string>', 'Status filter (enable/disable)')
|
|
17
|
-
.option('--keyword <string>', 'Keyword search (dictTypeCode and dictTypeName)')
|
|
18
|
-
.option('--json', 'Output as JSON')
|
|
19
|
-
.action(async (options) => {
|
|
20
|
-
const context = configManager.getCurrentContext();
|
|
21
|
-
const environment = (options.env as Environment) || context.environment;
|
|
22
|
-
const tenant = options.tenant || context.tenant;
|
|
23
|
-
|
|
24
|
-
const page = parseInt(options.page as string, 10) - 1;
|
|
25
|
-
const size = parseInt(options.size as string, 10);
|
|
26
|
-
|
|
27
|
-
const params: {
|
|
28
|
-
pageNo: number;
|
|
29
|
-
pageSize: number;
|
|
30
|
-
status?: DictStatusFlag;
|
|
31
|
-
dictTypeCode?: string;
|
|
32
|
-
dictTypeName?: string;
|
|
33
|
-
} = { pageNo: page, pageSize: size };
|
|
34
|
-
|
|
35
|
-
if (options.status !== undefined) {
|
|
36
|
-
const statusVal = (options.status as string).toLowerCase();
|
|
37
|
-
if (statusVal === 'enable' || statusVal === '1') {
|
|
38
|
-
params.status = 1;
|
|
39
|
-
} else if (statusVal === 'disable' || statusVal === '2') {
|
|
40
|
-
params.status = 2;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Keyword searches both dictTypeCode and dictTypeName
|
|
45
|
-
if (options.keyword !== undefined) {
|
|
46
|
-
const keyword = options.keyword as string;
|
|
47
|
-
params.dictTypeCode = keyword;
|
|
48
|
-
params.dictTypeName = keyword;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const response = await apiClient.listDictTypes(environment, tenant, params);
|
|
52
|
-
|
|
53
|
-
if (!response.success) {
|
|
54
|
-
console.error(chalk.red(`\n✗ Failed to list dictionary types: ${response.error?.message || 'Unknown error'}`));
|
|
55
|
-
if (response.error?.code) {
|
|
56
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
57
|
-
}
|
|
58
|
-
console.error();
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const records = (response.data as unknown as DictType[]) || [];
|
|
63
|
-
|
|
64
|
-
if (!records || records.length === 0) {
|
|
65
|
-
if (options.json) {
|
|
66
|
-
console.log(JSON.stringify({ success: true, data: { items: [] } }, null, 2));
|
|
67
|
-
} else {
|
|
68
|
-
console.log(chalk.bold('\n📖 Dict Type List\n'));
|
|
69
|
-
console.log(chalk.gray(' No dictionary types found\n'));
|
|
70
|
-
}
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (options.json) {
|
|
75
|
-
console.log(
|
|
76
|
-
JSON.stringify(
|
|
77
|
-
{
|
|
78
|
-
success: true,
|
|
79
|
-
data: {
|
|
80
|
-
items: records,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
null,
|
|
84
|
-
2
|
|
85
|
-
)
|
|
86
|
-
);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log(chalk.bold('\n📖 Dict Type List\n'));
|
|
91
|
-
|
|
92
|
-
const table = new Table({
|
|
93
|
-
head: [chalk.bold('ID'), chalk.bold('Code'), chalk.bold('Name'), chalk.bold('Status')],
|
|
94
|
-
colWidths: [14, 18, 35, 10],
|
|
95
|
-
style: {
|
|
96
|
-
head: [],
|
|
97
|
-
border: [],
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
for (const dictType of records) {
|
|
102
|
-
const statusText = dictType.statusFlag === 1 ? chalk.green('Enable') : chalk.red('Disable');
|
|
103
|
-
table.push([
|
|
104
|
-
dictType.dictTypeId,
|
|
105
|
-
dictType.dictTypeCode || '-',
|
|
106
|
-
dictType.dictTypeName || '-',
|
|
107
|
-
statusText,
|
|
108
|
-
]);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
console.log(table.toString());
|
|
112
|
-
console.log();
|
|
113
|
-
console.log(chalk.gray(` Total: ${records.length}`));
|
|
114
|
-
console.log();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return listCommand;
|
|
118
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
4
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
-
import { Environment } from '../../../types/index.js';
|
|
6
|
-
import { DictType, UpdateDictTypeRequest } from '../../../types/dict.js';
|
|
7
|
-
|
|
8
|
-
export function createDictTypeUpdateCommand(): Command {
|
|
9
|
-
const updateCommand = new Command('update');
|
|
10
|
-
updateCommand
|
|
11
|
-
.description('Update dictionary type')
|
|
12
|
-
.argument('<dict-type-id>', 'Dictionary Type ID')
|
|
13
|
-
.option('-c, --code <code>', 'Dictionary type code')
|
|
14
|
-
.option('-n, --name <name>', 'Dictionary type name')
|
|
15
|
-
.option('-s, --status <status>', 'Status (1: enable, 2: disable)')
|
|
16
|
-
.option('--sort <sort>', 'Sort order')
|
|
17
|
-
.option('--dry-run', 'Preview changes without making API call')
|
|
18
|
-
.option('--json', 'Output result as JSON')
|
|
19
|
-
.action(async (dictTypeId: string, options: Record<string, unknown>) => {
|
|
20
|
-
const context = configManager.getCurrentContext();
|
|
21
|
-
const environment = context.environment as Environment;
|
|
22
|
-
const tenant = context.tenant;
|
|
23
|
-
|
|
24
|
-
const fields: Partial<UpdateDictTypeRequest> = {};
|
|
25
|
-
if (options.code) fields.dictTypeCode = options.code as string;
|
|
26
|
-
if (options.name) fields.dictTypeName = options.name as string;
|
|
27
|
-
if (options.status) {
|
|
28
|
-
const status = parseInt(options.status as string, 10);
|
|
29
|
-
if (status === 1 || status === 2) {
|
|
30
|
-
fields.statusFlag = status as 1 | 2;
|
|
31
|
-
} else {
|
|
32
|
-
console.error(chalk.red('\n✗ Invalid status. Use 1 (enable) or 2 (disable)\n'));
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (options.sort) {
|
|
37
|
-
const sortOrder = parseInt(options.sort as string, 10);
|
|
38
|
-
if (!isNaN(sortOrder)) {
|
|
39
|
-
fields.sortOrder = sortOrder;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const providedFields = Object.keys(fields).filter(
|
|
44
|
-
(k) => fields[k as keyof UpdateDictTypeRequest] !== undefined && k !== 'dictTypeId'
|
|
45
|
-
);
|
|
46
|
-
if (providedFields.length === 0) {
|
|
47
|
-
console.error(
|
|
48
|
-
chalk.red('\n✗ No fields to update. Provide at least one of: --code, --name, --status, --sort\n')
|
|
49
|
-
);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (options.dryRun) {
|
|
54
|
-
console.log(chalk.bold(`\n📖 Update Dict Type — Dry Run (${environment})\n`));
|
|
55
|
-
console.log(chalk.gray(` Dict Type ID: ${dictTypeId}`));
|
|
56
|
-
console.log(chalk.gray('\n Changes to be applied:'));
|
|
57
|
-
for (const field of providedFields) {
|
|
58
|
-
const label = field.replace(/([A-Z])/g, (m) => ` ${m.toLowerCase()}`).trim();
|
|
59
|
-
console.log(chalk.cyan(` ${label}: "${fields[field as keyof UpdateDictTypeRequest]}"`));
|
|
60
|
-
}
|
|
61
|
-
console.log();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
let currentDictType: DictType | undefined;
|
|
66
|
-
try {
|
|
67
|
-
const dictTypeResponse = await apiClient.getDictType(environment, tenant, dictTypeId);
|
|
68
|
-
if (!dictTypeResponse.success || !dictTypeResponse.data) {
|
|
69
|
-
console.error(chalk.red(`\n✗ Dictionary type not found: ${dictTypeId}`));
|
|
70
|
-
if (dictTypeResponse.error?.message) {
|
|
71
|
-
console.error(chalk.gray(` ${dictTypeResponse.error.message}`));
|
|
72
|
-
}
|
|
73
|
-
if (dictTypeResponse.error?.code) {
|
|
74
|
-
console.error(chalk.gray(` Error code: ${dictTypeResponse.error.code}`));
|
|
75
|
-
}
|
|
76
|
-
console.error();
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
currentDictType = dictTypeResponse.data as DictType;
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error(chalk.red(`\n✗ Failed to fetch dictionary type: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
console.log(chalk.bold(`\n📖 Update Dict Type (${environment})\n`));
|
|
86
|
-
console.log(chalk.gray(` Dict Type ID: ${dictTypeId}`));
|
|
87
|
-
console.log(chalk.gray(` Current Name: ${currentDictType.dictTypeName}`));
|
|
88
|
-
console.log(chalk.gray('\n Changes:'));
|
|
89
|
-
for (const field of providedFields) {
|
|
90
|
-
const label = field.replace(/([A-Z])/g, (m) => ` ${m.toLowerCase()}`).trim();
|
|
91
|
-
const currentVal = (currentDictType as unknown as Record<string, unknown>)[field] ?? '(not set)';
|
|
92
|
-
const newVal = fields[field as keyof UpdateDictTypeRequest];
|
|
93
|
-
console.log(chalk.cyan(` ${label}: "${currentVal}" → "${newVal}"`));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const updateData: UpdateDictTypeRequest = { dictTypeId, ...fields };
|
|
97
|
-
try {
|
|
98
|
-
const response = await apiClient.updateDictType(environment, tenant, updateData);
|
|
99
|
-
|
|
100
|
-
if (response.success) {
|
|
101
|
-
if (options.json) {
|
|
102
|
-
console.log(JSON.stringify({ success: true, data: response.data }, null, 2));
|
|
103
|
-
} else {
|
|
104
|
-
console.log(chalk.green('\n✓ Dictionary type updated successfully\n'));
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
if (options.json) {
|
|
108
|
-
console.log(JSON.stringify({ success: false, error: response.error }, null, 2));
|
|
109
|
-
} else {
|
|
110
|
-
console.error(chalk.red(`\n✗ Update failed: ${response.error?.message || 'Unknown error'}`));
|
|
111
|
-
if (response.error?.code) {
|
|
112
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
113
|
-
}
|
|
114
|
-
console.error();
|
|
115
|
-
}
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (options.json) {
|
|
120
|
-
console.log(
|
|
121
|
-
JSON.stringify({
|
|
122
|
-
success: false,
|
|
123
|
-
error: { message: error instanceof Error ? error.message : 'Unknown error' },
|
|
124
|
-
})
|
|
125
|
-
);
|
|
126
|
-
} else {
|
|
127
|
-
console.error(chalk.red(`\n✗ Error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
128
|
-
}
|
|
129
|
-
process.exit(1);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return updateCommand;
|
|
134
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
-
import { CreateDictItemRequest, DictType } from '../../../types/dict.js';
|
|
7
|
-
|
|
8
|
-
function formatTable(data: CreateDictItemRequest): string {
|
|
9
|
-
const lines: string[] = [];
|
|
10
|
-
lines.push(` ${chalk.gray('Dict Type Code:')} ${data.dictTypeCode || '(not set)'}`);
|
|
11
|
-
lines.push(` ${chalk.gray('Code:')} ${data.dictCode || '(not set)'}`);
|
|
12
|
-
lines.push(` ${chalk.gray('Name:')} ${data.dictName || '(not set)'}`);
|
|
13
|
-
if (data.dictValue) lines.push(` ${chalk.gray('Value:')} ${data.dictValue}`);
|
|
14
|
-
if (data.sortOrder !== undefined) lines.push(` ${chalk.gray('Sort Order:')} ${data.sortOrder}`);
|
|
15
|
-
if (data.statusFlag) lines.push(` ${chalk.gray('Status:')} ${data.statusFlag === 1 ? 'Enabled' : 'Disabled'}`);
|
|
16
|
-
if (data.remark) lines.push(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
17
|
-
return lines.join('\n');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function createDictCreateCommand(): Command {
|
|
21
|
-
const cmd = new Command('create');
|
|
22
|
-
cmd.description('Create a new dictionary item');
|
|
23
|
-
|
|
24
|
-
cmd
|
|
25
|
-
.requiredOption('-t, --type-code <string>', 'Dict type code (e.g., ID_TYPE, sex) (required)')
|
|
26
|
-
.requiredOption('-c, --code <string>', 'Dict code (required)')
|
|
27
|
-
.requiredOption('-n, --name <string>', 'Dict name (required)')
|
|
28
|
-
.option('-p, --parent <string>', 'Parent dict ID (-1 for root)', '-1')
|
|
29
|
-
.option('-s, --status <string>', 'Status (1=enable, 2=disable)', '1')
|
|
30
|
-
.option('-o, --sort <number>', 'Sort order', '0')
|
|
31
|
-
.option('-v, --value <string>', 'Dict value')
|
|
32
|
-
.option('-r, --remark <text>', 'Remark')
|
|
33
|
-
.option('--dry-run', 'Preview without making API call')
|
|
34
|
-
.option('--json', 'Output as JSON');
|
|
35
|
-
|
|
36
|
-
cmd.action(async () => {
|
|
37
|
-
const context = configManager.getCurrentContext();
|
|
38
|
-
const opts = cmd.opts();
|
|
39
|
-
|
|
40
|
-
let typeCode = opts.typeCode as string | undefined;
|
|
41
|
-
const code = opts.code as string | undefined;
|
|
42
|
-
const name = opts.name as string | undefined;
|
|
43
|
-
const parentId = (opts.parent as string) === '-1' ? '-1' : (opts.parent as string);
|
|
44
|
-
const statusFlag = parseInt(opts.status as string, 10) || 1;
|
|
45
|
-
const sortOrder = parseInt(opts.sort as string, 10) || 0;
|
|
46
|
-
const dictValue = opts.value as string | undefined;
|
|
47
|
-
const remark = opts.remark as string | undefined;
|
|
48
|
-
const dryRun = opts.dryRun === true;
|
|
49
|
-
const outputJson = opts.json === true || process.argv.includes('--json');
|
|
50
|
-
|
|
51
|
-
if (!typeCode) {
|
|
52
|
-
const { inputTypeCode } = await inquirer.prompt([
|
|
53
|
-
{
|
|
54
|
-
type: 'input',
|
|
55
|
-
name: 'inputTypeCode',
|
|
56
|
-
message: 'Enter dict type code (e.g., ID_TYPE, sex):',
|
|
57
|
-
validate: (input: string) => input.trim().length > 0 || 'Dict type code is required',
|
|
58
|
-
},
|
|
59
|
-
]);
|
|
60
|
-
typeCode = inputTypeCode;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Look up dictTypeId from typeCode before creating
|
|
64
|
-
const dictTypeResponse = await apiClient.listDictTypes(
|
|
65
|
-
context.environment,
|
|
66
|
-
context.tenant,
|
|
67
|
-
{ dictTypeCode: typeCode, pageSize: 100 }
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
if (!dictTypeResponse.success || !dictTypeResponse.data) {
|
|
71
|
-
if (outputJson) {
|
|
72
|
-
console.log(JSON.stringify({ success: false, error: { code: 'DICT_TYPE_NOT_FOUND', message: `Dict type not found: ${typeCode}` } }));
|
|
73
|
-
} else {
|
|
74
|
-
console.error(chalk.red(`\n✗ Dict type not found: ${typeCode}\n`));
|
|
75
|
-
}
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// response.data is an array of DictType since the API returns plain array
|
|
80
|
-
const dictTypes = dictTypeResponse.data as unknown as DictType[];
|
|
81
|
-
const matchedDictType = dictTypes.find(dt => dt.dictTypeCode === typeCode);
|
|
82
|
-
|
|
83
|
-
if (!matchedDictType) {
|
|
84
|
-
if (outputJson) {
|
|
85
|
-
console.log(JSON.stringify({ success: false, error: { code: 'DICT_TYPE_NOT_FOUND', message: `Dict type not found: ${typeCode}` } }));
|
|
86
|
-
} else {
|
|
87
|
-
console.error(chalk.red(`\n✗ Dict type not found: ${typeCode}\n`));
|
|
88
|
-
}
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const dictTypeId = matchedDictType.dictTypeId;
|
|
93
|
-
|
|
94
|
-
const data: CreateDictItemRequest = {
|
|
95
|
-
dictTypeId: dictTypeId,
|
|
96
|
-
dictCode: code!,
|
|
97
|
-
dictName: name!,
|
|
98
|
-
dictValue: dictValue || name!,
|
|
99
|
-
sortOrder: sortOrder,
|
|
100
|
-
statusFlag: statusFlag as 1 | 2,
|
|
101
|
-
remark: remark,
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// Add parent and predefinedFlag as additional fields
|
|
105
|
-
data.dictParentId = parentId;
|
|
106
|
-
data.predefinedFlag = 'N';
|
|
107
|
-
|
|
108
|
-
if (dryRun) {
|
|
109
|
-
if (outputJson) {
|
|
110
|
-
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
111
|
-
} else {
|
|
112
|
-
console.log(chalk.bold('\n🔍 Dry-Run Mode: No changes will be made\n'));
|
|
113
|
-
console.log(' Dict item to be created:');
|
|
114
|
-
console.log(formatTable(data));
|
|
115
|
-
console.log();
|
|
116
|
-
}
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (!outputJson) {
|
|
121
|
-
console.log(chalk.bold('\n📝 Creating Dict Item\n'));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const response = await apiClient.createDictItem(context.environment, context.tenant, data);
|
|
125
|
-
|
|
126
|
-
if (!response.success) {
|
|
127
|
-
const errorMsg = response.error?.message || 'Failed to create dict item';
|
|
128
|
-
const errorCode = response.error?.code || 'CREATE_DICT_ITEM_ERROR';
|
|
129
|
-
if (outputJson) {
|
|
130
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
131
|
-
} else {
|
|
132
|
-
console.error(chalk.red(`\n✗ Failed to create dict item: ${errorMsg}`));
|
|
133
|
-
if (response.error?.code) {
|
|
134
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
135
|
-
}
|
|
136
|
-
console.error();
|
|
137
|
-
}
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (response.success) {
|
|
142
|
-
const dictItem = response.data as {
|
|
143
|
-
dictId?: string;
|
|
144
|
-
dictTypeId?: string;
|
|
145
|
-
dictCode?: string;
|
|
146
|
-
dictName?: string;
|
|
147
|
-
dictValue?: string;
|
|
148
|
-
sortOrder?: number;
|
|
149
|
-
statusFlag?: number;
|
|
150
|
-
remark?: string;
|
|
151
|
-
createTime?: string;
|
|
152
|
-
} | undefined;
|
|
153
|
-
|
|
154
|
-
if (outputJson) {
|
|
155
|
-
console.log(JSON.stringify({ success: true, data: dictItem }));
|
|
156
|
-
} else {
|
|
157
|
-
console.log(chalk.green('✓ Dict item created successfully\n'));
|
|
158
|
-
if (dictItem?.dictId) console.log(` ${chalk.gray('Dict ID:')} ${chalk.green(String(dictItem.dictId))}`);
|
|
159
|
-
if (dictItem?.dictTypeId) console.log(` ${chalk.gray('Type ID:')} ${dictItem.dictTypeId}`);
|
|
160
|
-
if (dictItem?.dictCode) console.log(` ${chalk.gray('Code:')} ${dictItem.dictCode}`);
|
|
161
|
-
if (dictItem?.dictName) console.log(` ${chalk.gray('Name:')} ${dictItem.dictName}`);
|
|
162
|
-
if (dictItem?.dictValue) console.log(` ${chalk.gray('Value:')} ${dictItem.dictValue}`);
|
|
163
|
-
if (dictItem?.sortOrder !== undefined) console.log(` ${chalk.gray('Sort Order:')} ${dictItem.sortOrder}`);
|
|
164
|
-
if (dictItem?.statusFlag !== undefined) {
|
|
165
|
-
const statusText = dictItem.statusFlag === 1 ? 'Enabled' : 'Disabled';
|
|
166
|
-
console.log(` ${chalk.gray('Status:')} ${chalk.green(statusText)}`);
|
|
167
|
-
}
|
|
168
|
-
if (dictItem?.remark) console.log(` ${chalk.gray('Remark:')} ${dictItem.remark}`);
|
|
169
|
-
console.log();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
return cmd;
|
|
175
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
4
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
-
import { Environment } from '../../../types/index.js';
|
|
6
|
-
import { DictItem } from '../../../types/dict.js';
|
|
7
|
-
|
|
8
|
-
export function createDictDeleteCommand(): Command {
|
|
9
|
-
const deleteCommand = new Command('delete');
|
|
10
|
-
deleteCommand
|
|
11
|
-
.description('Delete a dictionary item')
|
|
12
|
-
.argument('<dictId>', 'Dict Item ID')
|
|
13
|
-
.option('--force', 'Skip confirmation and delete directly')
|
|
14
|
-
.option('--dry-run', 'Preview without making API call')
|
|
15
|
-
.option('--json', 'Output as JSON')
|
|
16
|
-
.action(async (dictId: string, options: Record<string, unknown>) => {
|
|
17
|
-
const context = configManager.getCurrentContext();
|
|
18
|
-
const environment = context.environment as Environment;
|
|
19
|
-
const tenant = context.tenant;
|
|
20
|
-
const dryRun = options.dryRun === true;
|
|
21
|
-
const jsonOutput = options.json === true;
|
|
22
|
-
|
|
23
|
-
if (!jsonOutput) {
|
|
24
|
-
console.log(chalk.bold(`\n🗑️ Delete Dictionary Item (${environment})\n`));
|
|
25
|
-
console.log(chalk.gray(` Dict ID: ${dictId}`));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let dictItem: DictItem | undefined;
|
|
29
|
-
try {
|
|
30
|
-
const dictResponse = await apiClient.getDictItem(environment, tenant, dictId);
|
|
31
|
-
if (!dictResponse.success || !dictResponse.data || !('dictId' in dictResponse.data)) {
|
|
32
|
-
const errMsg = `Dictionary item not found: ${dictId}`;
|
|
33
|
-
if (jsonOutput) {
|
|
34
|
-
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
35
|
-
} else {
|
|
36
|
-
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
37
|
-
}
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
dictItem = dictResponse.data as DictItem;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
43
|
-
if (jsonOutput) {
|
|
44
|
-
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch dictionary item: ${errMsg}` } }));
|
|
45
|
-
} else {
|
|
46
|
-
console.error(chalk.red(`\n✗ Failed to fetch dictionary item: ${errMsg}\n`));
|
|
47
|
-
}
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!jsonOutput) {
|
|
52
|
-
console.log(chalk.gray(` Name: ${dictItem.dictName}`));
|
|
53
|
-
console.log(chalk.gray(` Code: ${dictItem.dictCode}`));
|
|
54
|
-
console.log(chalk.gray(` Value: ${dictItem.dictValue}`));
|
|
55
|
-
console.log(chalk.gray(` Type ID: ${dictItem.dictTypeId}`));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (dryRun) {
|
|
59
|
-
if (jsonOutput) {
|
|
60
|
-
console.log(JSON.stringify({ success: true, dryRun: true, dictItem }));
|
|
61
|
-
} else {
|
|
62
|
-
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual deletion will be made\n'));
|
|
63
|
-
console.log(chalk.yellow(' To delete, add: --force\n'));
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!options.force) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const response = await apiClient.deleteDictItem(environment, tenant, dictId);
|
|
74
|
-
|
|
75
|
-
if (response.success) {
|
|
76
|
-
if (jsonOutput) {
|
|
77
|
-
console.log(JSON.stringify({ success: true, dictId, name: dictItem.dictName }));
|
|
78
|
-
} else {
|
|
79
|
-
console.log(chalk.green(`\n✓ Dictionary Item "${dictItem.dictName}" (ID: ${dictId}) deleted\n`));
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
const errorMsg = response.error?.message || 'Unknown error';
|
|
83
|
-
const errorCode = response.error?.code || 'DELETE_ERROR';
|
|
84
|
-
if (jsonOutput) {
|
|
85
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
86
|
-
} else {
|
|
87
|
-
console.error(chalk.red(`\n✗ Failed to delete dictionary item: ${errorMsg}`));
|
|
88
|
-
if (response.error?.code) {
|
|
89
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
90
|
-
}
|
|
91
|
-
console.error();
|
|
92
|
-
}
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
} catch (error) {
|
|
96
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
97
|
-
if (jsonOutput) {
|
|
98
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
99
|
-
} else {
|
|
100
|
-
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
101
|
-
}
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
return deleteCommand;
|
|
107
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
4
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
-
import { Environment } from '../../../types/index.js';
|
|
6
|
-
import { DictItem } from '../../../types/dict.js';
|
|
7
|
-
|
|
8
|
-
export function createDictGetCommand(): Command {
|
|
9
|
-
const getCommand = new Command('get');
|
|
10
|
-
getCommand.description('Get dictionary item details by ID');
|
|
11
|
-
getCommand.arguments('<dictId>');
|
|
12
|
-
getCommand.option('--json', 'Output as JSON');
|
|
13
|
-
|
|
14
|
-
getCommand.action(async (dictId: string, options: Record<string, unknown>) => {
|
|
15
|
-
const context = configManager.getCurrentContext();
|
|
16
|
-
const environment = (options.env as Environment) || context.environment;
|
|
17
|
-
const tenant = (options.tenant as string) || context.tenant;
|
|
18
|
-
|
|
19
|
-
if (!dictId) {
|
|
20
|
-
console.error(chalk.red('\n✗ Dict ID is required\n'));
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!dictId || dictId.trim() === '') {
|
|
25
|
-
console.error(chalk.red('\n✗ Invalid dict ID.\n'));
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const response = await apiClient.getDictItem(environment, tenant, dictId);
|
|
31
|
-
|
|
32
|
-
if (!response.success) {
|
|
33
|
-
const errorCode = response.error?.code || 'UNKNOWN_ERROR';
|
|
34
|
-
const errorMessage = response.error?.message || 'Unknown error';
|
|
35
|
-
|
|
36
|
-
// Handle "dict item not found" case
|
|
37
|
-
if (errorCode === '01001150001' || errorMessage.includes('不存在')) {
|
|
38
|
-
console.error(chalk.red(`\n✗ Dictionary item not found: ${dictId}\n`));
|
|
39
|
-
} else {
|
|
40
|
-
console.error(chalk.red(`\n✗ Error: ${errorMessage} (${errorCode})\n`));
|
|
41
|
-
}
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const dictItem = response.data as DictItem | null;
|
|
46
|
-
|
|
47
|
-
if (!dictItem) {
|
|
48
|
-
console.error(chalk.red('\n✗ Dictionary item not found\n'));
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (options.json) {
|
|
53
|
-
console.log(JSON.stringify({
|
|
54
|
-
success: true,
|
|
55
|
-
data: dictItem,
|
|
56
|
-
}, null, 2));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Table output
|
|
61
|
-
console.log(chalk.bold('\n📖 Dictionary Item Details\n'));
|
|
62
|
-
console.log(` ${chalk.gray('ID:')} ${dictItem.dictId}`);
|
|
63
|
-
console.log(` ${chalk.gray('Type ID:')} ${dictItem.dictTypeId}`);
|
|
64
|
-
console.log(` ${chalk.gray('Code:')} ${dictItem.dictCode}`);
|
|
65
|
-
console.log(` ${chalk.gray('Name:')} ${dictItem.dictName}`);
|
|
66
|
-
console.log(` ${chalk.gray('Value:')} ${dictItem.dictValue}`);
|
|
67
|
-
console.log(` ${chalk.gray('Sort Order:')} ${dictItem.sortOrder}`);
|
|
68
|
-
console.log(` ${chalk.gray('Status:')} ${dictItem.statusFlag === 1 ? 'Enable' : 'Disable'}`);
|
|
69
|
-
if (dictItem.remark) {
|
|
70
|
-
console.log(` ${chalk.gray('Remark:')} ${dictItem.remark}`);
|
|
71
|
-
}
|
|
72
|
-
console.log();
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.error(chalk.red(`\n✗ Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return getCommand;
|
|
80
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { createDictListCommand } from './list.js';
|
|
3
|
-
import { createDictGetCommand } from './get.js';
|
|
4
|
-
import { createDictDeleteCommand } from './delete.js';
|
|
5
|
-
import { createDictCreateCommand } from './create.js';
|
|
6
|
-
import { createDictUpdateCommand } from './update.js';
|
|
7
|
-
|
|
8
|
-
export function createDictsCommand(): Command {
|
|
9
|
-
const dictsCommand = new Command('dicts');
|
|
10
|
-
dictsCommand.description('Manage dictionary items');
|
|
11
|
-
|
|
12
|
-
dictsCommand.addCommand(createDictListCommand());
|
|
13
|
-
dictsCommand.addCommand(createDictGetCommand());
|
|
14
|
-
dictsCommand.addCommand(createDictDeleteCommand());
|
|
15
|
-
dictsCommand.addCommand(createDictCreateCommand());
|
|
16
|
-
dictsCommand.addCommand(createDictUpdateCommand());
|
|
17
|
-
|
|
18
|
-
return dictsCommand;
|
|
19
|
-
}
|