@natlibfi/marc-record-validators-melinda 3.2.0 → 3.3.14-alpha.3
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 +2 -0
- package/.github/dependabot.yml +40 -0
- package/.github/workflows/melinda-node-tests.yml +61 -0
- package/LICENSE.txt +21 -661
- package/README.md +4 -5
- package/dist/access-rights.js +94 -0
- package/dist/access-rights.js.map +1 -0
- package/dist/access-rights.spec.js +150 -0
- package/dist/access-rights.spec.js.map +1 -0
- package/dist/double-commas.js +17 -27
- package/dist/double-commas.js.map +1 -1
- package/dist/double-commas.spec.js +72 -27
- package/dist/double-commas.spec.js.map +1 -1
- package/dist/duplicates-ind1.js +47 -27
- package/dist/duplicates-ind1.js.map +1 -1
- package/dist/duplicates-ind1.spec.js +44 -27
- package/dist/duplicates-ind1.spec.js.map +1 -1
- package/dist/empty-fields.js +79 -29
- package/dist/empty-fields.js.map +1 -1
- package/dist/empty-fields.spec.js +113 -27
- package/dist/empty-fields.spec.js.map +1 -1
- package/dist/ending-punctuation-conf.js +772 -129
- package/dist/ending-punctuation-conf.js.map +1 -1
- package/dist/ending-punctuation.js +291 -72
- package/dist/ending-punctuation.js.map +1 -1
- package/dist/ending-punctuation.spec.js +2638 -118
- package/dist/ending-punctuation.spec.js.map +1 -1
- package/dist/ending-whitespace.js +58 -0
- package/dist/ending-whitespace.js.map +1 -0
- package/dist/ending-whitespace.spec.js +42 -0
- package/dist/ending-whitespace.spec.js.map +1 -0
- package/dist/field-521-fix.js +96 -0
- package/dist/field-521-fix.js.map +1 -0
- package/dist/field-521-fix.spec.js +51 -0
- package/dist/field-521-fix.spec.js.map +1 -0
- package/dist/field-exclusion.js +214 -63
- package/dist/field-exclusion.js.map +1 -1
- package/dist/field-exclusion.spec.js +1057 -31
- package/dist/field-exclusion.spec.js.map +1 -1
- package/dist/field-structure.js +249 -78
- package/dist/field-structure.js.map +1 -1
- package/dist/field-structure.spec.js +534 -31
- package/dist/field-structure.spec.js.map +1 -1
- package/dist/fields-present.js +31 -27
- package/dist/fields-present.js.map +1 -1
- package/dist/fields-present.spec.js +120 -27
- package/dist/fields-present.spec.js.map +1 -1
- package/dist/fixed-fields.js +72 -27
- package/dist/fixed-fields.js.map +1 -1
- package/dist/fixed-fields.spec.js +139 -27
- package/dist/fixed-fields.spec.js.map +1 -1
- package/dist/identical-fields.js +42 -28
- package/dist/identical-fields.js.map +1 -1
- package/dist/identical-fields.spec.js +98 -27
- package/dist/identical-fields.spec.js.map +1 -1
- package/dist/index.js +202 -27
- package/dist/index.js.map +1 -1
- package/dist/indicator-fixes.js +191 -0
- package/dist/indicator-fixes.js.map +1 -0
- package/dist/indicator-fixes.spec.js +51 -0
- package/dist/indicator-fixes.spec.js.map +1 -0
- package/dist/isbn-issn.js +266 -27
- package/dist/isbn-issn.js.map +1 -1
- package/dist/isbn-issn.spec.js +594 -27
- package/dist/isbn-issn.spec.js.map +1 -1
- package/dist/item-language.js +171 -27
- package/dist/item-language.js.map +1 -1
- package/dist/item-language.spec.js +305 -27
- package/dist/item-language.spec.js.map +1 -1
- package/dist/mergeField500Lisapainokset.js +155 -0
- package/dist/mergeField500Lisapainokset.js.map +1 -0
- package/dist/mergeField500Lisapainokset.spec.js +51 -0
- package/dist/mergeField500Lisapainokset.spec.js.map +1 -0
- package/dist/mergeRelatorTermFields.js +140 -0
- package/dist/mergeRelatorTermFields.js.map +1 -0
- package/dist/mergeRelatorTermFields.spec.js +51 -0
- package/dist/mergeRelatorTermFields.spec.js.map +1 -0
- package/dist/multiple-subfield-0.js +120 -0
- package/dist/multiple-subfield-0.js.map +1 -0
- package/dist/multiple-subfield-0.spec.js +51 -0
- package/dist/multiple-subfield-0.spec.js.map +1 -0
- package/dist/non-breaking-space.js +61 -0
- package/dist/non-breaking-space.js.map +1 -0
- package/dist/non-breaking-space.spec.js +42 -0
- package/dist/non-breaking-space.spec.js.map +1 -0
- package/dist/normalize-identifiers.js +210 -0
- package/dist/normalize-identifiers.js.map +1 -0
- package/dist/normalize-identifiers.spec.js +51 -0
- package/dist/normalize-identifiers.spec.js.map +1 -0
- package/dist/normalize-utf8-diacritics.js +140 -0
- package/dist/normalize-utf8-diacritics.js.map +1 -0
- package/dist/normalize-utf8-diacritics.spec.js +51 -0
- package/dist/normalize-utf8-diacritics.spec.js.map +1 -0
- package/dist/punctuation/index.js +281 -0
- package/dist/punctuation/index.js.map +1 -0
- package/dist/punctuation/rules/aut.js +332 -0
- package/dist/punctuation/rules/aut.js.map +1 -0
- package/dist/punctuation/rules/bib.js +374 -0
- package/dist/punctuation/rules/bib.js.map +1 -0
- package/dist/punctuation/rules/index.js +21 -0
- package/dist/punctuation/rules/index.js.map +1 -0
- package/dist/punctuation.spec.js +51 -0
- package/dist/punctuation.spec.js.map +1 -0
- package/dist/punctuation2.js +726 -0
- package/dist/punctuation2.js.map +1 -0
- package/dist/punctuation2.spec.js +51 -0
- package/dist/punctuation2.spec.js.map +1 -0
- package/dist/reindexSubfield6OccurenceNumbers.js +199 -0
- package/dist/reindexSubfield6OccurenceNumbers.js.map +1 -0
- package/dist/reindexSubfield6OccurenceNumbers.spec.js +51 -0
- package/dist/reindexSubfield6OccurenceNumbers.spec.js.map +1 -0
- package/dist/removeDuplicateDataFields.js +405 -0
- package/dist/removeDuplicateDataFields.js.map +1 -0
- package/dist/removeDuplicateDataFields.spec.js +51 -0
- package/dist/removeDuplicateDataFields.spec.js.map +1 -0
- package/dist/removeInferiorDataFields.js +245 -0
- package/dist/removeInferiorDataFields.js.map +1 -0
- package/dist/removeInferiorDataFields.spec.js +51 -0
- package/dist/removeInferiorDataFields.spec.js.map +1 -0
- package/dist/resolvable-ext-references-melinda.js +112 -31
- package/dist/resolvable-ext-references-melinda.js.map +1 -1
- package/dist/resolvable-ext-references-melinda.spec.js +166 -27
- package/dist/resolvable-ext-references-melinda.spec.js.map +1 -1
- package/dist/resolveOrphanedSubfield6s.js +116 -0
- package/dist/resolveOrphanedSubfield6s.js.map +1 -0
- package/dist/resolveOrphanedSubfield6s.spec.js +51 -0
- package/dist/resolveOrphanedSubfield6s.spec.js.map +1 -0
- package/dist/sanitize-vocabulary-source-codes.js +93 -0
- package/dist/sanitize-vocabulary-source-codes.js.map +1 -0
- package/dist/sanitize-vocabulary-source-codes.spec.js +51 -0
- package/dist/sanitize-vocabulary-source-codes.spec.js.map +1 -0
- package/dist/sort-tags.js +53 -27
- package/dist/sort-tags.js.map +1 -1
- package/dist/sort-tags.spec.js +206 -27
- package/dist/sort-tags.spec.js.map +1 -1
- package/dist/sortRelatorTerms.js +135 -0
- package/dist/sortRelatorTerms.js.map +1 -0
- package/dist/sortRelatorTerms.spec.js +51 -0
- package/dist/sortRelatorTerms.spec.js.map +1 -0
- package/dist/sortSubfields.js +279 -0
- package/dist/sortSubfields.js.map +1 -0
- package/dist/sortSubfields.spec.js +51 -0
- package/dist/sortSubfields.spec.js.map +1 -0
- package/dist/stripPunctuation.js +49 -0
- package/dist/stripPunctuation.js.map +1 -0
- package/dist/stripPunctuation.spec.js +51 -0
- package/dist/stripPunctuation.spec.js.map +1 -0
- package/dist/subfield-exclusion.js +174 -57
- package/dist/subfield-exclusion.js.map +1 -1
- package/dist/subfield-exclusion.spec.js +521 -31
- package/dist/subfield-exclusion.spec.js.map +1 -1
- package/dist/subfield6Utils.js +457 -0
- package/dist/subfield6Utils.js.map +1 -0
- package/dist/subfield8Utils.js +99 -0
- package/dist/subfield8Utils.js.map +1 -0
- package/dist/typeOfDate-008.js +48 -0
- package/dist/typeOfDate-008.js.map +1 -0
- package/dist/typeOfDate-008.spec.js +47 -0
- package/dist/typeOfDate-008.spec.js.map +1 -0
- package/dist/unicode-decomposition.js +139 -30
- package/dist/unicode-decomposition.js.map +1 -1
- package/dist/unicode-decomposition.spec.js +90 -27
- package/dist/unicode-decomposition.spec.js.map +1 -1
- package/dist/update-field-540.js +119 -0
- package/dist/update-field-540.js.map +1 -0
- package/dist/update-field-540.spec.js +51 -0
- package/dist/update-field-540.spec.js.map +1 -0
- package/dist/urn.js +185 -0
- package/dist/urn.js.map +1 -0
- package/dist/urn.spec.js +238 -0
- package/dist/urn.spec.js.map +1 -0
- package/dist/utils.js +58 -0
- package/dist/utils.js.map +1 -0
- package/package.json +114 -124
- package/src/access-rights.js +84 -0
- package/src/access-rights.spec.js +126 -0
- package/src/double-commas.js +12 -49
- package/src/double-commas.spec.js +50 -82
- package/src/duplicates-ind1.js +34 -74
- package/src/duplicates-ind1.spec.js +39 -117
- package/src/empty-fields.js +62 -74
- package/src/empty-fields.spec.js +134 -207
- package/src/ending-punctuation-conf.js +679 -644
- package/src/ending-punctuation.js +260 -250
- package/src/ending-punctuation.spec.js +2545 -2322
- package/src/ending-whitespace.js +40 -0
- package/src/ending-whitespace.spec.js +44 -0
- package/src/field-521-fix.js +92 -0
- package/src/field-521-fix.spec.js +52 -0
- package/src/field-exclusion.js +197 -215
- package/src/field-exclusion.spec.js +883 -481
- package/src/field-structure.js +213 -271
- package/src/field-structure.spec.js +597 -474
- package/src/fields-present.js +19 -49
- package/src/fields-present.spec.js +90 -91
- package/src/fixed-fields.js +61 -94
- package/src/fixed-fields.spec.js +81 -125
- package/src/identical-fields.js +29 -48
- package/src/identical-fields.spec.js +114 -146
- package/src/index.js +41 -46
- package/src/indicator-fixes.js +211 -0
- package/src/indicator-fixes.spec.js +52 -0
- package/src/isbn-issn.js +254 -106
- package/src/isbn-issn.spec.js +399 -172
- package/src/item-language.js +158 -195
- package/src/item-language.spec.js +314 -306
- package/src/mergeField500Lisapainokset.js +153 -0
- package/src/mergeField500Lisapainokset.spec.js +52 -0
- package/src/mergeRelatorTermFields.js +143 -0
- package/src/mergeRelatorTermFields.spec.js +52 -0
- package/src/multiple-subfield-0.js +129 -0
- package/src/multiple-subfield-0.spec.js +52 -0
- package/src/non-breaking-space.js +49 -0
- package/src/non-breaking-space.spec.js +44 -0
- package/src/normalize-identifiers.js +197 -0
- package/src/normalize-identifiers.spec.js +52 -0
- package/src/normalize-utf8-diacritics.js +141 -0
- package/src/normalize-utf8-diacritics.spec.js +52 -0
- package/src/punctuation/index.js +292 -0
- package/src/punctuation/rules/aut.js +372 -0
- package/src/punctuation/rules/bib.js +420 -0
- package/src/punctuation/rules/index.js +7 -0
- package/src/punctuation.spec.js +52 -0
- package/src/punctuation2.js +441 -0
- package/src/punctuation2.spec.js +52 -0
- package/src/reindexSubfield6OccurenceNumbers.js +210 -0
- package/src/reindexSubfield6OccurenceNumbers.spec.js +52 -0
- package/src/removeDuplicateDataFields.js +447 -0
- package/src/removeDuplicateDataFields.spec.js +52 -0
- package/src/removeInferiorDataFields.js +259 -0
- package/src/removeInferiorDataFields.spec.js +52 -0
- package/src/resolvable-ext-references-melinda.js +89 -122
- package/src/resolvable-ext-references-melinda.spec.js +168 -198
- package/src/resolveOrphanedSubfield6s.js +115 -0
- package/src/resolveOrphanedSubfield6s.spec.js +52 -0
- package/src/sanitize-vocabulary-source-codes.js +99 -0
- package/src/sanitize-vocabulary-source-codes.spec.js +52 -0
- package/src/sort-tags.js +34 -60
- package/src/sort-tags.spec.js +256 -290
- package/src/sortRelatorTerms.js +142 -0
- package/src/sortRelatorTerms.spec.js +52 -0
- package/src/sortSubfields.js +176 -0
- package/src/sortSubfields.spec.js +52 -0
- package/src/stripPunctuation.js +42 -0
- package/src/stripPunctuation.spec.js +52 -0
- package/src/subfield-exclusion.js +157 -180
- package/src/subfield-exclusion.spec.js +507 -453
- package/src/subfield6Utils.js +485 -0
- package/src/subfield8Utils.js +102 -0
- package/src/typeOfDate-008.js +40 -0
- package/src/typeOfDate-008.spec.js +47 -0
- package/src/unicode-decomposition.js +130 -145
- package/src/unicode-decomposition.spec.js +89 -115
- package/src/update-field-540.js +99 -0
- package/src/update-field-540.spec.js +52 -0
- package/src/urn.js +164 -0
- package/src/urn.spec.js +231 -0
- package/src/utils.js +52 -0
- package/test-fixtures/duplicates-ind1/01/expectedResult.json +4 -0
- package/test-fixtures/duplicates-ind1/01/metadata.json +4 -0
- package/test-fixtures/duplicates-ind1/01/record.json +16 -0
- package/test-fixtures/duplicates-ind1/02/expectedResult.json +6 -0
- package/test-fixtures/duplicates-ind1/02/metadata.json +4 -0
- package/test-fixtures/duplicates-ind1/02/record.json +16 -0
- package/test-fixtures/duplicates-ind1/03/expectedResult.json +13 -0
- package/test-fixtures/duplicates-ind1/03/metadata.json +6 -0
- package/test-fixtures/duplicates-ind1/03/record.json +16 -0
- package/test-fixtures/ending-whitespace/01/expectedResult.json +4 -0
- package/test-fixtures/ending-whitespace/01/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/01/record.json +15 -0
- package/test-fixtures/ending-whitespace/02/expectedResult.json +4 -0
- package/test-fixtures/ending-whitespace/02/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/02/record.json +15 -0
- package/test-fixtures/ending-whitespace/03/expectedResult.json +17 -0
- package/test-fixtures/ending-whitespace/03/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/03/record.json +15 -0
- package/test-fixtures/ending-whitespace/04/expectedResult.json +10 -0
- package/test-fixtures/ending-whitespace/04/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/04/record.json +8 -0
- package/test-fixtures/fix521/01/expectedResult.json +6 -0
- package/test-fixtures/fix521/01/metadata.json +5 -0
- package/test-fixtures/fix521/01/record.json +13 -0
- package/test-fixtures/fix521/02/expectedResult.json +15 -0
- package/test-fixtures/fix521/02/metadata.json +5 -0
- package/test-fixtures/fix521/02/record.json +13 -0
- package/test-fixtures/fix521/03/expectedResult.json +5 -0
- package/test-fixtures/fix521/03/metadata.json +5 -0
- package/test-fixtures/fix521/03/record.json +13 -0
- package/test-fixtures/indicator-fixes/01/expectedResult.json +9 -0
- package/test-fixtures/indicator-fixes/01/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/01/record.json +64 -0
- package/test-fixtures/indicator-fixes/02/expectedResult.json +66 -0
- package/test-fixtures/indicator-fixes/02/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/02/record.json +64 -0
- package/test-fixtures/indicator-fixes/03/expectedResult.json +55 -0
- package/test-fixtures/indicator-fixes/03/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/03/record.json +54 -0
- package/test-fixtures/indicator-fixes/04/expectedResult.json +66 -0
- package/test-fixtures/indicator-fixes/04/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/04/record.json +65 -0
- package/test-fixtures/indicator-fixes/05/expectedResult.json +66 -0
- package/test-fixtures/indicator-fixes/05/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/05/record.json +65 -0
- package/test-fixtures/indicator-fixes/06/expectedResult.json +75 -0
- package/test-fixtures/indicator-fixes/06/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/06/record.json +74 -0
- package/test-fixtures/lisapainokset/fixer/01/expectedResult.json +37 -0
- package/test-fixtures/lisapainokset/fixer/01/metadata.json +6 -0
- package/test-fixtures/lisapainokset/fixer/01/record.json +61 -0
- package/test-fixtures/lisapainokset/fixer/02/expectedResult.json +44 -0
- package/test-fixtures/lisapainokset/fixer/02/metadata.json +6 -0
- package/test-fixtures/lisapainokset/fixer/02/record.json +45 -0
- package/test-fixtures/lisapainokset/fixer/03/expectedResult.json +21 -0
- package/test-fixtures/lisapainokset/fixer/03/metadata.json +6 -0
- package/test-fixtures/lisapainokset/fixer/03/record.json +45 -0
- package/test-fixtures/lisapainokset/validator/01/expectedResult.json +7 -0
- package/test-fixtures/lisapainokset/validator/01/metadata.json +6 -0
- package/test-fixtures/lisapainokset/validator/01/record.json +45 -0
- package/test-fixtures/lisapainokset/validator/02/expectedResult.json +6 -0
- package/test-fixtures/lisapainokset/validator/02/metadata.json +6 -0
- package/test-fixtures/lisapainokset/validator/02/record.json +61 -0
- package/test-fixtures/lisapainokset/validator/03/expectedResult.json +4 -0
- package/test-fixtures/lisapainokset/validator/03/metadata.json +6 -0
- package/test-fixtures/lisapainokset/validator/03/record.json +37 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/01/expectedResult.json +14 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/01/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/01/record.json +16 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/02/expectedResult.json +17 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/02/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/02/record.json +23 -0
- package/test-fixtures/mergeRelatorTermFields/validator/01/expectedResult.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/validator/01/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/validator/01/record.json +16 -0
- package/test-fixtures/mergeRelatorTermFields/validator/02/expectedResult.json +4 -0
- package/test-fixtures/mergeRelatorTermFields/validator/02/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/validator/02/record.json +16 -0
- package/test-fixtures/non-breaking-space/01/expectedResult.json +4 -0
- package/test-fixtures/non-breaking-space/01/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/01/record.json +15 -0
- package/test-fixtures/non-breaking-space/02/expectedResult.json +4 -0
- package/test-fixtures/non-breaking-space/02/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/02/record.json +15 -0
- package/test-fixtures/non-breaking-space/03/expectedResult.json +17 -0
- package/test-fixtures/non-breaking-space/03/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/03/record.json +15 -0
- package/test-fixtures/non-breaking-space/04/expectedResult.json +21 -0
- package/test-fixtures/non-breaking-space/04/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/04/record.json +19 -0
- package/test-fixtures/normalize-identifiers/01/expectedResult.json +8 -0
- package/test-fixtures/normalize-identifiers/01/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/01/record.json +81 -0
- package/test-fixtures/normalize-identifiers/02/expectedResult.json +92 -0
- package/test-fixtures/normalize-identifiers/02/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/02/record.json +92 -0
- package/test-fixtures/normalize-identifiers/03/expectedResult.json +63 -0
- package/test-fixtures/normalize-identifiers/03/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/03/record.json +61 -0
- package/test-fixtures/normalize-identifiers/04/expectedResult.json +79 -0
- package/test-fixtures/normalize-identifiers/04/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/04/record.json +77 -0
- package/test-fixtures/normalize-utf8-diacritics/01/expectedResult.json +7 -0
- package/test-fixtures/normalize-utf8-diacritics/01/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/01/record.json +39 -0
- package/test-fixtures/normalize-utf8-diacritics/02/expectedResult.json +41 -0
- package/test-fixtures/normalize-utf8-diacritics/02/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/02/record.json +39 -0
- package/test-fixtures/normalize-utf8-diacritics/03/expectedResult.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/03/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/03/record.json +37 -0
- package/test-fixtures/normalize-utf8-diacritics/04/expectedResult.json +41 -0
- package/test-fixtures/normalize-utf8-diacritics/04/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/04/record.json +39 -0
- package/test-fixtures/normalize-utf8-diacritics/05/expectedResult.json +41 -0
- package/test-fixtures/normalize-utf8-diacritics/05/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/05/record.json +41 -0
- package/test-fixtures/punctuation/01/expectedResult.json +3 -0
- package/test-fixtures/punctuation/01/metadata.json +4 -0
- package/test-fixtures/punctuation/01/record.json +18 -0
- package/test-fixtures/punctuation/02/expectedResult.json +3 -0
- package/test-fixtures/punctuation/02/metadata.json +4 -0
- package/test-fixtures/punctuation/02/record.json +18 -0
- package/test-fixtures/punctuation/03/expectedResult.json +21 -0
- package/test-fixtures/punctuation/03/metadata.json +5 -0
- package/test-fixtures/punctuation/03/record.json +19 -0
- package/test-fixtures/punctuation/04/expectedResult.json +21 -0
- package/test-fixtures/punctuation/04/metadata.json +5 -0
- package/test-fixtures/punctuation/04/record.json +19 -0
- package/test-fixtures/punctuation/05/expectedResult.json +44 -0
- package/test-fixtures/punctuation/05/metadata.json +5 -0
- package/test-fixtures/punctuation/05/record.json +42 -0
- package/test-fixtures/punctuation2/01/expectedResult.json +12 -0
- package/test-fixtures/punctuation2/01/metadata.json +6 -0
- package/test-fixtures/punctuation2/01/record.json +37 -0
- package/test-fixtures/punctuation2/02/expectedResult.json +4 -0
- package/test-fixtures/punctuation2/02/metadata.json +6 -0
- package/test-fixtures/punctuation2/02/record.json +14 -0
- package/test-fixtures/punctuation2/04/expectedResult.json +7 -0
- package/test-fixtures/punctuation2/04/metadata.json +6 -0
- package/test-fixtures/punctuation2/04/record.json +22 -0
- package/test-fixtures/punctuation2/05/expectedResult.json +6 -0
- package/test-fixtures/punctuation2/05/metadata.json +6 -0
- package/test-fixtures/punctuation2/05/record.json +12 -0
- package/test-fixtures/punctuation2/98/expectedResult.json +45 -0
- package/test-fixtures/punctuation2/98/metadata.json +6 -0
- package/test-fixtures/punctuation2/98/record.json +43 -0
- package/test-fixtures/punctuation2/99/expectedResult.json +15 -0
- package/test-fixtures/punctuation2/99/metadata.json +6 -0
- package/test-fixtures/punctuation2/99/record.json +14 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f01/expectedResult.json +35 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f01/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f01/record.json +34 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f02/expectedResult.json +53 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f02/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f02/record.json +51 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f03/expectedResult.json +46 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f03/metadata.json +7 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f03/record.json +44 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v01/expectedResult.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v01/metadata.json +5 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v01/record.json +31 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v02/expectedResult.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v02/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v02/record.json +38 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v03/expectedResult.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v03/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v03/record.json +30 -0
- package/test-fixtures/remove-duplicate-datafields/f01/expectedResult.json +35 -0
- package/test-fixtures/remove-duplicate-datafields/f01/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f01/record.json +34 -0
- package/test-fixtures/remove-duplicate-datafields/f03/expectedResult.json +20 -0
- package/test-fixtures/remove-duplicate-datafields/f03/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f03/record.json +33 -0
- package/test-fixtures/remove-duplicate-datafields/f03b/expectedResult.json +20 -0
- package/test-fixtures/remove-duplicate-datafields/f03b/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f03b/record.json +35 -0
- package/test-fixtures/remove-duplicate-datafields/f03c/expectedResult.json +25 -0
- package/test-fixtures/remove-duplicate-datafields/f03c/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f03c/record.json +43 -0
- package/test-fixtures/remove-duplicate-datafields/f04/expectedResult.json +31 -0
- package/test-fixtures/remove-duplicate-datafields/f04/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f04/record.json +41 -0
- package/test-fixtures/remove-duplicate-datafields/f05/expectedResult.json +23 -0
- package/test-fixtures/remove-duplicate-datafields/f05/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f05/record.json +29 -0
- package/test-fixtures/remove-duplicate-datafields/f06/expectedResult.json +24 -0
- package/test-fixtures/remove-duplicate-datafields/f06/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f06/record.json +41 -0
- package/test-fixtures/remove-duplicate-datafields/f07/expectedResult.json +15 -0
- package/test-fixtures/remove-duplicate-datafields/f07/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f07/record.json +21 -0
- package/test-fixtures/remove-duplicate-datafields/f08/expectedResult.json +21 -0
- package/test-fixtures/remove-duplicate-datafields/f08/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f08/record.json +33 -0
- package/test-fixtures/remove-duplicate-datafields/f09/expectedResult.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f09/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f09/record.json +9 -0
- package/test-fixtures/remove-duplicate-datafields/f10/expectedResult.json +15 -0
- package/test-fixtures/remove-duplicate-datafields/f10/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f10/record.json +24 -0
- package/test-fixtures/remove-duplicate-datafields/f11/expectedResult.json +30 -0
- package/test-fixtures/remove-duplicate-datafields/f11/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f11/record.json +53 -0
- package/test-fixtures/remove-duplicate-datafields/v01/expectedResult.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v01/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v01/record.json +31 -0
- package/test-fixtures/remove-duplicate-datafields/v02/expectedResult.json +10 -0
- package/test-fixtures/remove-duplicate-datafields/v02/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v02/record.json +45 -0
- package/test-fixtures/remove-duplicate-datafields/v03/expectedResult.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v03/metadata.json +7 -0
- package/test-fixtures/remove-duplicate-datafields/v03/record.json +37 -0
- package/test-fixtures/remove-duplicate-datafields/v04/expectedResult.json +8 -0
- package/test-fixtures/remove-duplicate-datafields/v04/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v04/record.json +41 -0
- package/test-fixtures/remove-inferior-datafields/f01/expectedResult.json +21 -0
- package/test-fixtures/remove-inferior-datafields/f01/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f01/record.json +31 -0
- package/test-fixtures/remove-inferior-datafields/f03/expectedResult.json +16 -0
- package/test-fixtures/remove-inferior-datafields/f03/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f03/record.json +27 -0
- package/test-fixtures/remove-inferior-datafields/f04/expectedResult.json +31 -0
- package/test-fixtures/remove-inferior-datafields/f04/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f04/record.json +38 -0
- package/test-fixtures/remove-inferior-datafields/f05/expectedResult.json +34 -0
- package/test-fixtures/remove-inferior-datafields/f05/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f05/record.json +41 -0
- package/test-fixtures/remove-inferior-datafields/f06/expectedResult.json +16 -0
- package/test-fixtures/remove-inferior-datafields/f06/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f06/record.json +20 -0
- package/test-fixtures/remove-inferior-datafields/v01/expectedResult.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v01/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v01/record.json +31 -0
- package/test-fixtures/remove-inferior-datafields/v02/expectedResult.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v02/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v02/record.json +21 -0
- package/test-fixtures/remove-orphanded-sf6s/f01/expectedResult.json +35 -0
- package/test-fixtures/remove-orphanded-sf6s/f01/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/f01/record.json +34 -0
- package/test-fixtures/remove-orphanded-sf6s/f02/expectedResult.json +40 -0
- package/test-fixtures/remove-orphanded-sf6s/f02/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/f02/record.json +43 -0
- package/test-fixtures/remove-orphanded-sf6s/v01/expectedResult.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v01/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v01/record.json +31 -0
- package/test-fixtures/remove-orphanded-sf6s/v02/expectedResult.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v02/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v02/record.json +31 -0
- package/test-fixtures/resolvable-ext-references-melinda.js +0 -27
- package/test-fixtures/sanitize-vocabulary-source-codes/f01/expectedResult.json +32 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f01/metadata.json +6 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f01/record.json +32 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f02/expectedResult.json +24 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f02/metadata.json +6 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f02/record.json +24 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/v01/expectedResult.json +12 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/v01/metadata.json +6 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/v01/record.json +24 -0
- package/test-fixtures/sort-relator-terms/f01/expectedResult.json +23 -0
- package/test-fixtures/sort-relator-terms/f01/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/f01/record.json +22 -0
- package/test-fixtures/sort-relator-terms/f02/expectedResult.json +26 -0
- package/test-fixtures/sort-relator-terms/f02/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/f02/record.json +22 -0
- package/test-fixtures/sort-relator-terms/v01/expectedResult.json +5 -0
- package/test-fixtures/sort-relator-terms/v01/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/v01/record.json +22 -0
- package/test-fixtures/sort-relator-terms/v02/expectedResult.json +6 -0
- package/test-fixtures/sort-relator-terms/v02/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/v02/record.json +14 -0
- package/test-fixtures/sort-subfields/f01/expectedResult.json +24 -0
- package/test-fixtures/sort-subfields/f01/metadata.json +6 -0
- package/test-fixtures/sort-subfields/f01/record.json +20 -0
- package/test-fixtures/sort-subfields/v01/expectedResult.json +5 -0
- package/test-fixtures/sort-subfields/v01/metadata.json +6 -0
- package/test-fixtures/sort-subfields/v01/record.json +24 -0
- package/test-fixtures/sort-subfields/v02/expectedResult.json +6 -0
- package/test-fixtures/sort-subfields/v02/metadata.json +6 -0
- package/test-fixtures/sort-subfields/v02/record.json +8 -0
- package/test-fixtures/strip-punctuation/01/expectedResult.json +12 -0
- package/test-fixtures/strip-punctuation/01/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/01/record.json +37 -0
- package/test-fixtures/strip-punctuation/02/expectedResult.json +4 -0
- package/test-fixtures/strip-punctuation/02/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/02/record.json +14 -0
- package/test-fixtures/strip-punctuation/04/expectedResult.json +6 -0
- package/test-fixtures/strip-punctuation/04/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/04/record.json +22 -0
- package/test-fixtures/strip-punctuation/05/expectedResult.json +6 -0
- package/test-fixtures/strip-punctuation/05/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/05/record.json +12 -0
- package/test-fixtures/strip-punctuation/98/expectedResult.json +44 -0
- package/test-fixtures/strip-punctuation/98/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/98/record.json +45 -0
- package/test-fixtures/strip-punctuation/99/expectedResult.json +16 -0
- package/test-fixtures/strip-punctuation/99/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/99/record.json +16 -0
- package/test-fixtures/subfield0/f01/expectedResult.json +25 -0
- package/test-fixtures/subfield0/f01/metadata.json +6 -0
- package/test-fixtures/subfield0/f01/record.json +23 -0
- package/test-fixtures/subfield0/f02/expectedResult.json +35 -0
- package/test-fixtures/subfield0/f02/metadata.json +6 -0
- package/test-fixtures/subfield0/f02/record.json +41 -0
- package/test-fixtures/subfield0/f03/expectedResult.json +21 -0
- package/test-fixtures/subfield0/f03/metadata.json +7 -0
- package/test-fixtures/subfield0/f03/record.json +24 -0
- package/test-fixtures/subfield0/v01/expectedResult.json +4 -0
- package/test-fixtures/subfield0/v01/metadata.json +6 -0
- package/test-fixtures/subfield0/v01/record.json +23 -0
- package/test-fixtures/subfield0/v02/expectedResult.json +9 -0
- package/test-fixtures/subfield0/v02/metadata.json +6 -0
- package/test-fixtures/subfield0/v02/record.json +38 -0
- package/test-fixtures/typeOfDate-008/01/expectedResult.json +3 -0
- package/test-fixtures/typeOfDate-008/01/metadata.json +4 -0
- package/test-fixtures/typeOfDate-008/01/record.json +14 -0
- package/test-fixtures/typeOfDate-008/02/expectedResult.json +4 -0
- package/test-fixtures/typeOfDate-008/02/metadata.json +4 -0
- package/test-fixtures/typeOfDate-008/02/record.json +14 -0
- package/test-fixtures/typeOfDate-008/03/expectedResult.json +14 -0
- package/test-fixtures/typeOfDate-008/03/metadata.json +5 -0
- package/test-fixtures/typeOfDate-008/03/record.json +14 -0
- package/test-fixtures/typeOfDate-008/04/expectedResult.json +14 -0
- package/test-fixtures/typeOfDate-008/04/metadata.json +5 -0
- package/test-fixtures/typeOfDate-008/04/record.json +14 -0
- package/test-fixtures/typeOfDate-008/05/expectedResult.json +14 -0
- package/test-fixtures/typeOfDate-008/05/metadata.json +5 -0
- package/test-fixtures/typeOfDate-008/05/record.json +14 -0
- package/test-fixtures/update-field-540/f01/expectedResult.json +23 -0
- package/test-fixtures/update-field-540/f01/metadata.json +6 -0
- package/test-fixtures/update-field-540/f01/record.json +23 -0
- package/test-fixtures/update-field-540/v01/expectedResult.json +7 -0
- package/test-fixtures/update-field-540/v01/metadata.json +6 -0
- package/test-fixtures/update-field-540/v01/record.json +23 -0
- package/.travis.yml +0 -10
|
@@ -1,64 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* This file is part of marc-record-validators-melinda
|
|
10
|
-
*
|
|
11
|
-
* marc-record-validators-melinda program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Affero General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* marc-record-validators-melinda is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Affero General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*//* eslint-disable require-await */'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _lodash=require('lodash');var _util=require('util');function _asyncToGenerator(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{return Promise.resolve(value).then(function(value){step('next',value)},function(err){step('throw',err)})}}return step('next')})}}// Tag (RegExp): Pattern to match the field's tags Mandatory
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
// Tag (RegExp): Pattern to match the field's tags Mandatory
|
|
28
8
|
// ind1 (RegExp): Pattern to match the field's ind1 property
|
|
29
9
|
// ind2 (RegExp): Pattern to match the field's ind2 property
|
|
30
10
|
// subfields (Array<Object>): An array of objects with the following properties (Mandatory):
|
|
31
11
|
// // code (RegExp): Pattern to match the subfield's code Mandatory
|
|
32
12
|
// // value (RegExp): Pattern to match the subfield's value
|
|
13
|
+
|
|
33
14
|
// Configuration specification
|
|
34
|
-
const confSpec={
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
15
|
+
const confSpec = {
|
|
16
|
+
tag: {
|
|
17
|
+
// Pattern to match the field's tags
|
|
18
|
+
type: 'RegExp',
|
|
19
|
+
mandatory: true
|
|
20
|
+
},
|
|
21
|
+
ind1: {
|
|
22
|
+
// Pattern to match the field's ind1 property.
|
|
23
|
+
type: 'RegExp' // Array<Indicator>
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
ind2: {
|
|
27
|
+
// Pattern to match the field's ind2 property.
|
|
28
|
+
type: 'RegExp' // Array<Indicator>
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
subfields: {
|
|
32
|
+
// An array of objects with the following properties
|
|
33
|
+
code: {
|
|
34
|
+
type: 'RegExp',
|
|
35
|
+
mandatory: true
|
|
36
|
+
},
|
|
37
|
+
value: {
|
|
38
|
+
type: 'RegExp'
|
|
39
|
+
},
|
|
40
|
+
mandatory: true
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function forEach(obj, fun) {
|
|
44
|
+
Object.entries(obj).forEach(fun);
|
|
45
|
+
}
|
|
46
|
+
function isRegExp(re) {
|
|
47
|
+
return re instanceof RegExp;
|
|
48
|
+
}
|
|
49
|
+
function _default(config) {
|
|
50
|
+
if (!Array.isArray(config)) {
|
|
51
|
+
throw new TypeError('Configuration array not provided');
|
|
52
|
+
}
|
|
53
|
+
configValid(config);
|
|
54
|
+
return {
|
|
55
|
+
description: 'Checks that the record does not contain the configured subfields',
|
|
56
|
+
validate: record => excludeSubfields(record, config, false),
|
|
57
|
+
fix: record => excludeSubfields(record, config, true)
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/// /////////////////////////////////////////
|
|
61
|
+
// These check that configuration is valid
|
|
62
|
+
function configValid(config) {
|
|
63
|
+
config.forEach(obj => {
|
|
64
|
+
checkMandatory(confSpec, obj);
|
|
65
|
+
forEach(obj, ([key, val]) => {
|
|
66
|
+
configMatchesSpec(val, key, confSpec);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Recursive validator
|
|
72
|
+
function configMatchesSpec(data, key, spec) {
|
|
73
|
+
// Field not found in configuration spec
|
|
74
|
+
if (!spec[key]) {
|
|
75
|
+
throw new Error(`Configuration not valid - unidentified value: ${key}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// If configuration type does not match type in configuration spec
|
|
79
|
+
if (typeof data !== spec[key].type && spec[key].type === 'RegExp' && !isRegExp(data)) {
|
|
80
|
+
throw new Error(`Configuration not valid - invalid data type for: ${key}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Check subfields recursively
|
|
84
|
+
if (key === 'subfields') {
|
|
85
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
86
|
+
forEach(data, ([, subObj]) => {
|
|
87
|
+
// Console.log("subObj: ", subObj, " type: ", typeof subObj, !(Array.isArray(subObj)))
|
|
88
|
+
if (typeof subObj === 'object' && !Array.isArray(subObj)) {
|
|
89
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
90
|
+
checkMandatory(spec[key], subObj);
|
|
91
|
+
forEach(subObj, ([subKey, subVal]) => {
|
|
92
|
+
configMatchesSpec(subVal, subKey, spec[key]);
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
throw new TypeError(`Configuration not valid - subfield: ${subObj} not object`);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function checkMandatory(spec, obj) {
|
|
101
|
+
// Check if all mandatory fields are present
|
|
102
|
+
forEach(spec, ([key, val]) => {
|
|
103
|
+
if (val.mandatory && typeof obj[key] === 'undefined') {
|
|
104
|
+
throw new Error(`Configuration not valid - missing mandatory element: ${key}`);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/// /////////////////////////////////////////
|
|
109
|
+
|
|
110
|
+
/// /////////////////////////////////////////
|
|
111
|
+
// These check that record is valid
|
|
112
|
+
function excludeSubfields(record, conf, fix) {
|
|
113
|
+
const res = {
|
|
114
|
+
message: [],
|
|
115
|
+
valid: true
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Parse trough every element of config array
|
|
119
|
+
conf.forEach(confObj => {
|
|
120
|
+
const found = record.get(confObj.tag); // Find matching record fields based on mandatory tag
|
|
121
|
+
|
|
122
|
+
// Check if some of found record fields matches all configuration fields
|
|
123
|
+
found.forEach(element => {
|
|
124
|
+
// Compare each found element against each configuration object
|
|
125
|
+
if (Object.entries(confObj).every(([confKey, confField]) => {
|
|
126
|
+
// Tag already checked at .get(), subfields later
|
|
127
|
+
if (confKey === 'tag' || confKey === 'subfields') {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Configuration object is RegExp and record value matches it
|
|
132
|
+
if (element[confKey] && isRegExp(confField) && confField.test(element[confKey])) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Configuration object not found from found element
|
|
137
|
+
return false;
|
|
138
|
+
})) {
|
|
139
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
140
|
+
// All configuration fields match, check if some subfields should be excluded.
|
|
141
|
+
confObj.subfields.forEach(subField => {
|
|
142
|
+
const excluded = [];
|
|
143
|
+
element.subfields.forEach(elemSub => {
|
|
144
|
+
// Check if subfield matches configuration spec
|
|
145
|
+
const subFieldCodeFine = subField.code && elemSub.code && subField.code.test(elemSub.code);
|
|
146
|
+
const subFieldValueFine = subField.value && elemSub.value && subField.value.test(elemSub.value);
|
|
147
|
+
if (subFieldCodeFine && (typeof subField.value === 'undefined' || subFieldValueFine)) {
|
|
148
|
+
if (fix) {
|
|
149
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
150
|
+
excluded.push(elemSub); // eslint-disable-line functional/immutable-data
|
|
151
|
+
} else {
|
|
152
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
153
|
+
res.message.push(`Subfield $${element.tag}$$${elemSub.code}should be excluded`); // eslint-disable-line functional/immutable-data
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
excluded.forEach(sf => record.removeSubfield(sf, element));
|
|
159
|
+
// If no subfields remains, the whole field will be removed as well:
|
|
160
|
+
if (element.subfields && element.subfields.length === 0) {
|
|
161
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
162
|
+
record.removeField(element);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Fix does not send response
|
|
170
|
+
if (!fix) {
|
|
171
|
+
if (res.message.length > 0) {
|
|
172
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
173
|
+
res.valid = false; // eslint-disable-line functional/immutable-data
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return res;
|
|
177
|
+
}
|
|
178
|
+
// Res.fix.push('Field $' + element.tag + ' excluded');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
64
181
|
//# sourceMappingURL=subfield-exclusion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/subfield-exclusion.js"],"names":["confSpec","tag","type","mandatory","ind1","ind2","subfields","code","value","config","Array","isArray","TypeError","configValid","description","validate","record","excludeFields","fix","forEach","obj","checkMandatory","val","key","configMatchesSpec","data","spec","Error","subObj","subVal","subKey","conf","res","message","valid","confObj","found","get","element","confField","confKey","test","subField","elemSub","removeSubfield","push","length"],"m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D;AACA,C","file":"subfield-exclusion.js","sourcesContent":["/**\n *\n * @licstart The following is the entire license notice for the JavaScript code in this file.\n *\n * MARC record validators used in Melinda\n *\n * Copyright (C) 2014-2018 University Of Helsinki (The National Library Of Finland)\n *\n * This file is part of marc-record-validators-melinda\n *\n * marc-record-validators-melinda program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero 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-validators-melinda 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero 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\n/* eslint-disable require-await */\n\n'use strict';\n\nimport {forEach, every} from 'lodash';\nimport {isRegExp} from 'util';\n\n// Tag (RegExp): Pattern to match the field's tags Mandatory\n// ind1 (RegExp): Pattern to match the field's ind1 property\n// ind2 (RegExp): Pattern to match the field's ind2 property\n// subfields (Array<Object>): An array of objects with the following properties (Mandatory):\n// // code (RegExp): Pattern to match the subfield's code Mandatory\n// // value (RegExp): Pattern to match the subfield's value\n\n// Configuration specification\nconst confSpec = {\n\ttag: { // Pattern to match the field's tags\n\t\ttype: 'RegExp',\n\t\tmandatory: true\n\t},\n\tind1: { // Pattern to match the field's ind1 property.\n\t\ttype: 'RegExp' // Array<Indicator>\n\t},\n\tind2: { // Pattern to match the field's ind2 property.\n\t\ttype: 'RegExp' // Array<Indicator>\n\t},\n\tsubfields: { // An array of objects with the following properties\n\t\tcode: {\n\t\t\ttype: 'RegExp',\n\t\t\tmandatory: true\n\t\t},\n\t\tvalue: {\n\t\t\ttype: 'RegExp'\n\t\t},\n\t\tmandatory: true\n\t}\n};\n\nexport default async function (config) {\n\tif (!Array.isArray(config)) {\n\t\tthrow new TypeError('Configuration array not provided');\n\t}\n\n\tconfigValid(config);\n\n\treturn {\n\t\tdescription:\n\t\t\t'Checks whether the configured field-specific objects are valid in the record',\n\t\tvalidate: async record => (\n\t\t\texcludeFields(record, config, false)\n\t\t),\n\t\tfix: async record =>\n\t\t\texcludeFields(record, config, true)\n\t};\n\n\t/// /////////////////////////////////////////\n\t// These check that configuration is valid\n\tfunction configValid(config) {\n\t\tconfig.forEach(obj => {\n\t\t\tcheckMandatory(confSpec, obj);\n\n\t\t\tforEach(obj, (val, key) => {\n\t\t\t\tconfigMatchesSpec(val, key, confSpec);\n\t\t\t});\n\t\t});\n\t}\n\n\t// Recursive validator\n\tfunction configMatchesSpec(data, key, spec) {\n\t\t// Field not found in configuration spec\n\t\tif (!spec[key]) {\n\t\t\tthrow new Error('Configuration not valid - unidentified value: ' + key);\n\t\t}\n\n\t\t// If configuration type does not match type in configuration spec\n\t\tif (typeof data !== spec[key].type &&\n\t\t\t(spec[key].type === 'RegExp' && !(isRegExp(data)))) {\n\t\t\tthrow new Error('Configuration not valid - invalid data type for: ' + key);\n\t\t}\n\n\t\t// Check subfields recursively\n\t\tif (key === 'subfields') {\n\t\t\tforEach(data, subObj => {\n\t\t\t\t// Console.log(\"subObj: \", subObj, \" type: \", typeof subObj, !(Array.isArray(subObj)))\n\t\t\t\tif (typeof subObj === 'object' && !(Array.isArray(subObj))) {\n\t\t\t\t\tcheckMandatory(spec[key], subObj);\n\n\t\t\t\t\tforEach(subObj, (subVal, subKey) => {\n\t\t\t\t\t\tconfigMatchesSpec(subVal, subKey, spec[key]);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Configuration not valid - subfield: ' + subObj + ' not object');\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tfunction checkMandatory(spec, obj) {\n\t\t// Check if all mandatory fields are present\n\t\tforEach(spec, (val, key) => {\n\t\t\tif (val.mandatory && typeof (obj[key]) === 'undefined') {\n\t\t\t\tthrow new Error('Configuration not valid - missing mandatory element: ' + key);\n\t\t\t}\n\t\t});\n\t}\n\t/// /////////////////////////////////////////\n\n\t/// /////////////////////////////////////////\n\t// These check that record is valid\n\tfunction excludeFields(record, conf, fix) {\n\t\tvar res = {};\n\t\tres.message = [];\n\t\tres.valid = true;\n\n\t\t// Parse trough every element of config array\n\t\tforEach(conf, confObj => {\n\t\t\tvar found = record.get(confObj.tag); // Find matching record fields based on mandatory tag\n\n\t\t\t// Check if some of found record fields matches all configuration fields\n\t\t\tforEach(found, element => {\n\t\t\t\t// Compare each found element against each configuration object\n\t\t\t\tif (every(confObj, (confField, confKey) => {\n\t\t\t\t\t// Tag already checked at .get(), subfields later\n\t\t\t\t\tif (confKey === 'tag' || confKey === 'subfields') {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Configuration object is RegExp and record value matches it\n\t\t\t\t\tif (element[confKey] && isRegExp(confField) && confField.test(element[confKey])) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Configuration object not found from found element\n\t\t\t\t\treturn false;\n\t\t\t\t})) {\n\t\t\t\t\t// All configuration fields match, check if some subfields should be excluded.\n\t\t\t\t\tforEach(confObj.subfields, subField => {\n\t\t\t\t\t\tforEach(element.subfields, elemSub => {\n\t\t\t\t\t\t\t// Check if subfield matches configuration spec\n\t\t\t\t\t\t\tif (subField.code && elemSub.code && (subField.code.test(elemSub.code)) &&\n\t\t\t\t\t\t\t\t(typeof subField.value === 'undefined' || (subField.value && elemSub.value && (subField.value.test(elemSub.value))))) {\n\t\t\t\t\t\t\t\tif (fix) {\n\t\t\t\t\t\t\t\t\trecord.removeSubfield(elemSub, element);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tres.message.push('Subfield $' + element.tag + '$$' + elemSub.code + 'should be excluded');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t// Fix does not send response\n\t\tif (!fix) {\n\t\t\tif (res.message.length > 0) {\n\t\t\t\tres.valid = false;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t\t// Res.fix.push('Field $' + element.tag + ' excluded');\n\t}\n\t/// /////////////////////////////////////////\n}\n"]}
|
|
1
|
+
{"version":3,"file":"subfield-exclusion.js","names":["confSpec","tag","type","mandatory","ind1","ind2","subfields","code","value","forEach","obj","fun","Object","entries","isRegExp","re","RegExp","_default","config","Array","isArray","TypeError","configValid","description","validate","record","excludeSubfields","fix","checkMandatory","key","val","configMatchesSpec","data","spec","Error","subObj","subKey","subVal","conf","res","message","valid","confObj","found","get","element","every","confKey","confField","test","subField","excluded","elemSub","subFieldCodeFine","subFieldValueFine","push","sf","removeSubfield","length","removeField"],"sources":["../src/subfield-exclusion.js"],"sourcesContent":["// Tag (RegExp): Pattern to match the field's tags Mandatory\n// ind1 (RegExp): Pattern to match the field's ind1 property\n// ind2 (RegExp): Pattern to match the field's ind2 property\n// subfields (Array<Object>): An array of objects with the following properties (Mandatory):\n// // code (RegExp): Pattern to match the subfield's code Mandatory\n// // value (RegExp): Pattern to match the subfield's value\n\n// Configuration specification\nconst confSpec = {\n tag: { // Pattern to match the field's tags\n type: 'RegExp',\n mandatory: true\n },\n ind1: { // Pattern to match the field's ind1 property.\n type: 'RegExp' // Array<Indicator>\n },\n ind2: { // Pattern to match the field's ind2 property.\n type: 'RegExp' // Array<Indicator>\n },\n subfields: { // An array of objects with the following properties\n code: {\n type: 'RegExp',\n mandatory: true\n },\n value: {\n type: 'RegExp'\n },\n mandatory: true\n }\n};\n\nfunction forEach(obj, fun) {\n Object.entries(obj).forEach(fun);\n}\n\nfunction isRegExp(re) {\n return re instanceof RegExp;\n}\n\nexport default function (config) {\n if (!Array.isArray(config)) {\n throw new TypeError('Configuration array not provided');\n }\n\n configValid(config);\n\n return {\n description:\n 'Checks that the record does not contain the configured subfields',\n validate: record => excludeSubfields(record, config, false),\n fix: record => excludeSubfields(record, config, true)\n };\n\n /// /////////////////////////////////////////\n // These check that configuration is valid\n function configValid(config) {\n config.forEach(obj => {\n checkMandatory(confSpec, obj);\n\n forEach(obj, ([key, val]) => {\n configMatchesSpec(val, key, confSpec);\n });\n });\n }\n\n // Recursive validator\n function configMatchesSpec(data, key, spec) {\n // Field not found in configuration spec\n if (!spec[key]) {\n throw new Error(`Configuration not valid - unidentified value: ${key}`);\n }\n\n // If configuration type does not match type in configuration spec\n if (typeof data !== spec[key].type &&\n (spec[key].type === 'RegExp' && !isRegExp(data))) {\n throw new Error(`Configuration not valid - invalid data type for: ${key}`);\n }\n\n // Check subfields recursively\n if (key === 'subfields') { // eslint-disable-line functional/no-conditional-statements\n forEach(data, ([, subObj]) => {\n // Console.log(\"subObj: \", subObj, \" type: \", typeof subObj, !(Array.isArray(subObj)))\n if (typeof subObj === 'object' && !Array.isArray(subObj)) { // eslint-disable-line functional/no-conditional-statements\n checkMandatory(spec[key], subObj);\n\n forEach(subObj, ([subKey, subVal]) => {\n configMatchesSpec(subVal, subKey, spec[key]);\n });\n } else {\n throw new TypeError(`Configuration not valid - subfield: ${subObj} not object`);\n }\n });\n }\n }\n\n function checkMandatory(spec, obj) {\n // Check if all mandatory fields are present\n forEach(spec, ([key, val]) => {\n if (val.mandatory && typeof obj[key] === 'undefined') {\n throw new Error(`Configuration not valid - missing mandatory element: ${key}`);\n }\n });\n }\n /// /////////////////////////////////////////\n\n /// /////////////////////////////////////////\n // These check that record is valid\n function excludeSubfields(record, conf, fix) {\n const res = {message: [], valid: true};\n\n // Parse trough every element of config array\n conf.forEach(confObj => {\n const found = record.get(confObj.tag); // Find matching record fields based on mandatory tag\n\n // Check if some of found record fields matches all configuration fields\n found.forEach(element => {\n // Compare each found element against each configuration object\n if (Object.entries(confObj).every(([confKey, confField]) => {\n // Tag already checked at .get(), subfields later\n if (confKey === 'tag' || confKey === 'subfields') {\n return true;\n }\n\n // Configuration object is RegExp and record value matches it\n if (element[confKey] && isRegExp(confField) && confField.test(element[confKey])) {\n return true;\n }\n\n // Configuration object not found from found element\n return false;\n })) { // eslint-disable-line functional/no-conditional-statements\n // All configuration fields match, check if some subfields should be excluded.\n confObj.subfields.forEach(subField => {\n const excluded = [];\n\n element.subfields.forEach(elemSub => {\n // Check if subfield matches configuration spec\n const subFieldCodeFine = subField.code && elemSub.code && subField.code.test(elemSub.code);\n const subFieldValueFine = subField.value && elemSub.value && subField.value.test(elemSub.value);\n if (subFieldCodeFine && (typeof subField.value === 'undefined' || subFieldValueFine)) {\n if (fix) { // eslint-disable-line functional/no-conditional-statements\n excluded.push(elemSub); // eslint-disable-line functional/immutable-data\n } else { // eslint-disable-line functional/no-conditional-statements\n res.message.push(`Subfield $${element.tag}$$${elemSub.code}should be excluded`); // eslint-disable-line functional/immutable-data\n }\n }\n });\n\n excluded.forEach(sf => record.removeSubfield(sf, element));\n // If no subfields remains, the whole field will be removed as well:\n if (element.subfields && element.subfields.length === 0) { // eslint-disable-line functional/no-conditional-statements\n record.removeField(element);\n }\n });\n }\n });\n });\n\n // Fix does not send response\n if (!fix) {\n if (res.message.length > 0) { // eslint-disable-line functional/no-conditional-statements\n res.valid = false; // eslint-disable-line functional/immutable-data\n }\n\n return res;\n }\n // Res.fix.push('Field $' + element.tag + ' excluded');\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAMA,QAAQ,GAAG;EACfC,GAAG,EAAE;IAAE;IACLC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE;EACb,CAAC;EACDC,IAAI,EAAE;IAAE;IACNF,IAAI,EAAE,QAAQ,CAAC;EACjB,CAAC;;EACDG,IAAI,EAAE;IAAE;IACNH,IAAI,EAAE,QAAQ,CAAC;EACjB,CAAC;;EACDI,SAAS,EAAE;IAAE;IACXC,IAAI,EAAE;MACJL,IAAI,EAAE,QAAQ;MACdC,SAAS,EAAE;IACb,CAAC;IACDK,KAAK,EAAE;MACLN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