@interactive-inc/docs-client 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
+ import { z } from 'zod';
2
+
1
3
  // lib/modules/file-system/doc-file-system-json.ts
2
- import { z as z3 } from "zod";
3
4
 
4
5
  // lib/modules/path-system/doc-path-system.ts
5
6
  var DocPathSystem = class {
@@ -121,269 +122,6 @@ var DocPathSystem = class {
121
122
  }
122
123
  };
123
124
 
124
- // lib/modules/file-system/doc-file-system-read.ts
125
- import * as fs from "fs/promises";
126
- var DocFileSystemRead = class {
127
- basePath;
128
- pathSystem;
129
- constructor(props) {
130
- this.basePath = props.basePath;
131
- this.pathSystem = props.pathSystem ?? new DocPathSystem();
132
- }
133
- /**
134
- * Read file content at the specified path
135
- */
136
- async readFile(relativePath) {
137
- try {
138
- const exists = await this.exists(relativePath);
139
- if (!exists) return null;
140
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
141
- return await fs.readFile(fullPath, "utf-8");
142
- } catch (error) {
143
- return error instanceof Error ? error : new Error(`Failed to read file at ${relativePath}`);
144
- }
145
- }
146
- /**
147
- * Get file name from path
148
- */
149
- readFileName(relativePath) {
150
- return this.pathSystem.basename(relativePath);
151
- }
152
- /**
153
- * Get file extension from path
154
- */
155
- readFileExtension(relativePath) {
156
- return this.pathSystem.extname(relativePath);
157
- }
158
- /**
159
- * Get directory path where the file exists
160
- */
161
- readFileDirectory(relativePath) {
162
- return this.pathSystem.dirname(relativePath);
163
- }
164
- /**
165
- * Get list of entries in directory
166
- */
167
- async readDirectoryFileNames(relativePath = "") {
168
- try {
169
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
170
- return await fs.readdir(fullPath);
171
- } catch (error) {
172
- return error instanceof Error ? error : new Error(`Failed to read directory at ${relativePath}`);
173
- }
174
- }
175
- async readDirectoryFilePaths(relativePath) {
176
- try {
177
- const fileNames = await this.readDirectoryFileNames(relativePath);
178
- if (fileNames instanceof Error) {
179
- return fileNames;
180
- }
181
- return fileNames.map(
182
- (fileName) => this.pathSystem.join(relativePath, fileName)
183
- );
184
- } catch (error) {
185
- return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
186
- }
187
- }
188
- /**
189
- * Check if path is a directory
190
- */
191
- async isDirectory(relativePath) {
192
- try {
193
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
194
- const stats = await fs.stat(fullPath);
195
- return stats.isDirectory();
196
- } catch {
197
- return false;
198
- }
199
- }
200
- /**
201
- * Check if path is a file
202
- */
203
- async isFile(relativePath) {
204
- try {
205
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
206
- const stats = await fs.stat(fullPath);
207
- return stats.isFile();
208
- } catch {
209
- return false;
210
- }
211
- }
212
- /**
213
- * Check if file or directory exists
214
- */
215
- async exists(relativePath) {
216
- try {
217
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
218
- await fs.access(fullPath);
219
- return true;
220
- } catch {
221
- return false;
222
- }
223
- }
224
- /**
225
- * Check if directory exists
226
- */
227
- async directoryExists(relativePath) {
228
- return this.isDirectory(relativePath);
229
- }
230
- /**
231
- * Check if file exists
232
- */
233
- async fileExists(relativePath) {
234
- return this.isFile(relativePath);
235
- }
236
- /**
237
- * Get base path
238
- */
239
- getBasePath() {
240
- return this.basePath;
241
- }
242
- /**
243
- * Convert relative path to absolute path
244
- */
245
- resolve(relativePath) {
246
- return this.pathSystem.join(this.basePath, relativePath);
247
- }
248
- /**
249
- * Get file size in bytes
250
- */
251
- async getFileSize(relativePath) {
252
- try {
253
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
254
- const stats = await fs.stat(fullPath);
255
- return stats.size;
256
- } catch (error) {
257
- return error instanceof Error ? error : new Error(`Failed to get file size at ${relativePath}`);
258
- }
259
- }
260
- /**
261
- * Get file last modified time
262
- */
263
- async getFileModifiedTime(relativePath) {
264
- try {
265
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
266
- const stats = await fs.stat(fullPath);
267
- return stats.mtime;
268
- } catch (error) {
269
- return error instanceof Error ? error : new Error(`Failed to get file modified time at ${relativePath}`);
270
- }
271
- }
272
- /**
273
- * Get file creation time
274
- */
275
- async getFileCreatedTime(relativePath) {
276
- try {
277
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
278
- const stats = await fs.stat(fullPath);
279
- return stats.birthtime;
280
- } catch (error) {
281
- return error instanceof Error ? error : new Error(`Failed to get file created time at ${relativePath}`);
282
- }
283
- }
284
- };
285
-
286
- // lib/modules/file-system/doc-file-system-write.ts
287
- import * as fs2 from "fs/promises";
288
- var DocFileSystemWrite = class {
289
- basePath;
290
- pathSystem;
291
- reader;
292
- constructor(props) {
293
- this.basePath = props.basePath;
294
- this.pathSystem = props.pathSystem ?? new DocPathSystem();
295
- this.reader = props.reader;
296
- }
297
- /**
298
- * Write content to file at the specified path (creates directory if needed)
299
- */
300
- async writeFile(relativePath, content) {
301
- try {
302
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
303
- const dirPath = this.pathSystem.dirname(fullPath);
304
- await fs2.mkdir(dirPath, { recursive: true });
305
- await fs2.writeFile(fullPath, content, "utf-8");
306
- return null;
307
- } catch (error) {
308
- return error instanceof Error ? error : new Error(`Failed to write file at ${relativePath}`);
309
- }
310
- }
311
- /**
312
- * Delete file at the specified path
313
- */
314
- async deleteFile(relativePath) {
315
- try {
316
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
317
- await fs2.unlink(fullPath);
318
- return null;
319
- } catch (error) {
320
- return new Error(`Failed to delete file at ${relativePath}: ${error}`);
321
- }
322
- }
323
- /**
324
- * Create directory
325
- */
326
- async createDirectory(relativePath) {
327
- try {
328
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
329
- await fs2.mkdir(fullPath, { recursive: true });
330
- return null;
331
- } catch (error) {
332
- return error instanceof Error ? error : new Error(`Failed to create directory at ${relativePath}`);
333
- }
334
- }
335
- /**
336
- * Create directory if it doesn't exist
337
- */
338
- async ensureDirectoryExists(relativePath) {
339
- try {
340
- if (this.reader) {
341
- const exists = await this.reader.exists(relativePath);
342
- if (exists) {
343
- return null;
344
- }
345
- }
346
- const result = await this.createDirectory(relativePath);
347
- if (result instanceof Error) {
348
- return result;
349
- }
350
- return null;
351
- } catch (error) {
352
- return error instanceof Error ? error : new Error(`Failed to ensure directory exists at ${relativePath}`);
353
- }
354
- }
355
- /**
356
- * Copy file
357
- */
358
- async copyFile(sourcePath, destinationPath) {
359
- try {
360
- const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
361
- const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
362
- await fs2.copyFile(sourceFullPath, destFullPath);
363
- return null;
364
- } catch (error) {
365
- return error instanceof Error ? error : new Error(
366
- `Failed to copy file from ${sourcePath} to ${destinationPath}`
367
- );
368
- }
369
- }
370
- /**
371
- * Move file
372
- */
373
- async moveFile(sourcePath, destinationPath) {
374
- try {
375
- const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
376
- const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
377
- await fs2.rename(sourceFullPath, destFullPath);
378
- return null;
379
- } catch (error) {
380
- return error instanceof Error ? error : new Error(
381
- `Failed to move file from ${sourcePath} to ${destinationPath}`
382
- );
383
- }
384
- }
385
- };
386
-
387
125
  // lib/modules/file-system/doc-file-system.ts
388
126
  var DocFileSystem = class {
389
127
  reader;
@@ -393,15 +131,8 @@ var DocFileSystem = class {
393
131
  constructor(props) {
394
132
  this.basePath = props.basePath;
395
133
  this.pathSystem = props.pathSystem ?? new DocPathSystem();
396
- this.reader = props.reader ?? new DocFileSystemRead({
397
- basePath: this.basePath,
398
- pathSystem: this.pathSystem
399
- });
400
- this.writer = props.writer ?? new DocFileSystemWrite({
401
- basePath: this.basePath,
402
- pathSystem: this.pathSystem,
403
- reader: this.reader
404
- });
134
+ this.reader = props.reader;
135
+ this.writer = props.writer;
405
136
  }
406
137
  /**
407
138
  * Read file content at the specified path
@@ -493,8 +224,8 @@ var DocFileSystem = class {
493
224
  /**
494
225
  * Create directory
495
226
  */
496
- async createDirectory(relativePath) {
497
- return this.writer.createDirectory(relativePath);
227
+ async createEmptyDirectory(relativePath) {
228
+ return this.writer.createEmptyDirectory(relativePath);
498
229
  }
499
230
  /**
500
231
  * Get file size in bytes
@@ -505,8 +236,8 @@ var DocFileSystem = class {
505
236
  /**
506
237
  * Create directory if it doesn't exist
507
238
  */
508
- async ensureDirectoryExists(relativePath) {
509
- return this.writer.ensureDirectoryExists(relativePath);
239
+ async createDirectory(relativePath) {
240
+ return this.writer.createDirectory(relativePath);
510
241
  }
511
242
  /**
512
243
  * Copy file
@@ -523,8 +254,8 @@ var DocFileSystem = class {
523
254
  /**
524
255
  * Get file last modified time
525
256
  */
526
- async getFileModifiedTime(relativePath) {
527
- return this.reader.getFileModifiedTime(relativePath);
257
+ async getFileUpdatedTime(relativePath) {
258
+ return this.reader.getFileUpdatedTime(relativePath);
528
259
  }
529
260
  /**
530
261
  * Get file creation time
@@ -533,9 +264,6 @@ var DocFileSystem = class {
533
264
  return this.reader.getFileCreatedTime(relativePath);
534
265
  }
535
266
  };
536
-
537
- // lib/modules/file-system/doc-file-system-json-read.ts
538
- import { z } from "zod";
539
267
  var zJsonDocumentData = z.record(z.string(), z.string());
540
268
  function parseJsonDocumentData(data) {
541
269
  try {
@@ -708,7 +436,7 @@ var DocFileSystemJsonRead = class {
708
436
  /**
709
437
  * Get file last modified time (not available for JSON data)
710
438
  */
711
- async getFileModifiedTime(_relativePath) {
439
+ async getFileUpdatedTime(_relativePath) {
712
440
  return new Error("File modified time not available for JSON data");
713
441
  }
714
442
  /**
@@ -757,10 +485,7 @@ var DocFileSystemJsonRead = class {
757
485
  return "";
758
486
  }
759
487
  };
760
-
761
- // lib/modules/file-system/doc-file-system-json-write.ts
762
- import { z as z2 } from "zod";
763
- var zJsonDocumentData2 = z2.record(z2.string(), z2.string());
488
+ var zJsonDocumentData2 = z.record(z.string(), z.string());
764
489
  function parseJsonDocumentData2(data) {
765
490
  try {
766
491
  return zJsonDocumentData2.parse(data);
@@ -821,7 +546,7 @@ var DocFileSystemJsonWrite = class {
821
546
  /**
822
547
  * Create directory (creates a placeholder entry)
823
548
  */
824
- async createDirectory(relativePath) {
549
+ async createEmptyDirectory(relativePath) {
825
550
  try {
826
551
  const normalizedPath = this.normalizePath(relativePath);
827
552
  const gitkeepPath = this.pathSystem.join(normalizedPath, ".gitkeep");
@@ -836,7 +561,7 @@ var DocFileSystemJsonWrite = class {
836
561
  /**
837
562
  * Create directory if it doesn't exist
838
563
  */
839
- async ensureDirectoryExists(relativePath) {
564
+ async createDirectory(relativePath) {
840
565
  try {
841
566
  if (this.reader) {
842
567
  const exists = await this.reader.exists(relativePath);
@@ -848,7 +573,7 @@ var DocFileSystemJsonWrite = class {
848
573
  return null;
849
574
  }
850
575
  }
851
- return await this.createDirectory(relativePath);
576
+ return await this.createEmptyDirectory(relativePath);
852
577
  } catch (error) {
853
578
  return error instanceof Error ? error : new Error(`Failed to ensure directory exists at ${relativePath}`);
854
579
  }
@@ -963,7 +688,7 @@ var DocFileSystemJsonWrite = class {
963
688
  };
964
689
 
965
690
  // lib/modules/file-system/doc-file-system-json.ts
966
- var zJsonDocumentData3 = z3.record(z3.string(), z3.string());
691
+ z.record(z.string(), z.string());
967
692
  var DocFileSystemJson = class _DocFileSystemJson extends DocFileSystem {
968
693
  jsonReader;
969
694
  jsonWriter;
@@ -1036,8 +761,5 @@ var DocFileSystemJson = class _DocFileSystemJson extends DocFileSystem {
1036
761
  return this.getData();
1037
762
  }
1038
763
  };
1039
- export {
1040
- DocFileSystemJson,
1041
- DocFileSystemJsonRead,
1042
- DocFileSystemJsonWrite
1043
- };
764
+
765
+ export { DocFileSystemJson, DocFileSystemJsonRead, DocFileSystemJsonWrite };
@@ -1,21 +1,41 @@
1
- import { D as DocFileSystem, a as DocPathSystem } from './doc-file-system-BQAOBIO-.js';
1
+ import { D as DocFileSystemInterface, a as DocPathSystem } from './doc-file-system.interface-C5vpYrOL.js';
2
2
 
3
3
  /**
4
4
  * In-memory file system for testing
5
5
  */
6
- declare class DocFileSystemMock extends DocFileSystem {
6
+ declare class DocFileSystemMock implements DocFileSystemInterface {
7
7
  private files;
8
- private readonly _pathSystem;
9
- private readonly _basePath;
8
+ private readonly pathSystem;
9
+ private readonly basePath;
10
10
  constructor(props: {
11
11
  basePath: string;
12
- pathSystem: DocPathSystem;
12
+ pathSystem?: DocPathSystem;
13
13
  skipDefaultFiles?: boolean;
14
14
  });
15
15
  /**
16
16
  * PathSystem accessor (for testing)
17
17
  */
18
18
  getPathSystem(): DocPathSystem;
19
+ /**
20
+ * Get file name from path
21
+ */
22
+ readFileName(relativePath: string): string;
23
+ /**
24
+ * Get file extension from path
25
+ */
26
+ readFileExtension(relativePath: string): string;
27
+ /**
28
+ * Get directory path where the file exists
29
+ */
30
+ readFileDirectory(relativePath: string): string;
31
+ /**
32
+ * Get base path
33
+ */
34
+ getBasePath(): string;
35
+ /**
36
+ * Convert relative path to absolute path
37
+ */
38
+ resolve(relativePath: string): string;
19
39
  /**
20
40
  * Normalize path using basePath
21
41
  */
@@ -40,10 +60,10 @@ declare class DocFileSystemMock extends DocFileSystem {
40
60
  readDirectory(directoryPath: string): Promise<string[]>;
41
61
  readDirectoryRecursive(directoryPath: string): Promise<string[]>;
42
62
  readDirectoryFilePaths(directoryPath: string): Promise<string[] | Error>;
43
- createDirectory(_directoryPath: string): Promise<Error | null>;
63
+ createEmptyDirectory(_directoryPath: string): Promise<Error | null>;
44
64
  deleteDirectory(directoryPath: string): Promise<void>;
45
65
  getFileSize(filePath: string): Promise<number | Error>;
46
- getFileModifiedTime(filePath: string): Promise<Date | Error>;
66
+ getFileUpdatedTime(filePath: string): Promise<Date | Error>;
47
67
  getFileCreatedTime(filePath: string): Promise<Date | Error>;
48
68
  isDirectory(relativePath: string): Promise<boolean>;
49
69
  isFile(relativePath: string): Promise<boolean>;
@@ -62,7 +82,7 @@ declare class DocFileSystemMock extends DocFileSystem {
62
82
  /**
63
83
  * Create directory if it doesn't exist
64
84
  */
65
- ensureDirectoryExists(_relativePath: string): Promise<Error | null>;
85
+ createDirectory(_relativePath: string): Promise<Error | null>;
66
86
  /**
67
87
  * Clear all files
68
88
  */