zen-fs-webdav 0.1.0
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/LICENSE +21 -0
- package/README.md +261 -0
- package/dist/index.d.mts +278 -0
- package/dist/index.d.ts +278 -0
- package/dist/index.js +768 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +752 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +2374 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebDAV 文件系统配置选项
|
|
3
|
+
*/
|
|
4
|
+
interface WebDAVOptions {
|
|
5
|
+
/**
|
|
6
|
+
* WebDAV 服务器的基础 URL
|
|
7
|
+
*/
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* 认证用户名(可选)
|
|
11
|
+
*/
|
|
12
|
+
username?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 认证密码(可选)
|
|
15
|
+
*/
|
|
16
|
+
password?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 认证令牌(可选,如果提供则优先使用)
|
|
19
|
+
*/
|
|
20
|
+
token?: string;
|
|
21
|
+
/**
|
|
22
|
+
* 自定义请求头(可选)
|
|
23
|
+
*/
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* 请求超时时间,单位毫秒(可选,默认 30000)
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* WebDAV 请求选项
|
|
32
|
+
*/
|
|
33
|
+
interface WebDAVRequestOptions {
|
|
34
|
+
/**
|
|
35
|
+
* 请求方法
|
|
36
|
+
*/
|
|
37
|
+
method: string;
|
|
38
|
+
/**
|
|
39
|
+
* 请求头
|
|
40
|
+
*/
|
|
41
|
+
headers?: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* 请求体
|
|
44
|
+
*/
|
|
45
|
+
body?: string | ArrayBuffer | null;
|
|
46
|
+
/**
|
|
47
|
+
* 请求超时时间,单位毫秒
|
|
48
|
+
*/
|
|
49
|
+
timeout?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 文件或目录条目
|
|
53
|
+
*/
|
|
54
|
+
interface FileEntry {
|
|
55
|
+
/**
|
|
56
|
+
* 文件或目录名称
|
|
57
|
+
*/
|
|
58
|
+
name: string;
|
|
59
|
+
/**
|
|
60
|
+
* 是否为目录
|
|
61
|
+
*/
|
|
62
|
+
isDirectory: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 文件大小(字节)
|
|
65
|
+
*/
|
|
66
|
+
size?: number;
|
|
67
|
+
/**
|
|
68
|
+
* 最后修改时间
|
|
69
|
+
*/
|
|
70
|
+
lastModified?: Date;
|
|
71
|
+
/**
|
|
72
|
+
* 创建时间
|
|
73
|
+
*/
|
|
74
|
+
createdAt?: Date;
|
|
75
|
+
/**
|
|
76
|
+
* 文件或目录的完整路径
|
|
77
|
+
*/
|
|
78
|
+
path: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 文件或目录统计信息
|
|
82
|
+
*/
|
|
83
|
+
interface Stats {
|
|
84
|
+
/**
|
|
85
|
+
* 是否为目录
|
|
86
|
+
*/
|
|
87
|
+
isDirectory: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* 是否为文件
|
|
90
|
+
*/
|
|
91
|
+
isFile: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* 文件大小(字节)
|
|
94
|
+
*/
|
|
95
|
+
size: number;
|
|
96
|
+
/**
|
|
97
|
+
* 最后修改时间
|
|
98
|
+
*/
|
|
99
|
+
lastModified?: Date;
|
|
100
|
+
/**
|
|
101
|
+
* 创建时间
|
|
102
|
+
*/
|
|
103
|
+
createdAt?: Date;
|
|
104
|
+
/**
|
|
105
|
+
* 文件或目录名称
|
|
106
|
+
*/
|
|
107
|
+
name: string;
|
|
108
|
+
/**
|
|
109
|
+
* 文件或目录的完整路径
|
|
110
|
+
*/
|
|
111
|
+
path: string;
|
|
112
|
+
/**
|
|
113
|
+
* 文件的 MIME 类型
|
|
114
|
+
*/
|
|
115
|
+
mimeType?: string;
|
|
116
|
+
/**
|
|
117
|
+
* 文件的 ETag
|
|
118
|
+
*/
|
|
119
|
+
etag?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 读取文件选项
|
|
123
|
+
*/
|
|
124
|
+
interface ReadFileOptions {
|
|
125
|
+
/**
|
|
126
|
+
* 响应类型
|
|
127
|
+
*/
|
|
128
|
+
responseType?: 'text' | 'arraybuffer';
|
|
129
|
+
/**
|
|
130
|
+
* 编码(仅当 responseType 为 'text' 时有效)
|
|
131
|
+
*/
|
|
132
|
+
encoding?: string;
|
|
133
|
+
headers?: Record<string, string>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 写入文件选项
|
|
137
|
+
*/
|
|
138
|
+
interface WriteFileOptions {
|
|
139
|
+
/**
|
|
140
|
+
* 是否覆盖现有文件
|
|
141
|
+
*/
|
|
142
|
+
overwrite?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* 文件的 MIME 类型
|
|
145
|
+
*/
|
|
146
|
+
contentType?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* 创建目录选项
|
|
150
|
+
*/
|
|
151
|
+
interface MkdirOptions {
|
|
152
|
+
/**
|
|
153
|
+
* 是否递归创建目录
|
|
154
|
+
*/
|
|
155
|
+
recursive?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 删除目录选项
|
|
159
|
+
*/
|
|
160
|
+
interface RmdirOptions {
|
|
161
|
+
/**
|
|
162
|
+
* 是否递归删除目录及其内容
|
|
163
|
+
*/
|
|
164
|
+
recursive?: boolean;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 读取目录选项
|
|
168
|
+
*/
|
|
169
|
+
interface ReaddirOptions {
|
|
170
|
+
/**
|
|
171
|
+
* 是否包含详细信息
|
|
172
|
+
*/
|
|
173
|
+
withFileTypes?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* 深度,1 表示只列出当前目录,大于 1 表示递归列出子目录
|
|
176
|
+
*/
|
|
177
|
+
depth?: number;
|
|
178
|
+
includeHidden?: boolean;
|
|
179
|
+
headers?: Record<string, string>;
|
|
180
|
+
recursive?: boolean;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 复制选项
|
|
184
|
+
*/
|
|
185
|
+
interface CopyOptions {
|
|
186
|
+
/**
|
|
187
|
+
* 是否覆盖目标位置的现有文件
|
|
188
|
+
*/
|
|
189
|
+
overwrite?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* 是否递归复制目录
|
|
192
|
+
*/
|
|
193
|
+
recursive?: boolean;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 移动选项
|
|
197
|
+
*/
|
|
198
|
+
interface MoveOptions {
|
|
199
|
+
/**
|
|
200
|
+
* 是否覆盖目标位置的现有文件
|
|
201
|
+
*/
|
|
202
|
+
overwrite?: boolean;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* WebDAV操作结果
|
|
206
|
+
*/
|
|
207
|
+
interface WebDAVResult {
|
|
208
|
+
/**
|
|
209
|
+
* 操作是否成功
|
|
210
|
+
*/
|
|
211
|
+
success: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* HTTP状态码
|
|
214
|
+
*/
|
|
215
|
+
statusCode: number;
|
|
216
|
+
/**
|
|
217
|
+
* 操作结果消息(可选)
|
|
218
|
+
*/
|
|
219
|
+
message?: string;
|
|
220
|
+
/**
|
|
221
|
+
* 操作返回的数据(可选)
|
|
222
|
+
*/
|
|
223
|
+
data?: unknown;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface WebDAVFileSystem {
|
|
227
|
+
readFile(path: string, options?: ReadFileOptions): Promise<Buffer | string>;
|
|
228
|
+
writeFile(path: string, data: Buffer | string, options?: WriteFileOptions): Promise<WebDAVResult>;
|
|
229
|
+
deleteFile(path: string): Promise<WebDAVResult>;
|
|
230
|
+
readDir(path: string, options?: ReaddirOptions): Promise<Stats[]>;
|
|
231
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
232
|
+
rm(path: string, options?: {
|
|
233
|
+
recursive?: boolean;
|
|
234
|
+
force?: boolean;
|
|
235
|
+
}): Promise<void>;
|
|
236
|
+
rmdir(path: string, options?: boolean | {
|
|
237
|
+
recursive?: boolean;
|
|
238
|
+
force?: boolean;
|
|
239
|
+
}): Promise<void>;
|
|
240
|
+
stat(path: string): Promise<Stats>;
|
|
241
|
+
exists(path: string): Promise<boolean>;
|
|
242
|
+
copy(source: string, destination: string, overwrite?: boolean): Promise<WebDAVResult>;
|
|
243
|
+
move(source: string, destination: string, overwrite?: boolean): Promise<WebDAVResult>;
|
|
244
|
+
unlink(path: string): Promise<void>;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 创建 WebDAV 文件系统实例(工厂函数)
|
|
249
|
+
* @param options WebDAV 配置选项
|
|
250
|
+
* @returns WebDAVFileSystem 实例
|
|
251
|
+
*/
|
|
252
|
+
declare function createWebDAVFileSystem(options: WebDAVOptions): WebDAVFileSystem;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* WebDAV文件系统库的错误类型定义
|
|
256
|
+
*/
|
|
257
|
+
/**
|
|
258
|
+
* WebDAV错误基类
|
|
259
|
+
*/
|
|
260
|
+
declare class WebDAVError extends Error {
|
|
261
|
+
/**
|
|
262
|
+
* HTTP状态码
|
|
263
|
+
*/
|
|
264
|
+
status?: number;
|
|
265
|
+
/**
|
|
266
|
+
* 原始错误对象(如果有)
|
|
267
|
+
*/
|
|
268
|
+
cause?: unknown;
|
|
269
|
+
constructor(message: string, status?: number, cause?: unknown);
|
|
270
|
+
toString(): string;
|
|
271
|
+
static fromResponse(response: {
|
|
272
|
+
status: number;
|
|
273
|
+
statusText: string;
|
|
274
|
+
}, message?: string): WebDAVError;
|
|
275
|
+
static fromError(error: unknown): WebDAVError;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export { type CopyOptions, type FileEntry, type MkdirOptions, type MoveOptions, type ReadFileOptions, type ReaddirOptions, type RmdirOptions, type Stats, WebDAVError, type WebDAVFileSystem, type WebDAVOptions, type WebDAVRequestOptions, type WriteFileOptions, createWebDAVFileSystem };
|