@newpeak/barista-cli 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +714 -0
- package/README.ja.md +708 -0
- package/README.md +68 -0
- package/README.vi.md +714 -0
- package/dist/commands/liberica/calendar/index.d.ts +3 -0
- package/dist/commands/liberica/calendar/index.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/index.js +11 -0
- package/dist/commands/liberica/calendar/index.js.map +1 -0
- package/dist/commands/liberica/calendar/list.d.ts +3 -0
- package/dist/commands/liberica/calendar/list.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/list.js +181 -0
- package/dist/commands/liberica/calendar/list.js.map +1 -0
- package/dist/commands/liberica/calendar/set.d.ts +3 -0
- package/dist/commands/liberica/calendar/set.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/set.js +120 -0
- package/dist/commands/liberica/calendar/set.js.map +1 -0
- package/dist/commands/liberica/client-contacts/create.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/create.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/create.js +132 -0
- package/dist/commands/liberica/client-contacts/create.js.map +1 -0
- package/dist/commands/liberica/client-contacts/delete.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/delete.js +139 -0
- package/dist/commands/liberica/client-contacts/delete.js.map +1 -0
- package/dist/commands/liberica/client-contacts/get.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/get.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/get.js +92 -0
- package/dist/commands/liberica/client-contacts/get.js.map +1 -0
- package/dist/commands/liberica/client-contacts/index.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/index.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/index.js +17 -0
- package/dist/commands/liberica/client-contacts/index.js.map +1 -0
- package/dist/commands/liberica/client-contacts/list.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/list.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/list.js +92 -0
- package/dist/commands/liberica/client-contacts/list.js.map +1 -0
- package/dist/commands/liberica/client-contacts/update.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/update.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/update.js +156 -0
- package/dist/commands/liberica/client-contacts/update.js.map +1 -0
- package/dist/commands/liberica/dict-types/get.d.ts +3 -0
- package/dist/commands/liberica/dict-types/get.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/get.js +62 -0
- package/dist/commands/liberica/dict-types/get.js.map +1 -0
- package/dist/commands/liberica/dict-types/index.d.ts +3 -0
- package/dist/commands/liberica/dict-types/index.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/index.js +13 -0
- package/dist/commands/liberica/dict-types/index.js.map +1 -0
- package/dist/commands/liberica/dict-types/list.d.ts +3 -0
- package/dist/commands/liberica/dict-types/list.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/list.js +91 -0
- package/dist/commands/liberica/dict-types/list.js.map +1 -0
- package/dist/commands/liberica/dict-types/update.d.ts +3 -0
- package/dist/commands/liberica/dict-types/update.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/update.js +127 -0
- package/dist/commands/liberica/dict-types/update.js.map +1 -0
- package/dist/commands/liberica/dicts/create.d.ts +3 -0
- package/dist/commands/liberica/dicts/create.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/create.js +157 -0
- package/dist/commands/liberica/dicts/create.js.map +1 -0
- package/dist/commands/liberica/dicts/delete.d.ts +3 -0
- package/dist/commands/liberica/dicts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/delete.js +106 -0
- package/dist/commands/liberica/dicts/delete.js.map +1 -0
- package/dist/commands/liberica/dicts/get.d.ts +3 -0
- package/dist/commands/liberica/dicts/get.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/get.js +69 -0
- package/dist/commands/liberica/dicts/get.js.map +1 -0
- package/dist/commands/liberica/dicts/index.d.ts +3 -0
- package/dist/commands/liberica/dicts/index.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/index.js +17 -0
- package/dist/commands/liberica/dicts/index.js.map +1 -0
- package/dist/commands/liberica/dicts/list.d.ts +3 -0
- package/dist/commands/liberica/dicts/list.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/list.js +88 -0
- package/dist/commands/liberica/dicts/list.js.map +1 -0
- package/dist/commands/liberica/dicts/update.d.ts +3 -0
- package/dist/commands/liberica/dicts/update.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/update.js +112 -0
- package/dist/commands/liberica/dicts/update.js.map +1 -0
- package/dist/commands/liberica/index.d.ts.map +1 -1
- package/dist/commands/liberica/index.js +22 -0
- package/dist/commands/liberica/index.js.map +1 -1
- package/dist/commands/liberica/materials/create.d.ts.map +1 -1
- package/dist/commands/liberica/materials/create.js +35 -9
- package/dist/commands/liberica/materials/create.js.map +1 -1
- package/dist/commands/liberica/operations/active.d.ts +3 -0
- package/dist/commands/liberica/operations/active.d.ts.map +1 -0
- package/dist/commands/liberica/operations/active.js +152 -0
- package/dist/commands/liberica/operations/active.js.map +1 -0
- package/dist/commands/liberica/operations/batch-delete.d.ts +3 -0
- package/dist/commands/liberica/operations/batch-delete.d.ts.map +1 -0
- package/dist/commands/liberica/operations/batch-delete.js +130 -0
- package/dist/commands/liberica/operations/batch-delete.js.map +1 -0
- package/dist/commands/liberica/operations/copy.d.ts +3 -0
- package/dist/commands/liberica/operations/copy.d.ts.map +1 -0
- package/dist/commands/liberica/operations/copy.js +137 -0
- package/dist/commands/liberica/operations/copy.js.map +1 -0
- package/dist/commands/liberica/operations/create.d.ts +3 -0
- package/dist/commands/liberica/operations/create.d.ts.map +1 -0
- package/dist/commands/liberica/operations/create.js +212 -0
- package/dist/commands/liberica/operations/create.js.map +1 -0
- package/dist/commands/liberica/operations/deactive.d.ts +3 -0
- package/dist/commands/liberica/operations/deactive.d.ts.map +1 -0
- package/dist/commands/liberica/operations/deactive.js +152 -0
- package/dist/commands/liberica/operations/deactive.js.map +1 -0
- package/dist/commands/liberica/operations/delete.d.ts +3 -0
- package/dist/commands/liberica/operations/delete.d.ts.map +1 -0
- package/dist/commands/liberica/operations/delete.js +128 -0
- package/dist/commands/liberica/operations/delete.js.map +1 -0
- package/dist/commands/liberica/operations/get.d.ts +3 -0
- package/dist/commands/liberica/operations/get.d.ts.map +1 -0
- package/dist/commands/liberica/operations/get.js +93 -0
- package/dist/commands/liberica/operations/get.js.map +1 -0
- package/dist/commands/liberica/operations/index.d.ts +3 -0
- package/dist/commands/liberica/operations/index.d.ts.map +1 -0
- package/dist/commands/liberica/operations/index.js +25 -0
- package/dist/commands/liberica/operations/index.js.map +1 -0
- package/dist/commands/liberica/operations/list.d.ts +3 -0
- package/dist/commands/liberica/operations/list.d.ts.map +1 -0
- package/dist/commands/liberica/operations/list.js +141 -0
- package/dist/commands/liberica/operations/list.js.map +1 -0
- package/dist/commands/liberica/operations/update.d.ts +3 -0
- package/dist/commands/liberica/operations/update.d.ts.map +1 -0
- package/dist/commands/liberica/operations/update.js +208 -0
- package/dist/commands/liberica/operations/update.js.map +1 -0
- package/dist/commands/liberica/orgs/index.d.ts.map +1 -1
- package/dist/commands/liberica/orgs/index.js.map +1 -1
- package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts +2 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts.map +1 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.js +41 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.js.map +1 -0
- package/dist/commands/liberica/stock/__tests__/list.test.d.ts +2 -0
- package/dist/commands/liberica/stock/__tests__/list.test.d.ts.map +1 -0
- package/dist/commands/liberica/stock/__tests__/list.test.js +39 -0
- package/dist/commands/liberica/stock/__tests__/list.test.js.map +1 -0
- package/dist/commands/liberica/stock/index.d.ts +3 -0
- package/dist/commands/liberica/stock/index.d.ts.map +1 -0
- package/dist/commands/liberica/stock/index.js +11 -0
- package/dist/commands/liberica/stock/index.js.map +1 -0
- package/dist/commands/liberica/stock/ledger.d.ts +3 -0
- package/dist/commands/liberica/stock/ledger.d.ts.map +1 -0
- package/dist/commands/liberica/stock/ledger.js +154 -0
- package/dist/commands/liberica/stock/ledger.js.map +1 -0
- package/dist/commands/liberica/stock/list.d.ts +3 -0
- package/dist/commands/liberica/stock/list.d.ts.map +1 -0
- package/dist/commands/liberica/stock/list.js +127 -0
- package/dist/commands/liberica/stock/list.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/create.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/create.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/create.js +129 -0
- package/dist/commands/liberica/supplier-contacts/create.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/delete.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/delete.js +88 -0
- package/dist/commands/liberica/supplier-contacts/delete.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/get.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/get.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/get.js +84 -0
- package/dist/commands/liberica/supplier-contacts/get.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/index.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/index.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/index.js +17 -0
- package/dist/commands/liberica/supplier-contacts/index.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/list.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/list.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/list.js +98 -0
- package/dist/commands/liberica/supplier-contacts/list.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/update.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/update.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/update.js +136 -0
- package/dist/commands/liberica/supplier-contacts/update.js.map +1 -0
- package/dist/commands/liberica/users/create.d.ts.map +1 -1
- package/dist/commands/liberica/users/create.js +1 -0
- package/dist/commands/liberica/users/create.js.map +1 -1
- package/dist/commands/liberica/warehouses/create.d.ts +3 -0
- package/dist/commands/liberica/warehouses/create.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/create.js +196 -0
- package/dist/commands/liberica/warehouses/create.js.map +1 -0
- package/dist/commands/liberica/warehouses/delete.d.ts +3 -0
- package/dist/commands/liberica/warehouses/delete.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/delete.js +111 -0
- package/dist/commands/liberica/warehouses/delete.js.map +1 -0
- package/dist/commands/liberica/warehouses/disable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/disable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/disable.js +173 -0
- package/dist/commands/liberica/warehouses/disable.js.map +1 -0
- package/dist/commands/liberica/warehouses/enable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/enable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/enable.js +173 -0
- package/dist/commands/liberica/warehouses/enable.js.map +1 -0
- package/dist/commands/liberica/warehouses/get.d.ts +3 -0
- package/dist/commands/liberica/warehouses/get.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/get.js +90 -0
- package/dist/commands/liberica/warehouses/get.js.map +1 -0
- package/dist/commands/liberica/warehouses/index.d.ts +3 -0
- package/dist/commands/liberica/warehouses/index.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/index.js +23 -0
- package/dist/commands/liberica/warehouses/index.js.map +1 -0
- package/dist/commands/liberica/warehouses/list.d.ts +3 -0
- package/dist/commands/liberica/warehouses/list.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/list.js +101 -0
- package/dist/commands/liberica/warehouses/list.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/create.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/create.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/create.js +199 -0
- package/dist/commands/liberica/warehouses/locations/create.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/delete.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/delete.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/delete.js +115 -0
- package/dist/commands/liberica/warehouses/locations/delete.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/disable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/disable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/disable.js +173 -0
- package/dist/commands/liberica/warehouses/locations/disable.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/enable.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/enable.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/enable.js +173 -0
- package/dist/commands/liberica/warehouses/locations/enable.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/get.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/get.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/get.js +73 -0
- package/dist/commands/liberica/warehouses/locations/get.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/index.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/index.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/index.js +21 -0
- package/dist/commands/liberica/warehouses/locations/index.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/list.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/list.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/list.js +104 -0
- package/dist/commands/liberica/warehouses/locations/list.js.map +1 -0
- package/dist/commands/liberica/warehouses/locations/update.d.ts +3 -0
- package/dist/commands/liberica/warehouses/locations/update.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/locations/update.js +128 -0
- package/dist/commands/liberica/warehouses/locations/update.js.map +1 -0
- package/dist/commands/liberica/warehouses/update.d.ts +3 -0
- package/dist/commands/liberica/warehouses/update.d.ts.map +1 -0
- package/dist/commands/liberica/warehouses/update.js +143 -0
- package/dist/commands/liberica/warehouses/update.js.map +1 -0
- package/dist/core/api/client.d.ts +62 -0
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +1203 -104
- package/dist/core/api/client.js.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/types/calendar.d.ts +28 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/calendar.js +2 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/client-contact.d.ts +65 -0
- package/dist/types/client-contact.d.ts.map +1 -0
- package/dist/types/client-contact.js +4 -0
- package/dist/types/client-contact.js.map +1 -0
- package/dist/types/dict.d.ts +97 -0
- package/dist/types/dict.d.ts.map +1 -0
- package/dist/types/dict.js +2 -0
- package/dist/types/dict.js.map +1 -0
- package/dist/types/index.d.ts +9 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/location.d.ts +53 -0
- package/dist/types/location.d.ts.map +1 -0
- package/dist/types/location.js +2 -0
- package/dist/types/location.js.map +1 -0
- package/dist/types/operation.d.ts +66 -0
- package/dist/types/operation.d.ts.map +1 -0
- package/dist/types/operation.js +2 -0
- package/dist/types/operation.js.map +1 -0
- package/dist/types/stock.d.ts +133 -0
- package/dist/types/stock.d.ts.map +1 -0
- package/dist/types/stock.js +3 -0
- package/dist/types/stock.js.map +1 -0
- package/dist/types/supplier-contact.d.ts +65 -0
- package/dist/types/supplier-contact.d.ts.map +1 -0
- package/dist/types/supplier-contact.js +4 -0
- package/dist/types/supplier-contact.js.map +1 -0
- package/dist/types/warehouse.d.ts +68 -0
- package/dist/types/warehouse.d.ts.map +1 -0
- package/dist/types/warehouse.js +2 -0
- package/dist/types/warehouse.js.map +1 -0
- package/docs/commands/REFERENCE.md +24 -4
- package/docs/commands/liberica/calendar/DESIGN.md +333 -0
- package/docs/commands/liberica/client-contacts/create.md +152 -0
- package/docs/commands/liberica/client-contacts/delete.md +123 -0
- package/docs/commands/liberica/client-contacts/get.md +133 -0
- package/docs/commands/liberica/client-contacts/list.md +143 -0
- package/docs/commands/liberica/client-contacts/update.md +158 -0
- package/docs/commands/liberica/locations/create.md +195 -0
- package/docs/commands/liberica/locations/list.md +171 -0
- package/docs/commands/liberica/stock/ledger.md +209 -0
- package/docs/commands/liberica/stock/list.md +165 -0
- package/docs/commands/liberica/supplier-contacts/create.md +152 -0
- package/docs/commands/liberica/supplier-contacts/delete.md +123 -0
- package/docs/commands/liberica/supplier-contacts/get.md +133 -0
- package/docs/commands/liberica/supplier-contacts/list.md +143 -0
- package/docs/commands/liberica/supplier-contacts/update.md +158 -0
- package/docs/commands/liberica/warehouses/create.md +222 -0
- package/docs/commands/liberica/warehouses/list.md +184 -0
- package/package.json +1 -1
- package/src/commands/liberica/calendar/index.ts +13 -0
- package/src/commands/liberica/calendar/list.ts +214 -0
- package/src/commands/liberica/calendar/set.ts +130 -0
- package/src/commands/liberica/client-contacts/create.ts +115 -0
- package/src/commands/liberica/client-contacts/delete.ts +140 -0
- package/src/commands/liberica/client-contacts/get.ts +103 -0
- package/src/commands/liberica/client-contacts/index.ts +19 -0
- package/src/commands/liberica/client-contacts/list.ts +118 -0
- package/src/commands/liberica/client-contacts/update.ts +137 -0
- package/src/commands/liberica/dict-types/get.ts +74 -0
- package/src/commands/liberica/dict-types/index.ts +15 -0
- package/src/commands/liberica/dict-types/list.ts +118 -0
- package/src/commands/liberica/dict-types/update.ts +134 -0
- package/src/commands/liberica/dicts/create.ts +175 -0
- package/src/commands/liberica/dicts/delete.ts +107 -0
- package/src/commands/liberica/dicts/get.ts +80 -0
- package/src/commands/liberica/dicts/index.ts +19 -0
- package/src/commands/liberica/dicts/list.ts +114 -0
- package/src/commands/liberica/dicts/update.ts +116 -0
- package/src/commands/liberica/index.ts +22 -0
- package/src/commands/liberica/materials/create.ts +32 -9
- package/src/commands/liberica/operations/active.ts +153 -0
- package/src/commands/liberica/operations/batch-delete.ts +131 -0
- package/src/commands/liberica/operations/copy.ts +138 -0
- package/src/commands/liberica/operations/create.ts +223 -0
- package/src/commands/liberica/operations/deactive.ts +152 -0
- package/src/commands/liberica/operations/delete.ts +128 -0
- package/src/commands/liberica/operations/design.md +587 -0
- package/src/commands/liberica/operations/get.ts +112 -0
- package/src/commands/liberica/operations/index.ts +27 -0
- package/src/commands/liberica/operations/list.ts +180 -0
- package/src/commands/liberica/operations/update.ts +218 -0
- package/src/commands/liberica/orgs/index.ts +0 -1
- package/src/commands/liberica/stock/index.ts +13 -0
- package/src/commands/liberica/stock/ledger.ts +159 -0
- package/src/commands/liberica/stock/list.ts +128 -0
- package/src/commands/liberica/supplier-contacts/create.ts +120 -0
- package/src/commands/liberica/supplier-contacts/delete.ts +88 -0
- package/src/commands/liberica/supplier-contacts/get.ts +94 -0
- package/src/commands/liberica/supplier-contacts/index.ts +19 -0
- package/src/commands/liberica/supplier-contacts/list.ts +130 -0
- package/src/commands/liberica/supplier-contacts/update.ts +127 -0
- package/src/commands/liberica/users/create.ts +1 -0
- package/src/commands/liberica/warehouses/create.ts +204 -0
- package/src/commands/liberica/warehouses/delete.ts +112 -0
- package/src/commands/liberica/warehouses/disable.ts +174 -0
- package/src/commands/liberica/warehouses/enable.ts +174 -0
- package/src/commands/liberica/warehouses/get.ts +101 -0
- package/src/commands/liberica/warehouses/index.ts +25 -0
- package/src/commands/liberica/warehouses/list.ts +136 -0
- package/src/commands/liberica/warehouses/locations/create.ts +209 -0
- package/src/commands/liberica/warehouses/locations/delete.ts +116 -0
- package/src/commands/liberica/warehouses/locations/disable.ts +174 -0
- package/src/commands/liberica/warehouses/locations/enable.ts +174 -0
- package/src/commands/liberica/warehouses/locations/get.ts +84 -0
- package/src/commands/liberica/warehouses/locations/index.ts +23 -0
- package/src/commands/liberica/warehouses/locations/list.ts +140 -0
- package/src/commands/liberica/warehouses/locations/update.ts +135 -0
- package/src/commands/liberica/warehouses/update.ts +142 -0
- package/src/core/api/client.ts +1493 -78
- package/src/index.ts +1 -3
- package/src/types/calendar.ts +36 -0
- package/src/types/client-contact.ts +78 -0
- package/src/types/dict.ts +121 -0
- package/src/types/index.ts +9 -4
- package/src/types/location.ts +66 -0
- package/src/types/operation.ts +72 -0
- package/src/types/stock.ts +161 -0
- package/src/types/supplier-contact.ts +78 -0
- package/src/types/warehouse.ts +82 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
4
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
+
import { UpdateSupplierContactRequest } from '../../../types/supplier-contact.js';
|
|
6
|
+
|
|
7
|
+
export function createSupplierContactUpdateCommand(): Command {
|
|
8
|
+
const cmd = new Command('update');
|
|
9
|
+
cmd.description('Update an existing supplier contact');
|
|
10
|
+
|
|
11
|
+
cmd
|
|
12
|
+
.arguments('<contact-id>')
|
|
13
|
+
.option('-n, --name <string>', 'Contact name')
|
|
14
|
+
.option('-p, --phone <string>', 'Phone number')
|
|
15
|
+
.option('-t, --telephone <string>', 'Telephone number')
|
|
16
|
+
.option('-e, --email <string>', 'Email address')
|
|
17
|
+
.option('-x, --sex <string>', 'Sex')
|
|
18
|
+
.option('-b, --birthday <string>', 'Birthday (YYYY-MM-DD)')
|
|
19
|
+
.option('-q, --qq <string>', 'QQ number')
|
|
20
|
+
.option('-w, --wechat <string>', 'WeChat ID')
|
|
21
|
+
.option('-a, --address <string>', 'Address')
|
|
22
|
+
.option('-d, --default', 'Set as default contact')
|
|
23
|
+
.option('-r, --remark <string>', 'Remark')
|
|
24
|
+
.option('--dry-run', 'Preview the operation without executing')
|
|
25
|
+
.option('--json', 'Output as JSON')
|
|
26
|
+
.action(async (contactId: string, options: Record<string, unknown>) => {
|
|
27
|
+
const context = configManager.getCurrentContext();
|
|
28
|
+
const environment = context.environment;
|
|
29
|
+
const tenant = context.tenant;
|
|
30
|
+
const jsonOutput = options.json === true;
|
|
31
|
+
|
|
32
|
+
if (!contactId || contactId.trim() === '') {
|
|
33
|
+
if (jsonOutput) {
|
|
34
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'contact-id is required' } }));
|
|
35
|
+
} else {
|
|
36
|
+
console.error(chalk.red('\n✗ Contact ID is required\n'));
|
|
37
|
+
}
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const data: UpdateSupplierContactRequest = {
|
|
42
|
+
supplierContactId: contactId,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (options.name) data.supplierContactName = options.name as string;
|
|
46
|
+
if (options.phone) data.supplierContactPhone = options.phone as string;
|
|
47
|
+
if (options.telephone) data.supplierContactTelephone = options.telephone as string;
|
|
48
|
+
if (options.email) data.supplierContactEmail = options.email as string;
|
|
49
|
+
if (options.sex) data.supplierContactSex = options.sex as string;
|
|
50
|
+
if (options.birthday) data.supplierContactBirthday = options.birthday as string;
|
|
51
|
+
if (options.qq) data.supplierContactQq = options.qq as string;
|
|
52
|
+
if (options.wechat) data.supplierContactWechat = options.wechat as string;
|
|
53
|
+
if (options.address) data.supplierContactAddress = options.address as string;
|
|
54
|
+
if (options.default === true) data.defaultFlag = 'Y';
|
|
55
|
+
else if (options.default === false) data.defaultFlag = 'N';
|
|
56
|
+
if (options.remark) data.remark = options.remark as string;
|
|
57
|
+
|
|
58
|
+
Object.keys(data).forEach(key => {
|
|
59
|
+
if (data[key as keyof UpdateSupplierContactRequest] === undefined) {
|
|
60
|
+
delete data[key as keyof UpdateSupplierContactRequest];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (Object.keys(data).length <= 1) {
|
|
65
|
+
if (jsonOutput) {
|
|
66
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'At least one field must be provided to update' } }));
|
|
67
|
+
} else {
|
|
68
|
+
console.error(chalk.red('\n✗ At least one field must be provided to update\n'));
|
|
69
|
+
}
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (options.dryRun) {
|
|
74
|
+
if (jsonOutput) {
|
|
75
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
76
|
+
} else {
|
|
77
|
+
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual API call will be made\n'));
|
|
78
|
+
console.log(chalk.gray(' This operation will update the following supplier contact:'));
|
|
79
|
+
console.log(` ${chalk.gray('Contact ID:')} ${contactId}`);
|
|
80
|
+
Object.keys(data).forEach(key => {
|
|
81
|
+
if (key !== 'supplierContactId' && data[key as keyof UpdateSupplierContactRequest] !== undefined) {
|
|
82
|
+
console.log(` ${chalk.gray(key + ':')} ${data[key as keyof UpdateSupplierContactRequest]}`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
console.log();
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const response = await apiClient.updateSupplierContact(environment, tenant, data);
|
|
92
|
+
|
|
93
|
+
if (response.success) {
|
|
94
|
+
if (jsonOutput) {
|
|
95
|
+
console.log(JSON.stringify({ success: true, data: response.data }));
|
|
96
|
+
} else {
|
|
97
|
+
console.log(chalk.green('\n✓ Supplier contact updated successfully\n'));
|
|
98
|
+
console.log(` ${chalk.gray('Contact ID:')} ${chalk.green(contactId)}`);
|
|
99
|
+
console.log();
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
const errorMsg = response.error?.message || 'Failed to update supplier contact';
|
|
103
|
+
const errorCode = response.error?.code || 'UPDATE_ERROR';
|
|
104
|
+
if (jsonOutput) {
|
|
105
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
106
|
+
} else {
|
|
107
|
+
console.error(chalk.red(`\n✗ Failed to update supplier contact: ${errorMsg}`));
|
|
108
|
+
if (response.error?.code) {
|
|
109
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
110
|
+
}
|
|
111
|
+
console.error();
|
|
112
|
+
}
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
117
|
+
if (jsonOutput) {
|
|
118
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
119
|
+
} else {
|
|
120
|
+
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
121
|
+
}
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return cmd;
|
|
127
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
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 { Warehouse } from '../../../types/warehouse.js';
|
|
8
|
+
|
|
9
|
+
export function createWarehouseDisableCommand(): Command {
|
|
10
|
+
const disableCommand = new Command('disable');
|
|
11
|
+
disableCommand
|
|
12
|
+
.description('Disable (deactivate) a warehouse')
|
|
13
|
+
.argument('[warehouse-id]', 'Warehouse ID (mutually exclusive with --ids)')
|
|
14
|
+
.option('--ids <ids>', 'Comma-separated warehouse IDs for batch operations')
|
|
15
|
+
.option('--force', 'Skip confirmation prompt')
|
|
16
|
+
.option('--dry-run', 'Preview the operation without executing')
|
|
17
|
+
.option('--json', 'Output as JSON')
|
|
18
|
+
.action(async (warehouseId: string | undefined, options: Record<string, unknown>) => {
|
|
19
|
+
const context = configManager.getCurrentContext();
|
|
20
|
+
const environment = context.environment as Environment;
|
|
21
|
+
const tenant = context.tenant;
|
|
22
|
+
const force = options.force === true;
|
|
23
|
+
const dryRun = options.dryRun === true;
|
|
24
|
+
const jsonOutput = options.json === true;
|
|
25
|
+
|
|
26
|
+
const batchIds = options.ids
|
|
27
|
+
? (options.ids as string).split(',').map((id) => id.trim()).filter((id) => id !== '')
|
|
28
|
+
: [];
|
|
29
|
+
|
|
30
|
+
if (!warehouseId && batchIds.length === 0) {
|
|
31
|
+
const errMsg = 'Invalid warehouse ID. Provide <warehouse-id> or use --ids for batch operations.';
|
|
32
|
+
if (jsonOutput) {
|
|
33
|
+
console.log(JSON.stringify({ success: false, error: { code: 'INVALID_ID', message: errMsg } }));
|
|
34
|
+
} else {
|
|
35
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
36
|
+
}
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const allIds = warehouseId ? [warehouseId] : batchIds;
|
|
41
|
+
|
|
42
|
+
if (!jsonOutput) {
|
|
43
|
+
console.log(chalk.bold(`\n⬇ Disable Warehouse (${environment})\n`));
|
|
44
|
+
if (batchIds.length > 0) {
|
|
45
|
+
console.log(chalk.gray(` Warehouse IDs: ${batchIds.join(', ')}`));
|
|
46
|
+
} else {
|
|
47
|
+
console.log(chalk.gray(` Warehouse ID: ${warehouseId}`));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (dryRun) {
|
|
52
|
+
if (jsonOutput) {
|
|
53
|
+
console.log(JSON.stringify({
|
|
54
|
+
success: true,
|
|
55
|
+
dryRun: true,
|
|
56
|
+
warehouseIds: allIds,
|
|
57
|
+
message: 'No actual API call will be made',
|
|
58
|
+
}));
|
|
59
|
+
} else {
|
|
60
|
+
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual API call will be made\n'));
|
|
61
|
+
console.log(chalk.gray(` This operation will disable ${allIds.length} warehouse(s).`));
|
|
62
|
+
console.log();
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const warehouses: Warehouse[] = [];
|
|
68
|
+
for (const id of allIds) {
|
|
69
|
+
try {
|
|
70
|
+
const response = await apiClient.getWarehouse(environment, tenant, id);
|
|
71
|
+
if (!response.success || !response.data || !('warehouseId' in response.data)) {
|
|
72
|
+
const errMsg = `Warehouse not found: ${id}`;
|
|
73
|
+
if (jsonOutput) {
|
|
74
|
+
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
75
|
+
} else {
|
|
76
|
+
console.error(chalk.red(`\n✗ ${errMsg}\n`));
|
|
77
|
+
}
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
warehouses.push(response.data as Warehouse);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
83
|
+
const jsonErr = { success: false, error: { code: 'FETCH_ERROR', message: 'Failed to fetch warehouse: ' + errMsg } };
|
|
84
|
+
if (jsonOutput) {
|
|
85
|
+
console.log(JSON.stringify(jsonErr));
|
|
86
|
+
} else {
|
|
87
|
+
console.error(chalk.red(`\n✗ Failed to fetch warehouse: ${errMsg}\n`));
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const allAlreadyDisabled = warehouses.every((w) => w.statusFlag === 2);
|
|
94
|
+
if (allAlreadyDisabled) {
|
|
95
|
+
const names = warehouses.map((w) => `"${w.warehouseName}"`).join(', ');
|
|
96
|
+
const errMsg = `Warehouse(s) ${names} ${warehouses.length === 1 ? 'is' : 'are'} already disabled`;
|
|
97
|
+
if (jsonOutput) {
|
|
98
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ALREADY_DISABLED', message: errMsg } }));
|
|
99
|
+
} else {
|
|
100
|
+
console.error(chalk.yellow(`\n⚠ ${errMsg}\n`));
|
|
101
|
+
}
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!force) {
|
|
106
|
+
if (!jsonOutput) {
|
|
107
|
+
if (warehouses.length === 1) {
|
|
108
|
+
console.log(chalk.gray(` Name: ${warehouses[0].warehouseName}`));
|
|
109
|
+
console.log(chalk.gray(` Code: ${warehouses[0].warehouseCode}`));
|
|
110
|
+
} else {
|
|
111
|
+
warehouses.forEach((w, i) => {
|
|
112
|
+
console.log(chalk.gray(` [${i + 1}] ${w.warehouseName} (${w.warehouseCode})`));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const { confirm } = await inquirer.prompt([
|
|
118
|
+
{
|
|
119
|
+
type: 'confirm',
|
|
120
|
+
name: 'confirm',
|
|
121
|
+
message: warehouses.length === 1
|
|
122
|
+
? `Disable warehouse "${warehouses[0].warehouseName}"?`
|
|
123
|
+
: `Disable ${warehouses.length} warehouses?`,
|
|
124
|
+
default: false,
|
|
125
|
+
},
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
if (!confirm) {
|
|
129
|
+
if (jsonOutput) {
|
|
130
|
+
console.log(JSON.stringify({ success: false, error: { code: 'CANCELLED', message: 'Operation cancelled' } }));
|
|
131
|
+
} else {
|
|
132
|
+
console.log(chalk.gray('\n Operation cancelled.\n'));
|
|
133
|
+
}
|
|
134
|
+
process.exit(0);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
const response = await apiClient.batchDisableWarehouses(environment, tenant, allIds);
|
|
140
|
+
|
|
141
|
+
if (response.success) {
|
|
142
|
+
if (jsonOutput) {
|
|
143
|
+
console.log(JSON.stringify({ success: true, warehouseIds: allIds }));
|
|
144
|
+
} else {
|
|
145
|
+
const names = warehouses.map((w) => w.warehouseName).join(', ');
|
|
146
|
+
console.log(chalk.green(`\n✓ Warehouse(s) ${names || allIds.join(', ')} disabled\n`));
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
const errorMsg = response.error?.message || 'Unknown error';
|
|
150
|
+
const errorCode = response.error?.code || 'DISABLE_ERROR';
|
|
151
|
+
if (jsonOutput) {
|
|
152
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
153
|
+
} else {
|
|
154
|
+
console.error(chalk.red(`\n✗ Failed to disable warehouse(s): ${errorMsg}`));
|
|
155
|
+
if (response.error?.code) {
|
|
156
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
157
|
+
}
|
|
158
|
+
console.error();
|
|
159
|
+
}
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
} catch (error) {
|
|
163
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
164
|
+
if (jsonOutput) {
|
|
165
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
166
|
+
} else {
|
|
167
|
+
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
168
|
+
}
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
return disableCommand;
|
|
174
|
+
}
|