@soga/sdk 0.0.1 → 0.2.7

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 ADDED
@@ -0,0 +1 @@
1
+ # downloader
package/dist/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Sdk } from './sdk';
2
+ export declare function getSdk(domain: string): Sdk;
3
+ export { Sdk };
package/dist/main.js ADDED
@@ -0,0 +1,17 @@
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.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { AliHostDetail, BaiduHostDetail, MemberInfo, RecordDetail } from '@soga/types';
2
+ import { AxiosInstance } from 'axios';
3
+ export declare class Sdk {
4
+ protected sdkAxios: AxiosInstance;
5
+ 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
+ getUserInfo(params: {
15
+ refresh?: boolean;
16
+ }): Promise<MemberInfo>;
17
+ getSystemConfig(): Promise<{
18
+ encode_root: string;
19
+ download_root: string;
20
+ cache_root: string;
21
+ }>;
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
+ getBaiduHostInfo(params: {
32
+ host_id: number;
33
+ refresh?: boolean;
34
+ }): Promise<BaiduHostDetail>;
35
+ getBaiduHostAuthData(params: {
36
+ host_id: number;
37
+ refresh?: boolean;
38
+ }): Promise<{
39
+ access_token: string;
40
+ vip_type: number;
41
+ }>;
42
+ getAliHostInfo(params: {
43
+ host_id: number;
44
+ refresh?: boolean;
45
+ }): Promise<AliHostDetail>;
46
+ getAliHostAuthData(params: {
47
+ host_id: number;
48
+ refresh?: boolean;
49
+ }): Promise<{
50
+ access_token: string;
51
+ vip_type: number;
52
+ drive_id: string;
53
+ }>;
54
+ getSpaceInfo(params: {
55
+ space_id: number;
56
+ refresh?: boolean;
57
+ }): Promise<import("@soga/types").SpaceListItem>;
58
+ getRecordInfo(params: {
59
+ space_id: number;
60
+ record_id: number;
61
+ refresh?: boolean;
62
+ }): Promise<RecordDetail>;
63
+ createRecord(params: {
64
+ space_id: number;
65
+ name: string;
66
+ parent_id: number;
67
+ type: number;
68
+ ftype: number;
69
+ }): Promise<RecordDetail>;
70
+ updateRecord(params: {
71
+ space_id: number;
72
+ record_id: number;
73
+ parent_id: number;
74
+ manifest?: string;
75
+ }): Promise<RecordDetail>;
76
+ }
package/dist/sdk.js ADDED
@@ -0,0 +1,68 @@
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/read-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;
package/package.json CHANGED
@@ -1,15 +1,56 @@
1
1
  {
2
2
  "name": "@soga/sdk",
3
- "version": "0.0.1",
4
- "main": "index.js",
3
+ "version": "0.2.7",
5
4
  "publishConfig": {
6
5
  "access": "public"
7
6
  },
7
+ "description": "",
8
+ "main": "dist/main.js",
9
+ "types": "dist/main.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
8
13
  "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1"
14
+ "build": "rimraf dist && tsc && ts-node ./scripts/minify",
15
+ "minify": "ts-node ./scripts/minify",
16
+ "demo_backup": "ts-node ./demo/demo.ts",
17
+ "demo": "ts-node ./demo/demo.ts",
18
+ "worker": "tsc && ts-node ./demo/worker.ts",
19
+ "test": "jest",
20
+ "dev": "ts-node ./src/main.ts",
21
+ "lint": "eslint . --ext .ts",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "devDependencies": {
25
+ "@soga/types": "file:../types",
26
+ "@types/fs-extra": "^11.0.4",
27
+ "@types/glob": "^8.1.0",
28
+ "@types/jest": "^29.5.14",
29
+ "@types/node": "^20.8.7",
30
+ "@typescript-eslint/eslint-plugin": "^6.4.1",
31
+ "@typescript-eslint/parser": "^6.4.1",
32
+ "eslint": "^8.47.0",
33
+ "eslint-config-prettier": "^9.1.0",
34
+ "eslint-plugin-jest": "^27.9.0",
35
+ "eslint-plugin-prettier": "^5.2.3",
36
+ "glob": "^10.4.5",
37
+ "jest": "^29.7.0",
38
+ "prettier": "^3.0.2",
39
+ "rimraf": "^6.0.1",
40
+ "terser": "^5.19.2",
41
+ "ts-jest": "^29.2.5",
42
+ "ts-node": "^10.9.1",
43
+ "typescript": "^5.1.6"
10
44
  },
11
45
  "keywords": [],
12
46
  "author": "",
13
47
  "license": "ISC",
14
- "description": ""
48
+ "peerDependencies": {
49
+ "level": "*"
50
+ },
51
+ "dependencies": {
52
+ "@soga/types": "^0.2.7",
53
+ "axios": "^1.8.4"
54
+ },
55
+ "gitHead": "527e923683c11ace899c5111d7dcfb38115d4d48"
15
56
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- console.log("cache");