@manuscripts/transform 2.3.36 → 2.3.37-LEAN-3911.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/jats/importer/create-article-node.js +31 -0
- package/dist/cjs/jats/importer/index.js +3 -3
- package/dist/cjs/jats/importer/jats-body-transformations.js +70 -0
- package/dist/cjs/jats/importer/jats-comments.js +27 -104
- package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +229 -9
- package/dist/cjs/jats/importer/jats-front-transformations.js +262 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +8 -1
- package/dist/cjs/jats/importer/jats-parser-utils.js +39 -5
- package/dist/cjs/jats/importer/jats-reference-parser.js +16 -27
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +42 -78
- package/dist/cjs/jats/index.js +4 -3
- package/dist/cjs/jats/jats-exporter.js +251 -354
- package/dist/cjs/{transformer → jats}/labels.js +3 -3
- package/dist/cjs/lib/utils.js +9 -1
- package/dist/cjs/transformer/id.js +10 -5
- package/dist/cjs/transformer/index.js +0 -18
- package/dist/cjs/version.js +1 -1
- package/dist/{cjs/transformer/serializer.js → es/jats/importer/create-article-node.js} +12 -8
- package/dist/es/jats/importer/index.js +2 -1
- package/dist/es/jats/importer/jats-body-transformations.js +70 -0
- package/dist/es/jats/importer/jats-comments.js +26 -101
- package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +230 -10
- package/dist/es/jats/importer/jats-front-transformations.js +259 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +6 -0
- package/dist/es/jats/importer/jats-parser-utils.js +40 -6
- package/dist/es/jats/importer/jats-reference-parser.js +16 -27
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +43 -77
- package/dist/es/jats/index.js +3 -1
- package/dist/es/jats/jats-exporter.js +253 -356
- package/dist/es/{transformer → jats}/labels.js +3 -3
- package/dist/es/lib/utils.js +7 -0
- package/dist/es/transformer/id.js +8 -3
- package/dist/es/transformer/index.js +0 -16
- package/dist/es/version.js +1 -1
- package/dist/{cjs/transformer/models.js → types/jats/importer/create-article-node.d.ts} +3 -3
- package/dist/types/jats/importer/index.d.ts +2 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +5 -0
- package/dist/types/jats/importer/jats-comments.d.ts +4 -10
- package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-front-transformations.d.ts +38 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +10 -0
- package/dist/types/jats/importer/jats-references.d.ts +19 -8
- package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
- package/dist/types/jats/index.d.ts +3 -1
- package/dist/types/jats/jats-exporter.d.ts +10 -29
- package/dist/types/{transformer → jats}/labels.d.ts +2 -1
- package/dist/types/lib/utils.d.ts +3 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +28 -5
- package/dist/types/schema/nodes/contributor.d.ts +10 -0
- package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
- package/dist/types/transformer/id.d.ts +5 -2
- package/dist/types/transformer/index.d.ts +0 -16
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -2
- package/dist/cjs/__tests__/data/project-dump.json +0 -825
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
- package/dist/cjs/transformer/builders.js +0 -219
- package/dist/cjs/transformer/decode.js +0 -874
- package/dist/cjs/transformer/document-object-types.js +0 -31
- package/dist/cjs/transformer/encode.js +0 -664
- package/dist/cjs/transformer/footnote-category.js +0 -20
- package/dist/cjs/transformer/footnotes-order.js +0 -60
- package/dist/cjs/transformer/highlight-markers.js +0 -138
- package/dist/cjs/transformer/html.js +0 -400
- package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
- package/dist/cjs/transformer/model-map.js +0 -26
- package/dist/cjs/transformer/object-types.js +0 -57
- package/dist/cjs/transformer/project-bundle.js +0 -94
- package/dist/cjs/transformer/update-identifiers.js +0 -93
- package/dist/es/__tests__/data/project-dump.json +0 -825
- package/dist/es/jats/importer/jats-front-parser.js +0 -315
- package/dist/es/transformer/__tests__/__helpers__/doc.js +0 -29
- package/dist/es/transformer/builders.js +0 -186
- package/dist/es/transformer/decode.js +0 -864
- package/dist/es/transformer/document-object-types.js +0 -28
- package/dist/es/transformer/encode.js +0 -654
- package/dist/es/transformer/footnote-category.js +0 -16
- package/dist/es/transformer/footnotes-order.js +0 -55
- package/dist/es/transformer/highlight-markers.js +0 -132
- package/dist/es/transformer/html.js +0 -393
- package/dist/es/transformer/manuscript-dependencies.js +0 -17
- package/dist/es/transformer/model-map.js +0 -22
- package/dist/es/transformer/models.js +0 -16
- package/dist/es/transformer/object-types.js +0 -52
- package/dist/es/transformer/project-bundle.js +0 -85
- package/dist/es/transformer/serializer.js +0 -17
- package/dist/es/transformer/update-identifiers.js +0 -87
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
- package/dist/types/transformer/builders.d.ts +0 -61
- package/dist/types/transformer/decode.d.ts +0 -51
- package/dist/types/transformer/document-object-types.d.ts +0 -17
- package/dist/types/transformer/encode.d.ts +0 -29
- package/dist/types/transformer/footnote-category.d.ts +0 -17
- package/dist/types/transformer/footnotes-order.d.ts +0 -22
- package/dist/types/transformer/highlight-markers.d.ts +0 -31
- package/dist/types/transformer/html.d.ts +0 -36
- package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
- package/dist/types/transformer/model-map.d.ts +0 -19
- package/dist/types/transformer/models.d.ts +0 -48
- package/dist/types/transformer/object-types.d.ts +0 -30
- package/dist/types/transformer/project-bundle.d.ts +0 -30
- package/dist/types/transformer/serializer.d.ts +0 -19
- package/dist/types/transformer/update-identifiers.d.ts +0 -23
- /package/dist/cjs/{transformer → jats}/filename.js +0 -0
- /package/dist/cjs/{transformer → jats}/timestamp.js +0 -0
- /package/dist/es/{transformer → jats}/filename.js +0 -0
- /package/dist/es/{transformer → jats}/timestamp.js +0 -0
- /package/dist/types/{transformer → jats}/filename.d.ts +0 -0
- /package/dist/types/{transformer → jats}/timestamp.d.ts +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.isKeyword = exports.isCommentAnnotation = exports.isTable = exports.isManuscript = exports.isFigure = exports.hasObjectType = exports.isManuscriptModel = exports.manuscriptObjects = exports.elementObjects = exports.ExtraObjectTypes = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
|
-
var ExtraObjectTypes;
|
|
21
|
-
(function (ExtraObjectTypes) {
|
|
22
|
-
ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
|
|
23
|
-
ExtraObjectTypes["GeneralTableFootnote"] = "MPGeneralTableFootnote";
|
|
24
|
-
})(ExtraObjectTypes = exports.ExtraObjectTypes || (exports.ExtraObjectTypes = {}));
|
|
25
|
-
exports.elementObjects = [
|
|
26
|
-
json_schema_1.ObjectTypes.BibliographyElement,
|
|
27
|
-
json_schema_1.ObjectTypes.EquationElement,
|
|
28
|
-
json_schema_1.ObjectTypes.FigureElement,
|
|
29
|
-
json_schema_1.ObjectTypes.FootnotesElement,
|
|
30
|
-
json_schema_1.ObjectTypes.ListElement,
|
|
31
|
-
json_schema_1.ObjectTypes.ListingElement,
|
|
32
|
-
json_schema_1.ObjectTypes.ParagraphElement,
|
|
33
|
-
json_schema_1.ObjectTypes.TableElement,
|
|
34
|
-
json_schema_1.ObjectTypes.TOCElement,
|
|
35
|
-
];
|
|
36
|
-
exports.manuscriptObjects = [
|
|
37
|
-
json_schema_1.ObjectTypes.Affiliation,
|
|
38
|
-
json_schema_1.ObjectTypes.Citation,
|
|
39
|
-
json_schema_1.ObjectTypes.CommentAnnotation,
|
|
40
|
-
json_schema_1.ObjectTypes.Contributor,
|
|
41
|
-
json_schema_1.ObjectTypes.Footnote,
|
|
42
|
-
json_schema_1.ObjectTypes.Section,
|
|
43
|
-
].concat(exports.elementObjects);
|
|
44
|
-
const isManuscriptModel = (model) => {
|
|
45
|
-
if (!model.objectType) {
|
|
46
|
-
throw new Error('Model must have objectType');
|
|
47
|
-
}
|
|
48
|
-
return json_schema_1.manuscriptIDTypes.has(model.objectType);
|
|
49
|
-
};
|
|
50
|
-
exports.isManuscriptModel = isManuscriptModel;
|
|
51
|
-
const hasObjectType = (objectType) => (model) => model.objectType === objectType;
|
|
52
|
-
exports.hasObjectType = hasObjectType;
|
|
53
|
-
exports.isFigure = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Figure);
|
|
54
|
-
exports.isManuscript = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
|
|
55
|
-
exports.isTable = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Table);
|
|
56
|
-
exports.isCommentAnnotation = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.CommentAnnotation);
|
|
57
|
-
exports.isKeyword = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.findTitles = exports.findManuscriptById = exports.findManuscriptModelByType = exports.findJournal = exports.findManuscript = exports.parseProjectBundle = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
|
-
const decode_1 = require("./decode");
|
|
21
|
-
const object_types_1 = require("./object-types");
|
|
22
|
-
const parseProjectBundle = (projectBundle, manuscriptID) => {
|
|
23
|
-
const manuscriptData = manuscriptID
|
|
24
|
-
? projectBundle.data.filter((doc) => !doc.manuscriptID || doc.manuscriptID === manuscriptID)
|
|
25
|
-
: projectBundle.data;
|
|
26
|
-
const modelMap = new Map();
|
|
27
|
-
for (const component of manuscriptData) {
|
|
28
|
-
modelMap.set(component._id, component);
|
|
29
|
-
}
|
|
30
|
-
const decoder = new decode_1.Decoder(modelMap);
|
|
31
|
-
const doc = decoder.createArticleNode();
|
|
32
|
-
return { doc, modelMap };
|
|
33
|
-
};
|
|
34
|
-
exports.parseProjectBundle = parseProjectBundle;
|
|
35
|
-
const isManuscript = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
|
|
36
|
-
const findManuscript = (modelMap) => {
|
|
37
|
-
for (const model of modelMap.values()) {
|
|
38
|
-
if (isManuscript(model)) {
|
|
39
|
-
return model;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
throw new Error('No manuscript found');
|
|
43
|
-
};
|
|
44
|
-
exports.findManuscript = findManuscript;
|
|
45
|
-
const isJournal = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Journal);
|
|
46
|
-
const findJournal = (modelMap) => {
|
|
47
|
-
for (const model of modelMap.values()) {
|
|
48
|
-
if (isJournal(model)) {
|
|
49
|
-
return model;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
};
|
|
54
|
-
exports.findJournal = findJournal;
|
|
55
|
-
const isManuscriptModel = (model) => 'manuscriptID' in model;
|
|
56
|
-
const findManuscriptModelByType = (modelMap, manuscript, objectType) => {
|
|
57
|
-
for (const model of modelMap.values()) {
|
|
58
|
-
if (model.objectType === objectType &&
|
|
59
|
-
isManuscriptModel(model) &&
|
|
60
|
-
manuscript._id === model.manuscriptID) {
|
|
61
|
-
return model;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
exports.findManuscriptModelByType = findManuscriptModelByType;
|
|
66
|
-
const findManuscriptById = (modelMap, manuscriptID) => {
|
|
67
|
-
const manuscript = modelMap.get(manuscriptID);
|
|
68
|
-
if (manuscript && isManuscript(manuscript)) {
|
|
69
|
-
return manuscript;
|
|
70
|
-
}
|
|
71
|
-
throw new Error(`There is no manuscript found for the following _id (${manuscriptID})`);
|
|
72
|
-
};
|
|
73
|
-
exports.findManuscriptById = findManuscriptById;
|
|
74
|
-
const isTitle = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Titles);
|
|
75
|
-
const findTitles = (modelMap) => {
|
|
76
|
-
for (const model of modelMap.values()) {
|
|
77
|
-
if (isTitle(model)) {
|
|
78
|
-
return model;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const defaultTitle = {
|
|
82
|
-
_id: 'MPTitles:8EB79C14-9F61-483A-902F-A0B8EF5973C1',
|
|
83
|
-
createdAt: 1538472121.690101,
|
|
84
|
-
updatedAt: 1538472121.690101,
|
|
85
|
-
objectType: 'MPTitles',
|
|
86
|
-
title: 'main title',
|
|
87
|
-
subtitle: 'subtitle',
|
|
88
|
-
runningTitle: 'running title',
|
|
89
|
-
manuscriptID: 'MPManuscript:E3830344-E77B-42BA-BD77-3E95489712A0',
|
|
90
|
-
containerID: 'MPProject:1',
|
|
91
|
-
};
|
|
92
|
-
return defaultTitle;
|
|
93
|
-
};
|
|
94
|
-
exports.findTitles = findTitles;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2020 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.updateAttachments = exports.updateAttachmentPath = exports.updateIdentifiers = void 0;
|
|
19
|
-
const id_1 = require("./id");
|
|
20
|
-
const updateIdentifiers = async (data) => {
|
|
21
|
-
const idMap = new Map();
|
|
22
|
-
const updateIDs = (model) => {
|
|
23
|
-
const { _id, objectType } = model;
|
|
24
|
-
if (!objectType || !_id || !_id.match(/^MP.+:.+/)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (idMap.has(_id)) {
|
|
28
|
-
model._id = idMap.get(_id);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
model._id = (0, id_1.generateID)(objectType);
|
|
32
|
-
idMap.set(_id, model._id);
|
|
33
|
-
}
|
|
34
|
-
for (const value of Object.values(model)) {
|
|
35
|
-
if (Array.isArray(value)) {
|
|
36
|
-
value.forEach(updateIDs);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
updateIDs(value);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const replaceContent = (content) => {
|
|
44
|
-
content = content.replace(/MP\w+:[\w-]+/g, (match) => {
|
|
45
|
-
const value = idMap.get(match);
|
|
46
|
-
return value !== null && value !== void 0 ? value : match;
|
|
47
|
-
});
|
|
48
|
-
content = content.replace(/MP\w+_[\w-]+/g, (match) => {
|
|
49
|
-
const value = idMap.get(match.replace('_', ':'));
|
|
50
|
-
return value ? value.replace(':', '_') : match;
|
|
51
|
-
});
|
|
52
|
-
return content;
|
|
53
|
-
};
|
|
54
|
-
const updateContent = (model) => {
|
|
55
|
-
for (const [key, value] of Object.entries(model)) {
|
|
56
|
-
if (typeof value === 'object') {
|
|
57
|
-
updateContent(value);
|
|
58
|
-
}
|
|
59
|
-
else if (typeof value === 'string') {
|
|
60
|
-
model[key] = replaceContent(value);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
for (const item of data) {
|
|
65
|
-
updateIDs(item);
|
|
66
|
-
}
|
|
67
|
-
for (const item of data) {
|
|
68
|
-
updateContent(item);
|
|
69
|
-
}
|
|
70
|
-
return { data, idMap };
|
|
71
|
-
};
|
|
72
|
-
exports.updateIdentifiers = updateIdentifiers;
|
|
73
|
-
const updateAttachmentPath = (oldPath, idMap) => {
|
|
74
|
-
const matches = oldPath.match(/^Data\/([^.]+)(.*)/);
|
|
75
|
-
if (matches) {
|
|
76
|
-
const [, prefix, suffix] = matches;
|
|
77
|
-
const id = idMap.get(prefix.replace('_', ':'));
|
|
78
|
-
if (id) {
|
|
79
|
-
const newPrefix = id.replace(':', '_');
|
|
80
|
-
return `Data/${newPrefix}${suffix}`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
exports.updateAttachmentPath = updateAttachmentPath;
|
|
85
|
-
const updateAttachments = async (zip, idMap) => {
|
|
86
|
-
for (const [oldPath, entry] of Object.entries(zip.files)) {
|
|
87
|
-
const newPath = (0, exports.updateAttachmentPath)(oldPath, idMap);
|
|
88
|
-
if (newPath) {
|
|
89
|
-
zip.file(newPath, await entry.async('blob')).remove(oldPath);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
exports.updateAttachments = updateAttachments;
|