@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,173 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"input": {
|
|
4
|
+
"type": "object", "required": ["kdtId", "deliveryId"], "additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"kdtId": { "$ref": "#/definitions/shopId" },
|
|
7
|
+
"deliveryId": { "$ref": "#/definitions/deliveryId" }
|
|
8
|
+
},
|
|
9
|
+
"description": "参数解析后的配送单查询业务输入。无 include、订单号或货单号输入。"
|
|
10
|
+
},
|
|
11
|
+
"output": {
|
|
12
|
+
"type": "object", "required": ["data"], "additionalProperties": false,
|
|
13
|
+
"properties": {
|
|
14
|
+
"data": {
|
|
15
|
+
"type": "object", "required": ["delivery"], "additionalProperties": false,
|
|
16
|
+
"properties": { "delivery": { "$ref": "#/definitions/delivery" } }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"preview": {
|
|
21
|
+
"type": "object", "additionalProperties": false,
|
|
22
|
+
"required": ["scope", "prerequisites", "requests", "conditionalRequest", "result"],
|
|
23
|
+
"properties": {
|
|
24
|
+
"scope": {
|
|
25
|
+
"type": "object", "required": ["kdtId"], "additionalProperties": false,
|
|
26
|
+
"properties": { "kdtId": { "$ref": "#/definitions/shopId" } }
|
|
27
|
+
},
|
|
28
|
+
"prerequisites": {
|
|
29
|
+
"type": "array", "minItems": 1, "maxItems": 1,
|
|
30
|
+
"items": {
|
|
31
|
+
"type": "object", "required": ["method", "path", "body"], "additionalProperties": false,
|
|
32
|
+
"properties": {
|
|
33
|
+
"method": { "const": "POST" }, "path": { "const": "youzan.shop.basic.get/3.0.0" },
|
|
34
|
+
"body": { "type": "object", "maxProperties": 0 }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"requests": {
|
|
39
|
+
"type": "array", "minItems": 1, "maxItems": 1,
|
|
40
|
+
"items": {
|
|
41
|
+
"type": "object", "required": ["method", "path", "body"], "additionalProperties": false,
|
|
42
|
+
"properties": {
|
|
43
|
+
"method": { "const": "POST" },
|
|
44
|
+
"path": { "const": "youzan.logistics.online.distorder.query.querybydistid/3.0.0" },
|
|
45
|
+
"body": {
|
|
46
|
+
"type": "object", "required": ["dist_id"], "additionalProperties": false,
|
|
47
|
+
"properties": { "dist_id": { "type": "string", "pattern": "^\\*\\*\\*[^\\s\\u0000-\\u001f\\u007f-\\u009f]{1,4}$(?![\\s\\S])" } }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"conditionalRequest": {
|
|
53
|
+
"type": "object", "required": ["when", "method", "path", "bodyFrom", "fixedBody"],
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"properties": {
|
|
56
|
+
"when": { "const": "deliveryType 为 11/12/14" }, "method": { "const": "POST" },
|
|
57
|
+
"path": { "const": "youzan.trade.dc.query.querybyorderno/1.0.1" },
|
|
58
|
+
"bodyFrom": {
|
|
59
|
+
"type": "object", "required": ["tid"], "additionalProperties": false,
|
|
60
|
+
"properties": { "tid": { "const": "data.delivery.orderNo" } },
|
|
61
|
+
"description": "只记录待取得的业务字段来源,不是可发送的订单号或占位请求。"
|
|
62
|
+
},
|
|
63
|
+
"fixedBody": {
|
|
64
|
+
"type": "object", "additionalProperties": false,
|
|
65
|
+
"required": ["include_dist_order", "include_all_dist_order", "open_query_requestinclude_dist_order_and_detail"],
|
|
66
|
+
"properties": {
|
|
67
|
+
"include_dist_order": { "const": true }, "include_all_dist_order": { "const": true },
|
|
68
|
+
"open_query_requestinclude_dist_order_and_detail": { "const": true }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"result": { "const": "类型和订单待主查询取得;21/23 本地投影同城摘要,11/12/14 补查运单引用,其他类型仅返回基础内容。" }
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"error": {
|
|
77
|
+
"type": "object", "required": ["success", "code", "message", "details"], "additionalProperties": false,
|
|
78
|
+
"properties": {
|
|
79
|
+
"success": { "const": false }, "code": { "const": -10001 },
|
|
80
|
+
"message": { "type": "string", "minLength": 1 },
|
|
81
|
+
"details": {
|
|
82
|
+
"type": "object", "additionalProperties": false,
|
|
83
|
+
"required": ["category", "stage", "command", "targetScope", "requestState", "nextStep"],
|
|
84
|
+
"if": { "properties": { "requestState": { "enum": ["sent", "unknown"] } } },
|
|
85
|
+
"then": {
|
|
86
|
+
"properties": {
|
|
87
|
+
"targetScope": {
|
|
88
|
+
"type": "object", "required": ["kdtId"], "additionalProperties": false,
|
|
89
|
+
"properties": { "kdtId": { "$ref": "#/definitions/shopId" } }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"properties": {
|
|
94
|
+
"category": { "enum": ["validation", "parameter", "configuration", "authentication", "permission", "scope_unresolved", "transport", "http", "business_rejected", "protocol", "not_found_in_scope", "module_unavailable", "budget_exceeded"] },
|
|
95
|
+
"stage": { "type": "string", "minLength": 1 },
|
|
96
|
+
"command": { "const": "fulfillment.delivery.get" },
|
|
97
|
+
"targetScope": {
|
|
98
|
+
"type": "object", "additionalProperties": false,
|
|
99
|
+
"properties": { "kdtId": { "$ref": "#/definitions/shopId" } },
|
|
100
|
+
"description": "目标尚未解析且未发送请求时允许空对象,不推造店铺;已解析时保留合法 kdtId,已发送或发送结果未知时必须包含该店铺。"
|
|
101
|
+
},
|
|
102
|
+
"requestState": { "enum": ["not_sent", "sent", "unknown"] },
|
|
103
|
+
"nextStep": { "type": "string", "minLength": 1 },
|
|
104
|
+
"api": { "type": "string", "minLength": 1 },
|
|
105
|
+
"httpStatus": { "type": "integer", "minimum": 100, "maximum": 599 },
|
|
106
|
+
"businessCode": { "$ref": "#/definitions/code" },
|
|
107
|
+
"gatewayCode": { "$ref": "#/definitions/code" },
|
|
108
|
+
"trace_id": { "$ref": "#/definitions/trace" },
|
|
109
|
+
"request_id": { "$ref": "#/definitions/trace" }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"definitions": {
|
|
115
|
+
"shopId": { "type": "integer", "minimum": 1, "maximum": 9007199254740991, "description": "目标店铺正安全整数,须与当前店铺及凭证店铺相同。" },
|
|
116
|
+
"deliveryId": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[^\\s\\u0000-\\u001f\\u007f-\\u009f]+$(?![\\s\\S])", "description": "有赞配送单号,保留原始编码和前导零,不是货单或服务商单号。" },
|
|
117
|
+
"text": { "type": "string", "minLength": 1, "pattern": "\\S" },
|
|
118
|
+
"code": { "anyOf": [{ "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "string", "pattern": "^-?\\d{1,12}$" }] },
|
|
119
|
+
"trace": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[a-zA-Z0-9_-]+$" },
|
|
120
|
+
"time": { "type": "string", "format": "beijing-date-time-ms", "description": "北京时间完整时间 YYYY-MM-DD HH:mm:ss.SSS,缺省或空值时省略,不推断事件未发生。", "$comment": "upstream-time:milliseconds" },
|
|
121
|
+
"localDelivery": {
|
|
122
|
+
"type": "object", "required": ["providerName", "providerOrderNo", "statusText"], "additionalProperties": false,
|
|
123
|
+
"properties": {
|
|
124
|
+
"providerName": { "$ref": "#/definitions/text", "description": "第三方配送公司名称,不据此推断供应商 ID。" },
|
|
125
|
+
"providerOrderNo": { "$ref": "#/definitions/text", "description": "同城服务商详情单号,不等于有赞配送单号或货单号。" },
|
|
126
|
+
"statusText": { "$ref": "#/definitions/text", "description": "服务商原始展示状态,不转换为有赞配送单状态。" },
|
|
127
|
+
"cancelReason": { "type": "string", "description": "原始取消原因,可为空串,缺省或空值时省略,不能据此推断是否取消。" }
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"waybill": {
|
|
131
|
+
"type": "object", "required": ["waybillNo", "carrierId"], "additionalProperties": false,
|
|
132
|
+
"properties": {
|
|
133
|
+
"waybillNo": { "$ref": "#/definitions/text", "description": "当前快递运单号,用于后续运单查询,不承诺子母件全集。" },
|
|
134
|
+
"carrierId": { "type": "integer", "minimum": 1, "maximum": 9007199254740991, "description": "有赞快递公司 ID,后续查询需与该运单号一起使用。" }
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"delivery": {
|
|
138
|
+
"type": "object", "additionalProperties": false,
|
|
139
|
+
"required": ["deliveryId", "shipmentNo", "orderNo", "kdtId", "status", "deliveryMethod", "deliveryType"],
|
|
140
|
+
"properties": {
|
|
141
|
+
"deliveryId": { "$ref": "#/definitions/deliveryId" },
|
|
142
|
+
"shipmentNo": { "$ref": "#/definitions/text", "description": "所属发货单编号,不是运单号或服务商单号。" },
|
|
143
|
+
"orderNo": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[^\\s\\u0000-\\u001f\\u007f-\\u009f]+$(?![\\s\\S])", "description": "所属原始订单号,不按前缀或位数判断有效性;保留原值用于补查和关联核对,不含空白或控制字符。" },
|
|
144
|
+
"kdtId": { "$ref": "#/definitions/shopId" },
|
|
145
|
+
"status": { "type": "integer", "minimum": 0, "maximum": 9007199254740991, "description": "0 未发货,NON_DELIVERY;1 发货中,DELIVERING;2 已发货,DELIVERED;3 已取消,CANCELED。未知非负安全整数原值保留,不补含义。已发货不证明物流签收、买家收货或售后确认。" },
|
|
146
|
+
"deliveryMethod": { "type": "integer", "minimum": 0, "maximum": 9007199254740991, "description": "1 快递;2 同城送;3 自提。未知非负安全整数保留原值,不猜含义。已知执行类型须与方式一致。" },
|
|
147
|
+
"deliveryType": { "type": "integer", "minimum": 0, "maximum": 9007199254740991, "description": "11 快递、系统呼叫;12 快递、商家呼叫;13 快递、无需物流;14 快递、电子面单;21 同城送、商家呼叫第三方;22 同城送、商家自主配送;23 同城送、系统呼叫第三方;24 自提、核销提货;91 自提、有码提货;92 自提、无码提货。未知非负安全整数保留原值,不推断补查路径。" },
|
|
148
|
+
"createdAt": { "$ref": "#/definitions/time", "description": "配送创建时间,北京时间毫秒精度,缺省或空值时省略。", "$comment": "upstream-time:milliseconds" },
|
|
149
|
+
"updatedAt": { "$ref": "#/definitions/time", "description": "配送更新时间,不是包裹发货时间,北京时间毫秒精度,缺省或空值时省略。", "$comment": "upstream-time:milliseconds" },
|
|
150
|
+
"localDelivery": { "$ref": "#/definitions/localDelivery", "description": "类型 21/23 的必需默认同城摘要,其他类型省略。" },
|
|
151
|
+
"waybill": { "$ref": "#/definitions/waybill", "description": "类型 11/12/14 的必需默认快递引用,其他类型省略。" }
|
|
152
|
+
},
|
|
153
|
+
"allOf": [
|
|
154
|
+
{ "if": { "properties": { "deliveryType": { "enum": [21, 23] } } }, "then": { "required": ["localDelivery"], "properties": { "localDelivery": true } }, "else": { "properties": { "localDelivery": false } } },
|
|
155
|
+
{ "if": { "properties": { "deliveryType": { "enum": [11, 12, 14] } } }, "then": { "required": ["waybill"], "properties": { "waybill": true } }, "else": { "properties": { "waybill": false } } },
|
|
156
|
+
{ "if": { "properties": { "deliveryType": { "enum": [11, 12, 13, 14] } } }, "then": { "properties": { "deliveryMethod": { "const": 1 } } } },
|
|
157
|
+
{ "if": { "properties": { "deliveryType": { "enum": [21, 22, 23] } } }, "then": { "properties": { "deliveryMethod": { "const": 2 } } } },
|
|
158
|
+
{ "if": { "properties": { "deliveryType": { "enum": [24, 91, 92] } } }, "then": { "properties": { "deliveryMethod": { "const": 3 } } } }
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"api": { "method": "POST", "path": "youzan.logistics.online.distorder.query.querybydistid/3.0.0" },
|
|
163
|
+
"success": { "rule": "同店核验、目标与关联匹配,基础内容及类型适用的默认内容全部通过后才返回 data.delivery。" },
|
|
164
|
+
"errors": { "recovery": "失败 stdout 为空,stderr 为错误信封,退出码 1。保留原店铺与对象排查,不能把业务拒绝或默认内容缺失解释成没有配送,不自动重试、换店或换身份。" },
|
|
165
|
+
"notes": [
|
|
166
|
+
"--kdt-id 省略时使用本次有效上下文 shopId;显式提供的非法值不回退。两者都缺失时拒绝;目标范围、同店核验和服务端权限仍按本命令校验。",
|
|
167
|
+
"订单号通常为 E/V/C 开头加 23 位数字,仅供核对,不限定前缀、数字组合或 24 位长度;按原值传递。仅保留非空、无空白或控制字符和最多 128 字符的文本保护;服务端仍判断支持范围和对象归属。",
|
|
168
|
+
"仅支持当前店铺四字段上下文和同店凭证,店铺核验不证明员工授权通过。无 include、分页、商品、骑手、位置、费用、日志或轨迹。",
|
|
169
|
+
"快递类型 11/12/14 最多三次请求,其他类型最多两次。每请求超时 10 秒,无重试或回退。",
|
|
170
|
+
"每响应读取后最多 10 MiB,不是流式读取硬限制;最多检查 1000 张货单及每张 1000 条配送,输出最多 5 MiB,超限整体失败不截断。",
|
|
171
|
+
"类型专属字段省略表示未进入对应已知类型分支,不表示已确认不存在其他关联。主对象或所需引用未取得时不输出部分成功。"
|
|
172
|
+
]
|
|
173
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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, constraints, modelAt } = require('../../../../../execution/error-details');
|
|
8
|
+
const { readContext } = require('../../../../../identity/context');
|
|
9
|
+
const { resolveTargetShop } = require('../../../../../execution/target-shop');
|
|
10
|
+
const { validateCommandValue } = require('../../../../../execution/command-schema');
|
|
11
|
+
const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
|
|
12
|
+
const { project } = require('./projection');
|
|
13
|
+
const schema = require('./schema.json');
|
|
14
|
+
|
|
15
|
+
const command = 'fulfillment.shipment.list';
|
|
16
|
+
const reject = (category, stage, scope, state, facts) =>
|
|
17
|
+
failure(command, category, stage, scope, state, facts);
|
|
18
|
+
|
|
19
|
+
function createCommand({ context } = {}) {
|
|
20
|
+
return new DiagnosticCommand('list', { path: command, schema, parameterCategory: 'parameter' })
|
|
21
|
+
.description('查询指定订单本次返回的发货单集合,默认包含商品明细和配送引用')
|
|
22
|
+
.allowExcessArguments(false)
|
|
23
|
+
.option('--kdt-id <id>', '目标店铺正安全整数,必须与当前上下文店铺相同;省略时使用当前上下文店铺')
|
|
24
|
+
.requiredOption('--order-no <no>', '必填:原始订单号,最多 128 字符;不限定前缀或位数')
|
|
25
|
+
.addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
|
|
26
|
+
.choices(['json', 'pretty']).default('json'))
|
|
27
|
+
.option('--dry-run', '仅本地预览脱敏请求计划,不读凭证、不联网')
|
|
28
|
+
.addHelpText('after', `
|
|
29
|
+
输出 data.shipments 数组,零张、一张、多张均不改变形状。
|
|
30
|
+
订单号通常为 E/V/C 开头加 23 位数字,仅供核对;不按该格式拒绝输入或响应,订单与店铺关联仍须一致。
|
|
31
|
+
默认包含每张货单的 items 和 deliveries,不查询配送详情、轨迹或日志。
|
|
32
|
+
空数组只表示本次未返回货单,不证明订单不存在、无需发货或履约完成。
|
|
33
|
+
没有分页,不提供 --include、--shipment-no 或旧参数别名。
|
|
34
|
+
最多一次店铺核验与一次订单查询,不重试、不切换店铺或身份。
|
|
35
|
+
每个集合最多 1000 条,主响应读取后最多 10 MiB,最终输出最多 5 MiB。
|
|
36
|
+
超预算整体失败,不截断;响应预算不是流式网络读取硬上限。
|
|
37
|
+
真实执行需有效四字段上下文和同店授权凭证,店铺核验不证明员工授权通过。
|
|
38
|
+
契约:zan-saas schema fulfillment.shipment.list
|
|
39
|
+
示例:zan-saas fulfillment shipment list --kdt-id 63077 --order-no E20200413232015099300005 --dry-run
|
|
40
|
+
`)
|
|
41
|
+
.action(async options => {
|
|
42
|
+
if (String(Number(options.kdtId)) !== options.kdtId) {
|
|
43
|
+
const error = inputIssue('/kdtId', 'invalid_format', constraints(modelAt(schema, 'input', '/kdtId')));
|
|
44
|
+
error.cliDetails = reject('validation', 'input').cliDetails;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
const scope = resolveTargetShop(options, context, command);
|
|
48
|
+
const state = readContext(context);
|
|
49
|
+
if (state.status === 'ready' && String(scope.kdtId) !== state.context.shopId) {
|
|
50
|
+
throw reject('permission', 'scope', scope);
|
|
51
|
+
}
|
|
52
|
+
const input = { ...scope, orderNo: options.orderNo };
|
|
53
|
+
withInputScope(scope, () => validateCommandValue(schema, 'input', input));
|
|
54
|
+
const body = { tid: input.orderNo, include_item_delivery_status: true, include_dist_order: true };
|
|
55
|
+
const preview = {
|
|
56
|
+
scope, prerequisites: [{ method: 'POST', path: bindingPath, body: {} }],
|
|
57
|
+
requests: [{ method: 'POST', path: schema.api.path,
|
|
58
|
+
body: { ...body, tid: `***${Array.from(input.orderNo).slice(-4).join('')}` } }],
|
|
59
|
+
result: { collection: 'data.shipments', items: true, deliveries: true, pagination: false }
|
|
60
|
+
};
|
|
61
|
+
validateCommandValue(schema, 'preview', preview);
|
|
62
|
+
let output = preview;
|
|
63
|
+
let facts = {};
|
|
64
|
+
if (!options.dryRun) {
|
|
65
|
+
const read = await createShopQuery(scope, command);
|
|
66
|
+
const response = await read(schema.api.path, body, 'shipment-list');
|
|
67
|
+
const { rawBody } = response;
|
|
68
|
+
facts = response.facts;
|
|
69
|
+
if (response.responseBytes > 10 * 1024 * 1024) {
|
|
70
|
+
throw reject('budget_exceeded', 'response-bytes', scope, 'sent', facts);
|
|
71
|
+
}
|
|
72
|
+
try { output = project(rawBody, input); }
|
|
73
|
+
catch (error) { throw reject(error.category || 'protocol', 'shipment-list-model', scope, 'sent', facts); }
|
|
74
|
+
}
|
|
75
|
+
const text = `${JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0)}\n`;
|
|
76
|
+
if (Buffer.byteLength(text) > 5 * 1024 * 1024) {
|
|
77
|
+
throw reject('budget_exceeded', 'output-bytes', scope, 'sent', facts);
|
|
78
|
+
}
|
|
79
|
+
process.stdout.write(text);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { validateCommandValue } = require('../../../../../execution/command-schema');
|
|
4
|
+
const { object } = require('../../../../../execution/query-api');
|
|
5
|
+
const schema = require('./schema.json');
|
|
6
|
+
|
|
7
|
+
class NumericToken {
|
|
8
|
+
constructor(text) { this.text = text; }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function parseNumbers(text) {
|
|
12
|
+
const tokens = text.match(/"(?:[^"\\]|\\.)*"|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null|[{}\[\]:,]/g);
|
|
13
|
+
let index = 0;
|
|
14
|
+
function value() {
|
|
15
|
+
const token = tokens[index++];
|
|
16
|
+
if (token === '{') {
|
|
17
|
+
const result = Object.create(null);
|
|
18
|
+
while (tokens[index] !== '}') {
|
|
19
|
+
const key = JSON.parse(tokens[index++]);
|
|
20
|
+
index++;
|
|
21
|
+
result[key] = value();
|
|
22
|
+
if (tokens[index] !== ',') break;
|
|
23
|
+
index++;
|
|
24
|
+
}
|
|
25
|
+
index++;
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
if (token === '[') {
|
|
29
|
+
const result = [];
|
|
30
|
+
while (tokens[index] !== ']') {
|
|
31
|
+
result.push(value());
|
|
32
|
+
if (tokens[index] !== ',') break;
|
|
33
|
+
index++;
|
|
34
|
+
}
|
|
35
|
+
index++;
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
return /^-?\d/.test(token) ? new NumericToken(token) : JSON.parse(token);
|
|
39
|
+
}
|
|
40
|
+
JSON.parse(text);
|
|
41
|
+
return value();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function integer(value, minimum = 0) {
|
|
45
|
+
if (!(value instanceof NumericToken)) throw new Error('Expected numeric token');
|
|
46
|
+
const match = /^(-?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/.exec(value.text);
|
|
47
|
+
const fraction = match[3] || '';
|
|
48
|
+
const significant = `${match[2]}${fraction}`.replace(/^0+/, '');
|
|
49
|
+
const digits = significant.replace(/0+$/, '');
|
|
50
|
+
if (!digits) {
|
|
51
|
+
if (minimum > 0) throw new Error('Invalid integer');
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
const scale = Number(match[4] || 0) - fraction.length + significant.length - digits.length;
|
|
55
|
+
if (match[1] || scale < 0 || digits.length + scale > 16) throw new Error('Invalid integer');
|
|
56
|
+
const exact = BigInt(digits) * 10n ** BigInt(scale);
|
|
57
|
+
if (exact > BigInt(Number.MAX_SAFE_INTEGER) || exact < BigInt(minimum)) throw new Error('Invalid integer');
|
|
58
|
+
return Number(exact);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function identifier(value) {
|
|
62
|
+
if (typeof value !== 'string' || !value.trim()) throw new Error('Invalid identifier');
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function collection(value) {
|
|
67
|
+
if (!Array.isArray(value)) throw new Error('Missing collection');
|
|
68
|
+
if (value.length > 1000) {
|
|
69
|
+
const error = new Error('Collection budget exceeded');
|
|
70
|
+
error.category = 'budget_exceeded';
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function project(rawBody, input) {
|
|
77
|
+
const envelope = parseNumbers(rawBody);
|
|
78
|
+
const shipmentNumbers = new Set();
|
|
79
|
+
const deliveryIds = new Set();
|
|
80
|
+
const shipments = collection(envelope.data).map(shipment => {
|
|
81
|
+
if (!object(shipment)) throw new Error('Invalid shipment');
|
|
82
|
+
const shipmentNo = identifier(shipment.delivery_no);
|
|
83
|
+
if (shipmentNumbers.has(shipmentNo)) throw new Error('Duplicate shipment');
|
|
84
|
+
shipmentNumbers.add(shipmentNo);
|
|
85
|
+
function relation(row) {
|
|
86
|
+
if (!object(row) || row.tid !== input.orderNo ||
|
|
87
|
+
row.delivery_no !== shipmentNo || integer(row.kdt_id, 1) !== input.kdtId) {
|
|
88
|
+
throw new Error('Relation mismatch');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
relation(shipment);
|
|
92
|
+
const result = {
|
|
93
|
+
shipmentNo, orderNo: shipment.tid, kdtId: integer(shipment.kdt_id, 1),
|
|
94
|
+
status: integer(shipment.status), deliveryMethod: integer(shipment.dist_type),
|
|
95
|
+
items: collection(shipment.delivery_order_items).map(item => {
|
|
96
|
+
relation(item);
|
|
97
|
+
if (!(item.item_id instanceof NumericToken) || !/^[1-9]\d*$/.test(item.item_id.text)) {
|
|
98
|
+
throw new Error('Invalid order item ID');
|
|
99
|
+
}
|
|
100
|
+
return { orderItemId: item.item_id.text, quantity: integer(item.num) };
|
|
101
|
+
}),
|
|
102
|
+
deliveries: collection(shipment.dist_order_d_t_os).map(delivery => {
|
|
103
|
+
relation(delivery);
|
|
104
|
+
const deliveryId = identifier(delivery.dist_id);
|
|
105
|
+
if (deliveryIds.has(deliveryId)) throw new Error('Duplicate delivery');
|
|
106
|
+
deliveryIds.add(deliveryId);
|
|
107
|
+
return { deliveryId, status: integer(delivery.status), deliveryMethod: integer(delivery.dist_type) };
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
for (const [source, target] of [['flow_type', 'flowType'], ['delivery_mode', 'mode']]) {
|
|
111
|
+
if (shipment[source] !== undefined && shipment[source] !== null) result[target] = integer(shipment[source]);
|
|
112
|
+
}
|
|
113
|
+
const hasPointId = shipment.delivery_point_id !== undefined && shipment.delivery_point_id !== null;
|
|
114
|
+
const hasPointType = shipment.delivery_point_type !== undefined && shipment.delivery_point_type !== null;
|
|
115
|
+
if (hasPointId !== hasPointType) throw new Error('Incomplete delivery point');
|
|
116
|
+
if (hasPointId) result.deliveryPoint = {
|
|
117
|
+
id: String(integer(shipment.delivery_point_id, 1)), type: integer(shipment.delivery_point_type)
|
|
118
|
+
};
|
|
119
|
+
if (shipment.remark !== undefined && shipment.remark !== null) {
|
|
120
|
+
if (typeof shipment.remark !== 'string') throw new Error('Invalid remark');
|
|
121
|
+
result.remark = shipment.remark;
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
});
|
|
125
|
+
const output = { data: { shipments } };
|
|
126
|
+
validateCommandValue(schema, 'output', output);
|
|
127
|
+
return output;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = { project };
|