@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,656 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "input": {
4
+ "type": "object",
5
+ "description": "规范化业务输入。input-file 仅为有界文件或 stdin 来源;reason 裁首尾空白,其余业务文本不改写。根、object、values 项拒绝额外属性、null 及重复 JSON 成员。",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "kdtId",
9
+ "object",
10
+ "values",
11
+ "reason",
12
+ "format",
13
+ "dryRun"
14
+ ],
15
+ "properties": {
16
+ "kdtId": {
17
+ "$ref": "#/definitions/shopId"
18
+ },
19
+ "object": {
20
+ "$ref": "#/definitions/sourceObject"
21
+ },
22
+ "values": {
23
+ "type": "array",
24
+ "minItems": 1,
25
+ "maxItems": 3,
26
+ "description": "输入顺序即输出顺序;key 和 field 分别唯一,密文可相同。",
27
+ "items": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "required": [
31
+ "key",
32
+ "field",
33
+ "ciphertext"
34
+ ],
35
+ "properties": {
36
+ "key": {
37
+ "$ref": "#/definitions/key"
38
+ },
39
+ "field": {
40
+ "$ref": "#/definitions/field"
41
+ },
42
+ "ciphertext": {
43
+ "type": "string",
44
+ "minLength": 1,
45
+ "maxLength": 16384,
46
+ "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]+$",
47
+ "description": "原始密文,不 trim;实际 UTF-8 上限 16384 字节。外形不证明加密或授权,必须与源字段完全相等。"
48
+ }
49
+ }
50
+ }
51
+ },
52
+ "reason": {
53
+ "type": "string",
54
+ "minLength": 1,
55
+ "maxLength": 200,
56
+ "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]+$",
57
+ "description": "裁首尾空白后 1 至 200 个 Unicode 码点,无控制字符;不要填写个人信息,不提供权限。"
58
+ },
59
+ "format": {
60
+ "type": "string",
61
+ "enum": [
62
+ "json",
63
+ "pretty"
64
+ ],
65
+ "description": "json 为紧凑 JSON;pretty 仅增加缩进。"
66
+ },
67
+ "dryRun": {
68
+ "type": "boolean",
69
+ "description": "true 只做本地校验和计划,不读取凭证或联网;false 执行需真实受控 provider。"
70
+ }
71
+ }
72
+ },
73
+ "output": {
74
+ "type": "object",
75
+ "additionalProperties": false,
76
+ "required": [
77
+ "data"
78
+ ],
79
+ "properties": {
80
+ "data": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": [
84
+ "values"
85
+ ],
86
+ "properties": {
87
+ "values": {
88
+ "type": "array",
89
+ "minItems": 1,
90
+ "maxItems": 3,
91
+ "description": "全部选定字段通过来源、判密、完整解密及可靠审计后一次性交付;顺序和关联与输入相同。",
92
+ "items": {
93
+ "type": "object",
94
+ "additionalProperties": false,
95
+ "required": [
96
+ "key",
97
+ "field",
98
+ "value"
99
+ ],
100
+ "properties": {
101
+ "key": {
102
+ "$ref": "#/definitions/key"
103
+ },
104
+ "field": {
105
+ "$ref": "#/definitions/field"
106
+ },
107
+ "value": {
108
+ "type": "string",
109
+ "description": "平台成功返回的明文;空字符串原样保留,缺失、null 或非字符串整体拒绝。"
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ },
118
+ "preview": {
119
+ "type": "object",
120
+ "additionalProperties": false,
121
+ "required": [
122
+ "plan"
123
+ ],
124
+ "properties": {
125
+ "plan": {
126
+ "type": "object",
127
+ "additionalProperties": false,
128
+ "required": [
129
+ "kdtId",
130
+ "object",
131
+ "fields",
132
+ "itemCount",
133
+ "maximumApiRequests",
134
+ "requiresSensitiveAuthorization"
135
+ ],
136
+ "properties": {
137
+ "kdtId": {
138
+ "$ref": "#/definitions/shopId"
139
+ },
140
+ "object": {
141
+ "$ref": "#/definitions/sourceObject"
142
+ },
143
+ "fields": {
144
+ "type": "array",
145
+ "minItems": 1,
146
+ "maxItems": 3,
147
+ "uniqueItems": true,
148
+ "description": "本次选定的源字段,不含 key 或内容。",
149
+ "items": {
150
+ "$ref": "#/definitions/field"
151
+ }
152
+ },
153
+ "itemCount": {
154
+ "type": "integer",
155
+ "minimum": 1,
156
+ "maximum": 3,
157
+ "description": "输入项数量。"
158
+ },
159
+ "maximumApiRequests": {
160
+ "const": 4,
161
+ "description": "最多四次有赞业务请求,不包括待接入的授权及审计请求。"
162
+ },
163
+ "requiresSensitiveAuthorization": {
164
+ "const": true,
165
+ "description": "必须完成员工字段权限、来源与可靠审计;计划不证明权限或对象存在。"
166
+ }
167
+ }
168
+ }
169
+ }
170
+ },
171
+ "error": {
172
+ "type": "object",
173
+ "additionalProperties": false,
174
+ "required": [
175
+ "success",
176
+ "code",
177
+ "message",
178
+ "details"
179
+ ],
180
+ "properties": {
181
+ "success": {
182
+ "const": false
183
+ },
184
+ "code": {
185
+ "const": -10001
186
+ },
187
+ "message": {
188
+ "type": "string",
189
+ "minLength": 1
190
+ },
191
+ "details": {
192
+ "type": "object",
193
+ "additionalProperties": false,
194
+ "required": [
195
+ "category",
196
+ "stage",
197
+ "command",
198
+ "targetScope",
199
+ "requestState",
200
+ "nextStep",
201
+ "errorVersion",
202
+ "recovery",
203
+ "execution"
204
+ ],
205
+ "properties": {
206
+ "category": {
207
+ "type": "string",
208
+ "description": "安全失败分类,不包含上游 message 或个人内容。"
209
+ },
210
+ "stage": {
211
+ "type": "string",
212
+ "enum": [
213
+ "input",
214
+ "scope",
215
+ "shop-binding",
216
+ "source-object",
217
+ "source-binding",
218
+ "privacy-authorization",
219
+ "verify",
220
+ "decrypt",
221
+ "audit",
222
+ "output-model",
223
+ "transport"
224
+ ],
225
+ "description": "失败所在阶段。"
226
+ },
227
+ "command": {
228
+ "const": "privacy.field.decrypt"
229
+ },
230
+ "targetScope": {
231
+ "type": "object",
232
+ "additionalProperties": false,
233
+ "properties": {
234
+ "kdtId": {
235
+ "$ref": "#/definitions/shopId"
236
+ }
237
+ },
238
+ "description": "仅已校验的店铺 ID,不携带订单内容。"
239
+ },
240
+ "requestState": {
241
+ "type": "string",
242
+ "enum": [
243
+ "not_sent",
244
+ "sent",
245
+ "unknown"
246
+ ],
247
+ "description": "not_sent 尚未发出,sent 已收到响应,unknown 请求结果未知,不自动重放。"
248
+ },
249
+ "nextStep": {
250
+ "type": "string",
251
+ "minLength": 1
252
+ },
253
+ "api": {
254
+ "type": "string",
255
+ "minLength": 1
256
+ },
257
+ "httpStatus": {
258
+ "type": "integer"
259
+ },
260
+ "businessCode": {
261
+ "$ref": "#/definitions/diagnosticCode"
262
+ },
263
+ "gatewayCode": {
264
+ "$ref": "#/definitions/diagnosticCode"
265
+ },
266
+ "trace_id": {
267
+ "type": "string",
268
+ "pattern": "^[a-zA-Z0-9_-]{1,128}$"
269
+ },
270
+ "request_id": {
271
+ "type": "string",
272
+ "pattern": "^[a-zA-Z0-9_-]{1,128}$"
273
+ },
274
+ "errorVersion": {
275
+ "const": 2,
276
+ "description": "本命令采用错误诊断协议第二版。"
277
+ },
278
+ "issues": {
279
+ "type": "array",
280
+ "minItems": 1,
281
+ "maxItems": 16,
282
+ "items": {
283
+ "$ref": "#/definitions/diagnosticIssue"
284
+ },
285
+ "description": "最多十六个已定位问题,不包含收到的原值。"
286
+ },
287
+ "issuesTruncated": {
288
+ "const": true,
289
+ "description": "问题超过返回上限,当前列表没有穷尽全部问题。"
290
+ },
291
+ "recovery": {
292
+ "$ref": "#/definitions/diagnosticRecovery",
293
+ "description": "受限的恢复说明,不会自动执行。"
294
+ },
295
+ "execution": {
296
+ "$ref": "#/definitions/diagnosticExecution",
297
+ "description": "整次调用的请求观察,独立于失败阶段的 requestState。"
298
+ }
299
+ }
300
+ }
301
+ }
302
+ },
303
+ "definitions": {
304
+ "shopId": {
305
+ "type": "string",
306
+ "pattern": "^[1-9][0-9]*$",
307
+ "description": "目标店铺正十进制安全整数,规范化保留字符串,不自动切店。"
308
+ },
309
+ "sourceObject": {
310
+ "type": "object",
311
+ "additionalProperties": false,
312
+ "required": [
313
+ "type",
314
+ "orderNo"
315
+ ],
316
+ "properties": {
317
+ "type": {
318
+ "const": "order",
319
+ "description": "order 为交易订单;未知对象类型拒绝。"
320
+ },
321
+ "orderNo": {
322
+ "type": "string",
323
+ "minLength": 1,
324
+ "maxLength": 128,
325
+ "pattern": "^(?=.*[^\\s])[^\\u0000-\\u001f\\u007f-\\u009f]+$",
326
+ "description": "原始订单号,保留合法业务空格,不猜前缀或位数。"
327
+ }
328
+ }
329
+ },
330
+ "key": {
331
+ "type": "string",
332
+ "minLength": 1,
333
+ "maxLength": 64,
334
+ "pattern": "^[a-z][a-z0-9-]*$",
335
+ "description": "本次唯一的结果关联标识,不是业务对象身份。"
336
+ },
337
+ "field": {
338
+ "type": "string",
339
+ "enum": [
340
+ "address.receiverName",
341
+ "address.receiverPhone",
342
+ "address.address"
343
+ ],
344
+ "description": "address.receiverName 为收货姓名;address.receiverPhone 为收货联系方式;address.address 为订单详细收货地址。未知字段拒绝,不接受任意 JSONPath。"
345
+ },
346
+ "diagnosticCode": {
347
+ "anyOf": [
348
+ {
349
+ "type": "integer"
350
+ },
351
+ {
352
+ "type": "string",
353
+ "pattern": "^-?[0-9]{1,12}$"
354
+ }
355
+ ],
356
+ "description": "原样保留安全错误码,不推测未知码含义。"
357
+ },
358
+ "diagnosticExpected": {
359
+ "type": "object",
360
+ "additionalProperties": false,
361
+ "required": [],
362
+ "properties": {
363
+ "type": {
364
+ "anyOf": [
365
+ {
366
+ "type": "string",
367
+ "description": "预期的 JSON 类型。"
368
+ },
369
+ {
370
+ "type": "array",
371
+ "items": {
372
+ "type": "string",
373
+ "description": "预期的 JSON 类型。"
374
+ }
375
+ }
376
+ ],
377
+ "description": "同版模型允许的类型。"
378
+ },
379
+ "enum": {
380
+ "type": "array",
381
+ "items": {
382
+ "anyOf": [
383
+ {
384
+ "type": "string"
385
+ },
386
+ {
387
+ "type": "number"
388
+ },
389
+ {
390
+ "type": "boolean"
391
+ },
392
+ {
393
+ "type": "null"
394
+ }
395
+ ],
396
+ "description": "契约声明的静态标量约束。"
397
+ },
398
+ "description": "同版模型允许的静态值。"
399
+ },
400
+ "const": {
401
+ "anyOf": [
402
+ {
403
+ "type": "string"
404
+ },
405
+ {
406
+ "type": "number"
407
+ },
408
+ {
409
+ "type": "boolean"
410
+ },
411
+ {
412
+ "type": "null"
413
+ }
414
+ ],
415
+ "description": "契约声明的静态标量约束。"
416
+ },
417
+ "minimum": {
418
+ "type": "number",
419
+ "description": "包含的最小值。"
420
+ },
421
+ "maximum": {
422
+ "type": "number",
423
+ "description": "包含的最大值。"
424
+ },
425
+ "exclusiveMinimum": {
426
+ "type": "number",
427
+ "description": "不包含的最小值。"
428
+ },
429
+ "exclusiveMaximum": {
430
+ "type": "number",
431
+ "description": "不包含的最大值。"
432
+ },
433
+ "minLength": {
434
+ "type": "integer",
435
+ "description": "最少字符数。"
436
+ },
437
+ "maxLength": {
438
+ "type": "integer",
439
+ "description": "最多字符数。"
440
+ },
441
+ "minItems": {
442
+ "type": "integer",
443
+ "description": "最少元素数。"
444
+ },
445
+ "maxItems": {
446
+ "type": "integer",
447
+ "description": "最多元素数。"
448
+ },
449
+ "format": {
450
+ "type": "string",
451
+ "description": "同版模型声明的格式。"
452
+ },
453
+ "pattern": {
454
+ "type": "string",
455
+ "description": "同版模型声明的字符约束。"
456
+ },
457
+ "additionalProperties": {
458
+ "const": false,
459
+ "description": "对象拒绝契约以外的属性。"
460
+ },
461
+ "contains": {
462
+ "type": "object",
463
+ "additionalProperties": false,
464
+ "required": [
465
+ "const"
466
+ ],
467
+ "properties": {
468
+ "const": {
469
+ "anyOf": [
470
+ {
471
+ "type": "string"
472
+ },
473
+ {
474
+ "type": "number"
475
+ },
476
+ {
477
+ "type": "boolean"
478
+ },
479
+ {
480
+ "type": "null"
481
+ }
482
+ ],
483
+ "description": "契约声明的静态标量约束。"
484
+ }
485
+ }
486
+ },
487
+ "items": {
488
+ "type": "object",
489
+ "additionalProperties": false,
490
+ "required": [
491
+ "enum"
492
+ ],
493
+ "properties": {
494
+ "enum": {
495
+ "type": "array",
496
+ "items": {
497
+ "anyOf": [
498
+ {
499
+ "type": "string"
500
+ },
501
+ {
502
+ "type": "number"
503
+ },
504
+ {
505
+ "type": "boolean"
506
+ },
507
+ {
508
+ "type": "null"
509
+ }
510
+ ],
511
+ "description": "契约声明的静态标量约束。"
512
+ },
513
+ "description": "元素允许的静态值。"
514
+ }
515
+ }
516
+ }
517
+ }
518
+ },
519
+ "diagnosticIssue": {
520
+ "type": "object",
521
+ "additionalProperties": false,
522
+ "required": [
523
+ "source",
524
+ "reason"
525
+ ],
526
+ "properties": {
527
+ "source": {
528
+ "enum": [
529
+ "argv",
530
+ "input",
531
+ "context",
532
+ "output",
533
+ "preview"
534
+ ],
535
+ "description": "问题所属的参数、输入、上下文、结果或预览模型。"
536
+ },
537
+ "path": {
538
+ "type": "string",
539
+ "description": "对应模型中的 JSON Pointer;不含原始输入或动态字典键。"
540
+ },
541
+ "option": {
542
+ "type": "string",
543
+ "description": "可定位时给出的已注册 CLI 选项。"
544
+ },
545
+ "reason": {
546
+ "enum": [
547
+ "required",
548
+ "invalid_type",
549
+ "invalid_choice",
550
+ "out_of_range",
551
+ "invalid_format",
552
+ "conditional_required",
553
+ "constraint",
554
+ "unexpected_property",
555
+ "unknown_option",
556
+ "unknown_command",
557
+ "excess_arguments",
558
+ "missing_value"
559
+ ],
560
+ "description": "字段违反的约束类型,原始值不回显。"
561
+ },
562
+ "expected": {
563
+ "$ref": "#/definitions/diagnosticExpected",
564
+ "description": "同版契约的静态预期。"
565
+ },
566
+ "relatedPaths": {
567
+ "type": "array",
568
+ "items": {
569
+ "type": "string",
570
+ "description": "关联字段的 JSON Pointer。"
571
+ },
572
+ "description": "触发条件约束的关联字段。"
573
+ }
574
+ }
575
+ },
576
+ "diagnosticRecovery": {
577
+ "type": "object",
578
+ "additionalProperties": false,
579
+ "required": [
580
+ "action",
581
+ "automaticBusinessRetry"
582
+ ],
583
+ "properties": {
584
+ "action": {
585
+ "enum": [
586
+ "correct_input",
587
+ "complete_authentication",
588
+ "request_access_review",
589
+ "stop_and_inspect"
590
+ ],
591
+ "description": "依次表示修正本地输入、补认证、核对权限或停止核查;仅是说明,不执行操作或授予权限。"
592
+ },
593
+ "automaticBusinessRetry": {
594
+ "const": false,
595
+ "description": "不据此自动重放业务请求。"
596
+ }
597
+ }
598
+ },
599
+ "diagnosticExecution": {
600
+ "type": "object",
601
+ "additionalProperties": false,
602
+ "required": [
603
+ "requestState",
604
+ "coverage",
605
+ "observedAttempts"
606
+ ],
607
+ "properties": {
608
+ "requestState": {
609
+ "enum": [
610
+ "not_sent",
611
+ "sent",
612
+ "unknown"
613
+ ],
614
+ "description": "整次调用尚未发送、已有发送记录或无法排除未知请求;不代表业务完成。"
615
+ },
616
+ "coverage": {
617
+ "enum": [
618
+ "complete",
619
+ "partial"
620
+ ],
621
+ "description": "请求观察覆盖全部已接入路径,或存在未观测路径;部分覆盖不能声明零请求。"
622
+ },
623
+ "observedAttempts": {
624
+ "type": "integer",
625
+ "minimum": 0,
626
+ "maximum": 9007199254740991,
627
+ "description": "本地已进入发送边界的观测次数下界,不是服务端执行次数。"
628
+ }
629
+ }
630
+ }
631
+ },
632
+ "api": {
633
+ "method": "POST",
634
+ "path": "youzan.cloud.secret.decrypt.single/1.0.0"
635
+ },
636
+ "success": {
637
+ "description": "同一原应用、店铺和订单字段来源,全部判密、解密、输出模型及可靠审计满足后,按输入关联一次性交付明文。当前生产 provider 未接入,不宣称真实披露可用。"
638
+ },
639
+ "errors": {
640
+ "exitCode": 1,
641
+ "stdout": "empty",
642
+ "stderr": "一条安全错误 JSON,末尾换行。",
643
+ "recovery": "停止并核对原店铺、对象、权限及审计记录,结果未知时不重放,不切换店铺、应用或身份。",
644
+ "diagnosticsVersion": 2
645
+ },
646
+ "notes": [
647
+ "--kdt-id 省略时使用本次有效上下文 shopId;显式提供的非法值不回退。两者都缺失时拒绝;目标范围、同店核验和服务端权限仍按本命令校验。",
648
+ "当前仅本地预览可直接使用,缺少员工字段明文授权、来源绑定和可靠审计的生产 provider;执行在任何业务请求前拒绝,不表示命令全部完成。",
649
+ "输入文件或 stdin 最多 64KiB;一笔订单一至三个字段,拒绝额外属性、重复 JSON 成员、重复 key/field 及非密文。",
650
+ "密文持有权、本地 userId、订单可读或应用 API 权限都不证明员工字段明文权限。",
651
+ "接入后最多四次顺序有赞业务请求,敏感链禁止应用初始化、重发、重定向、换店或身份;累计响应 10MiB,最终输出含换行 5MiB,超限无部分明文。",
652
+ "10800 可能未授权或次数用完;10500 保留处理失败事实,不猜根因。",
653
+ "不新增明文文件、剪贴板或缓存;stdout 可能被终端、重定向或 Agent 保存,不提供批量导出或第三方传输授权。",
654
+ "dry-run 零凭证零网络,计划不包含 key、密文或 reason,也不证明远端对象或授权。"
655
+ ]
656
+ }
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const { object } = require('../../../../execution/query-api');
4
+ const { privacyError } = require('../../../../execution/privacy');
5
+
6
+ const fields = Object.freeze({
7
+ 'address.receiverName': 'receiver_name',
8
+ 'address.receiverPhone': 'receiver_tel',
9
+ 'address.address': 'delivery_address'
10
+ });
11
+ const orderPath = 'youzan.trade.get/4.0.2';
12
+
13
+ async function loadOrderSource(input, read, context, command) {
14
+ const { data, facts } = await read(orderPath, { tid: input.object.orderNo }, 'source-object');
15
+ const full = data?.full_order_info;
16
+ const order = full?.order_info;
17
+ const validId = value => Number.isSafeInteger(value) && value > 0 ||
18
+ typeof value === 'string' && /^[1-9]\d*$/.test(value);
19
+ if (!object(order) || order.tid !== input.object.orderNo || !validId(order.node_kdt_id) ||
20
+ String(order.node_kdt_id) !== input.scope.kdtId ||
21
+ (Object.hasOwn(order, 'root_kdt_id') && (!validId(order.root_kdt_id) || String(order.root_kdt_id) !== context.hq))) {
22
+ throw privacyError(command, 'scope_unresolved', 'source-object', input.scope, 'sent', facts);
23
+ }
24
+ if (!object(full.address_info)) {
25
+ throw privacyError(command, 'source_mismatch', 'source-binding', input.scope, 'sent', facts);
26
+ }
27
+ return { sourceData: data, ciphertexts: input.fields.map(field => {
28
+ const source = fields[field];
29
+ return Object.hasOwn(full.address_info, source) ? full.address_info[source] : undefined;
30
+ }) };
31
+ }
32
+
33
+ module.exports = { fields, orderPath, loadOrderSource };