@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,134 @@
|
|
|
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 { DictType, UpdateDictTypeRequest } from '../../../types/dict.js';
|
|
7
|
+
|
|
8
|
+
export function createDictTypeUpdateCommand(): Command {
|
|
9
|
+
const updateCommand = new Command('update');
|
|
10
|
+
updateCommand
|
|
11
|
+
.description('Update dictionary type')
|
|
12
|
+
.argument('<dict-type-id>', 'Dictionary Type ID')
|
|
13
|
+
.option('-c, --code <code>', 'Dictionary type code')
|
|
14
|
+
.option('-n, --name <name>', 'Dictionary type name')
|
|
15
|
+
.option('-s, --status <status>', 'Status (1: enable, 2: disable)')
|
|
16
|
+
.option('--sort <sort>', 'Sort order')
|
|
17
|
+
.option('--dry-run', 'Preview changes without making API call')
|
|
18
|
+
.option('--json', 'Output result as JSON')
|
|
19
|
+
.action(async (dictTypeId: string, options: Record<string, unknown>) => {
|
|
20
|
+
const context = configManager.getCurrentContext();
|
|
21
|
+
const environment = context.environment as Environment;
|
|
22
|
+
const tenant = context.tenant;
|
|
23
|
+
|
|
24
|
+
const fields: Partial<UpdateDictTypeRequest> = {};
|
|
25
|
+
if (options.code) fields.dictTypeCode = options.code as string;
|
|
26
|
+
if (options.name) fields.dictTypeName = options.name as string;
|
|
27
|
+
if (options.status) {
|
|
28
|
+
const status = parseInt(options.status as string, 10);
|
|
29
|
+
if (status === 1 || status === 2) {
|
|
30
|
+
fields.statusFlag = status as 1 | 2;
|
|
31
|
+
} else {
|
|
32
|
+
console.error(chalk.red('\n✗ Invalid status. Use 1 (enable) or 2 (disable)\n'));
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (options.sort) {
|
|
37
|
+
const sortOrder = parseInt(options.sort as string, 10);
|
|
38
|
+
if (!isNaN(sortOrder)) {
|
|
39
|
+
fields.sortOrder = sortOrder;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const providedFields = Object.keys(fields).filter(
|
|
44
|
+
(k) => fields[k as keyof UpdateDictTypeRequest] !== undefined && k !== 'dictTypeId'
|
|
45
|
+
);
|
|
46
|
+
if (providedFields.length === 0) {
|
|
47
|
+
console.error(
|
|
48
|
+
chalk.red('\n✗ No fields to update. Provide at least one of: --code, --name, --status, --sort\n')
|
|
49
|
+
);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (options.dryRun) {
|
|
54
|
+
console.log(chalk.bold(`\n📖 Update Dict Type — Dry Run (${environment})\n`));
|
|
55
|
+
console.log(chalk.gray(` Dict Type ID: ${dictTypeId}`));
|
|
56
|
+
console.log(chalk.gray('\n Changes to be applied:'));
|
|
57
|
+
for (const field of providedFields) {
|
|
58
|
+
const label = field.replace(/([A-Z])/g, (m) => ` ${m.toLowerCase()}`).trim();
|
|
59
|
+
console.log(chalk.cyan(` ${label}: "${fields[field as keyof UpdateDictTypeRequest]}"`));
|
|
60
|
+
}
|
|
61
|
+
console.log();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let currentDictType: DictType | undefined;
|
|
66
|
+
try {
|
|
67
|
+
const dictTypeResponse = await apiClient.getDictType(environment, tenant, dictTypeId);
|
|
68
|
+
if (!dictTypeResponse.success || !dictTypeResponse.data) {
|
|
69
|
+
console.error(chalk.red(`\n✗ Dictionary type not found: ${dictTypeId}`));
|
|
70
|
+
if (dictTypeResponse.error?.message) {
|
|
71
|
+
console.error(chalk.gray(` ${dictTypeResponse.error.message}`));
|
|
72
|
+
}
|
|
73
|
+
if (dictTypeResponse.error?.code) {
|
|
74
|
+
console.error(chalk.gray(` Error code: ${dictTypeResponse.error.code}`));
|
|
75
|
+
}
|
|
76
|
+
console.error();
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
currentDictType = dictTypeResponse.data as DictType;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error(chalk.red(`\n✗ Failed to fetch dictionary type: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log(chalk.bold(`\n📖 Update Dict Type (${environment})\n`));
|
|
86
|
+
console.log(chalk.gray(` Dict Type ID: ${dictTypeId}`));
|
|
87
|
+
console.log(chalk.gray(` Current Name: ${currentDictType.dictTypeName}`));
|
|
88
|
+
console.log(chalk.gray('\n Changes:'));
|
|
89
|
+
for (const field of providedFields) {
|
|
90
|
+
const label = field.replace(/([A-Z])/g, (m) => ` ${m.toLowerCase()}`).trim();
|
|
91
|
+
const currentVal = (currentDictType as unknown as Record<string, unknown>)[field] ?? '(not set)';
|
|
92
|
+
const newVal = fields[field as keyof UpdateDictTypeRequest];
|
|
93
|
+
console.log(chalk.cyan(` ${label}: "${currentVal}" → "${newVal}"`));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const updateData: UpdateDictTypeRequest = { dictTypeId, ...fields };
|
|
97
|
+
try {
|
|
98
|
+
const response = await apiClient.updateDictType(environment, tenant, updateData);
|
|
99
|
+
|
|
100
|
+
if (response.success) {
|
|
101
|
+
if (options.json) {
|
|
102
|
+
console.log(JSON.stringify({ success: true, data: response.data }, null, 2));
|
|
103
|
+
} else {
|
|
104
|
+
console.log(chalk.green('\n✓ Dictionary type updated successfully\n'));
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
if (options.json) {
|
|
108
|
+
console.log(JSON.stringify({ success: false, error: response.error }, null, 2));
|
|
109
|
+
} else {
|
|
110
|
+
console.error(chalk.red(`\n✗ Update failed: ${response.error?.message || 'Unknown error'}`));
|
|
111
|
+
if (response.error?.code) {
|
|
112
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
113
|
+
}
|
|
114
|
+
console.error();
|
|
115
|
+
}
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (options.json) {
|
|
120
|
+
console.log(
|
|
121
|
+
JSON.stringify({
|
|
122
|
+
success: false,
|
|
123
|
+
error: { message: error instanceof Error ? error.message : 'Unknown error' },
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
} else {
|
|
127
|
+
console.error(chalk.red(`\n✗ Error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
128
|
+
}
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return updateCommand;
|
|
134
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
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 { CreateDictItemRequest, DictType } from '../../../types/dict.js';
|
|
7
|
+
|
|
8
|
+
function formatTable(data: CreateDictItemRequest): string {
|
|
9
|
+
const lines: string[] = [];
|
|
10
|
+
lines.push(` ${chalk.gray('Dict Type Code:')} ${data.dictTypeCode || '(not set)'}`);
|
|
11
|
+
lines.push(` ${chalk.gray('Code:')} ${data.dictCode || '(not set)'}`);
|
|
12
|
+
lines.push(` ${chalk.gray('Name:')} ${data.dictName || '(not set)'}`);
|
|
13
|
+
if (data.dictValue) lines.push(` ${chalk.gray('Value:')} ${data.dictValue}`);
|
|
14
|
+
if (data.sortOrder !== undefined) lines.push(` ${chalk.gray('Sort Order:')} ${data.sortOrder}`);
|
|
15
|
+
if (data.statusFlag) lines.push(` ${chalk.gray('Status:')} ${data.statusFlag === 1 ? 'Enabled' : 'Disabled'}`);
|
|
16
|
+
if (data.remark) lines.push(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
17
|
+
return lines.join('\n');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createDictCreateCommand(): Command {
|
|
21
|
+
const cmd = new Command('create');
|
|
22
|
+
cmd.description('Create a new dictionary item');
|
|
23
|
+
|
|
24
|
+
cmd
|
|
25
|
+
.requiredOption('-t, --type-code <string>', 'Dict type code (e.g., ID_TYPE, sex) (required)')
|
|
26
|
+
.requiredOption('-c, --code <string>', 'Dict code (required)')
|
|
27
|
+
.requiredOption('-n, --name <string>', 'Dict name (required)')
|
|
28
|
+
.option('-p, --parent <string>', 'Parent dict ID (-1 for root)', '-1')
|
|
29
|
+
.option('-s, --status <string>', 'Status (1=enable, 2=disable)', '1')
|
|
30
|
+
.option('-o, --sort <number>', 'Sort order', '0')
|
|
31
|
+
.option('-v, --value <string>', 'Dict value')
|
|
32
|
+
.option('-r, --remark <text>', 'Remark')
|
|
33
|
+
.option('--dry-run', 'Preview without making API call')
|
|
34
|
+
.option('--json', 'Output as JSON');
|
|
35
|
+
|
|
36
|
+
cmd.action(async () => {
|
|
37
|
+
const context = configManager.getCurrentContext();
|
|
38
|
+
const opts = cmd.opts();
|
|
39
|
+
|
|
40
|
+
let typeCode = opts.typeCode as string | undefined;
|
|
41
|
+
const code = opts.code as string | undefined;
|
|
42
|
+
const name = opts.name as string | undefined;
|
|
43
|
+
const parentId = (opts.parent as string) === '-1' ? '-1' : (opts.parent as string);
|
|
44
|
+
const statusFlag = parseInt(opts.status as string, 10) || 1;
|
|
45
|
+
const sortOrder = parseInt(opts.sort as string, 10) || 0;
|
|
46
|
+
const dictValue = opts.value as string | undefined;
|
|
47
|
+
const remark = opts.remark as string | undefined;
|
|
48
|
+
const dryRun = opts.dryRun === true;
|
|
49
|
+
const outputJson = opts.json === true || process.argv.includes('--json');
|
|
50
|
+
|
|
51
|
+
if (!typeCode) {
|
|
52
|
+
const { inputTypeCode } = await inquirer.prompt([
|
|
53
|
+
{
|
|
54
|
+
type: 'input',
|
|
55
|
+
name: 'inputTypeCode',
|
|
56
|
+
message: 'Enter dict type code (e.g., ID_TYPE, sex):',
|
|
57
|
+
validate: (input: string) => input.trim().length > 0 || 'Dict type code is required',
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
typeCode = inputTypeCode;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Look up dictTypeId from typeCode before creating
|
|
64
|
+
const dictTypeResponse = await apiClient.listDictTypes(
|
|
65
|
+
context.environment,
|
|
66
|
+
context.tenant,
|
|
67
|
+
{ dictTypeCode: typeCode, pageSize: 100 }
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (!dictTypeResponse.success || !dictTypeResponse.data) {
|
|
71
|
+
if (outputJson) {
|
|
72
|
+
console.log(JSON.stringify({ success: false, error: { code: 'DICT_TYPE_NOT_FOUND', message: `Dict type not found: ${typeCode}` } }));
|
|
73
|
+
} else {
|
|
74
|
+
console.error(chalk.red(`\n✗ Dict type not found: ${typeCode}\n`));
|
|
75
|
+
}
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// response.data is an array of DictType since the API returns plain array
|
|
80
|
+
const dictTypes = dictTypeResponse.data as unknown as DictType[];
|
|
81
|
+
const matchedDictType = dictTypes.find(dt => dt.dictTypeCode === typeCode);
|
|
82
|
+
|
|
83
|
+
if (!matchedDictType) {
|
|
84
|
+
if (outputJson) {
|
|
85
|
+
console.log(JSON.stringify({ success: false, error: { code: 'DICT_TYPE_NOT_FOUND', message: `Dict type not found: ${typeCode}` } }));
|
|
86
|
+
} else {
|
|
87
|
+
console.error(chalk.red(`\n✗ Dict type not found: ${typeCode}\n`));
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const dictTypeId = matchedDictType.dictTypeId;
|
|
93
|
+
|
|
94
|
+
const data: CreateDictItemRequest = {
|
|
95
|
+
dictTypeId: dictTypeId,
|
|
96
|
+
dictCode: code!,
|
|
97
|
+
dictName: name!,
|
|
98
|
+
dictValue: dictValue || name!,
|
|
99
|
+
sortOrder: sortOrder,
|
|
100
|
+
statusFlag: statusFlag as 1 | 2,
|
|
101
|
+
remark: remark,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Add parent and predefinedFlag as additional fields
|
|
105
|
+
data.dictParentId = parentId;
|
|
106
|
+
data.predefinedFlag = 'N';
|
|
107
|
+
|
|
108
|
+
if (dryRun) {
|
|
109
|
+
if (outputJson) {
|
|
110
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
111
|
+
} else {
|
|
112
|
+
console.log(chalk.bold('\n🔍 Dry-Run Mode: No changes will be made\n'));
|
|
113
|
+
console.log(' Dict item to be created:');
|
|
114
|
+
console.log(formatTable(data));
|
|
115
|
+
console.log();
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!outputJson) {
|
|
121
|
+
console.log(chalk.bold('\n📝 Creating Dict Item\n'));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const response = await apiClient.createDictItem(context.environment, context.tenant, data);
|
|
125
|
+
|
|
126
|
+
if (!response.success) {
|
|
127
|
+
const errorMsg = response.error?.message || 'Failed to create dict item';
|
|
128
|
+
const errorCode = response.error?.code || 'CREATE_DICT_ITEM_ERROR';
|
|
129
|
+
if (outputJson) {
|
|
130
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
131
|
+
} else {
|
|
132
|
+
console.error(chalk.red(`\n✗ Failed to create dict item: ${errorMsg}`));
|
|
133
|
+
if (response.error?.code) {
|
|
134
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
135
|
+
}
|
|
136
|
+
console.error();
|
|
137
|
+
}
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (response.success) {
|
|
142
|
+
const dictItem = response.data as {
|
|
143
|
+
dictId?: string;
|
|
144
|
+
dictTypeId?: string;
|
|
145
|
+
dictCode?: string;
|
|
146
|
+
dictName?: string;
|
|
147
|
+
dictValue?: string;
|
|
148
|
+
sortOrder?: number;
|
|
149
|
+
statusFlag?: number;
|
|
150
|
+
remark?: string;
|
|
151
|
+
createTime?: string;
|
|
152
|
+
} | undefined;
|
|
153
|
+
|
|
154
|
+
if (outputJson) {
|
|
155
|
+
console.log(JSON.stringify({ success: true, data: dictItem }));
|
|
156
|
+
} else {
|
|
157
|
+
console.log(chalk.green('✓ Dict item created successfully\n'));
|
|
158
|
+
if (dictItem?.dictId) console.log(` ${chalk.gray('Dict ID:')} ${chalk.green(String(dictItem.dictId))}`);
|
|
159
|
+
if (dictItem?.dictTypeId) console.log(` ${chalk.gray('Type ID:')} ${dictItem.dictTypeId}`);
|
|
160
|
+
if (dictItem?.dictCode) console.log(` ${chalk.gray('Code:')} ${dictItem.dictCode}`);
|
|
161
|
+
if (dictItem?.dictName) console.log(` ${chalk.gray('Name:')} ${dictItem.dictName}`);
|
|
162
|
+
if (dictItem?.dictValue) console.log(` ${chalk.gray('Value:')} ${dictItem.dictValue}`);
|
|
163
|
+
if (dictItem?.sortOrder !== undefined) console.log(` ${chalk.gray('Sort Order:')} ${dictItem.sortOrder}`);
|
|
164
|
+
if (dictItem?.statusFlag !== undefined) {
|
|
165
|
+
const statusText = dictItem.statusFlag === 1 ? 'Enabled' : 'Disabled';
|
|
166
|
+
console.log(` ${chalk.gray('Status:')} ${chalk.green(statusText)}`);
|
|
167
|
+
}
|
|
168
|
+
if (dictItem?.remark) console.log(` ${chalk.gray('Remark:')} ${dictItem.remark}`);
|
|
169
|
+
console.log();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
return cmd;
|
|
175
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 { DictItem } from '../../../types/dict.js';
|
|
7
|
+
|
|
8
|
+
export function createDictDeleteCommand(): Command {
|
|
9
|
+
const deleteCommand = new Command('delete');
|
|
10
|
+
deleteCommand
|
|
11
|
+
.description('Delete a dictionary item')
|
|
12
|
+
.argument('<dictId>', 'Dict Item 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 (dictId: 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 Dictionary Item (${environment})\n`));
|
|
25
|
+
console.log(chalk.gray(` Dict ID: ${dictId}`));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let dictItem: DictItem | undefined;
|
|
29
|
+
try {
|
|
30
|
+
const dictResponse = await apiClient.getDictItem(environment, tenant, dictId);
|
|
31
|
+
if (!dictResponse.success || !dictResponse.data || !('dictId' in dictResponse.data)) {
|
|
32
|
+
const errMsg = `Dictionary item not found: ${dictId}`;
|
|
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
|
+
dictItem = dictResponse.data as DictItem;
|
|
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 dictionary item: ${errMsg}` } }));
|
|
45
|
+
} else {
|
|
46
|
+
console.error(chalk.red(`\n✗ Failed to fetch dictionary item: ${errMsg}\n`));
|
|
47
|
+
}
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!jsonOutput) {
|
|
52
|
+
console.log(chalk.gray(` Name: ${dictItem.dictName}`));
|
|
53
|
+
console.log(chalk.gray(` Code: ${dictItem.dictCode}`));
|
|
54
|
+
console.log(chalk.gray(` Value: ${dictItem.dictValue}`));
|
|
55
|
+
console.log(chalk.gray(` Type ID: ${dictItem.dictTypeId}`));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (dryRun) {
|
|
59
|
+
if (jsonOutput) {
|
|
60
|
+
console.log(JSON.stringify({ success: true, dryRun: true, dictItem }));
|
|
61
|
+
} else {
|
|
62
|
+
console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual deletion will be made\n'));
|
|
63
|
+
console.log(chalk.yellow(' To delete, add: --force\n'));
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!options.force) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const response = await apiClient.deleteDictItem(environment, tenant, dictId);
|
|
74
|
+
|
|
75
|
+
if (response.success) {
|
|
76
|
+
if (jsonOutput) {
|
|
77
|
+
console.log(JSON.stringify({ success: true, dictId, name: dictItem.dictName }));
|
|
78
|
+
} else {
|
|
79
|
+
console.log(chalk.green(`\n✓ Dictionary Item "${dictItem.dictName}" (ID: ${dictId}) deleted\n`));
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
const errorMsg = response.error?.message || 'Unknown error';
|
|
83
|
+
const errorCode = response.error?.code || 'DELETE_ERROR';
|
|
84
|
+
if (jsonOutput) {
|
|
85
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
86
|
+
} else {
|
|
87
|
+
console.error(chalk.red(`\n✗ Failed to delete dictionary item: ${errorMsg}`));
|
|
88
|
+
if (response.error?.code) {
|
|
89
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
90
|
+
}
|
|
91
|
+
console.error();
|
|
92
|
+
}
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
97
|
+
if (jsonOutput) {
|
|
98
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
99
|
+
} else {
|
|
100
|
+
console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
|
|
101
|
+
}
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return deleteCommand;
|
|
107
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { DictItem } from '../../../types/dict.js';
|
|
7
|
+
|
|
8
|
+
export function createDictGetCommand(): Command {
|
|
9
|
+
const getCommand = new Command('get');
|
|
10
|
+
getCommand.description('Get dictionary item details by ID');
|
|
11
|
+
getCommand.arguments('<dictId>');
|
|
12
|
+
getCommand.option('--json', 'Output as JSON');
|
|
13
|
+
|
|
14
|
+
getCommand.action(async (dictId: string, options: Record<string, unknown>) => {
|
|
15
|
+
const context = configManager.getCurrentContext();
|
|
16
|
+
const environment = (options.env as Environment) || context.environment;
|
|
17
|
+
const tenant = (options.tenant as string) || context.tenant;
|
|
18
|
+
|
|
19
|
+
if (!dictId) {
|
|
20
|
+
console.error(chalk.red('\n✗ Dict ID is required\n'));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!dictId || dictId.trim() === '') {
|
|
25
|
+
console.error(chalk.red('\n✗ Invalid dict ID.\n'));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const response = await apiClient.getDictItem(environment, tenant, dictId);
|
|
31
|
+
|
|
32
|
+
if (!response.success) {
|
|
33
|
+
const errorCode = response.error?.code || 'UNKNOWN_ERROR';
|
|
34
|
+
const errorMessage = response.error?.message || 'Unknown error';
|
|
35
|
+
|
|
36
|
+
// Handle "dict item not found" case
|
|
37
|
+
if (errorCode === '01001150001' || errorMessage.includes('不存在')) {
|
|
38
|
+
console.error(chalk.red(`\n✗ Dictionary item not found: ${dictId}\n`));
|
|
39
|
+
} else {
|
|
40
|
+
console.error(chalk.red(`\n✗ Error: ${errorMessage} (${errorCode})\n`));
|
|
41
|
+
}
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const dictItem = response.data as DictItem | null;
|
|
46
|
+
|
|
47
|
+
if (!dictItem) {
|
|
48
|
+
console.error(chalk.red('\n✗ Dictionary item not found\n'));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (options.json) {
|
|
53
|
+
console.log(JSON.stringify({
|
|
54
|
+
success: true,
|
|
55
|
+
data: dictItem,
|
|
56
|
+
}, null, 2));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Table output
|
|
61
|
+
console.log(chalk.bold('\n📖 Dictionary Item Details\n'));
|
|
62
|
+
console.log(` ${chalk.gray('ID:')} ${dictItem.dictId}`);
|
|
63
|
+
console.log(` ${chalk.gray('Type ID:')} ${dictItem.dictTypeId}`);
|
|
64
|
+
console.log(` ${chalk.gray('Code:')} ${dictItem.dictCode}`);
|
|
65
|
+
console.log(` ${chalk.gray('Name:')} ${dictItem.dictName}`);
|
|
66
|
+
console.log(` ${chalk.gray('Value:')} ${dictItem.dictValue}`);
|
|
67
|
+
console.log(` ${chalk.gray('Sort Order:')} ${dictItem.sortOrder}`);
|
|
68
|
+
console.log(` ${chalk.gray('Status:')} ${dictItem.statusFlag === 1 ? 'Enable' : 'Disable'}`);
|
|
69
|
+
if (dictItem.remark) {
|
|
70
|
+
console.log(` ${chalk.gray('Remark:')} ${dictItem.remark}`);
|
|
71
|
+
}
|
|
72
|
+
console.log();
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error(chalk.red(`\n✗ Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return getCommand;
|
|
80
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createDictListCommand } from './list.js';
|
|
3
|
+
import { createDictGetCommand } from './get.js';
|
|
4
|
+
import { createDictDeleteCommand } from './delete.js';
|
|
5
|
+
import { createDictCreateCommand } from './create.js';
|
|
6
|
+
import { createDictUpdateCommand } from './update.js';
|
|
7
|
+
|
|
8
|
+
export function createDictsCommand(): Command {
|
|
9
|
+
const dictsCommand = new Command('dicts');
|
|
10
|
+
dictsCommand.description('Manage dictionary items');
|
|
11
|
+
|
|
12
|
+
dictsCommand.addCommand(createDictListCommand());
|
|
13
|
+
dictsCommand.addCommand(createDictGetCommand());
|
|
14
|
+
dictsCommand.addCommand(createDictDeleteCommand());
|
|
15
|
+
dictsCommand.addCommand(createDictCreateCommand());
|
|
16
|
+
dictsCommand.addCommand(createDictUpdateCommand());
|
|
17
|
+
|
|
18
|
+
return dictsCommand;
|
|
19
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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 { DictItem, DictStatusFlag } from '../../../types/dict.js';
|
|
7
|
+
import { Environment } from '../../../types/index.js';
|
|
8
|
+
|
|
9
|
+
export function createDictListCommand(): Command {
|
|
10
|
+
const listCommand = new Command('list');
|
|
11
|
+
listCommand.description('List dictionary items by type');
|
|
12
|
+
|
|
13
|
+
listCommand
|
|
14
|
+
.requiredOption('-t, --type-code <string>', 'Dict type code (e.g., ID_TYPE, sex)')
|
|
15
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
16
|
+
.option('-s, --size <number>', 'Page size', '20')
|
|
17
|
+
.option('--status <string>', 'Status filter (enable/disable)')
|
|
18
|
+
.option('--json', 'Output as JSON')
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
const outputJson = options.json === true || process.argv.includes('--json');
|
|
21
|
+
|
|
22
|
+
const context = configManager.getCurrentContext();
|
|
23
|
+
const environment = (options.env as Environment) || context.environment;
|
|
24
|
+
const tenant = options.tenant || context.tenant;
|
|
25
|
+
|
|
26
|
+
const typeCode = options.typeCode as string;
|
|
27
|
+
const page = parseInt(options.page as string, 10) - 1;
|
|
28
|
+
const size = parseInt(options.size as string, 10);
|
|
29
|
+
|
|
30
|
+
const params: {
|
|
31
|
+
dictTypeCode: string;
|
|
32
|
+
pageNo: number;
|
|
33
|
+
pageSize: number;
|
|
34
|
+
status?: DictStatusFlag;
|
|
35
|
+
} = { dictTypeCode: typeCode, pageNo: page, pageSize: size };
|
|
36
|
+
|
|
37
|
+
if (options.status !== undefined) {
|
|
38
|
+
const statusVal = (options.status as string).toLowerCase();
|
|
39
|
+
if (statusVal === 'enable' || statusVal === '1') {
|
|
40
|
+
params.status = 1;
|
|
41
|
+
} else if (statusVal === 'disable' || statusVal === '2') {
|
|
42
|
+
params.status = 2;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const response = await apiClient.listDictItems(environment, tenant, params);
|
|
47
|
+
|
|
48
|
+
if (!response.success) {
|
|
49
|
+
console.error(chalk.red(`\n✗ Failed to list dict items: ${response.error?.message || 'Unknown error'}`));
|
|
50
|
+
if (response.error?.code) {
|
|
51
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
52
|
+
}
|
|
53
|
+
console.error();
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const records = (response.data as unknown as DictItem[]) || [];
|
|
58
|
+
|
|
59
|
+
if (!records || records.length === 0) {
|
|
60
|
+
if (outputJson) {
|
|
61
|
+
console.log(JSON.stringify({ success: true, data: { items: [] } }, null, 2));
|
|
62
|
+
} else {
|
|
63
|
+
console.log(chalk.bold('\n📖 Dict Items\n'));
|
|
64
|
+
console.log(chalk.gray(' No dict items found\n'));
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (outputJson) {
|
|
70
|
+
console.log(
|
|
71
|
+
JSON.stringify(
|
|
72
|
+
{
|
|
73
|
+
success: true,
|
|
74
|
+
data: {
|
|
75
|
+
items: records,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
null,
|
|
79
|
+
2
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log(chalk.bold('\n📖 Dict Items\n'));
|
|
86
|
+
|
|
87
|
+
const table = new Table({
|
|
88
|
+
head: [chalk.bold('ID'), chalk.bold('Code'), chalk.bold('Name'), chalk.bold('Sort'), chalk.bold('Status')],
|
|
89
|
+
colWidths: [14, 20, 30, 10, 10],
|
|
90
|
+
style: {
|
|
91
|
+
head: [],
|
|
92
|
+
border: [],
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
for (const item of records) {
|
|
97
|
+
const statusText = item.statusFlag === 1 ? chalk.green('Enable') : chalk.red('Disable');
|
|
98
|
+
table.push([
|
|
99
|
+
item.dictId,
|
|
100
|
+
item.dictCode || '-',
|
|
101
|
+
item.dictName || '-',
|
|
102
|
+
item.sortOrder?.toString() || '-',
|
|
103
|
+
statusText,
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(table.toString());
|
|
108
|
+
console.log();
|
|
109
|
+
console.log(chalk.gray(` Total: ${records.length}`));
|
|
110
|
+
console.log();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return listCommand;
|
|
114
|
+
}
|