@manuscripts/transform 4.5.2 → 4.5.4

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 (60) hide show
  1. package/dist/cjs/jats/__tests__/data/section-categories.js +5 -5
  2. package/dist/cjs/jats/__tests__/jats-importer.test.js +19 -5
  3. package/dist/cjs/jats/exporter/jats-exporter.js +725 -910
  4. package/dist/cjs/jats/exporter/jats-versions.js +9 -9
  5. package/dist/cjs/jats/importer/jats-dom-parser.js +25 -24
  6. package/dist/cjs/jats/importer/jats-transformations.js +14 -30
  7. package/dist/cjs/lib/section-categories.js +31 -1
  8. package/dist/cjs/schema/index.js +3 -0
  9. package/dist/cjs/schema/migration/migration-scripts/4.5.3.js +37 -0
  10. package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
  11. package/dist/cjs/schema/nodes/abstract.js +51 -0
  12. package/dist/cjs/schema/nodes/abstracts.js +1 -1
  13. package/dist/cjs/transformer/node-names.js +1 -0
  14. package/dist/cjs/transformer/node-title.js +2 -0
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/es/jats/__tests__/data/section-categories.js +5 -5
  17. package/dist/es/jats/__tests__/jats-importer.test.js +19 -5
  18. package/dist/es/jats/exporter/jats-exporter.js +728 -913
  19. package/dist/es/jats/exporter/jats-versions.js +7 -7
  20. package/dist/es/jats/importer/jats-dom-parser.js +25 -24
  21. package/dist/es/jats/importer/jats-transformations.js +14 -30
  22. package/dist/es/lib/section-categories.js +28 -0
  23. package/dist/es/schema/index.js +3 -0
  24. package/dist/es/schema/migration/migration-scripts/4.5.3.js +35 -0
  25. package/dist/es/schema/migration/migration-scripts/index.js +2 -0
  26. package/dist/es/schema/nodes/abstract.js +47 -0
  27. package/dist/es/schema/nodes/abstracts.js +1 -1
  28. package/dist/es/transformer/node-names.js +1 -0
  29. package/dist/es/transformer/node-title.js +2 -0
  30. package/dist/es/version.js +1 -1
  31. package/dist/types/jats/exporter/jats-exporter.d.ts +31 -27
  32. package/dist/types/jats/exporter/jats-versions.d.ts +4 -4
  33. package/dist/types/jats/importer/jats-dom-parser.d.ts +0 -1
  34. package/dist/types/lib/section-categories.d.ts +3 -0
  35. package/dist/types/schema/index.d.ts +1 -0
  36. package/dist/types/schema/migration/migration-scripts/4.5.3.d.ts +8 -0
  37. package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
  38. package/dist/types/schema/nodes/abstract.d.ts +26 -0
  39. package/dist/types/schema/types.d.ts +1 -1
  40. package/dist/types/version.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/src/jats/__tests__/__snapshots__/jats-exporter.test.ts.snap +3 -3
  43. package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +86 -132
  44. package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +3 -3
  45. package/src/jats/__tests__/data/section-categories.ts +5 -5
  46. package/src/jats/__tests__/jats-importer.test.ts +22 -6
  47. package/src/jats/exporter/jats-exporter.ts +855 -1126
  48. package/src/jats/exporter/jats-versions.ts +11 -11
  49. package/src/jats/importer/jats-dom-parser.ts +34 -34
  50. package/src/jats/importer/jats-transformations.ts +21 -37
  51. package/src/lib/section-categories.ts +36 -0
  52. package/src/schema/index.ts +3 -0
  53. package/src/schema/migration/migration-scripts/4.5.3.ts +57 -0
  54. package/src/schema/migration/migration-scripts/index.ts +2 -0
  55. package/src/schema/nodes/abstract.ts +66 -0
  56. package/src/schema/nodes/abstracts.ts +2 -1
  57. package/src/schema/types.ts +1 -0
  58. package/src/transformer/node-names.ts +1 -0
  59. package/src/transformer/node-title.ts +2 -0
  60. package/src/version.ts +1 -1
@@ -25,35 +25,35 @@ exports.sectionCategories = [
25
25
  isUnique: true,
26
26
  },
27
27
  {
28
- id: 'abstract-graphical',
28
+ id: 'graphical',
29
29
  titles: ['Graphical Abstract'],
30
30
  synonyms: [''],
31
31
  group: 'abstracts-graphic',
32
32
  isUnique: true,
33
33
  },
34
34
  {
35
- id: 'abstract-key-image',
35
+ id: 'key-image',
36
36
  titles: ['Key Image'],
37
37
  synonyms: [''],
38
38
  group: 'abstracts-graphic',
39
39
  isUnique: true,
40
40
  },
41
41
  {
42
- id: 'abstract-short',
42
+ id: 'short',
43
43
  titles: ['Short'],
44
44
  synonyms: [''],
45
45
  group: 'abstracts',
46
46
  isUnique: true,
47
47
  },
48
48
  {
49
- id: 'abstract-teaser',
49
+ id: 'teaser',
50
50
  titles: ['Abstract Teaser'],
51
51
  synonyms: [''],
52
52
  isUnique: true,
53
53
  group: 'abstracts',
54
54
  },
55
55
  {
56
- id: 'abstract-toc',
56
+ id: 'toc',
57
57
  titles: ['Table of contents'],
58
58
  synonyms: [''],
59
59
  group: 'abstracts',
@@ -291,8 +291,22 @@ describe('JATS importer', () => {
291
291
  }
292
292
  const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
293
293
  const abstractsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
294
- const sections = (0, utils_1.findNodesByType)(abstractsNode, schema_1.schema.nodes.section);
295
- expect(sections).toHaveLength(6);
294
+ const abstracts = (0, utils_1.findNodesByType)(abstractsNode, schema_1.schema.nodes.abstract);
295
+ expect(abstracts).toHaveLength(2);
296
+ });
297
+ it('should order abstracts children per the schema', async () => {
298
+ const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
299
+ const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
300
+ const abstractsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
301
+ const childTypes = [];
302
+ abstractsNode.content.forEach((child) => childTypes.push(child.type.name));
303
+ expect(childTypes).toEqual([
304
+ 'abstract',
305
+ 'graphical_abstract_section',
306
+ 'graphical_abstract_section',
307
+ 'abstract',
308
+ 'trans_abstract',
309
+ ]);
296
310
  });
297
311
  it('should set the title to Abstract if no title is provided', async () => {
298
312
  const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
@@ -302,9 +316,9 @@ describe('JATS importer', () => {
302
316
  }
303
317
  const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
304
318
  const abstractsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
305
- const sections = (0, utils_1.findNodesByType)(abstractsNode, schema_1.schema.nodes.section);
306
- const firstSection = sections[0];
307
- const titleNode = (0, utils_1.findNodeByType)(firstSection, schema_1.schema.nodes.section_title);
319
+ const abstracts = (0, utils_1.findNodesByType)(abstractsNode, schema_1.schema.nodes.abstract);
320
+ const firstAbstract = abstracts[0];
321
+ const titleNode = (0, utils_1.findNodeByType)(firstAbstract, schema_1.schema.nodes.section_title);
308
322
  expect(titleNode.textContent).toBe('Abstract');
309
323
  });
310
324
  });