From 56da9191fc89e6db593937f3ca0394b9295b56fc Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Fri, 19 Apr 2024 09:40:47 +0100 Subject: [PATCH] Match changes --- src/Program.ts | 22 +++++++++++----------- src/Users.ts | 4 ++-- src/Zenodo.ts | 4 ++-- src/index.ts | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Program.ts b/src/Program.ts index 3b06436..172bd73 100644 --- a/src/Program.ts +++ b/src/Program.ts @@ -1,4 +1,4 @@ -import { Effect, Match, Option, ReadonlyArray, Stream, flow } from 'effect' +import { Array, Effect, Match, Option, Stream, flow } from 'effect' import * as Decision from './Decision.js' import * as Doi from './Doi.js' import * as Orcid from './Orcid.js' @@ -10,13 +10,13 @@ import * as Zenodo from './Zenodo.js' const getPeerReviewsForOrcidId = flow( (user: Users.User) => Orcid.getPeerReviewsForOrcidId(user.orcidId), Effect.flatMap( - ReadonlyArray.findFirst( + Array.findFirst( (group): group is Orcid.PrereviewGroupSchema => group['external-ids']['external-id'][0]['external-id-value'] === 'orcid-generated:prereview', ), ), Effect.map(group => - ReadonlyArray.map( + Array.map( group['peer-review-group'], peerReview => ({ @@ -80,12 +80,12 @@ const getPeerReviewsOnZenodoForOrcidId = flow( }), ), Effect.map(reviews => - ReadonlyArray.map( + Array.map( reviews.hits, review => ({ doi: review.doi, - preprintDoi: ReadonlyArray.findFirst( + preprintDoi: Array.findFirst( review.metadata.related_identifiers, relatedIdentifier => relatedIdentifier.relation === 'reviews' && relatedIdentifier.scheme === 'doi', ).pipe( @@ -119,11 +119,11 @@ const makeDecisions = ({ zenodoReviews: ReadonlyArray orcidReviews: ReadonlyArray }) => - ReadonlyArray.union( - ReadonlyArray.filter( + Array.union( + Array.filter( zenodoReviews, zenodoReview => - !ReadonlyArray.contains( + !Array.contains( orcidReviews.map(review => review.doi), zenodoReview.doi, ), @@ -133,10 +133,10 @@ const makeDecisions = ({ ...zenodoReview, }), ), - ReadonlyArray.filter( + Array.filter( orcidReviews, orcidReview => - !ReadonlyArray.contains( + !Array.contains( zenodoReviews.map(review => review.doi), orcidReview.doi, ), @@ -165,7 +165,7 @@ const processUser = (user: Users.User) => ), ) - if (ReadonlyArray.isEmptyArray(decisions)) { + if (Array.isEmptyArray(decisions)) { return yield* _(Effect.logInfo('Nothing to do')) } diff --git a/src/Users.ts b/src/Users.ts index caf6eed..4c5638c 100644 --- a/src/Users.ts +++ b/src/Users.ts @@ -1,5 +1,5 @@ import { type ParseResult, Schema } from '@effect/schema' -import { type Cause, Data, Effect, ReadonlyArray, Stream, String, flow } from 'effect' +import { Array, type Cause, Data, Effect, Stream, String, flow } from 'effect' import * as OrcidId from './OrcidId.js' import * as Redis from './Redis.js' @@ -19,7 +19,7 @@ export const getUsers: Stream.Stream< }).pipe( Stream.flattenChunks, Stream.map(String.split(':')), - Stream.map(ReadonlyArray.lastNonEmpty), + Stream.map(Array.lastNonEmpty), Stream.flatMap(Schema.decodeEither(OrcidId.OrcidIdSchema)), Stream.bindTo('orcidId'), Stream.bind('accessToken', ({ orcidId }) => getAccessToken(orcidId)), diff --git a/src/Zenodo.ts b/src/Zenodo.ts index 55f50fa..db385f2 100644 --- a/src/Zenodo.ts +++ b/src/Zenodo.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@effect/platform' import { type ParseResult, Schema } from '@effect/schema' -import { Context, Effect, type ReadonlyRecord } from 'effect' +import { Context, Effect, type Record } from 'effect' import { DoiSchema } from './Doi.js' import type * as OrcidId from './OrcidId.js' import * as Temporal from './Temporal.js' @@ -27,7 +27,7 @@ export const getReviewsByOrcidId = (orcid: OrcidId.OrcidId) => }) const getRecords = ( - params: ReadonlyRecord.ReadonlyRecord, + params: Record.ReadonlyRecord, ): Effect.Effect => Effect.gen(function* (_) { const client = yield* _(zenodoClient) diff --git a/src/index.ts b/src/index.ts index 2cada28..ffd5152 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ const HttpClientLive = Layer.succeed( Effect.annotateLogs({ headers: HttpClient.headers.redact(request.headers, 'authorization') }), ), ), - Effect.zipRight(HttpClient.client.fetch()(request)), + Effect.zipRight(HttpClient.client.fetch(request)), Effect.tap(response => Effect.logDebug('Received HTTP response').pipe( Effect.annotateLogs({ status: response.status, headers: response.headers }),