@@ -117,7 +117,7 @@ export class Resource<C extends OptionalClass = any> {
117117
118118 throw new Error (
119119 'Invalid subject given to resource, must be a string, found ' +
120- typeof subject ,
120+ typeof subject ,
121121 ) ;
122122 }
123123
@@ -225,6 +225,11 @@ export class Resource<C extends OptionalClass = any> {
225225 } ) ;
226226 }
227227
228+ /** Returns `true` when there are locally-signed commits waiting to be pushed. */
229+ public get hasPendingCommits ( ) : boolean {
230+ return this . _pendingCommits . length > 0 ;
231+ }
232+
228233 private get store ( ) : Store {
229234 if ( ! this . _store ) {
230235 console . error ( `Resource ${ this . subject } has no store` ) ;
@@ -547,9 +552,10 @@ export class Resource<C extends OptionalClass = any> {
547552 public getCommitsCollectionSubject ( ) : string {
548553 // For DID subjects (or other non-HTTP URIs) we can't derive the server
549554 // origin from the subject itself — use the store's server URL instead.
550- const base = this . subject . startsWith ( 'did:' ) || this . subject . startsWith ( '_' )
551- ? this . store . getServerUrl ( )
552- : this . subject ;
555+ const base =
556+ this . subject . startsWith ( 'did:' ) || this . subject . startsWith ( '_' )
557+ ? this . store . getServerUrl ( )
558+ : this . subject ;
553559 const url = new URL ( '/commits' , base ) ;
554560 url . searchParams . append ( 'property' , commits . properties . subject ) ;
555561 url . searchParams . append ( 'value' , this . subject ) ;
@@ -599,9 +605,8 @@ export class Resource<C extends OptionalClass = any> {
599605 const commitsCollection = await this . store . fetchResourceFromServer (
600606 this . getCommitsCollectionSubject ( ) ,
601607 ) ;
602- const commitList = ( commitsCollection . get (
603- collections . properties . members ,
604- ) ?? [ ] ) as string [ ] ;
608+ const commitList = ( commitsCollection . get ( collections . properties . members ) ??
609+ [ ] ) as string [ ] ;
605610
606611 const builtVersions : Version [ ] = [ ] ;
607612
@@ -878,11 +883,6 @@ export class Resource<C extends OptionalClass = any> {
878883 return commit ;
879884 }
880885
881- /** Returns `true` when there are locally-signed commits waiting to be pushed. */
882- public get hasPendingCommits ( ) : boolean {
883- return this . _pendingCommits . length > 0 ;
884- }
885-
886886 /**
887887 * Push all locally-queued commits to the server, in order.
888888 *
@@ -895,7 +895,9 @@ export class Resource<C extends OptionalClass = any> {
895895 }
896896
897897 const endpoint = this . getCommitEndpoint ( ) ;
898- const wasNew = this . _pendingCommits . length > 0 && this . _pendingCommits [ 0 ] . previousCommit === undefined ;
898+ const wasNew =
899+ this . _pendingCommits . length > 0 &&
900+ this . _pendingCommits [ 0 ] . previousCommit === undefined ;
899901
900902 let lastCommitId : string | undefined ;
901903
@@ -935,19 +937,6 @@ export class Resource<C extends OptionalClass = any> {
935937 }
936938 }
937939
938- /** Resolves the `/commit` endpoint for this resource. */
939- private getCommitEndpoint ( ) : string {
940- if ( this . subject . startsWith ( 'did:' ) ) {
941- return new URL ( '/commit' , this . store . getServerUrl ( ) ) . toString ( ) ;
942- }
943-
944- try {
945- return new URL ( this . subject ) . origin + `/commit` ;
946- } catch {
947- return new URL ( '/commit' , this . store . getServerUrl ( ) ) . toString ( ) ;
948- }
949- }
950-
951940 /**
952941 * Commits the changes and sends the Commit to the resource's `/commit`
953942 * endpoint. Returns the Url of the created Commit. If you don't pass an Agent
@@ -1000,7 +989,9 @@ export class Resource<C extends OptionalClass = any> {
1000989 } ) ;
1001990
1002991 // Keep a backup of the commit builder in case push fails.
1003- const oldCommitBuilder = hasChanges ? this . commitBuilder . clone ( ) : undefined ;
992+ const oldCommitBuilder = hasChanges
993+ ? this . commitBuilder . clone ( )
994+ : undefined ;
1004995 const wasNew = this . new ;
1005996
1006997 try {
@@ -1150,6 +1141,19 @@ export class Resource<C extends OptionalClass = any> {
11501141 } ) ;
11511142 }
11521143
1144+ /** Resolves the `/commit` endpoint for this resource. */
1145+ private getCommitEndpoint ( ) : string {
1146+ if ( this . subject . startsWith ( 'did:' ) ) {
1147+ return new URL ( '/commit' , this . store . getServerUrl ( ) ) . toString ( ) ;
1148+ }
1149+
1150+ try {
1151+ return new URL ( this . subject ) . origin + `/commit` ;
1152+ } catch {
1153+ return new URL ( '/commit' , this . store . getServerUrl ( ) ) . toString ( ) ;
1154+ }
1155+ }
1156+
11531157 private isParentNew ( ) {
11541158 const parentSubject = this . propvals . get ( core . properties . parent ) as string ;
11551159
0 commit comments