@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,51 @@
1
+ {
2
+ "schemaVersion": 3,
3
+ "domain": "benefit",
4
+ "businessCommands": [
5
+ {
6
+ "path": "benefit.card-definition.get",
7
+ "kind": "atomic",
8
+ "risk": "read",
9
+ "availability": "available",
10
+ "at": "all",
11
+ "module": "benefit/card-definition/get/command.js",
12
+ "fingerprint": "2f2d6c59004d152c5630abc5c4dc12f250b654db2d1435bfdfbfe69461d71e1e"
13
+ },
14
+ {
15
+ "path": "benefit.card-definition.list",
16
+ "kind": "atomic",
17
+ "risk": "read",
18
+ "availability": "available",
19
+ "at": "all",
20
+ "module": "benefit/card-definition/list/command.js",
21
+ "fingerprint": "6e1e404d0773b8360796d76c850f5913b0db5cf17556625bccb3bc1a90a4ef48"
22
+ },
23
+ {
24
+ "path": "benefit.card-grant.list",
25
+ "kind": "atomic",
26
+ "risk": "read",
27
+ "availability": "available",
28
+ "at": "all",
29
+ "module": "benefit/card-grant/list/command.js",
30
+ "fingerprint": "fcdc6d6a0415449fc65bff2dd942e5332b87f3b87fac3372953c4ca4a421b1af"
31
+ },
32
+ {
33
+ "path": "benefit.customer-card.get",
34
+ "kind": "atomic",
35
+ "risk": "read",
36
+ "availability": "available",
37
+ "at": "all",
38
+ "module": "benefit/customer-card/get/command.js",
39
+ "fingerprint": "c13c8d29bea7cd4de36916cacb7d61ac7112f005e88189137d48e7f7332e5551"
40
+ },
41
+ {
42
+ "path": "benefit.customer-card.list",
43
+ "kind": "atomic",
44
+ "risk": "read",
45
+ "availability": "available",
46
+ "at": "all",
47
+ "module": "benefit/customer-card/list/command.js",
48
+ "fingerprint": "99950d67fbfed296117eb6ad44be1fb6bae4875128847757ebd958c38a570189"
49
+ }
50
+ ]
51
+ }
@@ -0,0 +1,110 @@
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 { normalizeTimes } = require('../../../../../execution/datetime');
8
+ const { resolveTargetShop } = require('../../../../../execution/target-shop');
9
+ const { validateCommandValue } = require('../../../../../execution/command-schema');
10
+ const { object } = require('../../../../../execution/query-api');
11
+ const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
12
+
13
+ const command = 'benefit.customer-card.get';
14
+ const reject = (category, stage, scope, state, facts) =>
15
+ failure(command, category, stage, scope, state, facts);
16
+ const fields = {
17
+ card_alias: 'cardAlias', yz_open_id: 'yzOpenId', card_start_time: 'cardStartTime',
18
+ card_end_time: 'cardEndTime', card_name: 'cardName', take_card_time: 'takeCardTime',
19
+ activated_time: 'activatedTime', is_experience_card: 'isExperienceCard'
20
+ };
21
+
22
+ function buildInput(options, context) {
23
+ const scope = resolveTargetShop(options, context, command);
24
+ try {
25
+ const input = { ...scope, cardNo: options.cardNo.trim() };
26
+ validateCommandValue(schema, 'input', input);
27
+ return Object.freeze(input);
28
+ } catch { throw reject('parameter', 'input', scope); }
29
+ }
30
+
31
+ function project(envelope, input, facts) {
32
+ const invalid = () => reject('protocol', 'customer-card-get-model',
33
+ { kdtId: input.kdtId }, 'sent', facts);
34
+ const wrapped = Object.hasOwn(envelope, 'data');
35
+ if (wrapped && (!object(envelope.data) ||
36
+ Object.keys(fields).some(field => Object.hasOwn(envelope, field)))) throw invalid();
37
+ const payload = wrapped ? envelope.data : envelope;
38
+ const customerCard = { cardNo: input.cardNo };
39
+ for (const [source, target] of Object.entries(fields)) {
40
+ if (Object.hasOwn(payload, source)) customerCard[target] = payload[source];
41
+ }
42
+ const output = { data: { customerCard } };
43
+ try {
44
+ output.data.customerCard = normalizeTimes(customerCard,
45
+ schema.output.properties.data.properties.customerCard, schema.definitions);
46
+ validateCommandValue(schema, 'output', output);
47
+ }
48
+ catch { throw invalid(); }
49
+ return output;
50
+ }
51
+
52
+ async function execute(input, preview) {
53
+ const scope = { kdtId: input.kdtId };
54
+ const read = await createShopQuery(scope, command);
55
+ let response;
56
+ try {
57
+ response = await read(preview.path, preview.body, 'customer-card-get');
58
+ } catch (error) {
59
+ const details = error.cliDetails;
60
+ if (details?.category === 'business_rejected' && details.stage === 'customer-card-get' &&
61
+ details.api === schema.api.path &&
62
+ !Object.hasOwn(details, 'gatewayCode') &&
63
+ [141502105, 141502107, '141502105', '141502107'].includes(details.businessCode)) {
64
+ details.category = 'not_found';
65
+ error.message = '查询失败:not_found(customer-card-get)';
66
+ }
67
+ throw error;
68
+ }
69
+ return project(response.envelope, input, response.facts);
70
+ }
71
+
72
+ function createCommand({ context } = {}) {
73
+ return new Command('get')
74
+ .description('根据卡号查询一张客户权益卡的关联信息和有效期')
75
+ .allowExcessArguments(false)
76
+ .exitOverride(error => {
77
+ if (['commander.helpDisplayed', 'commander.version'].includes(error.code)) throw error;
78
+ throw reject('parameter', 'input');
79
+ })
80
+ .requiredOption('--card-no <no>', '必填:完整卡号字符串,保留前导零和长数字,不是卡定义 alias')
81
+ .option('--kdt-id <id>', '目标店铺正安全整数;省略取本次有效上下文 shopId')
82
+ .addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
83
+ .choices(['json', 'pretty']).default('json'))
84
+ .option('--dry-run', '仅本地预览主请求与店铺核验;不读凭证、不联网')
85
+ .addHelpText('after', `
86
+ 输出 data.customerCard:cardNo、cardAlias、yzOpenId、cardStartTime、cardEndTime 为必需字段。
87
+ cardName、takeCardTime、activatedTime、isExperienceCard 仅取得时返回;false 原样保留。
88
+ 时间点统一为北京时间 YYYY-MM-DD HH:mm:ss.SSS;空文本哨兵保留,不由时间合成 cardState。
89
+ 先核验凭证店铺 sid,再按卡号查询一次;最多两次请求,不重试、切店、换身份或遍历列表。
90
+ 只接受完整单层载荷;缺核心字段、错型或双层混合均整体失败,不输出部分结果。
91
+ 支持微商城单店、零售单店、连锁 D 总部/网店/合伙人;不承诺教育多校区总部。
92
+ 执行需有效四字段上下文及同店铺授权凭证;店铺核验不证明员工 OAuth 或跨店共享。
93
+ 没有上下文时,仅显式合法店铺配合 --dry-run 可预览;失败 stdout 为空,stderr 为安全错误 JSON。
94
+ 契约:zan-saas schema benefit.customer-card.get --format json
95
+ 示例:zan-saas benefit customer-card get --card-no 000337092113264760725
96
+ 预览:zan-saas benefit customer-card get --kdt-id 63077 --card-no 000337092113264760725 --dry-run`)
97
+ .action(async options => {
98
+ const input = buildInput(options, context);
99
+ const preview = {
100
+ method: 'POST', path: schema.api.path, body: { card_no: input.cardNo },
101
+ scope: { kdtId: input.kdtId },
102
+ prerequisites: [{ method: 'POST', path: bindingPath, body: {} }]
103
+ };
104
+ validateCommandValue(schema, 'preview', preview);
105
+ const result = options.dryRun ? preview : await execute(input, preview);
106
+ console.log(JSON.stringify(result, null, options.format === 'pretty' ? 2 : 0));
107
+ });
108
+ }
109
+
110
+ module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
@@ -0,0 +1,340 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "input": {
4
+ "type": "object",
5
+ "required": [
6
+ "kdtId",
7
+ "cardNo"
8
+ ],
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "kdtId": {
12
+ "$ref": "#/definitions/shopId"
13
+ },
14
+ "cardNo": {
15
+ "$ref": "#/definitions/cardNo"
16
+ }
17
+ },
18
+ "description": "CLI 解析参数并完成必要上下文补全后的业务输入;不是直接传入 CLI 的 JSON。原始选项、必填条件和默认值见 options。"
19
+ },
20
+ "output": {
21
+ "type": "object",
22
+ "required": [
23
+ "data"
24
+ ],
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "data": {
28
+ "type": "object",
29
+ "required": [
30
+ "customerCard"
31
+ ],
32
+ "additionalProperties": false,
33
+ "properties": {
34
+ "customerCard": {
35
+ "type": "object",
36
+ "required": [
37
+ "cardNo",
38
+ "cardAlias",
39
+ "yzOpenId",
40
+ "cardStartTime",
41
+ "cardEndTime"
42
+ ],
43
+ "additionalProperties": false,
44
+ "properties": {
45
+ "cardNo": {
46
+ "$ref": "#/definitions/cardNo",
47
+ "description": "成功查询的规范化输入卡号;不是响应回显的独立核验证据。"
48
+ },
49
+ "cardAlias": {
50
+ "type": "string",
51
+ "minLength": 1,
52
+ "description": "关联卡定义的别名。"
53
+ },
54
+ "yzOpenId": {
55
+ "type": "string",
56
+ "minLength": 1,
57
+ "description": "持卡客户的有赞用户标识,不是操作员工 ID。"
58
+ },
59
+ "cardStartTime": {
60
+ "anyOf": [
61
+ {
62
+ "type": "string",
63
+ "format": "beijing-date-time-ms"
64
+ },
65
+ {
66
+ "const": ""
67
+ }
68
+ ],
69
+ "$comment": "upstream-time:text:empty",
70
+ "description": "实例有效期开始的源时间文本;北京时间 YYYY-MM-DD HH:mm:ss.SSS。业务哨兵原值保留:['']。"
71
+ },
72
+ "cardEndTime": {
73
+ "anyOf": [
74
+ {
75
+ "type": "string",
76
+ "format": "beijing-date-time-ms"
77
+ },
78
+ {
79
+ "const": ""
80
+ }
81
+ ],
82
+ "$comment": "upstream-time:text:empty",
83
+ "description": "实例有效期结束的源时间文本;北京时间 YYYY-MM-DD HH:mm:ss.SSS。业务哨兵原值保留:['']。"
84
+ },
85
+ "cardName": {
86
+ "type": "string"
87
+ },
88
+ "takeCardTime": {
89
+ "anyOf": [
90
+ {
91
+ "type": "string",
92
+ "format": "beijing-date-time-ms"
93
+ },
94
+ {
95
+ "const": ""
96
+ }
97
+ ],
98
+ "$comment": "upstream-time:text:empty",
99
+ "description": "领取时间;北京时间 YYYY-MM-DD HH:mm:ss.SSS。业务哨兵原值保留:['']。"
100
+ },
101
+ "activatedTime": {
102
+ "anyOf": [
103
+ {
104
+ "type": "string",
105
+ "format": "beijing-date-time-ms"
106
+ },
107
+ {
108
+ "const": ""
109
+ }
110
+ ],
111
+ "$comment": "upstream-time:text:empty",
112
+ "description": "激活时间;北京时间 YYYY-MM-DD HH:mm:ss.SSS。业务哨兵原值保留:['']。"
113
+ },
114
+ "isExperienceCard": {
115
+ "type": "boolean"
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ },
123
+ "preview": {
124
+ "type": "object",
125
+ "required": [
126
+ "method",
127
+ "path",
128
+ "body",
129
+ "scope",
130
+ "prerequisites"
131
+ ],
132
+ "additionalProperties": false,
133
+ "properties": {
134
+ "method": {
135
+ "const": "POST"
136
+ },
137
+ "path": {
138
+ "const": "youzan.scrm.customer.info.get/3.0.0"
139
+ },
140
+ "body": {
141
+ "type": "object",
142
+ "required": [
143
+ "card_no"
144
+ ],
145
+ "additionalProperties": false,
146
+ "properties": {
147
+ "card_no": {
148
+ "$ref": "#/definitions/cardNo"
149
+ }
150
+ }
151
+ },
152
+ "scope": {
153
+ "type": "object",
154
+ "required": [
155
+ "kdtId"
156
+ ],
157
+ "additionalProperties": false,
158
+ "properties": {
159
+ "kdtId": {
160
+ "$ref": "#/definitions/shopId"
161
+ }
162
+ }
163
+ },
164
+ "prerequisites": {
165
+ "type": "array",
166
+ "minItems": 1,
167
+ "maxItems": 1,
168
+ "items": {
169
+ "type": "object",
170
+ "required": [
171
+ "method",
172
+ "path",
173
+ "body"
174
+ ],
175
+ "additionalProperties": false,
176
+ "properties": {
177
+ "method": {
178
+ "const": "POST"
179
+ },
180
+ "path": {
181
+ "const": "youzan.shop.basic.get/3.0.0"
182
+ },
183
+ "body": {
184
+ "type": "object",
185
+ "additionalProperties": false
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+ },
192
+ "error": {
193
+ "type": "object",
194
+ "required": [
195
+ "success",
196
+ "code",
197
+ "message",
198
+ "details"
199
+ ],
200
+ "additionalProperties": false,
201
+ "properties": {
202
+ "success": {
203
+ "const": false
204
+ },
205
+ "code": {
206
+ "const": -10001
207
+ },
208
+ "message": {
209
+ "type": "string",
210
+ "minLength": 1
211
+ },
212
+ "details": {
213
+ "type": "object",
214
+ "required": [
215
+ "category",
216
+ "stage",
217
+ "command",
218
+ "targetScope",
219
+ "requestState",
220
+ "nextStep"
221
+ ],
222
+ "additionalProperties": false,
223
+ "properties": {
224
+ "category": {
225
+ "enum": [
226
+ "validation",
227
+ "configuration",
228
+ "parameter",
229
+ "permission",
230
+ "authentication",
231
+ "scope_unresolved",
232
+ "transport",
233
+ "http",
234
+ "protocol",
235
+ "business_rejected",
236
+ "not_found"
237
+ ]
238
+ },
239
+ "stage": {
240
+ "enum": [
241
+ "validation",
242
+ "context",
243
+ "scope",
244
+ "input",
245
+ "configuration",
246
+ "shop-binding",
247
+ "customer-card-get",
248
+ "customer-card-get-model"
249
+ ]
250
+ },
251
+ "command": {
252
+ "const": "benefit.customer-card.get"
253
+ },
254
+ "targetScope": {
255
+ "type": "object",
256
+ "additionalProperties": false,
257
+ "properties": {
258
+ "kdtId": {
259
+ "$ref": "#/definitions/shopId"
260
+ }
261
+ }
262
+ },
263
+ "requestState": {
264
+ "enum": [
265
+ "not_sent",
266
+ "sent",
267
+ "unknown"
268
+ ]
269
+ },
270
+ "nextStep": {
271
+ "type": "string",
272
+ "minLength": 1
273
+ },
274
+ "api": {
275
+ "type": "string"
276
+ },
277
+ "httpStatus": {
278
+ "type": "integer"
279
+ },
280
+ "businessCode": {
281
+ "anyOf": [
282
+ {
283
+ "type": "integer"
284
+ },
285
+ {
286
+ "type": "string"
287
+ }
288
+ ]
289
+ },
290
+ "gatewayCode": {
291
+ "anyOf": [
292
+ {
293
+ "type": "integer"
294
+ },
295
+ {
296
+ "type": "string"
297
+ }
298
+ ]
299
+ },
300
+ "trace_id": {
301
+ "type": "string"
302
+ },
303
+ "request_id": {
304
+ "type": "string"
305
+ }
306
+ }
307
+ }
308
+ }
309
+ },
310
+ "definitions": {
311
+ "shopId": {
312
+ "type": "integer",
313
+ "minimum": 1,
314
+ "maximum": 9007199254740991
315
+ },
316
+ "cardNo": {
317
+ "type": "string",
318
+ "minLength": 1,
319
+ "pattern": "^(?![\\s\\S]*[\\u0000-\\u001f\\u007f-\\u009f])\\S(?:[\\s\\S]*\\S)?$",
320
+ "description": "去除首尾空白的完整卡号字符串,无控制字符;长数字和前导零无损,不转 number。"
321
+ }
322
+ },
323
+ "success": {
324
+ "description": "目标持卡实例及所有必需内容满足模型后成功;不接受空或混合层级载荷。"
325
+ },
326
+ "errors": {
327
+ "description": "失败 stdout 为空,stderr 为一份脱敏错误 JSON,退出码非零;不返回部分成功,不自动重试、切换身份或目标。按 error 模型及安全下一步处理。 明确业务拒绝 141502105 或 141502107 为 not_found;矛盾信号、空或错型载荷为 protocol。"
328
+ },
329
+ "notes": [
330
+ "按完整卡号查询单张客户持卡实例,卡号按文本无损保留;不补查客户、权益卡定义或列表。",
331
+ "可选字段缺失保持省略,null 或错型失败;false 和字段显式允许的空文本保留。",
332
+ "不返回姓名、手机号、粉丝资料或 cardState;不按日期自行推算持卡状态。",
333
+ "支持微商城单店、零售单店、连锁 D 总部、网店及合伙人;不承诺教育多校区总部。",
334
+ "本地 --dry-run 不读取凭证、不联网;预览只证明构造计划,不证明对象存在或权限有效。真实执行仍需有效上下文及目标范围授权,at 声明不替代服务端授权。"
335
+ ],
336
+ "api": {
337
+ "method": "POST",
338
+ "path": "youzan.scrm.customer.info.get/3.0.0"
339
+ }
340
+ }
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ const { readTotal } = require('../../../../../execution/list-total');
4
+
5
+ const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
6
+
7
+ const { Option } = require('commander');
8
+ const { DiagnosticCommand } = require('../../../../../cli/diagnostic-command');
9
+ const { parseIntegerOption, withInputScope } = require('../../../../../execution/error-details');
10
+ const { resolveTargetShop } = require('../../../../../execution/target-shop');
11
+ const { validateCommandValue } = require('../../../../../execution/command-schema');
12
+ const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
13
+ const { object } = require('../../../../../execution/query-api');
14
+ const schema = require('./schema.json');
15
+ const { normalizeTimes } = require('../../../../../execution/datetime');
16
+
17
+ const command = 'benefit.customer-card.list';
18
+ const reject = (category, stage, scope, state, facts) =>
19
+ failure(command, category, stage, scope, state, facts);
20
+
21
+ function project(data, input, facts) {
22
+ const scope = { kdtId: input.kdtId };
23
+ const invalid = () => reject('protocol', 'customer-card-list-model', scope, 'sent', facts);
24
+ if (!object(data) || !Array.isArray(data.items) || data.page !== input.pageNo ||
25
+ !Number.isSafeInteger(data.page_size) || data.page_size < 1 ||
26
+ !Number.isSafeInteger(data.page * data.page_size) ||
27
+ data.items.length > data.page_size) {
28
+ throw invalid();
29
+ }
30
+ try { readTotal(data, 'total'); } catch { throw invalid(); }
31
+ const seen = new Set();
32
+ const customerCards = data.items.map(row => {
33
+ if (!object(row) || seen.has(row.card_no)) throw invalid();
34
+ seen.add(row.card_no);
35
+ return {
36
+ cardNo: row.card_no, cardAlias: row.card_alias, cardState: row.card_state,
37
+ cardStartTime: row.card_start_time, cardEndTime: row.card_end_time
38
+ };
39
+ });
40
+ const output = { data: {
41
+ customerCards,
42
+ pagination: { pageNo: data.page, pageSize: data.page_size, returned: customerCards.length,
43
+ hasMore: null, nextPageNo: null, windowLimitReached: input.pageNo === Number.MAX_SAFE_INTEGER }
44
+ } };
45
+ try {
46
+ output.data.customerCards = normalizeTimes(customerCards,
47
+ { type: 'array', items: { $ref: '#/definitions/customerCard' } }, schema.definitions);
48
+ validateCommandValue(schema, 'output', output);
49
+ }
50
+ catch { throw invalid(); }
51
+ return output;
52
+ }
53
+
54
+ function createCommand({ context } = {}) {
55
+ return new DiagnosticCommand('list', { path: command, schema, parameterCategory: 'parameter' })
56
+ .description('分页查询指定客户持有的权益卡、状态和有效期')
57
+ .allowExcessArguments(false)
58
+ .requiredOption('--yz-open-id <id>', '必填:客户 yzOpenId;不是手机号或微信 openId')
59
+ .option('--kdt-id <id>', '目标店铺正安全整数;省略取本次有效上下文 shopId')
60
+ .addOption(new Option('--status <status>', 'available 查询可用范围;all 请求全部状态范围')
61
+ .choices(['available', 'all']).default('available'))
62
+ .option('--page-no <n>', '页码正安全整数,从 1 开始;容量以实际响应为准', '1')
63
+ .addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
64
+ .choices(['json', 'pretty']).default('json'))
65
+ .option('--dry-run', '本地预览店铺核验和持卡请求,不读凭证、不联网')
66
+ .addHelpText('after', `
67
+ 当前接口未提供可靠的匹配总数,因此省略 total,hasMore 为 null、nextPageNo 为 null,不自动续页。
68
+ 返回 data.customerCards 和 data.pagination;returned 为本次客户持卡条数。
69
+ 分页仅支持 --page-no;页容量由服务端决定,不支持 --page-size。
70
+ cardNo 是完整字符串实例号;cardAlias 仅关联定义,不按定义合并持卡。
71
+ 保留源 cardState;时间点统一为北京时间 YYYY-MM-DD HH:mm:ss.SSS,包括 9999 年永久哨兵。
72
+ 空页不证明耗尽;all 不保证删除历史完整或跨页快照。
73
+ 先核验凭证店铺,再查询一页持卡;最多两次请求,不重试或切换身份、店铺。
74
+ 支持微商城单店、零售单店、连锁 D 总部/网店/合伙人,不承诺教育多校区总部。
75
+ 真实执行需有效四字段上下文和同店授权凭证;店铺核验不证明员工 OAuth。
76
+ 契约:zan-saas schema benefit.customer-card.list
77
+ 示例:zan-saas benefit customer-card list --yz-open-id customer-a --status all --page-no 2
78
+ `)
79
+ .action(async options => {
80
+ const scope = resolveTargetShop(options, context, command);
81
+ const input = withInputScope(scope, () => {
82
+ const value = { ...scope, yzOpenId: options.yzOpenId.trim(), status: options.status,
83
+ pageNo: parseIntegerOption(options.pageNo, schema, '/pageNo') };
84
+ validateCommandValue(schema, 'input', value);
85
+ return value;
86
+ });
87
+ const request = { method: 'POST', path: schema.api.path,
88
+ body: { params: { user: { account_id: input.yzOpenId, account_type: 5 },
89
+ page_no: input.pageNo, state: input.status === 'all' } } };
90
+ const preview = { scope, prerequisites: [{ method: 'POST', path: bindingPath, body: {} }],
91
+ requests: [request] };
92
+ validateCommandValue(schema, 'preview', preview);
93
+ let output = preview;
94
+ if (!options.dryRun) {
95
+ const read = await createShopQuery(scope, command, { transportOptions: { shopApp: false } });
96
+ const { data, facts } = await read(request.path, request.body, 'customer-card-list');
97
+ output = project(data, input, facts);
98
+ }
99
+ process.stdout.write(`${JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0)}\n`);
100
+ });
101
+ }
102
+
103
+ module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };