Skip to content

Commit

Permalink
Tighten up the Docmap type to conform to the fp-ts Json type #3334
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiosironi committed Jun 18, 2024
1 parent ec06a69 commit 1fd4b82
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Json } from 'fp-ts/Json';
import * as RA from 'fp-ts/ReadonlyArray';
import * as TE from 'fp-ts/TaskEither';
import { pipe } from 'fp-ts/function';
Expand All @@ -24,5 +23,5 @@ export const docmapIndex: DocmapIndex = (dependencies) => (query) => pipe(
internalErrorResponse.status,
)),
TE.map(RA.map(renderDocmap)),
TE.map((docmaps) => toNonHtmlViewRepresentation({ articles: docmaps } as Json, 'application/ld+json')),
TE.map((docmaps) => toNonHtmlViewRepresentation({ articles: docmaps }, 'application/ld+json')),
);
7 changes: 6 additions & 1 deletion src/read-side/non-html-views/docmaps/docmap/docmap-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ type Editor = {
role: 'editor',
};

type ContentItem = {
'type': 'web-page' | 'web-content',
url: string,
};

type Output = {
type: 'review-article' | 'evaluation-summary' | 'reply',
published: string,
content: ReadonlyArray<unknown>,
content: ReadonlyArray<ContentItem>,
};

type Action = {
Expand Down
3 changes: 1 addition & 2 deletions src/read-side/non-html-views/docmaps/docmap/docmap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as E from 'fp-ts/Either';
import { Json } from 'fp-ts/Json';
import * as TE from 'fp-ts/TaskEither';
import { pipe } from 'fp-ts/function';
import { StatusCodes } from 'http-status-codes';
Expand Down Expand Up @@ -29,5 +28,5 @@ export const docmap = (
decodedParams.doi,
generateDocmaps(ports),
)),
TE.map((state) => toNonHtmlViewRepresentation(state as Json, 'application/ld+json')),
TE.map((state) => toNonHtmlViewRepresentation(state, 'application/ld+json')),
);
6 changes: 3 additions & 3 deletions src/read-side/non-html-views/docmaps/docmap/render-docmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const createAction = (expressionDoi: EDOI.ExpressionDoi) => (evaluation: Evaluat
published: evaluation.publishedAt.toISOString(),
content: [
{
type: 'web-page',
type: 'web-page' as const,
url: evaluation.sourceUrl.toString(),
},
{
type: 'web-page',
type: 'web-page' as const,
url: `https://sciety.org${constructPaperActivityPageHref(expressionDoi)}#${EL.serialize(evaluation.evaluationLocator)}`,
},
{
type: 'web-content',
type: 'web-content' as const,
url: `https://sciety.org/evaluations/${EL.serialize(evaluation.evaluationLocator)}/content`,
},
],
Expand Down

0 comments on commit 1fd4b82

Please sign in to comment.