From b6dadbf0e12bd450d6d34c0e44353188134a8566 Mon Sep 17 00:00:00 2001 From: Nathan Lisgo Date: Thu, 24 Oct 2024 17:06:51 +0100 Subject: [PATCH] Update to encoda 1.0.9 to improve reference data [elifesciences/enhanced-preprints-issues#626] --- integration-tests/api.spec.ts | 5 ++- package.json | 1 + src/app.ts | 5 +++ yarn.lock | 72 +++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) diff --git a/integration-tests/api.spec.ts b/integration-tests/api.spec.ts index de2b646..d0afdda 100644 --- a/integration-tests/api.spec.ts +++ b/integration-tests/api.spec.ts @@ -11,7 +11,7 @@ describe('api', () => { .post('/') .send(xml.toString()) .expect(200) - .then((response) => expect(response.headers['content-type']).toBe('application/vnd.elife.encoda.v1.0.8+json; charset=utf-8')); + .then((response) => expect(response.headers['content-type']).toBe('application/vnd.elife.encoda.v1.0.9+json; charset=utf-8')); }); it.each([ @@ -21,6 +21,7 @@ describe('api', () => { '1.0.6', '1.0.7', '1.0.8', + '1.0.9', ])('should use the specified version - %s', async (version) => { const mimeType = `application/vnd.elife.encoda.v${version}+json`; await request(app) @@ -35,7 +36,7 @@ describe('api', () => { 'unknown', '1.0.4', '1.0.5', - '1.0.9', + '1.0.10', ])('should error if you specify wrong version - %s', async (version) => { const mimeType = `application/vnd.elife.encoda.v${version}+json`; await request(app) diff --git a/package.json b/package.json index 79897d6..00358ff 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@stencila/encoda-1-0-6": "npm:@stencila/encoda@1.0.6", "@stencila/encoda-1-0-7": "npm:@stencila/encoda@1.0.7", "@stencila/encoda-1-0-8": "npm:@stencila/encoda@1.0.8", + "@stencila/encoda-1-0-9": "npm:@stencila/encoda@1.0.9", "body-parser": "^1.20.3", "express": "^4.21.1" }, diff --git a/src/app.ts b/src/app.ts index 685af0b..80eaf5a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -6,6 +6,7 @@ import { convert as convert_1_0_3 } from '@stencila/encoda-1-0-3'; import { convert as convert_1_0_6 } from '@stencila/encoda-1-0-6'; import { convert as convert_1_0_7 } from '@stencila/encoda-1-0-7'; import { convert as convert_1_0_8 } from '@stencila/encoda-1-0-8'; +import { convert as convert_1_0_9 } from '@stencila/encoda-1-0-9'; import { mkdtempSync, writeFileSync, rmSync } from 'fs'; import { tmpdir } from 'os'; @@ -38,6 +39,10 @@ app.post('/', async (req, res) => { const replacementPath = typeof req.query.replacementPath === 'string' ? req.query.replacementPath : ''; const versionResponders = { + 'application/vnd.elife.encoda.v1.0.9+json': async () => { + res.json(JSON.parse(((await convert_1_0_9(xmlFile, undefined, parameters)) ?? '{}').replaceAll(tempOutput, replacementPath))); + rmSync(tempOutput, { recursive: true, force: true }); + }, 'application/vnd.elife.encoda.v1.0.8+json': async () => { res.json(JSON.parse(((await convert_1_0_8(xmlFile, undefined, parameters)) ?? '{}').replaceAll(tempOutput, replacementPath))); rmSync(tempOutput, { recursive: true, force: true }); diff --git a/yarn.lock b/yarn.lock index a3e625b..6f1a477 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2641,6 +2641,77 @@ __metadata: languageName: node linkType: hard +"@stencila/encoda-1-0-9@npm:@stencila/encoda@1.0.9": + version: 1.0.9 + resolution: "@stencila/encoda@npm:1.0.9" + dependencies: + "@stencila/jesta": ^1.10.5 + "@stencila/logga": ^4.0.0 + "@stencila/thema": ^2.24.4 + appdata-path: ^1.0.0 + asciimath2tex: "https://github.com/christianp/asciimath2tex/tarball/dedc42ddfdb80678bfb09864cfa76afb0a4b5f44" + async-lock: ^1.4.1 + bin-wrapper: ^4.1.0 + citation-js: ^0.5.7 + collapse-whitespace: ^1.1.7 + content-type: ^1.0.5 + datapackage: ^1.1.10 + escape-html: ^1.0.3 + fastest-levenshtein: ^1.0.16 + fp-ts: ^2.16.5 + fs-extra: ^11.2.0 + get-stdin: ^8.0.0 + github-slugger: ^1.5.0 + globby: ^11.1.0 + hyperscript: ^2.0.2 + is-docker: ^2.2.1 + jimp: ^0.22.10 + js-beautify: ^1.15.1 + js-yaml: ^4.1.0 + jsdom: ^22.1.0 + json5: ^2.2.3 + jsonld: ^8.3.2 + mathjax-node: ^2.1.1 + mdast-util-compact: ^3.0.0 + mime: ^3.0.0 + minimist: ^1.2.8 + papaparse: ^5.4.1 + parse-author: ^2.0.0 + parse-full-name: ^1.2.6 + pdf-lib: ^1.17.1 + plotly.js-dist: ^1.58.5 + png-chunk-text: ^1.0.0 + png-chunks-encode: ^1.0.0 + png-chunks-extract: ^1.0.0 + puppeteer: ^11.0.0 + remark-attr: ^0.11.1 + remark-frontmatter: ^2.0.0 + remark-generic-extensions: ^1.4.0 + remark-math: ^3.0.1 + remark-parse: ^8.0.3 + remark-stringify: ^8.1.1 + remark-sub-super: ^1.0.21 + sentence-case: ^3.0.4 + tar: ^6.1.15 + temp-dir: ^2.0.0 + tempy: ^1.0.1 + to-vfile: ^6.1.0 + trash: ^7.2.0 + unified: ^9.2.2 + unist-util-filter: ^2.0.3 + unist-util-map: ^2.0.1 + unist-util-select: ^3.0.4 + vfile: ^4.2.1 + xlsx: ^0.18.5 + xml-js: ^1.6.11 + peerDependencies: + "@stencila/schema": 1.9.0 + bin: + encoda: dist/index.js + checksum: 08ab1d40e8dae6cadf7e346b477e7894df337eeb6407409703d5fcfb3db76d73331c659f1b0479d80d26722d44b506d9ca12c215659a5cdc69c6730aa29e3449 + languageName: node + linkType: hard + "@stencila/executa@npm:^1.15.7": version: 1.15.7 resolution: "@stencila/executa@npm:1.15.7" @@ -12321,6 +12392,7 @@ __metadata: "@stencila/encoda-1-0-6": "npm:@stencila/encoda@1.0.6" "@stencila/encoda-1-0-7": "npm:@stencila/encoda@1.0.7" "@stencila/encoda-1-0-8": "npm:@stencila/encoda@1.0.8" + "@stencila/encoda-1-0-9": "npm:@stencila/encoda@1.0.9" "@types/eslint": ^8.44.6 "@types/express": ^4.17.17 "@types/jest": ^29.5.6