@natlibfi/marc-record-merge 5.0.0 → 6.0.0-beta.10

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 (579) 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 +90 -242
  6. package/dist/index.js +55 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/reducers/copy.js +249 -0
  9. package/dist/reducers/copy.js.map +1 -0
  10. package/dist/reducers/copy.spec.js +64 -0
  11. package/dist/reducers/copy.spec.js.map +1 -0
  12. package/dist/reducers/index.js +19 -0
  13. package/dist/reducers/index.js.map +1 -0
  14. package/dist/reducers/select.js +118 -0
  15. package/dist/reducers/select.js.map +1 -0
  16. package/dist/reducers/select.spec.js +55 -0
  17. package/dist/reducers/select.spec.js.map +1 -0
  18. package/package.json +101 -57
  19. package/src/index.js +34 -0
  20. package/src/reducers/copy.js +251 -0
  21. package/src/reducers/copy.spec.js +54 -0
  22. package/src/reducers/index.js +4 -0
  23. package/src/reducers/select.js +110 -0
  24. package/src/reducers/select.spec.js +49 -0
  25. package/test-fixtures/reducers/copy/01 - copy/01/base.json +9 -0
  26. package/test-fixtures/reducers/copy/01 - copy/01/merged.json +20 -0
  27. package/test-fixtures/reducers/copy/01 - copy/01/metadata.json +4 -0
  28. package/test-fixtures/reducers/copy/01 - copy/01/source.json +20 -0
  29. package/test-fixtures/reducers/copy/01 - copy/02/base.json +20 -0
  30. package/test-fixtures/reducers/copy/01 - copy/02/merged.json +20 -0
  31. package/test-fixtures/reducers/copy/01 - copy/02/metadata.json +4 -0
  32. package/test-fixtures/reducers/copy/01 - copy/02/source.json +20 -0
  33. package/test-fixtures/reducers/copy/01 - copy/03/base.json +20 -0
  34. package/test-fixtures/reducers/copy/01 - copy/03/merged.json +28 -0
  35. package/test-fixtures/reducers/copy/01 - copy/03/metadata.json +4 -0
  36. package/test-fixtures/reducers/copy/01 - copy/03/source.json +24 -0
  37. package/test-fixtures/reducers/copy/01 - copy/04/base.json +39 -0
  38. package/test-fixtures/reducers/copy/01 - copy/04/merged.json +39 -0
  39. package/test-fixtures/reducers/copy/01 - copy/04/metadata.json +4 -0
  40. package/test-fixtures/reducers/copy/01 - copy/04/source.json +39 -0
  41. package/test-fixtures/reducers/copy/01 - copy/05/base.json +39 -0
  42. package/test-fixtures/reducers/copy/01 - copy/05/merged.json +77 -0
  43. package/test-fixtures/reducers/copy/01 - copy/05/metadata.json +4 -0
  44. package/test-fixtures/reducers/copy/01 - copy/05/source.json +62 -0
  45. package/test-fixtures/reducers/copy/01 - copy/06/base.json +24 -0
  46. package/test-fixtures/reducers/copy/01 - copy/06/merged.json +39 -0
  47. package/test-fixtures/reducers/copy/01 - copy/06/metadata.json +4 -0
  48. package/test-fixtures/reducers/copy/01 - copy/06/source.json +24 -0
  49. package/test-fixtures/reducers/copy/01 - copy/07/base.json +39 -0
  50. package/test-fixtures/reducers/copy/01 - copy/07/merged.json +39 -0
  51. package/test-fixtures/reducers/copy/01 - copy/07/metadata.json +5 -0
  52. package/test-fixtures/reducers/copy/01 - copy/07/source.json +24 -0
  53. package/test-fixtures/reducers/copy/01 - copy/08/base.json +28 -0
  54. package/test-fixtures/reducers/copy/01 - copy/08/merged.json +28 -0
  55. package/test-fixtures/reducers/copy/01 - copy/08/metadata.json +4 -0
  56. package/test-fixtures/reducers/copy/01 - copy/08/source.json +24 -0
  57. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/base.json +17 -0
  58. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/merged.json +20 -0
  59. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/metadata.json +6 -0
  60. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/source.json +20 -0
  61. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/base.json +9 -0
  62. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/merged.json +20 -0
  63. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/metadata.json +6 -0
  64. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/source.json +20 -0
  65. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/base.json +24 -0
  66. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/merged.json +24 -0
  67. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/metadata.json +5 -0
  68. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/source.json +24 -0
  69. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/base.json +24 -0
  70. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/merged.json +100 -0
  71. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/metadata.json +5 -0
  72. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/source.json +100 -0
  73. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/base.json +24 -0
  74. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/merged.json +24 -0
  75. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/metadata.json +5 -0
  76. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/source.json +24 -0
  77. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/base.json +24 -0
  78. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/merged.json +39 -0
  79. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/metadata.json +5 -0
  80. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/source.json +24 -0
  81. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/03/metadata.json +6 -0
  82. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/base.json +20 -0
  83. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/merged.json +31 -0
  84. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/metadata.json +5 -0
  85. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/source.json +20 -0
  86. package/test-fixtures/reducers/copy/05 - copyUnless/01/base.json +9 -0
  87. package/test-fixtures/reducers/copy/05 - copyUnless/01/merged.json +24 -0
  88. package/test-fixtures/reducers/copy/05 - copyUnless/01/metadata.json +5 -0
  89. package/test-fixtures/reducers/copy/05 - copyUnless/01/source.json +47 -0
  90. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/base.json +24 -0
  91. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/merged.json +39 -0
  92. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/metadata.json +5 -0
  93. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/source.json +24 -0
  94. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/base.json +24 -0
  95. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/merged.json +24 -0
  96. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/metadata.json +5 -0
  97. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/source.json +24 -0
  98. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/base.json +28 -0
  99. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/merged.json +43 -0
  100. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/metadata.json +5 -0
  101. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/source.json +24 -0
  102. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/base.json +28 -0
  103. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/merged.json +28 -0
  104. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/metadata.json +5 -0
  105. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/source.json +24 -0
  106. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/base.json +20 -0
  107. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/merged.json +35 -0
  108. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/metadata.json +5 -0
  109. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/source.json +24 -0
  110. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/base.json +20 -0
  111. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/merged.json +35 -0
  112. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/metadata.json +5 -0
  113. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/source.json +24 -0
  114. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/base.json +39 -0
  115. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/merged.json +39 -0
  116. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/metadata.json +8 -0
  117. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/source.json +43 -0
  118. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/base.json +39 -0
  119. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/merged.json +58 -0
  120. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/metadata.json +5 -0
  121. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/source.json +43 -0
  122. package/test-fixtures/reducers/copy/08 - dropSubfields/01/base.json +35 -0
  123. package/test-fixtures/reducers/copy/08 - dropSubfields/01/merged.json +54 -0
  124. package/test-fixtures/reducers/copy/08 - dropSubfields/01/metadata.json +5 -0
  125. package/test-fixtures/reducers/copy/08 - dropSubfields/01/source.json +43 -0
  126. package/test-fixtures/reducers/copy/08 - dropSubfields/02/base.json +43 -0
  127. package/test-fixtures/reducers/copy/08 - dropSubfields/02/merged.json +58 -0
  128. package/test-fixtures/reducers/copy/08 - dropSubfields/02/metadata.json +5 -0
  129. package/test-fixtures/reducers/copy/08 - dropSubfields/02/source.json +32 -0
  130. package/test-fixtures/reducers/copy/08 - dropSubfields/03/base.json +43 -0
  131. package/test-fixtures/reducers/copy/08 - dropSubfields/03/merged.json +58 -0
  132. package/test-fixtures/reducers/copy/08 - dropSubfields/03/metadata.json +5 -0
  133. package/test-fixtures/reducers/copy/08 - dropSubfields/03/source.json +32 -0
  134. package/test-fixtures/reducers/copy/08 - dropSubfields/04/base.json +43 -0
  135. package/test-fixtures/reducers/copy/08 - dropSubfields/04/merged.json +43 -0
  136. package/test-fixtures/reducers/copy/08 - dropSubfields/04/metadata.json +5 -0
  137. package/test-fixtures/reducers/copy/08 - dropSubfields/04/source.json +32 -0
  138. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/base.json +9 -0
  139. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/merged.json +20 -0
  140. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/metadata.json +6 -0
  141. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/source.json +20 -0
  142. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/base.json +9 -0
  143. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/merged.json +20 -0
  144. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/metadata.json +6 -0
  145. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/source.json +20 -0
  146. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/base.json +9 -0
  147. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/merged.json +31 -0
  148. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/metadata.json +6 -0
  149. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/source.json +31 -0
  150. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/base.json +9 -0
  151. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/merged.json +42 -0
  152. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/metadata.json +6 -0
  153. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/source.json +42 -0
  154. package/test-fixtures/reducers/copy/10 - swapTag/01/base.json +17 -0
  155. package/test-fixtures/reducers/copy/10 - swapTag/01/merged.json +28 -0
  156. package/test-fixtures/reducers/copy/10 - swapTag/01/metadata.json +6 -0
  157. package/test-fixtures/reducers/copy/10 - swapTag/01/source.json +20 -0
  158. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/base.json +28 -0
  159. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/merged.json +28 -0
  160. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/metadata.json +6 -0
  161. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/source.json +20 -0
  162. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/base.json +28 -0
  163. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/merged.json +39 -0
  164. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/metadata.json +6 -0
  165. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/source.json +31 -0
  166. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/base.json +28 -0
  167. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/merged.json +28 -0
  168. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/metadata.json +7 -0
  169. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/source.json +20 -0
  170. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/base.json +17 -0
  171. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/merged.json +28 -0
  172. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/metadata.json +7 -0
  173. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/source.json +31 -0
  174. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/base.json +28 -0
  175. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/merged.json +28 -0
  176. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/metadata.json +7 -0
  177. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/source.json +28 -0
  178. package/test-fixtures/reducers/metadata.json +4 -0
  179. package/test-fixtures/reducers/select/01/base.json +21 -0
  180. package/test-fixtures/reducers/select/01/merged.json +20 -0
  181. package/test-fixtures/reducers/select/01/metadata.json +5 -0
  182. package/test-fixtures/reducers/select/01/source.json +20 -0
  183. package/test-fixtures/reducers/select/02/base.json +31 -0
  184. package/test-fixtures/reducers/select/02/merged.json +31 -0
  185. package/test-fixtures/reducers/select/02/metadata.json +4 -0
  186. package/test-fixtures/reducers/select/02/source.json +42 -0
  187. package/test-fixtures/reducers/select/03/base.json +20 -0
  188. package/test-fixtures/reducers/select/03/merged.json +20 -0
  189. package/test-fixtures/reducers/select/03/metadata.json +4 -0
  190. package/test-fixtures/reducers/select/03/source.json +20 -0
  191. package/test-fixtures/reducers/select/04/base.json +20 -0
  192. package/test-fixtures/reducers/select/04/merged.json +20 -0
  193. package/test-fixtures/reducers/select/04/metadata.json +5 -0
  194. package/test-fixtures/reducers/select/04/source.json +20 -0
  195. package/test-fixtures/reducers/select/05/base.json +24 -0
  196. package/test-fixtures/reducers/select/05/merged.json +24 -0
  197. package/test-fixtures/reducers/select/05/metadata.json +4 -0
  198. package/test-fixtures/reducers/select/05/source.json +24 -0
  199. package/test-fixtures/reducers/select/06/base.json +28 -0
  200. package/test-fixtures/reducers/select/06/merged.json +28 -0
  201. package/test-fixtures/reducers/select/06/metadata.json +4 -0
  202. package/test-fixtures/reducers/select/06/source.json +28 -0
  203. package/test-fixtures/reducers/select/07/base.json +24 -0
  204. package/test-fixtures/reducers/select/07/merged.json +24 -0
  205. package/test-fixtures/reducers/select/07/metadata.json +5 -0
  206. package/test-fixtures/reducers/select/07/source.json +24 -0
  207. package/test-fixtures/reducers/select/08/base.json +24 -0
  208. package/test-fixtures/reducers/select/08/merged.json +24 -0
  209. package/test-fixtures/reducers/select/08/metadata.json +4 -0
  210. package/test-fixtures/reducers/select/08/source.json +24 -0
  211. package/test-fixtures/reducers/select/09/base.json +24 -0
  212. package/test-fixtures/reducers/select/09/merged.json +24 -0
  213. package/test-fixtures/reducers/select/09/metadata.json +4 -0
  214. package/test-fixtures/reducers/select/09/source.json +24 -0
  215. package/test-fixtures/reducers/select/10/base.json +24 -0
  216. package/test-fixtures/reducers/select/10/merged.json +28 -0
  217. package/test-fixtures/reducers/select/10/metadata.json +5 -0
  218. package/test-fixtures/reducers/select/10/source.json +28 -0
  219. package/test-fixtures/reducers/select/11/base.json +24 -0
  220. package/test-fixtures/reducers/select/11/merged.json +24 -0
  221. package/test-fixtures/reducers/select/11/metadata.json +4 -0
  222. package/test-fixtures/reducers/select/11/source.json +28 -0
  223. package/test-fixtures/reducers/select/12/base.json +24 -0
  224. package/test-fixtures/reducers/select/12/merged.json +28 -0
  225. package/test-fixtures/reducers/select/12/metadata.json +5 -0
  226. package/test-fixtures/reducers/select/12/source.json +28 -0
  227. package/test-fixtures/reducers/select/13/base.json +28 -0
  228. package/test-fixtures/reducers/select/13/merged.json +28 -0
  229. package/test-fixtures/reducers/select/13/metadata.json +4 -0
  230. package/test-fixtures/reducers/select/13/source.json +24 -0
  231. package/test-fixtures/reducers/select/14/base.json +24 -0
  232. package/test-fixtures/reducers/select/14/merged.json +24 -0
  233. package/test-fixtures/reducers/select/14/metadata.json +4 -0
  234. package/test-fixtures/reducers/select/14/source.json +24 -0
  235. package/.editorconfig +0 -10
  236. package/.istanbul.yml +0 -6
  237. package/.jshintignore +0 -2
  238. package/.jshintrc +0 -3
  239. package/.travis.yml +0 -16
  240. package/LICENSE.txt +0 -661
  241. package/karma.conf.js +0 -39
  242. package/lib/main.js +0 -1215
  243. package/resources/action-copy-options-schema.json +0 -81
  244. package/resources/action-select-better-options-schema.json +0 -34
  245. package/resources/configuration-schema.json +0 -46
  246. package/test/browser/main.spec.js +0 -96
  247. package/test/nodejs/main.spec.js +0 -71
  248. package/test/suites/74.json +0 -10
  249. package/test/suites/config/1to3.json +0 -10
  250. package/test/suites/config/27to28.json +0 -10
  251. package/test/suites/config/29to31.json +0 -10
  252. package/test/suites/config/32to40.json +0 -16
  253. package/test/suites/config/41to43.json +0 -10
  254. package/test/suites/config/44to56.json +0 -15
  255. package/test/suites/config/4to26.json +0 -81
  256. package/test/suites/config/57to63.json +0 -63
  257. package/test/suites/config/64.json +0 -7
  258. package/test/suites/config/65.json +0 -19
  259. package/test/suites/config/66.json +0 -13
  260. package/test/suites/config/67.json +0 -14
  261. package/test/suites/config/68.json +0 -12
  262. package/test/suites/config/69.json +0 -12
  263. package/test/suites/config/70.json +0 -13
  264. package/test/suites/config/71.json +0 -10
  265. package/test/suites/config/72.json +0 -12
  266. package/test/suites/config/73.json +0 -10
  267. package/test/suites/config/76.json +0 -13
  268. package/test/suites/config/77.json +0 -11
  269. package/test/suites/config/78to79.json +0 -12
  270. package/test/suites/config/80to81.json +0 -12
  271. package/test/suites/config/82.json +0 -10
  272. package/test/suites/config/83to85.json +0 -15
  273. package/test/suites/config/86.json +0 -16
  274. package/test/suites/config/87.json +0 -15
  275. package/test/suites/config/88.json +0 -16
  276. package/test/suites/data/1/merged +0 -3
  277. package/test/suites/data/1/other +0 -3
  278. package/test/suites/data/1/preferred +0 -2
  279. package/test/suites/data/10/descr +0 -1
  280. package/test/suites/data/10/merged +0 -2
  281. package/test/suites/data/10/other +0 -2
  282. package/test/suites/data/10/preferred +0 -2
  283. package/test/suites/data/11/descr +0 -1
  284. package/test/suites/data/11/merged +0 -2
  285. package/test/suites/data/11/other +0 -2
  286. package/test/suites/data/11/preferred +0 -2
  287. package/test/suites/data/12/descr +0 -1
  288. package/test/suites/data/12/merged +0 -2
  289. package/test/suites/data/12/other +0 -2
  290. package/test/suites/data/12/preferred +0 -2
  291. package/test/suites/data/13/descr +0 -1
  292. package/test/suites/data/13/merged +0 -3
  293. package/test/suites/data/13/other +0 -2
  294. package/test/suites/data/13/preferred +0 -3
  295. package/test/suites/data/14/descr +0 -1
  296. package/test/suites/data/14/merged +0 -2
  297. package/test/suites/data/14/other +0 -2
  298. package/test/suites/data/14/preferred +0 -2
  299. package/test/suites/data/15/descr +0 -1
  300. package/test/suites/data/15/merged +0 -2
  301. package/test/suites/data/15/other +0 -2
  302. package/test/suites/data/15/preferred +0 -2
  303. package/test/suites/data/16/descr +0 -1
  304. package/test/suites/data/16/merged +0 -2
  305. package/test/suites/data/16/other +0 -2
  306. package/test/suites/data/16/preferred +0 -2
  307. package/test/suites/data/17/descr +0 -1
  308. package/test/suites/data/17/merged +0 -2
  309. package/test/suites/data/17/other +0 -2
  310. package/test/suites/data/17/preferred +0 -2
  311. package/test/suites/data/18/descr +0 -1
  312. package/test/suites/data/18/merged +0 -2
  313. package/test/suites/data/18/other +0 -2
  314. package/test/suites/data/18/preferred +0 -2
  315. package/test/suites/data/19/descr +0 -1
  316. package/test/suites/data/19/merged +0 -2
  317. package/test/suites/data/19/other +0 -2
  318. package/test/suites/data/19/preferred +0 -2
  319. package/test/suites/data/2/merged +0 -3
  320. package/test/suites/data/2/other +0 -2
  321. package/test/suites/data/2/preferred +0 -3
  322. package/test/suites/data/20/descr +0 -1
  323. package/test/suites/data/20/merged +0 -3
  324. package/test/suites/data/20/other +0 -2
  325. package/test/suites/data/20/preferred +0 -2
  326. package/test/suites/data/21/descr +0 -1
  327. package/test/suites/data/21/merged +0 -4
  328. package/test/suites/data/21/other +0 -4
  329. package/test/suites/data/21/preferred +0 -3
  330. package/test/suites/data/22/descr +0 -1
  331. package/test/suites/data/22/merged +0 -10
  332. package/test/suites/data/22/other +0 -7
  333. package/test/suites/data/22/preferred +0 -10
  334. package/test/suites/data/23/descr +0 -1
  335. package/test/suites/data/23/merged +0 -2
  336. package/test/suites/data/23/other +0 -2
  337. package/test/suites/data/23/preferred +0 -2
  338. package/test/suites/data/24/descr +0 -1
  339. package/test/suites/data/24/merged +0 -2
  340. package/test/suites/data/24/other +0 -2
  341. package/test/suites/data/24/preferred +0 -2
  342. package/test/suites/data/25/descr +0 -1
  343. package/test/suites/data/25/merged +0 -2
  344. package/test/suites/data/25/other +0 -2
  345. package/test/suites/data/25/preferred +0 -2
  346. package/test/suites/data/26/descr +0 -1
  347. package/test/suites/data/26/merged +0 -3
  348. package/test/suites/data/26/other +0 -3
  349. package/test/suites/data/26/preferred +0 -3
  350. package/test/suites/data/27/merged +0 -3
  351. package/test/suites/data/27/other +0 -2
  352. package/test/suites/data/27/preferred +0 -2
  353. package/test/suites/data/28/merged +0 -3
  354. package/test/suites/data/28/other +0 -2
  355. package/test/suites/data/28/preferred +0 -2
  356. package/test/suites/data/29/merged +0 -2
  357. package/test/suites/data/29/other +0 -2
  358. package/test/suites/data/29/preferred +0 -2
  359. package/test/suites/data/3/merged +0 -3
  360. package/test/suites/data/3/other +0 -3
  361. package/test/suites/data/3/preferred +0 -3
  362. package/test/suites/data/30/merged +0 -3
  363. package/test/suites/data/30/other +0 -2
  364. package/test/suites/data/30/preferred +0 -2
  365. package/test/suites/data/31/merged +0 -3
  366. package/test/suites/data/31/other +0 -2
  367. package/test/suites/data/31/preferred +0 -3
  368. package/test/suites/data/32/other +0 -2
  369. package/test/suites/data/32/preferred +0 -3
  370. package/test/suites/data/33/merged +0 -2
  371. package/test/suites/data/33/other +0 -2
  372. package/test/suites/data/33/preferred +0 -2
  373. package/test/suites/data/34/merged +0 -2
  374. package/test/suites/data/34/other +0 -2
  375. package/test/suites/data/34/preferred +0 -2
  376. package/test/suites/data/35/merged +0 -2
  377. package/test/suites/data/35/other +0 -2
  378. package/test/suites/data/35/preferred +0 -2
  379. package/test/suites/data/36/merged +0 -2
  380. package/test/suites/data/36/other +0 -2
  381. package/test/suites/data/36/preferred +0 -2
  382. package/test/suites/data/37/merged +0 -3
  383. package/test/suites/data/37/other +0 -2
  384. package/test/suites/data/37/preferred +0 -2
  385. package/test/suites/data/38/merged +0 -3
  386. package/test/suites/data/38/other +0 -2
  387. package/test/suites/data/38/preferred +0 -2
  388. package/test/suites/data/39/merged +0 -2
  389. package/test/suites/data/39/other +0 -2
  390. package/test/suites/data/39/preferred +0 -2
  391. package/test/suites/data/4/descr +0 -1
  392. package/test/suites/data/4/merged +0 -2
  393. package/test/suites/data/4/other +0 -2
  394. package/test/suites/data/4/preferred +0 -2
  395. package/test/suites/data/40/merged +0 -2
  396. package/test/suites/data/40/other +0 -2
  397. package/test/suites/data/40/preferred +0 -2
  398. package/test/suites/data/41/merged +0 -2
  399. package/test/suites/data/41/other +0 -2
  400. package/test/suites/data/41/preferred +0 -2
  401. package/test/suites/data/42/merged +0 -2
  402. package/test/suites/data/42/other +0 -2
  403. package/test/suites/data/42/preferred +0 -2
  404. package/test/suites/data/43/merged +0 -2
  405. package/test/suites/data/43/other +0 -2
  406. package/test/suites/data/43/preferred +0 -2
  407. package/test/suites/data/44/merged +0 -2
  408. package/test/suites/data/44/other +0 -2
  409. package/test/suites/data/44/preferred +0 -2
  410. package/test/suites/data/45/merged +0 -2
  411. package/test/suites/data/45/other +0 -2
  412. package/test/suites/data/45/preferred +0 -2
  413. package/test/suites/data/46/merged +0 -2
  414. package/test/suites/data/46/other +0 -2
  415. package/test/suites/data/46/preferred +0 -2
  416. package/test/suites/data/47/merged +0 -2
  417. package/test/suites/data/47/other +0 -2
  418. package/test/suites/data/47/preferred +0 -2
  419. package/test/suites/data/48/merged +0 -2
  420. package/test/suites/data/48/other +0 -2
  421. package/test/suites/data/48/preferred +0 -2
  422. package/test/suites/data/49/merged +0 -3
  423. package/test/suites/data/49/other +0 -2
  424. package/test/suites/data/49/preferred +0 -2
  425. package/test/suites/data/5/descr +0 -1
  426. package/test/suites/data/5/merged +0 -2
  427. package/test/suites/data/5/other +0 -2
  428. package/test/suites/data/5/preferred +0 -2
  429. package/test/suites/data/50/merged +0 -3
  430. package/test/suites/data/50/other +0 -2
  431. package/test/suites/data/50/preferred +0 -2
  432. package/test/suites/data/51/merged +0 -3
  433. package/test/suites/data/51/other +0 -2
  434. package/test/suites/data/51/preferred +0 -2
  435. package/test/suites/data/52/merged +0 -2
  436. package/test/suites/data/52/other +0 -2
  437. package/test/suites/data/52/preferred +0 -2
  438. package/test/suites/data/53/merged +0 -3
  439. package/test/suites/data/53/other +0 -2
  440. package/test/suites/data/53/preferred +0 -2
  441. package/test/suites/data/54/merged +0 -3
  442. package/test/suites/data/54/other +0 -2
  443. package/test/suites/data/54/preferred +0 -2
  444. package/test/suites/data/55/merged +0 -3
  445. package/test/suites/data/55/other +0 -2
  446. package/test/suites/data/55/preferred +0 -2
  447. package/test/suites/data/56/merged +0 -2
  448. package/test/suites/data/56/other +0 -2
  449. package/test/suites/data/56/preferred +0 -2
  450. package/test/suites/data/57/descr +0 -1
  451. package/test/suites/data/57/merged +0 -4
  452. package/test/suites/data/57/other +0 -4
  453. package/test/suites/data/57/preferred +0 -4
  454. package/test/suites/data/58/descr +0 -1
  455. package/test/suites/data/58/merged +0 -2
  456. package/test/suites/data/58/other +0 -2
  457. package/test/suites/data/58/preferred +0 -2
  458. package/test/suites/data/59/descr +0 -1
  459. package/test/suites/data/59/merged +0 -2
  460. package/test/suites/data/59/other +0 -2
  461. package/test/suites/data/59/preferred +0 -2
  462. package/test/suites/data/6/descr +0 -1
  463. package/test/suites/data/6/merged +0 -2
  464. package/test/suites/data/6/other +0 -3
  465. package/test/suites/data/6/preferred +0 -2
  466. package/test/suites/data/60/descr +0 -1
  467. package/test/suites/data/60/merged +0 -2
  468. package/test/suites/data/60/other +0 -2
  469. package/test/suites/data/60/preferred +0 -2
  470. package/test/suites/data/61/descr +0 -1
  471. package/test/suites/data/61/merged +0 -2
  472. package/test/suites/data/61/other +0 -2
  473. package/test/suites/data/61/preferred +0 -2
  474. package/test/suites/data/62/descr +0 -1
  475. package/test/suites/data/62/merged +0 -3
  476. package/test/suites/data/62/other +0 -2
  477. package/test/suites/data/62/preferred +0 -2
  478. package/test/suites/data/63/descr +0 -1
  479. package/test/suites/data/63/merged +0 -3
  480. package/test/suites/data/63/other +0 -2
  481. package/test/suites/data/63/preferred +0 -2
  482. package/test/suites/data/64/merged +0 -2
  483. package/test/suites/data/64/other +0 -2
  484. package/test/suites/data/64/preferred +0 -2
  485. package/test/suites/data/65/merged +0 -3
  486. package/test/suites/data/65/other +0 -2
  487. package/test/suites/data/65/preferred +0 -2
  488. package/test/suites/data/66/merged +0 -2
  489. package/test/suites/data/66/other +0 -2
  490. package/test/suites/data/66/preferred +0 -2
  491. package/test/suites/data/67/merged +0 -2
  492. package/test/suites/data/67/other +0 -2
  493. package/test/suites/data/67/preferred +0 -2
  494. package/test/suites/data/68/merged +0 -2
  495. package/test/suites/data/68/other +0 -2
  496. package/test/suites/data/68/preferred +0 -2
  497. package/test/suites/data/69/merged +0 -2
  498. package/test/suites/data/69/other +0 -2
  499. package/test/suites/data/69/preferred +0 -2
  500. package/test/suites/data/7/descr +0 -1
  501. package/test/suites/data/7/merged +0 -4
  502. package/test/suites/data/7/other +0 -3
  503. package/test/suites/data/7/preferred +0 -3
  504. package/test/suites/data/70/merged +0 -2
  505. package/test/suites/data/70/other +0 -2
  506. package/test/suites/data/70/preferred +0 -2
  507. package/test/suites/data/71/merged +0 -3
  508. package/test/suites/data/71/other +0 -2
  509. package/test/suites/data/71/preferred +0 -2
  510. package/test/suites/data/72/merged +0 -5
  511. package/test/suites/data/72/other +0 -2
  512. package/test/suites/data/72/preferred +0 -4
  513. package/test/suites/data/73/merged +0 -3
  514. package/test/suites/data/73/other +0 -3
  515. package/test/suites/data/73/preferred +0 -3
  516. package/test/suites/data/74/1/merged +0 -3
  517. package/test/suites/data/74/1/other +0 -3
  518. package/test/suites/data/74/1/preferred +0 -2
  519. package/test/suites/data/74/merged +0 -4
  520. package/test/suites/data/74/other +0 -4
  521. package/test/suites/data/74/preferred +0 -2
  522. package/test/suites/data/75/74/1/merged +0 -3
  523. package/test/suites/data/75/74/1/other +0 -3
  524. package/test/suites/data/75/74/1/preferred +0 -2
  525. package/test/suites/data/75/74/merged +0 -4
  526. package/test/suites/data/75/74/other +0 -4
  527. package/test/suites/data/75/74/preferred +0 -2
  528. package/test/suites/data/75/merged +0 -4
  529. package/test/suites/data/75/other +0 -3
  530. package/test/suites/data/75/preferred +0 -2
  531. package/test/suites/data/76/merged +0 -2
  532. package/test/suites/data/76/other +0 -2
  533. package/test/suites/data/76/preferred +0 -2
  534. package/test/suites/data/77/descr +0 -1
  535. package/test/suites/data/77/merged +0 -2
  536. package/test/suites/data/77/other +0 -2
  537. package/test/suites/data/77/preferred +0 -2
  538. package/test/suites/data/78/merged +0 -3
  539. package/test/suites/data/78/other +0 -2
  540. package/test/suites/data/78/preferred +0 -2
  541. package/test/suites/data/79/merged +0 -2
  542. package/test/suites/data/79/other +0 -2
  543. package/test/suites/data/79/preferred +0 -2
  544. package/test/suites/data/8/descr +0 -1
  545. package/test/suites/data/8/merged +0 -3
  546. package/test/suites/data/8/other +0 -3
  547. package/test/suites/data/8/preferred +0 -3
  548. package/test/suites/data/80/merged +0 -3
  549. package/test/suites/data/80/other +0 -2
  550. package/test/suites/data/80/preferred +0 -2
  551. package/test/suites/data/81/merged +0 -2
  552. package/test/suites/data/81/other +0 -2
  553. package/test/suites/data/81/preferred +0 -2
  554. package/test/suites/data/82/merged +0 -2
  555. package/test/suites/data/82/other +0 -2
  556. package/test/suites/data/82/preferred +0 -2
  557. package/test/suites/data/83/merged +0 -2
  558. package/test/suites/data/83/other +0 -2
  559. package/test/suites/data/83/preferred +0 -1
  560. package/test/suites/data/84/merged +0 -2
  561. package/test/suites/data/84/other +0 -2
  562. package/test/suites/data/84/preferred +0 -1
  563. package/test/suites/data/85/merged +0 -2
  564. package/test/suites/data/85/other +0 -2
  565. package/test/suites/data/85/preferred +0 -2
  566. package/test/suites/data/86/merged +0 -2
  567. package/test/suites/data/86/other +0 -2
  568. package/test/suites/data/86/preferred +0 -1
  569. package/test/suites/data/87/merged +0 -2
  570. package/test/suites/data/87/other +0 -2
  571. package/test/suites/data/87/preferred +0 -1
  572. package/test/suites/data/88/merged +0 -2
  573. package/test/suites/data/88/other +0 -2
  574. package/test/suites/data/88/preferred +0 -1
  575. package/test/suites/data/9/descr +0 -1
  576. package/test/suites/data/9/merged +0 -2
  577. package/test/suites/data/9/other +0 -2
  578. package/test/suites/data/9/preferred +0 -2
  579. package/test/test.js +0 -1001
@@ -0,0 +1,9 @@
1
+ # With this line @NatLibFi/melinda-js-lead owns any files in the /.github/
2
+ # directory at the root of the repository and any of its
3
+ # subdirectories.
4
+ /.github/ @NatLibFi/melinda-js-lead
5
+
6
+ # With this line @NatLibFi/melinda-js-lead owns any files in the /src/
7
+ # directory at the root of the repository and any of its
8
+ # subdirectories.
9
+ /src/ @NatLibFi/melinda-js-lead
@@ -0,0 +1,41 @@
1
+ # NatLibFi/Melinda maintenance strategy
2
+ # https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3
+
4
+ version: 2
5
+ updates:
6
+ # Maintain dependencies for GitHub Actions
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
11
+ time: "06:30"
12
+ timezone: "Europe/Helsinki"
13
+
14
+
15
+ # Minor updates to npm production dependencies daily
16
+ - package-ecosystem: "npm"
17
+ directory: "/"
18
+ schedule:
19
+ interval: "daily"
20
+ time: "06:45"
21
+ timezone: "Europe/Helsinki"
22
+ versioning-strategy: lockfile-only
23
+ labels:
24
+ - "npm minor dependencies"
25
+ allow:
26
+ - dependency-type: "production"
27
+
28
+ # Major updates to npm dependencies weekly @tuesday
29
+ # Not possible yet https://github.com/dependabot/dependabot-core/issues/1778
30
+ # - package-ecosystem: "npm"
31
+ # directory: "/"
32
+ # schedule:
33
+ # interval: "weekly"
34
+ # day: "tuesday"
35
+ # time: "07:00"
36
+ # timezone: "Europe/Helsinki"
37
+ # versioning-strategy: increase-if-necessary
38
+ # labels:
39
+ # - "npm major dependencies"
40
+ # reviewers:
41
+ # - "natlibfi/melinda-js-lead"
@@ -0,0 +1,60 @@
1
+ # Melinda node tests
2
+
3
+ name: Melinda node tests
4
+
5
+ on: push
6
+
7
+ jobs:
8
+ build-node-versions:
9
+ name: Node version matrix
10
+ runs-on: ubuntu-latest
11
+
12
+ strategy:
13
+ matrix:
14
+ node-version: [14.x, 16.x, 18.x]
15
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
16
+
17
+ steps:
18
+ - name: Checkout the code
19
+ uses: actions/checkout@v3
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v2
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+ env:
26
+ NPM_CONFIG_IGNORE_SCRIPTS: true
27
+ - run: npm audit --package-lock-only --production --audit-level=moderate
28
+ - run: npm ci
29
+ - run: npm test
30
+ - run: npm run build --if-present
31
+
32
+ njsscan:
33
+ name: Njsscan check
34
+ runs-on: ubuntu-latest
35
+
36
+ steps:
37
+ - name: Checkout the code
38
+ uses: actions/checkout@v3
39
+ - name: nodejsscan scan
40
+ id: njsscan
41
+ uses: ajinabraham/njsscan-action@master
42
+ with:
43
+ args: '.'
44
+
45
+ publish:
46
+ runs-on: ubuntu-latest
47
+ needs: [build-node-versions, njsscan]
48
+ if: contains(github.ref, 'refs/tags/')
49
+
50
+ steps:
51
+ - uses: actions/checkout@v3
52
+ # Setup .npmrc file to publish to npm
53
+ - uses: actions/setup-node@v3
54
+ with:
55
+ node-version: '14.x'
56
+ registry-url: 'https://registry.npmjs.org'
57
+ - run: npm ci
58
+ - run: npm publish
59
+ env:
60
+ NODE_AUTH_TOKEN: ${{ secrets.MARC_RECORD_MERGE_JS_NPM_TOKEN }}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-current University of Helsinki (National Library of Finland)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,283 +1,131 @@
1
- # MARC record merge [![NPM Version](https://img.shields.io/npm/v/@natlibfi/marc-record-merge.svg)](https://npmjs.org/package/marc-record-merge) [![Build Status](https://travis-ci.org/NatLibFi/marc-record-merge.svg)](https://travis-ci.org/NatLibFi/marc-record-merge) [![Test Coverage](https://codeclimate.com/github/NatLibFi/marc-record-merge/badges/coverage.svg)](https://codeclimate.com/github/NatLibFi/marc-record-merge/coverage)
1
+ # Merge MARC records [![NPM Version](https://img.shields.io/npm/v/@natlibfi/marc-record-merge.svg)](https://npmjs.org/package/@natlibfi/marc-record-merge)
2
2
 
3
- A configurable Javascript module for merging [MARC](https://en.wikipedia.org/wiki/MARC_standards) records.
3
+ Merge MARC records
4
4
 
5
- ## Installation
5
+ ## Usage
6
+ ### COPY
6
7
 
7
- Clone the sources and install the package (In the source directory) on command line using `npm`:
8
+ Chosing fields for reducer:
9
+ ```
10
+ const copyReducerConfigs = [
11
+ {tagPattern: /010/u},
12
+ {tagPattern: /010|020/u},
13
+ {tagPattern: new RegExp('010', 'u')},
14
+ {tagPattern: new RegExp(String((/^(?<tags1>010|020$)/u').source))},
15
+ ]
16
+ ```
8
17
 
9
- ```sh
10
- npm install
18
+ ### compareTagsOnly (Defaults false)
19
+ ```
20
+ {tagPattern: /010/u, compareTagsOnly: false}
11
21
  ```
12
22
 
13
- ## Testing
23
+ If base has field with that tag source field is ignored
24
+
25
+ ### doNotCopyIfFieldPresent (Defaults false)
26
+ ```
27
+ {tagPattern: /010/u, doNotCopyIfFieldPresent: "^011$"}
28
+ ```
14
29
 
15
- Run the following NPM script to lint, test and check coverage of the code:
30
+ If base has field with that tag 011 source field is ignored
16
31
 
17
- ```javascript
32
+ ### compareWithoutIndicators (Defaults false)
33
+ ```
34
+ {tagPattern: /010/u, compareWithoutIndicators: false}
35
+ ```
18
36
 
19
- npm run check
37
+ When base and source fields are compared, indicator differences are ignored
20
38
 
39
+ ### compareWithoutTag (Defaults false)
40
+ ```
41
+ {tagPattern: /^(100|700)$/u, compareWithoutTag: false}
42
+ {tagPattern: /^(100|700)$/u, compareWithoutTag: false, swapTag: [{"from": "^100$", "to": "700"}]}
21
43
  ```
22
44
 
23
- To run browser test run following npm commands:
45
+ When base and source fields are compared, tag differences are ignored
24
46
 
47
+ ### subfieldsMustBeIdentical (Defaults true)
25
48
  ```
26
- npm install karma-phantomjs-launcher
27
- npm run test-browser
49
+ {tagPattern: /010/u, subfieldsMustBeIdentical: true}
28
50
  ```
29
51
 
30
- ## Usage
52
+ If source subfields are subset of base subfields this option says if it is copied
53
+ | subfieldsMustBeIdentical | base | source | copy |
54
+ |--------------------------|---------------|---------------|-------|
55
+ | true or false | $a foo | $a foo | false |
56
+ | true or false | $a foo | $b bar | true |
57
+ | true | $a foo | $a foo,$b bar | true |
58
+ | false | $a foo | $a foo,$b bar | true |
59
+ | true | $a foo,$b bar | $a foo | true |
60
+ | false | $a foo,$b bar | $a foo | false |
61
+
62
+ ### excludeSubfields (Defaults [ ])
63
+ ```
64
+ {tagPattern: /010/u, excludeSubfields: ['a']}
65
+ ```
31
66
 
32
- The module returns a factory function that takes configuration object as the first (mandatory) argument. The second argument (optional) is an object specifying plugin functions. The factory returns a function that takes two MARC records (Instances of [marc-record-js](https://github.com/petuomin/marc-record-js)) as arguments. The first one is the preferred record which will be used as a base records (All fields are taken from this record unless otherwise specified).
67
+ When base and source fields are compared, excluded subfields are ignored
33
68
 
34
- ### Node.js
35
- ```js
36
- var mergeRecords = require('marc-record-merge')(config),
37
- record_merged = mergeRecords(record_preferred, record_other);
69
+ ### swapTag (Defaults [ ])
70
+ ```
71
+ {tagPattern: /^100$/u, swapTag: [{"from": "^100$", "to": "700"}]}
72
+ {tagPattern: /^(100|700)$/u, compareWithoutTag: false, swapTag: [{"from": "^100$", "to": "700"}]}
38
73
  ```
39
74
 
40
- ### AMD
41
- ```js
42
- define(['marc-record-merge'], function(mergeFactory) {
75
+ When fields are copied, tags are swapped. From is Regexp filter and to is string value.
43
76
 
44
- var mergeRecords = mergeFactory(config),
45
- record_merged = mergeRecords(record_preferred, record_other);
77
+ ### swapSubfieldCode (Defaults [ ])
78
+ ```
79
+ {tagPattern: /010/u, swapSubfieldCode: [{"from": "a", "to": "b"}]}
80
+ ```
46
81
 
47
- });
82
+ When source fields are copied, subfields are checkked and if subfield.code match to 'from' value is that code swapped to 'to' value
83
+
84
+ ### dropSubfields (Defaults [ ])
85
+ ```
86
+ {tagPattern: /010/u, dropSubfields: [{"code": "9"}]}
48
87
  ```
88
+ Drops subfields 9's from all fields tagged 010
49
89
 
50
- ### Browser globals
51
- ```js
52
- var mergeRecords = mergeMarcRecordsFactory(config),
53
- record_merged = mergeRecords(record_preferred, record_other);
54
90
  ```
91
+ {tagPattern: /010/u, dropSubfields: [{"code": "9", "value": "FENNI<KEEP>"}]}
92
+ ```
93
+ Drops subfields 9's that have "FENNI<KEEP>" from all fields tagged 010
55
94
 
56
- ## Configuration
57
-
58
- The configuration object is a document conforming to the [schema](https://github.com/natlibfi/marc-record-merge/blob/master/resources/configuration-schema.json). The document looks like this:
59
-
60
- ```js
61
- {
62
- "fields": {
63
- "005": {
64
- "action": "controlfield"
65
- },
66
- "008": {
67
- "action": "mergeControlfield",
68
- "options": {
69
- "actions": [
70
- {
71
- "formats": ["BK", "CF", "CR", "MU", "MX", "VM", "MP"],
72
- "range": [15, 17],
73
- "significantCaret": false,
74
- "type": "selectNonEmpty"
75
- },
76
- {
77
- "formats": ["BK", "CF", "CR", "MU", "MX", "VM", "MP"],
78
- "range": [35, 37],
79
- "significantCaret": false,
80
- "type": "selectNonEmpty"
81
- },
82
- {
83
- "formats": ["BK"],
84
- "range": [18, 21],
85
- "significantCaret": true,
86
- "type": "combine"
87
- },
88
- {
89
- "formats": ["BK"],
90
- "range": [29, 29],
91
- "significantCaret": false,
92
- "type": "selectNonEmpty"
93
- }
94
- ]
95
- }
96
- },
97
- "7..": {
98
- "action": "copy",
99
- "options": {
100
- "compareWithoutIndicators": true
101
- }
102
- },
103
-
104
-
105
- }
106
- }
107
95
 
108
96
  ```
109
-
110
- Each property of **fields** is a MARC field name or pattern (*..5*, *700*). The value of the **field** property is an object which must contain a **action** property. Action-specific options are defined in **options** property.
111
-
112
- The specified action is executed for each field in the other record that matches the field tag pattern.
113
-
114
- ### Predefined actions
115
-
116
- **controlfield**: Copy missing control fields from the other record.
117
-
118
- **mergeControlfield**: Merge controlfields. The rules are set using options:
119
- - _**formats**_: Array of formats to apply the rule. Available formats: `["BK", "CF", "CR", "MU", "MX", "VM", "MP"]`
120
- - _**range**_: character range of the controlfield fragment (start, end). One character range requires same number in both.
121
- - _**significantCaret**_: whether the ^ is significant or not.
122
- - _**type**_: either `combine` or `selectNonEmpty`. `selectNonEmpty` selects value from preferred, or if it's missing the from other. `combine` merges and sorts values from both fragments.
123
-
124
- **copy**: Copy fields from other record. The following options are supported:
125
-
126
- - _**mustBeIdentical**_: A boolean determing whether all subfields must be identical
127
- - _**compareWithoutIndicators**_: A boolean determing whether field indicators must be identical
128
- - _**compareWithout**_: An array of subfield codes. These subfields are filtered out from the comparison
129
- - _**compareSubfieldsNormalized**_: A boolean determing whether the subfields included in _compareWithout_ should be compared as normalized
130
- - _**combine**_: An array of subfields codes. These subfields will be combined into a single subfield
131
- - _**dropOriginal**_: Drop matching original field taken from preferred record.
132
- - _**copyIf/copyUnless**_: Object with subfields as keys containing conditions for copying. Each condition are defined as follows:
133
- - _**value**_: Required value for subfield
134
- - _**comparator**_: A subfield comparator function name
135
- - _**pick**_: Include subfields from the field that is not preserved.
136
- - _**subfields**_: An array of subfield codes (*Mandatory*)
137
- - _**missingOnly**_: A boolean determing whether only subfields missing from the target field should be picked
138
- - _**reduce**_: Drop defined subfield from other record
139
- - _**subfields**_: An array of subfield codes (*Mandatory*)
140
- - _**condition**_: Condition used to determine if field should be dropped. If undefined drops all subfields of type. Possible values _if_ and _unless_.
141
- - _**value**_: Value for comparison. Can be regular expression if exact is option is not set.
142
- - _**exact**_: If set requires subfield value match exactly. Defaults to false.
143
- - _**transformOnInequality**_: An object describing how to transform an inequal field. For this option to take effect the preferred record must have at least one field with the same tag name as the other record. The following properties are supported:
144
- - _**tag**_: Tag name of the new field (*Mandatory*)
145
- - _**drop**_: An array of subfields codes. These subfields are not included in the new field.
146
- - _**add**_: An object with subfield codes as keys and subfield values as values.
147
- - _**map**_: An object with new subfield codes as keys and the old subfield codes as values.
148
-
149
- The action copies only fields that have no match in the preferred record:
150
-
151
- 1. Attempt to find a corresponding field from preferred record
152
- 1. Attempt to find an identical field (All options are applied to comparison)
153
- - [Normalize fields](#field-normalization)
154
- - Tag names must be identical
155
- - Indicators must be identical
156
- - Values must be identical
157
- 1. Variable fields: Each subfield must have a matching subfield in the opposite record (Code and value identical).
158
- 1. Control fields: The values must be identical
159
- 1. Attempt to find a similar field if an identical field was not found (All options are applied to comparison)
160
- - [Normalize fields](#field-normalization)
161
- - Tag names must be identical
162
- - Indicators must be identical
163
- - Values comparison
164
- 1. Variable fields: Either field's subfields must be a subset of the opposite subfields (There is a match for all of the opposite field's subfields)
165
- 1. Control fields: The values must be identical
166
- 1. Copy or do nothing
167
- 1. No corresponding field was found
168
- 1. If no fields in the preferred record with the same tag name were found, copy the field
169
- 1. If fields with the same tag were found and option *transformOnInequality* is enabled, copy the other field using the specified transformations. Otherwise do nothing.
170
-
171
- 1. Corresponding field was found. Check if the other field is deemed different and should be copied to the merged record (All options are applied to comparison)
172
- 1. [Normalize fields](#field-normalization)
173
- 1. Check if the other field is a "proper" subset of the preferred field (Preferred field contains all of the other field's subfields and more)
174
- 1. If it is, copy the field
175
- 1. If it's not, keep the preferred field
176
- 1. In both cases, merge the subfields that were not included in comparison by removing identical subfields
177
-
178
- **selectBetter**: Selects the **"better"** of the two fields of each record. Cannot be used if the tag has multiple fields. The following options are supported:
179
-
180
- - _**requireFieldInBoth**_: A boolean determing whether the field must exist in both records to make changes
181
- - _**onlyIfMissing**_: A boolean determing whether the field will be selected from the other record only if it missing from preferred record
182
- - _**skipOnMultiple**_: A boolean determing whether to skip the action (And keep the preferred fields) if the are multiple fields of the same tag. Default behavior is to fail the processing
183
- - _**pick**_: Include subfields from the field that is not preserved.
184
- - _**subfields**_: An array of subfield codes (*Mandatory*)
185
- - _**missingOnly**_: A boolean determing whether only subfields missing from the target field should be picked
186
- - _**comparator**_: A subfield comparator function name
187
-
188
- The better field is selected as follows:
189
-
190
- 1. [Normalize fields](#field-normalization)
191
- 1. Check if both fields' subfields are considered equal (Using the comparator function)
192
- 1. If equal, select the field that gets the most points (Fields get points for each subfield that has more characters than the corresponding subfield in the opposite field)
193
- 1. If not equal, check if the other field is a "proper" subset of the preferred field (Preferred field contains all of the other field's subfields and more)
194
- 1. If the other field is a subset of the preferred field, select the other field
195
- 1. Otherwise select the preferred field
196
-
197
- **createFrom**: Creates new field based on field other record. The following options are supported:
198
- - _**convertTag**_: Converts field tag to another.
199
- - _**ind[1-2]**_: Converts indicator in created field.
200
- - _**skipIfExists**_: Skip creating new field if target field is found in preferred.
201
- - _**useExisting**_: Use existing field from preferred as base copying all subrecords.
202
- - _**keepExisting**_: Keep existing field from preferred and create new field.
203
- - _**subfields**_: Object of subfields as keys to be included in created field. Each subfield object can have following properties:
204
- - _**convertCode**_: Converts subfield code to another.
205
- - _**convertValue**_: Converts value to another.
206
- - _**append**_: Append value to existing subfield. If subfield does not exists create as new.
207
- - _**replace**_: Replace existing subfield.
208
- - _**modifications**_: Array of modifications for value. Can be either function or following object:
209
- - _**type**_: Type of operation. Possible values are: _copy_, _replace_, _wrap_, _prepend_, _append_
210
- - _**args**_: Array of arguments for operation
211
-
212
- If subfield object is empty subfield is copied as is.
213
-
214
- ## Field normalization
215
-
216
- Field values (Variable field subfields or control field value) are normalized as follows:
217
-
218
- 1. String is converted to lower case
219
- 1. Punctuation (See the function _**removePunctuation**_ in [lib/main.js](https://github.com/NatLibFi/marc-record-merge/blob/master/lib/main.js) for the characters replaced) is replaced with whitespace. The resulting string is trimmed (Whitespace removed from both ends) and subsequent whitespace is reduced to single whitespace.
220
- 1. Diacritics are replaced with their corresponding ASCII characters (See the variable __*DIACRITICS_REMOVAL_MAP*__ in [lib/main.js](https://github.com/NatLibFi/marc-record-merge/blob/master/lib/main.js) for mapping)
221
-
222
- ## Predefined comparators
223
-
224
- - **substring**: Require both subfields to have equal codes and that at least one value is a substring of the other subfield's value
225
- - **equality**: Require both subfields to have stricly equal codes and values
226
-
227
- ### Plugins
228
-
229
- The second argument to the factory function is a optional object specifying plugin functions. The object can have one or both of the following properties:
230
-
231
- #### actions
232
-
233
- An object with action names as keys and functions as values. The action is a function which alters the merged record. It has the following signature:
234
-
235
- ```js
236
- function (record_merge, field_other, options, return_details) {}
97
+ {tagPattern: /010/u, dropSubfields: [{"code": "9", "condition": "unless", "value": "^FENNI<(?<option>KEEP|DROP)>$"}]}
237
98
  ```
238
- **Parameters:**
239
- - *record_merge*: The merged record which is to be modified (Based on the preferred record)
240
- - *field_other*: The field from the other record which is the subject of the action
241
- - *options*: Action specific options
242
- - *return_details*: If this is defined, return action specific details about processing
99
+ Drops all subfield 9's unless they have "FENNI<KEEP>" or "FENNI<DROP>" from all fields tagged 010
243
100
 
244
- The function's return value is not used unless *return_detail* is defined.
245
101
 
246
- #### comparators
102
+ When comparing or copying field dropped fields are ignored
247
103
 
248
- An object with comparator names as keys and functions as values. The comparator is a function which returns a boolean denoting whether two subfields are deemed equal. It has the following signature:
104
+ ### copyUnless (Defaults [ ])
105
+ ```
106
+ {tagPattern: /010/u, copyUnless: [{"code": "9", "value": "FENNI<KEEP>"}]}
107
+ ```
108
+
109
+ When field is otherwise ok to be copied, if it contains given subfield whole field is ignored
249
110
 
250
- ```js
251
- function (subfield1, subfield2) {}
111
+ ### baseValidators (Defaults {subfieldValues: false})
112
+ ```
113
+ {tagPattern: /010/u, baseValidators: {fields: true, subfields: true, subfieldValues: true}}
252
114
  ```
253
115
 
254
- ### Sorting
255
-
256
- By default, new fields are added after the similar fields. This can be changed with the **sort** property:
257
-
258
- ```js
259
- {
260
- "fields": {
261
- "020": {
262
- "action": "copy"
263
- }
264
- },
265
- "sort": {
266
- "insert": "before",
267
- "indexes": {
268
- "CAT": 995
269
- }
270
- }
271
- }
116
+ Marc record validators for base record while reducer is working.
117
+ More info can be read here: https://github.com/NatLibFi/marc-record-js
118
+
119
+ ### sourceValidators (Defaults {subfieldValues: false})
120
+ ```
121
+ {tagPattern: /010/u, sourceValidators: {fields: true, subfields: true, subfieldValues: true}}
272
122
  ```
273
123
 
274
- ### Properties
275
- - **insert**: Defines whether new fields are inserted before or after similar fields. Defaults to *after*.
276
- - **indexes**: An object with field tag patterns as keys and static sort indexes as values. By default, new fields are inserted by the tag's numeric index (If similar fields don't exist)
124
+ Marc record validators for source record while reducer is working.
125
+ More info can be read here: https://github.com/NatLibFi/marc-record-js
277
126
 
278
127
  ## License and copyright
279
128
 
280
- Copyright (c) 2015-2017 **University Of Helsinki (The National Library Of Finland)**
281
-
129
+ Copyright (c) 2020-2022 **University Of Helsinki (The National Library Of Finland)**
282
130
 
283
- This project's source code is licensed under the terms of **GNU Affero General Public License Version 3**.
131
+ This project's source code is licensed under the terms of **MIT** or any later version.
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Reducers", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _reducers.default;
10
+ }
11
+ });
12
+ exports.default = void 0;
13
+ var _reducers = _interopRequireDefault(require("./reducers"));
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ // export default ({base, source, reducers}) => reducers.reduce((base, reducer) => reducer(base, source), base);
16
+ // NV: Modified the reducer loop so, that not only base, but also is carried back.
17
+ // However, we try to be backward-compatible: normally after the reducers, only base is returned.
18
+ var _default = ({
19
+ base,
20
+ source,
21
+ reducers
22
+ }) => {
23
+ const combo = {
24
+ base,
25
+ source
26
+ }; // eslint-disable-line functional/no-let
27
+
28
+ reducers.reduce((combo, reducer) => {
29
+ combo = singleRound(reducer, combo.base, combo.source); // eslint-disable-line no-param-reassign
30
+
31
+ return combo;
32
+ }, combo);
33
+
34
+ // Hack to make my melinda-marc-record-merge-reducers single tests that expect both
35
+ // base and source to return them both:
36
+ if (reducers.length === 1 && combo.base && combo.source) {
37
+ return combo;
38
+ }
39
+ // All other tests return just base... Backward (compability) it is!
40
+ return combo.base;
41
+ function singleRound(reducer, base, source) {
42
+ const combo = reducer(base, source);
43
+ if (combo.base !== undefined && combo.source !== undefined) {
44
+ //console.info('NEW STYLE REDUCER RESULT v2'); // eslint-disable-line no-console
45
+ return combo;
46
+ }
47
+ //console.info('OLD SCHOOL REDUCER RESULT v2'); // eslint-disable-line no-console
48
+ return {
49
+ base: combo.base,
50
+ source
51
+ };
52
+ }
53
+ };
54
+ exports.default = _default;
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["base","source","reducers","combo","reduce","reducer","singleRound","length","undefined"],"sources":["../src/index.js"],"sourcesContent":["import Reducers from './reducers';\n\nexport {Reducers};\n// export default ({base, source, reducers}) => reducers.reduce((base, reducer) => reducer(base, source), base);\n\n// NV: Modified the reducer loop so, that not only base, but also is carried back.\n// However, we try to be backward-compatible: normally after the reducers, only base is returned.\nexport default ({base, source, reducers}) => {\n const combo = {base, source}; // eslint-disable-line functional/no-let\n\n reducers.reduce((combo, reducer) => {\n combo = singleRound(reducer, combo.base, combo.source); // eslint-disable-line no-param-reassign\n\n return combo;\n }, combo);\n\n // Hack to make my melinda-marc-record-merge-reducers single tests that expect both\n // base and source to return them both:\n if (reducers.length === 1 && combo.base && combo.source) {\n return combo;\n }\n // All other tests return just base... Backward (compability) it is!\n return combo.base;\n\n function singleRound(reducer, base, source) {\n const combo = reducer(base, source);\n if (combo.base !== undefined && combo.source !== undefined) {\n //console.info('NEW STYLE REDUCER RESULT v2'); // eslint-disable-line no-console\n return combo;\n }\n //console.info('OLD SCHOOL REDUCER RESULT v2'); // eslint-disable-line no-console\n return {base: combo.base, source};\n }\n};\n"],"mappings":";;;;;;;;;;;;AAAA;AAAkC;AAGlC;AAEA;AACA;AAAA,eACe,CAAC;EAACA,IAAI;EAAEC,MAAM;EAAEC;AAAQ,CAAC,KAAK;EAC3C,MAAMC,KAAK,GAAG;IAACH,IAAI;IAAEC;EAAM,CAAC,CAAC,CAAC;;EAE9BC,QAAQ,CAACE,MAAM,CAAC,CAACD,KAAK,EAAEE,OAAO,KAAK;IAClCF,KAAK,GAAGG,WAAW,CAACD,OAAO,EAAEF,KAAK,CAACH,IAAI,EAAEG,KAAK,CAACF,MAAM,CAAC,CAAC,CAAC;;IAExD,OAAOE,KAAK;EACd,CAAC,EAAEA,KAAK,CAAC;;EAET;EACA;EACA,IAAID,QAAQ,CAACK,MAAM,KAAK,CAAC,IAAIJ,KAAK,CAACH,IAAI,IAAIG,KAAK,CAACF,MAAM,EAAE;IACvD,OAAOE,KAAK;EACd;EACA;EACA,OAAOA,KAAK,CAACH,IAAI;EAEjB,SAASM,WAAW,CAACD,OAAO,EAAEL,IAAI,EAAEC,MAAM,EAAE;IAC1C,MAAME,KAAK,GAAGE,OAAO,CAACL,IAAI,EAAEC,MAAM,CAAC;IACnC,IAAIE,KAAK,CAACH,IAAI,KAAKQ,SAAS,IAAIL,KAAK,CAACF,MAAM,KAAKO,SAAS,EAAE;MAC1D;MACA,OAAOL,KAAK;IACd;IACA;IACA,OAAO;MAACH,IAAI,EAAEG,KAAK,CAACH,IAAI;MAAEC;IAAM,CAAC;EACnC;AACF,CAAC;AAAA"}