@newpeak/barista-cli 0.1.9 → 0.1.11
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/commands/liberica/index.d.ts.map +1 -1
- package/dist/commands/liberica/index.js +7 -0
- package/dist/commands/liberica/index.js.map +1 -1
- package/dist/commands/liberica/teams/index.d.ts +3 -0
- package/dist/commands/liberica/teams/index.d.ts.map +1 -0
- package/dist/commands/liberica/teams/index.js +15 -0
- package/dist/commands/liberica/teams/index.js.map +1 -0
- package/dist/commands/liberica/teams/issues/close.d.ts +3 -0
- package/dist/commands/liberica/teams/issues/close.d.ts.map +1 -0
- package/dist/commands/liberica/teams/issues/close.js +99 -0
- package/dist/commands/liberica/teams/issues/close.js.map +1 -0
- package/dist/commands/liberica/teams/issues/create.d.ts +3 -0
- package/dist/commands/liberica/teams/issues/create.d.ts.map +1 -0
- package/dist/commands/liberica/teams/issues/create.js +255 -0
- package/dist/commands/liberica/teams/issues/create.js.map +1 -0
- package/dist/commands/liberica/teams/issues/delete.d.ts +3 -0
- package/dist/commands/liberica/teams/issues/delete.d.ts.map +1 -0
- package/dist/commands/liberica/teams/issues/delete.js +55 -0
- package/dist/commands/liberica/teams/issues/delete.js.map +1 -0
- package/dist/commands/liberica/teams/issues/get.d.ts +3 -0
- package/dist/commands/liberica/teams/issues/get.d.ts.map +1 -0
- package/dist/commands/liberica/teams/issues/get.js +68 -0
- package/dist/commands/liberica/teams/issues/get.js.map +1 -0
- package/dist/commands/liberica/teams/issues/index.d.ts +3 -0
- package/dist/commands/liberica/teams/issues/index.d.ts.map +1 -0
- package/dist/commands/liberica/teams/issues/index.js +19 -0
- package/dist/commands/liberica/teams/issues/index.js.map +1 -0
- package/dist/commands/liberica/teams/issues/list.d.ts +3 -0
- package/dist/commands/liberica/teams/issues/list.d.ts.map +1 -0
- package/dist/commands/liberica/teams/issues/list.js +111 -0
- package/dist/commands/liberica/teams/issues/list.js.map +1 -0
- package/dist/commands/liberica/teams/issues/update.d.ts +3 -0
- package/dist/commands/liberica/teams/issues/update.d.ts.map +1 -0
- package/dist/commands/liberica/teams/issues/update.js +132 -0
- package/dist/commands/liberica/teams/issues/update.js.map +1 -0
- package/dist/commands/liberica/teams/projects/create.d.ts +3 -0
- package/dist/commands/liberica/teams/projects/create.d.ts.map +1 -0
- package/dist/commands/liberica/teams/projects/create.js +164 -0
- package/dist/commands/liberica/teams/projects/create.js.map +1 -0
- package/dist/commands/liberica/teams/projects/delete.d.ts +3 -0
- package/dist/commands/liberica/teams/projects/delete.d.ts.map +1 -0
- package/dist/commands/liberica/teams/projects/delete.js +55 -0
- package/dist/commands/liberica/teams/projects/delete.js.map +1 -0
- package/dist/commands/liberica/teams/projects/get.d.ts +3 -0
- package/dist/commands/liberica/teams/projects/get.d.ts.map +1 -0
- package/dist/commands/liberica/teams/projects/get.js +77 -0
- package/dist/commands/liberica/teams/projects/get.js.map +1 -0
- package/dist/commands/liberica/teams/projects/index.d.ts +3 -0
- package/dist/commands/liberica/teams/projects/index.d.ts.map +1 -0
- package/dist/commands/liberica/teams/projects/index.js +17 -0
- package/dist/commands/liberica/teams/projects/index.js.map +1 -0
- package/dist/commands/liberica/teams/projects/list.d.ts +3 -0
- package/dist/commands/liberica/teams/projects/list.d.ts.map +1 -0
- package/dist/commands/liberica/teams/projects/list.js +115 -0
- package/dist/commands/liberica/teams/projects/list.js.map +1 -0
- package/dist/commands/liberica/teams/projects/update.d.ts +3 -0
- package/dist/commands/liberica/teams/projects/update.d.ts.map +1 -0
- package/dist/commands/liberica/teams/projects/update.js +115 -0
- package/dist/commands/liberica/teams/projects/update.js.map +1 -0
- package/dist/commands/liberica/teams/tasks/create.d.ts +3 -0
- package/dist/commands/liberica/teams/tasks/create.d.ts.map +1 -0
- package/dist/commands/liberica/teams/tasks/create.js +88 -0
- package/dist/commands/liberica/teams/tasks/create.js.map +1 -0
- package/dist/commands/liberica/teams/tasks/delete.d.ts +3 -0
- package/dist/commands/liberica/teams/tasks/delete.d.ts.map +1 -0
- package/dist/commands/liberica/teams/tasks/delete.js +73 -0
- package/dist/commands/liberica/teams/tasks/delete.js.map +1 -0
- package/dist/commands/liberica/teams/tasks/get.d.ts +3 -0
- package/dist/commands/liberica/teams/tasks/get.d.ts.map +1 -0
- package/dist/commands/liberica/teams/tasks/get.js +51 -0
- package/dist/commands/liberica/teams/tasks/get.js.map +1 -0
- package/dist/commands/liberica/teams/tasks/index.d.ts +3 -0
- package/dist/commands/liberica/teams/tasks/index.d.ts.map +1 -0
- package/dist/commands/liberica/teams/tasks/index.js +17 -0
- package/dist/commands/liberica/teams/tasks/index.js.map +1 -0
- package/dist/commands/liberica/teams/tasks/list.d.ts +3 -0
- package/dist/commands/liberica/teams/tasks/list.d.ts.map +1 -0
- package/dist/commands/liberica/teams/tasks/list.js +82 -0
- package/dist/commands/liberica/teams/tasks/list.js.map +1 -0
- package/dist/commands/liberica/teams/tasks/update.d.ts +3 -0
- package/dist/commands/liberica/teams/tasks/update.d.ts.map +1 -0
- package/dist/commands/liberica/teams/tasks/update.js +114 -0
- package/dist/commands/liberica/teams/tasks/update.js.map +1 -0
- package/dist/commands/liberica/teams/work-logs/create.d.ts +3 -0
- package/dist/commands/liberica/teams/work-logs/create.d.ts.map +1 -0
- package/dist/commands/liberica/teams/work-logs/create.js +183 -0
- package/dist/commands/liberica/teams/work-logs/create.js.map +1 -0
- package/dist/commands/liberica/teams/work-logs/delete.d.ts +3 -0
- package/dist/commands/liberica/teams/work-logs/delete.d.ts.map +1 -0
- package/dist/commands/liberica/teams/work-logs/delete.js +55 -0
- package/dist/commands/liberica/teams/work-logs/delete.js.map +1 -0
- package/dist/commands/liberica/teams/work-logs/get.d.ts +3 -0
- package/dist/commands/liberica/teams/work-logs/get.d.ts.map +1 -0
- package/dist/commands/liberica/teams/work-logs/get.js +77 -0
- package/dist/commands/liberica/teams/work-logs/get.js.map +1 -0
- package/dist/commands/liberica/teams/work-logs/index.d.ts +3 -0
- package/dist/commands/liberica/teams/work-logs/index.d.ts.map +1 -0
- package/dist/commands/liberica/teams/work-logs/index.js +17 -0
- package/dist/commands/liberica/teams/work-logs/index.js.map +1 -0
- package/dist/commands/liberica/teams/work-logs/list.d.ts +3 -0
- package/dist/commands/liberica/teams/work-logs/list.d.ts.map +1 -0
- package/dist/commands/liberica/teams/work-logs/list.js +109 -0
- package/dist/commands/liberica/teams/work-logs/list.js.map +1 -0
- package/dist/commands/liberica/teams/work-logs/update.d.ts +3 -0
- package/dist/commands/liberica/teams/work-logs/update.d.ts.map +1 -0
- package/dist/commands/liberica/teams/work-logs/update.js +105 -0
- package/dist/commands/liberica/teams/work-logs/update.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/batch-delete.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/batch-delete.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/batch-delete.js +147 -0
- package/dist/commands/liberica/transfer-in-forms/batch-delete.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/batch-review.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/batch-review.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/batch-review.js +146 -0
- package/dist/commands/liberica/transfer-in-forms/batch-review.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/batch-unreview.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/batch-unreview.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/batch-unreview.js +147 -0
- package/dist/commands/liberica/transfer-in-forms/batch-unreview.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/create.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/create.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/create.js +168 -0
- package/dist/commands/liberica/transfer-in-forms/create.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/get.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/get.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/get.js +94 -0
- package/dist/commands/liberica/transfer-in-forms/get.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/index.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/index.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/index.js +21 -0
- package/dist/commands/liberica/transfer-in-forms/index.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/list.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/list.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/list.js +94 -0
- package/dist/commands/liberica/transfer-in-forms/list.js.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/update.d.ts +3 -0
- package/dist/commands/liberica/transfer-in-forms/update.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-in-forms/update.js +206 -0
- package/dist/commands/liberica/transfer-in-forms/update.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/batch-delete.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/batch-delete.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/batch-delete.js +80 -0
- package/dist/commands/liberica/transfer-out-forms/batch-delete.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/batch-review.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/batch-review.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/batch-review.js +142 -0
- package/dist/commands/liberica/transfer-out-forms/batch-review.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/batch-unreview.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/batch-unreview.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/batch-unreview.js +53 -0
- package/dist/commands/liberica/transfer-out-forms/batch-unreview.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/create.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/create.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/create.js +191 -0
- package/dist/commands/liberica/transfer-out-forms/create.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/get.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/get.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/get.js +87 -0
- package/dist/commands/liberica/transfer-out-forms/get.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/index.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/index.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/index.js +21 -0
- package/dist/commands/liberica/transfer-out-forms/index.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/list.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/list.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/list.js +118 -0
- package/dist/commands/liberica/transfer-out-forms/list.js.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/update.d.ts +3 -0
- package/dist/commands/liberica/transfer-out-forms/update.d.ts.map +1 -0
- package/dist/commands/liberica/transfer-out-forms/update.js +197 -0
- package/dist/commands/liberica/transfer-out-forms/update.js.map +1 -0
- package/dist/core/api/client.d.ts +42 -0
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +798 -0
- package/dist/core/api/client.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/team-issue.d.ts +87 -0
- package/dist/types/team-issue.d.ts.map +1 -0
- package/dist/types/team-issue.js +2 -0
- package/dist/types/team-issue.js.map +1 -0
- package/dist/types/team-project.d.ts +68 -0
- package/dist/types/team-project.d.ts.map +1 -0
- package/dist/types/team-project.js +2 -0
- package/dist/types/team-project.js.map +1 -0
- package/dist/types/team-task.d.ts +91 -0
- package/dist/types/team-task.d.ts.map +1 -0
- package/dist/types/team-task.js +2 -0
- package/dist/types/team-task.js.map +1 -0
- package/dist/types/team-work-log.d.ts +81 -0
- package/dist/types/team-work-log.d.ts.map +1 -0
- package/dist/types/team-work-log.js +2 -0
- package/dist/types/team-work-log.js.map +1 -0
- package/dist/types/transfer-in-form.d.ts +242 -0
- package/dist/types/transfer-in-form.d.ts.map +1 -0
- package/dist/types/transfer-in-form.js +2 -0
- package/dist/types/transfer-in-form.js.map +1 -0
- package/dist/types/transfer-out-form.d.ts +252 -0
- package/dist/types/transfer-out-form.d.ts.map +1 -0
- package/dist/types/transfer-out-form.js +4 -0
- package/dist/types/transfer-out-form.js.map +1 -0
- package/docs/commands/liberica/teams/issues/close.md +161 -0
- package/docs/commands/liberica/teams/issues/create.md +212 -0
- package/docs/commands/liberica/teams/issues/delete.md +179 -0
- package/docs/commands/liberica/teams/issues/get.md +167 -0
- package/docs/commands/liberica/teams/issues/list.md +182 -0
- package/docs/commands/liberica/teams/issues/tests-design.md +341 -0
- package/docs/commands/liberica/teams/issues/update.md +202 -0
- package/docs/commands/liberica/teams/projects/create.md +174 -0
- package/docs/commands/liberica/teams/projects/delete.md +180 -0
- package/docs/commands/liberica/teams/projects/get.md +150 -0
- package/docs/commands/liberica/teams/projects/list.md +179 -0
- package/docs/commands/liberica/teams/projects/update.md +175 -0
- package/docs/commands/liberica/teams/tasks/create.md +163 -0
- package/docs/commands/liberica/teams/tasks/delete.md +109 -0
- package/docs/commands/liberica/teams/tasks/get.md +121 -0
- package/docs/commands/liberica/teams/tasks/list.md +148 -0
- package/docs/commands/liberica/teams/tasks/update.md +158 -0
- package/docs/commands/liberica/teams/work-logs/create.md +151 -0
- package/docs/commands/liberica/teams/work-logs/delete.md +130 -0
- package/docs/commands/liberica/teams/work-logs/get.md +131 -0
- package/docs/commands/liberica/teams/work-logs/list.md +153 -0
- package/docs/commands/liberica/teams/work-logs/update.md +150 -0
- package/docs/commands/liberica/transfer-in-forms/batch-delete.md +157 -0
- package/docs/commands/liberica/transfer-in-forms/batch-review.md +157 -0
- package/docs/commands/liberica/transfer-in-forms/batch-unreview.md +157 -0
- package/docs/commands/liberica/transfer-in-forms/create.md +220 -0
- package/docs/commands/liberica/transfer-in-forms/get.md +221 -0
- package/docs/commands/liberica/transfer-in-forms/list.md +242 -0
- package/docs/commands/liberica/transfer-in-forms/update.md +185 -0
- package/docs/commands/liberica/transfer-out-forms/batch-delete.md +187 -0
- package/docs/commands/liberica/transfer-out-forms/batch-review.md +157 -0
- package/docs/commands/liberica/transfer-out-forms/batch-unreview.md +157 -0
- package/docs/commands/liberica/transfer-out-forms/create.md +280 -0
- package/docs/commands/liberica/transfer-out-forms/get.md +211 -0
- package/docs/commands/liberica/transfer-out-forms/list.md +233 -0
- package/docs/commands/liberica/transfer-out-forms/update.md +286 -0
- package/package.json +1 -1
- package/src/commands/liberica/index.ts +8 -1
- package/src/commands/liberica/teams/index.ts +17 -0
- package/src/commands/liberica/teams/issues/close.ts +104 -0
- package/src/commands/liberica/teams/issues/create.ts +254 -0
- package/src/commands/liberica/teams/issues/delete.ts +58 -0
- package/src/commands/liberica/teams/issues/get.ts +78 -0
- package/src/commands/liberica/teams/issues/index.ts +21 -0
- package/src/commands/liberica/teams/issues/list.ts +144 -0
- package/src/commands/liberica/teams/issues/update.ts +141 -0
- package/src/commands/liberica/teams/projects/create.ts +159 -0
- package/src/commands/liberica/teams/projects/delete.ts +58 -0
- package/src/commands/liberica/teams/projects/get.ts +87 -0
- package/src/commands/liberica/teams/projects/index.ts +19 -0
- package/src/commands/liberica/teams/projects/list.ts +147 -0
- package/src/commands/liberica/teams/projects/update.ts +117 -0
- package/src/commands/liberica/teams/tasks/create.ts +102 -0
- package/src/commands/liberica/teams/tasks/delete.ts +92 -0
- package/src/commands/liberica/teams/tasks/get.ts +64 -0
- package/src/commands/liberica/teams/tasks/index.ts +19 -0
- package/src/commands/liberica/teams/tasks/list.ts +102 -0
- package/src/commands/liberica/teams/tasks/update.ts +122 -0
- package/src/commands/liberica/teams/work-logs/create.ts +204 -0
- package/src/commands/liberica/teams/work-logs/delete.ts +58 -0
- package/src/commands/liberica/teams/work-logs/get.ts +87 -0
- package/src/commands/liberica/teams/work-logs/index.ts +19 -0
- package/src/commands/liberica/teams/work-logs/list.ts +141 -0
- package/src/commands/liberica/teams/work-logs/update.ts +120 -0
- package/src/commands/liberica/transfer-in-forms/batch-delete.ts +152 -0
- package/src/commands/liberica/transfer-in-forms/batch-review.ts +151 -0
- package/src/commands/liberica/transfer-in-forms/batch-unreview.ts +152 -0
- package/src/commands/liberica/transfer-in-forms/create.ts +179 -0
- package/src/commands/liberica/transfer-in-forms/get.ts +107 -0
- package/src/commands/liberica/transfer-in-forms/index.ts +23 -0
- package/src/commands/liberica/transfer-in-forms/list.ts +97 -0
- package/src/commands/liberica/transfer-in-forms/update.ts +213 -0
- package/src/commands/liberica/transfer-out-forms/batch-delete.ts +83 -0
- package/src/commands/liberica/transfer-out-forms/batch-review.ts +148 -0
- package/src/commands/liberica/transfer-out-forms/batch-unreview.ts +56 -0
- package/src/commands/liberica/transfer-out-forms/create.ts +194 -0
- package/src/commands/liberica/transfer-out-forms/get.ts +114 -0
- package/src/commands/liberica/transfer-out-forms/index.ts +23 -0
- package/src/commands/liberica/transfer-out-forms/list.ts +125 -0
- package/src/commands/liberica/transfer-out-forms/update.ts +197 -0
- package/src/core/api/client.ts +1218 -190
- package/src/index.ts +1 -1
- package/src/types/index.ts +5 -0
- package/src/types/team-issue.ts +94 -0
- package/src/types/team-project.ts +74 -0
- package/src/types/team-task.ts +98 -0
- package/src/types/team-work-log.ts +87 -0
- package/src/types/transfer-in-form.ts +265 -0
- package/src/types/transfer-out-form.ts +290 -0
|
@@ -0,0 +1,107 @@
|
|
|
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 { Environment } from '../../../types/index.js';
|
|
7
|
+
import { TransferInForm, TransferInFormItem } from '../../../types/transfer-in-form.js';
|
|
8
|
+
|
|
9
|
+
export function createTransferInFormGetCommand(): Command {
|
|
10
|
+
const getCommand = new Command('get');
|
|
11
|
+
getCommand.description('Get transfer-in form details by ID');
|
|
12
|
+
getCommand.arguments('<transferInFormId>');
|
|
13
|
+
getCommand.option('--json', 'Output as JSON');
|
|
14
|
+
|
|
15
|
+
getCommand.action(async (transferInFormId: string, options: Record<string, unknown>) => {
|
|
16
|
+
const context = configManager.getCurrentContext();
|
|
17
|
+
const environment = (options.env as Environment) || context.environment;
|
|
18
|
+
const tenant = (options.tenant as string) || context.tenant;
|
|
19
|
+
|
|
20
|
+
if (!transferInFormId || transferInFormId.trim() === '') {
|
|
21
|
+
console.error(chalk.red('\n✗ Invalid transfer-in form ID.\n'));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const response = await apiClient.getTransferInForm(environment, tenant, transferInFormId);
|
|
27
|
+
|
|
28
|
+
if (!response.success) {
|
|
29
|
+
const errorCode = response.error?.code || 'UNKNOWN_ERROR';
|
|
30
|
+
const errorMessage = response.error?.message || 'Unknown error';
|
|
31
|
+
|
|
32
|
+
// Handle "transfer-in form not found" case
|
|
33
|
+
if (errorCode === '01001xx001' || errorMessage.includes('不存在')) {
|
|
34
|
+
console.error(chalk.red(`\n✗ Transfer-in form not found: ${transferInFormId}\n`));
|
|
35
|
+
} else {
|
|
36
|
+
console.error(chalk.red(`\n✗ Error: ${errorMessage} (${errorCode})\n`));
|
|
37
|
+
}
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const transferInForm = response.data as TransferInForm | null;
|
|
42
|
+
|
|
43
|
+
if (!transferInForm) {
|
|
44
|
+
console.error(chalk.red('\n✗ Transfer-in form not found\n'));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (options.json) {
|
|
49
|
+
console.log(JSON.stringify({
|
|
50
|
+
success: true,
|
|
51
|
+
data: transferInForm,
|
|
52
|
+
}, null, 2));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Main details table
|
|
57
|
+
console.log(chalk.bold('\n📋 Transfer-In Form Details\n'));
|
|
58
|
+
console.log(` ${chalk.gray('ID:')} ${transferInForm.transferInFormId}`);
|
|
59
|
+
console.log(` ${chalk.gray('Code:')} ${transferInForm.transferInFormCode}`);
|
|
60
|
+
console.log(` ${chalk.gray('Warehouse:')} ${transferInForm.mainWarehouseCode}`);
|
|
61
|
+
console.log(` ${chalk.gray('Stock Date:')} ${transferInForm.stockDate}`);
|
|
62
|
+
console.log(` ${chalk.gray('Type:')} ${transferInForm.transferInType}`);
|
|
63
|
+
console.log(` ${chalk.gray('Follower:')} ${transferInForm.followerName || transferInForm.follower}`);
|
|
64
|
+
console.log(` ${chalk.gray('Review Flag:')} ${transferInForm.reviewFlag === 'REVIEWED' ? 'Reviewed' : 'Unreviewed'}`);
|
|
65
|
+
if (transferInForm.reviewer) {
|
|
66
|
+
console.log(` ${chalk.gray('Reviewer:')} ${transferInForm.reviewerName || transferInForm.reviewer}`);
|
|
67
|
+
}
|
|
68
|
+
if (transferInForm.reviewTime) {
|
|
69
|
+
console.log(` ${chalk.gray('Review Time:')} ${transferInForm.reviewTime}`);
|
|
70
|
+
}
|
|
71
|
+
if (transferInForm.remark) {
|
|
72
|
+
console.log(` ${chalk.gray('Remark:')} ${transferInForm.remark}`);
|
|
73
|
+
}
|
|
74
|
+
console.log();
|
|
75
|
+
|
|
76
|
+
// Item list table
|
|
77
|
+
const items = transferInForm.itemList || [];
|
|
78
|
+
if (items.length > 0) {
|
|
79
|
+
console.log(chalk.bold(`Items (${items.length}):\n`));
|
|
80
|
+
const itemTable = new Table({
|
|
81
|
+
head: [chalk.bold('Material Code'), chalk.bold('Material Name'), chalk.bold('Qty'), chalk.bold('UOM'), chalk.bold('Unit Price'), chalk.bold('Amount')],
|
|
82
|
+
colWidths: [15, 20, 10, 8, 12, 12],
|
|
83
|
+
style: { head: [], border: [] },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
for (const item of items as TransferInFormItem[]) {
|
|
87
|
+
itemTable.push([
|
|
88
|
+
item.materialCode || '-',
|
|
89
|
+
item.materialName || '-',
|
|
90
|
+
String(item.stockQuantity !== undefined ? item.stockQuantity : item.formQuantity),
|
|
91
|
+
item.materialUomCode || '-',
|
|
92
|
+
item.unitPrice !== undefined ? String(item.unitPrice) : '-',
|
|
93
|
+
item.stockAmount !== undefined ? String(item.stockAmount) : '-',
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
console.log(itemTable.toString());
|
|
98
|
+
console.log();
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error(chalk.red(`\n✗ Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return getCommand;
|
|
107
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createTransferInFormListCommand } from './list.js';
|
|
3
|
+
import { createTransferInFormGetCommand } from './get.js';
|
|
4
|
+
import { createTransferInFormCreateCommand } from './create.js';
|
|
5
|
+
import { createTransferInFormUpdateCommand } from './update.js';
|
|
6
|
+
import { createTransferInFormBatchDeleteCommand } from './batch-delete.js';
|
|
7
|
+
import { createTransferInFormBatchReviewCommand } from './batch-review.js';
|
|
8
|
+
import { createTransferInFormBatchUnreviewCommand } from './batch-unreview.js';
|
|
9
|
+
|
|
10
|
+
export function createTransferInFormsCommand(): Command {
|
|
11
|
+
const transferInFormsCommand = new Command('transfer-in-forms');
|
|
12
|
+
transferInFormsCommand.description('Manage transfer-in forms');
|
|
13
|
+
|
|
14
|
+
transferInFormsCommand.addCommand(createTransferInFormListCommand());
|
|
15
|
+
transferInFormsCommand.addCommand(createTransferInFormGetCommand());
|
|
16
|
+
transferInFormsCommand.addCommand(createTransferInFormCreateCommand());
|
|
17
|
+
transferInFormsCommand.addCommand(createTransferInFormUpdateCommand());
|
|
18
|
+
transferInFormsCommand.addCommand(createTransferInFormBatchDeleteCommand());
|
|
19
|
+
transferInFormsCommand.addCommand(createTransferInFormBatchReviewCommand());
|
|
20
|
+
transferInFormsCommand.addCommand(createTransferInFormBatchUnreviewCommand());
|
|
21
|
+
|
|
22
|
+
return transferInFormsCommand;
|
|
23
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 { TransferInFormCompact, TransferInFormCompactListResponse } from '../../../types/transfer-in-form.js';
|
|
7
|
+
import { Environment } from '../../../types/index.js';
|
|
8
|
+
|
|
9
|
+
export function createTransferInFormListCommand(): Command {
|
|
10
|
+
const listCommand = new Command('list');
|
|
11
|
+
listCommand.description('List transfer-in forms with pagination');
|
|
12
|
+
|
|
13
|
+
listCommand
|
|
14
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
15
|
+
.option('-s, --size <number>', 'Page size', '20')
|
|
16
|
+
.option('--code <string>', 'Transfer-in form code')
|
|
17
|
+
.option('--warehouse-code <string>', 'Warehouse code')
|
|
18
|
+
.option('--type <string>', 'Transfer-in type')
|
|
19
|
+
.option('--review-flag <string>', 'Review flag (REVIEWED/UN_REVIEWED)')
|
|
20
|
+
.option('--stock-date <string>', 'Stock date (YYYY-MM-DD)')
|
|
21
|
+
.option('--stock-date-from <string>', 'Stock date from (YYYY-MM-DD)')
|
|
22
|
+
.option('--stock-date-to <string>', 'Stock date to (YYYY-MM-DD)')
|
|
23
|
+
.option('--material-code <string>', 'Material code')
|
|
24
|
+
.option('--material-name <string>', 'Material name')
|
|
25
|
+
.option('--follower <string>', 'Follower')
|
|
26
|
+
.option('--reviewer <string>', 'Reviewer')
|
|
27
|
+
.option('--json', 'Output as JSON')
|
|
28
|
+
.action(async (options) => {
|
|
29
|
+
const context = configManager.getCurrentContext();
|
|
30
|
+
const environment = (options.env as Environment) || context.environment;
|
|
31
|
+
const tenant = options.tenant || context.tenant;
|
|
32
|
+
|
|
33
|
+
const page = parseInt(options.page as string, 10) - 1; // API uses 0-based
|
|
34
|
+
const size = parseInt(options.size as string, 10);
|
|
35
|
+
|
|
36
|
+
const params: Record<string, unknown> = { pageNo: page, pageSize: size };
|
|
37
|
+
if (options.code) params.transferInFormCode = options.code;
|
|
38
|
+
if (options.warehouseCode) params.warehouseCode = options.warehouseCode;
|
|
39
|
+
if (options.type) params.transferInType = options.type;
|
|
40
|
+
if (options.reviewFlag) params.reviewFlag = options.reviewFlag;
|
|
41
|
+
if (options.stockDate) params.stockDate = options.stockDate;
|
|
42
|
+
if (options.stockDateFrom) params.stockDateBegin = options.stockDateFrom;
|
|
43
|
+
if (options.stockDateTo) params.stockDateEnd = options.stockDateTo;
|
|
44
|
+
if (options.materialCode) params.materialCode = options.materialCode;
|
|
45
|
+
if (options.materialName) params.materialName = options.materialName;
|
|
46
|
+
if (options.follower) params.follower = options.follower;
|
|
47
|
+
if (options.reviewer) params.reviewer = options.reviewer;
|
|
48
|
+
|
|
49
|
+
const response = await apiClient.listTransferInForms(environment, tenant, params as any);
|
|
50
|
+
|
|
51
|
+
if (!response.success) {
|
|
52
|
+
console.error(chalk.red(`\n✗ Failed to list transfer-in forms: ${response.error?.message || 'Unknown error'}`));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const data = response.data as TransferInFormCompactListResponse | undefined;
|
|
57
|
+
if (!data || data.totalRows === 0) {
|
|
58
|
+
console.log(chalk.bold('\n📋 Transfer-In Form List\n'));
|
|
59
|
+
console.log(chalk.gray(' No records found\n'));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (options.json) {
|
|
64
|
+
console.log(JSON.stringify({ success: true, data }, null, 2));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const records = data.rows || [];
|
|
69
|
+
console.log(chalk.bold('\n📋 Transfer-In Form List\n'));
|
|
70
|
+
|
|
71
|
+
const table = new Table({
|
|
72
|
+
head: [chalk.bold('ID'), chalk.bold('Code'), chalk.bold('Warehouse'), chalk.bold('Material'), chalk.bold('Qty'), chalk.bold('Review'), chalk.bold('Date')],
|
|
73
|
+
colWidths: [20, 15, 12, 20, 10, 10, 12],
|
|
74
|
+
style: { head: [], border: [] },
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
for (const r of records as TransferInFormCompact[]) {
|
|
78
|
+
const quantity = r.stockQuantity !== undefined ? r.stockQuantity : r.formQuantity;
|
|
79
|
+
table.push([
|
|
80
|
+
r.transferInFormId || '-',
|
|
81
|
+
r.transferInFormCode || '-',
|
|
82
|
+
r.warehouseCode || '-',
|
|
83
|
+
r.materialName || '-',
|
|
84
|
+
String(quantity || ''),
|
|
85
|
+
r.reviewFlag === 'REVIEWED' ? chalk.green('Reviewed') : chalk.yellow('Unreviewed'),
|
|
86
|
+
r.stockDate || '-',
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(table.toString());
|
|
91
|
+
console.log();
|
|
92
|
+
console.log(chalk.gray(` Total: ${data.totalRows} | Page: ${data.pageNo + 1} / ${Math.ceil(data.totalRows / data.pageSize) || 1}`));
|
|
93
|
+
console.log();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return listCommand;
|
|
97
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
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 { UpdateTransferInFormRequest, TransferInFormItemRequest } from '../../../types/transfer-in-form.js';
|
|
6
|
+
import { Environment } from '../../../types/index.js';
|
|
7
|
+
|
|
8
|
+
export function createTransferInFormUpdateCommand(): Command {
|
|
9
|
+
const cmd = new Command('update');
|
|
10
|
+
cmd.description('Update a transfer-in form');
|
|
11
|
+
|
|
12
|
+
cmd
|
|
13
|
+
.argument('<id>', 'Transfer-in form ID')
|
|
14
|
+
.option('-c, --code <code>', 'Transfer-in form code')
|
|
15
|
+
.option('-w, --warehouse-code <code>', 'Main warehouse code')
|
|
16
|
+
.option('-t, --type <type>', 'Transfer-in type')
|
|
17
|
+
.option('-f, --follower <id>', 'Follower ID')
|
|
18
|
+
.option('--follower-name <name>', 'Follower name')
|
|
19
|
+
.option('--stock-date <date>', 'Stock date (YYYY-MM-DD)')
|
|
20
|
+
.option('--remark <remark>', 'Remark')
|
|
21
|
+
// Individual item options (for single item update)
|
|
22
|
+
.option('--item-id <id>', 'Existing transfer-in form item ID (for updating existing item)')
|
|
23
|
+
.option('--item-warehouse-code <code>', 'Item warehouse code')
|
|
24
|
+
.option('-m, --material-code <code>', 'Material code')
|
|
25
|
+
.option('--material-no <no>', 'Material number')
|
|
26
|
+
.option('--material-name <name>', 'Material name')
|
|
27
|
+
.option('--material-type <type>', 'Material type')
|
|
28
|
+
.option('-q, --quantity <number>', 'Form quantity')
|
|
29
|
+
.option('--form-uom <code>', 'Form UOM code')
|
|
30
|
+
.option('--unit-price <price>', 'Unit price')
|
|
31
|
+
.option('--produced-date <date>', 'Produced date (YYYY-MM-DD)')
|
|
32
|
+
.option('--lot-no <no>', 'Lot number')
|
|
33
|
+
.option('--item-remark <remark>', 'Item remark')
|
|
34
|
+
// JSON items array (alternative to individual item options)
|
|
35
|
+
.option('--items <json>', 'JSON array of items (overrides individual item options)')
|
|
36
|
+
.option('--dry-run', 'Preview mode')
|
|
37
|
+
.option('--json', 'Output as JSON');
|
|
38
|
+
|
|
39
|
+
cmd.action(async (id, options) => {
|
|
40
|
+
const context = configManager.getCurrentContext();
|
|
41
|
+
const environment = context.environment as Environment;
|
|
42
|
+
const tenant = context.tenant;
|
|
43
|
+
const dryRun = options.dryRun === true;
|
|
44
|
+
const jsonOutput = options.json === true;
|
|
45
|
+
|
|
46
|
+
// Validate stock date format
|
|
47
|
+
if (options.stockDate && !/^\d{4}-\d{2}-\d{2}$/.test(options.stockDate)) {
|
|
48
|
+
console.error(chalk.red('\n✗ Invalid stock-date format. Use YYYY-MM-DD\n'));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const request: UpdateTransferInFormRequest = {
|
|
53
|
+
transferInFormId: id,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Add optional fields if provided
|
|
57
|
+
if (options.code !== undefined) request.transferInFormCode = options.code;
|
|
58
|
+
if (options.warehouseCode !== undefined) request.mainWarehouseCode = options.warehouseCode;
|
|
59
|
+
if (options.stockDate !== undefined) request.stockDate = options.stockDate;
|
|
60
|
+
if (options.type !== undefined) request.transferInType = options.type;
|
|
61
|
+
if (options.follower !== undefined) request.follower = options.follower;
|
|
62
|
+
if (options.followerName !== undefined) request.followerName = options.followerName;
|
|
63
|
+
if (options.remark !== undefined) request.remark = options.remark;
|
|
64
|
+
|
|
65
|
+
let itemList: TransferInFormItemRequest[] | undefined = undefined;
|
|
66
|
+
|
|
67
|
+
if (options.items) {
|
|
68
|
+
// Parse JSON items
|
|
69
|
+
try {
|
|
70
|
+
const parsed = JSON.parse(options.items);
|
|
71
|
+
if (!Array.isArray(parsed)) {
|
|
72
|
+
console.error(chalk.red('\n✗ --items must be a JSON array\n'));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
// Validate each item has required fields (if updating items, all required fields must be present)
|
|
76
|
+
for (const item of parsed) {
|
|
77
|
+
if (!item.warehouseCode || !item.materialCode || !item.formQuantity || !item.formMaterialUomCode || item.formUnitPrice == null) {
|
|
78
|
+
console.error(chalk.red('\n✗ Each item must have warehouseCode, materialCode, formQuantity, formMaterialUomCode, formUnitPrice\n'));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
itemList = parsed;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(chalk.red('\n✗ Invalid JSON for --items: ' + (error instanceof Error ? error.message : 'Unknown error') + '\n'));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
// Check if any individual item option is provided
|
|
89
|
+
const hasItemOption = options.itemId !== undefined ||
|
|
90
|
+
options.itemWarehouseCode !== undefined ||
|
|
91
|
+
options.materialCode !== undefined ||
|
|
92
|
+
options.materialNo !== undefined ||
|
|
93
|
+
options.materialName !== undefined ||
|
|
94
|
+
options.materialType !== undefined ||
|
|
95
|
+
options.quantity !== undefined ||
|
|
96
|
+
options.formUom !== undefined ||
|
|
97
|
+
options.unitPrice !== undefined ||
|
|
98
|
+
options.producedDate !== undefined ||
|
|
99
|
+
options.lotNo !== undefined ||
|
|
100
|
+
options.itemRemark !== undefined;
|
|
101
|
+
|
|
102
|
+
if (hasItemOption) {
|
|
103
|
+
// Validate required fields for item update
|
|
104
|
+
if (!options.materialCode) {
|
|
105
|
+
console.error(chalk.red('\n✗ Material code is required when updating item (--material-code)\n'));
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
if (!options.formUom) {
|
|
109
|
+
console.error(chalk.red('\n✗ Form UOM code is required when updating item (--form-uom)\n'));
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
if (!options.unitPrice) {
|
|
113
|
+
console.error(chalk.red('\n✗ Unit price is required when updating item (--unit-price)\n'));
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Validate quantity
|
|
118
|
+
let quantity = 1;
|
|
119
|
+
if (options.quantity) {
|
|
120
|
+
const q = parseFloat(options.quantity);
|
|
121
|
+
if (isNaN(q) || q <= 0) {
|
|
122
|
+
console.error(chalk.red('\n✗ Quantity must be a positive number\n'));
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
quantity = q;
|
|
126
|
+
} else {
|
|
127
|
+
console.error(chalk.red('\n✗ Quantity is required when updating item (--quantity)\n'));
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Validate unit price
|
|
132
|
+
const unitPrice = parseFloat(options.unitPrice);
|
|
133
|
+
if (isNaN(unitPrice) || unitPrice < 0) {
|
|
134
|
+
console.error(chalk.red('\n✗ Unit price must be a non-negative number\n'));
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Validate produced date format
|
|
139
|
+
if (options.producedDate && !/^\d{4}-\d{2}-\d{2}$/.test(options.producedDate)) {
|
|
140
|
+
console.error(chalk.red('\n✗ Invalid produced-date format. Use YYYY-MM-DD\n'));
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const item: TransferInFormItemRequest = {
|
|
145
|
+
transferInFormItemId: options.itemId,
|
|
146
|
+
warehouseCode: options.itemWarehouseCode || options.warehouseCode,
|
|
147
|
+
materialCode: options.materialCode,
|
|
148
|
+
materialNo: options.materialNo,
|
|
149
|
+
materialName: options.materialName,
|
|
150
|
+
materialType: options.materialType,
|
|
151
|
+
formQuantity: quantity,
|
|
152
|
+
formMaterialUomCode: options.formUom,
|
|
153
|
+
formUnitPrice: unitPrice,
|
|
154
|
+
producedDate: options.producedDate,
|
|
155
|
+
lotNo: options.lotNo,
|
|
156
|
+
remark: options.itemRemark,
|
|
157
|
+
};
|
|
158
|
+
itemList = [item];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (itemList) {
|
|
163
|
+
request.itemList = itemList;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Check if any fields to update (excluding transferInFormId)
|
|
167
|
+
const updateFields = Object.keys(request).filter(k => k !== 'transferInFormId');
|
|
168
|
+
if (updateFields.length === 0) {
|
|
169
|
+
console.error(chalk.red('\n✗ No fields to update. Provide at least one option to change.\n'));
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (dryRun) {
|
|
174
|
+
if (jsonOutput) {
|
|
175
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data: request }));
|
|
176
|
+
} else {
|
|
177
|
+
console.log(chalk.bold('\n🔍 Dry-Run Mode: No changes will be made\n'));
|
|
178
|
+
console.log(' Transfer-in form to be updated:');
|
|
179
|
+
console.log(` ID: ${request.transferInFormId}`);
|
|
180
|
+
updateFields.forEach(field => {
|
|
181
|
+
const value = request[field as keyof UpdateTransferInFormRequest];
|
|
182
|
+
console.log(` ${field}: ${Array.isArray(value) ? JSON.stringify(value) : value}`);
|
|
183
|
+
});
|
|
184
|
+
console.log();
|
|
185
|
+
}
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!jsonOutput) {
|
|
190
|
+
console.log(chalk.bold('\n📝 Updating Transfer-In Form\n'));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const response = await apiClient.updateTransferInForm(environment, tenant, request);
|
|
194
|
+
|
|
195
|
+
if (response.success) {
|
|
196
|
+
if (jsonOutput) {
|
|
197
|
+
console.log(JSON.stringify({ success: true, data: response.data }));
|
|
198
|
+
} else {
|
|
199
|
+
console.log(chalk.green('\n✓ Transfer-in form updated successfully\n'));
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
const errMsg = response.error?.message || 'Failed to update';
|
|
203
|
+
if (jsonOutput) {
|
|
204
|
+
console.log(JSON.stringify({ success: false, error: { code: response.error?.code, message: errMsg } }));
|
|
205
|
+
} else {
|
|
206
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
207
|
+
}
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return cmd;
|
|
213
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
|
|
7
|
+
export function createTransferOutFormBatchDeleteCommand(): Command {
|
|
8
|
+
const cmd = new Command('batch-delete');
|
|
9
|
+
cmd
|
|
10
|
+
.description('Batch delete transfer-out forms')
|
|
11
|
+
.argument('<ids...>', 'Transfer-out form IDs to delete')
|
|
12
|
+
.option('--force', 'Skip confirmation and delete directly')
|
|
13
|
+
.option('--dry-run', 'Preview what would be deleted')
|
|
14
|
+
.option('--json', 'Output as JSON');
|
|
15
|
+
|
|
16
|
+
cmd.action(async (ids: string[], options: Record<string, unknown>) => {
|
|
17
|
+
const context = configManager.getCurrentContext();
|
|
18
|
+
const environment = context.environment as Environment;
|
|
19
|
+
const tenant = context.tenant;
|
|
20
|
+
const jsonOutput = options.json === true;
|
|
21
|
+
const dryRun = options.dryRun === true;
|
|
22
|
+
const force = options.force === true;
|
|
23
|
+
|
|
24
|
+
if (ids.length === 0) {
|
|
25
|
+
const errMsg = 'No transfer-out form IDs provided';
|
|
26
|
+
if (jsonOutput) {
|
|
27
|
+
console.log(JSON.stringify({ success: false, error: { code: 'MISSING_IDS', message: errMsg } }));
|
|
28
|
+
} else {
|
|
29
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
30
|
+
}
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (dryRun) {
|
|
35
|
+
if (jsonOutput) {
|
|
36
|
+
console.log(JSON.stringify({ success: true, dryRun: true, ids }));
|
|
37
|
+
} else {
|
|
38
|
+
console.log(chalk.bold(`\n🔍 Dry-Run Mode: No actual deletion will be made\n`));
|
|
39
|
+
console.log(chalk.gray(` Form IDs: ${ids.join(', ')}`));
|
|
40
|
+
console.log(chalk.gray(` Count: ${ids.length}\n`));
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!force) {
|
|
46
|
+
if (jsonOutput) {
|
|
47
|
+
console.log(JSON.stringify({ success: true, dryRun: true, ids }));
|
|
48
|
+
} else {
|
|
49
|
+
console.log(chalk.bold(`\n🗑️ Batch Delete Transfer-Out Forms (${environment})\n`));
|
|
50
|
+
console.log(chalk.gray(` Form IDs: ${ids.join(', ')}`));
|
|
51
|
+
console.log(chalk.gray(` Count: ${ids.length}\n`));
|
|
52
|
+
console.log(chalk.cyan(' To delete, add: --force\n'));
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!jsonOutput) {
|
|
58
|
+
console.log(chalk.bold(`\n🗑️ Batch Delete Transfer-Out Forms (${environment})\n`));
|
|
59
|
+
console.log(chalk.gray(` Form IDs: ${ids.join(', ')}`));
|
|
60
|
+
console.log(chalk.gray(` Count: ${ids.length}\n`));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const response = await apiClient.batchDeleteTransferOutForms(environment, tenant, ids);
|
|
64
|
+
|
|
65
|
+
if (response.success) {
|
|
66
|
+
if (jsonOutput) {
|
|
67
|
+
console.log(JSON.stringify({ success: true, ids, count: ids.length }));
|
|
68
|
+
} else {
|
|
69
|
+
console.log(chalk.green(`\n✓ ${ids.length} transfer-out form(s) deleted successfully\n`));
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
const errMsg = response.error?.message || 'Failed to delete';
|
|
73
|
+
if (jsonOutput) {
|
|
74
|
+
console.log(JSON.stringify({ success: false, error: { code: response.error?.code, message: errMsg } }));
|
|
75
|
+
} else {
|
|
76
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
77
|
+
}
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return cmd;
|
|
83
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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 { Environment } from '../../../types/index.js';
|
|
7
|
+
import { TransferOutForm } from '../../../types/transfer-out-form.js';
|
|
8
|
+
|
|
9
|
+
export function createTransferOutFormBatchReviewCommand(): Command {
|
|
10
|
+
const cmd = new Command('batch-review');
|
|
11
|
+
cmd
|
|
12
|
+
.description('Batch review (审核) transfer-out forms')
|
|
13
|
+
.argument('<ids...>', 'Transfer-out form IDs to review')
|
|
14
|
+
.option('--force', 'Skip confirmation and review directly')
|
|
15
|
+
.option('--dry-run', 'Preview what would be reviewed')
|
|
16
|
+
.option('--json', 'Output as JSON');
|
|
17
|
+
|
|
18
|
+
cmd.action(async (ids: string[], options: Record<string, unknown>) => {
|
|
19
|
+
const context = configManager.getCurrentContext();
|
|
20
|
+
const environment = context.environment as Environment;
|
|
21
|
+
const tenant = context.tenant;
|
|
22
|
+
const jsonOutput = options.json === true;
|
|
23
|
+
const dryRun = options.dryRun === true;
|
|
24
|
+
const force = options.force === true;
|
|
25
|
+
|
|
26
|
+
if (ids.length === 0) {
|
|
27
|
+
const errMsg = 'No transfer-out form IDs provided';
|
|
28
|
+
if (jsonOutput) {
|
|
29
|
+
console.log(JSON.stringify({ success: false, error: { code: 'MISSING_IDS', message: errMsg } }));
|
|
30
|
+
} else {
|
|
31
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
32
|
+
}
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Validate IDs are non-empty strings
|
|
37
|
+
const validIds = ids.filter(id => id.trim() !== '');
|
|
38
|
+
if (validIds.length === 0) {
|
|
39
|
+
const errMsg = 'No valid transfer-out form IDs provided';
|
|
40
|
+
if (jsonOutput) {
|
|
41
|
+
console.log(JSON.stringify({ success: false, error: { code: 'INVALID_IDS', message: errMsg } }));
|
|
42
|
+
} else {
|
|
43
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
44
|
+
}
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Fetch details for dry-run or confirmation
|
|
49
|
+
const forms: TransferOutForm[] = [];
|
|
50
|
+
if (!force || dryRun) {
|
|
51
|
+
for (const id of validIds) {
|
|
52
|
+
try {
|
|
53
|
+
const response = await apiClient.getTransferOutForm(environment, tenant, id);
|
|
54
|
+
if (response.success && response.data && 'transferOutFormId' in (response.data as any)) {
|
|
55
|
+
forms.push(response.data as TransferOutForm);
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
// ignore fetch errors
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (dryRun) {
|
|
64
|
+
if (jsonOutput) {
|
|
65
|
+
console.log(JSON.stringify({
|
|
66
|
+
success: true,
|
|
67
|
+
dryRun: true,
|
|
68
|
+
ids: validIds,
|
|
69
|
+
forms: forms.map(form => ({
|
|
70
|
+
transferOutFormId: form.transferOutFormId,
|
|
71
|
+
transferOutFormCode: form.transferOutFormCode,
|
|
72
|
+
warehouseCode: form.warehouseCode,
|
|
73
|
+
stockDate: form.stockDate,
|
|
74
|
+
reviewFlag: form.reviewFlag,
|
|
75
|
+
})),
|
|
76
|
+
message: 'Dry-run mode: no actual review will be performed',
|
|
77
|
+
}));
|
|
78
|
+
} else {
|
|
79
|
+
console.log(chalk.bold('\n🔍 Dry-Run Mode: No changes will be made\n'));
|
|
80
|
+
console.log(chalk.gray(` IDs to review: ${validIds.join(', ')}\n`));
|
|
81
|
+
if (forms.length > 0) {
|
|
82
|
+
console.log(chalk.gray(' Transfer-out forms to be reviewed:'));
|
|
83
|
+
forms.forEach(form => {
|
|
84
|
+
console.log(chalk.gray(` • ${form.transferOutFormCode} (ID: ${form.transferOutFormId})`));
|
|
85
|
+
});
|
|
86
|
+
console.log();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!force) {
|
|
93
|
+
if (!jsonOutput) {
|
|
94
|
+
console.log(chalk.bold('\n📝 Batch Review Transfer-Out Forms\n'));
|
|
95
|
+
console.log(chalk.gray(` IDs: ${validIds.join(', ')}\n`));
|
|
96
|
+
if (forms.length > 0) {
|
|
97
|
+
console.log(chalk.gray(' Transfer-out forms to review:'));
|
|
98
|
+
forms.forEach(form => {
|
|
99
|
+
console.log(chalk.gray(` • ${form.transferOutFormCode} (ID: ${form.transferOutFormId})`));
|
|
100
|
+
});
|
|
101
|
+
console.log();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const { confirm } = await inquirer.prompt([
|
|
106
|
+
{
|
|
107
|
+
type: 'confirm',
|
|
108
|
+
name: 'confirm',
|
|
109
|
+
message: `Review ${validIds.length} transfer-out form(s)?`,
|
|
110
|
+
default: false,
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
if (!confirm) {
|
|
115
|
+
if (jsonOutput) {
|
|
116
|
+
console.log(JSON.stringify({ success: false, error: { code: 'CANCELLED', message: 'Operation cancelled by user' } }));
|
|
117
|
+
} else {
|
|
118
|
+
console.log(chalk.gray('\n Operation cancelled.\n'));
|
|
119
|
+
}
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!jsonOutput) {
|
|
125
|
+
console.log(chalk.bold(`\n📝 Reviewing ${validIds.length} Transfer-Out Form(s)\n`));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const response = await apiClient.batchReviewTransferOutForms(environment, tenant, validIds);
|
|
129
|
+
|
|
130
|
+
if (response.success) {
|
|
131
|
+
if (jsonOutput) {
|
|
132
|
+
console.log(JSON.stringify({ success: true, reviewedCount: validIds.length, ids: validIds }));
|
|
133
|
+
} else {
|
|
134
|
+
console.log(chalk.green(`\n✓ ${validIds.length} transfer-out form(s) reviewed\n`));
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
const errMsg = response.error?.message || 'Failed to review';
|
|
138
|
+
if (jsonOutput) {
|
|
139
|
+
console.log(JSON.stringify({ success: false, error: { code: response.error?.code, message: errMsg } }));
|
|
140
|
+
} else {
|
|
141
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
142
|
+
}
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
return cmd;
|
|
148
|
+
}
|