@interactive-inc/docs-client 1.0.0 → 1.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/build/index.js CHANGED
@@ -1878,6 +1878,9 @@ var DocFileRelationReference = class {
1878
1878
  }
1879
1879
  async read() {
1880
1880
  const files = await this.readFiles();
1881
+ if (files instanceof Error) {
1882
+ return files;
1883
+ }
1881
1884
  return new DocRelationValue({
1882
1885
  path: this.path,
1883
1886
  files: files.map((value) => value.toJson())
@@ -1892,9 +1895,15 @@ var DocFileRelationReference = class {
1892
1895
  return [];
1893
1896
  }
1894
1897
  const filePaths = await this.fileSystem.readDirectoryFilePaths(this.path);
1898
+ if (filePaths instanceof Error) {
1899
+ return filePaths;
1900
+ }
1895
1901
  const files = [];
1896
1902
  for (const filePath of filePaths) {
1897
1903
  const file = await this.readFile(filePath);
1904
+ if (file instanceof Error) {
1905
+ return file;
1906
+ }
1898
1907
  if (file === null) continue;
1899
1908
  files.push(file);
1900
1909
  }
@@ -1908,6 +1917,9 @@ var DocFileRelationReference = class {
1908
1917
  return null;
1909
1918
  }
1910
1919
  const content = await this.fileSystem.readFile(filePath);
1920
+ if (content instanceof Error) {
1921
+ return content;
1922
+ }
1911
1923
  if (content === null) {
1912
1924
  return null;
1913
1925
  }
@@ -1940,6 +1952,9 @@ var DocFileRelationReference = class {
1940
1952
  */
1941
1953
  async readSlugs() {
1942
1954
  const files = await this.readFiles();
1955
+ if (files instanceof Error) {
1956
+ return files;
1957
+ }
1943
1958
  return files.map((file) => file.id);
1944
1959
  }
1945
1960
  /**
@@ -1947,6 +1962,9 @@ var DocFileRelationReference = class {
1947
1962
  */
1948
1963
  async count() {
1949
1964
  const files = await this.readFiles();
1965
+ if (files instanceof Error) {
1966
+ return files;
1967
+ }
1950
1968
  return files.length;
1951
1969
  }
1952
1970
  /**
@@ -1954,6 +1972,9 @@ var DocFileRelationReference = class {
1954
1972
  */
1955
1973
  async isEmpty() {
1956
1974
  const count = await this.count();
1975
+ if (count instanceof Error) {
1976
+ return count;
1977
+ }
1957
1978
  return count === 0;
1958
1979
  }
1959
1980
  };
@@ -3273,6 +3294,9 @@ var DocFileIndexReference = class _DocFileIndexReference {
3273
3294
  }
3274
3295
  async read() {
3275
3296
  const content = await this.fileSystem.readFile(this.filePath);
3297
+ if (content instanceof Error) {
3298
+ return content;
3299
+ }
3276
3300
  if (content === null) {
3277
3301
  const dirPath = this.pathSystem.dirname(this.filePath);
3278
3302
  const dirName = this.pathSystem.basename(dirPath);
@@ -3330,14 +3354,14 @@ var DocFileIndexReference = class _DocFileIndexReference {
3330
3354
  * Write content to file
3331
3355
  */
3332
3356
  async writeContent(content) {
3333
- await this.fileSystem.writeFile(this.filePath, content);
3357
+ return await this.fileSystem.writeFile(this.filePath, content);
3334
3358
  }
3335
3359
  /**
3336
3360
  * Write entity
3337
3361
  */
3338
3362
  async write(entity) {
3339
3363
  const content = entity.content.toText();
3340
- await this.fileSystem.writeFile(this.filePath, content);
3364
+ return await this.fileSystem.writeFile(this.filePath, content);
3341
3365
  }
3342
3366
  /**
3343
3367
  * Create new file with default content
@@ -3350,7 +3374,13 @@ var DocFileIndexReference = class _DocFileIndexReference {
3350
3374
  "",
3351
3375
  `Please describe the overview of ${dirName} here.`
3352
3376
  ].join("\n");
3353
- await this.fileSystem.writeFile(this.filePath, defaultContent);
3377
+ const writeResult = await this.fileSystem.writeFile(
3378
+ this.filePath,
3379
+ defaultContent
3380
+ );
3381
+ if (writeResult instanceof Error) {
3382
+ return writeResult;
3383
+ }
3354
3384
  return null;
3355
3385
  }
3356
3386
  /**
@@ -3367,6 +3397,9 @@ var DocFileIndexReference = class _DocFileIndexReference {
3367
3397
  }
3368
3398
  async relations() {
3369
3399
  const indexFile = await this.read();
3400
+ if (indexFile instanceof Error) {
3401
+ return indexFile;
3402
+ }
3370
3403
  const schema = indexFile.content.meta().schema();
3371
3404
  if (!schema) {
3372
3405
  return [];
@@ -3391,10 +3424,14 @@ var DocFileIndexReference = class _DocFileIndexReference {
3391
3424
  }
3392
3425
  async readRelations() {
3393
3426
  const relations = await this.relations();
3427
+ if (relations instanceof Error) {
3428
+ return relations;
3429
+ }
3394
3430
  const files = [];
3395
3431
  for (const relation of relations) {
3396
3432
  const entity = await relation.read();
3397
3433
  if (entity === null) continue;
3434
+ if (entity instanceof Error) continue;
3398
3435
  files.push(entity);
3399
3436
  }
3400
3437
  return files;
@@ -3428,7 +3465,13 @@ var DocFileIndexReference = class _DocFileIndexReference {
3428
3465
  archiveDirectoryName,
3429
3466
  fileName
3430
3467
  );
3431
- await this.fileSystem.moveFile(this.filePath, archivePath);
3468
+ const moveResult = await this.fileSystem.moveFile(
3469
+ this.filePath,
3470
+ archivePath
3471
+ );
3472
+ if (moveResult instanceof Error) {
3473
+ throw moveResult;
3474
+ }
3432
3475
  return new _DocFileIndexReference({
3433
3476
  path: archivePath,
3434
3477
  fileSystem: this.fileSystem,
@@ -3451,7 +3494,13 @@ var DocFileIndexReference = class _DocFileIndexReference {
3451
3494
  this.pathSystem.dirname(dirPath),
3452
3495
  fileName
3453
3496
  );
3454
- await this.fileSystem.moveFile(this.filePath, restorePath);
3497
+ const moveResult = await this.fileSystem.moveFile(
3498
+ this.filePath,
3499
+ restorePath
3500
+ );
3501
+ if (moveResult instanceof Error) {
3502
+ throw moveResult;
3503
+ }
3455
3504
  return new _DocFileIndexReference({
3456
3505
  path: restorePath,
3457
3506
  fileSystem: this.fileSystem,
@@ -3507,9 +3556,15 @@ var DocFileMdReference = class _DocFileMdReference {
3507
3556
  }
3508
3557
  async read() {
3509
3558
  const content = await this.fileSystem.readFile(this.path);
3559
+ if (content instanceof Error) {
3560
+ return content;
3561
+ }
3510
3562
  const actualPath = this.path;
3511
3563
  if (content === null) {
3512
3564
  const archivedContent = await this.fileSystem.readFile(this.archivedPath);
3565
+ if (archivedContent instanceof Error) {
3566
+ return archivedContent;
3567
+ }
3513
3568
  if (archivedContent !== null) {
3514
3569
  const contentValue2 = DocFileMdContentValue.fromMarkdown(
3515
3570
  archivedContent,
@@ -3569,7 +3624,10 @@ var DocFileMdReference = class _DocFileMdReference {
3569
3624
  */
3570
3625
  async write(entity) {
3571
3626
  const content = entity.content.toText();
3572
- await this.fileSystem.writeFile(this.path, content);
3627
+ const writeResult = await this.fileSystem.writeFile(this.path, content);
3628
+ if (writeResult instanceof Error) {
3629
+ return writeResult;
3630
+ }
3573
3631
  return null;
3574
3632
  }
3575
3633
  async writeText(text) {
@@ -3597,13 +3655,13 @@ var DocFileMdReference = class _DocFileMdReference {
3597
3655
  * Copy file
3598
3656
  */
3599
3657
  async copyTo(destinationPath) {
3600
- await this.fileSystem.copyFile(this.path, destinationPath);
3658
+ return await this.fileSystem.copyFile(this.path, destinationPath);
3601
3659
  }
3602
3660
  /**
3603
3661
  * Move file
3604
3662
  */
3605
3663
  async moveTo(destinationPath) {
3606
- await this.fileSystem.moveFile(this.path, destinationPath);
3664
+ return await this.fileSystem.moveFile(this.path, destinationPath);
3607
3665
  }
3608
3666
  /**
3609
3667
  * Move file to archive and return new reference
@@ -3616,7 +3674,10 @@ var DocFileMdReference = class _DocFileMdReference {
3616
3674
  archiveDirectoryName,
3617
3675
  fileName
3618
3676
  );
3619
- await this.moveTo(archivePath);
3677
+ const moveResult = await this.moveTo(archivePath);
3678
+ if (moveResult instanceof Error) {
3679
+ throw moveResult;
3680
+ }
3620
3681
  return new _DocFileMdReference({
3621
3682
  path: archivePath,
3622
3683
  fileSystem: this.fileSystem,
@@ -3639,7 +3700,10 @@ var DocFileMdReference = class _DocFileMdReference {
3639
3700
  this.pathSystem.dirname(dirPath),
3640
3701
  fileName
3641
3702
  );
3642
- await this.moveTo(restorePath);
3703
+ const moveResult = await this.moveTo(restorePath);
3704
+ if (moveResult instanceof Error) {
3705
+ throw moveResult;
3706
+ }
3643
3707
  return new _DocFileMdReference({
3644
3708
  path: restorePath,
3645
3709
  fileSystem: this.fileSystem,
@@ -3902,6 +3966,9 @@ var DocFileUnknownReference = class _DocFileUnknownReference {
3902
3966
  }
3903
3967
  async read() {
3904
3968
  const content = await this.fileSystem.readFile(this.path);
3969
+ if (content instanceof Error) {
3970
+ return content;
3971
+ }
3905
3972
  if (content === null) {
3906
3973
  return new Error(`File not found at ${this.path}.`);
3907
3974
  }
@@ -3937,19 +4004,19 @@ var DocFileUnknownReference = class _DocFileUnknownReference {
3937
4004
  * Write content to file
3938
4005
  */
3939
4006
  async writeContent(content) {
3940
- await this.fileSystem.writeFile(this.path, content);
4007
+ return await this.fileSystem.writeFile(this.path, content);
3941
4008
  }
3942
4009
  /**
3943
4010
  * Write entity
3944
4011
  */
3945
4012
  async write(entity) {
3946
- await this.fileSystem.writeFile(this.path, entity.value.content);
4013
+ return await this.fileSystem.writeFile(this.path, entity.value.content);
3947
4014
  }
3948
4015
  /**
3949
4016
  * Write raw content
3950
4017
  */
3951
4018
  async writeRaw(content) {
3952
- await this.fileSystem.writeFile(this.path, content);
4019
+ return await this.fileSystem.writeFile(this.path, content);
3953
4020
  }
3954
4021
  /**
3955
4022
  * Delete file
@@ -3967,13 +4034,13 @@ var DocFileUnknownReference = class _DocFileUnknownReference {
3967
4034
  * Copy file
3968
4035
  */
3969
4036
  async copyTo(destinationPath) {
3970
- await this.fileSystem.copyFile(this.path, destinationPath);
4037
+ return await this.fileSystem.copyFile(this.path, destinationPath);
3971
4038
  }
3972
4039
  /**
3973
4040
  * Move file
3974
4041
  */
3975
4042
  async moveTo(destinationPath) {
3976
- await this.fileSystem.moveFile(this.path, destinationPath);
4043
+ return await this.fileSystem.moveFile(this.path, destinationPath);
3977
4044
  }
3978
4045
  /**
3979
4046
  * Get file size in bytes
@@ -4004,7 +4071,10 @@ var DocFileUnknownReference = class _DocFileUnknownReference {
4004
4071
  archiveDirectoryName,
4005
4072
  fileName
4006
4073
  );
4007
- await this.moveTo(archivePath);
4074
+ const moveResult = await this.moveTo(archivePath);
4075
+ if (moveResult instanceof Error) {
4076
+ throw moveResult;
4077
+ }
4008
4078
  return new _DocFileUnknownReference({
4009
4079
  path: archivePath,
4010
4080
  fileSystem: this.fileSystem,
@@ -4026,7 +4096,10 @@ var DocFileUnknownReference = class _DocFileUnknownReference {
4026
4096
  this.pathSystem.dirname(dirPath),
4027
4097
  fileName
4028
4098
  );
4029
- await this.moveTo(restorePath);
4099
+ const moveResult = await this.moveTo(restorePath);
4100
+ if (moveResult instanceof Error) {
4101
+ throw moveResult;
4102
+ }
4030
4103
  return new _DocFileUnknownReference({
4031
4104
  path: restorePath,
4032
4105
  fileSystem: this.fileSystem,
@@ -4078,6 +4151,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4078
4151
  const filePaths = await this.fileSystem.readDirectoryFilePaths(
4079
4152
  this.relativePath
4080
4153
  );
4154
+ if (filePaths instanceof Error) {
4155
+ return filePaths;
4156
+ }
4081
4157
  return filePaths.map((p) => this.pathSystem.basename(p)).filter((name) => name.includes("."));
4082
4158
  }
4083
4159
  async archivedFileNames() {
@@ -4086,10 +4162,17 @@ var DocDirectoryReference = class _DocDirectoryReference {
4086
4162
  this.archiveDirectoryName
4087
4163
  );
4088
4164
  const filePaths = await this.fileSystem.readDirectoryFilePaths(archivePath);
4165
+ if (filePaths instanceof Error) {
4166
+ return filePaths;
4167
+ }
4089
4168
  return filePaths.map((p) => this.pathSystem.basename(p)).filter((name) => name.includes("."));
4090
4169
  }
4091
4170
  async *filesGenerator() {
4092
4171
  const fileNames = await this.fileNames();
4172
+ if (fileNames instanceof Error) {
4173
+ yield fileNames;
4174
+ return;
4175
+ }
4093
4176
  for (const fileName of fileNames) {
4094
4177
  if (fileName === "index.md") continue;
4095
4178
  if (fileName.endsWith(".md")) {
@@ -4110,6 +4193,10 @@ var DocDirectoryReference = class _DocDirectoryReference {
4110
4193
  });
4111
4194
  }
4112
4195
  const archivedFileNames = await this.archivedFileNames();
4196
+ if (archivedFileNames instanceof Error) {
4197
+ yield archivedFileNames;
4198
+ return;
4199
+ }
4113
4200
  for (const fileName of archivedFileNames) {
4114
4201
  if (fileName === this.indexFileName) continue;
4115
4202
  if (fileName.endsWith(".md")) {
@@ -4141,6 +4228,10 @@ var DocDirectoryReference = class _DocDirectoryReference {
4141
4228
  async *mdFilesGenerator() {
4142
4229
  const generator = this.filesGenerator();
4143
4230
  for await (const file of generator) {
4231
+ if (file instanceof Error) {
4232
+ yield file;
4233
+ return;
4234
+ }
4144
4235
  if (file instanceof DocFileMdReference) {
4145
4236
  yield file;
4146
4237
  }
@@ -4149,6 +4240,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4149
4240
  async files() {
4150
4241
  const files = [];
4151
4242
  for await (const ref of this.filesGenerator()) {
4243
+ if (ref instanceof Error) {
4244
+ return ref;
4245
+ }
4152
4246
  files.push(ref);
4153
4247
  }
4154
4248
  return files;
@@ -4156,6 +4250,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4156
4250
  async mdFiles() {
4157
4251
  const refs = [];
4158
4252
  for await (const file of this.mdFilesGenerator()) {
4253
+ if (file instanceof Error) {
4254
+ return file;
4255
+ }
4159
4256
  refs.push(file);
4160
4257
  }
4161
4258
  return refs;
@@ -4190,6 +4287,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4190
4287
  async readFiles() {
4191
4288
  const entities = [];
4192
4289
  for await (const file of this.filesGenerator()) {
4290
+ if (file instanceof Error) {
4291
+ return file;
4292
+ }
4193
4293
  const entity = await file.read();
4194
4294
  if (entity instanceof Error) continue;
4195
4295
  entities.push(entity);
@@ -4199,6 +4299,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4199
4299
  async readMdFiles() {
4200
4300
  const entities = [];
4201
4301
  for await (const file of this.filesGenerator()) {
4302
+ if (file instanceof Error) {
4303
+ return file;
4304
+ }
4202
4305
  const entity = await file.read();
4203
4306
  if (entity instanceof Error) continue;
4204
4307
  if (entity instanceof DocFileUnknownEntity) continue;
@@ -4209,6 +4312,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4209
4312
  async readUnknownFiles() {
4210
4313
  const entities = [];
4211
4314
  for await (const file of this.filesGenerator()) {
4315
+ if (file instanceof Error) {
4316
+ return file;
4317
+ }
4212
4318
  const entity = await file.read();
4213
4319
  if (entity instanceof Error) continue;
4214
4320
  if (entity instanceof DocFileMdEntity) continue;
@@ -4223,6 +4329,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4223
4329
  const allFileNames = await this.fileSystem.readDirectoryFileNames(
4224
4330
  this.relativePath
4225
4331
  );
4332
+ if (allFileNames instanceof Error) {
4333
+ return allFileNames;
4334
+ }
4226
4335
  const directoryNames = [];
4227
4336
  for (const fileName of allFileNames) {
4228
4337
  if (fileName.startsWith(this.archiveDirectoryName)) continue;
@@ -4240,6 +4349,9 @@ var DocDirectoryReference = class _DocDirectoryReference {
4240
4349
  */
4241
4350
  async directories() {
4242
4351
  const directoryNames = await this.directoryNames();
4352
+ if (directoryNames instanceof Error) {
4353
+ return directoryNames;
4354
+ }
4243
4355
  return directoryNames.map((dirName) => {
4244
4356
  const dirPath = this.pathSystem.join(this.relativePath, dirName);
4245
4357
  return new _DocDirectoryReference({
@@ -4306,7 +4418,10 @@ var DocDirectoryReference = class _DocDirectoryReference {
4306
4418
  if (content === null) {
4307
4419
  return new Error("Entity content is undefined");
4308
4420
  }
4309
- await this.fileSystem.writeFile(filePath, content);
4421
+ const writeResult = await this.fileSystem.writeFile(filePath, content);
4422
+ if (writeResult instanceof Error) {
4423
+ return writeResult;
4424
+ }
4310
4425
  return null;
4311
4426
  }
4312
4427
  async exists() {
@@ -4333,7 +4448,10 @@ var DocDirectoryReference = class _DocDirectoryReference {
4333
4448
  pathSystem: this.pathSystem,
4334
4449
  config: this.props.config
4335
4450
  });
4336
- await fileRef.writeDefault();
4451
+ const writeResult = await fileRef.writeDefault();
4452
+ if (writeResult instanceof Error) {
4453
+ throw writeResult;
4454
+ }
4337
4455
  return fileRef;
4338
4456
  }
4339
4457
  };
@@ -4470,6 +4588,9 @@ var DocFileTreeSystem = class {
4470
4588
  */
4471
4589
  async buildFileTree(directoryPath = "") {
4472
4590
  const fileNames = await this.props.fileSystem.readDirectoryFileNames(directoryPath);
4591
+ if (fileNames instanceof Error) {
4592
+ return fileNames;
4593
+ }
4473
4594
  const results = [];
4474
4595
  for (const fileName of fileNames) {
4475
4596
  if (fileName === this.props.archiveDirectoryName) continue;
@@ -4478,10 +4599,16 @@ var DocFileTreeSystem = class {
4478
4599
  const isDirectory = await this.props.fileSystem.isDirectory(filePath);
4479
4600
  if (!isDirectory) {
4480
4601
  const fileNode = await this.createFileNode(fileName, filePath);
4602
+ if (fileNode instanceof Error) {
4603
+ return fileNode;
4604
+ }
4481
4605
  results.push(fileNode);
4482
4606
  continue;
4483
4607
  }
4484
4608
  const directoryNode = await this.createDirectoryNode(fileName, filePath);
4609
+ if (directoryNode instanceof Error) {
4610
+ return directoryNode;
4611
+ }
4485
4612
  results.push(directoryNode);
4486
4613
  }
4487
4614
  return results;
@@ -4520,6 +4647,9 @@ var DocFileTreeSystem = class {
4520
4647
  const indexFile = this.createIndexFileReference(filePath);
4521
4648
  if (await indexFile.exists()) {
4522
4649
  const entity = await indexFile.read();
4650
+ if (entity instanceof Error) {
4651
+ return entity;
4652
+ }
4523
4653
  title = entity.value.content.title || fileName;
4524
4654
  const content = entity.content;
4525
4655
  const frontMatter = content.meta();
@@ -4528,6 +4658,9 @@ var DocFileTreeSystem = class {
4528
4658
  }
4529
4659
  }
4530
4660
  const children = await this.buildFileTree(filePath);
4661
+ if (children instanceof Error) {
4662
+ return children;
4663
+ }
4531
4664
  return DocTreeDirectoryNodeValue.from({
4532
4665
  name: fileName,
4533
4666
  path: filePath,
@@ -4566,6 +4699,9 @@ var DocFileTreeSystem = class {
4566
4699
  */
4567
4700
  async buildDirectoryTree(directoryPath = "") {
4568
4701
  const fileNames = await this.props.fileSystem.readDirectoryFileNames(directoryPath);
4702
+ if (fileNames instanceof Error) {
4703
+ return fileNames;
4704
+ }
4569
4705
  const results = [];
4570
4706
  for (const fileName of fileNames) {
4571
4707
  if (fileName === this.props.archiveDirectoryName) continue;
@@ -4577,6 +4713,9 @@ var DocFileTreeSystem = class {
4577
4713
  fileName,
4578
4714
  filePath
4579
4715
  );
4716
+ if (directoryNode instanceof Error) {
4717
+ return directoryNode;
4718
+ }
4580
4719
  results.push(directoryNode);
4581
4720
  }
4582
4721
  return results;
@@ -4590,6 +4729,9 @@ var DocFileTreeSystem = class {
4590
4729
  const indexFile = this.createIndexFileReference(filePath);
4591
4730
  if (await indexFile.exists()) {
4592
4731
  const entity = await indexFile.read();
4732
+ if (entity instanceof Error) {
4733
+ return entity;
4734
+ }
4593
4735
  title = entity.value.content.title || fileName;
4594
4736
  const content = entity.content;
4595
4737
  const frontMatter = content.meta();
@@ -4598,6 +4740,9 @@ var DocFileTreeSystem = class {
4598
4740
  }
4599
4741
  }
4600
4742
  const children = await this.buildDirectoryTree(filePath);
4743
+ if (children instanceof Error) {
4744
+ return children;
4745
+ }
4601
4746
  return DocTreeDirectoryNodeValue.from({
4602
4747
  name: fileName,
4603
4748
  path: filePath,
@@ -4852,10 +4997,16 @@ var DocClient = class {
4852
4997
  }
4853
4998
  async fileTree(directoryPath = "") {
4854
4999
  const results = await this.fileTreeSystem.buildFileTree(directoryPath);
5000
+ if (results instanceof Error) {
5001
+ throw results;
5002
+ }
4855
5003
  return results.map((node) => node.toJson());
4856
5004
  }
4857
5005
  async directoryTree(directoryPath = "") {
4858
5006
  const results = await this.fileTreeSystem.buildDirectoryTree(directoryPath);
5007
+ if (results instanceof Error) {
5008
+ throw results;
5009
+ }
4859
5010
  return results.map((node) => node.toJson());
4860
5011
  }
4861
5012
  };
@@ -4873,29 +5024,27 @@ var DocFileSystem = class {
4873
5024
  * Read file content at the specified path
4874
5025
  */
4875
5026
  async readFile(relativePath) {
4876
- const exists = await this.exists(relativePath);
4877
- if (!exists) return null;
4878
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
4879
5027
  try {
5028
+ const exists = await this.exists(relativePath);
5029
+ if (!exists) return null;
5030
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
4880
5031
  return await fs.readFile(fullPath, "utf-8");
4881
- } catch {
4882
- return null;
5032
+ } catch (error) {
5033
+ return error instanceof Error ? error : new Error(`Failed to read file at ${relativePath}`);
4883
5034
  }
4884
5035
  }
4885
5036
  /**
4886
5037
  * Write content to file at the specified path (creates directory if needed)
4887
5038
  */
4888
5039
  async writeFile(relativePath, content) {
4889
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
4890
- const dirPath = this.pathSystem.dirname(fullPath);
4891
5040
  try {
5041
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
5042
+ const dirPath = this.pathSystem.dirname(fullPath);
4892
5043
  await fs.mkdir(dirPath, { recursive: true });
4893
5044
  await fs.writeFile(fullPath, content, "utf-8");
5045
+ return null;
4894
5046
  } catch (error) {
4895
- if (error instanceof Error) {
4896
- throw error;
4897
- }
4898
- throw new Error(`Failed to write file at ${fullPath}`);
5047
+ return error instanceof Error ? error : new Error(`Failed to write file at ${relativePath}`);
4899
5048
  }
4900
5049
  }
4901
5050
  /**
@@ -4932,18 +5081,25 @@ var DocFileSystem = class {
4932
5081
  * Get list of entries in directory
4933
5082
  */
4934
5083
  async readDirectoryFileNames(relativePath = "") {
4935
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
4936
5084
  try {
5085
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
4937
5086
  return await fs.readdir(fullPath);
4938
- } catch {
4939
- return [];
5087
+ } catch (error) {
5088
+ return error instanceof Error ? error : new Error(`Failed to read directory at ${relativePath}`);
4940
5089
  }
4941
5090
  }
4942
5091
  async readDirectoryFilePaths(relativePath) {
4943
- const fileNames = await this.readDirectoryFileNames(relativePath);
4944
- return fileNames.map(
4945
- (fileName) => this.pathSystem.join(relativePath, fileName)
4946
- );
5092
+ try {
5093
+ const fileNames = await this.readDirectoryFileNames(relativePath);
5094
+ if (fileNames instanceof Error) {
5095
+ return fileNames;
5096
+ }
5097
+ return fileNames.map(
5098
+ (fileName) => this.pathSystem.join(relativePath, fileName)
5099
+ );
5100
+ } catch (error) {
5101
+ return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
5102
+ }
4947
5103
  }
4948
5104
  /**
4949
5105
  * Check if path is a directory
@@ -5009,66 +5165,138 @@ var DocFileSystem = class {
5009
5165
  * Create directory
5010
5166
  */
5011
5167
  async createDirectory(relativePath) {
5012
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
5013
- await fs.mkdir(fullPath, { recursive: true });
5168
+ try {
5169
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
5170
+ await fs.mkdir(fullPath, { recursive: true });
5171
+ return null;
5172
+ } catch (error) {
5173
+ return error instanceof Error ? error : new Error(`Failed to create directory at ${relativePath}`);
5174
+ }
5014
5175
  }
5015
5176
  /**
5016
5177
  * Get file size in bytes
5017
5178
  */
5018
5179
  async getFileSize(relativePath) {
5019
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
5020
- const stats = await fs.stat(fullPath);
5021
- return stats.size;
5180
+ try {
5181
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
5182
+ const stats = await fs.stat(fullPath);
5183
+ return stats.size;
5184
+ } catch (error) {
5185
+ return error instanceof Error ? error : new Error(`Failed to get file size at ${relativePath}`);
5186
+ }
5022
5187
  }
5023
5188
  /**
5024
5189
  * Create directory if it doesn't exist
5025
5190
  */
5026
5191
  async ensureDirectoryExists(relativePath) {
5027
- if (!await this.exists(relativePath)) {
5028
- await this.createDirectory(relativePath);
5192
+ try {
5193
+ if (!await this.exists(relativePath)) {
5194
+ const result = await this.createDirectory(relativePath);
5195
+ if (result instanceof Error) {
5196
+ return result;
5197
+ }
5198
+ }
5199
+ return null;
5200
+ } catch (error) {
5201
+ return error instanceof Error ? error : new Error(`Failed to ensure directory exists at ${relativePath}`);
5029
5202
  }
5030
5203
  }
5031
5204
  /**
5032
5205
  * Copy file
5033
5206
  */
5034
5207
  async copyFile(sourcePath, destinationPath) {
5035
- const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
5036
- const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
5037
- await fs.copyFile(sourceFullPath, destFullPath);
5208
+ try {
5209
+ const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
5210
+ const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
5211
+ await fs.copyFile(sourceFullPath, destFullPath);
5212
+ return null;
5213
+ } catch (error) {
5214
+ return error instanceof Error ? error : new Error(
5215
+ `Failed to copy file from ${sourcePath} to ${destinationPath}`
5216
+ );
5217
+ }
5038
5218
  }
5039
5219
  /**
5040
5220
  * Move file
5041
5221
  */
5042
5222
  async moveFile(sourcePath, destinationPath) {
5043
- const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
5044
- const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
5045
- await fs.rename(sourceFullPath, destFullPath);
5223
+ try {
5224
+ const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
5225
+ const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
5226
+ await fs.rename(sourceFullPath, destFullPath);
5227
+ return null;
5228
+ } catch (error) {
5229
+ return error instanceof Error ? error : new Error(
5230
+ `Failed to move file from ${sourcePath} to ${destinationPath}`
5231
+ );
5232
+ }
5046
5233
  }
5047
5234
  /**
5048
5235
  * Get file last modified time
5049
5236
  */
5050
5237
  async getFileModifiedTime(relativePath) {
5051
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
5052
- const stats = await fs.stat(fullPath);
5053
- return stats.mtime;
5238
+ try {
5239
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
5240
+ const stats = await fs.stat(fullPath);
5241
+ return stats.mtime;
5242
+ } catch (error) {
5243
+ return error instanceof Error ? error : new Error(`Failed to get file modified time at ${relativePath}`);
5244
+ }
5054
5245
  }
5055
5246
  /**
5056
5247
  * Get file creation time
5057
5248
  */
5058
5249
  async getFileCreatedTime(relativePath) {
5059
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
5060
- const stats = await fs.stat(fullPath);
5061
- return stats.birthtime;
5250
+ try {
5251
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
5252
+ const stats = await fs.stat(fullPath);
5253
+ return stats.birthtime;
5254
+ } catch (error) {
5255
+ return error instanceof Error ? error : new Error(`Failed to get file created time at ${relativePath}`);
5256
+ }
5062
5257
  }
5063
5258
  };
5064
5259
 
5065
- // lib/doc-file-system-debug.ts
5066
- var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5260
+ // lib/doc-file-system-mock.ts
5261
+ var mockDirectoryData = {
5262
+ "docs/index.md": `---
5263
+ icon: \u{1F4DA}
5264
+ ---
5265
+
5266
+ # Documentation
5267
+
5268
+ Welcome to the documentation!`,
5269
+ "docs/guide/index.md": `---
5270
+ icon: \u{1F4D6}
5271
+ ---
5272
+
5273
+ # Guide
5274
+
5275
+ This is a guide.`,
5276
+ "docs/guide/getting-started.md": `# Getting Started
5277
+
5278
+ Let's get started!`,
5279
+ "docs/guide/advanced.md": `# Advanced
5280
+
5281
+ Advanced topics here.`,
5282
+ "docs/api/index.md": `---
5283
+ icon: \u{1F527}
5284
+ ---
5285
+
5286
+ # API
5287
+
5288
+ API documentation.`,
5289
+ "docs/api/reference.md": `# API Reference
5290
+
5291
+ Complete API reference.`
5292
+ };
5293
+ var DocFileSystemMock = class _DocFileSystemMock extends DocFileSystem {
5067
5294
  files = /* @__PURE__ */ new Map();
5068
5295
  _pathSystem;
5069
5296
  constructor(props) {
5070
5297
  super(props);
5071
5298
  this._pathSystem = props.pathSystem;
5299
+ this.setupTestFiles(mockDirectoryData);
5072
5300
  Object.freeze(this);
5073
5301
  }
5074
5302
  /**
@@ -5077,13 +5305,20 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5077
5305
  getPathSystem() {
5078
5306
  return this._pathSystem;
5079
5307
  }
5308
+ /**
5309
+ * Create instance (mock data is automatically loaded)
5310
+ */
5311
+ static create(basePath = "/test") {
5312
+ const pathSystem = new DocPathSystem();
5313
+ return new _DocFileSystemMock({ basePath, pathSystem });
5314
+ }
5080
5315
  /**
5081
5316
  * Factory method for testing
5082
5317
  */
5083
5318
  static createWithFiles(props) {
5084
5319
  const pathSystem = new DocPathSystem();
5085
5320
  const basePath = props.basePath ?? "/test";
5086
- const fileSystem = new _DocFileSystemDebug({ basePath, pathSystem });
5321
+ const fileSystem = new _DocFileSystemMock({ basePath, pathSystem });
5087
5322
  if (props.fileContents) {
5088
5323
  const now = /* @__PURE__ */ new Date();
5089
5324
  for (const [path, content] of Object.entries(props.fileContents)) {
@@ -5098,20 +5333,29 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5098
5333
  return fileSystem;
5099
5334
  }
5100
5335
  async readFile(filePath) {
5101
- const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5102
- const file = this.files.get(normalizedPath);
5103
- return file ? file.content : null;
5336
+ try {
5337
+ const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5338
+ const file = this.files.get(normalizedPath);
5339
+ return file ? file.content : null;
5340
+ } catch (error) {
5341
+ return error instanceof Error ? error : new Error(`Failed to read file at ${filePath}`);
5342
+ }
5104
5343
  }
5105
5344
  async writeFile(filePath, content) {
5106
- const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5107
- const now = /* @__PURE__ */ new Date();
5108
- const existing = this.files.get(normalizedPath);
5109
- this.files.set(normalizedPath, {
5110
- content,
5111
- modifiedTime: now,
5112
- createdTime: existing?.createdTime ?? now,
5113
- size: new TextEncoder().encode(content).length
5114
- });
5345
+ try {
5346
+ const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5347
+ const now = /* @__PURE__ */ new Date();
5348
+ const existing = this.files.get(normalizedPath);
5349
+ this.files.set(normalizedPath, {
5350
+ content,
5351
+ modifiedTime: now,
5352
+ createdTime: existing?.createdTime ?? now,
5353
+ size: new TextEncoder().encode(content).length
5354
+ });
5355
+ return null;
5356
+ } catch (error) {
5357
+ return error instanceof Error ? error : new Error(`Failed to write file at ${filePath}`);
5358
+ }
5115
5359
  }
5116
5360
  async deleteFile(filePath) {
5117
5361
  const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
@@ -5136,26 +5380,36 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5136
5380
  return false;
5137
5381
  }
5138
5382
  async copyFile(source, destination) {
5139
- const normalizedSource = source.startsWith("docs/") ? source : `docs/${source}`;
5140
- const normalizedDest = destination.startsWith("docs/") ? destination : `docs/${destination}`;
5141
- const file = this.files.get(normalizedSource);
5142
- if (!file) {
5143
- throw new Error(`Source file not found: ${normalizedSource}`);
5144
- }
5145
- this.files.set(normalizedDest, {
5146
- ...file,
5147
- createdTime: /* @__PURE__ */ new Date()
5148
- });
5383
+ try {
5384
+ const normalizedSource = source.startsWith("docs/") ? source : `docs/${source}`;
5385
+ const normalizedDest = destination.startsWith("docs/") ? destination : `docs/${destination}`;
5386
+ const file = this.files.get(normalizedSource);
5387
+ if (!file) {
5388
+ return new Error(`Source file not found: ${normalizedSource}`);
5389
+ }
5390
+ this.files.set(normalizedDest, {
5391
+ ...file,
5392
+ createdTime: /* @__PURE__ */ new Date()
5393
+ });
5394
+ return null;
5395
+ } catch (error) {
5396
+ return error instanceof Error ? error : new Error(`Failed to copy file from ${source} to ${destination}`);
5397
+ }
5149
5398
  }
5150
5399
  async moveFile(source, destination) {
5151
- const normalizedSource = source.startsWith("docs/") ? source : `docs/${source}`;
5152
- const normalizedDest = destination.startsWith("docs/") ? destination : `docs/${destination}`;
5153
- const file = this.files.get(normalizedSource);
5154
- if (!file) {
5155
- throw new Error(`Source file not found: ${normalizedSource}`);
5400
+ try {
5401
+ const normalizedSource = source.startsWith("docs/") ? source : `docs/${source}`;
5402
+ const normalizedDest = destination.startsWith("docs/") ? destination : `docs/${destination}`;
5403
+ const file = this.files.get(normalizedSource);
5404
+ if (!file) {
5405
+ return new Error(`Source file not found: ${normalizedSource}`);
5406
+ }
5407
+ this.files.set(normalizedDest, file);
5408
+ this.files.delete(normalizedSource);
5409
+ return null;
5410
+ } catch (error) {
5411
+ return error instanceof Error ? error : new Error(`Failed to move file from ${source} to ${destination}`);
5156
5412
  }
5157
- this.files.set(normalizedDest, file);
5158
- this.files.delete(normalizedSource);
5159
5413
  }
5160
5414
  async readDirectory(directoryPath) {
5161
5415
  const dirPath = directoryPath.endsWith("/") ? directoryPath : `${directoryPath}/`;
@@ -5182,16 +5436,21 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5182
5436
  return files.sort();
5183
5437
  }
5184
5438
  async readDirectoryFilePaths(directoryPath) {
5185
- const dirPath = directoryPath.endsWith("/") ? directoryPath : `${directoryPath}/`;
5186
- const files = [];
5187
- for (const path of this.files.keys()) {
5188
- if (path.startsWith(dirPath) && !path.slice(dirPath.length).includes("/")) {
5189
- files.push(path);
5439
+ try {
5440
+ const dirPath = directoryPath.endsWith("/") ? directoryPath : `${directoryPath}/`;
5441
+ const files = [];
5442
+ for (const path of this.files.keys()) {
5443
+ if (path.startsWith(dirPath) && !path.slice(dirPath.length).includes("/")) {
5444
+ files.push(path);
5445
+ }
5190
5446
  }
5447
+ return files.sort();
5448
+ } catch (error) {
5449
+ return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${directoryPath}`);
5191
5450
  }
5192
- return files.sort();
5193
5451
  }
5194
5452
  async createDirectory(_directoryPath) {
5453
+ return null;
5195
5454
  }
5196
5455
  async deleteDirectory(directoryPath) {
5197
5456
  const dirPath = directoryPath.endsWith("/") ? directoryPath : `${directoryPath}/`;
@@ -5202,28 +5461,40 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5202
5461
  }
5203
5462
  }
5204
5463
  async getFileSize(filePath) {
5205
- const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5206
- const file = this.files.get(normalizedPath);
5207
- if (!file) {
5208
- throw new Error(`File not found: ${normalizedPath}`);
5464
+ try {
5465
+ const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5466
+ const file = this.files.get(normalizedPath);
5467
+ if (!file) {
5468
+ return new Error(`File not found: ${normalizedPath}`);
5469
+ }
5470
+ return file.size;
5471
+ } catch (error) {
5472
+ return error instanceof Error ? error : new Error(`Failed to get file size at ${filePath}`);
5209
5473
  }
5210
- return file.size;
5211
5474
  }
5212
5475
  async getFileModifiedTime(filePath) {
5213
- const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5214
- const file = this.files.get(normalizedPath);
5215
- if (!file) {
5216
- throw new Error(`File not found: ${normalizedPath}`);
5476
+ try {
5477
+ const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5478
+ const file = this.files.get(normalizedPath);
5479
+ if (!file) {
5480
+ return new Error(`File not found: ${normalizedPath}`);
5481
+ }
5482
+ return file.modifiedTime;
5483
+ } catch (error) {
5484
+ return error instanceof Error ? error : new Error(`Failed to get file modified time at ${filePath}`);
5217
5485
  }
5218
- return file.modifiedTime;
5219
5486
  }
5220
5487
  async getFileCreatedTime(filePath) {
5221
- const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5222
- const file = this.files.get(normalizedPath);
5223
- if (!file) {
5224
- throw new Error(`File not found: ${normalizedPath}`);
5488
+ try {
5489
+ const normalizedPath = filePath.startsWith("docs/") ? filePath : `docs/${filePath}`;
5490
+ const file = this.files.get(normalizedPath);
5491
+ if (!file) {
5492
+ return new Error(`File not found: ${normalizedPath}`);
5493
+ }
5494
+ return file.createdTime;
5495
+ } catch (error) {
5496
+ return error instanceof Error ? error : new Error(`Failed to get file created time at ${filePath}`);
5225
5497
  }
5226
- return file.createdTime;
5227
5498
  }
5228
5499
  async isDirectory(relativePath) {
5229
5500
  const normalizedPath = relativePath.startsWith("docs/") ? relativePath : `docs/${relativePath}`;
@@ -5243,19 +5514,23 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5243
5514
  * Get list of entries in directory
5244
5515
  */
5245
5516
  async readDirectoryFileNames(directoryPath = "") {
5246
- const normalizedDir = directoryPath === "" ? "docs" : directoryPath.startsWith("docs/") ? directoryPath : `docs/${directoryPath}`;
5247
- const dirPath = normalizedDir.endsWith("/") ? normalizedDir : `${normalizedDir}/`;
5248
- const entries = /* @__PURE__ */ new Set();
5249
- for (const path of this.files.keys()) {
5250
- if (path.startsWith(dirPath)) {
5251
- const relativePath = path.slice(dirPath.length);
5252
- const firstSegment = relativePath.split("/")[0];
5253
- if (firstSegment) {
5254
- entries.add(firstSegment);
5517
+ try {
5518
+ const normalizedDir = directoryPath === "" ? "docs" : directoryPath === "docs" ? "docs" : directoryPath.startsWith("docs/") ? directoryPath : `docs/${directoryPath}`;
5519
+ const dirPath = normalizedDir.endsWith("/") ? normalizedDir : `${normalizedDir}/`;
5520
+ const entries = /* @__PURE__ */ new Set();
5521
+ for (const path of this.files.keys()) {
5522
+ if (path.startsWith(dirPath)) {
5523
+ const relativePath = path.slice(dirPath.length);
5524
+ const firstSegment = relativePath.split("/")[0];
5525
+ if (firstSegment) {
5526
+ entries.add(firstSegment);
5527
+ }
5255
5528
  }
5256
5529
  }
5530
+ return Array.from(entries).sort();
5531
+ } catch (error) {
5532
+ return error instanceof Error ? error : new Error(`Failed to read directory at ${directoryPath}`);
5257
5533
  }
5258
- return Array.from(entries).sort();
5259
5534
  }
5260
5535
  /**
5261
5536
  * Check if directory exists
@@ -5273,6 +5548,7 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5273
5548
  * Create directory if it doesn't exist
5274
5549
  */
5275
5550
  async ensureDirectoryExists(_relativePath) {
5551
+ return null;
5276
5552
  }
5277
5553
  /**
5278
5554
  * Clear all files
@@ -5320,6 +5596,109 @@ var DocFileSystemDebug = class _DocFileSystemDebug extends DocFileSystem {
5320
5596
  }
5321
5597
  };
5322
5598
 
5599
+ // lib/doc-path-system-mock.ts
5600
+ var DocPathSystemMock = class _DocPathSystemMock extends DocPathSystem {
5601
+ _separator;
5602
+ constructor(separator = "/") {
5603
+ super();
5604
+ this._separator = separator;
5605
+ Object.freeze(this);
5606
+ }
5607
+ join(...paths) {
5608
+ return paths.filter((path) => path !== "").join(this._separator).replace(new RegExp(`${this._separator}+`, "g"), this._separator);
5609
+ }
5610
+ basename(path, ext) {
5611
+ const normalizedPath = path.replace(/\\/g, "/");
5612
+ const lastSlashIndex = normalizedPath.lastIndexOf("/");
5613
+ let base = lastSlashIndex === -1 ? normalizedPath : normalizedPath.slice(lastSlashIndex + 1);
5614
+ if (ext && base.endsWith(ext)) {
5615
+ base = base.slice(0, -ext.length);
5616
+ }
5617
+ return base;
5618
+ }
5619
+ dirname(path) {
5620
+ const normalizedPath = path.replace(/\\/g, "/");
5621
+ const lastSlashIndex = normalizedPath.lastIndexOf("/");
5622
+ if (lastSlashIndex === -1) {
5623
+ return ".";
5624
+ }
5625
+ if (lastSlashIndex === 0) {
5626
+ return "/";
5627
+ }
5628
+ return normalizedPath.slice(0, lastSlashIndex);
5629
+ }
5630
+ extname(path) {
5631
+ const base = this.basename(path);
5632
+ const lastDotIndex = base.lastIndexOf(".");
5633
+ if (lastDotIndex === -1 || lastDotIndex === 0) {
5634
+ return "";
5635
+ }
5636
+ return base.slice(lastDotIndex);
5637
+ }
5638
+ relative(from, to) {
5639
+ const fromParts = from.split("/").filter(Boolean);
5640
+ const toParts = to.split("/").filter(Boolean);
5641
+ let commonLength = 0;
5642
+ for (let i = 0; i < Math.min(fromParts.length, toParts.length); i++) {
5643
+ if (fromParts[i] === toParts[i]) {
5644
+ commonLength++;
5645
+ } else {
5646
+ break;
5647
+ }
5648
+ }
5649
+ const upLevels = fromParts.length - commonLength;
5650
+ const downParts = toParts.slice(commonLength);
5651
+ const result = Array(upLevels).fill("..").concat(downParts);
5652
+ return result.length === 0 ? "." : result.join("/");
5653
+ }
5654
+ resolve(...paths) {
5655
+ let resolved = "";
5656
+ let isAbsolute = false;
5657
+ for (let i = paths.length - 1; i >= 0 && !isAbsolute; i--) {
5658
+ const path = paths[i];
5659
+ if (path) {
5660
+ resolved = path + (resolved ? `/${resolved}` : "");
5661
+ isAbsolute = path.startsWith("/");
5662
+ }
5663
+ }
5664
+ if (!isAbsolute) {
5665
+ resolved = `/mock-cwd/${resolved}`;
5666
+ }
5667
+ return this.normalize(resolved);
5668
+ }
5669
+ normalize(path) {
5670
+ if (!path) return ".";
5671
+ const isAbsolute = path.startsWith("/");
5672
+ const parts = path.split("/").filter(Boolean);
5673
+ const normalizedParts = [];
5674
+ for (const part of parts) {
5675
+ if (part === "..") {
5676
+ if (normalizedParts.length > 0 && normalizedParts[normalizedParts.length - 1] !== "..") {
5677
+ normalizedParts.pop();
5678
+ } else if (!isAbsolute) {
5679
+ normalizedParts.push("..");
5680
+ }
5681
+ } else if (part !== ".") {
5682
+ normalizedParts.push(part);
5683
+ }
5684
+ }
5685
+ const result = (isAbsolute ? "/" : "") + normalizedParts.join("/");
5686
+ return result || (isAbsolute ? "/" : ".");
5687
+ }
5688
+ isAbsolute(path) {
5689
+ return path.startsWith("/");
5690
+ }
5691
+ get sep() {
5692
+ return this._separator;
5693
+ }
5694
+ /**
5695
+ * Set custom separator for testing
5696
+ */
5697
+ static createWithSeparator(separator) {
5698
+ return new _DocPathSystemMock(separator);
5699
+ }
5700
+ };
5701
+
5323
5702
  // lib/doc-schema-builder.ts
5324
5703
  var DocSchemaBuilder = class _DocSchemaBuilder {
5325
5704
  constructor(schema = {}) {
@@ -5489,12 +5868,13 @@ export {
5489
5868
  DocFileMdReference,
5490
5869
  DocFileRelationReference,
5491
5870
  DocFileSystem,
5492
- DocFileSystemDebug,
5871
+ DocFileSystemMock,
5493
5872
  DocFileTreeSystem,
5494
5873
  DocFileUnknownEntity,
5495
5874
  DocFileUnknownReference,
5496
5875
  DocMarkdownSystem,
5497
5876
  DocPathSystem,
5877
+ DocPathSystemMock,
5498
5878
  DocSchemaBuilder,
5499
5879
  assertType,
5500
5880
  defaultTestConfig,