Skip to content

Commit

Permalink
Update to encoda 1.0.9 to improve reference data [elifesciences/enhan…
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisgo committed Oct 24, 2024
1 parent 3c0a3d4 commit b6dadbf
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,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([
Expand All @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@stencila/encoda-1-0-6": "npm:@stencila/[email protected]",
"@stencila/encoda-1-0-7": "npm:@stencila/[email protected]",
"@stencila/encoda-1-0-8": "npm:@stencila/[email protected]",
"@stencila/encoda-1-0-9": "npm:@stencila/[email protected]",
"body-parser": "^1.20.3",
"express": "^4.21.1"
},
Expand Down
5 changes: 5 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 });
Expand Down
72 changes: 72 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,77 @@ __metadata:
languageName: node
linkType: hard

"@stencila/encoda-1-0-9@npm:@stencila/[email protected]":
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"
Expand Down Expand Up @@ -12321,6 +12392,7 @@ __metadata:
"@stencila/encoda-1-0-6": "npm:@stencila/[email protected]"
"@stencila/encoda-1-0-7": "npm:@stencila/[email protected]"
"@stencila/encoda-1-0-8": "npm:@stencila/[email protected]"
"@stencila/encoda-1-0-9": "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 b6dadbf

Please sign in to comment.