@newpeak/barista-cli 0.1.11 ā 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/liberica/dict-types/get.d.ts.map +1 -1
- package/dist/commands/liberica/dict-types/get.js +9 -1
- package/dist/commands/liberica/dict-types/get.js.map +1 -1
- package/dist/commands/liberica/dict-types/index.d.ts.map +1 -1
- package/dist/commands/liberica/dict-types/index.js +2 -0
- package/dist/commands/liberica/dict-types/index.js.map +1 -1
- package/dist/commands/liberica/dict-types/list.d.ts.map +1 -1
- package/dist/commands/liberica/dict-types/list.js +19 -1
- package/dist/commands/liberica/dict-types/list.js.map +1 -1
- package/dist/commands/liberica/dict-types/tenant-items.d.ts +3 -0
- package/dist/commands/liberica/dict-types/tenant-items.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/tenant-items.js +275 -0
- package/dist/commands/liberica/dict-types/tenant-items.js.map +1 -0
- package/dist/commands/liberica/dicts/get.d.ts.map +1 -1
- package/dist/commands/liberica/dicts/get.js +9 -1
- package/dist/commands/liberica/dicts/get.js.map +1 -1
- package/dist/commands/liberica/dicts/list.d.ts.map +1 -1
- package/dist/commands/liberica/dicts/list.js +9 -1
- package/dist/commands/liberica/dicts/list.js.map +1 -1
- package/dist/core/api/client.d.ts +7 -7
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +15 -12
- package/dist/core/api/client.js.map +1 -1
- package/dist/core/config/manager.d.ts.map +1 -1
- package/dist/core/config/manager.js +1 -0
- package/dist/core/config/manager.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/dict.d.ts +2 -0
- package/dist/types/dict.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +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,41 +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
|
-
|
|
8
|
-
export function createUserDisableCommand(): Command {
|
|
9
|
-
const disableCommand = new Command('disable');
|
|
10
|
-
disableCommand.description('Disable a user');
|
|
11
|
-
|
|
12
|
-
disableCommand
|
|
13
|
-
.argument('<userId>', 'User ID')
|
|
14
|
-
.option('--force', 'Skip confirmation')
|
|
15
|
-
.action(async (userId, options) => {
|
|
16
|
-
const context = configManager.getCurrentContext();
|
|
17
|
-
const environment = (options.env as Environment) || context.environment;
|
|
18
|
-
const tenant = options.tenant || context.tenant;
|
|
19
|
-
|
|
20
|
-
if (!options.force) {
|
|
21
|
-
const { confirm } = await inquirer.prompt([
|
|
22
|
-
{ type: 'confirm', name: 'confirm', message: `Disable user ${userId}?`, default: false },
|
|
23
|
-
]);
|
|
24
|
-
if (!confirm) {
|
|
25
|
-
console.log(chalk.yellow('\nā© Cancelled\n'));
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const response = await apiClient.disableUser(environment, tenant, userId);
|
|
31
|
-
|
|
32
|
-
if (!response.success) {
|
|
33
|
-
console.error(chalk.red(`\nā Failed: ${response.error?.message}\n`));
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log(chalk.green('\nā User disabled successfully\n'));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return disableCommand;
|
|
41
|
-
}
|
|
@@ -1,30 +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
|
-
|
|
7
|
-
export function createUserEnableCommand(): Command {
|
|
8
|
-
const enableCommand = new Command('enable');
|
|
9
|
-
enableCommand.description('Enable a user');
|
|
10
|
-
|
|
11
|
-
enableCommand
|
|
12
|
-
.argument('<userId>', 'User ID')
|
|
13
|
-
.option('--force', 'Skip confirmation')
|
|
14
|
-
.action(async (userId, options) => {
|
|
15
|
-
const context = configManager.getCurrentContext();
|
|
16
|
-
const environment = (options.env as Environment) || context.environment;
|
|
17
|
-
const tenant = options.tenant || context.tenant;
|
|
18
|
-
|
|
19
|
-
const response = await apiClient.enableUser(environment, tenant, userId);
|
|
20
|
-
|
|
21
|
-
if (!response.success) {
|
|
22
|
-
console.error(chalk.red(`\nā Failed: ${response.error?.message}\n`));
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
console.log(chalk.green('\nā User enabled successfully\n'));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return enableCommand;
|
|
30
|
-
}
|
|
@@ -1,46 +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
|
-
|
|
7
|
-
export function createUserGetCommand(): Command {
|
|
8
|
-
const getCommand = new Command('get');
|
|
9
|
-
getCommand.description('Get user details');
|
|
10
|
-
|
|
11
|
-
getCommand
|
|
12
|
-
.argument('<userId>', 'User ID')
|
|
13
|
-
.option('--json', 'Output as JSON')
|
|
14
|
-
.action(async (userId, options) => {
|
|
15
|
-
const context = configManager.getCurrentContext();
|
|
16
|
-
const environment = (options.env as Environment) || context.environment;
|
|
17
|
-
const tenant = options.tenant || context.tenant;
|
|
18
|
-
|
|
19
|
-
const response = await apiClient.getUser(environment, tenant, userId);
|
|
20
|
-
|
|
21
|
-
if (!response.success) {
|
|
22
|
-
console.error(chalk.red(`\nā Failed: ${response.error?.message}\n`));
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const user = response.data as any;
|
|
27
|
-
|
|
28
|
-
if (options.json) {
|
|
29
|
-
console.log(JSON.stringify({ success: true, data: user }, null, 2));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
console.log(chalk.bold('\nš¤ User Details\n'));
|
|
34
|
-
console.log(chalk.gray('ID: ') + user.userId);
|
|
35
|
-
console.log(chalk.gray('Name: ') + user.realName);
|
|
36
|
-
console.log(chalk.gray('Account: ') + user.account);
|
|
37
|
-
console.log(chalk.gray('Email: ') + (user.email || '-'));
|
|
38
|
-
console.log(chalk.gray('Status: ') + (user.statusFlag === 1 ? chalk.green('Enabled') : chalk.red('Disabled')));
|
|
39
|
-
console.log(chalk.gray('Employee: ') + (user.employeeName || '-'));
|
|
40
|
-
console.log(chalk.gray('Roles: ') + (user.roleNameList?.join(', ') || '-'));
|
|
41
|
-
console.log(chalk.gray('Created: ') + user.createTime);
|
|
42
|
-
console.log();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return getCommand;
|
|
46
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { createUserCreateCommand } from './create.js';
|
|
3
|
-
import { createUserListCommand } from './list.js';
|
|
4
|
-
import { createUserGetCommand } from './get.js';
|
|
5
|
-
import { createUserUpdateCommand } from './update.js';
|
|
6
|
-
import { createUserDeleteCommand } from './delete.js';
|
|
7
|
-
import { createUserEnableCommand } from './enable.js';
|
|
8
|
-
import { createUserDisableCommand } from './disable.js';
|
|
9
|
-
import { createUserMeCommand } from './me.js';
|
|
10
|
-
import { createUserResetPasswordCommand } from './reset-password.js';
|
|
11
|
-
|
|
12
|
-
export function createUsersCommand(): Command {
|
|
13
|
-
const usersCommand = new Command('users');
|
|
14
|
-
usersCommand.description('Manage users');
|
|
15
|
-
|
|
16
|
-
usersCommand.addCommand(createUserCreateCommand());
|
|
17
|
-
usersCommand.addCommand(createUserListCommand());
|
|
18
|
-
usersCommand.addCommand(createUserGetCommand());
|
|
19
|
-
usersCommand.addCommand(createUserUpdateCommand());
|
|
20
|
-
usersCommand.addCommand(createUserDeleteCommand());
|
|
21
|
-
usersCommand.addCommand(createUserEnableCommand());
|
|
22
|
-
usersCommand.addCommand(createUserDisableCommand());
|
|
23
|
-
usersCommand.addCommand(createUserMeCommand());
|
|
24
|
-
usersCommand.addCommand(createUserResetPasswordCommand());
|
|
25
|
-
|
|
26
|
-
return usersCommand;
|
|
27
|
-
}
|
|
@@ -1,68 +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 { Environment } from '../../../types/index.js';
|
|
7
|
-
|
|
8
|
-
export function createUserListCommand(): Command {
|
|
9
|
-
const listCommand = new Command('list');
|
|
10
|
-
listCommand.description('List users with pagination');
|
|
11
|
-
|
|
12
|
-
listCommand
|
|
13
|
-
.option('-p, --page <number>', 'Page number', '1')
|
|
14
|
-
.option('-s, --size <number>', 'Page size', '20')
|
|
15
|
-
.option('--status <status>', 'Status (1=enabled, 2=disabled)')
|
|
16
|
-
.option('--account <account>', 'Filter by account')
|
|
17
|
-
.option('--real-name <realName>', 'Filter by name')
|
|
18
|
-
.option('--json', 'Output as JSON')
|
|
19
|
-
.action(async (options) => {
|
|
20
|
-
const context = configManager.getCurrentContext();
|
|
21
|
-
const environment = (options.env as Environment) || context.environment;
|
|
22
|
-
const tenant = options.tenant || context.tenant;
|
|
23
|
-
|
|
24
|
-
const params: any = {
|
|
25
|
-
pageNo: parseInt(options.page) - 1,
|
|
26
|
-
pageSize: parseInt(options.size),
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
if (options.status) params.status = parseInt(options.status);
|
|
30
|
-
if (options.account) params.account = options.account;
|
|
31
|
-
if (options.realName) params.realName = options.realName;
|
|
32
|
-
|
|
33
|
-
const response = await apiClient.listUsers(environment, tenant, params);
|
|
34
|
-
|
|
35
|
-
if (!response.success) {
|
|
36
|
-
console.error(chalk.red(`\nā Failed: ${response.error?.message}\n`));
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const data = response.data as any;
|
|
41
|
-
const items = data?.rows || [];
|
|
42
|
-
|
|
43
|
-
if (options.json) {
|
|
44
|
-
console.log(JSON.stringify({ success: true, data: { items, pagination: data } }, null, 2));
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const table = new Table({
|
|
49
|
-
head: [chalk.bold('ID'), chalk.bold('Name'), chalk.bold('Account'), chalk.bold('Email'), chalk.bold('Status')],
|
|
50
|
-
colWidths: [10, 18, 18, 25, 10],
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
for (const user of items) {
|
|
54
|
-
table.push([
|
|
55
|
-
user.userId,
|
|
56
|
-
user.realName,
|
|
57
|
-
user.account,
|
|
58
|
-
user.email || '-',
|
|
59
|
-
user.statusFlag === 1 ? chalk.green('Enabled') : chalk.red('Disabled'),
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
console.log(table.toString());
|
|
64
|
-
console.log(chalk.gray(`\nTotal: ${data?.totalRows || 0} users`));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return listCommand;
|
|
68
|
-
}
|
|
@@ -1,42 +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
|
-
|
|
7
|
-
export function createUserMeCommand(): Command {
|
|
8
|
-
const meCommand = new Command('me');
|
|
9
|
-
meCommand.description('Get current user info');
|
|
10
|
-
|
|
11
|
-
meCommand
|
|
12
|
-
.option('--json', 'Output as JSON')
|
|
13
|
-
.action(async (options) => {
|
|
14
|
-
const context = configManager.getCurrentContext();
|
|
15
|
-
const environment = (options.env as Environment) || context.environment;
|
|
16
|
-
const tenant = options.tenant || context.tenant;
|
|
17
|
-
|
|
18
|
-
const response = await apiClient.getCurrentUser(environment, tenant);
|
|
19
|
-
|
|
20
|
-
if (!response.success) {
|
|
21
|
-
console.error(chalk.red(`\nā Failed: ${response.error?.message}\n`));
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const user = response.data as any;
|
|
26
|
-
|
|
27
|
-
if (options.json) {
|
|
28
|
-
console.log(JSON.stringify({ success: true, data: user }, null, 2));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
console.log(chalk.bold('\nš¤ Current User\n'));
|
|
33
|
-
console.log(chalk.gray('ID: ') + user.userId);
|
|
34
|
-
console.log(chalk.gray('Name: ') + user.realName);
|
|
35
|
-
console.log(chalk.gray('Account: ') + user.account);
|
|
36
|
-
console.log(chalk.gray('Email: ') + (user.email || '-'));
|
|
37
|
-
console.log(chalk.gray('Roles: ') + (user.roleNameList?.join(', ') || '-'));
|
|
38
|
-
console.log();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return meCommand;
|
|
42
|
-
}
|
|
@@ -1,42 +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
|
-
|
|
8
|
-
export function createUserResetPasswordCommand(): Command {
|
|
9
|
-
const resetCommand = new Command('reset-password');
|
|
10
|
-
resetCommand.description('Reset user password');
|
|
11
|
-
|
|
12
|
-
resetCommand
|
|
13
|
-
.argument('<userId>', 'User ID')
|
|
14
|
-
.option('--force', 'Skip confirmation')
|
|
15
|
-
.action(async (userId, options) => {
|
|
16
|
-
const context = configManager.getCurrentContext();
|
|
17
|
-
const environment = (options.env as Environment) || context.environment;
|
|
18
|
-
const tenant = options.tenant || context.tenant;
|
|
19
|
-
|
|
20
|
-
if (!options.force) {
|
|
21
|
-
const { confirm } = await inquirer.prompt([
|
|
22
|
-
{ type: 'confirm', name: 'confirm', message: `Reset password for user ${userId}?`, default: false },
|
|
23
|
-
]);
|
|
24
|
-
if (!confirm) {
|
|
25
|
-
console.log(chalk.yellow('\nā© Cancelled\n'));
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const response = await apiClient.resetPassword(environment, tenant, userId);
|
|
31
|
-
|
|
32
|
-
if (!response.success) {
|
|
33
|
-
console.error(chalk.red(`\nā Failed: ${response.error?.message}\n`));
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log(chalk.green('\nā Password reset successfully\n'));
|
|
38
|
-
console.log(chalk.yellow('Note: New password will be sent to user email\n'));
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return resetCommand;
|
|
42
|
-
}
|
|
@@ -1,48 +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
|
-
|
|
7
|
-
export function createUserUpdateCommand(): Command {
|
|
8
|
-
const updateCommand = new Command('update');
|
|
9
|
-
updateCommand.description('Update user information');
|
|
10
|
-
|
|
11
|
-
updateCommand
|
|
12
|
-
.argument('<userId>', 'User ID')
|
|
13
|
-
.option('-n, --name <name>', 'User real name')
|
|
14
|
-
.option('-e, --email <email>', 'User email')
|
|
15
|
-
.option('-r, --role-ids <roleIds>', 'Role IDs (comma-separated)')
|
|
16
|
-
.option('--dry-run', 'Preview without executing')
|
|
17
|
-
.option('--json', 'Output as JSON')
|
|
18
|
-
.action(async (userId, 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 updateData: any = { userId };
|
|
24
|
-
if (options.name) updateData.realName = options.name;
|
|
25
|
-
if (options.email) updateData.email = options.email;
|
|
26
|
-
if (options.roleIds) {
|
|
27
|
-
updateData.roleIdList = options.roleIds.split(',').map((id: string) => id.trim());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (options.dryRun) {
|
|
31
|
-
console.log(chalk.bold('\nš Dry-Run Mode\n'));
|
|
32
|
-
console.log(chalk.gray('Update Data:'));
|
|
33
|
-
console.log(JSON.stringify(updateData, null, 2));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const response = await apiClient.updateUser(environment, tenant, updateData);
|
|
38
|
-
|
|
39
|
-
if (!response.success) {
|
|
40
|
-
console.error(chalk.red(`\nā Failed: ${response.error?.message}\n`));
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
console.log(chalk.green('\nā User updated successfully\n'));
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return updateCommand;
|
|
48
|
-
}
|
|
@@ -1,204 +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 { CreateWarehouseRequest } from '../../../types/warehouse.js';
|
|
7
|
-
|
|
8
|
-
function formatTable(data: CreateWarehouseRequest): string {
|
|
9
|
-
const lines: string[] = [];
|
|
10
|
-
lines.push(` ${chalk.gray('Code:')} ${data.warehouseCode}`);
|
|
11
|
-
lines.push(` ${chalk.gray('Name:')} ${data.warehouseName || '(not set)'}`);
|
|
12
|
-
if (data.warehouseType) lines.push(` ${chalk.gray('Type:')} ${data.warehouseType}`);
|
|
13
|
-
if (data.warehouseClasses) lines.push(` ${chalk.gray('Classes:')} ${data.warehouseClasses}`);
|
|
14
|
-
if (data.address) lines.push(` ${chalk.gray('Address:')} ${data.address}`);
|
|
15
|
-
if (data.contact) lines.push(` ${chalk.gray('Contact:')} ${data.contact}`);
|
|
16
|
-
if (data.phone) lines.push(` ${chalk.gray('Phone:')} ${data.phone}`);
|
|
17
|
-
if (data.manager) lines.push(` ${chalk.gray('Manager:')} ${data.manager}`);
|
|
18
|
-
if (data.enableLocation !== undefined) {
|
|
19
|
-
lines.push(` ${chalk.gray('Enable Location:')} ${data.enableLocation === 'Y' ? 'Yes' : 'No'}`);
|
|
20
|
-
}
|
|
21
|
-
if (data.enableNegativeInventory !== undefined) {
|
|
22
|
-
lines.push(` ${chalk.gray('Enable Negative Inventory:')} ${data.enableNegativeInventory === 'Y' ? 'Yes' : 'No'}`);
|
|
23
|
-
}
|
|
24
|
-
if (data.remark) lines.push(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
25
|
-
return lines.join('\n');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function createWarehouseCreateCommand(): Command {
|
|
29
|
-
const cmd = new Command('create');
|
|
30
|
-
cmd.description('Create a new warehouse (auto-generates code if not provided)');
|
|
31
|
-
|
|
32
|
-
cmd
|
|
33
|
-
.option('-n, --name <name>', 'Warehouse name (required)')
|
|
34
|
-
.option('-c, --code <code>', 'Warehouse code (auto-generated if not provided)')
|
|
35
|
-
.option('-t, --type <type>', 'Warehouse type')
|
|
36
|
-
.option('--classes <classes>', 'Warehouse classes')
|
|
37
|
-
.option('-a, --address <address>', 'Address')
|
|
38
|
-
.option('--contact <contact>', 'Contact person')
|
|
39
|
-
.option('-p, --phone <phone>', 'Contact phone')
|
|
40
|
-
.option('-m, --manager <manager>', 'Warehouse manager')
|
|
41
|
-
.option('--enable-location', 'Enable location management')
|
|
42
|
-
.option('--disable-location', 'Disable location management')
|
|
43
|
-
.option('--enable-negative-inventory', 'Enable negative inventory')
|
|
44
|
-
.option('--disable-negative-inventory', 'Disable negative inventory')
|
|
45
|
-
.option('--remark <remark>', 'Remark')
|
|
46
|
-
.option('--dry-run', 'Preview without making API call')
|
|
47
|
-
.option('--json', 'Output as JSON');
|
|
48
|
-
|
|
49
|
-
cmd.action(async (options) => {
|
|
50
|
-
const context = configManager.getCurrentContext();
|
|
51
|
-
|
|
52
|
-
let name = options.name as string | undefined;
|
|
53
|
-
let code = options.code as string | undefined;
|
|
54
|
-
const type = options.type as string | undefined;
|
|
55
|
-
const classes = options.classes as string | undefined;
|
|
56
|
-
const address = options.address as string | undefined;
|
|
57
|
-
const contact = options.contact as string | undefined;
|
|
58
|
-
const phone = options.phone as string | undefined;
|
|
59
|
-
const manager = options.manager as string | undefined;
|
|
60
|
-
const enableLocationRaw = options.enableLocation as boolean | undefined;
|
|
61
|
-
const disableLocationRaw = options.disableLocation as boolean | undefined;
|
|
62
|
-
const enableNegativeInventoryRaw = options.enableNegativeInventory as boolean | undefined;
|
|
63
|
-
const disableNegativeInventoryRaw = options.disableNegativeInventory as boolean | undefined;
|
|
64
|
-
const remark = options.remark as string | undefined;
|
|
65
|
-
const dryRun = options.dryRun === true;
|
|
66
|
-
const jsonOutput = options.json === true;
|
|
67
|
-
|
|
68
|
-
if (!name) {
|
|
69
|
-
const { inputName } = await inquirer.prompt([
|
|
70
|
-
{
|
|
71
|
-
type: 'input',
|
|
72
|
-
name: 'inputName',
|
|
73
|
-
message: 'Enter warehouse name:',
|
|
74
|
-
validate: (input: string) => input.trim().length > 0 || 'Warehouse name is required',
|
|
75
|
-
},
|
|
76
|
-
]);
|
|
77
|
-
name = inputName;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!code) {
|
|
81
|
-
const codeResponse = await apiClient.getCodeByType(context.environment, context.tenant, 'TenantWarehouseCode');
|
|
82
|
-
if (codeResponse.success && codeResponse.data) {
|
|
83
|
-
code = codeResponse.data;
|
|
84
|
-
} else {
|
|
85
|
-
const errMsg = codeResponse.error?.message || 'Failed to generate warehouse code';
|
|
86
|
-
if (jsonOutput) {
|
|
87
|
-
console.log(JSON.stringify({ success: false, error: { code: 'CODE_GENERATION_ERROR', message: errMsg } }));
|
|
88
|
-
} else {
|
|
89
|
-
console.error(chalk.red(`\nā Failed to generate warehouse code: ${errMsg}\n`));
|
|
90
|
-
}
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
let enableLocation: string | undefined;
|
|
96
|
-
if (enableLocationRaw !== undefined) {
|
|
97
|
-
enableLocation = 'Y';
|
|
98
|
-
} else if (disableLocationRaw !== undefined) {
|
|
99
|
-
enableLocation = 'N';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let enableNegativeInventory: string | undefined;
|
|
103
|
-
if (enableNegativeInventoryRaw !== undefined) {
|
|
104
|
-
enableNegativeInventory = 'Y';
|
|
105
|
-
} else if (disableNegativeInventoryRaw !== undefined) {
|
|
106
|
-
enableNegativeInventory = 'N';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const data: CreateWarehouseRequest = {
|
|
110
|
-
warehouseCode: code!,
|
|
111
|
-
warehouseName: name!,
|
|
112
|
-
warehouseType: type,
|
|
113
|
-
warehouseClasses: classes,
|
|
114
|
-
address: address,
|
|
115
|
-
contact: contact,
|
|
116
|
-
phone: phone,
|
|
117
|
-
manager: manager,
|
|
118
|
-
enableLocation: enableLocation,
|
|
119
|
-
enableNegativeInventory: enableNegativeInventory,
|
|
120
|
-
remark: remark,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
if (dryRun) {
|
|
124
|
-
if (jsonOutput) {
|
|
125
|
-
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
126
|
-
} else {
|
|
127
|
-
console.log(chalk.bold('\nš Dry-Run Mode: No changes will be made\n'));
|
|
128
|
-
console.log(' Warehouse to be created:');
|
|
129
|
-
console.log(formatTable(data));
|
|
130
|
-
console.log();
|
|
131
|
-
}
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (!jsonOutput) {
|
|
136
|
-
console.log(chalk.bold('\nš Creating Warehouse\n'));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const response = await apiClient.createWarehouse(context.environment, context.tenant, data);
|
|
140
|
-
|
|
141
|
-
if (!response.success) {
|
|
142
|
-
const errorMsg = response.error?.message || 'Failed to create warehouse';
|
|
143
|
-
const errorCode = response.error?.code || 'CREATE_WAREHOUSE_ERROR';
|
|
144
|
-
if (jsonOutput) {
|
|
145
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
146
|
-
} else {
|
|
147
|
-
console.error(chalk.red(`\nā Failed to create warehouse: ${errorMsg}`));
|
|
148
|
-
if (response.error?.code) {
|
|
149
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
150
|
-
}
|
|
151
|
-
console.error();
|
|
152
|
-
}
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (response.success) {
|
|
157
|
-
const warehouse = response.data as {
|
|
158
|
-
warehouseId?: string;
|
|
159
|
-
warehouseCode?: string;
|
|
160
|
-
warehouseName?: string;
|
|
161
|
-
warehouseType?: string;
|
|
162
|
-
warehouseClasses?: string;
|
|
163
|
-
address?: string;
|
|
164
|
-
contact?: string;
|
|
165
|
-
phone?: string;
|
|
166
|
-
manager?: string;
|
|
167
|
-
enableLocation?: boolean;
|
|
168
|
-
enableNegativeInventory?: boolean;
|
|
169
|
-
remark?: string;
|
|
170
|
-
status?: number;
|
|
171
|
-
createTime?: string;
|
|
172
|
-
} | undefined;
|
|
173
|
-
|
|
174
|
-
if (jsonOutput) {
|
|
175
|
-
console.log(JSON.stringify({ success: true, data: warehouse }));
|
|
176
|
-
} else {
|
|
177
|
-
console.log(chalk.green('ā Warehouse created successfully\n'));
|
|
178
|
-
if (warehouse?.warehouseId) console.log(` ${chalk.gray('Warehouse ID:')} ${chalk.green(String(warehouse.warehouseId))}`);
|
|
179
|
-
if (warehouse?.warehouseCode) console.log(` ${chalk.gray('Code:')} ${warehouse.warehouseCode}`);
|
|
180
|
-
if (warehouse?.warehouseName) console.log(` ${chalk.gray('Name:')} ${warehouse.warehouseName}`);
|
|
181
|
-
if (warehouse?.warehouseType) console.log(` ${chalk.gray('Type:')} ${warehouse.warehouseType}`);
|
|
182
|
-
if (warehouse?.warehouseClasses) console.log(` ${chalk.gray('Classes:')} ${warehouse.warehouseClasses}`);
|
|
183
|
-
if (warehouse?.address) console.log(` ${chalk.gray('Address:')} ${warehouse.address}`);
|
|
184
|
-
if (warehouse?.contact) console.log(` ${chalk.gray('Contact:')} ${warehouse.contact}`);
|
|
185
|
-
if (warehouse?.phone) console.log(` ${chalk.gray('Phone:')} ${warehouse.phone}`);
|
|
186
|
-
if (warehouse?.manager) console.log(` ${chalk.gray('Manager:')} ${warehouse.manager}`);
|
|
187
|
-
if (warehouse?.enableLocation !== undefined) {
|
|
188
|
-
console.log(` ${chalk.gray('Enable Location:')} ${warehouse.enableLocation ? 'Yes' : 'No'}`);
|
|
189
|
-
}
|
|
190
|
-
if (warehouse?.enableNegativeInventory !== undefined) {
|
|
191
|
-
console.log(` ${chalk.gray('Enable Negative Inventory:')} ${warehouse.enableNegativeInventory ? 'Yes' : 'No'}`);
|
|
192
|
-
}
|
|
193
|
-
if (warehouse?.remark) console.log(` ${chalk.gray('Remark:')} ${warehouse.remark}`);
|
|
194
|
-
if (warehouse?.status !== undefined) {
|
|
195
|
-
const statusText = warehouse.status === 1 ? 'Enabled' : 'Disabled';
|
|
196
|
-
console.log(` ${chalk.gray('Status:')} ${chalk.green(statusText)}`);
|
|
197
|
-
}
|
|
198
|
-
console.log();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
return cmd;
|
|
204
|
-
}
|
|
@@ -1,112 +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 { Warehouse } from '../../../types/warehouse.js';
|
|
7
|
-
|
|
8
|
-
export function createWarehouseDeleteCommand(): Command {
|
|
9
|
-
const deleteCommand = new Command('delete');
|
|
10
|
-
deleteCommand
|
|
11
|
-
.description('Delete a warehouse')
|
|
12
|
-
.argument('<warehouseId>', 'Warehouse ID')
|
|
13
|
-
.option('--force', 'Skip confirmation and delete directly')
|
|
14
|
-
.option('--dry-run', 'Preview without making API call')
|
|
15
|
-
.option('--json', 'Output as JSON')
|
|
16
|
-
.action(async (warehouseId: string, options: Record<string, unknown>) => {
|
|
17
|
-
const context = configManager.getCurrentContext();
|
|
18
|
-
const environment = context.environment as Environment;
|
|
19
|
-
const tenant = context.tenant;
|
|
20
|
-
const dryRun = options.dryRun === true;
|
|
21
|
-
const jsonOutput = options.json === true;
|
|
22
|
-
|
|
23
|
-
if (!jsonOutput) {
|
|
24
|
-
console.log(chalk.bold(`\nšļø Delete Warehouse (${environment})\n`));
|
|
25
|
-
console.log(chalk.gray(` Warehouse ID: ${warehouseId}`));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let warehouse: Warehouse | undefined;
|
|
29
|
-
try {
|
|
30
|
-
const warehouseResponse = await apiClient.getWarehouse(environment, tenant, warehouseId);
|
|
31
|
-
if (!warehouseResponse.success || !warehouseResponse.data || !('warehouseId' in warehouseResponse.data)) {
|
|
32
|
-
const errMsg = `Warehouse not found: ${warehouseId}`;
|
|
33
|
-
if (jsonOutput) {
|
|
34
|
-
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
35
|
-
} else {
|
|
36
|
-
console.error(chalk.red(`\nā ${errMsg}\n`));
|
|
37
|
-
}
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
warehouse = warehouseResponse.data as Warehouse;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
43
|
-
if (jsonOutput) {
|
|
44
|
-
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch warehouse: ${errMsg}` } }));
|
|
45
|
-
} else {
|
|
46
|
-
console.error(chalk.red(`\nā Failed to fetch warehouse: ${errMsg}\n`));
|
|
47
|
-
}
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!jsonOutput) {
|
|
52
|
-
console.log(chalk.gray(` Name: ${warehouse.warehouseName}`));
|
|
53
|
-
console.log(chalk.gray(` Code: ${warehouse.warehouseCode}`));
|
|
54
|
-
if (warehouse.contact) {
|
|
55
|
-
console.log(chalk.gray(` Contact: ${warehouse.contact} (${warehouse.phone || 'N/A'})`));
|
|
56
|
-
}
|
|
57
|
-
if (warehouse.address) {
|
|
58
|
-
console.log(chalk.gray(` Address: ${warehouse.address}`));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (dryRun) {
|
|
63
|
-
if (jsonOutput) {
|
|
64
|
-
console.log(JSON.stringify({ success: true, dryRun: true, warehouse }));
|
|
65
|
-
} else {
|
|
66
|
-
console.log(chalk.cyan('\nš Dry-Run Mode: No actual deletion will be made\n'));
|
|
67
|
-
console.log(chalk.yellow(' To delete, add: --force\n'));
|
|
68
|
-
}
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!options.force) {
|
|
73
|
-
// TODO: add confirmation prompt here
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
const response = await apiClient.deleteWarehouse(environment, tenant, warehouseId);
|
|
79
|
-
|
|
80
|
-
if (response.success) {
|
|
81
|
-
if (jsonOutput) {
|
|
82
|
-
console.log(JSON.stringify({ success: true, warehouseId, name: warehouse.warehouseName }));
|
|
83
|
-
} else {
|
|
84
|
-
console.log(chalk.green(`\nā Warehouse "${warehouse.warehouseName}" (ID: ${warehouseId}) deleted\n`));
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
const errorMsg = response.error?.message || 'Unknown error';
|
|
88
|
-
const errorCode = response.error?.code || 'DELETE_ERROR';
|
|
89
|
-
if (jsonOutput) {
|
|
90
|
-
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
91
|
-
} else {
|
|
92
|
-
console.error(chalk.red(`\nā Failed to delete warehouse: ${errorMsg}`));
|
|
93
|
-
if (response.error?.code) {
|
|
94
|
-
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
95
|
-
}
|
|
96
|
-
console.error();
|
|
97
|
-
}
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
} catch (error) {
|
|
101
|
-
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
102
|
-
if (jsonOutput) {
|
|
103
|
-
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
104
|
-
} else {
|
|
105
|
-
console.error(chalk.red(`\nā Error: ${errMsg}\n`));
|
|
106
|
-
}
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return deleteCommand;
|
|
112
|
-
}
|