@natlibfi/marc-record-merge 6.0.0-beta.2 → 6.0.0-beta.6

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 (224) 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 +106 -2
  6. package/dist/index.js +2 -37
  7. package/dist/index.js.map +1 -1
  8. package/dist/reducers/copy.js +310 -109
  9. package/dist/reducers/copy.js.map +1 -1
  10. package/dist/reducers/copy.spec.js +52 -99
  11. package/dist/reducers/copy.spec.js.map +1 -1
  12. package/dist/reducers/index.js +0 -27
  13. package/dist/reducers/index.js.map +1 -1
  14. package/dist/reducers/select.js +12 -50
  15. package/dist/reducers/select.js.map +1 -1
  16. package/dist/reducers/select.spec.js +49 -83
  17. package/dist/reducers/select.spec.js.map +1 -1
  18. package/package.json +30 -27
  19. package/src/index.js +1 -33
  20. package/src/reducers/copy.js +306 -115
  21. package/src/reducers/copy.spec.js +44 -66
  22. package/src/reducers/index.js +0 -27
  23. package/src/reducers/select.js +8 -51
  24. package/src/reducers/select.spec.js +37 -58
  25. package/test-fixtures/reducers/copy/{01/base.json → 01 - copy/01/base.json } +1 -1
  26. package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/merged.json +0 -0
  27. package/test-fixtures/reducers/copy/01 - copy/01/metadata.json +4 -0
  28. package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/source.json +0 -0
  29. package/test-fixtures/reducers/copy/{02/source.json → 01 - copy/02/base.json} +0 -0
  30. package/test-fixtures/reducers/copy/{02 → 01 - copy/02}/merged.json +0 -0
  31. package/test-fixtures/reducers/copy/01 - copy/02/metadata.json +4 -0
  32. package/test-fixtures/reducers/copy/{02/base.json → 01 - copy/02/source.json } +1 -1
  33. package/test-fixtures/reducers/copy/{03/base.json → 01 - copy/03/base.json } +1 -1
  34. package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/merged.json +0 -0
  35. package/test-fixtures/reducers/copy/01 - copy/03/metadata.json +4 -0
  36. package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/source.json +0 -0
  37. package/test-fixtures/reducers/copy/{05/base.json → 01 - copy/04/base.json } +1 -1
  38. package/test-fixtures/reducers/copy/{04/merged.json → 01 - copy/04/merged.json } +1 -1
  39. package/test-fixtures/reducers/copy/01 - copy/04/metadata.json +4 -0
  40. package/test-fixtures/reducers/copy/{04/source.json → 01 - copy/04/source.json } +1 -1
  41. package/test-fixtures/reducers/copy/{04/base.json → 01 - copy/05/base.json } +1 -1
  42. package/test-fixtures/reducers/copy/{05 → 01 - copy/05}/merged.json +0 -0
  43. package/test-fixtures/reducers/copy/01 - copy/05/metadata.json +4 -0
  44. package/test-fixtures/reducers/copy/{05 → 01 - copy/05}/source.json +0 -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/{06 → 03 - compareTagsOnly/01}/base.json +0 -0
  66. package/test-fixtures/reducers/copy/{06 → 03 - compareTagsOnly/01}/merged.json +0 -0
  67. package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/metadata.json +5 -0
  68. package/test-fixtures/reducers/copy/{06 → 03 - compareTagsOnly/01}/source.json +0 -0
  69. package/test-fixtures/reducers/copy/{09 → 03 - compareTagsOnly/02}/base.json +0 -0
  70. package/test-fixtures/reducers/copy/{09 → 03 - compareTagsOnly/02}/merged.json +0 -0
  71. package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/metadata.json +5 -0
  72. package/test-fixtures/reducers/copy/{09 → 03 - compareTagsOnly/02}/source.json +0 -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/05 - copyUnless/01/base.json +9 -0
  82. package/test-fixtures/reducers/copy/05 - copyUnless/01/merged.json +24 -0
  83. package/test-fixtures/reducers/copy/05 - copyUnless/01/metadata.json +5 -0
  84. package/test-fixtures/reducers/copy/05 - copyUnless/01/source.json +47 -0
  85. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/base.json +24 -0
  86. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/merged.json +39 -0
  87. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/metadata.json +5 -0
  88. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/source.json +24 -0
  89. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/base.json +24 -0
  90. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/merged.json +24 -0
  91. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/metadata.json +5 -0
  92. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/source.json +24 -0
  93. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/base.json +28 -0
  94. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/merged.json +43 -0
  95. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/metadata.json +5 -0
  96. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/source.json +24 -0
  97. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/base.json +28 -0
  98. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/merged.json +28 -0
  99. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/metadata.json +5 -0
  100. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/source.json +24 -0
  101. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/base.json +20 -0
  102. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/merged.json +35 -0
  103. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/metadata.json +5 -0
  104. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/source.json +24 -0
  105. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/base.json +20 -0
  106. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/merged.json +35 -0
  107. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/metadata.json +5 -0
  108. package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/source.json +24 -0
  109. package/test-fixtures/reducers/copy/{07 → 07 - excludeSubfields/01}/base.json +0 -0
  110. package/test-fixtures/reducers/copy/{07 → 07 - excludeSubfields/01}/merged.json +0 -0
  111. package/test-fixtures/reducers/copy/07 - excludeSubfields/01/metadata.json +8 -0
  112. package/test-fixtures/reducers/copy/{07 → 07 - excludeSubfields/01}/source.json +0 -0
  113. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/base.json +39 -0
  114. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/merged.json +58 -0
  115. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/metadata.json +5 -0
  116. package/test-fixtures/reducers/copy/07 - excludeSubfields/02/source.json +43 -0
  117. package/test-fixtures/reducers/copy/{08 → 08 - dropSubfields/01}/base.json +0 -0
  118. package/test-fixtures/reducers/copy/{08/merged.json → 08 - dropSubfields/01/merged.json } +8 -0
  119. package/test-fixtures/reducers/copy/08 - dropSubfields/01/metadata.json +5 -0
  120. package/test-fixtures/reducers/copy/{08 → 08 - dropSubfields/01}/source.json +0 -0
  121. package/test-fixtures/reducers/copy/08 - dropSubfields/02/base.json +43 -0
  122. package/test-fixtures/reducers/copy/08 - dropSubfields/02/merged.json +58 -0
  123. package/test-fixtures/reducers/copy/08 - dropSubfields/02/metadata.json +5 -0
  124. package/test-fixtures/reducers/copy/08 - dropSubfields/02/source.json +32 -0
  125. package/test-fixtures/reducers/copy/08 - dropSubfields/03/base.json +43 -0
  126. package/test-fixtures/reducers/copy/08 - dropSubfields/03/merged.json +58 -0
  127. package/test-fixtures/reducers/copy/08 - dropSubfields/03/metadata.json +5 -0
  128. package/test-fixtures/reducers/copy/08 - dropSubfields/03/source.json +32 -0
  129. package/test-fixtures/reducers/copy/08 - dropSubfields/04/base.json +43 -0
  130. package/test-fixtures/reducers/copy/08 - dropSubfields/04/merged.json +43 -0
  131. package/test-fixtures/reducers/copy/08 - dropSubfields/04/metadata.json +5 -0
  132. package/test-fixtures/reducers/copy/08 - dropSubfields/04/source.json +32 -0
  133. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/base.json +9 -0
  134. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/merged.json +20 -0
  135. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/metadata.json +6 -0
  136. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/source.json +20 -0
  137. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/base.json +9 -0
  138. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/merged.json +20 -0
  139. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/metadata.json +6 -0
  140. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/source.json +20 -0
  141. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/base.json +9 -0
  142. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/merged.json +31 -0
  143. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/metadata.json +6 -0
  144. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/source.json +31 -0
  145. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/base.json +9 -0
  146. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/merged.json +42 -0
  147. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/metadata.json +6 -0
  148. package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/source.json +42 -0
  149. package/test-fixtures/reducers/copy/10 - swapTag/01/base.json +17 -0
  150. package/test-fixtures/reducers/copy/10 - swapTag/01/merged.json +28 -0
  151. package/test-fixtures/reducers/copy/10 - swapTag/01/metadata.json +6 -0
  152. package/test-fixtures/reducers/copy/10 - swapTag/01/source.json +20 -0
  153. package/test-fixtures/reducers/metadata.json +4 -0
  154. package/test-fixtures/reducers/select/01/metadata.json +5 -0
  155. package/test-fixtures/reducers/select/02/metadata.json +4 -0
  156. package/test-fixtures/reducers/select/03/metadata.json +4 -0
  157. package/test-fixtures/reducers/select/04/metadata.json +5 -0
  158. package/test-fixtures/reducers/select/05/metadata.json +4 -0
  159. package/test-fixtures/reducers/select/06/metadata.json +4 -0
  160. package/test-fixtures/reducers/select/07/metadata.json +5 -0
  161. package/test-fixtures/reducers/select/08/metadata.json +4 -0
  162. package/test-fixtures/reducers/select/09/metadata.json +4 -0
  163. package/test-fixtures/reducers/select/10/metadata.json +5 -0
  164. package/test-fixtures/reducers/select/11/metadata.json +4 -0
  165. package/test-fixtures/reducers/select/12/metadata.json +5 -0
  166. package/test-fixtures/reducers/select/13/metadata.json +4 -0
  167. package/test-fixtures/reducers/select/14/metadata.json +4 -0
  168. package/.drone.yml +0 -92
  169. package/.nyc_output/72717fff-b4ac-4aef-a145-37cae88e07f8.json +0 -1
  170. package/.nyc_output/processinfo/72717fff-b4ac-4aef-a145-37cae88e07f8.json +0 -1
  171. package/.nyc_output/processinfo/index.json +0 -1
  172. package/LICENSE.txt +0 -165
  173. package/coverage/base.css +0 -224
  174. package/coverage/block-navigation.js +0 -79
  175. package/coverage/copy.js.html +0 -500
  176. package/coverage/favicon.png +0 -0
  177. package/coverage/index.html +0 -126
  178. package/coverage/lcov-report/base.css +0 -224
  179. package/coverage/lcov-report/block-navigation.js +0 -79
  180. package/coverage/lcov-report/copy.js.html +0 -500
  181. package/coverage/lcov-report/favicon.png +0 -0
  182. package/coverage/lcov-report/index.html +0 -126
  183. package/coverage/lcov-report/prettify.css +0 -1
  184. package/coverage/lcov-report/prettify.js +0 -2
  185. package/coverage/lcov-report/select.js.html +0 -539
  186. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  187. package/coverage/lcov-report/sorter.js +0 -170
  188. package/coverage/lcov.info +0 -274
  189. package/coverage/prettify.css +0 -1
  190. package/coverage/prettify.js +0 -2
  191. package/coverage/select.js.html +0 -539
  192. package/coverage/sort-arrow-sprite.png +0 -0
  193. package/coverage/sorter.js +0 -170
  194. package/test-fixtures/reducers/copy/01/tagPattern.txt +0 -1
  195. package/test-fixtures/reducers/copy/02/tagPattern.txt +0 -1
  196. package/test-fixtures/reducers/copy/03/tagPattern.txt +0 -1
  197. package/test-fixtures/reducers/copy/04/tagPattern.txt +0 -1
  198. package/test-fixtures/reducers/copy/05/tagPattern.txt +0 -1
  199. package/test-fixtures/reducers/copy/06/compareTagsOnly.txt +0 -1
  200. package/test-fixtures/reducers/copy/06/tagPattern.txt +0 -1
  201. package/test-fixtures/reducers/copy/07/excludeSubfields.json +0 -1
  202. package/test-fixtures/reducers/copy/07/tagPattern.txt +0 -1
  203. package/test-fixtures/reducers/copy/08/dropSubfields.json +0 -1
  204. package/test-fixtures/reducers/copy/08/tagPattern.txt +0 -1
  205. package/test-fixtures/reducers/copy/09/compareTagsOnly.txt +0 -1
  206. package/test-fixtures/reducers/copy/09/tagPattern.txt +0 -1
  207. package/test-fixtures/reducers/select/01/expected-error.txt +0 -1
  208. package/test-fixtures/reducers/select/01/pattern.txt +0 -1
  209. package/test-fixtures/reducers/select/02/pattern.txt +0 -1
  210. package/test-fixtures/reducers/select/03/pattern.txt +0 -1
  211. package/test-fixtures/reducers/select/04/pattern.txt +0 -1
  212. package/test-fixtures/reducers/select/05/pattern.txt +0 -1
  213. package/test-fixtures/reducers/select/06/pattern.txt +0 -1
  214. package/test-fixtures/reducers/select/07/equalityFunction.txt +0 -1
  215. package/test-fixtures/reducers/select/07/pattern.txt +0 -1
  216. package/test-fixtures/reducers/select/08/pattern.txt +0 -1
  217. package/test-fixtures/reducers/select/09/pattern.txt +0 -1
  218. package/test-fixtures/reducers/select/10/equalityFunction.txt +0 -1
  219. package/test-fixtures/reducers/select/10/pattern.txt +0 -1
  220. package/test-fixtures/reducers/select/11/pattern.txt +0 -1
  221. package/test-fixtures/reducers/select/12/equalityFunction.txt +0 -1
  222. package/test-fixtures/reducers/select/12/pattern.txt +0 -1
  223. package/test-fixtures/reducers/select/13/pattern.txt +0 -1
  224. package/test-fixtures/reducers/select/14/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,113 @@
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
+ ### subfieldsMustBeIdentical (Defaults true)
40
+ ```
41
+ {tagPattern: /010/u, subfieldsMustBeIdentical: true}
42
+ ```
43
+
44
+ If source subfields are subset of base subfields this option says if it is copied
45
+ | subfieldsMustBeIdentical | base | source | copy |
46
+ |--------------------------|---------------|---------------|-------|
47
+ | true or false | $a foo | $a foo | false |
48
+ | true or false | $a foo | $b bar | true |
49
+ | true | $a foo | $a foo,$b bar | true |
50
+ | false | $a foo | $a foo,$b bar | true |
51
+ | true | $a foo,$b bar | $a foo | true |
52
+ | false | $a foo,$b bar | $a foo | false |
53
+
54
+ ### excludeSubfields (Defaults [ ])
55
+ ```
56
+ {tagPattern: /010/u, excludeSubfields: ['a']}
57
+ ```
58
+
59
+ When base and source fields are compared, excluded subfields are ignored
60
+
61
+ ### swapSubfieldCode (Defaults [ ])
62
+ ```
63
+ {tagPattern: /010/u, swapSubfieldCode: [{"from": "a", "to": "b"}]}
64
+ ```
65
+
66
+ When source fields are copied, subfields are checkked and if subfield.code match to 'from' value is that code swapped to 'to' value
67
+
68
+ ### dropSubfields (Defaults [ ])
69
+ ```
70
+ {tagPattern: /010/u, dropSubfields: [{"code": "9"}]}
71
+ ```
72
+ Drops subfields 9's from all fields tagged 010
73
+
74
+ ```
75
+ {tagPattern: /010/u, dropSubfields: [{"code": "9", "value": "FENNI<KEEP>"}]}
76
+ ```
77
+ Drops subfields 9's that have "FENNI<KEEP>" from all fields tagged 010
78
+
79
+
80
+ ```
81
+ {tagPattern: /010/u, dropSubfields: [{"code": "9", "condition": "unless", "value": "^FENNI<(?<option>KEEP|DROP)>$"}]}
82
+ ```
83
+ Drops all subfield 9's unless they have "FENNI<KEEP>" or "FENNI<DROP>" from all fields tagged 010
84
+
85
+
86
+ When comparing or copying field dropped fields are ignored
87
+
88
+ ### copyUnless (Defaults [ ])
89
+ ```
90
+ {tagPattern: /010/u, copyUnless: [{"code": "9", "value": "FENNI<KEEP>"}]}
91
+ ```
92
+
93
+ When field is otherwise ok to be copied, if it contains given subfield whole field is ignored
94
+
95
+ ### baseValidators (Defaults {subfieldValues: false})
96
+ ```
97
+ {tagPattern: /010/u, baseValidators: {fields: true, subfields: true, subfieldValues: true}}
98
+ ```
99
+
100
+ Marc record validators for base record while reducer is working.
101
+ More info can be read here: https://github.com/NatLibFi/marc-record-js
102
+
103
+ ### sourceValidators (Defaults {subfieldValues: false})
104
+ ```
105
+ {tagPattern: /010/u, sourceValidators: {fields: true, subfields: true, subfieldValues: true}}
106
+ ```
107
+
108
+ Marc record validators for source record while reducer is working.
109
+ More info can be read here: https://github.com/NatLibFi/marc-record-js
6
110
 
7
111
  ## License and copyright
8
112
 
9
- Copyright (c) 2017-2019 **University Of Helsinki (The National Library Of Finland)**
113
+ Copyright (c) 2020-2022 **University Of Helsinki (The National Library Of Finland)**
10
114
 
11
- This project's source code is licensed under the terms of **GNU Lesser General Public License Version 3** or any later version.
115
+ This project's source code is licensed under the terms of **MIT** or any later version.
package/dist/index.js CHANGED
@@ -11,50 +11,15 @@ Object.defineProperty(exports, "Reducers", {
11
11
  });
12
12
  exports.default = void 0;
13
13
 
14
- var _marcRecord = require("@natlibfi/marc-record");
15
-
16
14
  var _reducers = _interopRequireDefault(require("./reducers"));
17
15
 
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
17
 
20
- /**
21
- *
22
- * @licstart The following is the entire license notice for the JavaScript code in this file.
23
- *
24
- * Merge MARC records
25
- *
26
- * Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
27
- *
28
- * This file is part of marc-record-merge-js
29
-
30
- * marc-record-merge-js program is free software: you can redistribute it and/or modify
31
- * it under the terms of the GNU Lesser General Public License as
32
- * published by the Free Software Foundation, either version 3 of the
33
- * License, or (at your option) any later version.
34
- *
35
- * marc-record-merge-js is distributed in the hope that it will be useful,
36
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
37
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38
- * GNU Lesser General Public License for more details.
39
- *
40
- * You should have received a copy of the GNU Lesser General Public License
41
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
42
- *
43
- * @licend The above is the entire license notice
44
- * for the JavaScript code in this file.
45
- *
46
- */
47
18
  var _default = ({
48
19
  base,
49
20
  source,
50
- reducers,
51
- baseValidators = {},
52
- sourceValidators = {}
53
- }) => {
54
- const sourceRecord = _marcRecord.MarcRecord.clone(source, sourceValidators);
55
-
56
- return reducers.reduce((baseRecord, reducer) => reducer(baseRecord, sourceRecord), _marcRecord.MarcRecord.clone(base, baseValidators));
57
- };
21
+ reducers
22
+ }) => reducers.reduce((base, reducer) => reducer(base, source), base);
58
23
 
59
24
  exports.default = _default;
60
25
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["base","source","reducers","baseValidators","sourceValidators","sourceRecord","MarcRecord","clone","reduce","baseRecord","reducer"],"mappings":";;;;;;;;;;;;;AA4BA;;AACA;;;;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAMe,CAAC;AAACA,EAAAA,IAAD;AAAOC,EAAAA,MAAP;AAAeC,EAAAA,QAAf;AAAyBC,EAAAA,cAAc,GAAG,EAA1C;AAA8CC,EAAAA,gBAAgB,GAAG;AAAjE,CAAD,KAA0E;AACvF,QAAMC,YAAY,GAAGC,uBAAWC,KAAX,CAAiBN,MAAjB,EAAyBG,gBAAzB,CAArB;;AACA,SAAOF,QAAQ,CAACM,MAAT,CAAgB,CAACC,UAAD,EAAaC,OAAb,KAAyBA,OAAO,CAACD,UAAD,EAAaJ,YAAb,CAAhD,EAA4EC,uBAAWC,KAAX,CAAiBP,IAAjB,EAAuBG,cAAvB,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 {MarcRecord} from '@natlibfi/marc-record';\nimport Reducers from './reducers';\n\nexport {Reducers};\nexport default ({base, source, reducers, baseValidators = {}, sourceValidators = {}}) => {\n const sourceRecord = MarcRecord.clone(source, sourceValidators);\n return reducers.reduce((baseRecord, reducer) => reducer(baseRecord, sourceRecord), MarcRecord.clone(base, baseValidators));\n};\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["base","source","reducers","reduce","reducer"],"sources":["../src/index.js"],"sourcesContent":["import Reducers from './reducers';\n\nexport {Reducers};\nexport default ({base, source, reducers}) => reducers.reduce((base, reducer) => reducer(base, source), base);\n"],"mappings":";;;;;;;;;;;;;AAAA;;;;eAGe,CAAC;EAACA,IAAD;EAAOC,MAAP;EAAeC;AAAf,CAAD,KAA8BA,QAAQ,CAACC,MAAT,CAAgB,CAACH,IAAD,EAAOI,OAAP,KAAmBA,OAAO,CAACJ,IAAD,EAAOC,MAAP,CAA1C,EAA0DD,IAA1D,C"}