@interactive-inc/docs-client 1.1.0 → 1.1.1
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/build/{doc-file-system-BQAOBIO-.d.ts → doc-file-system-DEmPPJPE.d.ts} +10 -142
- package/build/doc-file-system.interface-C5vpYrOL.d.ts +135 -0
- package/build/file-system-json.d.ts +5 -4
- package/build/file-system-json.js +18 -296
- package/build/file-system-mock.d.ts +28 -8
- package/build/file-system-mock.js +47 -435
- package/build/file-system-node.d.ts +16 -0
- package/build/file-system-node.js +544 -0
- package/build/file-system-octokit.d.ts +8 -15
- package/build/file-system-octokit.js +17 -304
- package/build/file-system.d.ts +10 -8
- package/build/file-system.js +157 -171
- package/build/index.d.ts +23 -18
- package/build/index.js +29 -132
- package/build/models.js +4 -75
- package/package.json +3 -2
- package/tmp/docs-studio/files/a.md +9 -0
- package/tmp/docs-studio/pages/delete-document.md +7 -0
- package/tmp/docs-studio/pages/document-editor.md +9 -0
- package/tmp/docs-studio/pages/edit-document-content.md +7 -0
- package/tmp/docs-studio/pages/index.md +14 -0
|
@@ -118,419 +118,6 @@ var DocPathSystem = class {
|
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
// lib/modules/file-system/doc-file-system-read.ts
|
|
122
|
-
import * as fs from "fs/promises";
|
|
123
|
-
var DocFileSystemRead = class {
|
|
124
|
-
basePath;
|
|
125
|
-
pathSystem;
|
|
126
|
-
constructor(props) {
|
|
127
|
-
this.basePath = props.basePath;
|
|
128
|
-
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Read file content at the specified path
|
|
132
|
-
*/
|
|
133
|
-
async readFile(relativePath) {
|
|
134
|
-
try {
|
|
135
|
-
const exists = await this.exists(relativePath);
|
|
136
|
-
if (!exists) return null;
|
|
137
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
138
|
-
return await fs.readFile(fullPath, "utf-8");
|
|
139
|
-
} catch (error) {
|
|
140
|
-
return error instanceof Error ? error : new Error(`Failed to read file at ${relativePath}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Get file name from path
|
|
145
|
-
*/
|
|
146
|
-
readFileName(relativePath) {
|
|
147
|
-
return this.pathSystem.basename(relativePath);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get file extension from path
|
|
151
|
-
*/
|
|
152
|
-
readFileExtension(relativePath) {
|
|
153
|
-
return this.pathSystem.extname(relativePath);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Get directory path where the file exists
|
|
157
|
-
*/
|
|
158
|
-
readFileDirectory(relativePath) {
|
|
159
|
-
return this.pathSystem.dirname(relativePath);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Get list of entries in directory
|
|
163
|
-
*/
|
|
164
|
-
async readDirectoryFileNames(relativePath = "") {
|
|
165
|
-
try {
|
|
166
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
167
|
-
return await fs.readdir(fullPath);
|
|
168
|
-
} catch (error) {
|
|
169
|
-
return error instanceof Error ? error : new Error(`Failed to read directory at ${relativePath}`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
async readDirectoryFilePaths(relativePath) {
|
|
173
|
-
try {
|
|
174
|
-
const fileNames = await this.readDirectoryFileNames(relativePath);
|
|
175
|
-
if (fileNames instanceof Error) {
|
|
176
|
-
return fileNames;
|
|
177
|
-
}
|
|
178
|
-
return fileNames.map(
|
|
179
|
-
(fileName) => this.pathSystem.join(relativePath, fileName)
|
|
180
|
-
);
|
|
181
|
-
} catch (error) {
|
|
182
|
-
return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Check if path is a directory
|
|
187
|
-
*/
|
|
188
|
-
async isDirectory(relativePath) {
|
|
189
|
-
try {
|
|
190
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
191
|
-
const stats = await fs.stat(fullPath);
|
|
192
|
-
return stats.isDirectory();
|
|
193
|
-
} catch {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Check if path is a file
|
|
199
|
-
*/
|
|
200
|
-
async isFile(relativePath) {
|
|
201
|
-
try {
|
|
202
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
203
|
-
const stats = await fs.stat(fullPath);
|
|
204
|
-
return stats.isFile();
|
|
205
|
-
} catch {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Check if file or directory exists
|
|
211
|
-
*/
|
|
212
|
-
async exists(relativePath) {
|
|
213
|
-
try {
|
|
214
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
215
|
-
await fs.access(fullPath);
|
|
216
|
-
return true;
|
|
217
|
-
} catch {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Check if directory exists
|
|
223
|
-
*/
|
|
224
|
-
async directoryExists(relativePath) {
|
|
225
|
-
return this.isDirectory(relativePath);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Check if file exists
|
|
229
|
-
*/
|
|
230
|
-
async fileExists(relativePath) {
|
|
231
|
-
return this.isFile(relativePath);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Get base path
|
|
235
|
-
*/
|
|
236
|
-
getBasePath() {
|
|
237
|
-
return this.basePath;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Convert relative path to absolute path
|
|
241
|
-
*/
|
|
242
|
-
resolve(relativePath) {
|
|
243
|
-
return this.pathSystem.join(this.basePath, relativePath);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Get file size in bytes
|
|
247
|
-
*/
|
|
248
|
-
async getFileSize(relativePath) {
|
|
249
|
-
try {
|
|
250
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
251
|
-
const stats = await fs.stat(fullPath);
|
|
252
|
-
return stats.size;
|
|
253
|
-
} catch (error) {
|
|
254
|
-
return error instanceof Error ? error : new Error(`Failed to get file size at ${relativePath}`);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Get file last modified time
|
|
259
|
-
*/
|
|
260
|
-
async getFileModifiedTime(relativePath) {
|
|
261
|
-
try {
|
|
262
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
263
|
-
const stats = await fs.stat(fullPath);
|
|
264
|
-
return stats.mtime;
|
|
265
|
-
} catch (error) {
|
|
266
|
-
return error instanceof Error ? error : new Error(`Failed to get file modified time at ${relativePath}`);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Get file creation time
|
|
271
|
-
*/
|
|
272
|
-
async getFileCreatedTime(relativePath) {
|
|
273
|
-
try {
|
|
274
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
275
|
-
const stats = await fs.stat(fullPath);
|
|
276
|
-
return stats.birthtime;
|
|
277
|
-
} catch (error) {
|
|
278
|
-
return error instanceof Error ? error : new Error(`Failed to get file created time at ${relativePath}`);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// lib/modules/file-system/doc-file-system-write.ts
|
|
284
|
-
import * as fs2 from "fs/promises";
|
|
285
|
-
var DocFileSystemWrite = class {
|
|
286
|
-
basePath;
|
|
287
|
-
pathSystem;
|
|
288
|
-
reader;
|
|
289
|
-
constructor(props) {
|
|
290
|
-
this.basePath = props.basePath;
|
|
291
|
-
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
292
|
-
this.reader = props.reader;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Write content to file at the specified path (creates directory if needed)
|
|
296
|
-
*/
|
|
297
|
-
async writeFile(relativePath, content) {
|
|
298
|
-
try {
|
|
299
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
300
|
-
const dirPath = this.pathSystem.dirname(fullPath);
|
|
301
|
-
await fs2.mkdir(dirPath, { recursive: true });
|
|
302
|
-
await fs2.writeFile(fullPath, content, "utf-8");
|
|
303
|
-
return null;
|
|
304
|
-
} catch (error) {
|
|
305
|
-
return error instanceof Error ? error : new Error(`Failed to write file at ${relativePath}`);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Delete file at the specified path
|
|
310
|
-
*/
|
|
311
|
-
async deleteFile(relativePath) {
|
|
312
|
-
try {
|
|
313
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
314
|
-
await fs2.unlink(fullPath);
|
|
315
|
-
return null;
|
|
316
|
-
} catch (error) {
|
|
317
|
-
return new Error(`Failed to delete file at ${relativePath}: ${error}`);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Create directory
|
|
322
|
-
*/
|
|
323
|
-
async createDirectory(relativePath) {
|
|
324
|
-
try {
|
|
325
|
-
const fullPath = this.pathSystem.join(this.basePath, relativePath);
|
|
326
|
-
await fs2.mkdir(fullPath, { recursive: true });
|
|
327
|
-
return null;
|
|
328
|
-
} catch (error) {
|
|
329
|
-
return error instanceof Error ? error : new Error(`Failed to create directory at ${relativePath}`);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Create directory if it doesn't exist
|
|
334
|
-
*/
|
|
335
|
-
async ensureDirectoryExists(relativePath) {
|
|
336
|
-
try {
|
|
337
|
-
if (this.reader) {
|
|
338
|
-
const exists = await this.reader.exists(relativePath);
|
|
339
|
-
if (exists) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
const result = await this.createDirectory(relativePath);
|
|
344
|
-
if (result instanceof Error) {
|
|
345
|
-
return result;
|
|
346
|
-
}
|
|
347
|
-
return null;
|
|
348
|
-
} catch (error) {
|
|
349
|
-
return error instanceof Error ? error : new Error(`Failed to ensure directory exists at ${relativePath}`);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Copy file
|
|
354
|
-
*/
|
|
355
|
-
async copyFile(sourcePath, destinationPath) {
|
|
356
|
-
try {
|
|
357
|
-
const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
|
|
358
|
-
const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
|
|
359
|
-
await fs2.copyFile(sourceFullPath, destFullPath);
|
|
360
|
-
return null;
|
|
361
|
-
} catch (error) {
|
|
362
|
-
return error instanceof Error ? error : new Error(
|
|
363
|
-
`Failed to copy file from ${sourcePath} to ${destinationPath}`
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Move file
|
|
369
|
-
*/
|
|
370
|
-
async moveFile(sourcePath, destinationPath) {
|
|
371
|
-
try {
|
|
372
|
-
const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
|
|
373
|
-
const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
|
|
374
|
-
await fs2.rename(sourceFullPath, destFullPath);
|
|
375
|
-
return null;
|
|
376
|
-
} catch (error) {
|
|
377
|
-
return error instanceof Error ? error : new Error(
|
|
378
|
-
`Failed to move file from ${sourcePath} to ${destinationPath}`
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
// lib/modules/file-system/doc-file-system.ts
|
|
385
|
-
var DocFileSystem = class {
|
|
386
|
-
reader;
|
|
387
|
-
writer;
|
|
388
|
-
basePath;
|
|
389
|
-
pathSystem;
|
|
390
|
-
constructor(props) {
|
|
391
|
-
this.basePath = props.basePath;
|
|
392
|
-
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
393
|
-
this.reader = props.reader ?? new DocFileSystemRead({
|
|
394
|
-
basePath: this.basePath,
|
|
395
|
-
pathSystem: this.pathSystem
|
|
396
|
-
});
|
|
397
|
-
this.writer = props.writer ?? new DocFileSystemWrite({
|
|
398
|
-
basePath: this.basePath,
|
|
399
|
-
pathSystem: this.pathSystem,
|
|
400
|
-
reader: this.reader
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Read file content at the specified path
|
|
405
|
-
*/
|
|
406
|
-
async readFile(relativePath) {
|
|
407
|
-
return this.reader.readFile(relativePath);
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Write content to file at the specified path (creates directory if needed)
|
|
411
|
-
*/
|
|
412
|
-
async writeFile(relativePath, content) {
|
|
413
|
-
return this.writer.writeFile(relativePath, content);
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Delete file at the specified path
|
|
417
|
-
*/
|
|
418
|
-
async deleteFile(relativePath) {
|
|
419
|
-
return this.writer.deleteFile(relativePath);
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Get file name from path
|
|
423
|
-
*/
|
|
424
|
-
readFileName(relativePath) {
|
|
425
|
-
return this.reader.readFileName(relativePath);
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Get file extension from path
|
|
429
|
-
*/
|
|
430
|
-
readFileExtension(relativePath) {
|
|
431
|
-
return this.reader.readFileExtension(relativePath);
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Get directory path where the file exists
|
|
435
|
-
*/
|
|
436
|
-
readFileDirectory(relativePath) {
|
|
437
|
-
return this.reader.readFileDirectory(relativePath);
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Get list of entries in directory
|
|
441
|
-
*/
|
|
442
|
-
async readDirectoryFileNames(relativePath = "") {
|
|
443
|
-
return this.reader.readDirectoryFileNames(relativePath);
|
|
444
|
-
}
|
|
445
|
-
async readDirectoryFilePaths(relativePath) {
|
|
446
|
-
return this.reader.readDirectoryFilePaths(relativePath);
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Check if path is a directory
|
|
450
|
-
*/
|
|
451
|
-
async isDirectory(relativePath) {
|
|
452
|
-
return this.reader.isDirectory(relativePath);
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Check if path is a file
|
|
456
|
-
*/
|
|
457
|
-
async isFile(relativePath) {
|
|
458
|
-
return this.reader.isFile(relativePath);
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Check if file or directory exists
|
|
462
|
-
*/
|
|
463
|
-
async exists(relativePath) {
|
|
464
|
-
return this.reader.exists(relativePath);
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Check if directory exists
|
|
468
|
-
*/
|
|
469
|
-
async directoryExists(relativePath) {
|
|
470
|
-
return this.reader.directoryExists(relativePath);
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Check if file exists
|
|
474
|
-
*/
|
|
475
|
-
async fileExists(relativePath) {
|
|
476
|
-
return this.reader.fileExists(relativePath);
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Get base path
|
|
480
|
-
*/
|
|
481
|
-
getBasePath() {
|
|
482
|
-
return this.reader.getBasePath();
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Convert relative path to absolute path
|
|
486
|
-
*/
|
|
487
|
-
resolve(relativePath) {
|
|
488
|
-
return this.reader.resolve(relativePath);
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Create directory
|
|
492
|
-
*/
|
|
493
|
-
async createDirectory(relativePath) {
|
|
494
|
-
return this.writer.createDirectory(relativePath);
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Get file size in bytes
|
|
498
|
-
*/
|
|
499
|
-
async getFileSize(relativePath) {
|
|
500
|
-
return this.reader.getFileSize(relativePath);
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Create directory if it doesn't exist
|
|
504
|
-
*/
|
|
505
|
-
async ensureDirectoryExists(relativePath) {
|
|
506
|
-
return this.writer.ensureDirectoryExists(relativePath);
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Copy file
|
|
510
|
-
*/
|
|
511
|
-
async copyFile(sourcePath, destinationPath) {
|
|
512
|
-
return this.writer.copyFile(sourcePath, destinationPath);
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Move file
|
|
516
|
-
*/
|
|
517
|
-
async moveFile(sourcePath, destinationPath) {
|
|
518
|
-
return this.writer.moveFile(sourcePath, destinationPath);
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Get file last modified time
|
|
522
|
-
*/
|
|
523
|
-
async getFileModifiedTime(relativePath) {
|
|
524
|
-
return this.reader.getFileModifiedTime(relativePath);
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Get file creation time
|
|
528
|
-
*/
|
|
529
|
-
async getFileCreatedTime(relativePath) {
|
|
530
|
-
return this.reader.getFileCreatedTime(relativePath);
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
|
|
534
121
|
// lib/modules/file-system/doc-file-system-mock.ts
|
|
535
122
|
var mockDirectoryData = {
|
|
536
123
|
"docs/index.md": `---
|
|
@@ -564,14 +151,13 @@ API documentation.`,
|
|
|
564
151
|
|
|
565
152
|
Complete API reference.`
|
|
566
153
|
};
|
|
567
|
-
var DocFileSystemMock = class _DocFileSystemMock
|
|
154
|
+
var DocFileSystemMock = class _DocFileSystemMock {
|
|
568
155
|
files = /* @__PURE__ */ new Map();
|
|
569
|
-
|
|
570
|
-
|
|
156
|
+
pathSystem;
|
|
157
|
+
basePath;
|
|
571
158
|
constructor(props) {
|
|
572
|
-
|
|
573
|
-
this.
|
|
574
|
-
this._basePath = props.basePath.endsWith("/") ? props.basePath.slice(0, -1) : props.basePath;
|
|
159
|
+
this.pathSystem = props.pathSystem ?? new DocPathSystem();
|
|
160
|
+
this.basePath = props.basePath.endsWith("/") ? props.basePath.slice(0, -1) : props.basePath;
|
|
575
161
|
if (!props.skipDefaultFiles) {
|
|
576
162
|
this.setupTestFiles(mockDirectoryData);
|
|
577
163
|
}
|
|
@@ -581,34 +167,61 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
581
167
|
* PathSystem accessor (for testing)
|
|
582
168
|
*/
|
|
583
169
|
getPathSystem() {
|
|
584
|
-
return this.
|
|
170
|
+
return this.pathSystem;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get file name from path
|
|
174
|
+
*/
|
|
175
|
+
readFileName(relativePath) {
|
|
176
|
+
return this.pathSystem.basename(relativePath);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get file extension from path
|
|
180
|
+
*/
|
|
181
|
+
readFileExtension(relativePath) {
|
|
182
|
+
return this.pathSystem.extname(relativePath);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get directory path where the file exists
|
|
186
|
+
*/
|
|
187
|
+
readFileDirectory(relativePath) {
|
|
188
|
+
return this.pathSystem.dirname(relativePath);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Get base path
|
|
192
|
+
*/
|
|
193
|
+
getBasePath() {
|
|
194
|
+
return this.basePath;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Convert relative path to absolute path
|
|
198
|
+
*/
|
|
199
|
+
resolve(relativePath) {
|
|
200
|
+
return this.pathSystem.join(this.basePath, relativePath);
|
|
585
201
|
}
|
|
586
202
|
/**
|
|
587
203
|
* Normalize path using basePath
|
|
588
204
|
*/
|
|
589
205
|
normalizePath(filePath) {
|
|
590
|
-
if (filePath.startsWith(this.
|
|
206
|
+
if (filePath.startsWith(this.basePath)) {
|
|
591
207
|
return filePath;
|
|
592
208
|
}
|
|
593
209
|
const cleanPath = filePath.startsWith("/") ? filePath.slice(1) : filePath;
|
|
594
|
-
return `${this.
|
|
210
|
+
return `${this.basePath}/${cleanPath}`;
|
|
595
211
|
}
|
|
596
212
|
/**
|
|
597
213
|
* Create instance (mock data is automatically loaded)
|
|
598
214
|
*/
|
|
599
215
|
static create(basePath = "/test") {
|
|
600
|
-
|
|
601
|
-
return new _DocFileSystemMock({ basePath, pathSystem });
|
|
216
|
+
return new _DocFileSystemMock({ basePath });
|
|
602
217
|
}
|
|
603
218
|
/**
|
|
604
219
|
* Factory method for testing
|
|
605
220
|
*/
|
|
606
221
|
static createWithFiles(props) {
|
|
607
|
-
const pathSystem = new DocPathSystem();
|
|
608
222
|
const basePath = props.basePath ?? "/test";
|
|
609
223
|
const fileSystem = new _DocFileSystemMock({
|
|
610
224
|
basePath,
|
|
611
|
-
pathSystem,
|
|
612
225
|
skipDefaultFiles: true
|
|
613
226
|
});
|
|
614
227
|
if (props.fileContents) {
|
|
@@ -736,7 +349,7 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
736
349
|
const files = [];
|
|
737
350
|
for (const path of this.files.keys()) {
|
|
738
351
|
if (path.startsWith(dirPath) && !path.slice(dirPath.length).includes("/")) {
|
|
739
|
-
const relativePath = path.startsWith(`${this.
|
|
352
|
+
const relativePath = path.startsWith(`${this.basePath}/`) ? path.slice(this.basePath.length + 1) : path;
|
|
740
353
|
files.push(relativePath);
|
|
741
354
|
}
|
|
742
355
|
}
|
|
@@ -745,7 +358,7 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
745
358
|
return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${directoryPath}`);
|
|
746
359
|
}
|
|
747
360
|
}
|
|
748
|
-
async
|
|
361
|
+
async createEmptyDirectory(_directoryPath) {
|
|
749
362
|
return null;
|
|
750
363
|
}
|
|
751
364
|
async deleteDirectory(directoryPath) {
|
|
@@ -768,7 +381,7 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
768
381
|
return error instanceof Error ? error : new Error(`Failed to get file size at ${filePath}`);
|
|
769
382
|
}
|
|
770
383
|
}
|
|
771
|
-
async
|
|
384
|
+
async getFileUpdatedTime(filePath) {
|
|
772
385
|
try {
|
|
773
386
|
const normalizedPath = this.normalizePath(filePath);
|
|
774
387
|
const file = this.files.get(normalizedPath);
|
|
@@ -811,7 +424,7 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
811
424
|
*/
|
|
812
425
|
async readDirectoryFileNames(directoryPath = "") {
|
|
813
426
|
try {
|
|
814
|
-
const normalizedDir = directoryPath === "" ? this.
|
|
427
|
+
const normalizedDir = directoryPath === "" ? this.basePath : this.normalizePath(directoryPath);
|
|
815
428
|
const dirPath = normalizedDir.endsWith("/") ? normalizedDir : `${normalizedDir}/`;
|
|
816
429
|
const entries = /* @__PURE__ */ new Set();
|
|
817
430
|
for (const path of this.files.keys()) {
|
|
@@ -843,7 +456,7 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
843
456
|
/**
|
|
844
457
|
* Create directory if it doesn't exist
|
|
845
458
|
*/
|
|
846
|
-
async
|
|
459
|
+
async createDirectory(_relativePath) {
|
|
847
460
|
return null;
|
|
848
461
|
}
|
|
849
462
|
/**
|
|
@@ -871,7 +484,7 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
871
484
|
*/
|
|
872
485
|
getAllFilePaths() {
|
|
873
486
|
return Array.from(this.files.keys()).map((path) => {
|
|
874
|
-
return path.startsWith(`${this.
|
|
487
|
+
return path.startsWith(`${this.basePath}/`) ? path.slice(this.basePath.length + 1) : path;
|
|
875
488
|
}).sort();
|
|
876
489
|
}
|
|
877
490
|
/**
|
|
@@ -896,6 +509,5 @@ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
|
|
|
896
509
|
}
|
|
897
510
|
}
|
|
898
511
|
};
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
};
|
|
512
|
+
|
|
513
|
+
export { DocFileSystemMock };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as DocPathSystem } from './doc-file-system.interface-C5vpYrOL.js';
|
|
2
|
+
import { D as DocFileSystem } from './doc-file-system-DEmPPJPE.js';
|
|
3
|
+
export { DocFileSystemRead as DocFileSystemNodeRead, DocFileSystemWrite as DocFileSystemNodeWrite } from './file-system.js';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
basePath: string;
|
|
7
|
+
pathSystem?: DocPathSystem;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Node.js file system with separate read/write components
|
|
11
|
+
*/
|
|
12
|
+
declare class DocFileSystemNode extends DocFileSystem {
|
|
13
|
+
constructor(props: Props);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { DocFileSystemNode };
|