@fett/synology-api 0.0.3-beta.1 → 0.0.3-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.
package/lib/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestConfig } from "axios";
2
- import { BaseSynologyApi } from "./modules/index.js";
2
+ import { BaseModuleSynologyApi } from "./modules/index.js";
3
3
  import { QuickConnectServerType } from "./types/index.js";
4
4
  interface Agent {
5
5
  http?: {
@@ -30,7 +30,7 @@ export interface SynologyApiAuthInfo {
30
30
  is_portal_port: boolean;
31
31
  synotoken: string;
32
32
  }
33
- export declare class SynologyApi extends BaseSynologyApi {
33
+ export declare class SynologyApi extends BaseModuleSynologyApi {
34
34
  server: string;
35
35
  username: string;
36
36
  password: string;
package/lib/core.js CHANGED
@@ -1,13 +1,13 @@
1
1
  // reference: https://kb.synology.com/zh-tw/DSM/tutorial/What_websites_does_Synology_NAS_connect_to_when_running_services_or_updating_software
2
2
  import Axios from "axios";
3
3
  import { isNode } from "./utils/index.js";
4
- import { BaseSynologyApi } from "./modules/index.js";
4
+ import { BaseModuleSynologyApi } from "./modules/index.js";
5
5
  import { isHttpUrl, getApiKey, isUndfined } from "./utils/index.js";
6
6
  import { getServerInfo } from "./helpers.js";
7
7
  import { login, logout, getApiInfo } from "./modules/Api/index.js";
8
8
  import { resWithErrorCode } from "./errorcodes.js";
9
9
  import { QuickConnectServerType } from "./types/index.js";
10
- export class SynologyApi extends BaseSynologyApi {
10
+ export class SynologyApi extends BaseModuleSynologyApi {
11
11
  constructor(options) {
12
12
  super();
13
13
  this.isConnecting = false;
@@ -106,12 +106,13 @@ export class SynologyApi extends BaseSynologyApi {
106
106
  // https agent for node
107
107
  if (isNode) {
108
108
  if (this.agent?.https) {
109
- const HttpsProxyAgent = require("https-proxy-agent").HttpsProxyAgent;
110
- requestOptions.httpsAgent = new HttpsProxyAgent(`https://${this.agent.https.host}:${this.agent.https.port}`);
109
+ const hspa = await import("https-proxy-agent");
110
+ requestOptions.httpsAgent = new hspa.HttpsProxyAgent(`https://${this.agent.https.host}:${this.agent.https.port}`);
111
111
  }
112
112
  // http agent
113
113
  if (this.agent?.http) {
114
- const HttpProxyAgent = require("http-proxy-agent").HttpProxyAgent;
114
+ const hpa = await import("http-proxy-agent");
115
+ const HttpProxyAgent = hpa.HttpProxyAgent;
115
116
  requestOptions.httpAgent = new HttpProxyAgent(`http://${this.agent.http.host}:${this.agent.http.port}`);
116
117
  }
117
118
  }
@@ -0,0 +1,50 @@
1
+ import { AxiosRequestConfig } from "axios";
2
+ import { RnBaseModuleSynologyApi } from "./modules/index.rn.js";
3
+ import { QuickConnectServerType } from "./types/index.js";
4
+ export interface SynologyApiOptions {
5
+ server: string;
6
+ username: string;
7
+ password: string;
8
+ quickConnectServerType?: QuickConnectServerType;
9
+ }
10
+ export interface SynologyApiInfoData {
11
+ maxVersion: number;
12
+ minVersion: number;
13
+ path: string;
14
+ requestFormat?: string;
15
+ }
16
+ export interface SynologyApiAuthInfo {
17
+ sid: string;
18
+ did: number;
19
+ is_portal_port: boolean;
20
+ synotoken: string;
21
+ }
22
+ export declare class RnSynologyApi extends RnBaseModuleSynologyApi {
23
+ server: string;
24
+ username: string;
25
+ password: string;
26
+ baseUrl: string;
27
+ isConnecting: boolean;
28
+ quickConnectServerType?: QuickConnectServerType;
29
+ private authInfo;
30
+ private apiInfo;
31
+ constructor(options: SynologyApiOptions);
32
+ connect(): Promise<boolean>;
33
+ disconnect(): Promise<boolean>;
34
+ private _getApiInfo;
35
+ protected getApiInfoByName(apiName: string): SynologyApiInfoData;
36
+ hasApi(apiName: string): any;
37
+ getApiInfo(): Record<string, SynologyApiInfoData>;
38
+ protected genRequestOptions(apiName: string, options: {
39
+ method?: "get" | "post";
40
+ params?: Record<string, any>;
41
+ data?: Record<string, any>;
42
+ headers?: Record<string, any>;
43
+ }): Promise<AxiosRequestConfig>;
44
+ protected run(apiName: string, options: {
45
+ method?: "get" | "post";
46
+ params?: Record<string, any>;
47
+ data?: Record<string, any>;
48
+ headers?: Record<string, any>;
49
+ }): Promise<any>;
50
+ }
package/lib/core.rn.js ADDED
@@ -0,0 +1,120 @@
1
+ // reference: https://kb.synology.com/zh-tw/DSM/tutorial/What_websites_does_Synology_NAS_connect_to_when_running_services_or_updating_software
2
+ import Axios from "axios";
3
+ import { RnBaseModuleSynologyApi } from "./modules/index.rn.js";
4
+ import { isHttpUrl, getApiKey, isUndfined } from "./utils/index.js";
5
+ import { getServerInfo } from "./helpers.js";
6
+ import { login, logout, getApiInfo } from "./modules/Api/index.js";
7
+ import { resWithErrorCode } from "./errorcodes.js";
8
+ import { QuickConnectServerType } from "./types/index.js";
9
+ export class RnSynologyApi extends RnBaseModuleSynologyApi {
10
+ constructor(options) {
11
+ super();
12
+ this.isConnecting = false;
13
+ this.authInfo = null;
14
+ this.apiInfo = {};
15
+ this.server = options.server;
16
+ this.username = options.username;
17
+ this.password = options.password;
18
+ this.quickConnectServerType = options.quickConnectServerType ?? QuickConnectServerType.proxy;
19
+ this.baseUrl = `${this.server}/webapi/`;
20
+ }
21
+ async connect() {
22
+ // if quickconnect id
23
+ if (!isHttpUrl(this.server)) {
24
+ this.server = await getServerInfo(this.server, this.quickConnectServerType);
25
+ this.baseUrl = `${this.server}/webapi/`;
26
+ }
27
+ try {
28
+ const result = await login(this);
29
+ this.authInfo = result.data;
30
+ this.isConnecting = true;
31
+ await this._getApiInfo();
32
+ return true;
33
+ }
34
+ catch (err) {
35
+ console.error(err);
36
+ return false;
37
+ }
38
+ }
39
+ async disconnect() {
40
+ try {
41
+ await logout(this);
42
+ this.authInfo = null;
43
+ this.apiInfo = {};
44
+ this.isConnecting = false;
45
+ return true;
46
+ }
47
+ catch (err) {
48
+ console.error(err);
49
+ return false;
50
+ }
51
+ }
52
+ async _getApiInfo() {
53
+ try {
54
+ const result = await getApiInfo(this);
55
+ this.apiInfo = result.data;
56
+ }
57
+ catch (err) {
58
+ console.error(err);
59
+ }
60
+ }
61
+ getApiInfoByName(apiName) {
62
+ return this.apiInfo[apiName];
63
+ }
64
+ hasApi(apiName) {
65
+ if (!this.isConnecting) {
66
+ throw new Error("Not connected");
67
+ }
68
+ return Object.prototype.hasOwnProperty.call(this.apiInfo, apiName);
69
+ }
70
+ getApiInfo() {
71
+ if (!this.isConnecting) {
72
+ throw new Error("Not connected");
73
+ }
74
+ return this.apiInfo;
75
+ }
76
+ async genRequestOptions(apiName, options) {
77
+ if (!this.isConnecting) {
78
+ const res = await this.connect();
79
+ if (!res) {
80
+ throw new Error("Not connected");
81
+ }
82
+ }
83
+ if (!this.hasApi(apiName)) {
84
+ throw new Error(`${apiName} not found`);
85
+ }
86
+ const api = this.apiInfo[apiName];
87
+ const url = `${this.baseUrl}${api.path}`;
88
+ // create options
89
+ const requestOptions = {
90
+ url: url,
91
+ method: options.method || "get",
92
+ params: {
93
+ api: apiName,
94
+ version: api.maxVersion || api.minVersion,
95
+ _sid: this.authInfo.sid,
96
+ ...(options.params ?? {}),
97
+ },
98
+ headers: {
99
+ ...(options.headers ?? {}),
100
+ "x-syno-token": this.authInfo.synotoken,
101
+ },
102
+ data: options.data ?? null,
103
+ };
104
+ return requestOptions;
105
+ }
106
+ async run(apiName, options) {
107
+ const requestOptions = await this.genRequestOptions(apiName, options);
108
+ const apiKey = getApiKey(apiName);
109
+ try {
110
+ let result = (await Axios(requestOptions)).data;
111
+ if (!isUndfined(apiKey)) {
112
+ result = resWithErrorCode(apiKey, result);
113
+ }
114
+ return result;
115
+ }
116
+ catch (err) {
117
+ return resWithErrorCode(apiKey, { error: err, success: false });
118
+ }
119
+ }
120
+ }
@@ -0,0 +1,4 @@
1
+ import { RnSynologyApi as SynologyApi } from "./core.rn.js";
2
+ export * from "./types/index.js";
3
+ export * from "./core.rn.js";
4
+ export default SynologyApi;
@@ -0,0 +1,4 @@
1
+ import { RnSynologyApi as SynologyApi } from "./core.rn.js";
2
+ export * from "./types/index.js";
3
+ export * from "./core.rn.js";
4
+ export default SynologyApi;
@@ -1,4 +1,5 @@
1
1
  import { SynologyApiResponse } from "../../types/index.js";
2
2
  import { SynologyApi } from "../../core.js";
3
- export declare function login(core: SynologyApi): Promise<SynologyApiResponse>;
4
- export declare function logout(core: SynologyApi): Promise<void>;
3
+ import { RnSynologyApi } from "../../core.rn.js";
4
+ export declare function login(core: SynologyApi | RnSynologyApi): Promise<SynologyApiResponse>;
5
+ export declare function logout(core: SynologyApi | RnSynologyApi): Promise<void>;
@@ -1,3 +1,4 @@
1
1
  import { SynologyApiResponse } from "../../types/index.js";
2
2
  import { SynologyApi } from "../../core.js";
3
- export declare function getApiInfo(core: SynologyApi): Promise<SynologyApiResponse>;
3
+ import { RnSynologyApi } from "../../core.rn.js";
4
+ export declare function getApiInfo(core: SynologyApi | RnSynologyApi): Promise<SynologyApiResponse>;
@@ -0,0 +1,21 @@
1
+ import { AxiosProgressEvent } from "axios";
2
+ import { SynologyApiResponse } from "../../types/index.js";
3
+ declare enum OverwriteEnum {
4
+ OVERWRITE = "overwrite",
5
+ SKIP = "skip"
6
+ }
7
+ export type UploadFileParams = {
8
+ path: string;
9
+ file: File | Blob | string | any;
10
+ overwrite?: OverwriteEnum;
11
+ create_parents?: boolean;
12
+ onUploadProgress?: (progress: AxiosProgressEvent) => void;
13
+ };
14
+ export type UploadFileResponse = SynologyApiResponse<{
15
+ blSkip: boolean;
16
+ file: string;
17
+ pid: number;
18
+ progress: number;
19
+ }>;
20
+ export declare function uploadFileBase(params: UploadFileParams, parseFileFn: (file: File | Blob | string, formdata: any) => any): Promise<UploadFileResponse>;
21
+ export {};
@@ -0,0 +1,28 @@
1
+ import { createFormData, getFormDataHeaders } from "../../utils/index.js";
2
+ import { FileStationApi } from "../../types/index.js";
3
+ var OverwriteEnum;
4
+ (function (OverwriteEnum) {
5
+ OverwriteEnum["OVERWRITE"] = "overwrite";
6
+ OverwriteEnum["SKIP"] = "skip";
7
+ })(OverwriteEnum || (OverwriteEnum = {}));
8
+ export async function uploadFileBase(params, parseFileFn) {
9
+ if (!this.isConnecting) {
10
+ await this.connect();
11
+ }
12
+ const { path, file, overwrite = OverwriteEnum.OVERWRITE, create_parents = true } = params;
13
+ const api = this.getApiInfoByName(FileStationApi.Upload);
14
+ let formData = createFormData();
15
+ formData.append("method", "upload");
16
+ formData.append("version", String(api?.maxVersion));
17
+ formData.append("api", FileStationApi.Upload);
18
+ formData.append("path", path);
19
+ formData.append("overwrite", overwrite);
20
+ formData.append("create_parents", String(create_parents));
21
+ formData = parseFileFn(file, formData);
22
+ const res = this.run(FileStationApi.Upload, {
23
+ method: "post",
24
+ data: formData,
25
+ headers: getFormDataHeaders(formData),
26
+ });
27
+ return res;
28
+ }
@@ -1,21 +1 @@
1
- import { AxiosProgressEvent } from "axios";
2
- import { SynologyApiResponse } from "../../types/index.js";
3
- declare enum OverwriteEnum {
4
- OVERWRITE = "overwrite",
5
- SKIP = "skip"
6
- }
7
- export type UploadFileParams = {
8
- path: string;
9
- file: File | Blob | string | any;
10
- overwrite?: OverwriteEnum;
11
- create_parents?: boolean;
12
- onUploadProgress?: (progress: AxiosProgressEvent) => void;
13
- };
14
- export type UploadFileResponse = SynologyApiResponse<{
15
- blSkip: boolean;
16
- file: string;
17
- pid: number;
18
- progress: number;
19
- }>;
20
- export declare function uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
21
- export {};
1
+ export declare const uploadFile: (...args: any[]) => Promise<import("./Upload.base.js").UploadFileResponse>;
@@ -1,44 +1,24 @@
1
- import { isNode, createFormData, getFormDataHeaders } from "../../utils/index.js";
2
- import { FileStationApi } from "../../types/index.js";
3
- var OverwriteEnum;
4
- (function (OverwriteEnum) {
5
- OverwriteEnum["OVERWRITE"] = "overwrite";
6
- OverwriteEnum["SKIP"] = "skip";
7
- })(OverwriteEnum || (OverwriteEnum = {}));
8
- export async function uploadFile(params) {
9
- if (!this.isConnecting) {
10
- await this.connect();
11
- }
12
- const { path, file, overwrite = OverwriteEnum.OVERWRITE, create_parents = true } = params;
13
- const api = this.getApiInfoByName(FileStationApi.Upload);
14
- let fileContent = file;
15
- let fileName = "";
16
- let formData = createFormData();
17
- formData.append("method", "upload");
18
- formData.append("version", String(api?.maxVersion));
19
- formData.append("api", FileStationApi.Upload);
20
- formData.append("path", path);
21
- formData.append("overwrite", overwrite);
22
- formData.append("create_parents", String(create_parents));
1
+ import { isNode } from "../../utils/index.js";
2
+ import { uploadFileBase } from "./Upload.base.js";
3
+ export const uploadFile = (...args) =>
4
+ // @ts-ignore
5
+ uploadFileBase(...args, async (file, formdata) => {
23
6
  // nodejs environment
24
7
  if (isNode) {
8
+ let fileContent;
9
+ let fileName = "";
25
10
  if (typeof file === "string") {
26
- fileName = require("path").basename(file);
27
- fileContent = await require("node:fs/promises").readFile(file);
11
+ fileName = await import("path").then((p) => p.basename(file));
12
+ fileContent = await import("node:fs/promises").then((fs) => fs.readFile(file));
28
13
  }
29
- formData.append("file", fileContent, {
14
+ formdata.append("file", fileContent, {
30
15
  filename: fileName,
31
16
  contentType: "application/octet-stream", // 可根据文件类型修改
32
17
  });
33
18
  }
34
19
  else {
35
20
  // for browser environment
36
- formData.append("file", file);
21
+ formdata.append("file", file);
37
22
  }
38
- const res = this.run(FileStationApi.Upload, {
39
- method: "post",
40
- data: formData,
41
- headers: getFormDataHeaders(formData),
42
- });
43
- return res;
44
- }
23
+ return formdata;
24
+ });
@@ -0,0 +1 @@
1
+ export declare const uploadFile: (...args: any[]) => Promise<import("./Upload.base.js").UploadFileResponse>;
@@ -0,0 +1,7 @@
1
+ import { uploadFileBase } from "./Upload.base.js";
2
+ export const uploadFile = (...args) =>
3
+ // @ts-ignore
4
+ uploadFileBase(...args, async (file, formdata) => {
5
+ formdata.append("file", file);
6
+ return formdata;
7
+ });
@@ -0,0 +1,58 @@
1
+ /**
2
+ * reference :https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/FileStation/All/enu/Synology_File_Station_API_Guide.pdf
3
+ */
4
+ import { getInfo } from "./Info.js";
5
+ import { getFileList, getShareFileList, getVirtualFolderList } from "./List.js";
6
+ import { addFavorite, deleteFavorite, getFavoriteList, clearBrokenFavorite, editFavorite } from "./Favorite.js";
7
+ import { startSearch, stopSearch, getSearchList, cleanSearch } from "./Search.js";
8
+ import { createFolder } from "./CreateFolder.js";
9
+ import { getDownloadFile } from "./Download.js";
10
+ import { stopDeleteFile, startDeleteFile, getDeleteFileStatus } from "./Delete.js";
11
+ import { getThumbUrl } from "./Thumb.js";
12
+ import { startDirSizeCalc, stopDirSizeCalc, getDirSizeCalcStatus } from "./DirSize.js";
13
+ import { startMD5Calc, stopMD5Calc, getMD5CalcStatus } from "./MD5.js";
14
+ import { checkPermission } from "./CheckPermission.js";
15
+ import { rename } from "./Rename.js";
16
+ import { startCopyMove, getCopyMoveStatus, stopCopyMove } from "./CopyMove.js";
17
+ import { getSharingInfo, getSharingList, createSharingLink, deleteSharingLink, editSharingLink, clearInvalidSharingLink } from "./Sharing.js";
18
+ import { getBackgroundTaskList, clearFinishedBackgroundTasks } from "./BackgroundTask.js";
19
+ export declare const METHODS: {
20
+ getInfo: typeof getInfo;
21
+ getFileList: typeof getFileList;
22
+ getShareFileList: typeof getShareFileList;
23
+ getVirtualFolderList: typeof getVirtualFolderList;
24
+ getFavoriteList: typeof getFavoriteList;
25
+ addFavorite: typeof addFavorite;
26
+ deleteFavorite: typeof deleteFavorite;
27
+ editFavorite: typeof editFavorite;
28
+ clearBrokenFavorite: typeof clearBrokenFavorite;
29
+ startSearch: typeof startSearch;
30
+ stopSearch: typeof stopSearch;
31
+ getSearchList: typeof getSearchList;
32
+ cleanSearch: typeof cleanSearch;
33
+ createFolder: typeof createFolder;
34
+ getDownloadFile: typeof getDownloadFile;
35
+ stopDeleteFile: typeof stopDeleteFile;
36
+ startDeleteFile: typeof startDeleteFile;
37
+ getDeleteFileStatus: typeof getDeleteFileStatus;
38
+ getThumbUrl: typeof getThumbUrl;
39
+ startDirSizeCalc: typeof startDirSizeCalc;
40
+ stopDirSizeCalc: typeof stopDirSizeCalc;
41
+ getDirSizeCalcStatus: typeof getDirSizeCalcStatus;
42
+ startMD5Calc: typeof startMD5Calc;
43
+ getMD5CalcStatus: typeof getMD5CalcStatus;
44
+ stopMD5Calc: typeof stopMD5Calc;
45
+ checkPermission: typeof checkPermission;
46
+ rename: typeof rename;
47
+ clearFinishedBackgroundTasks: typeof clearFinishedBackgroundTasks;
48
+ getBackgroundTaskList: typeof getBackgroundTaskList;
49
+ getSharingInfo: typeof getSharingInfo;
50
+ getSharingList: typeof getSharingList;
51
+ createSharingLink: typeof createSharingLink;
52
+ deleteSharingLink: typeof deleteSharingLink;
53
+ editSharingLink: typeof editSharingLink;
54
+ clearInvalidSharingLink: typeof clearInvalidSharingLink;
55
+ startCopyMove: typeof startCopyMove;
56
+ getCopyMoveStatus: typeof getCopyMoveStatus;
57
+ stopCopyMove: typeof stopCopyMove;
58
+ };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * reference :https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/FileStation/All/enu/Synology_File_Station_API_Guide.pdf
3
+ */
4
+ import { getInfo } from "./Info.js";
5
+ import { getFileList, getShareFileList, getVirtualFolderList } from "./List.js";
6
+ import { addFavorite, deleteFavorite, getFavoriteList, clearBrokenFavorite, editFavorite, } from "./Favorite.js";
7
+ import { startSearch, stopSearch, getSearchList, cleanSearch } from "./Search.js";
8
+ import { createFolder } from "./CreateFolder.js";
9
+ import { getDownloadFile } from "./Download.js";
10
+ import { stopDeleteFile, startDeleteFile, getDeleteFileStatus } from "./Delete.js";
11
+ import { getThumbUrl } from "./Thumb.js";
12
+ import { startDirSizeCalc, stopDirSizeCalc, getDirSizeCalcStatus } from "./DirSize.js";
13
+ import { startMD5Calc, stopMD5Calc, getMD5CalcStatus } from "./MD5.js";
14
+ import { checkPermission } from "./CheckPermission.js";
15
+ import { rename } from "./Rename.js";
16
+ import { startCopyMove, getCopyMoveStatus, stopCopyMove } from "./CopyMove.js";
17
+ import { getSharingInfo, getSharingList, createSharingLink, deleteSharingLink, editSharingLink, clearInvalidSharingLink, } from "./Sharing.js";
18
+ import { getBackgroundTaskList, clearFinishedBackgroundTasks } from "./BackgroundTask.js";
19
+ // methods
20
+ export const METHODS = {
21
+ getInfo,
22
+ getFileList,
23
+ getShareFileList,
24
+ getVirtualFolderList,
25
+ getFavoriteList,
26
+ addFavorite,
27
+ deleteFavorite,
28
+ editFavorite,
29
+ clearBrokenFavorite,
30
+ startSearch,
31
+ stopSearch,
32
+ getSearchList,
33
+ cleanSearch,
34
+ createFolder,
35
+ getDownloadFile,
36
+ stopDeleteFile,
37
+ startDeleteFile,
38
+ getDeleteFileStatus,
39
+ getThumbUrl,
40
+ startDirSizeCalc,
41
+ stopDirSizeCalc,
42
+ getDirSizeCalcStatus,
43
+ startMD5Calc,
44
+ getMD5CalcStatus,
45
+ stopMD5Calc,
46
+ checkPermission,
47
+ rename,
48
+ clearFinishedBackgroundTasks,
49
+ getBackgroundTaskList,
50
+ getSharingInfo,
51
+ getSharingList,
52
+ createSharingLink,
53
+ deleteSharingLink,
54
+ editSharingLink,
55
+ clearInvalidSharingLink,
56
+ startCopyMove,
57
+ getCopyMoveStatus,
58
+ stopCopyMove,
59
+ };
@@ -1,63 +1,46 @@
1
- /**
2
- * reference :https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/FileStation/All/enu/Synology_File_Station_API_Guide.pdf
3
- */
4
- import { getInfo } from "./Info.js";
5
- import { getFileList, getShareFileList, getVirtualFolderList } from "./List.js";
6
- import { addFavorite, deleteFavorite, getFavoriteList, clearBrokenFavorite, editFavorite } from "./Favorite.js";
7
- import { startSearch, stopSearch, getSearchList, cleanSearch } from "./Search.js";
8
- import { createFolder } from "./CreateFolder.js";
9
- import { getDownloadFile } from "./Download.js";
10
- import { stopDeleteFile, startDeleteFile, getDeleteFileStatus } from "./Delete.js";
11
- import { uploadFile } from "./Upload.js";
12
- import { getThumbUrl } from "./Thumb.js";
13
- import { startDirSizeCalc, stopDirSizeCalc, getDirSizeCalcStatus } from "./DirSize.js";
14
- import { startMD5Calc, stopMD5Calc, getMD5CalcStatus } from "./MD5.js";
15
- import { checkPermission } from "./CheckPermission.js";
16
- import { rename } from "./Rename.js";
17
- import { startCopyMove, getCopyMoveStatus, stopCopyMove } from "./CopyMove.js";
18
- import { getSharingInfo, getSharingList, createSharingLink, deleteSharingLink, editSharingLink, clearInvalidSharingLink } from "./Sharing.js";
19
- import { getBackgroundTaskList, clearFinishedBackgroundTasks } from "./BackgroundTask.js";
1
+ export * from "./index.js";
2
+ export type * from "./index.js";
20
3
  export declare const METHODS: {
21
- getInfo: typeof getInfo;
22
- getFileList: typeof getFileList;
23
- getShareFileList: typeof getShareFileList;
24
- getVirtualFolderList: typeof getVirtualFolderList;
25
- getFavoriteList: typeof getFavoriteList;
26
- addFavorite: typeof addFavorite;
27
- deleteFavorite: typeof deleteFavorite;
28
- editFavorite: typeof editFavorite;
29
- clearBrokenFavorite: typeof clearBrokenFavorite;
30
- startSearch: typeof startSearch;
31
- stopSearch: typeof stopSearch;
32
- getSearchList: typeof getSearchList;
33
- cleanSearch: typeof cleanSearch;
34
- createFolder: typeof createFolder;
35
- getDownloadFile: typeof getDownloadFile;
36
- stopDeleteFile: typeof stopDeleteFile;
37
- startDeleteFile: typeof startDeleteFile;
38
- getDeleteFileStatus: typeof getDeleteFileStatus;
39
- uploadFile: typeof uploadFile;
40
- getThumbUrl: typeof getThumbUrl;
41
- startDirSizeCalc: typeof startDirSizeCalc;
42
- stopDirSizeCalc: typeof stopDirSizeCalc;
43
- getDirSizeCalcStatus: typeof getDirSizeCalcStatus;
44
- startMD5Calc: typeof startMD5Calc;
45
- getMD5CalcStatus: typeof getMD5CalcStatus;
46
- stopMD5Calc: typeof stopMD5Calc;
47
- checkPermission: typeof checkPermission;
48
- rename: typeof rename;
49
- clearFinishedBackgroundTasks: typeof clearFinishedBackgroundTasks;
50
- getBackgroundTaskList: typeof getBackgroundTaskList;
51
- getSharingInfo: typeof getSharingInfo;
52
- getSharingList: typeof getSharingList;
53
- createSharingLink: typeof createSharingLink;
54
- deleteSharingLink: typeof deleteSharingLink;
55
- editSharingLink: typeof editSharingLink;
56
- clearInvalidSharingLink: typeof clearInvalidSharingLink;
57
- startCopyMove: typeof startCopyMove;
58
- getCopyMoveStatus: typeof getCopyMoveStatus;
59
- stopCopyMove: typeof stopCopyMove;
4
+ uploadFile: (...args: any[]) => Promise<import("./Upload.base.js").UploadFileResponse>;
5
+ getInfo: typeof import("./Info.js").getInfo;
6
+ getFileList: typeof import("./List.js").getFileList;
7
+ getShareFileList: typeof import("./List.js").getShareFileList;
8
+ getVirtualFolderList: typeof import("./List.js").getVirtualFolderList;
9
+ getFavoriteList: typeof import("./Favorite.js").getFavoriteList;
10
+ addFavorite: typeof import("./Favorite.js").addFavorite;
11
+ deleteFavorite: typeof import("./Favorite.js").deleteFavorite;
12
+ editFavorite: typeof import("./Favorite.js").editFavorite;
13
+ clearBrokenFavorite: typeof import("./Favorite.js").clearBrokenFavorite;
14
+ startSearch: typeof import("./Search.js").startSearch;
15
+ stopSearch: typeof import("./Search.js").stopSearch;
16
+ getSearchList: typeof import("./Search.js").getSearchList;
17
+ cleanSearch: typeof import("./Search.js").cleanSearch;
18
+ createFolder: typeof import("./CreateFolder.js").createFolder;
19
+ getDownloadFile: typeof import("./Download.js").getDownloadFile;
20
+ stopDeleteFile: typeof import("./Delete.js").stopDeleteFile;
21
+ startDeleteFile: typeof import("./Delete.js").startDeleteFile;
22
+ getDeleteFileStatus: typeof import("./Delete.js").getDeleteFileStatus;
23
+ getThumbUrl: typeof import("./Thumb.js").getThumbUrl;
24
+ startDirSizeCalc: typeof import("./DirSize.js").startDirSizeCalc;
25
+ stopDirSizeCalc: typeof import("./DirSize.js").stopDirSizeCalc;
26
+ getDirSizeCalcStatus: typeof import("./DirSize.js").getDirSizeCalcStatus;
27
+ startMD5Calc: typeof import("./MD5.js").startMD5Calc;
28
+ getMD5CalcStatus: typeof import("./MD5.js").getMD5CalcStatus;
29
+ stopMD5Calc: typeof import("./MD5.js").stopMD5Calc;
30
+ checkPermission: typeof import("./CheckPermission.js").checkPermission;
31
+ rename: typeof import("./Rename.js").rename;
32
+ clearFinishedBackgroundTasks: typeof import("./BackgroundTask.js").clearFinishedBackgroundTasks;
33
+ getBackgroundTaskList: typeof import("./BackgroundTask.js").getBackgroundTaskList;
34
+ getSharingInfo: typeof import("./Sharing.js").getSharingInfo;
35
+ getSharingList: typeof import("./Sharing.js").getSharingList;
36
+ createSharingLink: typeof import("./Sharing.js").createSharingLink;
37
+ deleteSharingLink: typeof import("./Sharing.js").deleteSharingLink;
38
+ editSharingLink: typeof import("./Sharing.js").editSharingLink;
39
+ clearInvalidSharingLink: typeof import("./Sharing.js").clearInvalidSharingLink;
40
+ startCopyMove: typeof import("./CopyMove.js").startCopyMove;
41
+ getCopyMoveStatus: typeof import("./CopyMove.js").getCopyMoveStatus;
42
+ stopCopyMove: typeof import("./CopyMove.js").stopCopyMove;
60
43
  };
44
+ export type TMethods = typeof METHODS;
61
45
  export declare const KEY = "FileStation";
62
46
  export declare const ALIAS_KEY = "fs";
63
- export type TMethods = typeof METHODS;
@@ -1,63 +1,9 @@
1
- /**
2
- * reference :https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/FileStation/All/enu/Synology_File_Station_API_Guide.pdf
3
- */
4
- import { getInfo } from "./Info.js";
5
- import { getFileList, getShareFileList, getVirtualFolderList } from "./List.js";
6
- import { addFavorite, deleteFavorite, getFavoriteList, clearBrokenFavorite, editFavorite, } from "./Favorite.js";
7
- import { startSearch, stopSearch, getSearchList, cleanSearch } from "./Search.js";
8
- import { createFolder } from "./CreateFolder.js";
9
- import { getDownloadFile } from "./Download.js";
10
- import { stopDeleteFile, startDeleteFile, getDeleteFileStatus } from "./Delete.js";
1
+ import { METHODS as BASE_METHODS } from "./index.base.js";
11
2
  import { uploadFile } from "./Upload.js";
12
- import { getThumbUrl } from "./Thumb.js";
13
- import { startDirSizeCalc, stopDirSizeCalc, getDirSizeCalcStatus } from "./DirSize.js";
14
- import { startMD5Calc, stopMD5Calc, getMD5CalcStatus } from "./MD5.js";
15
- import { checkPermission } from "./CheckPermission.js";
16
- import { rename } from "./Rename.js";
17
- import { startCopyMove, getCopyMoveStatus, stopCopyMove } from "./CopyMove.js";
18
- import { getSharingInfo, getSharingList, createSharingLink, deleteSharingLink, editSharingLink, clearInvalidSharingLink, } from "./Sharing.js";
19
- import { getBackgroundTaskList, clearFinishedBackgroundTasks } from "./BackgroundTask.js";
20
- // methods
3
+ export * from "./index.js";
21
4
  export const METHODS = {
22
- getInfo,
23
- getFileList,
24
- getShareFileList,
25
- getVirtualFolderList,
26
- getFavoriteList,
27
- addFavorite,
28
- deleteFavorite,
29
- editFavorite,
30
- clearBrokenFavorite,
31
- startSearch,
32
- stopSearch,
33
- getSearchList,
34
- cleanSearch,
35
- createFolder,
36
- getDownloadFile,
37
- stopDeleteFile,
38
- startDeleteFile,
39
- getDeleteFileStatus,
5
+ ...BASE_METHODS,
40
6
  uploadFile,
41
- getThumbUrl,
42
- startDirSizeCalc,
43
- stopDirSizeCalc,
44
- getDirSizeCalcStatus,
45
- startMD5Calc,
46
- getMD5CalcStatus,
47
- stopMD5Calc,
48
- checkPermission,
49
- rename,
50
- clearFinishedBackgroundTasks,
51
- getBackgroundTaskList,
52
- getSharingInfo,
53
- getSharingList,
54
- createSharingLink,
55
- deleteSharingLink,
56
- editSharingLink,
57
- clearInvalidSharingLink,
58
- startCopyMove,
59
- getCopyMoveStatus,
60
- stopCopyMove,
61
7
  };
62
8
  // name space
63
9
  export const KEY = "FileStation";
@@ -0,0 +1,45 @@
1
+ export * from "./index.js";
2
+ export declare const METHODS: {
3
+ uploadFile: (...args: any[]) => Promise<import("./Upload.base.js").UploadFileResponse>;
4
+ getInfo: typeof import("./Info.js").getInfo;
5
+ getFileList: typeof import("./List.js").getFileList;
6
+ getShareFileList: typeof import("./List.js").getShareFileList;
7
+ getVirtualFolderList: typeof import("./List.js").getVirtualFolderList;
8
+ getFavoriteList: typeof import("./Favorite.js").getFavoriteList;
9
+ addFavorite: typeof import("./Favorite.js").addFavorite;
10
+ deleteFavorite: typeof import("./Favorite.js").deleteFavorite;
11
+ editFavorite: typeof import("./Favorite.js").editFavorite;
12
+ clearBrokenFavorite: typeof import("./Favorite.js").clearBrokenFavorite;
13
+ startSearch: typeof import("./Search.js").startSearch;
14
+ stopSearch: typeof import("./Search.js").stopSearch;
15
+ getSearchList: typeof import("./Search.js").getSearchList;
16
+ cleanSearch: typeof import("./Search.js").cleanSearch;
17
+ createFolder: typeof import("./CreateFolder.js").createFolder;
18
+ getDownloadFile: typeof import("./Download.js").getDownloadFile;
19
+ stopDeleteFile: typeof import("./Delete.js").stopDeleteFile;
20
+ startDeleteFile: typeof import("./Delete.js").startDeleteFile;
21
+ getDeleteFileStatus: typeof import("./Delete.js").getDeleteFileStatus;
22
+ getThumbUrl: typeof import("./Thumb.js").getThumbUrl;
23
+ startDirSizeCalc: typeof import("./DirSize.js").startDirSizeCalc;
24
+ stopDirSizeCalc: typeof import("./DirSize.js").stopDirSizeCalc;
25
+ getDirSizeCalcStatus: typeof import("./DirSize.js").getDirSizeCalcStatus;
26
+ startMD5Calc: typeof import("./MD5.js").startMD5Calc;
27
+ getMD5CalcStatus: typeof import("./MD5.js").getMD5CalcStatus;
28
+ stopMD5Calc: typeof import("./MD5.js").stopMD5Calc;
29
+ checkPermission: typeof import("./CheckPermission.js").checkPermission;
30
+ rename: typeof import("./Rename.js").rename;
31
+ clearFinishedBackgroundTasks: typeof import("./BackgroundTask.js").clearFinishedBackgroundTasks;
32
+ getBackgroundTaskList: typeof import("./BackgroundTask.js").getBackgroundTaskList;
33
+ getSharingInfo: typeof import("./Sharing.js").getSharingInfo;
34
+ getSharingList: typeof import("./Sharing.js").getSharingList;
35
+ createSharingLink: typeof import("./Sharing.js").createSharingLink;
36
+ deleteSharingLink: typeof import("./Sharing.js").deleteSharingLink;
37
+ editSharingLink: typeof import("./Sharing.js").editSharingLink;
38
+ clearInvalidSharingLink: typeof import("./Sharing.js").clearInvalidSharingLink;
39
+ startCopyMove: typeof import("./CopyMove.js").startCopyMove;
40
+ getCopyMoveStatus: typeof import("./CopyMove.js").getCopyMoveStatus;
41
+ stopCopyMove: typeof import("./CopyMove.js").stopCopyMove;
42
+ };
43
+ export type TMethods = typeof METHODS;
44
+ export declare const KEY = "FileStation";
45
+ export declare const ALIAS_KEY = "fs";
@@ -0,0 +1,10 @@
1
+ import { METHODS as BASE_METHODS } from "./index.base.js";
2
+ import { uploadFile } from "./Upload.rn.js";
3
+ export * from "./index.js";
4
+ export const METHODS = {
5
+ ...BASE_METHODS,
6
+ uploadFile,
7
+ };
8
+ // name space
9
+ export const KEY = "FileStation";
10
+ export const ALIAS_KEY = "fs";
@@ -7,11 +7,11 @@ import * as Docker from "./Docker/index.js";
7
7
  type EnumFromArray<T extends string[]> = {
8
8
  [K in T[number]]: K;
9
9
  };
10
- export declare const SynologyApiModules: (typeof AudioStation | typeof FileStation | typeof VideoStation | typeof Auth | typeof Core | typeof Docker)[];
10
+ export declare const SynologyApiModules: (typeof AudioStation | typeof VideoStation | typeof Auth | typeof Core | typeof Docker | typeof FileStation)[];
11
11
  export declare const SynologyApiKeys: any[];
12
12
  export declare const SynologyApiKeysMap: EnumFromArray<typeof SynologyApiKeys>;
13
13
  export declare const SynologyApiMethods: {};
14
- export declare class BaseSynologyApi {
14
+ export declare class BaseModuleSynologyApi {
15
15
  [AudioStation.KEY]: AudioStation.TMethods;
16
16
  [AudioStation.ALIAS_KEY]: AudioStation.TMethods;
17
17
  [FileStation.KEY]: FileStation.TMethods;
@@ -54,23 +54,23 @@ export const SynologyApiMethods = SynologyApiModules.reduce((acc, module) => {
54
54
  acc[module.ALIAS_KEY] = module.METHODS;
55
55
  return acc;
56
56
  }, {});
57
- let BaseSynologyApi = (() => {
57
+ let BaseModuleSynologyApi = (() => {
58
58
  let _classDecorators = [BindMethods(SynologyApiMethods)];
59
59
  let _classDescriptor;
60
60
  let _classExtraInitializers = [];
61
61
  let _classThis;
62
- var BaseSynologyApi = class {
62
+ var BaseModuleSynologyApi = class {
63
63
  static { _classThis = this; }
64
64
  static { AudioStation.KEY, AudioStation.ALIAS_KEY, FileStation.KEY, FileStation.ALIAS_KEY, VideoStation.KEY, VideoStation.ALIAS_KEY, Auth.KEY, Auth.ALIAS_KEY, Core.KEY, Core.ALIAS_KEY, Docker.KEY, Docker.ALIAS_KEY; }
65
65
  static {
66
66
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
67
67
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
68
- BaseSynologyApi = _classThis = _classDescriptor.value;
68
+ BaseModuleSynologyApi = _classThis = _classDescriptor.value;
69
69
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
70
  __runInitializers(_classThis, _classExtraInitializers);
71
71
  }
72
72
  constructor() { }
73
73
  };
74
- return BaseSynologyApi = _classThis;
74
+ return BaseModuleSynologyApi = _classThis;
75
75
  })();
76
- export { BaseSynologyApi };
76
+ export { BaseModuleSynologyApi };
@@ -0,0 +1,29 @@
1
+ import * as AudioStation from "./AudioStation/index.js";
2
+ import * as FileStation from "./FileStation/index.rn.js";
3
+ import * as VideoStation from "./VideoStation/index.js";
4
+ import * as Auth from "./Auth/index.js";
5
+ import * as Core from "./Core/index.js";
6
+ import * as Docker from "./Docker/index.js";
7
+ type EnumFromArray<T extends string[]> = {
8
+ [K in T[number]]: K;
9
+ };
10
+ export declare const SynologyApiModules: (typeof AudioStation | typeof FileStation | typeof VideoStation | typeof Auth | typeof Core | typeof Docker)[];
11
+ export declare const SynologyApiKeys: any[];
12
+ export declare const SynologyApiKeysMap: EnumFromArray<typeof SynologyApiKeys>;
13
+ export declare const SynologyApiMethods: {};
14
+ export declare class RnBaseModuleSynologyApi {
15
+ [AudioStation.KEY]: AudioStation.TMethods;
16
+ [AudioStation.ALIAS_KEY]: AudioStation.TMethods;
17
+ [FileStation.KEY]: FileStation.TMethods;
18
+ [FileStation.ALIAS_KEY]: FileStation.TMethods;
19
+ [VideoStation.KEY]: VideoStation.TMethods;
20
+ [VideoStation.ALIAS_KEY]: VideoStation.TMethods;
21
+ [Auth.KEY]: Auth.TMethods;
22
+ [Auth.ALIAS_KEY]: Auth.TMethods;
23
+ [Core.KEY]: Core.TMethods;
24
+ [Core.ALIAS_KEY]: Core.TMethods;
25
+ [Docker.KEY]: Docker.TMethods;
26
+ [Docker.ALIAS_KEY]: Docker.TMethods;
27
+ constructor();
28
+ }
29
+ export {};
@@ -0,0 +1,76 @@
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
+ };
35
+ import * as AudioStation from "./AudioStation/index.js";
36
+ import * as FileStation from "./FileStation/index.rn.js";
37
+ import * as VideoStation from "./VideoStation/index.js";
38
+ import * as Auth from "./Auth/index.js";
39
+ import * as Core from "./Core/index.js";
40
+ import * as Docker from "./Docker/index.js";
41
+ import { BindMethods } from "../decorators/index.js";
42
+ export const SynologyApiModules = [FileStation, AudioStation, VideoStation, Auth, Core, Docker];
43
+ export const SynologyApiKeys = SynologyApiModules.reduce((acc, module) => {
44
+ acc = { ...acc, [module.KEY]: module.KEY, [module.ALIAS_KEY]: module.ALIAS_KEY };
45
+ return acc;
46
+ }, []);
47
+ export const SynologyApiKeysMap = SynologyApiModules.reduce((acc, module) => {
48
+ acc[module.KEY] = module.KEY;
49
+ acc[module.ALIAS_KEY] = module.ALIAS_KEY;
50
+ return acc;
51
+ }, {});
52
+ export const SynologyApiMethods = SynologyApiModules.reduce((acc, module) => {
53
+ acc[module.KEY] = module.METHODS;
54
+ acc[module.ALIAS_KEY] = module.METHODS;
55
+ return acc;
56
+ }, {});
57
+ let RnBaseModuleSynologyApi = (() => {
58
+ let _classDecorators = [BindMethods(SynologyApiMethods)];
59
+ let _classDescriptor;
60
+ let _classExtraInitializers = [];
61
+ let _classThis;
62
+ var RnBaseModuleSynologyApi = class {
63
+ static { _classThis = this; }
64
+ static { AudioStation.KEY, AudioStation.ALIAS_KEY, FileStation.KEY, FileStation.ALIAS_KEY, VideoStation.KEY, VideoStation.ALIAS_KEY, Auth.KEY, Auth.ALIAS_KEY, Core.KEY, Core.ALIAS_KEY, Docker.KEY, Docker.ALIAS_KEY; }
65
+ static {
66
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
67
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
68
+ RnBaseModuleSynologyApi = _classThis = _classDescriptor.value;
69
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
+ __runInitializers(_classThis, _classExtraInitializers);
71
+ }
72
+ constructor() { }
73
+ };
74
+ return RnBaseModuleSynologyApi = _classThis;
75
+ })();
76
+ export { RnBaseModuleSynologyApi };
@@ -0,0 +1 @@
1
+ export declare function applyMixins(target: any, baseClasses: any[]): void;
@@ -0,0 +1,7 @@
1
+ export function applyMixins(target, baseClasses) {
2
+ baseClasses.forEach(baseClass => {
3
+ Object.getOwnPropertyNames(baseClass.prototype).forEach(name => {
4
+ target.prototype[name] = baseClass.prototype[name];
5
+ });
6
+ });
7
+ }
@@ -1,2 +1,4 @@
1
+ export declare const getEnv: () => "browser" | "node" | "react-native" | "unknown";
1
2
  export declare const isBrowser: boolean;
2
3
  export declare const isNode: boolean;
4
+ export declare const isReactNative: boolean;
package/lib/utils/env.js CHANGED
@@ -1,2 +1,20 @@
1
- export const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
2
- export const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
1
+ export const getEnv = () => {
2
+ // browser
3
+ if (typeof window !== "undefined" && typeof window.document !== "undefined") {
4
+ return "browser";
5
+ }
6
+ // Node.js
7
+ if (typeof process !== "undefined" &&
8
+ process?.versions?.node &&
9
+ process?.versions?.node != null) {
10
+ return "node";
11
+ }
12
+ // React Native
13
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
14
+ return "react-native";
15
+ }
16
+ return "unknown";
17
+ };
18
+ export const isBrowser = getEnv() === "browser";
19
+ export const isNode = getEnv() === "node";
20
+ export const isReactNative = getEnv() === "react-native";
@@ -2,3 +2,4 @@ export * from "./common.js";
2
2
  export * from "./encryption.js";
3
3
  export * from "./formData.js";
4
4
  export * from "./env.js";
5
+ export * from "./class.js";
@@ -2,3 +2,4 @@ export * from "./common.js";
2
2
  export * from "./encryption.js";
3
3
  export * from "./formData.js";
4
4
  export * from "./env.js";
5
+ export * from "./class.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fett/synology-api",
3
- "version": "0.0.3-beta.1",
3
+ "version": "0.0.3-beta.2",
4
4
  "description": "synology api for nodejs",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -8,6 +8,16 @@
8
8
  "synology": "./lib/cli/index.js",
9
9
  "syno": "./lib/cli/index.js"
10
10
  },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./lib/index.js",
14
+ "require": "./lib/index.js"
15
+ },
16
+ "./react-native": {
17
+ "import": "./lib/index.rn.js",
18
+ "require": "./lib/index.rn.js"
19
+ }
20
+ },
11
21
  "files": [
12
22
  "lib",
13
23
  "bin"