@leaflow/sdk 0.0.0-dev.13.g732c6b7 → 0.0.0-dev.16.gac94fbe

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 (2) hide show
  1. package/README.md +22 -12
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,24 +1,34 @@
1
1
  # leaflow-ts
2
2
 
3
- Leaflow 平台的 TypeScript SDK(`@leaflow/sdk`)
4
- `gen/` 下全是产物,源在 `LeaflowNET/leaflowapis`。
3
+ Leaflow 平台的 TypeScript SDK(`@leaflow/sdk`),由
4
+ [leaflowapis](https://github.com/leaflowapis/leaflowapis) 生成。
5
5
 
6
- ## 为什么和 Go 分开在两个仓库
6
+ ```
7
+ npm i @leaflow/sdk openapi-fetch
8
+ ```
7
9
 
8
- **它们在同一个仓库里会抢同一个 tag 空间。** Go 的子目录模块要 `go/v1.2.3` 这种带前缀的 tag,
9
- npm 要 `v1.2.3`——上一版两者挤在一个仓库里,结果是 Go 那半从来没被正确发布过,而没有任何东西
10
- 会报错(`go get` 只是拿不到)。
10
+ 当前只含类型。请求由 `openapi-fetch` 发出,路径与参数由契约约束。
11
11
 
12
- ## 契约是一个 submodule
12
+ ```ts
13
+ import createClient from 'openapi-fetch';
14
+ import type { compute } from '@leaflow/sdk';
13
15
 
16
+ const api = createClient<compute.paths>({
17
+ baseUrl: 'https://compute.leaflow.cloud',
18
+ headers: { Authorization: `Bearer ${token}` },
19
+ });
20
+
21
+ const { data, error } = await api.GET('/api/v1/instances', {
22
+ params: { query: { limit: 20 } },
23
+ });
14
24
  ```
15
- leaflowapis/ 钉在某一个 commit 上——那个指针就是「这版 SDK 出自哪版契约」的答案
16
- ```
25
+
26
+ 每个操作另有 `<操作>Result` / `<操作>Body` / `<操作>Query` 三个类型别名。
27
+
28
+ ## 重新生成
17
29
 
18
30
  ```
19
- git submodule update --remote leaflowapis # 要跟进新契约时才做
20
31
  npm run generate
21
32
  ```
22
33
 
23
- 产物由人在本地跑完提交,CI 只验证不写回:一个会 commit 回来的流水线,在两次推送挨得近时只能靠
24
- 重试或者强推——前者会打架,后者会丢东西。
34
+ 契约版本记在 `CONTRACTS_REF`。
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.0.0-dev.13.g732c6b7",
3
+ "version": "0.0.0-dev.16.gac94fbe",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/LeaflowNET/leaflow-ts.git"
8
+ "url": "git+https://github.com/leaflowapis/leaflow-ts.git"
9
9
  },
10
10
  "type": "module",
11
11
  "main": "./dist/index.js",