Skip to content

Commit

Permalink
Add support for encoda version 1.0.7 [elifesciences/enhanced-preprint…
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisgo committed Sep 20, 2024
1 parent e16a8ae commit cb9cdd6
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 2 deletions.
5 changes: 3 additions & 2 deletions integration-tests/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ describe('api', () => {
.post('/')
.send(xml.toString())
.expect(200)
.then((response) => expect(response.headers['content-type']).toBe('application/vnd.elife.encoda.v1.0.6+json; charset=utf-8'));
.then((response) => expect(response.headers['content-type']).toBe('application/vnd.elife.encoda.v1.0.7+json; charset=utf-8'));
});

it.each([
'1.0.1',
'1.0.2',
'1.0.3',
'1.0.6',
'1.0.7',
])('should use the specified version - %s', async (version) => {
const mimeType = `application/vnd.elife.encoda.v${version}+json`;
await request(app)
Expand All @@ -33,7 +34,7 @@ describe('api', () => {
'unknown',
'1.0.4',
'1.0.5',
'1.0.7',
'1.0.8',
])('should error if you specify wrong version - %s', async (version) => {
const mimeType = `application/vnd.elife.encoda.v${version}+json`;
await request(app)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@stencila/encoda-1-0-2": "npm:@stencila/[email protected]",
"@stencila/encoda-1-0-3": "npm:@stencila/[email protected]",
"@stencila/encoda-1-0-6": "npm:@stencila/[email protected]",
"@stencila/encoda-1-0-7": "npm:@stencila/[email protected]",
"body-parser": "^1.20.2",
"express": "^4.18.2"
},
Expand Down
5 changes: 5 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { convert as convert_1_0_1 } from '@stencila/encoda-1-0-1';
import { convert as convert_1_0_2 } from '@stencila/encoda-1-0-2';
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 { mkdtempSync, writeFileSync, rmdirSync } from 'fs';
import { tmpdir } from 'os';

Expand Down Expand Up @@ -33,6 +34,10 @@ app.post('/', async (req, res) => {
const replacementPath = typeof req.query.replacementPath === 'string' ? req.query.replacementPath : '';

const versionResponders = {
'application/vnd.elife.encoda.v1.0.7+json': async () => {
res.json(JSON.parse(((await convert_1_0_7(xmlFile, undefined, parameters)) ?? '{}').replaceAll(tempOutput, replacementPath)));
rmdirSync(tempOutput, { recursive: true });
},
'application/vnd.elife.encoda.v1.0.6+json': async () => {
res.json(JSON.parse(((await convert_1_0_6(xmlFile, undefined, parameters)) ?? '{}').replaceAll(tempOutput, replacementPath)));
rmdirSync(tempOutput, { recursive: true });
Expand Down
72 changes: 72 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,77 @@ __metadata:
languageName: node
linkType: hard

"@stencila/encoda-1-0-7@npm:@stencila/[email protected]":
version: 1.0.7
resolution: "@stencila/encoda@npm:1.0.7"
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: 498033b11a2139a3c1d5a8eee64c13101da46fe5f654598b504d7d2f3a9b980f494ce19e1226931d4509f562e480fd5d8491173c4c9538582fbc8a40b55d5aa5
languageName: node
linkType: hard

"@stencila/executa@npm:^1.15.7":
version: 1.15.7
resolution: "@stencila/executa@npm:1.15.7"
Expand Down Expand Up @@ -12170,6 +12241,7 @@ __metadata:
"@stencila/encoda-1-0-2": "npm:@stencila/[email protected]"
"@stencila/encoda-1-0-3": "npm:@stencila/[email protected]"
"@stencila/encoda-1-0-6": "npm:@stencila/[email protected]"
"@stencila/encoda-1-0-7": "npm:@stencila/[email protected]"
"@types/eslint": ^8.44.6
"@types/express": ^4.17.17
"@types/jest": ^29.5.6
Expand Down

0 comments on commit cb9cdd6

Please sign in to comment.