Skip to content

Commit

Permalink
Support OSF Preprints
Browse files Browse the repository at this point in the history
Refs #290
  • Loading branch information
thewilkybarkid committed May 2, 2024
1 parent e77e575 commit 831764d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/CrossrefPreprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface CrossrefPreprint {
readonly authors: ReadonlyArray<string>
readonly doi: Doi.Doi
readonly posted: Temporal.PlainDate
readonly server: 'biorxiv' | 'edarxiv' | 'medrxiv' | 'psyarxiv' | 'scielo'
readonly server: 'biorxiv' | 'edarxiv' | 'medrxiv' | 'osf-preprints' | 'psyarxiv' | 'scielo'
readonly title: string
}

Expand Down Expand Up @@ -44,6 +44,7 @@ export const getPreprintFromCrossref = (
Match.when(['1101', { institution: [{ name: 'bioRxiv' }] }], () => 'biorxiv' as const),
Match.when(['1101', { institution: [{ name: 'medRxiv' }] }], () => 'medrxiv' as const),
Match.when(['1590'], () => 'scielo' as const),
Match.when(['31219', { 'group-title': 'Open Science Framework' }], () => 'osf-preprints' as const),
Match.when(['31234', { 'group-title': 'PsyArXiv' }], () => 'psyarxiv' as const),
Match.when(['35542', { 'group-title': 'EdArXiv' }], () => 'edarxiv' as const),
Match.either,
Expand Down
2 changes: 1 addition & 1 deletion src/Preprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getPreprint: (
doi: Doi.Doi,
) => Effect.Effect<Preprint, GetPreprintError, Crossref.CrossrefApi | Datacite.DataciteApi> = flow(
Match.value,
Match.when(Doi.hasRegistrant('1101', '1590', '31234', '35542'), CrossrefPreprint.getPreprintFromCrossref),
Match.when(Doi.hasRegistrant('1101', '1590', '31219', '31234', '35542'), CrossrefPreprint.getPreprintFromCrossref),
Match.when(Doi.hasRegistrant('48550'), DatacitePreprint.getPreprintFromDatacite),
Match.orElse(() => Effect.fail('Not from a supported server')),
Effect.mapError(toGetPreprintError),
Expand Down
1 change: 1 addition & 0 deletions src/ReviewRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Preprint server: """${Match.value(preprint.server).pipe(
Match.when('biorxiv', () => 'bioRxiv'),
Match.when('edarxiv', () => 'EdArXiv'),
Match.when('medrxiv', () => 'medRxiv'),
Match.when('osf-preprints', () => 'OSF Preprints'),
Match.when('psyarxiv', () => 'PsyArXiv'),
Match.when('scielo', () => 'SciELO Preprints'),
Match.exhaustive,
Expand Down
45 changes: 45 additions & 0 deletions test/CrossrefPreprint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ describe('getPreprintFromCrossref', () => {
fc.option(fc.string(), { nil: undefined }),
fc.constant('scielo'),
),
fc.tuple(
fc.doi({ registrant: fc.constant('31219') }),
fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }),
fc.constant('Open Science Framework'),
fc.constant('osf-preprints'),
),
fc.tuple(
fc.doi({ registrant: fc.constant('31234') }),
fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }),
Expand Down Expand Up @@ -100,6 +106,13 @@ describe('getPreprintFromCrossref', () => {
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.constant('31219') }),
'group-title': fc.constant('Open Science Framework'),
title: fc.constant([]),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.constant('31234') }),
'group-title': fc.constant('PsyArXiv'),
Expand Down Expand Up @@ -146,6 +159,14 @@ describe('getPreprintFromCrossref', () => {
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
abstract: fc.constant(undefined),
DOI: fc.doi({ registrant: fc.constant('31219') }),
'group-title': fc.constant('Open Science Framework'),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
abstract: fc.constant(undefined),
DOI: fc.doi({ registrant: fc.constant('31234') }),
Expand Down Expand Up @@ -196,6 +217,15 @@ describe('getPreprintFromCrossref', () => {
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constant('31219') }),
'group-title': fc.constant('Open Science Framework'),
published: fc.oneof(fc.plainYear(), fc.plainYearMonth()),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constant('31234') }),
Expand Down Expand Up @@ -248,6 +278,15 @@ describe('getPreprintFromCrossref', () => {
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constant('31219') }),
'group-title': fc.constant('Open Science Framework'),
published: fc.constant(undefined),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constant('31234') }),
Expand Down Expand Up @@ -318,6 +357,12 @@ describe('getPreprintFromCrossref', () => {
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.constant('31219') }),
'group-title': fc.string().filter(name => name !== 'Open Science Framework'),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.constant('31234') }),
'group-title': fc.string().filter(name => name !== 'PsyArXiv'),
Expand Down

0 comments on commit 831764d

Please sign in to comment.