@ichinese/open-sdk 0.0.0-stage → 1.0.0-rc.2
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 +21 -0
- package/README.md +53 -2
- package/dist/client.d.ts +53 -0
- package/dist/errors.d.ts +33 -0
- package/dist/events.d.ts +70 -0
- package/dist/gen/meta.d.ts +44 -0
- package/dist/gen/operations.d.ts +177 -0
- package/dist/gen/schema.d.ts +3102 -0
- package/dist/index.cjs +891 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +820 -0
- package/dist/types.d.ts +61 -0
- package/package.json +46 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type TokenType = 'app' | 'tenant' | 'user';
|
|
2
|
+
/** Which token a call goes with. Without any, the client uses the app token when the operation takes one. */
|
|
3
|
+
export interface RequestOptions {
|
|
4
|
+
/** Call as an institution that installed the app: the client gets (and renews) its tenant token. */
|
|
5
|
+
tenantKey?: string;
|
|
6
|
+
/** Call as a user (a token from `exchangeAuthCode` or `refreshUserToken`). */
|
|
7
|
+
userAccessToken?: string;
|
|
8
|
+
/** A token you already hold (any type), used as is. */
|
|
9
|
+
accessToken?: string;
|
|
10
|
+
/** Extra request headers. */
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
/** Cancels the call (and its retries). */
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
/** One call of an operation (made by the generated methods). */
|
|
16
|
+
export interface CallSpec {
|
|
17
|
+
id: string;
|
|
18
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
19
|
+
/** The contract's path, e.g. `/classes/{class_id}`. */
|
|
20
|
+
path: string;
|
|
21
|
+
pathParams: Record<string, string>;
|
|
22
|
+
query?: Record<string, unknown>;
|
|
23
|
+
body?: unknown;
|
|
24
|
+
tokenTypes: readonly TokenType[];
|
|
25
|
+
}
|
|
26
|
+
export interface ClientOptions {
|
|
27
|
+
appId: string;
|
|
28
|
+
appSecret: string;
|
|
29
|
+
/**
|
|
30
|
+
* The open API's address (default: the release's, see `DEFAULT_BASE_URL`). One address for every
|
|
31
|
+
* region: tokens carry their region and the gateway routes by it.
|
|
32
|
+
*/
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
/** Retries after a rate limit (429), a server error (5xx) or a network failure. Default 3. */
|
|
35
|
+
maxRetries?: number;
|
|
36
|
+
/** Per request, in milliseconds. Default 30 000. */
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
/** Your own fetch (tests, proxies). Default the global fetch. */
|
|
39
|
+
fetch?: typeof fetch;
|
|
40
|
+
/** Renew a cached app or tenant token this many seconds before it expires. Default 300. */
|
|
41
|
+
refreshBeforeSeconds?: number;
|
|
42
|
+
/** Appended to the User-Agent header. */
|
|
43
|
+
userAgent?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface UserAccessToken {
|
|
46
|
+
access_token: string;
|
|
47
|
+
token_type: 'Bearer';
|
|
48
|
+
expires_in: number;
|
|
49
|
+
refresh_token: string;
|
|
50
|
+
refresh_expires_in: number;
|
|
51
|
+
open_id: string;
|
|
52
|
+
scopes: string[];
|
|
53
|
+
denied_scopes: string[];
|
|
54
|
+
tenant_key?: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface TenantAccessToken {
|
|
57
|
+
tenant_access_token: string;
|
|
58
|
+
expires_in: number;
|
|
59
|
+
tenant_key: string;
|
|
60
|
+
scopes: string[];
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ichinese/open-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
|
+
"description": "Server SDK for the iChinese open platform (open API, tokens, events, web login): Node.js 20+",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node build.mjs",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "vitest run"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.cjs",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/ichinese-cn/open-sdk-node.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/ichinese-cn/open-sdk-node#readme",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/ichinese-cn/open-sdk-node/issues"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "24.19.2",
|
|
43
|
+
"esbuild": "0.28.2",
|
|
44
|
+
"tsx": "4.23.15",
|
|
45
|
+
"typescript": "5.9.3",
|
|
46
|
+
"vitest": "5.0.4"
|
|
47
|
+
}
|
|
48
|
+
}
|