@manuscripts/transform 1.2.1 → 1.2.3

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.
@@ -21,39 +21,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.jatsFrontParser = void 0;
22
22
  const debug_1 = __importDefault(require("debug"));
23
23
  const builders_1 = require("../../transformer/builders");
24
- const bundles_1 = require("../../transformer/bundles");
25
- const bundles_data_1 = require("../../transformer/bundles-data");
26
24
  const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
27
25
  const warn = (0, debug_1.default)('manuscripts-transform');
28
26
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
29
- const chooseBundle = async (issns) => {
30
- const issnBundleIndex = await (0, bundles_data_1.loadIssnBundleIndex)();
31
- for (const { ISSN } of issns) {
32
- const normalizedIssn = ISSN.toUpperCase().replace(/[^0-9X]/g, '');
33
- if (normalizedIssn in issnBundleIndex) {
34
- return issnBundleIndex[normalizedIssn];
35
- }
36
- }
37
- };
38
27
  exports.jatsFrontParser = {
39
- async loadJournalBundles(issns) {
40
- if (issns.length === 0) {
41
- return {
42
- manuscript_bundle: undefined,
43
- bundleNodes: [],
44
- };
45
- }
46
- const bundleID = await chooseBundle(issns);
47
- const bundlesMap = bundleID ? await (0, bundles_data_1.loadBundlesMap)() : undefined;
48
- const bundle = bundleID && bundlesMap ? (0, bundles_1.createNewBundle)(bundleID, bundlesMap) : undefined;
49
- const parentBundle = bundle && bundleID && bundlesMap
50
- ? (0, bundles_1.createParentBundle)(bundle, bundlesMap)
51
- : undefined;
52
- return {
53
- manuscript_bundle: bundle === null || bundle === void 0 ? void 0 : bundle._id,
54
- bundleNodes: [parentBundle, bundle].filter((v) => v !== undefined),
55
- };
56
- },
57
28
  parseCounts(counts) {
58
29
  var _a, _b, _c, _d, _e;
59
30
  if (counts) {
@@ -47,7 +47,6 @@ const parseJATSFront = async (front) => {
47
47
  var _a, _b, _c;
48
48
  const journalMeta = jats_front_parser_1.jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
49
49
  const journal = Object.assign(Object.assign({}, (0, builders_1.buildJournal)()), journalMeta);
50
- const { manuscript_bundle, bundleNodes } = await jats_front_parser_1.jatsFrontParser.loadJournalBundles(journal.ISSNs);
51
50
  const articleMeta = front.querySelector('article-meta');
52
51
  const title = (_a = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > article-title')) === null || _a === void 0 ? void 0 : _a.innerHTML;
53
52
  const subtitle = (_b = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > subtitle')) === null || _b === void 0 ? void 0 : _b.innerHTML;
@@ -74,11 +73,10 @@ const parseJATSFront = async (front) => {
74
73
  const supplements = jats_front_parser_1.jatsFrontParser.parseSupplements([
75
74
  ...front.querySelectorAll('article-meta > supplementary-material'),
76
75
  ]);
77
- const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), manuscriptMeta), { bundle: manuscript_bundle, keywordIDs: manuscript_keywordIDs }), history);
76
+ const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), manuscriptMeta), { keywordIDs: manuscript_keywordIDs }), history);
78
77
  return {
79
78
  models: generateModelIDs([
80
79
  manuscript,
81
- ...bundleNodes,
82
80
  ...keywords,
83
81
  ...affiliations,
84
82
  ...authors,
@@ -88,7 +86,6 @@ const parseJATSFront = async (front) => {
88
86
  journal,
89
87
  ...supplements,
90
88
  ]),
91
- bundles: bundleNodes,
92
89
  };
93
90
  };
94
91
  exports.parseJATSFront = parseJATSFront;
@@ -30,7 +30,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  __exportStar(require("./builders"), exports);
33
- __exportStar(require("./bundles"), exports);
34
33
  __exportStar(require("./decode"), exports);
35
34
  __exportStar(require("./document-object-types"), exports);
36
35
  __exportStar(require("./encode"), exports);
@@ -15,39 +15,10 @@
15
15
  */
16
16
  import debug from 'debug';
17
17
  import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildKeyword, buildKeywordGroup, buildSupplementaryMaterial, } from '../../transformer/builders';
18
- import { createNewBundle, createParentBundle } from '../../transformer/bundles';
19
- import { loadBundlesMap, loadIssnBundleIndex, } from '../../transformer/bundles-data';
20
18
  import { parseJournalMeta } from './jats-journal-meta-parser';
21
19
  const warn = debug('manuscripts-transform');
22
20
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
23
- const chooseBundle = async (issns) => {
24
- const issnBundleIndex = await loadIssnBundleIndex();
25
- for (const { ISSN } of issns) {
26
- const normalizedIssn = ISSN.toUpperCase().replace(/[^0-9X]/g, '');
27
- if (normalizedIssn in issnBundleIndex) {
28
- return issnBundleIndex[normalizedIssn];
29
- }
30
- }
31
- };
32
21
  export const jatsFrontParser = {
33
- async loadJournalBundles(issns) {
34
- if (issns.length === 0) {
35
- return {
36
- manuscript_bundle: undefined,
37
- bundleNodes: [],
38
- };
39
- }
40
- const bundleID = await chooseBundle(issns);
41
- const bundlesMap = bundleID ? await loadBundlesMap() : undefined;
42
- const bundle = bundleID && bundlesMap ? createNewBundle(bundleID, bundlesMap) : undefined;
43
- const parentBundle = bundle && bundleID && bundlesMap
44
- ? createParentBundle(bundle, bundlesMap)
45
- : undefined;
46
- return {
47
- manuscript_bundle: bundle === null || bundle === void 0 ? void 0 : bundle._id,
48
- bundleNodes: [parentBundle, bundle].filter((v) => v !== undefined),
49
- };
50
- },
51
22
  parseCounts(counts) {
52
23
  var _a, _b, _c, _d, _e;
53
24
  if (counts) {
@@ -44,7 +44,6 @@ export const parseJATSFront = async (front) => {
44
44
  var _a, _b, _c;
45
45
  const journalMeta = jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
46
46
  const journal = Object.assign(Object.assign({}, buildJournal()), journalMeta);
47
- const { manuscript_bundle, bundleNodes } = await jatsFrontParser.loadJournalBundles(journal.ISSNs);
48
47
  const articleMeta = front.querySelector('article-meta');
49
48
  const title = (_a = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > article-title')) === null || _a === void 0 ? void 0 : _a.innerHTML;
50
49
  const subtitle = (_b = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > subtitle')) === null || _b === void 0 ? void 0 : _b.innerHTML;
@@ -71,11 +70,10 @@ export const parseJATSFront = async (front) => {
71
70
  const supplements = jatsFrontParser.parseSupplements([
72
71
  ...front.querySelectorAll('article-meta > supplementary-material'),
73
72
  ]);
74
- const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, buildManuscript()), manuscriptMeta), { bundle: manuscript_bundle, keywordIDs: manuscript_keywordIDs }), history);
73
+ const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, buildManuscript()), manuscriptMeta), { keywordIDs: manuscript_keywordIDs }), history);
75
74
  return {
76
75
  models: generateModelIDs([
77
76
  manuscript,
78
- ...bundleNodes,
79
77
  ...keywords,
80
78
  ...affiliations,
81
79
  ...authors,
@@ -85,7 +83,6 @@ export const parseJATSFront = async (front) => {
85
83
  journal,
86
84
  ...supplements,
87
85
  ]),
88
- bundles: bundleNodes,
89
86
  };
90
87
  };
91
88
  export const parseJATSReferences = (back, body, createElement) => {
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export * from './builders';
17
- export * from './bundles';
18
17
  export * from './decode';
19
18
  export * from './document-object-types';
20
19
  export * from './encode';
@@ -13,14 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Bundle, Journal, Keyword, KeywordGroup } from '@manuscripts/json-schema';
16
+ import { Journal, Keyword, KeywordGroup } from '@manuscripts/json-schema';
17
17
  import { Build } from '../../transformer/builders';
18
- import { ISSN } from './jats-journal-meta-parser';
19
18
  export declare const jatsFrontParser: {
20
- loadJournalBundles(issns: ISSN[]): Promise<{
21
- manuscript_bundle: string | undefined;
22
- bundleNodes: Bundle[];
23
- }>;
24
19
  parseCounts(counts: Element | null | undefined): {
25
20
  wordCount: number | undefined;
26
21
  figureCount: number | undefined;
@@ -17,7 +17,6 @@ import { BibliographyItem, ElementsOrder, FootnotesOrder, Model } from '@manuscr
17
17
  import { ManuscriptNode } from '../../schema';
18
18
  export declare const parseJATSFront: (front: Element) => Promise<{
19
19
  models: Model[];
20
- bundles: import("@manuscripts/json-schema").Bundle[];
21
20
  }>;
22
21
  export declare const parseJATSReferences: (back: Element | null, body: Element | null, createElement: (tagName: string) => HTMLElement) => {
23
22
  references: Model[];
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export * from './builders';
17
- export * from './bundles';
18
17
  export * from './decode';
19
18
  export * from './document-object-types';
20
19
  export * from './encode';
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.2.1",
4
+ "version": "1.2.3",
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.0",
32
+ "@manuscripts/json-schema": "^2.0.1",
33
33
  "debug": "^4.3.4",
34
34
  "jszip": "^3.10.1",
35
35
  "mathjax-full": "^3.2.2",
@@ -43,7 +43,7 @@
43
43
  "@babel/preset-env": "^7.20.2",
44
44
  "@babel/preset-typescript": "^7.18.6",
45
45
  "@jats4r/dtds": "^0.0.8",
46
- "@manuscripts/data": "^0.1.12",
46
+ "@manuscripts/data": "^1.0.2",
47
47
  "@manuscripts/eslint-config": "^0.5.1",
48
48
  "@manuscripts/examples": "^0.1.0",
49
49
  "@types/debug": "^4.1.7",
@@ -80,7 +80,7 @@
80
80
  "typescript": "^4.0.5"
81
81
  },
82
82
  "peerDependencies": {
83
- "@manuscripts/data": "^0.1.12",
83
+ "@manuscripts/data": "^1.0.2",
84
84
  "prosemirror-model": "^1.18.3",
85
85
  "prosemirror-state": "^1.4.2",
86
86
  "prosemirror-view": "^1.29.1"
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.loadIssnBundleIndex = exports.loadBundlesMap = void 0;
27
- const loadBundlesMap = async () => {
28
- const { default: bundles } = await Promise.resolve().then(() => __importStar(require('@manuscripts/data/dist/shared/bundles.json')));
29
- return new Map(bundles.map((bundle) => [bundle._id, bundle]));
30
- };
31
- exports.loadBundlesMap = loadBundlesMap;
32
- const loadIssnBundleIndex = async () => {
33
- const { default: issnBundleIndex } = await Promise.resolve().then(() => __importStar(require('@manuscripts/data/dist/shared/issn-bundle-index.json')));
34
- return issnBundleIndex;
35
- };
36
- exports.loadIssnBundleIndex = loadIssnBundleIndex;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNewBundle = exports.createParentBundle = void 0;
4
- const manuscript_dependencies_1 = require("./manuscript-dependencies");
5
- const findBundleByURL = (url, bundles) => {
6
- for (const bundle of bundles.values()) {
7
- if (bundle.csl && bundle.csl['self-URL'] === url) {
8
- return bundle;
9
- }
10
- }
11
- };
12
- const createParentBundle = (bundle, bundles) => {
13
- if (bundle.csl) {
14
- const parentURL = bundle.csl['independent-parent-URL'];
15
- if (parentURL) {
16
- const parentBundle = findBundleByURL(parentURL, bundles);
17
- if (!parentBundle) {
18
- throw new Error(`Bundle with URL not found: ${parentURL} `);
19
- }
20
- return (0, manuscript_dependencies_1.fromPrototype)(parentBundle);
21
- }
22
- }
23
- };
24
- exports.createParentBundle = createParentBundle;
25
- const createNewBundle = (bundleID, bundles) => {
26
- const bundle = bundles.get(bundleID);
27
- if (!bundle) {
28
- throw new Error(`Bundle not found: ${bundleID}`);
29
- }
30
- return (0, manuscript_dependencies_1.fromPrototype)(bundle);
31
- };
32
- exports.createNewBundle = createNewBundle;
@@ -1,8 +0,0 @@
1
- export const loadBundlesMap = async () => {
2
- const { default: bundles } = await import('@manuscripts/data/dist/shared/bundles.json');
3
- return new Map(bundles.map((bundle) => [bundle._id, bundle]));
4
- };
5
- export const loadIssnBundleIndex = async () => {
6
- const { default: issnBundleIndex } = await import('@manuscripts/data/dist/shared/issn-bundle-index.json');
7
- return issnBundleIndex;
8
- };
@@ -1,27 +0,0 @@
1
- import { fromPrototype } from './manuscript-dependencies';
2
- const findBundleByURL = (url, bundles) => {
3
- for (const bundle of bundles.values()) {
4
- if (bundle.csl && bundle.csl['self-URL'] === url) {
5
- return bundle;
6
- }
7
- }
8
- };
9
- export const createParentBundle = (bundle, bundles) => {
10
- if (bundle.csl) {
11
- const parentURL = bundle.csl['independent-parent-URL'];
12
- if (parentURL) {
13
- const parentBundle = findBundleByURL(parentURL, bundles);
14
- if (!parentBundle) {
15
- throw new Error(`Bundle with URL not found: ${parentURL} `);
16
- }
17
- return fromPrototype(parentBundle);
18
- }
19
- }
20
- };
21
- export const createNewBundle = (bundleID, bundles) => {
22
- const bundle = bundles.get(bundleID);
23
- if (!bundle) {
24
- throw new Error(`Bundle not found: ${bundleID}`);
25
- }
26
- return fromPrototype(bundle);
27
- };
@@ -1,3 +0,0 @@
1
- import { Bundle } from '@manuscripts/json-schema';
2
- export declare const loadBundlesMap: () => Promise<Map<string, Bundle>>;
3
- export declare const loadIssnBundleIndex: () => Promise<Record<string, string>>;
@@ -1,3 +0,0 @@
1
- import { Bundle } from '@manuscripts/json-schema';
2
- export declare const createParentBundle: (bundle: Bundle, bundles: Map<string, Bundle>) => Bundle | undefined;
3
- export declare const createNewBundle: (bundleID: string, bundles: Map<string, Bundle>) => Bundle;