@manuscripts/transform 4.0.1 → 4.1.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.
package/dist/cjs/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.migrateFor = exports.getVersion = void 0;
17
+ exports.migrateFor = exports.CreditVocabTerm = exports.getVersion = void 0;
18
18
  __exportStar(require("./errors"), exports);
19
19
  var getVersion_1 = require("./getVersion");
20
20
  Object.defineProperty(exports, "getVersion", { enumerable: true, get: function () { return getVersion_1.getVersion; } });
@@ -23,6 +23,8 @@ __exportStar(require("./jats/types"), exports);
23
23
  __exportStar(require("./lib/footnotes"), exports);
24
24
  __exportStar(require("./lib/utils"), exports);
25
25
  __exportStar(require("./lib/section-categories"), exports);
26
+ var credit_roles_1 = require("./lib/credit-roles");
27
+ Object.defineProperty(exports, "CreditVocabTerm", { enumerable: true, get: function () { return credit_roles_1.CreditVocabTerm; } });
26
28
  __exportStar(require("./lib/citeproc"), exports);
27
29
  __exportStar(require("./schema"), exports);
28
30
  var migrate_1 = require("./schema/migration/migrate");
@@ -1057,10 +1057,10 @@ class JATSExporter {
1057
1057
  contrib.appendChild(xref);
1058
1058
  });
1059
1059
  }
1060
- if (contributor.attrs.CRediTRoles) {
1061
- contributor.attrs.CRediTRoles.forEach((cr) => {
1060
+ if (contributor.attrs.creditRoles) {
1061
+ contributor.attrs.creditRoles.forEach((cr) => {
1062
1062
  const role = this.createElement('role');
1063
- const creditUrl = credit_roles_1.CRediTRoleUrls.get(cr.vocabTerm);
1063
+ const creditUrl = credit_roles_1.CreditRoleUrls.get(cr.vocabTerm);
1064
1064
  if (creditUrl) {
1065
1065
  role.setAttribute('vocab-identifier', 'http://credit.niso.org/');
1066
1066
  role.setAttribute('vocab', 'CRediT');
@@ -414,7 +414,7 @@ class JATSDOMParser {
414
414
  ObjectType: json_schema_1.ObjectTypes.BibliographicName,
415
415
  },
416
416
  ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
417
- CRediTRoles: (0, utils_1.getCRediTRoleRole)(element),
417
+ creditRoles: (0, utils_1.getCreditRole)(element),
418
418
  priority: this.parsePriority(element.getAttribute('priority')),
419
419
  email: (0, utils_1.getTrimmedTextContent)(element, 'email') || '',
420
420
  prefix: (0, utils_1.getTrimmedTextContent)(element, 'prefix'),
@@ -15,62 +15,79 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.CRediTRoleUrls = void 0;
19
- exports.CRediTRoleUrls = new Map([
18
+ exports.CreditRoleUrls = exports.CreditVocabTerm = void 0;
19
+ var CreditVocabTerm;
20
+ (function (CreditVocabTerm) {
21
+ CreditVocabTerm["Conceptualization"] = "Conceptualization";
22
+ CreditVocabTerm["DataCuration"] = "Data curation";
23
+ CreditVocabTerm["FormalAnalysis"] = "Formal analysis";
24
+ CreditVocabTerm["FundingAcquisition"] = "Funding acquisition";
25
+ CreditVocabTerm["Investigation"] = "Investigation";
26
+ CreditVocabTerm["Methodology"] = "Methodology";
27
+ CreditVocabTerm["ProjectAdministration"] = "Project administration";
28
+ CreditVocabTerm["Resources"] = "Resources";
29
+ CreditVocabTerm["Software"] = "Software";
30
+ CreditVocabTerm["Supervision"] = "Supervision";
31
+ CreditVocabTerm["Validation"] = "Validation";
32
+ CreditVocabTerm["Visualization"] = "Visualization";
33
+ CreditVocabTerm["WritingOriginalDraft"] = "Writing \u2013 original draft";
34
+ CreditVocabTerm["WritingReviewEditing"] = "Writing \u2013 review & editing";
35
+ })(CreditVocabTerm = exports.CreditVocabTerm || (exports.CreditVocabTerm = {}));
36
+ exports.CreditRoleUrls = new Map([
20
37
  [
21
- "Conceptualization",
38
+ CreditVocabTerm.Conceptualization,
22
39
  'https://credit.niso.org/contributor-roles/conceptualization/',
23
40
  ],
24
41
  [
25
- "Data curation",
42
+ CreditVocabTerm.DataCuration,
26
43
  'https://credit.niso.org/contributor-roles/data-curation/',
27
44
  ],
28
45
  [
29
- "Formal analysis",
46
+ CreditVocabTerm.FormalAnalysis,
30
47
  'https://credit.niso.org/contributor-roles/formal-analysis/',
31
48
  ],
32
49
  [
33
- "Funding acquisition",
50
+ CreditVocabTerm.FundingAcquisition,
34
51
  'https://credit.niso.org/contributor-roles/funding-acquisition/',
35
52
  ],
36
53
  [
37
- "Investigation",
54
+ CreditVocabTerm.Investigation,
38
55
  'https://credit.niso.org/contributor-roles/investigation/',
39
56
  ],
40
57
  [
41
- "Methodology",
58
+ CreditVocabTerm.Methodology,
42
59
  'https://credit.niso.org/contributor-roles/methodology/',
43
60
  ],
44
61
  [
45
- "ProjectAdministration",
62
+ CreditVocabTerm.ProjectAdministration,
46
63
  'https://credit.niso.org/contributor-roles/project-administration/',
47
64
  ],
48
65
  [
49
- "Resources",
66
+ CreditVocabTerm.Resources,
50
67
  'https://credit.niso.org/contributor-roles/resources/',
51
68
  ],
52
69
  [
53
- "Software",
70
+ CreditVocabTerm.Software,
54
71
  'https://credit.niso.org/contributor-roles/software/',
55
72
  ],
56
73
  [
57
- "Supervision",
74
+ CreditVocabTerm.Supervision,
58
75
  'https://credit.niso.org/contributor-roles/supervision/',
59
76
  ],
60
77
  [
61
- "Validation",
78
+ CreditVocabTerm.Validation,
62
79
  'https://credit.niso.org/contributor-roles/validation/',
63
80
  ],
64
81
  [
65
- "Visualization",
82
+ CreditVocabTerm.Visualization,
66
83
  'https://credit.niso.org/contributor-roles/visualization/',
67
84
  ],
68
85
  [
69
- "Writing \u2013 original draft",
86
+ CreditVocabTerm.WritingOriginalDraft,
70
87
  'https://credit.niso.org/contributor-roles/writing-original-draft/',
71
88
  ],
72
89
  [
73
- "Writing \u2013 review & editing",
90
+ CreditVocabTerm.WritingReviewEditing,
74
91
  'https://credit.niso.org/contributor-roles/writing-review-editing/',
75
92
  ],
76
93
  ]);
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getCRediTRoleRole = exports.dateToTimestamp = exports.getHTMLContent = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
18
+ exports.getCreditRole = 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
21
  const credit_roles_1 = require("./credit-roles");
@@ -102,12 +102,12 @@ const dateToTimestamp = (dateElement) => {
102
102
  return Date.UTC(values[0], values[1] - 1, values[2]) / 1000;
103
103
  };
104
104
  exports.dateToTimestamp = dateToTimestamp;
105
- function getCRediTRoleRole(elem) {
105
+ function getCreditRole(elem) {
106
106
  const sources = elem.querySelectorAll('role[vocab="CRediT"][vocab-identifier="http://credit.niso.org/"][vocab-term][vocab-term-identifier]');
107
107
  const results = [];
108
108
  sources.forEach((source) => {
109
109
  if (source &&
110
- credit_roles_1.CRediTRoleUrls.has(source.getAttribute('vocab-term'))) {
110
+ credit_roles_1.CreditRoleUrls.has(source.getAttribute('vocab-term'))) {
111
111
  const result = {
112
112
  vocabTerm: source.getAttribute('vocab-term'),
113
113
  };
@@ -116,4 +116,4 @@ function getCRediTRoleRole(elem) {
116
116
  });
117
117
  return results;
118
118
  }
119
- exports.getCRediTRoleRole = getCRediTRoleRole;
119
+ exports.getCreditRole = getCreditRole;
@@ -17,7 +17,7 @@ exports.contributor = {
17
17
  isJointContributor: { default: undefined },
18
18
  ORCIDIdentifier: { default: undefined },
19
19
  priority: { default: undefined },
20
- CRediTRoles: { default: [] },
20
+ creditRoles: { default: [] },
21
21
  dataTracked: { default: null },
22
22
  contents: { default: '' },
23
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 = "4.0.1";
4
+ exports.VERSION = "4.1.0";
package/dist/es/index.js CHANGED
@@ -5,6 +5,7 @@ export * from './jats/types';
5
5
  export * from './lib/footnotes';
6
6
  export * from './lib/utils';
7
7
  export * from './lib/section-categories';
8
+ export { CreditVocabTerm } from './lib/credit-roles';
8
9
  export * from './lib/citeproc';
9
10
  export * from './schema';
10
11
  export { migrateFor } from './schema/migration/migrate';
@@ -18,7 +18,7 @@ import { DOMParser as ProsemirrorDOMParser, DOMSerializer, } from 'prosemirror-m
18
18
  import { findChildrenByAttr, findChildrenByType } from 'prosemirror-utils';
19
19
  import serializeToXML from 'w3c-xmlserializer';
20
20
  import { buildCiteprocCitation } from '../../lib/citeproc';
21
- import { CRediTRoleUrls } from '../../lib/credit-roles';
21
+ import { CreditRoleUrls } from '../../lib/credit-roles';
22
22
  import { generateFootnoteLabels } from '../../lib/footnotes';
23
23
  import { nodeFromHTML } from '../../lib/html';
24
24
  import { isBibliographyItemNode, isCitationNode, isNodeOfType, schema, } from '../../schema';
@@ -1027,10 +1027,10 @@ export class JATSExporter {
1027
1027
  contrib.appendChild(xref);
1028
1028
  });
1029
1029
  }
1030
- if (contributor.attrs.CRediTRoles) {
1031
- contributor.attrs.CRediTRoles.forEach((cr) => {
1030
+ if (contributor.attrs.creditRoles) {
1031
+ contributor.attrs.creditRoles.forEach((cr) => {
1032
1032
  const role = this.createElement('role');
1033
- const creditUrl = CRediTRoleUrls.get(cr.vocabTerm);
1033
+ const creditUrl = CreditRoleUrls.get(cr.vocabTerm);
1034
1034
  if (creditUrl) {
1035
1035
  role.setAttribute('vocab-identifier', 'http://credit.niso.org/');
1036
1036
  role.setAttribute('vocab', 'CRediT');
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { buildContribution, ObjectTypes } from '@manuscripts/json-schema';
17
17
  import { DOMParser, Fragment } from 'prosemirror-model';
18
- import { dateToTimestamp, getCRediTRoleRole, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
18
+ import { dateToTimestamp, getCreditRole, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
19
19
  import { DEFAULT_PROFILE_ID } from './jats-comments';
20
20
  export class JATSDOMParser {
21
21
  constructor(sectionCategories, schema) {
@@ -411,7 +411,7 @@ export class JATSDOMParser {
411
411
  ObjectType: ObjectTypes.BibliographicName,
412
412
  },
413
413
  ORCIDIdentifier: getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]'),
414
- CRediTRoles: getCRediTRoleRole(element),
414
+ creditRoles: getCreditRole(element),
415
415
  priority: this.parsePriority(element.getAttribute('priority')),
416
416
  email: getTrimmedTextContent(element, 'email') || '',
417
417
  prefix: getTrimmedTextContent(element, 'prefix'),
@@ -13,61 +13,78 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export const CRediTRoleUrls = new Map([
16
+ export var CreditVocabTerm;
17
+ (function (CreditVocabTerm) {
18
+ CreditVocabTerm["Conceptualization"] = "Conceptualization";
19
+ CreditVocabTerm["DataCuration"] = "Data curation";
20
+ CreditVocabTerm["FormalAnalysis"] = "Formal analysis";
21
+ CreditVocabTerm["FundingAcquisition"] = "Funding acquisition";
22
+ CreditVocabTerm["Investigation"] = "Investigation";
23
+ CreditVocabTerm["Methodology"] = "Methodology";
24
+ CreditVocabTerm["ProjectAdministration"] = "Project administration";
25
+ CreditVocabTerm["Resources"] = "Resources";
26
+ CreditVocabTerm["Software"] = "Software";
27
+ CreditVocabTerm["Supervision"] = "Supervision";
28
+ CreditVocabTerm["Validation"] = "Validation";
29
+ CreditVocabTerm["Visualization"] = "Visualization";
30
+ CreditVocabTerm["WritingOriginalDraft"] = "Writing \u2013 original draft";
31
+ CreditVocabTerm["WritingReviewEditing"] = "Writing \u2013 review & editing";
32
+ })(CreditVocabTerm || (CreditVocabTerm = {}));
33
+ export const CreditRoleUrls = new Map([
17
34
  [
18
- "Conceptualization",
35
+ CreditVocabTerm.Conceptualization,
19
36
  'https://credit.niso.org/contributor-roles/conceptualization/',
20
37
  ],
21
38
  [
22
- "Data curation",
39
+ CreditVocabTerm.DataCuration,
23
40
  'https://credit.niso.org/contributor-roles/data-curation/',
24
41
  ],
25
42
  [
26
- "Formal analysis",
43
+ CreditVocabTerm.FormalAnalysis,
27
44
  'https://credit.niso.org/contributor-roles/formal-analysis/',
28
45
  ],
29
46
  [
30
- "Funding acquisition",
47
+ CreditVocabTerm.FundingAcquisition,
31
48
  'https://credit.niso.org/contributor-roles/funding-acquisition/',
32
49
  ],
33
50
  [
34
- "Investigation",
51
+ CreditVocabTerm.Investigation,
35
52
  'https://credit.niso.org/contributor-roles/investigation/',
36
53
  ],
37
54
  [
38
- "Methodology",
55
+ CreditVocabTerm.Methodology,
39
56
  'https://credit.niso.org/contributor-roles/methodology/',
40
57
  ],
41
58
  [
42
- "ProjectAdministration",
59
+ CreditVocabTerm.ProjectAdministration,
43
60
  'https://credit.niso.org/contributor-roles/project-administration/',
44
61
  ],
45
62
  [
46
- "Resources",
63
+ CreditVocabTerm.Resources,
47
64
  'https://credit.niso.org/contributor-roles/resources/',
48
65
  ],
49
66
  [
50
- "Software",
67
+ CreditVocabTerm.Software,
51
68
  'https://credit.niso.org/contributor-roles/software/',
52
69
  ],
53
70
  [
54
- "Supervision",
71
+ CreditVocabTerm.Supervision,
55
72
  'https://credit.niso.org/contributor-roles/supervision/',
56
73
  ],
57
74
  [
58
- "Validation",
75
+ CreditVocabTerm.Validation,
59
76
  'https://credit.niso.org/contributor-roles/validation/',
60
77
  ],
61
78
  [
62
- "Visualization",
79
+ CreditVocabTerm.Visualization,
63
80
  'https://credit.niso.org/contributor-roles/visualization/',
64
81
  ],
65
82
  [
66
- "Writing \u2013 original draft",
83
+ CreditVocabTerm.WritingOriginalDraft,
67
84
  'https://credit.niso.org/contributor-roles/writing-original-draft/',
68
85
  ],
69
86
  [
70
- "Writing \u2013 review & editing",
87
+ CreditVocabTerm.WritingReviewEditing,
71
88
  'https://credit.niso.org/contributor-roles/writing-review-editing/',
72
89
  ],
73
90
  ]);
@@ -15,7 +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
+ import { CreditRoleUrls } from './credit-roles';
19
19
  export function* iterateChildren(node, recurse = false) {
20
20
  for (let i = 0; i < node.childCount; i++) {
21
21
  const child = node.child(i);
@@ -91,12 +91,12 @@ export const dateToTimestamp = (dateElement) => {
91
91
  }
92
92
  return Date.UTC(values[0], values[1] - 1, values[2]) / 1000;
93
93
  };
94
- export function getCRediTRoleRole(elem) {
94
+ export function getCreditRole(elem) {
95
95
  const sources = elem.querySelectorAll('role[vocab="CRediT"][vocab-identifier="http://credit.niso.org/"][vocab-term][vocab-term-identifier]');
96
96
  const results = [];
97
97
  sources.forEach((source) => {
98
98
  if (source &&
99
- CRediTRoleUrls.has(source.getAttribute('vocab-term'))) {
99
+ CreditRoleUrls.has(source.getAttribute('vocab-term'))) {
100
100
  const result = {
101
101
  vocabTerm: source.getAttribute('vocab-term'),
102
102
  };
@@ -14,7 +14,7 @@ export const contributor = {
14
14
  isJointContributor: { default: undefined },
15
15
  ORCIDIdentifier: { default: undefined },
16
16
  priority: { default: undefined },
17
- CRediTRoles: { default: [] },
17
+ creditRoles: { default: [] },
18
18
  dataTracked: { default: null },
19
19
  contents: { default: '' },
20
20
  prefix: { default: '' },
@@ -1 +1 @@
1
- export const VERSION = "4.0.1";
1
+ export const VERSION = "4.1.0";
@@ -5,6 +5,7 @@ export * from './jats/types';
5
5
  export * from './lib/footnotes';
6
6
  export * from './lib/utils';
7
7
  export * from './lib/section-categories';
8
+ export { CreditVocabTerm } from './lib/credit-roles';
8
9
  export * from './lib/citeproc';
9
10
  export * from './schema';
10
11
  export { migrateFor } from './schema/migration/migrate';
@@ -13,14 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const enum CreditVocabTerm {
16
+ export declare enum CreditVocabTerm {
17
17
  Conceptualization = "Conceptualization",
18
18
  DataCuration = "Data curation",
19
19
  FormalAnalysis = "Formal analysis",
20
20
  FundingAcquisition = "Funding acquisition",
21
21
  Investigation = "Investigation",
22
22
  Methodology = "Methodology",
23
- ProjectAdministration = "ProjectAdministration",
23
+ ProjectAdministration = "Project administration",
24
24
  Resources = "Resources",
25
25
  Software = "Software",
26
26
  Supervision = "Supervision",
@@ -29,4 +29,4 @@ export declare const enum CreditVocabTerm {
29
29
  WritingOriginalDraft = "Writing \u2013 original draft",
30
30
  WritingReviewEditing = "Writing \u2013 review & editing"
31
31
  }
32
- export declare const CRediTRoleUrls: Map<CreditVocabTerm, string>;
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 { CRediTRole, 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,4 +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[];
31
+ export declare function getCreditRole(elem: Element): CreditRole[];
@@ -1,6 +1,6 @@
1
1
  import { NodeSpec } from 'prosemirror-model';
2
2
  import { ManuscriptNode } from '../types';
3
- interface Email {
3
+ export interface Email {
4
4
  href: string;
5
5
  text: string;
6
6
  }
@@ -10,9 +10,8 @@ export type ContributorFootnote = {
10
10
  noteID: string;
11
11
  noteLabel: string;
12
12
  };
13
- export type CRediTRole = {
13
+ export type CreditRole = {
14
14
  vocabTerm: CreditVocabTerm;
15
- degreeContribution?: string;
16
15
  };
17
16
  interface Attrs {
18
17
  id: string;
@@ -29,7 +28,7 @@ interface Attrs {
29
28
  isJointContributor: boolean;
30
29
  footnote: ContributorFootnote[];
31
30
  prefix: string;
32
- CRediTRoles?: CRediTRole[];
31
+ creditRoles?: CreditRole[];
33
32
  }
34
33
  export interface ContributorNode extends ManuscriptNode {
35
34
  attrs: Attrs;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.1";
1
+ export declare const VERSION = "4.1.0";
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": "4.0.1",
4
+ "version": "4.1.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",