@youzan-cloud/zan-saas-cli 0.0.0-stage → 0.1.0-beta.3
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 +105 -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 +102 -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,478 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"input": {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"kdtId",
|
|
7
|
+
"include"
|
|
8
|
+
],
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"kdtId": {
|
|
12
|
+
"$ref": "#/definitions/shopId"
|
|
13
|
+
},
|
|
14
|
+
"include": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"uniqueItems": true,
|
|
17
|
+
"items": {
|
|
18
|
+
"enum": [
|
|
19
|
+
"address",
|
|
20
|
+
"contact",
|
|
21
|
+
"operation-status"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"description": "逗号拆分、去首尾空白并去重;默认空数组;空项和未知模块拒绝。"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"output": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"required": [
|
|
31
|
+
"data"
|
|
32
|
+
],
|
|
33
|
+
"additionalProperties": false,
|
|
34
|
+
"properties": {
|
|
35
|
+
"data": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"required": [
|
|
38
|
+
"unit"
|
|
39
|
+
],
|
|
40
|
+
"additionalProperties": false,
|
|
41
|
+
"properties": {
|
|
42
|
+
"unit": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"required": [
|
|
45
|
+
"kdtId",
|
|
46
|
+
"name",
|
|
47
|
+
"orgRole"
|
|
48
|
+
],
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"properties": {
|
|
51
|
+
"kdtId": {
|
|
52
|
+
"$ref": "#/definitions/shopId"
|
|
53
|
+
},
|
|
54
|
+
"name": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"minLength": 1,
|
|
57
|
+
"pattern": "\\S",
|
|
58
|
+
"description": "当前组织名称;名称必须非空,不用上下文名称补值。"
|
|
59
|
+
},
|
|
60
|
+
"orgRole": {
|
|
61
|
+
"type": "integer",
|
|
62
|
+
"minimum": 0,
|
|
63
|
+
"maximum": 9007199254740991,
|
|
64
|
+
"description": "组织角色:0 单店;1 总部;2001 门店;2002 网店;3 独立仓;4 合伙人;6 分销供货店铺;7 前置仓。未知合法代码保留,不推断含义;不是员工权限角色或列表筛选组。"
|
|
65
|
+
},
|
|
66
|
+
"rootKdtId": {
|
|
67
|
+
"$ref": "#/definitions/shopId"
|
|
68
|
+
},
|
|
69
|
+
"parentKdtId": {
|
|
70
|
+
"$ref": "#/definitions/shopId"
|
|
71
|
+
},
|
|
72
|
+
"lineOfBusiness": {
|
|
73
|
+
"type": "integer",
|
|
74
|
+
"minimum": 0,
|
|
75
|
+
"maximum": 9007199254740991,
|
|
76
|
+
"description": "业务线:10000 微商城;20000 教育;50000 餐饮;60000 美业;70000 零售;140000 供货。未知合法代码原值保留;不是店铺类型。"
|
|
77
|
+
},
|
|
78
|
+
"certType": {
|
|
79
|
+
"type": "integer",
|
|
80
|
+
"minimum": 0,
|
|
81
|
+
"maximum": 9007199254740991,
|
|
82
|
+
"description": "认证类型:0 未认证;2 企业认证;3 个人认证;12 个体工商户认证;10 其他组织、政府及事业单位。未知合法代码保留,不代表本次资料变更审核结果。"
|
|
83
|
+
},
|
|
84
|
+
"logo": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "Logo 原文,不检查可达性。"
|
|
87
|
+
},
|
|
88
|
+
"intro": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "简介,空串保留。"
|
|
91
|
+
},
|
|
92
|
+
"url": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"description": "主页链接原文,不访问。"
|
|
95
|
+
},
|
|
96
|
+
"physicalUrl": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"description": "线下店铺链接原文,不访问。"
|
|
99
|
+
},
|
|
100
|
+
"address": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"required": [
|
|
103
|
+
"address"
|
|
104
|
+
],
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"properties": {
|
|
107
|
+
"address": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"description": "详细地址原文,允许空串。"
|
|
110
|
+
},
|
|
111
|
+
"province": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"description": "省原文。"
|
|
114
|
+
},
|
|
115
|
+
"city": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"description": "市原文。"
|
|
118
|
+
},
|
|
119
|
+
"county": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"description": "区县原文。"
|
|
122
|
+
},
|
|
123
|
+
"countyId": {
|
|
124
|
+
"type": "integer",
|
|
125
|
+
"minimum": 0,
|
|
126
|
+
"maximum": 9007199254740991,
|
|
127
|
+
"description": "地址区县编码,允许 0;不是组织 ID。"
|
|
128
|
+
},
|
|
129
|
+
"lng": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"description": "百度坐标经度文本,不转浮点、不换坐标系。"
|
|
132
|
+
},
|
|
133
|
+
"lat": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"description": "百度坐标纬度文本,不推导缺失坐标。"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"contact": {
|
|
140
|
+
"type": "object",
|
|
141
|
+
"required": [
|
|
142
|
+
"phoneNumber"
|
|
143
|
+
],
|
|
144
|
+
"additionalProperties": false,
|
|
145
|
+
"properties": {
|
|
146
|
+
"phoneNumber": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"description": "客服电话原文,允许空串;不拼接区号。"
|
|
149
|
+
},
|
|
150
|
+
"areaCode": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"description": "客服电话区号原文,允许空串。"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"operationStatus": {
|
|
157
|
+
"type": "integer",
|
|
158
|
+
"enum": [
|
|
159
|
+
0,
|
|
160
|
+
1,
|
|
161
|
+
2,
|
|
162
|
+
3
|
|
163
|
+
],
|
|
164
|
+
"description": "运营状态:0 创建未完成;1 筹备中;2 运营中;3 停用。无法确认状态时整体失败。"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"preview": {
|
|
173
|
+
"type": "object",
|
|
174
|
+
"required": [
|
|
175
|
+
"scope",
|
|
176
|
+
"requests",
|
|
177
|
+
"selection"
|
|
178
|
+
],
|
|
179
|
+
"additionalProperties": false,
|
|
180
|
+
"properties": {
|
|
181
|
+
"scope": {
|
|
182
|
+
"type": "object",
|
|
183
|
+
"required": [
|
|
184
|
+
"kdtId"
|
|
185
|
+
],
|
|
186
|
+
"additionalProperties": false,
|
|
187
|
+
"properties": {
|
|
188
|
+
"kdtId": {
|
|
189
|
+
"$ref": "#/definitions/shopId"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
"requests": {
|
|
194
|
+
"type": "array",
|
|
195
|
+
"minItems": 1,
|
|
196
|
+
"maxItems": 2,
|
|
197
|
+
"items": {
|
|
198
|
+
"oneOf": [
|
|
199
|
+
{
|
|
200
|
+
"type": "object",
|
|
201
|
+
"required": [
|
|
202
|
+
"stage",
|
|
203
|
+
"method",
|
|
204
|
+
"path",
|
|
205
|
+
"body"
|
|
206
|
+
],
|
|
207
|
+
"additionalProperties": false,
|
|
208
|
+
"properties": {
|
|
209
|
+
"stage": {
|
|
210
|
+
"const": "unit-basic"
|
|
211
|
+
},
|
|
212
|
+
"method": {
|
|
213
|
+
"const": "POST"
|
|
214
|
+
},
|
|
215
|
+
"path": {
|
|
216
|
+
"const": "youzan.shop.basic.get/3.0.0"
|
|
217
|
+
},
|
|
218
|
+
"body": {
|
|
219
|
+
"type": "object",
|
|
220
|
+
"required": [],
|
|
221
|
+
"additionalProperties": false,
|
|
222
|
+
"properties": {}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"type": "object",
|
|
228
|
+
"required": [
|
|
229
|
+
"stage",
|
|
230
|
+
"method",
|
|
231
|
+
"path",
|
|
232
|
+
"body"
|
|
233
|
+
],
|
|
234
|
+
"additionalProperties": false,
|
|
235
|
+
"properties": {
|
|
236
|
+
"stage": {
|
|
237
|
+
"const": "operation-status"
|
|
238
|
+
},
|
|
239
|
+
"method": {
|
|
240
|
+
"const": "POST"
|
|
241
|
+
},
|
|
242
|
+
"path": {
|
|
243
|
+
"const": "youzan.shop.configs.get/2.0.0"
|
|
244
|
+
},
|
|
245
|
+
"body": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"required": [
|
|
248
|
+
"keys",
|
|
249
|
+
"node_kdt_ids"
|
|
250
|
+
],
|
|
251
|
+
"additionalProperties": false,
|
|
252
|
+
"properties": {
|
|
253
|
+
"keys": {
|
|
254
|
+
"type": "array",
|
|
255
|
+
"minItems": 1,
|
|
256
|
+
"maxItems": 1,
|
|
257
|
+
"items": {
|
|
258
|
+
"const": "shop_operation_status"
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"node_kdt_ids": {
|
|
262
|
+
"type": "array",
|
|
263
|
+
"minItems": 1,
|
|
264
|
+
"maxItems": 1,
|
|
265
|
+
"items": {
|
|
266
|
+
"$ref": "#/definitions/shopId"
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
},
|
|
275
|
+
"description": "严格按基础、可选运营状态的顺序;最多两次,无类型补查。"
|
|
276
|
+
},
|
|
277
|
+
"selection": {
|
|
278
|
+
"type": "object",
|
|
279
|
+
"required": [
|
|
280
|
+
"include"
|
|
281
|
+
],
|
|
282
|
+
"additionalProperties": false,
|
|
283
|
+
"properties": {
|
|
284
|
+
"include": {
|
|
285
|
+
"type": "array",
|
|
286
|
+
"uniqueItems": true,
|
|
287
|
+
"items": {
|
|
288
|
+
"enum": [
|
|
289
|
+
"address",
|
|
290
|
+
"contact",
|
|
291
|
+
"operation-status"
|
|
292
|
+
]
|
|
293
|
+
},
|
|
294
|
+
"description": "逗号拆分、去首尾空白并去重;默认空数组;空项和未知模块拒绝。"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
"error": {
|
|
301
|
+
"type": "object",
|
|
302
|
+
"required": [
|
|
303
|
+
"success",
|
|
304
|
+
"code",
|
|
305
|
+
"message",
|
|
306
|
+
"details"
|
|
307
|
+
],
|
|
308
|
+
"additionalProperties": false,
|
|
309
|
+
"properties": {
|
|
310
|
+
"success": {
|
|
311
|
+
"const": false
|
|
312
|
+
},
|
|
313
|
+
"code": {
|
|
314
|
+
"const": -10001
|
|
315
|
+
},
|
|
316
|
+
"message": {
|
|
317
|
+
"type": "string",
|
|
318
|
+
"minLength": 1
|
|
319
|
+
},
|
|
320
|
+
"details": {
|
|
321
|
+
"type": "object",
|
|
322
|
+
"required": [
|
|
323
|
+
"category",
|
|
324
|
+
"stage",
|
|
325
|
+
"command",
|
|
326
|
+
"targetScope",
|
|
327
|
+
"requestState",
|
|
328
|
+
"nextStep"
|
|
329
|
+
],
|
|
330
|
+
"additionalProperties": false,
|
|
331
|
+
"properties": {
|
|
332
|
+
"category": {
|
|
333
|
+
"enum": [
|
|
334
|
+
"parameter",
|
|
335
|
+
"validation",
|
|
336
|
+
"configuration",
|
|
337
|
+
"authentication",
|
|
338
|
+
"permission",
|
|
339
|
+
"scope_unresolved",
|
|
340
|
+
"transport",
|
|
341
|
+
"http",
|
|
342
|
+
"protocol",
|
|
343
|
+
"business_rejected"
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
"stage": {
|
|
347
|
+
"enum": [
|
|
348
|
+
"input",
|
|
349
|
+
"context",
|
|
350
|
+
"scope",
|
|
351
|
+
"configuration",
|
|
352
|
+
"unit-basic",
|
|
353
|
+
"unit-model",
|
|
354
|
+
"operation-status",
|
|
355
|
+
"transport",
|
|
356
|
+
"http",
|
|
357
|
+
"response"
|
|
358
|
+
]
|
|
359
|
+
},
|
|
360
|
+
"command": {
|
|
361
|
+
"const": "org.unit.get"
|
|
362
|
+
},
|
|
363
|
+
"targetScope": {
|
|
364
|
+
"type": "object",
|
|
365
|
+
"additionalProperties": false,
|
|
366
|
+
"properties": {
|
|
367
|
+
"kdtId": {
|
|
368
|
+
"$ref": "#/definitions/shopId"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
"requestState": {
|
|
373
|
+
"enum": [
|
|
374
|
+
"not_sent",
|
|
375
|
+
"sent",
|
|
376
|
+
"unknown"
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
"nextStep": {
|
|
380
|
+
"type": "string",
|
|
381
|
+
"minLength": 1
|
|
382
|
+
},
|
|
383
|
+
"api": {
|
|
384
|
+
"type": "string"
|
|
385
|
+
},
|
|
386
|
+
"httpStatus": {
|
|
387
|
+
"type": "integer"
|
|
388
|
+
},
|
|
389
|
+
"businessCode": {
|
|
390
|
+
"anyOf": [
|
|
391
|
+
{
|
|
392
|
+
"type": "integer",
|
|
393
|
+
"minimum": -9007199254740991,
|
|
394
|
+
"maximum": 9007199254740991
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"type": "string",
|
|
398
|
+
"pattern": "^-?\\d{1,12}$"
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
},
|
|
402
|
+
"gatewayCode": {
|
|
403
|
+
"anyOf": [
|
|
404
|
+
{
|
|
405
|
+
"type": "integer",
|
|
406
|
+
"minimum": -9007199254740991,
|
|
407
|
+
"maximum": 9007199254740991
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"type": "string",
|
|
411
|
+
"pattern": "^-?\\d{1,12}$"
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
},
|
|
415
|
+
"trace_id": {
|
|
416
|
+
"type": "string",
|
|
417
|
+
"pattern": "^[A-Za-z0-9_-]{1,128}$"
|
|
418
|
+
},
|
|
419
|
+
"request_id": {
|
|
420
|
+
"type": "string",
|
|
421
|
+
"pattern": "^[A-Za-z0-9_-]{1,128}$"
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
"definitions": {
|
|
428
|
+
"shopId": {
|
|
429
|
+
"type": "integer",
|
|
430
|
+
"minimum": 1,
|
|
431
|
+
"maximum": 9007199254740991,
|
|
432
|
+
"description": "正安全整数组织标识;目标必须等于当前上下文组织,总部也不可改查分店。资料与运营状态必须属于同一目标。"
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
"modules": {
|
|
436
|
+
"basic": {
|
|
437
|
+
"base": true,
|
|
438
|
+
"required": true,
|
|
439
|
+
"upstreamPath": "data",
|
|
440
|
+
"description": "组织标识、名称和组织角色必需。可选资料缺省或无值时省略;空串与 0 保留。"
|
|
441
|
+
},
|
|
442
|
+
"address": {
|
|
443
|
+
"base": false,
|
|
444
|
+
"required": false,
|
|
445
|
+
"upstreamPath": "data.shop_address",
|
|
446
|
+
"description": "仅选择时返回;地址对象与详细地址文本必需。"
|
|
447
|
+
},
|
|
448
|
+
"contact": {
|
|
449
|
+
"base": false,
|
|
450
|
+
"required": false,
|
|
451
|
+
"upstreamPath": "data.customer_service_phone_number",
|
|
452
|
+
"description": "仅选择时返回;联系电话对象与电话号码文本必需。"
|
|
453
|
+
},
|
|
454
|
+
"operation-status": {
|
|
455
|
+
"base": false,
|
|
456
|
+
"required": false,
|
|
457
|
+
"upstreamPath": "data[].configs.shop_operation_status",
|
|
458
|
+
"description": "仅选择时追加当前组织的运营状态查询;必须取得唯一匹配目标及已知状态。"
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
"api": {
|
|
462
|
+
"method": "POST",
|
|
463
|
+
"path": "youzan.shop.basic.get/3.0.0"
|
|
464
|
+
},
|
|
465
|
+
"success": {
|
|
466
|
+
"description": "当前组织归属已核实,名称非空、组织角色有效,所有选定扩展均已取得并通过模型校验后返回 data.unit。"
|
|
467
|
+
},
|
|
468
|
+
"errors": {
|
|
469
|
+
"description": "失败 stdout 为空,stderr 单一安全错误信封并退出 1。扩展失败不返回部分资料;不重试、不换身份/目标、不降级模块。中断 requestState=unknown;诊断不包含自由文本。"
|
|
470
|
+
},
|
|
471
|
+
"notes": [
|
|
472
|
+
"at=all 只表示位置准入,不证明员工授权或任意产品支持。",
|
|
473
|
+
"未选模块整体省略,不验证未消费内容;不返回店铺类型、QQ、升级历史或其他配置。",
|
|
474
|
+
"可选字段源缺省或 null 时省略,不代表不存在。扩展核心缺失整体失败。",
|
|
475
|
+
"默认一次请求;address/contact 不增加请求;operation-status 最多两次,传输固定同一网关/token 快照。",
|
|
476
|
+
"缺少上下文仅允许显式合法目标的本地预览;无效上下文仍拒绝。"
|
|
477
|
+
]
|
|
478
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { readTotal } = require('../../../../../execution/list-total');
|
|
4
|
+
|
|
5
|
+
const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
|
|
6
|
+
|
|
7
|
+
const { Option } = require('commander');
|
|
8
|
+
const { DiagnosticCommand } = require('../../../../../cli/diagnostic-command');
|
|
9
|
+
const { inputIssue, withInputScope, constraints, modelAt, parseIntegerOption } = require('../../../../../execution/error-details');
|
|
10
|
+
const schema = require('./schema.json');
|
|
11
|
+
const { resolveTargetShop } = require('../../../../../execution/target-shop');
|
|
12
|
+
const { readContext } = require('../../../../../identity/context');
|
|
13
|
+
const { validateCommandValue } = require('../../../../../execution/command-schema');
|
|
14
|
+
const { fromBeijingSeconds } = require('../../../../../execution/beijing-date-time');
|
|
15
|
+
const { object } = require('../../../../../execution/query-api');
|
|
16
|
+
const { createBoundShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
|
|
17
|
+
|
|
18
|
+
const command = 'org.unit.list';
|
|
19
|
+
const reject = (category, stage, scope, state, facts) =>
|
|
20
|
+
failure(command, category, stage, scope, state, facts);
|
|
21
|
+
|
|
22
|
+
function integer(value, path) {
|
|
23
|
+
if (path === '/orgRoles') {
|
|
24
|
+
if (typeof value !== 'string' || value !== value.trim() || !/^[1-9]\d*$/.test(value)) {
|
|
25
|
+
throw inputIssue(path, 'invalid_format', constraints(modelAt(schema, 'input', path)));
|
|
26
|
+
}
|
|
27
|
+
return Number(value);
|
|
28
|
+
}
|
|
29
|
+
return parseIntegerOption(value, schema, path);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function csv(value) {
|
|
33
|
+
return value === undefined ? [] : [...new Set(value.split(',').map(part => part.trim()))];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function buildInput(options, context) {
|
|
37
|
+
let scope;
|
|
38
|
+
try {
|
|
39
|
+
scope = resolveTargetShop(options, context, command);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error.cliDetails?.stage === 'validation') error.cliDetails.stage = 'input';
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
const state = readContext(context);
|
|
45
|
+
const rawTarget = Object.hasOwn(options, 'kdtId') ? options.kdtId : state.context?.shopId;
|
|
46
|
+
if (String(scope.kdtId) !== rawTarget) {
|
|
47
|
+
throw reject(Object.hasOwn(options, 'kdtId') ? 'validation' : 'configuration', 'input', scope);
|
|
48
|
+
}
|
|
49
|
+
if (state.status === 'ready' && (state.context.orgType !== 'hq' ||
|
|
50
|
+
state.context.shopId !== state.context.hq || String(scope.kdtId) !== state.context.hq)) {
|
|
51
|
+
throw reject('permission', 'scope', scope);
|
|
52
|
+
}
|
|
53
|
+
return withInputScope(scope, () => {
|
|
54
|
+
const input = { ...scope, pageNo: integer(options.pageNo, '/pageNo'), pageSize: integer(options.pageSize, '/pageSize'),
|
|
55
|
+
orgRoles: csv(options.orgRoles).map(value => integer(value, '/orgRoles')), include: csv(options.include) };
|
|
56
|
+
validateCommandValue(schema, 'input', input);
|
|
57
|
+
return input;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function previewFor(input) {
|
|
62
|
+
const body = { page_num: input.pageNo, page_size: input.pageSize,
|
|
63
|
+
...(input.orgRoles.length && { shop_roles: input.orgRoles }),
|
|
64
|
+
with_dept_info: input.include.includes('departments'),
|
|
65
|
+
with_shop_status_and_lifecycle_end_time: input.include.some(name => ['status', 'lifecycle'].includes(name)),
|
|
66
|
+
with_crm_shop: false };
|
|
67
|
+
return { scope: { kdtId: input.kdtId }, requests: [
|
|
68
|
+
{ stage: 'unit-basic', method: 'POST', path: bindingPath, body: {} },
|
|
69
|
+
{ stage: 'units', method: 'POST', path: schema.api.path, body }
|
|
70
|
+
], selection: { orgRoles: input.orgRoles, include: input.include } };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function optionalFields(source, mapping) {
|
|
74
|
+
const result = {};
|
|
75
|
+
for (const [field, upstream] of Object.entries(mapping)) {
|
|
76
|
+
if (source[upstream] !== undefined && source[upstream] !== null) result[field] = source[upstream];
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function projectUnit(source, include) {
|
|
82
|
+
if (!object(source)) throw new TypeError('Invalid unit');
|
|
83
|
+
const unit = { kdtId: source.kdt_id, name: source.name, orgRole: source.role,
|
|
84
|
+
...optionalFields(source, { joinType: 'join_type', parentKdtId: 'parent_kdt_id', externalCode: 'outer_id' }) };
|
|
85
|
+
if (include.includes('address')) {
|
|
86
|
+
if (!object(source.shop_address)) throw new TypeError('Invalid address');
|
|
87
|
+
unit.address = { address: source.shop_address.address,
|
|
88
|
+
...optionalFields(source.shop_address, { county: 'county', countyId: 'county_id' }) };
|
|
89
|
+
}
|
|
90
|
+
if (include.includes('departments')) {
|
|
91
|
+
if (!Array.isArray(source.dept_info_list)) throw new TypeError('Invalid departments');
|
|
92
|
+
unit.departments = source.dept_info_list.map(department => {
|
|
93
|
+
if (!object(department)) throw new TypeError('Invalid department');
|
|
94
|
+
return { departmentId: department.dept_id,
|
|
95
|
+
...optionalFields(department, { name: 'dept_name', externalDepartmentId: 'out_dept_id' }) };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (include.includes('status')) {
|
|
99
|
+
unit.status = optionalFields(source, { onlineBusinessStatus: 'access_status',
|
|
100
|
+
offlineBusinessStatus: 'offline_business_status', storeStatus: 'store_status' });
|
|
101
|
+
}
|
|
102
|
+
if (include.includes('lifecycle')) {
|
|
103
|
+
const value = source.lifecycle_end_time;
|
|
104
|
+
const normalized = typeof value === 'string' && value.length === 19 && /^\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}$/.test(value) ?
|
|
105
|
+
`${value.slice(0, 10)} ${value.slice(11, 13)}:${value.slice(14, 16)}:${value.slice(17, 19)}` : value;
|
|
106
|
+
unit.lifecycle = { endsAt: fromBeijingSeconds(normalized) };
|
|
107
|
+
}
|
|
108
|
+
return unit;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function project(data, input, facts) {
|
|
112
|
+
const scope = { kdtId: input.kdtId };
|
|
113
|
+
const invalid = category => reject(category, 'units', scope, 'sent', facts);
|
|
114
|
+
if (!object(data) || !Array.isArray(data.organization_list) ||
|
|
115
|
+
data.page_num !== input.pageNo || data.page_size !== input.pageSize ||
|
|
116
|
+
data.organization_list.length > input.pageSize) {
|
|
117
|
+
throw invalid('protocol');
|
|
118
|
+
}
|
|
119
|
+
const rows = data.organization_list;
|
|
120
|
+
let total;
|
|
121
|
+
try { total = readTotal(data, 'total'); } catch { throw invalid('protocol'); }
|
|
122
|
+
if (total !== null && rows.length && (input.pageNo - 1) * input.pageSize + rows.length > total) throw invalid('protocol');
|
|
123
|
+
if (rows.some(row => object(row) && row.role === 9)) throw invalid('scope_unresolved');
|
|
124
|
+
if (input.orgRoles.length) {
|
|
125
|
+
const roles = input.orgRoles.flatMap(role => role === 2 ? [2001, 2002] : [role]);
|
|
126
|
+
if (rows.some(row => object(row) && Number.isSafeInteger(row.role) && row.role >= 0 &&
|
|
127
|
+
!roles.includes(row.role))) throw invalid('scope_unresolved');
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const units = rows.map(row => projectUnit(row, input.include));
|
|
131
|
+
if (new Set(units.map(unit => unit.kdtId)).size !== units.length) throw new TypeError('Duplicate unit');
|
|
132
|
+
const output = { data: { units, pagination: { pageNo: data.page_num, pageSize: data.page_size,
|
|
133
|
+
...(total === null ? {} : { total }), hasMore: total === null ? null : input.pageNo * input.pageSize < total } } };
|
|
134
|
+
validateCommandValue(schema, 'output', output);
|
|
135
|
+
return output;
|
|
136
|
+
} catch {
|
|
137
|
+
throw invalid('protocol');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function execute(input, preview) {
|
|
142
|
+
const scope = { kdtId: input.kdtId };
|
|
143
|
+
const { read, binding } = await createBoundShopQuery(scope, command, 'unit-basic');
|
|
144
|
+
if (binding.data.role !== 1) {
|
|
145
|
+
throw reject('scope_unresolved', 'unit-basic', scope, 'sent', binding.facts);
|
|
146
|
+
}
|
|
147
|
+
const request = preview.requests[1];
|
|
148
|
+
const { data, facts } = await read(request.path, request.body, request.stage);
|
|
149
|
+
return project(data, input, facts);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function createCommand({ context } = {}) {
|
|
153
|
+
return new DiagnosticCommand('list', { path: command, schema, parameterCategory: 'parameter' })
|
|
154
|
+
.description('仅从当前连锁总部查询一页下级组织,不含三方 CRM 节点')
|
|
155
|
+
.allowExcessArguments(false)
|
|
156
|
+
.option('--kdt-id <id>', '当前总部正安全整数;默认上下文 shopId,不可跨总部')
|
|
157
|
+
.option('--page-no <n>', '页码 1..2147483647,每次仅一页', '1')
|
|
158
|
+
.option('--page-size <n>', '每页容量 1..50', '20')
|
|
159
|
+
.option('--org-roles <codes>', '筛选组 CSV:2 门店/网店、3 独立仓、4 合伙人、6 分销供货店铺、7 前置仓')
|
|
160
|
+
.option('--include <modules>', '可选 address,departments,status,lifecycle;逗号分隔并去重')
|
|
161
|
+
.addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
|
|
162
|
+
.choices(['json', 'pretty']).default('json'))
|
|
163
|
+
.option('--dry-run', '仅本地预览;零凭证、零网络')
|
|
164
|
+
.addHelpText('after', `
|
|
165
|
+
筛选组 2 对应返回 orgRole=2001 门店或 2002 网店;筛选组不是响应角色枚举。
|
|
166
|
+
未指定筛选时保留未知合法角色,始终排除 CRM 角色 9;异常返回 9 时整体失败,不过滤后沿用 total。
|
|
167
|
+
基础绑定必须是当前总部且 role=1;绑定后只读一页,最多两次请求,不自动翻页或逐项补查。
|
|
168
|
+
hasMore 由 pageNo * pageSize < total 计算;空页或短页不代表全局无记录。
|
|
169
|
+
status 分别保留网店营业、门店营业和门店状态,不推导综合启停或详情 operationStatus。
|
|
170
|
+
lifecycle.endsAt 固定 UTC+08:00 北京时间 YYYY-MM-DD HH:mm:ss.SSS,秒补 .000。
|
|
171
|
+
API 两种有依据的秒文本在内部严格转换;缺失/非法时间不当作永久有效,未选择时不解析。
|
|
172
|
+
地址仅含 address/county/countyId;部门数组不是完整部门树。本命令不提供店铺类型或 CRM 范围开关。
|
|
173
|
+
真实执行需要总部上下文和同总部凭证;位置准入不代表店铺员工身份授权与权限隔离验收通过。
|
|
174
|
+
无上下文仅显式合法目标可本地预览;失败 stdout 为空,不输出部分结果。
|
|
175
|
+
契约:zan-saas schema org.unit.list
|
|
176
|
+
示例:zan-saas org unit list --kdt-id 63077 --org-roles 2 --include departments,status --dry-run
|
|
177
|
+
`)
|
|
178
|
+
.action(async options => {
|
|
179
|
+
const input = buildInput(options, context);
|
|
180
|
+
const preview = previewFor(input);
|
|
181
|
+
validateCommandValue(schema, 'preview', preview);
|
|
182
|
+
const output = options.dryRun ? preview : await execute(input, preview);
|
|
183
|
+
console.log(JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'hq', createCommand: withTargetShopDefault(createCommand) };
|