Skip to content

Commit

Permalink
Finish migrating all userDatasetServiceWrappers to VDI
Browse files Browse the repository at this point in the history
  • Loading branch information
jernestmyers committed Oct 20, 2023
1 parent bd77767 commit 50b6b2b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
19 changes: 0 additions & 19 deletions packages/libs/user-datasets/src/lib/Service/UserDatasetWrappers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { WdkService } from '@veupathdb/wdk-client/lib/Core';
import {
arrayOf,
number,
objectOf,
record,
} from '@veupathdb/wdk-client/lib/Utils/Json';
import { EpicDependencies } from '@veupathdb/wdk-client/lib/Core/Store';
import { ActionThunk } from '@veupathdb/wdk-client/lib/Core/WdkMiddleware';

Expand All @@ -25,10 +19,6 @@ export type UserDatasetShareResponse = {

type UserDatasetsServiceWrappers = typeof userDatasetsServiceWrappers;

const userIdsByEmailDecoder = record({
results: arrayOf(objectOf(number)),
});

export const userDatasetsServiceWrappers = {
// editUserDatasetSharing:
// (wdkService: WdkService) =>
Expand Down Expand Up @@ -59,15 +49,6 @@ export const userDatasetsServiceWrappers = {
// delta
// );
// },
getUserIdsByEmail: (wdkService: WdkService) => (emails: string[]) => {
return wdkService.sendRequest(userIdsByEmailDecoder, {
path: '/user-id-query',
method: 'POST',
body: JSON.stringify({
emails,
}),
});
},
};

export function isUserDatasetsCompatibleWdkService(
Expand Down
21 changes: 21 additions & 0 deletions packages/libs/user-datasets/src/lib/Service/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { zipWith } from 'lodash';

import {
arrayOf,
number,
objectOf,
record,
} from '@veupathdb/wdk-client/lib/Utils/Json';

import {
createJsonRequest,
FetchClientWithCredentials,
Expand All @@ -20,6 +27,10 @@ import { submitAsForm } from '@veupathdb/wdk-client/lib/Utils/FormSubmitter';
export const VDI_SERVICE_BASE_URL = 'http://localhost:8080';
const VDI_SERVICE = '/vdi-datasets';

const userIdsByEmailDecoder = record({
results: arrayOf(objectOf(number)),
});

export class UserDatasetApi extends FetchClientWithCredentials {
getCurrentUserDatasets = (
projectId?: string,
Expand Down Expand Up @@ -161,6 +172,16 @@ export class UserDatasetApi extends FetchClientWithCredentials {
})
);
};

getUserIdsByEmail = (emails: string[]) => {
return this.wdkService.sendRequest(userIdsByEmailDecoder, {
path: '/user-id-query',
method: 'POST',
body: JSON.stringify({
emails,
}),
});
};
}

// TODO: copied from study-data-access's api => move to a different package's util functions
Expand Down
4 changes: 1 addition & 3 deletions packages/libs/user-datasets/src/lib/Service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { mapValues } from 'lodash';

import { WdkService } from '@veupathdb/wdk-client/lib/Core';

import { userDatasetsServiceWrappers } from './UserDatasetWrappers';
import {
ServiceConfig as UserDatasetUploadServiceConfig,
makeUserDatasetUploadServiceWrappers,
Expand All @@ -21,9 +20,8 @@ export function wrapWdkService(

const wrappersToInclude =
serviceConfig == null
? userDatasetsServiceWrappers
? undefined
: {
...userDatasetsServiceWrappers,
...makeUserDatasetUploadServiceWrappers(serviceConfig),
};

Expand Down

0 comments on commit 50b6b2b

Please sign in to comment.