Skip to content

Commit

Permalink
Support Preprints.org preprints
Browse files Browse the repository at this point in the history
Refs #290
  • Loading branch information
thewilkybarkid committed Jul 10, 2024
1 parent 632840d commit 68ec4e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/CrossrefPreprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface CrossrefPreprint {
| 'edarxiv'
| 'medrxiv'
| 'osf-preprints'
| 'preprints.org'
| 'psyarxiv'
| 'scielo'
| 'socarxiv'
Expand All @@ -29,6 +30,7 @@ export const CrossrefPreprintServerSchema = Schema.Literal(
'edarxiv',
'medrxiv',
'osf-preprints',
'preprints.org',
'psyarxiv',
'scielo',
'socarxiv',
Expand Down Expand Up @@ -64,6 +66,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(['20944'], () => 'preprints.org' 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(['31235', { 'group-title': 'SocArXiv' }], () => 'socarxiv' as const),
Expand Down
2 changes: 1 addition & 1 deletion src/Preprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getPreprint: (
) => Effect.Effect<Preprint, GetPreprintError, Crossref.CrossrefApi | Datacite.DataciteApi> = flow(
Match.value,
Match.when(
Doi.hasRegistrant('1101', '1590', '31219', '31234', '31235', '32942', '35542'),
Doi.hasRegistrant('1101', '1590', '20944', '31219', '31234', '31235', '32942', '35542'),
CrossrefPreprint.getPreprintFromCrossref,
),
Match.when(Doi.hasRegistrant('48550'), DatacitePreprint.getPreprintFromDatacite),
Expand Down
1 change: 1 addition & 0 deletions src/ReviewRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ Preprint server: """${Match.value(preprint.server).pipe(
Match.when('edarxiv', () => 'EdArXiv'),
Match.when('medrxiv', () => 'medRxiv'),
Match.when('osf-preprints', () => 'OSF Preprints'),
Match.when('preprints.org', () => 'Preprints.org'),
Match.when('psyarxiv', () => 'PsyArXiv'),
Match.when('scielo', () => 'SciELO Preprints'),
Match.when('socarxiv', () => 'SocArXiv'),
Expand Down
18 changes: 13 additions & 5 deletions test/CrossrefPreprint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ describe('getPreprintFromCrossref', () => {
fc.constant('Open Science Framework'),
fc.constant('osf-preprints'),
),
fc.tuple(
fc.doi({ registrant: fc.constant('20944') }),
fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }),
fc.option(fc.string(), { nil: undefined }),
fc.constant('preprints.org'),
),
fc.tuple(
fc.doi({ registrant: fc.constant('31234') }),
fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }),
Expand Down Expand Up @@ -113,7 +119,7 @@ describe('getPreprintFromCrossref', () => {
subtype: fc.constant('preprint'),
}),
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }),
title: fc.constant([]),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
Expand Down Expand Up @@ -173,7 +179,7 @@ describe('getPreprintFromCrossref', () => {
}),
fc.crossrefWork({
abstract: fc.constant(undefined),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
Expand Down Expand Up @@ -238,7 +244,7 @@ describe('getPreprintFromCrossref', () => {
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }),
published: fc.oneof(fc.plainYear(), fc.plainYearMonth()),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
Expand Down Expand Up @@ -308,7 +314,7 @@ describe('getPreprintFromCrossref', () => {
}),
fc.crossrefWork({
abstract: fc.string(),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }),
DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }),
published: fc.constant(undefined),
title: fc.nonEmptyArray(fc.string()),
type: fc.constant('posted-content'),
Expand Down Expand Up @@ -392,7 +398,9 @@ describe('getPreprintFromCrossref', () => {
fc.doi(),
fc.oneof(
fc.crossrefWork({
DOI: fc.doi({ registrant: fc.doiRegistrant().filter(registrant => !['1590', '32942'].includes(registrant)) }),
DOI: fc.doi({
registrant: fc.doiRegistrant().filter(registrant => !['1590', '20944', '32942'].includes(registrant)),
}),
type: fc.constant('posted-content'),
subtype: fc.constant('preprint'),
}),
Expand Down

0 comments on commit 68ec4e5

Please sign in to comment.