@manuscripts/transform 2.4.0 → 2.6.1-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.
Files changed (126) hide show
  1. package/dist/cjs/index.js +6 -6
  2. package/dist/cjs/jats/{jats-exporter.js → exporter/jats-exporter.js} +267 -414
  3. package/dist/cjs/jats/{jats-versions.js → exporter/jats-versions.js} +1 -3
  4. package/dist/cjs/{transformer → jats/exporter}/labels.js +4 -4
  5. package/dist/cjs/{transformer/filename.js → jats/importer/create-article-node.js} +10 -9
  6. package/dist/cjs/jats/importer/jats-comments.js +32 -111
  7. package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +330 -10
  8. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +11 -1
  9. package/dist/cjs/jats/importer/jats-parser-utils.js +67 -4
  10. package/dist/cjs/jats/importer/jats-transformations.js +389 -0
  11. package/dist/cjs/jats/importer/parse-jats-article.js +43 -101
  12. package/dist/cjs/jats/index.js +7 -7
  13. package/dist/cjs/{transformer/models.js → lib/deafults.js} +3 -1
  14. package/dist/cjs/lib/utils.js +3 -1
  15. package/dist/cjs/schema/nodes/highlight_marker.js +0 -4
  16. package/dist/cjs/transformer/id.js +1 -5
  17. package/dist/cjs/transformer/index.js +0 -18
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/es/index.js +5 -5
  20. package/dist/es/jats/{jats-exporter.js → exporter/jats-exporter.js} +262 -409
  21. package/dist/es/jats/{jats-versions.js → exporter/jats-versions.js} +0 -1
  22. package/dist/es/{transformer → jats/exporter}/labels.js +4 -4
  23. package/dist/{cjs/transformer/model-map.js → es/jats/importer/create-article-node.js} +8 -10
  24. package/dist/es/jats/importer/jats-comments.js +32 -107
  25. package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +330 -10
  26. package/dist/es/jats/importer/jats-journal-meta-parser.js +9 -0
  27. package/dist/es/jats/importer/jats-parser-utils.js +69 -6
  28. package/dist/es/jats/importer/jats-transformations.js +370 -0
  29. package/dist/es/jats/importer/parse-jats-article.js +43 -99
  30. package/dist/es/jats/index.js +5 -3
  31. package/dist/{types/transformer/timestamp.d.ts → es/lib/deafults.js} +2 -2
  32. package/dist/es/lib/utils.js +1 -0
  33. package/dist/es/schema/nodes/highlight_marker.js +0 -4
  34. package/dist/es/transformer/id.js +0 -3
  35. package/dist/es/transformer/index.js +0 -16
  36. package/dist/es/version.js +1 -1
  37. package/dist/types/index.d.ts +6 -6
  38. package/dist/types/jats/{jats-exporter.d.ts → exporter/jats-exporter.d.ts} +15 -29
  39. package/dist/types/jats/{jats-versions.d.ts → exporter/jats-versions.d.ts} +0 -1
  40. package/dist/types/{transformer → jats/exporter}/labels.d.ts +2 -2
  41. package/dist/{es/transformer/footnote-category.js → types/jats/importer/create-article-node.d.ts} +3 -2
  42. package/dist/types/jats/importer/jats-comments.d.ts +2 -15
  43. package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
  44. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +9 -0
  45. package/dist/types/jats/importer/jats-parser-utils.d.ts +2 -2
  46. package/dist/types/jats/importer/jats-transformations.d.ts +32 -0
  47. package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
  48. package/dist/types/jats/index.d.ts +5 -3
  49. package/dist/types/jats/types.d.ts +1 -0
  50. package/dist/{es/transformer/models.js → types/lib/deafults.d.ts} +2 -2
  51. package/dist/types/lib/utils.d.ts +1 -0
  52. package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
  53. package/dist/types/schema/nodes/contributor.d.ts +10 -0
  54. package/dist/types/schema/nodes/highlight_marker.d.ts +0 -2
  55. package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
  56. package/dist/types/schema/nodes/manuscript.d.ts +8 -7
  57. package/dist/types/schema/nodes/title.d.ts +0 -3
  58. package/dist/types/transformer/id.d.ts +0 -3
  59. package/dist/types/transformer/index.d.ts +0 -16
  60. package/dist/types/version.d.ts +1 -1
  61. package/package.json +2 -1
  62. package/dist/cjs/__tests__/data/project-dump.json +0 -825
  63. package/dist/cjs/jats/importer/index.js +0 -22
  64. package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
  65. package/dist/cjs/jats/importer/jats-reference-parser.js +0 -130
  66. package/dist/cjs/jats/importer/jats-references.js +0 -34
  67. package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
  68. package/dist/cjs/transformer/builders.js +0 -219
  69. package/dist/cjs/transformer/decode.js +0 -898
  70. package/dist/cjs/transformer/document-object-types.js +0 -31
  71. package/dist/cjs/transformer/encode.js +0 -674
  72. package/dist/cjs/transformer/footnote-category.js +0 -20
  73. package/dist/cjs/transformer/footnotes-order.js +0 -60
  74. package/dist/cjs/transformer/highlight-markers.js +0 -138
  75. package/dist/cjs/transformer/html.js +0 -400
  76. package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
  77. package/dist/cjs/transformer/object-types.js +0 -57
  78. package/dist/cjs/transformer/project-bundle.js +0 -94
  79. package/dist/cjs/transformer/serializer.js +0 -23
  80. package/dist/cjs/transformer/timestamp.js +0 -20
  81. package/dist/cjs/transformer/update-identifiers.js +0 -93
  82. package/dist/es/__tests__/data/project-dump.json +0 -825
  83. package/dist/es/jats/importer/index.js +0 -16
  84. package/dist/es/jats/importer/jats-front-parser.js +0 -315
  85. package/dist/es/jats/importer/jats-reference-parser.js +0 -127
  86. package/dist/es/jats/importer/jats-references.js +0 -30
  87. package/dist/es/transformer/__tests__/__helpers__/doc.js +0 -29
  88. package/dist/es/transformer/builders.js +0 -186
  89. package/dist/es/transformer/decode.js +0 -888
  90. package/dist/es/transformer/document-object-types.js +0 -28
  91. package/dist/es/transformer/encode.js +0 -664
  92. package/dist/es/transformer/filename.js +0 -23
  93. package/dist/es/transformer/footnotes-order.js +0 -55
  94. package/dist/es/transformer/highlight-markers.js +0 -132
  95. package/dist/es/transformer/html.js +0 -393
  96. package/dist/es/transformer/manuscript-dependencies.js +0 -17
  97. package/dist/es/transformer/model-map.js +0 -22
  98. package/dist/es/transformer/object-types.js +0 -52
  99. package/dist/es/transformer/project-bundle.js +0 -85
  100. package/dist/es/transformer/serializer.js +0 -17
  101. package/dist/es/transformer/timestamp.js +0 -16
  102. package/dist/es/transformer/update-identifiers.js +0 -87
  103. package/dist/types/jats/importer/index.d.ts +0 -16
  104. package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
  105. package/dist/types/jats/importer/jats-reference-parser.d.ts +0 -19
  106. package/dist/types/jats/importer/jats-references.d.ts +0 -12
  107. package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
  108. package/dist/types/transformer/builders.d.ts +0 -61
  109. package/dist/types/transformer/decode.d.ts +0 -52
  110. package/dist/types/transformer/document-object-types.d.ts +0 -17
  111. package/dist/types/transformer/encode.d.ts +0 -29
  112. package/dist/types/transformer/filename.d.ts +0 -16
  113. package/dist/types/transformer/footnote-category.d.ts +0 -17
  114. package/dist/types/transformer/footnotes-order.d.ts +0 -22
  115. package/dist/types/transformer/highlight-markers.d.ts +0 -31
  116. package/dist/types/transformer/html.d.ts +0 -36
  117. package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
  118. package/dist/types/transformer/model-map.d.ts +0 -19
  119. package/dist/types/transformer/models.d.ts +0 -48
  120. package/dist/types/transformer/object-types.d.ts +0 -30
  121. package/dist/types/transformer/project-bundle.d.ts +0 -30
  122. package/dist/types/transformer/serializer.d.ts +0 -19
  123. package/dist/types/transformer/update-identifiers.d.ts +0 -23
  124. package/dist/types/types.d.ts +0 -2
  125. /package/dist/cjs/{types.js → jats/types.js} +0 -0
  126. /package/dist/es/{types.js → jats/types.js} +0 -0
@@ -1,219 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildAuthorNotes = exports.buildFootnote = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
22
- const json_schema_1 = require("@manuscripts/json-schema");
23
- const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
24
- const schema_1 = require("../schema");
25
- const id_1 = require("./id");
26
- const timestamp_1 = require("./timestamp");
27
- const buildProject = (owner) => ({
28
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Project),
29
- objectType: json_schema_1.ObjectTypes.Project,
30
- owners: [owner],
31
- writers: [],
32
- viewers: [],
33
- title: '',
34
- });
35
- exports.buildProject = buildProject;
36
- const buildManuscript = () => ({
37
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Manuscript),
38
- objectType: json_schema_1.ObjectTypes.Manuscript,
39
- });
40
- exports.buildManuscript = buildManuscript;
41
- const buildContributor = (bibliographicName, role = 'author', priority = 0, userID, invitationID) => ({
42
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Contributor),
43
- objectType: json_schema_1.ObjectTypes.Contributor,
44
- priority,
45
- role,
46
- affiliations: [],
47
- bibliographicName: (0, exports.buildBibliographicName)(bibliographicName),
48
- userID,
49
- invitationID,
50
- });
51
- exports.buildContributor = buildContributor;
52
- const buildBibliographyItem = (data) => (Object.assign(Object.assign({}, data), { type: data.type || 'article-journal', _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.BibliographyItem), objectType: json_schema_1.ObjectTypes.BibliographyItem }));
53
- exports.buildBibliographyItem = buildBibliographyItem;
54
- const buildBibliographicName = (data) => (Object.assign(Object.assign({}, data), { _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.BibliographicName), objectType: json_schema_1.ObjectTypes.BibliographicName }));
55
- exports.buildBibliographicName = buildBibliographicName;
56
- const buildBibliographicDate = (data) => (Object.assign(Object.assign({}, data), { _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.BibliographicDate), objectType: json_schema_1.ObjectTypes.BibliographicDate }));
57
- exports.buildBibliographicDate = buildBibliographicDate;
58
- const buildBibliographyElement = (bibliographyItems) => ({
59
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.BibliographyElement),
60
- objectType: json_schema_1.ObjectTypes.BibliographyElement,
61
- contents: '',
62
- elementType: 'div',
63
- containedObjectIDs: bibliographyItems.map((b) => b._id),
64
- });
65
- exports.buildBibliographyElement = buildBibliographyElement;
66
- const buildKeyword = (name) => ({
67
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Keyword),
68
- objectType: json_schema_1.ObjectTypes.Keyword,
69
- name,
70
- });
71
- exports.buildKeyword = buildKeyword;
72
- const buildKeywordGroup = (attributes) => (Object.assign(Object.assign(Object.assign({ _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.KeywordGroup), objectType: json_schema_1.ObjectTypes.KeywordGroup }, (attributes.type && { type: attributes.type })), (attributes.title && { title: attributes.title })), (attributes.label && { label: attributes.label })));
73
- exports.buildKeywordGroup = buildKeywordGroup;
74
- const buildFigure = (blob) => ({
75
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Figure),
76
- objectType: json_schema_1.ObjectTypes.Figure,
77
- contentType: blob.type,
78
- src: window.URL.createObjectURL(blob),
79
- attachment: {
80
- id: 'image',
81
- type: blob.type,
82
- data: blob,
83
- },
84
- });
85
- exports.buildFigure = buildFigure;
86
- const buildAffiliation = (institution, priority = 0) => ({
87
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Affiliation),
88
- objectType: json_schema_1.ObjectTypes.Affiliation,
89
- institution,
90
- priority,
91
- });
92
- exports.buildAffiliation = buildAffiliation;
93
- const buildSupplementaryMaterial = (title, href) => ({
94
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Supplement),
95
- objectType: json_schema_1.ObjectTypes.Supplement,
96
- title,
97
- href,
98
- });
99
- exports.buildSupplementaryMaterial = buildSupplementaryMaterial;
100
- const buildComment = (target, contents = '', selector, contributions, annotationColor) => ({
101
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.CommentAnnotation),
102
- objectType: json_schema_1.ObjectTypes.CommentAnnotation,
103
- target,
104
- selector,
105
- contents,
106
- contributions,
107
- annotationColor,
108
- });
109
- exports.buildComment = buildComment;
110
- const buildNote = (target, source, contents = '') => ({
111
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.ManuscriptNote),
112
- objectType: json_schema_1.ObjectTypes.ManuscriptNote,
113
- target,
114
- source,
115
- contents,
116
- });
117
- exports.buildNote = buildNote;
118
- const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
119
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Footnote),
120
- objectType: json_schema_1.ObjectTypes.Footnote,
121
- containingObject: containingObject || undefined,
122
- contents,
123
- kind,
124
- });
125
- exports.buildFootnote = buildFootnote;
126
- const buildAuthorNotes = (containedObjectIDs) => ({
127
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.AuthorNotes),
128
- objectType: json_schema_1.ObjectTypes.AuthorNotes,
129
- containedObjectIDs: containedObjectIDs,
130
- });
131
- exports.buildAuthorNotes = buildAuthorNotes;
132
- const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
133
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
134
- objectType: json_schema_1.ObjectTypes.FootnotesOrder,
135
- footnotesList,
136
- containedObjectID,
137
- });
138
- exports.buildFootnotesOrder = buildFootnotesOrder;
139
- const buildCorresp = (contents) => ({
140
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Corresponding),
141
- objectType: json_schema_1.ObjectTypes.Corresponding,
142
- contents,
143
- });
144
- exports.buildCorresp = buildCorresp;
145
- const buildSection = (priority = 0, path = []) => {
146
- const id = (0, id_1.generateID)(json_schema_1.ObjectTypes.Section);
147
- return {
148
- _id: id,
149
- objectType: json_schema_1.ObjectTypes.Section,
150
- priority,
151
- path: path.concat(id),
152
- };
153
- };
154
- exports.buildSection = buildSection;
155
- const buildParagraph = (innerHTML = '') => {
156
- const _id = (0, id_1.generateID)(json_schema_1.ObjectTypes.ParagraphElement);
157
- const element = document.createElementNS(null, 'p');
158
- element.setAttribute('id', _id);
159
- if (innerHTML) {
160
- element.innerHTML = innerHTML;
161
- }
162
- const contents = (0, w3c_xmlserializer_1.default)(element);
163
- return {
164
- _id,
165
- objectType: json_schema_1.ObjectTypes.ParagraphElement,
166
- elementType: 'p',
167
- contents,
168
- };
169
- };
170
- exports.buildParagraph = buildParagraph;
171
- const buildColor = (value, priority) => ({
172
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Color),
173
- objectType: json_schema_1.ObjectTypes.Color,
174
- priority,
175
- value,
176
- });
177
- exports.buildColor = buildColor;
178
- const buildContribution = (profileID) => ({
179
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Contribution),
180
- objectType: json_schema_1.ObjectTypes.Contribution,
181
- profileID,
182
- timestamp: (0, timestamp_1.timestamp)(),
183
- });
184
- exports.buildContribution = buildContribution;
185
- const buildContributorRole = (name) => ({
186
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.ContributorRole),
187
- objectType: json_schema_1.ObjectTypes.ContributorRole,
188
- name,
189
- });
190
- exports.buildContributorRole = buildContributorRole;
191
- const buildAttribution = () => ({
192
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Attribution),
193
- objectType: json_schema_1.ObjectTypes.Attribution,
194
- });
195
- exports.buildAttribution = buildAttribution;
196
- const buildJournal = () => ({
197
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Journal),
198
- objectType: json_schema_1.ObjectTypes.Journal,
199
- });
200
- exports.buildJournal = buildJournal;
201
- exports.auxiliaryObjectTypes = new Set([
202
- schema_1.schema.nodes.figure_element,
203
- schema_1.schema.nodes.table_element,
204
- schema_1.schema.nodes.equation_element,
205
- schema_1.schema.nodes.listing_element,
206
- ]);
207
- const buildElementsOrder = (elementType) => ({
208
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.ElementsOrder),
209
- objectType: json_schema_1.ObjectTypes.ElementsOrder,
210
- elementType: elementType,
211
- elements: [],
212
- });
213
- exports.buildElementsOrder = buildElementsOrder;
214
- const buildTitles = (title) => ({
215
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Titles),
216
- objectType: json_schema_1.ObjectTypes.Titles,
217
- title: title || '',
218
- });
219
- exports.buildTitles = buildTitles;