@natlibfi/marc-record-validators-melinda 12.0.0 → 12.0.1
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/dist/disambiguateSeriesStatements.test.js +1 -7
- package/dist/disambiguateSeriesStatements.test.js.map +2 -2
- package/dist/drop-terms.js +122 -0
- package/dist/drop-terms.js.map +7 -0
- package/dist/drop-terms.test.js +56 -0
- package/dist/drop-terms.test.js.map +7 -0
- package/dist/field-008-18-34-character-groups.test.js +1 -7
- package/dist/field-008-18-34-character-groups.test.js.map +2 -2
- package/dist/field-505-separators.test.js +1 -7
- package/dist/field-505-separators.test.js.map +2 -2
- package/dist/field-521-fix.test.js +1 -7
- package/dist/field-521-fix.test.js.map +2 -2
- package/dist/fix-33X.test.js +1 -1
- package/dist/fix-33X.test.js.map +1 -1
- package/dist/fix-country-codes.test.js +1 -7
- package/dist/fix-country-codes.test.js.map +2 -2
- package/dist/fix-sami-041.js +87 -0
- package/dist/fix-sami-041.js.map +7 -0
- package/dist/fix-sami-041.test.js +40 -0
- package/dist/fix-sami-041.test.js.map +7 -0
- package/dist/fixRelatorTerms.test.js +1 -7
- package/dist/fixRelatorTerms.test.js.map +2 -2
- package/dist/index.js +7 -1
- package/dist/index.js.map +2 -2
- package/dist/indicator-fixes.js +10 -0
- package/dist/indicator-fixes.js.map +2 -2
- package/dist/indicator-fixes.test.js +1 -7
- package/dist/indicator-fixes.test.js.map +2 -2
- package/dist/merge-fields.test.js +2 -7
- package/dist/merge-fields.test.js.map +2 -2
- package/dist/mergeField500Lisapainokset.test.js +1 -7
- package/dist/mergeField500Lisapainokset.test.js.map +2 -2
- package/dist/mergeRelatorTermFields.test.js +1 -7
- package/dist/mergeRelatorTermFields.test.js.map +2 -2
- package/dist/multiple-subfield-0.test.js +1 -7
- package/dist/multiple-subfield-0.test.js.map +2 -2
- package/dist/normalize-dashes.test.js +1 -7
- package/dist/normalize-dashes.test.js.map +2 -2
- package/dist/normalize-identifiers.test.js +1 -7
- package/dist/normalize-identifiers.test.js.map +2 -2
- package/dist/normalize-qualifying-information.test.js +1 -7
- package/dist/normalize-qualifying-information.test.js.map +2 -2
- package/dist/normalize-utf8-diacritics.test.js +1 -7
- package/dist/normalize-utf8-diacritics.test.js.map +2 -2
- package/dist/punctuation.test.js +1 -7
- package/dist/punctuation.test.js.map +2 -2
- package/dist/punctuation2.test.js +1 -7
- package/dist/punctuation2.test.js.map +2 -2
- package/dist/reindexSubfield6OccurenceNumbers.test.js +1 -7
- package/dist/reindexSubfield6OccurenceNumbers.test.js.map +2 -2
- package/dist/remove-041-zxx.js +56 -0
- package/dist/remove-041-zxx.js.map +7 -0
- package/dist/remove-041-zxx.test.js +40 -0
- package/dist/remove-041-zxx.test.js.map +7 -0
- package/dist/removeDuplicateDataFields.test.js +1 -7
- package/dist/removeDuplicateDataFields.test.js.map +2 -2
- package/dist/removeInferiorDataFields.js +1 -9
- package/dist/removeInferiorDataFields.js.map +2 -2
- package/dist/removeInferiorDataFields.test.js +1 -7
- package/dist/removeInferiorDataFields.test.js.map +2 -2
- package/dist/resolveOrphanedSubfield6s.js +1 -3
- package/dist/resolveOrphanedSubfield6s.js.map +2 -2
- package/dist/resolveOrphanedSubfield6s.test.js +1 -7
- package/dist/resolveOrphanedSubfield6s.test.js.map +2 -2
- package/dist/sanitize-vocabulary-source-codes.test.js +1 -7
- package/dist/sanitize-vocabulary-source-codes.test.js.map +2 -2
- package/dist/sortFields.js +16 -1
- package/dist/sortFields.js.map +2 -2
- package/dist/sortFields.test.js +1 -7
- package/dist/sortFields.test.js.map +2 -2
- package/dist/sortRelatorTerms.test.js +1 -7
- package/dist/sortRelatorTerms.test.js.map +2 -2
- package/dist/sortSubfields.js +3 -1
- package/dist/sortSubfields.js.map +2 -2
- package/dist/sortSubfields.test.js +1 -7
- package/dist/sortSubfields.test.js.map +2 -2
- package/dist/stripPunctuation.js +7 -4
- package/dist/stripPunctuation.js.map +2 -2
- package/dist/stripPunctuation.test.js +1 -7
- package/dist/stripPunctuation.test.js.map +2 -2
- package/dist/subfield6Utils.js +1 -13
- package/dist/subfield6Utils.js.map +2 -2
- package/dist/subfieldValueNormalizations.test.js +1 -7
- package/dist/subfieldValueNormalizations.test.js.map +2 -2
- package/dist/sync-007-and-300.test.js +1 -7
- package/dist/sync-007-and-300.test.js.map +2 -2
- package/dist/sync-language.js +103 -0
- package/dist/sync-language.js.map +7 -0
- package/dist/sync-language.test.js +40 -0
- package/dist/sync-language.test.js.map +7 -0
- package/dist/translate-terms.js +121 -85
- package/dist/translate-terms.js.map +3 -3
- package/dist/translate-terms.test.js +5 -8
- package/dist/translate-terms.test.js.map +2 -2
- package/dist/update-field-540.test.js +1 -7
- package/dist/update-field-540.test.js.map +2 -2
- package/dist/urn.test.js +1 -7
- package/dist/urn.test.js.map +2 -2
- package/package.json +8 -6
- package/src/disambiguateSeriesStatements.test.js +3 -8
- package/src/drop-terms.js +162 -0
- package/src/drop-terms.test.js +81 -0
- package/src/field-008-18-34-character-groups.test.js +3 -8
- package/src/field-505-separators.test.js +3 -8
- package/src/field-521-fix.test.js +3 -8
- package/src/fix-33X.test.js +1 -1
- package/src/fix-country-codes.test.js +3 -8
- package/src/fix-sami-041.js +113 -0
- package/src/fix-sami-041.test.js +52 -0
- package/src/fixRelatorTerms.test.js +3 -8
- package/src/index.js +8 -1
- package/src/indicator-fixes.js +12 -0
- package/src/indicator-fixes.test.js +3 -8
- package/src/merge-fields.test.js +3 -8
- package/src/mergeField500Lisapainokset.test.js +3 -8
- package/src/mergeRelatorTermFields.test.js +3 -8
- package/src/multiple-subfield-0.test.js +3 -8
- package/src/normalize-dashes.test.js +3 -8
- package/src/normalize-identifiers.test.js +3 -8
- package/src/normalize-qualifying-information.test.js +3 -8
- package/src/normalize-utf8-diacritics.test.js +3 -8
- package/src/punctuation.test.js +3 -8
- package/src/punctuation2.test.js +3 -8
- package/src/reindexSubfield6OccurenceNumbers.test.js +3 -8
- package/src/remove-041-zxx.js +85 -0
- package/src/remove-041-zxx.test.js +52 -0
- package/src/removeDuplicateDataFields.test.js +3 -8
- package/src/removeInferiorDataFields.js +7 -7
- package/src/removeInferiorDataFields.test.js +3 -8
- package/src/resolveOrphanedSubfield6s.js +3 -3
- package/src/resolveOrphanedSubfield6s.test.js +3 -8
- package/src/sanitize-vocabulary-source-codes.test.js +3 -8
- package/src/sortFields.js +20 -1
- package/src/sortFields.test.js +3 -8
- package/src/sortRelatorTerms.test.js +3 -8
- package/src/sortSubfields.js +3 -1
- package/src/sortSubfields.test.js +3 -8
- package/src/stripPunctuation.js +9 -6
- package/src/stripPunctuation.test.js +3 -8
- package/src/subfield6Utils.js +13 -13
- package/src/subfieldValueNormalizations.test.js +3 -8
- package/src/sync-007-and-300.test.js +3 -8
- package/src/sync-language.js +148 -0
- package/src/sync-language.test.js +52 -0
- package/src/translate-terms.js +158 -103
- package/src/translate-terms.test.js +12 -16
- package/src/update-field-540.test.js +3 -8
- package/src/urn.test.js +3 -8
- package/test-fixtures/drop-terms/01/expectedResult.json +31 -0
- package/test-fixtures/drop-terms/01/metadata.json +6 -0
- package/test-fixtures/drop-terms/01/record.json +35 -0
- package/test-fixtures/drop-terms/02/expectedResult.json +7 -0
- package/test-fixtures/drop-terms/02/metadata.json +6 -0
- package/test-fixtures/drop-terms/02/record.json +40 -0
- package/test-fixtures/drop-terms/03/expectedResult.json +6 -0
- package/test-fixtures/drop-terms/03/metadata.json +18 -0
- package/test-fixtures/drop-terms/03/record.json +39 -0
- package/test-fixtures/drop-terms/04/expectedResult.json +6 -0
- package/test-fixtures/drop-terms/04/metadata.json +19 -0
- package/test-fixtures/drop-terms/04/record.json +24 -0
- package/test-fixtures/fix-language-codes/02/metadata.json +1 -1
- package/test-fixtures/fix-sami-041/01/expectedResult.json +6 -0
- package/test-fixtures/fix-sami-041/01/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/01/record.json +13 -0
- package/test-fixtures/fix-sami-041/02/expectedResult.json +10 -0
- package/test-fixtures/fix-sami-041/02/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/02/record.json +8 -0
- package/test-fixtures/fix-sami-041/03/expectedResult.json +5 -0
- package/test-fixtures/fix-sami-041/03/metadata.json +5 -0
- package/test-fixtures/fix-sami-041/03/record.json +8 -0
- package/test-fixtures/fix-sami-041/04/expectedResult.json +7 -0
- package/test-fixtures/fix-sami-041/04/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/04/record.json +10 -0
- package/test-fixtures/fix-sami-041/05/expectedResult.json +10 -0
- package/test-fixtures/fix-sami-041/05/metadata.json +6 -0
- package/test-fixtures/fix-sami-041/05/record.json +8 -0
- package/test-fixtures/indicator-fixes/11/expectedResult.json +10 -0
- package/test-fixtures/indicator-fixes/11/metadata.json +4 -0
- package/test-fixtures/indicator-fixes/11/record.json +10 -0
- package/test-fixtures/merge-fields/f05/metadata.json +1 -1
- package/test-fixtures/remove-041-zxx/01/expectedResult.json +5 -0
- package/test-fixtures/remove-041-zxx/01/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/01/record.json +10 -0
- package/test-fixtures/remove-041-zxx/02/expectedResult.json +7 -0
- package/test-fixtures/remove-041-zxx/02/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/02/record.json +9 -0
- package/test-fixtures/remove-041-zxx/11/expectedResult.json +10 -0
- package/test-fixtures/remove-041-zxx/11/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/11/record.json +9 -0
- package/test-fixtures/remove-041-zxx/12/expectedResult.json +10 -0
- package/test-fixtures/remove-041-zxx/12/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/12/record.json +9 -0
- package/test-fixtures/sort-fields/15/input.json +9 -0
- package/test-fixtures/sort-fields/15/metadata.json +5 -0
- package/test-fixtures/sort-fields/15/result.json +10 -0
- package/test-fixtures/sync-language/01/expectedResult.json +5 -0
- package/test-fixtures/sync-language/01/metadata.json +5 -0
- package/test-fixtures/sync-language/01/record.json +7 -0
- package/test-fixtures/sync-language/02/expectedResult.json +6 -0
- package/test-fixtures/sync-language/02/metadata.json +5 -0
- package/test-fixtures/sync-language/02/record.json +10 -0
- package/test-fixtures/sync-language/03/expectedResult.json +6 -0
- package/test-fixtures/sync-language/03/metadata.json +5 -0
- package/test-fixtures/sync-language/03/record.json +6 -0
- package/test-fixtures/sync-language/10/expectedResult.json +10 -0
- package/test-fixtures/sync-language/10/metadata.json +5 -0
- package/test-fixtures/sync-language/10/record.json +8 -0
- package/test-fixtures/sync-language/11/expectedResult.json +10 -0
- package/test-fixtures/sync-language/11/metadata.json +5 -0
- package/test-fixtures/sync-language/11/record.json +7 -0
- package/test-fixtures/sync-language/12/expectedResult.json +9 -0
- package/test-fixtures/sync-language/12/metadata.json +6 -0
- package/test-fixtures/sync-language/12/record.json +6 -0
- package/test-fixtures/sync-language/13/expectedResult.json +10 -0
- package/test-fixtures/sync-language/13/metadata.json +5 -0
- package/test-fixtures/sync-language/13/record.json +8 -0
- package/test-fixtures/sync-language/14/expectedResult.json +9 -0
- package/test-fixtures/sync-language/14/metadata.json +5 -0
- package/test-fixtures/sync-language/14/record.json +7 -0
- package/test-fixtures/sync-language/15/expectedResult.json +9 -0
- package/test-fixtures/sync-language/15/metadata.json +5 -0
- package/test-fixtures/sync-language/15/record.json +7 -0
- package/test-fixtures/translate-terms/05/expectedResult.json +12 -0
- package/test-fixtures/translate-terms/05/metadata.json +7 -0
- package/test-fixtures/translate-terms/05/record.json +11 -0
- package/test-fixtures/translate-terms/06/expectedResult.json +12 -0
- package/test-fixtures/translate-terms/06/metadata.json +7 -0
- package/test-fixtures/translate-terms/06/record.json +11 -0
- package/test-fixtures/translate-terms-data.js +23 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
//import createDebugLogger from 'debug';
|
|
3
|
+
|
|
4
|
+
import validatorFactory from './remove-041-zxx.js';
|
|
5
|
+
|
|
6
|
+
import {MarcRecord} from '@natlibfi/marc-record';
|
|
7
|
+
import {READERS} from '@natlibfi/fixura';
|
|
8
|
+
import generateTests from '@natlibfi/fixugen';
|
|
9
|
+
|
|
10
|
+
generateTests({
|
|
11
|
+
callback,
|
|
12
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'remove-041-zxx'],
|
|
13
|
+
useMetadataFile: true,
|
|
14
|
+
recurse: false,
|
|
15
|
+
fixura: {
|
|
16
|
+
reader: READERS.JSON
|
|
17
|
+
},
|
|
18
|
+
hooks: {
|
|
19
|
+
before: async () => {
|
|
20
|
+
testValidatorFactory();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/drop-terms:test');
|
|
26
|
+
|
|
27
|
+
async function testValidatorFactory() {
|
|
28
|
+
const validator = await validatorFactory();
|
|
29
|
+
|
|
30
|
+
assert.equal(typeof validator, 'object');
|
|
31
|
+
assert.equal(typeof validator.description, 'string');
|
|
32
|
+
assert.equal(typeof validator.validate, 'function');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function callback({getFixture, fix = false}) {
|
|
36
|
+
const validator = await validatorFactory();
|
|
37
|
+
const record = new MarcRecord(getFixture('record.json'));
|
|
38
|
+
const expectedResult = getFixture('expectedResult.json');
|
|
39
|
+
//const expectedResult = new MarcRecord(getFixture('expectedResult.json'));
|
|
40
|
+
// console.log(expectedResult); // eslint-disable-line
|
|
41
|
+
|
|
42
|
+
if (!fix) {
|
|
43
|
+
const result = await validator.validate(record);
|
|
44
|
+
assert.deepEqual(result, expectedResult);
|
|
45
|
+
const originalRecord = new MarcRecord(getFixture('record.json'));
|
|
46
|
+
assert.deepEqual(record, originalRecord); // Validation should not change the record
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await validator.fix(record);
|
|
51
|
+
assert.deepEqual(record, new MarcRecord(expectedResult));
|
|
52
|
+
}
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './removeDuplicateDataFields.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/removeDuplicateDataFields:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/removeDuplicateDataFields:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -29,12 +29,7 @@ async function testValidatorFactory() {
|
|
|
29
29
|
assert.equal(typeof validator.validate, 'function');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function callback({getFixture,
|
|
33
|
-
if (enabled === false) {
|
|
34
|
-
debug('TEST SKIPPED!');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
async function callback({getFixture, fix = false}) {
|
|
38
33
|
const validator = await validatorFactory();
|
|
39
34
|
const record = new MarcRecord(getFixture('record.json'));
|
|
40
35
|
const expectedResult = getFixture('expectedResult.json');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import createDebugLogger from 'debug';
|
|
1
|
+
//import createDebugLogger from 'debug';
|
|
2
2
|
import {fieldToChain, sameField} from './removeDuplicateDataFields.js';
|
|
3
3
|
import {fieldGetOccurrenceNumberPairs, fieldHasValidSubfield6, fieldSevenToOneOccurrenceNumber, fieldsToNormalizedString} from './subfield6Utils.js';
|
|
4
|
-
import {fieldHasSubfield, fieldsToString, fieldToString, nvdebug
|
|
4
|
+
import {fieldHasSubfield, fieldsToString, fieldToString, /*nvdebug,*/ uniqArray} from './utils.js';
|
|
5
5
|
import {fieldHasValidSubfield8} from './subfield8Utils.js';
|
|
6
6
|
import {encodingLevelIsBetterThanPrepublication, fieldRefersToKoneellisestiTuotettuTietue, getEncodingLevel} from './prepublicationUtils.js';
|
|
7
7
|
import {cloneAndNormalizeFieldForComparison} from './normalizeFieldForComparison.js';
|
|
@@ -12,7 +12,7 @@ import {fixComposition, precomposeFinnishLetters} from './normalize-utf8-diacrit
|
|
|
12
12
|
// NB! This validator handles only full fields, and does not support subfield $8 removal.
|
|
13
13
|
// Also, having multiple $8 subfields in same fields is not supported.
|
|
14
14
|
// If this functionality is needed, see removeDuplicateDatafields.js for examples of subfield-only stuff.
|
|
15
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:removeInferiorDataFields');
|
|
15
|
+
// const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:removeInferiorDataFields');
|
|
16
16
|
|
|
17
17
|
export default function () {
|
|
18
18
|
return {
|
|
@@ -21,7 +21,7 @@ export default function () {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
function fix(record) {
|
|
24
|
-
nvdebug('Fix record: remove inferior (eg. subset) data fields', debug);
|
|
24
|
+
//nvdebug('Fix record: remove inferior (eg. subset) data fields', debug);
|
|
25
25
|
const res = {message: [], fix: [], valid: true};
|
|
26
26
|
removeInferiorDatafields(record, true);
|
|
27
27
|
// This can not really fail...
|
|
@@ -30,7 +30,7 @@ export default function () {
|
|
|
30
30
|
|
|
31
31
|
function validate(record) {
|
|
32
32
|
// Check max, and check number of different indexes
|
|
33
|
-
nvdebug('Validate record: remove inferior (eg. subset) data fields', debug);
|
|
33
|
+
//nvdebug('Validate record: remove inferior (eg. subset) data fields', debug);
|
|
34
34
|
|
|
35
35
|
const duplicates = removeInferiorDatafields(record, false);
|
|
36
36
|
|
|
@@ -444,8 +444,8 @@ export function removeInferiorDatafields(record, fix = true) {
|
|
|
444
444
|
const removables6 = removeInferiorChains(record, fix); // Lone subfield $6 chains
|
|
445
445
|
// HOW TO HANDLE $6+$8 combos? Skipping is relatively OK.
|
|
446
446
|
|
|
447
|
-
nvdebug(`REMOVABLES:\n ${removables.join('\n ')}`, debug);
|
|
448
|
-
nvdebug(`REMOVABLES 6:\n ${removables6.join('\n ')}`, debug);
|
|
447
|
+
//nvdebug(`REMOVABLES:\n ${removables.join('\n ')}`, debug);
|
|
448
|
+
//nvdebug(`REMOVABLES 6:\n ${removables6.join('\n ')}`, debug);
|
|
449
449
|
|
|
450
450
|
const removablesAll = removables.concat(removables6); //.concat(removables8);
|
|
451
451
|
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './removeInferiorDataFields.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/removeInferiorDataFields:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/removeInferiorDataFields:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate).to.be.a('function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import createDebugLogger from 'debug';
|
|
2
|
-
import {fieldHasSubfield, fieldToString, nvdebug
|
|
2
|
+
import {fieldHasSubfield, fieldToString, nvdebug /*, subfieldToString*/ } from './utils.js';
|
|
3
3
|
import {fieldHasWantedTagAndOccurrenceNumber, isValidSubfield6, subfield6GetOccurrenceNumber, subfield6ResetOccurrenceNumber} from './subfield6Utils.js';
|
|
4
4
|
|
|
5
5
|
// Relocated from melinda-marc-record-merge-reducers (and renamed)
|
|
@@ -77,7 +77,7 @@ function findPairForSubfield6OccurrenceNumber(subfield6, myTag, candPairFields)
|
|
|
77
77
|
if (!isValidSubfield6(subfield6)) {
|
|
78
78
|
return undefined;
|
|
79
79
|
}
|
|
80
|
-
nvdebug(`LOOKING FOR PAIR: ${myTag} ${subfieldToString(subfield6)}`);
|
|
80
|
+
//nvdebug(`LOOKING FOR PAIR: ${myTag} ${subfieldToString(subfield6)}`);
|
|
81
81
|
candPairFields.forEach(field => fieldToString(field));
|
|
82
82
|
|
|
83
83
|
// Only valid $6 value that fails to map to another field is iffy...
|
|
@@ -88,7 +88,7 @@ function findPairForSubfield6OccurrenceNumber(subfield6, myTag, candPairFields)
|
|
|
88
88
|
return undefined;
|
|
89
89
|
}
|
|
90
90
|
const tagAndOccurrenceNumber = `${myTag}-${occurrenceNumber}`;
|
|
91
|
-
nvdebug(`Try to find occurrence number ${tagAndOccurrenceNumber} in field ${referredTag}...`);
|
|
91
|
+
//nvdebug(`Try to find occurrence number ${tagAndOccurrenceNumber} in field ${referredTag}...`);
|
|
92
92
|
//const relevantFields = fields.filter(field => field.tag === referredTag && field.subfields.some(sf => subfield6GetOccurrenceNumber(sf) === occurrenceNumber));
|
|
93
93
|
const relevantFields = candPairFields.filter(field => field.tag === referredTag && fieldHasWantedTagAndOccurrenceNumber(field, tagAndOccurrenceNumber));
|
|
94
94
|
if (relevantFields.length === 0) {
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './resolveOrphanedSubfield6s.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/resolveOrphanedSubfield6s:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/resolveOrphanedSubfield6s:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './sanitize-vocabulary-source-codes.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sanitize-vocabulary-source-codes:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sanitize-vocabulary-source-codes:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -29,12 +29,7 @@ async function testValidatorFactory() {
|
|
|
29
29
|
assert.equal(typeof validator.validate, 'function');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function callback({getFixture,
|
|
33
|
-
if (enabled === false) {
|
|
34
|
-
debug('TEST SKIPPED!');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
async function callback({getFixture, fix = false}) {
|
|
38
33
|
const validator = await validatorFactory();
|
|
39
34
|
|
|
40
35
|
const recordFixture = getFixture('record.json');
|
package/src/sortFields.js
CHANGED
|
@@ -211,7 +211,7 @@ export function fieldOrderComparator(fieldA, fieldB) {
|
|
|
211
211
|
|
|
212
212
|
//const sorterFunctions = [sortByTag, sortByIndexTerms, sortAlphabetically, sortByRelatorTerm, sortByOccurrenceNumber, preferFenniKeep, sortByFieldLinkAndSequenceNumber];
|
|
213
213
|
|
|
214
|
-
const sorterFunctions = [sortByTag, sortByIndexTerms, sortAlphabetically, sortByRelatorTerm, sortBySubfield6, preferFenniKeep, sortByFieldLinkAndSequenceNumber];
|
|
214
|
+
const sorterFunctions = [sortByTag, sortByIndexTerms, sortAlphabetically, sortByRelatorTerm, sortBySubfield6, preferFenniKeep, sortByFieldLinkAndSequenceNumber, sortByHacks];
|
|
215
215
|
//const sorterFunctions = [sortByIndexTerms, sortByRelatorTerm, sortByOccurrenceNumber, preferFenniKeep, sortByFieldLinkAndSequenceNumber];
|
|
216
216
|
|
|
217
217
|
return globalFieldOrderComparator(fieldA, fieldB, sorterFunctions);
|
|
@@ -390,6 +390,25 @@ function sortByFieldLinkAndSequenceNumber(fieldA, fieldB) { // Sort by subfield
|
|
|
390
390
|
return -1;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
+
function sortByHacks(fieldA, fieldB) {
|
|
394
|
+
// Place for various hackier rules
|
|
395
|
+
|
|
396
|
+
if (fieldA.tag === fieldB.tag) {
|
|
397
|
+
if (fieldA.tag === '041') {
|
|
398
|
+
// If we have multiple f041, we want to put the $2-less first; Values from $2 whatever can not be copied to 008/35-37. (See sync-language.js.)
|
|
399
|
+
const a2 = fieldA.subfields.some(sf => sf.code === '2');
|
|
400
|
+
const b2 = fieldB.subfields.some(sf => sf.code === '2');
|
|
401
|
+
if (a2 && !b2) {
|
|
402
|
+
return 1;
|
|
403
|
+
}
|
|
404
|
+
if (b2 && !a2) {
|
|
405
|
+
return -1;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
return 0;
|
|
411
|
+
}
|
|
393
412
|
|
|
394
413
|
function sortBySubfield6(fieldA, fieldB) { // Sort by subfield $6, ex-sortByOccurrenceNumber...
|
|
395
414
|
if (fieldA.tag !== '880' || fieldB.tag !== '880') {
|
package/src/sortFields.test.js
CHANGED
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './sortFields.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sortFields:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sortFields:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -29,12 +29,7 @@ async function testValidatorFactory() {
|
|
|
29
29
|
assert.equal(typeof validator.validate, 'function');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function callback({getFixture,
|
|
33
|
-
if (enabled === false) {
|
|
34
|
-
debug('TEST SKIPPED!');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
async function callback({getFixture, fix = true}) {
|
|
38
33
|
const validator = await validatorFactory();
|
|
39
34
|
const record = new MarcRecord(getFixture('input.json'));
|
|
40
35
|
const expectedResult = getFixture('result.json');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './sortRelatorTerms.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sortRelatorTerms:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sortRelatorTerms:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|
package/src/sortSubfields.js
CHANGED
|
@@ -136,7 +136,9 @@ function getSubfieldSortOrder(field) {
|
|
|
136
136
|
debugDev(`sort order for ${field.tag}: ${entry[0].sortOrder}`);
|
|
137
137
|
return entry[0].sortOrder;
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
if (!['300'].includes(field.tag)) { // Lis tags which use normal $a...$z order here!
|
|
140
|
+
nvdebug(`WARNING!\tNo subfield order found for ${field.tag}.`);
|
|
141
|
+
}
|
|
140
142
|
return [];
|
|
141
143
|
}
|
|
142
144
|
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './sortSubfields.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sortSubfields:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sortSubfields:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false, tagPattern = false}) {
|
|
39
34
|
const validator = await validatorFactory(tagPattern);
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|
package/src/stripPunctuation.js
CHANGED
|
@@ -6,26 +6,29 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {fieldGetFixedString, fieldNeedsModification, fieldStripPunctuation} from './punctuation2.js';
|
|
9
|
-
|
|
10
|
-
import {fieldToString, nvdebug} from './utils.js';
|
|
9
|
+
import createDebugLogger from 'debug';
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
import {fieldToString} from './utils.js';
|
|
12
|
+
|
|
13
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/punctuation2');
|
|
14
|
+
|
|
15
|
+
const description = 'Strip punctuation in data fields';
|
|
13
16
|
|
|
14
17
|
export default function () {
|
|
15
18
|
return {
|
|
16
|
-
description:
|
|
19
|
+
description: description,
|
|
17
20
|
validate, fix
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
function fix(record) {
|
|
21
|
-
|
|
24
|
+
debug(`${description}: fixer`);
|
|
22
25
|
const res = {message: [], fix: [], valid: true};
|
|
23
26
|
record.fields.forEach(f => fieldStripPunctuation(f));
|
|
24
27
|
return res;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
function validate(record) {
|
|
28
|
-
|
|
31
|
+
debug(`${description}: validate`);
|
|
29
32
|
|
|
30
33
|
const fieldsNeedingModification = record.fields.filter(f => fieldNeedsModification(f, false));
|
|
31
34
|
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './stripPunctuation.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/stripPunctuation:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/stripPunctuation:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|
package/src/subfield6Utils.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import createDebugLogger from 'debug';
|
|
1
|
+
//import createDebugLogger from 'debug';
|
|
2
2
|
// const debug = createDebugLogger('@natlibfi/marc-record-validator-melinda/subfield6Utils');
|
|
3
3
|
|
|
4
4
|
import {add8s, fieldsGetAllSubfield8LinkingNumbers, getSubfield8LinkingNumber, isValidSubfield8} from './subfield8Utils.js';
|
|
5
|
-
import {fieldHasSubfield, fieldToString, fieldsToString, nvdebug, subfieldToString} from './utils.js';
|
|
5
|
+
import {fieldHasSubfield, fieldToString, /* fieldsToString, */ nvdebug, subfieldToString} from './utils.js';
|
|
6
6
|
|
|
7
|
-
const debug = createDebugLogger('@natlibfi/melinda-marc-record-merge-reducers:subfield6Utils');
|
|
7
|
+
//const debug = createDebugLogger('@natlibfi/melinda-marc-record-merge-reducers:subfield6Utils');
|
|
8
8
|
//const debugData = debug.extend('data');
|
|
9
|
-
const debugDev = debug.extend('dev');
|
|
9
|
+
//const debugDev = debug.extend('dev');
|
|
10
10
|
|
|
11
11
|
// NB! Subfield 6 is non-repeatable and it should always comes first!
|
|
12
12
|
// NB! Index size should always be 2 (preceding 0 required for 01..09) However, support for 100+ was added on 2023-02-27.
|
|
@@ -71,7 +71,7 @@ export function subfield6HasWantedTagAndOccurrenceNumber(subfield, tagAndOccurre
|
|
|
71
71
|
}
|
|
72
72
|
// We could also use generic code and go getTag()+'-'+getIndex() instead of regexp...
|
|
73
73
|
const key = subfield.value.replace(/^([0-9][0-9][0-9]-[0-9][0-9]+).*$/u, '$1');
|
|
74
|
-
nvdebug(` Compare '${key}' vs '${tagAndOccurrenceNumber}'`);
|
|
74
|
+
//nvdebug(` Compare '${key}' vs '${tagAndOccurrenceNumber}'`);
|
|
75
75
|
return key === tagAndOccurrenceNumber;
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -222,7 +222,7 @@ export function fieldGetOccurrenceNumberPairs(field, candFields) {
|
|
|
222
222
|
nvdebug(`NO PAIRS FOUND FOR '${fieldToString(field)}'`);
|
|
223
223
|
return pairs;
|
|
224
224
|
}
|
|
225
|
-
nvdebug(`${pairs.length} PAIR(S) FOUND FOR '${fieldToString(field)}'`);
|
|
225
|
+
//nvdebug(`${pairs.length} PAIR(S) FOUND FOR '${fieldToString(field)}'`);
|
|
226
226
|
pairs.forEach(pairedField => nvdebug(` '${fieldToString(pairedField)}'`));
|
|
227
227
|
return pairs;
|
|
228
228
|
}
|
|
@@ -357,7 +357,7 @@ function guessTargetLinkingNumber(fields, defaultTargetLinkingNumber) {
|
|
|
357
357
|
export function fieldsToNormalizedString(fields, defaultTargetLinkingNumber = 0, normalizeOccurrenceNumber = false, normalizeEntryTag = false) {
|
|
358
358
|
const targetLinkingNumber = guessTargetLinkingNumber(fields, defaultTargetLinkingNumber);
|
|
359
359
|
|
|
360
|
-
nvdebug(`fieldsToNormalizedString: OCC: ${normalizeOccurrenceNumber}`);
|
|
360
|
+
//nvdebug(`fieldsToNormalizedString: OCC: ${normalizeOccurrenceNumber}`);
|
|
361
361
|
const strings = fields.map(field => fieldToNormalizedString(field, targetLinkingNumber, normalizeOccurrenceNumber, normalizeEntryTag));
|
|
362
362
|
strings.sort();
|
|
363
363
|
return strings.join('\t__SEPARATOR__\t');
|
|
@@ -445,7 +445,7 @@ export function isFirstLinkedSubfield6Field(field, record) {
|
|
|
445
445
|
}
|
|
446
446
|
const chain = getAllLinkedSubfield6Fields(field, record);
|
|
447
447
|
if (!isRelevantSubfield6Chain(chain)) {
|
|
448
|
-
nvdebug(`Rejected 6: ${fieldsToString(chain)}`);
|
|
448
|
+
//nvdebug(`Rejected 6: ${fieldsToString(chain)}`);
|
|
449
449
|
return false;
|
|
450
450
|
}
|
|
451
451
|
|
|
@@ -472,13 +472,13 @@ export function get6s(field, candidateFields) { // NB! Convert field to fields!!
|
|
|
472
472
|
if (sixes.length === 0) {
|
|
473
473
|
return [field];
|
|
474
474
|
}
|
|
475
|
-
nvdebug(`SIXES: ${sixes.length}`);
|
|
475
|
+
//nvdebug(`SIXES: ${sixes.length}`);
|
|
476
476
|
const occurrenceNumbers = sixes.map(sf => subfield6GetOccurrenceNumber(sf)).filter(value => value !== undefined && value !== '00');
|
|
477
|
-
nvdebug(occurrenceNumbers.join(' -- '));
|
|
477
|
+
//nvdebug(occurrenceNumbers.join(' -- '));
|
|
478
478
|
|
|
479
479
|
const relevantFields = candidateFields.filter(f => occurrenceNumbers.some(o => fieldHasOccurrenceNumber(f, o)));
|
|
480
|
-
nvdebug(`${fieldToString(field)}: $6-RELFIELDS FOUND: ${relevantFields.length}...`);
|
|
481
|
-
relevantFields.forEach(f => nvdebug(fieldToString(f)));
|
|
480
|
+
//nvdebug(`${fieldToString(field)}: $6-RELFIELDS FOUND: ${relevantFields.length}...`);
|
|
481
|
+
//relevantFields.forEach(f => nvdebug(fieldToString(f)));
|
|
482
482
|
return relevantFields;
|
|
483
483
|
}
|
|
484
484
|
|
|
@@ -488,6 +488,6 @@ export function resetSubfield6Tag(subfield, tag) {
|
|
|
488
488
|
}
|
|
489
489
|
// NB! mainly for 1XX<->7XX transfers
|
|
490
490
|
const newValue = `${tag}-${subfield.value.substring(4)}`;
|
|
491
|
-
nvdebug(`Set subfield $6 value from ${subfieldToString(subfield)} to ${newValue}`, debugDev);
|
|
491
|
+
//nvdebug(`Set subfield $6 value from ${subfieldToString(subfield)} to ${newValue}`, debugDev);
|
|
492
492
|
subfield.value = newValue;
|
|
493
493
|
}
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './subfieldValueNormalizations.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/subfieldValueNormalizations:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/subfieldValueNormalizations:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
|
|
41
36
|
const recordFixture = getFixture('record.json');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './sync-007-and-300.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -20,7 +20,7 @@ generateTests({
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
});
|
|
23
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sync-007-and-300:test');
|
|
23
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/sync-007-and-300:test');
|
|
24
24
|
|
|
25
25
|
async function testValidatorFactory() {
|
|
26
26
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|