@fett/synology-api 0.0.1 → 0.0.2-beta.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.
- package/README.md +10 -20
- package/lib/cli/apis.d.ts +2 -1
- package/lib/cli/apis.js +38 -28
- package/lib/cli/config.d.ts +0 -1
- package/lib/cli/config.js +4 -6
- package/lib/decorators/bindMethods.d.ts +5 -0
- package/lib/decorators/bindMethods.js +29 -45
- package/lib/decorators/index.d.ts +1 -0
- package/lib/decorators/index.js +1 -0
- package/lib/helpers.js +11 -8
- package/lib/modules/AudioStation/index.d.ts +2 -2
- package/lib/modules/AudioStation/index.js +2 -2
- package/lib/modules/Auth/index.d.ts +2 -2
- package/lib/modules/Auth/index.js +2 -2
- package/lib/modules/FileStation/index.d.ts +2 -2
- package/lib/modules/FileStation/index.js +2 -2
- package/lib/modules/VideoStation/index.d.ts +2 -2
- package/lib/modules/VideoStation/index.js +2 -2
- package/lib/modules/index.d.ts +10 -9
- package/lib/modules/index.js +69 -68
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a >
|
|
3
|
+
<img width="100" src="assets/logo.png">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
<h1 align="center">Javascript Synology Api</h1>
|
|
2
7
|
|
|
3
8
|
⚠️ The project is under development ...
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
Synology Api Node.js wrapper, can be used in Browser、CLI or Nodejs to interact with Synology NAS.
|
|
10
|
+
Synology Api Javascript wrapper, can be used in Browser、CLI or Nodejs to interact with Synology NAS.
|
|
7
11
|
You can use domain or ip address, also supports Synology Quick Connect connect Synology server.
|
|
8
12
|
All apis from [https://kb.synology.cn](https://kb.synology.cn/zh-cn/search?query=API&services%5B%5D=File_Station)
|
|
9
13
|
|
|
@@ -13,25 +17,10 @@ All apis from [https://kb.synology.cn](https://kb.synology.cn/zh-cn/search?query
|
|
|
13
17
|
npm install @fett/synology-api
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
## Use In Browser
|
|
20
|
+
## Use In Browser or Node.js
|
|
17
21
|
|
|
18
22
|
First you need to confirm that you can access across domains,for example in the React Native environment
|
|
19
23
|
|
|
20
|
-
```js
|
|
21
|
-
import { SynologyApi } from "@fett/synology-api/browser";
|
|
22
|
-
// Create a new instance
|
|
23
|
-
const api = new SynologyApi({
|
|
24
|
-
server: "https://192.168.1.1:5001",
|
|
25
|
-
username: "username",
|
|
26
|
-
password: "password",
|
|
27
|
-
});
|
|
28
|
-
// you can now use the api by calling the methods
|
|
29
|
-
const info = await api.fs.getInfo();
|
|
30
|
-
console.log(info);
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Use In Node.js
|
|
34
|
-
|
|
35
24
|
```js
|
|
36
25
|
import SynologyApi from '@fett/synology-api';
|
|
37
26
|
|
|
@@ -94,4 +83,5 @@ syno fs getInfo --pretty # print file system info
|
|
|
94
83
|
```
|
|
95
84
|
|
|
96
85
|
## License
|
|
97
|
-
|
|
86
|
+
|
|
87
|
+
[MIT](https://github.com/ChrisSong1994/synology-api/blob/main/LICENSE)
|
package/lib/cli/apis.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type MethodOptions = {
|
|
2
2
|
params?: string;
|
|
3
3
|
pretty?: boolean;
|
|
4
|
+
list?: boolean;
|
|
4
5
|
};
|
|
5
|
-
export declare const
|
|
6
|
+
export declare const onMethodCall: (module: string) => (method: string, options: MethodOptions) => Promise<void>;
|
|
6
7
|
export declare const apiCmdRegister: () => void;
|
package/lib/cli/apis.js
CHANGED
|
@@ -1,47 +1,57 @@
|
|
|
1
1
|
import { program } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import { loadConfig } from "./config.js";
|
|
3
4
|
import { SynologyApi } from "../core.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { SynologyApiModules, SynologyApiMethods } from "../modules/index.js";
|
|
6
|
+
import { printMessages } from "./helper.js";
|
|
7
|
+
export const onMethodCall = (module) => async (method, options) => {
|
|
6
8
|
const config = await loadConfig();
|
|
7
9
|
const params = JSON.parse(options.params || "{}");
|
|
8
10
|
const pretty = options.pretty;
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const connection = config.connections?.[config.used];
|
|
12
|
+
if (!connection) {
|
|
13
|
+
throw new Error("Connection undefined");
|
|
14
|
+
}
|
|
15
|
+
if (!SynologyApiMethods[module]) {
|
|
16
|
+
throw new Error(`Module ${module} not found`);
|
|
17
|
+
}
|
|
18
|
+
// list all module methods
|
|
19
|
+
if (!method && options.list) {
|
|
20
|
+
const methods = SynologyApiMethods[module];
|
|
21
|
+
console.log(chalk.greenBright(`${module} methods list:`));
|
|
22
|
+
return printMessages(Object.keys(methods));
|
|
23
|
+
}
|
|
24
|
+
if (!SynologyApiMethods[module]?.[method]) {
|
|
25
|
+
throw new Error(`Module method ${module} not found`);
|
|
26
|
+
}
|
|
27
|
+
if (typeof SynologyApiMethods[module][method] !== "function") {
|
|
28
|
+
throw new Error(`Module method ${module} is not a function`);
|
|
29
|
+
}
|
|
30
|
+
const synologyApi = new SynologyApi(connection);
|
|
31
|
+
const result = await synologyApi[module]?.[method](params);
|
|
32
|
+
if (pretty) {
|
|
33
|
+
console.log(JSON.stringify(result, null, 2));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log(JSON.stringify(result));
|
|
18
37
|
}
|
|
19
38
|
synologyApi.disconnect();
|
|
20
39
|
process.exit(0);
|
|
21
40
|
};
|
|
22
41
|
// register all modules
|
|
23
|
-
const apisCmdRegisterInfo =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
cmd: SynologyApiKeys.AudioStation,
|
|
30
|
-
alias: SynologyApiKeys.as,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
cmd: SynologyApiKeys.VideoStation,
|
|
34
|
-
alias: SynologyApiKeys.vs,
|
|
35
|
-
},
|
|
36
|
-
];
|
|
42
|
+
const apisCmdRegisterInfo = SynologyApiModules.map((module) => ({
|
|
43
|
+
cmd: module.KEY,
|
|
44
|
+
alias: module.ALIAS_KEY,
|
|
45
|
+
}));
|
|
37
46
|
export const apiCmdRegister = () => {
|
|
38
47
|
apisCmdRegisterInfo.forEach((info) => {
|
|
39
48
|
program
|
|
40
|
-
.command(`${info.cmd} [
|
|
49
|
+
.command(`${info.cmd} [method]`)
|
|
41
50
|
.alias(info.alias)
|
|
42
|
-
.option("-p,--params <params>", `${info.cmd}
|
|
51
|
+
.option("-p,--params <params>", `${info.cmd} method params`)
|
|
43
52
|
.option("--pretty", "Prettyprint JSON Output")
|
|
53
|
+
.option("-l,--list", `list all ${info.cmd} methods`)
|
|
44
54
|
.description(`Synology ${info.cmd} method call`)
|
|
45
|
-
.action(
|
|
55
|
+
.action(onMethodCall(info.cmd));
|
|
46
56
|
});
|
|
47
57
|
};
|
package/lib/cli/config.d.ts
CHANGED
|
@@ -9,5 +9,4 @@ export type Config = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const loadConfig: () => Promise<Config>;
|
|
11
11
|
export declare const updateConfig: (config: Config) => Promise<void>;
|
|
12
|
-
export declare const checkConfig: () => Promise<void>;
|
|
13
12
|
export declare const configCmdRegister: () => void;
|
package/lib/cli/config.js
CHANGED
|
@@ -23,8 +23,6 @@ export const loadConfig = async () => {
|
|
|
23
23
|
export const updateConfig = async (config) => {
|
|
24
24
|
await fse.writeJSON(CONFIG_FILE_PATH, config);
|
|
25
25
|
};
|
|
26
|
-
// check config
|
|
27
|
-
export const checkConfig = async () => { };
|
|
28
26
|
export const configCmdRegister = () => {
|
|
29
27
|
const configCmd = program.command("config").description("synology api config management");
|
|
30
28
|
// list connection config
|
|
@@ -51,7 +49,7 @@ export const configCmdRegister = () => {
|
|
|
51
49
|
});
|
|
52
50
|
// add connection
|
|
53
51
|
configCmd
|
|
54
|
-
.command("add
|
|
52
|
+
.command("add <name>")
|
|
55
53
|
.description("Add connection config")
|
|
56
54
|
.requiredOption("-s, --server <server>", "Synology server domain or QuickConnect ID ")
|
|
57
55
|
.requiredOption("-u, --username <username>", "username")
|
|
@@ -62,7 +60,7 @@ export const configCmdRegister = () => {
|
|
|
62
60
|
// 实际代码中应保存配置到文件
|
|
63
61
|
const config = await loadConfig();
|
|
64
62
|
const newConfig = {
|
|
65
|
-
|
|
63
|
+
used: config.used || name,
|
|
66
64
|
connections: {
|
|
67
65
|
...config.connections,
|
|
68
66
|
[name]: {
|
|
@@ -76,7 +74,7 @@ export const configCmdRegister = () => {
|
|
|
76
74
|
});
|
|
77
75
|
// use connection
|
|
78
76
|
configCmd
|
|
79
|
-
.command("use
|
|
77
|
+
.command("use <name>")
|
|
80
78
|
.description("Change current connection")
|
|
81
79
|
.action(async (name) => {
|
|
82
80
|
const config = await loadConfig();
|
|
@@ -91,7 +89,7 @@ export const configCmdRegister = () => {
|
|
|
91
89
|
});
|
|
92
90
|
// del connection
|
|
93
91
|
configCmd
|
|
94
|
-
.command("del
|
|
92
|
+
.command("del <name>")
|
|
95
93
|
.description("Remove a connection")
|
|
96
94
|
.action(async (name) => {
|
|
97
95
|
console.log("Remove a connection", name);
|
|
@@ -1,45 +1,29 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// // 为实例创建绑定方法并缓存
|
|
31
|
-
// const boundMethod = originalMethod.bind(this);
|
|
32
|
-
// Object.defineProperty(this, methodName, {
|
|
33
|
-
// value: boundMethod,
|
|
34
|
-
// configurable: true,
|
|
35
|
-
// writable: true,
|
|
36
|
-
// enumerable: false,
|
|
37
|
-
// });
|
|
38
|
-
// return boundMethod;
|
|
39
|
-
// },
|
|
40
|
-
// };
|
|
41
|
-
// // 将绑定方法定义到类原型上
|
|
42
|
-
// Object.defineProperty(target.prototype, methodName, descriptor);
|
|
43
|
-
// });
|
|
44
|
-
// };
|
|
45
|
-
// }
|
|
1
|
+
// bind methods to context
|
|
2
|
+
function methodsBundler(cxt, methods) {
|
|
3
|
+
const output = {};
|
|
4
|
+
for (const key in methods) {
|
|
5
|
+
output[key] = methods[key].bind(cxt);
|
|
6
|
+
}
|
|
7
|
+
return output;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* bind methods to BaseSynologyApi prototype
|
|
11
|
+
* @param source
|
|
12
|
+
*/
|
|
13
|
+
export function BindMethods(source) {
|
|
14
|
+
return function (target) {
|
|
15
|
+
const modulesKeys = Object.getOwnPropertyNames(source);
|
|
16
|
+
modulesKeys.forEach((moduleName) => {
|
|
17
|
+
const methods = source[moduleName];
|
|
18
|
+
const descriptor = {
|
|
19
|
+
configurable: false,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get() {
|
|
22
|
+
return methodsBundler(this, methods);
|
|
23
|
+
},
|
|
24
|
+
set() { },
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(target.prototype, moduleName, descriptor);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./bindMethods.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./bindMethods.js";
|
package/lib/helpers.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import ky from "ky";
|
|
2
2
|
import { GLOBAL_QUICK_CONNECT_URL, QUICK_CONNECT_PINGPANG_API } from "./constants.js";
|
|
3
3
|
const getServersFromServerInfo = async (serverInfo) => {
|
|
4
|
+
// first lan ip
|
|
5
|
+
// lan ip
|
|
6
|
+
if (serverInfo?.server?.interface?.[0]) {
|
|
7
|
+
const server = `http://${serverInfo.server.interface?.[0].ip}:${serverInfo.service.port}`;
|
|
8
|
+
const res = await pingpang(server);
|
|
9
|
+
if (res) {
|
|
10
|
+
return server;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
4
13
|
// WAN IP
|
|
5
14
|
if (serverInfo?.server?.external?.ip) {
|
|
6
15
|
const server = `http://${serverInfo.server.external.ip}:${serverInfo.service.port}`;
|
|
7
|
-
|
|
16
|
+
const res = await pingpang(server);
|
|
17
|
+
if (res) {
|
|
8
18
|
return server;
|
|
9
19
|
}
|
|
10
20
|
}
|
|
@@ -16,13 +26,6 @@ const getServersFromServerInfo = async (serverInfo) => {
|
|
|
16
26
|
return server;
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
|
-
// lan ip
|
|
20
|
-
if (serverInfo?.server?.interface?.[0]) {
|
|
21
|
-
const server = `http://${serverInfo.server.interface?.[0].ip}:${serverInfo.service.port}`;
|
|
22
|
-
if (await pingpang(server)) {
|
|
23
|
-
return server;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
29
|
};
|
|
27
30
|
export const getServerInfo = async (quickConnectId) => {
|
|
28
31
|
const params = {
|
|
@@ -18,6 +18,6 @@ export declare const METHODS: {
|
|
|
18
18
|
searchLyrics: typeof searchLyrics;
|
|
19
19
|
getInfo: typeof getInfo;
|
|
20
20
|
};
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
21
|
+
export declare const KEY = "AudioStation";
|
|
22
|
+
export declare const ALIAS_KEY = "as";
|
|
23
23
|
export type TMethods = typeof METHODS;
|
|
@@ -2,6 +2,6 @@ import { getAuthKeyGrant } from "./AuthKey.js";
|
|
|
2
2
|
export declare const METHODS: {
|
|
3
3
|
getAuthKeyGrant: typeof getAuthKeyGrant;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const KEY = "Auth";
|
|
6
|
+
export declare const ALIAS_KEY = "au";
|
|
7
7
|
export type TMethods = typeof METHODS;
|
|
@@ -8,6 +8,6 @@ export declare const METHODS: {
|
|
|
8
8
|
getFileList: typeof getFileList;
|
|
9
9
|
getFileListShare: typeof getFileListShare;
|
|
10
10
|
};
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
11
|
+
export declare const KEY = "FileStation";
|
|
12
|
+
export declare const ALIAS_KEY = "fs";
|
|
13
13
|
export type TMethods = typeof METHODS;
|
|
@@ -10,6 +10,6 @@ export declare const METHODS: {
|
|
|
10
10
|
getMoiveInfo: typeof getMoiveInfo;
|
|
11
11
|
getStreamId: typeof getStreamId;
|
|
12
12
|
};
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
13
|
+
export declare const KEY = "VideoStation";
|
|
14
|
+
export declare const ALIAS_KEY = "vs";
|
|
15
15
|
export type TMethods = typeof METHODS;
|
package/lib/modules/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as AudioStation from "./AudioStation/index.js";
|
|
|
2
2
|
import * as FileStation from "./FileStation/index.js";
|
|
3
3
|
import * as VideoStation from "./VideoStation/index.js";
|
|
4
4
|
import * as Auth from "./Auth/index.js";
|
|
5
|
+
export declare const SynologyApiModules: (typeof AudioStation | typeof FileStation | typeof VideoStation | typeof Auth)[];
|
|
5
6
|
export declare const SynologyApiKeys: {
|
|
6
7
|
FileStation: string;
|
|
7
8
|
fs: string;
|
|
@@ -12,15 +13,15 @@ export declare const SynologyApiKeys: {
|
|
|
12
13
|
Auth: string;
|
|
13
14
|
au: string;
|
|
14
15
|
};
|
|
15
|
-
export
|
|
16
|
+
export declare const SynologyApiMethods: {};
|
|
16
17
|
export declare class BaseSynologyApi {
|
|
17
|
-
[AudioStation.
|
|
18
|
-
[AudioStation.
|
|
19
|
-
[FileStation.
|
|
20
|
-
[FileStation.
|
|
21
|
-
[VideoStation.
|
|
22
|
-
[VideoStation.
|
|
23
|
-
[Auth.
|
|
24
|
-
[Auth.
|
|
18
|
+
[AudioStation.KEY]: AudioStation.TMethods;
|
|
19
|
+
[AudioStation.ALIAS_KEY]: AudioStation.TMethods;
|
|
20
|
+
[FileStation.KEY]: FileStation.TMethods;
|
|
21
|
+
[FileStation.ALIAS_KEY]: FileStation.TMethods;
|
|
22
|
+
[VideoStation.KEY]: VideoStation.TMethods;
|
|
23
|
+
[VideoStation.ALIAS_KEY]: VideoStation.TMethods;
|
|
24
|
+
[Auth.KEY]: Auth.TMethods;
|
|
25
|
+
[Auth.ALIAS_KEY]: Auth.TMethods;
|
|
25
26
|
constructor();
|
|
26
27
|
}
|
package/lib/modules/index.js
CHANGED
|
@@ -1,74 +1,75 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
1
35
|
import * as AudioStation from "./AudioStation/index.js";
|
|
2
36
|
import * as FileStation from "./FileStation/index.js";
|
|
3
37
|
import * as VideoStation from "./VideoStation/index.js";
|
|
4
38
|
import * as Auth from "./Auth/index.js";
|
|
39
|
+
import { BindMethods } from "../decorators/index.js";
|
|
40
|
+
export const SynologyApiModules = [FileStation, AudioStation, VideoStation, Auth];
|
|
5
41
|
export const SynologyApiKeys = {
|
|
6
|
-
FileStation: FileStation.
|
|
7
|
-
fs: FileStation.
|
|
8
|
-
AudioStation: AudioStation.
|
|
9
|
-
as: AudioStation.
|
|
10
|
-
VideoStation: VideoStation.
|
|
11
|
-
vs: VideoStation.
|
|
12
|
-
Auth: Auth.
|
|
13
|
-
au: Auth.
|
|
42
|
+
FileStation: FileStation.KEY,
|
|
43
|
+
fs: FileStation.ALIAS_KEY,
|
|
44
|
+
AudioStation: AudioStation.KEY,
|
|
45
|
+
as: AudioStation.ALIAS_KEY,
|
|
46
|
+
VideoStation: VideoStation.KEY,
|
|
47
|
+
vs: VideoStation.ALIAS_KEY,
|
|
48
|
+
Auth: Auth.KEY,
|
|
49
|
+
au: Auth.ALIAS_KEY,
|
|
14
50
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Object.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
// AudioStation
|
|
42
|
-
[SynologyApiKeys.AudioStation]: {
|
|
43
|
-
get() {
|
|
44
|
-
return methodsBundler(this, AudioStation.METHODS);
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
[SynologyApiKeys.as]: {
|
|
48
|
-
get() {
|
|
49
|
-
return methodsBundler(this, AudioStation.METHODS);
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
// VideoStation
|
|
53
|
-
[SynologyApiKeys.VideoStation]: {
|
|
54
|
-
get() {
|
|
55
|
-
return methodsBundler(this, VideoStation.METHODS);
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
[SynologyApiKeys.vs]: {
|
|
59
|
-
get() {
|
|
60
|
-
return methodsBundler(this, VideoStation.METHODS);
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
// Auth
|
|
64
|
-
[SynologyApiKeys.Auth]: {
|
|
65
|
-
get() {
|
|
66
|
-
return methodsBundler(this, Auth.METHODS);
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
[SynologyApiKeys.au]: {
|
|
70
|
-
get() {
|
|
71
|
-
return methodsBundler(this, Auth.METHODS);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
51
|
+
export const SynologyApiMethods = SynologyApiModules.reduce((acc, module) => {
|
|
52
|
+
acc[module.KEY] = module.METHODS;
|
|
53
|
+
acc[module.ALIAS_KEY] = module.METHODS;
|
|
54
|
+
return acc;
|
|
55
|
+
}, {});
|
|
56
|
+
let BaseSynologyApi = (() => {
|
|
57
|
+
let _classDecorators = [BindMethods(SynologyApiMethods)];
|
|
58
|
+
let _classDescriptor;
|
|
59
|
+
let _classExtraInitializers = [];
|
|
60
|
+
let _classThis;
|
|
61
|
+
var BaseSynologyApi = class {
|
|
62
|
+
static { _classThis = this; }
|
|
63
|
+
static { AudioStation.KEY, AudioStation.ALIAS_KEY, FileStation.KEY, FileStation.ALIAS_KEY, VideoStation.KEY, VideoStation.ALIAS_KEY, Auth.KEY, Auth.ALIAS_KEY; }
|
|
64
|
+
static {
|
|
65
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
66
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
67
|
+
BaseSynologyApi = _classThis = _classDescriptor.value;
|
|
68
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
69
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
70
|
+
}
|
|
71
|
+
constructor() { }
|
|
72
|
+
};
|
|
73
|
+
return BaseSynologyApi = _classThis;
|
|
74
|
+
})();
|
|
75
|
+
export { BaseSynologyApi };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fett/synology-api",
|
|
3
|
-
"version": "0.0.1",
|
|
3
|
+
"version": "0.0.2-beta.1",
|
|
4
4
|
"description": "synology api for nodejs",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -28,11 +28,14 @@
|
|
|
28
28
|
"nodejs",
|
|
29
29
|
"browser",
|
|
30
30
|
"typescript",
|
|
31
|
-
"esmodule"
|
|
31
|
+
"esmodule",
|
|
32
|
+
"cli",
|
|
33
|
+
"vitest"
|
|
32
34
|
],
|
|
33
35
|
"scripts": {
|
|
34
|
-
"dev
|
|
36
|
+
"dev": "npm run clean && concurrently --kill-others \"tsc --sourceMap -w\" \"tsc-alias -w\"",
|
|
35
37
|
"build": "npm run clean && tsc && tsc-alias",
|
|
38
|
+
"build:dev": "cross-env NODE_ENV=development npm run build",
|
|
36
39
|
"docs:dev": "rspress dev",
|
|
37
40
|
"docs:build": "cross-env BASE_PATH=/synology-api/ rspress build",
|
|
38
41
|
"docs:preview": "rspress preview",
|
|
@@ -48,6 +51,7 @@
|
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"@eslint/js": "^9.26.0",
|
|
54
|
+
"concurrently": "^9.2.0",
|
|
51
55
|
"cross-env": "^7.0.3",
|
|
52
56
|
"eslint": "9.25.1",
|
|
53
57
|
"execa": "^9.6.0",
|