@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,3 +1,5 @@
1
+ import { Octokit } from '@octokit/rest';
2
+
1
3
  // lib/modules/path-system/doc-path-system.ts
2
4
  var DocPathSystem = class {
3
5
  separator = "/";
@@ -118,269 +120,6 @@ var DocPathSystem = class {
118
120
  }
119
121
  };
120
122
 
121
- // lib/modules/file-system/doc-file-system-read.ts
122
- import * as fs from "fs/promises";
123
- var DocFileSystemRead = class {
124
- basePath;
125
- pathSystem;
126
- constructor(props) {
127
- this.basePath = props.basePath;
128
- this.pathSystem = props.pathSystem ?? new DocPathSystem();
129
- }
130
- /**
131
- * Read file content at the specified path
132
- */
133
- async readFile(relativePath) {
134
- try {
135
- const exists = await this.exists(relativePath);
136
- if (!exists) return null;
137
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
138
- return await fs.readFile(fullPath, "utf-8");
139
- } catch (error) {
140
- return error instanceof Error ? error : new Error(`Failed to read file at ${relativePath}`);
141
- }
142
- }
143
- /**
144
- * Get file name from path
145
- */
146
- readFileName(relativePath) {
147
- return this.pathSystem.basename(relativePath);
148
- }
149
- /**
150
- * Get file extension from path
151
- */
152
- readFileExtension(relativePath) {
153
- return this.pathSystem.extname(relativePath);
154
- }
155
- /**
156
- * Get directory path where the file exists
157
- */
158
- readFileDirectory(relativePath) {
159
- return this.pathSystem.dirname(relativePath);
160
- }
161
- /**
162
- * Get list of entries in directory
163
- */
164
- async readDirectoryFileNames(relativePath = "") {
165
- try {
166
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
167
- return await fs.readdir(fullPath);
168
- } catch (error) {
169
- return error instanceof Error ? error : new Error(`Failed to read directory at ${relativePath}`);
170
- }
171
- }
172
- async readDirectoryFilePaths(relativePath) {
173
- try {
174
- const fileNames = await this.readDirectoryFileNames(relativePath);
175
- if (fileNames instanceof Error) {
176
- return fileNames;
177
- }
178
- return fileNames.map(
179
- (fileName) => this.pathSystem.join(relativePath, fileName)
180
- );
181
- } catch (error) {
182
- return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
183
- }
184
- }
185
- /**
186
- * Check if path is a directory
187
- */
188
- async isDirectory(relativePath) {
189
- try {
190
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
191
- const stats = await fs.stat(fullPath);
192
- return stats.isDirectory();
193
- } catch {
194
- return false;
195
- }
196
- }
197
- /**
198
- * Check if path is a file
199
- */
200
- async isFile(relativePath) {
201
- try {
202
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
203
- const stats = await fs.stat(fullPath);
204
- return stats.isFile();
205
- } catch {
206
- return false;
207
- }
208
- }
209
- /**
210
- * Check if file or directory exists
211
- */
212
- async exists(relativePath) {
213
- try {
214
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
215
- await fs.access(fullPath);
216
- return true;
217
- } catch {
218
- return false;
219
- }
220
- }
221
- /**
222
- * Check if directory exists
223
- */
224
- async directoryExists(relativePath) {
225
- return this.isDirectory(relativePath);
226
- }
227
- /**
228
- * Check if file exists
229
- */
230
- async fileExists(relativePath) {
231
- return this.isFile(relativePath);
232
- }
233
- /**
234
- * Get base path
235
- */
236
- getBasePath() {
237
- return this.basePath;
238
- }
239
- /**
240
- * Convert relative path to absolute path
241
- */
242
- resolve(relativePath) {
243
- return this.pathSystem.join(this.basePath, relativePath);
244
- }
245
- /**
246
- * Get file size in bytes
247
- */
248
- async getFileSize(relativePath) {
249
- try {
250
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
251
- const stats = await fs.stat(fullPath);
252
- return stats.size;
253
- } catch (error) {
254
- return error instanceof Error ? error : new Error(`Failed to get file size at ${relativePath}`);
255
- }
256
- }
257
- /**
258
- * Get file last modified time
259
- */
260
- async getFileModifiedTime(relativePath) {
261
- try {
262
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
263
- const stats = await fs.stat(fullPath);
264
- return stats.mtime;
265
- } catch (error) {
266
- return error instanceof Error ? error : new Error(`Failed to get file modified time at ${relativePath}`);
267
- }
268
- }
269
- /**
270
- * Get file creation time
271
- */
272
- async getFileCreatedTime(relativePath) {
273
- try {
274
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
275
- const stats = await fs.stat(fullPath);
276
- return stats.birthtime;
277
- } catch (error) {
278
- return error instanceof Error ? error : new Error(`Failed to get file created time at ${relativePath}`);
279
- }
280
- }
281
- };
282
-
283
- // lib/modules/file-system/doc-file-system-write.ts
284
- import * as fs2 from "fs/promises";
285
- var DocFileSystemWrite = class {
286
- basePath;
287
- pathSystem;
288
- reader;
289
- constructor(props) {
290
- this.basePath = props.basePath;
291
- this.pathSystem = props.pathSystem ?? new DocPathSystem();
292
- this.reader = props.reader;
293
- }
294
- /**
295
- * Write content to file at the specified path (creates directory if needed)
296
- */
297
- async writeFile(relativePath, content) {
298
- try {
299
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
300
- const dirPath = this.pathSystem.dirname(fullPath);
301
- await fs2.mkdir(dirPath, { recursive: true });
302
- await fs2.writeFile(fullPath, content, "utf-8");
303
- return null;
304
- } catch (error) {
305
- return error instanceof Error ? error : new Error(`Failed to write file at ${relativePath}`);
306
- }
307
- }
308
- /**
309
- * Delete file at the specified path
310
- */
311
- async deleteFile(relativePath) {
312
- try {
313
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
314
- await fs2.unlink(fullPath);
315
- return null;
316
- } catch (error) {
317
- return new Error(`Failed to delete file at ${relativePath}: ${error}`);
318
- }
319
- }
320
- /**
321
- * Create directory
322
- */
323
- async createDirectory(relativePath) {
324
- try {
325
- const fullPath = this.pathSystem.join(this.basePath, relativePath);
326
- await fs2.mkdir(fullPath, { recursive: true });
327
- return null;
328
- } catch (error) {
329
- return error instanceof Error ? error : new Error(`Failed to create directory at ${relativePath}`);
330
- }
331
- }
332
- /**
333
- * Create directory if it doesn't exist
334
- */
335
- async ensureDirectoryExists(relativePath) {
336
- try {
337
- if (this.reader) {
338
- const exists = await this.reader.exists(relativePath);
339
- if (exists) {
340
- return null;
341
- }
342
- }
343
- const result = await this.createDirectory(relativePath);
344
- if (result instanceof Error) {
345
- return result;
346
- }
347
- return null;
348
- } catch (error) {
349
- return error instanceof Error ? error : new Error(`Failed to ensure directory exists at ${relativePath}`);
350
- }
351
- }
352
- /**
353
- * Copy file
354
- */
355
- async copyFile(sourcePath, destinationPath) {
356
- try {
357
- const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
358
- const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
359
- await fs2.copyFile(sourceFullPath, destFullPath);
360
- return null;
361
- } catch (error) {
362
- return error instanceof Error ? error : new Error(
363
- `Failed to copy file from ${sourcePath} to ${destinationPath}`
364
- );
365
- }
366
- }
367
- /**
368
- * Move file
369
- */
370
- async moveFile(sourcePath, destinationPath) {
371
- try {
372
- const sourceFullPath = this.pathSystem.join(this.basePath, sourcePath);
373
- const destFullPath = this.pathSystem.join(this.basePath, destinationPath);
374
- await fs2.rename(sourceFullPath, destFullPath);
375
- return null;
376
- } catch (error) {
377
- return error instanceof Error ? error : new Error(
378
- `Failed to move file from ${sourcePath} to ${destinationPath}`
379
- );
380
- }
381
- }
382
- };
383
-
384
123
  // lib/modules/file-system/doc-file-system.ts
385
124
  var DocFileSystem = class {
386
125
  reader;
@@ -390,15 +129,8 @@ var DocFileSystem = class {
390
129
  constructor(props) {
391
130
  this.basePath = props.basePath;
392
131
  this.pathSystem = props.pathSystem ?? new DocPathSystem();
393
- this.reader = props.reader ?? new DocFileSystemRead({
394
- basePath: this.basePath,
395
- pathSystem: this.pathSystem
396
- });
397
- this.writer = props.writer ?? new DocFileSystemWrite({
398
- basePath: this.basePath,
399
- pathSystem: this.pathSystem,
400
- reader: this.reader
401
- });
132
+ this.reader = props.reader;
133
+ this.writer = props.writer;
402
134
  }
403
135
  /**
404
136
  * Read file content at the specified path
@@ -490,8 +222,8 @@ var DocFileSystem = class {
490
222
  /**
491
223
  * Create directory
492
224
  */
493
- async createDirectory(relativePath) {
494
- return this.writer.createDirectory(relativePath);
225
+ async createEmptyDirectory(relativePath) {
226
+ return this.writer.createEmptyDirectory(relativePath);
495
227
  }
496
228
  /**
497
229
  * Get file size in bytes
@@ -502,8 +234,8 @@ var DocFileSystem = class {
502
234
  /**
503
235
  * Create directory if it doesn't exist
504
236
  */
505
- async ensureDirectoryExists(relativePath) {
506
- return this.writer.ensureDirectoryExists(relativePath);
237
+ async createDirectory(relativePath) {
238
+ return this.writer.createDirectory(relativePath);
507
239
  }
508
240
  /**
509
241
  * Copy file
@@ -520,8 +252,8 @@ var DocFileSystem = class {
520
252
  /**
521
253
  * Get file last modified time
522
254
  */
523
- async getFileModifiedTime(relativePath) {
524
- return this.reader.getFileModifiedTime(relativePath);
255
+ async getFileUpdatedTime(relativePath) {
256
+ return this.reader.getFileUpdatedTime(relativePath);
525
257
  }
526
258
  /**
527
259
  * Get file creation time
@@ -530,9 +262,6 @@ var DocFileSystem = class {
530
262
  return this.reader.getFileCreatedTime(relativePath);
531
263
  }
532
264
  };
533
-
534
- // lib/modules/file-system/doc-file-system-octokit-read.ts
535
- import { Octokit } from "@octokit/rest";
536
265
  var DocFileSystemOctokitRead = class {
537
266
  octokit;
538
267
  owner;
@@ -737,7 +466,7 @@ var DocFileSystemOctokitRead = class {
737
466
  /**
738
467
  * Get file last modified time
739
468
  */
740
- async getFileModifiedTime(relativePath) {
469
+ async getFileUpdatedTime(relativePath) {
741
470
  try {
742
471
  const commits = await this.octokit.repos.listCommits({
743
472
  owner: this.owner,
@@ -782,9 +511,6 @@ var DocFileSystemOctokitRead = class {
782
511
  return this.fileCache.get(fullPath)?.sha;
783
512
  }
784
513
  };
785
-
786
- // lib/modules/file-system/doc-file-system-octokit-write.ts
787
- import { Octokit as Octokit2 } from "@octokit/rest";
788
514
  var DocFileSystemOctokitWrite = class {
789
515
  octokit;
790
516
  owner;
@@ -799,7 +525,7 @@ var DocFileSystemOctokitWrite = class {
799
525
  this.basePath = props.basePath;
800
526
  this.branch = props.branch ?? "main";
801
527
  this.pathSystem = props.pathSystem ?? new DocPathSystem();
802
- this.octokit = new Octokit2({ auth: props.token });
528
+ this.octokit = new Octokit({ auth: props.token });
803
529
  this.reader = props.reader;
804
530
  Object.freeze(this);
805
531
  }
@@ -886,7 +612,7 @@ var DocFileSystemOctokitWrite = class {
886
612
  /**
887
613
  * Create directory by creating a .gitkeep file
888
614
  */
889
- async createDirectory(relativePath) {
615
+ async createEmptyDirectory(relativePath) {
890
616
  try {
891
617
  const gitkeepPath = this.pathSystem.join(relativePath, ".gitkeep");
892
618
  return await this.writeFile(gitkeepPath, "");
@@ -897,7 +623,7 @@ var DocFileSystemOctokitWrite = class {
897
623
  /**
898
624
  * Create directory if it doesn't exist
899
625
  */
900
- async ensureDirectoryExists(relativePath) {
626
+ async createDirectory(relativePath) {
901
627
  try {
902
628
  if (this.reader) {
903
629
  const exists = await this.reader.exists(relativePath);
@@ -905,7 +631,7 @@ var DocFileSystemOctokitWrite = class {
905
631
  return null;
906
632
  }
907
633
  }
908
- return await this.createDirectory(relativePath);
634
+ return await this.createEmptyDirectory(relativePath);
909
635
  } catch (error) {
910
636
  return error instanceof Error ? error : new Error(`Failed to ensure directory exists at ${relativePath}`);
911
637
  }
@@ -984,19 +710,6 @@ var DocFileSystemOctokit = class extends DocFileSystem {
984
710
  this.branch = props.branch ?? "main";
985
711
  Object.freeze(this);
986
712
  }
987
- /**
988
- * Get repository information
989
- */
990
- getRepositoryInfo() {
991
- return {
992
- owner: this.owner,
993
- repo: this.repo,
994
- branch: this.branch
995
- };
996
- }
997
- };
998
- export {
999
- DocFileSystemOctokit,
1000
- DocFileSystemOctokitRead,
1001
- DocFileSystemOctokitWrite
1002
713
  };
714
+
715
+ export { DocFileSystemOctokit, DocFileSystemOctokitRead, DocFileSystemOctokitWrite };
@@ -1,5 +1,7 @@
1
- import { b as DocFileSystemReadInterface, a as DocPathSystem, c as DocFileSystemWriteInterface } from './doc-file-system-BQAOBIO-.js';
2
- export { D as DocFileSystem, d as DocFileSystemInterface } from './doc-file-system-BQAOBIO-.js';
1
+ import { a as DocFileSystemReadInterface, b as DocFileSystemWriteInterface } from './doc-file-system-DEmPPJPE.js';
2
+ export { D as DocFileSystem } from './doc-file-system-DEmPPJPE.js';
3
+ import { a as DocPathSystem } from './doc-file-system.interface-C5vpYrOL.js';
4
+ export { D as DocFileSystemInterface } from './doc-file-system.interface-C5vpYrOL.js';
3
5
 
4
6
  type Props$1 = {
5
7
  basePath: string;
@@ -8,7 +10,7 @@ type Props$1 = {
8
10
  /**
9
11
  * Read-only file system implementation
10
12
  */
11
- declare class DocFileSystemRead implements DocFileSystemReadInterface {
13
+ declare class DocFileSystemNodeRead implements DocFileSystemReadInterface {
12
14
  protected readonly basePath: string;
13
15
  protected readonly pathSystem: DocPathSystem;
14
16
  constructor(props: Props$1);
@@ -68,7 +70,7 @@ declare class DocFileSystemRead implements DocFileSystemReadInterface {
68
70
  /**
69
71
  * Get file last modified time
70
72
  */
71
- getFileModifiedTime(relativePath: string): Promise<Date | Error>;
73
+ getFileUpdatedTime(relativePath: string): Promise<Date | Error>;
72
74
  /**
73
75
  * Get file creation time
74
76
  */
@@ -83,7 +85,7 @@ type Props = {
83
85
  /**
84
86
  * Write-only file system implementation
85
87
  */
86
- declare class DocFileSystemWrite implements DocFileSystemWriteInterface {
88
+ declare class DocFileSystemNodeWrite implements DocFileSystemWriteInterface {
87
89
  protected readonly basePath: string;
88
90
  protected readonly pathSystem: DocPathSystem;
89
91
  private readonly reader?;
@@ -99,11 +101,11 @@ declare class DocFileSystemWrite implements DocFileSystemWriteInterface {
99
101
  /**
100
102
  * Create directory
101
103
  */
102
- createDirectory(relativePath: string): Promise<Error | null>;
104
+ createEmptyDirectory(relativePath: string): Promise<Error | null>;
103
105
  /**
104
106
  * Create directory if it doesn't exist
105
107
  */
106
- ensureDirectoryExists(relativePath: string): Promise<Error | null>;
108
+ createDirectory(relativePath: string): Promise<Error | null>;
107
109
  /**
108
110
  * Copy file
109
111
  */
@@ -114,4 +116,4 @@ declare class DocFileSystemWrite implements DocFileSystemWriteInterface {
114
116
  moveFile(sourcePath: string, destinationPath: string): Promise<Error | null>;
115
117
  }
116
118
 
117
- export { DocFileSystemRead, DocFileSystemWrite };
119
+ export { DocFileSystemNodeRead as DocFileSystemRead, DocFileSystemNodeWrite as DocFileSystemWrite };