@natlibfi/marc-record-merge 6.0.0-beta.1 → 6.0.0-beta.5

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 (193) hide show
  1. package/.github/CODEOWNERS +9 -0
  2. package/.github/dependabot.yml +41 -0
  3. package/.github/workflows/melinda-node-tests.yml +60 -0
  4. package/LICENSE +21 -0
  5. package/README.md +92 -2
  6. package/dist/index.js +10 -41
  7. package/dist/index.js.map +1 -1
  8. package/dist/reducers/copy.js +280 -73
  9. package/dist/reducers/copy.js.map +1 -1
  10. package/dist/reducers/copy.spec.js +51 -62
  11. package/dist/reducers/copy.spec.js.map +1 -1
  12. package/dist/reducers/index.js +15 -20
  13. package/dist/reducers/index.js.map +1 -1
  14. package/dist/reducers/select.js +28 -34
  15. package/dist/reducers/select.js.map +1 -1
  16. package/dist/reducers/select.spec.js +49 -83
  17. package/dist/reducers/select.spec.js.map +1 -1
  18. package/package.json +33 -32
  19. package/src/index.js +2 -34
  20. package/src/reducers/copy.js +274 -79
  21. package/src/reducers/copy.spec.js +43 -47
  22. package/src/reducers/index.js +3 -30
  23. package/src/reducers/select.js +22 -32
  24. package/src/reducers/select.spec.js +37 -56
  25. package/test-fixtures/reducers/copy/{01/base.json → basic copy/01/base.json } +1 -1
  26. package/test-fixtures/reducers/copy/{01 → basic copy/01}/merged.json +0 -0
  27. package/test-fixtures/reducers/copy/basic copy/01/metadata.json +4 -0
  28. package/test-fixtures/reducers/copy/{01 → basic copy/01}/source.json +0 -0
  29. package/test-fixtures/reducers/copy/{02/source.json → basic copy/02/base.json} +0 -0
  30. package/test-fixtures/reducers/copy/{02 → basic copy/02}/merged.json +0 -0
  31. package/test-fixtures/reducers/copy/basic copy/02/metadata.json +4 -0
  32. package/test-fixtures/reducers/copy/{02/base.json → basic copy/02/source.json } +1 -1
  33. package/test-fixtures/reducers/copy/{03/base.json → basic copy/03/base.json } +1 -1
  34. package/test-fixtures/reducers/copy/{03 → basic copy/03}/merged.json +0 -0
  35. package/test-fixtures/reducers/copy/basic copy/03/metadata.json +4 -0
  36. package/test-fixtures/reducers/copy/{03 → basic copy/03}/source.json +0 -0
  37. package/test-fixtures/reducers/copy/{05/base.json → basic copy/04/base.json } +1 -1
  38. package/test-fixtures/reducers/copy/{04/merged.json → basic copy/04/merged.json } +1 -1
  39. package/test-fixtures/reducers/copy/basic copy/04/metadata.json +4 -0
  40. package/test-fixtures/reducers/copy/{04/source.json → basic copy/04/source.json } +1 -1
  41. package/test-fixtures/reducers/copy/{04/base.json → basic copy/05/base.json } +1 -1
  42. package/test-fixtures/reducers/copy/basic copy/05/merged.json +77 -0
  43. package/test-fixtures/reducers/copy/basic copy/05/metadata.json +4 -0
  44. package/test-fixtures/reducers/copy/basic copy/05/source.json +62 -0
  45. package/test-fixtures/reducers/copy/basic copy/06/base.json +24 -0
  46. package/test-fixtures/reducers/copy/basic copy/06/merged.json +39 -0
  47. package/test-fixtures/reducers/copy/basic copy/06/metadata.json +4 -0
  48. package/test-fixtures/reducers/copy/basic copy/06/source.json +24 -0
  49. package/test-fixtures/reducers/copy/basic copy/07/base.json +39 -0
  50. package/test-fixtures/reducers/copy/basic copy/07/merged.json +39 -0
  51. package/test-fixtures/reducers/copy/basic copy/07/metadata.json +5 -0
  52. package/test-fixtures/reducers/copy/basic copy/07/source.json +24 -0
  53. package/test-fixtures/reducers/copy/basic copy/08/base.json +28 -0
  54. package/test-fixtures/reducers/copy/basic copy/08/merged.json +28 -0
  55. package/test-fixtures/reducers/copy/basic copy/08/metadata.json +4 -0
  56. package/test-fixtures/reducers/copy/basic copy/08/source.json +24 -0
  57. package/test-fixtures/reducers/copy/compareTagsOnly/01/base.json +24 -0
  58. package/test-fixtures/reducers/copy/compareTagsOnly/01/merged.json +24 -0
  59. package/test-fixtures/reducers/copy/compareTagsOnly/01/metadata.json +5 -0
  60. package/test-fixtures/reducers/copy/compareTagsOnly/01/source.json +24 -0
  61. package/test-fixtures/reducers/copy/compareTagsOnly/02/base.json +24 -0
  62. package/test-fixtures/reducers/copy/compareTagsOnly/02/merged.json +100 -0
  63. package/test-fixtures/reducers/copy/compareTagsOnly/02/metadata.json +5 -0
  64. package/test-fixtures/reducers/copy/compareTagsOnly/02/source.json +100 -0
  65. package/test-fixtures/reducers/copy/compareWithoutIndicators/01/base.json +24 -0
  66. package/test-fixtures/reducers/copy/compareWithoutIndicators/01/merged.json +24 -0
  67. package/test-fixtures/reducers/copy/compareWithoutIndicators/01/metadata.json +5 -0
  68. package/test-fixtures/reducers/copy/compareWithoutIndicators/01/source.json +24 -0
  69. package/test-fixtures/reducers/copy/compareWithoutIndicators/02/base.json +24 -0
  70. package/test-fixtures/reducers/copy/compareWithoutIndicators/02/merged.json +39 -0
  71. package/test-fixtures/reducers/copy/compareWithoutIndicators/02/metadata.json +5 -0
  72. package/test-fixtures/reducers/copy/compareWithoutIndicators/02/source.json +24 -0
  73. package/test-fixtures/reducers/copy/copyUnless/01/base.json +9 -0
  74. package/test-fixtures/reducers/copy/copyUnless/01/merged.json +24 -0
  75. package/test-fixtures/reducers/copy/copyUnless/01/metadata.json +5 -0
  76. package/test-fixtures/reducers/copy/copyUnless/01/source.json +47 -0
  77. package/test-fixtures/reducers/copy/dropSubfields/01/base.json +35 -0
  78. package/test-fixtures/reducers/copy/dropSubfields/01/merged.json +54 -0
  79. package/test-fixtures/reducers/copy/dropSubfields/01/metadata.json +5 -0
  80. package/test-fixtures/reducers/copy/dropSubfields/01/source.json +43 -0
  81. package/test-fixtures/reducers/copy/dropSubfields/02/base.json +43 -0
  82. package/test-fixtures/reducers/copy/dropSubfields/02/merged.json +58 -0
  83. package/test-fixtures/reducers/copy/dropSubfields/02/metadata.json +5 -0
  84. package/test-fixtures/reducers/copy/dropSubfields/02/source.json +32 -0
  85. package/test-fixtures/reducers/copy/dropSubfields/03/base.json +43 -0
  86. package/test-fixtures/reducers/copy/dropSubfields/03/merged.json +58 -0
  87. package/test-fixtures/reducers/copy/dropSubfields/03/metadata.json +5 -0
  88. package/test-fixtures/reducers/copy/dropSubfields/03/source.json +32 -0
  89. package/test-fixtures/reducers/copy/dropSubfields/04/base.json +43 -0
  90. package/test-fixtures/reducers/copy/dropSubfields/04/merged.json +43 -0
  91. package/test-fixtures/reducers/copy/dropSubfields/04/metadata.json +5 -0
  92. package/test-fixtures/reducers/copy/dropSubfields/04/source.json +32 -0
  93. package/test-fixtures/reducers/copy/excludeSubfields/01/base.json +39 -0
  94. package/test-fixtures/reducers/copy/excludeSubfields/01/merged.json +39 -0
  95. package/test-fixtures/reducers/copy/excludeSubfields/01/metadata.json +8 -0
  96. package/test-fixtures/reducers/copy/{05 → excludeSubfields/01}/source.json +1 -1
  97. package/test-fixtures/reducers/copy/excludeSubfields/02/base.json +39 -0
  98. package/test-fixtures/reducers/copy/{05 → excludeSubfields/02}/merged.json +5 -5
  99. package/test-fixtures/reducers/copy/excludeSubfields/02/metadata.json +5 -0
  100. package/test-fixtures/reducers/copy/excludeSubfields/02/source.json +43 -0
  101. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/base.json +24 -0
  102. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/merged.json +39 -0
  103. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/metadata.json +5 -0
  104. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/source.json +24 -0
  105. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/base.json +24 -0
  106. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/merged.json +24 -0
  107. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/metadata.json +5 -0
  108. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/source.json +24 -0
  109. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/base.json +28 -0
  110. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/merged.json +43 -0
  111. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/metadata.json +5 -0
  112. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/source.json +24 -0
  113. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/base.json +28 -0
  114. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/merged.json +28 -0
  115. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/metadata.json +5 -0
  116. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/source.json +24 -0
  117. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/base.json +20 -0
  118. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/merged.json +35 -0
  119. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/metadata.json +5 -0
  120. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/source.json +24 -0
  121. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/base.json +20 -0
  122. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/merged.json +35 -0
  123. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/metadata.json +5 -0
  124. package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/source.json +24 -0
  125. package/test-fixtures/reducers/metadata.json +4 -0
  126. package/test-fixtures/reducers/select/01/metadata.json +5 -0
  127. package/test-fixtures/reducers/select/02/metadata.json +4 -0
  128. package/test-fixtures/reducers/select/03/metadata.json +4 -0
  129. package/test-fixtures/reducers/select/04/metadata.json +5 -0
  130. package/test-fixtures/reducers/select/05/metadata.json +4 -0
  131. package/test-fixtures/reducers/select/06/base.json +4 -0
  132. package/test-fixtures/reducers/select/06/merged.json +4 -0
  133. package/test-fixtures/reducers/select/06/metadata.json +4 -0
  134. package/test-fixtures/reducers/select/06/source.json +4 -0
  135. package/test-fixtures/reducers/select/07/metadata.json +5 -0
  136. package/test-fixtures/reducers/select/08/metadata.json +4 -0
  137. package/test-fixtures/reducers/select/09/metadata.json +4 -0
  138. package/test-fixtures/reducers/select/10/metadata.json +5 -0
  139. package/test-fixtures/reducers/select/11/metadata.json +4 -0
  140. package/test-fixtures/reducers/select/12/metadata.json +5 -0
  141. package/test-fixtures/reducers/select/13/metadata.json +4 -0
  142. package/test-fixtures/reducers/select/14/base.json +24 -0
  143. package/test-fixtures/reducers/select/14/merged.json +24 -0
  144. package/test-fixtures/reducers/select/14/metadata.json +4 -0
  145. package/test-fixtures/reducers/select/14/source.json +24 -0
  146. package/.drone.yml +0 -92
  147. package/.nyc_output/7ecda3cd-9f84-4416-a466-fa1e5889c6a3.json +0 -1
  148. package/.nyc_output/processinfo/7ecda3cd-9f84-4416-a466-fa1e5889c6a3.json +0 -1
  149. package/.nyc_output/processinfo/index.json +0 -1
  150. package/LICENSE.txt +0 -165
  151. package/coverage/base.css +0 -224
  152. package/coverage/block-navigation.js +0 -79
  153. package/coverage/copy.js.html +0 -344
  154. package/coverage/favicon.png +0 -0
  155. package/coverage/index.html +0 -126
  156. package/coverage/lcov-report/base.css +0 -224
  157. package/coverage/lcov-report/block-navigation.js +0 -79
  158. package/coverage/lcov-report/copy.js.html +0 -344
  159. package/coverage/lcov-report/favicon.png +0 -0
  160. package/coverage/lcov-report/index.html +0 -126
  161. package/coverage/lcov-report/prettify.css +0 -1
  162. package/coverage/lcov-report/prettify.js +0 -2
  163. package/coverage/lcov-report/select.js.html +0 -431
  164. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  165. package/coverage/lcov-report/sorter.js +0 -170
  166. package/coverage/lcov.info +0 -195
  167. package/coverage/prettify.css +0 -1
  168. package/coverage/prettify.js +0 -2
  169. package/coverage/select.js.html +0 -431
  170. package/coverage/sort-arrow-sprite.png +0 -0
  171. package/coverage/sorter.js +0 -170
  172. package/test-fixtures/reducers/copy/01/pattern.txt +0 -1
  173. package/test-fixtures/reducers/copy/02/pattern.txt +0 -1
  174. package/test-fixtures/reducers/copy/03/pattern.txt +0 -1
  175. package/test-fixtures/reducers/copy/04/pattern.txt +0 -1
  176. package/test-fixtures/reducers/copy/05/pattern.txt +0 -1
  177. package/test-fixtures/reducers/select/01/expected-error.txt +0 -1
  178. package/test-fixtures/reducers/select/01/pattern.txt +0 -1
  179. package/test-fixtures/reducers/select/02/pattern.txt +0 -1
  180. package/test-fixtures/reducers/select/03/pattern.txt +0 -1
  181. package/test-fixtures/reducers/select/04/pattern.txt +0 -1
  182. package/test-fixtures/reducers/select/05/pattern.txt +0 -1
  183. package/test-fixtures/reducers/select/06/pattern.txt +0 -1
  184. package/test-fixtures/reducers/select/07/equalityFunction.txt +0 -1
  185. package/test-fixtures/reducers/select/07/pattern.txt +0 -1
  186. package/test-fixtures/reducers/select/08/pattern.txt +0 -1
  187. package/test-fixtures/reducers/select/09/pattern.txt +0 -1
  188. package/test-fixtures/reducers/select/10/equalityFunction.txt +0 -1
  189. package/test-fixtures/reducers/select/10/pattern.txt +0 -1
  190. package/test-fixtures/reducers/select/11/pattern.txt +0 -1
  191. package/test-fixtures/reducers/select/12/equalityFunction.txt +0 -1
  192. package/test-fixtures/reducers/select/12/pattern.txt +0 -1
  193. package/test-fixtures/reducers/select/13/pattern.txt +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/reducers/index.js"],"names":[],"mappings":";;;;;;AA4BA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Merge MARC records\n*\n* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of marc-record-merge-js\n\n* marc-record-merge-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* marc-record-merge-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nexport * from './copy';\nexport * from './select';\n\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["copy","select","strictEquality","subsetEquality"],"sources":["../../src/reducers/index.js"],"sourcesContent":["import copy from './copy';\nimport select, {strictEquality, subsetEquality} from './select';\n\nexport default {copy, select, strictEquality, subsetEquality};\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;eAEe;EAACA,IAAI,EAAJA,aAAD;EAAOC,MAAM,EAANA,eAAP;EAAeC,cAAc,EAAdA,sBAAf;EAA+BC,cAAc,EAAdA;AAA/B,C"}
@@ -3,57 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
  exports.strictEquality = strictEquality;
7
8
  exports.subsetEquality = subsetEquality;
8
- exports.default = void 0;
9
9
 
10
10
  var _normalizeDiacritics = require("normalize-diacritics");
11
11
 
12
- /**
13
- *
14
- * @licstart The following is the entire license notice for the JavaScript code in this file.
15
- *
16
- * Merge MARC records
17
- *
18
- * Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
19
- *
20
- * This file is part of marc-record-merge-js
21
-
22
- * marc-record-merge-js program is free software: you can redistribute it and/or modify
23
- * it under the terms of the GNU Lesser General Public License as
24
- * published by the Free Software Foundation, either version 3 of the
25
- * License, or (at your option) any later version.
26
- *
27
- * marc-record-merge-js is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- * GNU Lesser General Public License for more details.
31
- *
32
- * You should have received a copy of the GNU Lesser General Public License
33
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
- *
35
- * @licend The above is the entire license notice
36
- * for the JavaScript code in this file.
37
- *
38
- */
12
+ var _debug = _interopRequireDefault(require("debug"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
39
16
  function strictEquality(subfieldA, subfieldB) {
40
17
  return subfieldA.code === subfieldB.code && subfieldA.value === subfieldB.value;
41
18
  }
42
19
 
43
20
  function subsetEquality(subfieldA, subfieldB) {
44
21
  return subfieldA.code === subfieldB.code && (subfieldA.value.indexOf(subfieldB.value) !== -1 || subfieldB.value.indexOf(subfieldA.value) !== -1);
45
- }
22
+ } // EqualityFunction can be either strictEquality or subsetEquality
23
+
46
24
 
47
25
  var _default = ({
48
- pattern,
26
+ tagPattern,
49
27
  equalityFunction = strictEquality
50
28
  }) => (base, source) => {
51
- const baseFields = base.get(pattern);
52
- const sourceFields = source.get(pattern);
29
+ const debug = (0, _debug.default)('@natlibfi/marc-record-merge:select');
30
+ const baseFields = base.get(tagPattern);
31
+ const sourceFields = source.get(tagPattern);
32
+ const fieldTag = sourceFields.map(field => field.tag);
33
+ debug(`Comparing field ${fieldTag}`);
53
34
  checkFieldType(baseFields);
54
35
  checkFieldType(sourceFields);
55
36
 
56
37
  if (baseFields.length > 1 || sourceFields.length > 1) {
38
+ debug(`Multiple fields in base or source`);
39
+ debug(`No changes to base`);
57
40
  return base;
58
41
  }
59
42
 
@@ -61,6 +44,8 @@ var _default = ({
61
44
  const [sourceField] = sourceFields;
62
45
 
63
46
  if (baseField.tag === sourceField.tag === false) {
47
+ debug(`Base tag ${baseField.tag} is not equal to source tag ${sourceField.tag}`);
48
+ debug(`No changes to base`);
64
49
  return base;
65
50
  }
66
51
 
@@ -79,15 +64,22 @@ var _default = ({
79
64
  }) => ({
80
65
  code,
81
66
  value: normalizeSubfieldValue(value)
82
- }));
67
+ })); // Returns the base subfields for which a matching source subfield is found
68
+
83
69
  const equalSubfieldsBase = baseSubsNormalized.filter(baseSubfield => sourceSubsNormalized.some(sourceSubfield => equalityFunction(baseSubfield, sourceSubfield)));
70
+ debug(`equalSubfieldsBase: ${JSON.stringify(equalSubfieldsBase, undefined, 2)}`); // Returns the source subfields for which a matching base subfield is found
71
+
84
72
  const equalSubfieldsSource = sourceSubsNormalized.filter(sourceSubfield => baseSubsNormalized.some(baseSubfield => equalityFunction(sourceSubfield, baseSubfield)));
73
+ debug(`equalSubfieldsSource: ${JSON.stringify(equalSubfieldsSource, undefined, 2)}`);
85
74
 
86
75
  if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length < baseSubs.length) {
76
+ debug(`Base and source subfields are not equal`);
77
+ debug(`No changes to base`);
87
78
  return base;
88
79
  }
89
80
 
90
81
  if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length === equalSubfieldsSource.length) {
82
+ debug(`Checking subfield equality`);
91
83
  const totalSubfieldLengthBase = baseSubsNormalized.map(({
92
84
  value
93
85
  }) => value.length).reduce((acc, value) => acc + value);
@@ -104,12 +96,14 @@ var _default = ({
104
96
  return replaceBasefieldWithSourcefield(base);
105
97
  }
106
98
 
99
+ debug(`No changes to base`);
107
100
  return base;
108
101
 
109
102
  function replaceBasefieldWithSourcefield(base) {
110
103
  const index = base.fields.findIndex(field => field === baseField);
111
104
  base.fields.splice(index, 1, sourceField); // eslint-disable-line functional/immutable-data
112
105
 
106
+ debug(`Source field is longer, replacing base with source`);
113
107
  return base;
114
108
  }
115
109
 
@@ -127,7 +121,7 @@ var _default = ({
127
121
 
128
122
  function normalizeSubfieldValue(value) {
129
123
  // Regexp options: g: global search, u: unicode
130
- const punctuation = /[.,\-/#!$%^&*;:{}=_`~()[\]]/gu;
124
+ const punctuation = /[.,\-/#!?$%^&*;:{}=_`~()[\]]/gu;
131
125
  return (0, _normalizeDiacritics.normalizeSync)(value).toLowerCase().replace(punctuation, '', 'u').replace(/\s+/gu, ' ').trim();
132
126
  }
133
127
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/reducers/select.js"],"names":["strictEquality","subfieldA","subfieldB","code","value","subsetEquality","indexOf","pattern","equalityFunction","base","source","baseFields","get","sourceFields","checkFieldType","length","baseField","sourceField","tag","baseSubs","subfields","sourceSubs","baseSubsNormalized","map","normalizeSubfieldValue","sourceSubsNormalized","equalSubfieldsBase","filter","baseSubfield","some","sourceSubfield","equalSubfieldsSource","totalSubfieldLengthBase","reduce","acc","totalSubfieldLengthSource","replaceBasefieldWithSourcefield","index","fields","findIndex","field","splice","checkedFields","Error","punctuation","toLowerCase","replace","trim"],"mappings":";;;;;;;;;AA2BA;;AA3BA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,SAASA,cAAT,CAAwBC,SAAxB,EAAmCC,SAAnC,EAA8C;AACnD,SAAOD,SAAS,CAACE,IAAV,KAAmBD,SAAS,CAACC,IAA7B,IACPF,SAAS,CAACG,KAAV,KAAoBF,SAAS,CAACE,KAD9B;AAED;;AAEM,SAASC,cAAT,CAAwBJ,SAAxB,EAAmCC,SAAnC,EAA8C;AACnD,SAAOD,SAAS,CAACE,IAAV,KAAmBD,SAAS,CAACC,IAA7B,KACNF,SAAS,CAACG,KAAV,CAAgBE,OAAhB,CAAwBJ,SAAS,CAACE,KAAlC,MAA6C,CAAC,CAA9C,IAAmDF,SAAS,CAACE,KAAV,CAAgBE,OAAhB,CAAwBL,SAAS,CAACG,KAAlC,MAA6C,CAAC,CAD3F,CAAP;AAED;;eAEc,CAAC;AAACG,EAAAA,OAAD;AAAUC,EAAAA,gBAAgB,GAAGR;AAA7B,CAAD,KAAkD,CAACS,IAAD,EAAOC,MAAP,KAAkB;AACjF,QAAMC,UAAU,GAAGF,IAAI,CAACG,GAAL,CAASL,OAAT,CAAnB;AACA,QAAMM,YAAY,GAAGH,MAAM,CAACE,GAAP,CAAWL,OAAX,CAArB;AAEAO,EAAAA,cAAc,CAACH,UAAD,CAAd;AACAG,EAAAA,cAAc,CAACD,YAAD,CAAd;;AAEA,MAAIF,UAAU,CAACI,MAAX,GAAoB,CAApB,IAAyBF,YAAY,CAACE,MAAb,GAAsB,CAAnD,EAAsD;AACpD,WAAON,IAAP;AACD;;AACD,QAAM,CAACO,SAAD,IAA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G,KAAJ,CAAU,4CAAV,CAAN;AACD;;AACD,aAAOH,KAAP;AACD,KALqB,CAAtB;AAMA,WAAOE,aAAP;AACD;;AAED,WAASlB,sBAAT,CAAgCpB,KAAhC,EAAuC;AACrC;AACA,UAAMwC,WAAW,GAAG,+BAApB;AACA,WAAO,wCAAcxC,KAAd,EAAqByC,WAArB,GAAmCC,OAAnC,CAA2CF,WAA3C,EAAwD,EAAxD,EAA4D,GAA5D,EAAiEE,OAAjE,CAAyE,OAAzE,EAAkF,GAAlF,EAAuFC,IAAvF,EAAP;AACD;AACF,C","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Merge MARC records\n*\n* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of marc-record-merge-js\n\n* marc-record-merge-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* marc-record-merge-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\nimport {normalizeSync} from 'normalize-diacritics';\n\nexport function strictEquality(subfieldA, subfieldB) {\n return subfieldA.code === subfieldB.code &&\n subfieldA.value === subfieldB.value;\n}\n\nexport function subsetEquality(subfieldA, subfieldB) {\n return subfieldA.code === subfieldB.code &&\n (subfieldA.value.indexOf(subfieldB.value) !== -1 || subfieldB.value.indexOf(subfieldA.value) !== -1);\n}\n\nexport default ({pattern, equalityFunction = strictEquality}) => (base, source) => {\n const baseFields = base.get(pattern);\n const sourceFields = source.get(pattern);\n\n checkFieldType(baseFields);\n checkFieldType(sourceFields);\n\n if (baseFields.length > 1 || sourceFields.length > 1) {\n return base;\n }\n const [baseField] = baseFields;\n const [sourceField] = sourceFields;\n\n if (baseField.tag === sourceField.tag === false) {\n return base;\n }\n const baseSubs = baseField.subfields;\n const sourceSubs = sourceField.subfields;\n\n const baseSubsNormalized = baseSubs\n .map(({code, value}) => ({code, value: normalizeSubfieldValue(value)}));\n\n const sourceSubsNormalized = sourceSubs\n .map(({code, value}) => ({code, value: normalizeSubfieldValue(value)}));\n\n const equalSubfieldsBase = baseSubsNormalized\n .filter(baseSubfield => sourceSubsNormalized\n .some(sourceSubfield => equalityFunction(baseSubfield, sourceSubfield)));\n\n const equalSubfieldsSource = sourceSubsNormalized\n .filter(sourceSubfield => baseSubsNormalized\n .some(baseSubfield => equalityFunction(sourceSubfield, baseSubfield)));\n\n if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length < baseSubs.length) {\n return base;\n }\n\n if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length === equalSubfieldsSource.length) {\n const totalSubfieldLengthBase = baseSubsNormalized\n .map(({value}) => value.length)\n .reduce((acc, value) => acc + value);\n const totalSubfieldLengthSource = sourceSubsNormalized\n .map(({value}) => value.length)\n .reduce((acc, value) => acc + value);\n\n if (totalSubfieldLengthSource > totalSubfieldLengthBase) {\n return replaceBasefieldWithSourcefield(base);\n }\n }\n\n if (sourceSubs.length > baseSubs.length && equalSubfieldsBase.length === baseSubs.length) {\n return replaceBasefieldWithSourcefield(base);\n }\n\n return base;\n\n function replaceBasefieldWithSourcefield(base) {\n const index = base.fields.findIndex(field => field === baseField);\n base.fields.splice(index, 1, sourceField); // eslint-disable-line functional/immutable-data\n return base;\n }\n\n function checkFieldType(fields) {\n const checkedFields = fields.map(field => {\n if ('value' in field) { // eslint-disable-line functional/no-conditional-statement\n throw new Error('Invalid control field, expected data field');\n }\n return field;\n });\n return checkedFields;\n }\n\n function normalizeSubfieldValue(value) {\n // Regexp options: g: global search, u: unicode\n const punctuation = /[.,\\-/#!$%^&*;:{}=_`~()[\\]]/gu;\n return normalizeSync(value).toLowerCase().replace(punctuation, '', 'u').replace(/\\s+/gu, ' ').trim();\n }\n};\n"],"file":"select.js"}
1
+ {"version":3,"file":"select.js","names":["strictEquality","subfieldA","subfieldB","code","value","subsetEquality","indexOf","tagPattern","equalityFunction","base","source","debug","createDebugLogger","baseFields","get","sourceFields","fieldTag","map","field","tag","checkFieldType","length","baseField","sourceField","baseSubs","subfields","sourceSubs","baseSubsNormalized","normalizeSubfieldValue","sourceSubsNormalized","equalSubfieldsBase","filter","baseSubfield","some","sourceSubfield","JSON","stringify","undefined","equalSubfieldsSource","totalSubfieldLengthBase","reduce","acc","totalSubfieldLengthSource","replaceBasefieldWithSourcefield","index","fields","findIndex","splice","checkedFields","Error","punctuation","normalizeSync","toLowerCase","replace","trim"],"sources":["../../src/reducers/select.js"],"sourcesContent":["import {normalizeSync} from 'normalize-diacritics';\nimport createDebugLogger from 'debug';\n\nexport function strictEquality(subfieldA, subfieldB) {\n return subfieldA.code === subfieldB.code &&\n subfieldA.value === subfieldB.value;\n}\n\nexport function subsetEquality(subfieldA, subfieldB) {\n return subfieldA.code === subfieldB.code &&\n (subfieldA.value.indexOf(subfieldB.value) !== -1 || subfieldB.value.indexOf(subfieldA.value) !== -1);\n}\n// EqualityFunction can be either strictEquality or subsetEquality\nexport default ({tagPattern, equalityFunction = strictEquality}) => (base, source) => {\n const debug = createDebugLogger('@natlibfi/marc-record-merge:select');\n const baseFields = base.get(tagPattern);\n const sourceFields = source.get(tagPattern);\n const fieldTag = sourceFields.map(field => field.tag);\n debug(`Comparing field ${fieldTag}`);\n\n checkFieldType(baseFields);\n checkFieldType(sourceFields);\n\n if (baseFields.length > 1 || sourceFields.length > 1) {\n debug(`Multiple fields in base or source`);\n debug(`No changes to base`);\n return base;\n }\n const [baseField] = baseFields;\n const [sourceField] = sourceFields;\n\n if (baseField.tag === sourceField.tag === false) {\n debug(`Base tag ${baseField.tag} is not equal to source tag ${sourceField.tag}`);\n debug(`No changes to base`);\n return base;\n }\n const baseSubs = baseField.subfields;\n const sourceSubs = sourceField.subfields;\n\n const baseSubsNormalized = baseSubs\n .map(({code, value}) => ({code, value: normalizeSubfieldValue(value)}));\n\n const sourceSubsNormalized = sourceSubs\n .map(({code, value}) => ({code, value: normalizeSubfieldValue(value)}));\n\n // Returns the base subfields for which a matching source subfield is found\n const equalSubfieldsBase = baseSubsNormalized\n .filter(baseSubfield => sourceSubsNormalized\n .some(sourceSubfield => equalityFunction(baseSubfield, sourceSubfield)));\n debug(`equalSubfieldsBase: ${JSON.stringify(equalSubfieldsBase, undefined, 2)}`);\n\n // Returns the source subfields for which a matching base subfield is found\n const equalSubfieldsSource = sourceSubsNormalized\n .filter(sourceSubfield => baseSubsNormalized\n .some(baseSubfield => equalityFunction(sourceSubfield, baseSubfield)));\n debug(`equalSubfieldsSource: ${JSON.stringify(equalSubfieldsSource, undefined, 2)}`);\n\n if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length < baseSubs.length) {\n debug(`Base and source subfields are not equal`);\n debug(`No changes to base`);\n return base;\n }\n\n if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length === equalSubfieldsSource.length) {\n debug(`Checking subfield equality`);\n const totalSubfieldLengthBase = baseSubsNormalized\n .map(({value}) => value.length)\n .reduce((acc, value) => acc + value);\n const totalSubfieldLengthSource = sourceSubsNormalized\n .map(({value}) => value.length)\n .reduce((acc, value) => acc + value);\n\n if (totalSubfieldLengthSource > totalSubfieldLengthBase) {\n return replaceBasefieldWithSourcefield(base);\n }\n }\n\n if (sourceSubs.length > baseSubs.length && equalSubfieldsBase.length === baseSubs.length) {\n return replaceBasefieldWithSourcefield(base);\n }\n\n debug(`No changes to base`);\n return base;\n\n function replaceBasefieldWithSourcefield(base) {\n const index = base.fields.findIndex(field => field === baseField);\n base.fields.splice(index, 1, sourceField); // eslint-disable-line functional/immutable-data\n debug(`Source field is longer, replacing base with source`);\n return base;\n }\n\n function checkFieldType(fields) {\n const checkedFields = fields.map(field => {\n if ('value' in field) { // eslint-disable-line functional/no-conditional-statement\n throw new Error('Invalid control field, expected data field');\n }\n return field;\n });\n return checkedFields;\n }\n\n function normalizeSubfieldValue(value) {\n // Regexp options: g: global search, u: unicode\n const punctuation = /[.,\\-/#!?$%^&*;:{}=_`~()[\\]]/gu;\n return normalizeSync(value).toLowerCase().replace(punctuation, '', 'u').replace(/\\s+/gu, ' ').trim();\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;;;AAEO,SAASA,cAAT,CAAwBC,SAAxB,EAAmCC,SAAnC,EAA8C;EACnD,OAAOD,SAAS,CAACE,IAAV,KAAmBD,SAAS,CAACC,IAA7B,IACPF,SAAS,CAACG,KAAV,KAAoBF,SAAS,CAACE,KAD9B;AAED;;AAEM,SAASC,cAAT,CAAwBJ,SAAxB,EAAmCC,SAAnC,EAA8C;EACnD,OAAOD,SAAS,CAACE,IAAV,KAAmBD,SAAS,CAACC,IAA7B,KACNF,SAAS,CAACG,KAAV,CAAgBE,OAAhB,CAAwBJ,SAAS,CAACE,KAAlC,MAA6C,CAAC,CAA9C,IAAmDF,SAAS,CAACE,KAAV,CAAgBE,OAAhB,CAAwBL,SAAS,CAACG,KAAlC,MAA6C,CAAC,CAD3F,CAAP;AAED,C,CACD;;;eACe,CAAC;EAACG,UAAD;EAAaC,gBAAgB,GAAGR;AAAhC,CAAD,KAAqD,CAACS,IAAD,EAAOC,MAAP,KAAkB;EACpF,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAkB,oCAAlB,CAAd;EACA,MAAMC,UAAU,GAAGJ,IAAI,CAACK,GAAL,CAASP,UAAT,CAAnB;EACA,MAAMQ,YAAY,GAAGL,MAAM,CAACI,GAAP,CAAWP,UAAX,CAArB;EACA,MAAMS,QAAQ,GAAGD,YAAY,CAACE,GAAb,CAAiBC,KAAK,IAAIA,KAAK,CAACC,GAAhC,CAAjB;EACAR,KAAK,CAAE,mBAAkBK,QAAS,EAA7B,CAAL;EAEAI,cAAc,CAACP,UAAD,CA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L,MAAX,GAAoBG,QAAQ,CAACH,MAA7B,IAAuCS,kBAAkB,CAACT,MAAnB,KAA8BG,QAAQ,CAACH,MAAlF,EAA0F;IACxF,OAAOsB,+BAA+B,CAAClC,IAAD,CAAtC;EACD;;EAEDE,KAAK,CAAE,oBAAF,CAAL;EACA,OAAOF,IAAP;;EAEA,SAASkC,+BAAT,CAAyClC,IAAzC,EAA+C;IAC7C,MAAMmC,KAAK,GAAGnC,IAAI,CAACoC,MAAL,CAAYC,SAAZ,CAAsB5B,KAAK,IAAIA,KAAK,KAAKI,SAAzC,CAAd;IACAb,IAAI,CAACoC,MAAL,CAAYE,MAAZ,CAAmBH,KAAnB,EAA0B,CAA1B,EAA6BrB,WAA7B,EAF6C,CAEF;;IAC3CZ,KAAK,CAAE,oDAAF,CAAL;IACA,OAAOF,IAAP;EACD;;EAED,SAASW,cAAT,CAAwByB,MAAxB,EAAgC;IAC9B,MAAMG,aAAa,GAAGH,MAAM,CAAC5B,GAAP,CAAWC,KAAK,IAAI;MACxC,IAAI,WAAWA,KAAf,EAAsB;QAAE;QACtB,MAAM,IAAI+B,KAAJ,CAAU,4CAAV,CAAN;MACD;;MACD,OAAO/B,KAAP;IACD,CALqB,CAAtB;IAMA,OAAO8B,aAAP;EACD;;EAED,SAASpB,sBAAT,CAAgCxB,KAAhC,EAAuC;IACrC;IACA,MAAM8C,WAAW,GAAG,gCAApB;IACA,OAAO,IAAAC,kCAAA,EAAc/C,KAAd,EAAqBgD,WAArB,GAAmCC,OAAnC,CAA2CH,WAA3C,EAAwD,EAAxD,EAA4D,GAA5D,EAAiEG,OAAjE,CAAyE,OAAzE,EAAkF,GAAlF,EAAuFC,IAAvF,EAAP;EACD;AACF,C"}
@@ -1,102 +1,68 @@
1
1
  "use strict";
2
2
 
3
- var _chai = _interopRequireDefault(require("chai"));
4
-
5
- var _fs = _interopRequireDefault(require("fs"));
6
-
7
- var _path = _interopRequireDefault(require("path"));
3
+ var _chai = require("chai");
8
4
 
9
5
  var _marcRecord = require("@natlibfi/marc-record");
10
6
 
11
7
  var _select = _interopRequireWildcard(require("./select"));
12
8
 
13
- var _fixura = _interopRequireWildcard(require("@natlibfi/fixura"));
14
-
15
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
9
+ var _fixura = require("@natlibfi/fixura");
16
10
 
17
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
18
12
 
19
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
14
 
21
- /**
22
- *
23
- * @licstart The following is the entire license notice for the JavaScript code in this file.
24
- *
25
- * Merge MARC records
26
- *
27
- * Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
28
- *
29
- * This file is part of marc-record-merge-js
15
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
+
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
30
18
 
31
- * marc-record-merge-js program is free software: you can redistribute it and/or modify
32
- * it under the terms of the GNU Lesser General Public License as
33
- * published by the Free Software Foundation, either version 3 of the
34
- * License, or (at your option) any later version.
35
- *
36
- * marc-record-merge-js is distributed in the hope that it will be useful,
37
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
38
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
- * GNU Lesser General Public License for more details.
40
- *
41
- * You should have received a copy of the GNU Lesser General Public License
42
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
43
- *
44
- * @licend The above is the entire license notice
45
- * for the JavaScript code in this file.
46
- *
47
- */
48
19
  _marcRecord.MarcRecord.setValidationOptions({
49
20
  subfieldValues: false
50
21
  });
51
22
 
52
- describe('reducers/select', () => {
53
- const {
54
- expect
55
- } = _chai.default;
56
-
57
- const fixturesPath = _path.default.join(__dirname, '..', '..', 'test-fixtures', 'reducers', 'select');
58
-
59
- _fs.default.readdirSync(fixturesPath).forEach(subDir => {
60
- const {
61
- getFixture
62
- } = (0, _fixura.default)({
63
- root: [fixturesPath, subDir],
64
- reader: _fixura.READERS.JSON,
65
- failWhenNotFound: false
66
- });
67
- it(subDir, () => {
68
- const baseTest = new _marcRecord.MarcRecord(getFixture('base.json'));
69
- const sourceTest = new _marcRecord.MarcRecord(getFixture('source.json'));
70
- const patternTest = new RegExp(getFixture({
71
- components: ['pattern.txt'],
72
- reader: _fixura.READERS.TEXT
73
- }), 'u');
74
- const expectedRecord = getFixture('merged.json');
75
- const expectedError = getFixture({
76
- components: ['expected-error.txt'],
77
- reader: _fixura.READERS.TEXT
78
- });
79
- const equalityFunction = getEqualityFunction();
80
-
81
- if (expectedError) {
82
- expect(() => _select.default.to.throw(Error, 'control field'));
83
- return;
84
- }
85
-
86
- const mergedRecord = (0, _select.default)({
87
- pattern: patternTest,
88
- equalityFunction
89
- })(baseTest, sourceTest);
90
- expect(mergedRecord.toObject()).to.eql(expectedRecord);
23
+ (0, _fixugen.default)({
24
+ callback,
25
+ path: [__dirname, '..', '..', 'test-fixtures', 'reducers', 'select'],
26
+ useMetadataFile: true,
27
+ recurse: false,
28
+ fixura: {
29
+ reader: _fixura.READERS.JSON,
30
+ failWhenNotFound: false
31
+ }
32
+ });
91
33
 
92
- function getEqualityFunction() {
93
- const functionName = getFixture({
94
- components: ['equalityFunction.txt'],
95
- reader: _fixura.READERS.TEXT
96
- });
97
- return functionName === 'subsetEquality' ? _select.subsetEquality : undefined;
98
- }
99
- });
34
+ function callback({
35
+ getFixture,
36
+ disabled = false,
37
+ tagPatternRegExp = false,
38
+ expectedError = false,
39
+ useSubsetEquality = false
40
+ }) {
41
+ if (disabled) {
42
+ console.log('TEST DISABLED!'); // eslint-disable-line no-console
43
+
44
+ return;
45
+ }
46
+
47
+ const base = new _marcRecord.MarcRecord(getFixture('base.json'), {
48
+ subfieldValues: false
100
49
  });
101
- });
50
+ const source = new _marcRecord.MarcRecord(getFixture('source.json'), {
51
+ subfieldValues: false
52
+ });
53
+ const tagPattern = new RegExp(tagPatternRegExp, 'u');
54
+ const expectedRecord = getFixture('merged.json');
55
+ const equalityFunction = useSubsetEquality ? _select.subsetEquality : undefined; // Bypass expected error in testing
56
+
57
+ if (expectedError) {
58
+ (0, _chai.expect)(() => _select.default.to.throw(Error, 'control field'));
59
+ return;
60
+ }
61
+
62
+ const mergedRecord = (0, _select.default)({
63
+ tagPattern,
64
+ equalityFunction
65
+ })(base, source);
66
+ (0, _chai.expect)(mergedRecord.toObject()).to.eql(expectedRecord);
67
+ }
102
68
  //# sourceMappingURL=select.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/reducers/select.spec.js"],"names":["MarcRecord","setValidationOptions","subfieldValues","describe","expect","chai","fixturesPath","path","join","__dirname","fs","readdirSync","forEach","subDir","getFixture","root","reader","READERS","JSON","failWhenNotFound","it","baseTest","sourceTest","patternTest","RegExp","components","TEXT","expectedRecord","expectedError","equalityFunction","getEqualityFunction","createReducer","to","throw","Error","mergedRecord","pattern","toObject","eql","functionName","subsetEquality","undefined"],"mappings":";;AA2BA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAhCA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCAA,uBAAWC,oBAAX,CAAgC;AAACC,EAAAA,cAAc,EAAE;AAAjB,CAAhC;;AAEAC,QAAQ,CAAC,iBAAD,EAAoB,MAAM;AAChC,QAAM;AAACC,IAAAA;AAAD,MAAWC,aAAjB;;AACA,QAAMC,YAAY,GAAGC,cAAKC,IAAL,CAAUC,SAAV,EAAqB,IAArB,EAA2B,IAA3B,EAAiC,eAAjC,EAAkD,UAAlD,EAA8D,QAA9D,CAArB;;AAEAC,cAAGC,WAAH,CAAeL,YAAf,EAA6BM,OAA7B,CAAqCC,MAAM,IAAI;AAC7C,UAAM;AAACC,MAAAA;AAAD,QAAe,qBAAgB;AAACC,MAAAA,IAAI,EAAE,CAACT,YAAD,EAAeO,MAAf,CAAP;AAA+BG,MAAAA,MAAM,EAAEC,gBAAQC,IAA/C;AAAqDC,MAAAA,gBAAgB,EAAE;AAAvE,KAAhB,CAArB;AACAC,IAAAA,EAAE,CAACP,MAAD,EAAS,MAAM;AACf,YAAMQ,QAAQ,GAAG,IAAIrB,sBAAJ,CAAec,UAAU,CAAC,WAAD,CAAzB,CAAjB;AACA,YAAMQ,UAAU,GAAG,IAAItB,sBAAJ,CAAec,UAAU,CAAC,aAAD,CAAzB,CAAnB;AACA,YAAMS,WAAW,GAAG,IAAIC,MAAJ,CAAWV,UAAU,CAAC;AAACW,QAAAA,UAAU,EAAE,CAAC,aAAD,CAAb;AAA8BT,QAAAA,MAAM,EAAEC,gBAAQS;AAA9C,OAAD,CAArB,EAA4E,GAA5E,CAApB;AACA,YAAMC,cAAc,GAAGb,UAAU,CAAC,aAAD,CAAjC;AACA,YAAMc,aAAa,GAAGd,UAAU,CAAC;AAACW,QAAAA,UAAU,EAAE,CAAC,oBAAD,CAAb;AAAqCT,QAAAA,MAAM,EAAEC,gBAAQS;AAArD,OAAD,CAAhC;AACA,YAAMG,gBAAgB,GAAGC,mBAAmB,EAA5C;;AAEA,UAAIF,aAAJ,EAAmB;AACjBxB,QAAAA,MAAM,CAAC,MAAM2B,gBAAcC,EAAd,CAAiBC,KAAjB,CAAuBC,KAAvB,EAA8B,eAA9B,CAAP,CAAN;AACA;AACD;;AACD,YAAMC,YAAY,GAAG,qBAAc;AAACC,QAAAA,OAAO,EAAEb,WAAV;AAAuBM,QAAAA;AAAvB,OAAd,EAAwDR,QAAxD,EAAkEC,UAAlE,CAArB;AACAlB,MAAAA,MAAM,CAAC+B,YAAY,CAACE,QAAb,EAAD,CAAN,CAAgCL,EAAhC,CAAmCM,GAAnC,CAAuCX,cAAvC;;AAEA,eAASG,mBAAT,GAA+B;AAC7B,cAAMS,YAAY,GAAGzB,UAAU,CAAC;AAACW,UAAAA,UAAU,EAAE,CAAC,sBAAD,CAAb;AAAuCT,UAAAA,MAAM,EAAEC,gBAAQS;AAAvD,SAAD,CAA/B;AACA,eAAOa,YAAY,KAAK,gBAAjB,GAAoCC,sBAApC,GAAqDC,SAA5D;AACD;AACF,KAnBC,CAAF;AAoBD,GAtBD;AAuBD,CA3BO,CAAR","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Merge MARC records\n*\n* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of marc-record-merge-js\n\n* marc-record-merge-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* marc-record-merge-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\nimport chai from 'chai';\nimport fs from 'fs';\nimport path from 'path';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createReducer, {subsetEquality} from './select';\nimport fixturesFactory, {READERS} from '@natlibfi/fixura';\n\nMarcRecord.setValidationOptions({subfieldValues: false});\n\ndescribe('reducers/select', () => {\n const {expect} = chai;\n const fixturesPath = path.join(__dirname, '..', '..', 'test-fixtures', 'reducers', 'select');\n\n fs.readdirSync(fixturesPath).forEach(subDir => {\n const {getFixture} = fixturesFactory({root: [fixturesPath, subDir], reader: READERS.JSON, failWhenNotFound: false});\n it(subDir, () => {\n const baseTest = new MarcRecord(getFixture('base.json'));\n const sourceTest = new MarcRecord(getFixture('source.json'));\n const patternTest = new RegExp(getFixture({components: ['pattern.txt'], reader: READERS.TEXT}), 'u');\n const expectedRecord = getFixture('merged.json');\n const expectedError = getFixture({components: ['expected-error.txt'], reader: READERS.TEXT});\n const equalityFunction = getEqualityFunction();\n\n if (expectedError) {\n expect(() => createReducer.to.throw(Error, 'control field'));\n return;\n }\n const mergedRecord = createReducer({pattern: patternTest, equalityFunction})(baseTest, sourceTest);\n expect(mergedRecord.toObject()).to.eql(expectedRecord);\n\n function getEqualityFunction() {\n const functionName = getFixture({components: ['equalityFunction.txt'], reader: READERS.TEXT});\n return functionName === 'subsetEquality' ? subsetEquality : undefined;\n }\n });\n });\n});\n"],"file":"select.spec.js"}
1
+ {"version":3,"file":"select.spec.js","names":["MarcRecord","setValidationOptions","subfieldValues","generateTests","callback","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","failWhenNotFound","getFixture","disabled","tagPatternRegExp","expectedError","useSubsetEquality","console","log","base","source","tagPattern","RegExp","expectedRecord","equalityFunction","subsetEquality","undefined","expect","createReducer","to","throw","Error","mergedRecord","toObject","eql"],"sources":["../../src/reducers/select.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createReducer, {subsetEquality} from './select';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\n\nMarcRecord.setValidationOptions({subfieldValues: false});\n\ngenerateTests({\n callback,\n path: [__dirname, '..', '..', 'test-fixtures', 'reducers', 'select'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON,\n failWhenNotFound: false\n }\n});\n\nfunction callback({\n getFixture,\n disabled = false,\n tagPatternRegExp = false,\n expectedError = false,\n useSubsetEquality = false\n}) {\n if (disabled) {\n console.log('TEST DISABLED!'); // eslint-disable-line no-console\n return;\n }\n const base = new MarcRecord(getFixture('base.json'), {subfieldValues: false});\n const source = new MarcRecord(getFixture('source.json'), {subfieldValues: false});\n const tagPattern = new RegExp(tagPatternRegExp, 'u');\n const expectedRecord = getFixture('merged.json');\n const equalityFunction = useSubsetEquality ? subsetEquality : undefined;\n\n // Bypass expected error in testing\n if (expectedError) {\n expect(() => createReducer.to.throw(Error, 'control field'));\n return;\n }\n\n const mergedRecord = createReducer({tagPattern, equalityFunction})(base, source);\n expect(mergedRecord.toObject()).to.eql(expectedRecord);\n}\n"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEAA,sBAAA,CAAWC,oBAAX,CAAgC;EAACC,cAAc,EAAE;AAAjB,CAAhC;;AAEA,IAAAC,gBAAA,EAAc;EACZC,QADY;EAEZC,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,IAAlB,EAAwB,eAAxB,EAAyC,UAAzC,EAAqD,QAArD,CAFM;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13
13
  "type": "git",
14
14
  "url": "git@github.com:natlibfi/marc-record-merge-js.git"
15
15
  },
16
- "license": "LGPL-3.0+",
17
- "version": "6.0.0-beta.1",
16
+ "license": "MIT",
17
+ "version": "6.0.0-beta.5",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
- "node": ">=12"
20
+ "node": ">=14"
21
21
  },
22
+ "type": "commonjs",
22
23
  "scripts": {
24
+ "prepare": "npm run build",
23
25
  "prepublishOnly": "npm run build:transpile",
24
- "check-deps": "npm-check;exit 0",
25
26
  "lint": "eslint ./src",
26
27
  "lint:dev": "eslint ./src --fix",
27
- "test:base": "cross-env NODE_ENV=test nyc mocha --require @babel/register",
28
- "test": "npm run lint && npm run test:base -- src/**/*.spec.js",
29
- "test:dev": "npm run lint:dev && npm run test:base -- src/**/*.spec.js && npm run coverage",
30
- "coverage": "nyc check-coverage --per-file",
28
+ "test:base": "cross-env NODE_ENV=test mocha --require @babel/register --reporter-option maxDiffSize=15000 src/reducers/*.spec.js",
29
+ "test": "npm run lint && npm run test:base",
30
+ "test:dev": "npm run lint:dev && npm run coverage",
31
+ "coverage": "npm run coverage:unit && npm run coverage:report",
32
+ "coverage:unit": "nyc --silent npm run test:base",
33
+ "coverage:report": "nyc report",
31
34
  "build:transpile": "babel src --copy-files --source-maps --delete-dir-on-start --out-dir=dist",
32
- "build": "npm run build:transpile && npm run check-deps",
33
- "watch:test": "cross-env DEBUG=1 NODE_ENV=test nodemon -w src -w test-fixtures --exec 'npm run test:dev'"
35
+ "build": "npm run build:transpile",
36
+ "dev:test": "cross-env NODE_ENV=test nodemon -w src -w test-fixtures --exec 'clear && npm run test:dev'",
37
+ "dev:test:debug": "cross-env DEBUG=@natlibfi/* NODE_ENV=test nodemon -w src -w test-fixtures --exec 'clear && npm run test:dev'"
34
38
  },
35
39
  "dependencies": {
36
- "@natlibfi/fixura": "^2.0.0",
37
- "@natlibfi/marc-record": "^6.0.0",
38
- "debug": "^4.1.1",
39
- "normalize-diacritics": "^2.11.1"
40
+ "@natlibfi/fixugen": "1.1.0",
41
+ "@natlibfi/fixura": "^2.2.1",
42
+ "@natlibfi/marc-record": "^7.1.0-alpha.2",
43
+ "debug": "^4.3.4",
44
+ "normalize-diacritics": "2.14.0"
40
45
  },
41
46
  "devDependencies": {
42
- "@babel/cli": "^7.10.1",
43
- "@babel/core": "^7.10.2",
44
- "@babel/preset-env": "^7.10.2",
45
- "@babel/register": "^7.10.1",
46
- "@natlibfi/eslint-config-melinda-backend": "^1.0.3",
47
- "babel-eslint": "^10.0.3",
48
- "babel-plugin-istanbul": "^6.0.0",
47
+ "@babel/cli": "^7.17.10",
48
+ "@babel/core": "^7.18.0",
49
+ "@babel/eslint-parser": "^7.17.0",
50
+ "@babel/preset-env": "^7.18.0",
51
+ "@babel/register": "^7.17.7",
52
+ "@natlibfi/eslint-config-melinda-backend": "^2.0.0",
53
+ "babel-plugin-istanbul": "^6.1.1",
49
54
  "babel-plugin-rewire": "^1.2.0",
50
- "chai": "^4.2.0",
51
- "cross-env": "^7.0.2",
52
- "eslint": "^7.1.0",
53
- "mocha": "^7.2.0",
54
- "nodemon": "^2.0.4",
55
- "npm-check": "^5.9.0",
55
+ "chai": "^4.3.4",
56
+ "cross-env": "^7.0.3",
57
+ "eslint": "^8.16.0",
58
+ "mocha": "^10.0.0",
59
+ "nodemon": "^2.0.16",
56
60
  "nyc": "^15.1.0"
57
61
  },
58
62
  "eslintConfig": {
@@ -65,9 +69,7 @@
65
69
  [
66
70
  "@babel/preset-env",
67
71
  {
68
- "targets": {
69
- "node": "12"
70
- }
72
+ "targets": "maintained node versions"
71
73
  }
72
74
  ]
73
75
  ],
@@ -86,8 +88,7 @@
86
88
  "*/**/*.spec.js"
87
89
  ],
88
90
  "reporter": [
89
- "lcov",
90
- "html"
91
+ "text"
91
92
  ],
92
93
  "require": [
93
94
  "@babel/register"
package/src/index.js CHANGED
@@ -1,36 +1,4 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Merge MARC records
6
- *
7
- * Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of marc-record-merge-js
10
-
11
- * marc-record-merge-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * marc-record-merge-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
- import * as Reducers from './reducers';
30
- import {MarcRecord} from '@natlibfi/marc-record';
1
+ import Reducers from './reducers';
31
2
 
32
3
  export {Reducers};
33
- export default ({base, source, reducers}) => {
34
- const sourceRecord = MarcRecord.clone(source);
35
- return reducers.reduce((baseRecord, reducer) => reducer(baseRecord, sourceRecord), MarcRecord.clone(base));
36
- };
4
+ export default ({base, source, reducers}) => reducers.reduce((base, reducer) => reducer(base, source), base);