@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.
- package/.github/CODEOWNERS +9 -0
- package/.github/dependabot.yml +41 -0
- package/.github/workflows/melinda-node-tests.yml +60 -0
- package/LICENSE +21 -0
- package/README.md +90 -242
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/reducers/copy.js +249 -0
- package/dist/reducers/copy.js.map +1 -0
- package/dist/reducers/copy.spec.js +64 -0
- package/dist/reducers/copy.spec.js.map +1 -0
- package/dist/reducers/index.js +19 -0
- package/dist/reducers/index.js.map +1 -0
- package/dist/reducers/select.js +118 -0
- package/dist/reducers/select.js.map +1 -0
- package/dist/reducers/select.spec.js +55 -0
- package/dist/reducers/select.spec.js.map +1 -0
- package/package.json +101 -57
- package/src/index.js +34 -0
- package/src/reducers/copy.js +251 -0
- package/src/reducers/copy.spec.js +54 -0
- package/src/reducers/index.js +4 -0
- package/src/reducers/select.js +110 -0
- package/src/reducers/select.spec.js +49 -0
- package/test-fixtures/reducers/copy/01 - copy/01/base.json +9 -0
- package/test-fixtures/reducers/copy/01 - copy/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/01 - copy/01/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/01/source.json +20 -0
- package/test-fixtures/reducers/copy/01 - copy/02/base.json +20 -0
- package/test-fixtures/reducers/copy/01 - copy/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/01 - copy/02/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/02/source.json +20 -0
- package/test-fixtures/reducers/copy/01 - copy/03/base.json +20 -0
- package/test-fixtures/reducers/copy/01 - copy/03/merged.json +28 -0
- package/test-fixtures/reducers/copy/01 - copy/03/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/03/source.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/04/base.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/04/merged.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/04/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/04/source.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/05/base.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/05/merged.json +77 -0
- package/test-fixtures/reducers/copy/01 - copy/05/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/05/source.json +62 -0
- package/test-fixtures/reducers/copy/01 - copy/06/base.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/06/merged.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/06/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/06/source.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/07/base.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/07/merged.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/07/metadata.json +5 -0
- package/test-fixtures/reducers/copy/01 - copy/07/source.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/08/base.json +28 -0
- package/test-fixtures/reducers/copy/01 - copy/08/merged.json +28 -0
- package/test-fixtures/reducers/copy/01 - copy/08/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/08/source.json +24 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/base.json +17 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/source.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/base.json +9 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/source.json +20 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/base.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/source.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/base.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/merged.json +100 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/source.json +100 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/base.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/source.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/base.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/merged.json +39 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/source.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/03/metadata.json +6 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/base.json +20 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/merged.json +31 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/source.json +20 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/base.json +9 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/source.json +47 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/base.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/merged.json +39 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/base.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/merged.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/base.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/merged.json +43 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/base.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/merged.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/base.json +20 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/merged.json +35 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/base.json +20 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/merged.json +35 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/source.json +24 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/base.json +39 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/merged.json +39 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/metadata.json +8 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/source.json +43 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/base.json +39 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/merged.json +58 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/source.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/base.json +35 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/merged.json +54 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/source.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/merged.json +58 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/source.json +32 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/merged.json +58 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/source.json +32 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/merged.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/source.json +32 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/source.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/source.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/merged.json +31 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/source.json +31 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/merged.json +42 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/source.json +42 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/base.json +17 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/merged.json +28 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/source.json +20 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/source.json +20 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/merged.json +39 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/source.json +31 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/metadata.json +7 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/source.json +20 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/base.json +17 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/metadata.json +7 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/source.json +31 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/metadata.json +7 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/source.json +28 -0
- package/test-fixtures/reducers/metadata.json +4 -0
- package/test-fixtures/reducers/select/01/base.json +21 -0
- package/test-fixtures/reducers/select/01/merged.json +20 -0
- package/test-fixtures/reducers/select/01/metadata.json +5 -0
- package/test-fixtures/reducers/select/01/source.json +20 -0
- package/test-fixtures/reducers/select/02/base.json +31 -0
- package/test-fixtures/reducers/select/02/merged.json +31 -0
- package/test-fixtures/reducers/select/02/metadata.json +4 -0
- package/test-fixtures/reducers/select/02/source.json +42 -0
- package/test-fixtures/reducers/select/03/base.json +20 -0
- package/test-fixtures/reducers/select/03/merged.json +20 -0
- package/test-fixtures/reducers/select/03/metadata.json +4 -0
- package/test-fixtures/reducers/select/03/source.json +20 -0
- package/test-fixtures/reducers/select/04/base.json +20 -0
- package/test-fixtures/reducers/select/04/merged.json +20 -0
- package/test-fixtures/reducers/select/04/metadata.json +5 -0
- package/test-fixtures/reducers/select/04/source.json +20 -0
- package/test-fixtures/reducers/select/05/base.json +24 -0
- package/test-fixtures/reducers/select/05/merged.json +24 -0
- package/test-fixtures/reducers/select/05/metadata.json +4 -0
- package/test-fixtures/reducers/select/05/source.json +24 -0
- package/test-fixtures/reducers/select/06/base.json +28 -0
- package/test-fixtures/reducers/select/06/merged.json +28 -0
- package/test-fixtures/reducers/select/06/metadata.json +4 -0
- package/test-fixtures/reducers/select/06/source.json +28 -0
- package/test-fixtures/reducers/select/07/base.json +24 -0
- package/test-fixtures/reducers/select/07/merged.json +24 -0
- package/test-fixtures/reducers/select/07/metadata.json +5 -0
- package/test-fixtures/reducers/select/07/source.json +24 -0
- package/test-fixtures/reducers/select/08/base.json +24 -0
- package/test-fixtures/reducers/select/08/merged.json +24 -0
- package/test-fixtures/reducers/select/08/metadata.json +4 -0
- package/test-fixtures/reducers/select/08/source.json +24 -0
- package/test-fixtures/reducers/select/09/base.json +24 -0
- package/test-fixtures/reducers/select/09/merged.json +24 -0
- package/test-fixtures/reducers/select/09/metadata.json +4 -0
- package/test-fixtures/reducers/select/09/source.json +24 -0
- package/test-fixtures/reducers/select/10/base.json +24 -0
- package/test-fixtures/reducers/select/10/merged.json +28 -0
- package/test-fixtures/reducers/select/10/metadata.json +5 -0
- package/test-fixtures/reducers/select/10/source.json +28 -0
- package/test-fixtures/reducers/select/11/base.json +24 -0
- package/test-fixtures/reducers/select/11/merged.json +24 -0
- package/test-fixtures/reducers/select/11/metadata.json +4 -0
- package/test-fixtures/reducers/select/11/source.json +28 -0
- package/test-fixtures/reducers/select/12/base.json +24 -0
- package/test-fixtures/reducers/select/12/merged.json +28 -0
- package/test-fixtures/reducers/select/12/metadata.json +5 -0
- package/test-fixtures/reducers/select/12/source.json +28 -0
- package/test-fixtures/reducers/select/13/base.json +28 -0
- package/test-fixtures/reducers/select/13/merged.json +28 -0
- package/test-fixtures/reducers/select/13/metadata.json +4 -0
- package/test-fixtures/reducers/select/13/source.json +24 -0
- package/test-fixtures/reducers/select/14/base.json +24 -0
- package/test-fixtures/reducers/select/14/merged.json +24 -0
- package/test-fixtures/reducers/select/14/metadata.json +4 -0
- package/test-fixtures/reducers/select/14/source.json +24 -0
- package/.editorconfig +0 -10
- package/.istanbul.yml +0 -6
- package/.jshintignore +0 -2
- package/.jshintrc +0 -3
- package/.travis.yml +0 -16
- package/LICENSE.txt +0 -661
- package/karma.conf.js +0 -39
- package/lib/main.js +0 -1215
- package/resources/action-copy-options-schema.json +0 -81
- package/resources/action-select-better-options-schema.json +0 -34
- package/resources/configuration-schema.json +0 -46
- package/test/browser/main.spec.js +0 -96
- package/test/nodejs/main.spec.js +0 -71
- package/test/suites/74.json +0 -10
- package/test/suites/config/1to3.json +0 -10
- package/test/suites/config/27to28.json +0 -10
- package/test/suites/config/29to31.json +0 -10
- package/test/suites/config/32to40.json +0 -16
- package/test/suites/config/41to43.json +0 -10
- package/test/suites/config/44to56.json +0 -15
- package/test/suites/config/4to26.json +0 -81
- package/test/suites/config/57to63.json +0 -63
- package/test/suites/config/64.json +0 -7
- package/test/suites/config/65.json +0 -19
- package/test/suites/config/66.json +0 -13
- package/test/suites/config/67.json +0 -14
- package/test/suites/config/68.json +0 -12
- package/test/suites/config/69.json +0 -12
- package/test/suites/config/70.json +0 -13
- package/test/suites/config/71.json +0 -10
- package/test/suites/config/72.json +0 -12
- package/test/suites/config/73.json +0 -10
- package/test/suites/config/76.json +0 -13
- package/test/suites/config/77.json +0 -11
- package/test/suites/config/78to79.json +0 -12
- package/test/suites/config/80to81.json +0 -12
- package/test/suites/config/82.json +0 -10
- package/test/suites/config/83to85.json +0 -15
- package/test/suites/config/86.json +0 -16
- package/test/suites/config/87.json +0 -15
- package/test/suites/config/88.json +0 -16
- package/test/suites/data/1/merged +0 -3
- package/test/suites/data/1/other +0 -3
- package/test/suites/data/1/preferred +0 -2
- package/test/suites/data/10/descr +0 -1
- package/test/suites/data/10/merged +0 -2
- package/test/suites/data/10/other +0 -2
- package/test/suites/data/10/preferred +0 -2
- package/test/suites/data/11/descr +0 -1
- package/test/suites/data/11/merged +0 -2
- package/test/suites/data/11/other +0 -2
- package/test/suites/data/11/preferred +0 -2
- package/test/suites/data/12/descr +0 -1
- package/test/suites/data/12/merged +0 -2
- package/test/suites/data/12/other +0 -2
- package/test/suites/data/12/preferred +0 -2
- package/test/suites/data/13/descr +0 -1
- package/test/suites/data/13/merged +0 -3
- package/test/suites/data/13/other +0 -2
- package/test/suites/data/13/preferred +0 -3
- package/test/suites/data/14/descr +0 -1
- package/test/suites/data/14/merged +0 -2
- package/test/suites/data/14/other +0 -2
- package/test/suites/data/14/preferred +0 -2
- package/test/suites/data/15/descr +0 -1
- package/test/suites/data/15/merged +0 -2
- package/test/suites/data/15/other +0 -2
- package/test/suites/data/15/preferred +0 -2
- package/test/suites/data/16/descr +0 -1
- package/test/suites/data/16/merged +0 -2
- package/test/suites/data/16/other +0 -2
- package/test/suites/data/16/preferred +0 -2
- package/test/suites/data/17/descr +0 -1
- package/test/suites/data/17/merged +0 -2
- package/test/suites/data/17/other +0 -2
- package/test/suites/data/17/preferred +0 -2
- package/test/suites/data/18/descr +0 -1
- package/test/suites/data/18/merged +0 -2
- package/test/suites/data/18/other +0 -2
- package/test/suites/data/18/preferred +0 -2
- package/test/suites/data/19/descr +0 -1
- package/test/suites/data/19/merged +0 -2
- package/test/suites/data/19/other +0 -2
- package/test/suites/data/19/preferred +0 -2
- package/test/suites/data/2/merged +0 -3
- package/test/suites/data/2/other +0 -2
- package/test/suites/data/2/preferred +0 -3
- package/test/suites/data/20/descr +0 -1
- package/test/suites/data/20/merged +0 -3
- package/test/suites/data/20/other +0 -2
- package/test/suites/data/20/preferred +0 -2
- package/test/suites/data/21/descr +0 -1
- package/test/suites/data/21/merged +0 -4
- package/test/suites/data/21/other +0 -4
- package/test/suites/data/21/preferred +0 -3
- package/test/suites/data/22/descr +0 -1
- package/test/suites/data/22/merged +0 -10
- package/test/suites/data/22/other +0 -7
- package/test/suites/data/22/preferred +0 -10
- package/test/suites/data/23/descr +0 -1
- package/test/suites/data/23/merged +0 -2
- package/test/suites/data/23/other +0 -2
- package/test/suites/data/23/preferred +0 -2
- package/test/suites/data/24/descr +0 -1
- package/test/suites/data/24/merged +0 -2
- package/test/suites/data/24/other +0 -2
- package/test/suites/data/24/preferred +0 -2
- package/test/suites/data/25/descr +0 -1
- package/test/suites/data/25/merged +0 -2
- package/test/suites/data/25/other +0 -2
- package/test/suites/data/25/preferred +0 -2
- package/test/suites/data/26/descr +0 -1
- package/test/suites/data/26/merged +0 -3
- package/test/suites/data/26/other +0 -3
- package/test/suites/data/26/preferred +0 -3
- package/test/suites/data/27/merged +0 -3
- package/test/suites/data/27/other +0 -2
- package/test/suites/data/27/preferred +0 -2
- package/test/suites/data/28/merged +0 -3
- package/test/suites/data/28/other +0 -2
- package/test/suites/data/28/preferred +0 -2
- package/test/suites/data/29/merged +0 -2
- package/test/suites/data/29/other +0 -2
- package/test/suites/data/29/preferred +0 -2
- package/test/suites/data/3/merged +0 -3
- package/test/suites/data/3/other +0 -3
- package/test/suites/data/3/preferred +0 -3
- package/test/suites/data/30/merged +0 -3
- package/test/suites/data/30/other +0 -2
- package/test/suites/data/30/preferred +0 -2
- package/test/suites/data/31/merged +0 -3
- package/test/suites/data/31/other +0 -2
- package/test/suites/data/31/preferred +0 -3
- package/test/suites/data/32/other +0 -2
- package/test/suites/data/32/preferred +0 -3
- package/test/suites/data/33/merged +0 -2
- package/test/suites/data/33/other +0 -2
- package/test/suites/data/33/preferred +0 -2
- package/test/suites/data/34/merged +0 -2
- package/test/suites/data/34/other +0 -2
- package/test/suites/data/34/preferred +0 -2
- package/test/suites/data/35/merged +0 -2
- package/test/suites/data/35/other +0 -2
- package/test/suites/data/35/preferred +0 -2
- package/test/suites/data/36/merged +0 -2
- package/test/suites/data/36/other +0 -2
- package/test/suites/data/36/preferred +0 -2
- package/test/suites/data/37/merged +0 -3
- package/test/suites/data/37/other +0 -2
- package/test/suites/data/37/preferred +0 -2
- package/test/suites/data/38/merged +0 -3
- package/test/suites/data/38/other +0 -2
- package/test/suites/data/38/preferred +0 -2
- package/test/suites/data/39/merged +0 -2
- package/test/suites/data/39/other +0 -2
- package/test/suites/data/39/preferred +0 -2
- package/test/suites/data/4/descr +0 -1
- package/test/suites/data/4/merged +0 -2
- package/test/suites/data/4/other +0 -2
- package/test/suites/data/4/preferred +0 -2
- package/test/suites/data/40/merged +0 -2
- package/test/suites/data/40/other +0 -2
- package/test/suites/data/40/preferred +0 -2
- package/test/suites/data/41/merged +0 -2
- package/test/suites/data/41/other +0 -2
- package/test/suites/data/41/preferred +0 -2
- package/test/suites/data/42/merged +0 -2
- package/test/suites/data/42/other +0 -2
- package/test/suites/data/42/preferred +0 -2
- package/test/suites/data/43/merged +0 -2
- package/test/suites/data/43/other +0 -2
- package/test/suites/data/43/preferred +0 -2
- package/test/suites/data/44/merged +0 -2
- package/test/suites/data/44/other +0 -2
- package/test/suites/data/44/preferred +0 -2
- package/test/suites/data/45/merged +0 -2
- package/test/suites/data/45/other +0 -2
- package/test/suites/data/45/preferred +0 -2
- package/test/suites/data/46/merged +0 -2
- package/test/suites/data/46/other +0 -2
- package/test/suites/data/46/preferred +0 -2
- package/test/suites/data/47/merged +0 -2
- package/test/suites/data/47/other +0 -2
- package/test/suites/data/47/preferred +0 -2
- package/test/suites/data/48/merged +0 -2
- package/test/suites/data/48/other +0 -2
- package/test/suites/data/48/preferred +0 -2
- package/test/suites/data/49/merged +0 -3
- package/test/suites/data/49/other +0 -2
- package/test/suites/data/49/preferred +0 -2
- package/test/suites/data/5/descr +0 -1
- package/test/suites/data/5/merged +0 -2
- package/test/suites/data/5/other +0 -2
- package/test/suites/data/5/preferred +0 -2
- package/test/suites/data/50/merged +0 -3
- package/test/suites/data/50/other +0 -2
- package/test/suites/data/50/preferred +0 -2
- package/test/suites/data/51/merged +0 -3
- package/test/suites/data/51/other +0 -2
- package/test/suites/data/51/preferred +0 -2
- package/test/suites/data/52/merged +0 -2
- package/test/suites/data/52/other +0 -2
- package/test/suites/data/52/preferred +0 -2
- package/test/suites/data/53/merged +0 -3
- package/test/suites/data/53/other +0 -2
- package/test/suites/data/53/preferred +0 -2
- package/test/suites/data/54/merged +0 -3
- package/test/suites/data/54/other +0 -2
- package/test/suites/data/54/preferred +0 -2
- package/test/suites/data/55/merged +0 -3
- package/test/suites/data/55/other +0 -2
- package/test/suites/data/55/preferred +0 -2
- package/test/suites/data/56/merged +0 -2
- package/test/suites/data/56/other +0 -2
- package/test/suites/data/56/preferred +0 -2
- package/test/suites/data/57/descr +0 -1
- package/test/suites/data/57/merged +0 -4
- package/test/suites/data/57/other +0 -4
- package/test/suites/data/57/preferred +0 -4
- package/test/suites/data/58/descr +0 -1
- package/test/suites/data/58/merged +0 -2
- package/test/suites/data/58/other +0 -2
- package/test/suites/data/58/preferred +0 -2
- package/test/suites/data/59/descr +0 -1
- package/test/suites/data/59/merged +0 -2
- package/test/suites/data/59/other +0 -2
- package/test/suites/data/59/preferred +0 -2
- package/test/suites/data/6/descr +0 -1
- package/test/suites/data/6/merged +0 -2
- package/test/suites/data/6/other +0 -3
- package/test/suites/data/6/preferred +0 -2
- package/test/suites/data/60/descr +0 -1
- package/test/suites/data/60/merged +0 -2
- package/test/suites/data/60/other +0 -2
- package/test/suites/data/60/preferred +0 -2
- package/test/suites/data/61/descr +0 -1
- package/test/suites/data/61/merged +0 -2
- package/test/suites/data/61/other +0 -2
- package/test/suites/data/61/preferred +0 -2
- package/test/suites/data/62/descr +0 -1
- package/test/suites/data/62/merged +0 -3
- package/test/suites/data/62/other +0 -2
- package/test/suites/data/62/preferred +0 -2
- package/test/suites/data/63/descr +0 -1
- package/test/suites/data/63/merged +0 -3
- package/test/suites/data/63/other +0 -2
- package/test/suites/data/63/preferred +0 -2
- package/test/suites/data/64/merged +0 -2
- package/test/suites/data/64/other +0 -2
- package/test/suites/data/64/preferred +0 -2
- package/test/suites/data/65/merged +0 -3
- package/test/suites/data/65/other +0 -2
- package/test/suites/data/65/preferred +0 -2
- package/test/suites/data/66/merged +0 -2
- package/test/suites/data/66/other +0 -2
- package/test/suites/data/66/preferred +0 -2
- package/test/suites/data/67/merged +0 -2
- package/test/suites/data/67/other +0 -2
- package/test/suites/data/67/preferred +0 -2
- package/test/suites/data/68/merged +0 -2
- package/test/suites/data/68/other +0 -2
- package/test/suites/data/68/preferred +0 -2
- package/test/suites/data/69/merged +0 -2
- package/test/suites/data/69/other +0 -2
- package/test/suites/data/69/preferred +0 -2
- package/test/suites/data/7/descr +0 -1
- package/test/suites/data/7/merged +0 -4
- package/test/suites/data/7/other +0 -3
- package/test/suites/data/7/preferred +0 -3
- package/test/suites/data/70/merged +0 -2
- package/test/suites/data/70/other +0 -2
- package/test/suites/data/70/preferred +0 -2
- package/test/suites/data/71/merged +0 -3
- package/test/suites/data/71/other +0 -2
- package/test/suites/data/71/preferred +0 -2
- package/test/suites/data/72/merged +0 -5
- package/test/suites/data/72/other +0 -2
- package/test/suites/data/72/preferred +0 -4
- package/test/suites/data/73/merged +0 -3
- package/test/suites/data/73/other +0 -3
- package/test/suites/data/73/preferred +0 -3
- package/test/suites/data/74/1/merged +0 -3
- package/test/suites/data/74/1/other +0 -3
- package/test/suites/data/74/1/preferred +0 -2
- package/test/suites/data/74/merged +0 -4
- package/test/suites/data/74/other +0 -4
- package/test/suites/data/74/preferred +0 -2
- package/test/suites/data/75/74/1/merged +0 -3
- package/test/suites/data/75/74/1/other +0 -3
- package/test/suites/data/75/74/1/preferred +0 -2
- package/test/suites/data/75/74/merged +0 -4
- package/test/suites/data/75/74/other +0 -4
- package/test/suites/data/75/74/preferred +0 -2
- package/test/suites/data/75/merged +0 -4
- package/test/suites/data/75/other +0 -3
- package/test/suites/data/75/preferred +0 -2
- package/test/suites/data/76/merged +0 -2
- package/test/suites/data/76/other +0 -2
- package/test/suites/data/76/preferred +0 -2
- package/test/suites/data/77/descr +0 -1
- package/test/suites/data/77/merged +0 -2
- package/test/suites/data/77/other +0 -2
- package/test/suites/data/77/preferred +0 -2
- package/test/suites/data/78/merged +0 -3
- package/test/suites/data/78/other +0 -2
- package/test/suites/data/78/preferred +0 -2
- package/test/suites/data/79/merged +0 -2
- package/test/suites/data/79/other +0 -2
- package/test/suites/data/79/preferred +0 -2
- package/test/suites/data/8/descr +0 -1
- package/test/suites/data/8/merged +0 -3
- package/test/suites/data/8/other +0 -3
- package/test/suites/data/8/preferred +0 -3
- package/test/suites/data/80/merged +0 -3
- package/test/suites/data/80/other +0 -2
- package/test/suites/data/80/preferred +0 -2
- package/test/suites/data/81/merged +0 -2
- package/test/suites/data/81/other +0 -2
- package/test/suites/data/81/preferred +0 -2
- package/test/suites/data/82/merged +0 -2
- package/test/suites/data/82/other +0 -2
- package/test/suites/data/82/preferred +0 -2
- package/test/suites/data/83/merged +0 -2
- package/test/suites/data/83/other +0 -2
- package/test/suites/data/83/preferred +0 -1
- package/test/suites/data/84/merged +0 -2
- package/test/suites/data/84/other +0 -2
- package/test/suites/data/84/preferred +0 -1
- package/test/suites/data/85/merged +0 -2
- package/test/suites/data/85/other +0 -2
- package/test/suites/data/85/preferred +0 -2
- package/test/suites/data/86/merged +0 -2
- package/test/suites/data/86/other +0 -2
- package/test/suites/data/86/preferred +0 -1
- package/test/suites/data/87/merged +0 -2
- package/test/suites/data/87/other +0 -2
- package/test/suites/data/87/preferred +0 -1
- package/test/suites/data/88/merged +0 -2
- package/test/suites/data/88/other +0 -2
- package/test/suites/data/88/preferred +0 -1
- package/test/suites/data/9/descr +0 -1
- package/test/suites/data/9/merged +0 -2
- package/test/suites/data/9/other +0 -2
- package/test/suites/data/9/preferred +0 -2
- 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
|
|
1
|
+
# Merge MARC records [](https://npmjs.org/package/@natlibfi/marc-record-merge)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Merge MARC records
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
|
+
### COPY
|
|
6
7
|
|
|
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
|
+
```
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
### compareTagsOnly (Defaults false)
|
|
19
|
+
```
|
|
20
|
+
{tagPattern: /010/u, compareTagsOnly: false}
|
|
11
21
|
```
|
|
12
22
|
|
|
13
|
-
|
|
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
|
-
|
|
30
|
+
If base has field with that tag 011 source field is ignored
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
### compareWithoutIndicators (Defaults false)
|
|
33
|
+
```
|
|
34
|
+
{tagPattern: /010/u, compareWithoutIndicators: false}
|
|
35
|
+
```
|
|
18
36
|
|
|
19
|
-
|
|
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
|
-
|
|
45
|
+
When base and source fields are compared, tag differences are ignored
|
|
24
46
|
|
|
47
|
+
### subfieldsMustBeIdentical (Defaults true)
|
|
25
48
|
```
|
|
26
|
-
|
|
27
|
-
npm run test-browser
|
|
49
|
+
{tagPattern: /010/u, subfieldsMustBeIdentical: true}
|
|
28
50
|
```
|
|
29
51
|
|
|
30
|
-
|
|
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
|
-
|
|
67
|
+
When base and source fields are compared, excluded subfields are ignored
|
|
33
68
|
|
|
34
|
-
###
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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
|
-
|
|
102
|
+
When comparing or copying field dropped fields are ignored
|
|
247
103
|
|
|
248
|
-
|
|
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
|
-
|
|
251
|
-
|
|
111
|
+
### baseValidators (Defaults {subfieldValues: false})
|
|
112
|
+
```
|
|
113
|
+
{tagPattern: /010/u, baseValidators: {fields: true, subfields: true, subfieldValues: true}}
|
|
252
114
|
```
|
|
253
115
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
```
|
|
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
|
-
|
|
275
|
-
|
|
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)
|
|
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 **
|
|
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"}
|