@fett/synology-api 0.0.1-beta.9 → 0.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.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -10
  3. package/lib/cli/apis.js +47 -0
  4. package/lib/{esm/cli → cli}/config.js +38 -41
  5. package/lib/cli/core.js +20 -0
  6. package/lib/{types/cli → cli}/helper.d.ts +1 -0
  7. package/lib/{esm/cli → cli}/helper.js +9 -5
  8. package/lib/cli/index.d.ts +2 -0
  9. package/lib/cli/index.js +5 -0
  10. package/lib/{types/core.d.ts → core.d.ts} +1 -1
  11. package/lib/core.js +99 -0
  12. package/lib/decorators/bindMethods.js +45 -0
  13. package/lib/{types/errorcodes.d.ts → errorcodes.d.ts} +2 -2
  14. package/lib/{esm/errorcodes.js → errorcodes.js} +10 -5
  15. package/lib/helpers.js +70 -0
  16. package/lib/index.d.ts +4 -0
  17. package/lib/index.js +4 -0
  18. package/lib/{types/modules → modules}/Api/Auth.d.ts +2 -2
  19. package/lib/modules/Api/Auth.js +30 -0
  20. package/lib/modules/Api/Info.d.ts +3 -0
  21. package/lib/modules/Api/Info.js +15 -0
  22. package/lib/modules/Api/index.d.ts +2 -0
  23. package/lib/modules/Api/index.js +2 -0
  24. package/lib/modules/AudioStation/Album.d.ts +30 -0
  25. package/lib/modules/AudioStation/Album.js +17 -0
  26. package/lib/modules/AudioStation/Artist.d.ts +25 -0
  27. package/lib/modules/AudioStation/Artist.js +17 -0
  28. package/lib/modules/AudioStation/Cover.js +0 -0
  29. package/lib/modules/AudioStation/Folder.d.ts +24 -0
  30. package/lib/modules/AudioStation/Folder.js +17 -0
  31. package/lib/modules/AudioStation/Info.d.ts +45 -0
  32. package/lib/modules/AudioStation/Info.js +9 -0
  33. package/lib/modules/AudioStation/Lyrics.d.ts +25 -0
  34. package/lib/modules/AudioStation/Lyrics.js +23 -0
  35. package/lib/modules/AudioStation/Playlist.d.ts +34 -0
  36. package/lib/modules/AudioStation/Playlist.js +38 -0
  37. package/lib/modules/AudioStation/Search.d.ts +53 -0
  38. package/lib/modules/AudioStation/Search.js +17 -0
  39. package/lib/modules/AudioStation/Song.d.ts +33 -0
  40. package/lib/modules/AudioStation/Song.js +27 -0
  41. package/lib/modules/AudioStation/index.d.ts +23 -0
  42. package/lib/modules/AudioStation/index.js +23 -0
  43. package/lib/modules/Auth/AuthKey.d.ts +8 -0
  44. package/lib/modules/Auth/AuthKey.js +12 -0
  45. package/lib/modules/Auth/index.d.ts +7 -0
  46. package/lib/modules/Auth/index.js +8 -0
  47. package/lib/modules/FileStation/File.d.ts +0 -0
  48. package/lib/modules/FileStation/File.js +0 -0
  49. package/lib/{types/modules → modules}/FileStation/Info.d.ts +1 -1
  50. package/lib/modules/FileStation/Info.js +9 -0
  51. package/lib/{types/modules → modules}/FileStation/List.d.ts +1 -1
  52. package/lib/modules/FileStation/List.js +30 -0
  53. package/lib/{types/modules → modules}/FileStation/index.d.ts +2 -2
  54. package/lib/{esm/modules → modules}/FileStation/index.js +2 -2
  55. package/lib/modules/VideoStation/File.d.ts +48 -0
  56. package/lib/modules/VideoStation/File.js +20 -0
  57. package/lib/modules/VideoStation/HomeVideo.d.ts +6 -0
  58. package/lib/modules/VideoStation/HomeVideo.js +10 -0
  59. package/lib/modules/VideoStation/Info.d.ts +44 -0
  60. package/lib/modules/VideoStation/Info.js +9 -0
  61. package/lib/modules/VideoStation/Library.d.ts +70 -0
  62. package/lib/modules/VideoStation/Library.js +23 -0
  63. package/lib/modules/VideoStation/Movie.d.ts +27 -0
  64. package/lib/modules/VideoStation/Movie.js +13 -0
  65. package/lib/modules/VideoStation/Streaming.d.ts +11 -0
  66. package/lib/modules/VideoStation/Streaming.js +24 -0
  67. package/lib/modules/VideoStation/index.d.ts +15 -0
  68. package/lib/modules/VideoStation/index.js +16 -0
  69. package/lib/modules/VideoStation/types.d.ts +27 -0
  70. package/lib/modules/VideoStation/types.js +1 -0
  71. package/lib/modules/index.d.ts +26 -0
  72. package/lib/{esm/modules → modules}/index.js +31 -3
  73. package/lib/types/{types/apiInfo.d.ts → apiInfo.d.ts} +15 -2
  74. package/lib/{esm/types → types}/apiInfo.js +15 -1
  75. package/lib/types/index.d.ts +2 -5
  76. package/lib/types/index.js +2 -0
  77. package/lib/{types/utils.d.ts → utils.d.ts} +1 -0
  78. package/lib/{esm/utils.js → utils.js} +3 -0
  79. package/package.json +23 -24
  80. package/bin/syno +0 -6
  81. package/lib/cjs/index.js +0 -728
  82. package/lib/esm/cli/apis.js +0 -53
  83. package/lib/esm/cli/index.js +0 -30
  84. package/lib/esm/core.js +0 -111
  85. package/lib/esm/helpers.js +0 -81
  86. package/lib/esm/index.js +0 -5
  87. package/lib/esm/modules/Api/Auth.js +0 -43
  88. package/lib/esm/modules/Api/Info.js +0 -26
  89. package/lib/esm/modules/Api/index.js +0 -2
  90. package/lib/esm/modules/AudioStation/Song.js +0 -18
  91. package/lib/esm/modules/AudioStation/index.js +0 -7
  92. package/lib/esm/modules/FileStation/Info.js +0 -20
  93. package/lib/esm/modules/FileStation/List.js +0 -32
  94. package/lib/esm/types/index.js +0 -2
  95. package/lib/types/modules/Api/Info.d.ts +0 -3
  96. package/lib/types/modules/Api/index.d.ts +0 -2
  97. package/lib/types/modules/AudioStation/Song.d.ts +0 -22
  98. package/lib/types/modules/AudioStation/index.d.ts +0 -7
  99. package/lib/types/modules/index.d.ts +0 -16
  100. package/lib/types/types/index.d.ts +0 -2
  101. /package/lib/{types/cli → cli}/apis.d.ts +0 -0
  102. /package/lib/{types/cli → cli}/config.d.ts +0 -0
  103. /package/lib/{types/cli/index.d.ts → cli/core.d.ts} +0 -0
  104. /package/lib/{types/constants.d.ts → constants.d.ts} +0 -0
  105. /package/lib/{esm/constants.js → constants.js} +0 -0
  106. /package/lib/{esm/modules/FileStation/File.js → decorators/bindMethods.d.ts} +0 -0
  107. /package/lib/{types/helpers.d.ts → helpers.d.ts} +0 -0
  108. /package/lib/{types/modules/FileStation/File.d.ts → modules/AudioStation/Cover.d.ts} +0 -0
  109. /package/lib/types/{types/request.d.ts → request.d.ts} +0 -0
  110. /package/lib/{esm/types → types}/request.js +0 -0
@@ -1,53 +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
- import { program } from "commander";
11
- import { loadConfig } from "./config";
12
- import { SynologyApi } from "../core";
13
- import { SynologyApiKeys } from "../modules";
14
- export const onMethodsCall = (module) => (method, options) => __awaiter(void 0, void 0, void 0, function* () {
15
- var _a, _b;
16
- const config = yield loadConfig();
17
- const params = JSON.parse(options.params || "{}");
18
- const pretty = options.pretty;
19
- const synologyApi = new SynologyApi(config.connections[config.used]);
20
- if ((_a = synologyApi[module]) === null || _a === void 0 ? void 0 : _a[method]) {
21
- const result = yield ((_b = synologyApi[module]) === null || _b === void 0 ? void 0 : _b[method](params));
22
- if (pretty) {
23
- console.log(JSON.stringify(result, null, 2));
24
- }
25
- else {
26
- console.log(JSON.stringify(result));
27
- }
28
- }
29
- synologyApi.disconnect();
30
- process.exit(0);
31
- });
32
- // register all modules
33
- const apisCmdRegisterInfo = [
34
- {
35
- cmd: SynologyApiKeys.FileStation,
36
- alias: SynologyApiKeys.fs,
37
- },
38
- {
39
- cmd: SynologyApiKeys.AudioStation,
40
- alias: SynologyApiKeys.as,
41
- },
42
- ];
43
- export const apiCmdRegister = () => {
44
- apisCmdRegisterInfo.forEach((info) => {
45
- program
46
- .command(`${info.cmd} [methods]`)
47
- .alias(info.alias)
48
- .option("-p,--params <params>", `${info.cmd} methods params`)
49
- .option("--pretty", "Prettyprint JSON Output")
50
- .description(`Synology ${info.cmd} method call`)
51
- .action(onMethodsCall(info.cmd));
52
- });
53
- };
@@ -1,30 +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
- import fse from "fs-extra";
11
- import path from "path";
12
- import { program } from "commander";
13
- import { configCmdRegister } from "./config";
14
- import { apiCmdRegister } from "./apis";
15
- export function loadCli() {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- // git program info
18
- const pkg = yield fse.readJSON(path.join(__dirname, "../../package.json"));
19
- // command
20
- program
21
- .name("synology")
22
- .usage("<command> [options]")
23
- .description("synology api cli tool")
24
- .version(pkg.version, "-v, --version", "output the version number");
25
- // register commands
26
- configCmdRegister();
27
- apiCmdRegister();
28
- program.parse(process.argv);
29
- });
30
- }
package/lib/esm/core.js DELETED
@@ -1,111 +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
- // reference: https://kb.synology.com/zh-tw/DSM/tutorial/What_websites_does_Synology_NAS_connect_to_when_running_services_or_updating_software
11
- import ky from "ky";
12
- import { BaseSynologyApi } from "./modules";
13
- import { isHttpUrl, getApiKey, isUndfined } from "./utils";
14
- import { getServerInfo } from "./helpers";
15
- import { login, logout, getApiInfo } from "./modules/Api";
16
- import { resWithErrorCode } from "./errorcodes";
17
- export class SynologyApi extends BaseSynologyApi {
18
- constructor(options) {
19
- super();
20
- this.isConnecting = false;
21
- this.authInfo = null;
22
- this.apiInfo = {};
23
- this.server = options.server;
24
- this.username = options.username;
25
- this.password = options.password;
26
- this.baseUrl = `${this.server}/webapi/`;
27
- }
28
- connect() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- // if quickconnect id
31
- if (!isHttpUrl(this.server)) {
32
- this.server = yield getServerInfo(this.server);
33
- // reset base url
34
- this.baseUrl = `${this.server}/webapi/`;
35
- }
36
- try {
37
- const result = yield login(this);
38
- this.authInfo = result.data;
39
- this.isConnecting = true;
40
- yield this._getApiInfo();
41
- return true;
42
- }
43
- catch (err) {
44
- console.error(err);
45
- return false;
46
- }
47
- });
48
- }
49
- disconnect() {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- try {
52
- yield logout(this);
53
- this.authInfo = null;
54
- this.apiInfo = {};
55
- this.isConnecting = false;
56
- return true;
57
- }
58
- catch (err) {
59
- console.error(err);
60
- return false;
61
- }
62
- });
63
- }
64
- _getApiInfo() {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- try {
67
- const result = yield getApiInfo(this);
68
- this.apiInfo = result.data;
69
- }
70
- catch (err) {
71
- console.error(err);
72
- }
73
- });
74
- }
75
- hasApi(apiName) {
76
- if (!this.isConnecting) {
77
- throw new Error("Not connected");
78
- }
79
- return Object.prototype.hasOwnProperty.call(this.apiInfo, apiName);
80
- }
81
- run(apiName, options) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- if (!this.isConnecting) {
84
- const res = yield this.connect();
85
- if (!res) {
86
- throw new Error("Not connected");
87
- }
88
- }
89
- if (!this.hasApi(apiName)) {
90
- throw new Error(`${apiName} not found`);
91
- }
92
- const { method = "get", params, data, headers } = options;
93
- const api = this.apiInfo[apiName];
94
- const url = `${this.baseUrl}${api.path}`;
95
- const externalParams = Object.assign({ api: apiName, version: api.maxVersion, _sid: this.authInfo.sid }, params);
96
- let result = null;
97
- if (method === "get") {
98
- result = yield ky.get(url, { searchParams: externalParams, headers }).json();
99
- }
100
- if (method === "post") {
101
- result = yield ky.post(url, { searchParams: externalParams, json: data, headers }).json();
102
- }
103
- // match error code msg
104
- const apiKey = getApiKey(apiName);
105
- if (!isUndfined(apiKey)) {
106
- result = resWithErrorCode(apiKey, result);
107
- }
108
- return result;
109
- });
110
- }
111
- }
@@ -1,81 +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
- import ky from "ky";
11
- import { GLOBAL_QUICK_CONNECT_URL, QUICK_CONNECT_PINGPANG_API } from "./constants";
12
- const getServersFromServerInfo = (serverInfo) => __awaiter(void 0, void 0, void 0, function* () {
13
- var _a, _b, _c, _d, _e, _f;
14
- // proxy server
15
- if ((_a = serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.service) === null || _a === void 0 ? void 0 : _a.relay_ip) {
16
- const server = `http://${serverInfo.service.relay_ip}:${serverInfo.service.relay_port}`;
17
- const res = yield pingpang(server);
18
- if (res) {
19
- return server;
20
- }
21
- }
22
- // WAN IP
23
- if ((_c = (_b = serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.server) === null || _b === void 0 ? void 0 : _b.external) === null || _c === void 0 ? void 0 : _c.ip) {
24
- const server = `http://${serverInfo.server.external.ip}:${serverInfo.service.port}`;
25
- if (yield pingpang(server)) {
26
- return server;
27
- }
28
- }
29
- // lan ip
30
- if ((_e = (_d = serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.server) === null || _d === void 0 ? void 0 : _d.interface) === null || _e === void 0 ? void 0 : _e[0]) {
31
- const server = `http://${(_f = serverInfo.server.interface) === null || _f === void 0 ? void 0 : _f[0].ip}:${serverInfo.service.port}`;
32
- if (yield pingpang(server)) {
33
- return server;
34
- }
35
- }
36
- });
37
- export const getServerInfo = (quickConnectId) => __awaiter(void 0, void 0, void 0, function* () {
38
- var _a, _b;
39
- const params = {
40
- version: 1,
41
- id: "dsm",
42
- serverID: quickConnectId,
43
- get_ca_fingerprints: true,
44
- command: "get_server_info",
45
- };
46
- const serverInfo = yield ky.post(GLOBAL_QUICK_CONNECT_URL, { json: params }).json();
47
- if (!((_a = serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.service) === null || _a === void 0 ? void 0 : _a.relay_ip) && !((_b = serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.service) === null || _b === void 0 ? void 0 : _b.relay_port)) {
48
- const relayRequestParams = {
49
- version: 1,
50
- id: "dsm",
51
- serverID: quickConnectId,
52
- platform: "web",
53
- command: "request_tunnel",
54
- };
55
- const result = yield ky
56
- .post(`https://${serverInfo.env.control_host}/Serv.php`, { json: relayRequestParams })
57
- .json();
58
- return getServersFromServerInfo(result);
59
- }
60
- else {
61
- return getServersFromServerInfo(serverInfo);
62
- }
63
- });
64
- // pingpang
65
- export const pingpang = (server) => __awaiter(void 0, void 0, void 0, function* () {
66
- try {
67
- const result = yield ky
68
- .get(`${server}/${QUICK_CONNECT_PINGPANG_API}`)
69
- .json();
70
- if (result.success) {
71
- return true;
72
- }
73
- else {
74
- return false;
75
- }
76
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
77
- }
78
- catch (_err) {
79
- return false;
80
- }
81
- });
package/lib/esm/index.js DELETED
@@ -1,5 +0,0 @@
1
- import { SynologyApi } from "./core";
2
- export * from "./types";
3
- export * from "./core";
4
- export * from "./cli";
5
- export default SynologyApi;
@@ -1,43 +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
- import ky from "ky";
11
- import { SynologyApiInfo } from "../../types";
12
- export function login(core) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- const params = {
15
- api: SynologyApiInfo.Auth,
16
- version: 6,
17
- method: "login",
18
- account: core.username,
19
- passwd: core.password,
20
- format: "sid",
21
- };
22
- const url = `${core.baseUrl}entry.cgi`;
23
- const result = yield ky.get(url, { searchParams: params }).json();
24
- if (!result.success) {
25
- throw new Error(result.error.message);
26
- }
27
- return result;
28
- });
29
- }
30
- export function logout(core) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const params = {
33
- api: SynologyApiInfo.Auth,
34
- version: 6,
35
- method: "logout",
36
- };
37
- const url = `${core.baseUrl}entry.cgi`;
38
- const result = yield ky.get(url, { searchParams: params }).json();
39
- if (!result.success) {
40
- throw new Error(result.error.message);
41
- }
42
- });
43
- }
@@ -1,26 +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
- import ky from "ky";
11
- import { SynologyApiInfo } from "../../types";
12
- export function getApiInfo(core) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- const params = {
15
- api: SynologyApiInfo.Info,
16
- version: 1,
17
- method: "query",
18
- };
19
- const url = `${core.baseUrl}entry.cgi`;
20
- const result = yield ky.get(url, { searchParams: params }).json();
21
- if (!result.success) {
22
- throw new Error(result.error.message);
23
- }
24
- return result;
25
- });
26
- }
@@ -1,2 +0,0 @@
1
- export * from "./Auth";
2
- export * from "./Info";
@@ -1,18 +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
- import { AudioStationApi } from "../../types";
11
- export function getSongList(params) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- const res = yield this.run(AudioStationApi.Song, {
14
- params: Object.assign({ method: "list", library: "all" }, params),
15
- });
16
- return res;
17
- });
18
- }
@@ -1,7 +0,0 @@
1
- import { getSongList } from "./Song";
2
- export const METHODS = {
3
- getSongList,
4
- };
5
- // name space
6
- export const SPELLING_KEY = "AudioStation";
7
- export const SIMPLIFY_KEY = "as";
@@ -1,20 +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
- import { FileStationApi } from "../../types";
11
- export function getInfo() {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- const res = yield this.run(FileStationApi.Info, {
14
- params: {
15
- method: "get",
16
- },
17
- });
18
- return res;
19
- });
20
- }
@@ -1,32 +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
- import { FileStationApi } from "../../types";
11
- import { isUndfined } from "../../utils";
12
- export function getFileList() {
13
- return __awaiter(this, arguments, void 0, function* (params = {}) {
14
- const { additional = ["real_path", "size", "owner", "time"], filetype = "all" } = params;
15
- if (isUndfined(params.folder_path)) {
16
- throw new Error("folder_path is required");
17
- }
18
- const res = yield this.run(FileStationApi.List, {
19
- params: Object.assign({ method: "list", additional: JSON.stringify(additional), filetype: filetype, folder_path: params.folder_path }, params),
20
- });
21
- return res;
22
- });
23
- }
24
- export function getFileListShare() {
25
- return __awaiter(this, arguments, void 0, function* (params = {}) {
26
- const { additional = ["real_path", "size", "owner", "time"], onlywritable = false } = params;
27
- const res = yield this.run(FileStationApi.List, {
28
- params: Object.assign({ method: "list_share", additional: JSON.stringify(additional), onlywritable: onlywritable }, params),
29
- });
30
- return res;
31
- });
32
- }
@@ -1,2 +0,0 @@
1
- export * from "./request";
2
- export * from "./apiInfo";
@@ -1,3 +0,0 @@
1
- import { SynologyApiResponse } from "../../types";
2
- import { SynologyApi } from "../../core";
3
- export declare function getApiInfo(core: SynologyApi): Promise<SynologyApiResponse>;
@@ -1,2 +0,0 @@
1
- export * from "./Auth";
2
- export * from "./Info";
@@ -1,22 +0,0 @@
1
- import { SynologyApiResponse } from "../../types";
2
- /**
3
- * fetch song list
4
- * */
5
- export type AudioStationSongListRequest = {
6
- limit?: number;
7
- offset?: number;
8
- method?: string;
9
- library?: string;
10
- additional?: string;
11
- version?: number;
12
- sort_by?: string;
13
- sort_direction?: string;
14
- };
15
- export type AudioStationSongListResponse = SynologyApiResponse<{
16
- offset: number;
17
- total: number;
18
- songs: {
19
- [key: string]: any;
20
- };
21
- }>;
22
- export declare function getSongList(params: AudioStationSongListRequest): Promise<AudioStationSongListResponse>;
@@ -1,7 +0,0 @@
1
- import { getSongList } from "./Song";
2
- export declare const METHODS: {
3
- getSongList: typeof getSongList;
4
- };
5
- export declare const SPELLING_KEY = "AudioStation";
6
- export declare const SIMPLIFY_KEY = "as";
7
- export type TMethods = typeof METHODS;
@@ -1,16 +0,0 @@
1
- import * as AudioStation from "./AudioStation";
2
- import * as FileStation from "./FileStation";
3
- export declare const SynologyApiKeys: {
4
- FileStation: string;
5
- fs: string;
6
- AudioStation: string;
7
- as: string;
8
- };
9
- export type SynologyApiMethods = FileStation.TMethods | AudioStation.TMethods;
10
- export declare class BaseSynologyApi {
11
- [AudioStation.SPELLING_KEY]: AudioStation.TMethods;
12
- [AudioStation.SIMPLIFY_KEY]: AudioStation.TMethods;
13
- [FileStation.SPELLING_KEY]: FileStation.TMethods;
14
- [FileStation.SIMPLIFY_KEY]: FileStation.TMethods;
15
- constructor();
16
- }
@@ -1,2 +0,0 @@
1
- export * from "./request";
2
- export * from "./apiInfo";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes