@pointcosm/sdk 0.0.0-stage → 0.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-12-02
4
+
5
+ - Initial TypeScript SDK for the PointCosm customer API: `train`, `storage`, `webhooks` and
6
+ `billing` namespaces plus the preview `livecosm` namespace, covering all 37 operations of
7
+ contract bundle `0.14.0`
8
+ (`pointcosm-sdk-contracts` revision `5c16aa762ae0ada16aaaa021390ee1af0d6bd710`).
9
+ - Static bearer token and server-side client credentials authentication.
10
+ - Envelope and schema checking, typed errors, opt-in retries for safe operations, `Secret`
11
+ wrapping of sensitive response fields, optional `acceptLanguage`, and an optional
12
+ `idempotencyKey` for LiveCosm room creation.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising 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
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 PointCosm
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,135 @@
1
- # Temporary Holding Version
1
+ # PointCosm TypeScript SDK
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
+ Official TypeScript/JavaScript SDK for the PointCosm customer API. [中文文档](README.zh-CN.md)
4
+
5
+ - Node.js 20 or later, using the built-in `fetch`. ESM and CommonJS builds, bundled types.
6
+ - No runtime dependencies.
7
+ - Five namespaces covering all 37 customer operations: `train`, `storage`, `webhooks`, `billing`
8
+ and the preview `livecosm`.
9
+
10
+ Status: 0.1.0, early release. The API may change before 1.0.
11
+
12
+ ## Usage
13
+
14
+ ```sh
15
+ npm install @pointcosm/sdk
16
+ ```
17
+
18
+ ```ts
19
+ import { Pointcosm } from "@pointcosm/sdk";
20
+
21
+ const client = Pointcosm.fromClientCredentials({
22
+ baseUrl: "https://api.pointcosm.cn",
23
+ authBaseUrl: process.env.POINTCOSM_AUTH_URL!,
24
+ clientId: process.env.POINTCOSM_CLIENT_ID!,
25
+ clientSecret: process.env.POINTCOSM_CLIENT_SECRET!,
26
+ resource: process.env.POINTCOSM_RESOURCE!,
27
+ });
28
+
29
+ const products = await client.train.listProducts({ limit: 20 });
30
+ const { asset } = await client.storage.createAsset({ product_id: products.items[0]!.id, name: "building-a" });
31
+ ```
32
+
33
+ `baseUrl` and `authBaseUrl` have no defaults; pass the site you use (for example
34
+ `https://api.pointcosm.cn` or `https://api.pointcosm.ai`).
35
+
36
+ With a token you already hold:
37
+
38
+ ```ts
39
+ const client = new Pointcosm({ baseUrl: "https://api.pointcosm.cn", accessToken });
40
+ ```
41
+
42
+ `fromClientCredentials` is for servers only and throws in a browser. Tokens are fetched on first
43
+ use, cached in memory only, refreshed shortly before expiry, and dropped by `client.close()`.
44
+
45
+ ## Operations
46
+
47
+ | Namespace | Methods |
48
+ |---|---|
49
+ | `client.train` | `listProducts`, `getProduct`, `createTask`, `listTasks`, `getTask`, `getTaskFinalization`, `cancelTask`, `deleteTask`, `listArtifacts`, `createArtifactDownloadUrl` |
50
+ | `client.storage` | `createAsset`, `listAssets`, `createAssetCredentials`, `completeAssetUpload`, `getAsset`, `listAssetFiles`, `checkAssetAdmission`, `deleteAsset` |
51
+ | `client.webhooks` | `getConfiguration`, `updateConfiguration`, `disableConfiguration`, `rotateSecret` |
52
+ | `client.billing` | `getGreenPointAccount`, `listGreenPointLedger`, `listGreenPointPurchaseOrders` |
53
+ | `client.livecosm` (preview) | `getConfig`, `listScenes`, `registerScene`, `revokeScene`, `createRoom`, `listRooms`, `getRoom`, `stopRoom`, `createGuestLink`, `createHostLink`, `listMembers`, `removeMember` |
54
+
55
+ Methods return the decoded `data` of the response envelope. Request and response fields keep the
56
+ API's `snake_case` names; types are exported under their contract names (`TaskOut`, `AssetOut`,
57
+ …). UUIDs and timestamps are strings. Unknown response fields are kept; a missing required field
58
+ or an unknown value of a closed enum raises `PointcosmContractError`.
59
+
60
+ Asset creation is direct upload only. `admissible: false` from an admission check is a normal
61
+ return value, not an error.
62
+
63
+ ### LiveCosm (preview)
64
+
65
+ `client.livecosm` may change in a minor release. In production it returns 403 until the service
66
+ is deployed and your credentials are granted access.
67
+
68
+ ```ts
69
+ const artifacts = await client.train.listArtifacts(taskId);
70
+ const file = artifacts.items.find((item) => item.stream_registerable)!;
71
+ const scene = await client.livecosm.registerScene({
72
+ asset_id: file.asset_id!,
73
+ key: file.key!,
74
+ source: artifacts.pipeline_code!,
75
+ });
76
+ const room = await client.livecosm.createRoom(
77
+ { model_id: scene.id, duration_hours: 1 },
78
+ { idempotencyKey: crypto.randomUUID() },
79
+ );
80
+ ```
81
+
82
+ `createRoom` spends green points and is never retried automatically. Repeat it with the same
83
+ `idempotencyKey` (16–128 characters of `[A-Za-z0-9_-]`) to avoid a second charge. A room's
84
+ `viewers` of `null` or absent means unknown, not zero.
85
+
86
+ ## Secrets
87
+
88
+ Signed download URLs, storage credentials, webhook secrets, the webhook URL, LiveCosm guest
89
+ passwords and host links are returned as
90
+ `Secret`. They print as `[REDACTED]` in strings, JSON and `console.log`; call `.reveal()` to get
91
+ the value. The SDK writes no logs. A custom `fetch` sees tokens and full payloads, so treat it
92
+ as part of your own security boundary.
93
+
94
+ ## Errors
95
+
96
+ All errors extend `PointcosmError`.
97
+
98
+ | Class | When |
99
+ |---|---|
100
+ | `PointcosmAuthenticationError` | HTTP 401, or rejected client credentials |
101
+ | `PointcosmAuthorizationError` | HTTP 403 |
102
+ | `PointcosmValidationError` | HTTP 422 |
103
+ | `PointcosmRateLimitError` | HTTP 429 |
104
+ | `PointcosmServerError` | HTTP 5xx |
105
+ | `PointcosmApiError` | Any other API failure; base of the five above |
106
+ | `PointcosmTimeoutError` | The request timed out |
107
+ | `PointcosmTransportError` | No HTTP response was received |
108
+ | `PointcosmContractError` | The response did not match the contract |
109
+ | `PointcosmConfigurationError` | Invalid options, or a call after `close()` |
110
+
111
+ API errors expose `statusCode`, `code`, `message`, `details`, `requestId`, `operationId` and
112
+ `localizedMessage`. `message` is always the English developer message. Pass
113
+ `acceptLanguage: "zh-Hans" | "zh-Hant" | "en-US"` to the client to receive an end-user message
114
+ in `localizedMessage`.
115
+
116
+ ## Timeouts and retries
117
+
118
+ `timeoutMs` (default 30000) applies to each attempt. Retries are off by default. Setting
119
+ `retry: { maxAttempts: 3 }` retries only operations the contract marks safe, and only on
120
+ connection errors, timeouts and HTTP 429/502/503/504, with jittered backoff bounded by
121
+ `maxElapsedMs`. Task creation, cancellation, deletion, room creation and secret-issuing calls are never retried.
122
+
123
+ ## Contract
124
+
125
+ Pinned to `pointcosm-sdk-contracts` revision `5c16aa762ae0ada16aaaa021390ee1af0d6bd710`, bundle
126
+ `0.14.0`; the same values are exported as `CONTRACT`. Types are generated with
127
+ openapi-typescript 7.13.0. The build never fetches a contract from the network.
128
+
129
+ ```sh
130
+ node scripts/import-contract-bundle.mjs ../pointcosm-sdk-contracts --revision <commit>
131
+ npm run generate
132
+ npm run check # generate:check, typecheck, test, build
133
+ ```
134
+
135
+ Building locally does not authorize publishing to npm.
@@ -0,0 +1,129 @@
1
+ # PointCosm TypeScript SDK
2
+
3
+ PointCosm 客户 API 的官方 TypeScript/JavaScript SDK。[English](README.md)
4
+
5
+ - 需要 Node.js 20 及以上,使用内置 `fetch`;同时提供 ESM 和 CommonJS,自带类型声明。
6
+ - 没有运行时依赖。
7
+ - 五个命名空间覆盖全部 37 个客户接口:`train`、`storage`、`webhooks`、`billing`,以及预览阶段的
8
+ `livecosm`。
9
+
10
+ 状态:0.1.0,早期版本,1.0 之前接口可能调整。
11
+
12
+ ## 使用
13
+
14
+ ```sh
15
+ npm install @pointcosm/sdk
16
+ ```
17
+
18
+ ```ts
19
+ import { Pointcosm } from "@pointcosm/sdk";
20
+
21
+ const client = Pointcosm.fromClientCredentials({
22
+ baseUrl: "https://api.pointcosm.cn",
23
+ authBaseUrl: process.env.POINTCOSM_AUTH_URL!,
24
+ clientId: process.env.POINTCOSM_CLIENT_ID!,
25
+ clientSecret: process.env.POINTCOSM_CLIENT_SECRET!,
26
+ resource: process.env.POINTCOSM_RESOURCE!,
27
+ });
28
+
29
+ const products = await client.train.listProducts({ limit: 20 });
30
+ const { asset } = await client.storage.createAsset({ product_id: products.items[0]!.id, name: "building-a" });
31
+ ```
32
+
33
+ `baseUrl` 和 `authBaseUrl` 没有默认值,请传入所用站点的地址(例如 `https://api.pointcosm.cn`
34
+ 或 `https://api.pointcosm.ai`)。
35
+
36
+ 已有令牌时:
37
+
38
+ ```ts
39
+ const client = new Pointcosm({ baseUrl: "https://api.pointcosm.cn", accessToken });
40
+ ```
41
+
42
+ `fromClientCredentials` 只用于服务端,在浏览器中调用会抛出异常。令牌在首次请求时获取,只缓存在
43
+ 内存中,临近过期时自动刷新,`client.close()` 会清除缓存。
44
+
45
+ ## 接口
46
+
47
+ | 命名空间 | 方法 |
48
+ |---|---|
49
+ | `client.train` | `listProducts`、`getProduct`、`createTask`、`listTasks`、`getTask`、`getTaskFinalization`、`cancelTask`、`deleteTask`、`listArtifacts`、`createArtifactDownloadUrl` |
50
+ | `client.storage` | `createAsset`、`listAssets`、`createAssetCredentials`、`completeAssetUpload`、`getAsset`、`listAssetFiles`、`checkAssetAdmission`、`deleteAsset` |
51
+ | `client.webhooks` | `getConfiguration`、`updateConfiguration`、`disableConfiguration`、`rotateSecret` |
52
+ | `client.billing` | `getGreenPointAccount`、`listGreenPointLedger`、`listGreenPointPurchaseOrders` |
53
+ | `client.livecosm`(预览) | `getConfig`、`listScenes`、`registerScene`、`revokeScene`、`createRoom`、`listRooms`、`getRoom`、`stopRoom`、`createGuestLink`、`createHostLink`、`listMembers`、`removeMember` |
54
+
55
+ 方法返回响应 envelope 中解码后的 `data`。请求和响应字段保持 API 的 `snake_case` 命名;类型按合同
56
+ 中的名称导出(`TaskOut`、`AssetOut` 等)。UUID 和时间为字符串。响应中的未知字段会保留;缺少必填
57
+ 字段或封闭枚举出现未知值时抛出 `PointcosmContractError`。
58
+
59
+ 创建素材只支持直传。准入检查返回 `admissible: false` 是正常返回值,不是异常。
60
+
61
+ ### LiveCosm(预览阶段)
62
+
63
+ `client.livecosm` 的接口可能在次版本中调整。生产环境需等服务端部署并为凭证授权后才可调用,
64
+ 此前返回 403。
65
+
66
+ ```ts
67
+ const artifacts = await client.train.listArtifacts(taskId);
68
+ const file = artifacts.items.find((item) => item.stream_registerable)!;
69
+ const scene = await client.livecosm.registerScene({
70
+ asset_id: file.asset_id!,
71
+ key: file.key!,
72
+ source: artifacts.pipeline_code!,
73
+ });
74
+ const room = await client.livecosm.createRoom(
75
+ { model_id: scene.id, duration_hours: 1 },
76
+ { idempotencyKey: crypto.randomUUID() },
77
+ );
78
+ ```
79
+
80
+ `createRoom` 会扣绿点,SDK 不会自动重试。需要重试时传入同一个 `idempotencyKey`(16 到 128 位
81
+ 字母、数字、`_`、`-`),不会重复扣费。房间的 `viewers` 为 `null` 或缺省表示未知,不表示 0。
82
+
83
+ ## 敏感数据
84
+
85
+ 签名下载地址、存储凭证、Webhook 密钥、Webhook 地址、LiveCosm 访客密码和房主链接以 `Secret` 返回,在字符串、JSON 和
86
+ `console.log` 中显示为 `[REDACTED]`,调用 `.reveal()` 取得原值。SDK 不写任何日志。自定义 `fetch`
87
+ 能看到令牌和完整请求响应,属于调用方自己的安全边界。
88
+
89
+ ## 异常
90
+
91
+ 所有异常都继承 `PointcosmError`。
92
+
93
+ | 类 | 触发条件 |
94
+ |---|---|
95
+ | `PointcosmAuthenticationError` | HTTP 401,或客户端凭证被拒绝 |
96
+ | `PointcosmAuthorizationError` | HTTP 403 |
97
+ | `PointcosmValidationError` | HTTP 422 |
98
+ | `PointcosmRateLimitError` | HTTP 429 |
99
+ | `PointcosmServerError` | HTTP 5xx |
100
+ | `PointcosmApiError` | 其他 API 失败;以上五类的基类 |
101
+ | `PointcosmTimeoutError` | 请求超时 |
102
+ | `PointcosmTransportError` | 未收到 HTTP 响应 |
103
+ | `PointcosmContractError` | 响应不符合合同 |
104
+ | `PointcosmConfigurationError` | 配置无效,或在 `close()` 之后调用 |
105
+
106
+ API 异常提供 `statusCode`、`code`、`message`、`details`、`requestId`、`operationId` 和
107
+ `localizedMessage`。`message` 始终是英文开发者信息;构造客户端时传
108
+ `acceptLanguage: "zh-Hans" | "zh-Hant" | "en-US"`,可在 `localizedMessage` 中得到面向最终用户
109
+ 的文案。
110
+
111
+ ## 超时与重试
112
+
113
+ `timeoutMs`(默认 30000)作用于每次尝试。重试默认关闭。设置 `retry: { maxAttempts: 3 }` 后,
114
+ 只有合同标记为安全的接口会重试,且仅限连接错误、超时和 HTTP 429/502/503/504,使用带抖动的退避,
115
+ 总耗时不超过 `maxElapsedMs`。创建任务、取消、删除、创建房间和签发密钥类接口永不重试。
116
+
117
+ ## 合同
118
+
119
+ 固定在 `pointcosm-sdk-contracts` 提交 `5c16aa762ae0ada16aaaa021390ee1af0d6bd710`、bundle
120
+ `0.14.0`,同样的值通过 `CONTRACT` 导出。类型由 openapi-typescript 7.13.0 生成。构建过程不会联网
121
+ 获取合同。
122
+
123
+ ```sh
124
+ node scripts/import-contract-bundle.mjs ../pointcosm-sdk-contracts --revision <commit>
125
+ npm run generate
126
+ npm run check # generate:check、typecheck、test、build
127
+ ```
128
+
129
+ 本地构建不代表获得 npm 发布授权。