@interactive-inc/docs-client 1.1.2 → 2.0.0

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.
@@ -3,8 +3,13 @@ import { z } from 'zod';
3
3
  // lib/modules/file-system/doc-file-system-json.ts
4
4
 
5
5
  // lib/modules/path-system/doc-path-system.ts
6
- var DocPathSystem = class {
6
+ var DocPathSystem = class _DocPathSystem {
7
7
  separator = "/";
8
+ constructor() {
9
+ if (new.target === _DocPathSystem) {
10
+ Object.freeze(this);
11
+ }
12
+ }
8
13
  /**
9
14
  * Join paths
10
15
  */
@@ -60,8 +65,8 @@ var DocPathSystem = class {
60
65
  * Calculate relative path
61
66
  */
62
67
  relative(from, to) {
63
- const fromSegments = from.split(this.separator).filter(Boolean);
64
- const toSegments = to.split(this.separator).filter(Boolean);
68
+ const fromSegments = from.split(this.separator).filter((s) => s !== "" && s !== ".");
69
+ const toSegments = to.split(this.separator).filter((s) => s !== "" && s !== ".");
65
70
  let commonLength = 0;
66
71
  for (let i = 0; i < Math.min(fromSegments.length, toSegments.length); i++) {
67
72
  if (fromSegments[i] === toSegments[i]) {
@@ -264,24 +269,14 @@ var DocFileSystem = class {
264
269
  return this.reader.getFileCreatedTime(relativePath);
265
270
  }
266
271
  };
267
- var zJsonDocumentData = z.record(z.string(), z.string());
268
- function parseJsonDocumentData(data) {
269
- try {
270
- return zJsonDocumentData.parse(data);
271
- } catch (error) {
272
- return error instanceof Error ? error : new Error("Failed to parse JSON document data");
273
- }
274
- }
272
+
273
+ // lib/modules/file-system/doc-file-system-json-read.ts
275
274
  var DocFileSystemJsonRead = class {
276
- data;
275
+ store;
277
276
  basePath;
278
277
  pathSystem;
279
278
  constructor(props) {
280
- const parsed = parseJsonDocumentData(props.data);
281
- if (parsed instanceof Error) {
282
- throw parsed;
283
- }
284
- this.data = parsed;
279
+ this.store = props.store;
285
280
  this.basePath = props.basePath ?? "docs";
286
281
  this.pathSystem = props.pathSystem ?? new DocPathSystem();
287
282
  Object.freeze(this);
@@ -292,7 +287,7 @@ var DocFileSystemJsonRead = class {
292
287
  async readFile(relativePath) {
293
288
  try {
294
289
  const normalizedPath = this.normalizePath(relativePath);
295
- const content = this.data[normalizedPath];
290
+ const content = this.store.get(normalizedPath);
296
291
  return content ?? null;
297
292
  } catch (error) {
298
293
  return error instanceof Error ? error : new Error(`Failed to read file at ${relativePath}`);
@@ -323,12 +318,9 @@ var DocFileSystemJsonRead = class {
323
318
  try {
324
319
  const normalizedDir = this.normalizePath(relativePath);
325
320
  const fileNames = /* @__PURE__ */ new Set();
326
- for (const filePath of Object.keys(this.data)) {
321
+ for (const filePath of this.store.keys()) {
327
322
  if (this.isFileInDirectory(filePath, normalizedDir)) {
328
- const relativePart = this.getRelativePartFromDirectory(
329
- filePath,
330
- normalizedDir
331
- );
323
+ const relativePart = this.getRelativePartFromDirectory(filePath, normalizedDir);
332
324
  const segments = relativePart.split("/").filter(Boolean);
333
325
  if (segments.length > 0) {
334
326
  fileNames.add(segments[0]);
@@ -349,9 +341,7 @@ var DocFileSystemJsonRead = class {
349
341
  if (fileNames instanceof Error) {
350
342
  return fileNames;
351
343
  }
352
- return fileNames.map(
353
- (fileName) => this.pathSystem.join(relativePath, fileName)
354
- );
344
+ return fileNames.map((fileName) => this.pathSystem.join(relativePath, fileName));
355
345
  } catch (error) {
356
346
  return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
357
347
  }
@@ -362,7 +352,7 @@ var DocFileSystemJsonRead = class {
362
352
  async isDirectory(relativePath) {
363
353
  try {
364
354
  const normalizedPath = this.normalizePath(relativePath);
365
- for (const filePath of Object.keys(this.data)) {
355
+ for (const filePath of this.store.keys()) {
366
356
  if (filePath.startsWith(`${normalizedPath}/`)) {
367
357
  return true;
368
358
  }
@@ -378,7 +368,7 @@ var DocFileSystemJsonRead = class {
378
368
  async isFile(relativePath) {
379
369
  try {
380
370
  const normalizedPath = this.normalizePath(relativePath);
381
- return normalizedPath in this.data;
371
+ return this.store.has(normalizedPath);
382
372
  } catch {
383
373
  return false;
384
374
  }
@@ -449,13 +439,13 @@ var DocFileSystemJsonRead = class {
449
439
  * Get all file paths in the JSON data
450
440
  */
451
441
  getAllFilePaths() {
452
- return Object.keys(this.data);
442
+ return this.store.keys();
453
443
  }
454
444
  /**
455
445
  * Get the raw JSON data
456
446
  */
457
447
  getRawData() {
458
- return { ...this.data };
448
+ return this.store.toData();
459
449
  }
460
450
  /**
461
451
  * Normalize path by removing leading/trailing slashes
@@ -485,29 +475,99 @@ var DocFileSystemJsonRead = class {
485
475
  return "";
486
476
  }
487
477
  };
488
- var zJsonDocumentData2 = z.record(z.string(), z.string());
489
- function parseJsonDocumentData2(data) {
478
+ var zJsonDocumentData = z.record(z.string(), z.string());
479
+ function parseJsonDocumentData(data) {
490
480
  try {
491
- return zJsonDocumentData2.parse(data);
481
+ return zJsonDocumentData.parse(data);
492
482
  } catch (error) {
493
483
  return error instanceof Error ? error : new Error("Failed to parse JSON document data");
494
484
  }
495
485
  }
496
- var DocFileSystemJsonWrite = class {
497
- data;
498
- pathSystem;
499
- reader;
500
- onDataChange;
486
+ var DocFileSystemJsonStore = class {
487
+ documents;
501
488
  constructor(props = {}) {
502
489
  if (props.data !== void 0) {
503
- const parsed = parseJsonDocumentData2(props.data);
490
+ const parsed = parseJsonDocumentData(props.data);
504
491
  if (parsed instanceof Error) {
505
492
  throw parsed;
506
493
  }
507
- this.data = parsed;
494
+ this.documents = parsed;
508
495
  } else {
509
- this.data = {};
496
+ this.documents = {};
497
+ }
498
+ }
499
+ /**
500
+ * 指定パスのドキュメント内容を取得する
501
+ */
502
+ get(path) {
503
+ return this.documents[path];
504
+ }
505
+ /**
506
+ * 指定パスにドキュメント内容を書き込む
507
+ */
508
+ set(path, content) {
509
+ this.documents[path] = content;
510
+ }
511
+ /**
512
+ * 指定パスを削除する。存在すれば true を返す
513
+ */
514
+ delete(path) {
515
+ if (!(path in this.documents)) {
516
+ return false;
517
+ }
518
+ const nextDocuments = {};
519
+ for (const key of Object.keys(this.documents)) {
520
+ if (key !== path) {
521
+ nextDocuments[key] = this.documents[key];
522
+ }
510
523
  }
524
+ this.documents = nextDocuments;
525
+ return true;
526
+ }
527
+ /**
528
+ * 指定パスが存在するかを返す
529
+ */
530
+ has(path) {
531
+ return path in this.documents;
532
+ }
533
+ /**
534
+ * 全ドキュメントのパス一覧を返す
535
+ */
536
+ keys() {
537
+ return Object.keys(this.documents);
538
+ }
539
+ /**
540
+ * データ全体を入れ替える
541
+ */
542
+ replace(data) {
543
+ const parsed = parseJsonDocumentData(data);
544
+ if (parsed instanceof Error) {
545
+ return parsed;
546
+ }
547
+ this.documents = parsed;
548
+ return null;
549
+ }
550
+ /**
551
+ * 全データを削除する
552
+ */
553
+ clear() {
554
+ this.documents = {};
555
+ }
556
+ /**
557
+ * 現在のデータの読み取り専用コピーを返す
558
+ */
559
+ toData() {
560
+ return { ...this.documents };
561
+ }
562
+ };
563
+ z.record(z.string(), z.string());
564
+ var DocFileSystemJsonWrite = class {
565
+ store;
566
+ pathSystem;
567
+ reader;
568
+ onDataChange;
569
+ constructor(props) {
570
+ this.store = props.store;
511
571
  this.pathSystem = props.pathSystem ?? new DocPathSystem();
512
572
  this.reader = props.reader;
513
573
  this.onDataChange = props.onDataChange;
@@ -518,7 +578,7 @@ var DocFileSystemJsonWrite = class {
518
578
  async writeFile(relativePath, content) {
519
579
  try {
520
580
  const normalizedPath = this.normalizePath(relativePath);
521
- this.data[normalizedPath] = content;
581
+ this.store.set(normalizedPath, content);
522
582
  this.notifyDataChange();
523
583
  return null;
524
584
  } catch (error) {
@@ -531,10 +591,10 @@ var DocFileSystemJsonWrite = class {
531
591
  async deleteFile(relativePath) {
532
592
  try {
533
593
  const normalizedPath = this.normalizePath(relativePath);
534
- if (!(normalizedPath in this.data)) {
594
+ const deleted = this.store.delete(normalizedPath);
595
+ if (!deleted) {
535
596
  return new Error(`File not found: ${relativePath}`);
536
597
  }
537
- delete this.data[normalizedPath];
538
598
  this.notifyDataChange();
539
599
  return null;
540
600
  } catch (error) {
@@ -549,7 +609,7 @@ var DocFileSystemJsonWrite = class {
549
609
  const normalizedPath = this.normalizePath(relativePath);
550
610
  const gitkeepPath = this.pathSystem.join(normalizedPath, ".gitkeep");
551
611
  const normalizedGitkeepPath = this.normalizePath(gitkeepPath);
552
- this.data[normalizedGitkeepPath] = "";
612
+ this.store.set(normalizedGitkeepPath, "");
553
613
  this.notifyDataChange();
554
614
  return null;
555
615
  } catch (error) {
@@ -591,19 +651,18 @@ var DocFileSystemJsonWrite = class {
591
651
  if (content === null) {
592
652
  return new Error(`Source file not found: ${sourcePath}`);
593
653
  }
594
- this.data[normalizedDestPath] = content;
654
+ this.store.set(normalizedDestPath, content);
595
655
  } else {
596
- if (!(normalizedSourcePath in this.data)) {
656
+ const sourceContent = this.store.get(normalizedSourcePath);
657
+ if (sourceContent === void 0) {
597
658
  return new Error(`Source file not found: ${sourcePath}`);
598
659
  }
599
- this.data[normalizedDestPath] = this.data[normalizedSourcePath];
660
+ this.store.set(normalizedDestPath, sourceContent);
600
661
  }
601
662
  this.notifyDataChange();
602
663
  return null;
603
664
  } catch (error) {
604
- return error instanceof Error ? error : new Error(
605
- `Failed to copy file from ${sourcePath} to ${destinationPath}`
606
- );
665
+ return error instanceof Error ? error : new Error(`Failed to copy file from ${sourcePath} to ${destinationPath}`);
607
666
  }
608
667
  }
609
668
  /**
@@ -617,27 +676,24 @@ var DocFileSystemJsonWrite = class {
617
676
  }
618
677
  return await this.deleteFile(sourcePath);
619
678
  } catch (error) {
620
- return error instanceof Error ? error : new Error(
621
- `Failed to move file from ${sourcePath} to ${destinationPath}`
622
- );
679
+ return error instanceof Error ? error : new Error(`Failed to move file from ${sourcePath} to ${destinationPath}`);
623
680
  }
624
681
  }
625
682
  /**
626
683
  * Get the current JSON data
627
684
  */
628
685
  getData() {
629
- return { ...this.data };
686
+ return this.store.toData();
630
687
  }
631
688
  /**
632
689
  * Update the entire JSON data
633
690
  */
634
691
  setData(data) {
635
692
  try {
636
- const parsed = parseJsonDocumentData2(data);
637
- if (parsed instanceof Error) {
638
- return parsed;
693
+ const result = this.store.replace(data);
694
+ if (result instanceof Error) {
695
+ return result;
639
696
  }
640
- this.data = parsed;
641
697
  this.notifyDataChange();
642
698
  return null;
643
699
  } catch (error) {
@@ -648,14 +704,14 @@ var DocFileSystemJsonWrite = class {
648
704
  * Clear all data
649
705
  */
650
706
  clear() {
651
- this.data = {};
707
+ this.store.clear();
652
708
  this.notifyDataChange();
653
709
  }
654
710
  /**
655
711
  * Get all file paths in the JSON data
656
712
  */
657
713
  getAllFilePaths() {
658
- return Object.keys(this.data);
714
+ return this.store.keys();
659
715
  }
660
716
  /**
661
717
  * Normalize path by removing leading/trailing slashes
@@ -668,7 +724,7 @@ var DocFileSystemJsonWrite = class {
668
724
  */
669
725
  async directoryExistsInData(relativePath) {
670
726
  const normalizedPath = this.normalizePath(relativePath);
671
- for (const filePath of Object.keys(this.data)) {
727
+ for (const filePath of this.store.keys()) {
672
728
  if (filePath.startsWith(`${normalizedPath}/`)) {
673
729
  return true;
674
730
  }
@@ -680,7 +736,7 @@ var DocFileSystemJsonWrite = class {
680
736
  */
681
737
  notifyDataChange() {
682
738
  if (this.onDataChange) {
683
- this.onDataChange({ ...this.data });
739
+ this.onDataChange(this.store.toData());
684
740
  }
685
741
  }
686
742
  };
@@ -691,13 +747,14 @@ var DocFileSystemJson = class _DocFileSystemJson extends DocFileSystem {
691
747
  jsonReader;
692
748
  jsonWriter;
693
749
  constructor(props = {}) {
750
+ const store = new DocFileSystemJsonStore({ data: props.data });
694
751
  const reader = new DocFileSystemJsonRead({
695
- data: props.data,
752
+ store,
696
753
  basePath: props.basePath,
697
754
  pathSystem: props.pathSystem
698
755
  });
699
756
  const writer = new DocFileSystemJsonWrite({
700
- data: props.data,
757
+ store,
701
758
  pathSystem: props.pathSystem,
702
759
  reader,
703
760
  onDataChange: props.onDataChange
@@ -1,4 +1,4 @@
1
- import { D as DocFileSystemInterface, a as DocPathSystem } from './doc-file-system.interface-C5vpYrOL.js';
1
+ import { D as DocFileSystemInterface, a as DocPathSystem } from './doc-file-system.interface-CmQywbuP.js';
2
2
 
3
3
  /**
4
4
  * In-memory file system for testing
@@ -1,6 +1,11 @@
1
1
  // lib/modules/path-system/doc-path-system.ts
2
- var DocPathSystem = class {
2
+ var DocPathSystem = class _DocPathSystem {
3
3
  separator = "/";
4
+ constructor() {
5
+ if (new.target === _DocPathSystem) {
6
+ Object.freeze(this);
7
+ }
8
+ }
4
9
  /**
5
10
  * Join paths
6
11
  */
@@ -56,8 +61,8 @@ var DocPathSystem = class {
56
61
  * Calculate relative path
57
62
  */
58
63
  relative(from, to) {
59
- const fromSegments = from.split(this.separator).filter(Boolean);
60
- const toSegments = to.split(this.separator).filter(Boolean);
64
+ const fromSegments = from.split(this.separator).filter((s) => s !== "" && s !== ".");
65
+ const toSegments = to.split(this.separator).filter((s) => s !== "" && s !== ".");
61
66
  let commonLength = 0;
62
67
  for (let i = 0; i < Math.min(fromSegments.length, toSegments.length); i++) {
63
68
  if (fromSegments[i] === toSegments[i]) {
@@ -1,5 +1,5 @@
1
- import { a as DocPathSystem } from './doc-file-system.interface-C5vpYrOL.js';
2
- import { D as DocFileSystem } from './doc-file-system-DEmPPJPE.js';
1
+ import { a as DocPathSystem } from './doc-file-system.interface-CmQywbuP.js';
2
+ import { D as DocFileSystem } from './doc-file-system-z2sEMkq0.js';
3
3
  export { DocFileSystemRead as DocFileSystemNodeRead, DocFileSystemWrite as DocFileSystemNodeWrite } from './file-system.js';
4
4
 
5
5
  type Props = {
@@ -1,8 +1,13 @@
1
1
  import * as fs from 'fs/promises';
2
2
 
3
3
  // lib/modules/path-system/doc-path-system.ts
4
- var DocPathSystem = class {
4
+ var DocPathSystem = class _DocPathSystem {
5
5
  separator = "/";
6
+ constructor() {
7
+ if (new.target === _DocPathSystem) {
8
+ Object.freeze(this);
9
+ }
10
+ }
6
11
  /**
7
12
  * Join paths
8
13
  */
@@ -58,8 +63,8 @@ var DocPathSystem = class {
58
63
  * Calculate relative path
59
64
  */
60
65
  relative(from, to) {
61
- const fromSegments = from.split(this.separator).filter(Boolean);
62
- const toSegments = to.split(this.separator).filter(Boolean);
66
+ const fromSegments = from.split(this.separator).filter((s) => s !== "" && s !== ".");
67
+ const toSegments = to.split(this.separator).filter((s) => s !== "" && s !== ".");
63
68
  let commonLength = 0;
64
69
  for (let i = 0; i < Math.min(fromSegments.length, toSegments.length); i++) {
65
70
  if (fromSegments[i] === toSegments[i]) {
@@ -268,6 +273,7 @@ var DocFileSystemNodeRead = class {
268
273
  constructor(props) {
269
274
  this.basePath = props.basePath;
270
275
  this.pathSystem = props.pathSystem ?? new DocPathSystem();
276
+ Object.freeze(this);
271
277
  }
272
278
  /**
273
279
  * Read file content at the specified path
@@ -317,9 +323,7 @@ var DocFileSystemNodeRead = class {
317
323
  if (fileNames instanceof Error) {
318
324
  return fileNames;
319
325
  }
320
- return fileNames.map(
321
- (fileName) => this.pathSystem.join(relativePath, fileName)
322
- );
326
+ return fileNames.map((fileName) => this.pathSystem.join(relativePath, fileName));
323
327
  } catch (error) {
324
328
  return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
325
329
  }
@@ -429,6 +433,7 @@ var DocFileSystemNodeWrite = class {
429
433
  this.basePath = props.basePath;
430
434
  this.pathSystem = props.pathSystem ?? new DocPathSystem();
431
435
  this.reader = props.reader;
436
+ Object.freeze(this);
432
437
  }
433
438
  /**
434
439
  * Write content to file at the specified path (creates directory if needed)
@@ -498,9 +503,7 @@ var DocFileSystemNodeWrite = class {
498
503
  await fs.copyFile(sourceFullPath, destFullPath);
499
504
  return null;
500
505
  } catch (error) {
501
- return error instanceof Error ? error : new Error(
502
- `Failed to copy file from ${sourcePath} to ${destinationPath}`
503
- );
506
+ return error instanceof Error ? error : new Error(`Failed to copy file from ${sourcePath} to ${destinationPath}`);
504
507
  }
505
508
  }
506
509
  /**
@@ -513,9 +516,7 @@ var DocFileSystemNodeWrite = class {
513
516
  await fs.rename(sourceFullPath, destFullPath);
514
517
  return null;
515
518
  } catch (error) {
516
- return error instanceof Error ? error : new Error(
517
- `Failed to move file from ${sourcePath} to ${destinationPath}`
518
- );
519
+ return error instanceof Error ? error : new Error(`Failed to move file from ${sourcePath} to ${destinationPath}`);
519
520
  }
520
521
  }
521
522
  };
@@ -538,6 +539,7 @@ var DocFileSystemNode = class extends DocFileSystem {
538
539
  reader,
539
540
  writer
540
541
  });
542
+ Object.freeze(this);
541
543
  }
542
544
  };
543
545
 
@@ -1,5 +1,5 @@
1
- import { a as DocPathSystem } from './doc-file-system.interface-C5vpYrOL.js';
2
- import { D as DocFileSystem, a as DocFileSystemReadInterface, b as DocFileSystemWriteInterface } from './doc-file-system-DEmPPJPE.js';
1
+ import { a as DocPathSystem } from './doc-file-system.interface-CmQywbuP.js';
2
+ import { D as DocFileSystem, a as DocFileSystemReadInterface, b as DocFileSystemWriteInterface } from './doc-file-system-z2sEMkq0.js';
3
3
  import { Octokit } from '@octokit/rest';
4
4
 
5
5
  type GitHubProps = {
@@ -137,6 +137,11 @@ declare class DocFileSystemOctokitWrite implements DocFileSystemWriteInterface {
137
137
  private readonly pathSystem;
138
138
  private readonly reader?;
139
139
  constructor(props: Props);
140
+ /**
141
+ * Check if reader exposes a SHA cache (OctokitRead instance)
142
+ */
143
+ private hasShaCache;
144
+ private cachedSha;
140
145
  /**
141
146
  * Write content to file in GitHub repository
142
147
  */
@@ -1,8 +1,13 @@
1
1
  import { Octokit } from '@octokit/rest';
2
2
 
3
3
  // lib/modules/path-system/doc-path-system.ts
4
- var DocPathSystem = class {
4
+ var DocPathSystem = class _DocPathSystem {
5
5
  separator = "/";
6
+ constructor() {
7
+ if (new.target === _DocPathSystem) {
8
+ Object.freeze(this);
9
+ }
10
+ }
6
11
  /**
7
12
  * Join paths
8
13
  */
@@ -58,8 +63,8 @@ var DocPathSystem = class {
58
63
  * Calculate relative path
59
64
  */
60
65
  relative(from, to) {
61
- const fromSegments = from.split(this.separator).filter(Boolean);
62
- const toSegments = to.split(this.separator).filter(Boolean);
66
+ const fromSegments = from.split(this.separator).filter((s) => s !== "" && s !== ".");
67
+ const toSegments = to.split(this.separator).filter((s) => s !== "" && s !== ".");
63
68
  let commonLength = 0;
64
69
  for (let i = 0; i < Math.min(fromSegments.length, toSegments.length); i++) {
65
70
  if (fromSegments[i] === toSegments[i]) {
@@ -292,9 +297,7 @@ var DocFileSystemOctokitRead = class {
292
297
  ref: this.branch
293
298
  });
294
299
  if ("type" in response.data && response.data.type === "file") {
295
- const content = Buffer.from(response.data.content, "base64").toString(
296
- "utf-8"
297
- );
300
+ const content = Buffer.from(response.data.content, "base64").toString("utf-8");
298
301
  this.fileCache.set(fullPath, {
299
302
  sha: response.data.sha,
300
303
  content,
@@ -357,9 +360,7 @@ var DocFileSystemOctokitRead = class {
357
360
  if (fileNames instanceof Error) {
358
361
  return fileNames;
359
362
  }
360
- return fileNames.map(
361
- (fileName) => this.pathSystem.join(relativePath, fileName)
362
- );
363
+ return fileNames.map((fileName) => this.pathSystem.join(relativePath, fileName));
363
364
  } catch (error) {
364
365
  return error instanceof Error ? error : new Error(`Failed to read directory file paths at ${relativePath}`);
365
366
  }
@@ -468,10 +469,11 @@ var DocFileSystemOctokitRead = class {
468
469
  */
469
470
  async getFileUpdatedTime(relativePath) {
470
471
  try {
472
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
471
473
  const commits = await this.octokit.repos.listCommits({
472
474
  owner: this.owner,
473
475
  repo: this.repo,
474
- path: relativePath,
476
+ path: fullPath,
475
477
  sha: this.branch,
476
478
  per_page: 1
477
479
  });
@@ -488,15 +490,23 @@ var DocFileSystemOctokitRead = class {
488
490
  */
489
491
  async getFileCreatedTime(relativePath) {
490
492
  try {
491
- const commits = await this.octokit.repos.listCommits({
493
+ const fullPath = this.pathSystem.join(this.basePath, relativePath);
494
+ const iterator = this.octokit.paginate.iterator(this.octokit.repos.listCommits, {
492
495
  owner: this.owner,
493
496
  repo: this.repo,
494
- path: relativePath,
495
- sha: this.branch
497
+ path: fullPath,
498
+ sha: this.branch,
499
+ per_page: 100
496
500
  });
497
- const lastCommit = commits.data[commits.data.length - 1];
498
- if (lastCommit?.commit.author?.date) {
499
- return new Date(lastCommit.commit.author.date);
501
+ let oldestDate;
502
+ for await (const response of iterator) {
503
+ const lastInPage = response.data[response.data.length - 1];
504
+ if (lastInPage?.commit.author?.date) {
505
+ oldestDate = lastInPage.commit.author.date;
506
+ }
507
+ }
508
+ if (oldestDate) {
509
+ return new Date(oldestDate);
500
510
  }
501
511
  return new Error(`No commits found for ${relativePath}`);
502
512
  } catch (error) {
@@ -529,6 +539,18 @@ var DocFileSystemOctokitWrite = class {
529
539
  this.reader = props.reader;
530
540
  Object.freeze(this);
531
541
  }
542
+ /**
543
+ * Check if reader exposes a SHA cache (OctokitRead instance)
544
+ */
545
+ hasShaCache(reader) {
546
+ return "getCachedSha" in reader;
547
+ }
548
+ cachedSha(relativePath) {
549
+ if (this.reader && this.hasShaCache(this.reader)) {
550
+ return this.reader.getCachedSha(relativePath);
551
+ }
552
+ return void 0;
553
+ }
532
554
  /**
533
555
  * Write content to file in GitHub repository
534
556
  */
@@ -536,12 +558,7 @@ var DocFileSystemOctokitWrite = class {
536
558
  try {
537
559
  const fullPath = this.pathSystem.join(this.basePath, relativePath);
538
560
  const encodedContent = Buffer.from(content).toString("base64");
539
- let sha;
540
- if (this.reader && "getCachedSha" in this.reader) {
541
- sha = this.reader.getCachedSha(
542
- relativePath
543
- );
544
- }
561
+ let sha = this.cachedSha(relativePath);
545
562
  if (!sha) {
546
563
  try {
547
564
  const existing = await this.octokit.repos.getContent({
@@ -576,12 +593,7 @@ var DocFileSystemOctokitWrite = class {
576
593
  async deleteFile(relativePath) {
577
594
  try {
578
595
  const fullPath = this.pathSystem.join(this.basePath, relativePath);
579
- let sha;
580
- if (this.reader && "getCachedSha" in this.reader) {
581
- sha = this.reader.getCachedSha(
582
- relativePath
583
- );
584
- }
596
+ let sha = this.cachedSha(relativePath);
585
597
  if (!sha) {
586
598
  const existing = await this.octokit.repos.getContent({
587
599
  owner: this.owner,
@@ -653,9 +665,7 @@ var DocFileSystemOctokitWrite = class {
653
665
  }
654
666
  return await this.writeFile(destinationPath, content);
655
667
  } catch (error) {
656
- return error instanceof Error ? error : new Error(
657
- `Failed to copy file from ${sourcePath} to ${destinationPath}`
658
- );
668
+ return error instanceof Error ? error : new Error(`Failed to copy file from ${sourcePath} to ${destinationPath}`);
659
669
  }
660
670
  }
661
671
  /**
@@ -669,9 +679,7 @@ var DocFileSystemOctokitWrite = class {
669
679
  }
670
680
  return await this.deleteFile(sourcePath);
671
681
  } catch (error) {
672
- return error instanceof Error ? error : new Error(
673
- `Failed to move file from ${sourcePath} to ${destinationPath}`
674
- );
682
+ return error instanceof Error ? error : new Error(`Failed to move file from ${sourcePath} to ${destinationPath}`);
675
683
  }
676
684
  }
677
685
  };
@@ -1,7 +1,7 @@
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';
1
+ import { a as DocFileSystemReadInterface, b as DocFileSystemWriteInterface } from './doc-file-system-z2sEMkq0.js';
2
+ export { D as DocFileSystem } from './doc-file-system-z2sEMkq0.js';
3
+ import { a as DocPathSystem } from './doc-file-system.interface-CmQywbuP.js';
4
+ export { D as DocFileSystemInterface } from './doc-file-system.interface-CmQywbuP.js';
5
5
 
6
6
  type Props$1 = {
7
7
  basePath: string;