@fgv/ts-json-base 5.1.0-15 → 5.1.0-17

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.
@@ -77,7 +77,9 @@ export class FileItem {
77
77
  return captureResult(() => new FileItem(path, hal));
78
78
  }
79
79
  /**
80
- * {@inheritDoc FileTree.IFileTreeFileItem.getIsMutable}
80
+ * Indicates whether this file can be saved.
81
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
82
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
81
83
  */
82
84
  getIsMutable() {
83
85
  if (isMutableAccessors(this._hal)) {
@@ -111,13 +113,17 @@ export class FileItem {
111
113
  this._contentType = contentType;
112
114
  }
113
115
  /**
114
- * {@inheritDoc FileTree.IFileTreeFileItem.setContents}
116
+ * Sets the contents of the file from a JSON value.
117
+ * @param json - The JSON value to serialize and save.
118
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
115
119
  */
116
120
  setContents(json) {
117
121
  return captureResult(() => JSON.stringify(json, null, 2)).onSuccess((contents) => this.setRawContents(contents).onSuccess(() => Success.with(json)));
118
122
  }
119
123
  /**
120
- * {@inheritDoc FileTree.IFileTreeFileItem.setRawContents}
124
+ * Sets the raw contents of the file.
125
+ * @param contents - The string contents to save.
126
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
121
127
  */
122
128
  setRawContents(contents) {
123
129
  if (isMutableAccessors(this._hal)) {
@@ -127,7 +133,8 @@ export class FileItem {
127
133
  return fail(`${this.absolutePath}: mutation not supported`);
128
134
  }
129
135
  /**
130
- * {@inheritDoc FileTree.IFileTreeFileItem.delete}
136
+ * Deletes this file from its backing store.
137
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
131
138
  */
132
139
  delete() {
133
140
  if (!isMutableAccessors(this._hal)) {
@@ -44,7 +44,9 @@ export class FsFileTreeAccessors {
44
44
  this._mutable = (_b = params === null || params === void 0 ? void 0 : params.mutable) !== null && _b !== void 0 ? _b : false;
45
45
  }
46
46
  /**
47
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
47
+ * Resolves paths to an absolute path.
48
+ * @param paths - Paths to resolve.
49
+ * @returns The resolved absolute path.
48
50
  */
49
51
  resolveAbsolutePath(...paths) {
50
52
  if (this.prefix && !path.isAbsolute(paths[0])) {
@@ -53,25 +55,34 @@ export class FsFileTreeAccessors {
53
55
  return path.resolve(...paths);
54
56
  }
55
57
  /**
56
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
58
+ * Gets the extension of a path.
59
+ * @param itemPath - Path to get the extension of.
60
+ * @returns The extension of the path.
57
61
  */
58
62
  getExtension(itemPath) {
59
63
  return path.extname(itemPath);
60
64
  }
61
65
  /**
62
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
66
+ * Gets the base name of a path.
67
+ * @param itemPath - Path to get the base name of.
68
+ * @param suffix - Optional suffix to remove from the base name.
69
+ * @returns The base name of the path.
63
70
  */
64
71
  getBaseName(itemPath, suffix) {
65
72
  return path.basename(itemPath, suffix);
66
73
  }
67
74
  /**
68
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
75
+ * Joins paths together.
76
+ * @param paths - Paths to join.
77
+ * @returns The joined paths.
69
78
  */
70
79
  joinPaths(...paths) {
71
80
  return path.join(...paths);
72
81
  }
73
82
  /**
74
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
83
+ * Gets an item from the file tree.
84
+ * @param itemPath - Path of the item to get.
85
+ * @returns The item if it exists.
75
86
  */
76
87
  getItem(itemPath) {
77
88
  return captureResult(() => {
@@ -87,13 +98,18 @@ export class FsFileTreeAccessors {
87
98
  });
88
99
  }
89
100
  /**
90
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
101
+ * Gets the contents of a file in the file tree.
102
+ * @param filePath - Absolute path of the file.
103
+ * @returns The contents of the file.
91
104
  */
92
105
  getFileContents(filePath) {
93
106
  return captureResult(() => fs.readFileSync(this.resolveAbsolutePath(filePath), 'utf8'));
94
107
  }
95
108
  /**
96
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
109
+ * Gets the content type of a file in the file tree.
110
+ * @param filePath - Absolute path of the file.
111
+ * @param provided - Optional supplied content type.
112
+ * @returns The content type of the file.
97
113
  */
98
114
  getFileContentType(filePath, provided) {
99
115
  if (provided !== undefined) {
@@ -103,7 +119,9 @@ export class FsFileTreeAccessors {
103
119
  return this._inferContentType(filePath);
104
120
  }
105
121
  /**
106
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
122
+ * Gets the children of a directory in the file tree.
123
+ * @param dirPath - Path of the directory.
124
+ * @returns The children of the directory.
107
125
  */
108
126
  getChildren(dirPath) {
109
127
  return captureResult(() => {
@@ -122,7 +140,10 @@ export class FsFileTreeAccessors {
122
140
  });
123
141
  }
124
142
  /**
125
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
143
+ * Checks if a file at the given path can be saved.
144
+ * @param path - The path to check.
145
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
146
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
126
147
  */
127
148
  fileIsMutable(path) {
128
149
  const absolutePath = this.resolveAbsolutePath(path);
@@ -155,7 +176,10 @@ export class FsFileTreeAccessors {
155
176
  }
156
177
  }
157
178
  /**
158
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
179
+ * Saves the contents to a file at the given path.
180
+ * @param path - The path of the file to save.
181
+ * @param contents - The string contents to save.
182
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
159
183
  */
160
184
  saveFileContents(path, contents) {
161
185
  return this.fileIsMutable(path).asResult.onSuccess(() => {
@@ -167,7 +191,9 @@ export class FsFileTreeAccessors {
167
191
  });
168
192
  }
169
193
  /**
170
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
194
+ * Deletes a file at the given path.
195
+ * @param path - The path of the file to delete.
196
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
171
197
  */
172
198
  deleteFile(path) {
173
199
  return this.fileIsMutable(path).asResult.onSuccess(() => {
@@ -183,7 +209,9 @@ export class FsFileTreeAccessors {
183
209
  });
184
210
  }
185
211
  /**
186
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
212
+ * Creates a directory at the given path, including any missing parent directories.
213
+ * @param dirPath - The path of the directory to create.
214
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
187
215
  */
188
216
  createDirectory(dirPath) {
189
217
  const absolutePath = this.resolveAbsolutePath(dirPath);
@@ -197,7 +225,10 @@ export class FsFileTreeAccessors {
197
225
  });
198
226
  }
199
227
  /**
200
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
228
+ * Deletes a directory at the given path.
229
+ * The directory must be empty or the operation will fail.
230
+ * @param dirPath - The path of the directory to delete.
231
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
201
232
  */
202
233
  deleteDirectory(dirPath) {
203
234
  return this.fileIsMutable(dirPath).asResult.onSuccess(() => {
@@ -135,7 +135,9 @@ export class InMemoryTreeAccessors {
135
135
  return captureResult(() => new InMemoryTreeAccessors(files, params));
136
136
  }
137
137
  /**
138
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
138
+ * Resolves paths to an absolute path.
139
+ * @param paths - Paths to resolve.
140
+ * @returns The resolved absolute path.
139
141
  */
140
142
  resolveAbsolutePath(...paths) {
141
143
  const parts = paths[0].startsWith('/') ? paths : [this._tree.prefix, ...paths];
@@ -143,7 +145,9 @@ export class InMemoryTreeAccessors {
143
145
  return `/${joined}`;
144
146
  }
145
147
  /**
146
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
148
+ * Gets the extension of a path.
149
+ * @param path - Path to get the extension of.
150
+ * @returns The extension of the path.
147
151
  */
148
152
  getExtension(path) {
149
153
  const parts = path.split('.');
@@ -153,7 +157,10 @@ export class InMemoryTreeAccessors {
153
157
  return `.${parts.pop()}`;
154
158
  }
155
159
  /**
156
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
160
+ * Gets the base name of a path.
161
+ * @param path - Path to get the base name of.
162
+ * @param suffix - Optional suffix to remove from the base name.
163
+ * @returns The base name of the path.
157
164
  */
158
165
  getBaseName(path, suffix) {
159
166
  var _a;
@@ -165,7 +172,9 @@ export class InMemoryTreeAccessors {
165
172
  return base;
166
173
  }
167
174
  /**
168
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
175
+ * Joins paths together.
176
+ * @param paths - Paths to join.
177
+ * @returns The joined paths.
169
178
  */
170
179
  joinPaths(...paths) {
171
180
  var _a;
@@ -173,7 +182,9 @@ export class InMemoryTreeAccessors {
173
182
  return ((_a = paths[0]) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? `/${joined}` : joined;
174
183
  }
175
184
  /**
176
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
185
+ * Gets an item from the file tree.
186
+ * @param itemPath - Path of the item to get.
187
+ * @returns The item if it exists.
177
188
  */
178
189
  getItem(itemPath) {
179
190
  const existing = this._tree.byAbsolutePath.get(itemPath);
@@ -188,7 +199,9 @@ export class InMemoryTreeAccessors {
188
199
  return fail(`${itemPath}: not found`);
189
200
  }
190
201
  /**
191
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
202
+ * Gets the contents of a file in the file tree.
203
+ * @param path - Absolute path of the file.
204
+ * @returns The contents of the file.
192
205
  */
193
206
  getFileContents(path) {
194
207
  const absolutePath = this.resolveAbsolutePath(path);
@@ -205,7 +218,10 @@ export class InMemoryTreeAccessors {
205
218
  return captureResult(() => JSON.stringify(item.contents));
206
219
  }
207
220
  /**
208
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
221
+ * Gets the content type of a file in the file tree.
222
+ * @param path - Absolute path of the file.
223
+ * @param provided - Optional supplied content type.
224
+ * @returns The content type of the file.
209
225
  */
210
226
  getFileContentType(path, provided) {
211
227
  // If provided contentType is given, use it directly (highest priority)
@@ -228,7 +244,9 @@ export class InMemoryTreeAccessors {
228
244
  return this._inferContentType(path);
229
245
  }
230
246
  /**
231
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
247
+ * Gets the children of a directory in the file tree.
248
+ * @param path - Path of the directory.
249
+ * @returns The children of the directory.
232
250
  */
233
251
  getChildren(path) {
234
252
  const item = this._tree.byAbsolutePath.get(path);
@@ -278,7 +296,9 @@ export class InMemoryTreeAccessors {
278
296
  });
279
297
  }
280
298
  /**
281
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
299
+ * Creates a directory at the given path, including any missing parent directories.
300
+ * @param dirPath - The path of the directory to create.
301
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
282
302
  */
283
303
  createDirectory(dirPath) {
284
304
  const absolutePath = this.resolveAbsolutePath(dirPath);
@@ -309,7 +329,10 @@ export class InMemoryTreeAccessors {
309
329
  return succeed(absolutePath);
310
330
  }
311
331
  /**
312
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
332
+ * Checks if a file at the given path can be saved.
333
+ * @param path - The path to check.
334
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
335
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
313
336
  */
314
337
  fileIsMutable(path) {
315
338
  const absolutePath = this.resolveAbsolutePath(path);
@@ -324,7 +347,9 @@ export class InMemoryTreeAccessors {
324
347
  return succeedWithDetail(true, 'transient');
325
348
  }
326
349
  /**
327
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
350
+ * Deletes a file at the given path.
351
+ * @param path - The path of the file to delete.
352
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
328
353
  */
329
354
  deleteFile(path) {
330
355
  const absolutePath = this.resolveAbsolutePath(path);
@@ -356,7 +381,10 @@ export class InMemoryTreeAccessors {
356
381
  return succeed(true);
357
382
  }
358
383
  /**
359
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
384
+ * Deletes a directory at the given path.
385
+ * The directory must be empty or the operation will fail.
386
+ * @param path - The path of the directory to delete.
387
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
360
388
  */
361
389
  deleteDirectory(path) {
362
390
  const absolutePath = this.resolveAbsolutePath(path);
@@ -396,7 +424,10 @@ export class InMemoryTreeAccessors {
396
424
  return succeed(true);
397
425
  }
398
426
  /**
399
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
427
+ * Saves the contents to a file at the given path.
428
+ * @param path - The path of the file to save.
429
+ * @param contents - The string contents to save.
430
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
400
431
  */
401
432
  saveFileContents(path, contents) {
402
433
  const isMutable = this.fileIsMutable(path);
@@ -345,7 +345,9 @@ declare class FileItem<TCT extends string = string> implements IMutableFileTreeF
345
345
  */
346
346
  static create<TCT extends string = string>(path: string, hal: IFileTreeAccessors<TCT>): Result<FileItem<TCT>>;
347
347
  /**
348
- * {@inheritDoc FileTree.IFileTreeFileItem.getIsMutable}
348
+ * Indicates whether this file can be saved.
349
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
350
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
349
351
  */
350
352
  getIsMutable(): DetailedResult<boolean, SaveDetail>;
351
353
  /**
@@ -366,15 +368,20 @@ declare class FileItem<TCT extends string = string> implements IMutableFileTreeF
366
368
  */
367
369
  setContentType(contentType: TCT | undefined): void;
368
370
  /**
369
- * {@inheritDoc FileTree.IFileTreeFileItem.setContents}
371
+ * Sets the contents of the file from a JSON value.
372
+ * @param json - The JSON value to serialize and save.
373
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
370
374
  */
371
375
  setContents(json: JsonValue): Result<JsonValue>;
372
376
  /**
373
- * {@inheritDoc FileTree.IFileTreeFileItem.setRawContents}
377
+ * Sets the raw contents of the file.
378
+ * @param contents - The string contents to save.
379
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
374
380
  */
375
381
  setRawContents(contents: string): Result<string>;
376
382
  /**
377
- * {@inheritDoc FileTree.IFileTreeFileItem.delete}
383
+ * Deletes this file from its backing store.
384
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
378
385
  */
379
386
  delete(): Result<boolean>;
380
387
  /**
@@ -542,55 +549,86 @@ declare class FsFileTreeAccessors<TCT extends string = string> implements IMutab
542
549
  */
543
550
  constructor(params?: IFileTreeInitParams<TCT>);
544
551
  /**
545
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
552
+ * Resolves paths to an absolute path.
553
+ * @param paths - Paths to resolve.
554
+ * @returns The resolved absolute path.
546
555
  */
547
556
  resolveAbsolutePath(...paths: string[]): string;
548
557
  /**
549
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
558
+ * Gets the extension of a path.
559
+ * @param itemPath - Path to get the extension of.
560
+ * @returns The extension of the path.
550
561
  */
551
562
  getExtension(itemPath: string): string;
552
563
  /**
553
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
564
+ * Gets the base name of a path.
565
+ * @param itemPath - Path to get the base name of.
566
+ * @param suffix - Optional suffix to remove from the base name.
567
+ * @returns The base name of the path.
554
568
  */
555
569
  getBaseName(itemPath: string, suffix?: string): string;
556
570
  /**
557
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
571
+ * Joins paths together.
572
+ * @param paths - Paths to join.
573
+ * @returns The joined paths.
558
574
  */
559
575
  joinPaths(...paths: string[]): string;
560
576
  /**
561
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
577
+ * Gets an item from the file tree.
578
+ * @param itemPath - Path of the item to get.
579
+ * @returns The item if it exists.
562
580
  */
563
581
  getItem(itemPath: string): Result<FileTreeItem<TCT>>;
564
582
  /**
565
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
583
+ * Gets the contents of a file in the file tree.
584
+ * @param filePath - Absolute path of the file.
585
+ * @returns The contents of the file.
566
586
  */
567
587
  getFileContents(filePath: string): Result<string>;
568
588
  /**
569
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
589
+ * Gets the content type of a file in the file tree.
590
+ * @param filePath - Absolute path of the file.
591
+ * @param provided - Optional supplied content type.
592
+ * @returns The content type of the file.
570
593
  */
571
594
  getFileContentType(filePath: string, provided?: string): Result<TCT | undefined>;
572
595
  /**
573
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
596
+ * Gets the children of a directory in the file tree.
597
+ * @param dirPath - Path of the directory.
598
+ * @returns The children of the directory.
574
599
  */
575
600
  getChildren(dirPath: string): Result<ReadonlyArray<FileTreeItem<TCT>>>;
576
601
  /**
577
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
602
+ * Checks if a file at the given path can be saved.
603
+ * @param path - The path to check.
604
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
605
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
578
606
  */
579
607
  fileIsMutable(path: string): DetailedResult<boolean, SaveDetail>;
580
608
  /**
581
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
609
+ * Saves the contents to a file at the given path.
610
+ * @param path - The path of the file to save.
611
+ * @param contents - The string contents to save.
612
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
582
613
  */
583
614
  saveFileContents(path: string, contents: string): Result<string>;
584
615
  /**
585
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
616
+ * Deletes a file at the given path.
617
+ * @param path - The path of the file to delete.
618
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
586
619
  */
587
620
  deleteFile(path: string): Result<boolean>;
588
621
  /**
589
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
622
+ * Creates a directory at the given path, including any missing parent directories.
623
+ * @param dirPath - The path of the directory to create.
624
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
590
625
  */
591
626
  createDirectory(dirPath: string): Result<string>;
592
627
  /**
593
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
628
+ * Deletes a directory at the given path.
629
+ * The directory must be empty or the operation will fail.
630
+ * @param dirPath - The path of the directory to delete.
631
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
594
632
  */
595
633
  deleteDirectory(dirPath: string): Result<boolean>;
596
634
  }
@@ -1011,56 +1049,87 @@ declare class InMemoryTreeAccessors<TCT extends string = string> implements IMut
1011
1049
  */
1012
1050
  static create<TCT extends string = string>(files: IInMemoryFile<TCT>[], params?: IFileTreeInitParams<TCT>): Result<InMemoryTreeAccessors<TCT>>;
1013
1051
  /**
1014
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
1052
+ * Resolves paths to an absolute path.
1053
+ * @param paths - Paths to resolve.
1054
+ * @returns The resolved absolute path.
1015
1055
  */
1016
1056
  resolveAbsolutePath(...paths: string[]): string;
1017
1057
  /**
1018
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
1058
+ * Gets the extension of a path.
1059
+ * @param path - Path to get the extension of.
1060
+ * @returns The extension of the path.
1019
1061
  */
1020
1062
  getExtension(path: string): string;
1021
1063
  /**
1022
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
1064
+ * Gets the base name of a path.
1065
+ * @param path - Path to get the base name of.
1066
+ * @param suffix - Optional suffix to remove from the base name.
1067
+ * @returns The base name of the path.
1023
1068
  */
1024
1069
  getBaseName(path: string, suffix?: string): string;
1025
1070
  /**
1026
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
1071
+ * Joins paths together.
1072
+ * @param paths - Paths to join.
1073
+ * @returns The joined paths.
1027
1074
  */
1028
1075
  joinPaths(...paths: string[]): string;
1029
1076
  /**
1030
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
1077
+ * Gets an item from the file tree.
1078
+ * @param itemPath - Path of the item to get.
1079
+ * @returns The item if it exists.
1031
1080
  */
1032
1081
  getItem(itemPath: string): Result<FileTreeItem<TCT>>;
1033
1082
  /**
1034
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
1083
+ * Gets the contents of a file in the file tree.
1084
+ * @param path - Absolute path of the file.
1085
+ * @returns The contents of the file.
1035
1086
  */
1036
1087
  getFileContents(path: string): Result<string>;
1037
1088
  /**
1038
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
1089
+ * Gets the content type of a file in the file tree.
1090
+ * @param path - Absolute path of the file.
1091
+ * @param provided - Optional supplied content type.
1092
+ * @returns The content type of the file.
1039
1093
  */
1040
1094
  getFileContentType(path: string, provided?: string): Result<TCT | undefined>;
1041
1095
  /**
1042
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
1096
+ * Gets the children of a directory in the file tree.
1097
+ * @param path - Path of the directory.
1098
+ * @returns The children of the directory.
1043
1099
  */
1044
1100
  getChildren(path: string): Result<ReadonlyArray<FileTreeItem<TCT>>>;
1045
1101
  private _addMutableFile;
1046
1102
  /**
1047
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
1103
+ * Creates a directory at the given path, including any missing parent directories.
1104
+ * @param dirPath - The path of the directory to create.
1105
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
1048
1106
  */
1049
1107
  createDirectory(dirPath: string): Result<string>;
1050
1108
  /**
1051
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
1109
+ * Checks if a file at the given path can be saved.
1110
+ * @param path - The path to check.
1111
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
1112
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
1052
1113
  */
1053
1114
  fileIsMutable(path: string): DetailedResult<boolean, SaveDetail>;
1054
1115
  /**
1055
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
1116
+ * Deletes a file at the given path.
1117
+ * @param path - The path of the file to delete.
1118
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
1056
1119
  */
1057
1120
  deleteFile(path: string): Result<boolean>;
1058
1121
  /**
1059
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
1122
+ * Deletes a directory at the given path.
1123
+ * The directory must be empty or the operation will fail.
1124
+ * @param path - The path of the directory to delete.
1125
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
1060
1126
  */
1061
1127
  deleteDirectory(path: string): Result<boolean>;
1062
1128
  /**
1063
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
1129
+ * Saves the contents to a file at the given path.
1130
+ * @param path - The path of the file to save.
1131
+ * @param contents - The string contents to save.
1132
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
1064
1133
  */
1065
1134
  saveFileContents(path: string, contents: string): Result<string>;
1066
1135
  }
@@ -58,7 +58,9 @@ export declare class FileItem<TCT extends string = string> implements IMutableFi
58
58
  */
59
59
  static create<TCT extends string = string>(path: string, hal: IFileTreeAccessors<TCT>): Result<FileItem<TCT>>;
60
60
  /**
61
- * {@inheritDoc FileTree.IFileTreeFileItem.getIsMutable}
61
+ * Indicates whether this file can be saved.
62
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
63
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
62
64
  */
63
65
  getIsMutable(): DetailedResult<boolean, SaveDetail>;
64
66
  /**
@@ -79,15 +81,20 @@ export declare class FileItem<TCT extends string = string> implements IMutableFi
79
81
  */
80
82
  setContentType(contentType: TCT | undefined): void;
81
83
  /**
82
- * {@inheritDoc FileTree.IFileTreeFileItem.setContents}
84
+ * Sets the contents of the file from a JSON value.
85
+ * @param json - The JSON value to serialize and save.
86
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
83
87
  */
84
88
  setContents(json: JsonValue): Result<JsonValue>;
85
89
  /**
86
- * {@inheritDoc FileTree.IFileTreeFileItem.setRawContents}
90
+ * Sets the raw contents of the file.
91
+ * @param contents - The string contents to save.
92
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
87
93
  */
88
94
  setRawContents(contents: string): Result<string>;
89
95
  /**
90
- * {@inheritDoc FileTree.IFileTreeFileItem.delete}
96
+ * Deletes this file from its backing store.
97
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
91
98
  */
92
99
  delete(): Result<boolean>;
93
100
  /**
@@ -80,7 +80,9 @@ class FileItem {
80
80
  return (0, ts_utils_1.captureResult)(() => new FileItem(path, hal));
81
81
  }
82
82
  /**
83
- * {@inheritDoc FileTree.IFileTreeFileItem.getIsMutable}
83
+ * Indicates whether this file can be saved.
84
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
85
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
84
86
  */
85
87
  getIsMutable() {
86
88
  if ((0, fileTreeAccessors_1.isMutableAccessors)(this._hal)) {
@@ -114,13 +116,17 @@ class FileItem {
114
116
  this._contentType = contentType;
115
117
  }
116
118
  /**
117
- * {@inheritDoc FileTree.IFileTreeFileItem.setContents}
119
+ * Sets the contents of the file from a JSON value.
120
+ * @param json - The JSON value to serialize and save.
121
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
118
122
  */
119
123
  setContents(json) {
120
124
  return (0, ts_utils_1.captureResult)(() => JSON.stringify(json, null, 2)).onSuccess((contents) => this.setRawContents(contents).onSuccess(() => ts_utils_1.Success.with(json)));
121
125
  }
122
126
  /**
123
- * {@inheritDoc FileTree.IFileTreeFileItem.setRawContents}
127
+ * Sets the raw contents of the file.
128
+ * @param contents - The string contents to save.
129
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
124
130
  */
125
131
  setRawContents(contents) {
126
132
  if ((0, fileTreeAccessors_1.isMutableAccessors)(this._hal)) {
@@ -130,7 +136,8 @@ class FileItem {
130
136
  return (0, ts_utils_1.fail)(`${this.absolutePath}: mutation not supported`);
131
137
  }
132
138
  /**
133
- * {@inheritDoc FileTree.IFileTreeFileItem.delete}
139
+ * Deletes this file from its backing store.
140
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
134
141
  */
135
142
  delete() {
136
143
  if (!(0, fileTreeAccessors_1.isMutableAccessors)(this._hal)) {
@@ -26,55 +26,86 @@ export declare class FsFileTreeAccessors<TCT extends string = string> implements
26
26
  */
27
27
  constructor(params?: IFileTreeInitParams<TCT>);
28
28
  /**
29
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
29
+ * Resolves paths to an absolute path.
30
+ * @param paths - Paths to resolve.
31
+ * @returns The resolved absolute path.
30
32
  */
31
33
  resolveAbsolutePath(...paths: string[]): string;
32
34
  /**
33
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
35
+ * Gets the extension of a path.
36
+ * @param itemPath - Path to get the extension of.
37
+ * @returns The extension of the path.
34
38
  */
35
39
  getExtension(itemPath: string): string;
36
40
  /**
37
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
41
+ * Gets the base name of a path.
42
+ * @param itemPath - Path to get the base name of.
43
+ * @param suffix - Optional suffix to remove from the base name.
44
+ * @returns The base name of the path.
38
45
  */
39
46
  getBaseName(itemPath: string, suffix?: string): string;
40
47
  /**
41
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
48
+ * Joins paths together.
49
+ * @param paths - Paths to join.
50
+ * @returns The joined paths.
42
51
  */
43
52
  joinPaths(...paths: string[]): string;
44
53
  /**
45
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
54
+ * Gets an item from the file tree.
55
+ * @param itemPath - Path of the item to get.
56
+ * @returns The item if it exists.
46
57
  */
47
58
  getItem(itemPath: string): Result<FileTreeItem<TCT>>;
48
59
  /**
49
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
60
+ * Gets the contents of a file in the file tree.
61
+ * @param filePath - Absolute path of the file.
62
+ * @returns The contents of the file.
50
63
  */
51
64
  getFileContents(filePath: string): Result<string>;
52
65
  /**
53
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
66
+ * Gets the content type of a file in the file tree.
67
+ * @param filePath - Absolute path of the file.
68
+ * @param provided - Optional supplied content type.
69
+ * @returns The content type of the file.
54
70
  */
55
71
  getFileContentType(filePath: string, provided?: string): Result<TCT | undefined>;
56
72
  /**
57
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
73
+ * Gets the children of a directory in the file tree.
74
+ * @param dirPath - Path of the directory.
75
+ * @returns The children of the directory.
58
76
  */
59
77
  getChildren(dirPath: string): Result<ReadonlyArray<FileTreeItem<TCT>>>;
60
78
  /**
61
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
79
+ * Checks if a file at the given path can be saved.
80
+ * @param path - The path to check.
81
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
82
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
62
83
  */
63
84
  fileIsMutable(path: string): DetailedResult<boolean, SaveDetail>;
64
85
  /**
65
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
86
+ * Saves the contents to a file at the given path.
87
+ * @param path - The path of the file to save.
88
+ * @param contents - The string contents to save.
89
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
66
90
  */
67
91
  saveFileContents(path: string, contents: string): Result<string>;
68
92
  /**
69
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
93
+ * Deletes a file at the given path.
94
+ * @param path - The path of the file to delete.
95
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
70
96
  */
71
97
  deleteFile(path: string): Result<boolean>;
72
98
  /**
73
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
99
+ * Creates a directory at the given path, including any missing parent directories.
100
+ * @param dirPath - The path of the directory to create.
101
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
74
102
  */
75
103
  createDirectory(dirPath: string): Result<string>;
76
104
  /**
77
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
105
+ * Deletes a directory at the given path.
106
+ * The directory must be empty or the operation will fail.
107
+ * @param dirPath - The path of the directory to delete.
108
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
78
109
  */
79
110
  deleteDirectory(dirPath: string): Result<boolean>;
80
111
  }
@@ -50,7 +50,9 @@ class FsFileTreeAccessors {
50
50
  this._mutable = (_b = params === null || params === void 0 ? void 0 : params.mutable) !== null && _b !== void 0 ? _b : false;
51
51
  }
52
52
  /**
53
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
53
+ * Resolves paths to an absolute path.
54
+ * @param paths - Paths to resolve.
55
+ * @returns The resolved absolute path.
54
56
  */
55
57
  resolveAbsolutePath(...paths) {
56
58
  if (this.prefix && !path_1.default.isAbsolute(paths[0])) {
@@ -59,25 +61,34 @@ class FsFileTreeAccessors {
59
61
  return path_1.default.resolve(...paths);
60
62
  }
61
63
  /**
62
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
64
+ * Gets the extension of a path.
65
+ * @param itemPath - Path to get the extension of.
66
+ * @returns The extension of the path.
63
67
  */
64
68
  getExtension(itemPath) {
65
69
  return path_1.default.extname(itemPath);
66
70
  }
67
71
  /**
68
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
72
+ * Gets the base name of a path.
73
+ * @param itemPath - Path to get the base name of.
74
+ * @param suffix - Optional suffix to remove from the base name.
75
+ * @returns The base name of the path.
69
76
  */
70
77
  getBaseName(itemPath, suffix) {
71
78
  return path_1.default.basename(itemPath, suffix);
72
79
  }
73
80
  /**
74
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
81
+ * Joins paths together.
82
+ * @param paths - Paths to join.
83
+ * @returns The joined paths.
75
84
  */
76
85
  joinPaths(...paths) {
77
86
  return path_1.default.join(...paths);
78
87
  }
79
88
  /**
80
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
89
+ * Gets an item from the file tree.
90
+ * @param itemPath - Path of the item to get.
91
+ * @returns The item if it exists.
81
92
  */
82
93
  getItem(itemPath) {
83
94
  return (0, ts_utils_1.captureResult)(() => {
@@ -93,13 +104,18 @@ class FsFileTreeAccessors {
93
104
  });
94
105
  }
95
106
  /**
96
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
107
+ * Gets the contents of a file in the file tree.
108
+ * @param filePath - Absolute path of the file.
109
+ * @returns The contents of the file.
97
110
  */
98
111
  getFileContents(filePath) {
99
112
  return (0, ts_utils_1.captureResult)(() => fs_1.default.readFileSync(this.resolveAbsolutePath(filePath), 'utf8'));
100
113
  }
101
114
  /**
102
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
115
+ * Gets the content type of a file in the file tree.
116
+ * @param filePath - Absolute path of the file.
117
+ * @param provided - Optional supplied content type.
118
+ * @returns The content type of the file.
103
119
  */
104
120
  getFileContentType(filePath, provided) {
105
121
  if (provided !== undefined) {
@@ -109,7 +125,9 @@ class FsFileTreeAccessors {
109
125
  return this._inferContentType(filePath);
110
126
  }
111
127
  /**
112
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
128
+ * Gets the children of a directory in the file tree.
129
+ * @param dirPath - Path of the directory.
130
+ * @returns The children of the directory.
113
131
  */
114
132
  getChildren(dirPath) {
115
133
  return (0, ts_utils_1.captureResult)(() => {
@@ -128,7 +146,10 @@ class FsFileTreeAccessors {
128
146
  });
129
147
  }
130
148
  /**
131
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
149
+ * Checks if a file at the given path can be saved.
150
+ * @param path - The path to check.
151
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
152
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
132
153
  */
133
154
  fileIsMutable(path) {
134
155
  const absolutePath = this.resolveAbsolutePath(path);
@@ -161,7 +182,10 @@ class FsFileTreeAccessors {
161
182
  }
162
183
  }
163
184
  /**
164
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
185
+ * Saves the contents to a file at the given path.
186
+ * @param path - The path of the file to save.
187
+ * @param contents - The string contents to save.
188
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
165
189
  */
166
190
  saveFileContents(path, contents) {
167
191
  return this.fileIsMutable(path).asResult.onSuccess(() => {
@@ -173,7 +197,9 @@ class FsFileTreeAccessors {
173
197
  });
174
198
  }
175
199
  /**
176
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
200
+ * Deletes a file at the given path.
201
+ * @param path - The path of the file to delete.
202
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
177
203
  */
178
204
  deleteFile(path) {
179
205
  return this.fileIsMutable(path).asResult.onSuccess(() => {
@@ -189,7 +215,9 @@ class FsFileTreeAccessors {
189
215
  });
190
216
  }
191
217
  /**
192
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
218
+ * Creates a directory at the given path, including any missing parent directories.
219
+ * @param dirPath - The path of the directory to create.
220
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
193
221
  */
194
222
  createDirectory(dirPath) {
195
223
  const absolutePath = this.resolveAbsolutePath(dirPath);
@@ -203,7 +231,10 @@ class FsFileTreeAccessors {
203
231
  });
204
232
  }
205
233
  /**
206
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
234
+ * Deletes a directory at the given path.
235
+ * The directory must be empty or the operation will fail.
236
+ * @param dirPath - The path of the directory to delete.
237
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
207
238
  */
208
239
  deleteDirectory(dirPath) {
209
240
  return this.fileIsMutable(dirPath).asResult.onSuccess(() => {
@@ -51,56 +51,87 @@ export declare class InMemoryTreeAccessors<TCT extends string = string> implemen
51
51
  */
52
52
  static create<TCT extends string = string>(files: IInMemoryFile<TCT>[], params?: IFileTreeInitParams<TCT>): Result<InMemoryTreeAccessors<TCT>>;
53
53
  /**
54
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
54
+ * Resolves paths to an absolute path.
55
+ * @param paths - Paths to resolve.
56
+ * @returns The resolved absolute path.
55
57
  */
56
58
  resolveAbsolutePath(...paths: string[]): string;
57
59
  /**
58
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
60
+ * Gets the extension of a path.
61
+ * @param path - Path to get the extension of.
62
+ * @returns The extension of the path.
59
63
  */
60
64
  getExtension(path: string): string;
61
65
  /**
62
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
66
+ * Gets the base name of a path.
67
+ * @param path - Path to get the base name of.
68
+ * @param suffix - Optional suffix to remove from the base name.
69
+ * @returns The base name of the path.
63
70
  */
64
71
  getBaseName(path: string, suffix?: string): string;
65
72
  /**
66
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
73
+ * Joins paths together.
74
+ * @param paths - Paths to join.
75
+ * @returns The joined paths.
67
76
  */
68
77
  joinPaths(...paths: string[]): string;
69
78
  /**
70
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
79
+ * Gets an item from the file tree.
80
+ * @param itemPath - Path of the item to get.
81
+ * @returns The item if it exists.
71
82
  */
72
83
  getItem(itemPath: string): Result<FileTreeItem<TCT>>;
73
84
  /**
74
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
85
+ * Gets the contents of a file in the file tree.
86
+ * @param path - Absolute path of the file.
87
+ * @returns The contents of the file.
75
88
  */
76
89
  getFileContents(path: string): Result<string>;
77
90
  /**
78
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
91
+ * Gets the content type of a file in the file tree.
92
+ * @param path - Absolute path of the file.
93
+ * @param provided - Optional supplied content type.
94
+ * @returns The content type of the file.
79
95
  */
80
96
  getFileContentType(path: string, provided?: string): Result<TCT | undefined>;
81
97
  /**
82
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
98
+ * Gets the children of a directory in the file tree.
99
+ * @param path - Path of the directory.
100
+ * @returns The children of the directory.
83
101
  */
84
102
  getChildren(path: string): Result<ReadonlyArray<FileTreeItem<TCT>>>;
85
103
  private _addMutableFile;
86
104
  /**
87
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
105
+ * Creates a directory at the given path, including any missing parent directories.
106
+ * @param dirPath - The path of the directory to create.
107
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
88
108
  */
89
109
  createDirectory(dirPath: string): Result<string>;
90
110
  /**
91
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
111
+ * Checks if a file at the given path can be saved.
112
+ * @param path - The path to check.
113
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
114
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
92
115
  */
93
116
  fileIsMutable(path: string): DetailedResult<boolean, SaveDetail>;
94
117
  /**
95
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
118
+ * Deletes a file at the given path.
119
+ * @param path - The path of the file to delete.
120
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
96
121
  */
97
122
  deleteFile(path: string): Result<boolean>;
98
123
  /**
99
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
124
+ * Deletes a directory at the given path.
125
+ * The directory must be empty or the operation will fail.
126
+ * @param path - The path of the directory to delete.
127
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
100
128
  */
101
129
  deleteDirectory(path: string): Result<boolean>;
102
130
  /**
103
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
131
+ * Saves the contents to a file at the given path.
132
+ * @param path - The path of the file to save.
133
+ * @param contents - The string contents to save.
134
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
104
135
  */
105
136
  saveFileContents(path: string, contents: string): Result<string>;
106
137
  }
@@ -138,7 +138,9 @@ class InMemoryTreeAccessors {
138
138
  return (0, ts_utils_1.captureResult)(() => new InMemoryTreeAccessors(files, params));
139
139
  }
140
140
  /**
141
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
141
+ * Resolves paths to an absolute path.
142
+ * @param paths - Paths to resolve.
143
+ * @returns The resolved absolute path.
142
144
  */
143
145
  resolveAbsolutePath(...paths) {
144
146
  const parts = paths[0].startsWith('/') ? paths : [this._tree.prefix, ...paths];
@@ -146,7 +148,9 @@ class InMemoryTreeAccessors {
146
148
  return `/${joined}`;
147
149
  }
148
150
  /**
149
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
151
+ * Gets the extension of a path.
152
+ * @param path - Path to get the extension of.
153
+ * @returns The extension of the path.
150
154
  */
151
155
  getExtension(path) {
152
156
  const parts = path.split('.');
@@ -156,7 +160,10 @@ class InMemoryTreeAccessors {
156
160
  return `.${parts.pop()}`;
157
161
  }
158
162
  /**
159
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
163
+ * Gets the base name of a path.
164
+ * @param path - Path to get the base name of.
165
+ * @param suffix - Optional suffix to remove from the base name.
166
+ * @returns The base name of the path.
160
167
  */
161
168
  getBaseName(path, suffix) {
162
169
  var _a;
@@ -168,7 +175,9 @@ class InMemoryTreeAccessors {
168
175
  return base;
169
176
  }
170
177
  /**
171
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
178
+ * Joins paths together.
179
+ * @param paths - Paths to join.
180
+ * @returns The joined paths.
172
181
  */
173
182
  joinPaths(...paths) {
174
183
  var _a;
@@ -176,7 +185,9 @@ class InMemoryTreeAccessors {
176
185
  return ((_a = paths[0]) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? `/${joined}` : joined;
177
186
  }
178
187
  /**
179
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
188
+ * Gets an item from the file tree.
189
+ * @param itemPath - Path of the item to get.
190
+ * @returns The item if it exists.
180
191
  */
181
192
  getItem(itemPath) {
182
193
  const existing = this._tree.byAbsolutePath.get(itemPath);
@@ -191,7 +202,9 @@ class InMemoryTreeAccessors {
191
202
  return (0, ts_utils_1.fail)(`${itemPath}: not found`);
192
203
  }
193
204
  /**
194
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
205
+ * Gets the contents of a file in the file tree.
206
+ * @param path - Absolute path of the file.
207
+ * @returns The contents of the file.
195
208
  */
196
209
  getFileContents(path) {
197
210
  const absolutePath = this.resolveAbsolutePath(path);
@@ -208,7 +221,10 @@ class InMemoryTreeAccessors {
208
221
  return (0, ts_utils_1.captureResult)(() => JSON.stringify(item.contents));
209
222
  }
210
223
  /**
211
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
224
+ * Gets the content type of a file in the file tree.
225
+ * @param path - Absolute path of the file.
226
+ * @param provided - Optional supplied content type.
227
+ * @returns The content type of the file.
212
228
  */
213
229
  getFileContentType(path, provided) {
214
230
  // If provided contentType is given, use it directly (highest priority)
@@ -231,7 +247,9 @@ class InMemoryTreeAccessors {
231
247
  return this._inferContentType(path);
232
248
  }
233
249
  /**
234
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
250
+ * Gets the children of a directory in the file tree.
251
+ * @param path - Path of the directory.
252
+ * @returns The children of the directory.
235
253
  */
236
254
  getChildren(path) {
237
255
  const item = this._tree.byAbsolutePath.get(path);
@@ -281,7 +299,9 @@ class InMemoryTreeAccessors {
281
299
  });
282
300
  }
283
301
  /**
284
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
302
+ * Creates a directory at the given path, including any missing parent directories.
303
+ * @param dirPath - The path of the directory to create.
304
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
285
305
  */
286
306
  createDirectory(dirPath) {
287
307
  const absolutePath = this.resolveAbsolutePath(dirPath);
@@ -312,7 +332,10 @@ class InMemoryTreeAccessors {
312
332
  return (0, ts_utils_1.succeed)(absolutePath);
313
333
  }
314
334
  /**
315
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
335
+ * Checks if a file at the given path can be saved.
336
+ * @param path - The path to check.
337
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
338
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
316
339
  */
317
340
  fileIsMutable(path) {
318
341
  const absolutePath = this.resolveAbsolutePath(path);
@@ -327,7 +350,9 @@ class InMemoryTreeAccessors {
327
350
  return (0, ts_utils_1.succeedWithDetail)(true, 'transient');
328
351
  }
329
352
  /**
330
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
353
+ * Deletes a file at the given path.
354
+ * @param path - The path of the file to delete.
355
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
331
356
  */
332
357
  deleteFile(path) {
333
358
  const absolutePath = this.resolveAbsolutePath(path);
@@ -359,7 +384,10 @@ class InMemoryTreeAccessors {
359
384
  return (0, ts_utils_1.succeed)(true);
360
385
  }
361
386
  /**
362
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
387
+ * Deletes a directory at the given path.
388
+ * The directory must be empty or the operation will fail.
389
+ * @param path - The path of the directory to delete.
390
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
363
391
  */
364
392
  deleteDirectory(path) {
365
393
  const absolutePath = this.resolveAbsolutePath(path);
@@ -399,7 +427,10 @@ class InMemoryTreeAccessors {
399
427
  return (0, ts_utils_1.succeed)(true);
400
428
  }
401
429
  /**
402
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
430
+ * Saves the contents to a file at the given path.
431
+ * @param path - The path of the file to save.
432
+ * @param contents - The string contents to save.
433
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
403
434
  */
404
435
  saveFileContents(path, contents) {
405
436
  const isMutable = this.fileIsMutable(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-json-base",
3
- "version": "5.1.0-15",
3
+ "version": "5.1.0-17",
4
4
  "description": "Typescript types and basic functions for working with json",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-json-base.d.ts",
@@ -55,13 +55,13 @@
55
55
  "@rushstack/heft-node-rig": "2.11.27",
56
56
  "@microsoft/api-extractor": "^7.55.2",
57
57
  "typedoc": "~0.28.16",
58
- "@fgv/ts-utils-jest": "5.1.0-15",
59
- "@fgv/heft-dual-rig": "5.1.0-15",
60
- "@fgv/ts-utils": "5.1.0-15",
61
- "@fgv/typedoc-compact-theme": "5.1.0-15"
58
+ "@fgv/ts-utils": "5.1.0-17",
59
+ "@fgv/heft-dual-rig": "5.1.0-17",
60
+ "@fgv/ts-utils-jest": "5.1.0-17",
61
+ "@fgv/typedoc-compact-theme": "5.1.0-17"
62
62
  },
63
63
  "peerDependencies": {
64
- "@fgv/ts-utils": "5.1.0-15"
64
+ "@fgv/ts-utils": "5.1.0-17"
65
65
  },
66
66
  "dependencies": {
67
67
  "luxon": "^3.7.2"