@omnistreamai/data-adapter-webdav 0.4.1 → 0.4.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/package.json +8 -2
- package/skills/configure-webdav-adapter/SKILL.md +186 -0
- package/CHANGELOG.md +0 -59
- package/dist/index.d.mts +0 -79
- package/dist/index.d.mts.map +0 -1
- package/dist/index.d.ts +0 -79
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -258
- package/dist/index.mjs.map +0 -1
- package/src/index.ts +0 -3
- package/src/webdav-adapter.test.ts +0 -423
- package/src/webdav-adapter.ts +0 -458
- package/tsconfig.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
- package/tsdown.config.ts +0 -12
- package/vitest.config.ts +0 -10
package/dist/index.mjs
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { AdapterType, AuthType } from "@omnistreamai/data-core";
|
|
2
|
-
|
|
3
|
-
//#region src/webdav-adapter.ts
|
|
4
|
-
/**
|
|
5
|
-
* WebDAV adapter implementation
|
|
6
|
-
*/
|
|
7
|
-
var WebDAVAdapter = class {
|
|
8
|
-
type = AdapterType.Remote;
|
|
9
|
-
name = "WebDAVAdapter";
|
|
10
|
-
service = null;
|
|
11
|
-
/**
|
|
12
|
-
* Set service configuration
|
|
13
|
-
*/
|
|
14
|
-
setService(service) {
|
|
15
|
-
this.service = service;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get request headers
|
|
19
|
-
*/
|
|
20
|
-
getHeaders() {
|
|
21
|
-
const headers = { "Content-Type": "application/json" };
|
|
22
|
-
if (!this.service?.authentication) return headers;
|
|
23
|
-
const { authentication } = this.service;
|
|
24
|
-
switch (authentication.authType) {
|
|
25
|
-
case AuthType.Token:
|
|
26
|
-
if (authentication.token) headers["Authorization"] = `${authentication.token.token_type} ${authentication.token.access_token}`;
|
|
27
|
-
break;
|
|
28
|
-
case AuthType.Bearer:
|
|
29
|
-
if (authentication.bearer) headers["Authorization"] = `Bearer ${authentication.bearer}`;
|
|
30
|
-
break;
|
|
31
|
-
case AuthType.Basic:
|
|
32
|
-
if (authentication.username && authentication.password) headers["Authorization"] = `Basic ${btoa(`${authentication.username}:${authentication.password}`)}`;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
return headers;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Build URL
|
|
39
|
-
*/
|
|
40
|
-
buildUrl(storeName) {
|
|
41
|
-
if (!this.service) throw new Error("Service not configured. Call setService() first.");
|
|
42
|
-
return `${this.service.endpoint.replace(/\/$/, "")}${this.service.basePath ? `/${this.service.basePath.replace(/^\/+|\/+$/g, "")}` : ""}/${storeName}.json`;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Send request
|
|
46
|
-
*/
|
|
47
|
-
async request(url, options = {}, { allowNotFound, createIfNotFound } = {}) {
|
|
48
|
-
const response = await fetch(url, {
|
|
49
|
-
...options,
|
|
50
|
-
headers: {
|
|
51
|
-
...this.getHeaders(),
|
|
52
|
-
...options.headers
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
if (!response.ok) {
|
|
56
|
-
if (response.status === 404) {
|
|
57
|
-
if (allowNotFound) return null;
|
|
58
|
-
if (createIfNotFound && options.method === "GET") {
|
|
59
|
-
await this.createPathIfNotExists(url);
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
throw new Error(`HTTP error! status: ${response.status}, message: ${response.statusText}`);
|
|
64
|
-
}
|
|
65
|
-
const text = await response.text();
|
|
66
|
-
if (!text) return null;
|
|
67
|
-
try {
|
|
68
|
-
return JSON.parse(text);
|
|
69
|
-
} catch {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Create path if not exists
|
|
75
|
-
*/
|
|
76
|
-
async createPathIfNotExists(url) {
|
|
77
|
-
const baseUrl = this.service.endpoint.replace(/\/$/, "");
|
|
78
|
-
const pathParts = url.replace(baseUrl, "").replace(/^\//, "").split("/");
|
|
79
|
-
let fullPath = "";
|
|
80
|
-
for (const part of pathParts) {
|
|
81
|
-
fullPath = fullPath ? `${fullPath}/${part}` : part;
|
|
82
|
-
const createUrl = `${baseUrl}/${fullPath}`;
|
|
83
|
-
const response = await fetch(createUrl, {
|
|
84
|
-
method: part.endsWith(".json") ? "PUT" : "MKCOL",
|
|
85
|
-
headers: this.getHeaders(),
|
|
86
|
-
body: part.endsWith(".json") ? JSON.stringify([]) : void 0
|
|
87
|
-
});
|
|
88
|
-
if (!response.ok && response.status !== 405) throw new Error(`Failed to create path: ${response.statusText}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Initialize store
|
|
93
|
-
*/
|
|
94
|
-
async initStore(_storeName, _indexes = [], _idKey = "id") {}
|
|
95
|
-
/**
|
|
96
|
-
* Add data
|
|
97
|
-
*/
|
|
98
|
-
async add(storeName, data, _idKey = "id") {
|
|
99
|
-
const url = this.buildUrl(storeName);
|
|
100
|
-
const items = await this.request(url, { method: "GET" }, { createIfNotFound: true }) || [];
|
|
101
|
-
items.push(data);
|
|
102
|
-
await this.request(url, {
|
|
103
|
-
method: "PUT",
|
|
104
|
-
body: JSON.stringify(items)
|
|
105
|
-
});
|
|
106
|
-
return data;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Update data
|
|
110
|
-
*/
|
|
111
|
-
async update(storeName, id, data, idKey = "id") {
|
|
112
|
-
const url = this.buildUrl(storeName);
|
|
113
|
-
const existing = await this.request(url, { method: "GET" });
|
|
114
|
-
if (!existing) throw new Error("Not found id:" + id);
|
|
115
|
-
const index = existing.findIndex((item) => String(item[idKey]) === id);
|
|
116
|
-
if (index === -1) throw new Error("Not found id:" + id);
|
|
117
|
-
existing[index] = {
|
|
118
|
-
...existing[index],
|
|
119
|
-
...data
|
|
120
|
-
};
|
|
121
|
-
await this.request(url, {
|
|
122
|
-
method: "PUT",
|
|
123
|
-
body: JSON.stringify(existing)
|
|
124
|
-
});
|
|
125
|
-
return existing[index];
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Delete data
|
|
129
|
-
*/
|
|
130
|
-
async delete(storeName, id, idKey = "id") {
|
|
131
|
-
const url = this.buildUrl(storeName);
|
|
132
|
-
const existing = await this.request(url, { method: "GET" });
|
|
133
|
-
if (!existing) throw new Error("Not found id:" + id);
|
|
134
|
-
const index = existing.findIndex((item) => String(item[idKey]) === id);
|
|
135
|
-
if (index === -1) throw new Error("Not found id:" + id);
|
|
136
|
-
existing.splice(index, 1);
|
|
137
|
-
await this.request(url, {
|
|
138
|
-
method: "PUT",
|
|
139
|
-
body: JSON.stringify(existing)
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Get data by ID
|
|
144
|
-
*/
|
|
145
|
-
async getData(storeName, id, idKey = "id") {
|
|
146
|
-
const url = this.buildUrl(storeName);
|
|
147
|
-
const existing = await this.request(url, { method: "GET" }, { allowNotFound: true });
|
|
148
|
-
if (!existing) return null;
|
|
149
|
-
return existing.find((item) => String(item[idKey]) === id) ?? null;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Get list data (with pagination support)
|
|
153
|
-
*/
|
|
154
|
-
async getList(storeName, options = {}, _idKey = "id") {
|
|
155
|
-
const url = this.buildUrl(storeName);
|
|
156
|
-
const allData = await this.request(url, { method: "GET" }, { createIfNotFound: true }) || [];
|
|
157
|
-
let filteredData = allData;
|
|
158
|
-
if (options.where) filteredData = allData.filter((item) => {
|
|
159
|
-
for (const key in options.where) if (item[key] !== options.where[key]) return false;
|
|
160
|
-
return true;
|
|
161
|
-
});
|
|
162
|
-
if (options.sortBy) filteredData = this.sortEntries(filteredData, String(options.sortBy), options.sortOrder);
|
|
163
|
-
const totalCount = filteredData.length;
|
|
164
|
-
const page = options.page ?? 1;
|
|
165
|
-
const limit = options.limit ?? totalCount;
|
|
166
|
-
const startIndex = (page - 1) * limit;
|
|
167
|
-
const endIndex = startIndex + limit;
|
|
168
|
-
return {
|
|
169
|
-
data: filteredData.slice(startIndex, endIndex),
|
|
170
|
-
totalCount,
|
|
171
|
-
page,
|
|
172
|
-
limit
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Sort entries by specified field
|
|
177
|
-
* @param entries Array of entries to sort
|
|
178
|
-
* @param key Sorting field name
|
|
179
|
-
* @param sortOrder Sort order: 'asc' or 'desc' (default: 'asc')
|
|
180
|
-
* @returns Sorted array of entries
|
|
181
|
-
*/
|
|
182
|
-
sortEntries(entries, key, sortOrder = "asc") {
|
|
183
|
-
return [...entries].sort((a, b) => {
|
|
184
|
-
const aValue = a[key];
|
|
185
|
-
const bValue = b[key];
|
|
186
|
-
if (aValue == null && bValue == null) return 0;
|
|
187
|
-
if (aValue == null) return 1;
|
|
188
|
-
if (bValue == null) return -1;
|
|
189
|
-
let comparison = 0;
|
|
190
|
-
if (typeof aValue === "number" && typeof bValue === "number") comparison = aValue - bValue;
|
|
191
|
-
else if (typeof aValue === "string" && typeof bValue === "string") comparison = aValue.localeCompare(bValue);
|
|
192
|
-
else if (typeof aValue === "string" && typeof bValue === "string") {
|
|
193
|
-
const aDate = new Date(aValue);
|
|
194
|
-
const bDate = new Date(bValue);
|
|
195
|
-
if (!isNaN(aDate.getTime()) && !isNaN(bDate.getTime())) comparison = aDate.getTime() - bDate.getTime();
|
|
196
|
-
else comparison = String(aValue).localeCompare(String(bValue));
|
|
197
|
-
} else comparison = String(aValue).localeCompare(String(bValue));
|
|
198
|
-
return sortOrder === "desc" ? -comparison : comparison;
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Clear store
|
|
203
|
-
*/
|
|
204
|
-
async clear(storeName) {
|
|
205
|
-
const list = await this.getList(storeName);
|
|
206
|
-
for (const item of list.data) {
|
|
207
|
-
const id = String(item["id"]);
|
|
208
|
-
await this.delete(storeName, id);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* List directory contents
|
|
213
|
-
*/
|
|
214
|
-
async listDirectory(path = "") {
|
|
215
|
-
if (!this.service) throw new Error("Service not configured. Call setService() first.");
|
|
216
|
-
const baseUrl = this.service.endpoint.replace(/\/$/, "");
|
|
217
|
-
const url = path ? `${baseUrl}/${path.replace(/^\//, "")}` : baseUrl;
|
|
218
|
-
const response = await fetch(url, {
|
|
219
|
-
method: "PROPFIND",
|
|
220
|
-
headers: {
|
|
221
|
-
...this.getHeaders(),
|
|
222
|
-
Depth: "1"
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
if (!response.ok) throw new Error(`Failed to list directory: ${response.statusText}`);
|
|
226
|
-
const text = await response.text();
|
|
227
|
-
const hrefRegex = /<d:href[^>]*>([^<]+)<\/d:href>/gi;
|
|
228
|
-
const files = [];
|
|
229
|
-
let match;
|
|
230
|
-
const basePath = new URL(baseUrl).pathname;
|
|
231
|
-
while ((match = hrefRegex.exec(text)) !== null) {
|
|
232
|
-
const fullPath = match[1] || "";
|
|
233
|
-
let relativePath = "";
|
|
234
|
-
try {
|
|
235
|
-
relativePath = new URL(fullPath).pathname;
|
|
236
|
-
} catch {}
|
|
237
|
-
const pathRegex = /* @__PURE__ */ new RegExp(`^/*${path}`);
|
|
238
|
-
relativePath = fullPath.replace(basePath, "").replace(pathRegex, "").replace(/^\//, "");
|
|
239
|
-
if (relativePath && relativePath !== path.replace(/^\//, "")) files.push(relativePath);
|
|
240
|
-
}
|
|
241
|
-
return files;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Test connection
|
|
245
|
-
*/
|
|
246
|
-
async testConnection() {
|
|
247
|
-
try {
|
|
248
|
-
await this.listDirectory("");
|
|
249
|
-
return true;
|
|
250
|
-
} catch {
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
//#endregion
|
|
257
|
-
export { WebDAVAdapter };
|
|
258
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["headers: Record<string, string>","files: string[]"],"sources":["../src/webdav-adapter.ts"],"sourcesContent":["import {\n AdapterType,\n type RemoteAdapter,\n type QueryOptions,\n type PaginatedResult,\n type ServiceConfig,\n AuthType,\n} from \"@omnistreamai/data-core\";\n\n/**\n * WebDAV adapter implementation\n */\nexport class WebDAVAdapter implements RemoteAdapter {\n readonly type = AdapterType.Remote;\n readonly name = \"WebDAVAdapter\";\n\n private service: ServiceConfig | null = null;\n\n /**\n * Set service configuration\n */\n setService(service: ServiceConfig): void {\n this.service = service;\n }\n\n /**\n * Get request headers\n */\n private getHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (!this.service?.authentication) {\n return headers;\n }\n\n const { authentication } = this.service;\n\n switch (authentication.authType) {\n case AuthType.Token:\n if (authentication.token) {\n headers[\"Authorization\"] =\n `${authentication.token.token_type} ${authentication.token.access_token}`;\n }\n break;\n case AuthType.Bearer:\n if (authentication.bearer) {\n headers[\"Authorization\"] = `Bearer ${authentication.bearer}`;\n }\n break;\n case AuthType.Basic:\n if (authentication.username && authentication.password) {\n const credentials = btoa(\n `${authentication.username}:${authentication.password}`,\n );\n headers[\"Authorization\"] = `Basic ${credentials}`;\n }\n break;\n }\n\n return headers;\n }\n\n /**\n * Build URL\n */\n private buildUrl(storeName: string): string {\n if (!this.service) {\n throw new Error(\"Service not configured. Call setService() first.\");\n }\n\n const baseUrl = this.service.endpoint.replace(/\\/$/, \"\");\n const basePath = this.service.basePath ? `/${this.service.basePath.replace(/^\\/+|\\/+$/g, \"\")}` : \"\";\n return `${baseUrl}${basePath}/${storeName}.json`;\n }\n\n /**\n * Send request\n */\n private async request<T>(\n url: string,\n options: RequestInit = {},\n {\n allowNotFound,\n createIfNotFound,\n }: {\n allowNotFound?: boolean;\n createIfNotFound?: boolean;\n } = {},\n ): Promise<T | null> {\n const response = await fetch(url, {\n ...options,\n headers: {\n ...this.getHeaders(),\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n if (response.status === 404) {\n if (allowNotFound) {\n return null;\n }\n if (createIfNotFound && options.method === \"GET\") {\n await this.createPathIfNotExists(url);\n return [] as T;\n }\n }\n throw new Error(\n `HTTP error! status: ${response.status}, message: ${response.statusText}`,\n );\n }\n\n const text = await response.text();\n if (!text) {\n return null;\n }\n\n try {\n return JSON.parse(text) as T;\n } catch {\n return null;\n }\n }\n\n /**\n * Create path if not exists\n */\n private async createPathIfNotExists(url: string): Promise<void> {\n const baseUrl = this.service!.endpoint.replace(/\\/$/, \"\");\n const relativePath = url.replace(baseUrl, \"\").replace(/^\\//, \"\");\n const pathParts = relativePath.split(\"/\");\n\n let fullPath = \"\";\n for (const part of pathParts) {\n fullPath = fullPath ? `${fullPath}/${part}` : part;\n const createUrl = `${baseUrl}/${fullPath}`;\n\n const response = await fetch(createUrl, {\n method: part.endsWith('.json') ? \"PUT\" : \"MKCOL\",\n headers: this.getHeaders(),\n body: part.endsWith('.json') ? JSON.stringify([]) : undefined,\n });\n\n if (!response.ok && response.status !== 405) {\n throw new Error(`Failed to create path: ${response.statusText}`);\n }\n }\n }\n\n /**\n * Initialize store\n */\n async initStore(\n _storeName: string,\n _indexes: string[] = [],\n _idKey: string = \"id\",\n ): Promise<void> {\n }\n\n /**\n * Add data\n */\n async add<T extends Record<string, unknown>>(\n storeName: string,\n data: T,\n _idKey: string = \"id\",\n ): Promise<T> {\n const url = this.buildUrl(storeName);\n\n const existing = await this.request<T[]>(url, {\n method: \"GET\",\n }, {\n createIfNotFound: true,\n }) || [];\n\n const items = existing || [];\n items.push(data);\n\n await this.request(url, {\n method: \"PUT\",\n body: JSON.stringify(items),\n });\n\n return data;\n }\n\n /**\n * Update data\n */\n async update<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n data: Partial<T>,\n idKey: string = \"id\",\n ): Promise<T> {\n const url = this.buildUrl(storeName);\n\n const existing = await this.request<T[]>(url, {\n method: \"GET\",\n });\n\n if (!existing) {\n throw new Error(\"Not found id:\" + id);\n }\n\n const index = existing.findIndex(item => String(item[idKey]) === id);\n if (index === -1) {\n throw new Error(\"Not found id:\" + id);\n }\n\n existing[index] = { ...existing[index], ...data } as T;\n\n await this.request(url, {\n method: \"PUT\",\n body: JSON.stringify(existing),\n });\n\n return existing[index];\n }\n\n /**\n * Delete data\n */\n async delete(\n storeName: string,\n id: string,\n idKey: string = \"id\",\n ): Promise<void> {\n const url = this.buildUrl(storeName);\n\n const existing = await this.request<Record<string, unknown>[]>(url, {\n method: \"GET\",\n });\n\n if (!existing) {\n throw new Error(\"Not found id:\" + id);\n }\n\n const index = existing.findIndex(item => String(item[idKey]) === id);\n if (index === -1) {\n throw new Error(\"Not found id:\" + id);\n }\n\n existing.splice(index, 1);\n\n await this.request(url, {\n method: \"PUT\",\n body: JSON.stringify(existing),\n });\n }\n\n /**\n * Get data by ID\n */\n async getData<T extends Record<string, unknown>>(\n storeName: string,\n id: string,\n idKey: string = \"id\",\n ): Promise<T | null> {\n const url = this.buildUrl(storeName);\n\n const existing = await this.request<T[]>(url, {\n method: \"GET\",\n }, {\n allowNotFound: true,\n });\n\n if (!existing) {\n return null;\n }\n\n const item = existing.find(item => String(item[idKey]) === id);\n return item ?? null;\n }\n\n /**\n * Get list data (with pagination support)\n */\n async getList<T extends Record<string, unknown>>(\n storeName: string,\n options: QueryOptions<T> = {},\n _idKey: string = \"id\",\n ): Promise<PaginatedResult<T>> {\n const url = this.buildUrl(storeName);\n\n const allData = await this.request<T[]>(url, {\n method: \"GET\",\n }, {\n createIfNotFound: true,\n }) || [];\n\n let filteredData = allData;\n\n if (options.where) {\n filteredData = allData.filter((item) => {\n for (const key in options.where) {\n const itemValue = item[key];\n const whereValue = options.where![key];\n if (itemValue !== whereValue) {\n return false;\n }\n }\n return true;\n });\n }\n\n // Sorting\n if (options.sortBy) {\n filteredData = this.sortEntries(\n filteredData,\n String(options.sortBy),\n options.sortOrder,\n );\n }\n\n const totalCount = filteredData.length;\n const page = options.page ?? 1;\n const limit = options.limit ?? totalCount;\n\n const startIndex = (page - 1) * limit;\n const endIndex = startIndex + limit;\n const paginatedData = filteredData.slice(startIndex, endIndex);\n\n return {\n data: paginatedData,\n totalCount,\n page,\n limit,\n };\n }\n\n /**\n * Sort entries by specified field\n * @param entries Array of entries to sort\n * @param key Sorting field name\n * @param sortOrder Sort order: 'asc' or 'desc' (default: 'asc')\n * @returns Sorted array of entries\n */\n private sortEntries<T extends Record<string, unknown>>(\n entries: T[],\n key: string,\n sortOrder: \"asc\" | \"desc\" = \"asc\",\n ): T[] {\n return [...entries].sort((a, b) => {\n const aValue = a[key];\n const bValue = b[key];\n\n // Handle undefined or null values\n if (aValue == null && bValue == null) return 0;\n if (aValue == null) return 1; // null/undefined at the end\n if (bValue == null) return -1; // null/undefined at the end\n\n let comparison = 0;\n\n // Number type sorting\n if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n comparison = aValue - bValue;\n }\n // String type sorting\n else if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n comparison = aValue.localeCompare(bValue);\n }\n // Date type sorting (if string format date)\n else if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n const aDate = new Date(aValue);\n const bDate = new Date(bValue);\n if (!isNaN(aDate.getTime()) && !isNaN(bDate.getTime())) {\n comparison = aDate.getTime() - bDate.getTime();\n } else {\n // Convert other types to string for comparison\n comparison = String(aValue).localeCompare(String(bValue));\n }\n }\n // Convert other types to string for comparison\n else {\n comparison = String(aValue).localeCompare(String(bValue));\n }\n\n // Apply sort order\n return sortOrder === \"desc\" ? -comparison : comparison;\n });\n }\n\n /**\n * Clear store\n */\n async clear(storeName: string): Promise<void> {\n const list = await this.getList(storeName);\n\n for (const item of list.data) {\n const id = String((item as Record<string, unknown>)[\"id\"]);\n await this.delete(storeName, id);\n }\n }\n\n /**\n * List directory contents\n */\n async listDirectory(path: string = \"\"): Promise<string[]> {\n if (!this.service) {\n throw new Error(\"Service not configured. Call setService() first.\");\n }\n\n const baseUrl = this.service.endpoint.replace(/\\/$/, \"\");\n const url = path ? `${baseUrl}/${path.replace(/^\\//, \"\")}` : baseUrl;\n\n const response = await fetch(url, {\n method: \"PROPFIND\",\n headers: {\n ...this.getHeaders(),\n Depth: \"1\",\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to list directory: ${response.statusText}`);\n }\n\n const text = await response.text();\n\n const hrefRegex = /<d:href[^>]*>([^<]+)<\\/d:href>/gi;\n const files: string[] = [];\n let match;\n\n const baseUrlObj = new URL(baseUrl);\n const basePath = baseUrlObj.pathname;\n\n while ((match = hrefRegex.exec(text)) !== null) {\n const fullPath = match[1] || \"\";\n let relativePath = \"\";\n try {\n const hrefUrl = new URL(fullPath);\n relativePath = hrefUrl.pathname;\n } catch {}\n const pathRegex = new RegExp(`^/*${path}`)\n relativePath = fullPath.replace(basePath, \"\").replace(pathRegex, '').replace(/^\\//, \"\");\n if (relativePath && relativePath !== path.replace(/^\\//, \"\")) {\n files.push(relativePath);\n }\n }\n\n return files;\n }\n\n /**\n * Test connection\n */\n async testConnection(): Promise<boolean> {\n try {\n await this.listDirectory(\"\");\n return true;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":";;;;;;AAYA,IAAa,gBAAb,MAAoD;CAClD,AAAS,OAAO,YAAY;CAC5B,AAAS,OAAO;CAEhB,AAAQ,UAAgC;;;;CAKxC,WAAW,SAA8B;AACvC,OAAK,UAAU;;;;;CAMjB,AAAQ,aAAqC;EAC3C,MAAMA,UAAkC,EACtC,gBAAgB,oBACjB;AAED,MAAI,CAAC,KAAK,SAAS,eACjB,QAAO;EAGT,MAAM,EAAE,mBAAmB,KAAK;AAEhC,UAAQ,eAAe,UAAvB;GACE,KAAK,SAAS;AACZ,QAAI,eAAe,MACjB,SAAQ,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