@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.
@@ -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,5 +0,0 @@
1
- import { getSongList } from "./Song";
2
- export const AudioStationMethods = {
3
- getSongList: getSongList,
4
- };
5
- export const AudioStationKey = "AudioStation";
@@ -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
- });
@@ -1,2 +0,0 @@
1
- // export response
2
- export {};
@@ -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";
@@ -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
- }
@@ -1,2 +0,0 @@
1
- export declare const getServerInfo: (quickConnectId: string) => Promise<string>;
2
- export declare const pingpang: (server: string) => Promise<boolean>;
@@ -1,3 +0,0 @@
1
- import { SynologyApi } from "./core";
2
- export * from "./core";
3
- export default SynologyApi;
@@ -1,3 +0,0 @@
1
- import { SynologyApi } from "../../core";
2
- export declare function login(core: SynologyApi): Promise<any>;
3
- export declare function logout(core: SynologyApi): Promise<void>;
@@ -1,2 +0,0 @@
1
- import { SynologyApi } from "../../core";
2
- export declare function getApiInfo(core: SynologyApi): Promise<any>;
@@ -1,2 +0,0 @@
1
- export * from "./Auth";
2
- export * from "./Info";
@@ -1,5 +0,0 @@
1
- import { AudioStationSongListRequest, AudioStationSongListResponse } from "./types";
2
- /**
3
- * fetch song list
4
- * */
5
- export declare function getSongList(params: AudioStationSongListRequest): Promise<AudioStationSongListResponse>;
@@ -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,5 +0,0 @@
1
- import { getSongList } from "./Song";
2
- export declare const AudioStationMethods: {
3
- getSongList: typeof getSongList;
4
- };
5
- export declare const AudioStationKey = "AudioStation";
@@ -1,5 +0,0 @@
1
- import { AudioStationKey, AudioStationMethods } from "./AudioStation";
2
- export declare class BaseSynologyApi {
3
- [AudioStationKey]: typeof AudioStationMethods;
4
- constructor();
5
- }
@@ -1,9 +0,0 @@
1
- export type SynologyApiResponse<T = any> = {
2
- data: T;
3
- error: {
4
- code: number;
5
- errors: Record<string, string>;
6
- message: string;
7
- };
8
- success: boolean;
9
- };
@@ -1 +0,0 @@
1
- export * from "./API";
@@ -1,3 +0,0 @@
1
- export declare function isObjEmpty(obj: Record<string, any>): boolean;
2
- export declare function queryObjToString(params: Record<string, any>): string;
3
- export declare function isHttpUrl(url: string): boolean;