@cn-quickotp/k3cloud-webapi-sdk 0.0.0-stage → 1.0.1
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 +168 -0
- package/LICENSE +102 -0
- package/README.md +104 -2
- package/dist/index.js +1751 -0
- package/package.json +66 -4
- package/types/index.d.ts +99 -0
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cn-quickotp/k3cloud-webapi-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Kingdee K3Cloud (金蝶云星空) WebAPI SDK for JavaScript — CommonJS, zero-framework core.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"license": "MulanPSL-2.0",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/cn-quickotp/k3cloud-webapi-sdk.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/cn-quickotp/k3cloud-webapi-sdk#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/cn-quickotp/k3cloud-webapi-sdk/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"kingdee",
|
|
18
|
+
"k3cloud",
|
|
19
|
+
"金蝶",
|
|
20
|
+
"金蝶云星空",
|
|
21
|
+
"webapi",
|
|
22
|
+
"sdk"
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"types",
|
|
27
|
+
"README.md",
|
|
28
|
+
"CHANGELOG.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
|
+
},
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./types/index.d.ts",
|
|
38
|
+
"require": "./dist/index.js",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {},
|
|
43
|
+
"optionalDependencies": {},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
46
|
+
"@types/node": "26.6.5",
|
|
47
|
+
"eslint": "^10.14.0",
|
|
48
|
+
"globals": "^15.14.0",
|
|
49
|
+
"jest": "^29.7.0",
|
|
50
|
+
"prettier": "^3.4.2",
|
|
51
|
+
"rollup": "^4.30.0",
|
|
52
|
+
"typescript": "^5.9.0"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"registry": "https://registry.npmjs.org/"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "rollup -c",
|
|
60
|
+
"test": "jest --coverage",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"lint": "eslint .",
|
|
63
|
+
"format": "prettier --write src tests types rollup.config.js jest.config.js eslint.config.cjs package.json tsconfig.json .prettierrc.json README.md",
|
|
64
|
+
"format:check": "prettier --check src tests types rollup.config.js jest.config.js eslint.config.cjs package.json tsconfig.json .prettierrc.json README.md",
|
|
65
|
+
"smoke": "node scripts/smoke.js",
|
|
66
|
+
"prepublishOnly": "npm run build && npm run typecheck && npm test && npm run smoke"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export declare const SDK_VERSION: string;
|
|
2
|
+
|
|
3
|
+
export interface Logger {
|
|
4
|
+
debug(record: Record<string, unknown>): void;
|
|
5
|
+
info(record: Record<string, unknown>): void;
|
|
6
|
+
warn(record: Record<string, unknown>): void;
|
|
7
|
+
error(record: Record<string, unknown>): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface FetchResponseHeaders {
|
|
11
|
+
forEach(callback: (value: string, key: string) => void): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface FetchResponse {
|
|
15
|
+
status: number;
|
|
16
|
+
headers: FetchResponseHeaders | Record<string, string>;
|
|
17
|
+
text(): Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface FetchRequestInit {
|
|
21
|
+
method?: string;
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
body?: string;
|
|
24
|
+
signal?: AbortSignal | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type FetchLike = (url: string, init?: FetchRequestInit) => Promise<FetchResponse>;
|
|
28
|
+
|
|
29
|
+
export interface ClientConfig {
|
|
30
|
+
serverUrl: string;
|
|
31
|
+
acctId: string;
|
|
32
|
+
username: string;
|
|
33
|
+
password: string;
|
|
34
|
+
appKey: string;
|
|
35
|
+
appSec: string;
|
|
36
|
+
lang?: number;
|
|
37
|
+
timeout?: number;
|
|
38
|
+
retries?: number;
|
|
39
|
+
retryBaseDelay?: number;
|
|
40
|
+
logger?: Logger;
|
|
41
|
+
fetchImpl?: FetchLike;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface LoginCredentials {
|
|
45
|
+
username?: string;
|
|
46
|
+
password?: string;
|
|
47
|
+
acctId?: string;
|
|
48
|
+
appId?: string;
|
|
49
|
+
appKey?: string;
|
|
50
|
+
appSec?: string;
|
|
51
|
+
lang?: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface BillService {
|
|
55
|
+
save(formId: string, model: object): Promise<unknown>;
|
|
56
|
+
view(formId: string, number: string): Promise<unknown>;
|
|
57
|
+
submit(formId: string, numbers: string[]): Promise<unknown>;
|
|
58
|
+
audit(formId: string, numbers: string[]): Promise<unknown>;
|
|
59
|
+
unAudit(formId: string, numbers: string[]): Promise<unknown>;
|
|
60
|
+
delete(formId: string, numbers: string[]): Promise<unknown>;
|
|
61
|
+
executeBillQuery(query: object | string): Promise<unknown[]>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface MetadataService {
|
|
65
|
+
queryBusinessInfo(formId: string, options?: { cache?: boolean }): Promise<object>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface SessionState {
|
|
69
|
+
authenticated: boolean;
|
|
70
|
+
cookie: string;
|
|
71
|
+
context: object | null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface Session {
|
|
75
|
+
isAuthenticated(): boolean;
|
|
76
|
+
getState(): SessionState;
|
|
77
|
+
getCookie(): string;
|
|
78
|
+
execute(send: (cookie: string) => Promise<unknown>): Promise<unknown>;
|
|
79
|
+
login(credentials: LoginCredentials): Promise<SessionState>;
|
|
80
|
+
logout(): Promise<SessionState>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface K3CloudClient {
|
|
84
|
+
login(credentials?: LoginCredentials): Promise<SessionState>;
|
|
85
|
+
logout(): Promise<SessionState>;
|
|
86
|
+
bill: BillService;
|
|
87
|
+
metadata: MetadataService;
|
|
88
|
+
session: Session;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export declare class K3CloudError extends Error {
|
|
92
|
+
code: string;
|
|
93
|
+
details: Record<string, unknown>;
|
|
94
|
+
constructor(code: string, message: string, options?: Record<string, unknown>);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare function createClient(config?: ClientConfig): K3CloudClient;
|
|
98
|
+
|
|
99
|
+
export declare function createClientFromEnv(env?: Record<string, string>): K3CloudClient;
|