@fett/synology-api 0.0.2-beta.2 → 0.0.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 +23 -1
- package/lib/core.js +53 -20
- package/lib/errorcodes.d.ts +21 -4
- package/lib/errorcodes.js +27 -6
- package/lib/helpers.js +5 -8
- package/lib/modules/Api/Auth.js +13 -8
- package/lib/modules/Api/Info.js +4 -4
- package/lib/modules/AudioStation/Album.d.ts +17 -0
- package/lib/modules/AudioStation/Album.js +17 -0
- package/lib/modules/AudioStation/Artist.d.ts +16 -0
- package/lib/modules/AudioStation/Artist.js +16 -0
- package/lib/modules/AudioStation/Folder.d.ts +14 -0
- package/lib/modules/AudioStation/Folder.js +14 -0
- package/lib/modules/AudioStation/index.d.ts +4 -0
- package/lib/modules/AudioStation/index.js +6 -0
- package/lib/modules/Auth/AuthKey.js +2 -2
- package/lib/modules/Auth/Encryption.d.ts +8 -0
- package/lib/modules/Auth/Encryption.js +10 -0
- package/lib/modules/Auth/index.d.ts +2 -0
- package/lib/modules/Auth/index.js +3 -1
- package/lib/modules/Core/System.d.ts +159 -0
- package/lib/modules/Core/System.js +42 -0
- package/lib/modules/Core/User.d.ts +51 -0
- package/lib/modules/Core/User.js +33 -0
- package/lib/modules/Core/index.d.ts +14 -0
- package/lib/modules/Core/index.js +15 -0
- package/lib/modules/Docker/Container.d.ts +43 -0
- package/lib/modules/Docker/Container.js +13 -0
- package/lib/modules/Docker/Network.d.ts +0 -0
- package/lib/modules/Docker/Network.js +0 -0
- package/lib/modules/Docker/Project.d.ts +0 -0
- package/lib/modules/Docker/Project.js +0 -0
- package/lib/modules/Docker/Registry.d.ts +0 -0
- package/lib/modules/Docker/Registry.js +0 -0
- package/lib/modules/Docker/index.d.ts +7 -0
- package/lib/modules/Docker/index.js +8 -0
- package/lib/modules/FileStation/BackgroundTask.d.ts +50 -0
- package/lib/modules/FileStation/BackgroundTask.js +22 -0
- package/lib/modules/FileStation/CheckPermission.d.ts +10 -0
- package/lib/modules/FileStation/CheckPermission.js +13 -0
- package/lib/modules/FileStation/CopyMove.d.ts +33 -0
- package/lib/modules/FileStation/CopyMove.js +28 -0
- package/lib/modules/FileStation/CreateFolder.d.ts +15 -0
- package/lib/modules/FileStation/CreateFolder.js +12 -0
- package/lib/modules/FileStation/Delete.d.ts +54 -0
- package/lib/modules/FileStation/Delete.js +35 -0
- package/lib/modules/FileStation/DirSize.d.ts +20 -0
- package/lib/modules/FileStation/DirSize.js +28 -0
- package/lib/modules/FileStation/Download.d.ts +7 -0
- package/lib/modules/FileStation/Download.js +19 -0
- package/lib/modules/FileStation/Extract.d.ts +1 -0
- package/lib/modules/FileStation/Extract.js +1 -0
- package/lib/modules/FileStation/Favorite.d.ts +45 -0
- package/lib/modules/FileStation/Favorite.js +60 -0
- package/lib/modules/FileStation/List.d.ts +39 -11
- package/lib/modules/FileStation/List.js +14 -6
- package/lib/modules/FileStation/MD5.d.ts +15 -0
- package/lib/modules/FileStation/MD5.js +29 -0
- package/lib/modules/FileStation/Rename.d.ts +38 -0
- package/lib/modules/FileStation/Rename.js +14 -0
- package/lib/modules/FileStation/Search.d.ts +40 -0
- package/lib/modules/FileStation/Search.js +49 -0
- package/lib/modules/FileStation/Sharing.d.ts +69 -0
- package/lib/modules/FileStation/Sharing.js +64 -0
- package/lib/modules/FileStation/Thumb.d.ts +18 -0
- package/lib/modules/FileStation/Thumb.js +18 -0
- package/lib/modules/FileStation/Upload.d.ts +21 -0
- package/lib/modules/FileStation/Upload.js +44 -0
- package/lib/modules/FileStation/index.d.ts +52 -2
- package/lib/modules/FileStation/index.js +53 -3
- package/lib/modules/VideoStation/Library.d.ts +4 -5
- package/lib/modules/VideoStation/Streaming.d.ts +5 -6
- package/lib/modules/VideoStation/Streaming.js +39 -13
- package/lib/modules/VideoStation/index.js +1 -1
- package/lib/modules/index.d.ts +12 -10
- package/lib/modules/index.js +13 -12
- package/lib/types/apiInfo.d.ts +55 -4
- package/lib/types/apiInfo.js +62 -9
- package/lib/{utils.js → utils/common.js} +1 -1
- package/lib/utils/encryption.d.ts +12 -0
- package/lib/utils/encryption.js +38 -0
- package/lib/utils/env.d.ts +2 -0
- package/lib/utils/env.js +2 -0
- package/lib/utils/formData.d.ts +2 -0
- package/lib/utils/formData.js +19 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +4 -0
- package/package.json +7 -2
- package/lib/modules/VideoStation/HomeVideo.d.ts +0 -6
- package/lib/modules/VideoStation/HomeVideo.js +0 -10
- /package/lib/modules/{FileStation/File.d.ts → Docker/Image.d.ts} +0 -0
- /package/lib/modules/{FileStation/File.js → Docker/Image.js} +0 -0
- /package/lib/{utils.d.ts → utils/common.d.ts} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
export async function startDeleteFile(params) {
|
|
3
|
+
const { accurate_progress = true, recursive = true, path } = params;
|
|
4
|
+
const paths = Array.isArray(path) ? path : [path];
|
|
5
|
+
const res = await this.run(FileStationApi.Delete, {
|
|
6
|
+
params: {
|
|
7
|
+
method: "start",
|
|
8
|
+
path: JSON.stringify(paths),
|
|
9
|
+
accurate_progress,
|
|
10
|
+
recursive,
|
|
11
|
+
search_taskid: params?.search_taskid,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
export async function stopDeleteFile(params) {
|
|
17
|
+
const { taskid } = params;
|
|
18
|
+
const res = await this.run(FileStationApi.Delete, {
|
|
19
|
+
params: {
|
|
20
|
+
method: "stop",
|
|
21
|
+
taskid,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
export async function getDeleteFileStatus(params) {
|
|
27
|
+
const { taskid } = params;
|
|
28
|
+
const res = await this.run(FileStationApi.Delete, {
|
|
29
|
+
params: {
|
|
30
|
+
method: "status",
|
|
31
|
+
taskid,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
+
export type StartDirSizeCalcParams = {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
export type StartDirSizeCalcResponse = SynologyApiResponse<{
|
|
6
|
+
taskid: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function startDirSizeCalc(params: StartDirSizeCalcParams): Promise<StartDirSizeCalcResponse>;
|
|
9
|
+
export declare function stopDirSizeCalc(params: {
|
|
10
|
+
taskid: string;
|
|
11
|
+
}): Promise<SynologyApiResponse<any>>;
|
|
12
|
+
export type DirSizeCalcStatusResponse = SynologyApiResponse<{
|
|
13
|
+
finished: boolean;
|
|
14
|
+
num_dir: number;
|
|
15
|
+
num_file: number;
|
|
16
|
+
total_size: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function getDirSizeCalcStatus(params: {
|
|
19
|
+
taskid: string;
|
|
20
|
+
}): Promise<DirSizeCalcStatusResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
export async function startDirSizeCalc(params) {
|
|
3
|
+
const res = await this.run(FileStationApi.DirSize, {
|
|
4
|
+
params: {
|
|
5
|
+
method: "start",
|
|
6
|
+
...params,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
return res;
|
|
10
|
+
}
|
|
11
|
+
export async function stopDirSizeCalc(params) {
|
|
12
|
+
const res = await this.run(FileStationApi.DirSize, {
|
|
13
|
+
params: {
|
|
14
|
+
method: "stop",
|
|
15
|
+
...params,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
export async function getDirSizeCalcStatus(params) {
|
|
21
|
+
const res = await this.run(FileStationApi.DirSize, {
|
|
22
|
+
params: {
|
|
23
|
+
method: "status",
|
|
24
|
+
...params,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
+
export type DownloadFileParams = {
|
|
3
|
+
path: string;
|
|
4
|
+
mode?: "download" | "open";
|
|
5
|
+
};
|
|
6
|
+
export type DownloadFileResponse = SynologyApiResponse<string>;
|
|
7
|
+
export declare function getDownloadFile(params: DownloadFileParams): Promise<DownloadFileResponse>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
import { buildUrlWithQuery } from "../../utils/index.js";
|
|
3
|
+
export async function getDownloadFile(params) {
|
|
4
|
+
const { path, mode = "download" } = params;
|
|
5
|
+
const api = this.getApiInfoByName(FileStationApi.Download);
|
|
6
|
+
const query = {
|
|
7
|
+
method: "download",
|
|
8
|
+
path,
|
|
9
|
+
mode,
|
|
10
|
+
version: api.maxVersion,
|
|
11
|
+
api: FileStationApi.Download,
|
|
12
|
+
_sid: this.authInfo.sid,
|
|
13
|
+
};
|
|
14
|
+
const url = buildUrlWithQuery(`${this.baseUrl}${api.path}`, query);
|
|
15
|
+
return {
|
|
16
|
+
data: url,
|
|
17
|
+
success: true,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
+
export type FavoriteListParams = {
|
|
3
|
+
limit?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
sort_by?: string;
|
|
6
|
+
sort_direction?: "ASC" | "DESC";
|
|
7
|
+
additional?: string[];
|
|
8
|
+
status_filter: "all" | "valid" | "broken";
|
|
9
|
+
};
|
|
10
|
+
export type FavoriteListResponse = SynologyApiResponse<{
|
|
11
|
+
is_manager: boolean;
|
|
12
|
+
support_virtual_protocol: number;
|
|
13
|
+
support_sharing: boolean;
|
|
14
|
+
hostname: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function getFavoriteList(params: FavoriteListParams): Promise<FavoriteListResponse>;
|
|
17
|
+
export type AddFavoriteParams = {
|
|
18
|
+
path: string;
|
|
19
|
+
name: string;
|
|
20
|
+
index: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* add favorite
|
|
24
|
+
*/
|
|
25
|
+
export declare function addFavorite(params: FavoriteListParams): Promise<SynologyApiResponse<any>>;
|
|
26
|
+
export type RemoveFavoriteParams = {
|
|
27
|
+
path: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* remove favorite
|
|
31
|
+
*/
|
|
32
|
+
export declare function deleteFavorite(params: RemoveFavoriteParams): Promise<SynologyApiResponse<any>>;
|
|
33
|
+
/**
|
|
34
|
+
* clear_broken
|
|
35
|
+
* Delete all broken statuses of favorites.
|
|
36
|
+
*/
|
|
37
|
+
export declare function clearBrokenFavorite(): Promise<SynologyApiResponse<any>>;
|
|
38
|
+
export type EditFavoriteParams = {
|
|
39
|
+
path: string;
|
|
40
|
+
name: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Edit a favorite name
|
|
44
|
+
*/
|
|
45
|
+
export declare function editFavorite(params: EditFavoriteParams): Promise<SynologyApiResponse<any>>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
export async function getFavoriteList(params) {
|
|
3
|
+
const { additional = ["real_path", "size", "owner", "time"], ...resetParams } = params;
|
|
4
|
+
const res = await this.run(FileStationApi.Favorite, {
|
|
5
|
+
params: {
|
|
6
|
+
method: "list",
|
|
7
|
+
...resetParams,
|
|
8
|
+
additional: JSON.stringify(additional),
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
return res;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* add favorite
|
|
15
|
+
*/
|
|
16
|
+
export async function addFavorite(params) {
|
|
17
|
+
const res = await this.run(FileStationApi.Favorite, {
|
|
18
|
+
params: {
|
|
19
|
+
method: "add",
|
|
20
|
+
...params,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* remove favorite
|
|
27
|
+
*/
|
|
28
|
+
export async function deleteFavorite(params) {
|
|
29
|
+
const res = await this.run(FileStationApi.Favorite, {
|
|
30
|
+
params: {
|
|
31
|
+
method: "delete",
|
|
32
|
+
...params,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return res;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* clear_broken
|
|
39
|
+
* Delete all broken statuses of favorites.
|
|
40
|
+
*/
|
|
41
|
+
export async function clearBrokenFavorite() {
|
|
42
|
+
const res = await this.run(FileStationApi.Favorite, {
|
|
43
|
+
params: {
|
|
44
|
+
method: "clear_broken",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return res;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Edit a favorite name
|
|
51
|
+
*/
|
|
52
|
+
export async function editFavorite(params) {
|
|
53
|
+
const res = await this.run(FileStationApi.Favorite, {
|
|
54
|
+
params: {
|
|
55
|
+
method: "edit",
|
|
56
|
+
...params
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return res;
|
|
60
|
+
}
|
|
@@ -2,17 +2,17 @@ import { SynologyApiResponse } from "../../types/index.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* fetch filestation list
|
|
4
4
|
*/
|
|
5
|
-
export type
|
|
5
|
+
export type FileListRequest = {
|
|
6
6
|
limit?: number;
|
|
7
7
|
offset?: number;
|
|
8
8
|
sort_by?: string;
|
|
9
9
|
sort_direction?: "ASC" | "DESC";
|
|
10
|
-
version?: number;
|
|
11
10
|
filetype?: "file" | "dir" | "all";
|
|
12
11
|
folder_path?: string;
|
|
13
|
-
additional?:
|
|
12
|
+
additional?: Array<"real_path" | "size" | "owner" | "time" | "perm" | "type" | "mount_point_type">;
|
|
13
|
+
pattern?: string;
|
|
14
14
|
};
|
|
15
|
-
export type
|
|
15
|
+
export type FileListItem = {
|
|
16
16
|
isdir: boolean;
|
|
17
17
|
name: string;
|
|
18
18
|
path: string;
|
|
@@ -31,16 +31,16 @@ export type FileStationFileListItem = {
|
|
|
31
31
|
description: Record<string, any>;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
export type
|
|
35
|
-
files:
|
|
34
|
+
export type FileListResponse = SynologyApiResponse<{
|
|
35
|
+
files: FileListItem[];
|
|
36
36
|
offset: number;
|
|
37
37
|
total: number;
|
|
38
38
|
}>;
|
|
39
|
-
export declare function getFileList(params?:
|
|
39
|
+
export declare function getFileList(params?: FileListRequest): Promise<FileListResponse>;
|
|
40
40
|
/**
|
|
41
41
|
* fetch file share list
|
|
42
42
|
* */
|
|
43
|
-
export type
|
|
43
|
+
export type FileShareListRequest = {
|
|
44
44
|
limit?: number;
|
|
45
45
|
offset?: number;
|
|
46
46
|
sort_by?: string;
|
|
@@ -48,12 +48,40 @@ export type FileStationFileShareListRequest = {
|
|
|
48
48
|
additional?: string[];
|
|
49
49
|
onlywritable?: boolean;
|
|
50
50
|
};
|
|
51
|
-
export type
|
|
52
|
-
shares:
|
|
51
|
+
export type FileShareListResponse = SynologyApiResponse<{
|
|
52
|
+
shares: FileListItem & {
|
|
53
53
|
hybridshare_cache_status: number;
|
|
54
54
|
hybridshare_pin_status: number;
|
|
55
55
|
}[];
|
|
56
56
|
offset: number;
|
|
57
57
|
total: number;
|
|
58
58
|
}>;
|
|
59
|
-
export declare function
|
|
59
|
+
export declare function getShareFileList(params?: FileShareListRequest): Promise<FileShareListResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* fetch file share list
|
|
62
|
+
* */
|
|
63
|
+
export type VirtualFolderListRequest = {
|
|
64
|
+
type?: "Nfs" | "cifs" | "iso";
|
|
65
|
+
limit?: number;
|
|
66
|
+
offset?: number;
|
|
67
|
+
sort_by?: string;
|
|
68
|
+
sort_direction?: "ASC" | "DESC";
|
|
69
|
+
additional?: Array<"real_path" | "owner" | "time" | "perm" | "mount_point_type" | "volume_status">;
|
|
70
|
+
};
|
|
71
|
+
export type VirtualFolderListResponse = SynologyApiResponse<{
|
|
72
|
+
folders: Array<{
|
|
73
|
+
path: string;
|
|
74
|
+
name: string;
|
|
75
|
+
additional?: {
|
|
76
|
+
real_path?: string;
|
|
77
|
+
owner?: Record<string, any>;
|
|
78
|
+
time?: Record<string, any>;
|
|
79
|
+
perm?: Record<string, any>;
|
|
80
|
+
mount_point_type?: string;
|
|
81
|
+
volume_status?: Record<string, any>;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
offset: number;
|
|
85
|
+
total: number;
|
|
86
|
+
}>;
|
|
87
|
+
export declare function getVirtualFolderList(params?: VirtualFolderListRequest): Promise<VirtualFolderListResponse>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileStationApi } from "../../types/index.js";
|
|
2
|
-
import { isUndfined } from "../../utils.js";
|
|
2
|
+
import { isUndfined } from "../../utils/index.js";
|
|
3
3
|
export async function getFileList(params = {}) {
|
|
4
4
|
const { additional = ["real_path", "size", "owner", "time"], filetype = "all" } = params;
|
|
5
5
|
if (isUndfined(params.folder_path)) {
|
|
@@ -8,22 +8,30 @@ export async function getFileList(params = {}) {
|
|
|
8
8
|
const res = await this.run(FileStationApi.List, {
|
|
9
9
|
params: {
|
|
10
10
|
method: "list",
|
|
11
|
-
additional: JSON.stringify(additional),
|
|
12
|
-
filetype: filetype,
|
|
13
|
-
folder_path: params.folder_path,
|
|
14
11
|
...params,
|
|
12
|
+
additional: JSON.stringify(additional),
|
|
15
13
|
},
|
|
16
14
|
});
|
|
17
15
|
return res;
|
|
18
16
|
}
|
|
19
|
-
export async function
|
|
17
|
+
export async function getShareFileList(params = {}) {
|
|
20
18
|
const { additional = ["real_path", "size", "owner", "time"], onlywritable = false } = params;
|
|
21
19
|
const res = await this.run(FileStationApi.List, {
|
|
22
20
|
params: {
|
|
23
21
|
method: "list_share",
|
|
22
|
+
...params,
|
|
24
23
|
additional: JSON.stringify(additional),
|
|
25
|
-
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return res;
|
|
27
|
+
}
|
|
28
|
+
export async function getVirtualFolderList(params = {}) {
|
|
29
|
+
const { additional = [] } = params;
|
|
30
|
+
const res = await this.run(FileStationApi.VirtualFolder, {
|
|
31
|
+
params: {
|
|
32
|
+
method: "list",
|
|
26
33
|
...params,
|
|
34
|
+
additional: JSON.stringify(additional),
|
|
27
35
|
},
|
|
28
36
|
});
|
|
29
37
|
return res;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
+
export declare function startMD5Calc(params: {
|
|
3
|
+
file_path: string;
|
|
4
|
+
}): Promise<SynologyApiResponse<{
|
|
5
|
+
taskid: string;
|
|
6
|
+
}>>;
|
|
7
|
+
export declare function stopMD5Calc(params: {
|
|
8
|
+
taskid: string;
|
|
9
|
+
}): Promise<SynologyApiResponse<any>>;
|
|
10
|
+
export declare function getMD5CalcStatus(params: {
|
|
11
|
+
taskid: string;
|
|
12
|
+
}): Promise<SynologyApiResponse<{
|
|
13
|
+
finished: boolean;
|
|
14
|
+
md5: string;
|
|
15
|
+
}>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
export async function startMD5Calc(params) {
|
|
3
|
+
const res = await this.run(FileStationApi.MD5, {
|
|
4
|
+
params: {
|
|
5
|
+
method: "start",
|
|
6
|
+
file_path: params.file_path,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
return res;
|
|
10
|
+
}
|
|
11
|
+
export async function stopMD5Calc(params) {
|
|
12
|
+
const { taskid } = params;
|
|
13
|
+
const res = await this.run(FileStationApi.MD5, {
|
|
14
|
+
params: {
|
|
15
|
+
method: "stop",
|
|
16
|
+
taskid,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
export async function getMD5CalcStatus(params) {
|
|
22
|
+
const res = await this.run(FileStationApi.MD5, {
|
|
23
|
+
params: {
|
|
24
|
+
method: "status",
|
|
25
|
+
taskid: params.taskid,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
+
export type RenameParams = {
|
|
3
|
+
path: string;
|
|
4
|
+
name: string;
|
|
5
|
+
additional?: Array<"real_path" | "size" | "owner" | "time" | "perm" | "type">;
|
|
6
|
+
/**
|
|
7
|
+
* Optional. A unique ID for the search
|
|
8
|
+
* task which is obtained from start
|
|
9
|
+
* method. It is used to update the
|
|
10
|
+
* renamed file in the search result.
|
|
11
|
+
*/
|
|
12
|
+
search_taskid?: string;
|
|
13
|
+
};
|
|
14
|
+
export type RenameResponse = SynologyApiResponse<{
|
|
15
|
+
files: Array<{
|
|
16
|
+
isdir: boolean;
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
additional?: {
|
|
20
|
+
type: string;
|
|
21
|
+
size: number;
|
|
22
|
+
time: {
|
|
23
|
+
atime: number;
|
|
24
|
+
mtime: number;
|
|
25
|
+
ctime: number;
|
|
26
|
+
btime: number;
|
|
27
|
+
};
|
|
28
|
+
real_path: string;
|
|
29
|
+
mount_point_type: string;
|
|
30
|
+
indexed: boolean;
|
|
31
|
+
description: Record<string, any>;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Rename a file/folder.
|
|
37
|
+
*/
|
|
38
|
+
export declare function rename(params: RenameParams): Promise<RenameResponse>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rename a file/folder.
|
|
4
|
+
*/
|
|
5
|
+
export async function rename(params) {
|
|
6
|
+
const res = await this.run(FileStationApi.Rename, {
|
|
7
|
+
params: {
|
|
8
|
+
method: "rename",
|
|
9
|
+
...params,
|
|
10
|
+
additional: JSON.stringify(params.additional ?? []),
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
+
import { FileListItem } from "./List.js";
|
|
3
|
+
export type StartSearchParams = {
|
|
4
|
+
folder_path?: string;
|
|
5
|
+
filetype?: "file" | "dir" | "all";
|
|
6
|
+
recursive?: boolean;
|
|
7
|
+
pattern?: string;
|
|
8
|
+
};
|
|
9
|
+
export type StartSearchResponse = SynologyApiResponse<{
|
|
10
|
+
has_not_index_share: boolean;
|
|
11
|
+
taskid: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function startSearch(params: StartSearchParams): Promise<StartSearchResponse>;
|
|
14
|
+
export declare function stopSearch(params: {
|
|
15
|
+
taskid: string;
|
|
16
|
+
}): Promise<SynologyApiResponse<any>>;
|
|
17
|
+
export type SearchListParams = {
|
|
18
|
+
taskid: string;
|
|
19
|
+
filetype?: "file" | "dir" | "all";
|
|
20
|
+
limit?: number;
|
|
21
|
+
offset?: number;
|
|
22
|
+
additional?: string[];
|
|
23
|
+
sort_by?: "name" | "size" | "user" | "group" | "mtime" | "atime" | "ctime" | "crtime" | "posix" | "type";
|
|
24
|
+
sort_direction?: "ASC" | "DESC";
|
|
25
|
+
};
|
|
26
|
+
export type SearchListResponse = SynologyApiResponse<{
|
|
27
|
+
offset: number;
|
|
28
|
+
total: number;
|
|
29
|
+
finished: boolean;
|
|
30
|
+
files: Array<FileListItem>;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function getSearchList(params: SearchListParams): Promise<SearchListResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete search temporary database(s).
|
|
35
|
+
* @param taskid - Unique ID(s) for the search task which are
|
|
36
|
+
obtained from start method.
|
|
37
|
+
*/
|
|
38
|
+
export declare function cleanSearch(params: {
|
|
39
|
+
taskid: string;
|
|
40
|
+
}): Promise<SynologyApiResponse<any>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
export async function startSearch(params) {
|
|
3
|
+
const { recursive = true } = params;
|
|
4
|
+
return await this.run(FileStationApi.Search, {
|
|
5
|
+
params: {
|
|
6
|
+
method: "start",
|
|
7
|
+
recursive: recursive,
|
|
8
|
+
...params,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export async function stopSearch(params) {
|
|
13
|
+
return await this.run(FileStationApi.Search, {
|
|
14
|
+
params: {
|
|
15
|
+
method: "stop",
|
|
16
|
+
...params,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export async function getSearchList(params) {
|
|
21
|
+
const { taskid, filetype, limit = 1000, offset = 0, sort_by = "name", additional = ["real_path", "size", "owner", "time", "perm", "type"], sort_direction = "ASC", ...resetParams } = params;
|
|
22
|
+
const res = await this.run(FileStationApi.Search, {
|
|
23
|
+
params: {
|
|
24
|
+
method: "list",
|
|
25
|
+
taskid,
|
|
26
|
+
filetype,
|
|
27
|
+
limit,
|
|
28
|
+
offset,
|
|
29
|
+
sort_by,
|
|
30
|
+
sort_direction,
|
|
31
|
+
additional: JSON.stringify(additional),
|
|
32
|
+
...resetParams,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return res;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Delete search temporary database(s).
|
|
39
|
+
* @param taskid - Unique ID(s) for the search task which are
|
|
40
|
+
obtained from start method.
|
|
41
|
+
*/
|
|
42
|
+
export async function cleanSearch(params) {
|
|
43
|
+
return await this.run(FileStationApi.Search, {
|
|
44
|
+
params: {
|
|
45
|
+
method: "clean",
|
|
46
|
+
...params,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { SynologyApiResponse } from "../../types/index.js";
|
|
2
|
+
export type SharingLink = {
|
|
3
|
+
id: string;
|
|
4
|
+
date_available?: string;
|
|
5
|
+
date_expired?: string;
|
|
6
|
+
has_password?: boolean;
|
|
7
|
+
isFolder?: boolean;
|
|
8
|
+
link_owner?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
url?: string;
|
|
12
|
+
qrcode?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Get information of a sharing link by the sharing link ID.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSharingInfo(params: {
|
|
18
|
+
id: string;
|
|
19
|
+
}): Promise<SynologyApiResponse<SharingLink>>;
|
|
20
|
+
/**
|
|
21
|
+
* Get Sharing List
|
|
22
|
+
* */
|
|
23
|
+
export type GetSharingListParams = {
|
|
24
|
+
limit?: number;
|
|
25
|
+
offset?: number;
|
|
26
|
+
sort_by?: string;
|
|
27
|
+
sort_direction?: "ASC" | "DESC";
|
|
28
|
+
force_clean?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type GetSharingListResponse = SynologyApiResponse<{
|
|
31
|
+
offset: number;
|
|
32
|
+
total: number;
|
|
33
|
+
links: Array<SharingLink>;
|
|
34
|
+
}>;
|
|
35
|
+
export declare function getSharingList(params?: GetSharingListParams): Promise<GetSharingListResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Generate one or more sharing link(s) by file/folder path(s)
|
|
38
|
+
*/
|
|
39
|
+
export type CreateSharingLinkParams = {
|
|
40
|
+
path: string | string[];
|
|
41
|
+
password?: string;
|
|
42
|
+
date_expired?: string;
|
|
43
|
+
date_available?: string;
|
|
44
|
+
};
|
|
45
|
+
export type CreateSharingLinkResponse = SynologyApiResponse<{
|
|
46
|
+
links: Array<SharingLink>;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function createSharingLink(params: CreateSharingLinkParams): Promise<CreateSharingLinkResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Delete one or more sharing links.
|
|
51
|
+
*/
|
|
52
|
+
export type DeleteSharingLinkParams = {
|
|
53
|
+
id: string | string[];
|
|
54
|
+
};
|
|
55
|
+
export declare function deleteSharingLink(params: DeleteSharingLinkParams): Promise<SynologyApiResponse<any>>;
|
|
56
|
+
/**
|
|
57
|
+
* Remove all expired and broken sharing links.
|
|
58
|
+
*/
|
|
59
|
+
export declare function clearInvalidSharingLink(): Promise<SynologyApiResponse<any>>;
|
|
60
|
+
/**
|
|
61
|
+
* Edit sharing link(s)
|
|
62
|
+
* */
|
|
63
|
+
export type EditSharingLinkParams = {
|
|
64
|
+
id: string | string[];
|
|
65
|
+
password?: string;
|
|
66
|
+
date_expired?: string;
|
|
67
|
+
date_available?: string;
|
|
68
|
+
};
|
|
69
|
+
export declare function editSharingLink(params: EditSharingLinkParams): Promise<SynologyApiResponse<any>>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FileStationApi } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get information of a sharing link by the sharing link ID.
|
|
4
|
+
*/
|
|
5
|
+
export async function getSharingInfo(params) {
|
|
6
|
+
return await this.run(FileStationApi.Sharing, {
|
|
7
|
+
params: {
|
|
8
|
+
method: "getinfo",
|
|
9
|
+
...params,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export async function getSharingList(params = {}) {
|
|
14
|
+
const res = await this.run(FileStationApi.Sharing, {
|
|
15
|
+
params: {
|
|
16
|
+
method: "list",
|
|
17
|
+
...params,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
export async function createSharingLink(params) {
|
|
23
|
+
const { path, ...resetParams } = params;
|
|
24
|
+
const res = await this.run(FileStationApi.Sharing, {
|
|
25
|
+
params: {
|
|
26
|
+
method: "create",
|
|
27
|
+
path: Array.isArray(path) ? path.join(",") : path,
|
|
28
|
+
...resetParams,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return res;
|
|
32
|
+
}
|
|
33
|
+
export async function deleteSharingLink(params) {
|
|
34
|
+
const { id } = params;
|
|
35
|
+
const res = await this.run(FileStationApi.Sharing, {
|
|
36
|
+
params: {
|
|
37
|
+
method: "delete",
|
|
38
|
+
id: Array.isArray(id) ? id.join(",") : id,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Remove all expired and broken sharing links.
|
|
45
|
+
*/
|
|
46
|
+
export async function clearInvalidSharingLink() {
|
|
47
|
+
const res = await this.run(FileStationApi.Sharing, {
|
|
48
|
+
params: {
|
|
49
|
+
method: "clear_invalid",
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return res;
|
|
53
|
+
}
|
|
54
|
+
export async function editSharingLink(params) {
|
|
55
|
+
const { id, ...resetParams } = params;
|
|
56
|
+
const res = await this.run(FileStationApi.Sharing, {
|
|
57
|
+
params: {
|
|
58
|
+
method: "edit",
|
|
59
|
+
id: Array.isArray(id) ? id.join(",") : id,
|
|
60
|
+
...resetParams,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return res;
|
|
64
|
+
}
|