ultrastiching-cli 0.0.0-stage → 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,186 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
21
+ such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source,
28
+ and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled
32
+ object code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work (an example is provided in the Appendix
37
+ below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form,
40
+ that is based on (or derived from) the Work and for which the editorial
41
+ revisions, annotations, elaborations, or other modifications represent, as a
42
+ whole, an original work of authorship. For the purposes of this License,
43
+ Derivative Works shall not include works that remain separable from, or
44
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
45
+ Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the original
48
+ version of the Work and any modifications or additions to that Work or
49
+ Derivative Works thereof, that is intentionally submitted to Licensor for
50
+ inclusion in the Work by the copyright owner or by an individual or Legal
51
+ Entity authorized to submit on behalf of the copyright owner. For the
52
+ purposes of this definition, "submitted" means any form of electronic,
53
+ verbal, or written communication sent to the Licensor or its representatives,
54
+ including but not limited to communication on electronic mailing lists, source
55
+ code control systems, and issue tracking systems that are managed by, or on
56
+ behalf of, the Licensor for the purpose of discussing and improving the Work,
57
+ but excluding communication that is conspicuously marked or otherwise
58
+ designated in writing by the copyright owner as "Not a Contribution."
59
+
60
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
61
+ behalf of whom a Contribution has been received by Licensor and subsequently
62
+ incorporated within the Work.
63
+
64
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
65
+ License, each Contributor hereby grants to You a perpetual, worldwide,
66
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
67
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
68
+ sublicense, and distribute the Work and such Derivative Works in Source or
69
+ Object form.
70
+
71
+ 3. Grant of Patent License. Subject to the terms and conditions of this
72
+ License, each Contributor hereby grants to You a perpetual, worldwide,
73
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
74
+ section) patent license to make, have made, use, offer to sell, sell, import,
75
+ and otherwise transfer the Work, where such license applies only to those
76
+ patent claims licensable by such Contributor that are necessarily infringed
77
+ by their Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You institute
79
+ patent litigation against any entity (including a cross-claim or counterclaim
80
+ in a lawsuit) alleging that the Work or a Contribution incorporated within
81
+ the Work constitutes direct or contributory patent infringement, then any
82
+ patent licenses granted to You under this License for that Work shall
83
+ terminate as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
86
+ Derivative Works thereof in any medium, with or without modifications, and in
87
+ Source or Object form, provided that You meet the following conditions:
88
+
89
+ (a) You must give any other recipients of the Work or Derivative Works a copy
90
+ of this License; and
91
+
92
+ (b) You must cause any modified files to carry prominent notices stating that
93
+ You changed the files; and
94
+
95
+ (c) You must retain, in the Source form of any Derivative Works that You
96
+ distribute, all copyright, patent, trademark, and attribution notices from the
97
+ Source form of the Work, excluding those notices that do not pertain to any
98
+ part of the Derivative Works; and
99
+
100
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
101
+ then any Derivative Works that You distribute must include a readable copy of
102
+ the attribution notices contained within such NOTICE file, excluding those
103
+ notices that do not pertain to any part of the Derivative Works, in at least
104
+ one of the following places: within a NOTICE text file distributed as part of
105
+ the Derivative Works; within the Source form or documentation, if provided
106
+ along with the Derivative Works; or, within a display generated by the
107
+ Derivative Works, if and wherever such third-party notices normally appear.
108
+ The contents of the NOTICE file are for informational purposes only and do
109
+ not modify the License. You may add Your own attribution notices within
110
+ Derivative Works that You distribute, alongside or as an addendum to the
111
+ NOTICE text from the Work, provided that such additional attribution notices
112
+ cannot be construed as modifying the License.
113
+
114
+ You may add Your own copyright statement to Your modifications and may
115
+ provide additional or different license terms and conditions for use,
116
+ reproduction, or distribution of Your modifications, or for any such
117
+ Derivative Works as a whole, provided Your use, reproduction, and distribution
118
+ of the Work otherwise complies with the conditions stated in this License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
121
+ Contribution intentionally submitted for inclusion in the Work by You to the
122
+ Licensor shall be under the terms and conditions of this License, without any
123
+ additional terms or conditions. Notwithstanding the above, nothing herein
124
+ shall supersede or modify the terms of any separate license agreement you may
125
+ have executed with Licensor regarding such Contributions.
126
+
127
+ 6. Trademarks. This License does not grant permission to use the trade names,
128
+ trademarks, service marks, or product names of the Licensor, except as
129
+ required for reasonable and customary use in describing the origin of the Work
130
+ and reproducing the content of the NOTICE file.
131
+
132
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
133
+ writing, Licensor provides the Work (and each Contributor provides its
134
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
135
+ KIND, either express or implied, including, without limitation, any warranties
136
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
137
+ PARTICULAR PURPOSE. You are solely responsible for determining the
138
+ appropriateness of using or redistributing the Work and assume any risks
139
+ associated with Your exercise of permissions under this License.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
142
+ tort (including negligence), contract, or otherwise, unless required by
143
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
144
+ writing, shall any Contributor be liable to You for damages, including any
145
+ direct, indirect, special, incidental, or consequential damages of any
146
+ character arising as a result of this License or out of the use or inability
147
+ to use the Work (including but not limited to damages for loss of goodwill,
148
+ work stoppage, computer failure or malfunction, or any and all other
149
+ commercial damages or losses), even if such Contributor has been advised of
150
+ the possibility of such damages.
151
+
152
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work
153
+ or Derivative Works thereof, You may choose to offer, and charge a fee for,
154
+ acceptance of support, warranty, indemnity, or other liability obligations
155
+ and/or rights consistent with this License. However, in accepting such
156
+ obligations, You may act only on Your own behalf and on Your sole
157
+ responsibility, not on behalf of any other Contributor, and only if You agree
158
+ to indemnify, defend, and hold each Contributor harmless for any liability
159
+ incurred by, or claims asserted against, such Contributor by reason of your
160
+ accepting any such warranty or additional liability.
161
+
162
+ END OF TERMS AND CONDITIONS
163
+
164
+ APPENDIX: How to apply the Apache License to your work.
165
+
166
+ To apply the Apache License to your work, attach the following boilerplate
167
+ notice, with the fields enclosed by brackets "[]" replaced with your own
168
+ identifying information. (Don't include the brackets!) The text should be
169
+ enclosed in the appropriate comment syntax for the file format. We also
170
+ recommend that a file or class name and description of purpose be included on
171
+ the same "printed page" as the copyright notice for easier identification
172
+ within third-party archives.
173
+
174
+ Copyright [yyyy] [name of copyright owner]
175
+
176
+ Licensed under the Apache License, Version 2.0 (the "License");
177
+ you may not use this file except in compliance with the License.
178
+ You may obtain a copy of the License at
179
+
180
+ http://www.apache.org/licenses/LICENSE-2.0
181
+
182
+ Unless required by applicable law or agreed to in writing, software
183
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
184
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
185
+ See the License for the specific language governing permissions and
186
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,60 @@
1
- # Temporary Holding Version
1
+ # ultrastiching-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ UltraStiching 数据 API 的 Node.js 命令行入口。要求 Node.js 22.12 或更高版本。实现 `doctor`、`list`、`info`、`call`、`arrow`、`ws newsflash`、`datasets` 和 `db`。本地数据库与 Python SDK 共用 DuckDB 文件,同步与校验行为见下文。14 个预设的数据完整同步仍待服务端验证,现阶段不把单次成功响应当作完整历史。
4
+
5
+ 发行包名为 `ultrastiching-cli`,安装后的命令为 `ultrastiching`。内部源码目录和现有配置名称保持原样。
6
+
7
+ ## 安装与离线发现
8
+
9
+ 从 npm 安装指定版本:
10
+
11
+ ```bash
12
+ npm install -g ultrastiching-cli@0.1.1
13
+ ultrastiching --help
14
+ ultrastiching list --search 交易日历
15
+ ultrastiching info plasma_trade_cal
16
+ ```
17
+
18
+ `list` 和 `info` 使用随包携带的目录,不需要 API Key,不发送业务请求。也可安装维护者提供的包:`npm install -g ./ultrastiching-cli-0.1.1.tgz`。源码环境使用下面的安装方式:
19
+
20
+ ```bash
21
+ cd meridian-cli
22
+ npm install
23
+ npm link
24
+ ultrastiching list --search 交易日历
25
+ ultrastiching info plasma_trade_cal
26
+ ultrastiching call plasma_trade_cal --start-date 20260901 --end-date 20260918 --out calendar.json
27
+ ultrastiching arrow get_s_stockname --args '{"params":{"code":["600745.SH"]},"fields":["code"]}' --out stockname.arrow
28
+ ultrastiching ws newsflash --limit 10 --count 10
29
+ ultrastiching datasets
30
+ ultrastiching db init
31
+ ultrastiching db sync --dataset concept_index_daily --concept-code '<实际概念指数代码>' --limit 100 --start 20260901 --end 20260918
32
+ ultrastiching db status
33
+ ultrastiching db validate
34
+ ultrastiching db repair --dataset concept_index_daily
35
+ ultrastiching db sql --query 'SELECT * FROM concept_index_daily LIMIT 5'
36
+ ultrastiching db export --table concept_index_daily --path concept.csv
37
+ ```
38
+
39
+ `call` 按仓库根目录 `registry/endpoints.json` 中的真实路径和 payload 模板发起请求。参数名称与 Python SDK 方法一致:`--start-date` 和 `--start_date` 均映射到 `start_date`。`--args` 接收参数名到值的 JSON 对象;同名命令行参数覆盖 `--args` 中的值。对于请求模板中的 `symbols`,单个字符串会成为单元素数组,逗号分隔的字符串会拆为数组。其他参数依注册表中的类型解析;复杂值可直接在 `--args` 中使用 JSON 数组或对象。`info` 输出完整的字段、来源与验证标记,使用前请核对该端点的实际请求形状。
40
+
41
+ API Key 优先级为 `--key`、`MERIDIAN_API_KEY`、`~/.meridian/credentials.env`。文件回退要求用户所有、权限为 `0600` 或更严,且 `~/.meridian` 不可由其他用户写入。HTTP 地址优先级为 `--base-url`、`MERIDIAN_BASE_URL`、`https://api.ultrastiching.com`。WebSocket 默认使用注册表中的 `wss://ws.ultrastiching.com`,可用 `--ws-base-url` 覆盖。`doctor` 默认只查本地 Key、注册表及 DuckDB 依赖/版本;`doctor --probe` 在有 Key 时调用一个已登记的示例端点,因而会产生真实 API 请求。
42
+
43
+ HTTP 结果按服务端 `Content-Type` 处理:JSON 输出到终端,已知数组超过 500 行时自动写入 `meridian-out/`;Arrow IPC 原始字节写入 `--out` 指定文件,未指定时写入 `meridian-out/`。`call` 和 `arrow` 保留原始 IPC,不解码。`db sync` 使用 `apache-arrow` 解码表格,并使用 `@duckdb/node-api` 写入与 Python 相同的数据库结构;WebSocket 使用 `ws` 在握手时发送 Bearer 头;Node 内建 `fetch` 负责 HTTP。三者是包的直接依赖。`npm pack` 时 `prepack` 从仓库根复制端点及数据集注册表快照到包内;发布前必须先运行生成链并核对快照。
44
+
45
+ 数据库路径优先级为 `--db`、`MERIDIAN_DB`、`~/.meridian/marketdb.duckdb`。`db sync` 保留每次请求的 run/chunk 日志;只有服务端给出的分页元数据与请求和行数逐页吻合,才将该请求范围内的数据写入类型化业务表。Arrow 流没有分页证明时返回 `incomplete`、写入 0 行,CLI 退出码为 2。Arrow int64 超出 JavaScript 精确整数范围时显式报错并记录 `failed`,避免改变数值类型或精度。当前同步在提交前把已验证的所有页保存在进程内存中;单个 run 超过 100,000 行或 64 MiB 规范 JSON 时显式失败,单次响应仍可能在检查前占用更多内存。`db validate` 有问题或 `db repair` 后仍未完整时也返回退出码 2。`repair` 仅重试每个数据集最新的失败或未完整请求,复用日志中的原参数。14 个预设的真实服务端分页、限行和键唯一性尚未逐项验证,真实完整历史能力仍需后续核实。
46
+
47
+ 默认不自动重试。HTTP 非 2xx 错误保留状态、服务端 `error`、`X-Meridian-Request-ID` 和原始响应体;终端输出仅替换当前 API Key 的字面值。不要把含敏感信息的完整原始错误对象转存到公开日志。离线测试运行 `npm test`;设置 `MERIDIAN_TEST_PYTHON` 和可选的 `MERIDIAN_TEST_PYTHON39` 为装有本仓库 Python SDK 及 DuckDB 的解释器路径,可额外执行跨语言同文件测试。未配置时只跳过跨语言用例。尚未用测试或正式环境 Key 验收真实端点、WebSocket 和服务限制。
48
+
49
+ 环境变量与私有凭据文件任选一种;CLI 不会自动加载项目 `.env`,`.env.example` 只是模板。用户在 CLI 执行环境配置现有 `MERIDIAN_API_KEY`,或使用前文说明的私有凭据文件。直接调用业务接口前需要配置有效 Key:
50
+
51
+ ```bash
52
+ export MERIDIAN_API_KEY='<your-api-key>'
53
+ ultrastiching call tracer_newsflash --limit 20
54
+ ```
55
+
56
+ 许可证:Apache-2.0,见本目录 `LICENSE`。
57
+
58
+ ## 2026-10-07 目录
59
+
60
+ 当前包携带 2051 个 HTTP 与 1 个 WebSocket 端点。主题 GET 使用 `tracer_` 名称,例如 `ultrastiching call tracer_newsflash --limit 20 --important-only false`、`ultrastiching call tracer_report --id 123`。`--from` 对应 GET 时间下界(Python 使用 `from_`);请求按公开契约编码路径/查询参数,不发送 GET 请求体。两个 SSE 可用 `info` 查契约,`call` 不支持持续流。金融 POST 使用平铺字段,Arrow 包装使用 `handler/params/fields`。
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { main } from '../src/main.js';
3
+
4
+ main(process.argv.slice(2)).then((result) => {
5
+ if (result?.exitCode) process.exitCode = result.exitCode;
6
+ }).catch((error) => {
7
+ const details = error.toDiagnostic?.() ?? { type: error.name, message: error.message };
8
+ process.stderr.write(`${JSON.stringify(details, null, 2)}\n`);
9
+ process.exitCode = 1;
10
+ });
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "ultrastiching-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "UltraStiching data API command line client",
5
+ "type": "module",
6
+ "bin": {
7
+ "ultrastiching": "./bin/meridian.js"
8
+ },
9
+ "engines": {
10
+ "node": ">=22.12.0"
11
+ },
12
+ "license": "Apache-2.0",
13
+ "files": [
14
+ "bin",
15
+ "src",
16
+ "registry",
17
+ "LICENSE",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "test": "node --test",
22
+ "prepack": "node scripts/prepare-registry.js"
23
+ },
24
+ "dependencies": {
25
+ "@duckdb/node-api": "1.5.5-r.5",
26
+ "apache-arrow": "21.2.0",
27
+ "ws": "^8.18.0"
28
+ }
29
+ }