@v587d/capital-generation 2.28.0 → 2.30.0

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 (302) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +5 -4
  3. package/THIRD_PARTY_NOTICES.md +16 -0
  4. package/automation/package.json +1 -1
  5. package/chart-ui/package.json +1 -1
  6. package/config/package.json +1 -1
  7. package/lib/collector-runtime.js +56 -1
  8. package/lib/data-collector/catalog-taxonomy.d.ts +1 -1
  9. package/lib/data-collector/catalog-taxonomy.js +33 -0
  10. package/lib/data-collector/tools.js +7 -7
  11. package/lib/host-version.d.ts +9 -0
  12. package/lib/host-version.js +57 -0
  13. package/lib/python-runtime/errors.d.ts +1 -1
  14. package/lib/python-runtime/errors.js +2 -0
  15. package/lib/python-runtime/manager.d.ts +28 -1
  16. package/lib/python-runtime/manager.js +141 -5
  17. package/lib/python-runtime/probe.d.ts +24 -0
  18. package/lib/python-runtime/probe.js +66 -50
  19. package/lib/runtime-entry.js +8 -0
  20. package/lib/sources/csindex-http.d.ts +4 -0
  21. package/lib/sources/csindex-http.js +233 -0
  22. package/lib/sources/eastmoney-http.js +1504 -1
  23. package/lib/sources/fuyao-rest.js +168 -8
  24. package/lib/sources/official-http.d.ts +4 -0
  25. package/lib/sources/official-http.js +477 -0
  26. package/lib/sources/python-remote.d.ts +25 -0
  27. package/lib/sources/python-remote.js +461 -0
  28. package/lib/sources/sina-http.d.ts +2 -0
  29. package/lib/sources/sina-http.js +484 -0
  30. package/lib/sources/tencent-http.js +23 -8
  31. package/lib/sources/ths-http.d.ts +2 -0
  32. package/lib/sources/ths-http.js +514 -0
  33. package/lib/time/tools.js +19 -0
  34. package/lib/web-retriever/local-fetch.d.ts +1 -1
  35. package/lib/web-retriever/local-fetch.js +1 -1
  36. package/lib/web-retriever/sources.d.ts +7 -0
  37. package/lib/web-retriever/sources.js +46 -21
  38. package/lib/web-retriever/throttle.d.ts +8 -0
  39. package/lib/web-retriever/throttle.js +13 -0
  40. package/lib/web-retriever/tools.js +1 -1
  41. package/lib/web-retriever/wind-client.d.ts +1 -1
  42. package/lib/web-retriever/wind-client.js +1 -1
  43. package/package.json +6 -3
  44. package/preset/capital-generation/agent.patch.yml +7 -5
  45. package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
  46. package/python/scripts/baostock_stock_basic.py +129 -0
  47. package/python/scripts/baostock_valuation_history.py +141 -0
  48. package/python/scripts/pbc_social_financing.py +291 -0
  49. package/python/vendor/baostock/LICENSE +19 -0
  50. package/python/vendor/baostock/__init__.py +42 -0
  51. package/python/vendor/baostock/common/__init__.py +0 -0
  52. package/python/vendor/baostock/common/contants.py +189 -0
  53. package/python/vendor/baostock/common/context.py +4 -0
  54. package/python/vendor/baostock/corpreport/__init__.py +0 -0
  55. package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
  56. package/python/vendor/baostock/data/__init__.py +0 -0
  57. package/python/vendor/baostock/data/messageheader.py +17 -0
  58. package/python/vendor/baostock/data/msg.py +21 -0
  59. package/python/vendor/baostock/data/resultset.py +200 -0
  60. package/python/vendor/baostock/demo/__init__.py +0 -0
  61. package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
  62. package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
  63. package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
  64. package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
  65. package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
  66. package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
  67. package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
  68. package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
  69. package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
  70. package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
  71. package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
  72. package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
  73. package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
  74. package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
  75. package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
  76. package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
  77. package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
  78. package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
  79. package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
  80. package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
  81. package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
  82. package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
  83. package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
  84. package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
  85. package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
  86. package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
  87. package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
  88. package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
  89. package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
  90. package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
  91. package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
  92. package/python/vendor/baostock/evaluation/__init__.py +0 -0
  93. package/python/vendor/baostock/evaluation/season_index.py +758 -0
  94. package/python/vendor/baostock/login/__init__.py +0 -0
  95. package/python/vendor/baostock/login/loginout.py +230 -0
  96. package/python/vendor/baostock/macroscopic/__init__.py +0 -0
  97. package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
  98. package/python/vendor/baostock/metadata/__init__.py +0 -0
  99. package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
  100. package/python/vendor/baostock/security/__init__.py +0 -0
  101. package/python/vendor/baostock/security/history.py +265 -0
  102. package/python/vendor/baostock/security/sectorinfo.py +1024 -0
  103. package/python/vendor/baostock/util/__init__.py +0 -0
  104. package/python/vendor/baostock/util/socketutil.py +97 -0
  105. package/python/vendor/baostock/util/stringutil.py +83 -0
  106. package/python/vendor/et_xmlfile/LICENSE +23 -0
  107. package/python/vendor/et_xmlfile/LICENSE.python +298 -0
  108. package/python/vendor/et_xmlfile/__init__.py +8 -0
  109. package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
  110. package/python/vendor/et_xmlfile/xmlfile.py +158 -0
  111. package/python/vendor/openpyxl/LICENSE +23 -0
  112. package/python/vendor/openpyxl/__init__.py +19 -0
  113. package/python/vendor/openpyxl/_constants.py +13 -0
  114. package/python/vendor/openpyxl/cell/__init__.py +4 -0
  115. package/python/vendor/openpyxl/cell/_writer.py +136 -0
  116. package/python/vendor/openpyxl/cell/cell.py +332 -0
  117. package/python/vendor/openpyxl/cell/read_only.py +136 -0
  118. package/python/vendor/openpyxl/cell/rich_text.py +202 -0
  119. package/python/vendor/openpyxl/cell/text.py +184 -0
  120. package/python/vendor/openpyxl/chart/_3d.py +105 -0
  121. package/python/vendor/openpyxl/chart/__init__.py +19 -0
  122. package/python/vendor/openpyxl/chart/_chart.py +199 -0
  123. package/python/vendor/openpyxl/chart/area_chart.py +106 -0
  124. package/python/vendor/openpyxl/chart/axis.py +401 -0
  125. package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
  126. package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
  127. package/python/vendor/openpyxl/chart/chartspace.py +195 -0
  128. package/python/vendor/openpyxl/chart/data_source.py +246 -0
  129. package/python/vendor/openpyxl/chart/descriptors.py +43 -0
  130. package/python/vendor/openpyxl/chart/error_bar.py +62 -0
  131. package/python/vendor/openpyxl/chart/label.py +127 -0
  132. package/python/vendor/openpyxl/chart/layout.py +74 -0
  133. package/python/vendor/openpyxl/chart/legend.py +75 -0
  134. package/python/vendor/openpyxl/chart/line_chart.py +129 -0
  135. package/python/vendor/openpyxl/chart/marker.py +90 -0
  136. package/python/vendor/openpyxl/chart/picture.py +35 -0
  137. package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
  138. package/python/vendor/openpyxl/chart/pivot.py +65 -0
  139. package/python/vendor/openpyxl/chart/plotarea.py +162 -0
  140. package/python/vendor/openpyxl/chart/print_settings.py +57 -0
  141. package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
  142. package/python/vendor/openpyxl/chart/reader.py +32 -0
  143. package/python/vendor/openpyxl/chart/reference.py +124 -0
  144. package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
  145. package/python/vendor/openpyxl/chart/series.py +197 -0
  146. package/python/vendor/openpyxl/chart/series_factory.py +41 -0
  147. package/python/vendor/openpyxl/chart/shapes.py +89 -0
  148. package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
  149. package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
  150. package/python/vendor/openpyxl/chart/text.py +78 -0
  151. package/python/vendor/openpyxl/chart/title.py +76 -0
  152. package/python/vendor/openpyxl/chart/trendline.py +98 -0
  153. package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
  154. package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
  155. package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
  156. package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
  157. package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
  158. package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
  159. package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
  160. package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
  161. package/python/vendor/openpyxl/chartsheet/views.py +51 -0
  162. package/python/vendor/openpyxl/comments/__init__.py +4 -0
  163. package/python/vendor/openpyxl/comments/author.py +21 -0
  164. package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
  165. package/python/vendor/openpyxl/comments/comments.py +62 -0
  166. package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
  167. package/python/vendor/openpyxl/compat/__init__.py +54 -0
  168. package/python/vendor/openpyxl/compat/abc.py +8 -0
  169. package/python/vendor/openpyxl/compat/numbers.py +43 -0
  170. package/python/vendor/openpyxl/compat/product.py +17 -0
  171. package/python/vendor/openpyxl/compat/singleton.py +40 -0
  172. package/python/vendor/openpyxl/compat/strings.py +25 -0
  173. package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
  174. package/python/vendor/openpyxl/descriptors/base.py +272 -0
  175. package/python/vendor/openpyxl/descriptors/container.py +41 -0
  176. package/python/vendor/openpyxl/descriptors/excel.py +112 -0
  177. package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
  178. package/python/vendor/openpyxl/descriptors/nested.py +129 -0
  179. package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
  180. package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
  181. package/python/vendor/openpyxl/descriptors/slots.py +18 -0
  182. package/python/vendor/openpyxl/drawing/__init__.py +4 -0
  183. package/python/vendor/openpyxl/drawing/colors.py +435 -0
  184. package/python/vendor/openpyxl/drawing/connector.py +144 -0
  185. package/python/vendor/openpyxl/drawing/drawing.py +92 -0
  186. package/python/vendor/openpyxl/drawing/effect.py +407 -0
  187. package/python/vendor/openpyxl/drawing/fill.py +425 -0
  188. package/python/vendor/openpyxl/drawing/geometry.py +584 -0
  189. package/python/vendor/openpyxl/drawing/graphic.py +177 -0
  190. package/python/vendor/openpyxl/drawing/image.py +65 -0
  191. package/python/vendor/openpyxl/drawing/line.py +144 -0
  192. package/python/vendor/openpyxl/drawing/picture.py +144 -0
  193. package/python/vendor/openpyxl/drawing/properties.py +174 -0
  194. package/python/vendor/openpyxl/drawing/relation.py +17 -0
  195. package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
  196. package/python/vendor/openpyxl/drawing/text.py +717 -0
  197. package/python/vendor/openpyxl/drawing/xdr.py +33 -0
  198. package/python/vendor/openpyxl/formatting/__init__.py +3 -0
  199. package/python/vendor/openpyxl/formatting/formatting.py +114 -0
  200. package/python/vendor/openpyxl/formatting/rule.py +291 -0
  201. package/python/vendor/openpyxl/formula/__init__.py +3 -0
  202. package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
  203. package/python/vendor/openpyxl/formula/translate.py +166 -0
  204. package/python/vendor/openpyxl/packaging/__init__.py +3 -0
  205. package/python/vendor/openpyxl/packaging/core.py +115 -0
  206. package/python/vendor/openpyxl/packaging/custom.py +289 -0
  207. package/python/vendor/openpyxl/packaging/extended.py +137 -0
  208. package/python/vendor/openpyxl/packaging/interface.py +56 -0
  209. package/python/vendor/openpyxl/packaging/manifest.py +194 -0
  210. package/python/vendor/openpyxl/packaging/relationship.py +158 -0
  211. package/python/vendor/openpyxl/packaging/workbook.py +185 -0
  212. package/python/vendor/openpyxl/pivot/__init__.py +1 -0
  213. package/python/vendor/openpyxl/pivot/cache.py +965 -0
  214. package/python/vendor/openpyxl/pivot/fields.py +326 -0
  215. package/python/vendor/openpyxl/pivot/record.py +111 -0
  216. package/python/vendor/openpyxl/pivot/table.py +1261 -0
  217. package/python/vendor/openpyxl/reader/__init__.py +1 -0
  218. package/python/vendor/openpyxl/reader/drawings.py +71 -0
  219. package/python/vendor/openpyxl/reader/excel.py +349 -0
  220. package/python/vendor/openpyxl/reader/strings.py +44 -0
  221. package/python/vendor/openpyxl/reader/workbook.py +133 -0
  222. package/python/vendor/openpyxl/styles/__init__.py +11 -0
  223. package/python/vendor/openpyxl/styles/alignment.py +62 -0
  224. package/python/vendor/openpyxl/styles/borders.py +103 -0
  225. package/python/vendor/openpyxl/styles/builtins.py +1397 -0
  226. package/python/vendor/openpyxl/styles/cell_style.py +206 -0
  227. package/python/vendor/openpyxl/styles/colors.py +172 -0
  228. package/python/vendor/openpyxl/styles/differential.py +95 -0
  229. package/python/vendor/openpyxl/styles/fills.py +224 -0
  230. package/python/vendor/openpyxl/styles/fonts.py +113 -0
  231. package/python/vendor/openpyxl/styles/named_styles.py +282 -0
  232. package/python/vendor/openpyxl/styles/numbers.py +200 -0
  233. package/python/vendor/openpyxl/styles/protection.py +17 -0
  234. package/python/vendor/openpyxl/styles/proxy.py +62 -0
  235. package/python/vendor/openpyxl/styles/styleable.py +151 -0
  236. package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
  237. package/python/vendor/openpyxl/styles/table.py +94 -0
  238. package/python/vendor/openpyxl/utils/__init__.py +17 -0
  239. package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
  240. package/python/vendor/openpyxl/utils/cell.py +240 -0
  241. package/python/vendor/openpyxl/utils/dataframe.py +87 -0
  242. package/python/vendor/openpyxl/utils/datetime.py +140 -0
  243. package/python/vendor/openpyxl/utils/escape.py +43 -0
  244. package/python/vendor/openpyxl/utils/exceptions.py +34 -0
  245. package/python/vendor/openpyxl/utils/formulas.py +24 -0
  246. package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
  247. package/python/vendor/openpyxl/utils/inference.py +60 -0
  248. package/python/vendor/openpyxl/utils/protection.py +22 -0
  249. package/python/vendor/openpyxl/utils/units.py +108 -0
  250. package/python/vendor/openpyxl/workbook/__init__.py +4 -0
  251. package/python/vendor/openpyxl/workbook/_writer.py +197 -0
  252. package/python/vendor/openpyxl/workbook/child.py +166 -0
  253. package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
  254. package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
  255. package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
  256. package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
  257. package/python/vendor/openpyxl/workbook/function_group.py +36 -0
  258. package/python/vendor/openpyxl/workbook/properties.py +151 -0
  259. package/python/vendor/openpyxl/workbook/protection.py +163 -0
  260. package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
  261. package/python/vendor/openpyxl/workbook/views.py +155 -0
  262. package/python/vendor/openpyxl/workbook/web.py +98 -0
  263. package/python/vendor/openpyxl/workbook/workbook.py +438 -0
  264. package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
  265. package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
  266. package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
  267. package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
  268. package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
  269. package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
  270. package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
  271. package/python/vendor/openpyxl/worksheet/controls.py +107 -0
  272. package/python/vendor/openpyxl/worksheet/copier.py +70 -0
  273. package/python/vendor/openpyxl/worksheet/custom.py +35 -0
  274. package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
  275. package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
  276. package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
  277. package/python/vendor/openpyxl/worksheet/errors.py +93 -0
  278. package/python/vendor/openpyxl/worksheet/filters.py +486 -0
  279. package/python/vendor/openpyxl/worksheet/formula.py +51 -0
  280. package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
  281. package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
  282. package/python/vendor/openpyxl/worksheet/merge.py +141 -0
  283. package/python/vendor/openpyxl/worksheet/ole.py +133 -0
  284. package/python/vendor/openpyxl/worksheet/page.py +174 -0
  285. package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
  286. package/python/vendor/openpyxl/worksheet/picture.py +8 -0
  287. package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
  288. package/python/vendor/openpyxl/worksheet/properties.py +97 -0
  289. package/python/vendor/openpyxl/worksheet/protection.py +120 -0
  290. package/python/vendor/openpyxl/worksheet/related.py +17 -0
  291. package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
  292. package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
  293. package/python/vendor/openpyxl/worksheet/table.py +385 -0
  294. package/python/vendor/openpyxl/worksheet/views.py +155 -0
  295. package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
  296. package/python/vendor/openpyxl/writer/__init__.py +1 -0
  297. package/python/vendor/openpyxl/writer/excel.py +295 -0
  298. package/python/vendor/openpyxl/writer/theme.py +291 -0
  299. package/python/vendor/openpyxl/xml/__init__.py +42 -0
  300. package/python/vendor/openpyxl/xml/constants.py +129 -0
  301. package/python/vendor/openpyxl/xml/functions.py +87 -0
  302. package/watchlist/package.json +1 -1
@@ -0,0 +1,461 @@
1
+ import { buildDataKey } from '../data-collector/hub.js';
2
+ export const MAX_BASIC_CODES = 50;
3
+ export const MAX_SOCIAL_FINANCING_MONTHS = 120;
4
+ /** Runtime-side codes that mean "install/fix the analysis environment", not "the request was bad". */
5
+ const RUNTIME_DOWN_CODES = new Set([
6
+ 'data-runtime-not-ready',
7
+ 'runtime-not-ready',
8
+ 'unsupported-platform',
9
+ 'pack-invalid',
10
+ 'pnpm-missing',
11
+ 'permission',
12
+ ]);
13
+ const RUNTIME_HINT = '需要私有 Python 运行时(插件设置 → 分析环境 → 安装 base pack)';
14
+ /** Shanghai-local trading day, no time part. */
15
+ const DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/u;
16
+ const MONTH_PATTERN = /^(\d{4})-(0[1-9]|1[0-2])$/u;
17
+ const BAOSTOCK_CODE_PATTERN = /^(sh|sz)\.(\d{6})$/u;
18
+ function fail(message) {
19
+ throw new Error(message);
20
+ }
21
+ function isRecord(value) {
22
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
23
+ }
24
+ function assertKnownParameters(values, allowed) {
25
+ for (const key of Object.keys(values)) {
26
+ if (!allowed.includes(key) && values[key] !== undefined) {
27
+ fail(`unknown parameter ${key} (allowed: ${allowed.join(', ')})`);
28
+ }
29
+ }
30
+ }
31
+ function text(value, name, maxLength = 64) {
32
+ if (typeof value !== 'string')
33
+ fail(`parameter ${name} must be a string`);
34
+ const trimmed = value.trim();
35
+ if (trimmed.length === 0)
36
+ fail(`parameter ${name} must not be empty`);
37
+ if (trimmed.length > maxLength)
38
+ fail(`parameter ${name} must be at most ${maxLength} characters`);
39
+ return trimmed;
40
+ }
41
+ /** `600519` / `600519.SH` / `sh.600519` → `sh.600519`; Beijing and B-share segments are refused. */
42
+ function normalizeAshareCode(value, name) {
43
+ const raw = text(value, name, 16).toLowerCase();
44
+ if (raw.includes('bj')) {
45
+ fail(`parameter ${name} rejects Beijing Stock Exchange (北交所) codes: BaoStock answers 10004011 股票代码未标识sh或sz; use a Shanghai/Shenzhen A-share code`);
46
+ }
47
+ const match = /^(?:(sh|sz)\.)?(\d{6})(?:\.(sh|sz))?$/u.exec(raw);
48
+ if (match === null) {
49
+ fail(`parameter ${name} must be an A-share code such as 600519, 600519.SH or sh.600519`);
50
+ }
51
+ const supplied = match[1] ?? match[3];
52
+ const digits = match[2];
53
+ let market;
54
+ if (digits.startsWith('60') || digits.startsWith('68'))
55
+ market = 'sh';
56
+ else if (digits.startsWith('00') || digits.startsWith('30'))
57
+ market = 'sz';
58
+ else if (digits[0] === '4' || digits[0] === '8' || digits.startsWith('92')) {
59
+ fail(`parameter ${name} rejects Beijing Stock Exchange (北交所) codes (4/8/92 segments); BaoStock answers 10004011 股票代码未标识sh或sz`);
60
+ }
61
+ else if (digits.startsWith('90') || digits.startsWith('20')) {
62
+ fail(`parameter ${name}: ${digits} is a B-share segment, which BaoStock does not cover (measured: sh.900901 / sz.200002 return 0 rows)`);
63
+ }
64
+ else {
65
+ fail(`parameter ${name}: ${digits} is not a Shanghai/Shenzhen A-share stock code (expected 60xxxx/68xxxx or 00xxxx/30xxxx)`);
66
+ }
67
+ if (supplied !== undefined && supplied !== market) {
68
+ fail(`parameter ${name}: ${digits} is a ${market.toUpperCase()} code, not ${supplied.toUpperCase()}`);
69
+ }
70
+ return `${market}.${digits}`;
71
+ }
72
+ function normalizeDate(value, name) {
73
+ const raw = text(value, name, 10);
74
+ const match = DATE_PATTERN.exec(raw);
75
+ if (match === null)
76
+ fail(`parameter ${name} must be a calendar date in YYYY-MM-DD form`);
77
+ const year = Number(match[1]);
78
+ const month = Number(match[2]);
79
+ const day = Number(match[3]);
80
+ const check = new Date(Date.UTC(year, month - 1, day));
81
+ if (check.getUTCFullYear() !== year || check.getUTCMonth() !== month - 1 || check.getUTCDate() !== day) {
82
+ fail(`parameter ${name} is not a real calendar date: ${raw}`);
83
+ }
84
+ if (year < 1990 || year > 2100)
85
+ fail(`parameter ${name} must be between 1990 and 2100`);
86
+ return raw;
87
+ }
88
+ function normalizeValuationParams(params) {
89
+ const values = isRecord(params) ? params : fail('params must be an object');
90
+ assertKnownParameters(values, ['code', 'start_date', 'end_date']);
91
+ const code = normalizeAshareCode(values.code, 'code');
92
+ const startDate = normalizeDate(values.start_date, 'start_date');
93
+ const endDate = normalizeDate(values.end_date, 'end_date');
94
+ if (startDate > endDate)
95
+ fail('parameter start_date must not be later than end_date');
96
+ return { code, start_date: startDate, end_date: endDate };
97
+ }
98
+ function normalizeBasicParams(params) {
99
+ const values = isRecord(params) ? params : fail('params must be an object');
100
+ assertKnownParameters(values, ['codes']);
101
+ if (!Array.isArray(values.codes))
102
+ fail('parameter codes must be an array of A-share codes');
103
+ if (values.codes.length === 0)
104
+ fail('parameter codes must contain at least one code');
105
+ if (values.codes.length > MAX_BASIC_CODES)
106
+ fail(`parameter codes accepts at most ${MAX_BASIC_CODES} codes per request`);
107
+ const codes = [];
108
+ for (const item of values.codes) {
109
+ const code = normalizeAshareCode(item, 'codes');
110
+ if (!codes.includes(code))
111
+ codes.push(code);
112
+ }
113
+ if (codes.length > MAX_BASIC_CODES)
114
+ fail(`parameter codes accepts at most ${MAX_BASIC_CODES} distinct codes per request`);
115
+ return { codes };
116
+ }
117
+ function normalizeSocialFinancingParams(params) {
118
+ const values = isRecord(params) ? params : fail('params must be an object');
119
+ assertKnownParameters(values, ['months']);
120
+ const months = values.months;
121
+ if (months === undefined)
122
+ return {};
123
+ if (typeof months !== 'number' || !Number.isSafeInteger(months))
124
+ fail('parameter months must be an integer');
125
+ if (months < 1 || months > MAX_SOCIAL_FINANCING_MONTHS) {
126
+ fail(`parameter months must be between 1 and ${MAX_SOCIAL_FINANCING_MONTHS}`);
127
+ }
128
+ return { months };
129
+ }
130
+ function requiredNumber(value, field) {
131
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
132
+ fail(`脚本返回的 ${field} 不是有限数字(${JSON.stringify(value)})`);
133
+ }
134
+ return value;
135
+ }
136
+ function optionalNumber(value, field) {
137
+ if (value === null || value === undefined)
138
+ return null;
139
+ return requiredNumber(value, field);
140
+ }
141
+ function optionalInteger(value, field) {
142
+ if (value === null || value === undefined)
143
+ return null;
144
+ if (typeof value !== 'number' || !Number.isSafeInteger(value)) {
145
+ fail(`脚本返回的 ${field} 不是整数(${JSON.stringify(value)})`);
146
+ }
147
+ return value;
148
+ }
149
+ function optionalFlag(value, field) {
150
+ const flag = optionalInteger(value, field);
151
+ if (flag !== null && flag !== 0 && flag !== 1)
152
+ fail(`脚本返回的 ${field} 不是 0/1(${JSON.stringify(value)})`);
153
+ return flag;
154
+ }
155
+ function rowAt(value, index, capability) {
156
+ if (!isRecord(value))
157
+ fail(`${capability} 脚本返回的第 ${index + 1} 行不是对象`);
158
+ return value;
159
+ }
160
+ function dateCell(value, field) {
161
+ if (typeof value !== 'string' || DATE_PATTERN.exec(value) === null) {
162
+ fail(`脚本返回的 ${field} 不是 YYYY-MM-DD(${JSON.stringify(value)})`);
163
+ }
164
+ return value;
165
+ }
166
+ function optionalDateCell(value, field) {
167
+ if (value === null || value === undefined)
168
+ return null;
169
+ return dateCell(value, field);
170
+ }
171
+ function baostockCodeCell(value, field) {
172
+ if (typeof value !== 'string' || BAOSTOCK_CODE_PATTERN.exec(value) === null) {
173
+ fail(`脚本返回的 ${field} 不是 BaoStock 代码形态(${JSON.stringify(value)})`);
174
+ }
175
+ return value;
176
+ }
177
+ function mapValuationRows(data) {
178
+ if (!Array.isArray(data))
179
+ fail('baostock_valuation_history 脚本没有返回行数组');
180
+ return data.map((item, index) => {
181
+ const row = rowAt(item, index, 'baostock_valuation_history');
182
+ return {
183
+ date: dateCell(row.date, 'date'),
184
+ code: baostockCodeCell(row.code, 'code'),
185
+ close: optionalNumber(row.close, 'close'),
186
+ pe_ttm: optionalNumber(row.pe_ttm, 'pe_ttm'),
187
+ pb_mrq: optionalNumber(row.pb_mrq, 'pb_mrq'),
188
+ ps_ttm: optionalNumber(row.ps_ttm, 'ps_ttm'),
189
+ pcf_ncf_ttm: optionalNumber(row.pcf_ncf_ttm, 'pcf_ncf_ttm'),
190
+ turnover_rate_pct: optionalNumber(row.turnover_rate_pct, 'turnover_rate_pct'),
191
+ trade_status: optionalFlag(row.trade_status, 'trade_status'),
192
+ is_st: optionalFlag(row.is_st, 'is_st'),
193
+ };
194
+ });
195
+ }
196
+ function mapBasicRows(data) {
197
+ if (!Array.isArray(data))
198
+ fail('baostock_stock_basic 脚本没有返回行数组');
199
+ return data.map((item, index) => {
200
+ const row = rowAt(item, index, 'baostock_stock_basic');
201
+ if (typeof row.name !== 'string' || row.name.trim().length === 0) {
202
+ fail(`脚本返回的第 ${index + 1} 行 name 不是非空字符串`);
203
+ }
204
+ return {
205
+ code: baostockCodeCell(row.code, 'code'),
206
+ name: row.name,
207
+ ipo_date: optionalDateCell(row.ipo_date, 'ipo_date'),
208
+ out_date: optionalDateCell(row.out_date, 'out_date'),
209
+ type: optionalInteger(row.type, 'type'),
210
+ status: optionalInteger(row.status, 'status'),
211
+ };
212
+ });
213
+ }
214
+ function monthCell(value, field) {
215
+ if (typeof value !== 'string' || MONTH_PATTERN.exec(value) === null) {
216
+ fail(`脚本返回的 ${field} 不是 YYYY-MM(${JSON.stringify(value)})`);
217
+ }
218
+ return value;
219
+ }
220
+ const SOCIAL_FINANCING_FIELDS = [
221
+ 'afre_total',
222
+ 'rmb_loans',
223
+ 'fx_loans',
224
+ 'entrusted_loans',
225
+ 'trust_loans',
226
+ 'undiscounted_bankers_acceptance',
227
+ 'corporate_bonds',
228
+ 'government_bonds',
229
+ 'equity_financing',
230
+ 'abs_by_depository',
231
+ 'loans_written_off',
232
+ ];
233
+ function mapSocialFinancingRows(data) {
234
+ if (!Array.isArray(data))
235
+ fail('pbc_social_financing 脚本没有返回行数组');
236
+ const rows = data.map((item, index) => {
237
+ const row = rowAt(item, index, 'pbc_social_financing');
238
+ const mapped = { month: monthCell(row.month, 'month') };
239
+ for (const field of SOCIAL_FINANCING_FIELDS) {
240
+ mapped[field] = optionalNumber(row[field], field);
241
+ }
242
+ return mapped;
243
+ });
244
+ for (let index = 1; index < rows.length; index += 1) {
245
+ if (rows[index].month <= rows[index - 1].month) {
246
+ fail(`脚本返回的社融月份不是严格升序:${rows[index - 1].month} → ${rows[index].month}`);
247
+ }
248
+ }
249
+ return rows;
250
+ }
251
+ function numberOrNullSchema(description) {
252
+ return { oneOf: [{ type: 'number' }, { type: 'null' }], description };
253
+ }
254
+ function flagOrNullSchema(description) {
255
+ return { oneOf: [{ type: 'integer', enum: [0, 1] }, { type: 'null' }], description };
256
+ }
257
+ const valuationRowSchema = {
258
+ type: 'object',
259
+ properties: {
260
+ date: { type: 'string', description: '交易日(上海时区日轴)' },
261
+ code: { type: 'string', description: 'BaoStock 形态代码,如 sh.600519' },
262
+ close: numberOrNullSchema('不复权收盘价(adjustflag=3)'),
263
+ pe_ttm: numberOrNullSchema('市盈率 TTM;负值代表亏损,不能直接排序;null=该日无估值'),
264
+ pb_mrq: numberOrNullSchema('市净率 MRQ;null=该日无估值'),
265
+ ps_ttm: numberOrNullSchema('市销率 TTM;null=该日无估值'),
266
+ pcf_ncf_ttm: numberOrNullSchema('市现率 TTM(NCF);null=该日无估值'),
267
+ turnover_rate_pct: numberOrNullSchema('换手率百分数原值(0.2731 = 0.2731%,不是 0.002731)'),
268
+ trade_status: flagOrNullSchema('1=正常交易 0=停牌'),
269
+ is_st: flagOrNullSchema('1=ST/*ST 0=正常;逐日历史标记'),
270
+ },
271
+ required: ['date', 'code', 'close', 'pe_ttm', 'pb_mrq', 'ps_ttm', 'pcf_ncf_ttm', 'turnover_rate_pct', 'trade_status', 'is_st'],
272
+ additionalProperties: false,
273
+ };
274
+ const basicRowSchema = {
275
+ type: 'object',
276
+ properties: {
277
+ code: { type: 'string', description: 'BaoStock 形态代码,如 sh.600519' },
278
+ name: { type: 'string', description: '证券简称' },
279
+ ipo_date: { oneOf: [{ type: 'string' }, { type: 'null' }], description: '上市日 YYYY-MM-DD' },
280
+ out_date: { oneOf: [{ type: 'string' }, { type: 'null' }], description: '退市日 YYYY-MM-DD;在市标的为 null(上游给空字符串)' },
281
+ type: numberOrNullSchema('证券类型:1=股票 2=指数 4=可转债 5=ETF(本能力只接受股票号段,正常为 1)'),
282
+ status: numberOrNullSchema('1=上市 0=退市'),
283
+ },
284
+ required: ['code', 'name', 'ipo_date', 'out_date', 'type', 'status'],
285
+ additionalProperties: false,
286
+ };
287
+ const socialFinancingRowSchema = {
288
+ type: 'object',
289
+ properties: {
290
+ month: { type: 'string', description: '统计月份 YYYY-MM(月频)' },
291
+ afre_total: numberOrNullSchema('社会融资规模增量(亿元)'),
292
+ rmb_loans: numberOrNullSchema('人民币贷款(亿元)'),
293
+ fx_loans: numberOrNullSchema('外币贷款折合人民币(亿元)'),
294
+ entrusted_loans: numberOrNullSchema('委托贷款(亿元)'),
295
+ trust_loans: numberOrNullSchema('信托贷款(亿元)'),
296
+ undiscounted_bankers_acceptance: numberOrNullSchema('未贴现银行承兑汇票(亿元)'),
297
+ corporate_bonds: numberOrNullSchema('企业债券(亿元)'),
298
+ government_bonds: numberOrNullSchema('政府债券(亿元)'),
299
+ equity_financing: numberOrNullSchema('非金融企业境内股票融资(亿元)'),
300
+ abs_by_depository: numberOrNullSchema('存款类金融机构资产支持证券(亿元)'),
301
+ loans_written_off: numberOrNullSchema('贷款核销(亿元)'),
302
+ },
303
+ required: ['month', ...SOCIAL_FINANCING_FIELDS],
304
+ additionalProperties: false,
305
+ };
306
+ function objectSchema(properties, required) {
307
+ return { type: 'object', properties, required, additionalProperties: false };
308
+ }
309
+ function sourceDescriptor(capability, script, rest) {
310
+ return {
311
+ capability,
312
+ name: rest.name,
313
+ source: `python:script.${script}`,
314
+ data_key: buildDataKey('python', 'script', capability),
315
+ source_label: 'python',
316
+ paginated: false,
317
+ cacheMaxAgeMs: rest.cacheMaxAgeMs,
318
+ rowShape: { rootArray: true },
319
+ summary: rest.summary,
320
+ description: rest.description,
321
+ input_schema: rest.input_schema,
322
+ output_schema: rest.output_schema,
323
+ };
324
+ }
325
+ /** Keep the runtime error code on the wrapped failure so the tool layer can classify it. */
326
+ function wrapFailure(capability, error) {
327
+ const message = error instanceof Error ? error.message : String(error);
328
+ const code = isRecord(error) && typeof error.code === 'string' ? error.code : undefined;
329
+ const wrapped = new Error(code !== undefined && RUNTIME_DOWN_CODES.has(code)
330
+ ? `${capability}: ${RUNTIME_HINT}:${message}`
331
+ : `${capability} 的固定 Python 脚本失败:${message}`);
332
+ if (code !== undefined)
333
+ wrapped.code = code;
334
+ return wrapped;
335
+ }
336
+ export function createPythonSources(runner) {
337
+ const run = async (script, params, signal) => {
338
+ let result;
339
+ try {
340
+ result = await runner({ script, params, signal });
341
+ }
342
+ catch (error) {
343
+ throw wrapFailure(script, error);
344
+ }
345
+ if (!isRecord(result) || !Array.isArray(result.rows)) {
346
+ fail(`${script}: runner 没有返回 rows 数组`);
347
+ }
348
+ return result.rows;
349
+ };
350
+ return [
351
+ {
352
+ schema: sourceDescriptor('baostock_valuation_history', 'baostock_valuation_history', {
353
+ name: 'get_baostock_valuation_history',
354
+ summary: 'BaoStock 日频历史估值:PE/PB/PS/PCF + 换手率 + 停牌/ST',
355
+ description: 'BaoStock(TCP 私有协议)日频估值历史,一次取回单只沪深股票一段区间内的每日估值与交易状态。⛔ 需私有 Python 运行时(插件设置 → 分析环境 → 安装 base pack);运行时缺失或脚本失败在调用期响亮报错,不会静默返回空表。代码接受 600519 / 600519.SH / sh.600519(大小写不敏感),内部归一为 BaoStock 形态 sh.600519;⛔ 不支持北交所(4/8/92 号段,服务端 10004011),参数层直接拒绝;B 股(900/200 号段)BaoStock 不覆盖(实测 sh.900901 / sz.200002 返回 0 行),同样拒绝。start_date / end_date 必填且为 YYYY-MM-DD,start_date 不得晚于 end_date。字段口径(实测):close 为不复权收盘价(adjustflag=3);pe_ttm/pb_mrq/ps_ttm/pcf_ncf_ttm 为 PE(TTM)/PB(MRQ)/PS(TTM)/PCF(NCF,TTM),**负值代表亏损,不能直接排序**,停牌日或无估值时该字段为 null(不是 0);turnover_rate_pct 是**百分数原值**(0.2731 = 0.2731%,不是小数比例);trade_status 1=正常交易、0=停牌;is_st 是逐日历史 ST 标记(1=ST/*ST),可用于还原「当时是不是 ST」。服务端无区间/行数上限(实测 2000-01-01..2026-11-21 的 600519 共 6,121 行、1991 起全历史 8,696 行都能一次返回);区间内没有交易日(周末、节假日、未来日期)返回空数组,是合法空结果、不是取数失败。date 是上海时区交易日,按升序排列。',
356
+ input_schema: objectSchema({
357
+ code: { type: 'string', description: '沪深股票代码,接受 600519 / 600519.SH / sh.600519;北交所与 B 股拒绝' },
358
+ start_date: { type: 'string', description: '起始交易日 YYYY-MM-DD(含)' },
359
+ end_date: { type: 'string', description: '结束交易日 YYYY-MM-DD(含)' },
360
+ }, ['code', 'start_date', 'end_date']),
361
+ output_schema: { type: 'array', items: valuationRowSchema },
362
+ cacheMaxAgeMs: 6 * 60 * 60 * 1000,
363
+ }),
364
+ normalizeParams: normalizeValuationParams,
365
+ validateOutput: (data) => {
366
+ try {
367
+ mapValuationRows(data);
368
+ return true;
369
+ }
370
+ catch {
371
+ return false;
372
+ }
373
+ },
374
+ execute: async (request, signal) => {
375
+ const params = normalizeValuationParams(request.params);
376
+ const rows = mapValuationRows(await run('baostock_valuation_history', params, signal));
377
+ for (const row of rows) {
378
+ if (row.code !== params.code)
379
+ fail(`baostock_valuation_history 返回了其他代码的行:${row.code} != ${String(params.code)}`);
380
+ }
381
+ return { data: rows, schema: { type: 'array', items: valuationRowSchema } };
382
+ },
383
+ },
384
+ {
385
+ schema: sourceDescriptor('baostock_stock_basic', 'baostock_stock_basic', {
386
+ name: 'get_baostock_stock_basic',
387
+ summary: 'BaoStock 上市日/退市日/证券类型/上市状态(批量 1..50)',
388
+ description: 'BaoStock(TCP 私有协议)标的的基本信息:上市日、退市日、证券类型与上市状态,批量 1..50 只逐个查询后按请求顺序合并。⛔ 需私有 Python 运行时(插件设置 → 分析环境 → 安装 base pack);运行时缺失在调用期响亮报错。codes 接受 600519 / 600519.SH / sh.600519,内部归一;⛔ 不支持北交所(4/8/92 号段)与 B 股(900/200 号段 BaoStock 无记录)。⛔ **整批原子失败**:任一只代码服务端没有记录(实测 sh.900901 B 股 error_code=0 但返回 0 行)就整批报错并点名缺失代码,不返回「少了几行」的结果——缺口必须由调用方看见。字段口径(实测):code 为 BaoStock 形态;name 为证券简称;ipo_date 为上市日;out_date 为退市日,**在市标的返回 null**(上游给空字符串,本层映射为 null,不是字段缺失);type 1=股票 2=指数 4=可转债 5=ETF(本能力只接受沪深股票号段,正常为 1);status 1=上市 0=退市。',
389
+ input_schema: objectSchema({
390
+ codes: {
391
+ type: 'array',
392
+ minItems: 1,
393
+ maxItems: MAX_BASIC_CODES,
394
+ items: { type: 'string', description: '沪深股票代码,如 600519.SH' },
395
+ description: `1..${MAX_BASIC_CODES} 只沪深股票代码;重复项会去重,任一只无记录则整批失败`,
396
+ },
397
+ }, ['codes']),
398
+ output_schema: { type: 'array', items: basicRowSchema },
399
+ cacheMaxAgeMs: 24 * 60 * 60 * 1000,
400
+ }),
401
+ normalizeParams: normalizeBasicParams,
402
+ validateOutput: (data) => {
403
+ try {
404
+ mapBasicRows(data);
405
+ return true;
406
+ }
407
+ catch {
408
+ return false;
409
+ }
410
+ },
411
+ execute: async (request, signal) => {
412
+ const params = normalizeBasicParams(request.params);
413
+ const requested = params.codes;
414
+ const rows = mapBasicRows(await run('baostock_stock_basic', params, signal));
415
+ const seen = new Set(rows.map((row) => row.code));
416
+ const missing = requested.filter((code) => !seen.has(code));
417
+ if (missing.length > 0)
418
+ fail(`baostock_stock_basic 没有返回这些代码:${missing.join(', ')}`);
419
+ if (rows.length !== requested.length)
420
+ fail(`baostock_stock_basic 返回行数 ${rows.length} 与请求代码数 ${requested.length} 不一致`);
421
+ return { data: rows, schema: { type: 'array', items: basicRowSchema } };
422
+ },
423
+ },
424
+ {
425
+ schema: sourceDescriptor('pbc_social_financing', 'pbc_social_financing', {
426
+ name: 'get_pbc_social_financing',
427
+ summary: '人民银行社会融资规模增量(月度,亿元,2022-01 起)',
428
+ description: '人民银行官网「社会融资规模增量统计表」的月度数据(月频,不是日频信号)。⛔ 需私有 Python 运行时(插件设置 → 分析环境 → 安装 base pack);链路是索引页 → 年份页 →「社会融资规模」专题页 → 第一个 xlsx 附件(openpyxl 解析),任一级结构变化都会响亮报错。单位统一为**亿元**(官方表头「单位:亿元人民币」),**不是万亿元**。参数 months 省略 = 最新年份的全部已发布月份;months=N 时从最新已发布月份往前回溯最多 N 个月(跨年自动取多年)。⛔ 可用历史从 **2022-01** 起:2021 及更早年份的专题页只挂 `.xls`(旧版二进制),本通道的 openpyxl 读不了,因此 months 要得再长也只返回已有月份、不报错。⛔ 未发布月份整行丢弃:表里未发布的月份只有月份、没有数值,本层按 afre_total 为空整行丢弃,不会把 12 行当 12 个月。⛔ Excel 会吃掉 10 月的尾零(`2026.10` 读成浮点 `2026.1`),本层按「单个小数位一律是 x0 月」逐行解析(1 月始终写作 `.01`),跨年工作簿不会错位。afre_total 是**社融增量合计**,不等于其余 10 个分项相加(表内还有未列出的「其他融资」),不要用分项和冒充合计。数值缺失用 null,不补 0。',
429
+ input_schema: objectSchema({
430
+ months: {
431
+ type: 'integer',
432
+ minimum: 1,
433
+ maximum: MAX_SOCIAL_FINANCING_MONTHS,
434
+ description: `回溯最近 N 个月(1..${MAX_SOCIAL_FINANCING_MONTHS});省略 = 最新年份的全部已发布月份`,
435
+ },
436
+ }, []),
437
+ output_schema: { type: 'array', items: socialFinancingRowSchema },
438
+ cacheMaxAgeMs: 6 * 60 * 60 * 1000,
439
+ }),
440
+ normalizeParams: normalizeSocialFinancingParams,
441
+ validateOutput: (data) => {
442
+ try {
443
+ mapSocialFinancingRows(data);
444
+ return true;
445
+ }
446
+ catch {
447
+ return false;
448
+ }
449
+ },
450
+ execute: async (request, signal) => {
451
+ const params = normalizeSocialFinancingParams(request.params);
452
+ const rows = mapSocialFinancingRows(await run('pbc_social_financing', params, signal));
453
+ const months = params.months;
454
+ if (typeof months === 'number' && rows.length > months) {
455
+ fail(`pbc_social_financing 返回 ${rows.length} 行,超过请求的 ${months} 个月`);
456
+ }
457
+ return { data: rows, schema: { type: 'array', items: socialFinancingRowSchema } };
458
+ },
459
+ },
460
+ ];
461
+ }
@@ -0,0 +1,2 @@
1
+ import type { DataSource } from '../data-collector/hub.js';
2
+ export declare function createSinaSources(): DataSource[];