@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,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"api": { "method": "POST", "path": "youzan.scrm.level.list/3.0.0" },
|
|
4
|
+
"input": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "参数及上下文补全后的业务输入,不是 CLI 接收的 JSON。format 和 dry-run 是调用控制,不进入业务模型。",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["kdtId"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"kdtId": { "$ref": "#/definitions/shopId" },
|
|
11
|
+
"levelType": { "type": "integer", "enum": [1, 2], "description": "1=免费等级,2=付费等级。省略依次读取两类。" }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"output": {
|
|
15
|
+
"type": "object", "additionalProperties": false, "required": ["data"],
|
|
16
|
+
"description": "所有必要类型成功后的当前目录;不提供历史或客户实际等级。",
|
|
17
|
+
"properties": {
|
|
18
|
+
"data": {
|
|
19
|
+
"type": "object", "additionalProperties": false, "required": ["levels"],
|
|
20
|
+
"description": "完整成功的本次查询结果。",
|
|
21
|
+
"properties": {
|
|
22
|
+
"levels": {
|
|
23
|
+
"type": "array", "maxItems": 2000,
|
|
24
|
+
"description": "默认先免费后付费,各类保持响应原序,保留禁用与零值。同类型 alias 不重复,跨类型可同名。不分页;明确成功空集合才返回 [],不承诺跨请求强一致快照。",
|
|
25
|
+
"items": {
|
|
26
|
+
"type": "object", "additionalProperties": false,
|
|
27
|
+
"required": ["level_alias", "name", "level_type", "level_value", "is_enabled"],
|
|
28
|
+
"properties": {
|
|
29
|
+
"level_alias": { "type": "string", "minLength": 1, "pattern": "\\S", "description": "完整等级别名,保留大小写;与类型组合引用定义,不是名称或数值 ID。" },
|
|
30
|
+
"name": { "type": "string", "description": "等级名称,明确空串保留。" },
|
|
31
|
+
"level_type": { "type": "integer", "enum": [1, 2], "description": "1=免费等级,2=付费等级,必须匹配本次请求类型。" },
|
|
32
|
+
"level_value": { "type": "integer", "minimum": -2147483648, "maximum": 2147483647, "description": "32位有符号等级值,保留0;不是定义 ID 或排序保证。" },
|
|
33
|
+
"is_enabled": { "type": "boolean", "description": "true=启用,false=禁用;禁用定义不被过滤。" },
|
|
34
|
+
"level_id": { "type": "string", "pattern": "^[1-9]\\d*$", "description": "源实际返回的正十进制等级定义 ID,无损转文本。源缺省时省略,不能用等级值或其它 ID 补造。缺失时不可用于需要数值定义 ID 的客户搜索。" },
|
|
35
|
+
"min_growth": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991, "description": "源返回的成长门槛,保留安全整数原值。未返回时省略,不能据此推算客户实际等级。" }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"preview": {
|
|
44
|
+
"type": "object", "additionalProperties": false, "required": ["scope", "requests"],
|
|
45
|
+
"description": "零凭证、零网络的本地目标及完整请求计划,不证明权限或实际目录数量。",
|
|
46
|
+
"properties": {
|
|
47
|
+
"scope": { "type": "object", "additionalProperties": false, "required": ["kdtId"], "description": "本次固定目标店铺。", "properties": { "kdtId": { "$ref": "#/definitions/shopId" } } },
|
|
48
|
+
"requests": {
|
|
49
|
+
"type": "array", "minItems": 2, "maxItems": 3,
|
|
50
|
+
"description": "先核验店铺,再请求指定类型一次或依次请求1、2;没有分页或动态请求。",
|
|
51
|
+
"items": {
|
|
52
|
+
"type": "object", "additionalProperties": false, "required": ["method", "path", "body"],
|
|
53
|
+
"properties": {
|
|
54
|
+
"method": { "const": "POST", "description": "请求方法。" },
|
|
55
|
+
"path": { "enum": ["youzan.shop.basic.get/3.0.0", "youzan.scrm.level.list/3.0.0"], "description": "店铺核验或等级目录请求的完整路径。" },
|
|
56
|
+
"body": { "type": "object", "additionalProperties": false, "description": "核验请求为空对象;目录请求仅含整数 level_type,不发送 kdt_id。", "properties": { "level_type": { "type": "integer", "enum": [1, 2], "description": "1=免费等级,2=付费等级。" } } }
|
|
57
|
+
},
|
|
58
|
+
"oneOf": [
|
|
59
|
+
{ "properties": { "path": { "const": "youzan.shop.basic.get/3.0.0" }, "body": { "type": "object", "maxProperties": 0 } } },
|
|
60
|
+
{ "properties": { "path": { "const": "youzan.scrm.level.list/3.0.0" }, "body": { "type": "object", "required": ["level_type"], "properties": { "level_type": { "type": "integer", "enum": [1, 2] } } } } }
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"error": {
|
|
67
|
+
"type": "object", "additionalProperties": false, "required": ["success", "code", "message", "details"],
|
|
68
|
+
"properties": {
|
|
69
|
+
"success": { "const": false, "description": "固定失败标记。" },
|
|
70
|
+
"code": { "const": -10001, "description": "统一 CLI 失败码。" },
|
|
71
|
+
"message": { "type": "string", "minLength": 1, "description": "受控说明,不回显源正文或自由消息。" },
|
|
72
|
+
"details": {
|
|
73
|
+
"type": "object", "additionalProperties": false,
|
|
74
|
+
"required": ["command", "category", "stage", "targetScope", "requestState", "nextStep"],
|
|
75
|
+
"properties": {
|
|
76
|
+
"command": { "const": "member.level.list", "description": "失败命令。" },
|
|
77
|
+
"category": { "enum": ["validation", "parameter", "configuration", "permission", "authentication", "scope_unresolved", "http", "business_rejected", "transport", "protocol", "limit"], "description": "validation=业务输入,parameter=argv,configuration=环境或上下文,permission=权限,authentication=认证,scope_unresolved=店铺不匹配,http=HTTP拒绝,business_rejected=业务拒绝,transport=传输未知,protocol=信封、字段或重复键错误,limit=数量或字节预算。" },
|
|
78
|
+
"stage": { "enum": ["input", "context", "configuration", "shop-binding", "levels", "output"], "description": "input=参数,context=上下文,configuration=凭证环境,shop-binding=店铺核验,levels=目录读取或模型,output=序列化。" },
|
|
79
|
+
"targetScope": { "type": "object", "additionalProperties": false, "description": "已验证目标,未知时为空对象。", "properties": { "kdtId": { "$ref": "#/definitions/shopId" } } },
|
|
80
|
+
"requestState": { "enum": ["not_sent", "sent", "unknown"], "description": "not_sent=失败请求未发送,sent=已收到响应但不证明成功,unknown=发送或响应结果不明。" },
|
|
81
|
+
"nextStep": { "type": "string", "minLength": 1, "description": "保持原目标和所选类型排查,不自动重试或切换身份。" },
|
|
82
|
+
"api": { "type": "string", "description": "实际失败请求的 API 名称及版本。" },
|
|
83
|
+
"httpStatus": { "type": "integer", "minimum": 100, "maximum": 599, "description": "已观察 HTTP 状态。" },
|
|
84
|
+
"businessCode": { "$ref": "#/definitions/diagnosticCode" },
|
|
85
|
+
"gatewayCode": { "$ref": "#/definitions/diagnosticCode" },
|
|
86
|
+
"trace_id": { "$ref": "#/definitions/traceId" },
|
|
87
|
+
"request_id": { "$ref": "#/definitions/traceId" }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"definitions": {
|
|
93
|
+
"shopId": { "type": "integer", "minimum": 1, "maximum": 9007199254740991, "description": "目标店铺安全正整数。省略 --kdt-id 时取有效上下文 shopId;显式非法值不得回退,非总部不得跨店。" },
|
|
94
|
+
"diagnosticCode": { "anyOf": [{ "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "string", "pattern": "^-?\\d{1,12}$" }], "description": "白名单诊断码,安全整数或最多12位数字文本。" },
|
|
95
|
+
"traceId": { "type": "string", "pattern": "^[a-zA-Z0-9_-]{1,128}$", "description": "脱敏请求追踪标识,仅保留字母数字、下划线和连字符。" }
|
|
96
|
+
},
|
|
97
|
+
"success": { "description": "同一凭证及目标快照先通过店铺核验,所有必要类型成功且每条核心模型、可选已返回字段及复合定义键合法才成功。核心缺失或可选已返回 null、错型均失败。" },
|
|
98
|
+
"errors": { "description": "失败 stdout 为空,stderr 一份 JSON 加换行,退出1;任一必要请求失败不输出部分目录。不重试、不移除失败类型、不换源。" },
|
|
99
|
+
"notes": [
|
|
100
|
+
"默认3次业务请求,指定类型2次,包含一次店铺核验;默认两次计费目录调用,费用遵循应用合同。每请求10秒,累计原始响应10MiB,含换行最终输出5MiB,每类1000条、组合2000条。超预算整体失败,不截断。",
|
|
101
|
+
"真实执行需有效 userId、hq、shopId、orgType 四字段上下文及同店授权。无上下文仅允许显式合法目标的 dry-run;无效上下文始终拒绝。店铺核验、应用身份测试不证明员工 OAuth 或跨店权限。",
|
|
102
|
+
"目录是当前定义,不代表客户实际拥有等级。可用完整 alias 及类型调用 member level get;缺少 level_id 时不能据此构造客户搜索的 level_ids。未返回权益或历史不表示不存在。"
|
|
103
|
+
]
|
|
104
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
|
|
4
|
+
|
|
5
|
+
const { Command, Option } = require('commander');
|
|
6
|
+
const schema = require('./schema.json');
|
|
7
|
+
const { resolveTargetShop } = require('../../../../../execution/target-shop');
|
|
8
|
+
const { validateCommandValue } = require('../../../../../execution/command-schema');
|
|
9
|
+
const { object } = require('../../../../../execution/query-api');
|
|
10
|
+
const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
|
|
11
|
+
|
|
12
|
+
const command = 'member.membership.get';
|
|
13
|
+
const reject = (category, stage, scope, state, facts) =>
|
|
14
|
+
failure(command, category, stage, scope, state, facts);
|
|
15
|
+
|
|
16
|
+
function buildInput(options, context) {
|
|
17
|
+
const scope = resolveTargetShop(options, context, command);
|
|
18
|
+
let input;
|
|
19
|
+
try {
|
|
20
|
+
input = { ...scope, yzOpenId: options.yzOpenId.trim() };
|
|
21
|
+
validateCommandValue(schema, 'input', input);
|
|
22
|
+
} catch {
|
|
23
|
+
throw reject('parameter', 'input', scope);
|
|
24
|
+
}
|
|
25
|
+
return Object.freeze(input);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function previewFor(input) {
|
|
29
|
+
return {
|
|
30
|
+
method: 'POST', path: schema.api.path, body: { yz_open_ids: [input.yzOpenId] },
|
|
31
|
+
scope: { kdtId: input.kdtId },
|
|
32
|
+
prerequisites: [{ method: 'POST', path: bindingPath, body: {} }]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function execute(input, preview) {
|
|
37
|
+
const scope = { kdtId: input.kdtId };
|
|
38
|
+
const read = await createShopQuery(scope, command);
|
|
39
|
+
const { data, facts } = await read(preview.path, preview.body, 'membership');
|
|
40
|
+
const invalid = category => reject(category, 'membership-model', scope, 'sent', facts);
|
|
41
|
+
if (!Array.isArray(data)) throw invalid('protocol');
|
|
42
|
+
if (data.length === 0) throw invalid('not_found');
|
|
43
|
+
if (data.length !== 1 || !object(data[0])) throw invalid('protocol');
|
|
44
|
+
const row = data[0];
|
|
45
|
+
if (typeof row.yz_open_id !== 'string') throw invalid('protocol');
|
|
46
|
+
if (row.yz_open_id !== input.yzOpenId) throw invalid('target_mismatch');
|
|
47
|
+
if (!object(row.label_info) || typeof row.label_info.is_member !== 'boolean') {
|
|
48
|
+
throw invalid('protocol');
|
|
49
|
+
}
|
|
50
|
+
const output = { data: { membership: { is_member: row.label_info.is_member } } };
|
|
51
|
+
validateCommandValue(schema, 'output', output);
|
|
52
|
+
return output;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function createCommand({ context } = {}) {
|
|
56
|
+
return new Command('get')
|
|
57
|
+
.description('查询一个客户明确的会员标记;未返回客户不能视为非会员')
|
|
58
|
+
.allowExcessArguments(false)
|
|
59
|
+
.exitOverride(error => {
|
|
60
|
+
if (['commander.helpDisplayed', 'commander.version'].includes(error.code)) throw error;
|
|
61
|
+
throw reject('parameter', 'input');
|
|
62
|
+
})
|
|
63
|
+
.requiredOption('--yz-open-id <id>', '必填:客户的 yzOpenId;不是手机号或员工 ID')
|
|
64
|
+
.option('--kdt-id <id>', '目标店铺正安全整数;省略取本次有效上下文 shopId,非总部不可跨店')
|
|
65
|
+
.addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
|
|
66
|
+
.choices(['json', 'pretty']).default('json'))
|
|
67
|
+
.option('--dry-run', '仅本地预览主请求与店铺核验请求;不读凭证、不联网')
|
|
68
|
+
.addHelpText('after', '\n输出:data.membership.is_member 为 Boolean。只支持已核实的微商城单店及连锁 D 总部/网店/合伙人;不承诺零售单店。\n执行需四字段上下文及同店铺授权凭证,先只读核验凭证店铺;不证明员工 OAuth。\n契约:zan-saas schema member.membership.get --format json\n示例:zan-saas member membership get --yz-open-id customer-1 --kdt-id 63077 --dry-run')
|
|
69
|
+
.action(async options => {
|
|
70
|
+
const input = buildInput(options, context);
|
|
71
|
+
const preview = previewFor(input);
|
|
72
|
+
validateCommandValue(schema, 'preview', preview);
|
|
73
|
+
const result = options.dryRun ? preview : await execute(input, preview);
|
|
74
|
+
console.log(JSON.stringify(result, null, options.format === 'pretty' ? 2 : 0));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"input": {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"kdtId",
|
|
7
|
+
"yzOpenId"
|
|
8
|
+
],
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"kdtId": {
|
|
12
|
+
"$ref": "#/definitions/shopId"
|
|
13
|
+
},
|
|
14
|
+
"yzOpenId": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"minLength": 1,
|
|
17
|
+
"pattern": "^\\S(?:[\\s\\S]*\\S)?$",
|
|
18
|
+
"description": "去除首尾空白后的单个客户 yzOpenId,不是手机号、微信 openId 或员工 ID。"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"description": "CLI 解析参数并完成必要上下文补全后的业务输入;不是直接传入 CLI 的 JSON。原始选项、必填条件和默认值见 options。"
|
|
22
|
+
},
|
|
23
|
+
"output": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"required": [
|
|
26
|
+
"data"
|
|
27
|
+
],
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"properties": {
|
|
30
|
+
"data": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"required": [
|
|
33
|
+
"membership"
|
|
34
|
+
],
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": {
|
|
37
|
+
"membership": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"required": [
|
|
40
|
+
"is_member"
|
|
41
|
+
],
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"properties": {
|
|
44
|
+
"is_member": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "匹配客户明确的会员标记;false 是明确非会员,空集合或缺字段不等于 false。"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"preview": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"required": [
|
|
57
|
+
"method",
|
|
58
|
+
"path",
|
|
59
|
+
"body",
|
|
60
|
+
"scope",
|
|
61
|
+
"prerequisites"
|
|
62
|
+
],
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"properties": {
|
|
65
|
+
"method": {
|
|
66
|
+
"const": "POST"
|
|
67
|
+
},
|
|
68
|
+
"path": {
|
|
69
|
+
"const": "youzan.scrm.customer.list.yzopenid/1.0.0"
|
|
70
|
+
},
|
|
71
|
+
"body": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"required": [
|
|
74
|
+
"yz_open_ids"
|
|
75
|
+
],
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"properties": {
|
|
78
|
+
"yz_open_ids": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"minItems": 1,
|
|
81
|
+
"maxItems": 1,
|
|
82
|
+
"items": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"minLength": 1
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"scope": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"required": [
|
|
92
|
+
"kdtId"
|
|
93
|
+
],
|
|
94
|
+
"additionalProperties": false,
|
|
95
|
+
"properties": {
|
|
96
|
+
"kdtId": {
|
|
97
|
+
"$ref": "#/definitions/shopId"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"prerequisites": {
|
|
102
|
+
"type": "array",
|
|
103
|
+
"minItems": 1,
|
|
104
|
+
"maxItems": 1,
|
|
105
|
+
"items": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"required": [
|
|
108
|
+
"method",
|
|
109
|
+
"path",
|
|
110
|
+
"body"
|
|
111
|
+
],
|
|
112
|
+
"additionalProperties": false,
|
|
113
|
+
"properties": {
|
|
114
|
+
"method": {
|
|
115
|
+
"const": "POST"
|
|
116
|
+
},
|
|
117
|
+
"path": {
|
|
118
|
+
"const": "youzan.shop.basic.get/3.0.0"
|
|
119
|
+
},
|
|
120
|
+
"body": {
|
|
121
|
+
"type": "object",
|
|
122
|
+
"additionalProperties": false
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"error": {
|
|
130
|
+
"type": "object",
|
|
131
|
+
"required": [
|
|
132
|
+
"success",
|
|
133
|
+
"code",
|
|
134
|
+
"message",
|
|
135
|
+
"details"
|
|
136
|
+
],
|
|
137
|
+
"additionalProperties": false,
|
|
138
|
+
"properties": {
|
|
139
|
+
"success": {
|
|
140
|
+
"const": false
|
|
141
|
+
},
|
|
142
|
+
"code": {
|
|
143
|
+
"const": -10001
|
|
144
|
+
},
|
|
145
|
+
"message": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"minLength": 1
|
|
148
|
+
},
|
|
149
|
+
"details": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"required": [
|
|
152
|
+
"category",
|
|
153
|
+
"stage",
|
|
154
|
+
"command",
|
|
155
|
+
"targetScope",
|
|
156
|
+
"requestState",
|
|
157
|
+
"nextStep"
|
|
158
|
+
],
|
|
159
|
+
"additionalProperties": false,
|
|
160
|
+
"properties": {
|
|
161
|
+
"category": {
|
|
162
|
+
"type": "string",
|
|
163
|
+
"enum": [
|
|
164
|
+
"validation",
|
|
165
|
+
"configuration",
|
|
166
|
+
"parameter",
|
|
167
|
+
"permission",
|
|
168
|
+
"authentication",
|
|
169
|
+
"scope_unresolved",
|
|
170
|
+
"transport",
|
|
171
|
+
"http",
|
|
172
|
+
"protocol",
|
|
173
|
+
"business_rejected",
|
|
174
|
+
"not_found",
|
|
175
|
+
"target_mismatch"
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"stage": {
|
|
179
|
+
"type": "string",
|
|
180
|
+
"enum": [
|
|
181
|
+
"validation",
|
|
182
|
+
"context",
|
|
183
|
+
"scope",
|
|
184
|
+
"input",
|
|
185
|
+
"configuration",
|
|
186
|
+
"shop-binding",
|
|
187
|
+
"membership",
|
|
188
|
+
"membership-model"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
"command": {
|
|
192
|
+
"const": "member.membership.get"
|
|
193
|
+
},
|
|
194
|
+
"targetScope": {
|
|
195
|
+
"type": "object",
|
|
196
|
+
"additionalProperties": false,
|
|
197
|
+
"properties": {
|
|
198
|
+
"kdtId": {
|
|
199
|
+
"$ref": "#/definitions/shopId"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"requestState": {
|
|
204
|
+
"enum": [
|
|
205
|
+
"not_sent",
|
|
206
|
+
"sent",
|
|
207
|
+
"unknown"
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
"nextStep": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"minLength": 1
|
|
213
|
+
},
|
|
214
|
+
"api": {
|
|
215
|
+
"type": "string"
|
|
216
|
+
},
|
|
217
|
+
"httpStatus": {
|
|
218
|
+
"type": "integer"
|
|
219
|
+
},
|
|
220
|
+
"businessCode": {
|
|
221
|
+
"anyOf": [
|
|
222
|
+
{
|
|
223
|
+
"type": "integer"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"type": "string"
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
"gatewayCode": {
|
|
231
|
+
"anyOf": [
|
|
232
|
+
{
|
|
233
|
+
"type": "integer"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"type": "string"
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
"trace_id": {
|
|
241
|
+
"type": "string"
|
|
242
|
+
},
|
|
243
|
+
"request_id": {
|
|
244
|
+
"type": "string"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"definitions": {
|
|
251
|
+
"shopId": {
|
|
252
|
+
"type": "integer",
|
|
253
|
+
"minimum": 1,
|
|
254
|
+
"maximum": 9007199254740991,
|
|
255
|
+
"description": "显式 --kdt-id 优先,否则取本次有效上下文 shopId。默认值是动态来源,不是授权证明;实际执行必须与同次凭证回读的店铺一致。"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"modules": {
|
|
259
|
+
"membership": {
|
|
260
|
+
"base": true,
|
|
261
|
+
"upstreamPath": "data[].label_info",
|
|
262
|
+
"required": true,
|
|
263
|
+
"description": "仅提取精确匹配目标客户的 Boolean is_member;不扁平化其他字段。"
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"api": {
|
|
267
|
+
"method": "POST",
|
|
268
|
+
"path": "youzan.scrm.customer.list.yzopenid/1.0.0"
|
|
269
|
+
},
|
|
270
|
+
"success": {
|
|
271
|
+
"description": "店铺核验通过,唯一匹配目标客户且会员标记严格为 Boolean 后成功。"
|
|
272
|
+
},
|
|
273
|
+
"errors": {
|
|
274
|
+
"description": "失败 stdout 为空,stderr 为一份脱敏错误 JSON,退出码非零;不返回部分成功,不自动重试、切换身份或目标。按 error 模型及安全下一步处理。"
|
|
275
|
+
},
|
|
276
|
+
"notes": [
|
|
277
|
+
"只返回 data.membership.is_member,类型严格为 Boolean;不从其他字段推导入会状态。",
|
|
278
|
+
"空集合只表示本次未返回目标,不能解释为客户不存在或非会员;多条、缺字段或错型失败。",
|
|
279
|
+
"支持已核实的微商城单店、连锁 D 总部、网店及合伙人,不承诺零售全覆盖。",
|
|
280
|
+
"一次店铺核验和一次会员读取,不批量、不自动重试;核验失败不继续业务请求。",
|
|
281
|
+
"本地 --dry-run 不读取凭证、不联网;预览只证明构造计划,不证明对象存在或权限有效。真实执行仍需有效上下文及目标范围授权,at 声明不替代服务端授权。"
|
|
282
|
+
]
|
|
283
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 3,
|
|
3
|
+
"domain": "order",
|
|
4
|
+
"businessCommands": [
|
|
5
|
+
{
|
|
6
|
+
"path": "order.order.get",
|
|
7
|
+
"kind": "atomic",
|
|
8
|
+
"risk": "read",
|
|
9
|
+
"availability": "available",
|
|
10
|
+
"at": "all",
|
|
11
|
+
"module": "order/order/get/command.js",
|
|
12
|
+
"fingerprint": "f418c43687be1a520d4ec877e01c36b2d3f4231ae0413423655c1923ba749e5a"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "order.order.list",
|
|
16
|
+
"kind": "atomic",
|
|
17
|
+
"risk": "read",
|
|
18
|
+
"availability": "available",
|
|
19
|
+
"at": "all",
|
|
20
|
+
"module": "order/order/list/command.js",
|
|
21
|
+
"fingerprint": "e724052bb9918a03649b7d53188869d4279f871dc86428f32615da29c5378ae2"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "order.order.scan",
|
|
25
|
+
"kind": "atomic",
|
|
26
|
+
"risk": "read",
|
|
27
|
+
"availability": "available",
|
|
28
|
+
"at": "all",
|
|
29
|
+
"module": "order/order/scan/command.js",
|
|
30
|
+
"fingerprint": "64e037283116df0e8862be7a01db999de0436c74dace75e688ec819f1adc026d"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
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 { parseIncludeModules } = require('../../../../../execution/command-io');
|
|
9
|
+
const { readContext } = require('../../../../../identity/context');
|
|
10
|
+
const { queryDefinition, validateCommandValue } = require('../../../../../execution/command-schema');
|
|
11
|
+
const { object } = require('../../../../../execution/query-api');
|
|
12
|
+
const { discloseFields, validReason } = require('../../../../../execution/privacy');
|
|
13
|
+
const { bindingPath, targetScope, createOrderQuery, reject, serialize } = require('../../shared/query');
|
|
14
|
+
const projection = require('../../shared/projection');
|
|
15
|
+
const schema = require('./schema.json');
|
|
16
|
+
|
|
17
|
+
const command = 'order.order.get';
|
|
18
|
+
const { includeModules } = queryDefinition(schema);
|
|
19
|
+
const decryptFields = ['address.receiverName', 'address.receiverPhone', 'address.address'];
|
|
20
|
+
|
|
21
|
+
function buildInput(options, context) {
|
|
22
|
+
const target = targetScope(options, context, command);
|
|
23
|
+
return withInputScope(target, () => normalizedInput(options, target));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalizedInput(options, target) {
|
|
27
|
+
const scope = Object.freeze({ ...target, orderNo: options.orderNo });
|
|
28
|
+
const input = {
|
|
29
|
+
scope, include: [...parseIncludeModules(options.include, includeModules, '/include')],
|
|
30
|
+
format: options.format, dryRun: options.dryRun === true
|
|
31
|
+
};
|
|
32
|
+
if (options.decrypt !== undefined) {
|
|
33
|
+
input.decrypt = [...parseIncludeModules(options.decrypt, decryptFields, '/decrypt')];
|
|
34
|
+
if (options.reason !== undefined) {
|
|
35
|
+
if (typeof options.reason !== 'string' || /[\p{Cc}\p{Zl}\p{Zp}]/u.test(options.reason)) {
|
|
36
|
+
throw inputIssue('/reason', 'invalid_format');
|
|
37
|
+
}
|
|
38
|
+
input.reason = options.reason.trim();
|
|
39
|
+
if (!validReason(input.reason)) throw inputIssue('/reason', 'invalid_format');
|
|
40
|
+
}
|
|
41
|
+
} else if (options.reason !== undefined) input.reason = options.reason;
|
|
42
|
+
validateCommandValue(schema, 'input', input);
|
|
43
|
+
return input;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function preview(input) {
|
|
47
|
+
const result = { requests: [
|
|
48
|
+
{ method: 'POST', path: bindingPath, body: {} },
|
|
49
|
+
{ method: 'POST', path: schema.api.path, body: { tid: input.scope.orderNo } }
|
|
50
|
+
] };
|
|
51
|
+
if (input.decrypt) result.privacy = {
|
|
52
|
+
fields: input.decrypt, maximumApiRequests: 4, requiresSensitiveAuthorization: true
|
|
53
|
+
};
|
|
54
|
+
validateCommandValue(schema, 'preview', result);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function adapt(data, input, context, facts) {
|
|
59
|
+
const { scope } = input;
|
|
60
|
+
let output;
|
|
61
|
+
try {
|
|
62
|
+
if (!object(data) || !object(data.full_order_info)) throw new Error('missing order');
|
|
63
|
+
const full = data.full_order_info;
|
|
64
|
+
const order = projection.order(full.order_info);
|
|
65
|
+
if (order.orderNo !== scope.orderNo || order.kdtId !== scope.kdtId ||
|
|
66
|
+
(Object.hasOwn(order, 'rootKdtId') && order.rootKdtId !== context.hq)) {
|
|
67
|
+
throw reject(command, 'scope_unresolved', 'order', scope, 'sent', facts);
|
|
68
|
+
}
|
|
69
|
+
output = { data: { order, items: projection.items(full.orders), payment: projection.payment(full.pay_info) } };
|
|
70
|
+
for (const name of input.include) output.data[name] = projection.extension(name, data, full);
|
|
71
|
+
validateCommandValue(schema, 'output', output);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if (error.cliDetails) throw error;
|
|
74
|
+
throw reject(command, 'protocol', 'output-model', scope, 'sent', facts);
|
|
75
|
+
}
|
|
76
|
+
return output;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function disclosedOutput(result, input, context, facts) {
|
|
80
|
+
const output = adapt(result.sourceData, input, context, facts);
|
|
81
|
+
for (const { field, value } of result.values) output.data.address[field.slice('address.'.length)] = value;
|
|
82
|
+
validateCommandValue(schema, 'output', output);
|
|
83
|
+
serialize(output, input.format, command, input.scope);
|
|
84
|
+
return output;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function createCommand({ context, privacyProvider } = {}) {
|
|
88
|
+
return new DiagnosticCommand('get', { path: command, schema,
|
|
89
|
+
optionPaths: { '/scope/kdtId': 'kdtId', '/scope/orderNo': 'orderNo' } })
|
|
90
|
+
.description('读取单笔交易订单及选定的有限售后、履约摘要')
|
|
91
|
+
.allowExcessArguments(false)
|
|
92
|
+
.option('--kdt-id <id>', '目标店铺正安全整数;省略时使用当前上下文店铺')
|
|
93
|
+
.requiredOption('--order-no <no>', '必填:原始订单号,最多 128 字符;不限定前缀或位数')
|
|
94
|
+
.option('--include <modules>', `追加模块:${includeModules.join(', ')};仅投影,不增加请求`)
|
|
95
|
+
.option('--decrypt <fields>', `显式解密:${decryptFields.join(', ')};必须 include address`)
|
|
96
|
+
.option('--reason <text>', '仅解密时必填:1 至 200 个 Unicode 码点,无控制字符或换行,不含个人信息')
|
|
97
|
+
.addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
|
|
98
|
+
.choices(['json', 'pretty']).default('json'))
|
|
99
|
+
.option('--dry-run', '纯本地校验和两步计划,不读凭证、不联网')
|
|
100
|
+
.addHelpText('after', `
|
|
101
|
+
固定返回 data.order、items、payment,include 只能追加模块,不能移除基础视图。
|
|
102
|
+
订单号通常为 E/V/C 开头加 23 位数字,仅供核对;不按该格式拒绝输入或响应,不改写订单号。
|
|
103
|
+
先用同一凭证核验店铺,再以 tid 读详情,最多两请求;核对订单号、node 店铺及已返回的 root 店铺。
|
|
104
|
+
非总部目标须等于 context.shopId,总部也不跨凭证店铺;执行需要有效四字段上下文。
|
|
105
|
+
ID 输出十进制字符串,交易行 oid 不是商品 ID。元金额仅无损补齐两位,不再除以 100。
|
|
106
|
+
payment 是整单应付,realPayment 是实付,不扣退款或推导到账;按用户确认默认以 CNY 计价。
|
|
107
|
+
基础 order 可返回支付时间 paidAt 和支付标记 isPaid;缺失不推断,零实付不等于未支付。
|
|
108
|
+
金额保留两位小数字符串,不新增币种字段或换汇;该默认不是上游逐订单币种或官方保证。
|
|
109
|
+
时间固定北京时间 YYYY-MM-DD HH:mm:ss.SSS,秒精度来源拒绝非零毫秒;发货空串原样保留。
|
|
110
|
+
缺可选字段省略,实际零、false、空文本保留;已选模块缺失、null、错型均整体失败。
|
|
111
|
+
售后仅本接口摘要,不证明资金到账;履约不含轨迹,不展开套餐 JSON 或查询关联详情。
|
|
112
|
+
默认不主动解密。decrypt 只允许收货姓名、电话和详细地址,要求 include address 和 reason。
|
|
113
|
+
选定字段全部判密、解密和可靠审计完成后原位返回;失败无部分明文,不将打星值当作可恢复的密文。
|
|
114
|
+
解密最多四次有赞业务请求,禁用 1106 自动初始化及重发;预览只显示字段,不显示用途或密文。
|
|
115
|
+
当前安装版尚未接通可信员工字段授权、来源绑定和可靠审计服务,实际解密拒绝;普通读取不受影响。
|
|
116
|
+
累计响应上限 10MiB、最终 UTF-8 输出上限 5MiB,超限不裁切;不提供流式内存保证。
|
|
117
|
+
不重试、重定向、切店或换身份;失败 stdout 为空,stderr 一份安全错误 JSON。
|
|
118
|
+
执行需要有效的用户、组织与店铺上下文,可通过登录后选店或 ZAN_SAAS_CONTEXT 提供;目标范围和服务端授权按本命令契约校验,公共调用前置见 zan-saas skills read zan-saas-shared。
|
|
119
|
+
应用 token 测试不证明员工 OAuth 或权限隔离。字段、枚举及边界见 zan-saas schema order.order.get。
|
|
120
|
+
示例:zan-saas order order get --kdt-id 63077 --order-no E20261020201817054602016 --dry-run
|
|
121
|
+
示例:zan-saas order order get --kdt-id 63077 --order-no E20261020201817054602016 --include aftersale,fulfillment
|
|
122
|
+
`)
|
|
123
|
+
.action(async options => {
|
|
124
|
+
const state = readContext(context);
|
|
125
|
+
const input = buildInput(options, context);
|
|
126
|
+
const plan = preview(input);
|
|
127
|
+
let output = plan;
|
|
128
|
+
if (!input.dryRun) {
|
|
129
|
+
if (input.decrypt) {
|
|
130
|
+
let sourceFacts;
|
|
131
|
+
const result = await discloseFields({ scope: { kdtId: input.scope.kdtId },
|
|
132
|
+
object: { type: 'order', orderNo: input.scope.orderNo }, fields: input.decrypt, reason: input.reason }, {
|
|
133
|
+
command, allowedFields: decryptFields, provider: privacyProvider,
|
|
134
|
+
readSource: async read => {
|
|
135
|
+
const { data, facts } = await read(schema.api.path, { tid: input.scope.orderNo }, 'order');
|
|
136
|
+
sourceFacts = facts;
|
|
137
|
+
const sourceOutput = adapt(data, input, state.context, facts);
|
|
138
|
+
return { sourceData: data, values: input.decrypt.map(field => ({ field,
|
|
139
|
+
value: sourceOutput.data.address[field.slice('address.'.length)] })) };
|
|
140
|
+
},
|
|
141
|
+
validateResult: result => disclosedOutput(result, input, state.context, sourceFacts)
|
|
142
|
+
});
|
|
143
|
+
output = disclosedOutput(result, input, state.context, sourceFacts);
|
|
144
|
+
} else {
|
|
145
|
+
const read = await createOrderQuery(input.scope, command, { shopApp: false });
|
|
146
|
+
const request = plan.requests[1];
|
|
147
|
+
const { data, facts } = await read(request.path, request.body);
|
|
148
|
+
output = adapt(data, input, state.context, facts);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
console.log(serialize(output, input.format, command, input.scope));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
|