@gravito/constellation 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -205,6 +205,7 @@ interface SitemapStorage {
205
205
  * @returns The XML content as a string, or null if not found.
206
206
  */
207
207
  read(filename: string): Promise<string | null>;
208
+ readStream?(filename: string): Promise<AsyncIterable<string> | null>;
208
209
  /**
209
210
  * Check if a sitemap file exists in storage.
210
211
  *
@@ -441,6 +442,33 @@ interface RedirectRule {
441
442
  /** Timestamp when the redirect rule was created. */
442
443
  createdAt?: Date;
443
444
  }
445
+ /**
446
+ * Represents a manifest file that tracks URL-to-shard mappings.
447
+ *
448
+ * @public
449
+ * @since 3.0.1
450
+ */
451
+ interface ShardManifest {
452
+ version: number;
453
+ generatedAt: Date | string;
454
+ baseUrl: string;
455
+ maxEntriesPerShard: number;
456
+ sort: string;
457
+ shards: ShardInfo[];
458
+ }
459
+ /**
460
+ * Metadata about a single sitemap shard.
461
+ *
462
+ * @public
463
+ * @since 3.0.1
464
+ */
465
+ interface ShardInfo {
466
+ filename: string;
467
+ from: string;
468
+ to: string;
469
+ count: number;
470
+ lastmod: Date | string;
471
+ }
444
472
  /**
445
473
  * Manager for registering and resolving redirect rules.
446
474
  *
@@ -505,6 +533,7 @@ interface MemoryChangeTrackerOptions {
505
533
  */
506
534
  declare class MemoryChangeTracker implements ChangeTracker {
507
535
  private changes;
536
+ private urlIndex;
508
537
  private maxChanges;
509
538
  constructor(options?: MemoryChangeTrackerOptions);
510
539
  track(change: SitemapChange): Promise<void>;
@@ -650,6 +679,7 @@ declare class ShadowProcessor {
650
679
  private options;
651
680
  private shadowId;
652
681
  private operations;
682
+ private mutex;
653
683
  constructor(options: ShadowProcessorOptions);
654
684
  /**
655
685
  * 添加一個影子操作
@@ -688,6 +718,8 @@ interface SitemapGeneratorOptions extends SitemapStreamOptions {
688
718
  maxEntriesPerFile?: number;
689
719
  /** The name of the main sitemap or sitemap index file. @default 'sitemap.xml' */
690
720
  filename?: string;
721
+ /** Whether to generate a shard manifest file. @default false */
722
+ generateManifest?: boolean;
691
723
  /** Configuration for staging files before atomic deployment. */
692
724
  shadow?: {
693
725
  /** Whether shadow processing is enabled. */
@@ -727,71 +759,34 @@ declare class SitemapGenerator {
727
759
  private shadowProcessor;
728
760
  constructor(options: SitemapGeneratorOptions);
729
761
  run(): Promise<void>;
762
+ private normalizeUrl;
730
763
  /**
731
764
  * 獲取影子處理器(如果啟用)
732
765
  */
733
766
  getShadowProcessor(): ShadowProcessor | null;
734
767
  }
735
768
 
736
- /**
737
- * Options for configuring the `IncrementalGenerator`.
738
- *
739
- * Extends `SitemapGeneratorOptions` to include change tracking and difference
740
- * calculation components.
741
- *
742
- * @public
743
- * @since 3.0.0
744
- */
745
769
  interface IncrementalGeneratorOptions extends SitemapGeneratorOptions {
746
- /** The change tracker used to store and retrieve sitemap changes. */
747
770
  changeTracker: ChangeTracker;
748
- /** Optional difference calculator. Defaults to a new `DiffCalculator` instance. */
749
771
  diffCalculator?: DiffCalculator;
750
- /** Whether to automatically track changes during full generation. @default true */
751
772
  autoTrack?: boolean;
752
773
  }
753
- /**
754
- * IncrementalGenerator optimizes sitemap updates by processing only changed URLs.
755
- *
756
- * Instead of regenerating the entire sitemap from scratch, it uses a `ChangeTracker`
757
- * to identify new, updated, or removed URLs and updates the sitemap incrementally.
758
- *
759
- * @public
760
- * @since 3.0.0
761
- */
762
774
  declare class IncrementalGenerator {
763
775
  private options;
764
776
  private changeTracker;
765
777
  private diffCalculator;
766
778
  private generator;
779
+ private mutex;
767
780
  constructor(options: IncrementalGeneratorOptions);
768
- /**
769
- * 生成完整的 sitemap(首次生成)
770
- */
771
781
  generateFull(): Promise<void>;
772
- /**
773
- * 增量生成(只更新變更的部分)
774
- */
775
782
  generateIncremental(since?: Date): Promise<void>;
776
- /**
777
- * 手動追蹤變更
778
- */
779
- trackChange(change: SitemapChange): Promise<void>;
780
- /**
781
- * 獲取變更記錄
782
- */
783
- getChanges(since?: Date): Promise<SitemapChange[]>;
784
- /**
785
- * 載入基礎 entries(從現有 sitemap)
786
- */
787
- private loadBaseEntries;
788
- /**
789
- * 生成差異部分
790
- */
791
- private generateDiff;
792
- /**
793
- * 將 AsyncIterable 轉換為陣列
794
- */
783
+ private performFullGeneration;
784
+ private performIncrementalGeneration;
785
+ private normalizeUrl;
786
+ private loadManifest;
787
+ private getAffectedShards;
788
+ private updateShards;
789
+ private applyChanges;
795
790
  private toArray;
796
791
  }
797
792
 
@@ -902,16 +897,14 @@ declare class SitemapIndex {
902
897
  declare class SitemapStream {
903
898
  private options;
904
899
  private entries;
900
+ private flags;
905
901
  constructor(options: SitemapStreamOptions);
906
902
  add(entry: string | SitemapEntry): this;
907
903
  addAll(entries: (string | SitemapEntry)[]): this;
908
904
  toXML(): string;
909
905
  private renderUrl;
910
- private hasImages;
911
- private hasVideos;
912
- private hasNews;
913
- private hasAlternates;
914
906
  private escape;
907
+ getEntries(): SitemapEntry[];
915
908
  }
916
909
 
917
910
  /**
@@ -1484,6 +1477,7 @@ declare class DiskSitemapStorage implements SitemapStorage {
1484
1477
  constructor(outDir: string, baseUrl: string);
1485
1478
  write(filename: string, content: string): Promise<void>;
1486
1479
  read(filename: string): Promise<string | null>;
1480
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1487
1481
  exists(filename: string): Promise<boolean>;
1488
1482
  getUrl(filename: string): string;
1489
1483
  }
@@ -1544,6 +1538,7 @@ declare class GCPSitemapStorage implements SitemapStorage {
1544
1538
  private getKey;
1545
1539
  write(filename: string, content: string): Promise<void>;
1546
1540
  read(filename: string): Promise<string | null>;
1541
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1547
1542
  exists(filename: string): Promise<boolean>;
1548
1543
  getUrl(filename: string): string;
1549
1544
  writeShadow(filename: string, content: string, shadowId?: string): Promise<void>;
@@ -1586,6 +1581,7 @@ declare class MemorySitemapStorage implements SitemapStorage {
1586
1581
  constructor(baseUrl: string);
1587
1582
  write(filename: string, content: string): Promise<void>;
1588
1583
  read(filename: string): Promise<string | null>;
1584
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1589
1585
  exists(filename: string): Promise<boolean>;
1590
1586
  getUrl(filename: string): string;
1591
1587
  }
@@ -1686,6 +1682,7 @@ declare class S3SitemapStorage implements SitemapStorage {
1686
1682
  private getKey;
1687
1683
  write(filename: string, content: string): Promise<void>;
1688
1684
  read(filename: string): Promise<string | null>;
1685
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1689
1686
  exists(filename: string): Promise<boolean>;
1690
1687
  getUrl(filename: string): string;
1691
1688
  writeShadow(filename: string, content: string, shadowId?: string): Promise<void>;
@@ -1694,4 +1691,4 @@ declare class S3SitemapStorage implements SitemapStorage {
1694
1691
  switchVersion(filename: string, version: string): Promise<void>;
1695
1692
  }
1696
1693
 
1697
- export { type AlternateUrl, type ChangeFreq, type ChangeTracker, type ChangeType, DiffCalculator, DiskSitemapStorage, type DynamicSitemapOptions, GCPSitemapStorage, type GCPSitemapStorageOptions, GenerateSitemapJob, type GenerateSitemapJobOptions, type I18nSitemapEntryOptions, IncrementalGenerator, type IncrementalGeneratorOptions, MemoryChangeTracker, MemoryProgressStorage, MemoryRedirectManager, type MemoryRedirectManagerOptions, MemorySitemapStorage, OrbitSitemap, ProgressTracker, type ProgressTrackerOptions, RedirectDetector, type RedirectDetectorOptions, RedirectHandler, type RedirectHandlerOptions, type RedirectHandlingStrategy, type RedirectManager, type RedirectRule, RedisChangeTracker, RedisProgressStorage, type RedisProgressStorageOptions, RedisRedirectManager, type RedisRedirectManagerOptions, RouteScanner, type RouteScannerOptions, S3SitemapStorage, type S3SitemapStorageOptions, ShadowProcessor, type ShadowProcessorOptions, type SitemapCache, type SitemapChange, type SitemapEntry, SitemapGenerator, type SitemapGeneratorOptions, type SitemapImage, SitemapIndex, type SitemapIndexEntry, type SitemapLock, type SitemapNews, type SitemapProgress, type SitemapProgressStorage, type SitemapProvider, type SitemapStorage, SitemapStream, type SitemapStreamOptions, type SitemapVideo, type StaticSitemapOptions, generateI18nEntries, routeScanner };
1694
+ export { type AlternateUrl, type ChangeFreq, type ChangeTracker, type ChangeType, DiffCalculator, DiskSitemapStorage, type DynamicSitemapOptions, GCPSitemapStorage, type GCPSitemapStorageOptions, GenerateSitemapJob, type GenerateSitemapJobOptions, type I18nSitemapEntryOptions, IncrementalGenerator, type IncrementalGeneratorOptions, MemoryChangeTracker, MemoryProgressStorage, MemoryRedirectManager, type MemoryRedirectManagerOptions, MemorySitemapStorage, OrbitSitemap, ProgressTracker, type ProgressTrackerOptions, RedirectDetector, type RedirectDetectorOptions, RedirectHandler, type RedirectHandlerOptions, type RedirectHandlingStrategy, type RedirectManager, type RedirectRule, RedisChangeTracker, RedisProgressStorage, type RedisProgressStorageOptions, RedisRedirectManager, type RedisRedirectManagerOptions, RouteScanner, type RouteScannerOptions, S3SitemapStorage, type S3SitemapStorageOptions, ShadowProcessor, type ShadowProcessorOptions, type ShardInfo, type ShardManifest, type SitemapCache, type SitemapChange, type SitemapEntry, SitemapGenerator, type SitemapGeneratorOptions, type SitemapImage, SitemapIndex, type SitemapIndexEntry, type SitemapLock, type SitemapNews, type SitemapProgress, type SitemapProgressStorage, type SitemapProvider, type SitemapStorage, SitemapStream, type SitemapStreamOptions, type SitemapVideo, type StaticSitemapOptions, generateI18nEntries, routeScanner };
package/dist/index.d.ts CHANGED
@@ -205,6 +205,7 @@ interface SitemapStorage {
205
205
  * @returns The XML content as a string, or null if not found.
206
206
  */
207
207
  read(filename: string): Promise<string | null>;
208
+ readStream?(filename: string): Promise<AsyncIterable<string> | null>;
208
209
  /**
209
210
  * Check if a sitemap file exists in storage.
210
211
  *
@@ -441,6 +442,33 @@ interface RedirectRule {
441
442
  /** Timestamp when the redirect rule was created. */
442
443
  createdAt?: Date;
443
444
  }
445
+ /**
446
+ * Represents a manifest file that tracks URL-to-shard mappings.
447
+ *
448
+ * @public
449
+ * @since 3.0.1
450
+ */
451
+ interface ShardManifest {
452
+ version: number;
453
+ generatedAt: Date | string;
454
+ baseUrl: string;
455
+ maxEntriesPerShard: number;
456
+ sort: string;
457
+ shards: ShardInfo[];
458
+ }
459
+ /**
460
+ * Metadata about a single sitemap shard.
461
+ *
462
+ * @public
463
+ * @since 3.0.1
464
+ */
465
+ interface ShardInfo {
466
+ filename: string;
467
+ from: string;
468
+ to: string;
469
+ count: number;
470
+ lastmod: Date | string;
471
+ }
444
472
  /**
445
473
  * Manager for registering and resolving redirect rules.
446
474
  *
@@ -505,6 +533,7 @@ interface MemoryChangeTrackerOptions {
505
533
  */
506
534
  declare class MemoryChangeTracker implements ChangeTracker {
507
535
  private changes;
536
+ private urlIndex;
508
537
  private maxChanges;
509
538
  constructor(options?: MemoryChangeTrackerOptions);
510
539
  track(change: SitemapChange): Promise<void>;
@@ -650,6 +679,7 @@ declare class ShadowProcessor {
650
679
  private options;
651
680
  private shadowId;
652
681
  private operations;
682
+ private mutex;
653
683
  constructor(options: ShadowProcessorOptions);
654
684
  /**
655
685
  * 添加一個影子操作
@@ -688,6 +718,8 @@ interface SitemapGeneratorOptions extends SitemapStreamOptions {
688
718
  maxEntriesPerFile?: number;
689
719
  /** The name of the main sitemap or sitemap index file. @default 'sitemap.xml' */
690
720
  filename?: string;
721
+ /** Whether to generate a shard manifest file. @default false */
722
+ generateManifest?: boolean;
691
723
  /** Configuration for staging files before atomic deployment. */
692
724
  shadow?: {
693
725
  /** Whether shadow processing is enabled. */
@@ -727,71 +759,34 @@ declare class SitemapGenerator {
727
759
  private shadowProcessor;
728
760
  constructor(options: SitemapGeneratorOptions);
729
761
  run(): Promise<void>;
762
+ private normalizeUrl;
730
763
  /**
731
764
  * 獲取影子處理器(如果啟用)
732
765
  */
733
766
  getShadowProcessor(): ShadowProcessor | null;
734
767
  }
735
768
 
736
- /**
737
- * Options for configuring the `IncrementalGenerator`.
738
- *
739
- * Extends `SitemapGeneratorOptions` to include change tracking and difference
740
- * calculation components.
741
- *
742
- * @public
743
- * @since 3.0.0
744
- */
745
769
  interface IncrementalGeneratorOptions extends SitemapGeneratorOptions {
746
- /** The change tracker used to store and retrieve sitemap changes. */
747
770
  changeTracker: ChangeTracker;
748
- /** Optional difference calculator. Defaults to a new `DiffCalculator` instance. */
749
771
  diffCalculator?: DiffCalculator;
750
- /** Whether to automatically track changes during full generation. @default true */
751
772
  autoTrack?: boolean;
752
773
  }
753
- /**
754
- * IncrementalGenerator optimizes sitemap updates by processing only changed URLs.
755
- *
756
- * Instead of regenerating the entire sitemap from scratch, it uses a `ChangeTracker`
757
- * to identify new, updated, or removed URLs and updates the sitemap incrementally.
758
- *
759
- * @public
760
- * @since 3.0.0
761
- */
762
774
  declare class IncrementalGenerator {
763
775
  private options;
764
776
  private changeTracker;
765
777
  private diffCalculator;
766
778
  private generator;
779
+ private mutex;
767
780
  constructor(options: IncrementalGeneratorOptions);
768
- /**
769
- * 生成完整的 sitemap(首次生成)
770
- */
771
781
  generateFull(): Promise<void>;
772
- /**
773
- * 增量生成(只更新變更的部分)
774
- */
775
782
  generateIncremental(since?: Date): Promise<void>;
776
- /**
777
- * 手動追蹤變更
778
- */
779
- trackChange(change: SitemapChange): Promise<void>;
780
- /**
781
- * 獲取變更記錄
782
- */
783
- getChanges(since?: Date): Promise<SitemapChange[]>;
784
- /**
785
- * 載入基礎 entries(從現有 sitemap)
786
- */
787
- private loadBaseEntries;
788
- /**
789
- * 生成差異部分
790
- */
791
- private generateDiff;
792
- /**
793
- * 將 AsyncIterable 轉換為陣列
794
- */
783
+ private performFullGeneration;
784
+ private performIncrementalGeneration;
785
+ private normalizeUrl;
786
+ private loadManifest;
787
+ private getAffectedShards;
788
+ private updateShards;
789
+ private applyChanges;
795
790
  private toArray;
796
791
  }
797
792
 
@@ -902,16 +897,14 @@ declare class SitemapIndex {
902
897
  declare class SitemapStream {
903
898
  private options;
904
899
  private entries;
900
+ private flags;
905
901
  constructor(options: SitemapStreamOptions);
906
902
  add(entry: string | SitemapEntry): this;
907
903
  addAll(entries: (string | SitemapEntry)[]): this;
908
904
  toXML(): string;
909
905
  private renderUrl;
910
- private hasImages;
911
- private hasVideos;
912
- private hasNews;
913
- private hasAlternates;
914
906
  private escape;
907
+ getEntries(): SitemapEntry[];
915
908
  }
916
909
 
917
910
  /**
@@ -1484,6 +1477,7 @@ declare class DiskSitemapStorage implements SitemapStorage {
1484
1477
  constructor(outDir: string, baseUrl: string);
1485
1478
  write(filename: string, content: string): Promise<void>;
1486
1479
  read(filename: string): Promise<string | null>;
1480
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1487
1481
  exists(filename: string): Promise<boolean>;
1488
1482
  getUrl(filename: string): string;
1489
1483
  }
@@ -1544,6 +1538,7 @@ declare class GCPSitemapStorage implements SitemapStorage {
1544
1538
  private getKey;
1545
1539
  write(filename: string, content: string): Promise<void>;
1546
1540
  read(filename: string): Promise<string | null>;
1541
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1547
1542
  exists(filename: string): Promise<boolean>;
1548
1543
  getUrl(filename: string): string;
1549
1544
  writeShadow(filename: string, content: string, shadowId?: string): Promise<void>;
@@ -1586,6 +1581,7 @@ declare class MemorySitemapStorage implements SitemapStorage {
1586
1581
  constructor(baseUrl: string);
1587
1582
  write(filename: string, content: string): Promise<void>;
1588
1583
  read(filename: string): Promise<string | null>;
1584
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1589
1585
  exists(filename: string): Promise<boolean>;
1590
1586
  getUrl(filename: string): string;
1591
1587
  }
@@ -1686,6 +1682,7 @@ declare class S3SitemapStorage implements SitemapStorage {
1686
1682
  private getKey;
1687
1683
  write(filename: string, content: string): Promise<void>;
1688
1684
  read(filename: string): Promise<string | null>;
1685
+ readStream(filename: string): Promise<AsyncIterable<string> | null>;
1689
1686
  exists(filename: string): Promise<boolean>;
1690
1687
  getUrl(filename: string): string;
1691
1688
  writeShadow(filename: string, content: string, shadowId?: string): Promise<void>;
@@ -1694,4 +1691,4 @@ declare class S3SitemapStorage implements SitemapStorage {
1694
1691
  switchVersion(filename: string, version: string): Promise<void>;
1695
1692
  }
1696
1693
 
1697
- export { type AlternateUrl, type ChangeFreq, type ChangeTracker, type ChangeType, DiffCalculator, DiskSitemapStorage, type DynamicSitemapOptions, GCPSitemapStorage, type GCPSitemapStorageOptions, GenerateSitemapJob, type GenerateSitemapJobOptions, type I18nSitemapEntryOptions, IncrementalGenerator, type IncrementalGeneratorOptions, MemoryChangeTracker, MemoryProgressStorage, MemoryRedirectManager, type MemoryRedirectManagerOptions, MemorySitemapStorage, OrbitSitemap, ProgressTracker, type ProgressTrackerOptions, RedirectDetector, type RedirectDetectorOptions, RedirectHandler, type RedirectHandlerOptions, type RedirectHandlingStrategy, type RedirectManager, type RedirectRule, RedisChangeTracker, RedisProgressStorage, type RedisProgressStorageOptions, RedisRedirectManager, type RedisRedirectManagerOptions, RouteScanner, type RouteScannerOptions, S3SitemapStorage, type S3SitemapStorageOptions, ShadowProcessor, type ShadowProcessorOptions, type SitemapCache, type SitemapChange, type SitemapEntry, SitemapGenerator, type SitemapGeneratorOptions, type SitemapImage, SitemapIndex, type SitemapIndexEntry, type SitemapLock, type SitemapNews, type SitemapProgress, type SitemapProgressStorage, type SitemapProvider, type SitemapStorage, SitemapStream, type SitemapStreamOptions, type SitemapVideo, type StaticSitemapOptions, generateI18nEntries, routeScanner };
1694
+ export { type AlternateUrl, type ChangeFreq, type ChangeTracker, type ChangeType, DiffCalculator, DiskSitemapStorage, type DynamicSitemapOptions, GCPSitemapStorage, type GCPSitemapStorageOptions, GenerateSitemapJob, type GenerateSitemapJobOptions, type I18nSitemapEntryOptions, IncrementalGenerator, type IncrementalGeneratorOptions, MemoryChangeTracker, MemoryProgressStorage, MemoryRedirectManager, type MemoryRedirectManagerOptions, MemorySitemapStorage, OrbitSitemap, ProgressTracker, type ProgressTrackerOptions, RedirectDetector, type RedirectDetectorOptions, RedirectHandler, type RedirectHandlerOptions, type RedirectHandlingStrategy, type RedirectManager, type RedirectRule, RedisChangeTracker, RedisProgressStorage, type RedisProgressStorageOptions, RedisRedirectManager, type RedisRedirectManagerOptions, RouteScanner, type RouteScannerOptions, S3SitemapStorage, type S3SitemapStorageOptions, ShadowProcessor, type ShadowProcessorOptions, type ShardInfo, type ShardManifest, type SitemapCache, type SitemapChange, type SitemapEntry, SitemapGenerator, type SitemapGeneratorOptions, type SitemapImage, SitemapIndex, type SitemapIndexEntry, type SitemapLock, type SitemapNews, type SitemapProgress, type SitemapProgressStorage, type SitemapProvider, type SitemapStorage, SitemapStream, type SitemapStreamOptions, type SitemapVideo, type StaticSitemapOptions, generateI18nEntries, routeScanner };