@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.
- package/README.md +22 -12
- 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
|
-
|
|
3
|
+
Leaflow 平台的 TypeScript SDK(`@leaflow/sdk`),由
|
|
4
|
+
[leaflowapis](https://github.com/leaflowapis/leaflowapis) 生成。
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
```
|
|
7
|
+
npm i @leaflow/sdk openapi-fetch
|
|
8
|
+
```
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
npm 要 `v1.2.3`——上一版两者挤在一个仓库里,结果是 Go 那半从来没被正确发布过,而没有任何东西
|
|
10
|
-
会报错(`go get` 只是拿不到)。
|
|
10
|
+
当前只含类型。请求由 `openapi-fetch` 发出,路径与参数由契约约束。
|
|
11
11
|
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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/
|
|
8
|
+
"url": "git+https://github.com/leaflowapis/leaflow-ts.git"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "./dist/index.js",
|