@manuscripts/transform 2.3.38-LEAN-3911.0 → 2.6.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/__tests__/data/project-dump.json +825 -0
  2. package/dist/cjs/index.js +6 -6
  3. package/dist/cjs/jats/importer/index.js +22 -0
  4. package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +34 -273
  5. package/dist/cjs/jats/importer/jats-body-transformations.js +22 -74
  6. package/dist/cjs/jats/importer/jats-comments.js +104 -27
  7. package/dist/cjs/jats/importer/jats-front-parser.js +321 -0
  8. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +1 -8
  9. package/dist/cjs/jats/importer/jats-parser-utils.js +5 -43
  10. package/dist/cjs/jats/importer/jats-reference-parser.js +23 -16
  11. package/dist/cjs/jats/importer/jats-references.js +18 -18
  12. package/dist/cjs/jats/importer/parse-jats-article.js +79 -40
  13. package/dist/cjs/jats/index.js +7 -7
  14. package/dist/cjs/jats/{exporter/jats-exporter.js → jats-exporter.js} +398 -264
  15. package/dist/cjs/jats/{exporter/jats-versions.js → jats-versions.js} +3 -1
  16. package/dist/cjs/lib/utils.js +1 -12
  17. package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
  18. package/dist/cjs/transformer/builders.js +219 -0
  19. package/dist/cjs/transformer/decode.js +898 -0
  20. package/dist/cjs/transformer/document-object-types.js +31 -0
  21. package/dist/cjs/transformer/encode.js +674 -0
  22. package/dist/cjs/{jats/importer/create-article-node.js → transformer/filename.js} +9 -10
  23. package/dist/cjs/transformer/footnote-category.js +20 -0
  24. package/dist/cjs/transformer/footnotes-order.js +60 -0
  25. package/dist/cjs/transformer/highlight-markers.js +138 -0
  26. package/dist/cjs/transformer/html.js +400 -0
  27. package/dist/cjs/transformer/id.js +5 -10
  28. package/dist/cjs/transformer/index.js +18 -0
  29. package/dist/cjs/{jats/exporter → transformer}/labels.js +5 -4
  30. package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
  31. package/dist/cjs/transformer/model-map.js +26 -0
  32. package/dist/cjs/{lib/deafults.js → transformer/models.js} +1 -3
  33. package/dist/cjs/transformer/node-names.js +1 -0
  34. package/dist/cjs/transformer/object-types.js +57 -0
  35. package/dist/cjs/transformer/project-bundle.js +94 -0
  36. package/dist/cjs/transformer/serializer.js +23 -0
  37. package/dist/cjs/transformer/timestamp.js +20 -0
  38. package/dist/cjs/transformer/update-identifiers.js +93 -0
  39. package/dist/cjs/version.js +1 -1
  40. package/dist/es/__tests__/data/project-dump.json +825 -0
  41. package/dist/es/index.js +5 -5
  42. package/dist/{types/jats/importer/create-article-node.d.ts → es/jats/importer/index.js} +2 -3
  43. package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +35 -274
  44. package/dist/es/jats/importer/jats-body-transformations.js +22 -74
  45. package/dist/es/jats/importer/jats-comments.js +101 -26
  46. package/dist/es/jats/importer/jats-front-parser.js +315 -0
  47. package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -6
  48. package/dist/es/jats/importer/jats-parser-utils.js +6 -44
  49. package/dist/es/jats/importer/jats-reference-parser.js +23 -16
  50. package/dist/es/jats/importer/jats-references.js +18 -18
  51. package/dist/es/jats/importer/parse-jats-article.js +78 -41
  52. package/dist/es/jats/index.js +3 -5
  53. package/dist/es/jats/{exporter/jats-exporter.js → jats-exporter.js} +392 -258
  54. package/dist/es/jats/{exporter/jats-versions.js → jats-versions.js} +1 -0
  55. package/dist/es/lib/utils.js +0 -9
  56. package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
  57. package/dist/es/transformer/builders.js +186 -0
  58. package/dist/es/transformer/decode.js +888 -0
  59. package/dist/es/transformer/document-object-types.js +28 -0
  60. package/dist/es/transformer/encode.js +664 -0
  61. package/dist/es/transformer/filename.js +23 -0
  62. package/dist/es/transformer/footnote-category.js +16 -0
  63. package/dist/es/transformer/footnotes-order.js +55 -0
  64. package/dist/es/transformer/highlight-markers.js +132 -0
  65. package/dist/es/transformer/html.js +393 -0
  66. package/dist/es/transformer/id.js +3 -8
  67. package/dist/es/transformer/index.js +16 -0
  68. package/dist/es/{jats/exporter → transformer}/labels.js +5 -4
  69. package/dist/es/transformer/manuscript-dependencies.js +17 -0
  70. package/dist/es/transformer/model-map.js +22 -0
  71. package/dist/es/{lib/deafults.js → transformer/models.js} +2 -2
  72. package/dist/es/transformer/node-names.js +1 -0
  73. package/dist/es/transformer/object-types.js +52 -0
  74. package/dist/es/transformer/project-bundle.js +85 -0
  75. package/dist/es/transformer/serializer.js +17 -0
  76. package/dist/es/transformer/timestamp.js +16 -0
  77. package/dist/es/transformer/update-identifiers.js +87 -0
  78. package/dist/es/version.js +1 -1
  79. package/dist/types/index.d.ts +6 -6
  80. package/dist/types/jats/importer/index.d.ts +16 -0
  81. package/dist/types/jats/importer/{jats-dom-parser.d.ts → jats-body-dom-parser.d.ts} +1 -1
  82. package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -5
  83. package/dist/types/jats/importer/jats-comments.d.ts +10 -4
  84. package/dist/types/jats/importer/jats-front-parser.d.ts +84 -0
  85. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -10
  86. package/dist/types/jats/importer/jats-references.d.ts +8 -19
  87. package/dist/types/jats/importer/parse-jats-article.d.ts +5 -12
  88. package/dist/types/jats/index.d.ts +3 -5
  89. package/dist/types/jats/{exporter/jats-exporter.d.ts → jats-exporter.d.ts} +29 -15
  90. package/dist/types/jats/{exporter/jats-versions.d.ts → jats-versions.d.ts} +1 -0
  91. package/dist/types/lib/utils.d.ts +0 -2
  92. package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
  93. package/dist/types/schema/nodes/contributor.d.ts +0 -10
  94. package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
  95. package/dist/types/schema/nodes/manuscript.d.ts +7 -8
  96. package/dist/types/schema/nodes/title.d.ts +3 -0
  97. package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +18 -0
  98. package/dist/types/transformer/builders.d.ts +61 -0
  99. package/dist/types/transformer/decode.d.ts +52 -0
  100. package/dist/types/transformer/document-object-types.d.ts +17 -0
  101. package/dist/types/transformer/encode.d.ts +29 -0
  102. package/dist/types/transformer/filename.d.ts +16 -0
  103. package/dist/types/transformer/footnote-category.d.ts +17 -0
  104. package/dist/{es/jats/importer/create-article-node.js → types/transformer/footnotes-order.d.ts} +8 -10
  105. package/dist/types/transformer/highlight-markers.d.ts +31 -0
  106. package/dist/types/transformer/html.d.ts +36 -0
  107. package/dist/types/transformer/id.d.ts +2 -5
  108. package/dist/types/transformer/index.d.ts +16 -0
  109. package/dist/types/{jats/exporter → transformer}/labels.d.ts +2 -2
  110. package/dist/types/transformer/manuscript-dependencies.d.ts +4 -0
  111. package/dist/types/transformer/model-map.d.ts +19 -0
  112. package/dist/types/transformer/models.d.ts +48 -0
  113. package/dist/types/transformer/object-types.d.ts +30 -0
  114. package/dist/types/transformer/project-bundle.d.ts +30 -0
  115. package/dist/types/transformer/serializer.d.ts +19 -0
  116. package/dist/types/{lib/deafults.d.ts → transformer/timestamp.d.ts} +2 -2
  117. package/dist/types/transformer/update-identifiers.d.ts +23 -0
  118. package/dist/types/types.d.ts +2 -0
  119. package/dist/types/version.d.ts +1 -1
  120. package/package.json +1 -2
  121. package/dist/cjs/jats/importer/jats-front-transformations.js +0 -79
  122. package/dist/es/jats/importer/jats-front-transformations.js +0 -76
  123. package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -22
  124. package/dist/types/jats/types.d.ts +0 -1
  125. /package/dist/cjs/{jats/types.js → types.js} +0 -0
  126. /package/dist/es/{jats/types.js → types.js} +0 -0
@@ -29,8 +29,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
29
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.createTestDoc = void 0;
33
+ __exportStar(require("./builders"), exports);
34
+ __exportStar(require("./decode"), exports);
35
+ __exportStar(require("./document-object-types"), exports);
36
+ __exportStar(require("./encode"), exports);
37
+ __exportStar(require("./filename"), exports);
38
+ __exportStar(require("./highlight-markers"), exports);
39
+ __exportStar(require("./html"), exports);
32
40
  __exportStar(require("./id"), exports);
41
+ __exportStar(require("./labels"), exports);
42
+ __exportStar(require("./manuscript-dependencies"), exports);
43
+ __exportStar(require("./models"), exports);
33
44
  __exportStar(require("./node-names"), exports);
34
45
  __exportStar(require("./node-title"), exports);
35
46
  __exportStar(require("./node-types"), exports);
47
+ __exportStar(require("./object-types"), exports);
48
+ __exportStar(require("./project-bundle"), exports);
36
49
  __exportStar(require("./section-category"), exports);
50
+ __exportStar(require("./serializer"), exports);
51
+ __exportStar(require("./timestamp"), exports);
52
+ __exportStar(require("./update-identifiers"), exports);
53
+ var doc_1 = require("./__tests__/__helpers__/doc");
54
+ Object.defineProperty(exports, "createTestDoc", { enumerable: true, get: function () { return doc_1.createTestDoc; } });
@@ -16,19 +16,20 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.buildTargets = void 0;
19
- const schema_1 = require("../../schema");
20
- const node_names_1 = require("../../transformer/node-names");
19
+ const schema_1 = require("../schema");
20
+ const node_names_1 = require("./node-names");
21
21
  const labelledNodeTypes = [
22
22
  schema_1.schema.nodes.figure_element,
23
23
  schema_1.schema.nodes.table_element,
24
24
  schema_1.schema.nodes.equation_element,
25
25
  schema_1.schema.nodes.listing_element,
26
+ schema_1.schema.nodes.box_element,
26
27
  ];
27
28
  const excludedTypes = [schema_1.schema.nodes.graphical_abstract_section];
28
29
  const chooseLabel = (nodeType) => {
29
30
  return node_names_1.nodeNames.get(nodeType);
30
31
  };
31
- const buildTargets = (node) => {
32
+ const buildTargets = (fragment) => {
32
33
  const counters = {};
33
34
  for (const nodeType of labelledNodeTypes) {
34
35
  counters[nodeType.name] = {
@@ -42,7 +43,7 @@ const buildTargets = (node) => {
42
43
  return `${counter.label} ${counter.index}`;
43
44
  };
44
45
  const targets = new Map();
45
- node.descendants((node, pos, parent) => {
46
+ fragment.descendants((node, pos, parent) => {
46
47
  var _a;
47
48
  if (node.type.name in counters) {
48
49
  if (parent && excludedTypes.includes(parent.type)) {
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.fromPrototype = void 0;
15
+ const id_1 = require("./id");
16
+ const fromPrototype = (model) => {
17
+ const { _id } = model, data = __rest(model, ["_id"]);
18
+ const output = Object.assign(Object.assign({}, data), { prototype: _id, _id: (0, id_1.generateID)(model.objectType) });
19
+ return output;
20
+ };
21
+ exports.fromPrototype = fromPrototype;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2020 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.addModelToMap = void 0;
19
+ const id_1 = require("./id");
20
+ const addModelToMap = (modelMap) => (data) => {
21
+ if (!data._id) {
22
+ data._id = (0, id_1.generateID)(data.objectType);
23
+ }
24
+ modelMap.set(data._id, data);
25
+ };
26
+ exports.addModelToMap = addModelToMap;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*!
3
- * © 2024 Atypon Systems LLC
3
+ * © 2019 Atypon Systems LLC
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -15,5 +15,3 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.defaultTitle = void 0;
19
- exports.defaultTitle = 'Untitled Manuscript';
@@ -39,4 +39,5 @@ exports.nodeNames = new Map([
39
39
  [schema_1.schema.nodes.pullquote_element, 'Pull Quote'],
40
40
  [schema_1.schema.nodes.keywords, 'Section'],
41
41
  [schema_1.schema.nodes.toc_section, 'Section'],
42
+ [schema_1.schema.nodes.box_element, 'Box'],
42
43
  ]);
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.isKeyword = exports.isCommentAnnotation = exports.isTable = exports.isManuscript = exports.isFigure = exports.hasObjectType = exports.isManuscriptModel = exports.manuscriptObjects = exports.elementObjects = exports.ExtraObjectTypes = void 0;
19
+ const json_schema_1 = require("@manuscripts/json-schema");
20
+ var ExtraObjectTypes;
21
+ (function (ExtraObjectTypes) {
22
+ ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
23
+ ExtraObjectTypes["GeneralTableFootnote"] = "MPGeneralTableFootnote";
24
+ })(ExtraObjectTypes = exports.ExtraObjectTypes || (exports.ExtraObjectTypes = {}));
25
+ exports.elementObjects = [
26
+ json_schema_1.ObjectTypes.BibliographyElement,
27
+ json_schema_1.ObjectTypes.EquationElement,
28
+ json_schema_1.ObjectTypes.FigureElement,
29
+ json_schema_1.ObjectTypes.FootnotesElement,
30
+ json_schema_1.ObjectTypes.ListElement,
31
+ json_schema_1.ObjectTypes.ListingElement,
32
+ json_schema_1.ObjectTypes.ParagraphElement,
33
+ json_schema_1.ObjectTypes.TableElement,
34
+ json_schema_1.ObjectTypes.TOCElement,
35
+ ];
36
+ exports.manuscriptObjects = [
37
+ json_schema_1.ObjectTypes.Affiliation,
38
+ json_schema_1.ObjectTypes.Citation,
39
+ json_schema_1.ObjectTypes.CommentAnnotation,
40
+ json_schema_1.ObjectTypes.Contributor,
41
+ json_schema_1.ObjectTypes.Footnote,
42
+ json_schema_1.ObjectTypes.Section,
43
+ ].concat(exports.elementObjects);
44
+ const isManuscriptModel = (model) => {
45
+ if (!model.objectType) {
46
+ throw new Error('Model must have objectType');
47
+ }
48
+ return json_schema_1.manuscriptIDTypes.has(model.objectType);
49
+ };
50
+ exports.isManuscriptModel = isManuscriptModel;
51
+ const hasObjectType = (objectType) => (model) => model.objectType === objectType;
52
+ exports.hasObjectType = hasObjectType;
53
+ exports.isFigure = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Figure);
54
+ exports.isManuscript = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
55
+ exports.isTable = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Table);
56
+ exports.isCommentAnnotation = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.CommentAnnotation);
57
+ exports.isKeyword = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.findTitles = exports.findManuscriptById = exports.findManuscriptModelByType = exports.findJournal = exports.findManuscript = exports.parseProjectBundle = void 0;
19
+ const json_schema_1 = require("@manuscripts/json-schema");
20
+ const decode_1 = require("./decode");
21
+ const object_types_1 = require("./object-types");
22
+ const parseProjectBundle = (projectBundle, manuscriptID) => {
23
+ const manuscriptData = manuscriptID
24
+ ? projectBundle.data.filter((doc) => !doc.manuscriptID || doc.manuscriptID === manuscriptID)
25
+ : projectBundle.data;
26
+ const modelMap = new Map();
27
+ for (const component of manuscriptData) {
28
+ modelMap.set(component._id, component);
29
+ }
30
+ const decoder = new decode_1.Decoder(modelMap);
31
+ const doc = decoder.createArticleNode();
32
+ return { doc, modelMap };
33
+ };
34
+ exports.parseProjectBundle = parseProjectBundle;
35
+ const isManuscript = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
36
+ const findManuscript = (modelMap) => {
37
+ for (const model of modelMap.values()) {
38
+ if (isManuscript(model)) {
39
+ return model;
40
+ }
41
+ }
42
+ throw new Error('No manuscript found');
43
+ };
44
+ exports.findManuscript = findManuscript;
45
+ const isJournal = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Journal);
46
+ const findJournal = (modelMap) => {
47
+ for (const model of modelMap.values()) {
48
+ if (isJournal(model)) {
49
+ return model;
50
+ }
51
+ }
52
+ return null;
53
+ };
54
+ exports.findJournal = findJournal;
55
+ const isManuscriptModel = (model) => 'manuscriptID' in model;
56
+ const findManuscriptModelByType = (modelMap, manuscript, objectType) => {
57
+ for (const model of modelMap.values()) {
58
+ if (model.objectType === objectType &&
59
+ isManuscriptModel(model) &&
60
+ manuscript._id === model.manuscriptID) {
61
+ return model;
62
+ }
63
+ }
64
+ };
65
+ exports.findManuscriptModelByType = findManuscriptModelByType;
66
+ const findManuscriptById = (modelMap, manuscriptID) => {
67
+ const manuscript = modelMap.get(manuscriptID);
68
+ if (manuscript && isManuscript(manuscript)) {
69
+ return manuscript;
70
+ }
71
+ throw new Error(`There is no manuscript found for the following _id (${manuscriptID})`);
72
+ };
73
+ exports.findManuscriptById = findManuscriptById;
74
+ const isTitle = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Titles);
75
+ const findTitles = (modelMap) => {
76
+ for (const model of modelMap.values()) {
77
+ if (isTitle(model)) {
78
+ return model;
79
+ }
80
+ }
81
+ const defaultTitle = {
82
+ _id: 'MPTitles:8EB79C14-9F61-483A-902F-A0B8EF5973C1',
83
+ createdAt: 1538472121.690101,
84
+ updatedAt: 1538472121.690101,
85
+ objectType: 'MPTitles',
86
+ title: 'main title',
87
+ subtitle: 'subtitle',
88
+ runningTitle: 'running title',
89
+ manuscriptID: 'MPManuscript:E3830344-E77B-42BA-BD77-3E95489712A0',
90
+ containerID: 'MPProject:1',
91
+ };
92
+ return defaultTitle;
93
+ };
94
+ exports.findTitles = findTitles;
@@ -0,0 +1,23 @@
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.xmlSerializer = void 0;
22
+ const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
23
+ exports.xmlSerializer = { serializeToString: w3c_xmlserializer_1.default };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.timestamp = void 0;
19
+ const timestamp = () => Math.floor(Date.now() / 1000);
20
+ exports.timestamp = timestamp;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2020 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.updateAttachments = exports.updateAttachmentPath = exports.updateIdentifiers = void 0;
19
+ const id_1 = require("./id");
20
+ const updateIdentifiers = async (data) => {
21
+ const idMap = new Map();
22
+ const updateIDs = (model) => {
23
+ const { _id, objectType } = model;
24
+ if (!objectType || !_id || !_id.match(/^MP.+:.+/)) {
25
+ return;
26
+ }
27
+ if (idMap.has(_id)) {
28
+ model._id = idMap.get(_id);
29
+ }
30
+ else {
31
+ model._id = (0, id_1.generateID)(objectType);
32
+ idMap.set(_id, model._id);
33
+ }
34
+ for (const value of Object.values(model)) {
35
+ if (Array.isArray(value)) {
36
+ value.forEach(updateIDs);
37
+ }
38
+ else {
39
+ updateIDs(value);
40
+ }
41
+ }
42
+ };
43
+ const replaceContent = (content) => {
44
+ content = content.replace(/MP\w+:[\w-]+/g, (match) => {
45
+ const value = idMap.get(match);
46
+ return value !== null && value !== void 0 ? value : match;
47
+ });
48
+ content = content.replace(/MP\w+_[\w-]+/g, (match) => {
49
+ const value = idMap.get(match.replace('_', ':'));
50
+ return value ? value.replace(':', '_') : match;
51
+ });
52
+ return content;
53
+ };
54
+ const updateContent = (model) => {
55
+ for (const [key, value] of Object.entries(model)) {
56
+ if (typeof value === 'object') {
57
+ updateContent(value);
58
+ }
59
+ else if (typeof value === 'string') {
60
+ model[key] = replaceContent(value);
61
+ }
62
+ }
63
+ };
64
+ for (const item of data) {
65
+ updateIDs(item);
66
+ }
67
+ for (const item of data) {
68
+ updateContent(item);
69
+ }
70
+ return { data, idMap };
71
+ };
72
+ exports.updateIdentifiers = updateIdentifiers;
73
+ const updateAttachmentPath = (oldPath, idMap) => {
74
+ const matches = oldPath.match(/^Data\/([^.]+)(.*)/);
75
+ if (matches) {
76
+ const [, prefix, suffix] = matches;
77
+ const id = idMap.get(prefix.replace('_', ':'));
78
+ if (id) {
79
+ const newPrefix = id.replace(':', '_');
80
+ return `Data/${newPrefix}${suffix}`;
81
+ }
82
+ }
83
+ };
84
+ exports.updateAttachmentPath = updateAttachmentPath;
85
+ const updateAttachments = async (zip, idMap) => {
86
+ for (const [oldPath, entry] of Object.entries(zip.files)) {
87
+ const newPath = (0, exports.updateAttachmentPath)(oldPath, idMap);
88
+ if (newPath) {
89
+ zip.file(newPath, await entry.async('blob')).remove(oldPath);
90
+ }
91
+ }
92
+ };
93
+ exports.updateAttachments = updateAttachments;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "2.3.38-LEAN-3911.0";
4
+ exports.VERSION = "2.6.0";