@newpeak/barista-cli 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/commands/liberica/calendar/index.d.ts +3 -0
- package/dist/commands/liberica/calendar/index.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/index.js +11 -0
- package/dist/commands/liberica/calendar/index.js.map +1 -0
- package/dist/commands/liberica/calendar/list.d.ts +3 -0
- package/dist/commands/liberica/calendar/list.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/list.js +181 -0
- package/dist/commands/liberica/calendar/list.js.map +1 -0
- package/dist/commands/liberica/calendar/set.d.ts +3 -0
- package/dist/commands/liberica/calendar/set.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/set.js +120 -0
- package/dist/commands/liberica/calendar/set.js.map +1 -0
- package/dist/commands/liberica/client-contacts/create.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/create.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/create.js +132 -0
- package/dist/commands/liberica/client-contacts/create.js.map +1 -0
- package/dist/commands/liberica/client-contacts/delete.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/delete.js +139 -0
- package/dist/commands/liberica/client-contacts/delete.js.map +1 -0
- package/dist/commands/liberica/client-contacts/get.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/get.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/get.js +92 -0
- package/dist/commands/liberica/client-contacts/get.js.map +1 -0
- package/dist/commands/liberica/client-contacts/index.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/index.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/index.js +17 -0
- package/dist/commands/liberica/client-contacts/index.js.map +1 -0
- package/dist/commands/liberica/client-contacts/list.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/list.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/list.js +92 -0
- package/dist/commands/liberica/client-contacts/list.js.map +1 -0
- package/dist/commands/liberica/client-contacts/update.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/update.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/update.js +156 -0
- package/dist/commands/liberica/client-contacts/update.js.map +1 -0
- package/dist/commands/liberica/dict-types/get.d.ts +3 -0
- package/dist/commands/liberica/dict-types/get.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/get.js +62 -0
- package/dist/commands/liberica/dict-types/get.js.map +1 -0
- package/dist/commands/liberica/dict-types/index.d.ts +3 -0
- package/dist/commands/liberica/dict-types/index.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/index.js +13 -0
- package/dist/commands/liberica/dict-types/index.js.map +1 -0
- package/dist/commands/liberica/dict-types/list.d.ts +3 -0
- package/dist/commands/liberica/dict-types/list.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/list.js +91 -0
- package/dist/commands/liberica/dict-types/list.js.map +1 -0
- package/dist/commands/liberica/dict-types/update.d.ts +3 -0
- package/dist/commands/liberica/dict-types/update.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/update.js +127 -0
- package/dist/commands/liberica/dict-types/update.js.map +1 -0
- package/dist/commands/liberica/dicts/create.d.ts +3 -0
- package/dist/commands/liberica/dicts/create.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/create.js +157 -0
- package/dist/commands/liberica/dicts/create.js.map +1 -0
- package/dist/commands/liberica/dicts/delete.d.ts +3 -0
- package/dist/commands/liberica/dicts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/delete.js +106 -0
- package/dist/commands/liberica/dicts/delete.js.map +1 -0
- package/dist/commands/liberica/dicts/get.d.ts +3 -0
- package/dist/commands/liberica/dicts/get.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/get.js +69 -0
- package/dist/commands/liberica/dicts/get.js.map +1 -0
- package/dist/commands/liberica/dicts/index.d.ts +3 -0
- package/dist/commands/liberica/dicts/index.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/index.js +17 -0
- package/dist/commands/liberica/dicts/index.js.map +1 -0
- package/dist/commands/liberica/dicts/list.d.ts +3 -0
- package/dist/commands/liberica/dicts/list.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/list.js +88 -0
- package/dist/commands/liberica/dicts/list.js.map +1 -0
- package/dist/commands/liberica/dicts/update.d.ts +3 -0
- package/dist/commands/liberica/dicts/update.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/update.js +112 -0
- package/dist/commands/liberica/dicts/update.js.map +1 -0
- package/dist/commands/liberica/index.d.ts.map +1 -1
- package/dist/commands/liberica/index.js +20 -0
- package/dist/commands/liberica/index.js.map +1 -1
- package/dist/commands/liberica/materials/create.d.ts.map +1 -1
- package/dist/commands/liberica/materials/create.js +13 -6
- package/dist/commands/liberica/materials/create.js.map +1 -1
- package/dist/commands/liberica/materials/update.js +1 -1
- package/dist/commands/liberica/materials/update.js.map +1 -1
- package/dist/commands/liberica/mould/get.d.ts +3 -0
- package/dist/commands/liberica/mould/get.d.ts.map +1 -0
- package/dist/commands/liberica/mould/get.js +90 -0
- package/dist/commands/liberica/mould/get.js.map +1 -0
- package/dist/commands/liberica/mould/index.d.ts +3 -0
- package/dist/commands/liberica/mould/index.d.ts.map +1 -0
- package/dist/commands/liberica/mould/index.js +15 -0
- package/dist/commands/liberica/mould/index.js.map +1 -0
- package/dist/commands/liberica/mould/list.d.ts +3 -0
- package/dist/commands/liberica/mould/list.d.ts.map +1 -0
- package/dist/commands/liberica/mould/list.js +114 -0
- package/dist/commands/liberica/mould/list.js.map +1 -0
- package/dist/commands/liberica/mould/set-status.d.ts +3 -0
- package/dist/commands/liberica/mould/set-status.d.ts.map +1 -0
- package/dist/commands/liberica/mould/set-status.js +84 -0
- package/dist/commands/liberica/mould/set-status.js.map +1 -0
- package/dist/commands/liberica/mould/stock-in.d.ts +3 -0
- package/dist/commands/liberica/mould/stock-in.d.ts.map +1 -0
- package/dist/commands/liberica/mould/stock-in.js +160 -0
- package/dist/commands/liberica/mould/stock-in.js.map +1 -0
- package/dist/commands/liberica/operations/active.d.ts +3 -0
- package/dist/commands/liberica/operations/active.d.ts.map +1 -0
- package/dist/commands/liberica/operations/active.js +152 -0
- package/dist/commands/liberica/operations/active.js.map +1 -0
- package/dist/commands/liberica/operations/batch-delete.d.ts +3 -0
- package/dist/commands/liberica/operations/batch-delete.d.ts.map +1 -0
- package/dist/commands/liberica/operations/batch-delete.js +130 -0
- package/dist/commands/liberica/operations/batch-delete.js.map +1 -0
- package/dist/commands/liberica/operations/copy.d.ts +3 -0
- package/dist/commands/liberica/operations/copy.d.ts.map +1 -0
- package/dist/commands/liberica/operations/copy.js +137 -0
- package/dist/commands/liberica/operations/copy.js.map +1 -0
- package/dist/commands/liberica/operations/create.d.ts +3 -0
- package/dist/commands/liberica/operations/create.d.ts.map +1 -0
- package/dist/commands/liberica/operations/create.js +212 -0
- package/dist/commands/liberica/operations/create.js.map +1 -0
- package/dist/commands/liberica/operations/deactive.d.ts +3 -0
- package/dist/commands/liberica/operations/deactive.d.ts.map +1 -0
- package/dist/commands/liberica/operations/deactive.js +152 -0
- package/dist/commands/liberica/operations/deactive.js.map +1 -0
- package/dist/commands/liberica/operations/delete.d.ts +3 -0
- package/dist/commands/liberica/operations/delete.d.ts.map +1 -0
- package/dist/commands/liberica/operations/delete.js +128 -0
- package/dist/commands/liberica/operations/delete.js.map +1 -0
- package/dist/commands/liberica/operations/get.d.ts +3 -0
- package/dist/commands/liberica/operations/get.d.ts.map +1 -0
- package/dist/commands/liberica/operations/get.js +93 -0
- package/dist/commands/liberica/operations/get.js.map +1 -0
- package/dist/commands/liberica/operations/index.d.ts +3 -0
- package/dist/commands/liberica/operations/index.d.ts.map +1 -0
- package/dist/commands/liberica/operations/index.js +25 -0
- package/dist/commands/liberica/operations/index.js.map +1 -0
- package/dist/commands/liberica/operations/list.d.ts +3 -0
- package/dist/commands/liberica/operations/list.d.ts.map +1 -0
- package/dist/commands/liberica/operations/list.js +141 -0
- package/dist/commands/liberica/operations/list.js.map +1 -0
- package/dist/commands/liberica/operations/update.d.ts +3 -0
- package/dist/commands/liberica/operations/update.d.ts.map +1 -0
- package/dist/commands/liberica/operations/update.js +208 -0
- package/dist/commands/liberica/operations/update.js.map +1 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts +2 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts.map +1 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.js +41 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.js.map +1 -0
- package/dist/commands/liberica/stock/__tests__/list.test.d.ts +2 -0
- package/dist/commands/liberica/stock/__tests__/list.test.d.ts.map +1 -0
- package/dist/commands/liberica/stock/__tests__/list.test.js +39 -0
- package/dist/commands/liberica/stock/__tests__/list.test.js.map +1 -0
- package/dist/commands/liberica/stock/index.d.ts +3 -0
- package/dist/commands/liberica/stock/index.d.ts.map +1 -0
- package/dist/commands/liberica/stock/index.js +11 -0
- package/dist/commands/liberica/stock/index.js.map +1 -0
- package/dist/commands/liberica/stock/ledger.d.ts +3 -0
- package/dist/commands/liberica/stock/ledger.d.ts.map +1 -0
- package/dist/commands/liberica/stock/ledger.js +154 -0
- package/dist/commands/liberica/stock/ledger.js.map +1 -0
- package/dist/commands/liberica/stock/list.d.ts +3 -0
- package/dist/commands/liberica/stock/list.d.ts.map +1 -0
- package/dist/commands/liberica/stock/list.js +127 -0
- package/dist/commands/liberica/stock/list.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/create.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/create.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/create.js +129 -0
- package/dist/commands/liberica/supplier-contacts/create.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/delete.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/delete.js +88 -0
- package/dist/commands/liberica/supplier-contacts/delete.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/get.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/get.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/get.js +84 -0
- package/dist/commands/liberica/supplier-contacts/get.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/index.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/index.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/index.js +17 -0
- package/dist/commands/liberica/supplier-contacts/index.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/list.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/list.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/list.js +98 -0
- package/dist/commands/liberica/supplier-contacts/list.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/update.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/update.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/update.js +136 -0
- package/dist/commands/liberica/supplier-contacts/update.js.map +1 -0
- package/dist/core/api/client.d.ts +63 -0
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +1050 -65
- package/dist/core/api/client.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/calendar.d.ts +28 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/calendar.js +2 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/client-contact.d.ts +65 -0
- package/dist/types/client-contact.d.ts.map +1 -0
- package/dist/types/client-contact.js +4 -0
- package/dist/types/client-contact.js.map +1 -0
- package/dist/types/dict.d.ts +97 -0
- package/dist/types/dict.d.ts.map +1 -0
- package/dist/types/dict.js +2 -0
- package/dist/types/dict.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/material.d.ts +1 -1
- package/dist/types/material.d.ts.map +1 -1
- package/dist/types/mould-stock-in.d.ts +70 -0
- package/dist/types/mould-stock-in.d.ts.map +1 -0
- package/dist/types/mould-stock-in.js +3 -0
- package/dist/types/mould-stock-in.js.map +1 -0
- package/dist/types/mould.d.ts +61 -0
- package/dist/types/mould.d.ts.map +1 -0
- package/dist/types/mould.js +2 -0
- package/dist/types/mould.js.map +1 -0
- package/dist/types/operation.d.ts +66 -0
- package/dist/types/operation.d.ts.map +1 -0
- package/dist/types/operation.js +2 -0
- package/dist/types/operation.js.map +1 -0
- package/dist/types/stock.d.ts +133 -0
- package/dist/types/stock.d.ts.map +1 -0
- package/dist/types/stock.js +3 -0
- package/dist/types/stock.js.map +1 -0
- package/dist/types/supplier-contact.d.ts +65 -0
- package/dist/types/supplier-contact.d.ts.map +1 -0
- package/dist/types/supplier-contact.js +4 -0
- package/dist/types/supplier-contact.js.map +1 -0
- package/docs/commands/REFERENCE.md +24 -4
- package/docs/commands/liberica/calendar/DESIGN.md +333 -0
- package/docs/commands/liberica/client-contacts/create.md +152 -0
- package/docs/commands/liberica/client-contacts/delete.md +123 -0
- package/docs/commands/liberica/client-contacts/get.md +133 -0
- package/docs/commands/liberica/client-contacts/list.md +143 -0
- package/docs/commands/liberica/client-contacts/update.md +158 -0
- package/docs/commands/liberica/stock/ledger.md +209 -0
- package/docs/commands/liberica/stock/list.md +165 -0
- package/docs/commands/liberica/supplier-contacts/create.md +152 -0
- package/docs/commands/liberica/supplier-contacts/delete.md +123 -0
- package/docs/commands/liberica/supplier-contacts/get.md +133 -0
- package/docs/commands/liberica/supplier-contacts/list.md +143 -0
- package/docs/commands/liberica/supplier-contacts/update.md +158 -0
- package/package.json +1 -1
- package/src/commands/liberica/calendar/index.ts +13 -0
- package/src/commands/liberica/calendar/list.ts +214 -0
- package/src/commands/liberica/calendar/set.ts +130 -0
- package/src/commands/liberica/client-contacts/create.ts +115 -0
- package/src/commands/liberica/client-contacts/delete.ts +140 -0
- package/src/commands/liberica/client-contacts/get.ts +103 -0
- package/src/commands/liberica/client-contacts/index.ts +19 -0
- package/src/commands/liberica/client-contacts/list.ts +118 -0
- package/src/commands/liberica/client-contacts/update.ts +137 -0
- package/src/commands/liberica/dict-types/get.ts +74 -0
- package/src/commands/liberica/dict-types/index.ts +15 -0
- package/src/commands/liberica/dict-types/list.ts +118 -0
- package/src/commands/liberica/dict-types/update.ts +134 -0
- package/src/commands/liberica/dicts/create.ts +175 -0
- package/src/commands/liberica/dicts/delete.ts +107 -0
- package/src/commands/liberica/dicts/get.ts +80 -0
- package/src/commands/liberica/dicts/index.ts +19 -0
- package/src/commands/liberica/dicts/list.ts +114 -0
- package/src/commands/liberica/dicts/update.ts +116 -0
- package/src/commands/liberica/index.ts +20 -0
- package/src/commands/liberica/materials/create.ts +13 -5
- package/src/commands/liberica/materials/update.ts +1 -1
- package/src/commands/liberica/mould/get.ts +111 -0
- package/src/commands/liberica/mould/index.ts +17 -0
- package/src/commands/liberica/mould/list.ts +157 -0
- package/src/commands/liberica/mould/set-status.ts +99 -0
- package/src/commands/liberica/mould/stock-in.ts +165 -0
- package/src/commands/liberica/operations/active.ts +153 -0
- package/src/commands/liberica/operations/batch-delete.ts +131 -0
- package/src/commands/liberica/operations/copy.ts +138 -0
- package/src/commands/liberica/operations/create.ts +223 -0
- package/src/commands/liberica/operations/deactive.ts +152 -0
- package/src/commands/liberica/operations/delete.ts +128 -0
- package/src/commands/liberica/operations/design.md +587 -0
- package/src/commands/liberica/operations/get.ts +112 -0
- package/src/commands/liberica/operations/index.ts +27 -0
- package/src/commands/liberica/operations/list.ts +180 -0
- package/src/commands/liberica/operations/update.ts +218 -0
- package/src/commands/liberica/stock/index.ts +13 -0
- package/src/commands/liberica/stock/ledger.ts +159 -0
- package/src/commands/liberica/stock/list.ts +128 -0
- package/src/commands/liberica/supplier-contacts/create.ts +120 -0
- package/src/commands/liberica/supplier-contacts/delete.ts +88 -0
- package/src/commands/liberica/supplier-contacts/get.ts +94 -0
- package/src/commands/liberica/supplier-contacts/index.ts +19 -0
- package/src/commands/liberica/supplier-contacts/list.ts +130 -0
- package/src/commands/liberica/supplier-contacts/update.ts +127 -0
- package/src/core/api/client.ts +1238 -17
- package/src/index.ts +1 -1
- package/src/types/calendar.ts +36 -0
- package/src/types/client-contact.ts +78 -0
- package/src/types/dict.ts +121 -0
- package/src/types/index.ts +7 -0
- package/src/types/material.ts +1 -1
- package/src/types/mould-stock-in.ts +82 -0
- package/src/types/mould.ts +74 -0
- package/src/types/operation.ts +72 -0
- package/src/types/stock.ts +161 -0
- package/src/types/supplier-contact.ts +78 -0
|
@@ -0,0 +1,130 @@
|
|
|
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 { SupplierContactListResponse } from '../../../types/supplier-contact.js';
|
|
7
|
+
import { Environment } from '../../../types/index.js';
|
|
8
|
+
|
|
9
|
+
export function createSupplierContactListCommand(): Command {
|
|
10
|
+
const listCommand = new Command('list');
|
|
11
|
+
listCommand.description('List supplier contacts with pagination');
|
|
12
|
+
|
|
13
|
+
listCommand
|
|
14
|
+
.requiredOption('-s, --supplier-id <string>', 'Supplier ID')
|
|
15
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
16
|
+
.option('-z, --size <number>', 'Page size', '20')
|
|
17
|
+
.option('-S, --search <string>', 'Search keyword (contact name)')
|
|
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
|
+
supplierId: string;
|
|
29
|
+
pageNo?: number;
|
|
30
|
+
pageSize?: number;
|
|
31
|
+
supplierContactName?: string;
|
|
32
|
+
} = { supplierId: options.supplierId };
|
|
33
|
+
|
|
34
|
+
if (page > 0) {
|
|
35
|
+
params.pageNo = page;
|
|
36
|
+
}
|
|
37
|
+
if (size > 0) {
|
|
38
|
+
params.pageSize = size;
|
|
39
|
+
}
|
|
40
|
+
if (options.search) {
|
|
41
|
+
params.supplierContactName = options.search as string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const response = await apiClient.listSupplierContacts(environment, tenant, params);
|
|
45
|
+
|
|
46
|
+
if (!response.success) {
|
|
47
|
+
console.error(chalk.red(`\n✗ Failed to list supplier contacts: ${response.error?.message || 'Unknown error'}`));
|
|
48
|
+
if (response.error?.code) {
|
|
49
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
50
|
+
}
|
|
51
|
+
console.error();
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const data = response.data as SupplierContactListResponse | null;
|
|
56
|
+
|
|
57
|
+
if (!data) {
|
|
58
|
+
if (options.json) {
|
|
59
|
+
console.log(JSON.stringify({ success: true, data: { items: [], pagination: { pageNo: 0, pageSize: 20, totalRows: 0 } } }, null, 2));
|
|
60
|
+
} else {
|
|
61
|
+
console.log(chalk.bold('\n📋 Supplier Contact List\n'));
|
|
62
|
+
console.log(chalk.gray(' No supplier contacts found\n'));
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (options.json) {
|
|
68
|
+
console.log(
|
|
69
|
+
JSON.stringify(
|
|
70
|
+
{
|
|
71
|
+
success: true,
|
|
72
|
+
data: {
|
|
73
|
+
items: data.rows || [],
|
|
74
|
+
pagination: {
|
|
75
|
+
pageNo: data.pageNo,
|
|
76
|
+
pageSize: data.pageSize,
|
|
77
|
+
totalRows: data.totalRows,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
null,
|
|
82
|
+
2
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const records = data.rows || [];
|
|
89
|
+
|
|
90
|
+
if (records.length === 0) {
|
|
91
|
+
console.log(chalk.bold('\n📋 Supplier Contact List\n'));
|
|
92
|
+
console.log(chalk.gray(' No supplier contacts found\n'));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log(chalk.bold('\n📋 Supplier Contact List\n'));
|
|
97
|
+
|
|
98
|
+
const table = new Table({
|
|
99
|
+
head: [chalk.bold('ID'), chalk.bold('NAME'), chalk.bold('PHONE'), chalk.bold('TELEPHONE'), chalk.bold('EMAIL'), chalk.bold('DEFAULT')],
|
|
100
|
+
colWidths: [10, 15, 15, 15, 25, 10],
|
|
101
|
+
style: {
|
|
102
|
+
head: [],
|
|
103
|
+
border: [],
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
for (const contact of records) {
|
|
108
|
+
const defaultText = contact.defaultFlag === 'Y' ? chalk.green('Y') : chalk.gray('N');
|
|
109
|
+
table.push([
|
|
110
|
+
contact.supplierContactId,
|
|
111
|
+
contact.supplierContactName || '-',
|
|
112
|
+
contact.supplierContactPhone || '-',
|
|
113
|
+
contact.supplierContactTelephone || '-',
|
|
114
|
+
contact.supplierContactEmail || '-',
|
|
115
|
+
defaultText,
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log(table.toString());
|
|
120
|
+
console.log();
|
|
121
|
+
console.log(
|
|
122
|
+
chalk.gray(
|
|
123
|
+
` Total: ${data.totalRows} | Page: ${data.pageNo + 1} / ${Math.ceil(data.totalRows / data.pageSize) || 1} | Size: ${data.pageSize}`
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
console.log();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return listCommand;
|
|
130
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
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 { UpdateSupplierContactRequest } from '../../../types/supplier-contact.js';
|
|
6
|
+
|
|
7
|
+
export function createSupplierContactUpdateCommand(): Command {
|
|
8
|
+
const cmd = new Command('update');
|
|
9
|
+
cmd.description('Update an existing supplier contact');
|
|
10
|
+
|
|
11
|
+
cmd
|
|
12
|
+
.arguments('<contact-id>')
|
|
13
|
+
.option('-n, --name <string>', 'Contact name')
|
|
14
|
+
.option('-p, --phone <string>', 'Phone number')
|
|
15
|
+
.option('-t, --telephone <string>', 'Telephone number')
|
|
16
|
+
.option('-e, --email <string>', 'Email address')
|
|
17
|
+
.option('-x, --sex <string>', 'Sex')
|
|
18
|
+
.option('-b, --birthday <string>', 'Birthday (YYYY-MM-DD)')
|
|
19
|
+
.option('-q, --qq <string>', 'QQ number')
|
|
20
|
+
.option('-w, --wechat <string>', 'WeChat ID')
|
|
21
|
+
.option('-a, --address <string>', 'Address')
|
|
22
|
+
.option('-d, --default', 'Set as default contact')
|
|
23
|
+
.option('-r, --remark <string>', 'Remark')
|
|
24
|
+
.option('--dry-run', 'Preview the operation without executing')
|
|
25
|
+
.option('--json', 'Output as JSON')
|
|
26
|
+
.action(async (contactId: string, options: Record<string, unknown>) => {
|
|
27
|
+
const context = configManager.getCurrentContext();
|
|
28
|
+
const environment = context.environment;
|
|
29
|
+
const tenant = context.tenant;
|
|
30
|
+
const jsonOutput = options.json === true;
|
|
31
|
+
|
|
32
|
+
if (!contactId || contactId.trim() === '') {
|
|
33
|
+
if (jsonOutput) {
|
|
34
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'contact-id is required' } }));
|
|
35
|
+
} else {
|
|
36
|
+
console.error(chalk.red('\n✗ Contact ID is required\n'));
|
|
37
|
+
}
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const data: UpdateSupplierContactRequest = {
|
|
42
|
+
supplierContactId: contactId,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (options.name) data.supplierContactName = options.name as string;
|
|
46
|
+
if (options.phone) data.supplierContactPhone = options.phone as string;
|
|
47
|
+
if (options.telephone) data.supplierContactTelephone = options.telephone as string;
|
|
48
|
+
if (options.email) data.supplierContactEmail = options.email as string;
|
|
49
|
+
if (options.sex) data.supplierContactSex = options.sex as string;
|
|
50
|
+
if (options.birthday) data.supplierContactBirthday = options.birthday as string;
|
|
51
|
+
if (options.qq) data.supplierContactQq = options.qq as string;
|
|
52
|
+
if (options.wechat) data.supplierContactWechat = options.wechat as string;
|
|
53
|
+
if (options.address) data.supplierContactAddress = options.address as string;
|
|
54
|
+
if (options.default === true) data.defaultFlag = 'Y';
|
|
55
|
+
else if (options.default === false) data.defaultFlag = 'N';
|
|
56
|
+
if (options.remark) data.remark = options.remark as string;
|
|
57
|
+
|
|
58
|
+
Object.keys(data).forEach(key => {
|
|
59
|
+
if (data[key as keyof UpdateSupplierContactRequest] === undefined) {
|
|
60
|
+
delete data[key as keyof UpdateSupplierContactRequest];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (Object.keys(data).length <= 1) {
|
|
65
|
+
if (jsonOutput) {
|
|
66
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'At least one field must be provided to update' } }));
|
|
67
|
+
} else {
|
|
68
|
+
console.error(chalk.red('\n✗ At least one field must be provided to update\n'));
|
|
69
|
+
}
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (options.dryRun) {
|
|
74
|
+
if (jsonOutput) {
|
|
75
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
76
|
+
} else {
|
|
77
|
+
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual API call will be made\n'));
|
|
78
|
+
console.log(chalk.gray(' This operation will update the following supplier contact:'));
|
|
79
|
+
console.log(` ${chalk.gray('Contact ID:')} ${contactId}`);
|
|
80
|
+
Object.keys(data).forEach(key => {
|
|
81
|
+
if (key !== 'supplierContactId' && data[key as keyof UpdateSupplierContactRequest] !== undefined) {
|
|
82
|
+
console.log(` ${chalk.gray(key + ':')} ${data[key as keyof UpdateSupplierContactRequest]}`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
console.log();
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const response = await apiClient.updateSupplierContact(environment, tenant, data);
|
|
92
|
+
|
|
93
|
+
if (response.success) {
|
|
94
|
+
if (jsonOutput) {
|
|
95
|
+
console.log(JSON.stringify({ success: true, data: response.data }));
|
|
96
|
+
} else {
|
|
97
|
+
console.log(chalk.green('\n✓ Supplier contact updated successfully\n'));
|
|
98
|
+
console.log(` ${chalk.gray('Contact ID:')} ${chalk.green(contactId)}`);
|
|
99
|
+
console.log();
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
const errorMsg = response.error?.message || 'Failed to update supplier contact';
|
|
103
|
+
const errorCode = response.error?.code || 'UPDATE_ERROR';
|
|
104
|
+
if (jsonOutput) {
|
|
105
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
106
|
+
} else {
|
|
107
|
+
console.error(chalk.red(`\n✗ Failed to update supplier contact: ${errorMsg}`));
|
|
108
|
+
if (response.error?.code) {
|
|
109
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
110
|
+
}
|
|
111
|
+
console.error();
|
|
112
|
+
}
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
117
|
+
if (jsonOutput) {
|
|
118
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
119
|
+
} else {
|
|
120
|
+
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
121
|
+
}
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return cmd;
|
|
127
|
+
}
|