@manuscripts/transform 2.3.38-LEAN-3911.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/__tests__/data/project-dump.json +825 -0
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/jats/importer/index.js +22 -0
- package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +34 -273
- package/dist/cjs/jats/importer/jats-body-transformations.js +22 -74
- package/dist/cjs/jats/importer/jats-comments.js +104 -27
- package/dist/cjs/jats/importer/jats-front-parser.js +321 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +1 -8
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -43
- package/dist/cjs/jats/importer/jats-reference-parser.js +23 -16
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +79 -40
- package/dist/cjs/jats/index.js +7 -7
- package/dist/cjs/jats/{exporter/jats-exporter.js → jats-exporter.js} +398 -264
- package/dist/cjs/jats/{exporter/jats-versions.js → jats-versions.js} +3 -1
- package/dist/cjs/lib/utils.js +1 -12
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
- package/dist/cjs/transformer/builders.js +219 -0
- package/dist/cjs/transformer/decode.js +898 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +674 -0
- package/dist/cjs/{jats/importer/create-article-node.js → transformer/filename.js} +9 -10
- package/dist/cjs/transformer/footnote-category.js +20 -0
- package/dist/cjs/transformer/footnotes-order.js +60 -0
- package/dist/cjs/transformer/highlight-markers.js +138 -0
- package/dist/cjs/transformer/html.js +400 -0
- package/dist/cjs/transformer/id.js +5 -10
- package/dist/cjs/transformer/index.js +18 -0
- package/dist/cjs/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/{lib/deafults.js → transformer/models.js} +1 -3
- package/dist/cjs/transformer/node-names.js +1 -0
- package/dist/cjs/transformer/object-types.js +57 -0
- package/dist/cjs/transformer/project-bundle.js +94 -0
- package/dist/cjs/transformer/serializer.js +23 -0
- package/dist/cjs/transformer/timestamp.js +20 -0
- package/dist/cjs/transformer/update-identifiers.js +93 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/__tests__/data/project-dump.json +825 -0
- package/dist/es/index.js +5 -5
- package/dist/{types/jats/importer/create-article-node.d.ts → es/jats/importer/index.js} +2 -3
- package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +35 -274
- package/dist/es/jats/importer/jats-body-transformations.js +22 -74
- package/dist/es/jats/importer/jats-comments.js +101 -26
- package/dist/es/jats/importer/jats-front-parser.js +315 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -6
- package/dist/es/jats/importer/jats-parser-utils.js +6 -44
- package/dist/es/jats/importer/jats-reference-parser.js +23 -16
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +78 -41
- package/dist/es/jats/index.js +3 -5
- package/dist/es/jats/{exporter/jats-exporter.js → jats-exporter.js} +392 -258
- package/dist/es/jats/{exporter/jats-versions.js → jats-versions.js} +1 -0
- package/dist/es/lib/utils.js +0 -9
- package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
- package/dist/es/transformer/builders.js +186 -0
- package/dist/es/transformer/decode.js +888 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +664 -0
- package/dist/es/transformer/filename.js +23 -0
- package/dist/es/transformer/footnote-category.js +16 -0
- package/dist/es/transformer/footnotes-order.js +55 -0
- package/dist/es/transformer/highlight-markers.js +132 -0
- package/dist/es/transformer/html.js +393 -0
- package/dist/es/transformer/id.js +3 -8
- package/dist/es/transformer/index.js +16 -0
- package/dist/es/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/es/transformer/manuscript-dependencies.js +17 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/{lib/deafults.js → transformer/models.js} +2 -2
- package/dist/es/transformer/node-names.js +1 -0
- package/dist/es/transformer/object-types.js +52 -0
- package/dist/es/transformer/project-bundle.js +85 -0
- package/dist/es/transformer/serializer.js +17 -0
- package/dist/es/transformer/timestamp.js +16 -0
- package/dist/es/transformer/update-identifiers.js +87 -0
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/jats/importer/index.d.ts +16 -0
- package/dist/types/jats/importer/{jats-dom-parser.d.ts → jats-body-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -5
- package/dist/types/jats/importer/jats-comments.d.ts +10 -4
- package/dist/types/jats/importer/jats-front-parser.d.ts +84 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -10
- package/dist/types/jats/importer/jats-references.d.ts +8 -19
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -12
- package/dist/types/jats/index.d.ts +3 -5
- package/dist/types/jats/{exporter/jats-exporter.d.ts → jats-exporter.d.ts} +29 -15
- package/dist/types/jats/{exporter/jats-versions.d.ts → jats-versions.d.ts} +1 -0
- package/dist/types/lib/utils.d.ts +0 -2
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/types/schema/nodes/contributor.d.ts +0 -10
- package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
- package/dist/types/schema/nodes/manuscript.d.ts +7 -8
- package/dist/types/schema/nodes/title.d.ts +3 -0
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +18 -0
- package/dist/types/transformer/builders.d.ts +61 -0
- package/dist/types/transformer/decode.d.ts +52 -0
- package/dist/types/transformer/document-object-types.d.ts +17 -0
- package/dist/types/transformer/encode.d.ts +29 -0
- package/dist/types/transformer/filename.d.ts +16 -0
- package/dist/types/transformer/footnote-category.d.ts +17 -0
- package/dist/{es/jats/importer/create-article-node.js → types/transformer/footnotes-order.d.ts} +8 -10
- package/dist/types/transformer/highlight-markers.d.ts +31 -0
- package/dist/types/transformer/html.d.ts +36 -0
- package/dist/types/transformer/id.d.ts +2 -5
- package/dist/types/transformer/index.d.ts +16 -0
- package/dist/types/{jats/exporter → transformer}/labels.d.ts +2 -2
- package/dist/types/transformer/manuscript-dependencies.d.ts +4 -0
- package/dist/types/transformer/model-map.d.ts +19 -0
- package/dist/types/transformer/models.d.ts +48 -0
- package/dist/types/transformer/object-types.d.ts +30 -0
- package/dist/types/transformer/project-bundle.d.ts +30 -0
- package/dist/types/transformer/serializer.d.ts +19 -0
- package/dist/types/{lib/deafults.d.ts → transformer/timestamp.d.ts} +2 -2
- package/dist/types/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cjs/jats/importer/jats-front-transformations.js +0 -79
- package/dist/es/jats/importer/jats-front-transformations.js +0 -76
- package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -22
- package/dist/types/jats/types.d.ts +0 -1
- /package/dist/cjs/{jats/types.js → types.js} +0 -0
- /package/dist/es/{jats/types.js → types.js} +0 -0
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2023 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.References = void 0;
|
|
19
4
|
class References {
|
|
20
5
|
constructor() {
|
|
21
6
|
this.items = new Map();
|
|
22
7
|
this.IDs = new Map();
|
|
8
|
+
this.comments = new Map();
|
|
23
9
|
}
|
|
24
|
-
add(item, id) {
|
|
25
|
-
this.items.set(item.
|
|
10
|
+
add(item, id, comments) {
|
|
11
|
+
this.items.set(item._id, item);
|
|
12
|
+
this.comments.set(item._id, comments);
|
|
26
13
|
if (id) {
|
|
27
|
-
this.IDs.set(id, item.
|
|
14
|
+
this.IDs.set(id, item._id);
|
|
28
15
|
}
|
|
29
16
|
}
|
|
30
17
|
getBibliographyItems() {
|
|
31
18
|
return [...this.items.values()];
|
|
32
19
|
}
|
|
20
|
+
getComments(id) {
|
|
21
|
+
return this.getValue(id, this.comments) || [];
|
|
22
|
+
}
|
|
23
|
+
getValue(id, map) {
|
|
24
|
+
const value = map.get(id);
|
|
25
|
+
if (value) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
const id2 = this.IDs.get(id);
|
|
29
|
+
if (id2) {
|
|
30
|
+
return map.get(id2);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
exports.References = References;
|
|
@@ -15,77 +15,116 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.parseJATSArticle = void 0;
|
|
18
|
+
exports.parseJATSArticle = exports.parseJATSBody = exports.parseJATSFront = void 0;
|
|
19
19
|
const errors_1 = require("../../errors");
|
|
20
|
+
const transformer_1 = require("../../transformer");
|
|
21
|
+
const builders_1 = require("../../transformer/builders");
|
|
22
|
+
const id_1 = require("../../transformer/id");
|
|
23
|
+
const project_bundle_1 = require("../../transformer/project-bundle");
|
|
24
|
+
const jats_body_dom_parser_1 = require("./jats-body-dom-parser");
|
|
20
25
|
const jats_body_transformations_1 = require("./jats-body-transformations");
|
|
21
26
|
const jats_comments_1 = require("./jats-comments");
|
|
22
|
-
const
|
|
23
|
-
const jats_front_transformations_1 = require("./jats-front-transformations");
|
|
24
|
-
const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
|
|
27
|
+
const jats_front_parser_1 = require("./jats-front-parser");
|
|
25
28
|
const jats_parser_utils_1 = require("./jats-parser-utils");
|
|
26
29
|
const jats_reference_parser_1 = require("./jats-reference-parser");
|
|
30
|
+
const parseJATSFront = (doc, front) => {
|
|
31
|
+
const createElement = createElementFn(doc);
|
|
32
|
+
const journal = jats_front_parser_1.jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
|
|
33
|
+
const titles = jats_front_parser_1.jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
|
|
34
|
+
const DOI = jats_front_parser_1.jatsFrontParser.parseDOI(front);
|
|
35
|
+
const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
|
|
36
|
+
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
37
|
+
]);
|
|
38
|
+
const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
|
|
39
|
+
const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
|
|
40
|
+
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
41
|
+
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
42
|
+
const history = jats_front_parser_1.jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
43
|
+
const counts = jats_front_parser_1.jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
44
|
+
const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history), { DOI });
|
|
45
|
+
return generateIDs([
|
|
46
|
+
manuscript,
|
|
47
|
+
titles,
|
|
48
|
+
journal,
|
|
49
|
+
...authorNotesParagraphs,
|
|
50
|
+
...authorNotes,
|
|
51
|
+
...footnotes,
|
|
52
|
+
...authors,
|
|
53
|
+
...affiliations,
|
|
54
|
+
...correspondingList,
|
|
55
|
+
]);
|
|
56
|
+
};
|
|
57
|
+
exports.parseJATSFront = parseJATSFront;
|
|
27
58
|
const parseJATSBody = (doc, body, references) => {
|
|
28
59
|
const createElement = createElementFn(doc);
|
|
29
60
|
jats_body_transformations_1.jatsBodyTransformations.ensureSection(body, createElement);
|
|
30
61
|
jats_body_transformations_1.jatsBodyTransformations.moveCaptionsToEnd(body);
|
|
31
62
|
jats_body_transformations_1.jatsBodyTransformations.fixTables(body, createElement);
|
|
63
|
+
jats_body_transformations_1.jatsBodyTransformations.createBoxedElementSection(doc, body, createElement);
|
|
32
64
|
jats_body_transformations_1.jatsBodyTransformations.createBody(doc, body, createElement);
|
|
33
65
|
jats_body_transformations_1.jatsBodyTransformations.createAbstracts(doc, body, createElement);
|
|
34
66
|
jats_body_transformations_1.jatsBodyTransformations.createBackmatter(doc, body, createElement);
|
|
35
67
|
jats_body_transformations_1.jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
|
|
36
68
|
jats_body_transformations_1.jatsBodyTransformations.createKeywords(doc, body, createElement);
|
|
37
69
|
jats_body_transformations_1.jatsBodyTransformations.orderTableFootnote(doc, body);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const createElement = createElementFn(doc);
|
|
42
|
-
jats_front_transformations_1.jatsFrontTransformations.setArticleAttrs(doc, template);
|
|
43
|
-
const authorNotes = jats_front_transformations_1.jatsFrontTransformations.createAuthorNotes(doc, createElement);
|
|
44
|
-
if (authorNotes) {
|
|
45
|
-
doc.documentElement.prepend(authorNotes);
|
|
46
|
-
}
|
|
47
|
-
const affiliations = jats_front_transformations_1.jatsFrontTransformations.createAffiliations(front, createElement);
|
|
48
|
-
if (affiliations) {
|
|
49
|
-
doc.documentElement.prepend(affiliations);
|
|
50
|
-
}
|
|
51
|
-
const contributors = jats_front_transformations_1.jatsFrontTransformations.createContributors(front, createElement);
|
|
52
|
-
if (contributors) {
|
|
53
|
-
doc.documentElement.prepend(contributors);
|
|
54
|
-
}
|
|
55
|
-
const title = jats_front_transformations_1.jatsFrontTransformations.createTitle(front, createElement);
|
|
56
|
-
if (title) {
|
|
57
|
-
doc.documentElement.prepend(title);
|
|
70
|
+
const node = jats_body_dom_parser_1.jatsBodyDOMParser.parse(body).firstChild;
|
|
71
|
+
if (!node) {
|
|
72
|
+
throw new Error('No content was parsed from the JATS article body');
|
|
58
73
|
}
|
|
74
|
+
const replacements = new Map(references === null || references === void 0 ? void 0 : references.IDs);
|
|
75
|
+
(0, jats_parser_utils_1.updateDocumentIDs)(node, replacements);
|
|
76
|
+
return (0, transformer_1.encode)(node).values();
|
|
77
|
+
};
|
|
78
|
+
exports.parseJATSBody = parseJATSBody;
|
|
79
|
+
const createBibliographyModels = (references) => {
|
|
80
|
+
const models = [];
|
|
81
|
+
const bibliographyItems = references.getBibliographyItems();
|
|
82
|
+
const bibliographyElement = (0, transformer_1.buildBibliographyElement)(bibliographyItems);
|
|
83
|
+
const bibliographySection = Object.assign(Object.assign({}, (0, transformer_1.buildSection)(99)), { category: 'MPSectionCategory:bibliography', elementIDs: [bibliographyElement._id], title: 'References' });
|
|
84
|
+
const comments = (0, jats_comments_1.createReferenceComments)(references);
|
|
85
|
+
models.push(bibliographySection);
|
|
86
|
+
models.push(bibliographyElement);
|
|
87
|
+
models.push(...bibliographyItems);
|
|
88
|
+
models.push(...comments);
|
|
89
|
+
return models;
|
|
59
90
|
};
|
|
60
91
|
const createElementFn = (doc) => (tagName) => doc.createElement(tagName);
|
|
61
|
-
const
|
|
92
|
+
const generateIDs = (models) => models.map((m) => m._id ? m : Object.assign(Object.assign({}, m), { _id: (0, id_1.generateID)(m.objectType) }));
|
|
93
|
+
const parseJATSArticle = (doc) => {
|
|
62
94
|
const article = doc.querySelector('article');
|
|
63
95
|
const front = doc.querySelector('front');
|
|
64
96
|
const body = doc.querySelector('body');
|
|
65
97
|
const back = doc.querySelector('back');
|
|
66
|
-
if (!
|
|
67
|
-
throw new errors_1.InvalidInput('
|
|
98
|
+
if (!front) {
|
|
99
|
+
throw new errors_1.InvalidInput('Invalid JATS format! Missing front element');
|
|
100
|
+
}
|
|
101
|
+
if (!article) {
|
|
102
|
+
throw new errors_1.InvalidInput('Invalid JATS format! Missing article element');
|
|
68
103
|
}
|
|
69
|
-
(0, jats_comments_1.markComments)(doc);
|
|
70
|
-
const journal = (0, jats_journal_meta_parser_1.parseJournal)(front.querySelector('journal-meta'));
|
|
104
|
+
const marks = (0, jats_comments_1.markComments)(doc);
|
|
71
105
|
const createElement = createElementFn(doc);
|
|
106
|
+
const models = [];
|
|
72
107
|
let references;
|
|
73
108
|
if (back) {
|
|
74
109
|
references = jats_reference_parser_1.jatsReferenceParser.parseReferences([...back.querySelectorAll('ref-list > ref')], createElement);
|
|
75
110
|
}
|
|
76
|
-
|
|
77
|
-
parseJATSFront(doc, front, template);
|
|
111
|
+
models.push(...(0, exports.parseJATSFront)(doc, front));
|
|
78
112
|
if (body) {
|
|
79
|
-
parseJATSBody(doc, body, references);
|
|
113
|
+
models.push(...(0, exports.parseJATSBody)(doc, body, references));
|
|
80
114
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
115
|
+
const modelMap = new Map(models.map((model) => [model._id, model]));
|
|
116
|
+
const manuscript = (0, project_bundle_1.findManuscript)(modelMap);
|
|
117
|
+
if (manuscript) {
|
|
118
|
+
const type = article.getAttribute('article-type');
|
|
119
|
+
manuscript.articleType = type || 'other';
|
|
84
120
|
}
|
|
85
|
-
(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
121
|
+
if (references && references.items.size) {
|
|
122
|
+
models.push(...createBibliographyModels(references));
|
|
123
|
+
}
|
|
124
|
+
if (marks.length) {
|
|
125
|
+
const comments = (0, jats_comments_1.createComments)(models, marks);
|
|
126
|
+
models.push(...comments);
|
|
127
|
+
}
|
|
128
|
+
return models;
|
|
90
129
|
};
|
|
91
130
|
exports.parseJATSArticle = parseJATSArticle;
|
package/dist/cjs/jats/index.js
CHANGED
|
@@ -29,10 +29,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
29
29
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.parseJATSArticle = void 0;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
exports.parseJATSArticle = exports.parseJATSBody = exports.parseJATSFront = void 0;
|
|
33
|
+
var importer_1 = require("./importer");
|
|
34
|
+
Object.defineProperty(exports, "parseJATSFront", { enumerable: true, get: function () { return importer_1.parseJATSFront; } });
|
|
35
|
+
Object.defineProperty(exports, "parseJATSBody", { enumerable: true, get: function () { return importer_1.parseJATSBody; } });
|
|
36
|
+
Object.defineProperty(exports, "parseJATSArticle", { enumerable: true, get: function () { return importer_1.parseJATSArticle; } });
|
|
37
|
+
__exportStar(require("./jats-exporter"), exports);
|
|
38
|
+
__exportStar(require("./jats-versions"), exports);
|