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

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 (263) 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 +122 -2
  6. package/dist/index.js +56 -42
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.spec.js +59 -0
  9. package/dist/index.spec.js.map +1 -0
  10. package/dist/reducers/copy.js +254 -80
  11. package/dist/reducers/copy.js.map +1 -1
  12. package/dist/reducers/copy.spec.js +57 -72
  13. package/dist/reducers/copy.spec.js.map +1 -1
  14. package/dist/reducers/copy2.spec.js +67 -0
  15. package/dist/reducers/copy2.spec.js.map +1 -0
  16. package/dist/reducers/index.js +13 -24
  17. package/dist/reducers/index.js.map +1 -1
  18. package/dist/reducers/select.js +63 -58
  19. package/dist/reducers/select.js.map +1 -1
  20. package/dist/reducers/select.spec.js +45 -92
  21. package/dist/reducers/select.spec.js.map +1 -1
  22. package/dist/reducers/select2.spec.js +58 -0
  23. package/dist/reducers/select2.spec.js.map +1 -0
  24. package/package.json +33 -32
  25. package/src/index.js +50 -32
  26. package/src/index.spec.js +45 -0
  27. package/src/reducers/copy.js +262 -80
  28. package/src/reducers/copy.spec.js +50 -48
  29. package/src/reducers/copy2.spec.js +55 -0
  30. package/src/reducers/index.js +3 -30
  31. package/src/reducers/select.js +53 -39
  32. package/src/reducers/select.spec.js +41 -56
  33. package/src/reducers/select2.spec.js +49 -0
  34. package/test-fixtures/index/01/base.json +24 -0
  35. package/test-fixtures/index/01/merged.json +24 -0
  36. package/test-fixtures/index/01/metadata.json +8 -0
  37. package/test-fixtures/index/01/source.json +40 -0
  38. package/test-fixtures/index/02/base.json +24 -0
  39. package/test-fixtures/index/02/merged.json +24 -0
  40. package/test-fixtures/index/02/metadata.json +7 -0
  41. package/test-fixtures/index/02/source.json +40 -0
  42. package/test-fixtures/reducers/copy/{01/base.json → 01 - copy/01/base.json } +1 -1
  43. package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/merged.json +0 -0
  44. package/test-fixtures/reducers/copy/01 - copy/01/metadata.json +4 -0
  45. package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/source.json +0 -0
  46. package/test-fixtures/reducers/copy/{02/source.json → 01 - copy/02/base.json} +0 -0
  47. package/test-fixtures/reducers/copy/{02 → 01 - copy/02}/merged.json +0 -0
  48. package/test-fixtures/reducers/copy/01 - copy/02/metadata.json +4 -0
  49. package/test-fixtures/reducers/copy/{02/base.json → 01 - copy/02/source.json } +1 -1
  50. package/test-fixtures/reducers/copy/{03/base.json → 01 - copy/03/base.json } +1 -1
  51. package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/merged.json +0 -0
  52. package/test-fixtures/reducers/copy/01 - copy/03/metadata.json +4 -0
  53. package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/source.json +0 -0
  54. package/test-fixtures/reducers/copy/{05/base.json → 01 - copy/04/base.json } +1 -1
  55. package/test-fixtures/reducers/copy/{04/merged.json → 01 - copy/04/merged.json } +1 -1
  56. package/test-fixtures/reducers/copy/01 - copy/04/metadata.json +4 -0
  57. package/test-fixtures/reducers/copy/{04/source.json → 01 - copy/04/source.json } +1 -1
  58. package/test-fixtures/reducers/copy/{04/base.json → 01 - copy/05/base.json } +1 -1
  59. package/test-fixtures/reducers/copy/01 - copy/05/merged.json +77 -0
  60. package/test-fixtures/reducers/copy/01 - copy/05/metadata.json +4 -0
  61. package/test-fixtures/reducers/copy/01 - copy/05/source.json +62 -0
  62. package/test-fixtures/reducers/copy/01 - copy/06/base.json +24 -0
  63. package/test-fixtures/reducers/copy/01 - copy/06/merged.json +39 -0
  64. package/test-fixtures/reducers/copy/01 - copy/06/metadata.json +4 -0
  65. package/test-fixtures/reducers/copy/01 - copy/06/source.json +24 -0
  66. package/test-fixtures/reducers/copy/01 - copy/07/base.json +39 -0
  67. package/test-fixtures/reducers/copy/01 - copy/07/merged.json +39 -0
  68. package/test-fixtures/reducers/copy/01 - copy/07/metadata.json +5 -0
  69. package/test-fixtures/reducers/copy/01 - copy/07/source.json +24 -0
  70. package/test-fixtures/reducers/copy/01 - copy/08/base.json +28 -0
  71. package/test-fixtures/reducers/copy/01 - copy/08/merged.json +28 -0
  72. package/test-fixtures/reducers/copy/01 - copy/08/metadata.json +4 -0
  73. package/test-fixtures/reducers/copy/01 - copy/08/source.json +24 -0
  74. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/base.json +17 -0
  75. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/merged.json +20 -0
  76. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/metadata.json +6 -0
  77. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/source.json +20 -0
  78. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/base.json +9 -0
  79. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/merged.json +20 -0
  80. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/metadata.json +6 -0
  81. package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/source.json +20 -0
  82. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/base.json +24 -0
  83. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/merged.json +24 -0
  84. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/metadata.json +5 -0
  85. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/source.json +24 -0
  86. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/base.json +24 -0
  87. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/merged.json +100 -0
  88. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/metadata.json +5 -0
  89. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/source.json +100 -0
  90. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/base.json +24 -0
  91. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/merged.json +24 -0
  92. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/metadata.json +5 -0
  93. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/source.json +24 -0
  94. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/base.json +24 -0
  95. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/merged.json +39 -0
  96. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/metadata.json +5 -0
  97. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/source.json +24 -0
  98. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/03/metadata.json +6 -0
  99. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/base.json +20 -0
  100. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/merged.json +31 -0
  101. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/metadata.json +5 -0
  102. package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/source.json +20 -0
  103. package/test-fixtures/reducers/copy/05 - copyUnless/01/base.json +9 -0
  104. package/test-fixtures/reducers/copy/05 - copyUnless/01/merged.json +24 -0
  105. package/test-fixtures/reducers/copy/05 - copyUnless/01/metadata.json +5 -0
  106. package/test-fixtures/reducers/copy/05 - copyUnless/01/source.json +47 -0
  107. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/base.json +24 -0
  108. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/merged.json +39 -0
  109. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/metadata.json +5 -0
  110. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/source.json +24 -0
  111. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/base.json +24 -0
  112. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/merged.json +24 -0
  113. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/metadata.json +5 -0
  114. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/source.json +24 -0
  115. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/base.json +28 -0
  116. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/merged.json +43 -0
  117. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/metadata.json +5 -0
  118. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/source.json +24 -0
  119. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/base.json +28 -0
  120. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/merged.json +28 -0
  121. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/metadata.json +5 -0
  122. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/source.json +24 -0
  123. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/base.json +20 -0
  124. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/merged.json +35 -0
  125. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/metadata.json +5 -0
  126. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/source.json +24 -0
  127. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/base.json +20 -0
  128. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/merged.json +35 -0
  129. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/metadata.json +5 -0
  130. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/source.json +24 -0
  131. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/base.json +39 -0
  132. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/merged.json +39 -0
  133. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/metadata.json +8 -0
  134. package/test-fixtures/reducers/copy/{05/source.json → 07 - excludeSubfields/01/source.json } +1 -1
  135. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/base.json +39 -0
  136. package/test-fixtures/reducers/copy/{05/merged.json → 07 - excludeSubfields/02/merged.json } +5 -5
  137. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/metadata.json +5 -0
  138. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/source.json +43 -0
  139. package/test-fixtures/reducers/copy/08 - dropSubfields/01/base.json +35 -0
  140. package/test-fixtures/reducers/copy/08 - dropSubfields/01/merged.json +54 -0
  141. package/test-fixtures/reducers/copy/08 - dropSubfields/01/metadata.json +5 -0
  142. package/test-fixtures/reducers/copy/08 - dropSubfields/01/source.json +43 -0
  143. package/test-fixtures/reducers/copy/08 - dropSubfields/02/base.json +43 -0
  144. package/test-fixtures/reducers/copy/08 - dropSubfields/02/merged.json +58 -0
  145. package/test-fixtures/reducers/copy/08 - dropSubfields/02/metadata.json +5 -0
  146. package/test-fixtures/reducers/copy/08 - dropSubfields/02/source.json +32 -0
  147. package/test-fixtures/reducers/copy/08 - dropSubfields/03/base.json +43 -0
  148. package/test-fixtures/reducers/copy/08 - dropSubfields/03/merged.json +58 -0
  149. package/test-fixtures/reducers/copy/08 - dropSubfields/03/metadata.json +5 -0
  150. package/test-fixtures/reducers/copy/08 - dropSubfields/03/source.json +32 -0
  151. package/test-fixtures/reducers/copy/08 - dropSubfields/04/base.json +43 -0
  152. package/test-fixtures/reducers/copy/08 - dropSubfields/04/merged.json +43 -0
  153. package/test-fixtures/reducers/copy/08 - dropSubfields/04/metadata.json +5 -0
  154. package/test-fixtures/reducers/copy/08 - dropSubfields/04/source.json +32 -0
  155. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/base.json +9 -0
  156. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/merged.json +20 -0
  157. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/metadata.json +6 -0
  158. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/source.json +20 -0
  159. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/base.json +9 -0
  160. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/merged.json +20 -0
  161. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/metadata.json +6 -0
  162. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/source.json +20 -0
  163. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/base.json +9 -0
  164. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/merged.json +31 -0
  165. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/metadata.json +6 -0
  166. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/source.json +31 -0
  167. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/base.json +9 -0
  168. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/merged.json +42 -0
  169. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/metadata.json +6 -0
  170. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/source.json +42 -0
  171. package/test-fixtures/reducers/copy/10 - swapTag/01/base.json +17 -0
  172. package/test-fixtures/reducers/copy/10 - swapTag/01/merged.json +28 -0
  173. package/test-fixtures/reducers/copy/10 - swapTag/01/metadata.json +6 -0
  174. package/test-fixtures/reducers/copy/10 - swapTag/01/source.json +20 -0
  175. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/base.json +28 -0
  176. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/merged.json +28 -0
  177. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/metadata.json +6 -0
  178. package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/source.json +20 -0
  179. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/base.json +28 -0
  180. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/merged.json +39 -0
  181. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/metadata.json +6 -0
  182. package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/source.json +31 -0
  183. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/base.json +28 -0
  184. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/merged.json +28 -0
  185. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/metadata.json +7 -0
  186. package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/source.json +20 -0
  187. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/base.json +17 -0
  188. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/merged.json +28 -0
  189. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/metadata.json +7 -0
  190. package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/source.json +31 -0
  191. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/base.json +28 -0
  192. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/merged.json +28 -0
  193. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/metadata.json +7 -0
  194. package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/source.json +28 -0
  195. package/test-fixtures/reducers/metadata.json +4 -0
  196. package/test-fixtures/reducers/select/01/metadata.json +5 -0
  197. package/test-fixtures/reducers/select/02/metadata.json +4 -0
  198. package/test-fixtures/reducers/select/03/metadata.json +4 -0
  199. package/test-fixtures/reducers/select/04/metadata.json +5 -0
  200. package/test-fixtures/reducers/select/05/metadata.json +4 -0
  201. package/test-fixtures/reducers/select/06/base.json +4 -0
  202. package/test-fixtures/reducers/select/06/merged.json +4 -0
  203. package/test-fixtures/reducers/select/06/metadata.json +4 -0
  204. package/test-fixtures/reducers/select/06/source.json +4 -0
  205. package/test-fixtures/reducers/select/07/metadata.json +5 -0
  206. package/test-fixtures/reducers/select/08/metadata.json +4 -0
  207. package/test-fixtures/reducers/select/09/metadata.json +4 -0
  208. package/test-fixtures/reducers/select/10/metadata.json +5 -0
  209. package/test-fixtures/reducers/select/11/metadata.json +4 -0
  210. package/test-fixtures/reducers/select/12/metadata.json +5 -0
  211. package/test-fixtures/reducers/select/13/metadata.json +4 -0
  212. package/test-fixtures/reducers/select/14/base.json +24 -0
  213. package/test-fixtures/reducers/select/14/merged.json +24 -0
  214. package/test-fixtures/reducers/select/14/metadata.json +4 -0
  215. package/test-fixtures/reducers/select/14/source.json +24 -0
  216. package/.drone.yml +0 -92
  217. package/.nyc_output/7ecda3cd-9f84-4416-a466-fa1e5889c6a3.json +0 -1
  218. package/.nyc_output/processinfo/7ecda3cd-9f84-4416-a466-fa1e5889c6a3.json +0 -1
  219. package/.nyc_output/processinfo/index.json +0 -1
  220. package/LICENSE.txt +0 -165
  221. package/coverage/base.css +0 -224
  222. package/coverage/block-navigation.js +0 -79
  223. package/coverage/copy.js.html +0 -344
  224. package/coverage/favicon.png +0 -0
  225. package/coverage/index.html +0 -126
  226. package/coverage/lcov-report/base.css +0 -224
  227. package/coverage/lcov-report/block-navigation.js +0 -79
  228. package/coverage/lcov-report/copy.js.html +0 -344
  229. package/coverage/lcov-report/favicon.png +0 -0
  230. package/coverage/lcov-report/index.html +0 -126
  231. package/coverage/lcov-report/prettify.css +0 -1
  232. package/coverage/lcov-report/prettify.js +0 -2
  233. package/coverage/lcov-report/select.js.html +0 -431
  234. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  235. package/coverage/lcov-report/sorter.js +0 -170
  236. package/coverage/lcov.info +0 -195
  237. package/coverage/prettify.css +0 -1
  238. package/coverage/prettify.js +0 -2
  239. package/coverage/select.js.html +0 -431
  240. package/coverage/sort-arrow-sprite.png +0 -0
  241. package/coverage/sorter.js +0 -170
  242. package/test-fixtures/reducers/copy/01/pattern.txt +0 -1
  243. package/test-fixtures/reducers/copy/02/pattern.txt +0 -1
  244. package/test-fixtures/reducers/copy/03/pattern.txt +0 -1
  245. package/test-fixtures/reducers/copy/04/pattern.txt +0 -1
  246. package/test-fixtures/reducers/copy/05/pattern.txt +0 -1
  247. package/test-fixtures/reducers/select/01/expected-error.txt +0 -1
  248. package/test-fixtures/reducers/select/01/pattern.txt +0 -1
  249. package/test-fixtures/reducers/select/02/pattern.txt +0 -1
  250. package/test-fixtures/reducers/select/03/pattern.txt +0 -1
  251. package/test-fixtures/reducers/select/04/pattern.txt +0 -1
  252. package/test-fixtures/reducers/select/05/pattern.txt +0 -1
  253. package/test-fixtures/reducers/select/06/pattern.txt +0 -1
  254. package/test-fixtures/reducers/select/07/equalityFunction.txt +0 -1
  255. package/test-fixtures/reducers/select/07/pattern.txt +0 -1
  256. package/test-fixtures/reducers/select/08/pattern.txt +0 -1
  257. package/test-fixtures/reducers/select/09/pattern.txt +0 -1
  258. package/test-fixtures/reducers/select/10/equalityFunction.txt +0 -1
  259. package/test-fixtures/reducers/select/10/pattern.txt +0 -1
  260. package/test-fixtures/reducers/select/11/pattern.txt +0 -1
  261. package/test-fixtures/reducers/select/12/equalityFunction.txt +0 -1
  262. package/test-fixtures/reducers/select/12/pattern.txt +0 -1
  263. package/test-fixtures/reducers/select/13/pattern.txt +0 -1
@@ -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
@@ -3,9 +3,129 @@
3
3
  Merge MARC records
4
4
 
5
5
  ## Usage
6
+ ### COPY
7
+
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
+ ```
17
+
18
+ ### compareTagsOnly (Defaults false)
19
+ ```
20
+ {tagPattern: /010/u, compareTagsOnly: false}
21
+ ```
22
+
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
+ ```
29
+
30
+ If base has field with that tag 011 source field is ignored
31
+
32
+ ### compareWithoutIndicators (Defaults false)
33
+ ```
34
+ {tagPattern: /010/u, compareWithoutIndicators: false}
35
+ ```
36
+
37
+ When base and source fields are compared, indicator differences are ignored
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"}]}
43
+ ```
44
+
45
+ When base and source fields are compared, tag differences are ignored
46
+
47
+ ### subfieldsMustBeIdentical (Defaults true)
48
+ ```
49
+ {tagPattern: /010/u, subfieldsMustBeIdentical: true}
50
+ ```
51
+
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
+ ```
66
+
67
+ When base and source fields are compared, excluded subfields are ignored
68
+
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"}]}
73
+ ```
74
+
75
+ When fields are copied, tags are swapped. From is Regexp filter and to is string value.
76
+
77
+ ### swapSubfieldCode (Defaults [ ])
78
+ ```
79
+ {tagPattern: /010/u, swapSubfieldCode: [{"from": "a", "to": "b"}]}
80
+ ```
81
+
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"}]}
87
+ ```
88
+ Drops subfields 9's from all fields tagged 010
89
+
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
94
+
95
+
96
+ ```
97
+ {tagPattern: /010/u, dropSubfields: [{"code": "9", "condition": "unless", "value": "^FENNI<(?<option>KEEP|DROP)>$"}]}
98
+ ```
99
+ Drops all subfield 9's unless they have "FENNI<KEEP>" or "FENNI<DROP>" from all fields tagged 010
100
+
101
+
102
+ When comparing or copying field dropped fields are ignored
103
+
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
110
+
111
+ ### baseValidators (Defaults {subfieldValues: false})
112
+ ```
113
+ {tagPattern: /010/u, baseValidators: {fields: true, subfields: true, subfieldValues: true}}
114
+ ```
115
+
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}}
122
+ ```
123
+
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
6
126
 
7
127
  ## License and copyright
8
128
 
9
- Copyright (c) 2017-2019 **University Of Helsinki (The National Library Of Finland)**
129
+ Copyright (c) 2020-2022 **University Of Helsinki (The National Library Of Finland)**
10
130
 
11
- This project's source code is licensed under the terms of **GNU Lesser General Public License Version 3** or any later version.
131
+ This project's source code is licensed under the terms of **MIT** or any later version.
package/dist/index.js CHANGED
@@ -3,54 +3,68 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Reducers = exports.default = void 0;
7
-
8
- var Reducers = _interopRequireWildcard(require("./reducers"));
9
-
10
- exports.Reducers = Reducers;
11
-
12
- var _marcRecord = require("@natlibfi/marc-record");
13
-
14
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
15
-
16
- 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; }
17
-
18
- /**
19
- *
20
- * @licstart The following is the entire license notice for the JavaScript code in this file.
21
- *
22
- * Merge MARC records
23
- *
24
- * Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
25
- *
26
- * This file is part of marc-record-merge-js
27
-
28
- * marc-record-merge-js program is free software: you can redistribute it and/or modify
29
- * it under the terms of the GNU Lesser General Public License as
30
- * published by the Free Software Foundation, either version 3 of the
31
- * License, or (at your option) any later version.
32
- *
33
- * marc-record-merge-js is distributed in the hope that it will be useful,
34
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
35
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36
- * GNU Lesser General Public License for more details.
37
- *
38
- * You should have received a copy of the GNU Lesser General Public License
39
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
40
- *
41
- * @licend The above is the entire license notice
42
- * for the JavaScript code in this file.
43
- *
44
- */
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
+ var _debug = _interopRequireDefault(require("debug"));
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ const debug = (0, _debug.default)('@natlibfi/melinda-marc-record-merge:index');
17
+ const debugData = debug.extend('data');
18
+ // export default ({base, source, reducers}) => reducers.reduce((base, reducer) => reducer(base, source), base);
19
+ // NV: Modified the reducer loop so, that not only base, but also is carried back.
20
+ // However, we try to be backward-compatible: normally after the reducers, only base is returned.
45
21
  var _default = ({
46
22
  base,
47
23
  source,
48
24
  reducers
49
25
  }) => {
50
- const sourceRecord = _marcRecord.MarcRecord.clone(source);
26
+ const combo = {
27
+ base,
28
+ source
29
+ };
30
+ const resultCombo = reducers.reduce((combo, reducer) => {
31
+ const returnCombo = singleRound(reducer, combo.base, combo.source);
32
+ //debugData(`returnCombo after current reducer: ${JSON.stringify(returnCombo)}`);
33
+ return returnCombo;
34
+ }, combo);
35
+ debugData(`ResultCombo after reducers: ${JSON.stringify(resultCombo)}`);
51
36
 
52
- return reducers.reduce((baseRecord, reducer) => reducer(baseRecord, sourceRecord), _marcRecord.MarcRecord.clone(base));
37
+ // Hack to make my melinda-marc-record-merge-reducers single tests that expect both
38
+ // base and source to return them both:
39
+ if (reducers.length === 1 && resultCombo.base && resultCombo.source) {
40
+ debug('Single reducer, returning resultCombo');
41
+ debugData(JSON.stringify(resultCombo));
42
+ return resultCombo;
43
+ }
44
+ // All other tests return just base... Backward (compability) it is!
45
+ debug('Multiple reducers, returning just base');
46
+ debugData(JSON.stringify(resultCombo.base));
47
+ return resultCombo.base;
48
+ function singleRound(reducer, base, source) {
49
+ //debug(`SINGLE ROUND INPUT (base, source)`);
50
+ //debugData(base);
51
+ //debugData(base);
52
+ const reducerResult = reducer(base, source);
53
+ //debug(`reducerResult:`);
54
+ //debugData(reducerResult);
55
+ if (reducerResult.base !== undefined && reducerResult.source !== undefined) {
56
+ debug('NEW STYLE REDUCER RESULT v2');
57
+ const combo = reducerResult;
58
+ //debugData(combo);
59
+ return combo;
60
+ }
61
+ debug('OLD SCHOOL REDUCER RESULT v2');
62
+ //debugData({base: reducerResult, source});
63
+ return {
64
+ base: reducerResult,
65
+ source
66
+ };
67
+ }
53
68
  };
54
-
55
69
  exports.default = _default;
56
70
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["base","source","reducers","sourceRecord","MarcRecord","clone","reduce","baseRecord","reducer"],"mappings":";;;;;;;AA4BA;;;;AACA;;;;;;AA7BA;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgCe,CAAC;AAACA,EAAAA,IAAD;AAAOC,EAAAA,MAAP;AAAeC,EAAAA;AAAf,CAAD,KAA8B;AAC3C,QAAMC,YAAY,GAAGC,uBAAWC,KAAX,CAAiBJ,MAAjB,CAArB;;AACA,SAAOC,QAAQ,CAACI,MAAT,CAAgB,CAACC,UAAD,EAAaC,OAAb,KAAyBA,OAAO,CAACD,UAAD,EAAaJ,YAAb,CAAhD,EAA4EC,uBAAWC,KAAX,CAAiBL,IAAjB,CAA5E,CAAP;AACD,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*/\n\nimport * as Reducers from './reducers';\nimport {MarcRecord} from '@natlibfi/marc-record';\n\nexport {Reducers};\nexport default ({base, source, reducers}) => {\n const sourceRecord = MarcRecord.clone(source);\n return reducers.reduce((baseRecord, reducer) => reducer(baseRecord, sourceRecord), MarcRecord.clone(base));\n};\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["debug","createDebugLogger","debugData","extend","base","source","reducers","combo","resultCombo","reduce","reducer","returnCombo","singleRound","JSON","stringify","length","reducerResult","undefined"],"sources":["../src/index.js"],"sourcesContent":["import Reducers from './reducers';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-marc-record-merge:index');\nconst debugData = debug.extend('data');\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.\n\nexport default ({base, source, reducers}) => {\n\n const combo = {base, source};\n const resultCombo = reducers.reduce((combo, reducer) => {\n const returnCombo = singleRound(reducer, combo.base, combo.source);\n //debugData(`returnCombo after current reducer: ${JSON.stringify(returnCombo)}`);\n return returnCombo;\n }, combo);\n\n debugData(`ResultCombo after reducers: ${JSON.stringify(resultCombo)}`);\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 && resultCombo.base && resultCombo.source) {\n debug('Single reducer, returning resultCombo');\n debugData(JSON.stringify(resultCombo));\n\n return resultCombo;\n }\n // All other tests return just base... Backward (compability) it is!\n debug('Multiple reducers, returning just base');\n debugData(JSON.stringify(resultCombo.base));\n return resultCombo.base;\n\n function singleRound(reducer, base, source) {\n //debug(`SINGLE ROUND INPUT (base, source)`);\n //debugData(base);\n //debugData(base);\n const reducerResult = reducer(base, source);\n //debug(`reducerResult:`);\n //debugData(reducerResult);\n if (reducerResult.base !== undefined && reducerResult.source !== undefined) {\n debug('NEW STYLE REDUCER RESULT v2');\n const combo = reducerResult;\n //debugData(combo);\n return combo;\n }\n debug('OLD SCHOOL REDUCER RESULT v2');\n //debugData({base: reducerResult, source});\n return {base: reducerResult, source};\n }\n};\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAAsC;AAEtC,MAAMA,KAAK,GAAG,IAAAC,cAAiB,EAAC,2CAA2C,CAAC;AAC5E,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;AAGtC;AAEA;AACA;AAAA,eAEe,CAAC;EAACC,IAAI;EAAEC,MAAM;EAAEC;AAAQ,CAAC,KAAK;EAE3C,MAAMC,KAAK,GAAG;IAACH,IAAI;IAAEC;EAAM,CAAC;EAC5B,MAAMG,WAAW,GAAGF,QAAQ,CAACG,MAAM,CAAC,CAACF,KAAK,EAAEG,OAAO,KAAK;IACtD,MAAMC,WAAW,GAAGC,WAAW,CAACF,OAAO,EAAEH,KAAK,CAACH,IAAI,EAAEG,KAAK,CAACF,MAAM,CAAC;IAClE;IACA,OAAOM,WAAW;EACpB,CAAC,EAAEJ,KAAK,CAAC;EAETL,SAAS,CAAE,+BAA8BW,IAAI,CAACC,SAAS,CAACN,WAAW,CAAE,EAAC,CAAC;;EAEvE;EACA;EACA,IAAIF,QAAQ,CAACS,MAAM,KAAK,CAAC,IAAIP,WAAW,CAACJ,IAAI,IAAII,WAAW,CAACH,MAAM,EAAE;IACnEL,KAAK,CAAC,uCAAuC,CAAC;IAC9CE,SAAS,CAACW,IAAI,CAACC,SAAS,CAACN,WAAW,CAAC,CAAC;IAEtC,OAAOA,WAAW;EACpB;EACA;EACAR,KAAK,CAAC,wCAAwC,CAAC;EAC/CE,SAAS,CAACW,IAAI,CAACC,SAAS,CAACN,WAAW,CAACJ,IAAI,CAAC,CAAC;EAC3C,OAAOI,WAAW,CAACJ,IAAI;EAEvB,SAASQ,WAAW,CAACF,OAAO,EAAEN,IAAI,EAAEC,MAAM,EAAE;IAC1C;IACA;IACA;IACA,MAAMW,aAAa,GAAGN,OAAO,CAACN,IAAI,EAAEC,MAAM,CAAC;IAC3C;IACA;IACA,IAAIW,aAAa,CAACZ,IAAI,KAAKa,SAAS,IAAID,aAAa,CAACX,MAAM,KAAKY,SAAS,EAAE;MAC1EjB,KAAK,CAAC,6BAA6B,CAAC;MACpC,MAAMO,KAAK,GAAGS,aAAa;MAC3B;MACA,OAAOT,KAAK;IACd;IACAP,KAAK,CAAC,8BAA8B,CAAC;IACrC;IACA,OAAO;MAACI,IAAI,EAAEY,aAAa;MAAEX;IAAM,CAAC;EACtC;AACF,CAAC;AAAA"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _index = _interopRequireWildcard(require("./index"));
4
+ var _util = require("util");
5
+ var _debug = _interopRequireDefault(require("debug"));
6
+ var _chai = require("chai");
7
+ var _marcRecord = require("@natlibfi/marc-record");
8
+ var _fixura = require("@natlibfi/fixura");
9
+ var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ 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); }
12
+ 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; }
13
+ (0, _fixugen.default)({
14
+ callback,
15
+ path: [__dirname, '..', 'test-fixtures', 'index'],
16
+ recurse: false,
17
+ useMetadataFile: true,
18
+ fixura: {
19
+ failWhenNotFound: false,
20
+ reader: _fixura.READERS.JSON
21
+ }
22
+ });
23
+ function callback({
24
+ getFixture,
25
+ reducerConfigs = []
26
+ }) {
27
+ const base = new _marcRecord.MarcRecord(getFixture('base.json'), {
28
+ subfieldValues: false
29
+ });
30
+ const source = new _marcRecord.MarcRecord(getFixture('source.json'), {
31
+ subfieldValues: false
32
+ });
33
+ const expectedRecord = getFixture('merged.json');
34
+ const debug = (0, _debug.default)('@natlibfi/melinda-marc-record-merge-reducers:index:test');
35
+ const debugData = debug.extend('data');
36
+ const testReducerConfigs = reducerConfigs;
37
+ const reducers = [...testReducerConfigs.map(conf => _index.Reducers.copy(conf))];
38
+ debugData(`Reducers: ${(0, _util.inspect)(reducers, {
39
+ colors: true,
40
+ maxArrayLength: 10,
41
+ depth: 8
42
+ })})}`);
43
+ const result = (0, _index.default)({
44
+ base,
45
+ source,
46
+ reducers
47
+ });
48
+ debug(`Merge result is: ${result.constructor.name}`);
49
+ debugData(`${JSON.stringify(result)}`);
50
+
51
+ // Use either result.base or a plain result as resultRecord
52
+ // It can also be a MarcRecord or a plain object
53
+ const resultRecord = result.base || result;
54
+ const resultRecordToRecord = new _marcRecord.MarcRecord(resultRecord, {
55
+ subfieldValues: false
56
+ });
57
+ (0, _chai.expect)(resultRecordToRecord.toObject()).to.eql(expectedRecord);
58
+ }
59
+ //# sourceMappingURL=index.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.js","names":["generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","getFixture","reducerConfigs","base","MarcRecord","subfieldValues","source","expectedRecord","debug","createDebugLogger","debugData","extend","testReducerConfigs","reducers","map","conf","Reducers","copy","inspect","colors","maxArrayLength","depth","result","merger","constructor","name","stringify","resultRecord","resultRecordToRecord","expect","toObject","to","eql"],"sources":["../src/index.spec.js"],"sourcesContent":["import merger, {Reducers} from './index';\nimport {inspect} from 'util';\nimport createDebugLogger from 'debug';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'index'],\n recurse: false,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: false,\n reader: READERS.JSON\n }\n});\n\nfunction callback({getFixture, reducerConfigs = []}) {\n const base = new MarcRecord(getFixture('base.json'), {subfieldValues: false});\n const source = new MarcRecord(getFixture('source.json'), {subfieldValues: false});\n const expectedRecord = getFixture('merged.json');\n\n const debug = createDebugLogger('@natlibfi/melinda-marc-record-merge-reducers:index:test');\n const debugData = debug.extend('data');\n\n const testReducerConfigs = reducerConfigs;\n const reducers = [...testReducerConfigs.map(conf => Reducers.copy(conf))];\n\n debugData(`Reducers: ${inspect(reducers, {colors: true, maxArrayLength: 10, depth: 8})})}`);\n\n const result = merger({base, source, reducers});\n\n debug(`Merge result is: ${result.constructor.name}`);\n debugData(`${JSON.stringify(result)}`);\n\n // Use either result.base or a plain result as resultRecord\n // It can also be a MarcRecord or a plain object\n const resultRecord = result.base || result;\n const resultRecordToRecord = new MarcRecord(resultRecord, {subfieldValues: false});\n expect(resultRecordToRecord.toObject()).to.eql(expectedRecord);\n\n\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAA8C;AAAA;AAAA;AAE9C,IAAAA,gBAAa,EAAC;EACZC,QAAQ;EACRC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC;EACjDC,OAAO,EAAE,KAAK;EACdC,eAAe,EAAE,IAAI;EACrBC,MAAM,EAAE;IACNC,gBAAgB,EAAE,KAAK;IACvBC,MAAM,EAAEC,eAAO,CAACC;EAClB;AACF,CAAC,CAAC;AAEF,SAAST,QAAQ,CAAC;EAACU,UAAU;EAAEC,cAAc,GAAG;AAAE,CAAC,EAAE;EACnD,MAAMC,IAAI,GAAG,IAAIC,sBAAU,CAACH,UAAU,CAAC,WAAW,CAAC,EAAE;IAACI,cAAc,EAAE;EAAK,CAAC,CAAC;EAC7E,MAAMC,MAAM,GAAG,IAAIF,sBAAU,CAACH,UAAU,CAAC,aAAa,CAAC,EAAE;IAACI,cAAc,EAAE;EAAK,CAAC,CAAC;EACjF,MAAME,cAAc,GAAGN,UAAU,CAAC,aAAa,CAAC;EAEhD,MAAMO,KAAK,GAAG,IAAAC,cAAiB,EAAC,yDAAyD,CAAC;EAC1F,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;EAEtC,MAAMC,kBAAkB,GAAGV,cAAc;EACzC,MAAMW,QAAQ,GAAG,CAAC,GAAGD,kBAAkB,CAACE,GAAG,CAACC,IAAI,IAAIC,eAAQ,CAACC,IAAI,CAACF,IAAI,CAAC,CAAC,CAAC;EAEzEL,SAAS,CAAE,aAAY,IAAAQ,aAAO,EAACL,QAAQ,EAAE;IAACM,MAAM,EAAE,IAAI;IAAEC,cAAc,EAAE,EAAE;IAAEC,KAAK,EAAE;EAAC,CAAC,CAAE,IAAG,CAAC;EAE3F,MAAMC,MAAM,GAAG,IAAAC,cAAM,EAAC;IAACpB,IAAI;IAAEG,MAAM;IAAEO;EAAQ,CAAC,CAAC;EAE/CL,KAAK,CAAE,oBAAmBc,MAAM,CAACE,WAAW,CAACC,IAAK,EAAC,CAAC;EACpDf,SAAS,CAAE,GAAEV,IAAI,CAAC0B,SAAS,CAACJ,MAAM,CAAE,EAAC,CAAC;;EAEtC;EACA;EACA,MAAMK,YAAY,GAAGL,MAAM,CAACnB,IAAI,IAAImB,MAAM;EAC1C,MAAMM,oBAAoB,GAAG,IAAIxB,sBAAU,CAACuB,YAAY,EAAE;IAACtB,cAAc,EAAE;EAAK,CAAC,CAAC;EAClF,IAAAwB,YAAM,EAACD,oBAAoB,CAACE,QAAQ,EAAE,CAAC,CAACC,EAAE,CAACC,GAAG,CAACzB,cAAc,CAAC;AAGhE"}