@fett/synology-api 0.0.1-beta.3 → 0.0.1-beta.6
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 +7 -3
- package/bin/syno +6 -0
- package/lib/cjs/index.js +732 -0
- package/package.json +21 -10
- package/dist/cjs/index.js +0 -341
- package/dist/esm/constants.js +0 -4
- package/dist/esm/core.js +0 -102
- package/dist/esm/helpers.js +0 -80
- package/dist/esm/index.js +0 -3
- package/dist/esm/modules/Api/Auth.js +0 -43
- package/dist/esm/modules/Api/Info.js +0 -26
- package/dist/esm/modules/Api/index.js +0 -2
- package/dist/esm/modules/AudioStation/Song/index.js +0 -25
- package/dist/esm/modules/AudioStation/Song/types.js +0 -1
- package/dist/esm/modules/AudioStation/index.js +0 -5
- package/dist/esm/modules/index.js +0 -20
- package/dist/esm/types/API.js +0 -2
- package/dist/esm/types/index.js +0 -1
- package/dist/esm/utils.js +0 -14
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/core.d.ts +0 -38
- package/dist/types/helpers.d.ts +0 -2
- package/dist/types/index.d.ts +0 -3
- package/dist/types/modules/Api/Auth.d.ts +0 -3
- package/dist/types/modules/Api/Info.d.ts +0 -2
- package/dist/types/modules/Api/index.d.ts +0 -2
- package/dist/types/modules/AudioStation/Song/index.d.ts +0 -5
- package/dist/types/modules/AudioStation/Song/types.d.ts +0 -18
- package/dist/types/modules/AudioStation/index.d.ts +0 -5
- package/dist/types/modules/index.d.ts +0 -5
- package/dist/types/types/API.d.ts +0 -9
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/utils.d.ts +0 -3
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* fetch song list
|
|
12
|
-
* */
|
|
13
|
-
export function getSongList(params) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const res = yield this.run("SYNO.AudioStation.Song", {
|
|
16
|
-
params: {
|
|
17
|
-
method: "list",
|
|
18
|
-
library: "all",
|
|
19
|
-
limit: params.limit,
|
|
20
|
-
offset: params.offset,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
return res.data;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AudioStationKey, AudioStationMethods } from "./AudioStation";
|
|
2
|
-
// bind methods to BaseSynologyApi instance
|
|
3
|
-
function methodsBundler(instance, methods) {
|
|
4
|
-
const output = {};
|
|
5
|
-
for (const key in methods) {
|
|
6
|
-
output[key] = methods[key].bind(instance);
|
|
7
|
-
}
|
|
8
|
-
return output;
|
|
9
|
-
}
|
|
10
|
-
export class BaseSynologyApi {
|
|
11
|
-
constructor() { }
|
|
12
|
-
}
|
|
13
|
-
// proxy methods namespace to BaseSynologyApi instance
|
|
14
|
-
Object.defineProperties(BaseSynologyApi.prototype, {
|
|
15
|
-
[AudioStationKey]: {
|
|
16
|
-
get() {
|
|
17
|
-
return methodsBundler(this, AudioStationMethods);
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
});
|
package/dist/esm/types/API.js
DELETED
package/dist/esm/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./API";
|
package/dist/esm/utils.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function isObjEmpty(obj) {
|
|
2
|
-
return obj && typeof obj === "object" && Object.keys(obj).length === 0;
|
|
3
|
-
}
|
|
4
|
-
export function queryObjToString(params) {
|
|
5
|
-
if (isObjEmpty(params)) {
|
|
6
|
-
return "";
|
|
7
|
-
}
|
|
8
|
-
return Object.keys(params)
|
|
9
|
-
.map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key]))
|
|
10
|
-
.join("&");
|
|
11
|
-
}
|
|
12
|
-
export function isHttpUrl(url) {
|
|
13
|
-
return /^https?:\/\//.test(url);
|
|
14
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const SYNOLOGY_API_AUTH = "SYNO.API.Auth";
|
|
2
|
-
export declare const SYNOLOGY_API_INFO = "SYNO.API.Info";
|
|
3
|
-
export declare const GLOBAL_QUICK_CONNECT_URL = "https://global.quickconnect.cn/Serv.php";
|
|
4
|
-
export declare const QUICK_CONNECT_PINGPANG_API = "/webman/pingpong.cgi?action=cors&quickconnect=true";
|
package/dist/types/core.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BaseSynologyApi } from "./modules";
|
|
2
|
-
export interface SynologyApiOptions {
|
|
3
|
-
server: string;
|
|
4
|
-
username: string;
|
|
5
|
-
password: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SynologyApiInfo {
|
|
8
|
-
maxVersion: number;
|
|
9
|
-
minVersion: number;
|
|
10
|
-
path: string;
|
|
11
|
-
requestFormat?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface SynologyApiAuthInfo {
|
|
14
|
-
sid: string;
|
|
15
|
-
did: number;
|
|
16
|
-
is_portal_port: boolean;
|
|
17
|
-
synotoken: string;
|
|
18
|
-
}
|
|
19
|
-
export declare class SynologyApi extends BaseSynologyApi {
|
|
20
|
-
server: string;
|
|
21
|
-
username: string;
|
|
22
|
-
password: string;
|
|
23
|
-
baseUrl: string;
|
|
24
|
-
isConnecting: boolean;
|
|
25
|
-
private authInfo;
|
|
26
|
-
private apiInfo;
|
|
27
|
-
constructor(options: SynologyApiOptions);
|
|
28
|
-
connect(): Promise<boolean>;
|
|
29
|
-
disconnect(): Promise<boolean>;
|
|
30
|
-
private _getApiInfo;
|
|
31
|
-
hasApi(apiName: string): any;
|
|
32
|
-
run(apiName: string, options: {
|
|
33
|
-
method?: "get" | "post";
|
|
34
|
-
params?: Record<string, any>;
|
|
35
|
-
data?: Record<string, any>;
|
|
36
|
-
headers?: Record<string, any>;
|
|
37
|
-
}): Promise<any>;
|
|
38
|
-
}
|
package/dist/types/helpers.d.ts
DELETED
package/dist/types/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SynologyApiResponse } from "../../../types";
|
|
2
|
-
export type AudioStationSongListRequest = {
|
|
3
|
-
limit?: number;
|
|
4
|
-
offset?: number;
|
|
5
|
-
method?: string;
|
|
6
|
-
library?: string;
|
|
7
|
-
additional?: string;
|
|
8
|
-
version?: number;
|
|
9
|
-
sort_by?: string;
|
|
10
|
-
sort_direction?: string;
|
|
11
|
-
};
|
|
12
|
-
export type AudioStationSongListResponse = SynologyApiResponse<{
|
|
13
|
-
offset: number;
|
|
14
|
-
total: number;
|
|
15
|
-
songs: {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./API";
|
package/dist/types/utils.d.ts
DELETED