11import { ConflictHttpError } from '@solid/community-server' ;
2- import { UCRulesStorage } from " ../ucp/storage/UCRulesStorage" ;
2+ import { ReadOnlyStore , UCRulesStorage } from ' ../ucp/storage/UCRulesStorage' ;
33import { getLoggerFor } from 'global-logger-factory' ;
44import { Parser , Store } from 'n3' ;
55import { writeStore } from "../util/ConvertUtil" ;
@@ -18,8 +18,8 @@ export abstract class BaseController {
1818 protected readonly store : UCRulesStorage ,
1919 protected sanitizePost : ( store : Store , clientID : string ) => Promise < { result : Store , id : string } > ,
2020 protected sanitizeDelete : ( store : Store , entityID : string , clientID : string ) => Promise < void > ,
21- protected sanitizeGets : ( store : Store , clientID : string ) => Promise < Store > ,
22- protected sanitizeGet : ( store : Store , entityID : string , clientID : string ) => Promise < Store > ,
21+ protected sanitizeGets : ( store : ReadOnlyStore , clientID : string ) => Promise < ReadOnlyStore > ,
22+ protected sanitizeGet : ( store : ReadOnlyStore , entityID : string , clientID : string ) => Promise < ReadOnlyStore > ,
2323 protected sanitizePatch : ( store : Store , entityID : string , clientID : string , patchInformation : string ) => Promise < void >
2424 ) { }
2525
@@ -30,7 +30,7 @@ export abstract class BaseController {
3030 * @returns results serialized in Turtle and status code 200,
3131 * or an empty body with status 404 if nothing was found
3232 */
33- private async get ( sanitizeGet : ( ) => Promise < Store > ) : Promise < { message : string , status : number } > {
33+ private async get ( sanitizeGet : ( ) => Promise < ReadOnlyStore > ) : Promise < { message : string , status : number } > {
3434 const store = await sanitizeGet ( ) ;
3535
3636 const message = store . size > 0 ? await writeStore ( store ) : '' ;
@@ -92,7 +92,7 @@ export abstract class BaseController {
9292 * - 204 if deletion was successful
9393 */
9494 public async deleteEntity ( entityID : string , clientID : string ) : Promise < { status : number } > {
95- const filteredStore = new Store ( await this . store . getStore ( ) ) ;
95+ const filteredStore = new Store ( await this . store . getStore ( ) as Store ) ;
9696 await this . sanitizeDelete ( filteredStore , entityID , clientID ) ;
9797 const diff = ( await this . store . getStore ( ) ) . difference ( filteredStore ) ;
9898 await this . store . removeData ( diff as Store ) ;
@@ -114,12 +114,12 @@ export abstract class BaseController {
114114 */
115115 public async patchEntity ( entityID : string , patchInformation : string , clientID : string , isolate : boolean = true ) : Promise < HttpHandlerResponse < string > > {
116116 let response : HttpHandlerResponse < string > = { status : 204 , body : '' } ;
117- let filteredStore = new Store ( await this . store . getStore ( ) ) ;
117+ let filteredStore = new Store ( await this . store . getStore ( ) as Store ) ;
118118 let omitStore : Store ;
119119
120120 if ( isolate ) { // requires isolating all information about the entity provided, as e.g. the patchinformation has a query to be executed
121- filteredStore = await this . sanitizeGet ( filteredStore , entityID , clientID ) ;
122- omitStore = new Store ( await this . store . getStore ( ) ) ;
121+ filteredStore = await this . sanitizeGet ( filteredStore , entityID , clientID ) as Store ;
122+ omitStore = new Store ( await this . store . getStore ( ) as Store ) ;
123123 omitStore . removeQuads ( [ ...filteredStore ] ) ;
124124 }
125125
@@ -130,14 +130,14 @@ export abstract class BaseController {
130130 // * bonus: filters out extra quads
131131 // ! drawback: PATCH may still be used to DELETE all information about the entity
132132 // TODO: check if PATCH is smth we want for all resources, make patchEntity optional otherwise
133- filteredStore = await this . sanitizeGet ( filteredStore , entityID , clientID ) || filteredStore ;
133+ filteredStore = await this . sanitizeGet ( filteredStore , entityID , clientID ) as Store || filteredStore ;
134134 omitStore ! . addAll ( filteredStore ) ;
135135 filteredStore = omitStore ! ;
136136 }
137137
138138 const originalStore = await this . store . getStore ( ) ;
139139 const remove = originalStore . difference ( filteredStore ) ;
140- const add = filteredStore . difference ( originalStore ) ;
140+ const add = filteredStore . difference ( originalStore as Store ) ;
141141
142142 if ( remove . size > 0 ) {
143143 await this . store . removeData ( remove as Store ) ;
0 commit comments