@manuscripts/transform 3.0.62 → 3.0.63-LEAN-4531.2

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.
@@ -25,6 +25,7 @@ const debug_1 = __importDefault(require("debug"));
25
25
  const prosemirror_model_1 = require("prosemirror-model");
26
26
  const prosemirror_utils_1 = require("prosemirror-utils");
27
27
  const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
28
+ const credit_roles_1 = require("../../lib/credit-roles");
28
29
  const footnotes_1 = require("../../lib/footnotes");
29
30
  const html_1 = require("../../lib/html");
30
31
  const schema_1 = require("../../schema");
@@ -1132,6 +1133,23 @@ class JATSExporter {
1132
1133
  contrib.appendChild(xref);
1133
1134
  });
1134
1135
  }
1136
+ if (contributor.attrs.CRediTRoles) {
1137
+ contributor.attrs.CRediTRoles.forEach((cr) => {
1138
+ const role = this.createElement('role');
1139
+ const creditUrl = credit_roles_1.CRediTRoleUrls.get(cr.vocabTerm);
1140
+ if (creditUrl) {
1141
+ role.setAttribute('vocab-identifier', 'http://credit.niso.org/');
1142
+ role.setAttribute('vocab', 'CRediT');
1143
+ role.setAttribute('vocab-term', cr.vocabTerm);
1144
+ role.setAttribute('vocab-term-identifier', creditUrl);
1145
+ role.innerHTML = cr.vocabTerm;
1146
+ }
1147
+ if (cr.degreeContribution) {
1148
+ role.setAttribute('degree-contribution', cr.degreeContribution);
1149
+ }
1150
+ contrib.appendChild(role);
1151
+ });
1152
+ }
1135
1153
  contribGroup.appendChild(contrib);
1136
1154
  });
1137
1155
  const affiliationRIDs = [];
@@ -402,7 +402,7 @@ class JATSDOMParser {
402
402
  }
403
403
  }
404
404
  return {
405
- id: element.getAttribute('id'),
405
+ id: element.getAttribute('id') || undefined,
406
406
  role: (0, utils_1.getTrimmedTextContent)(element, 'role'),
407
407
  affiliations,
408
408
  corresp,
@@ -416,6 +416,7 @@ class JATSDOMParser {
416
416
  ObjectType: json_schema_1.ObjectTypes.BibliographicName,
417
417
  },
418
418
  ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
419
+ CRediTRoles: (0, utils_1.getCRediTRoleRole)(element),
419
420
  priority: this.parsePriority(element.getAttribute('priority')),
420
421
  email: (0, utils_1.getTrimmedTextContent)(element, 'email') || '',
421
422
  prefix: (0, utils_1.getTrimmedTextContent)(element, 'prefix'),
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2025 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.CRediTRoleUrls = void 0;
19
+ exports.CRediTRoleUrls = new Map([
20
+ [
21
+ "Conceptualization",
22
+ 'https://credit.niso.org/contributor-roles/conceptualization/',
23
+ ],
24
+ [
25
+ "Data curation",
26
+ 'https://credit.niso.org/contributor-roles/data-curation/',
27
+ ],
28
+ [
29
+ "Formal analysis",
30
+ 'https://credit.niso.org/contributor-roles/formal-analysis/',
31
+ ],
32
+ [
33
+ "Funding acquisition",
34
+ 'https://credit.niso.org/contributor-roles/funding-acquisition/',
35
+ ],
36
+ [
37
+ "Investigation",
38
+ 'https://credit.niso.org/contributor-roles/investigation/',
39
+ ],
40
+ [
41
+ "Methodology",
42
+ 'https://credit.niso.org/contributor-roles/methodology/',
43
+ ],
44
+ [
45
+ "ProjectAdministration",
46
+ 'https://credit.niso.org/contributor-roles/project-administration/',
47
+ ],
48
+ [
49
+ "Resources",
50
+ 'https://credit.niso.org/contributor-roles/resources/',
51
+ ],
52
+ [
53
+ "Software",
54
+ 'https://credit.niso.org/contributor-roles/software/',
55
+ ],
56
+ [
57
+ "Supervision",
58
+ 'https://credit.niso.org/contributor-roles/supervision/',
59
+ ],
60
+ [
61
+ "Validation",
62
+ 'https://credit.niso.org/contributor-roles/validation/',
63
+ ],
64
+ [
65
+ "Visualization",
66
+ 'https://credit.niso.org/contributor-roles/visualization/',
67
+ ],
68
+ [
69
+ "Writing \u2013 original draft",
70
+ 'https://credit.niso.org/contributor-roles/writing-original-draft/',
71
+ ],
72
+ [
73
+ "Writing \u2013 review & editing",
74
+ 'https://credit.niso.org/contributor-roles/writing-review-editing/',
75
+ ],
76
+ ]);
@@ -15,9 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.dateToTimestamp = exports.getHTMLContent = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
18
+ exports.getCRediTRoleRole = exports.dateToTimestamp = exports.getHTMLContent = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
19
19
  const jats_parser_utils_1 = require("../jats/importer/jats-parser-utils");
20
20
  const schema_1 = require("../schema");
21
+ const credit_roles_1 = require("./credit-roles");
21
22
  function* iterateChildren(node, recurse = false) {
22
23
  for (let i = 0; i < node.childCount; i++) {
23
24
  const child = node.child(i);
@@ -102,3 +103,22 @@ const dateToTimestamp = (dateElement) => {
102
103
  return Date.UTC(values[0], values[1] - 1, values[2]) / 1000;
103
104
  };
104
105
  exports.dateToTimestamp = dateToTimestamp;
106
+ function getCRediTRoleRole(elem) {
107
+ const sources = elem.querySelectorAll('role[vocab="CRediT"][vocab-identifier="http://credit.niso.org/"][vocab-term][vocab-term-identifier]');
108
+ const results = [];
109
+ sources.forEach((source) => {
110
+ if (source &&
111
+ credit_roles_1.CRediTRoleUrls.has(source.getAttribute('vocab-term'))) {
112
+ const result = {
113
+ vocabTerm: source.getAttribute('vocab-term'),
114
+ };
115
+ if (source.getAttribute('degree-contribution')) {
116
+ result.degreeContribution =
117
+ source.getAttribute('degree-contribution') || undefined;
118
+ }
119
+ results.push(result);
120
+ }
121
+ });
122
+ return results;
123
+ }
124
+ exports.getCRediTRoleRole = getCRediTRoleRole;
@@ -17,6 +17,7 @@ exports.contributor = {
17
17
  isJointContributor: { default: undefined },
18
18
  ORCIDIdentifier: { default: undefined },
19
19
  priority: { default: undefined },
20
+ CRediTRoles: { default: [] },
20
21
  dataTracked: { default: null },
21
22
  contents: { default: '' },
22
23
  prefix: { default: '' },
@@ -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 = "3.0.62";
4
+ exports.VERSION = "3.0.63-LEAN-4531.2";
@@ -19,6 +19,7 @@ import debug from 'debug';
19
19
  import { DOMParser as ProsemirrorDOMParser, DOMSerializer, } from 'prosemirror-model';
20
20
  import { findChildrenByAttr, findChildrenByType } from 'prosemirror-utils';
21
21
  import serializeToXML from 'w3c-xmlserializer';
22
+ import { CRediTRoleUrls } from '../../lib/credit-roles';
22
23
  import { generateFootnoteLabels } from '../../lib/footnotes';
23
24
  import { nodeFromHTML, textFromHTML } from '../../lib/html';
24
25
  import { isCitationNode, isNodeOfType, schema, } from '../../schema';
@@ -1124,6 +1125,23 @@ export class JATSExporter {
1124
1125
  contrib.appendChild(xref);
1125
1126
  });
1126
1127
  }
1128
+ if (contributor.attrs.CRediTRoles) {
1129
+ contributor.attrs.CRediTRoles.forEach((cr) => {
1130
+ const role = this.createElement('role');
1131
+ const creditUrl = CRediTRoleUrls.get(cr.vocabTerm);
1132
+ if (creditUrl) {
1133
+ role.setAttribute('vocab-identifier', 'http://credit.niso.org/');
1134
+ role.setAttribute('vocab', 'CRediT');
1135
+ role.setAttribute('vocab-term', cr.vocabTerm);
1136
+ role.setAttribute('vocab-term-identifier', creditUrl);
1137
+ role.innerHTML = cr.vocabTerm;
1138
+ }
1139
+ if (cr.degreeContribution) {
1140
+ role.setAttribute('degree-contribution', cr.degreeContribution);
1141
+ }
1142
+ contrib.appendChild(role);
1143
+ });
1144
+ }
1127
1145
  contribGroup.appendChild(contrib);
1128
1146
  });
1129
1147
  const affiliationRIDs = [];
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { buildBibliographicDate, buildBibliographicName, buildContribution, ObjectTypes, } from '@manuscripts/json-schema';
17
17
  import { DOMParser, Fragment } from 'prosemirror-model';
18
- import { dateToTimestamp, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
18
+ import { dateToTimestamp, getCRediTRoleRole, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
19
19
  import { publicationTypeToPM, } from '../../schema';
20
20
  import { DEFAULT_PROFILE_ID } from './jats-comments';
21
21
  export class JATSDOMParser {
@@ -399,7 +399,7 @@ export class JATSDOMParser {
399
399
  }
400
400
  }
401
401
  return {
402
- id: element.getAttribute('id'),
402
+ id: element.getAttribute('id') || undefined,
403
403
  role: getTrimmedTextContent(element, 'role'),
404
404
  affiliations,
405
405
  corresp,
@@ -413,6 +413,7 @@ export class JATSDOMParser {
413
413
  ObjectType: ObjectTypes.BibliographicName,
414
414
  },
415
415
  ORCIDIdentifier: getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]'),
416
+ CRediTRoles: getCRediTRoleRole(element),
416
417
  priority: this.parsePriority(element.getAttribute('priority')),
417
418
  email: getTrimmedTextContent(element, 'email') || '',
418
419
  prefix: getTrimmedTextContent(element, 'prefix'),
@@ -0,0 +1,73 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export const CRediTRoleUrls = new Map([
17
+ [
18
+ "Conceptualization",
19
+ 'https://credit.niso.org/contributor-roles/conceptualization/',
20
+ ],
21
+ [
22
+ "Data curation",
23
+ 'https://credit.niso.org/contributor-roles/data-curation/',
24
+ ],
25
+ [
26
+ "Formal analysis",
27
+ 'https://credit.niso.org/contributor-roles/formal-analysis/',
28
+ ],
29
+ [
30
+ "Funding acquisition",
31
+ 'https://credit.niso.org/contributor-roles/funding-acquisition/',
32
+ ],
33
+ [
34
+ "Investigation",
35
+ 'https://credit.niso.org/contributor-roles/investigation/',
36
+ ],
37
+ [
38
+ "Methodology",
39
+ 'https://credit.niso.org/contributor-roles/methodology/',
40
+ ],
41
+ [
42
+ "ProjectAdministration",
43
+ 'https://credit.niso.org/contributor-roles/project-administration/',
44
+ ],
45
+ [
46
+ "Resources",
47
+ 'https://credit.niso.org/contributor-roles/resources/',
48
+ ],
49
+ [
50
+ "Software",
51
+ 'https://credit.niso.org/contributor-roles/software/',
52
+ ],
53
+ [
54
+ "Supervision",
55
+ 'https://credit.niso.org/contributor-roles/supervision/',
56
+ ],
57
+ [
58
+ "Validation",
59
+ 'https://credit.niso.org/contributor-roles/validation/',
60
+ ],
61
+ [
62
+ "Visualization",
63
+ 'https://credit.niso.org/contributor-roles/visualization/',
64
+ ],
65
+ [
66
+ "Writing \u2013 original draft",
67
+ 'https://credit.niso.org/contributor-roles/writing-original-draft/',
68
+ ],
69
+ [
70
+ "Writing \u2013 review & editing",
71
+ 'https://credit.niso.org/contributor-roles/writing-review-editing/',
72
+ ],
73
+ ]);
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { htmlFromJatsNode } from '../jats/importer/jats-parser-utils';
17
17
  import { isBibliographySectionNode, isGraphicalAbstractSectionNode, } from '../schema';
18
+ import { CRediTRoleUrls } from './credit-roles';
18
19
  export function* iterateChildren(node, recurse = false) {
19
20
  for (let i = 0; i < node.childCount; i++) {
20
21
  const child = node.child(i);
@@ -91,3 +92,21 @@ export const dateToTimestamp = (dateElement) => {
91
92
  }
92
93
  return Date.UTC(values[0], values[1] - 1, values[2]) / 1000;
93
94
  };
95
+ export function getCRediTRoleRole(elem) {
96
+ const sources = elem.querySelectorAll('role[vocab="CRediT"][vocab-identifier="http://credit.niso.org/"][vocab-term][vocab-term-identifier]');
97
+ const results = [];
98
+ sources.forEach((source) => {
99
+ if (source &&
100
+ CRediTRoleUrls.has(source.getAttribute('vocab-term'))) {
101
+ const result = {
102
+ vocabTerm: source.getAttribute('vocab-term'),
103
+ };
104
+ if (source.getAttribute('degree-contribution')) {
105
+ result.degreeContribution =
106
+ source.getAttribute('degree-contribution') || undefined;
107
+ }
108
+ results.push(result);
109
+ }
110
+ });
111
+ return results;
112
+ }
@@ -14,6 +14,7 @@ export const contributor = {
14
14
  isJointContributor: { default: undefined },
15
15
  ORCIDIdentifier: { default: undefined },
16
16
  priority: { default: undefined },
17
+ CRediTRoles: { default: [] },
17
18
  dataTracked: { default: null },
18
19
  contents: { default: '' },
19
20
  prefix: { default: '' },
@@ -1 +1 @@
1
- export const VERSION = "3.0.62";
1
+ export const VERSION = "3.0.63-LEAN-4531.2";
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const enum CreditVocabTerm {
17
+ Conceptualization = "Conceptualization",
18
+ DataCuration = "Data curation",
19
+ FormalAnalysis = "Formal analysis",
20
+ FundingAcquisition = "Funding acquisition",
21
+ Investigation = "Investigation",
22
+ Methodology = "Methodology",
23
+ ProjectAdministration = "ProjectAdministration",
24
+ Resources = "Resources",
25
+ Software = "Software",
26
+ Supervision = "Supervision",
27
+ Validation = "Validation",
28
+ Visualization = "Visualization",
29
+ WritingOriginalDraft = "Writing \u2013 original draft",
30
+ WritingReviewEditing = "Writing \u2013 review & editing"
31
+ }
32
+ export declare const CRediTRoleUrls: Map<CreditVocabTerm, string>;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Node as ProsemirrorNode, ResolvedPos } from 'prosemirror-model';
17
- import { ManuscriptEditorState, ManuscriptNode } from '../schema';
17
+ import { CRediTRole, ManuscriptEditorState, ManuscriptNode } from '../schema';
18
18
  export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean): Iterable<ManuscriptNode>;
19
19
  export declare const findNodePositions: (state: ManuscriptEditorState, predicate: (node: ManuscriptNode) => boolean) => number[];
20
20
  export declare const isInGraphicalAbstractSection: ($pos: ResolvedPos) => boolean;
@@ -28,3 +28,4 @@ export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate:
28
28
  export declare const getTrimmedTextContent: (node: Element | Document | null, selector?: string) => string | undefined;
29
29
  export declare const getHTMLContent: (node: Element, querySelector: string) => string | undefined;
30
30
  export declare const dateToTimestamp: (dateElement: Element) => number | undefined;
31
+ export declare function getCRediTRoleRole(elem: Element): CRediTRole[];
@@ -1,5 +1,6 @@
1
1
  import { BibliographicName } from '@manuscripts/json-schema';
2
2
  import { NodeSpec } from 'prosemirror-model';
3
+ import { CreditVocabTerm } from '../../lib/credit-roles';
3
4
  import { ManuscriptNode } from '../types';
4
5
  export type ContributorCorresp = {
5
6
  correspID: string;
@@ -9,6 +10,10 @@ export type ContributorFootnote = {
9
10
  noteID: string;
10
11
  noteLabel: string;
11
12
  };
13
+ export type CRediTRole = {
14
+ vocabTerm: CreditVocabTerm;
15
+ degreeContribution?: string;
16
+ };
12
17
  interface Attrs {
13
18
  id: string;
14
19
  role: string;
@@ -24,6 +29,7 @@ interface Attrs {
24
29
  isJointContributor: boolean;
25
30
  footnote: ContributorFootnote[];
26
31
  prefix: string;
32
+ CRediTRoles?: CRediTRole[];
27
33
  }
28
34
  export interface ContributorNode extends ManuscriptNode {
29
35
  attrs: Attrs;
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.62";
1
+ export declare const VERSION = "3.0.63-LEAN-4531.2";
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": "3.0.62",
4
+ "version": "3.0.63-LEAN-4531.2",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -30,8 +30,8 @@
30
30
  "version": "yarn build"
31
31
  },
32
32
  "dependencies": {
33
- "@manuscripts/json-schema": "2.2.11",
34
- "@manuscripts/library": "1.3.14",
33
+ "@manuscripts/json-schema": "2.2.12-LEAN-4531",
34
+ "@manuscripts/library": "1.3.15-LEAN-4531.2",
35
35
  "debug": "^4.3.4",
36
36
  "jszip": "^3.10.1",
37
37
  "lodash": "^4.17.21",