@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
package/dist/urn.spec.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _chai = require("chai");
|
|
4
|
+
var _marcRecord = require("@natlibfi/marc-record");
|
|
5
|
+
var _urn = _interopRequireDefault(require("../src/urn"));
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
describe('urn', async () => {
|
|
8
|
+
// Fields
|
|
9
|
+
const f337 = {
|
|
10
|
+
tag: '337',
|
|
11
|
+
ind1: ' ',
|
|
12
|
+
ind2: ' ',
|
|
13
|
+
subfields: [{
|
|
14
|
+
code: 'b',
|
|
15
|
+
value: 'c'
|
|
16
|
+
}, {
|
|
17
|
+
code: '2',
|
|
18
|
+
value: 'rdamedia'
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
21
|
+
const f337nonElectronic = {
|
|
22
|
+
tag: '337',
|
|
23
|
+
ind1: ' ',
|
|
24
|
+
ind2: ' ',
|
|
25
|
+
subfields: [{
|
|
26
|
+
code: 'b',
|
|
27
|
+
value: 'n'
|
|
28
|
+
}, {
|
|
29
|
+
code: '2',
|
|
30
|
+
value: 'rdamedia'
|
|
31
|
+
}]
|
|
32
|
+
};
|
|
33
|
+
const ldf856 = {
|
|
34
|
+
tag: '856',
|
|
35
|
+
ind1: '4',
|
|
36
|
+
ind2: '0',
|
|
37
|
+
subfields: [{
|
|
38
|
+
code: 'u',
|
|
39
|
+
value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'
|
|
40
|
+
}, {
|
|
41
|
+
code: 'z',
|
|
42
|
+
value: 'Käytettävissä vapaakappalekirjastoissa'
|
|
43
|
+
}, {
|
|
44
|
+
code: '5',
|
|
45
|
+
value: 'FI-Vapaa'
|
|
46
|
+
}]
|
|
47
|
+
};
|
|
48
|
+
const ldf856partial = {
|
|
49
|
+
tag: '856',
|
|
50
|
+
ind1: '4',
|
|
51
|
+
ind2: '0',
|
|
52
|
+
subfields: [{
|
|
53
|
+
code: 'u',
|
|
54
|
+
value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'
|
|
55
|
+
}, {
|
|
56
|
+
code: '5',
|
|
57
|
+
value: 'FI-Vapaa'
|
|
58
|
+
}]
|
|
59
|
+
};
|
|
60
|
+
const f856URN = {
|
|
61
|
+
tag: '856',
|
|
62
|
+
ind1: '4',
|
|
63
|
+
ind2: '0',
|
|
64
|
+
subfields: [{
|
|
65
|
+
code: 'u',
|
|
66
|
+
value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'
|
|
67
|
+
}]
|
|
68
|
+
};
|
|
69
|
+
const f856URNnotResource = {
|
|
70
|
+
tag: '856',
|
|
71
|
+
ind1: '4',
|
|
72
|
+
ind2: '1',
|
|
73
|
+
subfields: [{
|
|
74
|
+
code: 'u',
|
|
75
|
+
value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'
|
|
76
|
+
}]
|
|
77
|
+
};
|
|
78
|
+
const f856URL = {
|
|
79
|
+
tag: '856',
|
|
80
|
+
ind1: '4',
|
|
81
|
+
ind2: '0',
|
|
82
|
+
subfields: [{
|
|
83
|
+
code: 'u',
|
|
84
|
+
value: 'http://foo.bar/'
|
|
85
|
+
}]
|
|
86
|
+
};
|
|
87
|
+
const f020 = {
|
|
88
|
+
tag: '020',
|
|
89
|
+
ind1: ' ',
|
|
90
|
+
ind2: ' ',
|
|
91
|
+
subfields: [{
|
|
92
|
+
code: 'a',
|
|
93
|
+
value: '978-951-9155-47-0'
|
|
94
|
+
}]
|
|
95
|
+
};
|
|
96
|
+
const f020second = {
|
|
97
|
+
tag: '020',
|
|
98
|
+
ind1: ' ',
|
|
99
|
+
ind2: ' ',
|
|
100
|
+
subfields: [{
|
|
101
|
+
code: 'a',
|
|
102
|
+
value: '9789519155470'
|
|
103
|
+
}]
|
|
104
|
+
};
|
|
105
|
+
it('Creates a validator', async () => {
|
|
106
|
+
const validator = await (0, _urn.default)();
|
|
107
|
+
(0, _chai.expect)(validator).to.be.an('object').that.has.any.keys('description', 'validate');
|
|
108
|
+
(0, _chai.expect)(validator.description).to.be.a('string');
|
|
109
|
+
(0, _chai.expect)(validator.validate).to.be.a('function');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Tests
|
|
113
|
+
const test = async isLegalDeposit => {
|
|
114
|
+
const validator = await (0, _urn.default)(isLegalDeposit);
|
|
115
|
+
return {
|
|
116
|
+
validate: async (valid, ...recfields) => {
|
|
117
|
+
const result = await validator.validate(new _marcRecord.MarcRecord({
|
|
118
|
+
fields: recfields
|
|
119
|
+
}));
|
|
120
|
+
(0, _chai.expect)(result).to.eql({
|
|
121
|
+
valid
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
fix: async (recfields, resfields) => {
|
|
125
|
+
const record = new _marcRecord.MarcRecord({
|
|
126
|
+
fields: recfields
|
|
127
|
+
});
|
|
128
|
+
await validator.fix(record);
|
|
129
|
+
(0, _chai.expect)(record.fields).to.eql(resfields);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/// Non-legal and legal deposit
|
|
135
|
+
const nonld = await test(false);
|
|
136
|
+
const ld = await test(true);
|
|
137
|
+
describe('#validate', () => {
|
|
138
|
+
// Validate non-electoronic
|
|
139
|
+
it('Finds the record valid; non-electronic record', async () => {
|
|
140
|
+
await nonld.validate(true, f337nonElectronic);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Validate non-legal deposit
|
|
144
|
+
it('Finds the record valid; 856 with urn, and is non-legal deposit', async () => {
|
|
145
|
+
await nonld.validate(true, f337, f856URN);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// we should recognize that 856 with second indicator 1 is not describing the resource itself
|
|
149
|
+
it.skip('Finds the record invalid; 856 ind2: 1 with urn, and is non-legal deposit', async () => {
|
|
150
|
+
await nonld.validate(false, f337, f856URNnotResource);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// should we require urn if we're not handling a legal deposit
|
|
154
|
+
it('Finds the record invalid; 856 without urn, and is non-legal deposit', async () => {
|
|
155
|
+
await nonld.validate(false, f337, f856URL);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// should we require urn if we're not handling a legal deposit
|
|
159
|
+
it('Finds the record invalid; Missing 856, and is non-legal deposit', async () => {
|
|
160
|
+
await nonld.validate(false, f337, f020);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Validate legal deposit
|
|
164
|
+
it('Finds the record invalid; 856 with urn, and is legal deposit', async () => {
|
|
165
|
+
await ld.validate(false, f020, f337, f856URN);
|
|
166
|
+
});
|
|
167
|
+
it('Finds the record invalid; 856 without urn, and is legal deposit', async () => {
|
|
168
|
+
await ld.validate(false, f020, f337, f856URL);
|
|
169
|
+
});
|
|
170
|
+
it('Finds the record invalid; Missing 856, and is legal deposit', async () => {
|
|
171
|
+
await ld.validate(false, f337, f020);
|
|
172
|
+
});
|
|
173
|
+
it('Finds the record valid; 856 with URN and legal deposit subfields, and is legal deposit', async () => {
|
|
174
|
+
await ld.validate(true, f337, f020, ldf856);
|
|
175
|
+
});
|
|
176
|
+
it('Finds the record valid; 856 with URN and legal deposit subfields and other f856s, and is legal deposit', async () => {
|
|
177
|
+
await ld.validate(true, f337, f020, ldf856partial, ldf856, f856URL);
|
|
178
|
+
});
|
|
179
|
+
it('Finds the record invalid; 856 with URN and partial legal deposit subfields, and is legal deposit', async () => {
|
|
180
|
+
await ld.validate(false, f337, f020, ldf856partial);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
describe('#fix', () => {
|
|
184
|
+
// Fix non-legal deposit
|
|
185
|
+
it('856 with urn, and is non-legal deposit; Nothing to add', async () => {
|
|
186
|
+
await nonld.fix([f020, f856URL, f856URN], [f020, f856URL, f856URN]);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// should we actually add non-resolvable urns?
|
|
190
|
+
it('856 without urn, and is non-legal deposit; Adds 856 with urn', async () => {
|
|
191
|
+
await nonld.fix([f020, f856URL], [f020, f856URL, f856URN]);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// should we actually add non-resolvable urns?
|
|
195
|
+
it('Missing 856, and is non-legal deposit; Adds 856 with urn', async () => {
|
|
196
|
+
await nonld.fix([f020], [f020, f856URN]);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// should we actually add non-resolvable urns?
|
|
200
|
+
it('Missing 856, and is non-legal deposit, two 020 fields; Adds 856 with urn from second 020', async () => {
|
|
201
|
+
await nonld.fix([f020second, f020], [f020second, f020, f856URN]);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// should we actually add non resovable urns?
|
|
205
|
+
// we should think about how to choose the isbn to use in case of several ISBNs
|
|
206
|
+
it.skip('Missing 856, and is non-legal deposit, two 020 fields; Adds 856 with urn from first 020', async () => {
|
|
207
|
+
await nonld.fix([f020, f020second], [f020, f020second, f856URN]);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Fix legal deposit
|
|
211
|
+
it('856 with urn and legal deposit fields, and is legal deposit; Nothing to add', async () => {
|
|
212
|
+
await ld.fix([f020, f856URL, ldf856], [f020, f856URL, ldf856]);
|
|
213
|
+
});
|
|
214
|
+
it('856 without urn, and is legal deposit; Adds 856 with urn and legal deposit fields', async () => {
|
|
215
|
+
await ld.fix([f020, f856URL], [f020, f856URL, ldf856]);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// we should test generating the URN in case of no ISBN
|
|
219
|
+
|
|
220
|
+
// we should test creating Melinda-temp field
|
|
221
|
+
|
|
222
|
+
// We shouldn't lock the open URN for legal deposit use
|
|
223
|
+
it('Missing 856, and is legal deposit; Adds 856 with urn and legal deposit fields', async () => {
|
|
224
|
+
await ld.fix([f020], [f020, ldf856]);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// We should actually do this instead of locking the original non-legal deposit URN for legal deposit use
|
|
228
|
+
it.skip('856 with urn, and is legal deposit; Adds another f856 with URN and legal deposit fields', async () => {
|
|
229
|
+
await ld.fix([f020, f856URL, f856URN], [f020, f856URL, f856URN, ldf856]);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// We should actually add a new urn in case of a non-resource URN
|
|
233
|
+
it.skip('856 with non-resource-urn, and is legal deposit; Adds another f856 with URN and legal deposit fields', async () => {
|
|
234
|
+
await ld.fix([f020, f856URL, f856URNnotResource], [f020, f856URL, f856URNnotResource, ldf856]);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
//# sourceMappingURL=urn.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urn.spec.js","names":["_chai","require","_marcRecord","_urn","_interopRequireDefault","obj","__esModule","default","describe","f337","tag","ind1","ind2","subfields","code","value","f337nonElectronic","ldf856","ldf856partial","f856URN","f856URNnotResource","f856URL","f020","f020second","it","validator","validatorFactory","expect","to","be","an","that","has","any","keys","description","a","validate","test","isLegalDeposit","valid","recfields","result","MarcRecord","fields","eql","fix","resfields","record","nonld","ld","skip"],"sources":["../src/urn.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport validatorFactory from '../src/urn';\n\ndescribe('urn', async () => {\n // Fields\n const f337 = {\n tag: '337',\n ind1: ' ',\n ind2: ' ',\n subfields: [\n {code: 'b', value: 'c'},\n {code: '2', value: 'rdamedia'}\n ]\n };\n\n const f337nonElectronic = {\n tag: '337',\n ind1: ' ',\n ind2: ' ',\n subfields: [\n {code: 'b', value: 'n'},\n {code: '2', value: 'rdamedia'}\n ]\n };\n\n const ldf856 = {\n tag: '856',\n ind1: '4',\n ind2: '0',\n subfields: [\n {code: 'u', value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'},\n {code: 'z', value: 'Käytettävissä vapaakappalekirjastoissa'},\n {code: '5', value: 'FI-Vapaa'}\n ]\n };\n\n const ldf856partial = {\n tag: '856',\n ind1: '4',\n ind2: '0',\n subfields: [\n {code: 'u', value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'},\n {code: '5', value: 'FI-Vapaa'}\n ]\n };\n\n const f856URN = {\n tag: '856',\n ind1: '4',\n ind2: '0',\n subfields: [{code: 'u', value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'}]\n };\n\n const f856URNnotResource = {\n tag: '856',\n ind1: '4',\n ind2: '1',\n subfields: [{code: 'u', value: 'http://urn.fi/URN:ISBN:978-951-9155-47-0'}]\n };\n\n\n const f856URL = {\n tag: '856',\n ind1: '4',\n ind2: '0',\n subfields: [{code: 'u', value: 'http://foo.bar/'}]\n };\n\n const f020 = {\n tag: '020',\n ind1: ' ',\n ind2: ' ',\n subfields: [{code: 'a', value: '978-951-9155-47-0'}]\n };\n\n const f020second = {\n tag: '020',\n ind1: ' ',\n ind2: ' ',\n subfields: [{code: 'a', value: '9789519155470'}]\n };\n\n\n it('Creates a validator', async () => {\n const validator = await validatorFactory();\n\n expect(validator)\n .to.be.an('object')\n .that.has.any.keys('description', 'validate');\n\n expect(validator.description).to.be.a('string');\n expect(validator.validate).to.be.a('function');\n });\n\n // Tests\n const test = async isLegalDeposit => {\n const validator = await validatorFactory(isLegalDeposit);\n return {\n validate: async (valid, ...recfields) => {\n const result = await validator.validate(new MarcRecord({fields: recfields}));\n expect(result).to.eql({valid});\n },\n\n fix: async (recfields, resfields) => {\n const record = new MarcRecord({fields: recfields});\n await validator.fix(record);\n expect(record.fields).to.eql(resfields);\n }\n };\n };\n\n /// Non-legal and legal deposit\n const nonld = await test(false);\n const ld = await test(true);\n\n describe('#validate', () => {\n // Validate non-electoronic\n it('Finds the record valid; non-electronic record', async () => {\n await nonld.validate(true, f337nonElectronic);\n });\n\n // Validate non-legal deposit\n it('Finds the record valid; 856 with urn, and is non-legal deposit', async () => {\n await nonld.validate(true, f337, f856URN);\n });\n\n\n // we should recognize that 856 with second indicator 1 is not describing the resource itself\n it.skip('Finds the record invalid; 856 ind2: 1 with urn, and is non-legal deposit', async () => {\n await nonld.validate(false, f337, f856URNnotResource);\n });\n\n // should we require urn if we're not handling a legal deposit\n it('Finds the record invalid; 856 without urn, and is non-legal deposit', async () => {\n await nonld.validate(false, f337, f856URL);\n });\n\n\n // should we require urn if we're not handling a legal deposit\n it('Finds the record invalid; Missing 856, and is non-legal deposit', async () => {\n await nonld.validate(false, f337, f020);\n });\n\n // Validate legal deposit\n it('Finds the record invalid; 856 with urn, and is legal deposit', async () => {\n await ld.validate(false, f020, f337, f856URN);\n });\n\n it('Finds the record invalid; 856 without urn, and is legal deposit', async () => {\n await ld.validate(false, f020, f337, f856URL);\n });\n\n it('Finds the record invalid; Missing 856, and is legal deposit', async () => {\n await ld.validate(false, f337, f020);\n });\n\n it('Finds the record valid; 856 with URN and legal deposit subfields, and is legal deposit', async () => {\n await ld.validate(true, f337, f020, ldf856);\n });\n\n it('Finds the record valid; 856 with URN and legal deposit subfields and other f856s, and is legal deposit', async () => {\n await ld.validate(true, f337, f020, ldf856partial, ldf856, f856URL);\n });\n\n it('Finds the record invalid; 856 with URN and partial legal deposit subfields, and is legal deposit', async () => {\n await ld.validate(false, f337, f020, ldf856partial);\n });\n\n\n });\n\n describe('#fix', () => {\n // Fix non-legal deposit\n it('856 with urn, and is non-legal deposit; Nothing to add', async () => {\n await nonld.fix([f020, f856URL, f856URN], [f020, f856URL, f856URN]);\n });\n\n // should we actually add non-resolvable urns?\n it('856 without urn, and is non-legal deposit; Adds 856 with urn', async () => {\n await nonld.fix([f020, f856URL], [f020, f856URL, f856URN]);\n });\n\n // should we actually add non-resolvable urns?\n it('Missing 856, and is non-legal deposit; Adds 856 with urn', async () => {\n await nonld.fix([f020], [f020, f856URN]);\n });\n\n // should we actually add non-resolvable urns?\n it('Missing 856, and is non-legal deposit, two 020 fields; Adds 856 with urn from second 020', async () => {\n await nonld.fix([f020second, f020], [f020second, f020, f856URN]);\n });\n\n // should we actually add non resovable urns?\n // we should think about how to choose the isbn to use in case of several ISBNs\n it.skip('Missing 856, and is non-legal deposit, two 020 fields; Adds 856 with urn from first 020', async () => {\n await nonld.fix([f020, f020second], [f020, f020second, f856URN]);\n });\n\n\n // Fix legal deposit\n it('856 with urn and legal deposit fields, and is legal deposit; Nothing to add', async () => {\n await ld.fix([f020, f856URL, ldf856], [f020, f856URL, ldf856]);\n });\n\n it('856 without urn, and is legal deposit; Adds 856 with urn and legal deposit fields', async () => {\n await ld.fix([f020, f856URL], [f020, f856URL, ldf856]);\n });\n\n // we should test generating the URN in case of no ISBN\n\n // we should test creating Melinda-temp field\n\n // We shouldn't lock the open URN for legal deposit use\n it('Missing 856, and is legal deposit; Adds 856 with urn and legal deposit fields', async () => {\n await ld.fix([f020], [f020, ldf856]);\n });\n\n // We should actually do this instead of locking the original non-legal deposit URN for legal deposit use\n it.skip('856 with urn, and is legal deposit; Adds another f856 with URN and legal deposit fields', async () => {\n await ld.fix([f020, f856URL, f856URN], [f020, f856URL, f856URN, ldf856]);\n });\n\n // We should actually add a new urn in case of a non-resource URN\n it.skip('856 with non-resource-urn, and is legal deposit; Adds another f856 with URN and legal deposit fields', async () => {\n await ld.fix([f020, f856URL, f856URNnotResource], [f020, f856URL, f856URNnotResource, ldf856]);\n });\n\n\n });\n});\n"],"mappings":";;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA0C,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1CG,QAAQ,CAAC,KAAK,EAAE,YAAY;EAC1B;EACA,MAAMC,IAAI,GAAG;IACXC,GAAG,EAAE,KAAK;IACVC,IAAI,EAAE,GAAG;IACTC,IAAI,EAAE,GAAG;IACTC,SAAS,EAAE,CACT;MAACC,IAAI,EAAE,GAAG;MAAEC,KAAK,EAAE;IAAG,CAAC,EACvB;MAACD,IAAI,EAAE,GAAG;MAAEC,KAAK,EAAE;IAAU,CAAC;EAElC,CAAC;EAED,MAAMC,iBAAiB,GAAG;IACxBN,GAAG,EAAE,KAAK;IACVC,IAAI,EAAE,GAAG;IACTC,IAAI,EAAE,GAAG;IACTC,SAAS,EAAE,CACT;MAACC,IAAI,EAAE,GAAG;MAAEC,KAAK,EAAE;IAAG,CAAC,EACvB;MAACD,IAAI,EAAE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AAE,CAACA,IAAI,EAAEL,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC;;IAEF;IACAO,EAAE,CAAC2B,IAAI,CAAC,yFAAyF,EAAE,YAAY;MAC7G,MAAMD,EAAE,CAACJ,GAAG,CAAC,CAACxB,IAAI,EAAED,OAAO,EAAEF,OAAO,CAAC,EAAE,CAACG,IAAI,EAAED,OAAO,EAAEF,OAAO,EAAEF,MAAM,CAAC,CAAC;IAC1E,CAAC,CAAC;;IAEF;IACAO,EAAE,CAAC2B,IAAI,CAAC,sGAAsG,EAAE,YAAY;MAC1H,MAAMD,EAAE,CAACJ,GAAG,CAAC,CAACxB,IAAI,EAAED,OAAO,EAAED,kBAAkB,CAAC,EAAE,CAACE,IAAI,EAAED,OAAO,EAAED,kBAAkB,EAAEH,MAAM,CAAC,CAAC;IAChG,CAAC,CAAC;EAGJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fieldHasSubfield = fieldHasSubfield;
|
|
7
|
+
exports.fieldToString = fieldToString;
|
|
8
|
+
exports.fieldsToString = fieldsToString;
|
|
9
|
+
exports.isElectronicMaterial = isElectronicMaterial;
|
|
10
|
+
exports.nvdebug = nvdebug;
|
|
11
|
+
exports.subfieldToString = subfieldToString;
|
|
12
|
+
function isElectronicMaterial(record) {
|
|
13
|
+
const f337s = record.get('337');
|
|
14
|
+
return f337s.some(field => {
|
|
15
|
+
const mediaTypeIsC = field.subfields.some(sub => sub.code === 'b' && sub.value === 'c');
|
|
16
|
+
const sourceIsRdamedia = field.subfields.some(sub => sub.code === '2' && sub.value === 'rdamedia');
|
|
17
|
+
return mediaTypeIsC && sourceIsRdamedia;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function nvdebug(message, func = undefined) {
|
|
21
|
+
if (func) {
|
|
22
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
23
|
+
func(message);
|
|
24
|
+
}
|
|
25
|
+
//console.info(message); // eslint-disable-line no-console
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function fieldHasSubfield(field, subfieldCode, subfieldValue = null) {
|
|
29
|
+
if (!field.subfields) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (subfieldValue === null) {
|
|
33
|
+
return field.subfields.some(sf => sf.code === subfieldCode);
|
|
34
|
+
}
|
|
35
|
+
return field.subfields.some(sf => sf.code === subfieldCode && subfieldValue === sf.value);
|
|
36
|
+
}
|
|
37
|
+
function subfieldToString(sf) {
|
|
38
|
+
return `‡${sf.code} ${sf.value}`;
|
|
39
|
+
}
|
|
40
|
+
function normalizeIndicatorValue(val) {
|
|
41
|
+
if (val === ' ') {
|
|
42
|
+
return '#';
|
|
43
|
+
}
|
|
44
|
+
return val;
|
|
45
|
+
}
|
|
46
|
+
function fieldToString(f) {
|
|
47
|
+
if ('subfields' in f) {
|
|
48
|
+
return `${f.tag} ${normalizeIndicatorValue(f.ind1)}${normalizeIndicatorValue(f.ind2)}${formatSubfields(f)}`;
|
|
49
|
+
}
|
|
50
|
+
return `${f.tag} ${f.value}`;
|
|
51
|
+
function formatSubfields(field) {
|
|
52
|
+
return field.subfields.map(sf => ` ${subfieldToString(sf)}`).join('');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function fieldsToString(fields) {
|
|
56
|
+
return fields.map(f => fieldToString(f)).join('\t__SEPARATOR__\t');
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["isElectronicMaterial","record","f337s","get","some","field","mediaTypeIsC","subfields","sub","code","value","sourceIsRdamedia","nvdebug","message","func","undefined","fieldHasSubfield","subfieldCode","subfieldValue","sf","subfieldToString","normalizeIndicatorValue","val","fieldToString","f","tag","ind1","ind2","formatSubfields","map","join","fieldsToString","fields"],"sources":["../src/utils.js"],"sourcesContent":["export function isElectronicMaterial(record) {\n const f337s = record.get('337');\n\n return f337s.some(field => {\n const mediaTypeIsC = field.subfields.some(sub => sub.code === 'b' && sub.value === 'c');\n const sourceIsRdamedia = field.subfields.some(sub => sub.code === '2' && sub.value === 'rdamedia');\n return mediaTypeIsC && sourceIsRdamedia;\n });\n}\n\nexport function nvdebug(message, func = undefined) {\n if (func) { // eslint-disable-line functional/no-conditional-statements\n func(message);\n }\n //console.info(message); // eslint-disable-line no-console\n}\n\nexport function fieldHasSubfield(field, subfieldCode, subfieldValue = null) {\n if (!field.subfields) {\n return false;\n }\n if (subfieldValue === null) {\n return field.subfields.some(sf => sf.code === subfieldCode);\n }\n return field.subfields.some(sf => sf.code === subfieldCode && subfieldValue === sf.value);\n}\n\nexport function subfieldToString(sf) {\n return `‡${sf.code} ${sf.value}`;\n}\n\nfunction normalizeIndicatorValue(val) {\n if (val === ' ') {\n return '#';\n }\n return val;\n}\n\nexport function fieldToString(f) {\n if ('subfields' in f) {\n return `${f.tag} ${normalizeIndicatorValue(f.ind1)}${normalizeIndicatorValue(f.ind2)}${formatSubfields(f)}`;\n }\n return `${f.tag} ${f.value}`;\n\n function formatSubfields(field) {\n return field.subfields.map(sf => ` ${subfieldToString(sf)}`).join('');\n }\n}\n\nexport function fieldsToString(fields) {\n return fields.map(f => fieldToString(f)).join('\\t__SEPARATOR__\\t');\n}\n"],"mappings":";;;;;;;;;;;AAAO,SAASA,oBAAoBA,CAACC,MAAM,EAAE;EAC3C,MAAMC,KAAK,GAAGD,MAAM,CAACE,GAAG,CAAC,KAAK,CAAC;EAE/B,OAAOD,KAAK,CAACE,IAAI,CAACC,KAAK,IAAI;IACzB,MAAMC,YAAY,GAAGD,KAAK,CAACE,SAAS,CAACH,IAAI,CAACI,GAAG,IAAIA,GAAG,CAACC,IAAI,KAAK,GAAG,IAAID,GAAG,CAACE,KAAK,K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-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"require": [
|
|
117
|
-
"babel-register"
|
|
118
|
-
],
|
|
119
|
-
"sourceMap": false,
|
|
120
|
-
"instrument": false,
|
|
121
|
-
"lines": 80,
|
|
122
|
-
"statements": 80,
|
|
123
|
-
"functions": 80,
|
|
124
|
-
"branches": 80
|
|
125
|
-
}
|
|
2
|
+
"name": "@natlibfi/marc-record-validators-melinda",
|
|
3
|
+
"description": "MARC record validators used in Melinda",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "The National Library of Finland"
|
|
6
|
+
},
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"homepage": "https://github.com/natlibfi/marc-record-validators-melinda",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/natlibfi/marc-record-validators-melinda/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git@github.com:natlibfi/marc-record-validators-melinda.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"version": "3.3.14-alpha.3",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepare": "npm run build",
|
|
27
|
+
"lint": "eslint src",
|
|
28
|
+
"lint:dev": "eslint --fix src",
|
|
29
|
+
"test:base": "cross-env NODE_ENV=test mocha --require @babel/register --reporter-option maxDiffSize=15000 --recursive --extension .spec.js src",
|
|
30
|
+
"test": "npm run lint && npm run test:base",
|
|
31
|
+
"test:dev": "npm run lint:dev && npm run coverage",
|
|
32
|
+
"coverage": "npm run cover:unit && npm run cover:report",
|
|
33
|
+
"cover:unit": "nyc --silent npm run test:base",
|
|
34
|
+
"cover:report": "nyc report",
|
|
35
|
+
"build": "babel src --source-maps --copy-files --delete-dir-on-start --out-dir=dist"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@babel/register": "^7.22.5",
|
|
39
|
+
"@natlibfi/issn-verify": "^1.0.0",
|
|
40
|
+
"@natlibfi/marc-record": "^7.2.2",
|
|
41
|
+
"@natlibfi/marc-record-validate": "^8.0.1",
|
|
42
|
+
"cld3-asm": "^3.1.1",
|
|
43
|
+
"debug": "^4.3.4",
|
|
44
|
+
"isbn3": "^1.1.39",
|
|
45
|
+
"langs": "^2.0.0",
|
|
46
|
+
"node-fetch": "^2.6.12",
|
|
47
|
+
"xml2js": ">=0.6.2 <1.0.0",
|
|
48
|
+
"clone": "^2.1.2"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@natlibfi/marc-record-validate": "^8.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@babel/cli": "^7.22.9",
|
|
55
|
+
"@babel/core": "^7.22.9",
|
|
56
|
+
"@babel/eslint-parser": "^7.22.9",
|
|
57
|
+
"@babel/preset-env": "^7.22.9",
|
|
58
|
+
"@natlibfi/eslint-config-melinda-backend": "^3.0.0",
|
|
59
|
+
"@natlibfi/fixugen": "^2.0.1",
|
|
60
|
+
"@natlibfi/fixura": "^3.0.1",
|
|
61
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
62
|
+
"babel-plugin-rewire": "^1.2.0",
|
|
63
|
+
"chai": "^4.3.7",
|
|
64
|
+
"chai-as-promised": "^7.1.1",
|
|
65
|
+
"cross-env": "^7.0.3",
|
|
66
|
+
"eslint": "^8.45.0",
|
|
67
|
+
"fetch-mock": "^9.11.0",
|
|
68
|
+
"mocha": "^10.2.0",
|
|
69
|
+
"nyc": "^15.1.0"
|
|
70
|
+
},
|
|
71
|
+
"eslintConfig": {
|
|
72
|
+
"parser": "@babel/eslint-parser",
|
|
73
|
+
"extends": [
|
|
74
|
+
"@natlibfi/melinda-backend"
|
|
75
|
+
],
|
|
76
|
+
"env": {
|
|
77
|
+
"mocha": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"babel": {
|
|
81
|
+
"presets": [
|
|
82
|
+
[
|
|
83
|
+
"@babel/preset-env",
|
|
84
|
+
{
|
|
85
|
+
"targets": "maintained node versions"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
],
|
|
89
|
+
"env": {
|
|
90
|
+
"test": {
|
|
91
|
+
"plugins": [
|
|
92
|
+
"rewire",
|
|
93
|
+
"istanbul"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"nyc": {
|
|
99
|
+
"exclude": [
|
|
100
|
+
"src/*.spec.js",
|
|
101
|
+
"src/**/*.spec.js"
|
|
102
|
+
],
|
|
103
|
+
"reporter": [
|
|
104
|
+
"text"
|
|
105
|
+
],
|
|
106
|
+
"require": [
|
|
107
|
+
"@babel/register"
|
|
108
|
+
],
|
|
109
|
+
"sourceMap": false,
|
|
110
|
+
"instrument": false,
|
|
111
|
+
"lines": 80,
|
|
112
|
+
"statements": 80,
|
|
113
|
+
"functions": 80,
|
|
114
|
+
"branches": 80
|
|
115
|
+
}
|
|
126
116
|
}
|