@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,214 @@
|
|
|
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 { CalendarQueryParams, CalendarItem } from '../../../types/calendar.js';
|
|
7
|
+
import { Environment } from '../../../types/index.js';
|
|
8
|
+
|
|
9
|
+
function getCurrentYear(): number {
|
|
10
|
+
return new Date().getFullYear();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getCurrentMonth(): number {
|
|
14
|
+
return new Date().getMonth() + 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function formatDate(dateStr: string): string {
|
|
18
|
+
return dateStr;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getDayOfWeek(dateStr: string): string {
|
|
22
|
+
const date = new Date(dateStr);
|
|
23
|
+
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
24
|
+
return days[date.getDay()];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function renderCalendarGrid(data: { [yearMonth: string]: CalendarItem[] }): void {
|
|
28
|
+
const yearMonths = Object.keys(data).sort();
|
|
29
|
+
|
|
30
|
+
for (const yearMonth of yearMonths) {
|
|
31
|
+
const items = data[yearMonth] || [];
|
|
32
|
+
const [year, month] = yearMonth.split('-').map(Number);
|
|
33
|
+
const monthName = new Date(year, month - 1).toLocaleString('default', { month: 'long' });
|
|
34
|
+
|
|
35
|
+
console.log(chalk.bold(`\nπ
${year} ${monthName}\n`));
|
|
36
|
+
|
|
37
|
+
// Build calendar grid
|
|
38
|
+
const calendarGrid: string[][] = [];
|
|
39
|
+
const dayMap: { [day: string]: CalendarItem } = {};
|
|
40
|
+
|
|
41
|
+
for (const item of items) {
|
|
42
|
+
const day = item.calendarDate.split('-')[2];
|
|
43
|
+
dayMap[day] = item;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Header
|
|
47
|
+
calendarGrid.push(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(d => chalk.gray(d)));
|
|
48
|
+
|
|
49
|
+
// Find first day of month
|
|
50
|
+
const firstDay = new Date(year, month - 1, 1).getDay();
|
|
51
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
52
|
+
|
|
53
|
+
let currentRow: string[] = [];
|
|
54
|
+
|
|
55
|
+
// Add empty cells for days before the first day
|
|
56
|
+
for (let i = 0; i < firstDay; i++) {
|
|
57
|
+
currentRow.push(' ');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Add days
|
|
61
|
+
for (let day = 1; day <= daysInMonth; day++) {
|
|
62
|
+
const dayStr = day.toString().padStart(2, '0');
|
|
63
|
+
const item = dayMap[dayStr];
|
|
64
|
+
|
|
65
|
+
if (item) {
|
|
66
|
+
if (item.dateType === 'WORKDAY') {
|
|
67
|
+
currentRow.push(chalk.green('Β·'));
|
|
68
|
+
} else if (item.dateType === 'HOLIDAY' || item.dateType === 'WEEKEND') {
|
|
69
|
+
currentRow.push(chalk.red('H'));
|
|
70
|
+
} else {
|
|
71
|
+
currentRow.push(' ');
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
currentRow.push(' ');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (currentRow.length === 7) {
|
|
78
|
+
calendarGrid.push(currentRow);
|
|
79
|
+
currentRow = [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Add remaining empty cells
|
|
84
|
+
while (currentRow.length > 0 && currentRow.length < 7) {
|
|
85
|
+
currentRow.push(' ');
|
|
86
|
+
}
|
|
87
|
+
if (currentRow.length > 0) {
|
|
88
|
+
calendarGrid.push(currentRow);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Print grid
|
|
92
|
+
const gridTable = new Table({
|
|
93
|
+
style: { border: [], compact: true },
|
|
94
|
+
colWidths: Array(7).fill(4),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
for (const row of calendarGrid) {
|
|
98
|
+
gridTable.push(row);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log(gridTable.toString());
|
|
102
|
+
console.log();
|
|
103
|
+
console.log(chalk.gray(' Β· ') + chalk.green('Workday') + chalk.gray(' H ') + chalk.red('Holiday/Weekend'));
|
|
104
|
+
console.log();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function createCalendarListCommand(): Command {
|
|
109
|
+
const listCommand = new Command('list');
|
|
110
|
+
listCommand.description('List calendar entries (workdays, holidays)');
|
|
111
|
+
|
|
112
|
+
listCommand
|
|
113
|
+
.option('-y, --year <number>', 'Year (required for query)')
|
|
114
|
+
.option('-m, --month <number>', 'Month (required for query)')
|
|
115
|
+
.option('--months <number>', 'Number of months to query', '12')
|
|
116
|
+
.option('--grid', 'Calendar grid view mode')
|
|
117
|
+
.option('--json', 'Output as JSON')
|
|
118
|
+
.action(async (options) => {
|
|
119
|
+
const context = configManager.getCurrentContext();
|
|
120
|
+
const environment = (options.env as Environment) || context.environment;
|
|
121
|
+
const tenant = options.tenant || context.tenant;
|
|
122
|
+
|
|
123
|
+
// Default to current year/month if not provided
|
|
124
|
+
const year = options.year ? parseInt(options.year as string, 10) : getCurrentYear();
|
|
125
|
+
const month = options.month ? parseInt(options.month as string, 10) : getCurrentMonth();
|
|
126
|
+
const months = parseInt(options.months as string, 10);
|
|
127
|
+
|
|
128
|
+
const params: CalendarQueryParams = { year, month, months };
|
|
129
|
+
|
|
130
|
+
const response = await apiClient.listCalendar(environment, tenant, params);
|
|
131
|
+
|
|
132
|
+
if (!response.success) {
|
|
133
|
+
console.error(chalk.red(`\nβ Failed to list calendar: ${response.error?.message || 'Unknown error'}`));
|
|
134
|
+
if (response.error?.code) {
|
|
135
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
136
|
+
}
|
|
137
|
+
console.error();
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const data = response.data;
|
|
142
|
+
|
|
143
|
+
if (!data) {
|
|
144
|
+
if (options.json) {
|
|
145
|
+
console.log(JSON.stringify({ success: true, data: {} }, null, 2));
|
|
146
|
+
} else {
|
|
147
|
+
console.log(chalk.bold('\nπ
Calendar\n'));
|
|
148
|
+
console.log(chalk.gray(' No calendar data found\n'));
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (options.json) {
|
|
154
|
+
console.log(JSON.stringify({ success: true, data }, null, 2));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (options.grid) {
|
|
159
|
+
renderCalendarGrid(data);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Table output mode
|
|
164
|
+
const allItems: CalendarItem[] = [];
|
|
165
|
+
for (const yearMonth of Object.keys(data)) {
|
|
166
|
+
const items = data[yearMonth] || [];
|
|
167
|
+
allItems.push(...items);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (allItems.length === 0) {
|
|
171
|
+
console.log(chalk.bold('\nπ
Calendar\n'));
|
|
172
|
+
console.log(chalk.gray(' No calendar data found\n'));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
console.log(chalk.bold('\nπ
Calendar\n'));
|
|
177
|
+
|
|
178
|
+
const table = new Table({
|
|
179
|
+
head: [chalk.bold('Date'), chalk.bold('Day'), chalk.bold('Type'), chalk.bold('Remark')],
|
|
180
|
+
colWidths: [12, 8, 12, 30],
|
|
181
|
+
style: {
|
|
182
|
+
head: [],
|
|
183
|
+
border: [],
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
for (const item of allItems) {
|
|
188
|
+
const dayType = item.dateType;
|
|
189
|
+
let typeText: string;
|
|
190
|
+
|
|
191
|
+
if (dayType === 'WORKDAY') {
|
|
192
|
+
typeText = chalk.green('WORKDAY');
|
|
193
|
+
} else if (dayType === 'HOLIDAY') {
|
|
194
|
+
typeText = chalk.red('HOLIDAY');
|
|
195
|
+
} else if (dayType === 'WEEKEND') {
|
|
196
|
+
typeText = chalk.red('WEEKEND');
|
|
197
|
+
} else {
|
|
198
|
+
typeText = dayType;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
table.push([
|
|
202
|
+
formatDate(item.calendarDate),
|
|
203
|
+
getDayOfWeek(item.calendarDate),
|
|
204
|
+
typeText,
|
|
205
|
+
item.remark || '-',
|
|
206
|
+
]);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
console.log(table.toString());
|
|
210
|
+
console.log();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return listCommand;
|
|
214
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
4
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
+
import { CalendarSetRequest, DateType } from '../../../types/calendar.js';
|
|
6
|
+
|
|
7
|
+
const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
8
|
+
const DATE_TYPE_REGEX = /^(WORKDAY|WEEKEND|HOLIDAY)$/;
|
|
9
|
+
|
|
10
|
+
function validateFields(data: CalendarSetRequest): string | null {
|
|
11
|
+
if (!DATE_REGEX.test(data.calendarDate)) {
|
|
12
|
+
return 'Invalid date format. Date must be in YYYY-MM-DD format.';
|
|
13
|
+
}
|
|
14
|
+
if (!DATE_TYPE_REGEX.test(data.dateType)) {
|
|
15
|
+
return 'Invalid date type. Must be WORKDAY, WEEKEND, or HOLIDAY.';
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function formatTable(data: CalendarSetRequest): string {
|
|
21
|
+
const lines: string[] = [];
|
|
22
|
+
lines.push(` ${chalk.gray('Date:')} ${data.calendarDate}`);
|
|
23
|
+
lines.push(` ${chalk.gray('Type:')} ${data.dateType}`);
|
|
24
|
+
if (data.remark) lines.push(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
25
|
+
return lines.join('\n');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createCalendarSetCommand(): Command {
|
|
29
|
+
const cmd = new Command('set');
|
|
30
|
+
cmd.description('Set calendar date type');
|
|
31
|
+
|
|
32
|
+
cmd
|
|
33
|
+
.option('-d, --date <date>', 'Date to set (YYYY-MM-DD, required)')
|
|
34
|
+
.option('-t, --type <type>', 'Date type (WORKDAY|WEEKEND|HOLIDAY, required)')
|
|
35
|
+
.option('-r, --remark <text>', 'Remark/note')
|
|
36
|
+
.option('--dry-run', 'Preview without making API call')
|
|
37
|
+
.option('--json', 'Output as JSON');
|
|
38
|
+
|
|
39
|
+
cmd.action(async () => {
|
|
40
|
+
const context = configManager.getCurrentContext();
|
|
41
|
+
const opts = cmd.opts();
|
|
42
|
+
|
|
43
|
+
const date = opts.date as string | undefined;
|
|
44
|
+
const type = opts.type as string | undefined;
|
|
45
|
+
const remark = opts.remark as string | undefined;
|
|
46
|
+
const dryRun = opts.dryRun === true;
|
|
47
|
+
const jsonOutput = opts.json === true;
|
|
48
|
+
|
|
49
|
+
// Validate required options
|
|
50
|
+
if (!date) {
|
|
51
|
+
if (jsonOutput) {
|
|
52
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'Date is required. Use --date (or -d).' } }));
|
|
53
|
+
} else {
|
|
54
|
+
console.error(chalk.red('\nβ Date is required. Use --date (or -d).\n'));
|
|
55
|
+
}
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!type) {
|
|
60
|
+
if (jsonOutput) {
|
|
61
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'Date type is required. Use --type (or -t).' } }));
|
|
62
|
+
} else {
|
|
63
|
+
console.error(chalk.red('\nβ Date type is required. Use --type (or -t).\n'));
|
|
64
|
+
}
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const data: CalendarSetRequest = {
|
|
69
|
+
calendarDate: date,
|
|
70
|
+
dateType: type as DateType,
|
|
71
|
+
remark,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Validate fields
|
|
75
|
+
const validationError = validateFields(data);
|
|
76
|
+
if (validationError) {
|
|
77
|
+
if (jsonOutput) {
|
|
78
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: validationError } }));
|
|
79
|
+
} else {
|
|
80
|
+
console.error(chalk.red(`\nβ ${validationError}\n`));
|
|
81
|
+
}
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (dryRun) {
|
|
86
|
+
if (jsonOutput) {
|
|
87
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
88
|
+
} else {
|
|
89
|
+
console.log(chalk.bold('\nπ Dry-Run Mode: No changes will be made\n'));
|
|
90
|
+
console.log(' Calendar to be updated:');
|
|
91
|
+
console.log(formatTable(data));
|
|
92
|
+
console.log();
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!jsonOutput) {
|
|
98
|
+
console.log(chalk.bold('\nπ Updating Calendar\n'));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const response = await apiClient.setCalendar(context.environment, context.tenant, data);
|
|
102
|
+
|
|
103
|
+
if (!response.success) {
|
|
104
|
+
const errorMsg = response.error?.message || 'Failed to update calendar';
|
|
105
|
+
const errorCode = response.error?.code || 'SET_CALENDAR_ERROR';
|
|
106
|
+
if (jsonOutput) {
|
|
107
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
108
|
+
} else {
|
|
109
|
+
console.error(chalk.red(`\nβ Failed to update calendar: ${errorMsg}`));
|
|
110
|
+
if (response.error?.code) {
|
|
111
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
112
|
+
}
|
|
113
|
+
console.error();
|
|
114
|
+
}
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (jsonOutput) {
|
|
119
|
+
console.log(JSON.stringify({ success: true, data: { calendarDate: data.calendarDate, dateType: data.dateType, remark: data.remark } }));
|
|
120
|
+
} else {
|
|
121
|
+
console.log(chalk.green(`β Calendar updated: ${data.calendarDate} -> ${data.dateType}\n`));
|
|
122
|
+
if (data.remark) {
|
|
123
|
+
console.log(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
124
|
+
}
|
|
125
|
+
console.log();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return cmd;
|
|
130
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
4
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
+
import { CreateClientContactRequest } from '../../../types/client-contact.js';
|
|
6
|
+
|
|
7
|
+
export function createClientContactCreateCommand(): Command {
|
|
8
|
+
const cmd = new Command('create');
|
|
9
|
+
cmd.description('Create a new client contact');
|
|
10
|
+
|
|
11
|
+
cmd
|
|
12
|
+
.requiredOption('-c, --client-id <string>', 'Client ID (required)')
|
|
13
|
+
.requiredOption('-n, --name <string>', 'Contact name (required)')
|
|
14
|
+
.option('-p, --phone <string>', 'Mobile phone')
|
|
15
|
+
.option('-t, --telephone <string>', 'Telephone')
|
|
16
|
+
.option('-e, --email <string>', 'Email')
|
|
17
|
+
.option('-s, --sex <string>', 'Sex')
|
|
18
|
+
.option('-b, --birthday <string>', 'Birthday (YYYY-MM-DD)')
|
|
19
|
+
.option('-q, --qq <string>', 'QQ number')
|
|
20
|
+
.option('-w, --wechat <string>', 'WeChat ID')
|
|
21
|
+
.option('-a, --address <string>', 'Address')
|
|
22
|
+
.option('-d, --default', 'Set as default contact')
|
|
23
|
+
.option('-r, --remark <string>', 'Remark')
|
|
24
|
+
.option('--dry-run', 'Preview the operation without executing')
|
|
25
|
+
.option('--json', 'Output as JSON')
|
|
26
|
+
.action(async (options: Record<string, unknown>) => {
|
|
27
|
+
const context = configManager.getCurrentContext();
|
|
28
|
+
const environment = context.environment;
|
|
29
|
+
const tenant = context.tenant;
|
|
30
|
+
const jsonOutput = options.json === true;
|
|
31
|
+
|
|
32
|
+
const clientId = options.clientId as string;
|
|
33
|
+
const clientContactName = options.name as string;
|
|
34
|
+
|
|
35
|
+
const data: CreateClientContactRequest = {
|
|
36
|
+
clientId,
|
|
37
|
+
clientContactName,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (options.phone) data.clientContactPhone = options.phone as string;
|
|
41
|
+
if (options.telephone) data.clientContactTelephone = options.telephone as string;
|
|
42
|
+
if (options.email) data.clientContactEmail = options.email as string;
|
|
43
|
+
if (options.sex) data.clientContactSex = options.sex as string;
|
|
44
|
+
if (options.birthday) data.clientContactBirthday = options.birthday as string;
|
|
45
|
+
if (options.qq) data.clientContactQq = options.qq as string;
|
|
46
|
+
if (options.wechat) data.clientContactWechat = options.wechat as string;
|
|
47
|
+
if (options.address) data.clientContactAddress = options.address as string;
|
|
48
|
+
if (options.default) data.defaultFlag = 'Y';
|
|
49
|
+
if (options.remark) data.remark = options.remark as string;
|
|
50
|
+
|
|
51
|
+
if (options.dryRun) {
|
|
52
|
+
if (jsonOutput) {
|
|
53
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
54
|
+
} else {
|
|
55
|
+
console.log(chalk.cyan('\nπ Dry-Run Mode: No actual API call will be made\n'));
|
|
56
|
+
console.log(chalk.gray(' This operation will create the following client contact:'));
|
|
57
|
+
console.log(` ${chalk.gray('Client ID:')} ${clientId}`);
|
|
58
|
+
console.log(` ${chalk.gray('Name:')} ${clientContactName}`);
|
|
59
|
+
if (data.clientContactPhone) console.log(` ${chalk.gray('Phone:')} ${data.clientContactPhone}`);
|
|
60
|
+
if (data.clientContactTelephone) console.log(` ${chalk.gray('Telephone:')} ${data.clientContactTelephone}`);
|
|
61
|
+
if (data.clientContactEmail) console.log(` ${chalk.gray('Email:')} ${data.clientContactEmail}`);
|
|
62
|
+
if (data.clientContactSex) console.log(` ${chalk.gray('Sex:')} ${data.clientContactSex}`);
|
|
63
|
+
if (data.clientContactBirthday) console.log(` ${chalk.gray('Birthday:')} ${data.clientContactBirthday}`);
|
|
64
|
+
if (data.clientContactQq) console.log(` ${chalk.gray('QQ:')} ${data.clientContactQq}`);
|
|
65
|
+
if (data.clientContactWechat) console.log(` ${chalk.gray('WeChat:')} ${data.clientContactWechat}`);
|
|
66
|
+
if (data.clientContactAddress) console.log(` ${chalk.gray('Address:')} ${data.clientContactAddress}`);
|
|
67
|
+
if (data.defaultFlag) console.log(` ${chalk.gray('Default:')} ${data.defaultFlag}`);
|
|
68
|
+
if (data.remark) console.log(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
69
|
+
console.log();
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
const response = await apiClient.createClientContact(environment, tenant, data);
|
|
76
|
+
|
|
77
|
+
if (response.success) {
|
|
78
|
+
if (jsonOutput) {
|
|
79
|
+
console.log(JSON.stringify({ success: true, data: response.data }));
|
|
80
|
+
} else {
|
|
81
|
+
console.log(chalk.green('\nβ Client contact created successfully\n'));
|
|
82
|
+
if (response.data && typeof response.data === 'object' && 'clientContactId' in response.data) {
|
|
83
|
+
console.log(` ${chalk.gray('Contact ID:')} ${chalk.green(String((response.data as { clientContactId: string }).clientContactId))}`);
|
|
84
|
+
}
|
|
85
|
+
console.log(` ${chalk.gray('Client ID:')} ${clientId}`);
|
|
86
|
+
console.log(` ${chalk.gray('Name:')} ${clientContactName}`);
|
|
87
|
+
console.log();
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
const errorMsg = response.error?.message || 'Failed to create client contact';
|
|
91
|
+
const errorCode = response.error?.code || 'CREATE_CLIENT_CONTACT_ERROR';
|
|
92
|
+
if (jsonOutput) {
|
|
93
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
94
|
+
} else {
|
|
95
|
+
console.error(chalk.red(`\nβ Failed to create client contact: ${errorMsg}`));
|
|
96
|
+
if (response.error?.code) {
|
|
97
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
98
|
+
}
|
|
99
|
+
console.error();
|
|
100
|
+
}
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
105
|
+
if (jsonOutput) {
|
|
106
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
107
|
+
} else {
|
|
108
|
+
console.error(chalk.red(`\nβ Error: ${errMsg}\n`));
|
|
109
|
+
}
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return cmd;
|
|
115
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
4
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
5
|
+
import { Environment } from '../../../types/index.js';
|
|
6
|
+
import { ClientContact } from '../../../types/client-contact.js';
|
|
7
|
+
|
|
8
|
+
export function createClientContactDeleteCommand(): Command {
|
|
9
|
+
const cmd = new Command('delete');
|
|
10
|
+
cmd.description('Delete a client contact');
|
|
11
|
+
|
|
12
|
+
cmd
|
|
13
|
+
.arguments('<contact-id>')
|
|
14
|
+
.option('--force', 'Skip confirmation and actually delete')
|
|
15
|
+
.option('--dry-run', 'Preview the operation (default)')
|
|
16
|
+
.option('--json', 'Output as JSON')
|
|
17
|
+
.action(async (contactId: string, options: Record<string, unknown>) => {
|
|
18
|
+
const context = configManager.getCurrentContext();
|
|
19
|
+
const environment = context.environment as Environment;
|
|
20
|
+
const tenant = context.tenant;
|
|
21
|
+
const jsonOutput = options.json === true;
|
|
22
|
+
|
|
23
|
+
if (!contactId || contactId.trim() === '') {
|
|
24
|
+
if (jsonOutput) {
|
|
25
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'contact-id is required' } }));
|
|
26
|
+
} else {
|
|
27
|
+
console.error(chalk.red('\nβ Contact ID is required\n'));
|
|
28
|
+
}
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!jsonOutput) {
|
|
33
|
+
console.log(chalk.bold(`\nποΈ Delete Client Contact (${environment})\n`));
|
|
34
|
+
console.log(chalk.gray(` Contact ID: ${contactId}`));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let contact: ClientContact | undefined;
|
|
38
|
+
try {
|
|
39
|
+
const contactResponse = await apiClient.getClientContact(environment, tenant, contactId);
|
|
40
|
+
if (!contactResponse.success || !contactResponse.data) {
|
|
41
|
+
const errMsg = `Client contact not found: ${contactId}`;
|
|
42
|
+
if (jsonOutput) {
|
|
43
|
+
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: errMsg } }));
|
|
44
|
+
} else {
|
|
45
|
+
console.error(chalk.red(`\nβ ${errMsg}\n`));
|
|
46
|
+
}
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
contact = contactResponse.data as ClientContact;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
52
|
+
if (jsonOutput) {
|
|
53
|
+
console.log(JSON.stringify({ success: false, error: { code: 'FETCH_ERROR', message: `Failed to fetch client contact: ${errMsg}` } }));
|
|
54
|
+
} else {
|
|
55
|
+
console.error(chalk.red(`\nβ Failed to fetch client contact: ${errMsg}\n`));
|
|
56
|
+
}
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!jsonOutput && contact) {
|
|
61
|
+
console.log(chalk.gray(` Name: ${contact.clientContactName}`));
|
|
62
|
+
console.log(chalk.gray(` Client ID: ${contact.clientId}`));
|
|
63
|
+
if (contact.clientContactPhone) {
|
|
64
|
+
console.log(chalk.gray(` Phone: ${contact.clientContactPhone}`));
|
|
65
|
+
}
|
|
66
|
+
if (contact.clientContactEmail) {
|
|
67
|
+
console.log(chalk.gray(` Email: ${contact.clientContactEmail}`));
|
|
68
|
+
}
|
|
69
|
+
if (contact.defaultFlag === 'Y') {
|
|
70
|
+
console.log(chalk.gray(` Default: Yes`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const isDryRun = !options.force;
|
|
75
|
+
|
|
76
|
+
if (isDryRun) {
|
|
77
|
+
if (jsonOutput) {
|
|
78
|
+
console.log(JSON.stringify({
|
|
79
|
+
success: true,
|
|
80
|
+
dryRun: true,
|
|
81
|
+
message: 'Dry-Run Mode: No actual API call will be made',
|
|
82
|
+
data: { clientContactId: contactId, contact }
|
|
83
|
+
}));
|
|
84
|
+
} else {
|
|
85
|
+
console.log(chalk.cyan('\nπ Dry-Run Mode: No actual API call will be made\n'));
|
|
86
|
+
console.log(chalk.yellow(' β οΈ Add --force option to confirm deletion'));
|
|
87
|
+
console.log();
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
const response = await apiClient.deleteClientContact(environment, tenant, contactId);
|
|
94
|
+
|
|
95
|
+
if (response.success) {
|
|
96
|
+
if (jsonOutput) {
|
|
97
|
+
console.log(JSON.stringify({ success: true, data: { clientContactId: contactId, contactName: contact.clientContactName } }));
|
|
98
|
+
} else {
|
|
99
|
+
console.log(chalk.green('\nβ Client contact deleted successfully\n'));
|
|
100
|
+
console.log(` ${chalk.gray('Contact ID:')} ${chalk.green(contactId)}`);
|
|
101
|
+
console.log(` ${chalk.gray('Name:')} ${chalk.green(contact.clientContactName)}`);
|
|
102
|
+
console.log();
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
const errorMsg = response.error?.message || 'Failed to delete client contact';
|
|
106
|
+
const errorCode = response.error?.code || 'DELETE_ERROR';
|
|
107
|
+
|
|
108
|
+
// Handle "not found" error (should not happen since we already fetched)
|
|
109
|
+
if (errorCode === '01001207001' || errorMsg.includes('δΈεε¨')) {
|
|
110
|
+
if (jsonOutput) {
|
|
111
|
+
console.log(JSON.stringify({ success: false, error: { code: 'NOT_FOUND', message: `Client contact not found: ${contactId}` } }));
|
|
112
|
+
} else {
|
|
113
|
+
console.error(chalk.red(`\nβ Client contact not found: ${contactId}\n`));
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
if (jsonOutput) {
|
|
117
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
118
|
+
} else {
|
|
119
|
+
console.error(chalk.red(`\nβ Failed to delete client contact: ${errorMsg}`));
|
|
120
|
+
if (response.error?.code) {
|
|
121
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
122
|
+
}
|
|
123
|
+
console.error();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
130
|
+
if (jsonOutput) {
|
|
131
|
+
console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
|
|
132
|
+
} else {
|
|
133
|
+
console.error(chalk.red(`\nβ Error: ${errMsg}\n`));
|
|
134
|
+
}
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return cmd;
|
|
140
|
+
}
|