@youzan-cloud/zan-saas-cli 0.0.0-stage → 0.1.0-beta.4
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/DEPENDENCIES.json +50 -0
- package/INSTALL.md +79 -0
- package/LICENSE +21 -0
- package/NOTICE +1 -0
- package/README.md +151 -2
- package/THIRD_PARTY_NOTICES.txt +162 -0
- package/bin/zan-saas-cli.js +28 -0
- package/internal/registry/index.js +123 -0
- package/internal/registry/manifest.json +424 -0
- package/npm-shrinkwrap.json +86 -0
- package/package.json +33 -4
- package/skills/README.md +30 -0
- package/skills/zan-saas/SKILL.md +54 -0
- package/skills/zan-saas/references/host-entry.md +25 -0
- package/skills/zan-saas-access/SKILL.md +37 -0
- package/skills/zan-saas-access/references/role-list.md +11 -0
- package/skills/zan-saas-access/references/staff-perms-get.md +11 -0
- package/skills/zan-saas-aftersale/SKILL.md +31 -0
- package/skills/zan-saas-aftersale/references/case-list.md +13 -0
- package/skills/zan-saas-aftersale/references/case-scan.md +31 -0
- package/skills/zan-saas-benefit/SKILL.md +46 -0
- package/skills/zan-saas-benefit/references/card-get.md +7 -0
- package/skills/zan-saas-benefit/references/card-grant-list.md +11 -0
- package/skills/zan-saas-benefit/references/card-list.md +7 -0
- package/skills/zan-saas-benefit/references/customer-card-get.md +7 -0
- package/skills/zan-saas-benefit/references/customer-card-list.md +7 -0
- package/skills/zan-saas-coupon/SKILL.md +41 -0
- package/skills/zan-saas-coupon/references/activity-get.md +11 -0
- package/skills/zan-saas-coupon/references/activity-list.md +15 -0
- package/skills/zan-saas-coupon/references/voucher-get.md +13 -0
- package/skills/zan-saas-coupon/references/voucher-list.md +25 -0
- package/skills/zan-saas-customer/SKILL.md +73 -0
- package/skills/zan-saas-customer/references/customer-scan.md +11 -0
- package/skills/zan-saas-customer/references/segment-list.md +22 -0
- package/skills/zan-saas-fulfillment/SKILL.md +36 -0
- package/skills/zan-saas-fulfillment/references/delivery-get.md +11 -0
- package/skills/zan-saas-fulfillment/references/shipment-list.md +11 -0
- package/skills/zan-saas-fulfillment/references/waybill-get.md +9 -0
- package/skills/zan-saas-interaction/SKILL.md +37 -0
- package/skills/zan-saas-interaction/references/lottery-get.md +11 -0
- package/skills/zan-saas-interaction/references/lottery-list.md +19 -0
- package/skills/zan-saas-item/SKILL.md +61 -0
- package/skills/zan-saas-item/references/attribute-list.md +11 -0
- package/skills/zan-saas-item/references/brand-list.md +7 -0
- package/skills/zan-saas-item/references/classification-get.md +7 -0
- package/skills/zan-saas-item/references/classification-list.md +7 -0
- package/skills/zan-saas-item/references/group-list.md +9 -0
- package/skills/zan-saas-item/references/item-content.md +9 -0
- package/skills/zan-saas-item/references/item-get.md +9 -0
- package/skills/zan-saas-item/references/item-search.md +23 -0
- package/skills/zan-saas-item/references/product-identity.md +11 -0
- package/skills/zan-saas-member/SKILL.md +41 -0
- package/skills/zan-saas-member/references/customer-level-get.md +7 -0
- package/skills/zan-saas-member/references/growth-log-list.md +17 -0
- package/skills/zan-saas-member/references/membership-get.md +7 -0
- package/skills/zan-saas-order/SKILL.md +56 -0
- package/skills/zan-saas-order/references/order-get.md +26 -0
- package/skills/zan-saas-order/references/order-list.md +25 -0
- package/skills/zan-saas-order/references/order-scan.md +35 -0
- package/skills/zan-saas-org/SKILL.md +37 -0
- package/skills/zan-saas-org/references/staff-get.md +15 -0
- package/skills/zan-saas-org/references/staff-role-get.md +11 -0
- package/skills/zan-saas-org/references/unit-get.md +11 -0
- package/skills/zan-saas-org/references/unit-list.md +15 -0
- package/skills/zan-saas-points/SKILL.md +42 -0
- package/skills/zan-saas-points/references/account-get.md +7 -0
- package/skills/zan-saas-points/references/log-list.md +17 -0
- package/skills/zan-saas-points/references/rule-list.md +2 -0
- package/skills/zan-saas-privacy/SKILL.md +30 -0
- package/skills/zan-saas-privacy/references/field-decrypt.md +19 -0
- package/skills/zan-saas-shared/SKILL.md +94 -0
- package/skills/zan-saas-shared/references/authentication.md +52 -0
- package/skills/zan-saas-shared/references/value-processing.md +27 -0
- package/skills/zan-saas-stock/SKILL.md +28 -0
- package/skills/zan-saas-stock/references/log-list.md +11 -0
- package/skills/zan-saas-valuecard/SKILL.md +37 -0
- package/skills/zan-saas-valuecard/references/card-get.md +13 -0
- package/skills/zan-saas-valuecard/references/card-list.md +11 -0
- package/src/auth/browser.js +28 -0
- package/src/auth/callback-server.js +99 -0
- package/src/auth/config.js +53 -0
- package/src/auth/credential-store.js +109 -0
- package/src/auth/oauth-client.js +105 -0
- package/src/auth/pkce.js +28 -0
- package/src/auth/session.js +178 -0
- package/src/auth/tool.js +25 -0
- package/src/cli/command-paths.js +126 -0
- package/src/cli/context-help.js +102 -0
- package/src/cli/diagnostic-command.js +57 -0
- package/src/cli/domain-catalog.js +42 -0
- package/src/cli/help-text.js +32 -0
- package/src/cli/native-loader.js +120 -0
- package/src/cli/native-path.js +22 -0
- package/src/cli/parser-policy.js +141 -0
- package/src/cli/program.js +134 -0
- package/src/cli/skill-catalog.js +241 -0
- package/src/commands/native/access/commands.index.json +24 -0
- package/src/commands/native/access/domain.json +3 -0
- package/src/commands/native/access/role/list/command.js +141 -0
- package/src/commands/native/access/role/list/schema.json +393 -0
- package/src/commands/native/access/staff-perms/get/command.js +119 -0
- package/src/commands/native/access/staff-perms/get/schema.json +703 -0
- package/src/commands/native/aftersale/case/get/command.js +104 -0
- package/src/commands/native/aftersale/case/get/exact-json.js +52 -0
- package/src/commands/native/aftersale/case/get/money.js +28 -0
- package/src/commands/native/aftersale/case/get/projection.js +120 -0
- package/src/commands/native/aftersale/case/get/query.js +72 -0
- package/src/commands/native/aftersale/case/get/schema.json +134 -0
- package/src/commands/native/aftersale/case/list/command.js +135 -0
- package/src/commands/native/aftersale/case/list/schema.json +1095 -0
- package/src/commands/native/aftersale/case/scan/command.js +110 -0
- package/src/commands/native/aftersale/case/scan/query.js +62 -0
- package/src/commands/native/aftersale/case/scan/scan.js +78 -0
- package/src/commands/native/aftersale/case/scan/schema.json +964 -0
- package/src/commands/native/aftersale/case/scan/search.js +108 -0
- package/src/commands/native/aftersale/commands.index.json +42 -0
- package/src/commands/native/aftersale/domain.json +3 -0
- package/src/commands/native/aftersale/refund/list/command.js +97 -0
- package/src/commands/native/aftersale/refund/list/money.js +25 -0
- package/src/commands/native/aftersale/refund/list/projection.js +50 -0
- package/src/commands/native/aftersale/refund/list/query.js +73 -0
- package/src/commands/native/aftersale/refund/list/schema.json +130 -0
- package/src/commands/native/aftersale/shared/query.js +58 -0
- package/src/commands/native/aftersale/shared/search.js +128 -0
- package/src/commands/native/benefit/card-definition/get/command.js +110 -0
- package/src/commands/native/benefit/card-definition/get/schema.json +545 -0
- package/src/commands/native/benefit/card-definition/list/command.js +106 -0
- package/src/commands/native/benefit/card-definition/list/schema.json +690 -0
- package/src/commands/native/benefit/card-grant/list/command.js +135 -0
- package/src/commands/native/benefit/card-grant/list/schema.json +758 -0
- package/src/commands/native/benefit/commands.index.json +51 -0
- package/src/commands/native/benefit/customer-card/get/command.js +110 -0
- package/src/commands/native/benefit/customer-card/get/schema.json +340 -0
- package/src/commands/native/benefit/customer-card/list/command.js +103 -0
- package/src/commands/native/benefit/customer-card/list/schema.json +731 -0
- package/src/commands/native/benefit/domain.json +3 -0
- package/src/commands/native/coupon/activity/get/command.js +183 -0
- package/src/commands/native/coupon/activity/get/schema.json +624 -0
- package/src/commands/native/coupon/activity/list/command.js +169 -0
- package/src/commands/native/coupon/activity/list/schema.json +845 -0
- package/src/commands/native/coupon/commands.index.json +42 -0
- package/src/commands/native/coupon/domain.json +3 -0
- package/src/commands/native/coupon/shared/query.js +15 -0
- package/src/commands/native/coupon/voucher/get/command.js +113 -0
- package/src/commands/native/coupon/voucher/get/schema.json +147 -0
- package/src/commands/native/coupon/voucher/list/command.js +155 -0
- package/src/commands/native/coupon/voucher/list/schema.json +772 -0
- package/src/commands/native/customer/commands.index.json +96 -0
- package/src/commands/native/customer/customer/get/adapter.js +82 -0
- package/src/commands/native/customer/customer/get/command.js +106 -0
- package/src/commands/native/customer/customer/get/schema.json +958 -0
- package/src/commands/native/customer/customer/list/command.js +78 -0
- package/src/commands/native/customer/customer/list/input.js +145 -0
- package/src/commands/native/customer/customer/list/query.js +103 -0
- package/src/commands/native/customer/customer/list/schema.json +969 -0
- package/src/commands/native/customer/customer/scan/command.js +80 -0
- package/src/commands/native/customer/customer/scan/scan.js +92 -0
- package/src/commands/native/customer/customer/scan/schema.json +211 -0
- package/src/commands/native/customer/customer-tag/get/command.js +166 -0
- package/src/commands/native/customer/customer-tag/get/schema.json +317 -0
- package/src/commands/native/customer/customer-tag/list/command.js +143 -0
- package/src/commands/native/customer/customer-tag/list/schema.json +259 -0
- package/src/commands/native/customer/domain.json +3 -0
- package/src/commands/native/customer/segment/list/command.js +96 -0
- package/src/commands/native/customer/segment/list/query.js +98 -0
- package/src/commands/native/customer/segment/list/schema.json +135 -0
- package/src/commands/native/customer/segment-customer/list/command.js +171 -0
- package/src/commands/native/customer/segment-customer/list/schema.json +123 -0
- package/src/commands/native/customer/shared/search-input.js +179 -0
- package/src/commands/native/customer/shared/search-page.js +54 -0
- package/src/commands/native/customer/tag/get/command.js +73 -0
- package/src/commands/native/customer/tag/get/schema.json +339 -0
- package/src/commands/native/customer/tagcategory/get/command.js +80 -0
- package/src/commands/native/customer/tagcategory/get/query.js +98 -0
- package/src/commands/native/customer/tagcategory/get/schema.json +339 -0
- package/src/commands/native/customer/tagcategory/list/command.js +127 -0
- package/src/commands/native/customer/tagcategory/list/schema.json +394 -0
- package/src/commands/native/fulfillment/commands.index.json +33 -0
- package/src/commands/native/fulfillment/delivery/get/command.js +107 -0
- package/src/commands/native/fulfillment/delivery/get/projection.js +142 -0
- package/src/commands/native/fulfillment/delivery/get/schema.json +173 -0
- package/src/commands/native/fulfillment/domain.json +3 -0
- package/src/commands/native/fulfillment/shipment/list/command.js +83 -0
- package/src/commands/native/fulfillment/shipment/list/projection.js +130 -0
- package/src/commands/native/fulfillment/shipment/list/schema.json +752 -0
- package/src/commands/native/fulfillment/waybill/get/command.js +193 -0
- package/src/commands/native/fulfillment/waybill/get/response.js +68 -0
- package/src/commands/native/fulfillment/waybill/get/schema.json +190 -0
- package/src/commands/native/interaction/commands.index.json +24 -0
- package/src/commands/native/interaction/domain.json +3 -0
- package/src/commands/native/interaction/lottery/get/command.js +61 -0
- package/src/commands/native/interaction/lottery/get/query.js +152 -0
- package/src/commands/native/interaction/lottery/get/schema.json +1004 -0
- package/src/commands/native/interaction/lottery/list/command.js +176 -0
- package/src/commands/native/interaction/lottery/list/schema.json +898 -0
- package/src/commands/native/item/attribute/list/command.js +122 -0
- package/src/commands/native/item/attribute/list/schema.json +727 -0
- package/src/commands/native/item/brand/list/command.js +114 -0
- package/src/commands/native/item/brand/list/schema.json +725 -0
- package/src/commands/native/item/classification/get/command.js +87 -0
- package/src/commands/native/item/classification/get/schema.json +596 -0
- package/src/commands/native/item/classification/list/command.js +105 -0
- package/src/commands/native/item/classification/list/schema.json +676 -0
- package/src/commands/native/item/commands.index.json +87 -0
- package/src/commands/native/item/domain.json +1 -0
- package/src/commands/native/item/group/list/command.js +122 -0
- package/src/commands/native/item/group/list/schema.json +809 -0
- package/src/commands/native/item/item/get/command.js +122 -0
- package/src/commands/native/item/item/get/schema.json +3799 -0
- package/src/commands/native/item/item/list/command.js +7 -0
- package/src/commands/native/item/item/list/schema.json +1118 -0
- package/src/commands/native/item/item/scan/command.js +7 -0
- package/src/commands/native/item/item/scan/schema.json +1046 -0
- package/src/commands/native/item/item-content/get/command.js +54 -0
- package/src/commands/native/item/item-content/get/schema.json +677 -0
- package/src/commands/native/item/shared/api.js +31 -0
- package/src/commands/native/item/shared/content.js +20 -0
- package/src/commands/native/item/shared/diagnostics.js +61 -0
- package/src/commands/native/item/shared/h5.js +63 -0
- package/src/commands/native/item/shared/identity.js +62 -0
- package/src/commands/native/item/shared/normalize.js +49 -0
- package/src/commands/native/item/shared/scope.js +22 -0
- package/src/commands/native/item/shared/search-command.js +61 -0
- package/src/commands/native/item/shared/search-options.js +150 -0
- package/src/commands/native/item/shared/search.js +158 -0
- package/src/commands/native/member/commands.index.json +60 -0
- package/src/commands/native/member/customer-level/get/command.js +122 -0
- package/src/commands/native/member/customer-level/get/schema.json +300 -0
- package/src/commands/native/member/domain.json +3 -0
- package/src/commands/native/member/growth/get/command.js +64 -0
- package/src/commands/native/member/growth/get/schema.json +283 -0
- package/src/commands/native/member/growth-log/list/command.js +203 -0
- package/src/commands/native/member/growth-log/list/schema.json +695 -0
- package/src/commands/native/member/level/get/command.js +70 -0
- package/src/commands/native/member/level/get/query.js +125 -0
- package/src/commands/native/member/level/get/schema.json +339 -0
- package/src/commands/native/member/level/list/command.js +50 -0
- package/src/commands/native/member/level/list/query.js +109 -0
- package/src/commands/native/member/level/list/schema.json +104 -0
- package/src/commands/native/member/membership/get/command.js +78 -0
- package/src/commands/native/member/membership/get/schema.json +283 -0
- package/src/commands/native/order/commands.index.json +33 -0
- package/src/commands/native/order/domain.json +3 -0
- package/src/commands/native/order/order/get/command.js +155 -0
- package/src/commands/native/order/order/get/schema.json +1167 -0
- package/src/commands/native/order/order/list/command.js +230 -0
- package/src/commands/native/order/order/list/schema.json +1363 -0
- package/src/commands/native/order/order/scan/command.js +148 -0
- package/src/commands/native/order/order/scan/scan.js +89 -0
- package/src/commands/native/order/order/scan/schema.json +1445 -0
- package/src/commands/native/order/shared/projection.js +183 -0
- package/src/commands/native/order/shared/query.js +84 -0
- package/src/commands/native/order/shared/search.js +112 -0
- package/src/commands/native/org/commands.index.json +42 -0
- package/src/commands/native/org/domain.json +3 -0
- package/src/commands/native/org/shared/single-staff.js +115 -0
- package/src/commands/native/org/staff/get/command.js +148 -0
- package/src/commands/native/org/staff/get/schema.json +114 -0
- package/src/commands/native/org/staff-role/get/command.js +45 -0
- package/src/commands/native/org/staff-role/get/schema.json +93 -0
- package/src/commands/native/org/unit/get/command.js +131 -0
- package/src/commands/native/org/unit/get/schema.json +478 -0
- package/src/commands/native/org/unit/list/command.js +187 -0
- package/src/commands/native/org/unit/list/schema.json +828 -0
- package/src/commands/native/points/account/get/command.js +65 -0
- package/src/commands/native/points/account/get/schema.json +303 -0
- package/src/commands/native/points/commands.index.json +33 -0
- package/src/commands/native/points/domain.json +3 -0
- package/src/commands/native/points/log/list/command.js +141 -0
- package/src/commands/native/points/log/list/schema.json +761 -0
- package/src/commands/native/points/rule/list/command.js +82 -0
- package/src/commands/native/points/rule/list/schema.json +294 -0
- package/src/commands/native/privacy/commands.index.json +15 -0
- package/src/commands/native/privacy/domain.json +3 -0
- package/src/commands/native/privacy/field/decrypt/command.js +185 -0
- package/src/commands/native/privacy/field/decrypt/schema.json +656 -0
- package/src/commands/native/privacy/shared/order-source.js +33 -0
- package/src/commands/native/stock/commands.index.json +15 -0
- package/src/commands/native/stock/domain.json +3 -0
- package/src/commands/native/stock/log/list/command.js +207 -0
- package/src/commands/native/stock/log/list/schema.json +922 -0
- package/src/commands/native/valuecard/card/get/command.js +107 -0
- package/src/commands/native/valuecard/card/get/schema.json +683 -0
- package/src/commands/native/valuecard/card/list/command.js +136 -0
- package/src/commands/native/valuecard/card/list/pagination.js +23 -0
- package/src/commands/native/valuecard/card/list/schema.json +780 -0
- package/src/commands/native/valuecard/commands.index.json +24 -0
- package/src/commands/native/valuecard/domain.json +3 -0
- package/src/commands/native/valuecard/shared/projection.js +57 -0
- package/src/commands/system/api.js +47 -0
- package/src/commands/system/auth.js +118 -0
- package/src/commands/system/contracts.js +373 -0
- package/src/commands/system/doctor.js +24 -0
- package/src/commands/system/install.js +41 -0
- package/src/commands/system/printer.js +16 -0
- package/src/commands/system/schema.js +162 -0
- package/src/commands/system/shop-guidance.js +9 -0
- package/src/commands/system/shop.js +237 -0
- package/src/commands/system/skills.js +49 -0
- package/src/execution/beijing-date-time.js +29 -0
- package/src/execution/beijing-time.js +21 -0
- package/src/execution/bounded-input.js +42 -0
- package/src/execution/command-io.js +137 -0
- package/src/execution/command-policy.js +41 -0
- package/src/execution/command-schema.js +131 -0
- package/src/execution/datetime.js +83 -0
- package/src/execution/error-details.js +399 -0
- package/src/execution/error-model.js +82 -0
- package/src/execution/exact-json.js +80 -0
- package/src/execution/list-total.js +10 -0
- package/src/execution/money.js +59 -0
- package/src/execution/parser-error.js +66 -0
- package/src/execution/privacy.js +197 -0
- package/src/execution/public-schema.js +52 -0
- package/src/execution/query-api.js +101 -0
- package/src/execution/range.js +84 -0
- package/src/execution/request-state.js +55 -0
- package/src/execution/schema-completeness.js +116 -0
- package/src/execution/shop-query.js +54 -0
- package/src/execution/target-shop-default.js +23 -0
- package/src/execution/target-shop.js +49 -0
- package/src/identity/context-store.js +54 -0
- package/src/identity/context.js +38 -0
- package/src/installation/install.js +158 -0
- package/src/installation/npm-error.js +93 -0
- package/src/installation/skill.js +113 -0
- package/src/transport/account-api.js +152 -0
- package/src/transport/api.js +199 -0
- package/src/transport/shop-app.js +63 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
|
|
4
|
+
|
|
5
|
+
const { Option } = require('commander');
|
|
6
|
+
const { DiagnosticCommand } = require('../../../../../cli/diagnostic-command');
|
|
7
|
+
const { inputIssue, withInputScope } = require('../../../../../execution/error-details');
|
|
8
|
+
const diagnostics = require('../../shared/diagnostics');
|
|
9
|
+
const schema = require('./schema.json');
|
|
10
|
+
const { queryDefinition, validateCommandValue } = require('../../../../../execution/command-schema');
|
|
11
|
+
const { parseIncludeModules, validateRequiredModules } = require('../../../../../execution/command-io');
|
|
12
|
+
const { readApi, ItemQueryError, object } = require('../../shared/api');
|
|
13
|
+
const { normalizeItem } = require('../../shared/normalize');
|
|
14
|
+
const { attachH5, SHOP_API, ORG_API, PAGE_SIZE, MAX_PAGES } = require('../../shared/h5');
|
|
15
|
+
|
|
16
|
+
const { contentRequest, readContent } = require('../../shared/content');
|
|
17
|
+
const { resolveTargetShop } = require('../../../../../execution/target-shop');
|
|
18
|
+
const DETAIL_API = schema.api.path;
|
|
19
|
+
const GROUP_API = 'youzan.item.itemgroup.get/1.0.0';
|
|
20
|
+
const { baseModules, includeModules: allowedModules } = queryDefinition(schema);
|
|
21
|
+
|
|
22
|
+
function buildInput(options, context) {
|
|
23
|
+
const kdtId = Object.hasOwn(options, 'kdtId') ? options.kdtId :
|
|
24
|
+
String(resolveTargetShop(options, context, 'item.item.get').kdtId);
|
|
25
|
+
const scope = diagnostics.itemScope({ ...options, kdtId }, schema);
|
|
26
|
+
return withInputScope(scope, () => {
|
|
27
|
+
if (options.include !== undefined && options.include.split(',').some(value => !value.trim())) {
|
|
28
|
+
throw inputIssue('/include', 'invalid_format', { type: 'array', items: { enum: allowedModules } });
|
|
29
|
+
}
|
|
30
|
+
if (options.include?.split(',').some(value => !allowedModules.includes(value.trim()))) {
|
|
31
|
+
throw inputIssue('/include', 'invalid_choice', { type: 'array', items: { enum: allowedModules } });
|
|
32
|
+
}
|
|
33
|
+
const modules = parseIncludeModules(options.include, allowedModules);
|
|
34
|
+
validateCommandValue(schema, 'input', { ...scope, include: [...modules] });
|
|
35
|
+
return { scope, modules, body: { request: { kdt_id: scope.kdtId, item_id: scope.item_id, channel: scope.channel } } };
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function preview(input) {
|
|
39
|
+
const requests = [{ method: 'POST', path: DETAIL_API, body: input.body }];
|
|
40
|
+
if (input.modules.has('group')) requests.push({ method: 'POST', path: GROUP_API, body: input.body });
|
|
41
|
+
requests.push({ method: 'POST', path: SHOP_API, body: {} });
|
|
42
|
+
if (input.modules.has('content')) requests.push(contentRequest(input.scope));
|
|
43
|
+
const result = {
|
|
44
|
+
requests,
|
|
45
|
+
conditionalRequests: [{
|
|
46
|
+
condition: '授权店铺为总部且与目标店铺不同:按页查询目标角色,找到即停;失败则停止后续请求。',
|
|
47
|
+
request: { method: 'POST', path: ORG_API, body: { page_num: 1, page_size: PAGE_SIZE } },
|
|
48
|
+
maxPages: MAX_PAGES
|
|
49
|
+
}]
|
|
50
|
+
};
|
|
51
|
+
validateCommandValue(schema, 'preview', result);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
async function execute(input) {
|
|
55
|
+
const { scope, body, modules } = input;
|
|
56
|
+
const raw = await readApi(DETAIL_API, body, 'item', scope);
|
|
57
|
+
const invalidIdentity = () => new ItemQueryError(raw == null ? 'not_found' : 'protocol', 'item', scope, { api: DETAIL_API }, 'sent');
|
|
58
|
+
if (!object(raw)) throw diagnostics.outputIssue(invalidIdentity, schema, '/data/item', 'invalid_type');
|
|
59
|
+
for (const [field, expected] of [['item_id', scope.item_id], ['kdt_id', scope.kdtId], ['channel', scope.channel]]) {
|
|
60
|
+
if ((field === 'item_id' || raw[field] != null) && raw[field] !== expected) {
|
|
61
|
+
throw diagnostics.outputIssue(invalidIdentity, schema, `/data/item/${field}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const data = {};
|
|
65
|
+
// Validate before auxiliary requests; diagnostic paths never contain received values.
|
|
66
|
+
const invalidItem = () => new ItemQueryError('protocol', 'item-model', scope, { api: DETAIL_API }, 'sent');
|
|
67
|
+
data.item = diagnostics.normalize(normalizeItem(raw), schema, '/data/item', invalidItem);
|
|
68
|
+
delete data.item.group;
|
|
69
|
+
delete data.item.content;
|
|
70
|
+
delete data.item.components;
|
|
71
|
+
diagnostics.validateOutput(schema, { data: { item: { ...data.item, h5_url: null } } }, invalidItem);
|
|
72
|
+
if (modules.has('group')) {
|
|
73
|
+
data.group = await readApi(GROUP_API, body, 'group', scope);
|
|
74
|
+
if (!Array.isArray(data.group)) throw new ItemQueryError('protocol', 'group', scope, { api: GROUP_API }, 'sent');
|
|
75
|
+
}
|
|
76
|
+
await attachH5(data.item, scope);
|
|
77
|
+
if (modules.has('content')) {
|
|
78
|
+
data.content = await readContent(scope);
|
|
79
|
+
}
|
|
80
|
+
validateRequiredModules(data, modules, baseModules);
|
|
81
|
+
const result = { data };
|
|
82
|
+
diagnostics.validateOutput(schema, result, () => new ItemQueryError('protocol', 'output-model', scope, {}, 'sent'));
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
function createCommand({ context } = {}) {
|
|
86
|
+
return new DiagnosticCommand('get', { path: 'item.item.get', schema, parameterCategory: 'parameter', optionPaths: { '/item_id': 'itemId' } })
|
|
87
|
+
.description('查询指定店铺和渠道的单个商品,含规格、SKU 和适用的 H5 链接')
|
|
88
|
+
.allowExcessArguments(false)
|
|
89
|
+
.option('--kdt-id <id>', '目标店铺 ID;省略时使用当前上下文店铺')
|
|
90
|
+
.requiredOption('--item-id <id>', '必填:新版商品 ID,同一商品在分店和渠道间保持相同;不是渠道商品 ID')
|
|
91
|
+
.option('--channel <channel>', '渠道:0 网店,1 门店', '0')
|
|
92
|
+
.option('--include <modules>', `追加模块:${allowedModules.join(', ')};始终保留商品基本信息`)
|
|
93
|
+
.addOption(new Option('--format <format>', 'json 或 pretty(仅改变缩进)').choices(['json', 'pretty']).default('json'))
|
|
94
|
+
.option('--dry-run', '本地预览固定请求与条件请求,不读凭证、不联网')
|
|
95
|
+
.addHelpText('after', `
|
|
96
|
+
时间点统一输出北京时间 YYYY-MM-DD HH:mm:ss.SSS,字段声明的业务哨兵保留。
|
|
97
|
+
默认返回 data.item,不返回库存数量;当前版本只提供库存变化日志,尚无当前库存数量查询入口。
|
|
98
|
+
商品 item_id、规格 sku_id 为统一标识;channel_item_id、channel_sku_id 为目标店铺渠道的标识。
|
|
99
|
+
以商品 ID 和渠道定位,不接收渠道商品 ID 作为替代;输出缺少渠道标识时不使用统一标识补造。
|
|
100
|
+
已定义金额统一为元、固定两位小数字符串;划线价已为元不再除100,原空串/null/省略保留。
|
|
101
|
+
--include group 追加 data.group 分组数组;content 追加 data.content 图文对象。
|
|
102
|
+
默认 H5 需查询店铺角色,总部查目标分店时还需分页查询组织(50/页,最多100页)。
|
|
103
|
+
任何必需查询失败则整体失败,stdout 为空;不将未知角色当作无链接。
|
|
104
|
+
网店/门店渠道不可任意互查,适用范围见同版 Skill reference。
|
|
105
|
+
|
|
106
|
+
示例:
|
|
107
|
+
zan-saas item item get --kdt-id 63077 --item-id 123
|
|
108
|
+
zan-saas item item get --kdt-id 63077 --item-id 123 --include group,content
|
|
109
|
+
zan-saas item item get --kdt-id 63077 --item-id 123 --channel 1 --dry-run
|
|
110
|
+
|
|
111
|
+
执行需要有效的用户、组织与店铺上下文,可通过登录后选店或 ZAN_SAAS_CONTEXT 提供;目标范围和服务端授权按本命令契约校验,公共调用前置见 zan-saas skills read zan-saas-shared。
|
|
112
|
+
at: all 允许总部和非总部位置;目标店铺可显式指定或取当前上下文,由服务端校验用户和店铺权限。
|
|
113
|
+
缺少上下文时可本地 --dry-run;提供了无效上下文时拒绝预览和真实调用。
|
|
114
|
+
无自动重试,不自动切换店铺、渠道或凭证。`)
|
|
115
|
+
.action(async options => {
|
|
116
|
+
const input = buildInput(options, context);
|
|
117
|
+
const result = options.dryRun ? preview(input) : await execute(input);
|
|
118
|
+
process.stdout.write(`${JSON.stringify(result, null, options.format === 'pretty' ? 2 : 0)}\n`);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'all' };
|
|
122
|
+
module.exports.createCommand = withTargetShopDefault(createCommand);
|