|
| 1 | +import { Data, type Option, Schema } from 'effect' |
| 2 | +import type * as Commands from '../Commands.ts' |
| 3 | +import type * as Preprints from '../Preprints/index.ts' |
| 4 | +import type { NonEmptyString, OrcidId, Temporal, Uuid } from '../types/index.ts' |
| 5 | +import * as Events from './Events.ts' |
| 6 | + |
| 7 | +export interface Input { |
| 8 | + author: { |
| 9 | + persona: 'public' | 'pseudonym' |
| 10 | + orcidId: OrcidId.OrcidId |
| 11 | + } |
| 12 | + publishedAt: Temporal.Instant |
| 13 | + preprintId: Preprints.IndeterminatePreprintId |
| 14 | + rapidPrereviewId: Uuid.Uuid |
| 15 | + questions: { |
| 16 | + availableCode: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 17 | + availableData: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 18 | + coherent: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 19 | + dataLink: Option.Option<NonEmptyString.NonEmptyString> |
| 20 | + ethics: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 21 | + future: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 22 | + limitations: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 23 | + methods: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 24 | + newData: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 25 | + novel: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 26 | + peerReview: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 27 | + recommend: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 28 | + reproducibility: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 29 | + technicalComments: Option.Option<NonEmptyString.NonEmptyString> |
| 30 | + editorialComments: Option.Option<NonEmptyString.NonEmptyString> |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +export const ImportRapidPrereviewInput: Schema.Schema<Input> = Schema.typeSchema(Events.RapidPrereviewImported).pipe( |
| 35 | + Schema.omit('_tag'), |
| 36 | +) |
| 37 | + |
| 38 | +type State = RapidPrereviewDoesNotExist | RapidPrereviewAlreadyExists |
| 39 | + |
| 40 | +class RapidPrereviewDoesNotExist extends Data.TaggedClass('RapidPrereviewDoesNotExist') {} |
| 41 | + |
| 42 | +class RapidPrereviewAlreadyExists extends Data.TaggedClass('RapidPrereviewAlreadyExists')<{ |
| 43 | + author: { |
| 44 | + persona: 'public' | 'pseudonym' |
| 45 | + orcidId: OrcidId.OrcidId |
| 46 | + } |
| 47 | + publishedAt: Temporal.Instant |
| 48 | + preprintId: Preprints.IndeterminatePreprintId |
| 49 | + rapidPrereviewId: Uuid.Uuid |
| 50 | + questions: { |
| 51 | + availableCode: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 52 | + availableData: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 53 | + coherent: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 54 | + dataLink: Option.Option<NonEmptyString.NonEmptyString> |
| 55 | + ethics: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 56 | + future: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 57 | + limitations: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 58 | + methods: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 59 | + newData: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 60 | + novel: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 61 | + peerReview: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 62 | + recommend: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 63 | + reproducibility: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 64 | + technicalComments: Option.Option<NonEmptyString.NonEmptyString> |
| 65 | + editorialComments: Option.Option<NonEmptyString.NonEmptyString> |
| 66 | + } |
| 67 | +}> {} |
| 68 | + |
| 69 | +export class MismatchWithExistingData extends Data.TaggedError('MismatchWithExistingData')<{ |
| 70 | + author: { |
| 71 | + persona: 'public' | 'pseudonym' |
| 72 | + orcidId: OrcidId.OrcidId |
| 73 | + } |
| 74 | + publishedAt: Temporal.Instant |
| 75 | + preprintId: Preprints.IndeterminatePreprintId |
| 76 | + rapidPrereviewId: Uuid.Uuid |
| 77 | + questions: { |
| 78 | + availableCode: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 79 | + availableData: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 80 | + coherent: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 81 | + dataLink: Option.Option<NonEmptyString.NonEmptyString> |
| 82 | + ethics: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 83 | + future: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 84 | + limitations: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 85 | + methods: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 86 | + newData: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 87 | + novel: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 88 | + peerReview: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 89 | + recommend: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 90 | + reproducibility: 'yes' | 'unsure' | 'not applicable' | 'no' |
| 91 | + technicalComments: Option.Option<NonEmptyString.NonEmptyString> |
| 92 | + editorialComments: Option.Option<NonEmptyString.NonEmptyString> |
| 93 | + } |
| 94 | +}> {} |
| 95 | + |
| 96 | +export declare const ImportRapidPrereview: Commands.Command< |
| 97 | + 'RapidPrereviewImported', |
| 98 | + [Input], |
| 99 | + State, |
| 100 | + MismatchWithExistingData |
| 101 | +> |
0 commit comments