From b55a3f9733407bd0bf713e430b78c55c74b5e2c6 Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Wed, 2 Aug 2023 10:24:44 +0100 Subject: [PATCH 1/7] add test case the expresses the bug --- src/docmap-parser.test.ts | 80 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/docmap-parser.test.ts b/src/docmap-parser.test.ts index 8454235..0976dcb 100644 --- a/src/docmap-parser.test.ts +++ b/src/docmap-parser.test.ts @@ -420,4 +420,84 @@ describe('docmap-parser', () => { versionIdentifier: '1', }); }); + + + it('matches preprints by for expressions', () => { + const docmap = ` + { + "@context": "https://w3id.org/docmaps/context.jsonld", + "type": "docmap", + "id": "http://mock-datahub/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-doi/10.1101%2F000002", + "created": "2022-11-28T11:30:05+00:00", + "updated": "2022-11-28T11:30:05+00:00", + "publisher": { + "account": { + "id": "https://sciety.org/groups/elife", + "service": "https://sciety.org" + }, + "homepage": "https://elifesciences.org/", + "id": "https://elifesciences.org/", + "logo": "https://sciety.org/static/groups/elife--b560187e-f2fb-4ff9-a861-a204f3fc0fb0.png", + "name": "eLife" + }, + "first-step": "_:b0", + "steps": { + "_:b0": { + "actions": [ + { + "participants": [], + "outputs": [ + { + "type": "preprint", + "identifier": "000002", + "doi": "10.7554/000002.1", + "versionIdentifier": "2", + "license": "http://creativecommons.org/licenses/by/4.0/" + } + ] + } + ], + "assertions": [ + { + "item": { + "type": "preprint", + "doi": "10.1101/000002", + "versionIdentifier": "2" + }, + "status": "under-review", + "happened": "2023-05-07T09:03:08+00:00" + }, + { + "item": { + "type": "preprint", + "doi": "10.7554/000002.1", + "versionIdentifier": "1" + }, + "status": "draft" + } + ], + "inputs": [ + { + "type": "preprint", + "doi": "10.1101/000002", + "url": "https://www.biorxiv.org/content/10.1101/000002v2", + "versionIdentifier": "2", + "published": "2023-05-06", + "content": [ + { + "type": "computer-file", + "url": "s3://biorxiv/dummy-2.meca" + } + ] + } + ] + } + } + } + + `; + const parsedData = parseDocMap(docmap); + + expect(parsedData.versions.length).toEqual(1); + }); }); From d4542ff54de5ac4f190bbd42b67695f6e4e19181 Mon Sep 17 00:00:00 2001 From: Nathan Lisgo Date: Wed, 2 Aug 2023 11:18:42 +0100 Subject: [PATCH 2/7] Refactor test to ensure correct parsing of umbrella expressions --- src/docmap-parser.test.ts | 148 ++++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 69 deletions(-) diff --git a/src/docmap-parser.test.ts b/src/docmap-parser.test.ts index 0976dcb..5b5c1a0 100644 --- a/src/docmap-parser.test.ts +++ b/src/docmap-parser.test.ts @@ -386,7 +386,7 @@ describe('docmap-parser', () => { expect(parsedData.versions[0].license).toStrictEqual('http://creativecommons.org/licenses/by/4.0/'); }); - it('extracts embodimentOf, if present', () => { + it('extracts partOf, if present', () => { const parsedData = parseDocMap(fixtures.preprintWithWorkAsOutput()); expect(parsedData.manuscript).toStrictEqual({ @@ -421,83 +421,93 @@ describe('docmap-parser', () => { }); }); - - it('matches preprints by for expressions', () => { - const docmap = ` - { - "@context": "https://w3id.org/docmaps/context.jsonld", - "type": "docmap", - "id": "http://mock-datahub/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-doi/10.1101%2F000002", - "created": "2022-11-28T11:30:05+00:00", - "updated": "2022-11-28T11:30:05+00:00", - "publisher": { - "account": { - "id": "https://sciety.org/groups/elife", - "service": "https://sciety.org" - }, - "homepage": "https://elifesciences.org/", - "id": "https://elifesciences.org/", - "logo": "https://sciety.org/static/groups/elife--b560187e-f2fb-4ff9-a861-a204f3fc0fb0.png", - "name": "eLife" - }, - "first-step": "_:b0", - "steps": { - "_:b0": { - "actions": [ - { - "participants": [], - "outputs": [ - { - "type": "preprint", - "identifier": "000002", - "doi": "10.7554/000002.1", - "versionIdentifier": "2", - "license": "http://creativecommons.org/licenses/by/4.0/" - } - ] - } - ], - "assertions": [ - { - "item": { - "type": "preprint", - "doi": "10.1101/000002", - "versionIdentifier": "2" - }, - "status": "under-review", - "happened": "2023-05-07T09:03:08+00:00" - }, + it('parses umbrella expressions', () => { + const docmap = `{ + "@context": "https://w3id.org/docmaps/context.jsonld", + "type": "docmap", + "id": "http://mock-datahub/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-doi/10.1101%2F000001", + "created": "2022-11-11T05:02:51+00:00", + "updated": "2022-11-11T05:02:51+00:00", + "publisher": { + "account": { + "id": "https://sciety.org/groups/elife", + "service": "https://sciety.org" + }, + "homepage": "https://elifesciences.org/", + "id": "https://elifesciences.org/", + "logo": "https://sciety.org/static/groups/elife--b560187e-f2fb-4ff9-a861-a204f3fc0fb0.png", + "name": "eLife" + }, + "first-step": "_:b0", + "steps": { + "_:b0": { + "actions": [ + { + "participants": [], + "outputs": [ { - "item": { - "type": "preprint", - "doi": "10.7554/000002.1", - "versionIdentifier": "1" - }, - "status": "draft" + "type": "preprint", + "identifier": "000001", + "doi": "10.7554/000001.1", + "versionIdentifier": "1", + "license": "http://creativecommons.org/licenses/by/4.0/", + "partOf": { + "type": "manuscript", + "doi": "10.7554/000001", + "identifier": "000001", + "volumeIdentifier": "1", + "electronicArticleIdentifier": "RP000001" + } } - ], - "inputs": [ + ] + } + ], + "assertions": [ + { + "item": { + "type": "preprint", + "doi": "10.1101/000001", + "versionIdentifier": "1" + }, + "status": "under-review", + "happened": "2023-05-06T09:03:08+00:00" + }, + { + "item": { + "type": "preprint", + "doi": "10.7554/000001.1", + "versionIdentifier": "1" + }, + "status": "draft" + } + ], + "inputs": [ + { + "type": "preprint", + "doi": "10.1101/000001", + "url": "https://www.biorxiv.org/content/10.1101/000001v1", + "versionIdentifier": "1", + "published": "2023-05-05", + "content": [ { - "type": "preprint", - "doi": "10.1101/000002", - "url": "https://www.biorxiv.org/content/10.1101/000002v2", - "versionIdentifier": "2", - "published": "2023-05-06", - "content": [ - { - "type": "computer-file", - "url": "s3://biorxiv/dummy-2.meca" - } - ] + "type": "computer-file", + "url": "s3://biorxiv/dummy-1.meca" } ] } - } + ] } - - `; + } +} +`; const parsedData = parseDocMap(docmap); expect(parsedData.versions.length).toEqual(1); + + expect(parsedData.manuscript).toStrictEqual({ + doi: '10.7554/000001', + volume: '1', + eLocationId: 'RP000001', + }); }); }); From 78cd8ed1a877e8f79b012beeaa3fc3d54bd61267 Mon Sep 17 00:00:00 2001 From: Nathan Lisgo Date: Wed, 2 Aug 2023 11:41:49 +0100 Subject: [PATCH 3/7] change embodimentOf to partOf --- src/docmap-generator.ts | 2 +- src/docmap-parser.ts | 8 ++++---- src/docmap.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/docmap-generator.ts b/src/docmap-generator.ts index 61beeec..d5e06e8 100644 --- a/src/docmap-generator.ts +++ b/src/docmap-generator.ts @@ -41,7 +41,7 @@ export const generatePreprint = (doi: DOI, published?: Date, url?: Url, version? versionIdentifier: version, content, license, - embodimentOf: work, + partOf: work, }); export const generateRevisedPreprint = (doi: DOI, published?: Date, url?: Url, version?: string, content?: Manifestation[]): RevisedPreprint => ({ diff --git a/src/docmap-parser.ts b/src/docmap-parser.ts index 47772c8..316df01 100644 --- a/src/docmap-parser.ts +++ b/src/docmap-parser.ts @@ -93,14 +93,14 @@ export type ManuscriptData = { }; const getManuscriptFromExpression = (expression: Expression): Manuscript | false => { - if (!expression.embodimentOf) { + if (!expression.partOf) { return false; } return { - doi: expression.embodimentOf.doi, - volume: expression.embodimentOf.volumeIdentifier, - eLocationId: expression.embodimentOf.electronicArticleIdentifier, + doi: expression.partOf.doi, + volume: expression.partOf.volumeIdentifier, + eLocationId: expression.partOf.electronicArticleIdentifier, }; }; diff --git a/src/docmap.ts b/src/docmap.ts index 449a713..9f9975e 100644 --- a/src/docmap.ts +++ b/src/docmap.ts @@ -38,7 +38,7 @@ export type Expression = { doi?: DOI, content?: Manifestation[], license?: string, - embodimentOf?: Work, + partOf?: Work, }; export type Manifestation = { From f9587bf49a195139223fe677b91571291f22b120 Mon Sep 17 00:00:00 2001 From: Nathan Lisgo Date: Wed, 2 Aug 2023 11:57:37 +0100 Subject: [PATCH 4/7] rename Work docmap type to Manuscript --- src/docmap-generator.ts | 6 +- src/docmap-parser.test.ts | 147 ++++++++++++++++++++------------------ src/docmap.ts | 4 +- 3 files changed, 81 insertions(+), 76 deletions(-) diff --git a/src/docmap-generator.ts b/src/docmap-generator.ts index d5e06e8..b3cd02e 100644 --- a/src/docmap-generator.ts +++ b/src/docmap-generator.ts @@ -25,7 +25,7 @@ import { Url, VersionOfRecord, WebPage, - Work, + Manuscript, } from './docmap'; type Steps = { @@ -33,7 +33,7 @@ type Steps = { steps: Map }; -export const generatePreprint = (doi: DOI, published?: Date, url?: Url, version?: string, content?: Manifestation[], license?: string, work?: Work): Preprint => ({ +export const generatePreprint = (doi: DOI, published?: Date, url?: Url, version?: string, content?: Manifestation[], license?: string, work?: Manuscript): Preprint => ({ type: ExpressionType.Preprint, doi, url, @@ -114,7 +114,7 @@ export const generateWebContent = (url: Url): WebPage => ({ url, }); -export const generateWork = (doi?: DOI, identifier?: string, volumeIdentifier?: string, electronicArticleIdentifier?: string): Work => ({ +export const generateWork = (doi?: DOI, identifier?: string, volumeIdentifier?: string, electronicArticleIdentifier?: string): Manuscript => ({ type: 'manuscript', doi, identifier, diff --git a/src/docmap-parser.test.ts b/src/docmap-parser.test.ts index 5b5c1a0..c87748c 100644 --- a/src/docmap-parser.test.ts +++ b/src/docmap-parser.test.ts @@ -421,85 +421,90 @@ describe('docmap-parser', () => { }); }); - it('parses umbrella expressions', () => { + it('parses umbrella expressions from multiple locations', () => { const docmap = `{ - "@context": "https://w3id.org/docmaps/context.jsonld", - "type": "docmap", - "id": "http://mock-datahub/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-doi/10.1101%2F000001", - "created": "2022-11-11T05:02:51+00:00", - "updated": "2022-11-11T05:02:51+00:00", - "publisher": { - "account": { - "id": "https://sciety.org/groups/elife", - "service": "https://sciety.org" - }, - "homepage": "https://elifesciences.org/", - "id": "https://elifesciences.org/", - "logo": "https://sciety.org/static/groups/elife--b560187e-f2fb-4ff9-a861-a204f3fc0fb0.png", - "name": "eLife" - }, - "first-step": "_:b0", - "steps": { - "_:b0": { - "actions": [ - { - "participants": [], - "outputs": [ + "@context": "https://w3id.org/docmaps/context.jsonld", + "type": "docmap", + "id": "http://mock-datahub/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-doi/10.1101%2F000001", + "created": "2022-11-11T05:02:51+00:00", + "updated": "2022-11-11T05:02:51+00:00", + "publisher": { + "account": { + "id": "https://sciety.org/groups/elife", + "service": "https://sciety.org" + }, + "homepage": "https://elifesciences.org/", + "id": "https://elifesciences.org/", + "logo": "https://sciety.org/static/groups/elife--b560187e-f2fb-4ff9-a861-a204f3fc0fb0.png", + "name": "eLife" + }, + "first-step": "_:b0", + "steps": { + "_:b0": { + "actions": [ { - "type": "preprint", - "identifier": "000001", - "doi": "10.7554/000001.1", - "versionIdentifier": "1", - "license": "http://creativecommons.org/licenses/by/4.0/", - "partOf": { - "type": "manuscript", - "doi": "10.7554/000001", - "identifier": "000001", - "volumeIdentifier": "1", - "electronicArticleIdentifier": "RP000001" - } + "participants": [], + "outputs": [ + { + "type": "preprint", + "identifier": "000001", + "doi": "10.7554/000001.1", + "versionIdentifier": "1", + "license": "http://creativecommons.org/licenses/by/4.0/", + "partOf": { + "type": "manuscript", + "doi": "10.7554/000001", + "identifier": "000001", + "volumeIdentifier": "1" + } + } + ] } - ] - } - ], - "assertions": [ - { - "item": { - "type": "preprint", - "doi": "10.1101/000001", - "versionIdentifier": "1" - }, - "status": "under-review", - "happened": "2023-05-06T09:03:08+00:00" - }, - { - "item": { - "type": "preprint", - "doi": "10.7554/000001.1", - "versionIdentifier": "1" - }, - "status": "draft" - } - ], - "inputs": [ - { - "type": "preprint", - "doi": "10.1101/000001", - "url": "https://www.biorxiv.org/content/10.1101/000001v1", - "versionIdentifier": "1", - "published": "2023-05-05", - "content": [ + ], + "assertions": [ { - "type": "computer-file", - "url": "s3://biorxiv/dummy-1.meca" + "item": { + "type": "preprint", + "doi": "10.1101/000001", + "versionIdentifier": "1" + }, + "status": "under-review", + "happened": "2023-05-06T09:03:08+00:00" + }, + { + "item": { + "type": "preprint", + "doi": "10.7554/000001.1", + "versionIdentifier": "1", + "partOf": { + "type": "manuscript", + "doi": "10.7554/000001", + "identifier": "000001", + "electronicArticleIdentifier": "RP000001" + } + }, + "status": "draft" + } + ], + "inputs": [ + { + "type": "preprint", + "doi": "10.1101/000001", + "url": "https://www.biorxiv.org/content/10.1101/000001v1", + "versionIdentifier": "1", + "published": "2023-05-05", + "content": [ + { + "type": "computer-file", + "url": "s3://biorxiv/dummy-1.meca" + } + ] } ] } - ] + } } - } -} -`; + `; const parsedData = parseDocMap(docmap); expect(parsedData.versions.length).toEqual(1); diff --git a/src/docmap.ts b/src/docmap.ts index 9f9975e..5b53413 100644 --- a/src/docmap.ts +++ b/src/docmap.ts @@ -38,7 +38,7 @@ export type Expression = { doi?: DOI, content?: Manifestation[], license?: string, - partOf?: Work, + partOf?: Manuscript, }; export type Manifestation = { @@ -116,7 +116,7 @@ export type Assertion = { happened?: Date, }; -export type Work = { +export type Manuscript = { type: 'manuscript', doi?: DOI, identifier?: string, From 589dbe33ab8f3611e0256f6799ee3b5ab2568bab Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Wed, 2 Aug 2023 12:34:04 +0100 Subject: [PATCH 5/7] complete the refactoring of Work->Manuscript --- src/docmap-generator.ts | 8 ++++---- src/docmap-parser.test.ts | 4 ++-- src/docmap.ts | 4 ++-- src/test-fixtures/docmapGenerators.ts | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/docmap-generator.ts b/src/docmap-generator.ts index d5e06e8..4fa4924 100644 --- a/src/docmap-generator.ts +++ b/src/docmap-generator.ts @@ -14,6 +14,7 @@ import { JsonLDFrameUrl, Manifestation, ManifestationType, + Manuscript, Output, Participant, PeerReview, @@ -25,7 +26,6 @@ import { Url, VersionOfRecord, WebPage, - Work, } from './docmap'; type Steps = { @@ -33,7 +33,7 @@ type Steps = { steps: Map }; -export const generatePreprint = (doi: DOI, published?: Date, url?: Url, version?: string, content?: Manifestation[], license?: string, work?: Work): Preprint => ({ +export const generatePreprint = (doi: DOI, published?: Date, url?: Url, version?: string, content?: Manifestation[], license?: string, partOf?: Manuscript): Preprint => ({ type: ExpressionType.Preprint, doi, url, @@ -41,7 +41,7 @@ export const generatePreprint = (doi: DOI, published?: Date, url?: Url, version? versionIdentifier: version, content, license, - partOf: work, + partOf, }); export const generateRevisedPreprint = (doi: DOI, published?: Date, url?: Url, version?: string, content?: Manifestation[]): RevisedPreprint => ({ @@ -114,7 +114,7 @@ export const generateWebContent = (url: Url): WebPage => ({ url, }); -export const generateWork = (doi?: DOI, identifier?: string, volumeIdentifier?: string, electronicArticleIdentifier?: string): Work => ({ +export const generateManuscript = (doi?: DOI, identifier?: string, volumeIdentifier?: string, electronicArticleIdentifier?: string): Manuscript => ({ type: 'manuscript', doi, identifier, diff --git a/src/docmap-parser.test.ts b/src/docmap-parser.test.ts index 5b5c1a0..28a4d61 100644 --- a/src/docmap-parser.test.ts +++ b/src/docmap-parser.test.ts @@ -387,7 +387,7 @@ describe('docmap-parser', () => { }); it('extracts partOf, if present', () => { - const parsedData = parseDocMap(fixtures.preprintWithWorkAsOutput()); + const parsedData = parseDocMap(fixtures.preprintWithManuscriptAsOutput()); expect(parsedData.manuscript).toStrictEqual({ doi: '10.1101/123456', @@ -397,7 +397,7 @@ describe('docmap-parser', () => { }); it('extracts partial embodimentOf, if present', () => { - const parsedData = parseDocMap(fixtures.preprintWithPartialWorkAsOutput()); + const parsedData = parseDocMap(fixtures.preprintWithPartialManuscriptAsOutput()); expect(parsedData.manuscript).toStrictEqual({ doi: '10.1101/123456', diff --git a/src/docmap.ts b/src/docmap.ts index 9f9975e..5b53413 100644 --- a/src/docmap.ts +++ b/src/docmap.ts @@ -38,7 +38,7 @@ export type Expression = { doi?: DOI, content?: Manifestation[], license?: string, - partOf?: Work, + partOf?: Manuscript, }; export type Manifestation = { @@ -116,7 +116,7 @@ export type Assertion = { happened?: Date, }; -export type Work = { +export type Manuscript = { type: 'manuscript', doi?: DOI, identifier?: string, diff --git a/src/test-fixtures/docmapGenerators.ts b/src/test-fixtures/docmapGenerators.ts index 691cf0b..36a3684 100644 --- a/src/test-fixtures/docmapGenerators.ts +++ b/src/test-fixtures/docmapGenerators.ts @@ -16,7 +16,7 @@ import { generateStep, generateUnderReviewAssertion, generateWebContent, - generateWork, + generateManuscript, } from '../docmap-generator'; const publisher = { @@ -48,16 +48,16 @@ export const fixtures = { return generateDocMap('test', publisher, firstStep); }, - preprintWithWorkAsOutput: (): DocMap => { - const work = generateWork('10.1101/123456', '123456', '1', 'RP123456'); - const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, work); + preprintWithManuscriptAsOutput: (): DocMap => { + const manuscript = generateManuscript('10.1101/123456', '123456', '1', 'RP123456'); + const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, manuscript); const firstStep = generateStep([], [generateAction([], [preprint])], []); return generateDocMap('test', publisher, firstStep); }, - preprintWithPartialWorkAsOutput: (): DocMap => { - const work = generateWork('10.1101/123456', '123456', undefined, 'RP123456'); - const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, work); + preprintWithPartialManuscriptAsOutput: (): DocMap => { + const manuscript = generateManuscript('10.1101/123456', '123456', undefined, 'RP123456'); + const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, manuscript); const firstStep = generateStep([], [generateAction([], [preprint])], []); return generateDocMap('test', publisher, firstStep); }, From a6d47d7d1a26b546d4f55975c2c6aeedb225b8c6 Mon Sep 17 00:00:00 2001 From: Nathan Lisgo Date: Wed, 2 Aug 2023 12:49:15 +0100 Subject: [PATCH 6/7] fix: Correct republishPreprintAs function to handle manuscript data --- src/docmap-parser.test.ts | 10 +++++----- src/docmap-parser.ts | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/docmap-parser.test.ts b/src/docmap-parser.test.ts index c87748c..d467455 100644 --- a/src/docmap-parser.test.ts +++ b/src/docmap-parser.test.ts @@ -477,11 +477,11 @@ describe('docmap-parser', () => { "doi": "10.7554/000001.1", "versionIdentifier": "1", "partOf": { - "type": "manuscript", - "doi": "10.7554/000001", - "identifier": "000001", - "electronicArticleIdentifier": "RP000001" - } + "type": "manuscript", + "doi": "10.7554/000001", + "identifier": "000001", + "electronicArticleIdentifier": "RP000001" + } }, "status": "draft" } diff --git a/src/docmap-parser.ts b/src/docmap-parser.ts index 316df01..9fdb812 100644 --- a/src/docmap-parser.ts +++ b/src/docmap-parser.ts @@ -214,11 +214,23 @@ const findAndUpdateOrAddPreprintDescribedBy = (expression: Expression, preprintC return foundPreprint; }; -const republishPreprintAs = (expression: Expression, preprint: ReviewedPreprint) => { +const republishPreprintAs = (expression: Expression, preprint: ReviewedPreprint, manuscript: Manuscript) => { if (!expression.doi) { throw Error('Cannot identify Expression by DOI'); } - + const foundManuscriptData = getManuscriptFromExpression(expression); + const existingManuscript = manuscript; + if (foundManuscriptData) { + if (foundManuscriptData.doi) { + existingManuscript.doi = foundManuscriptData.doi; + } + if (foundManuscriptData.eLocationId) { + existingManuscript.eLocationId = foundManuscriptData.eLocationId; + } + if (foundManuscriptData.volume) { + existingManuscript.volume = foundManuscriptData.volume; + } + } const newPreprint = preprint; newPreprint.id = expression.identifier ?? expression.doi; @@ -371,7 +383,7 @@ const parseStep = (step: Step, preprints: Array, manuscript: M if (inferredRepublished) { // preprint input, preprint output, but no evaluations = superceed input preprint with output Reviewed Preprint const preprint = findAndUpdateOrAddPreprintDescribedBy(inferredRepublished.originalExpression, preprints, manuscript); - republishPreprintAs(inferredRepublished.republishedExpression, preprint); + republishPreprintAs(inferredRepublished.republishedExpression, preprint, manuscript); } const inferredPeerReviewed = getPeerReviewedPreprint(step); @@ -382,7 +394,7 @@ const parseStep = (step: Step, preprints: Array, manuscript: M // sometimes a new reviewed preprint is published as an output if (inferredPeerReviewed.republishedPreprint) { - republishPreprintAs(inferredPeerReviewed.republishedPreprint, preprint); + republishPreprintAs(inferredPeerReviewed.republishedPreprint, preprint, manuscript); } } From 2b5ff8f9f21379b25a8101da15615e7356bc5d60 Mon Sep 17 00:00:00 2001 From: Will Byrne Date: Wed, 2 Aug 2023 14:47:12 +0100 Subject: [PATCH 7/7] add fixture for umbrella expressions from multiple locations --- src/docmap-parser.test.ts | 88 +-------------------------- src/test-fixtures/docmapGenerators.ts | 10 +++ 2 files changed, 13 insertions(+), 85 deletions(-) diff --git a/src/docmap-parser.test.ts b/src/docmap-parser.test.ts index 4c26fe7..acfa9ad 100644 --- a/src/docmap-parser.test.ts +++ b/src/docmap-parser.test.ts @@ -422,97 +422,15 @@ describe('docmap-parser', () => { }); it('parses umbrella expressions from multiple locations', () => { - const docmap = `{ - "@context": "https://w3id.org/docmaps/context.jsonld", - "type": "docmap", - "id": "http://mock-datahub/enhanced-preprints/docmaps/v1/by-publisher/elife/get-by-doi/10.1101%2F000001", - "created": "2022-11-11T05:02:51+00:00", - "updated": "2022-11-11T05:02:51+00:00", - "publisher": { - "account": { - "id": "https://sciety.org/groups/elife", - "service": "https://sciety.org" - }, - "homepage": "https://elifesciences.org/", - "id": "https://elifesciences.org/", - "logo": "https://sciety.org/static/groups/elife--b560187e-f2fb-4ff9-a861-a204f3fc0fb0.png", - "name": "eLife" - }, - "first-step": "_:b0", - "steps": { - "_:b0": { - "actions": [ - { - "participants": [], - "outputs": [ - { - "type": "preprint", - "identifier": "000001", - "doi": "10.7554/000001.1", - "versionIdentifier": "1", - "license": "http://creativecommons.org/licenses/by/4.0/", - "partOf": { - "type": "manuscript", - "doi": "10.7554/000001", - "identifier": "000001", - "volumeIdentifier": "1" - } - } - ] - } - ], - "assertions": [ - { - "item": { - "type": "preprint", - "doi": "10.1101/000001", - "versionIdentifier": "1" - }, - "status": "under-review", - "happened": "2023-05-06T09:03:08+00:00" - }, - { - "item": { - "type": "preprint", - "doi": "10.7554/000001.1", - "versionIdentifier": "1", - "partOf": { - "type": "manuscript", - "doi": "10.7554/000001", - "identifier": "000001", - "electronicArticleIdentifier": "RP000001" - } - }, - "status": "draft" - } - ], - "inputs": [ - { - "type": "preprint", - "doi": "10.1101/000001", - "url": "https://www.biorxiv.org/content/10.1101/000001v1", - "versionIdentifier": "1", - "published": "2023-05-05", - "content": [ - { - "type": "computer-file", - "url": "s3://biorxiv/dummy-1.meca" - } - ] - } - ] - } - } - } - `; + const docmap = fixtures.preprintWithUmbrellaExpressionsFromMultipleLocations(); const parsedData = parseDocMap(docmap); expect(parsedData.versions.length).toEqual(1); expect(parsedData.manuscript).toStrictEqual({ - doi: '10.7554/000001', + doi: '10.1101/123456', volume: '1', - eLocationId: 'RP000001', + eLocationId: 'RP123456', }); }); }); diff --git a/src/test-fixtures/docmapGenerators.ts b/src/test-fixtures/docmapGenerators.ts index 36a3684..c728ef2 100644 --- a/src/test-fixtures/docmapGenerators.ts +++ b/src/test-fixtures/docmapGenerators.ts @@ -62,6 +62,16 @@ export const fixtures = { return generateDocMap('test', publisher, firstStep); }, + preprintWithUmbrellaExpressionsFromMultipleLocations: (): DocMap => { + const manuscript = generateManuscript('10.1101/123456', '123456', undefined, 'RP123456'); + const manuscript2 = generateManuscript('10.1101/123456', '123456', "1"); + const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, manuscript); + const preprint2 = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, manuscript2); + const assertion = generateDraftAssertion(preprint2); + const firstStep = generateStep([], [generateAction([], [preprint])], [assertion]); + return generateDocMap('test', publisher, firstStep); + }, + simplePreprintWithUrlAsOutput: (): DocMap => { const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), 'https://somewhere.org/preprint/article1'); const firstStep = generateStep([], [generateAction([], [preprint])], []);