@newpeak/barista-cli 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +7 -3
- package/docs/ARCHITECTURE.md +0 -184
- package/docs/COMMANDS.md +0 -352
- package/docs/COMMAND_DESIGN_SPEC.md +0 -840
- package/docs/INTEGRATION_NOTES.md +0 -270
- package/docs/commands/REFERENCE.md +0 -323
- package/docs/commands/arabica/auth/index.md +0 -296
- package/docs/commands/liberica/auth/index.md +0 -133
- package/docs/commands/liberica/calendar/DESIGN.md +0 -333
- package/docs/commands/liberica/client-contacts/create.md +0 -152
- package/docs/commands/liberica/client-contacts/delete.md +0 -123
- package/docs/commands/liberica/client-contacts/get.md +0 -133
- package/docs/commands/liberica/client-contacts/list.md +0 -143
- package/docs/commands/liberica/client-contacts/update.md +0 -158
- package/docs/commands/liberica/context/index.md +0 -60
- package/docs/commands/liberica/currency/create.md +0 -145
- package/docs/commands/liberica/currency/delete.md +0 -121
- package/docs/commands/liberica/currency/disable.md +0 -119
- package/docs/commands/liberica/currency/enable.md +0 -115
- package/docs/commands/liberica/currency/get.md +0 -118
- package/docs/commands/liberica/currency/list.md +0 -149
- package/docs/commands/liberica/currency/update.md +0 -141
- package/docs/commands/liberica/employees/create.md +0 -185
- package/docs/commands/liberica/employees/disable.md +0 -138
- package/docs/commands/liberica/employees/enable.md +0 -137
- package/docs/commands/liberica/employees/get.md +0 -153
- package/docs/commands/liberica/employees/list.md +0 -168
- package/docs/commands/liberica/employees/update.md +0 -180
- package/docs/commands/liberica/locations/create.md +0 -195
- package/docs/commands/liberica/locations/list.md +0 -171
- package/docs/commands/liberica/materials/create.md +0 -293
- package/docs/commands/liberica/materials/delete.md +0 -240
- package/docs/commands/liberica/materials/disable.md +0 -150
- package/docs/commands/liberica/materials/enable.md +0 -146
- package/docs/commands/liberica/materials/get.md +0 -188
- package/docs/commands/liberica/materials/list.md +0 -198
- package/docs/commands/liberica/materials/update.md +0 -250
- package/docs/commands/liberica/orgs/list.md +0 -62
- package/docs/commands/liberica/positions/list.md +0 -61
- package/docs/commands/liberica/roles/list.md +0 -67
- package/docs/commands/liberica/stock/ledger.md +0 -209
- package/docs/commands/liberica/stock/list.md +0 -165
- package/docs/commands/liberica/supplier-contacts/create.md +0 -152
- package/docs/commands/liberica/supplier-contacts/delete.md +0 -123
- package/docs/commands/liberica/supplier-contacts/get.md +0 -133
- package/docs/commands/liberica/supplier-contacts/list.md +0 -143
- package/docs/commands/liberica/supplier-contacts/update.md +0 -158
- package/docs/commands/liberica/teams/issues/close.md +0 -161
- package/docs/commands/liberica/teams/issues/create.md +0 -212
- package/docs/commands/liberica/teams/issues/delete.md +0 -179
- package/docs/commands/liberica/teams/issues/get.md +0 -167
- package/docs/commands/liberica/teams/issues/list.md +0 -182
- package/docs/commands/liberica/teams/issues/tests-design.md +0 -341
- package/docs/commands/liberica/teams/issues/update.md +0 -202
- package/docs/commands/liberica/teams/projects/create.md +0 -174
- package/docs/commands/liberica/teams/projects/delete.md +0 -180
- package/docs/commands/liberica/teams/projects/get.md +0 -150
- package/docs/commands/liberica/teams/projects/list.md +0 -179
- package/docs/commands/liberica/teams/projects/update.md +0 -175
- package/docs/commands/liberica/teams/tasks/create.md +0 -163
- package/docs/commands/liberica/teams/tasks/delete.md +0 -109
- package/docs/commands/liberica/teams/tasks/get.md +0 -121
- package/docs/commands/liberica/teams/tasks/list.md +0 -148
- package/docs/commands/liberica/teams/tasks/update.md +0 -158
- package/docs/commands/liberica/teams/work-logs/create.md +0 -151
- package/docs/commands/liberica/teams/work-logs/delete.md +0 -130
- package/docs/commands/liberica/teams/work-logs/get.md +0 -131
- package/docs/commands/liberica/teams/work-logs/list.md +0 -153
- package/docs/commands/liberica/teams/work-logs/update.md +0 -150
- package/docs/commands/liberica/transfer-in-forms/batch-delete.md +0 -157
- package/docs/commands/liberica/transfer-in-forms/batch-review.md +0 -157
- package/docs/commands/liberica/transfer-in-forms/batch-unreview.md +0 -157
- package/docs/commands/liberica/transfer-in-forms/create.md +0 -220
- package/docs/commands/liberica/transfer-in-forms/get.md +0 -221
- package/docs/commands/liberica/transfer-in-forms/list.md +0 -242
- package/docs/commands/liberica/transfer-in-forms/update.md +0 -185
- package/docs/commands/liberica/transfer-out-forms/batch-delete.md +0 -187
- package/docs/commands/liberica/transfer-out-forms/batch-review.md +0 -157
- package/docs/commands/liberica/transfer-out-forms/batch-unreview.md +0 -157
- package/docs/commands/liberica/transfer-out-forms/create.md +0 -280
- package/docs/commands/liberica/transfer-out-forms/get.md +0 -211
- package/docs/commands/liberica/transfer-out-forms/list.md +0 -233
- package/docs/commands/liberica/transfer-out-forms/update.md +0 -286
- package/docs/commands/liberica/uoms/create.md +0 -136
- package/docs/commands/liberica/uoms/delete.md +0 -119
- package/docs/commands/liberica/uoms/disable.md +0 -117
- package/docs/commands/liberica/uoms/enable.md +0 -115
- package/docs/commands/liberica/uoms/get.md +0 -119
- package/docs/commands/liberica/uoms/list.md +0 -155
- package/docs/commands/liberica/uoms/update.md +0 -148
- package/docs/commands/liberica/users/create.md +0 -170
- package/docs/commands/liberica/users/get.md +0 -151
- package/docs/commands/liberica/users/list.md +0 -175
- package/docs/commands/liberica/warehouses/create.md +0 -222
- package/docs/commands/liberica/warehouses/list.md +0 -184
- package/src/commands/arabica/auth/index.ts +0 -277
- package/src/commands/arabica/auth/login.ts +0 -5
- package/src/commands/arabica/auth/logout.ts +0 -5
- package/src/commands/arabica/auth/register.ts +0 -5
- package/src/commands/arabica/auth/status.ts +0 -5
- package/src/commands/arabica/index.ts +0 -23
- package/src/commands/auth.ts +0 -107
- package/src/commands/context.ts +0 -60
- package/src/commands/liberica/auth/index.ts +0 -176
- package/src/commands/liberica/calendar/index.ts +0 -13
- package/src/commands/liberica/calendar/list.ts +0 -214
- package/src/commands/liberica/calendar/set.ts +0 -130
- package/src/commands/liberica/client-contacts/create.ts +0 -115
- package/src/commands/liberica/client-contacts/delete.ts +0 -140
- package/src/commands/liberica/client-contacts/get.ts +0 -103
- package/src/commands/liberica/client-contacts/index.ts +0 -19
- package/src/commands/liberica/client-contacts/list.ts +0 -118
- package/src/commands/liberica/client-contacts/update.ts +0 -137
- package/src/commands/liberica/clients/create.ts +0 -122
- package/src/commands/liberica/clients/delete.ts +0 -125
- package/src/commands/liberica/clients/get.ts +0 -88
- package/src/commands/liberica/clients/index.ts +0 -19
- package/src/commands/liberica/clients/list.ts +0 -123
- package/src/commands/liberica/clients/update.ts +0 -103
- package/src/commands/liberica/context/index.ts +0 -43
- package/src/commands/liberica/currency/create.ts +0 -183
- package/src/commands/liberica/currency/delete.ts +0 -124
- package/src/commands/liberica/currency/disable.ts +0 -147
- package/src/commands/liberica/currency/enable.ts +0 -128
- package/src/commands/liberica/currency/get.ts +0 -91
- package/src/commands/liberica/currency/index.ts +0 -23
- package/src/commands/liberica/currency/list.ts +0 -140
- package/src/commands/liberica/currency/update.ts +0 -129
- package/src/commands/liberica/dict-types/get.ts +0 -74
- package/src/commands/liberica/dict-types/index.ts +0 -15
- package/src/commands/liberica/dict-types/list.ts +0 -118
- package/src/commands/liberica/dict-types/update.ts +0 -134
- package/src/commands/liberica/dicts/create.ts +0 -175
- package/src/commands/liberica/dicts/delete.ts +0 -107
- package/src/commands/liberica/dicts/get.ts +0 -80
- package/src/commands/liberica/dicts/index.ts +0 -19
- package/src/commands/liberica/dicts/list.ts +0 -114
- package/src/commands/liberica/dicts/update.ts +0 -116
- package/src/commands/liberica/employees/create.ts +0 -275
- package/src/commands/liberica/employees/delete.ts +0 -122
- package/src/commands/liberica/employees/disable.ts +0 -97
- package/src/commands/liberica/employees/enable.ts +0 -97
- package/src/commands/liberica/employees/get.ts +0 -115
- package/src/commands/liberica/employees/index.ts +0 -23
- package/src/commands/liberica/employees/list.ts +0 -131
- package/src/commands/liberica/employees/update.ts +0 -157
- package/src/commands/liberica/index.ts +0 -81
- package/src/commands/liberica/materials/create.ts +0 -199
- package/src/commands/liberica/materials/delete.ts +0 -105
- package/src/commands/liberica/materials/disable.ts +0 -148
- package/src/commands/liberica/materials/enable.ts +0 -129
- package/src/commands/liberica/materials/get.ts +0 -83
- package/src/commands/liberica/materials/index.ts +0 -23
- package/src/commands/liberica/materials/list.ts +0 -142
- package/src/commands/liberica/materials/update.ts +0 -125
- package/src/commands/liberica/mould/get.ts +0 -111
- package/src/commands/liberica/mould/index.ts +0 -17
- package/src/commands/liberica/mould/list.ts +0 -157
- package/src/commands/liberica/mould/set-status.ts +0 -99
- package/src/commands/liberica/mould/stock-in.ts +0 -165
- package/src/commands/liberica/operations/active.ts +0 -153
- package/src/commands/liberica/operations/batch-delete.ts +0 -131
- package/src/commands/liberica/operations/copy.ts +0 -138
- package/src/commands/liberica/operations/create.ts +0 -223
- package/src/commands/liberica/operations/deactive.ts +0 -152
- package/src/commands/liberica/operations/delete.ts +0 -128
- package/src/commands/liberica/operations/design.md +0 -587
- package/src/commands/liberica/operations/get.ts +0 -112
- package/src/commands/liberica/operations/index.ts +0 -27
- package/src/commands/liberica/operations/list.ts +0 -180
- package/src/commands/liberica/operations/update.ts +0 -218
- package/src/commands/liberica/orgs/index.ts +0 -34
- package/src/commands/liberica/positions/index.ts +0 -30
- package/src/commands/liberica/roles/index.ts +0 -59
- package/src/commands/liberica/stock/index.ts +0 -13
- package/src/commands/liberica/stock/ledger.ts +0 -159
- package/src/commands/liberica/stock/list.ts +0 -128
- package/src/commands/liberica/supplier-contacts/create.ts +0 -120
- package/src/commands/liberica/supplier-contacts/delete.ts +0 -88
- package/src/commands/liberica/supplier-contacts/get.ts +0 -94
- package/src/commands/liberica/supplier-contacts/index.ts +0 -19
- package/src/commands/liberica/supplier-contacts/list.ts +0 -130
- package/src/commands/liberica/supplier-contacts/update.ts +0 -127
- package/src/commands/liberica/suppliers/create.ts +0 -149
- package/src/commands/liberica/suppliers/delete.ts +0 -102
- package/src/commands/liberica/suppliers/disable.ts +0 -145
- package/src/commands/liberica/suppliers/enable.ts +0 -126
- package/src/commands/liberica/suppliers/get.ts +0 -86
- package/src/commands/liberica/suppliers/index.ts +0 -23
- package/src/commands/liberica/suppliers/list.ts +0 -134
- package/src/commands/liberica/suppliers/update.ts +0 -128
- package/src/commands/liberica/teams/index.ts +0 -17
- package/src/commands/liberica/teams/issues/close.ts +0 -104
- package/src/commands/liberica/teams/issues/create.ts +0 -254
- package/src/commands/liberica/teams/issues/delete.ts +0 -58
- package/src/commands/liberica/teams/issues/get.ts +0 -78
- package/src/commands/liberica/teams/issues/index.ts +0 -21
- package/src/commands/liberica/teams/issues/list.ts +0 -144
- package/src/commands/liberica/teams/issues/update.ts +0 -141
- package/src/commands/liberica/teams/projects/create.ts +0 -159
- package/src/commands/liberica/teams/projects/delete.ts +0 -58
- package/src/commands/liberica/teams/projects/get.ts +0 -87
- package/src/commands/liberica/teams/projects/index.ts +0 -19
- package/src/commands/liberica/teams/projects/list.ts +0 -147
- package/src/commands/liberica/teams/projects/update.ts +0 -117
- package/src/commands/liberica/teams/tasks/create.ts +0 -102
- package/src/commands/liberica/teams/tasks/delete.ts +0 -92
- package/src/commands/liberica/teams/tasks/get.ts +0 -64
- package/src/commands/liberica/teams/tasks/index.ts +0 -19
- package/src/commands/liberica/teams/tasks/list.ts +0 -102
- package/src/commands/liberica/teams/tasks/update.ts +0 -122
- package/src/commands/liberica/teams/work-logs/create.ts +0 -204
- package/src/commands/liberica/teams/work-logs/delete.ts +0 -58
- package/src/commands/liberica/teams/work-logs/get.ts +0 -87
- package/src/commands/liberica/teams/work-logs/index.ts +0 -19
- package/src/commands/liberica/teams/work-logs/list.ts +0 -141
- package/src/commands/liberica/teams/work-logs/update.ts +0 -120
- package/src/commands/liberica/transfer-in-forms/batch-delete.ts +0 -152
- package/src/commands/liberica/transfer-in-forms/batch-review.ts +0 -151
- package/src/commands/liberica/transfer-in-forms/batch-unreview.ts +0 -152
- package/src/commands/liberica/transfer-in-forms/create.ts +0 -179
- package/src/commands/liberica/transfer-in-forms/get.ts +0 -107
- package/src/commands/liberica/transfer-in-forms/index.ts +0 -23
- package/src/commands/liberica/transfer-in-forms/list.ts +0 -97
- package/src/commands/liberica/transfer-in-forms/update.ts +0 -213
- package/src/commands/liberica/transfer-out-forms/batch-delete.ts +0 -83
- package/src/commands/liberica/transfer-out-forms/batch-review.ts +0 -148
- package/src/commands/liberica/transfer-out-forms/batch-unreview.ts +0 -56
- package/src/commands/liberica/transfer-out-forms/create.ts +0 -194
- package/src/commands/liberica/transfer-out-forms/get.ts +0 -114
- package/src/commands/liberica/transfer-out-forms/index.ts +0 -23
- package/src/commands/liberica/transfer-out-forms/list.ts +0 -125
- package/src/commands/liberica/transfer-out-forms/update.ts +0 -197
- package/src/commands/liberica/uoms/create.ts +0 -134
- package/src/commands/liberica/uoms/delete.ts +0 -105
- package/src/commands/liberica/uoms/disable.ts +0 -148
- package/src/commands/liberica/uoms/enable.ts +0 -129
- package/src/commands/liberica/uoms/get.ts +0 -83
- package/src/commands/liberica/uoms/index.ts +0 -23
- package/src/commands/liberica/uoms/list.ts +0 -129
- package/src/commands/liberica/uoms/update.ts +0 -124
- package/src/commands/liberica/users/create.ts +0 -133
- package/src/commands/liberica/users/delete.ts +0 -49
- package/src/commands/liberica/users/disable.ts +0 -41
- package/src/commands/liberica/users/enable.ts +0 -30
- package/src/commands/liberica/users/get.ts +0 -46
- package/src/commands/liberica/users/index.ts +0 -27
- package/src/commands/liberica/users/list.ts +0 -68
- package/src/commands/liberica/users/me.ts +0 -42
- package/src/commands/liberica/users/reset-password.ts +0 -42
- package/src/commands/liberica/users/update.ts +0 -48
- package/src/commands/liberica/warehouses/create.ts +0 -204
- package/src/commands/liberica/warehouses/delete.ts +0 -112
- package/src/commands/liberica/warehouses/disable.ts +0 -174
- package/src/commands/liberica/warehouses/enable.ts +0 -174
- package/src/commands/liberica/warehouses/get.ts +0 -101
- package/src/commands/liberica/warehouses/index.ts +0 -25
- package/src/commands/liberica/warehouses/list.ts +0 -136
- package/src/commands/liberica/warehouses/locations/create.ts +0 -209
- package/src/commands/liberica/warehouses/locations/delete.ts +0 -116
- package/src/commands/liberica/warehouses/locations/disable.ts +0 -174
- package/src/commands/liberica/warehouses/locations/enable.ts +0 -174
- package/src/commands/liberica/warehouses/locations/get.ts +0 -84
- package/src/commands/liberica/warehouses/locations/index.ts +0 -23
- package/src/commands/liberica/warehouses/locations/list.ts +0 -140
- package/src/commands/liberica/warehouses/locations/update.ts +0 -135
- package/src/commands/liberica/warehouses/update.ts +0 -142
- package/src/core/api/client.ts +0 -4443
- package/src/core/auth/token-manager.ts +0 -183
- package/src/core/config/manager.ts +0 -164
- package/src/index.ts +0 -35
- package/src/types/calendar.ts +0 -36
- package/src/types/client-contact.ts +0 -78
- package/src/types/client.ts +0 -115
- package/src/types/currency.ts +0 -90
- package/src/types/dict.ts +0 -121
- package/src/types/employee.ts +0 -102
- package/src/types/index.ts +0 -93
- package/src/types/location.ts +0 -66
- package/src/types/material.ts +0 -61
- package/src/types/mould-stock-in.ts +0 -82
- package/src/types/mould.ts +0 -74
- package/src/types/operation.ts +0 -72
- package/src/types/org.ts +0 -25
- package/src/types/position.ts +0 -24
- package/src/types/stock.ts +0 -161
- package/src/types/supplier-contact.ts +0 -78
- package/src/types/supplier.ts +0 -66
- package/src/types/team-issue.ts +0 -94
- package/src/types/team-project.ts +0 -74
- package/src/types/team-task.ts +0 -98
- package/src/types/team-work-log.ts +0 -87
- package/src/types/transfer-in-form.ts +0 -265
- package/src/types/transfer-out-form.ts +0 -290
- package/src/types/uom.ts +0 -60
- package/src/types/user.ts +0 -64
- package/src/types/warehouse.ts +0 -82
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { createLibericaAuthCommand } from './auth/index.js';
|
|
4
|
-
import { createLibericaContextCommand } from './context/index.js';
|
|
5
|
-
import { createEmployeesCommand } from './employees/index.js';
|
|
6
|
-
import { createUsersCommand } from './users/index.js';
|
|
7
|
-
import { createOrgsCommand } from './orgs/index.js';
|
|
8
|
-
import { createPositionsCommand } from './positions/index.js';
|
|
9
|
-
import { createRolesCommand } from './roles/index.js';
|
|
10
|
-
import { createClientsCommand } from './clients/index.js';
|
|
11
|
-
import { createSuppliersCommand } from './suppliers/index.js';
|
|
12
|
-
import { createMaterialsCommand } from './materials/index.js';
|
|
13
|
-
import { createUomsCommand } from './uoms/index.js';
|
|
14
|
-
import { createCurrencyCommand } from './currency/index.js';
|
|
15
|
-
import { createWarehousesCommand } from './warehouses/index.js';
|
|
16
|
-
import { createDictTypesCommand } from './dict-types/index.js';
|
|
17
|
-
import { createDictsCommand } from './dicts/index.js';
|
|
18
|
-
import { createOperationsCommand } from './operations/index.js';
|
|
19
|
-
import { createStockCommand } from './stock/index.js';
|
|
20
|
-
import { createCalendarCommand } from './calendar/index.js';
|
|
21
|
-
import { createClientContactsCommand } from './client-contacts/index.js';
|
|
22
|
-
import { createSupplierContactsCommand } from './supplier-contacts/index.js';
|
|
23
|
-
import { createMouldCommand } from './mould/index.js';
|
|
24
|
-
import { createTeamsCommand } from './teams/index.js';
|
|
25
|
-
import { createTransferInFormsCommand } from './transfer-in-forms/index.js';
|
|
26
|
-
import { createTransferOutFormsCommand } from './transfer-out-forms/index.js';
|
|
27
|
-
|
|
28
|
-
export function createLibericaCommand(): Command {
|
|
29
|
-
const libericaCommand = new Command('liberica');
|
|
30
|
-
libericaCommand.description('Liberica production management operations');
|
|
31
|
-
|
|
32
|
-
libericaCommand.addCommand(createLibericaAuthCommand());
|
|
33
|
-
libericaCommand.addCommand(createLibericaContextCommand());
|
|
34
|
-
libericaCommand.addCommand(createEmployeesCommand());
|
|
35
|
-
libericaCommand.addCommand(createUsersCommand());
|
|
36
|
-
libericaCommand.addCommand(createOrgsCommand());
|
|
37
|
-
libericaCommand.addCommand(createPositionsCommand());
|
|
38
|
-
libericaCommand.addCommand(createRolesCommand());
|
|
39
|
-
libericaCommand.addCommand(createClientsCommand());
|
|
40
|
-
libericaCommand.addCommand(createSuppliersCommand());
|
|
41
|
-
libericaCommand.addCommand(createMaterialsCommand());
|
|
42
|
-
libericaCommand.addCommand(createUomsCommand());
|
|
43
|
-
libericaCommand.addCommand(createCurrencyCommand());
|
|
44
|
-
libericaCommand.addCommand(createWarehousesCommand());
|
|
45
|
-
libericaCommand.addCommand(createDictTypesCommand());
|
|
46
|
-
libericaCommand.addCommand(createDictsCommand());
|
|
47
|
-
libericaCommand.addCommand(createOperationsCommand());
|
|
48
|
-
libericaCommand.addCommand(createStockCommand());
|
|
49
|
-
libericaCommand.addCommand(createCalendarCommand());
|
|
50
|
-
libericaCommand.addCommand(createClientContactsCommand());
|
|
51
|
-
libericaCommand.addCommand(createSupplierContactsCommand());
|
|
52
|
-
libericaCommand.addCommand(createMouldCommand());
|
|
53
|
-
libericaCommand.addCommand(createTeamsCommand());
|
|
54
|
-
libericaCommand.addCommand(createTransferInFormsCommand());
|
|
55
|
-
libericaCommand.addCommand(createTransferOutFormsCommand());
|
|
56
|
-
|
|
57
|
-
libericaCommand.action(() => {
|
|
58
|
-
console.log(chalk.bold('\n☕ Liberica Commands\n'));
|
|
59
|
-
console.log(' Use "barista liberica auth <command>" for authentication');
|
|
60
|
-
console.log(' Use "barista liberica context <command>" for context management');
|
|
61
|
-
console.log(' Use "barista liberica employees <command>" for employee management');
|
|
62
|
-
console.log(' Use "barista liberica users <command>" for user management');
|
|
63
|
-
console.log(' Use "barista liberica orders <command>" for order operations');
|
|
64
|
-
console.log(' Use "barista liberica products <command>" for product operations');
|
|
65
|
-
console.log(' Use "barista liberica production <command>" for production operations');
|
|
66
|
-
console.log(' Use "barista liberica clients <command>" for client management');
|
|
67
|
-
console.log(' Use "barista liberica materials <command>" for material management');
|
|
68
|
-
console.log(' Use "barista liberica uoms <command>" for unit of measure management');
|
|
69
|
-
console.log(' Use "barista liberica currencies <command>" for currency management');
|
|
70
|
-
console.log(' Use "barista liberica warehouses <command>" for warehouse management');
|
|
71
|
-
console.log(' Use "barista liberica warehouses locations <command>" for warehouse location management');
|
|
72
|
-
console.log(' Use "barista liberica dict-types <command>" for dictionary type management');
|
|
73
|
-
console.log(' Use "barista liberica dicts <command>" for dictionary item management');
|
|
74
|
-
console.log(' Use "barista liberica operations <command>" for operation management');
|
|
75
|
-
console.log(' Use "barista liberica stock <command>" for stock management');
|
|
76
|
-
console.log(' Use "barista liberica teams <command>" for teams and issue management');
|
|
77
|
-
console.log('\n Run "barista liberica <command> --help" for more details\n');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return libericaCommand;
|
|
81
|
-
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
6
|
-
import { MaterialRequest } from '../../../types/material.js';
|
|
7
|
-
|
|
8
|
-
function formatTable(data: MaterialRequest): string {
|
|
9
|
-
const lines: string[] = [];
|
|
10
|
-
lines.push(` ${chalk.gray('Name:')} ${data.materialName || '(not set)'}`);
|
|
11
|
-
lines.push(` ${chalk.gray('No:')} ${data.materialNo || '(not set)'}`);
|
|
12
|
-
lines.push(` ${chalk.gray('Code:')} ${data.materialCode}`);
|
|
13
|
-
lines.push(` ${chalk.gray('Class:')} ${data.materialClass || '(not set)'}`);
|
|
14
|
-
if (data.materialType) lines.push(` ${chalk.gray('Type:')} ${data.materialType}`);
|
|
15
|
-
if (data.materialUomCode) lines.push(` ${chalk.gray('Unit:')} ${data.materialUomCode}`);
|
|
16
|
-
return lines.join('\n');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function createMaterialsCreateCommand(): Command {
|
|
20
|
-
const cmd = new Command('create');
|
|
21
|
-
cmd.description('Create a new material (auto-generates material code)');
|
|
22
|
-
|
|
23
|
-
cmd
|
|
24
|
-
.option('-n, --name <name>', 'Material name (required)')
|
|
25
|
-
.option('-c, --class <class>', 'Material class (required)')
|
|
26
|
-
.option('--no <no>', 'Material number (required)')
|
|
27
|
-
.option('--type <type>', 'Material type')
|
|
28
|
-
.option('-u, --unit <unit>', 'Material unit')
|
|
29
|
-
.option('--dry-run', 'Preview without making API call')
|
|
30
|
-
.option('--json', 'Output as JSON');
|
|
31
|
-
|
|
32
|
-
cmd.action(async (options) => {
|
|
33
|
-
const context = configManager.getCurrentContext();
|
|
34
|
-
|
|
35
|
-
let name = options.name as string | undefined;
|
|
36
|
-
let materialNo = (options.no as string | undefined) || (options['no'] as string | undefined);
|
|
37
|
-
let materialClass = options.class as string | undefined;
|
|
38
|
-
const materialType = options.type as string | undefined;
|
|
39
|
-
const materialUomCode = options.unit as string | undefined;
|
|
40
|
-
const dryRun = options.dryRun === true;
|
|
41
|
-
const outputJson = options.json === true;
|
|
42
|
-
|
|
43
|
-
if (!name) {
|
|
44
|
-
if (dryRun) {
|
|
45
|
-
if (outputJson) {
|
|
46
|
-
console.log(JSON.stringify({ success: false, error: { code: 'DRY_RUN_MISSING_ARGS', message: 'Missing required --name in dry-run mode' } }));
|
|
47
|
-
} else {
|
|
48
|
-
console.error(chalk.red('\n✗ --name is required. Cannot preview without material name.\n'));
|
|
49
|
-
}
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
const { inputName } = await inquirer.prompt([
|
|
53
|
-
{
|
|
54
|
-
type: 'input',
|
|
55
|
-
name: 'inputName',
|
|
56
|
-
message: 'Enter material name:',
|
|
57
|
-
validate: (input: string) => input.trim().length > 0 || 'Material name is required',
|
|
58
|
-
},
|
|
59
|
-
]);
|
|
60
|
-
name = inputName;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!materialClass) {
|
|
64
|
-
if (dryRun) {
|
|
65
|
-
if (outputJson) {
|
|
66
|
-
console.log(JSON.stringify({ success: false, error: { code: 'DRY_RUN_MISSING_ARGS', message: 'Missing required --class in dry-run mode' } }));
|
|
67
|
-
} else {
|
|
68
|
-
console.error(chalk.red('\n✗ --class is required. Cannot preview without material class.\n'));
|
|
69
|
-
}
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
const { inputClass } = await inquirer.prompt([
|
|
73
|
-
{
|
|
74
|
-
type: 'input',
|
|
75
|
-
name: 'inputClass',
|
|
76
|
-
message: 'Enter material class:',
|
|
77
|
-
validate: (input: string) => input.trim().length > 0 || 'Material class is required',
|
|
78
|
-
},
|
|
79
|
-
]);
|
|
80
|
-
materialClass = inputClass;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!materialNo) {
|
|
84
|
-
if (dryRun) {
|
|
85
|
-
if (outputJson) {
|
|
86
|
-
console.log(JSON.stringify({ success: false, error: { code: 'DRY_RUN_MISSING_ARGS', message: 'Missing required --no in dry-run mode' } }));
|
|
87
|
-
} else {
|
|
88
|
-
console.error(chalk.red('\n✗ --no is required. Cannot preview without material number.\n'));
|
|
89
|
-
}
|
|
90
|
-
process.exit(1);
|
|
91
|
-
}
|
|
92
|
-
const { inputNo } = await inquirer.prompt([
|
|
93
|
-
{
|
|
94
|
-
type: 'input',
|
|
95
|
-
name: 'inputNo',
|
|
96
|
-
message: 'Enter material number:',
|
|
97
|
-
validate: (input: string) => input.trim().length > 0 || 'Material number is required',
|
|
98
|
-
},
|
|
99
|
-
]);
|
|
100
|
-
materialNo = inputNo;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const dictResponse = await apiClient.getDictItems(context.environment, context.tenant, 'MATERIAL_CLASS');
|
|
104
|
-
if (dictResponse.success && dictResponse.data) {
|
|
105
|
-
const matchedItem = dictResponse.data.find(item => item.dictName === materialClass);
|
|
106
|
-
if (matchedItem) {
|
|
107
|
-
materialClass = matchedItem.dictCode;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const codeResponse = await apiClient.getCodeByType(context.environment, context.tenant, 'TenantMaterialCode');
|
|
112
|
-
if (!codeResponse.success || !codeResponse.data) {
|
|
113
|
-
const errMsg = codeResponse.error?.message || 'Failed to generate material code';
|
|
114
|
-
if (outputJson) {
|
|
115
|
-
console.log(JSON.stringify({ success: false, error: { code: 'CODE_GENERATION_ERROR', message: errMsg } }));
|
|
116
|
-
} else {
|
|
117
|
-
console.error(chalk.red(`\n✗ Failed to generate material code: ${errMsg}\n`));
|
|
118
|
-
}
|
|
119
|
-
process.exit(1);
|
|
120
|
-
}
|
|
121
|
-
const materialCode = codeResponse.data;
|
|
122
|
-
|
|
123
|
-
const data: MaterialRequest = {
|
|
124
|
-
materialName: name!,
|
|
125
|
-
materialNo: materialNo!,
|
|
126
|
-
materialCode: materialCode,
|
|
127
|
-
materialClass: materialClass!,
|
|
128
|
-
materialType: materialType,
|
|
129
|
-
materialUomCode: materialUomCode,
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
if (dryRun) {
|
|
133
|
-
if (outputJson) {
|
|
134
|
-
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
135
|
-
} else {
|
|
136
|
-
console.log(chalk.bold('\n🔍 Dry-Run Mode: No changes will be made\n'));
|
|
137
|
-
console.log(' Material to be created:');
|
|
138
|
-
console.log(formatTable(data));
|
|
139
|
-
console.log();
|
|
140
|
-
}
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!outputJson) {
|
|
145
|
-
console.log(chalk.bold('\n📝 Creating Material\n'));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const response = await apiClient.createMaterial(context.environment, context.tenant, data);
|
|
149
|
-
|
|
150
|
-
if (!response.success) {
|
|
151
|
-
const errorMsg = response.error?.message || 'Failed to create material';
|
|
152
|
-
const errorCode = response.error?.code || 'CREATE_MATERIAL_ERROR';
|
|
153
|
-
if (outputJson) {
|
|
154
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
155
|
-
} else {
|
|
156
|
-
console.error(chalk.red(`\n✗ Failed to create material: ${errorMsg}`));
|
|
157
|
-
if (response.error?.code) {
|
|
158
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
159
|
-
}
|
|
160
|
-
console.error();
|
|
161
|
-
}
|
|
162
|
-
process.exit(1);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (response.success) {
|
|
166
|
-
const material = response.data as {
|
|
167
|
-
materialId?: number;
|
|
168
|
-
materialNo?: string;
|
|
169
|
-
materialCode?: string;
|
|
170
|
-
materialName?: string;
|
|
171
|
-
materialClass?: string;
|
|
172
|
-
materialType?: string;
|
|
173
|
-
materialUomCode?: string;
|
|
174
|
-
statusFlag?: number;
|
|
175
|
-
createTime?: string;
|
|
176
|
-
} | undefined;
|
|
177
|
-
|
|
178
|
-
if (outputJson) {
|
|
179
|
-
console.log(JSON.stringify({ success: true, data: material }));
|
|
180
|
-
} else {
|
|
181
|
-
console.log(chalk.green('✓ Material created successfully\n'));
|
|
182
|
-
if (material?.materialId) console.log(` ${chalk.gray('Material ID:')} ${chalk.green(String(material.materialId))}`);
|
|
183
|
-
if (material?.materialNo) console.log(` ${chalk.gray('No:')} ${material.materialNo}`);
|
|
184
|
-
if (material?.materialName) console.log(` ${chalk.gray('Name:')} ${material.materialName}`);
|
|
185
|
-
if (material?.materialCode) console.log(` ${chalk.gray('Code:')} ${material.materialCode}`);
|
|
186
|
-
if (material?.materialClass) console.log(` ${chalk.gray('Class:')} ${material.materialClass}`);
|
|
187
|
-
if (material?.materialType) console.log(` ${chalk.gray('Type:')} ${material.materialType}`);
|
|
188
|
-
if (material?.materialUomCode) console.log(` ${chalk.gray('Unit:')} ${material.materialUomCode}`);
|
|
189
|
-
if (material?.statusFlag !== undefined) {
|
|
190
|
-
const statusText = material.statusFlag === 1 ? 'Enabled' : 'Disabled';
|
|
191
|
-
console.log(` ${chalk.gray('Status:')} ${chalk.green(statusText)}`);
|
|
192
|
-
}
|
|
193
|
-
console.log();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
return cmd;
|
|
199
|
-
}
|
|
@@ -1,105 +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 { Material } from '../../../types/material.js';
|
|
7
|
-
|
|
8
|
-
export function createMaterialDeleteCommand(): Command {
|
|
9
|
-
const deleteCommand = new Command('delete');
|
|
10
|
-
deleteCommand
|
|
11
|
-
.description('Delete a material')
|
|
12
|
-
.argument('<materialId>', 'Material ID')
|
|
13
|
-
.option('--force', 'Skip confirmation and delete directly')
|
|
14
|
-
.option('--json', 'Output as JSON')
|
|
15
|
-
.action(async (materialId: string, options: Record<string, unknown>) => {
|
|
16
|
-
const context = configManager.getCurrentContext();
|
|
17
|
-
const environment = context.environment as Environment;
|
|
18
|
-
const tenant = context.tenant;
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
(options as any).json = process.argv.includes('--json');
|
|
22
|
-
const jsonOutput = options.json === true;
|
|
23
|
-
|
|
24
|
-
if (!jsonOutput) {
|
|
25
|
-
console.log(chalk.bold(`\n🗑️ Delete Material (${environment})\n`));
|
|
26
|
-
console.log(chalk.gray(` Material ID: ${materialId}`));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let material: Material | undefined;
|
|
30
|
-
try {
|
|
31
|
-
const materialResponse = await apiClient.getMaterial(environment, tenant, materialId);
|
|
32
|
-
if (!materialResponse.success || !materialResponse.data || !('materialId' in materialResponse.data)) {
|
|
33
|
-
const errMsg = `Material not found: ${materialId}`;
|
|
34
|
-
if (jsonOutput) {
|
|
35
|
-
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
36
|
-
} else {
|
|
37
|
-
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
38
|
-
}
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
material = materialResponse.data as Material;
|
|
42
|
-
} catch (error) {
|
|
43
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
44
|
-
if (jsonOutput) {
|
|
45
|
-
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch material: ${errMsg}` } }));
|
|
46
|
-
} else {
|
|
47
|
-
console.error(chalk.red(`\n✗ Failed to fetch material: ${errMsg}\n`));
|
|
48
|
-
}
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!jsonOutput) {
|
|
53
|
-
console.log(chalk.gray(` Name: ${material.materialName}`));
|
|
54
|
-
console.log(chalk.gray(` Code: ${material.materialCode}`));
|
|
55
|
-
if (material.materialClass) {
|
|
56
|
-
console.log(chalk.gray(` Class: ${material.materialClass}`));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!options.force) {
|
|
61
|
-
if (jsonOutput) {
|
|
62
|
-
console.log(JSON.stringify({ success: true, dryRun: true, material }));
|
|
63
|
-
} else {
|
|
64
|
-
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual deletion will be made\n'));
|
|
65
|
-
console.log(chalk.yellow(' To delete, add: --force\n'));
|
|
66
|
-
}
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const response = await apiClient.deleteMaterial(environment, tenant, materialId);
|
|
72
|
-
|
|
73
|
-
if (response.success) {
|
|
74
|
-
if (jsonOutput) {
|
|
75
|
-
console.log(JSON.stringify({ success: true, materialId, name: material.materialName }));
|
|
76
|
-
} else {
|
|
77
|
-
console.log(chalk.green(`\n✓ Material "${material.materialName}" (ID: ${materialId}) deleted\n`));
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
const errorMsg = response.error?.message || 'Unknown error';
|
|
81
|
-
const errorCode = response.error?.code || 'DELETE_ERROR';
|
|
82
|
-
if (jsonOutput) {
|
|
83
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
84
|
-
} else {
|
|
85
|
-
console.error(chalk.red(`\n✗ Failed to delete material: ${errorMsg}`));
|
|
86
|
-
if (response.error?.code) {
|
|
87
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
88
|
-
}
|
|
89
|
-
console.error();
|
|
90
|
-
}
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
} catch (error) {
|
|
94
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
95
|
-
if (jsonOutput) {
|
|
96
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
97
|
-
} else {
|
|
98
|
-
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
99
|
-
}
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
return deleteCommand;
|
|
105
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
-
import { Environment } from '../../../types/index.js';
|
|
7
|
-
import { Material } from '../../../types/material.js';
|
|
8
|
-
|
|
9
|
-
export function createMaterialDisableCommand(): Command {
|
|
10
|
-
const disableCommand = new Command('disable');
|
|
11
|
-
disableCommand
|
|
12
|
-
.description('Disable (deactivate) a material')
|
|
13
|
-
.argument('<materialId>', 'Material ID')
|
|
14
|
-
.option('--force', 'Skip confirmation prompt')
|
|
15
|
-
.option('--dry-run', 'Preview the operation without executing')
|
|
16
|
-
.option('--json', 'Output as JSON')
|
|
17
|
-
.action(async (materialId: string, options: Record<string, unknown>) => {
|
|
18
|
-
const context = configManager.getCurrentContext();
|
|
19
|
-
const environment = context.environment as Environment;
|
|
20
|
-
const tenant = context.tenant;
|
|
21
|
-
const force = options.force === true;
|
|
22
|
-
const dryRun = options.dryRun === true;
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
(options as any).json = process.argv.includes('--json');
|
|
26
|
-
const jsonOutput = options.json === true;
|
|
27
|
-
|
|
28
|
-
if (!materialId || materialId.trim() === '') {
|
|
29
|
-
const errMsg = 'Invalid material ID';
|
|
30
|
-
if (jsonOutput) {
|
|
31
|
-
console.log(JSON.stringify({ success: false, error: { code: 'INVALID_ID', message: errMsg } }));
|
|
32
|
-
} else {
|
|
33
|
-
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
34
|
-
}
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!jsonOutput) {
|
|
39
|
-
console.log(chalk.bold(`\n⬇ Disable Material (${environment})\n`));
|
|
40
|
-
console.log(chalk.gray(` Material ID: ${materialId}`));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (dryRun) {
|
|
44
|
-
if (jsonOutput) {
|
|
45
|
-
console.log(JSON.stringify({ success: true, dryRun: true, message: 'No actual API call will be made' }));
|
|
46
|
-
} else {
|
|
47
|
-
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual API call will be made\n'));
|
|
48
|
-
console.log(chalk.gray(' This operation will disable the material.'));
|
|
49
|
-
console.log();
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let material: Material | undefined;
|
|
55
|
-
try {
|
|
56
|
-
const materialResponse = await apiClient.getMaterial(environment, tenant, materialId);
|
|
57
|
-
if (!materialResponse.success || !materialResponse.data || !('materialId' in materialResponse.data)) {
|
|
58
|
-
const errMsg = `Material not found: ${materialId}`;
|
|
59
|
-
if (jsonOutput) {
|
|
60
|
-
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
61
|
-
} else {
|
|
62
|
-
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
63
|
-
}
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
material = materialResponse.data as Material;
|
|
67
|
-
} catch (error) {
|
|
68
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
69
|
-
const jsonErr = { success: false, error: { code: 'FETCH_ERROR', message: 'Failed to fetch material: ' + errMsg } };
|
|
70
|
-
if (jsonOutput) {
|
|
71
|
-
console.log(JSON.stringify(jsonErr));
|
|
72
|
-
} else {
|
|
73
|
-
console.error(chalk.red(`\n✗ Failed to fetch material: ${errMsg}\n`));
|
|
74
|
-
}
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (material.statusFlag === 2) {
|
|
79
|
-
const errMsg = `Material "${material.materialName}" is already disabled`;
|
|
80
|
-
if (jsonOutput) {
|
|
81
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ALREADY_DISABLED', message: errMsg } }));
|
|
82
|
-
} else {
|
|
83
|
-
console.error(chalk.yellow(`\n⚠ ${errMsg}\n`));
|
|
84
|
-
}
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (!force) {
|
|
89
|
-
if (!jsonOutput) {
|
|
90
|
-
console.log(chalk.gray(` Name: ${material.materialName}`));
|
|
91
|
-
console.log(chalk.gray(` Code: ${material.materialCode}`));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const { confirm } = await inquirer.prompt([
|
|
95
|
-
{
|
|
96
|
-
type: 'confirm',
|
|
97
|
-
name: 'confirm',
|
|
98
|
-
message: `Disable material "${material.materialName}"?`,
|
|
99
|
-
default: false,
|
|
100
|
-
},
|
|
101
|
-
]);
|
|
102
|
-
|
|
103
|
-
if (!confirm) {
|
|
104
|
-
if (jsonOutput) {
|
|
105
|
-
console.log(JSON.stringify({ success: false, error: { code: 'CANCELLED', message: 'Operation cancelled' } }));
|
|
106
|
-
} else {
|
|
107
|
-
console.log(chalk.gray('\n Operation cancelled.\n'));
|
|
108
|
-
}
|
|
109
|
-
process.exit(0);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
const response = await apiClient.disableMaterial(environment, tenant, materialId);
|
|
115
|
-
|
|
116
|
-
if (response.success) {
|
|
117
|
-
if (jsonOutput) {
|
|
118
|
-
console.log(JSON.stringify({ success: true, materialId, name: material?.materialName }));
|
|
119
|
-
} else {
|
|
120
|
-
console.log(chalk.green(`\n✓ Material ${material?.materialName || materialId} disabled\n`));
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
const errorMsg = response.error?.message || 'Unknown error';
|
|
124
|
-
const errorCode = response.error?.code || 'DISABLE_ERROR';
|
|
125
|
-
if (jsonOutput) {
|
|
126
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
127
|
-
} else {
|
|
128
|
-
console.error(chalk.red(`\n✗ Failed to disable material: ${errorMsg}`));
|
|
129
|
-
if (response.error?.code) {
|
|
130
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
131
|
-
}
|
|
132
|
-
console.error();
|
|
133
|
-
}
|
|
134
|
-
process.exit(1);
|
|
135
|
-
}
|
|
136
|
-
} catch (error) {
|
|
137
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
138
|
-
if (jsonOutput) {
|
|
139
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
140
|
-
} else {
|
|
141
|
-
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
142
|
-
}
|
|
143
|
-
process.exit(1);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
return disableCommand;
|
|
148
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
|
-
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
-
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
-
import { Environment } from '../../../types/index.js';
|
|
7
|
-
import { Material } from '../../../types/material.js';
|
|
8
|
-
|
|
9
|
-
export function createMaterialEnableCommand(): Command {
|
|
10
|
-
const enableCommand = new Command('enable');
|
|
11
|
-
enableCommand
|
|
12
|
-
.description('Enable (activate) a material')
|
|
13
|
-
.argument('<materialId>', 'Material ID')
|
|
14
|
-
.option('--json', 'Output as JSON')
|
|
15
|
-
.action(async (materialId: string, options: Record<string, unknown>) => {
|
|
16
|
-
const context = configManager.getCurrentContext();
|
|
17
|
-
const environment = context.environment as Environment;
|
|
18
|
-
const tenant = context.tenant;
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
(options as any).json = process.argv.includes('--json');
|
|
22
|
-
const jsonOutput = options.json === true;
|
|
23
|
-
|
|
24
|
-
if (!materialId || materialId.trim() === '') {
|
|
25
|
-
const errMsg = 'Invalid material ID';
|
|
26
|
-
if (jsonOutput) {
|
|
27
|
-
console.log(JSON.stringify({ success: false, error: { code: 'INVALID_ID', message: errMsg } }));
|
|
28
|
-
} else {
|
|
29
|
-
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
30
|
-
}
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!jsonOutput) {
|
|
35
|
-
console.log(chalk.bold(`\n✓ Enable Material (${environment})\n`));
|
|
36
|
-
console.log(chalk.gray(` Material ID: ${materialId}`));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Get material details for confirmation
|
|
40
|
-
let material: Material | undefined;
|
|
41
|
-
try {
|
|
42
|
-
const materialResponse = await apiClient.getMaterial(environment, tenant, materialId);
|
|
43
|
-
if (!materialResponse.success || !materialResponse.data || !('materialId' in materialResponse.data)) {
|
|
44
|
-
const errMsg = `Material not found: ${materialId}`;
|
|
45
|
-
if (jsonOutput) {
|
|
46
|
-
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
47
|
-
} else {
|
|
48
|
-
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
49
|
-
}
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
material = materialResponse.data as Material;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
55
|
-
if (jsonOutput) {
|
|
56
|
-
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch material: ${errMsg}` } }));
|
|
57
|
-
} else {
|
|
58
|
-
console.error(chalk.red(`\n✗ Failed to fetch material: ${errMsg}\n`));
|
|
59
|
-
}
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Check if already enabled
|
|
64
|
-
if (material.statusFlag === 1) {
|
|
65
|
-
const errMsg = `Material "${material.materialName}" is already enabled`;
|
|
66
|
-
if (jsonOutput) {
|
|
67
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ALREADY_ENABLED', message: errMsg } }));
|
|
68
|
-
} else {
|
|
69
|
-
console.error(chalk.yellow(`\n⚠ ${errMsg}\n`));
|
|
70
|
-
}
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!jsonOutput) {
|
|
75
|
-
console.log(chalk.gray(` Name: ${material.materialName}`));
|
|
76
|
-
console.log(chalk.gray(` Code: ${material.materialCode}`));
|
|
77
|
-
|
|
78
|
-
const { confirm } = await inquirer.prompt([
|
|
79
|
-
{
|
|
80
|
-
type: 'confirm',
|
|
81
|
-
name: 'confirm',
|
|
82
|
-
message: `Enable material "${material.materialName}"?`,
|
|
83
|
-
default: false,
|
|
84
|
-
},
|
|
85
|
-
]);
|
|
86
|
-
|
|
87
|
-
if (!confirm) {
|
|
88
|
-
console.log(chalk.gray('\n Operation cancelled.\n'));
|
|
89
|
-
process.exit(0);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Execute enable
|
|
94
|
-
try {
|
|
95
|
-
const response = await apiClient.enableMaterial(environment, tenant, materialId);
|
|
96
|
-
|
|
97
|
-
if (response.success) {
|
|
98
|
-
if (jsonOutput) {
|
|
99
|
-
console.log(JSON.stringify({ success: true, materialId, name: material?.materialName }));
|
|
100
|
-
} else {
|
|
101
|
-
console.log(chalk.green(`\n✓ Material ${material?.materialName || materialId} enabled\n`));
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
const errorMsg = response.error?.message || 'Unknown error';
|
|
105
|
-
const errorCode = response.error?.code || 'ENABLE_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 enable material: ${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
|
-
} catch (error) {
|
|
118
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
119
|
-
if (jsonOutput) {
|
|
120
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
121
|
-
} else {
|
|
122
|
-
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
123
|
-
}
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
return enableCommand;
|
|
129
|
-
}
|