@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,60 @@
1
+ {
2
+ "schemaVersion": 3,
3
+ "domain": "member",
4
+ "businessCommands": [
5
+ {
6
+ "path": "member.customer-level.get",
7
+ "kind": "atomic",
8
+ "risk": "read",
9
+ "availability": "available",
10
+ "at": "all",
11
+ "module": "member/customer-level/get/command.js",
12
+ "fingerprint": "063b35ccc6b58b76177ee9a795e1af587ff6a9359cd8d21f1fc92467bbe44621"
13
+ },
14
+ {
15
+ "path": "member.growth.get",
16
+ "kind": "atomic",
17
+ "risk": "read",
18
+ "availability": "available",
19
+ "at": "all",
20
+ "module": "member/growth/get/command.js",
21
+ "fingerprint": "63a83688cf2d6f04a7bc7c93ee4a56d825e559cdf68534404cb8ce99aecf7c12"
22
+ },
23
+ {
24
+ "path": "member.growth-log.list",
25
+ "kind": "atomic",
26
+ "risk": "read",
27
+ "availability": "available",
28
+ "at": "all",
29
+ "module": "member/growth-log/list/command.js",
30
+ "fingerprint": "94201dd01aa8de4189604afe7cd451975830555fea5f1d348239e5eab98ec935"
31
+ },
32
+ {
33
+ "path": "member.level.get",
34
+ "kind": "atomic",
35
+ "risk": "read",
36
+ "availability": "available",
37
+ "at": "all",
38
+ "module": "member/level/get/command.js",
39
+ "fingerprint": "75de5b4aeab1b821d50cbb285011f9dfe06fbc94cecb0d74c98768ce8d74ac0a"
40
+ },
41
+ {
42
+ "path": "member.level.list",
43
+ "kind": "atomic",
44
+ "risk": "read",
45
+ "availability": "available",
46
+ "at": "all",
47
+ "module": "member/level/list/command.js",
48
+ "fingerprint": "63315ed21f4222807353fa592caa73986d588200dc6a37974b10fbdcd7626874"
49
+ },
50
+ {
51
+ "path": "member.membership.get",
52
+ "kind": "atomic",
53
+ "risk": "read",
54
+ "availability": "available",
55
+ "at": "all",
56
+ "module": "member/membership/get/command.js",
57
+ "fingerprint": "9844185dc0e14890211624538193a8546a61d05f14a426fa86532ac46fead7da"
58
+ }
59
+ ]
60
+ }
@@ -0,0 +1,122 @@
1
+ 'use strict';
2
+
3
+ const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
4
+
5
+ const { Command, Option } = require('commander');
6
+ const schema = require('./schema.json');
7
+ const { resolveTargetShop } = require('../../../../../execution/target-shop');
8
+ const { validateCommandValue } = require('../../../../../execution/command-schema');
9
+ const {
10
+ QueryError, readApiEnvelope, object, assertSafeNumbers, diagnosticCode
11
+ } = require('../../../../../execution/query-api');
12
+
13
+ const commandPath = 'member.customer-level.get';
14
+ const nextStep = '核对本命令 help/schema、原店铺、客户标识和服务端授权;不自动重试、切店、换身份或创建客户。';
15
+
16
+ function failure(category, stage, scope = {}, requestState = 'not_sent', facts = {}) {
17
+ return new QueryError(category, stage, scope, facts, requestState, commandPath, nextStep);
18
+ }
19
+
20
+ function buildInput(options, context) {
21
+ const scope = resolveTargetShop(options, context, commandPath);
22
+ try {
23
+ const input = { ...scope, yzOpenId: options.yzOpenId.trim() };
24
+ validateCommandValue(schema, 'input', input);
25
+ return Object.freeze(input);
26
+ } catch {
27
+ throw failure('parameter', 'input', scope);
28
+ }
29
+ }
30
+
31
+ function assertSuccess(result, scope, facts) {
32
+ const reject = category => {
33
+ throw failure(category, 'customer-level', scope, 'sent', facts);
34
+ };
35
+ if (Object.hasOwn(result, 'gw_err_resp')) {
36
+ if (result.success === true || result.code === 200) reject('protocol');
37
+ if (object(result.gw_err_resp) && diagnosticCode(result.gw_err_resp.err_code)) {
38
+ reject('business_rejected');
39
+ }
40
+ reject('protocol');
41
+ }
42
+ if (result.success === false) {
43
+ reject(result.code === 200 ? 'protocol' : 'business_rejected');
44
+ }
45
+ if (result.success === undefined && Number.isSafeInteger(result.code) &&
46
+ ![0, 200].includes(result.code)) reject('business_rejected');
47
+ if (result.success !== true || result.code !== 200) reject('protocol');
48
+ }
49
+
50
+ function adaptLevels(result, input, facts) {
51
+ const invalid = () => failure('protocol', 'customer-level-model',
52
+ { kdtId: input.kdtId }, 'sent', facts);
53
+ if (!object(result.data) || result.data.yz_open_id !== input.yzOpenId ||
54
+ !Array.isArray(result.data.level_infos)) throw invalid();
55
+ try {
56
+ const levelInfos = result.data.level_infos.map(record => {
57
+ if (!object(record)) throw invalid();
58
+ return Object.fromEntries(['level_alias', 'level_name', 'level_type', 'level_value']
59
+ .filter(field => Object.hasOwn(record, field)).map(field => [field, record[field]]));
60
+ });
61
+ const output = { data: { customer_level: { level_infos: levelInfos } } };
62
+ assertSafeNumbers(output);
63
+ validateCommandValue(schema, 'output', output);
64
+ return output;
65
+ } catch {
66
+ throw invalid();
67
+ }
68
+ }
69
+
70
+ function createCommand({ context } = {}) {
71
+ return new Command('get')
72
+ .description('查询已知客户的实际等级,完整保留免费和付费等级记录')
73
+ .allowExcessArguments(false)
74
+ .exitOverride(error => {
75
+ if (['commander.helpDisplayed', 'commander.version'].includes(error.code)) throw error;
76
+ throw failure('parameter', 'input');
77
+ })
78
+ .requiredOption('--yz-open-id <id>', '必填:客户 yzOpenId,非空字符串;不是手机号')
79
+ .option('--kdt-id <id>', '目标店铺正安全整数;省略取本次有效上下文 shopId')
80
+ .addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
81
+ .choices(['json', 'pretty']).default('json'))
82
+ .option('--dry-run', '纯本地校验并预览,不读取凭证、不联网')
83
+ .addHelpText('after', `
84
+ 仅返回 data.customer_level.level_infos;不返回客户档案、成长值或推断会员身份。
85
+ 固定请求 fields=level,不提供 --fields/--include,不附加其他模块或辅助请求。
86
+ 保留全部免费/付费记录、顺序和重复;不取第一条、不排序、不从成长值推算。
87
+ 客户标识必须匹配,明确 [] 才是无等级;缺字段、null、错型或模块失败整体失败。
88
+ 每条记录必须包含 level_alias、level_name、level_type、level_value,其他源字段忽略。
89
+ 只接受 success=true、数字 code=200、扁平 data,不用整数 data.level 回填。
90
+ --kdt-id 显式值优先,非法显式值不回退;非总部须匹配上下文 shopId。
91
+ 总部默认当前总部店铺,不遍历下属店铺;范围授权由服务端校验,不以本地目标解析证明。
92
+ 真实执行需有效四字段上下文并满足目标范围授权;没有上下文时,仅显式店铺可本地预览。
93
+ 一次调用最多一个业务请求,不重试、跟随重定向、切换店铺或身份。
94
+ 保留服务端查询扩展点默认值;只读分类不证明自定义扩展点无副作用。
95
+ 成功/预览 stdout 为一份 JSON;失败 stdout 为空,stderr 为安全结构化错误。
96
+ 完整字段和验证边界见 zan-saas schema member.customer-level.get。
97
+
98
+ 示例:
99
+ zan-saas member customer-level get --yz-open-id customer-1
100
+ zan-saas member customer-level get --yz-open-id customer-1 --kdt-id 63077 --format pretty
101
+ zan-saas member customer-level get --yz-open-id customer-1 --kdt-id 63077 --dry-run
102
+ `)
103
+ .action(async options => {
104
+ const input = buildInput(options, context);
105
+ const request = { method: 'POST', path: schema.api.path,
106
+ body: { kdt_id: input.kdtId, yz_open_id: input.yzOpenId, fields: 'level' } };
107
+ let output;
108
+ if (options.dryRun) {
109
+ validateCommandValue(schema, 'preview', request);
110
+ output = request;
111
+ } else {
112
+ const scope = { kdtId: input.kdtId };
113
+ const { result, facts } = await readApiEnvelope(request.path, request.body,
114
+ (category, details, state, stage) => failure(category, stage, scope, state, details));
115
+ assertSuccess(result, scope, facts);
116
+ output = adaptLevels(result, input, facts);
117
+ }
118
+ process.stdout.write(`${JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0)}\n`);
119
+ });
120
+ }
121
+
122
+ module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
@@ -0,0 +1,300 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "input": {
4
+ "type": "object",
5
+ "required": [
6
+ "kdtId",
7
+ "yzOpenId"
8
+ ],
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "kdtId": {
12
+ "$ref": "#/definitions/shopId",
13
+ "description": "显式 --kdt-id 优先;省略取本次有效 context.shopId,不是静态默认。"
14
+ },
15
+ "yzOpenId": {
16
+ "type": "string",
17
+ "minLength": 1,
18
+ "pattern": "\\S",
19
+ "description": "去除首尾空白后的有赞客户 yzOpenId,不接受手机号或其他帐号替代。"
20
+ }
21
+ },
22
+ "description": "CLI 解析参数并完成必要上下文补全后的业务输入;不是直接传入 CLI 的 JSON。原始选项、必填条件和默认值见 options。"
23
+ },
24
+ "output": {
25
+ "type": "object",
26
+ "required": [
27
+ "data"
28
+ ],
29
+ "additionalProperties": false,
30
+ "properties": {
31
+ "data": {
32
+ "type": "object",
33
+ "required": [
34
+ "customer_level"
35
+ ],
36
+ "additionalProperties": false,
37
+ "properties": {
38
+ "customer_level": {
39
+ "type": "object",
40
+ "required": [
41
+ "level_infos"
42
+ ],
43
+ "additionalProperties": false,
44
+ "properties": {
45
+ "level_infos": {
46
+ "type": "array",
47
+ "description": "原序保留所有免费及付费等级、重复记录,不推算。仅成功且客户主键匹配时明确 [] 表示无等级;缺失/null/非数组失败。",
48
+ "items": {
49
+ "type": "object",
50
+ "required": [
51
+ "level_alias",
52
+ "level_name",
53
+ "level_type",
54
+ "level_value"
55
+ ],
56
+ "additionalProperties": false,
57
+ "properties": {
58
+ "level_alias": {
59
+ "type": "string",
60
+ "description": "等级别名设置,原样保留,不作唯一性推断。"
61
+ },
62
+ "level_name": {
63
+ "type": "string",
64
+ "description": "等级名称,原样保留。"
65
+ },
66
+ "level_type": {
67
+ "type": "integer",
68
+ "enum": [
69
+ 1,
70
+ 2
71
+ ],
72
+ "description": "1 免费等级,2 付费等级;未知类型失败,不转换成无等级。"
73
+ },
74
+ "level_value": {
75
+ "$ref": "#/definitions/safeInteger",
76
+ "description": "等级值,保留整数 0;不是成长值或稳定等级 ID。"
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ },
87
+ "preview": {
88
+ "type": "object",
89
+ "required": [
90
+ "method",
91
+ "path",
92
+ "body"
93
+ ],
94
+ "additionalProperties": false,
95
+ "properties": {
96
+ "method": {
97
+ "const": "POST"
98
+ },
99
+ "path": {
100
+ "const": "youzan.scrm.customer.detail.get/1.0.1"
101
+ },
102
+ "body": {
103
+ "type": "object",
104
+ "required": [
105
+ "kdt_id",
106
+ "yz_open_id",
107
+ "fields"
108
+ ],
109
+ "additionalProperties": false,
110
+ "properties": {
111
+ "kdt_id": {
112
+ "$ref": "#/definitions/shopId"
113
+ },
114
+ "yz_open_id": {
115
+ "type": "string",
116
+ "minLength": 1,
117
+ "pattern": "\\S"
118
+ },
119
+ "fields": {
120
+ "const": "level"
121
+ }
122
+ }
123
+ }
124
+ }
125
+ },
126
+ "error": {
127
+ "type": "object",
128
+ "required": [
129
+ "success",
130
+ "code",
131
+ "message",
132
+ "details"
133
+ ],
134
+ "additionalProperties": false,
135
+ "properties": {
136
+ "success": {
137
+ "const": false
138
+ },
139
+ "code": {
140
+ "const": -10001
141
+ },
142
+ "message": {
143
+ "type": "string",
144
+ "minLength": 1
145
+ },
146
+ "details": {
147
+ "type": "object",
148
+ "required": [
149
+ "category",
150
+ "stage",
151
+ "command",
152
+ "targetScope",
153
+ "requestState",
154
+ "nextStep"
155
+ ],
156
+ "additionalProperties": false,
157
+ "properties": {
158
+ "category": {
159
+ "type": "string",
160
+ "enum": [
161
+ "parameter",
162
+ "validation",
163
+ "configuration",
164
+ "permission",
165
+ "authentication",
166
+ "http",
167
+ "transport",
168
+ "business_rejected",
169
+ "protocol"
170
+ ]
171
+ },
172
+ "stage": {
173
+ "type": "string",
174
+ "enum": [
175
+ "input",
176
+ "validation",
177
+ "context",
178
+ "scope",
179
+ "configuration",
180
+ "http",
181
+ "transport",
182
+ "response",
183
+ "customer-level",
184
+ "customer-level-model"
185
+ ]
186
+ },
187
+ "command": {
188
+ "const": "member.customer-level.get"
189
+ },
190
+ "targetScope": {
191
+ "oneOf": [
192
+ {
193
+ "$ref": "#/definitions/scope"
194
+ },
195
+ {
196
+ "type": "object",
197
+ "maxProperties": 0
198
+ }
199
+ ]
200
+ },
201
+ "requestState": {
202
+ "type": "string",
203
+ "enum": [
204
+ "not_sent",
205
+ "sent",
206
+ "unknown"
207
+ ]
208
+ },
209
+ "nextStep": {
210
+ "type": "string",
211
+ "minLength": 1
212
+ },
213
+ "api": {
214
+ "type": "string",
215
+ "minLength": 1
216
+ },
217
+ "httpStatus": {
218
+ "type": "integer",
219
+ "minimum": 100,
220
+ "maximum": 599
221
+ },
222
+ "businessCode": {
223
+ "$ref": "#/definitions/diagnosticCode"
224
+ },
225
+ "gatewayCode": {
226
+ "$ref": "#/definitions/diagnosticCode"
227
+ },
228
+ "trace_id": {
229
+ "type": "string",
230
+ "pattern": "^[a-zA-Z0-9_-]{1,128}$"
231
+ },
232
+ "request_id": {
233
+ "type": "string",
234
+ "pattern": "^[a-zA-Z0-9_-]{1,128}$"
235
+ }
236
+ }
237
+ }
238
+ }
239
+ },
240
+ "definitions": {
241
+ "shopId": {
242
+ "type": "integer",
243
+ "minimum": 1,
244
+ "maximum": 9007199254740991
245
+ },
246
+ "safeInteger": {
247
+ "type": "integer",
248
+ "minimum": -9007199254740991,
249
+ "maximum": 9007199254740991
250
+ },
251
+ "scope": {
252
+ "type": "object",
253
+ "required": [
254
+ "kdtId"
255
+ ],
256
+ "additionalProperties": false,
257
+ "properties": {
258
+ "kdtId": {
259
+ "$ref": "#/definitions/shopId"
260
+ }
261
+ }
262
+ },
263
+ "diagnosticCode": {
264
+ "oneOf": [
265
+ {
266
+ "$ref": "#/definitions/safeInteger"
267
+ },
268
+ {
269
+ "type": "string",
270
+ "pattern": "^-?\\d{1,12}$"
271
+ }
272
+ ]
273
+ }
274
+ },
275
+ "modules": {
276
+ "customer_level": {
277
+ "base": true,
278
+ "upstreamPath": "data",
279
+ "required": true,
280
+ "description": "目标客户的等级关系有限视图,不是等级定义或入会状态。"
281
+ }
282
+ },
283
+ "api": {
284
+ "method": "POST",
285
+ "path": "youzan.scrm.customer.detail.get/1.0.1"
286
+ },
287
+ "success": {
288
+ "description": "客户 ID 精确匹配,等级集合明确取得且每条四字段完整后整体输出。"
289
+ },
290
+ "errors": {
291
+ "description": "失败 stdout 为空,stderr 为一份脱敏错误 JSON,退出码非零;不返回部分成功,不自动重试、切换身份或目标。按 error 模型及安全下一步处理。"
292
+ },
293
+ "notes": [
294
+ "只返回目标客户当前等级关系的有限视图,不推导会员身份或等级定义;每条等级的四个字段均必需。",
295
+ "等级集合必须明确读取成功;缺失或 null 不补空数组,未取得不表示无等级。",
296
+ "--kdt-id 省略取有效上下文 shopId,显式非法值不回退;非总部不切店,总部不自动遍历。",
297
+ "本地目标校验不证明凭证店铺绑定或员工授权;应用样本不能代替员工链路验收。",
298
+ "本地 --dry-run 不读取凭证、不联网;预览只证明构造计划,不证明对象存在或权限有效。真实执行仍需有效上下文及目标范围授权,at 声明不替代服务端授权。"
299
+ ]
300
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "会员:身份、等级、成长值与变更记录"
3
+ }
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
4
+
5
+ const { Command, Option } = require('commander');
6
+ const { resolveTargetShop } = require('../../../../../execution/target-shop');
7
+ const { validateCommandValue } = require('../../../../../execution/command-schema');
8
+ const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
9
+ const { object } = require('../../../../../execution/query-api');
10
+ const schema = require('./schema.json');
11
+
12
+ const command = 'member.growth.get';
13
+ const reject = (category, stage, scope, state, facts) =>
14
+ failure(command, category, stage, scope, state, facts);
15
+
16
+ function createCommand({ context } = {}) {
17
+ return new Command('get')
18
+ .description('查询一个客户的当前成长值,不推算等级或积分')
19
+ .allowExcessArguments(false)
20
+ .exitOverride(error => {
21
+ if (['commander.helpDisplayed', 'commander.version'].includes(error.code)) throw error;
22
+ throw reject('parameter', 'input');
23
+ })
24
+ .requiredOption('--yz-open-id <id>', '必填:客户 yzOpenId;不是手机号、微信 openId 或员工 ID')
25
+ .option('--kdt-id <id>', '目标店铺正安全整数;省略取本次有效上下文 shopId')
26
+ .addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
27
+ .choices(['json', 'pretty']).default('json'))
28
+ .option('--dry-run', '本地预览店铺核验和成长值请求,不读凭证、不联网')
29
+ .addHelpText('after', `
30
+ 输出 data.growth_account.growth,保留 0 和负整数;客户不存在不能补成 0。
31
+ 先核验凭证店铺,再读取一个客户;固定账号类型,不自动切换编码、身份或店铺。
32
+ 最多一次店铺核验与一次成长值请求,不读取流水、不重试,保留扩展点默认行为。
33
+ 真实执行需有效四字段上下文和同店授权凭证;店铺核验不证明员工 OAuth。
34
+ 契约:zan-saas schema member.growth.get
35
+ 示例:zan-saas member growth get --yz-open-id customer-1 --kdt-id 63077 --dry-run
36
+ `)
37
+ .action(async options => {
38
+ const scope = resolveTargetShop(options, context, command);
39
+ let input;
40
+ try {
41
+ input = { ...scope, yzOpenId: options.yzOpenId.trim() };
42
+ validateCommandValue(schema, 'input', input);
43
+ } catch { throw reject('parameter', 'input', scope); }
44
+ const preview = {
45
+ method: 'POST', path: schema.api.path,
46
+ body: { params: { user: { account_type: 5, account_id: input.yzOpenId } } },
47
+ scope, prerequisites: [{ method: 'POST', path: bindingPath, body: {} }]
48
+ };
49
+ validateCommandValue(schema, 'preview', preview);
50
+ let output = preview;
51
+ if (!options.dryRun) {
52
+ const read = await createShopQuery(scope, command);
53
+ const { data, facts } = await read(preview.path, preview.body, 'growth-account');
54
+ if (!object(data) || !Number.isSafeInteger(data.growth)) {
55
+ throw reject('protocol', 'growth-account-model', scope, 'sent', facts);
56
+ }
57
+ output = { data: { growth_account: { growth: data.growth } } };
58
+ validateCommandValue(schema, 'output', output);
59
+ }
60
+ process.stdout.write(`${JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0)}\n`);
61
+ });
62
+ }
63
+
64
+ module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };