@natlibfi/marc-record-validators-melinda 11.3.2 → 11.3.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.
@@ -6,15 +6,17 @@
6
6
 
7
7
 
8
8
  //import createDebugLogger from 'debug';
9
- import fs from 'fs';
10
- import path from 'path';
9
+ //import fs from 'fs';
10
+ //import path from 'path';
11
11
  import {mergeField} from './mergeField';
12
12
  import {MarcRecord} from '@natlibfi/marc-record';
13
13
  import {postprocessRecords} from './mergeOrAddPostprocess.js';
14
14
 
15
15
  const description = 'Merge fields within record';
16
16
 
17
- const defaultConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'merge-fields', 'config.json'), 'utf8'));
17
+ import {mergeConfig as defaultConfig} from './mergeConfig.js';
18
+
19
+ //const defaultConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'merge-fields', 'config.json'), 'utf8'));
18
20
 
19
21
  export default function () {
20
22
 
@@ -0,0 +1,69 @@
1
+ export const mergeConfig = {
2
+ 'mergeConfiguration': {
3
+ 'comment #1': 'Meaningless indicators (=indicators having but one legal value) are derived from melindaCustomMergeFields.',
4
+ 'comment #2': 'Meaningless indicators and non-filing indicators never prevent merge. (Hard-coded in mergableIndicator.js)',
5
+ 'comment #3': 'When merging, indicator preference defaults are defined in mergeIndicators.js. However, these can be overridden here.',
6
+ 'indicator1PreferredValues': {
7
+ '022': {'0': 1, '1': 1, ' ': 2},
8
+ '041': {'0': 1, '1': 1, ' ': 2},
9
+ '246': {'0': 1, '1': 1, '2': 1, '3': 1, ' ': 2},
10
+ '341': {'0': 1, '1': 1, ' ': 2},
11
+ '363': {'0': 1, '1': 1, ' ': 2},
12
+ '382': {'0': 1, '1': 1, '2': 1, '3': 1, ' ': 2},
13
+ '384': {'0': 1, '1': 1, ' ': 2},
14
+ '388': {'0': 1, '1': 1, ' ': 2},
15
+ '490': ['1', '0'],
16
+ '505': ['8', '0', '2', '1'],
17
+ '506': {'0': 1, '1': 1, ' ': 2},
18
+ '541': {'0': 1, '1': 1, ' ': 2},
19
+ '542': {'0': 1, '1': 1, ' ': 2},
20
+ '544': {'0': 1, '1': 1, ' ': 2},
21
+ '545': {'0': 1, '1': 1, ' ': 2},
22
+ '561': {'0': 1, '1': 1, ' ': 2},
23
+ '583': {'0': 1, '1': 1, ' ': 2},
24
+ '588': {'0': 1, '1': 1, ' ': 2},
25
+ '650': [' ', '1', '2', '0']
26
+ },
27
+ 'indicator2PreferredValues': {
28
+ '024': {'0': 1, '1': 1, ' ': 2},
29
+ '033': {'0': 1, '1': 1, '2': 1, ' ': 2},
30
+ '246': {'0': 1, '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1, '7': 1, '8': 1, ' ': 2},
31
+ '363': {'0': 1, '1': 1, ' ': 2},
32
+ '382': {'0': 1, '1': 1, ' ': 2},
33
+ '730': ['2', ' ']
34
+ },
35
+ 'comment #4': 'List indicators that do not block merge here. Non-filing indicators do not prevent field merge (their support is hard-coded). They are mainly listed here as an example.',
36
+ 'ignoreIndicator1': ['100', '110', '111', '130', '210', '242', '245', '246', '247', '307', '490', '505', '506', '510', '511', '516', '520', '521', '522', '524', '526', '583', '586', '600', '610', '630', '650', '651', '655', '700', '710', '730', '740', '760', '762', '765', '767', '770', '772', '773', '774', '775', '776', '777', '780', '785', '786', '787', '788', '800', '810'],
37
+ 'ignoreIndicator2': ['017', '222', '240', '242', '243', '245', '760', '762', '765', '767', '770', '773', '774', '775', '776', '777', '786', '787', '788', '830'],
38
+ 'comment #5': 'If one indicator has value, and the other has not, it does not necessarily mean mismatch',
39
+ 'tolerateBlankIndicator1': ['022', '037', '041', '046', '050', '055', '060', '070', '080', '246', '260', '264', '341', '363', '382', '384', '388', '541', '542', '544', '545', '561', '583', '588', '856'],
40
+ 'tolerateBlankIndicator2': ['024', '033', '082', '246', '363', '382', '856'],
41
+ 'preprocessorDirectives': [
42
+ {
43
+ 'operation': 'retag',
44
+ 'recordType': 'source',
45
+ 'fieldSpecification': {'tag': '100'},
46
+ 'comment': 'NB! Retags should check corresponding 880 fields as well.',
47
+ 'newTag': '700'
48
+ },
49
+ {
50
+ 'operation': 'retag',
51
+ 'recordType': 'source',
52
+ 'fieldSpecification': {'tag': '110'},
53
+ 'newTag': '710'
54
+ },
55
+ {
56
+ 'operation': 'retag',
57
+ 'recordType': 'source',
58
+ 'fieldSpecification': {'tag': '111'},
59
+ 'newTag': '711'
60
+ },
61
+ {
62
+ 'operation': 'retag',
63
+ 'recordType': 'source',
64
+ 'fieldSpecification': {'tag': '130'},
65
+ 'newTag': '730'
66
+ }
67
+ ]
68
+ }
69
+ };
@@ -121,6 +121,7 @@ const subfieldSortOrder = [
121
121
  {'tag': '810', 'sortOrder': sortOrderForX10},
122
122
  {'tag': '811', 'sortOrder': ['a', 'n', 'd', 'c', 'e', 'g', 'j']},
123
123
  {'tag': '830', 'sortOrder': ['a', 'n', 'x', 'v']}, // INCOMPLETE, SAME AS 490? APPARENTLY NOT...
124
+ {'tag': '856', 'sortOrder': ['3', 'u', 'q', 'x', 'y', 'z', '5']}, // incomplete, LoC examples are inconclusive
124
125
  {'tag': '880', 'sortOrder': ['6', 'a']},
125
126
  {'tag': '946', 'sortOrder': sortOrderFor246},
126
127
  {'tag': 'LOW', 'sortOrder': ['a', 'b', 'c', 'l', 'h']},
package/src/utils.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import createDebugLogger from 'debug';
2
2
 
3
- import fs from 'fs';
4
- import path from 'path';
3
+ //import fs from 'fs';
4
+ //import path from 'path';
5
5
 
6
6
  const debug = createDebugLogger('@natlibfi/melinda-marc-record-merge-reducers:utils');
7
7
  //const debugData = debug.extend('data');
8
8
  const debugDev = debug.extend('dev');
9
9
 
10
- const melindaFields = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'src', 'melindaCustomMergeFields.json'), 'utf8'));
10
+ import {melindaCustomMergeFields as melindaFields} from './melindaCustomMergeFields';
11
11
 
12
+ //JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'src', 'melindaCustomMergeFields.json'), 'utf8'));
12
13
 
13
14
  export function isElectronicMaterial(record) {
14
15
  const f337s = record.get('337');
@@ -1,83 +0,0 @@
1
- {
2
- "mergeConfiguration" :
3
- {
4
- "comment #1" : "Meaningless indicators (=indicators having but one legal value) are derived from melindaCustomMergeFields.",
5
- "comment #2" : "Meaningless indicators and non-filing indicators never prevent merge. (Hard-coded in mergableIndicator.js)",
6
- "comment #3" : "When merging, indicator preference defaults are defined in mergeIndicators.js. However, these can be overridden here.",
7
- "indicator1PreferredValues": {
8
- "022" : {"0": 1, "1": 1, " ": 2},
9
- "041" : {"0": 1, "1": 1, " ": 2},
10
- "246" : {"0": 1, "1": 1, "2": 1, "3": 1, " ": 2},
11
- "341" : {"0": 1, "1": 1, " ": 2},
12
- "363" : {"0": 1, "1": 1, " ": 2},
13
- "382" : {"0": 1, "1": 1, "2": 1, "3": 1, " ": 2},
14
- "384" : {"0": 1, "1": 1, " ": 2},
15
- "388" : {"0": 1, "1": 1, " ": 2},
16
- "490" : [ "1", "0" ],
17
- "505" : [ "8", "0", "2", "1" ],
18
- "506" : {"0": 1, "1": 1, " ": 2},
19
- "541" : {"0": 1, "1": 1, " ": 2},
20
- "542" : {"0": 1, "1": 1, " ": 2},
21
- "544" : {"0": 1, "1": 1, " ": 2},
22
- "545" : {"0": 1, "1": 1, " ": 2},
23
- "561" : {"0": 1, "1": 1, " ": 2},
24
- "583" : {"0": 1, "1": 1, " ": 2},
25
- "588" : {"0": 1, "1": 1, " ": 2},
26
- "650" : [ " ", "1", "2", "0" ]
27
- },
28
- "indicator2PreferredValues": {
29
- "024" : {"0": 1, "1": 1, " ": 2},
30
- "033" : {"0": 1, "1": 1, "2": 1, " ": 2},
31
- "246" : {"0": 1, "1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1, "8": 1, " ": 2},
32
- "363" : {"0": 1, "1": 1, " ": 2},
33
- "382" : {"0": 1, "1": 1, " ": 2},
34
- "730" : [ "2", " " ]
35
- },
36
- "comment #4" : "List indicators that don't block merge here. Non-filing indicators do not prevent field merge (their support is hard-coded). They are mainly listed here as an example.",
37
- "ignoreIndicator1" : ["100", "110", "111", "130",
38
- "210", "242", "245", "246", "247", "307", "490",
39
- "505", "506", "510", "511", "516", "520", "521", "522", "524", "526", "583", "586",
40
- "600", "610", "630", "650", "651", "655",
41
- "700", "710", "730", "740", "760", "762", "765", "767", "770", "772", "773", "774", "775", "776",
42
- "777", "780", "785", "786", "787", "788", "800", "810"],
43
- "ignoreIndicator2" : ["017", "222", "240", "242", "243", "245",
44
- "760", "762", "765", "767", "770", "773", "774", "775", "776", "777", "786", "787", "788", "830"],
45
- "comment #5" : "If one indicator has value, and the other has not, it does not necessarily mean mismatch",
46
- "tolerateBlankIndicator1": ["022", "037", "041", "046", "050", "055", "060", "070", "080",
47
- "246", "260", "264",
48
- "341", "363", "382", "384", "388",
49
- "541", "542", "544", "545", "561", "583", "588", "856"],
50
- "tolerateBlankIndicator2": ["024", "033", "082", "246", "363", "382", "856" ],
51
- "preprocessorDirectives" : [
52
- {
53
- "operation": "retag",
54
- "recordType": "source",
55
- "fieldSpecification": {"tag": "100"},
56
- "comment": "NB! Retags should check corresponding 880 fields as well.",
57
- "newTag": "700"
58
- },
59
-
60
- {
61
- "operation": "retag",
62
- "recordType": "source",
63
- "fieldSpecification": {"tag": "110"},
64
- "newTag": "710"
65
- },
66
-
67
- {
68
- "operation": "retag",
69
- "recordType": "source",
70
- "fieldSpecification": {"tag": "111"},
71
- "newTag": "711"
72
- },
73
-
74
- {
75
- "operation": "retag",
76
- "recordType": "source",
77
- "fieldSpecification": {"tag": "130"},
78
- "newTag": "730"
79
- }
80
- ]
81
- }
82
-
83
- }
@@ -1,83 +0,0 @@
1
- {
2
- "mergeConfiguration" :
3
- {
4
- "comment #1" : "Meaningless indicators (=indicators having but one legal value) are derived from melindaCustomMergeFields.",
5
- "comment #2" : "Meaningless indicators and non-filing indicators never prevent merge. (Hard-coded in mergableIndicator.js)",
6
- "comment #3" : "When merging, indicator preference defaults are defined in mergeIndicators.js. However, these can be overridden here.",
7
- "indicator1PreferredValues": {
8
- "022" : {"0": 1, "1": 1, " ": 2},
9
- "041" : {"0": 1, "1": 1, " ": 2},
10
- "246" : {"0": 1, "1": 1, "2": 1, "3": 1, " ": 2},
11
- "341" : {"0": 1, "1": 1, " ": 2},
12
- "363" : {"0": 1, "1": 1, " ": 2},
13
- "382" : {"0": 1, "1": 1, "2": 1, "3": 1, " ": 2},
14
- "384" : {"0": 1, "1": 1, " ": 2},
15
- "388" : {"0": 1, "1": 1, " ": 2},
16
- "490" : [ "1", "0" ],
17
- "505" : [ "8", "0", "2", "1" ],
18
- "506" : {"0": 1, "1": 1, " ": 2},
19
- "541" : {"0": 1, "1": 1, " ": 2},
20
- "542" : {"0": 1, "1": 1, " ": 2},
21
- "544" : {"0": 1, "1": 1, " ": 2},
22
- "545" : {"0": 1, "1": 1, " ": 2},
23
- "561" : {"0": 1, "1": 1, " ": 2},
24
- "583" : {"0": 1, "1": 1, " ": 2},
25
- "588" : {"0": 1, "1": 1, " ": 2},
26
- "650" : [ " ", "1", "2", "0" ]
27
- },
28
- "indicator2PreferredValues": {
29
- "024" : {"0": 1, "1": 1, " ": 2},
30
- "033" : {"0": 1, "1": 1, "2": 1, " ": 2},
31
- "246" : {"0": 1, "1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1, "7": 1, "8": 1, " ": 2},
32
- "363" : {"0": 1, "1": 1, " ": 2},
33
- "382" : {"0": 1, "1": 1, " ": 2},
34
- "730" : [ "2", " " ]
35
- },
36
- "comment #4" : "List indicators that don't block merge here. Non-filing indicators do not prevent field merge (their support is hard-coded). They are mainly listed here as an example.",
37
- "ignoreIndicator1" : ["100", "110", "111", "130",
38
- "210", "242", "245", "246", "247", "307", "490",
39
- "505", "506", "510", "511", "516", "520", "521", "522", "524", "526", "583", "586",
40
- "600", "610", "630", "650", "651", "655",
41
- "700", "710", "730", "740", "760", "762", "765", "767", "770", "772", "773", "774", "775", "776",
42
- "777", "780", "785", "786", "787", "788", "800", "810"],
43
- "ignoreIndicator2" : ["017", "222", "240", "242", "243", "245",
44
- "760", "762", "765", "767", "770", "773", "774", "775", "776", "777", "786", "787", "788", "830"],
45
- "comment #5" : "If one indicator has value, and the other has not, it does not necessarily mean mismatch",
46
- "tolerateBlankIndicator1": ["022", "037", "041", "046", "050", "055", "060", "070", "080",
47
- "246", "260", "264",
48
- "341", "363", "382", "384", "388",
49
- "541", "542", "544", "545", "561", "583", "588", "856"],
50
- "tolerateBlankIndicator2": ["024", "033", "082", "246", "363", "382", "856" ],
51
- "preprocessorDirectives" : [
52
- {
53
- "operation": "retag",
54
- "recordType": "source",
55
- "fieldSpecification": {"tag": "100"},
56
- "comment": "NB! Retags should check corresponding 880 fields as well.",
57
- "newTag": "700"
58
- },
59
-
60
- {
61
- "operation": "retag",
62
- "recordType": "source",
63
- "fieldSpecification": {"tag": "110"},
64
- "newTag": "710"
65
- },
66
-
67
- {
68
- "operation": "retag",
69
- "recordType": "source",
70
- "fieldSpecification": {"tag": "111"},
71
- "newTag": "711"
72
- },
73
-
74
- {
75
- "operation": "retag",
76
- "recordType": "source",
77
- "fieldSpecification": {"tag": "130"},
78
- "newTag": "730"
79
- }
80
- ]
81
- }
82
-
83
- }