Skip to content

Commit fd51336

Browse files
author
AxT-Team Bot
committed
chore: wire npm release workflow
0 parents  commit fd51336

File tree

570 files changed

+45940
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

570 files changed

+45940
-0
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
[*]
3+
charset = utf-8
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: release
2+
on:
3+
push:
4+
tags: ['v*.*.*']
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: '20'
15+
registry-url: 'https://registry.npmjs.org'
16+
- run: npm ci
17+
- run: npm run build || npm run test --if-present
18+
- name: Publish to npm
19+
run: npm publish --access public
20+
env:
21+
NODE_AUTH_TOKEN: {{ secrets.NPM_TOKEN }}
22+
- uses: softprops/action-gh-release@v2
23+
with:
24+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-node@v4
9+
with: { node-version: '20' }
10+
- run: npm ci || npm i
11+
- run: npm run build

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
.idea/
3+
.vscode/
4+
dist/
5+
build/
6+
coverage/

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# uapi-browser-sdk
2+
3+
![Banner](./banner.png)
4+
5+
[![Browser TS](https://img.shields.io/badge/TypeScript-ES2020-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
6+
[![Docs](https://img.shields.io/badge/Docs-uapis.cn-2EAE5D?style=flat-square)](https://uapis.cn/)
7+
8+
> [!NOTE]
9+
> 所有接口的 Browser (TypeScript) 示例都可以在 [UApi](https://uapis.cn/docs/introduction) 的接口文档页面,向下滚动至 **快速启动** 区块后直接复制。
10+
11+
## 快速开始
12+
13+
```bash
14+
npm i uapi-browser-sdk
15+
```
16+
17+
```ts
18+
import { UapiClient } from 'uapi-browser-sdk'
19+
20+
const client = new UapiClient('https://uapis.cn/api/v1')
21+
const result = await client.social.getSocialQqUserinfo({ qq: '10001' })
22+
console.log(result)
23+
```
24+
25+
## 特性
26+
27+
现在你不再需要反反复复的查阅文档了。
28+
29+
只需在 IDE 中键入 `client.`,所有核心模块——如 `social``game``image`——即刻同步展现。进一步输入即可直接定位到 `getSocialQqUserinfo` 这样的具体方法,其名称与文档的 `operationId` 严格保持一致,确保了开发过程的直观与高效。
30+
31+
所有方法签名只接受真实且必需的参数。当你在构建请求时,TypeScript 会即时提示 `qq``username` 等键名,这彻底杜绝了在对象字面量中因键名拼写错误而导致的运行时错误。
32+
33+
针对 401、404、429 等标准 HTTP 响应,SDK 已将其统一映射为 `UapiError`。错误对象自带 `code``status``details` 字段,确保你在浏览器日志中能第一时间准确、快速地诊断问题。
34+
35+
SDK 采用原生 `fetch`,自动补上 `Authorization` 头且不依赖任何 Node.js API;需要自定义超时或重试时,只要包装 `_request` 或替换调用处即可。
36+
37+
如果你需要查看字段细节或内部逻辑,仓库中的 `./internal` 目录同步保留了由 `openapi-generator` 生成的完整结构体,随时可供参考。
38+
39+
## 错误模型概览
40+
41+
| HTTP 状态码 | SDK 错误类型 | 附加信息 |
42+
|-------------|-------------|----------------------------------------------|
43+
| 401/403 | `UapiError` | `code``status``details` |
44+
| 404 | `UapiError` | `code``status` |
45+
| 400 | `UapiError` | `code``status``details` |
46+
| 429 | `UapiError` | `code``status``retry_after_seconds` |
47+
| 5xx | `UapiError` | `code``status` |
48+
49+
## 其他 SDK
50+
51+
| 语言 | 仓库地址 |
52+
|-------------|--------------------------------------------------------------|
53+
| Go | https://github.com/AxT-Team/uapi-go-sdk |
54+
| Python | https://github.com/AxT-Team/uapi-python-sdk |
55+
| TypeScript| https://github.com/AxT-Team/uapi-typescript-sdk |
56+
| Browser (TypeScript/JavaScript)(当前)| https://github.com/AxT-Team/uapi-browser-sdk |
57+
| Java | https://github.com/AxT-Team/uapi-java-sdk |
58+
| PHP | https://github.com/AxT-Team/uapi-php-sdk |
59+
| C# | https://github.com/AxT-Team/uapi-csharp-sdk |
60+
| C++ | https://github.com/AxT-Team/uapi-cpp-sdk |
61+
| Rust | https://github.com/AxT-Team/uapi-rust-sdk |
62+
63+
## 文档
64+
65+
访问 [UApi文档首页](https://uapis.cn/docs/introduction) 并选择任意接口,向下滚动到 **快速启动** 区块即可看到最新的 Browser (TypeScript) 示例代码。

banner.png

2.03 MB
Loading

internal/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
wwwroot/*.js
2+
node_modules
3+
typings
4+
dist

internal/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

internal/.openapi-generator-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

0 commit comments

Comments
 (0)