Skip to content

Commit

Permalink
Rename type to match an external query's scope #3239
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiosironi committed May 15, 2024
1 parent 478570f commit 8da6244
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { toJatsXmlUrlOfPublisher } from './to-jats-xml-url-of-publisher';
import { Logger } from '../../../shared-ports';
import * as DE from '../../../types/data-error';
import { QueryExternalService } from '../../query-external-service';
import { EvaluationFetcher } from '../evaluation-fetcher';
import { EvaluationDigestFetcher } from '../evaluation-digest-fetcher';

const fetchEvaluationFromPublisherJatsXmlEndpoint = (
queryExternalService: QueryExternalService,
Expand All @@ -26,7 +26,7 @@ const fetchEvaluationFromPublisherJatsXmlEndpoint = (
export const fetchAccessMicrobiologyEvaluation = (
queryExternalService: QueryExternalService,
logger: Logger,
): EvaluationFetcher => (key: string) => pipe(
): EvaluationDigestFetcher => (key: string) => pipe(
key,
fetchEvaluationFromPublisherJatsXmlEndpoint(queryExternalService, logger),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ExternalQueries } from '../external-queries';

export type EvaluationDigestFetcher = (key: string) => ReturnType<ExternalQueries['fetchEvaluationDigest']>;
3 changes: 0 additions & 3 deletions src/third-parties/fetch-evaluation/evaluation-fetcher.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as R from 'fp-ts/Record';
import * as TE from 'fp-ts/TaskEither';
import { pipe } from 'fp-ts/function';
import * as S from 'fp-ts/string';
import { EvaluationFetcher } from './evaluation-fetcher';
import { EvaluationDigestFetcher } from './evaluation-digest-fetcher';
import { Logger } from '../../shared-ports';
import * as DE from '../../types/data-error';

Expand All @@ -15,9 +15,9 @@ const deriveDoiPrefixFrom = (key: string) => pipe(
);

export const fetchDoiEvaluationByPublisher = (
evaluationFetchers: Record<string, EvaluationFetcher>,
evaluationFetchers: Record<string, EvaluationDigestFetcher>,
logger: Logger,
): EvaluationFetcher => (key) => pipe(
): EvaluationDigestFetcher => (key) => pipe(
evaluationFetchers,
R.lookup(deriveDoiPrefixFrom(key)),
O.match(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as R from 'fp-ts/Record';
import * as TE from 'fp-ts/TaskEither';
import { pipe } from 'fp-ts/function';
import { EvaluationFetcher } from './evaluation-fetcher';
import { EvaluationDigestFetcher } from './evaluation-digest-fetcher';
import * as DE from '../../types/data-error';
import * as EL from '../../types/evaluation-locator';
import { ExternalQueries } from '../external-queries';

export const fetchEvaluationFromAppropriateService = (fetchers: Record<string, EvaluationFetcher>): ExternalQueries['fetchEvaluationDigest'] => (id) => pipe(
export const fetchEvaluationFromAppropriateService = (fetchers: Record<string, EvaluationDigestFetcher>): ExternalQueries['fetchEvaluationDigest'] => (id) => pipe(
fetchers,
R.lookup(EL.service(id)),
TE.fromOption(() => DE.notFound),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { toHtmlFragment } from '../../../types/html-fragment';
import { sanitise } from '../../../types/sanitised-html-fragment';
import { decodeAndLogFailures } from '../../decode-and-log-failures';
import { QueryExternalService } from '../../query-external-service';
import { EvaluationFetcher } from '../evaluation-fetcher';
import { EvaluationDigestFetcher } from '../evaluation-digest-fetcher';

const converter = new Remarkable({ html: true }).use(linkify);

Expand Down Expand Up @@ -44,7 +44,7 @@ const toReview = (logger: Logger) => (response: HypothesisAnnotation) => {
export const fetchHypothesisAnnotation = (
queryExternalService: QueryExternalService,
logger: Logger,
): EvaluationFetcher => (key) => pipe(
): EvaluationDigestFetcher => (key) => pipe(
`https://api.hypothes.is/api/annotations/${key}`,
queryExternalService(),
TE.chainEitherKW(flow(
Expand Down
4 changes: 2 additions & 2 deletions src/third-parties/fetch-evaluation/ncrc/fetch-ncrc-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { constructNcrcReview, NcrcReview } from './construct-ncrc-review';
import { sheetId } from './sheet-id';
import { Logger } from '../../../shared-ports';
import * as DE from '../../../types/data-error';
import { EvaluationFetcher } from '../evaluation-fetcher';
import { EvaluationDigestFetcher } from '../evaluation-digest-fetcher';
import Params$Resource$Spreadsheets$Values$Get = sheets_v4.Params$Resource$Spreadsheets$Values$Get;

// https://github.com/gcanti/io-ts/issues/431
Expand Down Expand Up @@ -146,7 +146,7 @@ const fetchNcrcSpreadsheetRow = (logger: Logger) => (evaluationUuid: string) =>
}),
);

export const fetchNcrcReview = (logger: Logger): EvaluationFetcher => (evaluationUuid: string) => pipe(
export const fetchNcrcReview = (logger: Logger): EvaluationDigestFetcher => (evaluationUuid: string) => pipe(
evaluationUuid,
fetchNcrcSpreadsheetRow(logger),
TE.map(constructNcrcReview),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import * as DE from '../../../types/data-error';
import { toHtmlFragment } from '../../../types/html-fragment';
import { sanitise } from '../../../types/sanitised-html-fragment';
import { QueryExternalService } from '../../query-external-service';
import { EvaluationFetcher } from '../evaluation-fetcher';
import { EvaluationDigestFetcher } from '../evaluation-digest-fetcher';

export const fetchPrelightsHighlight = (
queryExternalService: QueryExternalService,
logger: Logger,
): EvaluationFetcher => (url: string) => pipe(
): EvaluationDigestFetcher => (url: string) => pipe(
url,
queryExternalService(),
TE.chainEitherKW(flow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as DE from '../../../types/data-error';
import { toHtmlFragment } from '../../../types/html-fragment';
import { sanitise } from '../../../types/sanitised-html-fragment';
import { QueryExternalService } from '../../query-external-service';
import { EvaluationFetcher } from '../evaluation-fetcher';
import { EvaluationDigestFetcher } from '../evaluation-digest-fetcher';

const summary = (logger: Logger) => (doc: CheerioAPI) => pipe(
doc('meta[name=description]').attr()?.content,
Expand Down Expand Up @@ -56,7 +56,7 @@ const extractEvaluation = (logger: Logger) => (html: string) => {
export const fetchRapidReview = (
queryExternalService: QueryExternalService,
logger: Logger,
): EvaluationFetcher => (url) => pipe(
): EvaluationDigestFetcher => (url) => pipe(
url,
queryExternalService(),
TE.chainEitherKW(flow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as DE from '../../../types/data-error';
import { htmlFragmentCodec } from '../../../types/html-fragment';
import { sanitise } from '../../../types/sanitised-html-fragment';
import { QueryExternalService } from '../../query-external-service';
import { EvaluationFetcher } from '../evaluation-fetcher';
import { EvaluationDigestFetcher } from '../evaluation-digest-fetcher';

const isDoiFromZenodo = (doi: string) => doi.startsWith('10.5281/');

Expand All @@ -29,7 +29,7 @@ const zenodoRecordCodec = t.type({
export const fetchZenodoRecord = (
queryExternalService: QueryExternalService,
logger: Logger,
): EvaluationFetcher => (key) => pipe(
): EvaluationDigestFetcher => (key) => pipe(
key,
E.fromPredicate(
isDoiFromZenodo,
Expand Down

0 comments on commit 8da6244

Please sign in to comment.