@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.
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 +106 -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 +103 -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,87 @@
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 diagnostics = require('../../shared/diagnostics');
8
+ const { withInputScope } = require('../../../../../execution/error-details');
9
+ const schema = require('./schema.json');
10
+ const { validateCommandValue } = require('../../../../../execution/command-schema');
11
+ const { readApi, ItemQueryError, object } = require('../../shared/api');
12
+
13
+ const commandPath = 'item.classification.get';
14
+ const API = 'youzan.item.classification.get/1.0.0';
15
+ const nextStep = '核对店铺 ID 和分类 ID;接口拒绝时检查授权,不自动换店重查。';
16
+
17
+ function failure(category, stage, scope = {}, facts = {}, state = 'not_sent') {
18
+ return new ItemQueryError(category, stage, scope, { ...facts, nextStep }, state, commandPath);
19
+ }
20
+
21
+ function buildInput(options) {
22
+ const scope = { kdtId: diagnostics.integer(options.kdtId, schema, '/kdtId') };
23
+ return withInputScope(scope, () => {
24
+ scope.classificationId = diagnostics.integer(options.classificationId, schema, '/classificationId');
25
+ validateCommandValue(schema, 'input', scope);
26
+ return { scope, request: { method: 'POST', path: API, body: { request: {
27
+ kdt_id: scope.kdtId, classification_id: scope.classificationId
28
+ } } } };
29
+ });
30
+ }
31
+
32
+ async function execute({ scope, request }) {
33
+ let classification;
34
+ try {
35
+ classification = await readApi(API, request.body, 'classification', scope, commandPath);
36
+ } catch (error) {
37
+ if (error instanceof ItemQueryError) {
38
+ const details = error.cliDetails;
39
+ details.nextStep = nextStep;
40
+ if (details.category === 'business_rejected' &&
41
+ String(details.businessCode) === '401000012') {
42
+ details.category = 'not_found';
43
+ details.nextStep = '该分类不存在,请核对店铺 ID 和分类 ID。';
44
+ error.message = '商品分类不存在。';
45
+ }
46
+ }
47
+ throw error;
48
+ }
49
+ const invalid = () => failure('protocol', 'classification-model', scope, { api: API }, 'sent');
50
+ if (!object(classification) || classification.kdt_id !== scope.kdtId ||
51
+ classification.classification_id !== scope.classificationId) throw invalid();
52
+ const result = { data: { classification } };
53
+ diagnostics.validateOutput(schema, result, invalid);
54
+ return result;
55
+ }
56
+
57
+ function createCommand() {
58
+ return new DiagnosticCommand('get', { path: commandPath, schema, parameterCategory: 'parameter' })
59
+ .description('查询零售店铺商品分类目录中的单个分类及其父分类标识')
60
+ .allowExcessArguments(false)
61
+ .option('--kdt-id <id>', '目标零售店铺 ID;省略时使用当前上下文店铺')
62
+ .requiredOption('--classification-id <id>', '必填:该店铺的商品分类 ID')
63
+ .addOption(new Option('--format <format>', 'json 或 pretty(仅改变缩进)').choices(['json', 'pretty']).default('json'))
64
+ .option('--dry-run', '仅本地预览一次分类详情请求,不读凭证、不联网')
65
+ .addHelpText('after', `
66
+ 返回 data.classification,包括分类 ID、店铺 ID 及接口提供的名称、父分类和总部店铺标识。
67
+ 分类与商品分组是不同对象;不能用 group_id 或商品 ID 代替分类 ID。
68
+ 仅查指定分类,不读取父分类详情、子分类、商品列表或 H5;无渠道、include 或分页参数。
69
+ 适用于接口支持的零售单店、连锁总部和分店;at: all 不表示任意跨店权限。
70
+ 执行需要有效的用户、组织与店铺上下文,可通过登录后选店或 ZAN_SAAS_CONTEXT 提供;目标范围和服务端授权按本命令契约校验,公共调用前置见 zan-saas skills read zan-saas-shared。
71
+ 目标由 --kdt-id 明确指定,服务端校验权限。缺少上下文可本地预览,无效上下文拒绝。
72
+ 失败 stdout 为空,stderr 为错误 JSON;分类不存在时保留业务码,不自动重试或切换目标。
73
+
74
+ 示例:
75
+ zan-saas item classification get --kdt-id 63077 --classification-id 123
76
+ zan-saas item classification get --kdt-id 63077 --classification-id 123 --dry-run
77
+ `)
78
+ .action(async options => {
79
+ const input = buildInput(options);
80
+ const result = options.dryRun ? input.request : await execute(input);
81
+ if (options.dryRun) validateCommandValue(schema, 'preview', result);
82
+ process.stdout.write(`${JSON.stringify(result, null, options.format === 'pretty' ? 2 : 0)}\n`);
83
+ });
84
+ }
85
+
86
+ module.exports = { kind: 'atomic', risk: 'read', at: 'all' };
87
+ module.exports.createCommand = withTargetShopDefault(createCommand);
@@ -0,0 +1,596 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "input": {
4
+ "$ref": "#/definitions/scope",
5
+ "description": "CLI 解析参数并完成必要上下文补全后的业务输入;不是直接传入 CLI 的 JSON。原始选项、必填条件和默认值见 options。"
6
+ },
7
+ "output": {
8
+ "type": "object",
9
+ "required": [
10
+ "data"
11
+ ],
12
+ "additionalProperties": false,
13
+ "properties": {
14
+ "data": {
15
+ "type": "object",
16
+ "required": [
17
+ "classification"
18
+ ],
19
+ "additionalProperties": false,
20
+ "properties": {
21
+ "classification": {
22
+ "$ref": "#/definitions/classification"
23
+ }
24
+ }
25
+ }
26
+ }
27
+ },
28
+ "preview": {
29
+ "type": "object",
30
+ "required": [
31
+ "method",
32
+ "path",
33
+ "body"
34
+ ],
35
+ "additionalProperties": false,
36
+ "properties": {
37
+ "method": {
38
+ "const": "POST"
39
+ },
40
+ "path": {
41
+ "const": "youzan.item.classification.get/1.0.0"
42
+ },
43
+ "body": {
44
+ "type": "object",
45
+ "required": [
46
+ "request"
47
+ ],
48
+ "additionalProperties": false,
49
+ "properties": {
50
+ "request": {
51
+ "type": "object",
52
+ "required": [
53
+ "kdt_id",
54
+ "classification_id"
55
+ ],
56
+ "additionalProperties": false,
57
+ "properties": {
58
+ "kdt_id": {
59
+ "type": "integer",
60
+ "minimum": 1,
61
+ "maximum": 9007199254740991,
62
+ "description": "目标店铺 ID。"
63
+ },
64
+ "classification_id": {
65
+ "type": "integer",
66
+ "minimum": 1,
67
+ "maximum": 9007199254740991,
68
+ "description": "目标商品分类 ID。"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ },
76
+ "definitions": {
77
+ "scope": {
78
+ "type": "object",
79
+ "required": [
80
+ "kdtId",
81
+ "classificationId"
82
+ ],
83
+ "additionalProperties": false,
84
+ "properties": {
85
+ "kdtId": {
86
+ "type": "integer",
87
+ "minimum": 1,
88
+ "maximum": 9007199254740991,
89
+ "description": "目标零售店铺 ID。"
90
+ },
91
+ "classificationId": {
92
+ "type": "integer",
93
+ "minimum": 1,
94
+ "maximum": 9007199254740991,
95
+ "description": "该店铺内的商品分类 ID;不能使用商品 ID 或 group_id。"
96
+ }
97
+ }
98
+ },
99
+ "classification": {
100
+ "type": "object",
101
+ "required": [
102
+ "kdt_id",
103
+ "classification_id"
104
+ ],
105
+ "additionalProperties": true,
106
+ "properties": {
107
+ "kdt_id": {
108
+ "type": "integer",
109
+ "minimum": 1,
110
+ "maximum": 9007199254740991,
111
+ "description": "分类所属的店铺 ID,必须等于本次请求的 kdtId。"
112
+ },
113
+ "root_kdt_id": {
114
+ "type": "integer",
115
+ "minimum": 0,
116
+ "maximum": 9007199254740991,
117
+ "description": "连锁总部店铺 ID;允许 0,保留原值,不替代目标店铺。"
118
+ },
119
+ "classification_id": {
120
+ "type": "integer",
121
+ "minimum": 1,
122
+ "maximum": 9007199254740991,
123
+ "description": "分类 ID,必须等于本次请求的 classificationId。"
124
+ },
125
+ "parent_classification_id": {
126
+ "type": "integer",
127
+ "minimum": 0,
128
+ "maximum": 9007199254740991,
129
+ "description": "父分类 ID,0 表示一级分类;不附带父分类详情。"
130
+ },
131
+ "name": {
132
+ "type": "string",
133
+ "description": "分类名称。"
134
+ }
135
+ }
136
+ },
137
+ "diagnosticExpected": {
138
+ "type": "object",
139
+ "additionalProperties": false,
140
+ "required": [],
141
+ "properties": {
142
+ "type": {
143
+ "anyOf": [
144
+ {
145
+ "type": "string",
146
+ "description": "预期的 JSON 类型。"
147
+ },
148
+ {
149
+ "type": "array",
150
+ "items": {
151
+ "type": "string",
152
+ "description": "预期的 JSON 类型。"
153
+ }
154
+ }
155
+ ],
156
+ "description": "同版模型允许的类型。"
157
+ },
158
+ "enum": {
159
+ "type": "array",
160
+ "items": {
161
+ "anyOf": [
162
+ {
163
+ "type": "string"
164
+ },
165
+ {
166
+ "type": "number"
167
+ },
168
+ {
169
+ "type": "boolean"
170
+ },
171
+ {
172
+ "type": "null"
173
+ }
174
+ ],
175
+ "description": "契约声明的静态标量约束。"
176
+ },
177
+ "description": "同版模型允许的静态值。"
178
+ },
179
+ "const": {
180
+ "anyOf": [
181
+ {
182
+ "type": "string"
183
+ },
184
+ {
185
+ "type": "number"
186
+ },
187
+ {
188
+ "type": "boolean"
189
+ },
190
+ {
191
+ "type": "null"
192
+ }
193
+ ],
194
+ "description": "契约声明的静态标量约束。"
195
+ },
196
+ "minimum": {
197
+ "type": "number",
198
+ "description": "包含的最小值。"
199
+ },
200
+ "maximum": {
201
+ "type": "number",
202
+ "description": "包含的最大值。"
203
+ },
204
+ "exclusiveMinimum": {
205
+ "type": "number",
206
+ "description": "不包含的最小值。"
207
+ },
208
+ "exclusiveMaximum": {
209
+ "type": "number",
210
+ "description": "不包含的最大值。"
211
+ },
212
+ "minLength": {
213
+ "type": "integer",
214
+ "description": "最少字符数。"
215
+ },
216
+ "maxLength": {
217
+ "type": "integer",
218
+ "description": "最多字符数。"
219
+ },
220
+ "minItems": {
221
+ "type": "integer",
222
+ "description": "最少元素数。"
223
+ },
224
+ "maxItems": {
225
+ "type": "integer",
226
+ "description": "最多元素数。"
227
+ },
228
+ "format": {
229
+ "type": "string",
230
+ "description": "同版模型声明的格式。"
231
+ },
232
+ "pattern": {
233
+ "type": "string",
234
+ "description": "同版模型声明的字符约束。"
235
+ },
236
+ "additionalProperties": {
237
+ "const": false,
238
+ "description": "对象拒绝契约以外的属性。"
239
+ },
240
+ "contains": {
241
+ "type": "object",
242
+ "additionalProperties": false,
243
+ "required": [
244
+ "const"
245
+ ],
246
+ "properties": {
247
+ "const": {
248
+ "anyOf": [
249
+ {
250
+ "type": "string"
251
+ },
252
+ {
253
+ "type": "number"
254
+ },
255
+ {
256
+ "type": "boolean"
257
+ },
258
+ {
259
+ "type": "null"
260
+ }
261
+ ],
262
+ "description": "契约声明的静态标量约束。"
263
+ }
264
+ }
265
+ },
266
+ "items": {
267
+ "type": "object",
268
+ "additionalProperties": false,
269
+ "required": [
270
+ "enum"
271
+ ],
272
+ "properties": {
273
+ "enum": {
274
+ "type": "array",
275
+ "items": {
276
+ "anyOf": [
277
+ {
278
+ "type": "string"
279
+ },
280
+ {
281
+ "type": "number"
282
+ },
283
+ {
284
+ "type": "boolean"
285
+ },
286
+ {
287
+ "type": "null"
288
+ }
289
+ ],
290
+ "description": "契约声明的静态标量约束。"
291
+ },
292
+ "description": "元素允许的静态值。"
293
+ }
294
+ }
295
+ }
296
+ }
297
+ },
298
+ "diagnosticIssue": {
299
+ "type": "object",
300
+ "additionalProperties": false,
301
+ "required": [
302
+ "source",
303
+ "reason"
304
+ ],
305
+ "properties": {
306
+ "source": {
307
+ "enum": [
308
+ "argv",
309
+ "input",
310
+ "context",
311
+ "output",
312
+ "preview"
313
+ ],
314
+ "description": "问题所属的参数、输入、上下文、结果或预览模型。"
315
+ },
316
+ "path": {
317
+ "type": "string",
318
+ "description": "对应模型中的 JSON Pointer;不含原始输入或动态字典键。"
319
+ },
320
+ "option": {
321
+ "type": "string",
322
+ "description": "可定位时给出的已注册 CLI 选项。"
323
+ },
324
+ "reason": {
325
+ "enum": [
326
+ "required",
327
+ "invalid_type",
328
+ "invalid_choice",
329
+ "out_of_range",
330
+ "invalid_format",
331
+ "conditional_required",
332
+ "constraint",
333
+ "unexpected_property",
334
+ "unknown_option",
335
+ "unknown_command",
336
+ "excess_arguments",
337
+ "missing_value"
338
+ ],
339
+ "description": "字段违反的约束类型,原始值不回显。"
340
+ },
341
+ "expected": {
342
+ "$ref": "#/definitions/diagnosticExpected",
343
+ "description": "同版契约的静态预期。"
344
+ },
345
+ "relatedPaths": {
346
+ "type": "array",
347
+ "items": {
348
+ "type": "string",
349
+ "description": "关联字段的 JSON Pointer。"
350
+ },
351
+ "description": "触发条件约束的关联字段。"
352
+ }
353
+ }
354
+ },
355
+ "diagnosticRecovery": {
356
+ "type": "object",
357
+ "additionalProperties": false,
358
+ "required": [
359
+ "action",
360
+ "automaticBusinessRetry"
361
+ ],
362
+ "properties": {
363
+ "action": {
364
+ "enum": [
365
+ "correct_input",
366
+ "complete_authentication",
367
+ "request_access_review",
368
+ "stop_and_inspect"
369
+ ],
370
+ "description": "依次表示修正本地输入、补认证、核对权限或停止核查;仅是说明,不执行操作或授予权限。"
371
+ },
372
+ "automaticBusinessRetry": {
373
+ "const": false,
374
+ "description": "不据此自动重放业务请求。"
375
+ }
376
+ }
377
+ },
378
+ "diagnosticExecution": {
379
+ "type": "object",
380
+ "additionalProperties": false,
381
+ "required": [
382
+ "requestState",
383
+ "coverage",
384
+ "observedAttempts"
385
+ ],
386
+ "properties": {
387
+ "requestState": {
388
+ "enum": [
389
+ "not_sent",
390
+ "sent",
391
+ "unknown"
392
+ ],
393
+ "description": "整次调用尚未发送、已有发送记录或无法排除未知请求;不代表业务完成。"
394
+ },
395
+ "coverage": {
396
+ "enum": [
397
+ "complete",
398
+ "partial"
399
+ ],
400
+ "description": "请求观察覆盖全部已接入路径,或存在未观测路径;部分覆盖不能声明零请求。"
401
+ },
402
+ "observedAttempts": {
403
+ "type": "integer",
404
+ "minimum": 0,
405
+ "maximum": 9007199254740991,
406
+ "description": "本地已进入发送边界的观测次数下界,不是服务端执行次数。"
407
+ }
408
+ }
409
+ }
410
+ },
411
+ "modules": {
412
+ "classification": {
413
+ "base": true,
414
+ "upstreamPath": "data",
415
+ "required": true,
416
+ "description": "本次指定店铺和分类 ID 的单个商品分类。"
417
+ }
418
+ },
419
+ "api": {
420
+ "method": "POST",
421
+ "path": "youzan.item.classification.get/1.0.0"
422
+ },
423
+ "success": {
424
+ "description": "分类及店铺 ID 均匹配目标,详情满足模型后输出 data.classification。"
425
+ },
426
+ "errors": {
427
+ "description": "失败 stdout 为空,stderr 为一份脱敏错误 JSON,退出码非零;不返回部分成功,不自动重试、切换身份或目标。按 error 模型及安全下一步处理。 明确业务拒绝 401000012 为 not_found;空或错型对象不代表不存在。",
428
+ "diagnosticsVersion": 2
429
+ },
430
+ "notes": [
431
+ "--kdt-id 省略时使用本次有效上下文 shopId;显式提供的非法值不回退。两者都缺失时拒绝;目标范围、同店核验和服务端权限仍按本命令校验。",
432
+ "对象是商家商品分类定义,不是商品分组、平台类目或商品;指定分类 ID,店铺省略时使用当前上下文;无渠道参数。",
433
+ "成功必须返回并匹配店铺 ID 和分类 ID;其余字段可省略,null 按字段模型判断,不补造。",
434
+ "parent_classification_id=0 表示一级,root_kdt_id 可为 0;不自动查询父子分类或组装树。",
435
+ "保留空名称和未知扩展,整数须在安全范围内;一次查询,不附带商品、H5 或角色资料。",
436
+ "支持零售单店、连锁总部及分店,不表示微商城支持、跨店授权或分类 ID 可跨店互换。",
437
+ "当前请求编码尚未在真实网关验收,本地预览不证明分类存在或授权有效。",
438
+ "本地 --dry-run 不读取凭证、不联网;预览只证明构造计划,不证明对象存在或权限有效。真实执行仍需有效上下文及目标范围授权,at 声明不替代服务端授权。"
439
+ ],
440
+ "error": {
441
+ "type": "object",
442
+ "required": [
443
+ "success",
444
+ "code",
445
+ "message",
446
+ "details"
447
+ ],
448
+ "additionalProperties": false,
449
+ "properties": {
450
+ "success": {
451
+ "const": false
452
+ },
453
+ "code": {
454
+ "const": -10001
455
+ },
456
+ "message": {
457
+ "type": "string",
458
+ "minLength": 1
459
+ },
460
+ "details": {
461
+ "type": "object",
462
+ "required": [
463
+ "category",
464
+ "stage",
465
+ "command",
466
+ "targetScope",
467
+ "requestState",
468
+ "nextStep",
469
+ "errorVersion",
470
+ "recovery",
471
+ "execution"
472
+ ],
473
+ "additionalProperties": false,
474
+ "properties": {
475
+ "category": {
476
+ "type": "string",
477
+ "enum": [
478
+ "parameter",
479
+ "configuration",
480
+ "transport",
481
+ "authentication",
482
+ "permission",
483
+ "http",
484
+ "protocol",
485
+ "business_rejected",
486
+ "not_found",
487
+ "scope_unresolved",
488
+ "pagination_stalled",
489
+ "budget_exceeded",
490
+ "missing_alias"
491
+ ]
492
+ },
493
+ "stage": {
494
+ "type": "string",
495
+ "minLength": 1
496
+ },
497
+ "command": {
498
+ "const": "item.classification.get"
499
+ },
500
+ "targetScope": {
501
+ "oneOf": [
502
+ {
503
+ "$ref": "#/definitions/scope"
504
+ },
505
+ {
506
+ "type": "object",
507
+ "maxProperties": 0
508
+ }
509
+ ]
510
+ },
511
+ "requestState": {
512
+ "type": "string",
513
+ "enum": [
514
+ "not_sent",
515
+ "sent",
516
+ "unknown"
517
+ ],
518
+ "description": "not_sent 确认本步请求未发送;sent 已取得本步响应;unknown 传输中断,无法确定本步结果。不是整个多步查询的发送汇总。"
519
+ },
520
+ "nextStep": {
521
+ "type": "string",
522
+ "minLength": 1
523
+ },
524
+ "api": {
525
+ "type": "string",
526
+ "minLength": 1
527
+ },
528
+ "httpStatus": {
529
+ "type": "integer",
530
+ "minimum": 100,
531
+ "maximum": 599
532
+ },
533
+ "businessCode": {
534
+ "oneOf": [
535
+ {
536
+ "type": "integer",
537
+ "minimum": -9007199254740991,
538
+ "maximum": 9007199254740991
539
+ },
540
+ {
541
+ "type": "string",
542
+ "pattern": "^-?\\d{1,12}$"
543
+ }
544
+ ]
545
+ },
546
+ "gatewayCode": {
547
+ "oneOf": [
548
+ {
549
+ "type": "integer",
550
+ "minimum": -9007199254740991,
551
+ "maximum": 9007199254740991
552
+ },
553
+ {
554
+ "type": "string",
555
+ "pattern": "^-?\\d{1,12}$"
556
+ }
557
+ ]
558
+ },
559
+ "trace_id": {
560
+ "type": "string",
561
+ "pattern": "^[a-zA-Z0-9_-]{1,128}$"
562
+ },
563
+ "request_id": {
564
+ "type": "string",
565
+ "pattern": "^[a-zA-Z0-9_-]{1,128}$"
566
+ },
567
+ "errorVersion": {
568
+ "const": 2,
569
+ "description": "本命令采用错误诊断协议第二版。"
570
+ },
571
+ "issues": {
572
+ "type": "array",
573
+ "minItems": 1,
574
+ "maxItems": 16,
575
+ "items": {
576
+ "$ref": "#/definitions/diagnosticIssue"
577
+ },
578
+ "description": "最多十六个已定位问题,不包含收到的原值。"
579
+ },
580
+ "issuesTruncated": {
581
+ "const": true,
582
+ "description": "问题超过返回上限,当前列表没有穷尽全部问题。"
583
+ },
584
+ "recovery": {
585
+ "$ref": "#/definitions/diagnosticRecovery",
586
+ "description": "受限的恢复说明,不会自动执行。"
587
+ },
588
+ "execution": {
589
+ "$ref": "#/definitions/diagnosticExecution",
590
+ "description": "整次调用的请求观察,独立于失败阶段的 requestState。"
591
+ }
592
+ }
593
+ }
594
+ }
595
+ }
596
+ }