File tree Expand file tree Collapse file tree 6 files changed +43
-1
lines changed
infrastructure/repositories Expand file tree Collapse file tree 6 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { CollectionFeaturedItemsDTO } from '../useCases/DTOs/CollectionFeaturedI
1111export interface CollectionRepository {
1212 getById : ( id ?: string ) => Promise < Collection >
1313 create ( collection : CollectionDTO , hostCollection ?: string ) : Promise < number >
14+ delete ( collectionIdOrAlias : number | string ) : Promise < void >
1415 getFacets ( collectionIdOrAlias ?: number | string ) : Promise < CollectionFacet [ ] >
1516 getUserPermissions ( collectionIdOrAlias ?: number | string ) : Promise < CollectionUserPermissions >
1617 publish ( collectionIdOrAlias : number | string ) : Promise < void >
Original file line number Diff line number Diff line change 1+ import { WriteError } from '@iqss/dataverse-client-javascript'
2+ import { CollectionRepository } from '../repositories/CollectionRepository'
3+
4+ export function deleteCollection (
5+ collectionRepository : CollectionRepository ,
6+ collectionIdOrAlias : number | string
7+ ) : Promise < void > {
8+ return collectionRepository . delete ( collectionIdOrAlias ) . catch ( ( error : WriteError | unknown ) => {
9+ throw error
10+ } )
11+ }
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import {
1010 updateCollection ,
1111 getCollectionFeaturedItems ,
1212 updateCollectionFeaturedItems ,
13- deleteCollectionFeaturedItems
13+ deleteCollectionFeaturedItems ,
14+ deleteCollection
1415} from '@iqss/dataverse-client-javascript'
1516import { JSCollectionMapper } from '../mappers/JSCollectionMapper'
1617import { CollectionDTO } from '../../domain/useCases/DTOs/CollectionDTO'
@@ -36,6 +37,10 @@ export class CollectionJSDataverseRepository implements CollectionRepository {
3637 . then ( ( newCollectionIdentifier ) => newCollectionIdentifier )
3738 }
3839
40+ delete ( collectionIdOrAlias : number | string ) : Promise < void > {
41+ return deleteCollection . execute ( collectionIdOrAlias )
42+ }
43+
3944 getFacets ( collectionIdOrAlias ?: number | string ) : Promise < CollectionFacet [ ] > {
4045 return getCollectionFacets . execute ( collectionIdOrAlias ) . then ( ( facets ) => facets )
4146 }
Original file line number Diff line number Diff line change @@ -17,6 +17,14 @@ export class CollectionErrorMockRepository extends CollectionMockRepository {
1717 } )
1818 }
1919
20+ delete ( _collectionIdOrAlias : number | string ) : Promise < void > {
21+ return new Promise ( ( _resolve , reject ) => {
22+ setTimeout ( ( ) => {
23+ reject ( 'Something went wrong' )
24+ } , FakerHelper . loadingTimout ( ) )
25+ } )
26+ }
27+
2028 getFacets ( _collectionIdOrAlias : number | string ) : Promise < CollectionFacet [ ] > {
2129 return new Promise ( ( _resolve , reject ) => {
2230 setTimeout ( ( ) => {
Original file line number Diff line number Diff line change @@ -13,15 +13,23 @@ export class CollectionLoadingMockRepository extends CollectionMockRepository {
1313 getById ( _id ?: string ) : Promise < Collection > {
1414 return new Promise ( ( ) => { } )
1515 }
16+
1617 create ( _collection : CollectionDTO , _hostCollection ?: string ) : Promise < number > {
1718 return new Promise ( ( ) => { } )
1819 }
20+
21+ delete ( _collectionIdOrAlias : number | string ) : Promise < void > {
22+ return new Promise ( ( ) => { } )
23+ }
24+
1925 getFacets ( _collectionIdOrAlias : number | string ) : Promise < CollectionFacet [ ] > {
2026 return new Promise ( ( ) => { } )
2127 }
28+
2229 getUserPermissions ( _collectionIdOrAlias : number | string ) : Promise < CollectionUserPermissions > {
2330 return new Promise ( ( ) => { } )
2431 }
32+
2533 getItems (
2634 _collectionId : string ,
2735 _paginationInfo : CollectionItemsPaginationInfo ,
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export class CollectionMockRepository implements CollectionRepository {
2323 } , FakerHelper . loadingTimout ( ) )
2424 } )
2525 }
26+
2627 create ( _collection : CollectionDTO , _hostCollection ?: string ) : Promise < number > {
2728 return new Promise ( ( resolve ) => {
2829 setTimeout ( ( ) => {
@@ -31,6 +32,14 @@ export class CollectionMockRepository implements CollectionRepository {
3132 } )
3233 }
3334
35+ delete ( _collectionIdOrAlias : number | string ) : Promise < void > {
36+ return new Promise ( ( resolve ) => {
37+ setTimeout ( ( ) => {
38+ resolve ( )
39+ } , FakerHelper . loadingTimout ( ) )
40+ } )
41+ }
42+
3443 getFacets ( _collectionIdOrAlias : number | string ) : Promise < CollectionFacet [ ] > {
3544 return new Promise ( ( resolve ) => {
3645 setTimeout ( ( ) => {
You can’t perform that action at this time.
0 commit comments