@manuscripts/transform 1.3.2 → 1.3.4-LEAN-2501-test

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.
Files changed (30) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +6 -3
  2. package/dist/cjs/jats/importer/jats-body-transformations.js +5 -1
  3. package/dist/cjs/jats/importer/jats-comments.js +2 -1
  4. package/dist/cjs/jats/importer/jats-front-parser.js +27 -24
  5. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +10 -6
  6. package/dist/cjs/jats/importer/jats-reference-parser.js +18 -17
  7. package/dist/cjs/jats/jats-exporter.js +0 -24
  8. package/dist/cjs/lib/utils.js +9 -1
  9. package/dist/cjs/transformer/builders.js +1 -13
  10. package/dist/cjs/transformer/decode.js +1 -1
  11. package/dist/cjs/transformer/labels.js +2 -1
  12. package/dist/cjs/transformer/manuscript-dependencies.js +1 -1
  13. package/dist/cjs/transformer/project-bundle.js +1 -14
  14. package/dist/es/jats/importer/jats-body-dom-parser.js +6 -3
  15. package/dist/es/jats/importer/jats-body-transformations.js +5 -1
  16. package/dist/es/jats/importer/jats-comments.js +2 -1
  17. package/dist/es/jats/importer/jats-front-parser.js +27 -24
  18. package/dist/es/jats/importer/jats-journal-meta-parser.js +10 -6
  19. package/dist/es/jats/importer/jats-reference-parser.js +18 -17
  20. package/dist/es/jats/jats-exporter.js +1 -25
  21. package/dist/es/lib/utils.js +7 -0
  22. package/dist/es/transformer/builders.js +0 -10
  23. package/dist/es/transformer/decode.js +1 -1
  24. package/dist/es/transformer/labels.js +2 -1
  25. package/dist/es/transformer/manuscript-dependencies.js +1 -1
  26. package/dist/es/transformer/project-bundle.js +0 -12
  27. package/dist/types/lib/utils.d.ts +1 -0
  28. package/dist/types/transformer/builders.d.ts +1 -3
  29. package/dist/types/transformer/project-bundle.d.ts +1 -2
  30. package/package.json +2 -2
@@ -649,10 +649,11 @@ const nodes = [
649
649
  tag: 'xref[ref-type="bibr"]',
650
650
  node: 'citation',
651
651
  getAttrs: (node) => {
652
+ var _a;
652
653
  const element = node;
653
654
  return {
654
655
  rid: element.getAttribute('rid'),
655
- contents: element.textContent,
656
+ contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
656
657
  };
657
658
  },
658
659
  },
@@ -660,10 +661,11 @@ const nodes = [
660
661
  tag: 'xref[ref-type="fn"]',
661
662
  node: 'inline_footnote',
662
663
  getAttrs: (node) => {
664
+ var _a;
663
665
  const element = node;
664
666
  return {
665
667
  rid: element.getAttribute('rid'),
666
- contents: element.textContent,
668
+ contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
667
669
  };
668
670
  },
669
671
  },
@@ -671,10 +673,11 @@ const nodes = [
671
673
  tag: 'xref',
672
674
  node: 'cross_reference',
673
675
  getAttrs: (node) => {
676
+ var _a;
674
677
  const element = node;
675
678
  return {
676
679
  rid: element.getAttribute('rid'),
677
- label: element.textContent,
680
+ label: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
678
681
  };
679
682
  },
680
683
  },
@@ -215,6 +215,7 @@ exports.jatsBodyTransformations = {
215
215
  body.append(backmatterContainer);
216
216
  },
217
217
  mapFootnotesToSections(doc, backmatterContainer, createElement) {
218
+ var _a;
218
219
  const footnoteGroups = [...doc.querySelectorAll('fn[fn-type]')];
219
220
  for (const footnote of footnoteGroups) {
220
221
  const type = footnote.getAttribute('fn-type') || '';
@@ -224,7 +225,10 @@ exports.jatsBodyTransformations = {
224
225
  const title = footnote.querySelector('p[content-type="fn-title"]');
225
226
  if (title) {
226
227
  const sectionTitleElement = createElement('title');
227
- sectionTitleElement.textContent = title.textContent;
228
+ const titleTextContent = (_a = title.textContent) === null || _a === void 0 ? void 0 : _a.trim();
229
+ if (titleTextContent) {
230
+ sectionTitleElement.textContent = titleTextContent;
231
+ }
228
232
  removeNodeFromParent(title);
229
233
  section.append(sectionTitleElement);
230
234
  }
@@ -21,7 +21,8 @@ const transformer_1 = require("../../transformer");
21
21
  const DEFAULT_ANNOTATION_COLOR = 'rgb(250, 224, 150)';
22
22
  const DEFAULT_PROFILE_ID = 'MPUserProfile:0000000000000000000000000000000000000001';
23
23
  const parseProcessingInstruction = (node) => {
24
- const value = `<AuthorQuery ${node.textContent} />`;
24
+ var _a;
25
+ const value = `<AuthorQuery ${(_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()} />`;
25
26
  const processingInstruction = new DOMParser().parseFromString(value, 'application/xml').firstElementChild;
26
27
  if (processingInstruction) {
27
28
  const queryText = processingInstruction.getAttribute('queryText');
@@ -20,6 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.jatsFrontParser = void 0;
22
22
  const debug_1 = __importDefault(require("debug"));
23
+ const utils_1 = require("../../lib/utils");
23
24
  const builders_1 = require("../../transformer/builders");
24
25
  const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
25
26
  const warn = (0, debug_1.default)('manuscripts-transform');
@@ -74,11 +75,10 @@ exports.jatsFrontParser = {
74
75
  }
75
76
  const history = {};
76
77
  const dateToTimestamp = (dateElement) => {
77
- var _a, _b;
78
78
  const selectors = ['year', 'month', 'day'];
79
79
  const values = [];
80
80
  for (const selector of selectors) {
81
- const value = (_b = (_a = dateElement.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
81
+ const value = (0, utils_1.getTrimmedTextContent)(dateElement, selector);
82
82
  if (!value || isNaN(+value)) {
83
83
  return;
84
84
  }
@@ -118,17 +118,17 @@ exports.jatsFrontParser = {
118
118
  return history;
119
119
  },
120
120
  parseSupplements(supplementNodes) {
121
- var _a, _b, _c, _d, _e;
121
+ var _a, _b, _c, _d;
122
122
  if (!supplementNodes || supplementNodes.length === 0) {
123
123
  return [];
124
124
  }
125
125
  const supplements = [];
126
126
  for (const supplementNode of supplementNodes) {
127
- const supplTitle = (_b = (_a = supplementNode.querySelector('caption > title')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '';
128
- const href = (_c = supplementNode.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _c !== void 0 ? _c : '';
127
+ const supplTitle = (_a = (0, utils_1.getTrimmedTextContent)(supplementNode, 'caption > title')) !== null && _a !== void 0 ? _a : '';
128
+ const href = (_b = supplementNode.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _b !== void 0 ? _b : '';
129
129
  const supplementaryMaterial = (0, builders_1.buildSupplementaryMaterial)(supplTitle, href);
130
- const mimeType = (_d = supplementNode.getAttribute('mimetype')) !== null && _d !== void 0 ? _d : '';
131
- const mimeSubtype = (_e = supplementNode.getAttribute('mime-subtype')) !== null && _e !== void 0 ? _e : '';
130
+ const mimeType = (_c = supplementNode.getAttribute('mimetype')) !== null && _c !== void 0 ? _c : '';
131
+ const mimeSubtype = (_d = supplementNode.getAttribute('mime-subtype')) !== null && _d !== void 0 ? _d : '';
132
132
  if (mimeType && mimeSubtype) {
133
133
  supplementaryMaterial.MIME = [mimeType, mimeSubtype].join('/');
134
134
  }
@@ -139,10 +139,10 @@ exports.jatsFrontParser = {
139
139
  parseAffiliationNodes(affiliationNodes) {
140
140
  const affiliationIDs = new Map();
141
141
  const affiliations = affiliationNodes.map((affiliationNode, priority) => {
142
- var _a, _b, _c, _d, _e;
142
+ var _a, _b;
143
143
  const affiliation = (0, builders_1.buildAffiliation)('', priority);
144
144
  for (const node of affiliationNode.querySelectorAll('institution')) {
145
- const content = node.textContent;
145
+ const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
146
146
  if (!content) {
147
147
  continue;
148
148
  }
@@ -157,22 +157,25 @@ exports.jatsFrontParser = {
157
157
  }
158
158
  }
159
159
  affiliation.addressLine1 =
160
- ((_a = affiliationNode.querySelector('addr-line:nth-of-type(1)')) === null || _a === void 0 ? void 0 : _a.textContent) || undefined;
160
+ (0, utils_1.getTrimmedTextContent)(affiliationNode, 'addr-line:nth-of-type(1)') ||
161
+ undefined;
161
162
  affiliation.addressLine2 =
162
- ((_b = affiliationNode.querySelector('addr-line:nth-of-type(2)')) === null || _b === void 0 ? void 0 : _b.textContent) || undefined;
163
+ (0, utils_1.getTrimmedTextContent)(affiliationNode, 'addr-line:nth-of-type(2)') ||
164
+ undefined;
163
165
  affiliation.addressLine3 =
164
- ((_c = affiliationNode.querySelector('addr-line:nth-of-type(3)')) === null || _c === void 0 ? void 0 : _c.textContent) || undefined;
166
+ (0, utils_1.getTrimmedTextContent)(affiliationNode, 'addr-line:nth-of-type(3)') ||
167
+ undefined;
165
168
  const emailNode = affiliationNode.querySelector('email');
166
169
  if (emailNode) {
167
170
  affiliation.email = {
168
171
  href: emailNode.getAttributeNS(XLINK_NAMESPACE, 'href') || undefined,
169
- text: emailNode.textContent || undefined,
172
+ text: ((_b = emailNode.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
170
173
  };
171
174
  }
172
175
  affiliation.postCode =
173
- ((_d = affiliationNode.querySelector('postal-code')) === null || _d === void 0 ? void 0 : _d.textContent) || undefined;
176
+ (0, utils_1.getTrimmedTextContent)(affiliationNode, 'postal-code') || undefined;
174
177
  affiliation.country =
175
- ((_e = affiliationNode.querySelector('country')) === null || _e === void 0 ? void 0 : _e.textContent) || undefined;
178
+ (0, utils_1.getTrimmedTextContent)(affiliationNode, 'country') || undefined;
176
179
  const id = affiliationNode.getAttribute('id');
177
180
  if (id) {
178
181
  affiliationIDs.set(id, affiliation._id);
@@ -202,13 +205,13 @@ exports.jatsFrontParser = {
202
205
  parseCorrespNodes(correspNodes) {
203
206
  const correspondingIDs = new Map();
204
207
  const correspondingList = correspNodes.map((correspNode) => {
205
- var _a;
208
+ var _a, _b, _c;
206
209
  const label = correspNode.querySelector('label');
207
210
  if (label) {
208
211
  label.remove();
209
212
  }
210
- const corresponding = (0, builders_1.buildCorresp)((_a = correspNode.textContent) !== null && _a !== void 0 ? _a : '');
211
- corresponding.label = (label === null || label === void 0 ? void 0 : label.textContent) || undefined;
213
+ const corresponding = (0, builders_1.buildCorresp)((_b = (_a = correspNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
214
+ corresponding.label = ((_c = label === null || label === void 0 ? void 0 : label.textContent) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
212
215
  const id = correspNode.getAttribute('id');
213
216
  if (id) {
214
217
  correspondingIDs.set(id, corresponding._id);
@@ -222,13 +225,13 @@ exports.jatsFrontParser = {
222
225
  },
223
226
  parseAuthorNodes(authorNodes, affiliationIDs, footnoteIDs, correspondingIDs) {
224
227
  return authorNodes.map((authorNode, priority) => {
225
- var _a, _b, _c;
228
+ var _a, _b;
226
229
  const name = (0, builders_1.buildBibliographicName)({});
227
- const given = (_a = authorNode.querySelector('name > given-names')) === null || _a === void 0 ? void 0 : _a.textContent;
230
+ const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'name > given-names');
228
231
  if (given) {
229
232
  name.given = given;
230
233
  }
231
- const surname = (_b = authorNode.querySelector('name > surname')) === null || _b === void 0 ? void 0 : _b.textContent;
234
+ const surname = (0, utils_1.getTrimmedTextContent)(authorNode, 'name > surname');
232
235
  if (surname) {
233
236
  name.family = surname;
234
237
  }
@@ -237,7 +240,7 @@ exports.jatsFrontParser = {
237
240
  if (corresponding) {
238
241
  contributor.isCorresponding = corresponding;
239
242
  }
240
- const orcid = (_c = authorNode.querySelector('contrib-id[contrib-id-type="orcid"]')) === null || _c === void 0 ? void 0 : _c.textContent;
243
+ const orcid = (0, utils_1.getTrimmedTextContent)(authorNode, 'contrib-id[contrib-id-type="orcid"]');
241
244
  if (orcid) {
242
245
  contributor.ORCIDIdentifier = orcid;
243
246
  }
@@ -253,7 +256,7 @@ exports.jatsFrontParser = {
253
256
  if (footnoteId) {
254
257
  const authorFootNoteRef = {
255
258
  noteID: footnoteId,
256
- noteLabel: xrefNode.textContent || '',
259
+ noteLabel: ((_a = xrefNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
257
260
  };
258
261
  contributor.footnote.push(authorFootNoteRef);
259
262
  }
@@ -264,7 +267,7 @@ exports.jatsFrontParser = {
264
267
  if (correspId) {
265
268
  const authorCorrespRef = {
266
269
  correspID: correspId,
267
- correspLabel: xrefNode.textContent || '',
270
+ correspLabel: ((_b = xrefNode.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
268
271
  };
269
272
  contributor.corresp.push(authorCorrespRef);
270
273
  }
@@ -16,12 +16,14 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.parseJournalMeta = exports.parseJournalISSNs = exports.parseJournalAbbreviatedTitles = exports.parseJournalIdentifiers = void 0;
19
+ const utils_1 = require("../../lib/utils");
19
20
  const parseJournalIdentifiers = (journalMeta) => {
21
+ var _a, _b;
20
22
  const output = [];
21
23
  const elements = journalMeta.querySelectorAll('journal-id');
22
24
  for (const element of elements) {
23
25
  const journalIDType = element.getAttribute('journal-id-type');
24
- const journalID = element.textContent;
26
+ const journalID = (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : element.textContent;
25
27
  if (journalID !== null && journalIDType != null) {
26
28
  output.push({ journalIDType, journalID });
27
29
  }
@@ -33,11 +35,12 @@ const parseJournalIdentifiers = (journalMeta) => {
33
35
  };
34
36
  exports.parseJournalIdentifiers = parseJournalIdentifiers;
35
37
  const parseJournalAbbreviatedTitles = (journalMeta) => {
38
+ var _a, _b;
36
39
  const output = [];
37
40
  const elements = journalMeta.querySelectorAll('journal-title-group > abbrev-journal-title');
38
41
  for (const element of elements) {
39
42
  const abbrevType = element.getAttribute('abbrev-type');
40
- const abbreviatedTitle = element.textContent;
43
+ const abbreviatedTitle = (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : element.textContent;
41
44
  if (abbreviatedTitle !== null && abbrevType !== null) {
42
45
  output.push({ abbreviatedTitle, abbrevType });
43
46
  }
@@ -49,11 +52,12 @@ const parseJournalAbbreviatedTitles = (journalMeta) => {
49
52
  };
50
53
  exports.parseJournalAbbreviatedTitles = parseJournalAbbreviatedTitles;
51
54
  const parseJournalISSNs = (journalMeta) => {
55
+ var _a, _b;
52
56
  const output = [];
53
57
  const elements = journalMeta.querySelectorAll('issn');
54
58
  for (const element of elements) {
55
59
  const publicationType = element.getAttribute('pub-type');
56
- const ISSN = element.textContent;
60
+ const ISSN = (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : element.textContent;
57
61
  if (publicationType !== null && ISSN !== null) {
58
62
  output.push({ publicationType, ISSN });
59
63
  }
@@ -65,13 +69,13 @@ const parseJournalISSNs = (journalMeta) => {
65
69
  };
66
70
  exports.parseJournalISSNs = parseJournalISSNs;
67
71
  const parseJournalMeta = (journalMeta) => {
68
- var _a, _b, _c, _d;
72
+ var _a, _b;
69
73
  return {
70
74
  abbreviatedTitles: (0, exports.parseJournalAbbreviatedTitles)(journalMeta),
71
75
  journalIdentifiers: (0, exports.parseJournalIdentifiers)(journalMeta),
72
76
  ISSNs: (0, exports.parseJournalISSNs)(journalMeta),
73
- publisherName: (_b = (_a = journalMeta.querySelector('publisher > publisher-name')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined,
74
- title: (_d = (_c = journalMeta.querySelector('journal-title-group > journal-title')) === null || _c === void 0 ? void 0 : _c.textContent) !== null && _d !== void 0 ? _d : undefined,
77
+ publisherName: (_a = (0, utils_1.getTrimmedTextContent)(journalMeta, 'publisher > publisher-name')) !== null && _a !== void 0 ? _a : undefined,
78
+ title: (_b = (0, utils_1.getTrimmedTextContent)(journalMeta, 'journal-title-group > journal-title')) !== null && _b !== void 0 ? _b : undefined,
75
79
  };
76
80
  };
77
81
  exports.parseJournalMeta = parseJournalMeta;
@@ -16,6 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.jatsReferenceParser = void 0;
19
+ const utils_1 = require("../../lib/utils");
19
20
  const builders_1 = require("../../transformer/builders");
20
21
  const jats_comments_1 = require("./jats-comments");
21
22
  const jats_parser_utils_1 = require("./jats-parser-utils");
@@ -34,7 +35,7 @@ exports.jatsReferenceParser = {
34
35
  const referenceIDs = new Map();
35
36
  const referenceQueries = new Map();
36
37
  const references = referenceNodes.map((referenceNode) => {
37
- var _a, _b, _c, _d, _e, _f, _g, _h;
38
+ var _a;
38
39
  const publicationType = referenceNode.getAttribute('publication-type');
39
40
  const authorNodes = [
40
41
  ...referenceNode.querySelectorAll('person-group[person-group-type="author"] > *'),
@@ -44,7 +45,7 @@ exports.jatsReferenceParser = {
44
45
  });
45
46
  const titleNode = referenceNode.querySelector('article-title');
46
47
  if (titleNode) {
47
- bibliographyItem.title = (0, jats_parser_utils_1.htmlFromJatsNode)(titleNode, createElement);
48
+ bibliographyItem.title = (_a = (0, jats_parser_utils_1.htmlFromJatsNode)(titleNode, createElement)) === null || _a === void 0 ? void 0 : _a.trim();
48
49
  }
49
50
  const queriesText = [];
50
51
  const mixedCitation = referenceNode.querySelector('mixed-citation');
@@ -63,63 +64,63 @@ exports.jatsReferenceParser = {
63
64
  }
64
65
  if (authorNodes.length <= 0) {
65
66
  mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
66
- var _a, _b;
67
+ var _a, _b, _c;
67
68
  if (item.nodeType === Node.TEXT_NODE &&
68
69
  ((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
69
- bibliographyItem.literal = (_b = mixedCitation.textContent) !== null && _b !== void 0 ? _b : '';
70
+ bibliographyItem.literal = (_c = (_b = mixedCitation.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
70
71
  return bibliographyItem;
71
72
  }
72
73
  });
73
74
  }
74
- const source = (_a = referenceNode.querySelector('source')) === null || _a === void 0 ? void 0 : _a.textContent;
75
+ const source = (0, utils_1.getTrimmedTextContent)(referenceNode, 'source');
75
76
  if (source) {
76
77
  bibliographyItem['container-title'] = source;
77
78
  }
78
- const volume = (_b = referenceNode.querySelector('volume')) === null || _b === void 0 ? void 0 : _b.textContent;
79
+ const volume = (0, utils_1.getTrimmedTextContent)(referenceNode, 'volume');
79
80
  if (volume) {
80
81
  bibliographyItem.volume = volume;
81
82
  }
82
- const issue = (_c = referenceNode.querySelector('issue')) === null || _c === void 0 ? void 0 : _c.textContent;
83
+ const issue = (0, utils_1.getTrimmedTextContent)(referenceNode, 'issue');
83
84
  if (issue) {
84
85
  bibliographyItem.issue = issue;
85
86
  }
86
- const supplement = (_d = referenceNode.querySelector('supplement')) === null || _d === void 0 ? void 0 : _d.textContent;
87
+ const supplement = (0, utils_1.getTrimmedTextContent)(referenceNode, 'supplement');
87
88
  if (supplement) {
88
89
  bibliographyItem.supplement = supplement;
89
90
  }
90
- const fpage = (_e = referenceNode.querySelector('fpage')) === null || _e === void 0 ? void 0 : _e.textContent;
91
- const lpage = (_f = referenceNode.querySelector('lpage')) === null || _f === void 0 ? void 0 : _f.textContent;
91
+ const fpage = (0, utils_1.getTrimmedTextContent)(referenceNode, 'fpage');
92
+ const lpage = (0, utils_1.getTrimmedTextContent)(referenceNode, 'lpage');
92
93
  if (fpage) {
93
94
  bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
94
95
  }
95
- const year = (_g = referenceNode.querySelector('year')) === null || _g === void 0 ? void 0 : _g.textContent;
96
+ const year = (0, utils_1.getTrimmedTextContent)(referenceNode, 'year');
96
97
  if (year) {
97
98
  bibliographyItem.issued = (0, builders_1.buildBibliographicDate)({
98
99
  'date-parts': [[year]],
99
100
  });
100
101
  }
101
- const doi = (_h = referenceNode.querySelector('pub-id[pub-id-type="doi"]')) === null || _h === void 0 ? void 0 : _h.textContent;
102
+ const doi = (0, utils_1.getTrimmedTextContent)(referenceNode, 'pub-id[pub-id-type="doi"]');
102
103
  if (doi) {
103
104
  bibliographyItem.DOI = doi;
104
105
  }
105
106
  const authors = [];
106
107
  authorNodes.forEach((authorNode) => {
107
- var _a, _b, _c;
108
+ var _a;
108
109
  const name = (0, builders_1.buildBibliographicName)({});
109
- const given = (_a = authorNode.querySelector('given-names')) === null || _a === void 0 ? void 0 : _a.textContent;
110
+ const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'given-names');
110
111
  if (given) {
111
112
  name.given = given;
112
113
  }
113
- const family = (_b = authorNode.querySelector('surname')) === null || _b === void 0 ? void 0 : _b.textContent;
114
+ const family = (0, utils_1.getTrimmedTextContent)(authorNode, 'surname');
114
115
  if (family) {
115
116
  name.family = family;
116
117
  }
117
- const suffix = (_c = authorNode.querySelector('suffix')) === null || _c === void 0 ? void 0 : _c.textContent;
118
+ const suffix = (0, utils_1.getTrimmedTextContent)(authorNode, 'suffix');
118
119
  if (suffix) {
119
120
  name.suffix = suffix;
120
121
  }
121
122
  if (authorNode.nodeName === 'collab') {
122
- name.literal = authorNode.textContent;
123
+ name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
123
124
  }
124
125
  authors.push(name);
125
126
  });
@@ -236,7 +236,6 @@ class JATSExporter {
236
236
  this.buildFront = (doi, id, links) => {
237
237
  var _a, _b, _c, _d;
238
238
  const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
239
- const submission = (0, project_bundle_1.findLatestManuscriptSubmission)(this.modelMap, manuscript);
240
239
  const front = this.document.createElement('front');
241
240
  const journalMeta = this.document.createElement('journal-meta');
242
241
  front.appendChild(journalMeta);
@@ -291,29 +290,6 @@ class JATSExporter {
291
290
  journalMeta.appendChild(publisher);
292
291
  }
293
292
  }
294
- else {
295
- if (submission) {
296
- if (submission.journalCode) {
297
- const journalID = this.document.createElement('journal-id');
298
- journalID.setAttribute('journal-id-type', 'publisher-id');
299
- journalID.textContent = submission.journalCode;
300
- journalMeta.appendChild(journalID);
301
- }
302
- if (submission.journalTitle) {
303
- const journalTitleGroup = this.document.createElement('journal-title-group');
304
- journalMeta.appendChild(journalTitleGroup);
305
- const journalTitle = this.document.createElement('journal-title');
306
- journalTitle.textContent = submission.journalTitle;
307
- journalTitleGroup.appendChild(journalTitle);
308
- }
309
- if (submission.issn) {
310
- const issn = this.document.createElement('issn');
311
- issn.setAttribute('pub-type', 'epub');
312
- issn.textContent = submission.issn;
313
- journalMeta.appendChild(issn);
314
- }
315
- }
316
- }
317
293
  if (id) {
318
294
  const articleID = this.document.createElement('article-id');
319
295
  articleID.setAttribute('pub-id-type', 'publisher-id');
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
18
+ exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
19
19
  const bibliography_section_1 = require("../schema/nodes/bibliography_section");
20
20
  const graphical_abstract_section_1 = require("../schema/nodes/graphical_abstract_section");
21
21
  function* iterateChildren(node, recurse = false) {
@@ -75,3 +75,11 @@ const findParentNodeClosestToPos = ($pos, predicate) => {
75
75
  }
76
76
  };
77
77
  exports.findParentNodeClosestToPos = findParentNodeClosestToPos;
78
+ const getTrimmedTextContent = (node, querySelector) => {
79
+ var _a, _b;
80
+ if (!node) {
81
+ return null;
82
+ }
83
+ return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
84
+ };
85
+ exports.getTrimmedTextContent = getTrimmedTextContent;
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildUserFootNote = exports.buildStatusLabel = exports.buildJournal = exports.buildSubmission = exports.buildAttribution = exports.buildInlineStyle = exports.buildContributorRole = exports.buildContribution = exports.buildHighlightMarker = exports.buildHighlight = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildValidation = exports.buildNote = exports.buildComment = exports.buildUserProfileAffiliation = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildLibraryCollection = exports.buildManuscriptKeyword = exports.buildKeywordGroup = exports.buildKeyword = exports.buildCitation = exports.buildEmbeddedCitationItem = exports.buildAuxiliaryObjectReference = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = exports.DEFAULT_PAGE_LAYOUT = exports.DEFAULT_BUNDLE = void 0;
21
+ exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildStatusLabel = exports.buildJournal = exports.buildAttribution = exports.buildInlineStyle = exports.buildContributorRole = exports.buildContribution = exports.buildHighlightMarker = exports.buildHighlight = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildValidation = exports.buildNote = exports.buildComment = exports.buildUserProfileAffiliation = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildLibraryCollection = exports.buildManuscriptKeyword = exports.buildKeywordGroup = exports.buildKeyword = exports.buildCitation = exports.buildEmbeddedCitationItem = exports.buildAuxiliaryObjectReference = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = exports.DEFAULT_PAGE_LAYOUT = exports.DEFAULT_BUNDLE = void 0;
22
22
  const json_schema_1 = require("@manuscripts/json-schema");
23
23
  const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
24
24
  const schema_1 = require("../schema");
@@ -267,11 +267,6 @@ const buildAttribution = () => ({
267
267
  objectType: json_schema_1.ObjectTypes.Attribution,
268
268
  });
269
269
  exports.buildAttribution = buildAttribution;
270
- const buildSubmission = () => ({
271
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Submission),
272
- objectType: json_schema_1.ObjectTypes.Submission,
273
- });
274
- exports.buildSubmission = buildSubmission;
275
270
  const buildJournal = () => ({
276
271
  _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Journal),
277
272
  objectType: json_schema_1.ObjectTypes.Journal,
@@ -283,13 +278,6 @@ const buildStatusLabel = (name) => ({
283
278
  name,
284
279
  });
285
280
  exports.buildStatusLabel = buildStatusLabel;
286
- const buildUserFootNote = (noteId, content) => ({
287
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.UserProfileFootNote),
288
- objectType: json_schema_1.ObjectTypes.UserProfileFootNote,
289
- noteId,
290
- content,
291
- });
292
- exports.buildUserFootNote = buildUserFootNote;
293
281
  exports.auxiliaryObjectTypes = new Set([
294
282
  schema_1.schema.nodes.figure_element,
295
283
  schema_1.schema.nodes.table_element,
@@ -43,7 +43,7 @@ const timestamp_1 = require("./timestamp");
43
43
  const warn = (0, debug_1.default)('manuscripts-transform');
44
44
  const parser = prosemirror_model_1.DOMParser.fromSchema(schema_1.schema);
45
45
  const getModelData = (model) => {
46
- const { _rev, _deleted, updatedAt, createdAt, sessionID } = model, data = __rest(model, ["_rev", "_deleted", "updatedAt", "createdAt", "sessionID"]);
46
+ const { updatedAt, createdAt } = model, data = __rest(model, ["updatedAt", "createdAt"]);
47
47
  return data;
48
48
  };
49
49
  exports.getModelData = getModelData;
@@ -65,6 +65,7 @@ const buildTargets = (fragment, manuscript) => {
65
65
  }
66
66
  });
67
67
  fragment.descendants((node) => {
68
+ var _a;
68
69
  if (node.type.name in counters) {
69
70
  const isInGraphicalAbstract = figures.indexOf(node.attrs.id) > -1;
70
71
  if (isInGraphicalAbstract) {
@@ -75,7 +76,7 @@ const buildTargets = (fragment, manuscript) => {
75
76
  type: node.type.name,
76
77
  id: node.attrs.id,
77
78
  label,
78
- caption: node.textContent,
79
+ caption: (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
79
80
  });
80
81
  }
81
82
  });
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.fromPrototype = void 0;
15
15
  const id_1 = require("./id");
16
16
  const fromPrototype = (model) => {
17
- const { _id, _rev } = model, data = __rest(model, ["_id", "_rev"]);
17
+ const { _id } = model, data = __rest(model, ["_id"]);
18
18
  const output = Object.assign(Object.assign({}, data), { prototype: _id, _id: (0, id_1.generateID)(model.objectType) });
19
19
  return output;
20
20
  };
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.findManuscriptById = exports.findLatestManuscriptSubmission = exports.findManuscriptModelByType = exports.findJournal = exports.findManuscript = exports.parseProjectBundle = void 0;
18
+ exports.findManuscriptById = exports.findManuscriptModelByType = exports.findJournal = exports.findManuscript = exports.parseProjectBundle = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const decode_1 = require("./decode");
21
21
  const object_types_1 = require("./object-types");
@@ -63,19 +63,6 @@ const findManuscriptModelByType = (modelMap, manuscript, objectType) => {
63
63
  }
64
64
  };
65
65
  exports.findManuscriptModelByType = findManuscriptModelByType;
66
- const isSubmission = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Submission);
67
- const newestFirst = (a, b) => b.createdAt - a.createdAt;
68
- const findLatestManuscriptSubmission = (modelMap, manuscript) => {
69
- const submissions = [];
70
- for (const model of modelMap.values()) {
71
- if (isSubmission(model) && model.manuscriptID === manuscript._id) {
72
- submissions.push(model);
73
- }
74
- }
75
- submissions.sort(newestFirst);
76
- return submissions.length ? submissions[0] : undefined;
77
- };
78
- exports.findLatestManuscriptSubmission = findLatestManuscriptSubmission;
79
66
  const findManuscriptById = (modelMap, manuscriptID) => {
80
67
  const manuscript = modelMap.get(manuscriptID);
81
68
  if (manuscript && isManuscript(manuscript)) {
@@ -643,10 +643,11 @@ const nodes = [
643
643
  tag: 'xref[ref-type="bibr"]',
644
644
  node: 'citation',
645
645
  getAttrs: (node) => {
646
+ var _a;
646
647
  const element = node;
647
648
  return {
648
649
  rid: element.getAttribute('rid'),
649
- contents: element.textContent,
650
+ contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
650
651
  };
651
652
  },
652
653
  },
@@ -654,10 +655,11 @@ const nodes = [
654
655
  tag: 'xref[ref-type="fn"]',
655
656
  node: 'inline_footnote',
656
657
  getAttrs: (node) => {
658
+ var _a;
657
659
  const element = node;
658
660
  return {
659
661
  rid: element.getAttribute('rid'),
660
- contents: element.textContent,
662
+ contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
661
663
  };
662
664
  },
663
665
  },
@@ -665,10 +667,11 @@ const nodes = [
665
667
  tag: 'xref',
666
668
  node: 'cross_reference',
667
669
  getAttrs: (node) => {
670
+ var _a;
668
671
  const element = node;
669
672
  return {
670
673
  rid: element.getAttribute('rid'),
671
- label: element.textContent,
674
+ label: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
672
675
  };
673
676
  },
674
677
  },
@@ -212,6 +212,7 @@ export const jatsBodyTransformations = {
212
212
  body.append(backmatterContainer);
213
213
  },
214
214
  mapFootnotesToSections(doc, backmatterContainer, createElement) {
215
+ var _a;
215
216
  const footnoteGroups = [...doc.querySelectorAll('fn[fn-type]')];
216
217
  for (const footnote of footnoteGroups) {
217
218
  const type = footnote.getAttribute('fn-type') || '';
@@ -221,7 +222,10 @@ export const jatsBodyTransformations = {
221
222
  const title = footnote.querySelector('p[content-type="fn-title"]');
222
223
  if (title) {
223
224
  const sectionTitleElement = createElement('title');
224
- sectionTitleElement.textContent = title.textContent;
225
+ const titleTextContent = (_a = title.textContent) === null || _a === void 0 ? void 0 : _a.trim();
226
+ if (titleTextContent) {
227
+ sectionTitleElement.textContent = titleTextContent;
228
+ }
225
229
  removeNodeFromParent(title);
226
230
  section.append(sectionTitleElement);
227
231
  }
@@ -18,7 +18,8 @@ import { buildComment, buildContribution, isCommentAnnotation, isHighlightableMo
18
18
  const DEFAULT_ANNOTATION_COLOR = 'rgb(250, 224, 150)';
19
19
  const DEFAULT_PROFILE_ID = 'MPUserProfile:0000000000000000000000000000000000000001';
20
20
  export const parseProcessingInstruction = (node) => {
21
- const value = `<AuthorQuery ${node.textContent} />`;
21
+ var _a;
22
+ const value = `<AuthorQuery ${(_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()} />`;
22
23
  const processingInstruction = new DOMParser().parseFromString(value, 'application/xml').firstElementChild;
23
24
  if (processingInstruction) {
24
25
  const queryText = processingInstruction.getAttribute('queryText');
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import debug from 'debug';
17
+ import { getTrimmedTextContent } from '../../lib/utils';
17
18
  import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildSupplementaryMaterial, } from '../../transformer/builders';
18
19
  import { parseJournalMeta } from './jats-journal-meta-parser';
19
20
  const warn = debug('manuscripts-transform');
@@ -68,11 +69,10 @@ export const jatsFrontParser = {
68
69
  }
69
70
  const history = {};
70
71
  const dateToTimestamp = (dateElement) => {
71
- var _a, _b;
72
72
  const selectors = ['year', 'month', 'day'];
73
73
  const values = [];
74
74
  for (const selector of selectors) {
75
- const value = (_b = (_a = dateElement.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
75
+ const value = getTrimmedTextContent(dateElement, selector);
76
76
  if (!value || isNaN(+value)) {
77
77
  return;
78
78
  }
@@ -112,17 +112,17 @@ export const jatsFrontParser = {
112
112
  return history;
113
113
  },
114
114
  parseSupplements(supplementNodes) {
115
- var _a, _b, _c, _d, _e;
115
+ var _a, _b, _c, _d;
116
116
  if (!supplementNodes || supplementNodes.length === 0) {
117
117
  return [];
118
118
  }
119
119
  const supplements = [];
120
120
  for (const supplementNode of supplementNodes) {
121
- const supplTitle = (_b = (_a = supplementNode.querySelector('caption > title')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '';
122
- const href = (_c = supplementNode.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _c !== void 0 ? _c : '';
121
+ const supplTitle = (_a = getTrimmedTextContent(supplementNode, 'caption > title')) !== null && _a !== void 0 ? _a : '';
122
+ const href = (_b = supplementNode.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _b !== void 0 ? _b : '';
123
123
  const supplementaryMaterial = buildSupplementaryMaterial(supplTitle, href);
124
- const mimeType = (_d = supplementNode.getAttribute('mimetype')) !== null && _d !== void 0 ? _d : '';
125
- const mimeSubtype = (_e = supplementNode.getAttribute('mime-subtype')) !== null && _e !== void 0 ? _e : '';
124
+ const mimeType = (_c = supplementNode.getAttribute('mimetype')) !== null && _c !== void 0 ? _c : '';
125
+ const mimeSubtype = (_d = supplementNode.getAttribute('mime-subtype')) !== null && _d !== void 0 ? _d : '';
126
126
  if (mimeType && mimeSubtype) {
127
127
  supplementaryMaterial.MIME = [mimeType, mimeSubtype].join('/');
128
128
  }
@@ -133,10 +133,10 @@ export const jatsFrontParser = {
133
133
  parseAffiliationNodes(affiliationNodes) {
134
134
  const affiliationIDs = new Map();
135
135
  const affiliations = affiliationNodes.map((affiliationNode, priority) => {
136
- var _a, _b, _c, _d, _e;
136
+ var _a, _b;
137
137
  const affiliation = buildAffiliation('', priority);
138
138
  for (const node of affiliationNode.querySelectorAll('institution')) {
139
- const content = node.textContent;
139
+ const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
140
140
  if (!content) {
141
141
  continue;
142
142
  }
@@ -151,22 +151,25 @@ export const jatsFrontParser = {
151
151
  }
152
152
  }
153
153
  affiliation.addressLine1 =
154
- ((_a = affiliationNode.querySelector('addr-line:nth-of-type(1)')) === null || _a === void 0 ? void 0 : _a.textContent) || undefined;
154
+ getTrimmedTextContent(affiliationNode, 'addr-line:nth-of-type(1)') ||
155
+ undefined;
155
156
  affiliation.addressLine2 =
156
- ((_b = affiliationNode.querySelector('addr-line:nth-of-type(2)')) === null || _b === void 0 ? void 0 : _b.textContent) || undefined;
157
+ getTrimmedTextContent(affiliationNode, 'addr-line:nth-of-type(2)') ||
158
+ undefined;
157
159
  affiliation.addressLine3 =
158
- ((_c = affiliationNode.querySelector('addr-line:nth-of-type(3)')) === null || _c === void 0 ? void 0 : _c.textContent) || undefined;
160
+ getTrimmedTextContent(affiliationNode, 'addr-line:nth-of-type(3)') ||
161
+ undefined;
159
162
  const emailNode = affiliationNode.querySelector('email');
160
163
  if (emailNode) {
161
164
  affiliation.email = {
162
165
  href: emailNode.getAttributeNS(XLINK_NAMESPACE, 'href') || undefined,
163
- text: emailNode.textContent || undefined,
166
+ text: ((_b = emailNode.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
164
167
  };
165
168
  }
166
169
  affiliation.postCode =
167
- ((_d = affiliationNode.querySelector('postal-code')) === null || _d === void 0 ? void 0 : _d.textContent) || undefined;
170
+ getTrimmedTextContent(affiliationNode, 'postal-code') || undefined;
168
171
  affiliation.country =
169
- ((_e = affiliationNode.querySelector('country')) === null || _e === void 0 ? void 0 : _e.textContent) || undefined;
172
+ getTrimmedTextContent(affiliationNode, 'country') || undefined;
170
173
  const id = affiliationNode.getAttribute('id');
171
174
  if (id) {
172
175
  affiliationIDs.set(id, affiliation._id);
@@ -196,13 +199,13 @@ export const jatsFrontParser = {
196
199
  parseCorrespNodes(correspNodes) {
197
200
  const correspondingIDs = new Map();
198
201
  const correspondingList = correspNodes.map((correspNode) => {
199
- var _a;
202
+ var _a, _b, _c;
200
203
  const label = correspNode.querySelector('label');
201
204
  if (label) {
202
205
  label.remove();
203
206
  }
204
- const corresponding = buildCorresp((_a = correspNode.textContent) !== null && _a !== void 0 ? _a : '');
205
- corresponding.label = (label === null || label === void 0 ? void 0 : label.textContent) || undefined;
207
+ const corresponding = buildCorresp((_b = (_a = correspNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
208
+ corresponding.label = ((_c = label === null || label === void 0 ? void 0 : label.textContent) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
206
209
  const id = correspNode.getAttribute('id');
207
210
  if (id) {
208
211
  correspondingIDs.set(id, corresponding._id);
@@ -216,13 +219,13 @@ export const jatsFrontParser = {
216
219
  },
217
220
  parseAuthorNodes(authorNodes, affiliationIDs, footnoteIDs, correspondingIDs) {
218
221
  return authorNodes.map((authorNode, priority) => {
219
- var _a, _b, _c;
222
+ var _a, _b;
220
223
  const name = buildBibliographicName({});
221
- const given = (_a = authorNode.querySelector('name > given-names')) === null || _a === void 0 ? void 0 : _a.textContent;
224
+ const given = getTrimmedTextContent(authorNode, 'name > given-names');
222
225
  if (given) {
223
226
  name.given = given;
224
227
  }
225
- const surname = (_b = authorNode.querySelector('name > surname')) === null || _b === void 0 ? void 0 : _b.textContent;
228
+ const surname = getTrimmedTextContent(authorNode, 'name > surname');
226
229
  if (surname) {
227
230
  name.family = surname;
228
231
  }
@@ -231,7 +234,7 @@ export const jatsFrontParser = {
231
234
  if (corresponding) {
232
235
  contributor.isCorresponding = corresponding;
233
236
  }
234
- const orcid = (_c = authorNode.querySelector('contrib-id[contrib-id-type="orcid"]')) === null || _c === void 0 ? void 0 : _c.textContent;
237
+ const orcid = getTrimmedTextContent(authorNode, 'contrib-id[contrib-id-type="orcid"]');
235
238
  if (orcid) {
236
239
  contributor.ORCIDIdentifier = orcid;
237
240
  }
@@ -247,7 +250,7 @@ export const jatsFrontParser = {
247
250
  if (footnoteId) {
248
251
  const authorFootNoteRef = {
249
252
  noteID: footnoteId,
250
- noteLabel: xrefNode.textContent || '',
253
+ noteLabel: ((_a = xrefNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
251
254
  };
252
255
  contributor.footnote.push(authorFootNoteRef);
253
256
  }
@@ -258,7 +261,7 @@ export const jatsFrontParser = {
258
261
  if (correspId) {
259
262
  const authorCorrespRef = {
260
263
  correspID: correspId,
261
- correspLabel: xrefNode.textContent || '',
264
+ correspLabel: ((_b = xrefNode.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
262
265
  };
263
266
  contributor.corresp.push(authorCorrespRef);
264
267
  }
@@ -13,12 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { getTrimmedTextContent } from '../../lib/utils';
16
17
  export const parseJournalIdentifiers = (journalMeta) => {
18
+ var _a, _b;
17
19
  const output = [];
18
20
  const elements = journalMeta.querySelectorAll('journal-id');
19
21
  for (const element of elements) {
20
22
  const journalIDType = element.getAttribute('journal-id-type');
21
- const journalID = element.textContent;
23
+ const journalID = (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : element.textContent;
22
24
  if (journalID !== null && journalIDType != null) {
23
25
  output.push({ journalIDType, journalID });
24
26
  }
@@ -29,11 +31,12 @@ export const parseJournalIdentifiers = (journalMeta) => {
29
31
  return output;
30
32
  };
31
33
  export const parseJournalAbbreviatedTitles = (journalMeta) => {
34
+ var _a, _b;
32
35
  const output = [];
33
36
  const elements = journalMeta.querySelectorAll('journal-title-group > abbrev-journal-title');
34
37
  for (const element of elements) {
35
38
  const abbrevType = element.getAttribute('abbrev-type');
36
- const abbreviatedTitle = element.textContent;
39
+ const abbreviatedTitle = (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : element.textContent;
37
40
  if (abbreviatedTitle !== null && abbrevType !== null) {
38
41
  output.push({ abbreviatedTitle, abbrevType });
39
42
  }
@@ -44,11 +47,12 @@ export const parseJournalAbbreviatedTitles = (journalMeta) => {
44
47
  return output;
45
48
  };
46
49
  export const parseJournalISSNs = (journalMeta) => {
50
+ var _a, _b;
47
51
  const output = [];
48
52
  const elements = journalMeta.querySelectorAll('issn');
49
53
  for (const element of elements) {
50
54
  const publicationType = element.getAttribute('pub-type');
51
- const ISSN = element.textContent;
55
+ const ISSN = (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : element.textContent;
52
56
  if (publicationType !== null && ISSN !== null) {
53
57
  output.push({ publicationType, ISSN });
54
58
  }
@@ -59,12 +63,12 @@ export const parseJournalISSNs = (journalMeta) => {
59
63
  return output;
60
64
  };
61
65
  export const parseJournalMeta = (journalMeta) => {
62
- var _a, _b, _c, _d;
66
+ var _a, _b;
63
67
  return {
64
68
  abbreviatedTitles: parseJournalAbbreviatedTitles(journalMeta),
65
69
  journalIdentifiers: parseJournalIdentifiers(journalMeta),
66
70
  ISSNs: parseJournalISSNs(journalMeta),
67
- publisherName: (_b = (_a = journalMeta.querySelector('publisher > publisher-name')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined,
68
- title: (_d = (_c = journalMeta.querySelector('journal-title-group > journal-title')) === null || _c === void 0 ? void 0 : _c.textContent) !== null && _d !== void 0 ? _d : undefined,
71
+ publisherName: (_a = getTrimmedTextContent(journalMeta, 'publisher > publisher-name')) !== null && _a !== void 0 ? _a : undefined,
72
+ title: (_b = getTrimmedTextContent(journalMeta, 'journal-title-group > journal-title')) !== null && _b !== void 0 ? _b : undefined,
69
73
  };
70
74
  };
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { getTrimmedTextContent } from '../../lib/utils';
16
17
  import { buildAuxiliaryObjectReference, buildBibliographicDate, buildBibliographicName, buildBibliographyItem, buildCitation, } from '../../transformer/builders';
17
18
  import { parseProcessingInstruction } from './jats-comments';
18
19
  import { flatten, htmlFromJatsNode } from './jats-parser-utils';
@@ -31,7 +32,7 @@ export const jatsReferenceParser = {
31
32
  const referenceIDs = new Map();
32
33
  const referenceQueries = new Map();
33
34
  const references = referenceNodes.map((referenceNode) => {
34
- var _a, _b, _c, _d, _e, _f, _g, _h;
35
+ var _a;
35
36
  const publicationType = referenceNode.getAttribute('publication-type');
36
37
  const authorNodes = [
37
38
  ...referenceNode.querySelectorAll('person-group[person-group-type="author"] > *'),
@@ -41,7 +42,7 @@ export const jatsReferenceParser = {
41
42
  });
42
43
  const titleNode = referenceNode.querySelector('article-title');
43
44
  if (titleNode) {
44
- bibliographyItem.title = htmlFromJatsNode(titleNode, createElement);
45
+ bibliographyItem.title = (_a = htmlFromJatsNode(titleNode, createElement)) === null || _a === void 0 ? void 0 : _a.trim();
45
46
  }
46
47
  const queriesText = [];
47
48
  const mixedCitation = referenceNode.querySelector('mixed-citation');
@@ -60,63 +61,63 @@ export const jatsReferenceParser = {
60
61
  }
61
62
  if (authorNodes.length <= 0) {
62
63
  mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
63
- var _a, _b;
64
+ var _a, _b, _c;
64
65
  if (item.nodeType === Node.TEXT_NODE &&
65
66
  ((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
66
- bibliographyItem.literal = (_b = mixedCitation.textContent) !== null && _b !== void 0 ? _b : '';
67
+ bibliographyItem.literal = (_c = (_b = mixedCitation.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
67
68
  return bibliographyItem;
68
69
  }
69
70
  });
70
71
  }
71
- const source = (_a = referenceNode.querySelector('source')) === null || _a === void 0 ? void 0 : _a.textContent;
72
+ const source = getTrimmedTextContent(referenceNode, 'source');
72
73
  if (source) {
73
74
  bibliographyItem['container-title'] = source;
74
75
  }
75
- const volume = (_b = referenceNode.querySelector('volume')) === null || _b === void 0 ? void 0 : _b.textContent;
76
+ const volume = getTrimmedTextContent(referenceNode, 'volume');
76
77
  if (volume) {
77
78
  bibliographyItem.volume = volume;
78
79
  }
79
- const issue = (_c = referenceNode.querySelector('issue')) === null || _c === void 0 ? void 0 : _c.textContent;
80
+ const issue = getTrimmedTextContent(referenceNode, 'issue');
80
81
  if (issue) {
81
82
  bibliographyItem.issue = issue;
82
83
  }
83
- const supplement = (_d = referenceNode.querySelector('supplement')) === null || _d === void 0 ? void 0 : _d.textContent;
84
+ const supplement = getTrimmedTextContent(referenceNode, 'supplement');
84
85
  if (supplement) {
85
86
  bibliographyItem.supplement = supplement;
86
87
  }
87
- const fpage = (_e = referenceNode.querySelector('fpage')) === null || _e === void 0 ? void 0 : _e.textContent;
88
- const lpage = (_f = referenceNode.querySelector('lpage')) === null || _f === void 0 ? void 0 : _f.textContent;
88
+ const fpage = getTrimmedTextContent(referenceNode, 'fpage');
89
+ const lpage = getTrimmedTextContent(referenceNode, 'lpage');
89
90
  if (fpage) {
90
91
  bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
91
92
  }
92
- const year = (_g = referenceNode.querySelector('year')) === null || _g === void 0 ? void 0 : _g.textContent;
93
+ const year = getTrimmedTextContent(referenceNode, 'year');
93
94
  if (year) {
94
95
  bibliographyItem.issued = buildBibliographicDate({
95
96
  'date-parts': [[year]],
96
97
  });
97
98
  }
98
- const doi = (_h = referenceNode.querySelector('pub-id[pub-id-type="doi"]')) === null || _h === void 0 ? void 0 : _h.textContent;
99
+ const doi = getTrimmedTextContent(referenceNode, 'pub-id[pub-id-type="doi"]');
99
100
  if (doi) {
100
101
  bibliographyItem.DOI = doi;
101
102
  }
102
103
  const authors = [];
103
104
  authorNodes.forEach((authorNode) => {
104
- var _a, _b, _c;
105
+ var _a;
105
106
  const name = buildBibliographicName({});
106
- const given = (_a = authorNode.querySelector('given-names')) === null || _a === void 0 ? void 0 : _a.textContent;
107
+ const given = getTrimmedTextContent(authorNode, 'given-names');
107
108
  if (given) {
108
109
  name.given = given;
109
110
  }
110
- const family = (_b = authorNode.querySelector('surname')) === null || _b === void 0 ? void 0 : _b.textContent;
111
+ const family = getTrimmedTextContent(authorNode, 'surname');
111
112
  if (family) {
112
113
  name.family = family;
113
114
  }
114
- const suffix = (_c = authorNode.querySelector('suffix')) === null || _c === void 0 ? void 0 : _c.textContent;
115
+ const suffix = getTrimmedTextContent(authorNode, 'suffix');
115
116
  if (suffix) {
116
117
  name.suffix = suffix;
117
118
  }
118
119
  if (authorNode.nodeName === 'collab') {
119
- name.literal = authorNode.textContent;
120
+ name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
120
121
  }
121
122
  authors.push(name);
122
123
  });
@@ -25,7 +25,7 @@ import { generateAttachmentFilename } from '../transformer/filename';
25
25
  import { buildTargets } from '../transformer/labels';
26
26
  import { isExecutableNodeType, isNodeType } from '../transformer/node-types';
27
27
  import { hasObjectType } from '../transformer/object-types';
28
- import { findLatestManuscriptSubmission, findManuscript, findManuscriptById, } from '../transformer/project-bundle';
28
+ import { findManuscript, findManuscriptById, } from '../transformer/project-bundle';
29
29
  import { chooseSecType } from '../transformer/section-category';
30
30
  import { selectVersionIds } from './jats-versions';
31
31
  const warn = debug('manuscripts-transform');
@@ -229,7 +229,6 @@ export class JATSExporter {
229
229
  this.buildFront = (doi, id, links) => {
230
230
  var _a, _b, _c, _d;
231
231
  const manuscript = findManuscript(this.modelMap);
232
- const submission = findLatestManuscriptSubmission(this.modelMap, manuscript);
233
232
  const front = this.document.createElement('front');
234
233
  const journalMeta = this.document.createElement('journal-meta');
235
234
  front.appendChild(journalMeta);
@@ -284,29 +283,6 @@ export class JATSExporter {
284
283
  journalMeta.appendChild(publisher);
285
284
  }
286
285
  }
287
- else {
288
- if (submission) {
289
- if (submission.journalCode) {
290
- const journalID = this.document.createElement('journal-id');
291
- journalID.setAttribute('journal-id-type', 'publisher-id');
292
- journalID.textContent = submission.journalCode;
293
- journalMeta.appendChild(journalID);
294
- }
295
- if (submission.journalTitle) {
296
- const journalTitleGroup = this.document.createElement('journal-title-group');
297
- journalMeta.appendChild(journalTitleGroup);
298
- const journalTitle = this.document.createElement('journal-title');
299
- journalTitle.textContent = submission.journalTitle;
300
- journalTitleGroup.appendChild(journalTitle);
301
- }
302
- if (submission.issn) {
303
- const issn = this.document.createElement('issn');
304
- issn.setAttribute('pub-type', 'epub');
305
- issn.textContent = submission.issn;
306
- journalMeta.appendChild(issn);
307
- }
308
- }
309
- }
310
286
  if (id) {
311
287
  const articleID = this.document.createElement('article-id');
312
288
  articleID.setAttribute('pub-id-type', 'publisher-id');
@@ -67,3 +67,10 @@ export const findParentNodeClosestToPos = ($pos, predicate) => {
67
67
  }
68
68
  }
69
69
  };
70
+ export const getTrimmedTextContent = (node, querySelector) => {
71
+ var _a, _b;
72
+ if (!node) {
73
+ return null;
74
+ }
75
+ return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
76
+ };
@@ -228,10 +228,6 @@ export const buildAttribution = () => ({
228
228
  _id: generateID(ObjectTypes.Attribution),
229
229
  objectType: ObjectTypes.Attribution,
230
230
  });
231
- export const buildSubmission = () => ({
232
- _id: generateID(ObjectTypes.Submission),
233
- objectType: ObjectTypes.Submission,
234
- });
235
231
  export const buildJournal = () => ({
236
232
  _id: generateID(ObjectTypes.Journal),
237
233
  objectType: ObjectTypes.Journal,
@@ -241,12 +237,6 @@ export const buildStatusLabel = (name) => ({
241
237
  objectType: ObjectTypes.StatusLabel,
242
238
  name,
243
239
  });
244
- export const buildUserFootNote = (noteId, content) => ({
245
- _id: generateID(ObjectTypes.UserProfileFootNote),
246
- objectType: ObjectTypes.UserProfileFootNote,
247
- noteId,
248
- content,
249
- });
250
240
  export const auxiliaryObjectTypes = new Set([
251
241
  schema.nodes.figure_element,
252
242
  schema.nodes.table_element,
@@ -37,7 +37,7 @@ import { timestamp } from './timestamp';
37
37
  const warn = debug('manuscripts-transform');
38
38
  const parser = DOMParser.fromSchema(schema);
39
39
  export const getModelData = (model) => {
40
- const { _rev, _deleted, updatedAt, createdAt, sessionID } = model, data = __rest(model, ["_rev", "_deleted", "updatedAt", "createdAt", "sessionID"]);
40
+ const { updatedAt, createdAt } = model, data = __rest(model, ["updatedAt", "createdAt"]);
41
41
  return data;
42
42
  };
43
43
  export const getModelsByType = (modelMap, objectType) => {
@@ -62,6 +62,7 @@ export const buildTargets = (fragment, manuscript) => {
62
62
  }
63
63
  });
64
64
  fragment.descendants((node) => {
65
+ var _a;
65
66
  if (node.type.name in counters) {
66
67
  const isInGraphicalAbstract = figures.indexOf(node.attrs.id) > -1;
67
68
  if (isInGraphicalAbstract) {
@@ -72,7 +73,7 @@ export const buildTargets = (fragment, manuscript) => {
72
73
  type: node.type.name,
73
74
  id: node.attrs.id,
74
75
  label,
75
- caption: node.textContent,
76
+ caption: (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
76
77
  });
77
78
  }
78
79
  });
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { generateID } from './id';
13
13
  export const fromPrototype = (model) => {
14
- const { _id, _rev } = model, data = __rest(model, ["_id", "_rev"]);
14
+ const { _id } = model, data = __rest(model, ["_id"]);
15
15
  const output = Object.assign(Object.assign({}, data), { prototype: _id, _id: generateID(model.objectType) });
16
16
  return output;
17
17
  };
@@ -56,18 +56,6 @@ export const findManuscriptModelByType = (modelMap, manuscript, objectType) => {
56
56
  }
57
57
  }
58
58
  };
59
- const isSubmission = hasObjectType(ObjectTypes.Submission);
60
- const newestFirst = (a, b) => b.createdAt - a.createdAt;
61
- export const findLatestManuscriptSubmission = (modelMap, manuscript) => {
62
- const submissions = [];
63
- for (const model of modelMap.values()) {
64
- if (isSubmission(model) && model.manuscriptID === manuscript._id) {
65
- submissions.push(model);
66
- }
67
- }
68
- submissions.sort(newestFirst);
69
- return submissions.length ? submissions[0] : undefined;
70
- };
71
59
  export const findManuscriptById = (modelMap, manuscriptID) => {
72
60
  const manuscript = modelMap.get(manuscriptID);
73
61
  if (manuscript && isManuscript(manuscript)) {
@@ -25,3 +25,4 @@ export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate:
25
25
  depth: number;
26
26
  node: ProsemirrorNode;
27
27
  } | undefined;
28
+ export declare const getTrimmedTextContent: (node: Element | Document, querySelector: string) => string | null | undefined;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Affiliation, Attribution, AuxiliaryObjectReference, BibliographicDate, BibliographicName, BibliographyItem, Citation, CitationItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Highlight, HighlightMarker, InlineMathFragment, InlineStyle, Journal, Keyword, KeywordGroup, LibraryCollection, Manuscript, ManuscriptKeyword, ManuscriptNote, ObjectTypes, ParagraphElement, Project, RequirementsValidation, RequirementsValidationData, Section, StatusLabel, Submission, Supplement, UserProfileAffiliation, UserProfileFootNote } from '@manuscripts/json-schema';
16
+ import { Affiliation, Attribution, AuxiliaryObjectReference, BibliographicDate, BibliographicName, BibliographyItem, Citation, CitationItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Highlight, HighlightMarker, InlineMathFragment, InlineStyle, Journal, Keyword, KeywordGroup, LibraryCollection, Manuscript, ManuscriptKeyword, ManuscriptNote, ObjectTypes, ParagraphElement, Project, RequirementsValidation, RequirementsValidationData, Section, StatusLabel, Supplement, UserProfileAffiliation } from '@manuscripts/json-schema';
17
17
  import { FootnotesOrderIndexList } from './footnotes-order';
18
18
  import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
19
19
  export declare const DEFAULT_BUNDLE = "MPBundle:www-zotero-org-styles-nature";
@@ -65,10 +65,8 @@ export declare const buildContribution: (profileID: string) => Contribution;
65
65
  export declare const buildContributorRole: (name: string) => Build<ContributorRole>;
66
66
  export declare const buildInlineStyle: (priority: number, title?: string) => Build<InlineStyle>;
67
67
  export declare const buildAttribution: () => Build<Attribution>;
68
- export declare const buildSubmission: () => Build<Submission>;
69
68
  export declare const buildJournal: () => Build<Journal>;
70
69
  export declare const buildStatusLabel: (name: string) => Build<StatusLabel>;
71
- export declare const buildUserFootNote: (noteId: string, content: string) => Build<UserProfileFootNote>;
72
70
  export type AuxiliaryObjects = 'MPFigureElement' | 'MPTableElement' | 'MPListingElement' | 'MPEquationElement';
73
71
  export declare const auxiliaryObjectTypes: Set<import("prosemirror-model").NodeType>;
74
72
  export declare const buildElementsOrder: (elementType: AuxiliaryObjects) => Build<ElementsOrder>;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Journal, Manuscript, Model, ObjectTypes, Submission } from '@manuscripts/json-schema';
16
+ import { Journal, Manuscript, Model, ObjectTypes } from '@manuscripts/json-schema';
17
17
  import { ManuscriptModel } from './models';
18
18
  export interface ProjectBundle {
19
19
  version: string;
@@ -26,5 +26,4 @@ export declare const parseProjectBundle: (projectBundle: ProjectBundle, manuscri
26
26
  export declare const findManuscript: (modelMap: Map<string, Model>) => Manuscript;
27
27
  export declare const findJournal: (modelMap: Map<string, Model>) => Journal | null;
28
28
  export declare const findManuscriptModelByType: <T extends ManuscriptModel>(modelMap: Map<string, Model>, manuscript: Manuscript, objectType: ObjectTypes) => T | undefined;
29
- export declare const findLatestManuscriptSubmission: (modelMap: Map<string, Model>, manuscript: Manuscript) => Submission | undefined;
30
29
  export declare const findManuscriptById: (modelMap: Map<string, Model>, manuscriptID: string) => Manuscript;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "1.3.2",
4
+ "version": "1.3.4-LEAN-2501-test",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -29,7 +29,7 @@
29
29
  "version": "yarn build"
30
30
  },
31
31
  "dependencies": {
32
- "@manuscripts/json-schema": "^2.0.2",
32
+ "@manuscripts/json-schema": "^2.1.0",
33
33
  "debug": "^4.3.4",
34
34
  "jszip": "^3.10.1",
35
35
  "mathjax-full": "^3.2.2",