@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.
Files changed (329) hide show
  1. package/DEPENDENCIES.json +50 -0
  2. package/INSTALL.md +79 -0
  3. package/LICENSE +21 -0
  4. package/NOTICE +1 -0
  5. package/README.md +151 -2
  6. package/THIRD_PARTY_NOTICES.txt +162 -0
  7. package/bin/zan-saas-cli.js +28 -0
  8. package/internal/registry/index.js +123 -0
  9. package/internal/registry/manifest.json +424 -0
  10. package/npm-shrinkwrap.json +86 -0
  11. package/package.json +33 -4
  12. package/skills/README.md +30 -0
  13. package/skills/zan-saas/SKILL.md +54 -0
  14. package/skills/zan-saas/references/host-entry.md +25 -0
  15. package/skills/zan-saas-access/SKILL.md +37 -0
  16. package/skills/zan-saas-access/references/role-list.md +11 -0
  17. package/skills/zan-saas-access/references/staff-perms-get.md +11 -0
  18. package/skills/zan-saas-aftersale/SKILL.md +31 -0
  19. package/skills/zan-saas-aftersale/references/case-list.md +13 -0
  20. package/skills/zan-saas-aftersale/references/case-scan.md +31 -0
  21. package/skills/zan-saas-benefit/SKILL.md +46 -0
  22. package/skills/zan-saas-benefit/references/card-get.md +7 -0
  23. package/skills/zan-saas-benefit/references/card-grant-list.md +11 -0
  24. package/skills/zan-saas-benefit/references/card-list.md +7 -0
  25. package/skills/zan-saas-benefit/references/customer-card-get.md +7 -0
  26. package/skills/zan-saas-benefit/references/customer-card-list.md +7 -0
  27. package/skills/zan-saas-coupon/SKILL.md +41 -0
  28. package/skills/zan-saas-coupon/references/activity-get.md +11 -0
  29. package/skills/zan-saas-coupon/references/activity-list.md +15 -0
  30. package/skills/zan-saas-coupon/references/voucher-get.md +13 -0
  31. package/skills/zan-saas-coupon/references/voucher-list.md +25 -0
  32. package/skills/zan-saas-customer/SKILL.md +73 -0
  33. package/skills/zan-saas-customer/references/customer-scan.md +11 -0
  34. package/skills/zan-saas-customer/references/segment-list.md +22 -0
  35. package/skills/zan-saas-fulfillment/SKILL.md +36 -0
  36. package/skills/zan-saas-fulfillment/references/delivery-get.md +11 -0
  37. package/skills/zan-saas-fulfillment/references/shipment-list.md +11 -0
  38. package/skills/zan-saas-fulfillment/references/waybill-get.md +9 -0
  39. package/skills/zan-saas-interaction/SKILL.md +37 -0
  40. package/skills/zan-saas-interaction/references/lottery-get.md +11 -0
  41. package/skills/zan-saas-interaction/references/lottery-list.md +19 -0
  42. package/skills/zan-saas-item/SKILL.md +61 -0
  43. package/skills/zan-saas-item/references/attribute-list.md +11 -0
  44. package/skills/zan-saas-item/references/brand-list.md +7 -0
  45. package/skills/zan-saas-item/references/classification-get.md +7 -0
  46. package/skills/zan-saas-item/references/classification-list.md +7 -0
  47. package/skills/zan-saas-item/references/group-list.md +9 -0
  48. package/skills/zan-saas-item/references/item-content.md +9 -0
  49. package/skills/zan-saas-item/references/item-get.md +9 -0
  50. package/skills/zan-saas-item/references/item-search.md +23 -0
  51. package/skills/zan-saas-item/references/product-identity.md +11 -0
  52. package/skills/zan-saas-member/SKILL.md +41 -0
  53. package/skills/zan-saas-member/references/customer-level-get.md +7 -0
  54. package/skills/zan-saas-member/references/growth-log-list.md +17 -0
  55. package/skills/zan-saas-member/references/membership-get.md +7 -0
  56. package/skills/zan-saas-order/SKILL.md +56 -0
  57. package/skills/zan-saas-order/references/order-get.md +26 -0
  58. package/skills/zan-saas-order/references/order-list.md +25 -0
  59. package/skills/zan-saas-order/references/order-scan.md +35 -0
  60. package/skills/zan-saas-org/SKILL.md +37 -0
  61. package/skills/zan-saas-org/references/staff-get.md +15 -0
  62. package/skills/zan-saas-org/references/staff-role-get.md +11 -0
  63. package/skills/zan-saas-org/references/unit-get.md +11 -0
  64. package/skills/zan-saas-org/references/unit-list.md +15 -0
  65. package/skills/zan-saas-points/SKILL.md +42 -0
  66. package/skills/zan-saas-points/references/account-get.md +7 -0
  67. package/skills/zan-saas-points/references/log-list.md +17 -0
  68. package/skills/zan-saas-points/references/rule-list.md +2 -0
  69. package/skills/zan-saas-privacy/SKILL.md +30 -0
  70. package/skills/zan-saas-privacy/references/field-decrypt.md +19 -0
  71. package/skills/zan-saas-shared/SKILL.md +94 -0
  72. package/skills/zan-saas-shared/references/authentication.md +52 -0
  73. package/skills/zan-saas-shared/references/value-processing.md +27 -0
  74. package/skills/zan-saas-stock/SKILL.md +28 -0
  75. package/skills/zan-saas-stock/references/log-list.md +11 -0
  76. package/skills/zan-saas-valuecard/SKILL.md +37 -0
  77. package/skills/zan-saas-valuecard/references/card-get.md +13 -0
  78. package/skills/zan-saas-valuecard/references/card-list.md +11 -0
  79. package/src/auth/browser.js +28 -0
  80. package/src/auth/callback-server.js +99 -0
  81. package/src/auth/config.js +53 -0
  82. package/src/auth/credential-store.js +109 -0
  83. package/src/auth/oauth-client.js +105 -0
  84. package/src/auth/pkce.js +28 -0
  85. package/src/auth/session.js +178 -0
  86. package/src/auth/tool.js +25 -0
  87. package/src/cli/command-paths.js +126 -0
  88. package/src/cli/context-help.js +102 -0
  89. package/src/cli/diagnostic-command.js +57 -0
  90. package/src/cli/domain-catalog.js +42 -0
  91. package/src/cli/help-text.js +32 -0
  92. package/src/cli/native-loader.js +120 -0
  93. package/src/cli/native-path.js +22 -0
  94. package/src/cli/parser-policy.js +141 -0
  95. package/src/cli/program.js +134 -0
  96. package/src/cli/skill-catalog.js +241 -0
  97. package/src/commands/native/access/commands.index.json +24 -0
  98. package/src/commands/native/access/domain.json +3 -0
  99. package/src/commands/native/access/role/list/command.js +141 -0
  100. package/src/commands/native/access/role/list/schema.json +393 -0
  101. package/src/commands/native/access/staff-perms/get/command.js +119 -0
  102. package/src/commands/native/access/staff-perms/get/schema.json +703 -0
  103. package/src/commands/native/aftersale/case/get/command.js +104 -0
  104. package/src/commands/native/aftersale/case/get/exact-json.js +52 -0
  105. package/src/commands/native/aftersale/case/get/money.js +28 -0
  106. package/src/commands/native/aftersale/case/get/projection.js +120 -0
  107. package/src/commands/native/aftersale/case/get/query.js +72 -0
  108. package/src/commands/native/aftersale/case/get/schema.json +134 -0
  109. package/src/commands/native/aftersale/case/list/command.js +135 -0
  110. package/src/commands/native/aftersale/case/list/schema.json +1095 -0
  111. package/src/commands/native/aftersale/case/scan/command.js +110 -0
  112. package/src/commands/native/aftersale/case/scan/query.js +62 -0
  113. package/src/commands/native/aftersale/case/scan/scan.js +78 -0
  114. package/src/commands/native/aftersale/case/scan/schema.json +964 -0
  115. package/src/commands/native/aftersale/case/scan/search.js +108 -0
  116. package/src/commands/native/aftersale/commands.index.json +42 -0
  117. package/src/commands/native/aftersale/domain.json +3 -0
  118. package/src/commands/native/aftersale/refund/list/command.js +97 -0
  119. package/src/commands/native/aftersale/refund/list/money.js +25 -0
  120. package/src/commands/native/aftersale/refund/list/projection.js +50 -0
  121. package/src/commands/native/aftersale/refund/list/query.js +73 -0
  122. package/src/commands/native/aftersale/refund/list/schema.json +130 -0
  123. package/src/commands/native/aftersale/shared/query.js +58 -0
  124. package/src/commands/native/aftersale/shared/search.js +128 -0
  125. package/src/commands/native/benefit/card-definition/get/command.js +110 -0
  126. package/src/commands/native/benefit/card-definition/get/schema.json +545 -0
  127. package/src/commands/native/benefit/card-definition/list/command.js +105 -0
  128. package/src/commands/native/benefit/card-definition/list/schema.json +690 -0
  129. package/src/commands/native/benefit/card-grant/list/command.js +135 -0
  130. package/src/commands/native/benefit/card-grant/list/schema.json +758 -0
  131. package/src/commands/native/benefit/commands.index.json +51 -0
  132. package/src/commands/native/benefit/customer-card/get/command.js +110 -0
  133. package/src/commands/native/benefit/customer-card/get/schema.json +340 -0
  134. package/src/commands/native/benefit/customer-card/list/command.js +102 -0
  135. package/src/commands/native/benefit/customer-card/list/schema.json +731 -0
  136. package/src/commands/native/benefit/domain.json +3 -0
  137. package/src/commands/native/coupon/activity/get/command.js +183 -0
  138. package/src/commands/native/coupon/activity/get/schema.json +624 -0
  139. package/src/commands/native/coupon/activity/list/command.js +169 -0
  140. package/src/commands/native/coupon/activity/list/schema.json +845 -0
  141. package/src/commands/native/coupon/commands.index.json +42 -0
  142. package/src/commands/native/coupon/domain.json +3 -0
  143. package/src/commands/native/coupon/shared/query.js +15 -0
  144. package/src/commands/native/coupon/voucher/get/command.js +113 -0
  145. package/src/commands/native/coupon/voucher/get/schema.json +147 -0
  146. package/src/commands/native/coupon/voucher/list/command.js +155 -0
  147. package/src/commands/native/coupon/voucher/list/schema.json +772 -0
  148. package/src/commands/native/customer/commands.index.json +96 -0
  149. package/src/commands/native/customer/customer/get/adapter.js +82 -0
  150. package/src/commands/native/customer/customer/get/command.js +106 -0
  151. package/src/commands/native/customer/customer/get/schema.json +958 -0
  152. package/src/commands/native/customer/customer/list/command.js +78 -0
  153. package/src/commands/native/customer/customer/list/input.js +145 -0
  154. package/src/commands/native/customer/customer/list/query.js +103 -0
  155. package/src/commands/native/customer/customer/list/schema.json +969 -0
  156. package/src/commands/native/customer/customer/scan/command.js +80 -0
  157. package/src/commands/native/customer/customer/scan/scan.js +92 -0
  158. package/src/commands/native/customer/customer/scan/schema.json +211 -0
  159. package/src/commands/native/customer/customer-tag/get/command.js +166 -0
  160. package/src/commands/native/customer/customer-tag/get/schema.json +317 -0
  161. package/src/commands/native/customer/customer-tag/list/command.js +143 -0
  162. package/src/commands/native/customer/customer-tag/list/schema.json +259 -0
  163. package/src/commands/native/customer/domain.json +3 -0
  164. package/src/commands/native/customer/segment/list/command.js +96 -0
  165. package/src/commands/native/customer/segment/list/query.js +98 -0
  166. package/src/commands/native/customer/segment/list/schema.json +135 -0
  167. package/src/commands/native/customer/segment-customer/list/command.js +171 -0
  168. package/src/commands/native/customer/segment-customer/list/schema.json +123 -0
  169. package/src/commands/native/customer/shared/search-input.js +179 -0
  170. package/src/commands/native/customer/shared/search-page.js +54 -0
  171. package/src/commands/native/customer/tag/get/command.js +73 -0
  172. package/src/commands/native/customer/tag/get/schema.json +339 -0
  173. package/src/commands/native/customer/tagcategory/get/command.js +80 -0
  174. package/src/commands/native/customer/tagcategory/get/query.js +98 -0
  175. package/src/commands/native/customer/tagcategory/get/schema.json +339 -0
  176. package/src/commands/native/customer/tagcategory/list/command.js +127 -0
  177. package/src/commands/native/customer/tagcategory/list/schema.json +394 -0
  178. package/src/commands/native/fulfillment/commands.index.json +33 -0
  179. package/src/commands/native/fulfillment/delivery/get/command.js +107 -0
  180. package/src/commands/native/fulfillment/delivery/get/projection.js +142 -0
  181. package/src/commands/native/fulfillment/delivery/get/schema.json +173 -0
  182. package/src/commands/native/fulfillment/domain.json +3 -0
  183. package/src/commands/native/fulfillment/shipment/list/command.js +83 -0
  184. package/src/commands/native/fulfillment/shipment/list/projection.js +130 -0
  185. package/src/commands/native/fulfillment/shipment/list/schema.json +752 -0
  186. package/src/commands/native/fulfillment/waybill/get/command.js +193 -0
  187. package/src/commands/native/fulfillment/waybill/get/response.js +68 -0
  188. package/src/commands/native/fulfillment/waybill/get/schema.json +190 -0
  189. package/src/commands/native/interaction/commands.index.json +24 -0
  190. package/src/commands/native/interaction/domain.json +3 -0
  191. package/src/commands/native/interaction/lottery/get/command.js +61 -0
  192. package/src/commands/native/interaction/lottery/get/query.js +152 -0
  193. package/src/commands/native/interaction/lottery/get/schema.json +1004 -0
  194. package/src/commands/native/interaction/lottery/list/command.js +176 -0
  195. package/src/commands/native/interaction/lottery/list/schema.json +898 -0
  196. package/src/commands/native/item/attribute/list/command.js +122 -0
  197. package/src/commands/native/item/attribute/list/schema.json +727 -0
  198. package/src/commands/native/item/brand/list/command.js +114 -0
  199. package/src/commands/native/item/brand/list/schema.json +725 -0
  200. package/src/commands/native/item/classification/get/command.js +87 -0
  201. package/src/commands/native/item/classification/get/schema.json +596 -0
  202. package/src/commands/native/item/classification/list/command.js +105 -0
  203. package/src/commands/native/item/classification/list/schema.json +676 -0
  204. package/src/commands/native/item/commands.index.json +87 -0
  205. package/src/commands/native/item/domain.json +1 -0
  206. package/src/commands/native/item/group/list/command.js +122 -0
  207. package/src/commands/native/item/group/list/schema.json +809 -0
  208. package/src/commands/native/item/item/get/command.js +122 -0
  209. package/src/commands/native/item/item/get/schema.json +3799 -0
  210. package/src/commands/native/item/item/list/command.js +7 -0
  211. package/src/commands/native/item/item/list/schema.json +1118 -0
  212. package/src/commands/native/item/item/scan/command.js +7 -0
  213. package/src/commands/native/item/item/scan/schema.json +1046 -0
  214. package/src/commands/native/item/item-content/get/command.js +54 -0
  215. package/src/commands/native/item/item-content/get/schema.json +677 -0
  216. package/src/commands/native/item/shared/api.js +31 -0
  217. package/src/commands/native/item/shared/content.js +20 -0
  218. package/src/commands/native/item/shared/diagnostics.js +61 -0
  219. package/src/commands/native/item/shared/h5.js +63 -0
  220. package/src/commands/native/item/shared/identity.js +62 -0
  221. package/src/commands/native/item/shared/normalize.js +49 -0
  222. package/src/commands/native/item/shared/scope.js +22 -0
  223. package/src/commands/native/item/shared/search-command.js +61 -0
  224. package/src/commands/native/item/shared/search-options.js +150 -0
  225. package/src/commands/native/item/shared/search.js +158 -0
  226. package/src/commands/native/member/commands.index.json +60 -0
  227. package/src/commands/native/member/customer-level/get/command.js +122 -0
  228. package/src/commands/native/member/customer-level/get/schema.json +300 -0
  229. package/src/commands/native/member/domain.json +3 -0
  230. package/src/commands/native/member/growth/get/command.js +64 -0
  231. package/src/commands/native/member/growth/get/schema.json +283 -0
  232. package/src/commands/native/member/growth-log/list/command.js +203 -0
  233. package/src/commands/native/member/growth-log/list/schema.json +695 -0
  234. package/src/commands/native/member/level/get/command.js +70 -0
  235. package/src/commands/native/member/level/get/query.js +125 -0
  236. package/src/commands/native/member/level/get/schema.json +339 -0
  237. package/src/commands/native/member/level/list/command.js +50 -0
  238. package/src/commands/native/member/level/list/query.js +109 -0
  239. package/src/commands/native/member/level/list/schema.json +104 -0
  240. package/src/commands/native/member/membership/get/command.js +78 -0
  241. package/src/commands/native/member/membership/get/schema.json +283 -0
  242. package/src/commands/native/order/commands.index.json +33 -0
  243. package/src/commands/native/order/domain.json +3 -0
  244. package/src/commands/native/order/order/get/command.js +155 -0
  245. package/src/commands/native/order/order/get/schema.json +1167 -0
  246. package/src/commands/native/order/order/list/command.js +230 -0
  247. package/src/commands/native/order/order/list/schema.json +1363 -0
  248. package/src/commands/native/order/order/scan/command.js +148 -0
  249. package/src/commands/native/order/order/scan/scan.js +89 -0
  250. package/src/commands/native/order/order/scan/schema.json +1445 -0
  251. package/src/commands/native/order/shared/projection.js +183 -0
  252. package/src/commands/native/order/shared/query.js +84 -0
  253. package/src/commands/native/order/shared/search.js +112 -0
  254. package/src/commands/native/org/commands.index.json +42 -0
  255. package/src/commands/native/org/domain.json +3 -0
  256. package/src/commands/native/org/shared/single-staff.js +115 -0
  257. package/src/commands/native/org/staff/get/command.js +148 -0
  258. package/src/commands/native/org/staff/get/schema.json +114 -0
  259. package/src/commands/native/org/staff-role/get/command.js +45 -0
  260. package/src/commands/native/org/staff-role/get/schema.json +93 -0
  261. package/src/commands/native/org/unit/get/command.js +131 -0
  262. package/src/commands/native/org/unit/get/schema.json +478 -0
  263. package/src/commands/native/org/unit/list/command.js +187 -0
  264. package/src/commands/native/org/unit/list/schema.json +828 -0
  265. package/src/commands/native/points/account/get/command.js +65 -0
  266. package/src/commands/native/points/account/get/schema.json +303 -0
  267. package/src/commands/native/points/commands.index.json +33 -0
  268. package/src/commands/native/points/domain.json +3 -0
  269. package/src/commands/native/points/log/list/command.js +141 -0
  270. package/src/commands/native/points/log/list/schema.json +761 -0
  271. package/src/commands/native/points/rule/list/command.js +82 -0
  272. package/src/commands/native/points/rule/list/schema.json +294 -0
  273. package/src/commands/native/privacy/commands.index.json +15 -0
  274. package/src/commands/native/privacy/domain.json +3 -0
  275. package/src/commands/native/privacy/field/decrypt/command.js +185 -0
  276. package/src/commands/native/privacy/field/decrypt/schema.json +656 -0
  277. package/src/commands/native/privacy/shared/order-source.js +33 -0
  278. package/src/commands/native/stock/commands.index.json +15 -0
  279. package/src/commands/native/stock/domain.json +3 -0
  280. package/src/commands/native/stock/log/list/command.js +207 -0
  281. package/src/commands/native/stock/log/list/schema.json +922 -0
  282. package/src/commands/native/valuecard/card/get/command.js +107 -0
  283. package/src/commands/native/valuecard/card/get/schema.json +683 -0
  284. package/src/commands/native/valuecard/card/list/command.js +136 -0
  285. package/src/commands/native/valuecard/card/list/pagination.js +23 -0
  286. package/src/commands/native/valuecard/card/list/schema.json +780 -0
  287. package/src/commands/native/valuecard/commands.index.json +24 -0
  288. package/src/commands/native/valuecard/domain.json +3 -0
  289. package/src/commands/native/valuecard/shared/projection.js +57 -0
  290. package/src/commands/system/api.js +47 -0
  291. package/src/commands/system/auth.js +118 -0
  292. package/src/commands/system/contracts.js +373 -0
  293. package/src/commands/system/doctor.js +24 -0
  294. package/src/commands/system/install.js +41 -0
  295. package/src/commands/system/printer.js +16 -0
  296. package/src/commands/system/schema.js +162 -0
  297. package/src/commands/system/shop-guidance.js +9 -0
  298. package/src/commands/system/shop.js +237 -0
  299. package/src/commands/system/skills.js +49 -0
  300. package/src/execution/beijing-date-time.js +29 -0
  301. package/src/execution/beijing-time.js +21 -0
  302. package/src/execution/bounded-input.js +42 -0
  303. package/src/execution/command-io.js +137 -0
  304. package/src/execution/command-policy.js +41 -0
  305. package/src/execution/command-schema.js +131 -0
  306. package/src/execution/datetime.js +83 -0
  307. package/src/execution/error-details.js +399 -0
  308. package/src/execution/error-model.js +82 -0
  309. package/src/execution/exact-json.js +80 -0
  310. package/src/execution/list-total.js +10 -0
  311. package/src/execution/money.js +59 -0
  312. package/src/execution/parser-error.js +66 -0
  313. package/src/execution/privacy.js +197 -0
  314. package/src/execution/public-schema.js +52 -0
  315. package/src/execution/query-api.js +101 -0
  316. package/src/execution/range.js +84 -0
  317. package/src/execution/request-state.js +55 -0
  318. package/src/execution/schema-completeness.js +116 -0
  319. package/src/execution/shop-query.js +54 -0
  320. package/src/execution/target-shop-default.js +23 -0
  321. package/src/execution/target-shop.js +49 -0
  322. package/src/identity/context-store.js +54 -0
  323. package/src/identity/context.js +38 -0
  324. package/src/installation/install.js +158 -0
  325. package/src/installation/npm-error.js +93 -0
  326. package/src/installation/skill.js +113 -0
  327. package/src/transport/account-api.js +152 -0
  328. package/src/transport/api.js +199 -0
  329. package/src/transport/shop-app.js +63 -0
@@ -0,0 +1,394 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "input": {
4
+ "type": "object",
5
+ "required": [
6
+ "kdtId",
7
+ "pageNo",
8
+ "pageSize"
9
+ ],
10
+ "additionalProperties": false,
11
+ "properties": {
12
+ "kdtId": {
13
+ "$ref": "#/definitions/shopId"
14
+ },
15
+ "pageNo": {
16
+ "type": "integer",
17
+ "minimum": 1,
18
+ "maximum": 9007199254740991,
19
+ "description": "页码正安全整数,从 1 开始"
20
+ },
21
+ "pageSize": {
22
+ "type": "integer",
23
+ "minimum": 1,
24
+ "maximum": 50,
25
+ "description": "每页 1–50 条,默认 20"
26
+ },
27
+ "keyword": {
28
+ "type": "string",
29
+ "minLength": 1,
30
+ "description": "标签组名称关键词,去除首尾空白后不能为空"
31
+ },
32
+ "status": {
33
+ "type": "string",
34
+ "enum": [
35
+ "normal",
36
+ "disabled"
37
+ ],
38
+ "description": "标签组状态;省略表示全部"
39
+ },
40
+ "addRule": {
41
+ "type": "string",
42
+ "enum": [
43
+ "unique",
44
+ "repeat"
45
+ ],
46
+ "description": "组内标签添加规则;省略表示全部"
47
+ }
48
+ },
49
+ "description": "CLI 解析参数并完成必要上下文补全后的业务输入;不是直接传入 CLI 的 JSON。原始选项、必填条件和默认值见 options。"
50
+ },
51
+ "output": {
52
+ "type": "object",
53
+ "required": [
54
+ "data"
55
+ ],
56
+ "additionalProperties": false,
57
+ "properties": {
58
+ "data": {
59
+ "type": "object",
60
+ "required": [
61
+ "tagCategories",
62
+ "pagination"
63
+ ],
64
+ "additionalProperties": false,
65
+ "properties": {
66
+ "tagCategories": {
67
+ "type": "array",
68
+ "items": {
69
+ "type": "object",
70
+ "required": [
71
+ "tagCategoryId",
72
+ "kdtId",
73
+ "tagCategoryName",
74
+ "addRule",
75
+ "tags"
76
+ ],
77
+ "additionalProperties": false,
78
+ "properties": {
79
+ "tagCategoryId": {
80
+ "type": "integer",
81
+ "minimum": 1,
82
+ "maximum": 9007199254740991
83
+ },
84
+ "kdtId": {
85
+ "$ref": "#/definitions/shopId"
86
+ },
87
+ "tagCategoryName": {
88
+ "type": "string"
89
+ },
90
+ "addRule": {
91
+ "type": "string",
92
+ "enum": [
93
+ "unique",
94
+ "repeat"
95
+ ]
96
+ },
97
+ "tags": {
98
+ "type": "array",
99
+ "items": {
100
+ "type": "object",
101
+ "required": [
102
+ "tagId",
103
+ "tagName"
104
+ ],
105
+ "additionalProperties": false,
106
+ "properties": {
107
+ "tagId": {
108
+ "type": "integer",
109
+ "minimum": 1,
110
+ "maximum": 9007199254740991
111
+ },
112
+ "tagName": {
113
+ "type": "string"
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ },
120
+ "maxItems": 50
121
+ },
122
+ "pagination": {
123
+ "type": "object",
124
+ "required": [
125
+ "pageNo",
126
+ "pageSize",
127
+ "hasMore"
128
+ ],
129
+ "additionalProperties": false,
130
+ "properties": {
131
+ "pageNo": {
132
+ "type": "integer",
133
+ "minimum": 1,
134
+ "maximum": 9007199254740991
135
+ },
136
+ "pageSize": {
137
+ "type": "integer",
138
+ "minimum": 1,
139
+ "maximum": 50
140
+ },
141
+ "total": {
142
+ "type": "integer",
143
+ "minimum": 0,
144
+ "maximum": 9007199254740991,
145
+ "description": "匹配本次查询条件的总记录数,不是当前页返回条数;上游未提供可确认总数时省略。"
146
+ },
147
+ "hasMore": {
148
+ "type": [
149
+ "boolean",
150
+ "null"
151
+ ],
152
+ "description": "true 表示还有后续页,false 表示已确认没有后续页;无法确定时为 null,不以空页或短页推算。"
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+ },
160
+ "preview": {
161
+ "type": "object",
162
+ "required": [
163
+ "method",
164
+ "path",
165
+ "body",
166
+ "scope",
167
+ "prerequisites"
168
+ ],
169
+ "additionalProperties": false,
170
+ "properties": {
171
+ "method": {
172
+ "const": "POST"
173
+ },
174
+ "path": {
175
+ "const": "youzan.scrm.tag.category.list/1.0.1"
176
+ },
177
+ "body": {
178
+ "type": "object",
179
+ "required": [
180
+ "page",
181
+ "page_size"
182
+ ],
183
+ "additionalProperties": false,
184
+ "properties": {
185
+ "page": {
186
+ "type": "integer",
187
+ "minimum": 1,
188
+ "maximum": 9007199254740991
189
+ },
190
+ "page_size": {
191
+ "type": "integer",
192
+ "minimum": 1,
193
+ "maximum": 50
194
+ },
195
+ "tag_category_name": {
196
+ "type": "string",
197
+ "minLength": 1
198
+ },
199
+ "tag_category_status": {
200
+ "type": "integer",
201
+ "enum": [
202
+ 0,
203
+ 1
204
+ ]
205
+ },
206
+ "tag_add_rule": {
207
+ "type": "integer",
208
+ "enum": [
209
+ 0,
210
+ 1
211
+ ]
212
+ }
213
+ }
214
+ },
215
+ "scope": {
216
+ "type": "object",
217
+ "required": [
218
+ "kdtId"
219
+ ],
220
+ "additionalProperties": false,
221
+ "properties": {
222
+ "kdtId": {
223
+ "$ref": "#/definitions/shopId"
224
+ }
225
+ }
226
+ },
227
+ "prerequisites": {
228
+ "type": "array",
229
+ "minItems": 1,
230
+ "maxItems": 1,
231
+ "items": {
232
+ "type": "object",
233
+ "required": [
234
+ "method",
235
+ "path",
236
+ "body"
237
+ ],
238
+ "additionalProperties": false,
239
+ "properties": {
240
+ "method": {
241
+ "const": "POST"
242
+ },
243
+ "path": {
244
+ "const": "youzan.shop.basic.get/3.0.0"
245
+ },
246
+ "body": {
247
+ "type": "object",
248
+ "additionalProperties": false
249
+ }
250
+ }
251
+ }
252
+ }
253
+ }
254
+ },
255
+ "error": {
256
+ "type": "object",
257
+ "required": [
258
+ "success",
259
+ "code",
260
+ "message",
261
+ "details"
262
+ ],
263
+ "additionalProperties": false,
264
+ "properties": {
265
+ "success": {
266
+ "const": false
267
+ },
268
+ "code": {
269
+ "const": -10001
270
+ },
271
+ "message": {
272
+ "type": "string",
273
+ "minLength": 1
274
+ },
275
+ "details": {
276
+ "type": "object",
277
+ "required": [
278
+ "category",
279
+ "stage",
280
+ "command",
281
+ "targetScope",
282
+ "requestState",
283
+ "nextStep"
284
+ ],
285
+ "additionalProperties": false,
286
+ "properties": {
287
+ "category": {
288
+ "type": "string",
289
+ "enum": [
290
+ "validation",
291
+ "configuration",
292
+ "parameter",
293
+ "permission",
294
+ "authentication",
295
+ "scope_unresolved",
296
+ "transport",
297
+ "http",
298
+ "protocol",
299
+ "business_rejected",
300
+ "not_found",
301
+ "target_mismatch",
302
+ "ambiguous"
303
+ ]
304
+ },
305
+ "stage": {
306
+ "type": "string",
307
+ "minLength": 1
308
+ },
309
+ "command": {
310
+ "const": "customer.tagcategory.list"
311
+ },
312
+ "targetScope": {
313
+ "type": "object",
314
+ "additionalProperties": false,
315
+ "properties": {
316
+ "kdtId": {
317
+ "$ref": "#/definitions/shopId"
318
+ }
319
+ }
320
+ },
321
+ "requestState": {
322
+ "enum": [
323
+ "not_sent",
324
+ "sent",
325
+ "unknown"
326
+ ]
327
+ },
328
+ "nextStep": {
329
+ "type": "string",
330
+ "minLength": 1
331
+ },
332
+ "api": {
333
+ "type": "string"
334
+ },
335
+ "httpStatus": {
336
+ "type": "integer"
337
+ },
338
+ "businessCode": {
339
+ "anyOf": [
340
+ {
341
+ "type": "integer"
342
+ },
343
+ {
344
+ "type": "string"
345
+ }
346
+ ]
347
+ },
348
+ "gatewayCode": {
349
+ "anyOf": [
350
+ {
351
+ "type": "integer"
352
+ },
353
+ {
354
+ "type": "string"
355
+ }
356
+ ]
357
+ },
358
+ "trace_id": {
359
+ "type": "string"
360
+ },
361
+ "request_id": {
362
+ "type": "string"
363
+ }
364
+ }
365
+ }
366
+ }
367
+ },
368
+ "definitions": {
369
+ "shopId": {
370
+ "type": "integer",
371
+ "minimum": 1,
372
+ "maximum": 9007199254740991
373
+ }
374
+ },
375
+ "api": {
376
+ "method": "POST",
377
+ "path": "youzan.scrm.tag.category.list/1.0.1"
378
+ },
379
+ "success": {
380
+ "description": "店铺核验通过,本页组、标签及分页符合模型和目标后成功。"
381
+ },
382
+ "errors": {
383
+ "description": "失败 stdout 为空,stderr 为一份脱敏错误 JSON,退出码非零;不返回部分成功,不自动重试、切换身份或目标。按 error 模型及安全下一步处理。"
384
+ },
385
+ "notes": [
386
+ "--kdt-id 省略时使用本次有效上下文 shopId;显式提供的非法值不回退。两者都缺失时拒绝;目标范围、同店核验和服务端权限仍按本命令校验。",
387
+ "每次只查询一页,默认第 1 页、每页 20 条,页大小最多 50;保留筛选及页大小,按 nextPage 继续。",
388
+ "hasMore 按已报告总数计算;页码、容量、组归属或重复记录矛盾时整体失败。",
389
+ "normal 表示正常,disabled 表示禁用;unique 表示组内标签仅唯一添加,repeat 表示可重复添加。返回内容不补造筛选状态。",
390
+ "仅返回本页组和本次组内标签,不保证跨请求快照或组内标签全集。",
391
+ "支持微商城单店及列明的连锁 L 总部、网店和门店,at=all 不授予跨店权限。",
392
+ "本地 --dry-run 不读取凭证、不联网;预览只证明构造计划,不证明对象存在或权限有效。真实执行仍需有效上下文及目标范围授权,at 声明不替代服务端授权。"
393
+ ]
394
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "schemaVersion": 3,
3
+ "domain": "fulfillment",
4
+ "businessCommands": [
5
+ {
6
+ "path": "fulfillment.delivery.get",
7
+ "kind": "atomic",
8
+ "risk": "read",
9
+ "availability": "available",
10
+ "at": "shop",
11
+ "module": "fulfillment/delivery/get/command.js",
12
+ "fingerprint": "671fca4f8b3cc9c313a89d120fb8da5953fa2dd2d18e2fee7cdfdfbe2ed62043"
13
+ },
14
+ {
15
+ "path": "fulfillment.shipment.list",
16
+ "kind": "atomic",
17
+ "risk": "read",
18
+ "availability": "available",
19
+ "at": "all",
20
+ "module": "fulfillment/shipment/list/command.js",
21
+ "fingerprint": "4a1d655372f602c7afa604af4f8b80052844a82ddeff49bdf61d1e1ed0267c38"
22
+ },
23
+ {
24
+ "path": "fulfillment.waybill.get",
25
+ "kind": "atomic",
26
+ "risk": "read",
27
+ "availability": "available",
28
+ "at": "all",
29
+ "module": "fulfillment/waybill/get/command.js",
30
+ "fingerprint": "bd10d2784139946b7225e22dc2d1aaebd2730919b9c89849dfd6e4a70863bc09"
31
+ }
32
+ ]
33
+ }
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
4
+
5
+ const { Command, Option } = require('commander');
6
+ const { readContext } = require('../../../../../identity/context');
7
+ const { resolveTargetShop } = require('../../../../../execution/target-shop');
8
+ const { validateCommandValue } = require('../../../../../execution/command-schema');
9
+ const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
10
+ const { projectDelivery, projectWaybill, expressTypes } = require('./projection');
11
+ const schema = require('./schema.json');
12
+
13
+ const command = 'fulfillment.delivery.get';
14
+ const conditionalPath = 'youzan.trade.dc.query.querybyorderno/1.0.1';
15
+ const switches = Object.freeze({ include_dist_order: true, include_all_dist_order: true,
16
+ open_query_requestinclude_dist_order_and_detail: true });
17
+
18
+ function reject(category, stage, scope = {}, requestState = 'not_sent', facts = {}) {
19
+ const error = failure(command, category, stage, scope, requestState, facts);
20
+ error.cliDetails.nextStep = '核对原店铺、配送单及服务端授权;默认内容未取得时整体失败,不推断配送不存在,不自动重试、切换身份或店铺。';
21
+ return error;
22
+ }
23
+
24
+ function project(response, projector, stage, scope, input) {
25
+ if (response.responseBytes > 10 * 1024 * 1024) {
26
+ throw reject('budget_exceeded', 'response-bytes', scope, 'sent', response.facts);
27
+ }
28
+ try { return projector(response.rawBody, input); }
29
+ catch (error) { throw reject(error.category || 'protocol', stage, scope, 'sent', response.facts); }
30
+ }
31
+
32
+ function createCommand({ context } = {}) {
33
+ return new Command('get')
34
+ .description('读取指定配送单,按类型默认返回第三方同城摘要或当前快递运单引用')
35
+ .allowExcessArguments(false)
36
+ .exitOverride(error => {
37
+ if (['commander.helpDisplayed', 'commander.version'].includes(error.code)) throw error;
38
+ throw reject('parameter', 'input');
39
+ })
40
+ .option('--kdt-id <id>', '规范十进制正安全整数,须与当前店铺一致;省略时使用当前上下文店铺')
41
+ .requiredOption('--delivery-id <id>', '必填:有赞配送单号,1 至 128 字符,不含空白或控制字符,保留前导零')
42
+ .addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
43
+ .choices(['json', 'pretty']).default('json'))
44
+ .option('--dry-run', '纯本地预览条件分支,不读取凭证、不联网')
45
+ .addHelpText('after', `
46
+ 输出 data.delivery。配送单是一次交付执行,不专指骑手单。
47
+ 所属订单号通常为 E/V/C 开头加 23 位数字,仅供核对;不按该格式拒绝响应,补查沿用主响应的原始订单号。
48
+ 类型 21/23 默认返回 localDelivery,同城服务商单号不等于有赞配送单号或货单号。
49
+ 类型 11/12/14 根据主查询取得的订单与货单精确补查一个 waybill 引用,不返回轨迹。
50
+ 类型 13/22/24/91/92 及未知类型仅返回基础内容,不猜补查路径。
51
+ 状态 0 未发货、1 发货中、2 已发货、3 已取消;未知非负安全整数保留原值。
52
+ 已发货不证明承运商签收或买家收货。缺少类型要求的默认内容时整体失败。
53
+ 无 --include 或旧参数别名,不读取商品、骑手、电话、位置、费用或任意扩展。
54
+ 仅支持当前店铺四字段上下文和同店凭证,核店不证明店铺员工授权验收通过。
55
+ 快递最多三次请求,其他最多两次;每请求 10 秒,不重试或回退其他 API。
56
+ 每响应读取后最多 10 MiB,不是流式读取硬上限;最多 1000 张货单及每张 1000 条配送。
57
+ 输出最多 5 MiB,超预算整体失败不截断。失败 stdout 为空。
58
+ 契约:zan-saas schema fulfillment.delivery.get
59
+ 示例:zan-saas fulfillment delivery get --kdt-id 63077 --delivery-id D-example --dry-run
60
+ `)
61
+ .action(async options => {
62
+ if (!/^[1-9]\d*$/.test(options.kdtId) || !Number.isSafeInteger(Number(options.kdtId)) ||
63
+ String(Number(options.kdtId)) !== options.kdtId) {
64
+ throw reject('parameter', 'input');
65
+ }
66
+ const scope = resolveTargetShop(options, context, command);
67
+ const state = readContext(context);
68
+ if (state.status === 'ready' && (state.context.orgType !== 'shop' ||
69
+ String(scope.kdtId) !== state.context.shopId)) throw reject('permission', 'scope', scope);
70
+ const input = { ...scope, deliveryId: options.deliveryId };
71
+ try { validateCommandValue(schema, 'input', input); }
72
+ catch { throw reject('parameter', 'input', scope); }
73
+ const preview = {
74
+ scope, prerequisites: [{ method: 'POST', path: bindingPath, body: {} }],
75
+ requests: [{ method: 'POST', path: schema.api.path,
76
+ body: { dist_id: `***${Array.from(input.deliveryId).slice(-4).join('')}` } }],
77
+ conditionalRequest: { when: 'deliveryType 为 11/12/14', method: 'POST', path: conditionalPath,
78
+ bodyFrom: { tid: 'data.delivery.orderNo' }, fixedBody: switches },
79
+ result: '类型和订单待主查询取得;21/23 本地投影同城摘要,11/12/14 补查运单引用,其他类型仅返回基础内容。'
80
+ };
81
+ validateCommandValue(schema, 'preview', preview);
82
+ let output = preview;
83
+ let facts = {};
84
+ if (!options.dryRun) {
85
+ const read = await createShopQuery(scope, command);
86
+ const response = await read(schema.api.path, { dist_id: input.deliveryId }, 'delivery-get');
87
+ facts = response.facts;
88
+ const delivery = project(response, projectDelivery, 'delivery-model', scope, input);
89
+ if (expressTypes.includes(delivery.deliveryType)) {
90
+ const conditional = await read(conditionalPath,
91
+ { tid: delivery.orderNo, ...switches }, 'waybill-reference');
92
+ facts = conditional.facts;
93
+ delivery.waybill = project(conditional, projectWaybill, 'waybill-model', scope, delivery);
94
+ }
95
+ output = { data: { delivery } };
96
+ try { validateCommandValue(schema, 'output', output); }
97
+ catch { throw reject('protocol', 'delivery-output', scope, 'sent', facts); }
98
+ }
99
+ const text = `${JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0)}\n`;
100
+ if (Buffer.byteLength(text) > 5 * 1024 * 1024) {
101
+ throw reject('budget_exceeded', 'output-bytes', scope, 'sent', facts);
102
+ }
103
+ process.stdout.write(text);
104
+ });
105
+ }
106
+
107
+ module.exports = { kind: 'atomic', risk: 'read', at: 'shop', createCommand: withTargetShopDefault(createCommand) };
@@ -0,0 +1,142 @@
1
+ 'use strict';
2
+
3
+ const { object } = require('../../../../../execution/query-api');
4
+ const { formatBeijingMilliseconds } = require('../../../../../execution/beijing-time');
5
+
6
+ const expressTypes = [11, 12, 14];
7
+ const localTypes = [21, 23];
8
+ const methods = new Map([[11, 1], [12, 1], [13, 1], [14, 1], [21, 2], [22, 2],
9
+ [23, 2], [24, 3], [91, 3], [92, 3]]);
10
+
11
+ function invalid(category = 'protocol') {
12
+ const error = new Error('Invalid delivery response');
13
+ error.category = category;
14
+ throw error;
15
+ }
16
+
17
+ class NumericToken {
18
+ constructor(text) { this.text = text; }
19
+ }
20
+
21
+ function parseResponse(text) {
22
+ JSON.parse(text);
23
+ const tokens = text.match(/"(?:[^"\\]|\\.)*"|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null|[{}\[\]:,]/g);
24
+ let index = 0;
25
+ function value() {
26
+ const token = tokens[index++];
27
+ if (token === '{') {
28
+ const result = Object.create(null);
29
+ while (tokens[index] !== '}') {
30
+ const key = JSON.parse(tokens[index++]);
31
+ index++;
32
+ result[key] = value();
33
+ if (tokens[index] !== ',') break;
34
+ index++;
35
+ }
36
+ index++;
37
+ return result;
38
+ }
39
+ if (token === '[') {
40
+ const result = [];
41
+ while (tokens[index] !== ']') {
42
+ result.push(value());
43
+ if (tokens[index] !== ',') break;
44
+ index++;
45
+ }
46
+ index++;
47
+ return result;
48
+ }
49
+ return /^-?\d/.test(token) ? new NumericToken(token) : JSON.parse(token);
50
+ }
51
+ return value();
52
+ }
53
+
54
+ function integer(value, minimum = 0) {
55
+ if (!(value instanceof NumericToken)) invalid();
56
+ const number = Number(value.text);
57
+ if (!Number.isSafeInteger(number) || number < minimum) invalid();
58
+ const match = /^(-?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/.exec(value.text);
59
+ let digits = `${match[2]}${match[3] || ''}`.replace(/^0+/, '');
60
+ if (!digits) return number;
61
+ let scale = Number(match[4] || 0) - (match[3] || '').length;
62
+ while (digits.endsWith('0')) { digits = digits.slice(0, -1); scale++; }
63
+ if (scale < 0 || digits.length + scale > 16 ||
64
+ BigInt(`${match[1]}${digits}`) * 10n ** BigInt(scale) !== BigInt(number)) invalid();
65
+ return number;
66
+ }
67
+
68
+ function text(value) {
69
+ if (typeof value !== 'string' || !value.trim()) invalid();
70
+ return value;
71
+ }
72
+
73
+ function collection(value) {
74
+ if (!Array.isArray(value)) invalid();
75
+ if (value.length > 1000) invalid('budget_exceeded');
76
+ return value;
77
+ }
78
+
79
+ function projectDelivery(rawBody, input) {
80
+ const source = parseResponse(rawBody).data;
81
+ if (source === undefined || source === null) invalid('not_found_in_scope');
82
+ if (!object(source)) invalid();
83
+ if (text(source.dist_id) !== input.deliveryId || integer(source.kdt_id, 1) !== input.kdtId) {
84
+ invalid('scope_unresolved');
85
+ }
86
+ const result = {
87
+ deliveryId: source.dist_id, shipmentNo: text(source.delivery_no), orderNo: text(source.order_no),
88
+ kdtId: input.kdtId, status: integer(source.status), deliveryMethod: integer(source.dist_type),
89
+ deliveryType: integer(source.delivery_type)
90
+ };
91
+ if (Array.from(result.orderNo).length > 128 || /[\s\u0000-\u001f\u007f-\u009f]/u.test(result.orderNo)) invalid();
92
+ if (methods.has(result.deliveryType) && methods.get(result.deliveryType) !== result.deliveryMethod) invalid();
93
+ for (const [sourceKey, targetKey] of [['create_time', 'createdAt'], ['update_time', 'updatedAt']]) {
94
+ if (source[sourceKey] !== undefined && source[sourceKey] !== null) {
95
+ result[targetKey] = formatBeijingMilliseconds(integer(source[sourceKey], -Number.MAX_SAFE_INTEGER));
96
+ }
97
+ }
98
+ if (localTypes.includes(result.deliveryType)) {
99
+ try {
100
+ const info = source.local_delivery_info;
101
+ if (!object(info) || !object(info.local_delivery_detail)) invalid();
102
+ const detail = info.local_delivery_detail;
103
+ result.localDelivery = { providerName: text(info.dist_company_name),
104
+ providerOrderNo: text(detail.delivery_no), statusText: text(detail.dist_status) };
105
+ if (detail.cancel_reason !== undefined && detail.cancel_reason !== null) {
106
+ if (typeof detail.cancel_reason !== 'string') invalid();
107
+ result.localDelivery.cancelReason = detail.cancel_reason;
108
+ }
109
+ } catch { invalid('module_unavailable'); }
110
+ }
111
+ return result;
112
+ }
113
+
114
+ function projectWaybill(rawBody, delivery) {
115
+ const shipments = collection(parseResponse(rawBody).data);
116
+ for (const shipment of shipments) {
117
+ if (!object(shipment)) invalid();
118
+ collection(shipment.dist_order_d_t_os);
119
+ }
120
+ const matches = shipments.filter(shipment => shipment.delivery_no === delivery.shipmentNo);
121
+ if (!matches.length) invalid('module_unavailable');
122
+ if (matches.length !== 1) invalid();
123
+ const shipment = matches[0];
124
+ function relation(row) {
125
+ if (row.tid !== delivery.orderNo || row.delivery_no !== delivery.shipmentNo ||
126
+ integer(row.kdt_id, 1) !== delivery.kdtId) invalid('scope_unresolved');
127
+ }
128
+ relation(shipment);
129
+ const deliveries = shipment.dist_order_d_t_os;
130
+ if (deliveries.some(row => !object(row))) invalid();
131
+ const selected = deliveries.filter(row => row.dist_id === delivery.deliveryId);
132
+ if (!selected.length) invalid('module_unavailable');
133
+ if (selected.length !== 1) invalid();
134
+ relation(selected[0]);
135
+ try {
136
+ const info = selected[0].express_info;
137
+ if (!object(info)) invalid();
138
+ return { waybillNo: text(info.express_no), carrierId: integer(info.express_id, 1) };
139
+ } catch { invalid('module_unavailable'); }
140
+ }
141
+
142
+ module.exports = { projectDelivery, projectWaybill, expressTypes };