@newpeak/barista-cli 0.1.11 → 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,130 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
4
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
-
import { CalendarSetRequest, DateType } from '../../../types/calendar.js';
|
|
6
|
-
|
|
7
|
-
const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
8
|
-
const DATE_TYPE_REGEX = /^(WORKDAY|WEEKEND|HOLIDAY)$/;
|
|
9
|
-
|
|
10
|
-
function validateFields(data: CalendarSetRequest): string | null {
|
|
11
|
-
if (!DATE_REGEX.test(data.calendarDate)) {
|
|
12
|
-
return 'Invalid date format. Date must be in YYYY-MM-DD format.';
|
|
13
|
-
}
|
|
14
|
-
if (!DATE_TYPE_REGEX.test(data.dateType)) {
|
|
15
|
-
return 'Invalid date type. Must be WORKDAY, WEEKEND, or HOLIDAY.';
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function formatTable(data: CalendarSetRequest): string {
|
|
21
|
-
const lines: string[] = [];
|
|
22
|
-
lines.push(` ${chalk.gray('Date:')} ${data.calendarDate}`);
|
|
23
|
-
lines.push(` ${chalk.gray('Type:')} ${data.dateType}`);
|
|
24
|
-
if (data.remark) lines.push(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
25
|
-
return lines.join('\n');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function createCalendarSetCommand(): Command {
|
|
29
|
-
const cmd = new Command('set');
|
|
30
|
-
cmd.description('Set calendar date type');
|
|
31
|
-
|
|
32
|
-
cmd
|
|
33
|
-
.option('-d, --date <date>', 'Date to set (YYYY-MM-DD, required)')
|
|
34
|
-
.option('-t, --type <type>', 'Date type (WORKDAY|WEEKEND|HOLIDAY, required)')
|
|
35
|
-
.option('-r, --remark <text>', 'Remark/note')
|
|
36
|
-
.option('--dry-run', 'Preview without making API call')
|
|
37
|
-
.option('--json', 'Output as JSON');
|
|
38
|
-
|
|
39
|
-
cmd.action(async () => {
|
|
40
|
-
const context = configManager.getCurrentContext();
|
|
41
|
-
const opts = cmd.opts();
|
|
42
|
-
|
|
43
|
-
const date = opts.date as string | undefined;
|
|
44
|
-
const type = opts.type as string | undefined;
|
|
45
|
-
const remark = opts.remark as string | undefined;
|
|
46
|
-
const dryRun = opts.dryRun === true;
|
|
47
|
-
const jsonOutput = opts.json === true;
|
|
48
|
-
|
|
49
|
-
// Validate required options
|
|
50
|
-
if (!date) {
|
|
51
|
-
if (jsonOutput) {
|
|
52
|
-
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'Date is required. Use --date (or -d).' } }));
|
|
53
|
-
} else {
|
|
54
|
-
console.error(chalk.red('\n✗ Date is required. Use --date (or -d).\n'));
|
|
55
|
-
}
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!type) {
|
|
60
|
-
if (jsonOutput) {
|
|
61
|
-
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'Date type is required. Use --type (or -t).' } }));
|
|
62
|
-
} else {
|
|
63
|
-
console.error(chalk.red('\n✗ Date type is required. Use --type (or -t).\n'));
|
|
64
|
-
}
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const data: CalendarSetRequest = {
|
|
69
|
-
calendarDate: date,
|
|
70
|
-
dateType: type as DateType,
|
|
71
|
-
remark,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// Validate fields
|
|
75
|
-
const validationError = validateFields(data);
|
|
76
|
-
if (validationError) {
|
|
77
|
-
if (jsonOutput) {
|
|
78
|
-
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: validationError } }));
|
|
79
|
-
} else {
|
|
80
|
-
console.error(chalk.red(`\n✗ ${validationError}\n`));
|
|
81
|
-
}
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (dryRun) {
|
|
86
|
-
if (jsonOutput) {
|
|
87
|
-
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
88
|
-
} else {
|
|
89
|
-
console.log(chalk.bold('\n🔍 Dry-Run Mode: No changes will be made\n'));
|
|
90
|
-
console.log(' Calendar to be updated:');
|
|
91
|
-
console.log(formatTable(data));
|
|
92
|
-
console.log();
|
|
93
|
-
}
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (!jsonOutput) {
|
|
98
|
-
console.log(chalk.bold('\n📝 Updating Calendar\n'));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const response = await apiClient.setCalendar(context.environment, context.tenant, data);
|
|
102
|
-
|
|
103
|
-
if (!response.success) {
|
|
104
|
-
const errorMsg = response.error?.message || 'Failed to update calendar';
|
|
105
|
-
const errorCode = response.error?.code || 'SET_CALENDAR_ERROR';
|
|
106
|
-
if (jsonOutput) {
|
|
107
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
108
|
-
} else {
|
|
109
|
-
console.error(chalk.red(`\n✗ Failed to update calendar: ${errorMsg}`));
|
|
110
|
-
if (response.error?.code) {
|
|
111
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
112
|
-
}
|
|
113
|
-
console.error();
|
|
114
|
-
}
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (jsonOutput) {
|
|
119
|
-
console.log(JSON.stringify({ success: true, data: { calendarDate: data.calendarDate, dateType: data.dateType, remark: data.remark } }));
|
|
120
|
-
} else {
|
|
121
|
-
console.log(chalk.green(`✓ Calendar updated: ${data.calendarDate} -> ${data.dateType}\n`));
|
|
122
|
-
if (data.remark) {
|
|
123
|
-
console.log(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
124
|
-
}
|
|
125
|
-
console.log();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
return cmd;
|
|
130
|
-
}
|
|
@@ -1,115 +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 { CreateClientContactRequest } from '../../../types/client-contact.js';
|
|
6
|
-
|
|
7
|
-
export function createClientContactCreateCommand(): Command {
|
|
8
|
-
const cmd = new Command('create');
|
|
9
|
-
cmd.description('Create a new client contact');
|
|
10
|
-
|
|
11
|
-
cmd
|
|
12
|
-
.requiredOption('-c, --client-id <string>', 'Client ID (required)')
|
|
13
|
-
.requiredOption('-n, --name <string>', 'Contact name (required)')
|
|
14
|
-
.option('-p, --phone <string>', 'Mobile phone')
|
|
15
|
-
.option('-t, --telephone <string>', 'Telephone')
|
|
16
|
-
.option('-e, --email <string>', 'Email')
|
|
17
|
-
.option('-s, --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 (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
|
-
const clientId = options.clientId as string;
|
|
33
|
-
const clientContactName = options.name as string;
|
|
34
|
-
|
|
35
|
-
const data: CreateClientContactRequest = {
|
|
36
|
-
clientId,
|
|
37
|
-
clientContactName,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
if (options.phone) data.clientContactPhone = options.phone as string;
|
|
41
|
-
if (options.telephone) data.clientContactTelephone = options.telephone as string;
|
|
42
|
-
if (options.email) data.clientContactEmail = options.email as string;
|
|
43
|
-
if (options.sex) data.clientContactSex = options.sex as string;
|
|
44
|
-
if (options.birthday) data.clientContactBirthday = options.birthday as string;
|
|
45
|
-
if (options.qq) data.clientContactQq = options.qq as string;
|
|
46
|
-
if (options.wechat) data.clientContactWechat = options.wechat as string;
|
|
47
|
-
if (options.address) data.clientContactAddress = options.address as string;
|
|
48
|
-
if (options.default) data.defaultFlag = 'Y';
|
|
49
|
-
if (options.remark) data.remark = options.remark as string;
|
|
50
|
-
|
|
51
|
-
if (options.dryRun) {
|
|
52
|
-
if (jsonOutput) {
|
|
53
|
-
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
54
|
-
} else {
|
|
55
|
-
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual API call will be made\n'));
|
|
56
|
-
console.log(chalk.gray(' This operation will create the following client contact:'));
|
|
57
|
-
console.log(` ${chalk.gray('Client ID:')} ${clientId}`);
|
|
58
|
-
console.log(` ${chalk.gray('Name:')} ${clientContactName}`);
|
|
59
|
-
if (data.clientContactPhone) console.log(` ${chalk.gray('Phone:')} ${data.clientContactPhone}`);
|
|
60
|
-
if (data.clientContactTelephone) console.log(` ${chalk.gray('Telephone:')} ${data.clientContactTelephone}`);
|
|
61
|
-
if (data.clientContactEmail) console.log(` ${chalk.gray('Email:')} ${data.clientContactEmail}`);
|
|
62
|
-
if (data.clientContactSex) console.log(` ${chalk.gray('Sex:')} ${data.clientContactSex}`);
|
|
63
|
-
if (data.clientContactBirthday) console.log(` ${chalk.gray('Birthday:')} ${data.clientContactBirthday}`);
|
|
64
|
-
if (data.clientContactQq) console.log(` ${chalk.gray('QQ:')} ${data.clientContactQq}`);
|
|
65
|
-
if (data.clientContactWechat) console.log(` ${chalk.gray('WeChat:')} ${data.clientContactWechat}`);
|
|
66
|
-
if (data.clientContactAddress) console.log(` ${chalk.gray('Address:')} ${data.clientContactAddress}`);
|
|
67
|
-
if (data.defaultFlag) console.log(` ${chalk.gray('Default:')} ${data.defaultFlag}`);
|
|
68
|
-
if (data.remark) console.log(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
69
|
-
console.log();
|
|
70
|
-
}
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const response = await apiClient.createClientContact(environment, tenant, data);
|
|
76
|
-
|
|
77
|
-
if (response.success) {
|
|
78
|
-
if (jsonOutput) {
|
|
79
|
-
console.log(JSON.stringify({ success: true, data: response.data }));
|
|
80
|
-
} else {
|
|
81
|
-
console.log(chalk.green('\n✓ Client contact created successfully\n'));
|
|
82
|
-
if (response.data && typeof response.data === 'object' && 'clientContactId' in response.data) {
|
|
83
|
-
console.log(` ${chalk.gray('Contact ID:')} ${chalk.green(String((response.data as { clientContactId: string }).clientContactId))}`);
|
|
84
|
-
}
|
|
85
|
-
console.log(` ${chalk.gray('Client ID:')} ${clientId}`);
|
|
86
|
-
console.log(` ${chalk.gray('Name:')} ${clientContactName}`);
|
|
87
|
-
console.log();
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
const errorMsg = response.error?.message || 'Failed to create client contact';
|
|
91
|
-
const errorCode = response.error?.code || 'CREATE_CLIENT_CONTACT_ERROR';
|
|
92
|
-
if (jsonOutput) {
|
|
93
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
94
|
-
} else {
|
|
95
|
-
console.error(chalk.red(`\n✗ Failed to create client contact: ${errorMsg}`));
|
|
96
|
-
if (response.error?.code) {
|
|
97
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
98
|
-
}
|
|
99
|
-
console.error();
|
|
100
|
-
}
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
105
|
-
if (jsonOutput) {
|
|
106
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
107
|
-
} else {
|
|
108
|
-
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
109
|
-
}
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
return cmd;
|
|
115
|
-
}
|
|
@@ -1,140 +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 { ClientContact } from '../../../types/client-contact.js';
|
|
7
|
-
|
|
8
|
-
export function createClientContactDeleteCommand(): Command {
|
|
9
|
-
const cmd = new Command('delete');
|
|
10
|
-
cmd.description('Delete a client contact');
|
|
11
|
-
|
|
12
|
-
cmd
|
|
13
|
-
.arguments('<contact-id>')
|
|
14
|
-
.option('--force', 'Skip confirmation and actually delete')
|
|
15
|
-
.option('--dry-run', 'Preview the operation (default)')
|
|
16
|
-
.option('--json', 'Output as JSON')
|
|
17
|
-
.action(async (contactId: string, options: Record<string, unknown>) => {
|
|
18
|
-
const context = configManager.getCurrentContext();
|
|
19
|
-
const environment = context.environment as Environment;
|
|
20
|
-
const tenant = context.tenant;
|
|
21
|
-
const jsonOutput = options.json === true;
|
|
22
|
-
|
|
23
|
-
if (!contactId || contactId.trim() === '') {
|
|
24
|
-
if (jsonOutput) {
|
|
25
|
-
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'contact-id is required' } }));
|
|
26
|
-
} else {
|
|
27
|
-
console.error(chalk.red('\n✗ Contact ID is required\n'));
|
|
28
|
-
}
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!jsonOutput) {
|
|
33
|
-
console.log(chalk.bold(`\n🗑️ Delete Client Contact (${environment})\n`));
|
|
34
|
-
console.log(chalk.gray(` Contact ID: ${contactId}`));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let contact: ClientContact | undefined;
|
|
38
|
-
try {
|
|
39
|
-
const contactResponse = await apiClient.getClientContact(environment, tenant, contactId);
|
|
40
|
-
if (!contactResponse.success || !contactResponse.data) {
|
|
41
|
-
const errMsg = `Client contact not found: ${contactId}`;
|
|
42
|
-
if (jsonOutput) {
|
|
43
|
-
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
44
|
-
} else {
|
|
45
|
-
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
46
|
-
}
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
contact = contactResponse.data as ClientContact;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
52
|
-
if (jsonOutput) {
|
|
53
|
-
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch client contact: ${errMsg}` } }));
|
|
54
|
-
} else {
|
|
55
|
-
console.error(chalk.red(`\n✗ Failed to fetch client contact: ${errMsg}\n`));
|
|
56
|
-
}
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!jsonOutput && contact) {
|
|
61
|
-
console.log(chalk.gray(` Name: ${contact.clientContactName}`));
|
|
62
|
-
console.log(chalk.gray(` Client ID: ${contact.clientId}`));
|
|
63
|
-
if (contact.clientContactPhone) {
|
|
64
|
-
console.log(chalk.gray(` Phone: ${contact.clientContactPhone}`));
|
|
65
|
-
}
|
|
66
|
-
if (contact.clientContactEmail) {
|
|
67
|
-
console.log(chalk.gray(` Email: ${contact.clientContactEmail}`));
|
|
68
|
-
}
|
|
69
|
-
if (contact.defaultFlag === 'Y') {
|
|
70
|
-
console.log(chalk.gray(` Default: Yes`));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const isDryRun = !options.force;
|
|
75
|
-
|
|
76
|
-
if (isDryRun) {
|
|
77
|
-
if (jsonOutput) {
|
|
78
|
-
console.log(JSON.stringify({
|
|
79
|
-
success: true,
|
|
80
|
-
dryRun: true,
|
|
81
|
-
message: 'Dry-Run Mode: No actual API call will be made',
|
|
82
|
-
data: { clientContactId: contactId, contact }
|
|
83
|
-
}));
|
|
84
|
-
} else {
|
|
85
|
-
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual API call will be made\n'));
|
|
86
|
-
console.log(chalk.yellow(' ⚠️ Add --force option to confirm deletion'));
|
|
87
|
-
console.log();
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
const response = await apiClient.deleteClientContact(environment, tenant, contactId);
|
|
94
|
-
|
|
95
|
-
if (response.success) {
|
|
96
|
-
if (jsonOutput) {
|
|
97
|
-
console.log(JSON.stringify({ success: true, data: { clientContactId: contactId, contactName: contact.clientContactName } }));
|
|
98
|
-
} else {
|
|
99
|
-
console.log(chalk.green('\n✓ Client contact deleted successfully\n'));
|
|
100
|
-
console.log(` ${chalk.gray('Contact ID:')} ${chalk.green(contactId)}`);
|
|
101
|
-
console.log(` ${chalk.gray('Name:')} ${chalk.green(contact.clientContactName)}`);
|
|
102
|
-
console.log();
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
const errorMsg = response.error?.message || 'Failed to delete client contact';
|
|
106
|
-
const errorCode = response.error?.code || 'DELETE_ERROR';
|
|
107
|
-
|
|
108
|
-
// Handle "not found" error (should not happen since we already fetched)
|
|
109
|
-
if (errorCode === '01001207001' || errorMsg.includes('不存在')) {
|
|
110
|
-
if (jsonOutput) {
|
|
111
|
-
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: `Client contact not found: ${contactId}` } }));
|
|
112
|
-
} else {
|
|
113
|
-
console.error(chalk.red(`\n✗ Client contact not found: ${contactId}\n`));
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
if (jsonOutput) {
|
|
117
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
118
|
-
} else {
|
|
119
|
-
console.error(chalk.red(`\n✗ Failed to delete client contact: ${errorMsg}`));
|
|
120
|
-
if (response.error?.code) {
|
|
121
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
122
|
-
}
|
|
123
|
-
console.error();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
} catch (error) {
|
|
129
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
130
|
-
if (jsonOutput) {
|
|
131
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
132
|
-
} else {
|
|
133
|
-
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
134
|
-
}
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
return cmd;
|
|
140
|
-
}
|
|
@@ -1,103 +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 { ClientContact } from '../../../types/client-contact.js';
|
|
7
|
-
|
|
8
|
-
export function createClientContactGetCommand(): Command {
|
|
9
|
-
const getCommand = new Command('get');
|
|
10
|
-
getCommand.description('Get client contact details by ID');
|
|
11
|
-
getCommand.arguments('<contact-id>');
|
|
12
|
-
getCommand.option('--json', 'Output as JSON');
|
|
13
|
-
|
|
14
|
-
getCommand.action(async (id: 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 (!id) {
|
|
20
|
-
console.error(chalk.red('\n✗ Client contact ID is required\n'));
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const clientContactId = id;
|
|
25
|
-
if (!clientContactId || clientContactId.trim() === '') {
|
|
26
|
-
console.error(chalk.red('\n✗ Invalid client contact ID.\n'));
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const response = await apiClient.getClientContact(environment, tenant, clientContactId);
|
|
32
|
-
|
|
33
|
-
if (!response.success) {
|
|
34
|
-
const errorCode = response.error?.code || 'UNKNOWN_ERROR';
|
|
35
|
-
const errorMessage = response.error?.message || 'Unknown error';
|
|
36
|
-
|
|
37
|
-
if (errorCode === '01001207001' || errorMessage.includes('不存在')) {
|
|
38
|
-
console.error(chalk.red(`\n✗ Client contact not found: ${clientContactId}\n`));
|
|
39
|
-
} else {
|
|
40
|
-
console.error(chalk.red(`\n✗ Error: ${errorMessage} (${errorCode})\n`));
|
|
41
|
-
}
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const contact = response.data as ClientContact | null;
|
|
46
|
-
|
|
47
|
-
if (!contact) {
|
|
48
|
-
console.error(chalk.red('\n✗ Client contact not found\n'));
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (options.json) {
|
|
53
|
-
console.log(JSON.stringify({
|
|
54
|
-
success: true,
|
|
55
|
-
data: contact,
|
|
56
|
-
}, null, 2));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.log(chalk.bold('\n📇 Client Contact Details\n'));
|
|
61
|
-
console.log(` ${chalk.gray('Contact ID:')} ${contact.clientContactId}`);
|
|
62
|
-
console.log(` ${chalk.gray('Client ID:')} ${contact.clientId}`);
|
|
63
|
-
console.log(` ${chalk.gray('Name:')} ${contact.clientContactName}`);
|
|
64
|
-
if (contact.clientContactPhone) {
|
|
65
|
-
console.log(` ${chalk.gray('Phone:')} ${contact.clientContactPhone}`);
|
|
66
|
-
}
|
|
67
|
-
if (contact.clientContactTelephone) {
|
|
68
|
-
console.log(` ${chalk.gray('Telephone:')} ${contact.clientContactTelephone}`);
|
|
69
|
-
}
|
|
70
|
-
if (contact.clientContactEmail) {
|
|
71
|
-
console.log(` ${chalk.gray('Email:')} ${contact.clientContactEmail}`);
|
|
72
|
-
}
|
|
73
|
-
if (contact.clientContactSex) {
|
|
74
|
-
console.log(` ${chalk.gray('Sex:')} ${contact.clientContactSex}`);
|
|
75
|
-
}
|
|
76
|
-
if (contact.clientContactBirthday) {
|
|
77
|
-
console.log(` ${chalk.gray('Birthday:')} ${contact.clientContactBirthday}`);
|
|
78
|
-
}
|
|
79
|
-
if (contact.clientContactQq) {
|
|
80
|
-
console.log(` ${chalk.gray('QQ:')} ${contact.clientContactQq}`);
|
|
81
|
-
}
|
|
82
|
-
if (contact.clientContactWechat) {
|
|
83
|
-
console.log(` ${chalk.gray('WeChat:')} ${contact.clientContactWechat}`);
|
|
84
|
-
}
|
|
85
|
-
if (contact.clientContactAddress) {
|
|
86
|
-
console.log(` ${chalk.gray('Address:')} ${contact.clientContactAddress}`);
|
|
87
|
-
}
|
|
88
|
-
if (contact.defaultFlag) {
|
|
89
|
-
const defaultText = contact.defaultFlag === 'Y' ? chalk.green('Yes') : chalk.gray('No');
|
|
90
|
-
console.log(` ${chalk.gray('Default:')} ${defaultText}`);
|
|
91
|
-
}
|
|
92
|
-
if (contact.remark) {
|
|
93
|
-
console.log(` ${chalk.gray('Remark:')} ${contact.remark}`);
|
|
94
|
-
}
|
|
95
|
-
console.log();
|
|
96
|
-
} catch (error) {
|
|
97
|
-
console.error(chalk.red(`\n✗ Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return getCommand;
|
|
103
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { createClientContactListCommand } from './list.js';
|
|
3
|
-
import { createClientContactGetCommand } from './get.js';
|
|
4
|
-
import { createClientContactCreateCommand } from './create.js';
|
|
5
|
-
import { createClientContactUpdateCommand } from './update.js';
|
|
6
|
-
import { createClientContactDeleteCommand } from './delete.js';
|
|
7
|
-
|
|
8
|
-
export function createClientContactsCommand(): Command {
|
|
9
|
-
const clientContactsCommand = new Command('client-contacts');
|
|
10
|
-
clientContactsCommand.description('Manage client contacts');
|
|
11
|
-
|
|
12
|
-
clientContactsCommand.addCommand(createClientContactListCommand());
|
|
13
|
-
clientContactsCommand.addCommand(createClientContactGetCommand());
|
|
14
|
-
clientContactsCommand.addCommand(createClientContactCreateCommand());
|
|
15
|
-
clientContactsCommand.addCommand(createClientContactUpdateCommand());
|
|
16
|
-
clientContactsCommand.addCommand(createClientContactDeleteCommand());
|
|
17
|
-
|
|
18
|
-
return clientContactsCommand;
|
|
19
|
-
}
|
|
@@ -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 { ClientContactListResponse } from '../../../types/client-contact.js';
|
|
7
|
-
import { Environment } from '../../../types/index.js';
|
|
8
|
-
|
|
9
|
-
export function createClientContactListCommand(): Command {
|
|
10
|
-
const listCommand = new Command('list');
|
|
11
|
-
listCommand.description('List client contacts with pagination');
|
|
12
|
-
|
|
13
|
-
listCommand
|
|
14
|
-
.requiredOption('-c, --client-id <string>', 'Client ID (required)')
|
|
15
|
-
.option('-p, --page <number>', 'Page number', '1')
|
|
16
|
-
.option('-s, --size <number>', 'Page size', '20')
|
|
17
|
-
.option('--json', 'Output as JSON')
|
|
18
|
-
.action(async (options) => {
|
|
19
|
-
const context = configManager.getCurrentContext();
|
|
20
|
-
const environment = (options.env as Environment) || context.environment;
|
|
21
|
-
const tenant = options.tenant || context.tenant;
|
|
22
|
-
|
|
23
|
-
const page = parseInt(options.page as string, 10) - 1; // API uses 0-based pagination
|
|
24
|
-
const size = parseInt(options.size as string, 10);
|
|
25
|
-
|
|
26
|
-
const params = {
|
|
27
|
-
clientId: options.clientId as string,
|
|
28
|
-
pageNo: page,
|
|
29
|
-
pageSize: size,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const response = await apiClient.listClientContacts(environment, tenant, params);
|
|
33
|
-
|
|
34
|
-
if (!response.success) {
|
|
35
|
-
console.error(chalk.red(`\n✗ Failed to list client contacts: ${response.error?.message || 'Unknown error'}`));
|
|
36
|
-
if (response.error?.code) {
|
|
37
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
38
|
-
}
|
|
39
|
-
console.error();
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const data = response.data as ClientContactListResponse | null;
|
|
44
|
-
|
|
45
|
-
if (!data) {
|
|
46
|
-
if (options.json) {
|
|
47
|
-
console.log(JSON.stringify({ success: true, data: { items: [], pagination: { pageNo: 0, pageSize: 20, totalRows: 0 } } }, null, 2));
|
|
48
|
-
} else {
|
|
49
|
-
console.log(chalk.bold('\n📋 Client Contact List\n'));
|
|
50
|
-
console.log(chalk.gray(' No client contacts found\n'));
|
|
51
|
-
}
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (options.json) {
|
|
56
|
-
console.log(
|
|
57
|
-
JSON.stringify(
|
|
58
|
-
{
|
|
59
|
-
success: true,
|
|
60
|
-
data: {
|
|
61
|
-
items: data.rows || [],
|
|
62
|
-
pagination: {
|
|
63
|
-
pageNo: data.pageNo,
|
|
64
|
-
pageSize: data.pageSize,
|
|
65
|
-
totalRows: data.totalRows,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
null,
|
|
70
|
-
2
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const records = data.rows || [];
|
|
77
|
-
|
|
78
|
-
if (records.length === 0) {
|
|
79
|
-
console.log(chalk.bold('\n📋 Client Contact List\n'));
|
|
80
|
-
console.log(chalk.gray(' No client contacts found\n'));
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log(chalk.bold('\n📋 Client Contact List\n'));
|
|
85
|
-
|
|
86
|
-
const table = new Table({
|
|
87
|
-
head: [chalk.bold('ID'), chalk.bold('NAME'), chalk.bold('PHONE'), chalk.bold('TELEPHONE'), chalk.bold('EMAIL'), chalk.bold('DEFAULT')],
|
|
88
|
-
colWidths: [10, 15, 15, 15, 25, 10],
|
|
89
|
-
style: {
|
|
90
|
-
head: [],
|
|
91
|
-
border: [],
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
for (const contact of records) {
|
|
96
|
-
const defaultText = contact.defaultFlag === 'Y' ? chalk.green('Y') : chalk.gray('N');
|
|
97
|
-
table.push([
|
|
98
|
-
contact.clientContactId,
|
|
99
|
-
contact.clientContactName || '-',
|
|
100
|
-
contact.clientContactPhone || '-',
|
|
101
|
-
contact.clientContactTelephone || '-',
|
|
102
|
-
contact.clientContactEmail || '-',
|
|
103
|
-
defaultText,
|
|
104
|
-
]);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
console.log(table.toString());
|
|
108
|
-
console.log();
|
|
109
|
-
console.log(
|
|
110
|
-
chalk.gray(
|
|
111
|
-
` Total: ${data.totalRows} | Page: ${data.pageNo + 1} / ${Math.ceil(data.totalRows / data.pageSize) || 1} | Size: ${data.pageSize}`
|
|
112
|
-
)
|
|
113
|
-
);
|
|
114
|
-
console.log();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return listCommand;
|
|
118
|
-
}
|