@optima-chat/commerce-cli 1.0.0
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/.claude/CLAUDE.md +101 -0
- package/LICENSE +21 -0
- package/README.md +1132 -0
- package/dist/api/rest/auth.d.ts +56 -0
- package/dist/api/rest/auth.d.ts.map +1 -0
- package/dist/api/rest/auth.js +150 -0
- package/dist/api/rest/auth.js.map +1 -0
- package/dist/api/rest/base.d.ts +7 -0
- package/dist/api/rest/base.d.ts.map +1 -0
- package/dist/api/rest/base.js +51 -0
- package/dist/api/rest/base.js.map +1 -0
- package/dist/api/rest/commerce.d.ts +730 -0
- package/dist/api/rest/commerce.d.ts.map +1 -0
- package/dist/api/rest/commerce.js +935 -0
- package/dist/api/rest/commerce.js.map +1 -0
- package/dist/commands/auth/index.d.ts +3 -0
- package/dist/commands/auth/index.d.ts.map +1 -0
- package/dist/commands/auth/index.js +14 -0
- package/dist/commands/auth/index.js.map +1 -0
- package/dist/commands/auth/login.d.ts +3 -0
- package/dist/commands/auth/login.d.ts.map +1 -0
- package/dist/commands/auth/login.js +194 -0
- package/dist/commands/auth/login.js.map +1 -0
- package/dist/commands/auth/logout.d.ts +3 -0
- package/dist/commands/auth/logout.d.ts.map +1 -0
- package/dist/commands/auth/logout.js +126 -0
- package/dist/commands/auth/logout.js.map +1 -0
- package/dist/commands/auth/switch.d.ts +3 -0
- package/dist/commands/auth/switch.d.ts.map +1 -0
- package/dist/commands/auth/switch.js +111 -0
- package/dist/commands/auth/switch.js.map +1 -0
- package/dist/commands/auth/test-refresh.d.ts +3 -0
- package/dist/commands/auth/test-refresh.d.ts.map +1 -0
- package/dist/commands/auth/test-refresh.js +43 -0
- package/dist/commands/auth/test-refresh.js.map +1 -0
- package/dist/commands/auth/whoami.d.ts +3 -0
- package/dist/commands/auth/whoami.d.ts.map +1 -0
- package/dist/commands/auth/whoami.js +117 -0
- package/dist/commands/auth/whoami.js.map +1 -0
- package/dist/commands/cleanup.d.ts +3 -0
- package/dist/commands/cleanup.d.ts.map +1 -0
- package/dist/commands/cleanup.js +100 -0
- package/dist/commands/cleanup.js.map +1 -0
- package/dist/commands/collection/add-products.d.ts +3 -0
- package/dist/commands/collection/add-products.d.ts.map +1 -0
- package/dist/commands/collection/add-products.js +105 -0
- package/dist/commands/collection/add-products.js.map +1 -0
- package/dist/commands/collection/create.d.ts +3 -0
- package/dist/commands/collection/create.d.ts.map +1 -0
- package/dist/commands/collection/create.js +154 -0
- package/dist/commands/collection/create.js.map +1 -0
- package/dist/commands/collection/delete.d.ts +3 -0
- package/dist/commands/collection/delete.d.ts.map +1 -0
- package/dist/commands/collection/delete.js +83 -0
- package/dist/commands/collection/delete.js.map +1 -0
- package/dist/commands/collection/get.d.ts +3 -0
- package/dist/commands/collection/get.d.ts.map +1 -0
- package/dist/commands/collection/get.js +83 -0
- package/dist/commands/collection/get.js.map +1 -0
- package/dist/commands/collection/index.d.ts +4 -0
- package/dist/commands/collection/index.d.ts.map +1 -0
- package/dist/commands/collection/index.js +22 -0
- package/dist/commands/collection/index.js.map +1 -0
- package/dist/commands/collection/list-products.d.ts +3 -0
- package/dist/commands/collection/list-products.d.ts.map +1 -0
- package/dist/commands/collection/list-products.js +100 -0
- package/dist/commands/collection/list-products.js.map +1 -0
- package/dist/commands/collection/list.d.ts +3 -0
- package/dist/commands/collection/list.d.ts.map +1 -0
- package/dist/commands/collection/list.js +98 -0
- package/dist/commands/collection/list.js.map +1 -0
- package/dist/commands/collection/remove-products.d.ts +3 -0
- package/dist/commands/collection/remove-products.d.ts.map +1 -0
- package/dist/commands/collection/remove-products.js +128 -0
- package/dist/commands/collection/remove-products.js.map +1 -0
- package/dist/commands/collection/update.d.ts +3 -0
- package/dist/commands/collection/update.d.ts.map +1 -0
- package/dist/commands/collection/update.js +166 -0
- package/dist/commands/collection/update.js.map +1 -0
- package/dist/commands/conversation/close.d.ts +3 -0
- package/dist/commands/conversation/close.d.ts.map +1 -0
- package/dist/commands/conversation/close.js +70 -0
- package/dist/commands/conversation/close.js.map +1 -0
- package/dist/commands/conversation/create.d.ts +3 -0
- package/dist/commands/conversation/create.d.ts.map +1 -0
- package/dist/commands/conversation/create.js +153 -0
- package/dist/commands/conversation/create.js.map +1 -0
- package/dist/commands/conversation/get.d.ts +3 -0
- package/dist/commands/conversation/get.d.ts.map +1 -0
- package/dist/commands/conversation/get.js +128 -0
- package/dist/commands/conversation/get.js.map +1 -0
- package/dist/commands/conversation/index.d.ts +3 -0
- package/dist/commands/conversation/index.d.ts.map +1 -0
- package/dist/commands/conversation/index.js +19 -0
- package/dist/commands/conversation/index.js.map +1 -0
- package/dist/commands/conversation/list.d.ts +3 -0
- package/dist/commands/conversation/list.d.ts.map +1 -0
- package/dist/commands/conversation/list.js +129 -0
- package/dist/commands/conversation/list.js.map +1 -0
- package/dist/commands/conversation/mark-read.d.ts +3 -0
- package/dist/commands/conversation/mark-read.d.ts.map +1 -0
- package/dist/commands/conversation/mark-read.js +69 -0
- package/dist/commands/conversation/mark-read.js.map +1 -0
- package/dist/commands/conversation/messages.d.ts +3 -0
- package/dist/commands/conversation/messages.d.ts.map +1 -0
- package/dist/commands/conversation/messages.js +128 -0
- package/dist/commands/conversation/messages.js.map +1 -0
- package/dist/commands/conversation/send.d.ts +3 -0
- package/dist/commands/conversation/send.d.ts.map +1 -0
- package/dist/commands/conversation/send.js +100 -0
- package/dist/commands/conversation/send.js.map +1 -0
- package/dist/commands/homepage/create.d.ts +3 -0
- package/dist/commands/homepage/create.d.ts.map +1 -0
- package/dist/commands/homepage/create.js +150 -0
- package/dist/commands/homepage/create.js.map +1 -0
- package/dist/commands/homepage/delete.d.ts +3 -0
- package/dist/commands/homepage/delete.d.ts.map +1 -0
- package/dist/commands/homepage/delete.js +83 -0
- package/dist/commands/homepage/delete.js.map +1 -0
- package/dist/commands/homepage/get.d.ts +3 -0
- package/dist/commands/homepage/get.d.ts.map +1 -0
- package/dist/commands/homepage/get.js +96 -0
- package/dist/commands/homepage/get.js.map +1 -0
- package/dist/commands/homepage/index.d.ts +4 -0
- package/dist/commands/homepage/index.d.ts.map +1 -0
- package/dist/commands/homepage/index.js +26 -0
- package/dist/commands/homepage/index.js.map +1 -0
- package/dist/commands/homepage/list.d.ts +3 -0
- package/dist/commands/homepage/list.d.ts.map +1 -0
- package/dist/commands/homepage/list.js +101 -0
- package/dist/commands/homepage/list.js.map +1 -0
- package/dist/commands/homepage/patch-settings.d.ts +3 -0
- package/dist/commands/homepage/patch-settings.d.ts.map +1 -0
- package/dist/commands/homepage/patch-settings.js +109 -0
- package/dist/commands/homepage/patch-settings.js.map +1 -0
- package/dist/commands/homepage/reorder.d.ts +3 -0
- package/dist/commands/homepage/reorder.d.ts.map +1 -0
- package/dist/commands/homepage/reorder.js +99 -0
- package/dist/commands/homepage/reorder.js.map +1 -0
- package/dist/commands/homepage/update-collections.d.ts +3 -0
- package/dist/commands/homepage/update-collections.d.ts.map +1 -0
- package/dist/commands/homepage/update-collections.js +93 -0
- package/dist/commands/homepage/update-collections.js.map +1 -0
- package/dist/commands/homepage/update-images.d.ts +3 -0
- package/dist/commands/homepage/update-images.d.ts.map +1 -0
- package/dist/commands/homepage/update-images.js +129 -0
- package/dist/commands/homepage/update-images.js.map +1 -0
- package/dist/commands/homepage/update-target.d.ts +3 -0
- package/dist/commands/homepage/update-target.d.ts.map +1 -0
- package/dist/commands/homepage/update-target.js +94 -0
- package/dist/commands/homepage/update-target.js.map +1 -0
- package/dist/commands/homepage/update.d.ts +3 -0
- package/dist/commands/homepage/update.d.ts.map +1 -0
- package/dist/commands/homepage/update.js +109 -0
- package/dist/commands/homepage/update.js.map +1 -0
- package/dist/commands/i18n/collection/create.d.ts +3 -0
- package/dist/commands/i18n/collection/create.d.ts.map +1 -0
- package/dist/commands/i18n/collection/create.js +147 -0
- package/dist/commands/i18n/collection/create.js.map +1 -0
- package/dist/commands/i18n/collection/delete.d.ts +3 -0
- package/dist/commands/i18n/collection/delete.d.ts.map +1 -0
- package/dist/commands/i18n/collection/delete.js +82 -0
- package/dist/commands/i18n/collection/delete.js.map +1 -0
- package/dist/commands/i18n/collection/get.d.ts +3 -0
- package/dist/commands/i18n/collection/get.d.ts.map +1 -0
- package/dist/commands/i18n/collection/get.js +85 -0
- package/dist/commands/i18n/collection/get.js.map +1 -0
- package/dist/commands/i18n/collection/index.d.ts +3 -0
- package/dist/commands/i18n/collection/index.d.ts.map +1 -0
- package/dist/commands/i18n/collection/index.js +14 -0
- package/dist/commands/i18n/collection/index.js.map +1 -0
- package/dist/commands/i18n/collection/list.d.ts +3 -0
- package/dist/commands/i18n/collection/list.d.ts.map +1 -0
- package/dist/commands/i18n/collection/list.js +89 -0
- package/dist/commands/i18n/collection/list.js.map +1 -0
- package/dist/commands/i18n/collection/update.d.ts +3 -0
- package/dist/commands/i18n/collection/update.d.ts.map +1 -0
- package/dist/commands/i18n/collection/update.js +108 -0
- package/dist/commands/i18n/collection/update.js.map +1 -0
- package/dist/commands/i18n/homepage/delete.d.ts +3 -0
- package/dist/commands/i18n/homepage/delete.d.ts.map +1 -0
- package/dist/commands/i18n/homepage/delete.js +90 -0
- package/dist/commands/i18n/homepage/delete.js.map +1 -0
- package/dist/commands/i18n/homepage/index.d.ts +4 -0
- package/dist/commands/i18n/homepage/index.d.ts.map +1 -0
- package/dist/commands/i18n/homepage/index.js +10 -0
- package/dist/commands/i18n/homepage/index.js.map +1 -0
- package/dist/commands/i18n/homepage/list.d.ts +3 -0
- package/dist/commands/i18n/homepage/list.d.ts.map +1 -0
- package/dist/commands/i18n/homepage/list.js +85 -0
- package/dist/commands/i18n/homepage/list.js.map +1 -0
- package/dist/commands/i18n/homepage/set.d.ts +3 -0
- package/dist/commands/i18n/homepage/set.d.ts.map +1 -0
- package/dist/commands/i18n/homepage/set.js +157 -0
- package/dist/commands/i18n/homepage/set.js.map +1 -0
- package/dist/commands/i18n/index.d.ts +3 -0
- package/dist/commands/i18n/index.d.ts.map +1 -0
- package/dist/commands/i18n/index.js +16 -0
- package/dist/commands/i18n/index.js.map +1 -0
- package/dist/commands/i18n/languages.d.ts +3 -0
- package/dist/commands/i18n/languages.d.ts.map +1 -0
- package/dist/commands/i18n/languages.js +90 -0
- package/dist/commands/i18n/languages.js.map +1 -0
- package/dist/commands/i18n/merchant/create.d.ts +3 -0
- package/dist/commands/i18n/merchant/create.d.ts.map +1 -0
- package/dist/commands/i18n/merchant/create.js +107 -0
- package/dist/commands/i18n/merchant/create.js.map +1 -0
- package/dist/commands/i18n/merchant/delete.d.ts +3 -0
- package/dist/commands/i18n/merchant/delete.d.ts.map +1 -0
- package/dist/commands/i18n/merchant/delete.js +57 -0
- package/dist/commands/i18n/merchant/delete.js.map +1 -0
- package/dist/commands/i18n/merchant/index.d.ts +3 -0
- package/dist/commands/i18n/merchant/index.d.ts.map +1 -0
- package/dist/commands/i18n/merchant/index.js +12 -0
- package/dist/commands/i18n/merchant/index.js.map +1 -0
- package/dist/commands/i18n/merchant/list.d.ts +3 -0
- package/dist/commands/i18n/merchant/list.d.ts.map +1 -0
- package/dist/commands/i18n/merchant/list.js +65 -0
- package/dist/commands/i18n/merchant/list.js.map +1 -0
- package/dist/commands/i18n/merchant/update.d.ts +3 -0
- package/dist/commands/i18n/merchant/update.d.ts.map +1 -0
- package/dist/commands/i18n/merchant/update.js +62 -0
- package/dist/commands/i18n/merchant/update.js.map +1 -0
- package/dist/commands/i18n/product/create.d.ts +3 -0
- package/dist/commands/i18n/product/create.d.ts.map +1 -0
- package/dist/commands/i18n/product/create.js +142 -0
- package/dist/commands/i18n/product/create.js.map +1 -0
- package/dist/commands/i18n/product/delete.d.ts +3 -0
- package/dist/commands/i18n/product/delete.d.ts.map +1 -0
- package/dist/commands/i18n/product/delete.js +67 -0
- package/dist/commands/i18n/product/delete.js.map +1 -0
- package/dist/commands/i18n/product/get.d.ts +3 -0
- package/dist/commands/i18n/product/get.d.ts.map +1 -0
- package/dist/commands/i18n/product/get.js +69 -0
- package/dist/commands/i18n/product/get.js.map +1 -0
- package/dist/commands/i18n/product/index.d.ts +3 -0
- package/dist/commands/i18n/product/index.d.ts.map +1 -0
- package/dist/commands/i18n/product/index.js +14 -0
- package/dist/commands/i18n/product/index.js.map +1 -0
- package/dist/commands/i18n/product/list.d.ts +3 -0
- package/dist/commands/i18n/product/list.d.ts.map +1 -0
- package/dist/commands/i18n/product/list.js +88 -0
- package/dist/commands/i18n/product/list.js.map +1 -0
- package/dist/commands/i18n/product/update.d.ts +3 -0
- package/dist/commands/i18n/product/update.d.ts.map +1 -0
- package/dist/commands/i18n/product/update.js +75 -0
- package/dist/commands/i18n/product/update.js.map +1 -0
- package/dist/commands/i18n/variant/create.d.ts +3 -0
- package/dist/commands/i18n/variant/create.d.ts.map +1 -0
- package/dist/commands/i18n/variant/create.js +179 -0
- package/dist/commands/i18n/variant/create.js.map +1 -0
- package/dist/commands/i18n/variant/delete.d.ts +3 -0
- package/dist/commands/i18n/variant/delete.d.ts.map +1 -0
- package/dist/commands/i18n/variant/delete.js +91 -0
- package/dist/commands/i18n/variant/delete.js.map +1 -0
- package/dist/commands/i18n/variant/get.d.ts +3 -0
- package/dist/commands/i18n/variant/get.d.ts.map +1 -0
- package/dist/commands/i18n/variant/get.js +75 -0
- package/dist/commands/i18n/variant/get.js.map +1 -0
- package/dist/commands/i18n/variant/index.d.ts +3 -0
- package/dist/commands/i18n/variant/index.d.ts.map +1 -0
- package/dist/commands/i18n/variant/index.js +14 -0
- package/dist/commands/i18n/variant/index.js.map +1 -0
- package/dist/commands/i18n/variant/list.d.ts +3 -0
- package/dist/commands/i18n/variant/list.d.ts.map +1 -0
- package/dist/commands/i18n/variant/list.js +79 -0
- package/dist/commands/i18n/variant/list.js.map +1 -0
- package/dist/commands/i18n/variant/update.d.ts +3 -0
- package/dist/commands/i18n/variant/update.d.ts.map +1 -0
- package/dist/commands/i18n/variant/update.js +113 -0
- package/dist/commands/i18n/variant/update.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +98 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inventory/history.d.ts +3 -0
- package/dist/commands/inventory/history.d.ts.map +1 -0
- package/dist/commands/inventory/history.js +133 -0
- package/dist/commands/inventory/history.js.map +1 -0
- package/dist/commands/inventory/index.d.ts +3 -0
- package/dist/commands/inventory/index.d.ts.map +1 -0
- package/dist/commands/inventory/index.js +12 -0
- package/dist/commands/inventory/index.js.map +1 -0
- package/dist/commands/inventory/low-stock.d.ts +3 -0
- package/dist/commands/inventory/low-stock.d.ts.map +1 -0
- package/dist/commands/inventory/low-stock.js +100 -0
- package/dist/commands/inventory/low-stock.js.map +1 -0
- package/dist/commands/inventory/reserve.d.ts +3 -0
- package/dist/commands/inventory/reserve.d.ts.map +1 -0
- package/dist/commands/inventory/reserve.js +103 -0
- package/dist/commands/inventory/reserve.js.map +1 -0
- package/dist/commands/inventory/update.d.ts +3 -0
- package/dist/commands/inventory/update.d.ts.map +1 -0
- package/dist/commands/inventory/update.js +119 -0
- package/dist/commands/inventory/update.js.map +1 -0
- package/dist/commands/merchant/index.d.ts +3 -0
- package/dist/commands/merchant/index.d.ts.map +1 -0
- package/dist/commands/merchant/index.js +12 -0
- package/dist/commands/merchant/index.js.map +1 -0
- package/dist/commands/merchant/info.d.ts +3 -0
- package/dist/commands/merchant/info.d.ts.map +1 -0
- package/dist/commands/merchant/info.js +113 -0
- package/dist/commands/merchant/info.js.map +1 -0
- package/dist/commands/merchant/setup.d.ts +3 -0
- package/dist/commands/merchant/setup.d.ts.map +1 -0
- package/dist/commands/merchant/setup.js +228 -0
- package/dist/commands/merchant/setup.js.map +1 -0
- package/dist/commands/merchant/update.d.ts +3 -0
- package/dist/commands/merchant/update.d.ts.map +1 -0
- package/dist/commands/merchant/update.js +177 -0
- package/dist/commands/merchant/update.js.map +1 -0
- package/dist/commands/merchant/url.d.ts +3 -0
- package/dist/commands/merchant/url.d.ts.map +1 -0
- package/dist/commands/merchant/url.js +96 -0
- package/dist/commands/merchant/url.js.map +1 -0
- package/dist/commands/order/cancel.d.ts +3 -0
- package/dist/commands/order/cancel.d.ts.map +1 -0
- package/dist/commands/order/cancel.js +142 -0
- package/dist/commands/order/cancel.js.map +1 -0
- package/dist/commands/order/complete.d.ts +3 -0
- package/dist/commands/order/complete.d.ts.map +1 -0
- package/dist/commands/order/complete.js +99 -0
- package/dist/commands/order/complete.js.map +1 -0
- package/dist/commands/order/get.d.ts +3 -0
- package/dist/commands/order/get.d.ts.map +1 -0
- package/dist/commands/order/get.js +80 -0
- package/dist/commands/order/get.js.map +1 -0
- package/dist/commands/order/index.d.ts +3 -0
- package/dist/commands/order/index.d.ts.map +1 -0
- package/dist/commands/order/index.js +16 -0
- package/dist/commands/order/index.js.map +1 -0
- package/dist/commands/order/list.d.ts +3 -0
- package/dist/commands/order/list.d.ts.map +1 -0
- package/dist/commands/order/list.js +135 -0
- package/dist/commands/order/list.js.map +1 -0
- package/dist/commands/order/mark-delivered.d.ts +3 -0
- package/dist/commands/order/mark-delivered.d.ts.map +1 -0
- package/dist/commands/order/mark-delivered.js +70 -0
- package/dist/commands/order/mark-delivered.js.map +1 -0
- package/dist/commands/order/ship.d.ts +3 -0
- package/dist/commands/order/ship.d.ts.map +1 -0
- package/dist/commands/order/ship.js +124 -0
- package/dist/commands/order/ship.js.map +1 -0
- package/dist/commands/product/add-images.d.ts +3 -0
- package/dist/commands/product/add-images.d.ts.map +1 -0
- package/dist/commands/product/add-images.js +210 -0
- package/dist/commands/product/add-images.js.map +1 -0
- package/dist/commands/product/create.d.ts +3 -0
- package/dist/commands/product/create.d.ts.map +1 -0
- package/dist/commands/product/create.js +369 -0
- package/dist/commands/product/create.js.map +1 -0
- package/dist/commands/product/delete.d.ts +3 -0
- package/dist/commands/product/delete.d.ts.map +1 -0
- package/dist/commands/product/delete.js +100 -0
- package/dist/commands/product/delete.js.map +1 -0
- package/dist/commands/product/get.d.ts +3 -0
- package/dist/commands/product/get.d.ts.map +1 -0
- package/dist/commands/product/get.js +123 -0
- package/dist/commands/product/get.js.map +1 -0
- package/dist/commands/product/index.d.ts +3 -0
- package/dist/commands/product/index.d.ts.map +1 -0
- package/dist/commands/product/index.js +18 -0
- package/dist/commands/product/index.js.map +1 -0
- package/dist/commands/product/list.d.ts +3 -0
- package/dist/commands/product/list.d.ts.map +1 -0
- package/dist/commands/product/list.js +154 -0
- package/dist/commands/product/list.js.map +1 -0
- package/dist/commands/product/update.d.ts +3 -0
- package/dist/commands/product/update.d.ts.map +1 -0
- package/dist/commands/product/update.js +183 -0
- package/dist/commands/product/update.js.map +1 -0
- package/dist/commands/product/url.d.ts +3 -0
- package/dist/commands/product/url.d.ts.map +1 -0
- package/dist/commands/product/url.js +124 -0
- package/dist/commands/product/url.js.map +1 -0
- package/dist/commands/refund/create.d.ts +3 -0
- package/dist/commands/refund/create.d.ts.map +1 -0
- package/dist/commands/refund/create.js +161 -0
- package/dist/commands/refund/create.js.map +1 -0
- package/dist/commands/refund/get.d.ts +3 -0
- package/dist/commands/refund/get.d.ts.map +1 -0
- package/dist/commands/refund/get.js +93 -0
- package/dist/commands/refund/get.js.map +1 -0
- package/dist/commands/refund/index.d.ts +3 -0
- package/dist/commands/refund/index.d.ts.map +1 -0
- package/dist/commands/refund/index.js +8 -0
- package/dist/commands/refund/index.js.map +1 -0
- package/dist/commands/shipping/calculate.d.ts +3 -0
- package/dist/commands/shipping/calculate.d.ts.map +1 -0
- package/dist/commands/shipping/calculate.js +183 -0
- package/dist/commands/shipping/calculate.js.map +1 -0
- package/dist/commands/shipping/history.d.ts +3 -0
- package/dist/commands/shipping/history.d.ts.map +1 -0
- package/dist/commands/shipping/history.js +111 -0
- package/dist/commands/shipping/history.js.map +1 -0
- package/dist/commands/shipping/index.d.ts +3 -0
- package/dist/commands/shipping/index.d.ts.map +1 -0
- package/dist/commands/shipping/index.js +10 -0
- package/dist/commands/shipping/index.js.map +1 -0
- package/dist/commands/shipping/update-status.d.ts +3 -0
- package/dist/commands/shipping/update-status.d.ts.map +1 -0
- package/dist/commands/shipping/update-status.js +138 -0
- package/dist/commands/shipping/update-status.js.map +1 -0
- package/dist/commands/shipping-zone/create.d.ts +3 -0
- package/dist/commands/shipping-zone/create.d.ts.map +1 -0
- package/dist/commands/shipping-zone/create.js +191 -0
- package/dist/commands/shipping-zone/create.js.map +1 -0
- package/dist/commands/shipping-zone/delete.d.ts +3 -0
- package/dist/commands/shipping-zone/delete.d.ts.map +1 -0
- package/dist/commands/shipping-zone/delete.js +97 -0
- package/dist/commands/shipping-zone/delete.js.map +1 -0
- package/dist/commands/shipping-zone/index.d.ts +3 -0
- package/dist/commands/shipping-zone/index.d.ts.map +1 -0
- package/dist/commands/shipping-zone/index.js +14 -0
- package/dist/commands/shipping-zone/index.js.map +1 -0
- package/dist/commands/shipping-zone/list.d.ts +3 -0
- package/dist/commands/shipping-zone/list.d.ts.map +1 -0
- package/dist/commands/shipping-zone/list.js +91 -0
- package/dist/commands/shipping-zone/list.js.map +1 -0
- package/dist/commands/shipping-zone/rates.d.ts +4 -0
- package/dist/commands/shipping-zone/rates.d.ts.map +1 -0
- package/dist/commands/shipping-zone/rates.js +285 -0
- package/dist/commands/shipping-zone/rates.js.map +1 -0
- package/dist/commands/test/health.d.ts +3 -0
- package/dist/commands/test/health.d.ts.map +1 -0
- package/dist/commands/test/health.js +126 -0
- package/dist/commands/test/health.js.map +1 -0
- package/dist/commands/test/index.d.ts +3 -0
- package/dist/commands/test/index.d.ts.map +1 -0
- package/dist/commands/test/index.js +8 -0
- package/dist/commands/test/index.js.map +1 -0
- package/dist/commands/test/smoke.d.ts +3 -0
- package/dist/commands/test/smoke.d.ts.map +1 -0
- package/dist/commands/test/smoke.js +201 -0
- package/dist/commands/test/smoke.js.map +1 -0
- package/dist/commands/transfer/index.d.ts +3 -0
- package/dist/commands/transfer/index.d.ts.map +1 -0
- package/dist/commands/transfer/index.js +8 -0
- package/dist/commands/transfer/index.js.map +1 -0
- package/dist/commands/transfer/list.d.ts +3 -0
- package/dist/commands/transfer/list.d.ts.map +1 -0
- package/dist/commands/transfer/list.js +90 -0
- package/dist/commands/transfer/list.js.map +1 -0
- package/dist/commands/transfer/summary.d.ts +3 -0
- package/dist/commands/transfer/summary.d.ts.map +1 -0
- package/dist/commands/transfer/summary.js +68 -0
- package/dist/commands/transfer/summary.js.map +1 -0
- package/dist/commands/upload/file.d.ts +3 -0
- package/dist/commands/upload/file.d.ts.map +1 -0
- package/dist/commands/upload/file.js +79 -0
- package/dist/commands/upload/file.js.map +1 -0
- package/dist/commands/upload/image.d.ts +3 -0
- package/dist/commands/upload/image.d.ts.map +1 -0
- package/dist/commands/upload/image.js +92 -0
- package/dist/commands/upload/image.js.map +1 -0
- package/dist/commands/upload/index.d.ts +3 -0
- package/dist/commands/upload/index.d.ts.map +1 -0
- package/dist/commands/upload/index.js +10 -0
- package/dist/commands/upload/index.js.map +1 -0
- package/dist/commands/upload/video.d.ts +3 -0
- package/dist/commands/upload/video.d.ts.map +1 -0
- package/dist/commands/upload/video.js +78 -0
- package/dist/commands/upload/video.js.map +1 -0
- package/dist/commands/variant/add-images.d.ts +3 -0
- package/dist/commands/variant/add-images.d.ts.map +1 -0
- package/dist/commands/variant/add-images.js +146 -0
- package/dist/commands/variant/add-images.js.map +1 -0
- package/dist/commands/variant/create.d.ts +3 -0
- package/dist/commands/variant/create.d.ts.map +1 -0
- package/dist/commands/variant/create.js +189 -0
- package/dist/commands/variant/create.js.map +1 -0
- package/dist/commands/variant/delete.d.ts +3 -0
- package/dist/commands/variant/delete.d.ts.map +1 -0
- package/dist/commands/variant/delete.js +110 -0
- package/dist/commands/variant/delete.js.map +1 -0
- package/dist/commands/variant/index.d.ts +3 -0
- package/dist/commands/variant/index.d.ts.map +1 -0
- package/dist/commands/variant/index.js +14 -0
- package/dist/commands/variant/index.js.map +1 -0
- package/dist/commands/variant/list.d.ts +3 -0
- package/dist/commands/variant/list.d.ts.map +1 -0
- package/dist/commands/variant/list.js +98 -0
- package/dist/commands/variant/list.js.map +1 -0
- package/dist/commands/variant/update.d.ts +3 -0
- package/dist/commands/variant/update.d.ts.map +1 -0
- package/dist/commands/variant/update.js +141 -0
- package/dist/commands/variant/update.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -0
- package/dist/postinstall.d.ts +3 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +108 -0
- package/dist/postinstall.js.map +1 -0
- package/dist/preuninstall.d.ts +3 -0
- package/dist/preuninstall.d.ts.map +1 -0
- package/dist/preuninstall.js +53 -0
- package/dist/preuninstall.js.map +1 -0
- package/dist/utils/config.d.ts +110 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +347 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/error.d.ts +35 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +110 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/format.d.ts +77 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +406 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/helpText.d.ts +116 -0
- package/dist/utils/helpText.d.ts.map +1 -0
- package/dist/utils/helpText.js +138 -0
- package/dist/utils/helpText.js.map +1 -0
- package/dist/utils/interactive.d.ts +60 -0
- package/dist/utils/interactive.d.ts.map +1 -0
- package/dist/utils/interactive.js +118 -0
- package/dist/utils/interactive.js.map +1 -0
- package/dist/utils/output.d.ts +82 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +151 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/validation.d.ts +16 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +46 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
import { createAuthenticatedClient } from './base.js';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
import { createReadStream } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { createHash } from 'crypto';
|
|
6
|
+
import { getApiUrl } from '../../utils/config.js';
|
|
7
|
+
// 辅助函数:清理文件名,移除非ASCII字符
|
|
8
|
+
function sanitizeFilename(filename) {
|
|
9
|
+
const ext = path.extname(filename);
|
|
10
|
+
const basename = path.basename(filename, ext);
|
|
11
|
+
// 如果文件名包含非ASCII字符,使用hash
|
|
12
|
+
if (!/^[\x00-\x7F]*$/.test(basename)) {
|
|
13
|
+
const hash = createHash('md5').update(basename).digest('hex').substring(0, 8);
|
|
14
|
+
return `upload-${hash}${ext}`;
|
|
15
|
+
}
|
|
16
|
+
return filename;
|
|
17
|
+
}
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Commerce API 客户端
|
|
20
|
+
// ============================================================================
|
|
21
|
+
class CommerceApiClient {
|
|
22
|
+
client;
|
|
23
|
+
constructor() {
|
|
24
|
+
// 优先级:环境变量 > 配置文件 > 默认值
|
|
25
|
+
this.client = createAuthenticatedClient(getApiUrl());
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 重新初始化客户端(当 API URL 改变时调用)
|
|
29
|
+
*/
|
|
30
|
+
reinitialize() {
|
|
31
|
+
this.client = createAuthenticatedClient(getApiUrl());
|
|
32
|
+
}
|
|
33
|
+
// ==========================================================================
|
|
34
|
+
// 商品管理 (products)
|
|
35
|
+
// ==========================================================================
|
|
36
|
+
products = {
|
|
37
|
+
/**
|
|
38
|
+
* 创建商品
|
|
39
|
+
*/
|
|
40
|
+
create: async (data) => {
|
|
41
|
+
const response = await this.client.post('/api/products', data);
|
|
42
|
+
return response.data;
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* 商品列表
|
|
46
|
+
*/
|
|
47
|
+
list: async (params) => {
|
|
48
|
+
const response = await this.client.get('/api/products', { params });
|
|
49
|
+
const data = response.data;
|
|
50
|
+
// 处理不同的响应格式
|
|
51
|
+
if (data.items) {
|
|
52
|
+
// 新格式: { items: [...] }
|
|
53
|
+
return {
|
|
54
|
+
products: data.items,
|
|
55
|
+
total: data.total || data.items.length,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// 旧格式: { products: [...], total: number }
|
|
59
|
+
return {
|
|
60
|
+
products: data.products || [],
|
|
61
|
+
total: data.total || 0,
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* 商品详情
|
|
66
|
+
*/
|
|
67
|
+
get: async (productId) => {
|
|
68
|
+
const response = await this.client.get(`/api/products/${productId}`);
|
|
69
|
+
return response.data;
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* 更新商品
|
|
73
|
+
*/
|
|
74
|
+
update: async (productId, data) => {
|
|
75
|
+
const response = await this.client.put(`/api/products/${productId}`, data);
|
|
76
|
+
return response.data;
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* 删除商品(软删除)
|
|
80
|
+
*/
|
|
81
|
+
delete: async (productId) => {
|
|
82
|
+
await this.client.delete(`/api/products/${productId}`);
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* 添加商品图片(两步流程)
|
|
86
|
+
* 1. 先上传图片到存储获取 media_id
|
|
87
|
+
* 2. 再关联 media_id 到商品
|
|
88
|
+
*/
|
|
89
|
+
addImages: async (productId, imagePaths) => {
|
|
90
|
+
// 第1步:上传图片获取 media_id
|
|
91
|
+
const mediaIds = [];
|
|
92
|
+
for (const imagePath of imagePaths) {
|
|
93
|
+
const formData = new FormData();
|
|
94
|
+
const filename = sanitizeFilename(path.basename(imagePath));
|
|
95
|
+
formData.append('file', createReadStream(imagePath), {
|
|
96
|
+
filename: filename,
|
|
97
|
+
});
|
|
98
|
+
const uploadResponse = await this.client.post('/api/upload/image', formData, {
|
|
99
|
+
headers: {
|
|
100
|
+
...formData.getHeaders(),
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
if (uploadResponse.data.media_id) {
|
|
104
|
+
mediaIds.push(uploadResponse.data.media_id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// 第2步:关联图片到商品
|
|
108
|
+
const response = await this.client.post(`/api/products/${productId}/images`, { media_ids: mediaIds });
|
|
109
|
+
return response.data;
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* 添加商品图片(通过 URL)
|
|
113
|
+
* 直接用图片 URL 关联到商品(后端会下载)
|
|
114
|
+
*/
|
|
115
|
+
addImageUrls: async (productId, imageUrls) => {
|
|
116
|
+
const response = await this.client.post(`/api/products/${productId}/images`, { image_urls: imageUrls });
|
|
117
|
+
return response.data;
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* 添加商品图片(通过 Media ID)
|
|
121
|
+
* 直接用 media_id 关联到商品(从 upload 命令获取)
|
|
122
|
+
*/
|
|
123
|
+
addImagesByMediaIds: async (productId, mediaIds) => {
|
|
124
|
+
const response = await this.client.post(`/api/products/${productId}/images`, { media_ids: mediaIds });
|
|
125
|
+
return response.data;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
// ==========================================================================
|
|
129
|
+
// 订单管理 (orders)
|
|
130
|
+
// ==========================================================================
|
|
131
|
+
orders = {
|
|
132
|
+
/**
|
|
133
|
+
* 商户订单列表
|
|
134
|
+
*/
|
|
135
|
+
list: async (params) => {
|
|
136
|
+
const response = await this.client.get('/api/orders/merchant', { params });
|
|
137
|
+
const data = response.data;
|
|
138
|
+
// 处理不同的响应格式
|
|
139
|
+
if (data.items) {
|
|
140
|
+
// 新格式: { items: [...] }
|
|
141
|
+
return {
|
|
142
|
+
orders: data.items,
|
|
143
|
+
total: data.total || data.items.length,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
// 旧格式: { orders: [...], total: number }
|
|
147
|
+
return {
|
|
148
|
+
orders: data.orders || [],
|
|
149
|
+
total: data.total || 0,
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
/**
|
|
153
|
+
* 订单详情
|
|
154
|
+
*/
|
|
155
|
+
get: async (orderId) => {
|
|
156
|
+
const response = await this.client.get(`/api/orders/merchant/${orderId}`);
|
|
157
|
+
return response.data;
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* 标记订单已发货
|
|
161
|
+
*/
|
|
162
|
+
ship: async (orderId, data) => {
|
|
163
|
+
const response = await this.client.post(`/api/orders/merchant/${orderId}/ship`, data);
|
|
164
|
+
return response.data;
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* 完成订单
|
|
168
|
+
*/
|
|
169
|
+
complete: async (orderId) => {
|
|
170
|
+
const response = await this.client.post(`/api/orders/merchant/${orderId}/complete`);
|
|
171
|
+
return response.data;
|
|
172
|
+
},
|
|
173
|
+
/**
|
|
174
|
+
* 取消订单
|
|
175
|
+
*/
|
|
176
|
+
cancel: async (orderId, reason) => {
|
|
177
|
+
const response = await this.client.post(`/api/orders/merchant/${orderId}/cancel`, { reason });
|
|
178
|
+
return response.data;
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* 标记已送达
|
|
182
|
+
*/
|
|
183
|
+
markDelivered: async (orderId) => {
|
|
184
|
+
const response = await this.client.post(`/api/orders/merchant/${orderId}/mark-delivered`, {});
|
|
185
|
+
return response.data;
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
// ==========================================================================
|
|
189
|
+
// 库存管理 (inventory)
|
|
190
|
+
// ==========================================================================
|
|
191
|
+
inventory = {
|
|
192
|
+
/**
|
|
193
|
+
* 获取低库存商品
|
|
194
|
+
*/
|
|
195
|
+
getLowStock: async (threshold) => {
|
|
196
|
+
const response = await this.client.get('/api/inventory/low-stock', {
|
|
197
|
+
params: { threshold },
|
|
198
|
+
});
|
|
199
|
+
// 处理不同的响应格式
|
|
200
|
+
const data = response.data;
|
|
201
|
+
if (Array.isArray(data)) {
|
|
202
|
+
return data;
|
|
203
|
+
}
|
|
204
|
+
return data.items || [];
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* 调整商品库存
|
|
208
|
+
*/
|
|
209
|
+
updateStock: async (productId, quantity, reason) => {
|
|
210
|
+
const response = await this.client.put(`/api/inventory/products/${productId}/stock`, {
|
|
211
|
+
quantity,
|
|
212
|
+
reason: reason || 'Manual adjustment',
|
|
213
|
+
});
|
|
214
|
+
return response.data;
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* 查看库存变更历史
|
|
218
|
+
*/
|
|
219
|
+
getHistory: async (productId) => {
|
|
220
|
+
const response = await this.client.get(`/api/inventory/products/${productId}/history`);
|
|
221
|
+
return response.data;
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* 预留库存(购物车功能)
|
|
225
|
+
*/
|
|
226
|
+
reserveStock: async (productId, quantity) => {
|
|
227
|
+
const response = await this.client.post(`/api/inventory/products/${productId}/reserve`, {
|
|
228
|
+
quantity,
|
|
229
|
+
});
|
|
230
|
+
return response.data;
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
// ==========================================================================
|
|
234
|
+
// 商户管理 (merchant)
|
|
235
|
+
// ==========================================================================
|
|
236
|
+
merchant = {
|
|
237
|
+
/**
|
|
238
|
+
* 获取当前商户信息
|
|
239
|
+
*/
|
|
240
|
+
getProfile: async () => {
|
|
241
|
+
const response = await this.client.get('/api/merchants/me');
|
|
242
|
+
return response.data;
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* 更新商户资料
|
|
246
|
+
*/
|
|
247
|
+
updateProfile: async (data) => {
|
|
248
|
+
const response = await this.client.put('/api/merchants/me', data);
|
|
249
|
+
return response.data;
|
|
250
|
+
},
|
|
251
|
+
/**
|
|
252
|
+
* 初始化 OAuth 用户的商户资料
|
|
253
|
+
*/
|
|
254
|
+
setupProfile: async (data) => {
|
|
255
|
+
const response = await this.client.post('/api/merchants/me', data);
|
|
256
|
+
return response.data;
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
// ==========================================================================
|
|
260
|
+
// 物流管理 (shipping)
|
|
261
|
+
// ==========================================================================
|
|
262
|
+
shipping = {
|
|
263
|
+
/**
|
|
264
|
+
* 更新物流状态
|
|
265
|
+
*/
|
|
266
|
+
updateShippingStatus: async (orderId, data) => {
|
|
267
|
+
const response = await this.client.post(`/api/orders/merchant/${orderId}/update-shipping-status`, data);
|
|
268
|
+
return response.data;
|
|
269
|
+
},
|
|
270
|
+
/**
|
|
271
|
+
* 获取物流历史
|
|
272
|
+
*/
|
|
273
|
+
getShippingHistory: async (orderId) => {
|
|
274
|
+
const response = await this.client.get(`/api/orders/merchant/${orderId}/shipping-history`);
|
|
275
|
+
return response.data;
|
|
276
|
+
},
|
|
277
|
+
/**
|
|
278
|
+
* 添加物流备注
|
|
279
|
+
*/
|
|
280
|
+
addShippingNote: async (orderId, note) => {
|
|
281
|
+
const response = await this.client.post(`/api/orders/merchant/${orderId}/add-shipping-note`, {
|
|
282
|
+
note,
|
|
283
|
+
});
|
|
284
|
+
return response.data;
|
|
285
|
+
},
|
|
286
|
+
/**
|
|
287
|
+
* 获取支持的国家列表
|
|
288
|
+
*/
|
|
289
|
+
listCountries: async () => {
|
|
290
|
+
const response = await this.client.get('/api/shipping/countries');
|
|
291
|
+
return response.data;
|
|
292
|
+
},
|
|
293
|
+
/**
|
|
294
|
+
* 获取当前物流模式
|
|
295
|
+
*/
|
|
296
|
+
getMode: async () => {
|
|
297
|
+
const response = await this.client.get('/api/shipping/mode');
|
|
298
|
+
return response.data;
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* 切换物流模式
|
|
302
|
+
*/
|
|
303
|
+
setMode: async (mode) => {
|
|
304
|
+
await this.client.post('/api/shipping/mode', { mode });
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
// ==========================================================================
|
|
308
|
+
// 固定运费配置 (shipping-fixed)
|
|
309
|
+
// ==========================================================================
|
|
310
|
+
shippingFixed = {
|
|
311
|
+
/**
|
|
312
|
+
* 获取固定运费全局配置
|
|
313
|
+
*/
|
|
314
|
+
getConfig: async () => {
|
|
315
|
+
const response = await this.client.get('/api/shipping/fixed/config');
|
|
316
|
+
return response.data;
|
|
317
|
+
},
|
|
318
|
+
/**
|
|
319
|
+
* 更新全局配置
|
|
320
|
+
*/
|
|
321
|
+
updateConfig: async (data) => {
|
|
322
|
+
const response = await this.client.post('/api/shipping/fixed/config', data);
|
|
323
|
+
return response.data;
|
|
324
|
+
},
|
|
325
|
+
/**
|
|
326
|
+
* 计算订单运费
|
|
327
|
+
*/
|
|
328
|
+
calculate: async (data) => {
|
|
329
|
+
const response = await this.client.post('/api/shipping/fixed/calculate', data);
|
|
330
|
+
return response.data;
|
|
331
|
+
},
|
|
332
|
+
/**
|
|
333
|
+
* 获取运费区域列表
|
|
334
|
+
*/
|
|
335
|
+
listZones: async () => {
|
|
336
|
+
const response = await this.client.get('/api/shipping/fixed/zones');
|
|
337
|
+
return response.data.zones;
|
|
338
|
+
},
|
|
339
|
+
/**
|
|
340
|
+
* 创建运费区域
|
|
341
|
+
*/
|
|
342
|
+
createZone: async (data) => {
|
|
343
|
+
const response = await this.client.post('/api/shipping/fixed/zones', data);
|
|
344
|
+
return response.data;
|
|
345
|
+
},
|
|
346
|
+
/**
|
|
347
|
+
* 获取运费区域详情
|
|
348
|
+
*/
|
|
349
|
+
getZone: async (zoneId) => {
|
|
350
|
+
const response = await this.client.get(`/api/shipping/fixed/zones/${zoneId}`);
|
|
351
|
+
return response.data;
|
|
352
|
+
},
|
|
353
|
+
/**
|
|
354
|
+
* 更新运费区域
|
|
355
|
+
*/
|
|
356
|
+
updateZone: async (zoneId, data) => {
|
|
357
|
+
const response = await this.client.put(`/api/shipping/fixed/zones/${zoneId}`, data);
|
|
358
|
+
return response.data;
|
|
359
|
+
},
|
|
360
|
+
/**
|
|
361
|
+
* 删除运费区域
|
|
362
|
+
*/
|
|
363
|
+
deleteZone: async (zoneId) => {
|
|
364
|
+
await this.client.delete(`/api/shipping/fixed/zones/${zoneId}`);
|
|
365
|
+
},
|
|
366
|
+
/**
|
|
367
|
+
* 获取区域运费费率
|
|
368
|
+
*/
|
|
369
|
+
listRates: async (zoneId) => {
|
|
370
|
+
const response = await this.client.get(`/api/shipping/fixed/zones/${zoneId}`);
|
|
371
|
+
return response.data.rates || [];
|
|
372
|
+
},
|
|
373
|
+
/**
|
|
374
|
+
* 创建运费费率
|
|
375
|
+
*/
|
|
376
|
+
createRate: async (zoneId, data) => {
|
|
377
|
+
const response = await this.client.post(`/api/shipping/fixed/zones/${zoneId}/rates`, data);
|
|
378
|
+
// API returns full zone, extract the newly created rate (last in array)
|
|
379
|
+
const rates = response.data.rates || [];
|
|
380
|
+
if (rates.length === 0) {
|
|
381
|
+
throw new Error('Failed to create rate: no rates returned');
|
|
382
|
+
}
|
|
383
|
+
return rates[rates.length - 1];
|
|
384
|
+
},
|
|
385
|
+
/**
|
|
386
|
+
* 更新运费费率
|
|
387
|
+
*/
|
|
388
|
+
updateRate: async (zoneId, rateId, data) => {
|
|
389
|
+
const response = await this.client.put(`/api/shipping/fixed/zones/${zoneId}/rates/${rateId}`, data);
|
|
390
|
+
// API returns full zone, find the updated rate by ID
|
|
391
|
+
const rate = response.data.rates?.find(r => r.id === rateId);
|
|
392
|
+
if (!rate) {
|
|
393
|
+
throw new Error(`Failed to find updated rate: ${rateId}`);
|
|
394
|
+
}
|
|
395
|
+
return rate;
|
|
396
|
+
},
|
|
397
|
+
/**
|
|
398
|
+
* 删除运费费率
|
|
399
|
+
*/
|
|
400
|
+
deleteRate: async (zoneId, rateId) => {
|
|
401
|
+
await this.client.delete(`/api/shipping/fixed/zones/${zoneId}/rates/${rateId}`);
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
// ==========================================================================
|
|
405
|
+
// 对话管理 (conversations)
|
|
406
|
+
// ==========================================================================
|
|
407
|
+
conversations = {
|
|
408
|
+
/**
|
|
409
|
+
* 创建对话
|
|
410
|
+
*/
|
|
411
|
+
create: async (data) => {
|
|
412
|
+
const response = await this.client.post('/api/conversations', data);
|
|
413
|
+
return response.data;
|
|
414
|
+
},
|
|
415
|
+
/**
|
|
416
|
+
* 获取对话列表
|
|
417
|
+
*/
|
|
418
|
+
list: async (params) => {
|
|
419
|
+
const response = await this.client.get('/api/conversations', { params });
|
|
420
|
+
return response.data;
|
|
421
|
+
},
|
|
422
|
+
/**
|
|
423
|
+
* 获取对话详情
|
|
424
|
+
*/
|
|
425
|
+
get: async (conversationId) => {
|
|
426
|
+
const response = await this.client.get(`/api/conversations/${conversationId}`);
|
|
427
|
+
return response.data;
|
|
428
|
+
},
|
|
429
|
+
/**
|
|
430
|
+
* 更新对话状态
|
|
431
|
+
*/
|
|
432
|
+
update: async (conversationId, data) => {
|
|
433
|
+
const response = await this.client.patch(`/api/conversations/${conversationId}`, data);
|
|
434
|
+
return response.data;
|
|
435
|
+
},
|
|
436
|
+
/**
|
|
437
|
+
* 发送消息
|
|
438
|
+
*/
|
|
439
|
+
sendMessage: async (conversationId, data) => {
|
|
440
|
+
const response = await this.client.post(`/api/conversations/${conversationId}/messages`, data);
|
|
441
|
+
return response.data;
|
|
442
|
+
},
|
|
443
|
+
/**
|
|
444
|
+
* 获取消息列表
|
|
445
|
+
*/
|
|
446
|
+
getMessages: async (conversationId, params) => {
|
|
447
|
+
const response = await this.client.get(`/api/conversations/${conversationId}/messages`, { params });
|
|
448
|
+
return response.data;
|
|
449
|
+
},
|
|
450
|
+
/**
|
|
451
|
+
* 标记消息已读
|
|
452
|
+
*/
|
|
453
|
+
markRead: async (conversationId) => {
|
|
454
|
+
const response = await this.client.post(`/api/conversations/${conversationId}/messages/mark-read`);
|
|
455
|
+
return response.data;
|
|
456
|
+
},
|
|
457
|
+
/**
|
|
458
|
+
* 获取对话上下文
|
|
459
|
+
*/
|
|
460
|
+
getContext: async (conversationId) => {
|
|
461
|
+
const response = await this.client.get(`/api/conversations/${conversationId}/context`);
|
|
462
|
+
return response.data;
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
// ==========================================================================
|
|
466
|
+
// 商品变体 (variants)
|
|
467
|
+
// ==========================================================================
|
|
468
|
+
variants = {
|
|
469
|
+
/**
|
|
470
|
+
* 获取商品变体列表
|
|
471
|
+
*/
|
|
472
|
+
list: async (productId) => {
|
|
473
|
+
const response = await this.client.get(`/api/products/${productId}/variants`);
|
|
474
|
+
const data = response.data;
|
|
475
|
+
// 处理不同的响应格式
|
|
476
|
+
if (Array.isArray(data)) {
|
|
477
|
+
return data;
|
|
478
|
+
}
|
|
479
|
+
if (data.items) {
|
|
480
|
+
return data.items;
|
|
481
|
+
}
|
|
482
|
+
if (data.variants) {
|
|
483
|
+
return data.variants;
|
|
484
|
+
}
|
|
485
|
+
return [];
|
|
486
|
+
},
|
|
487
|
+
/**
|
|
488
|
+
* 搜索商品变体
|
|
489
|
+
*/
|
|
490
|
+
search: async (productId, criteria) => {
|
|
491
|
+
const response = await this.client.post(`/api/products/${productId}/variants/search`, criteria);
|
|
492
|
+
return response.data;
|
|
493
|
+
},
|
|
494
|
+
/**
|
|
495
|
+
* 创建商品变体
|
|
496
|
+
*/
|
|
497
|
+
create: async (productId, data) => {
|
|
498
|
+
const response = await this.client.post(`/api/products/${productId}/variants`, data);
|
|
499
|
+
return response.data;
|
|
500
|
+
},
|
|
501
|
+
/**
|
|
502
|
+
* 获取变体详情
|
|
503
|
+
*/
|
|
504
|
+
get: async (productId, variantId) => {
|
|
505
|
+
const response = await this.client.get(`/api/products/${productId}/variants/${variantId}`);
|
|
506
|
+
return response.data;
|
|
507
|
+
},
|
|
508
|
+
/**
|
|
509
|
+
* 更新变体
|
|
510
|
+
*/
|
|
511
|
+
update: async (productId, variantId, data) => {
|
|
512
|
+
const response = await this.client.put(`/api/products/${productId}/variants/${variantId}`, data);
|
|
513
|
+
return response.data;
|
|
514
|
+
},
|
|
515
|
+
/**
|
|
516
|
+
* 删除变体
|
|
517
|
+
*/
|
|
518
|
+
delete: async (productId, variantId) => {
|
|
519
|
+
await this.client.delete(`/api/products/${productId}/variants/${variantId}`);
|
|
520
|
+
},
|
|
521
|
+
/**
|
|
522
|
+
* 添加变体图片(两步流程)
|
|
523
|
+
* 1. 先上传图片到存储获取 media_id
|
|
524
|
+
* 2. 再关联 media_id 到变体
|
|
525
|
+
*/
|
|
526
|
+
addImages: async (masterId, variantId, imagePaths) => {
|
|
527
|
+
// 第1步:上传图片获取 media_id
|
|
528
|
+
const mediaIds = [];
|
|
529
|
+
for (const imagePath of imagePaths) {
|
|
530
|
+
const formData = new FormData();
|
|
531
|
+
const filename = sanitizeFilename(path.basename(imagePath));
|
|
532
|
+
formData.append('file', createReadStream(imagePath), {
|
|
533
|
+
filename: filename,
|
|
534
|
+
});
|
|
535
|
+
const uploadResponse = await this.client.post('/api/upload/image', formData, {
|
|
536
|
+
headers: {
|
|
537
|
+
...formData.getHeaders(),
|
|
538
|
+
},
|
|
539
|
+
});
|
|
540
|
+
if (uploadResponse.data.media_id) {
|
|
541
|
+
mediaIds.push(uploadResponse.data.media_id);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
// 第2步:关联图片到变体
|
|
545
|
+
const response = await this.client.post(`/api/products/${masterId}/variants/${variantId}/images`, { media_ids: mediaIds });
|
|
546
|
+
return response.data;
|
|
547
|
+
},
|
|
548
|
+
/**
|
|
549
|
+
* 添加变体图片(通过 Media ID)
|
|
550
|
+
* 直接用 media_id 关联到变体(从 upload 命令获取)
|
|
551
|
+
*/
|
|
552
|
+
addImagesByMediaIds: async (masterId, variantId, mediaIds) => {
|
|
553
|
+
const response = await this.client.post(`/api/products/${masterId}/variants/${variantId}/images`, { media_ids: mediaIds });
|
|
554
|
+
return response.data;
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
// ==========================================================================
|
|
558
|
+
// 退款管理 (refunds)
|
|
559
|
+
// ==========================================================================
|
|
560
|
+
refunds = {
|
|
561
|
+
/**
|
|
562
|
+
* 创建退款
|
|
563
|
+
*/
|
|
564
|
+
create: async (data) => {
|
|
565
|
+
const response = await this.client.post('/api/refunds/create', data);
|
|
566
|
+
return response.data;
|
|
567
|
+
},
|
|
568
|
+
/**
|
|
569
|
+
* 获取退款详情
|
|
570
|
+
*/
|
|
571
|
+
get: async (refundId) => {
|
|
572
|
+
const response = await this.client.get(`/api/refunds/${refundId}`);
|
|
573
|
+
return response.data;
|
|
574
|
+
},
|
|
575
|
+
};
|
|
576
|
+
// ==========================================================================
|
|
577
|
+
// 文件上传 (upload)
|
|
578
|
+
// ==========================================================================
|
|
579
|
+
upload = {
|
|
580
|
+
/**
|
|
581
|
+
* 上传图片
|
|
582
|
+
*/
|
|
583
|
+
uploadImage: async (imagePath) => {
|
|
584
|
+
const formData = new FormData();
|
|
585
|
+
const filename = sanitizeFilename(path.basename(imagePath));
|
|
586
|
+
formData.append('file', createReadStream(imagePath), {
|
|
587
|
+
filename: filename,
|
|
588
|
+
});
|
|
589
|
+
const response = await this.client.post('/api/upload/image', formData, {
|
|
590
|
+
headers: {
|
|
591
|
+
...formData.getHeaders(),
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
return response.data;
|
|
595
|
+
},
|
|
596
|
+
/**
|
|
597
|
+
* 上传视频
|
|
598
|
+
*/
|
|
599
|
+
uploadVideo: async (videoPath) => {
|
|
600
|
+
const formData = new FormData();
|
|
601
|
+
formData.append('file', createReadStream(videoPath));
|
|
602
|
+
const response = await this.client.post('/api/upload/video', formData, {
|
|
603
|
+
headers: {
|
|
604
|
+
...formData.getHeaders(),
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
return response.data;
|
|
608
|
+
},
|
|
609
|
+
/**
|
|
610
|
+
* 上传文件
|
|
611
|
+
*/
|
|
612
|
+
uploadFile: async (filePath) => {
|
|
613
|
+
const formData = new FormData();
|
|
614
|
+
formData.append('file', createReadStream(filePath));
|
|
615
|
+
const response = await this.client.post('/api/upload/file', formData, {
|
|
616
|
+
headers: {
|
|
617
|
+
...formData.getHeaders(),
|
|
618
|
+
},
|
|
619
|
+
});
|
|
620
|
+
return response.data;
|
|
621
|
+
},
|
|
622
|
+
};
|
|
623
|
+
// ==========================================================================
|
|
624
|
+
// 财务管理 (transfers)
|
|
625
|
+
// ==========================================================================
|
|
626
|
+
transfers = {
|
|
627
|
+
list: async () => {
|
|
628
|
+
const response = await this.client.get('/api/transfers/merchant');
|
|
629
|
+
return response.data.transfers || response.data || [];
|
|
630
|
+
},
|
|
631
|
+
summary: async () => {
|
|
632
|
+
const response = await this.client.get('/api/transfers/merchant/summary');
|
|
633
|
+
return response.data;
|
|
634
|
+
},
|
|
635
|
+
};
|
|
636
|
+
// ==========================================================================
|
|
637
|
+
// 国际化翻译 (i18n)
|
|
638
|
+
// ==========================================================================
|
|
639
|
+
i18n = {
|
|
640
|
+
/**
|
|
641
|
+
* 获取支持的语言列表
|
|
642
|
+
*/
|
|
643
|
+
listLanguages: async (activeOnly = true) => {
|
|
644
|
+
const response = await this.client.get('/api/languages', {
|
|
645
|
+
params: { active_only: activeOnly },
|
|
646
|
+
});
|
|
647
|
+
return response.data;
|
|
648
|
+
},
|
|
649
|
+
// 商品翻译
|
|
650
|
+
productTranslations: {
|
|
651
|
+
list: async (productId) => {
|
|
652
|
+
const response = await this.client.get(`/api/products/${productId}/translations`);
|
|
653
|
+
return response.data;
|
|
654
|
+
},
|
|
655
|
+
get: async (productId, languageCode) => {
|
|
656
|
+
const response = await this.client.get(`/api/products/${productId}/translations/${languageCode}`);
|
|
657
|
+
return response.data;
|
|
658
|
+
},
|
|
659
|
+
create: async (productId, data) => {
|
|
660
|
+
const response = await this.client.post(`/api/products/${productId}/translations`, data);
|
|
661
|
+
return response.data;
|
|
662
|
+
},
|
|
663
|
+
update: async (productId, languageCode, data) => {
|
|
664
|
+
const response = await this.client.put(`/api/products/${productId}/translations/${languageCode}`, data);
|
|
665
|
+
return response.data;
|
|
666
|
+
},
|
|
667
|
+
delete: async (productId, languageCode) => {
|
|
668
|
+
await this.client.delete(`/api/products/${productId}/translations/${languageCode}`);
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
// 集合翻译
|
|
672
|
+
collectionTranslations: {
|
|
673
|
+
list: async (collectionId) => {
|
|
674
|
+
const response = await this.client.get(`/api/collections/${collectionId}/translations`);
|
|
675
|
+
return response.data;
|
|
676
|
+
},
|
|
677
|
+
get: async (collectionId, languageCode) => {
|
|
678
|
+
const response = await this.client.get(`/api/collections/${collectionId}/translations/${languageCode}`);
|
|
679
|
+
return response.data;
|
|
680
|
+
},
|
|
681
|
+
create: async (collectionId, data) => {
|
|
682
|
+
const response = await this.client.post(`/api/collections/${collectionId}/translations`, data);
|
|
683
|
+
return response.data;
|
|
684
|
+
},
|
|
685
|
+
update: async (collectionId, languageCode, data) => {
|
|
686
|
+
const response = await this.client.put(`/api/collections/${collectionId}/translations/${languageCode}`, data);
|
|
687
|
+
return response.data;
|
|
688
|
+
},
|
|
689
|
+
delete: async (collectionId, languageCode) => {
|
|
690
|
+
await this.client.delete(`/api/collections/${collectionId}/translations/${languageCode}`);
|
|
691
|
+
},
|
|
692
|
+
},
|
|
693
|
+
// 商户翻译
|
|
694
|
+
merchantTranslations: {
|
|
695
|
+
list: async () => {
|
|
696
|
+
const response = await this.client.get('/api/merchants/me/translations');
|
|
697
|
+
return response.data;
|
|
698
|
+
},
|
|
699
|
+
get: async (languageCode) => {
|
|
700
|
+
const response = await this.client.get(`/api/merchants/me/translations/${languageCode}`);
|
|
701
|
+
return response.data;
|
|
702
|
+
},
|
|
703
|
+
create: async (data) => {
|
|
704
|
+
const response = await this.client.post('/api/merchants/me/translations', data);
|
|
705
|
+
return response.data;
|
|
706
|
+
},
|
|
707
|
+
update: async (languageCode, data) => {
|
|
708
|
+
const response = await this.client.put(`/api/merchants/me/translations/${languageCode}`, data);
|
|
709
|
+
return response.data;
|
|
710
|
+
},
|
|
711
|
+
delete: async (languageCode) => {
|
|
712
|
+
await this.client.delete(`/api/merchants/me/translations/${languageCode}`);
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
};
|
|
716
|
+
// ==========================================================================
|
|
717
|
+
// 首页配置 (homepage)
|
|
718
|
+
// ==========================================================================
|
|
719
|
+
homepage = {
|
|
720
|
+
sections: {
|
|
721
|
+
/**
|
|
722
|
+
* 列出所有 sections
|
|
723
|
+
*/
|
|
724
|
+
list: async () => {
|
|
725
|
+
const response = await this.client.get('/api/v1/merchants/me/homepage-config/sections');
|
|
726
|
+
return response.data;
|
|
727
|
+
},
|
|
728
|
+
/**
|
|
729
|
+
* 创建 section
|
|
730
|
+
*/
|
|
731
|
+
create: async (data) => {
|
|
732
|
+
const response = await this.client.post('/api/v1/merchants/me/homepage-config/sections', data);
|
|
733
|
+
return response.data;
|
|
734
|
+
},
|
|
735
|
+
/**
|
|
736
|
+
* 获取单个 section
|
|
737
|
+
*/
|
|
738
|
+
get: async (id, expand) => {
|
|
739
|
+
const response = await this.client.get(`/api/v1/merchants/me/homepage-config/sections/${id}`, {
|
|
740
|
+
params: expand ? { expand } : undefined,
|
|
741
|
+
});
|
|
742
|
+
return response.data;
|
|
743
|
+
},
|
|
744
|
+
/**
|
|
745
|
+
* 更新 section
|
|
746
|
+
*/
|
|
747
|
+
update: async (id, data) => {
|
|
748
|
+
const response = await this.client.put(`/api/v1/merchants/me/homepage-config/sections/${id}`, data);
|
|
749
|
+
return response.data;
|
|
750
|
+
},
|
|
751
|
+
/**
|
|
752
|
+
* 删除 section
|
|
753
|
+
*/
|
|
754
|
+
delete: async (id) => {
|
|
755
|
+
await this.client.delete(`/api/v1/merchants/me/homepage-config/sections/${id}`);
|
|
756
|
+
},
|
|
757
|
+
/**
|
|
758
|
+
* 重排序 sections
|
|
759
|
+
*/
|
|
760
|
+
reorder: async (moves) => {
|
|
761
|
+
const response = await this.client.put('/api/v1/merchants/me/homepage-config/sections/reorder', {
|
|
762
|
+
moves,
|
|
763
|
+
});
|
|
764
|
+
return response.data;
|
|
765
|
+
},
|
|
766
|
+
},
|
|
767
|
+
settings: {
|
|
768
|
+
/**
|
|
769
|
+
* 更新 Banner 图片
|
|
770
|
+
*/
|
|
771
|
+
updateImages: async (id, images) => {
|
|
772
|
+
const response = await this.client.put(`/api/v1/merchants/me/homepage-config/sections/${id}/settings/images`, {
|
|
773
|
+
images,
|
|
774
|
+
});
|
|
775
|
+
return response.data;
|
|
776
|
+
},
|
|
777
|
+
/**
|
|
778
|
+
* 更新 Collections 列表
|
|
779
|
+
*/
|
|
780
|
+
updateCollections: async (id, collection_slugs) => {
|
|
781
|
+
const response = await this.client.put(`/api/v1/merchants/me/homepage-config/sections/${id}/settings/collections`, {
|
|
782
|
+
collection_slugs,
|
|
783
|
+
});
|
|
784
|
+
return response.data;
|
|
785
|
+
},
|
|
786
|
+
/**
|
|
787
|
+
* 更新 Collection Products 目标集合
|
|
788
|
+
*/
|
|
789
|
+
updateCollectionSlug: async (id, collection_slug) => {
|
|
790
|
+
const response = await this.client.put(`/api/v1/merchants/me/homepage-config/sections/${id}/settings/collection`, {
|
|
791
|
+
collection_slug,
|
|
792
|
+
});
|
|
793
|
+
return response.data;
|
|
794
|
+
},
|
|
795
|
+
/**
|
|
796
|
+
* 更新 Featured 目标
|
|
797
|
+
*/
|
|
798
|
+
updateTarget: async (id, target_type, target_handle) => {
|
|
799
|
+
const response = await this.client.put(`/api/v1/merchants/me/homepage-config/sections/${id}/settings/target`, {
|
|
800
|
+
target_type,
|
|
801
|
+
target_handle,
|
|
802
|
+
});
|
|
803
|
+
return response.data;
|
|
804
|
+
},
|
|
805
|
+
/**
|
|
806
|
+
* 通用设置补丁
|
|
807
|
+
*/
|
|
808
|
+
patch: async (id, settings) => {
|
|
809
|
+
const response = await this.client.patch(`/api/v1/merchants/me/homepage-config/sections/${id}/settings`, {
|
|
810
|
+
updates: settings,
|
|
811
|
+
});
|
|
812
|
+
return response.data;
|
|
813
|
+
},
|
|
814
|
+
},
|
|
815
|
+
translations: {
|
|
816
|
+
/**
|
|
817
|
+
* 列出所有翻译
|
|
818
|
+
*/
|
|
819
|
+
list: async (sectionId) => {
|
|
820
|
+
const response = await this.client.get(`/api/v1/merchants/me/homepage-config/sections/${sectionId}/translations`);
|
|
821
|
+
return response.data;
|
|
822
|
+
},
|
|
823
|
+
/**
|
|
824
|
+
* 创建或更新翻译 (upsert)
|
|
825
|
+
*/
|
|
826
|
+
set: async (sectionId, lang, data) => {
|
|
827
|
+
const response = await this.client.put(`/api/v1/merchants/me/homepage-config/sections/${sectionId}/translations/${lang}`, data);
|
|
828
|
+
return response.data;
|
|
829
|
+
},
|
|
830
|
+
/**
|
|
831
|
+
* 删除翻译
|
|
832
|
+
*/
|
|
833
|
+
delete: async (sectionId, lang) => {
|
|
834
|
+
await this.client.delete(`/api/v1/merchants/me/homepage-config/sections/${sectionId}/translations/${lang}`);
|
|
835
|
+
},
|
|
836
|
+
},
|
|
837
|
+
};
|
|
838
|
+
// ==========================================================================
|
|
839
|
+
// Collections 管理
|
|
840
|
+
// ==========================================================================
|
|
841
|
+
collections = {
|
|
842
|
+
/**
|
|
843
|
+
* 列出所有 collections
|
|
844
|
+
*/
|
|
845
|
+
list: async (params) => {
|
|
846
|
+
const response = await this.client.get('/api/collections', { params });
|
|
847
|
+
return response.data;
|
|
848
|
+
},
|
|
849
|
+
/**
|
|
850
|
+
* 创建 collection
|
|
851
|
+
*/
|
|
852
|
+
create: async (data) => {
|
|
853
|
+
const response = await this.client.post('/api/collections', data);
|
|
854
|
+
return response.data;
|
|
855
|
+
},
|
|
856
|
+
/**
|
|
857
|
+
* 获取单个 collection
|
|
858
|
+
*/
|
|
859
|
+
get: async (id) => {
|
|
860
|
+
const response = await this.client.get(`/api/collections/${id}`);
|
|
861
|
+
return response.data;
|
|
862
|
+
},
|
|
863
|
+
/**
|
|
864
|
+
* 更新 collection
|
|
865
|
+
*/
|
|
866
|
+
update: async (id, data) => {
|
|
867
|
+
const response = await this.client.put(`/api/collections/${id}`, data);
|
|
868
|
+
return response.data;
|
|
869
|
+
},
|
|
870
|
+
/**
|
|
871
|
+
* 删除 collection
|
|
872
|
+
*/
|
|
873
|
+
delete: async (id) => {
|
|
874
|
+
await this.client.delete(`/api/collections/${id}`);
|
|
875
|
+
},
|
|
876
|
+
/**
|
|
877
|
+
* 添加商品到 collection
|
|
878
|
+
*/
|
|
879
|
+
addProducts: async (id, productIds) => {
|
|
880
|
+
await this.client.post(`/api/collections/${id}/products`, { product_ids: productIds });
|
|
881
|
+
},
|
|
882
|
+
/**
|
|
883
|
+
* 从 collection 移除商品
|
|
884
|
+
* Note: Backend API 不支持批量删除,需要对每个产品发送单独的 DELETE 请求
|
|
885
|
+
*/
|
|
886
|
+
removeProducts: async (id, productIds) => {
|
|
887
|
+
// 串行删除每个产品
|
|
888
|
+
for (const productId of productIds) {
|
|
889
|
+
await this.client.delete(`/api/collections/${id}/products/${productId}`);
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
/**
|
|
893
|
+
* 列出 collection 中的商品
|
|
894
|
+
*/
|
|
895
|
+
listProducts: async (id, params) => {
|
|
896
|
+
const response = await this.client.get(`/api/collections/${id}/products`, { params });
|
|
897
|
+
return response.data;
|
|
898
|
+
},
|
|
899
|
+
};
|
|
900
|
+
// ==========================================================================
|
|
901
|
+
// Tags 管理
|
|
902
|
+
// ==========================================================================
|
|
903
|
+
tags = {
|
|
904
|
+
/**
|
|
905
|
+
* 列出所有 tags
|
|
906
|
+
*/
|
|
907
|
+
list: async () => {
|
|
908
|
+
const response = await this.client.get('/api/v1/merchants/me/tags');
|
|
909
|
+
return response.data;
|
|
910
|
+
},
|
|
911
|
+
/**
|
|
912
|
+
* 创建 tag
|
|
913
|
+
*/
|
|
914
|
+
create: async (name) => {
|
|
915
|
+
const response = await this.client.post('/api/v1/merchants/me/tags', { name });
|
|
916
|
+
return response.data;
|
|
917
|
+
},
|
|
918
|
+
/**
|
|
919
|
+
* 删除 tag
|
|
920
|
+
*/
|
|
921
|
+
delete: async (name) => {
|
|
922
|
+
await this.client.delete(`/api/v1/merchants/me/tags/${encodeURIComponent(name)}`);
|
|
923
|
+
},
|
|
924
|
+
/**
|
|
925
|
+
* 获取 tag 统计信息
|
|
926
|
+
*/
|
|
927
|
+
stats: async (name) => {
|
|
928
|
+
const response = await this.client.get(`/api/v1/merchants/me/tags/${encodeURIComponent(name)}/stats`);
|
|
929
|
+
return response.data;
|
|
930
|
+
},
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
// 导出单例实例
|
|
934
|
+
export const commerceApi = new CommerceApiClient();
|
|
935
|
+
//# sourceMappingURL=commerce.js.map
|