@@ -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,11 +225,6 @@ 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-
233228 private get store ( ) : Store {
234229 if ( ! this . _store ) {
235230 console . error ( `Resource ${ this . subject } has no store` ) ;
@@ -552,10 +547,9 @@ export class Resource<C extends OptionalClass = any> {
552547 public getCommitsCollectionSubject ( ) : string {
553548 // For DID subjects (or other non-HTTP URIs) we can't derive the server
554549 // origin from the subject itself — use the store's server URL instead.
555- const base =
556- this . subject . startsWith ( 'did:' ) || this . subject . startsWith ( '_' )
557- ? this . store . getServerUrl ( )
558- : this . subject ;
550+ const base = this . subject . startsWith ( 'did:' ) || this . subject . startsWith ( '_' )
551+ ? this . store . getServerUrl ( )
552+ : this . subject ;
559553 const url = new URL ( '/commits' , base ) ;
560554 url . searchParams . append ( 'property' , commits . properties . subject ) ;
561555 url . searchParams . append ( 'value' , this . subject ) ;
@@ -605,8 +599,9 @@ export class Resource<C extends OptionalClass = any> {
605599 const commitsCollection = await this . store . fetchResourceFromServer (
606600 this . getCommitsCollectionSubject ( ) ,
607601 ) ;
608- const commitList = ( commitsCollection . get ( collections . properties . members ) ??
609- [ ] ) as string [ ] ;
602+ const commitList = ( commitsCollection . get (
603+ collections . properties . members ,
604+ ) ?? [ ] ) as string [ ] ;
610605
611606 const builtVersions : Version [ ] = [ ] ;
612607
@@ -883,6 +878,11 @@ export class Resource<C extends OptionalClass = any> {
883878 return commit ;
884879 }
885880
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,9 +895,7 @@ export class Resource<C extends OptionalClass = any> {
895895 }
896896
897897 const endpoint = this . getCommitEndpoint ( ) ;
898- const wasNew =
899- this . _pendingCommits . length > 0 &&
900- this . _pendingCommits [ 0 ] . previousCommit === undefined ;
898+ const wasNew = this . _pendingCommits . length > 0 && this . _pendingCommits [ 0 ] . previousCommit === undefined ;
901899
902900 let lastCommitId : string | undefined ;
903901
@@ -937,6 +935,19 @@ export class Resource<C extends OptionalClass = any> {
937935 }
938936 }
939937
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+
940951 /**
941952 * Commits the changes and sends the Commit to the resource's `/commit`
942953 * endpoint. Returns the Url of the created Commit. If you don't pass an Agent
@@ -989,9 +1000,7 @@ export class Resource<C extends OptionalClass = any> {
9891000 } ) ;
9901001
9911002 // Keep a backup of the commit builder in case push fails.
992- const oldCommitBuilder = hasChanges
993- ? this . commitBuilder . clone ( )
994- : undefined ;
1003+ const oldCommitBuilder = hasChanges ? this . commitBuilder . clone ( ) : undefined ;
9951004 const wasNew = this . new ;
9961005
9971006 try {
@@ -1141,19 +1150,6 @@ export class Resource<C extends OptionalClass = any> {
11411150 } ) ;
11421151 }
11431152
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-
11571153 private isParentNew ( ) {
11581154 const parentSubject = this . propvals . get ( core . properties . parent ) as string ;
11591155
0 commit comments