@soga/sdk 0.3.0 → 1.0.0
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 +1 -1
- package/dist/{sdk.d.ts → index.d.mts} +16 -20
- package/dist/index.d.ts +72 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +18 -16
- package/dist/main.d.ts +0 -3
- package/dist/main.js +0 -17
- package/dist/sdk.js +0 -68
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sdk
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _soga_types from '@soga/types';
|
|
2
|
+
import { MemberInfo, BaiduHostDetail, AliHostDetail, RecordListItem, RecordDetail } from '@soga/types';
|
|
2
3
|
import { AxiosInstance } from 'axios';
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
declare class Sdk {
|
|
4
6
|
protected sdkAxios: AxiosInstance;
|
|
5
7
|
constructor(domain: string);
|
|
6
|
-
login(params: {
|
|
7
|
-
account: string;
|
|
8
|
-
password: string;
|
|
9
|
-
}): Promise<{
|
|
10
|
-
user_info: MemberInfo;
|
|
11
|
-
access_token: string;
|
|
12
|
-
}>;
|
|
13
|
-
logout(): Promise<{}>;
|
|
14
8
|
getUserInfo(params: {
|
|
15
9
|
refresh?: boolean;
|
|
16
10
|
}): Promise<MemberInfo>;
|
|
@@ -19,15 +13,6 @@ export declare class Sdk {
|
|
|
19
13
|
download_root: string;
|
|
20
14
|
cache_root: string;
|
|
21
15
|
}>;
|
|
22
|
-
updateSystemConfig(params: {
|
|
23
|
-
encode_root?: string;
|
|
24
|
-
download_root?: string;
|
|
25
|
-
cache_root?: string;
|
|
26
|
-
}): Promise<{
|
|
27
|
-
encode_root: string;
|
|
28
|
-
download_root: string;
|
|
29
|
-
cache_root: string;
|
|
30
|
-
}>;
|
|
31
16
|
getBaiduHostInfo(params: {
|
|
32
17
|
host_id: number;
|
|
33
18
|
refresh?: boolean;
|
|
@@ -54,7 +39,13 @@ export declare class Sdk {
|
|
|
54
39
|
getSpaceInfo(params: {
|
|
55
40
|
space_id: number;
|
|
56
41
|
refresh?: boolean;
|
|
57
|
-
}): Promise<
|
|
42
|
+
}): Promise<_soga_types.SpaceListItem>;
|
|
43
|
+
getRecordList(params: {
|
|
44
|
+
space_id: number;
|
|
45
|
+
parent_id: number;
|
|
46
|
+
page: number;
|
|
47
|
+
pagesize: number;
|
|
48
|
+
}): Promise<RecordListItem[]>;
|
|
58
49
|
getRecordInfo(params: {
|
|
59
50
|
space_id: number;
|
|
60
51
|
record_id: number;
|
|
@@ -66,6 +57,7 @@ export declare class Sdk {
|
|
|
66
57
|
parent_id: number;
|
|
67
58
|
type: number;
|
|
68
59
|
ftype: number;
|
|
60
|
+
manifest?: string;
|
|
69
61
|
}): Promise<RecordDetail>;
|
|
70
62
|
updateRecord(params: {
|
|
71
63
|
space_id: number;
|
|
@@ -74,3 +66,7 @@ export declare class Sdk {
|
|
|
74
66
|
manifest?: string;
|
|
75
67
|
}): Promise<RecordDetail>;
|
|
76
68
|
}
|
|
69
|
+
|
|
70
|
+
declare function getSdk(domain: string): Sdk;
|
|
71
|
+
|
|
72
|
+
export { Sdk, getSdk };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as _soga_types from '@soga/types';
|
|
2
|
+
import { MemberInfo, BaiduHostDetail, AliHostDetail, RecordListItem, RecordDetail } from '@soga/types';
|
|
3
|
+
import { AxiosInstance } from 'axios';
|
|
4
|
+
|
|
5
|
+
declare class Sdk {
|
|
6
|
+
protected sdkAxios: AxiosInstance;
|
|
7
|
+
constructor(domain: string);
|
|
8
|
+
getUserInfo(params: {
|
|
9
|
+
refresh?: boolean;
|
|
10
|
+
}): Promise<MemberInfo>;
|
|
11
|
+
getSystemConfig(): Promise<{
|
|
12
|
+
encode_root: string;
|
|
13
|
+
download_root: string;
|
|
14
|
+
cache_root: string;
|
|
15
|
+
}>;
|
|
16
|
+
getBaiduHostInfo(params: {
|
|
17
|
+
host_id: number;
|
|
18
|
+
refresh?: boolean;
|
|
19
|
+
}): Promise<BaiduHostDetail>;
|
|
20
|
+
getBaiduHostAuthData(params: {
|
|
21
|
+
host_id: number;
|
|
22
|
+
refresh?: boolean;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
access_token: string;
|
|
25
|
+
vip_type: number;
|
|
26
|
+
}>;
|
|
27
|
+
getAliHostInfo(params: {
|
|
28
|
+
host_id: number;
|
|
29
|
+
refresh?: boolean;
|
|
30
|
+
}): Promise<AliHostDetail>;
|
|
31
|
+
getAliHostAuthData(params: {
|
|
32
|
+
host_id: number;
|
|
33
|
+
refresh?: boolean;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
access_token: string;
|
|
36
|
+
vip_type: number;
|
|
37
|
+
drive_id: string;
|
|
38
|
+
}>;
|
|
39
|
+
getSpaceInfo(params: {
|
|
40
|
+
space_id: number;
|
|
41
|
+
refresh?: boolean;
|
|
42
|
+
}): Promise<_soga_types.SpaceListItem>;
|
|
43
|
+
getRecordList(params: {
|
|
44
|
+
space_id: number;
|
|
45
|
+
parent_id: number;
|
|
46
|
+
page: number;
|
|
47
|
+
pagesize: number;
|
|
48
|
+
}): Promise<RecordListItem[]>;
|
|
49
|
+
getRecordInfo(params: {
|
|
50
|
+
space_id: number;
|
|
51
|
+
record_id: number;
|
|
52
|
+
refresh?: boolean;
|
|
53
|
+
}): Promise<RecordDetail>;
|
|
54
|
+
createRecord(params: {
|
|
55
|
+
space_id: number;
|
|
56
|
+
name: string;
|
|
57
|
+
parent_id: number;
|
|
58
|
+
type: number;
|
|
59
|
+
ftype: number;
|
|
60
|
+
manifest?: string;
|
|
61
|
+
}): Promise<RecordDetail>;
|
|
62
|
+
updateRecord(params: {
|
|
63
|
+
space_id: number;
|
|
64
|
+
record_id: number;
|
|
65
|
+
parent_id: number;
|
|
66
|
+
manifest?: string;
|
|
67
|
+
}): Promise<RecordDetail>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare function getSdk(domain: string): Sdk;
|
|
71
|
+
|
|
72
|
+
export { Sdk, getSdk };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t,e=Object.create,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,d=(t,e,o,d)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of r(e))i.call(t,n)||n===o||s(t,n,{get:()=>e[n],enumerable:!(d=a(e,n))||d.enumerable});return t},n={};((t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})})(n,{Sdk:()=>p,getSdk:()=>g}),module.exports=(t=n,d(s({},"__esModule",{value:!0}),t));var c=((t,a,r)=>(r=null!=t?e(o(t)):{},d(!a&&t&&t.__esModule?r:s(r,"default",{value:t,enumerable:!0}),t)))(require("axios")),u=require("@soga/error"),p=class{sdkAxios;constructor(t){this.sdkAxios=c.default.create({baseURL:t}),this.sdkAxios.interceptors.response.use(t=>t.data,t=>{if(t.response?.data?.code){const{code:e,message:s}=t.response.data;throw(0,u.buildDError)(t,{message:s||t.message,detail:`Error code: ${e}; ${t.message?t.message:""}\n`,stack:t.stack,rewritable:!1,cause:t.response?.data?.cause})}throw(0,u.buildDError)(t,{message:t.message,detail:`request dpan api error code: ${t.code||t.status||"unknown"}`,stack:t.stack,rewritable:!1})})}async getUserInfo(t){return(await this.sdkAxios.post("/user/info",t)).data}async getSystemConfig(){return(await this.sdkAxios.get("/user/system/get-config")).data}async getBaiduHostInfo(t){return(await this.sdkAxios.post("/sdk/baidu/host/info",t)).data}async getBaiduHostAuthData(t){return(await this.sdkAxios.post("/sdk/baidu/host/auth-data",t)).data}async getAliHostInfo(t){return(await this.sdkAxios.post("/sdk/ali/host/info",t)).data}async getAliHostAuthData(t){return(await this.sdkAxios.post("/sdk/ali/host/auth-data",t)).data}async getSpaceInfo(t){return(await this.sdkAxios.post("/sdk/space/info",t)).data}async getRecordList(t){return(await this.sdkAxios.post("/sdk/record/list",t)).data}async getRecordInfo(t){return(await this.sdkAxios.post("/sdk/record/info",t).catch(t=>{throw console.error("Error fetching record info:",t),t})).data}async createRecord(t){return(await this.sdkAxios.post("/sdk/record/create",t)).data}async updateRecord(t){return(await this.sdkAxios.post("/sdk/record/update",t)).data}},k=new Map;function g(t){if(k.has(t))return k.get(t);{const e=new p(t);return k.set(t,e),e}}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"axios";import{buildDError as t}from"@soga/error";var a=class{sdkAxios;constructor(a){this.sdkAxios=s.create({baseURL:a}),this.sdkAxios.interceptors.response.use(s=>s.data,s=>{if(s.response?.data?.code){const{code:a,message:e}=s.response.data;throw t(s,{message:e||s.message,detail:`Error code: ${a}; ${s.message?s.message:""}\n`,stack:s.stack,rewritable:!1,cause:s.response?.data?.cause})}throw t(s,{message:s.message,detail:`request dpan api error code: ${s.code||s.status||"unknown"}`,stack:s.stack,rewritable:!1})})}async getUserInfo(s){return(await this.sdkAxios.post("/user/info",s)).data}async getSystemConfig(){return(await this.sdkAxios.get("/user/system/get-config")).data}async getBaiduHostInfo(s){return(await this.sdkAxios.post("/sdk/baidu/host/info",s)).data}async getBaiduHostAuthData(s){return(await this.sdkAxios.post("/sdk/baidu/host/auth-data",s)).data}async getAliHostInfo(s){return(await this.sdkAxios.post("/sdk/ali/host/info",s)).data}async getAliHostAuthData(s){return(await this.sdkAxios.post("/sdk/ali/host/auth-data",s)).data}async getSpaceInfo(s){return(await this.sdkAxios.post("/sdk/space/info",s)).data}async getRecordList(s){return(await this.sdkAxios.post("/sdk/record/list",s)).data}async getRecordInfo(s){return(await this.sdkAxios.post("/sdk/record/info",s).catch(s=>{throw console.error("Error fetching record info:",s),s})).data}async createRecord(s){return(await this.sdkAxios.post("/sdk/record/create",s)).data}async updateRecord(s){return(await this.sdkAxios.post("/sdk/record/update",s)).data}},e=new Map;function o(s){if(e.has(s))return e.get(s);{const t=new a(s);return e.set(s,t),t}}export{a as Sdk,o as getSdk};
|
package/package.json
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soga/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "",
|
|
8
|
-
"main": "dist/
|
|
9
|
-
"
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"files": [
|
|
11
12
|
"dist"
|
|
12
13
|
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts --minify terser",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
13
18
|
"keywords": [],
|
|
14
19
|
"author": "",
|
|
15
20
|
"license": "ISC",
|
|
16
21
|
"dependencies": {
|
|
17
|
-
"@soga/types": "
|
|
18
|
-
"
|
|
19
|
-
"
|
|
22
|
+
"@soga/types": "latest",
|
|
23
|
+
"@soga/error": "latest",
|
|
24
|
+
"axios": "^1.9.0"
|
|
20
25
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"test": "jest",
|
|
28
|
-
"dev": "ts-node ./src/main.ts",
|
|
29
|
-
"lint": "eslint . --ext .ts"
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@soga/typescript-config": "latest",
|
|
28
|
+
"rimraf": "^6.0.1",
|
|
29
|
+
"terser": "^5.43.1",
|
|
30
|
+
"tsup": "^8.5.0",
|
|
31
|
+
"typescript": "^5.8.3"
|
|
30
32
|
}
|
|
31
|
-
}
|
|
33
|
+
}
|
package/dist/main.d.ts
DELETED
package/dist/main.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Sdk = void 0;
|
|
4
|
-
exports.getSdk = getSdk;
|
|
5
|
-
const sdk_1 = require("./sdk");
|
|
6
|
-
Object.defineProperty(exports, "Sdk", { enumerable: true, get: function () { return sdk_1.Sdk; } });
|
|
7
|
-
const sdkMap = new Map();
|
|
8
|
-
function getSdk(domain) {
|
|
9
|
-
if (!sdkMap.has(domain)) {
|
|
10
|
-
const sdk = new sdk_1.Sdk(domain);
|
|
11
|
-
sdkMap.set(domain, sdk);
|
|
12
|
-
return sdk;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return sdkMap.get(domain);
|
|
16
|
-
}
|
|
17
|
-
}
|
package/dist/sdk.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Sdk = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
class Sdk {
|
|
9
|
-
sdkAxios;
|
|
10
|
-
constructor(domain) {
|
|
11
|
-
this.sdkAxios = axios_1.default.create({
|
|
12
|
-
baseURL: domain,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
async login(params) {
|
|
16
|
-
const res = await this.sdkAxios.post('/sdk/auth/login', params);
|
|
17
|
-
return res.data;
|
|
18
|
-
}
|
|
19
|
-
async logout() {
|
|
20
|
-
await this.sdkAxios.post('/sdk/auth/logout');
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
async getUserInfo(params) {
|
|
24
|
-
const res = await this.sdkAxios.post('/sdk/user/info', params);
|
|
25
|
-
return res.data;
|
|
26
|
-
}
|
|
27
|
-
async getSystemConfig() {
|
|
28
|
-
const res = await this.sdkAxios.get('/sdk/system/get-config');
|
|
29
|
-
return res.data;
|
|
30
|
-
}
|
|
31
|
-
async updateSystemConfig(params) {
|
|
32
|
-
const res = await this.sdkAxios.post('/sdk/system/update-config', params);
|
|
33
|
-
return res.data;
|
|
34
|
-
}
|
|
35
|
-
async getBaiduHostInfo(params) {
|
|
36
|
-
const res = await this.sdkAxios.post('/sdk/baidu/host/info', params);
|
|
37
|
-
return res.data;
|
|
38
|
-
}
|
|
39
|
-
async getBaiduHostAuthData(params) {
|
|
40
|
-
const res = await this.sdkAxios.post('/sdk/baidu/host/auth-data', params);
|
|
41
|
-
return res.data;
|
|
42
|
-
}
|
|
43
|
-
async getAliHostInfo(params) {
|
|
44
|
-
const res = await this.sdkAxios.post('/sdk/ali/host/info', params);
|
|
45
|
-
return res.data;
|
|
46
|
-
}
|
|
47
|
-
async getAliHostAuthData(params) {
|
|
48
|
-
const res = await this.sdkAxios.post('/sdk/ali/host/auth-data', params);
|
|
49
|
-
return res.data;
|
|
50
|
-
}
|
|
51
|
-
async getSpaceInfo(params) {
|
|
52
|
-
const res = await this.sdkAxios.post('/sdk/space/info', params);
|
|
53
|
-
return res.data;
|
|
54
|
-
}
|
|
55
|
-
async getRecordInfo(params) {
|
|
56
|
-
const res = await this.sdkAxios.post('/sdk/record/info', params);
|
|
57
|
-
return res.data;
|
|
58
|
-
}
|
|
59
|
-
async createRecord(params) {
|
|
60
|
-
const res = await this.sdkAxios.post('/sdk/record/create', params);
|
|
61
|
-
return res.data;
|
|
62
|
-
}
|
|
63
|
-
async updateRecord(params) {
|
|
64
|
-
const res = await this.sdkAxios.post('/sdk/record/update', params);
|
|
65
|
-
return res.data;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.Sdk = Sdk;
|