@fett/synology-api 0.0.1-beta.1 → 0.0.1-beta.2

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 (45) hide show
  1. package/dist/cjs/constants.js +7 -0
  2. package/dist/cjs/core.js +109 -0
  3. package/dist/cjs/helpers.js +88 -0
  4. package/dist/cjs/index.js +19 -0
  5. package/dist/cjs/modules/Api/Auth.js +50 -0
  6. package/dist/cjs/modules/Api/Info.js +32 -0
  7. package/dist/cjs/modules/Api/index.js +18 -0
  8. package/dist/cjs/modules/AudioStation/Song/index.js +28 -0
  9. package/dist/cjs/modules/AudioStation/Song/types.js +2 -0
  10. package/dist/cjs/modules/AudioStation/index.js +8 -0
  11. package/dist/cjs/modules/index.js +24 -0
  12. package/dist/cjs/types/API.js +3 -0
  13. package/dist/cjs/types/index.js +17 -0
  14. package/dist/cjs/utils.js +19 -0
  15. package/dist/esm/index.js +3 -0
  16. package/dist/types/index.d.ts +3 -1
  17. package/dist/types/types/index.d.ts +1 -0
  18. package/package.json +22 -11
  19. package/dist/index.d.ts +0 -3
  20. package/dist/index.js +0 -3
  21. /package/dist/{constants.js → esm/constants.js} +0 -0
  22. /package/dist/{core.js → esm/core.js} +0 -0
  23. /package/dist/{helpers.js → esm/helpers.js} +0 -0
  24. /package/dist/{modules → esm/modules}/Api/Auth.js +0 -0
  25. /package/dist/{modules → esm/modules}/Api/Info.js +0 -0
  26. /package/dist/{modules → esm/modules}/Api/index.js +0 -0
  27. /package/dist/{modules → esm/modules}/AudioStation/Song/index.js +0 -0
  28. /package/dist/{modules → esm/modules}/AudioStation/Song/types.js +0 -0
  29. /package/dist/{modules → esm/modules}/AudioStation/index.js +0 -0
  30. /package/dist/{modules → esm/modules}/index.js +0 -0
  31. /package/dist/{types → esm/types}/API.js +0 -0
  32. /package/dist/{types → esm/types}/index.js +0 -0
  33. /package/dist/{utils.js → esm/utils.js} +0 -0
  34. /package/dist/{constants.d.ts → types/constants.d.ts} +0 -0
  35. /package/dist/{core.d.ts → types/core.d.ts} +0 -0
  36. /package/dist/{helpers.d.ts → types/helpers.d.ts} +0 -0
  37. /package/dist/{modules → types/modules}/Api/Auth.d.ts +0 -0
  38. /package/dist/{modules → types/modules}/Api/Info.d.ts +0 -0
  39. /package/dist/{modules → types/modules}/Api/index.d.ts +0 -0
  40. /package/dist/{modules → types/modules}/AudioStation/Song/index.d.ts +0 -0
  41. /package/dist/{modules → types/modules}/AudioStation/Song/types.d.ts +0 -0
  42. /package/dist/{modules → types/modules}/AudioStation/index.d.ts +0 -0
  43. /package/dist/{modules → types/modules}/index.d.ts +0 -0
  44. /package/dist/types/{API.d.ts → types/API.d.ts} +0 -0
  45. /package/dist/{utils.d.ts → types/utils.d.ts} +0 -0
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QUICK_CONNECT_PINGPANG_API = exports.GLOBAL_QUICK_CONNECT_URL = exports.SYNOLOGY_API_INFO = exports.SYNOLOGY_API_AUTH = void 0;
4
+ exports.SYNOLOGY_API_AUTH = "SYNO.API.Auth";
5
+ exports.SYNOLOGY_API_INFO = "SYNO.API.Info";
6
+ exports.GLOBAL_QUICK_CONNECT_URL = "https://global.quickconnect.cn/Serv.php";
7
+ exports.QUICK_CONNECT_PINGPANG_API = "/webman/pingpong.cgi?action=cors&quickconnect=true";
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SynologyApi = void 0;
16
+ // reference: https://kb.synology.com/zh-tw/DSM/tutorial/What_websites_does_Synology_NAS_connect_to_when_running_services_or_updating_software
17
+ const axios_1 = __importDefault(require("axios"));
18
+ const modules_1 = require("./modules");
19
+ const utils_1 = require("./utils");
20
+ const helpers_1 = require("./helpers");
21
+ const Api_1 = require("./modules/Api");
22
+ class SynologyApi extends modules_1.BaseSynologyApi {
23
+ constructor(options) {
24
+ super();
25
+ this.isConnecting = false;
26
+ this.authInfo = null;
27
+ this.apiInfo = {};
28
+ this.server = options.server;
29
+ this.username = options.username;
30
+ this.password = options.password;
31
+ this.baseUrl = `${this.server}/webapi/`;
32
+ }
33
+ connect() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ // if quickconnect id
36
+ if (!(0, utils_1.isHttpUrl)(this.server)) {
37
+ this.server = yield (0, helpers_1.getServerInfo)(this.server);
38
+ // reset base url
39
+ this.baseUrl = `${this.server}/webapi/`;
40
+ }
41
+ try {
42
+ const result = yield (0, Api_1.login)(this);
43
+ this.authInfo = result.data;
44
+ this.isConnecting = true;
45
+ yield this._getApiInfo();
46
+ return true;
47
+ }
48
+ catch (err) {
49
+ console.error(err);
50
+ return false;
51
+ }
52
+ });
53
+ }
54
+ disconnect() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ try {
57
+ yield (0, Api_1.logout)(this);
58
+ this.authInfo = null;
59
+ this.apiInfo = {};
60
+ this.isConnecting = false;
61
+ return true;
62
+ }
63
+ catch (err) {
64
+ console.error(err);
65
+ return false;
66
+ }
67
+ });
68
+ }
69
+ _getApiInfo() {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ try {
72
+ const result = yield (0, Api_1.getApiInfo)(this);
73
+ this.apiInfo = result.data;
74
+ }
75
+ catch (err) {
76
+ console.error(err);
77
+ }
78
+ });
79
+ }
80
+ hasApi(apiName) {
81
+ if (!this.isConnecting) {
82
+ throw new Error("Not connected");
83
+ }
84
+ return Object.prototype.hasOwnProperty.call(this.apiInfo, apiName);
85
+ }
86
+ run(apiName, options) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ if (!this.isConnecting) {
89
+ throw new Error("Not connected");
90
+ }
91
+ if (!this.hasApi(apiName)) {
92
+ throw new Error(`${apiName} not found`);
93
+ }
94
+ const { method = "get", params, data, headers } = options;
95
+ const api = this.apiInfo[apiName];
96
+ const url = `${this.baseUrl}${api.path}`;
97
+ const externalParams = Object.assign({ api: apiName, version: api.maxVersion, _sid: this.authInfo.sid }, params);
98
+ let result = null;
99
+ if (method === "get") {
100
+ result = yield axios_1.default.get(url, { params: externalParams, data, headers });
101
+ }
102
+ if (method === "post") {
103
+ result = yield axios_1.default.post(url, { params: externalParams, data, headers });
104
+ }
105
+ return result;
106
+ });
107
+ }
108
+ }
109
+ exports.SynologyApi = SynologyApi;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.pingpang = exports.getServerInfo = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const constants_1 = require("./constants");
18
+ const getServersFromServerInfo = (serverInfo) => __awaiter(void 0, void 0, void 0, function* () {
19
+ var _a, _b;
20
+ // proxy server
21
+ if (serverInfo.service.relay_ip) {
22
+ const server = `http://${serverInfo.service.relay_ip}:${serverInfo.service.relay_port}`;
23
+ const res = yield (0, exports.pingpang)(server);
24
+ if (res) {
25
+ return server;
26
+ }
27
+ }
28
+ // WAN IP
29
+ if (serverInfo.server.external.ip) {
30
+ const server = `http://${serverInfo.server.external.ip}:${serverInfo.service.port}`;
31
+ if (yield (0, exports.pingpang)(server)) {
32
+ return server;
33
+ }
34
+ }
35
+ // lan ip
36
+ if ((_a = serverInfo.server.interface) === null || _a === void 0 ? void 0 : _a[0]) {
37
+ const server = `http://${(_b = serverInfo.server.interface) === null || _b === void 0 ? void 0 : _b[0].ip}:${serverInfo.service.port}`;
38
+ if (yield (0, exports.pingpang)(server)) {
39
+ return server;
40
+ }
41
+ }
42
+ });
43
+ // get server ip
44
+ const getServerInfo = (quickConnectId) => __awaiter(void 0, void 0, void 0, function* () {
45
+ var _a, _b, _c, _d;
46
+ const params = {
47
+ version: 1,
48
+ id: "dsm",
49
+ serverID: quickConnectId,
50
+ get_ca_fingerprints: true,
51
+ command: "get_server_info",
52
+ };
53
+ const serverInfo = yield axios_1.default.post(constants_1.GLOBAL_QUICK_CONNECT_URL, params);
54
+ if (!((_b = (_a = serverInfo.data) === null || _a === void 0 ? void 0 : _a.service) === null || _b === void 0 ? void 0 : _b.relay_ip) && !((_d = (_c = serverInfo.data) === null || _c === void 0 ? void 0 : _c.service) === null || _d === void 0 ? void 0 : _d.relay_port)) {
55
+ const relayRequestParams = {
56
+ version: 1,
57
+ id: "dsm",
58
+ serverID: quickConnectId,
59
+ platform: "web",
60
+ command: "request_tunnel",
61
+ };
62
+ const result = yield axios_1.default.post(`https://${serverInfo.data.env.control_host}/Serv.php`, relayRequestParams);
63
+ return getServersFromServerInfo(result.data);
64
+ }
65
+ else {
66
+ return getServersFromServerInfo(serverInfo.data);
67
+ }
68
+ });
69
+ exports.getServerInfo = getServerInfo;
70
+ // pingpang
71
+ const pingpang = (server) => __awaiter(void 0, void 0, void 0, function* () {
72
+ try {
73
+ const result = yield axios_1.default.get(`${server}/${constants_1.QUICK_CONNECT_PINGPANG_API}`, {
74
+ timeout: 3000,
75
+ });
76
+ if (result.data.success) {
77
+ return true;
78
+ }
79
+ else {
80
+ return false;
81
+ }
82
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
83
+ }
84
+ catch (_err) {
85
+ return false;
86
+ }
87
+ });
88
+ exports.pingpang = pingpang;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const core_1 = require("./core");
18
+ __exportStar(require("./core"), exports);
19
+ exports.default = core_1.SynologyApi;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.login = login;
16
+ exports.logout = logout;
17
+ const axios_1 = __importDefault(require("axios"));
18
+ const constants_1 = require("@/constants");
19
+ function login(core) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const params = {
22
+ api: constants_1.SYNOLOGY_API_AUTH,
23
+ version: 6,
24
+ method: "login",
25
+ account: core.username,
26
+ passwd: core.password,
27
+ format: "sid",
28
+ };
29
+ const url = `${core.baseUrl}entry.cgi`;
30
+ const result = yield axios_1.default.get(url, { params });
31
+ if (!result.data.success) {
32
+ throw new Error(result.data.error.message);
33
+ }
34
+ return result.data;
35
+ });
36
+ }
37
+ function logout(core) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const params = {
40
+ api: constants_1.SYNOLOGY_API_AUTH,
41
+ version: 6,
42
+ method: "logout",
43
+ };
44
+ const url = `${core.baseUrl}entry.cgi`;
45
+ const result = yield axios_1.default.get(url, { params });
46
+ if (!result.data.success) {
47
+ throw new Error(result.data.error.message);
48
+ }
49
+ });
50
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getApiInfo = getApiInfo;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const constants_1 = require("@/constants");
18
+ function getApiInfo(core) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const params = {
21
+ api: constants_1.SYNOLOGY_API_INFO,
22
+ version: 1,
23
+ method: "query",
24
+ };
25
+ const url = `${core.baseUrl}entry.cgi`;
26
+ const result = yield axios_1.default.get(url, { params });
27
+ if (!result.data.success) {
28
+ throw new Error(result.data.error.message);
29
+ }
30
+ return result.data;
31
+ });
32
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Auth"), exports);
18
+ __exportStar(require("./Info"), exports);
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getSongList = getSongList;
13
+ /**
14
+ * fetch song list
15
+ * */
16
+ function getSongList(params) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const res = yield this.run("SYNO.AudioStation.Song", {
19
+ params: {
20
+ method: "list",
21
+ library: "all",
22
+ limit: params.limit,
23
+ offset: params.offset,
24
+ },
25
+ });
26
+ return res.data;
27
+ });
28
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudioStationKey = exports.AudioStationMethods = void 0;
4
+ const Song_1 = require("./Song");
5
+ exports.AudioStationMethods = {
6
+ getSongList: Song_1.getSongList,
7
+ };
8
+ exports.AudioStationKey = "AudioStation";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSynologyApi = void 0;
4
+ const AudioStation_1 = require("./AudioStation");
5
+ // bind methods to BaseSynologyApi instance
6
+ function methodsBundler(instance, methods) {
7
+ const output = {};
8
+ for (const key in methods) {
9
+ output[key] = methods[key].bind(instance);
10
+ }
11
+ return output;
12
+ }
13
+ class BaseSynologyApi {
14
+ constructor() { }
15
+ }
16
+ exports.BaseSynologyApi = BaseSynologyApi;
17
+ // proxy methods namespace to BaseSynologyApi instance
18
+ Object.defineProperties(BaseSynologyApi.prototype, {
19
+ [AudioStation_1.AudioStationKey]: {
20
+ get() {
21
+ return methodsBundler(this, AudioStation_1.AudioStationMethods);
22
+ },
23
+ },
24
+ });
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // export response
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./API"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObjEmpty = isObjEmpty;
4
+ exports.queryObjToString = queryObjToString;
5
+ exports.isHttpUrl = isHttpUrl;
6
+ function isObjEmpty(obj) {
7
+ return obj && typeof obj === "object" && Object.keys(obj).length === 0;
8
+ }
9
+ function queryObjToString(params) {
10
+ if (isObjEmpty(params)) {
11
+ return "";
12
+ }
13
+ return Object.keys(params)
14
+ .map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key]))
15
+ .join("&");
16
+ }
17
+ function isHttpUrl(url) {
18
+ return /^https?:\/\//.test(url);
19
+ }
@@ -0,0 +1,3 @@
1
+ import { SynologyApi } from "./core";
2
+ export * from "./core";
3
+ export default SynologyApi;
@@ -1 +1,3 @@
1
- export * from "./API";
1
+ import { SynologyApi } from "./core";
2
+ export * from "./core";
3
+ export default SynologyApi;
@@ -0,0 +1 @@
1
+ export * from "./API";
package/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
2
  "name": "@fett/synology-api",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.1-beta.2",
4
4
  "description": "synology api for nodejs",
5
- "module": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
5
+ "module": "./dist/esm/index.js",
6
+ "main": "./dist/cjs/index.js",
7
+ "types": "./dist/types/index.d.ts",
7
8
  "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "require": "./dist/cjs/index.js",
12
+ "import": "./dist/esm/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
8
18
  "author": "ChrisSong1994 <https://github.com/ChrisSong1994>",
9
19
  "keywords": [
10
20
  "synology",
@@ -12,22 +22,23 @@
12
22
  "nodejs",
13
23
  "browser",
14
24
  "typescript",
15
- "esmodule"
16
- ],
17
- "files": [
18
- "dist"
25
+ "esmodule",
26
+ "cjs",
27
+ "commonjs"
19
28
  ],
20
29
  "scripts": {
21
- "dev": "tsc && tsc-alias --sourceMap --watch",
22
- "build": "npm run clean && tsc && tsc-alias",
30
+ "dev": "tsc --sourceMap --watch && tsc-alias",
31
+ "build:cjs": "tsc --module commonjs --outDir dist/cjs && tsc-alias",
32
+ "build:esm": "tsc --module esnext --outDir dist/esm && tsc-alias",
33
+ "build": "npm run clean && npm run build:cjs && npm run build:esm",
34
+ "clean": "rimraf dist",
23
35
  "lint": "eslint src --ext .ts --fix",
24
36
  "prettier": "prettier --write 'src/**/*.ts'",
25
37
  "format": "npm run prettier && npm run lint",
26
38
  "prepublish": "npm run build",
27
39
  "pub": "npm publish --access=public",
28
40
  "test": "vitest",
29
- "coverage": "vitest run --coverage",
30
- "clean": "rimraf dist"
41
+ "coverage": "vitest run --coverage"
31
42
  },
32
43
  "license": "ISC",
33
44
  "packageManager": "pnpm@10.8.1",
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./core";
2
- export * from "./modules";
3
- export { SynologyApi as default } from "./core";
package/dist/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./core";
2
- export * from "./modules";
3
- export { SynologyApi as default } from "./core";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes