File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,12 +99,28 @@ async function main() {
9999 console . log ( `✅ Logged in as ${ publisher . getDid ( ) } ` ) ;
100100
101101 // Get existing documents to avoid duplicates
102- const existingDocs = await publisher . listDocuments ( 100 ) ;
103- const existingPaths = new Set (
104- existingDocs
105- . map ( ( doc ) => doc . value . path )
106- . filter ( Boolean )
107- ) ;
102+ const existingPaths = new Set < string > ( ) ;
103+ let cursor : string | undefined ;
104+
105+ // Paginate through all existing documents (ATProto caps at 100 per request)
106+ do {
107+ const agent = publisher . getAtpAgent ( ) ;
108+ const response = await agent . api . com . atproto . repo . listRecords ( {
109+ repo : publisher . getDid ( ) ,
110+ collection : 'site.standard.document' ,
111+ limit : 100 ,
112+ cursor
113+ } ) ;
114+
115+ for ( const record of response . data . records ) {
116+ const doc = record . value as { path ?: string } ;
117+ if ( doc . path ) {
118+ existingPaths . add ( doc . path ) ;
119+ }
120+ }
121+
122+ cursor = response . data . cursor ;
123+ } while ( cursor ) ;
108124
109125 let published = 0 ;
110126 let skipped = 0 ;
You can’t perform that action at this time.
0 commit comments