@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,317 @@
|
|
|
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
|
+
"$ref": "#/definitions/customerId"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"description": "CLI 解析参数并完成必要上下文补全后的业务输入;不是直接传入 CLI 的 JSON。原始选项、必填条件和默认值见 options。"
|
|
19
|
+
},
|
|
20
|
+
"output": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"required": [
|
|
23
|
+
"data"
|
|
24
|
+
],
|
|
25
|
+
"additionalProperties": false,
|
|
26
|
+
"properties": {
|
|
27
|
+
"data": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"required": [
|
|
30
|
+
"customer_tag"
|
|
31
|
+
],
|
|
32
|
+
"additionalProperties": false,
|
|
33
|
+
"properties": {
|
|
34
|
+
"customer_tag": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "指定客户本次可见的标签关系视图;不承诺全集、稳定排序、唯一性或历史快照。",
|
|
37
|
+
"required": [
|
|
38
|
+
"yz_open_id",
|
|
39
|
+
"tags"
|
|
40
|
+
],
|
|
41
|
+
"additionalProperties": false,
|
|
42
|
+
"properties": {
|
|
43
|
+
"yz_open_id": {
|
|
44
|
+
"$ref": "#/definitions/customerId",
|
|
45
|
+
"description": "本次查询的客户 ID,必须精确匹配目标。"
|
|
46
|
+
},
|
|
47
|
+
"tags": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"description": "本次返回的关系内容;保持顺序和重复项。空数组合法,缺失和 null 拒绝。",
|
|
50
|
+
"items": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"required": [
|
|
53
|
+
"tag_id",
|
|
54
|
+
"tag_name"
|
|
55
|
+
],
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"properties": {
|
|
58
|
+
"tag_id": {
|
|
59
|
+
"$ref": "#/definitions/positiveId",
|
|
60
|
+
"description": "标签定义 ID,类型为安全整数,不接受字符串或失真整数。"
|
|
61
|
+
},
|
|
62
|
+
"tag_name": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "标签名称,保留空字符串,不是客户备注。"
|
|
65
|
+
},
|
|
66
|
+
"tag_category_id": {
|
|
67
|
+
"type": "integer",
|
|
68
|
+
"minimum": 0,
|
|
69
|
+
"maximum": 9007199254740991,
|
|
70
|
+
"description": "标签组 ID,缺失省略,0 原样保留,不推断为未分组。"
|
|
71
|
+
},
|
|
72
|
+
"tag_category_name": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "标签组名称,缺失省略,空字符串保留,不补 null 或默认名称。"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"preview": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"required": [
|
|
88
|
+
"targetScope",
|
|
89
|
+
"request"
|
|
90
|
+
],
|
|
91
|
+
"additionalProperties": false,
|
|
92
|
+
"properties": {
|
|
93
|
+
"targetScope": {
|
|
94
|
+
"$ref": "#/definitions/scope"
|
|
95
|
+
},
|
|
96
|
+
"request": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"required": [
|
|
99
|
+
"method",
|
|
100
|
+
"path",
|
|
101
|
+
"body"
|
|
102
|
+
],
|
|
103
|
+
"additionalProperties": false,
|
|
104
|
+
"properties": {
|
|
105
|
+
"method": {
|
|
106
|
+
"const": "POST"
|
|
107
|
+
},
|
|
108
|
+
"path": {
|
|
109
|
+
"const": "youzan.scrm.tagrelation.query/1.0.0"
|
|
110
|
+
},
|
|
111
|
+
"body": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"required": [
|
|
114
|
+
"account",
|
|
115
|
+
"filter_invalid_tag",
|
|
116
|
+
"filter_category_tag",
|
|
117
|
+
"display_type"
|
|
118
|
+
],
|
|
119
|
+
"additionalProperties": false,
|
|
120
|
+
"properties": {
|
|
121
|
+
"account": {
|
|
122
|
+
"type": "object",
|
|
123
|
+
"required": ["account_type", "account_id"],
|
|
124
|
+
"additionalProperties": false,
|
|
125
|
+
"properties": {
|
|
126
|
+
"account_type": { "const": 5 },
|
|
127
|
+
"account_id": { "type": "string", "minLength": 1 }
|
|
128
|
+
},
|
|
129
|
+
"description": "客户标识对象。"
|
|
130
|
+
},
|
|
131
|
+
"filter_invalid_tag": {
|
|
132
|
+
"const": false,
|
|
133
|
+
"description": "不主动排除禁用标签。"
|
|
134
|
+
},
|
|
135
|
+
"filter_category_tag": {
|
|
136
|
+
"const": false,
|
|
137
|
+
"description": "不主动排除标签组内标签。"
|
|
138
|
+
},
|
|
139
|
+
"display_type": {
|
|
140
|
+
"const": 2,
|
|
141
|
+
"description": "请求隐藏和展示标签,仍遵守服务端授权。"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"error": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"required": [
|
|
152
|
+
"success",
|
|
153
|
+
"code",
|
|
154
|
+
"message",
|
|
155
|
+
"details"
|
|
156
|
+
],
|
|
157
|
+
"additionalProperties": false,
|
|
158
|
+
"properties": {
|
|
159
|
+
"success": {
|
|
160
|
+
"const": false
|
|
161
|
+
},
|
|
162
|
+
"code": {
|
|
163
|
+
"const": -10001
|
|
164
|
+
},
|
|
165
|
+
"message": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"minLength": 1
|
|
168
|
+
},
|
|
169
|
+
"details": {
|
|
170
|
+
"type": "object",
|
|
171
|
+
"required": [
|
|
172
|
+
"category",
|
|
173
|
+
"stage",
|
|
174
|
+
"command",
|
|
175
|
+
"targetScope",
|
|
176
|
+
"requestState",
|
|
177
|
+
"nextStep"
|
|
178
|
+
],
|
|
179
|
+
"additionalProperties": false,
|
|
180
|
+
"properties": {
|
|
181
|
+
"category": {
|
|
182
|
+
"enum": [
|
|
183
|
+
"parameter",
|
|
184
|
+
"configuration",
|
|
185
|
+
"authentication",
|
|
186
|
+
"permission",
|
|
187
|
+
"http",
|
|
188
|
+
"transport",
|
|
189
|
+
"business_rejected",
|
|
190
|
+
"protocol"
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
"stage": {
|
|
194
|
+
"type": "string",
|
|
195
|
+
"minLength": 1
|
|
196
|
+
},
|
|
197
|
+
"command": {
|
|
198
|
+
"const": "customer.customer-tag.get"
|
|
199
|
+
},
|
|
200
|
+
"targetScope": {
|
|
201
|
+
"oneOf": [
|
|
202
|
+
{
|
|
203
|
+
"$ref": "#/definitions/scope"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"type": "object",
|
|
207
|
+
"maxProperties": 0
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"description": "只含安全店铺范围,不回显客户 ID。"
|
|
211
|
+
},
|
|
212
|
+
"requestState": {
|
|
213
|
+
"enum": [
|
|
214
|
+
"not_sent",
|
|
215
|
+
"sent",
|
|
216
|
+
"unknown"
|
|
217
|
+
],
|
|
218
|
+
"description": "本地拒绝为 not_sent;取得响应为 sent;传输中断无法确定结果为 unknown。"
|
|
219
|
+
},
|
|
220
|
+
"nextStep": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"minLength": 1
|
|
223
|
+
},
|
|
224
|
+
"api": {
|
|
225
|
+
"const": "youzan.scrm.tagrelation.query/1.0.0"
|
|
226
|
+
},
|
|
227
|
+
"httpStatus": {
|
|
228
|
+
"type": "integer",
|
|
229
|
+
"minimum": 100,
|
|
230
|
+
"maximum": 599
|
|
231
|
+
},
|
|
232
|
+
"businessCode": {
|
|
233
|
+
"oneOf": [
|
|
234
|
+
{
|
|
235
|
+
"type": "integer",
|
|
236
|
+
"minimum": -9007199254740991,
|
|
237
|
+
"maximum": 9007199254740991
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"type": "string",
|
|
241
|
+
"pattern": "^-?\\d{1,12}$"
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
"gatewayCode": {
|
|
246
|
+
"oneOf": [
|
|
247
|
+
{
|
|
248
|
+
"type": "integer",
|
|
249
|
+
"minimum": -9007199254740991,
|
|
250
|
+
"maximum": 9007199254740991
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"type": "string",
|
|
254
|
+
"pattern": "^-?\\d{1,12}$"
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
"trace_id": {
|
|
259
|
+
"type": "string",
|
|
260
|
+
"pattern": "^[a-zA-Z0-9_-]{1,128}$"
|
|
261
|
+
},
|
|
262
|
+
"request_id": {
|
|
263
|
+
"type": "string",
|
|
264
|
+
"pattern": "^[a-zA-Z0-9_-]{1,128}$"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"definitions": {
|
|
271
|
+
"positiveId": {
|
|
272
|
+
"type": "integer",
|
|
273
|
+
"minimum": 1,
|
|
274
|
+
"maximum": 9007199254740991
|
|
275
|
+
},
|
|
276
|
+
"shopId": {
|
|
277
|
+
"$ref": "#/definitions/positiveId",
|
|
278
|
+
"description": "显式目标店铺;真实调用前须独立确认凭证与目标店铺绑定。"
|
|
279
|
+
},
|
|
280
|
+
"customerId": {
|
|
281
|
+
"type": "string",
|
|
282
|
+
"minLength": 1,
|
|
283
|
+
"description": "客户 yzOpenId 字符串,不是手机号、微信 openId 或员工 ID。"
|
|
284
|
+
},
|
|
285
|
+
"scope": {
|
|
286
|
+
"type": "object",
|
|
287
|
+
"required": [
|
|
288
|
+
"kdtId"
|
|
289
|
+
],
|
|
290
|
+
"additionalProperties": false,
|
|
291
|
+
"properties": {
|
|
292
|
+
"kdtId": {
|
|
293
|
+
"$ref": "#/definitions/shopId"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"api": {
|
|
299
|
+
"method": "POST",
|
|
300
|
+
"path": "youzan.scrm.tagrelation.query/1.0.0"
|
|
301
|
+
},
|
|
302
|
+
"success": {
|
|
303
|
+
"description": "客户 ID 精确匹配,完整保留本次响应中的标签集合及已取得的分组字段,每项满足模型后成功;不据此声明历史全集或跨时点快照。"
|
|
304
|
+
},
|
|
305
|
+
"errors": {
|
|
306
|
+
"description": "失败 stdout 为空,stderr 为一份脱敏错误 JSON,退出码非零;不返回部分成功,不自动重试、切换身份或目标。按 error 模型及安全下一步处理。"
|
|
307
|
+
},
|
|
308
|
+
"notes": [
|
|
309
|
+
"获取一个客户的标签集合推荐本命令,返回 data.customer_tag;已有 list 保留原契约,不互为别名或失败降级入口,不以此区分时效性或历史范围。",
|
|
310
|
+
"只接受一个已知客户,不提供标签筛选、分页、关键词或 include;不改变客户详情的 tags 模块。",
|
|
311
|
+
"集合范围为本次接口在授权可见范围内返回的标签关系;不截断、不分页。分类缺失省略,0 原样保留,不推断未分组;不承诺历史全集、固定顺序或跨时点快照。",
|
|
312
|
+
"真实调用前须确认凭证与目标店铺绑定;本地上下文和客户匹配不证明该绑定或远端授权。",
|
|
313
|
+
"响应读取后检查 10 MiB、最终 stdout 文本含换行检查 5 MiB;json 与 pretty 按各自实际字节数判定。超限整体失败,不截断,不是流式内存上限。",
|
|
314
|
+
"省略 --kdt-id 时使用当前选中店铺;显式指定时使用指定店铺,权限由服务端校验。",
|
|
315
|
+
"本地 --dry-run 不读取凭证、不联网;预览只证明构造计划,不证明对象存在或权限有效。真实执行仍需有效上下文及目标范围授权,at 声明不替代服务端授权。"
|
|
316
|
+
]
|
|
317
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
|
|
4
|
+
|
|
5
|
+
const { Command } = require('commander');
|
|
6
|
+
const { requestApi, ApiConfigurationError } = require('../../../../../transport/api');
|
|
7
|
+
const { validateCommandValue } = require('../../../../../execution/command-schema');
|
|
8
|
+
const schema = require('./schema.json');
|
|
9
|
+
|
|
10
|
+
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
11
|
+
|
|
12
|
+
function failure(category, stage, requestState = 'not_sent', facts = {}) {
|
|
13
|
+
const error = new Error('客户标签查询失败;请查看错误分类和失败步骤。');
|
|
14
|
+
error.cliDetails = {
|
|
15
|
+
category, stage, command: 'customer.customer-tag.list', targetScope: {}, requestState,
|
|
16
|
+
nextStep: '核对本命令契约、目标店铺和服务端授权;不自动切换身份或重试。',
|
|
17
|
+
...facts
|
|
18
|
+
};
|
|
19
|
+
return error;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function listCustomerTags(options, context) {
|
|
23
|
+
if (!/^[1-9]\d*$/.test(options.kdtId) || !Number.isSafeInteger(Number(options.kdtId))) {
|
|
24
|
+
throw failure('input', 'kdtId');
|
|
25
|
+
}
|
|
26
|
+
const yzOpenId = options.yzOpenId.trim();
|
|
27
|
+
if (!yzOpenId) throw failure('input', 'yzOpenId');
|
|
28
|
+
if (!['json', 'pretty'].includes(options.format)) throw failure('input', 'format');
|
|
29
|
+
const input = { kdtId: Number(options.kdtId), yzOpenId };
|
|
30
|
+
validateCommandValue(schema, 'input', input);
|
|
31
|
+
if (context?.orgType === 'shop' && String(input.kdtId) !== context.shopId) {
|
|
32
|
+
throw failure('permission', 'context');
|
|
33
|
+
}
|
|
34
|
+
const request = {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
path: schema.api.path,
|
|
37
|
+
body: {
|
|
38
|
+
account: { account_id: yzOpenId, account_type: 5 },
|
|
39
|
+
display_type: 2,
|
|
40
|
+
filter_invalid_tag: false,
|
|
41
|
+
filter_category_tag: false
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
if (options.dryRun) {
|
|
45
|
+
validateCommandValue(schema, 'preview', request);
|
|
46
|
+
return request;
|
|
47
|
+
}
|
|
48
|
+
let response;
|
|
49
|
+
try {
|
|
50
|
+
response = await requestApi(request);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof ApiConfigurationError) throw failure('configuration', 'configuration');
|
|
53
|
+
throw failure('transport', 'request', 'unknown');
|
|
54
|
+
}
|
|
55
|
+
const facts = { api: request.path, httpStatus: response.httpStatus };
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
const category = response.httpStatus === 401 ? 'authentication' :
|
|
58
|
+
response.httpStatus === 403 ? 'permission' : 'http';
|
|
59
|
+
throw failure(category, 'response', 'sent', facts);
|
|
60
|
+
}
|
|
61
|
+
let result;
|
|
62
|
+
try {
|
|
63
|
+
result = JSON.parse(response.body);
|
|
64
|
+
} catch {
|
|
65
|
+
throw failure('protocol', 'response', 'sent', facts);
|
|
66
|
+
}
|
|
67
|
+
if (!object(result)) throw failure('protocol', 'response', 'sent', facts);
|
|
68
|
+
if (Number.isSafeInteger(result.code)) facts.businessCode = result.code;
|
|
69
|
+
if (object(result.gw_err_resp) &&
|
|
70
|
+
(Number.isSafeInteger(result.gw_err_resp.err_code) ||
|
|
71
|
+
(typeof result.gw_err_resp.err_code === 'string' && /^-?\d{1,12}$/.test(result.gw_err_resp.err_code)))) {
|
|
72
|
+
facts.gatewayCode = result.gw_err_resp.err_code;
|
|
73
|
+
}
|
|
74
|
+
const traceId = result.trace_id ?? result.gw_err_resp?.trace_id;
|
|
75
|
+
if (typeof traceId === 'string' && /^[a-zA-Z0-9_-]{1,128}$/.test(traceId)) facts.trace_id = traceId;
|
|
76
|
+
if (facts.gatewayCode !== undefined) {
|
|
77
|
+
throw failure(result.success === true || [0, 200].includes(result.code) ? 'protocol' : 'business_rejected',
|
|
78
|
+
'response', 'sent', facts);
|
|
79
|
+
}
|
|
80
|
+
if (result.success === false || !(result.success === true || [0, 200].includes(result.code))) {
|
|
81
|
+
throw failure('business_rejected', 'response', 'sent', facts);
|
|
82
|
+
}
|
|
83
|
+
if (!object(result.data) || result.data.yz_open_id !== yzOpenId ||
|
|
84
|
+
!Array.isArray(result.data.tags) || result.data.tags.some(tag => !object(tag))) {
|
|
85
|
+
throw failure('protocol', 'response', 'sent', facts);
|
|
86
|
+
}
|
|
87
|
+
const output = {
|
|
88
|
+
data: {
|
|
89
|
+
yzOpenId: result.data.yz_open_id,
|
|
90
|
+
tags: result.data.tags.map(tag => ({
|
|
91
|
+
tagId: tag.tag_id,
|
|
92
|
+
tagName: tag.name,
|
|
93
|
+
tagCategoryId: tag.category_id,
|
|
94
|
+
...(tag.category_name === null || tag.category_name === undefined ? {} :
|
|
95
|
+
{ tagCategoryName: tag.category_name })
|
|
96
|
+
}))
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
try {
|
|
100
|
+
validateCommandValue(schema, 'output', output);
|
|
101
|
+
} catch {
|
|
102
|
+
throw failure('protocol', 'response', 'sent', facts);
|
|
103
|
+
}
|
|
104
|
+
return output;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function createCommand({ context } = {}) {
|
|
108
|
+
return new Command('list')
|
|
109
|
+
.description('按既有 list 契约读取一个客户的标签关系;新调用推荐 customer-tag get')
|
|
110
|
+
.allowExcessArguments(false)
|
|
111
|
+
.exitOverride(error => {
|
|
112
|
+
if (['commander.helpDisplayed', 'commander.version'].includes(error.code)) throw error;
|
|
113
|
+
throw failure('input', 'arguments');
|
|
114
|
+
})
|
|
115
|
+
.option('--kdt-id <id>', '目标店铺 ID,须为正安全整数;省略时使用当前上下文店铺')
|
|
116
|
+
.requiredOption('--yz-open-id <id>', '客户 yzOpenId,去除首尾空白后须非空')
|
|
117
|
+
.option('--format <format>', 'json 或 pretty,仅改变缩进', 'json')
|
|
118
|
+
.option('--dry-run', '仅本地预览请求,不读凭证、不联网')
|
|
119
|
+
.addHelpText('after', `
|
|
120
|
+
查询客户标签关系;标签定义与标签组须使用各自入口,不执行写入或回退到客户详情。
|
|
121
|
+
新调用查询单个客户的标签集合时,推荐使用 customer-tag get。
|
|
122
|
+
本入口保留既有输出契约,不代表更新更及时或提供历史视图。
|
|
123
|
+
在服务端允许的范围内,包含可见与隐藏、启用与禁用、有分组与无分组的关系。
|
|
124
|
+
从单次响应返回 data.yzOpenId 和 data.tags,不分页,也不保证快照一致性。
|
|
125
|
+
|
|
126
|
+
示例:
|
|
127
|
+
zan-saas customer customer-tag list --kdt-id 63077 --yz-open-id customer-1
|
|
128
|
+
zan-saas customer customer-tag list --kdt-id 63077 --yz-open-id customer-1 --format pretty
|
|
129
|
+
zan-saas customer customer-tag list --kdt-id 63077 --yz-open-id customer-1 --dry-run
|
|
130
|
+
|
|
131
|
+
执行需要有效的用户、组织与店铺上下文,可通过登录后选店或 ZAN_SAAS_CONTEXT 提供;目标范围和服务端授权按本命令契约校验,公共调用前置见 zan-saas skills read zan-saas-shared。
|
|
132
|
+
ZAN_SAAS_CONTEXT 包含 userId、hq、shopId 和 orgType,orgType 为 hq 或 shop。
|
|
133
|
+
店铺上下文中,--kdt-id 必须与 context.shopId 一致;总部目标仍须服务端授权。
|
|
134
|
+
接口请求与响应均无 kdt_id 字段,本地检查不证明目标店铺已授权。
|
|
135
|
+
缺少上下文时 --dry-run 仍仅本地预览;失败仅向 stderr 写入结构化脱敏错误。
|
|
136
|
+
最多发送一次请求,不重试、重定向、更换编码或改用其他接口。`)
|
|
137
|
+
.action(async options => {
|
|
138
|
+
const result = await listCustomerTags(options, context);
|
|
139
|
+
process.stdout.write(`${JSON.stringify(result, null, options.format === 'pretty' ? 2 : 0)}\n`);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
|