@natlibfi/marc-record-validators-melinda 11.4.8-alpha.3 → 11.5.0-alpha.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.
Files changed (69) hide show
  1. package/dist/disambiguateSeriesStatements.js +200 -0
  2. package/dist/disambiguateSeriesStatements.js.map +1 -0
  3. package/dist/disambiguateSeriesStatements.spec.js +51 -0
  4. package/dist/disambiguateSeriesStatements.spec.js.map +1 -0
  5. package/dist/fix-country-codes.spec.js +1 -1
  6. package/dist/fix-country-codes.spec.js.map +1 -1
  7. package/dist/index.js +7 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/merge-fields/mergeField.js +2 -2
  10. package/dist/merge-fields/mergeField.js.map +1 -1
  11. package/dist/merge-fields/mergeOrAddSubfield.js +5 -2
  12. package/dist/merge-fields/mergeOrAddSubfield.js.map +1 -1
  13. package/dist/merge-fields.spec.js +1 -1
  14. package/dist/merge-fields.spec.js.map +1 -1
  15. package/dist/normalize-identifiers.js +1 -1
  16. package/dist/normalize-identifiers.js.map +1 -1
  17. package/dist/normalizeFieldForComparison.js +12 -2
  18. package/dist/normalizeFieldForComparison.js.map +1 -1
  19. package/dist/normalizeSubfieldValueForComparison.js +1 -1
  20. package/dist/normalizeSubfieldValueForComparison.js.map +1 -1
  21. package/dist/prepublicationUtils.js +17 -6
  22. package/dist/prepublicationUtils.js.map +1 -1
  23. package/dist/removeInferiorDataFields.js +27 -4
  24. package/dist/removeInferiorDataFields.js.map +1 -1
  25. package/dist/sortRelatorTerms.js +6 -4
  26. package/dist/sortRelatorTerms.js.map +1 -1
  27. package/dist/translate-terms.js +1 -3
  28. package/dist/translate-terms.js.map +1 -1
  29. package/package.json +5 -2
  30. package/src/disambiguateSeriesStatements.js +228 -0
  31. package/src/disambiguateSeriesStatements.spec.js +52 -0
  32. package/src/fix-country-codes.spec.js +1 -1
  33. package/src/index.js +2 -0
  34. package/src/merge-fields/mergeField.js +4 -4
  35. package/src/merge-fields/mergeOrAddSubfield.js +3 -3
  36. package/src/merge-fields.spec.js +1 -1
  37. package/src/normalize-identifiers.js +1 -1
  38. package/src/normalizeFieldForComparison.js +9 -4
  39. package/src/normalizeSubfieldValueForComparison.js +1 -1
  40. package/src/prepublicationUtils.js +17 -6
  41. package/src/removeInferiorDataFields.js +32 -5
  42. package/src/sortRelatorTerms.js +4 -4
  43. package/src/translate-terms.js +1 -2
  44. package/test-fixtures/disambiguate-series-statements/f01/expectedResult.json +16 -0
  45. package/test-fixtures/disambiguate-series-statements/f01/metadata.json +5 -0
  46. package/test-fixtures/disambiguate-series-statements/f01/record.json +16 -0
  47. package/test-fixtures/disambiguate-series-statements/f02/expectedResult.json +16 -0
  48. package/test-fixtures/disambiguate-series-statements/f02/metadata.json +5 -0
  49. package/test-fixtures/disambiguate-series-statements/f02/record.json +16 -0
  50. package/test-fixtures/disambiguate-series-statements/f03/expectedResult.json +16 -0
  51. package/test-fixtures/disambiguate-series-statements/f03/metadata.json +5 -0
  52. package/test-fixtures/disambiguate-series-statements/f03/record.json +15 -0
  53. package/test-fixtures/disambiguate-series-statements/f04/expectedResult.json +17 -0
  54. package/test-fixtures/disambiguate-series-statements/f04/metadata.json +6 -0
  55. package/test-fixtures/disambiguate-series-statements/f04/record.json +16 -0
  56. package/test-fixtures/disambiguate-series-statements/f05/expectedResult.json +17 -0
  57. package/test-fixtures/disambiguate-series-statements/f05/metadata.json +5 -0
  58. package/test-fixtures/disambiguate-series-statements/f05/record.json +17 -0
  59. package/test-fixtures/disambiguate-series-statements/v01/expectedResult.json +6 -0
  60. package/test-fixtures/disambiguate-series-statements/v01/metadata.json +5 -0
  61. package/test-fixtures/disambiguate-series-statements/v01/record.json +16 -0
  62. package/test-fixtures/disambiguate-series-statements/v04/expectedResult.json +4 -0
  63. package/test-fixtures/disambiguate-series-statements/v04/metadata.json +6 -0
  64. package/test-fixtures/disambiguate-series-statements/v04/record.json +16 -0
  65. package/test-fixtures/remove-inferior-datafields/f13/expectedResult.json +7 -0
  66. package/test-fixtures/remove-inferior-datafields/f13/record.json +11 -0
  67. package/test-fixtures/remove-inferior-datafields/f15/expectedResult.json +12 -0
  68. package/test-fixtures/remove-inferior-datafields/f15/metadata.json +6 -0
  69. package/test-fixtures/remove-inferior-datafields/f15/record.json +17 -0
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSruClient = createSruClient;
7
+ exports.default = _default;
8
+ exports.search = search;
9
+ var _debug = _interopRequireDefault(require("debug"));
10
+ var _utils = require("./utils");
11
+ var _marcRecordSerializers = require("@natlibfi/marc-record-serializers");
12
+ var _melindaCommons = require("@natlibfi/melinda-commons");
13
+ var _clone = _interopRequireDefault(require("clone"));
14
+ var _sruClient = _interopRequireDefault(require("@natlibfi/sru-client"));
15
+ var _punctuation = require("./punctuation2");
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ //const {default: createNatlibfiSruClient} = natlibfiSruClient;
18
+
19
+ const debug = (0, _debug.default)('@natlibfi/marc-record-validators-melinda:disambiguateSeriesStatements');
20
+ const ELECTRONIC = 1;
21
+ const PRINTED = 2;
22
+ const NEITHER_OR_UNKNOWN = 0;
23
+ const SRU_API_URL = 'https://sru.api.melinda.kansalliskirjasto.fi/bib';
24
+
25
+ // Author(s): Nicholas Volk
26
+ function _default() {
27
+ const sruClient = createSruClient(SRU_API_URL);
28
+ return {
29
+ description: 'Disambiguate between printed and electonic series statements (490 with multiple $xs)',
30
+ validate,
31
+ fix
32
+ };
33
+ async function fix(record) {
34
+ const recordType = getRecordType(record);
35
+ const relevantFields = getRelevantFields(record.fields);
36
+ const message = await fix490x(recordType, relevantFields, true);
37
+ return {
38
+ message,
39
+ fix: [],
40
+ valid: true
41
+ };
42
+ }
43
+ async function validate(record) {
44
+ const recordType = getRecordType(record);
45
+ const relevantFields = getRelevantFields(record.fields);
46
+ const message = await fix490x(recordType, relevantFields, false);
47
+ return {
48
+ message,
49
+ valid: message.length === 0
50
+ };
51
+ }
52
+ function getValidIssnSubfields(field) {
53
+ const subfields = field.subfields?.filter(sf => sf.code === 'x' && sf.value.match(/^[0-9]{4}-[0-9][0-9][0-9][0-9Xx][^0-9Xx]*$/u));
54
+ return subfields;
55
+ }
56
+ function isRelevantField(field) {
57
+ if (field.tag !== '490') {
58
+ return false;
59
+ }
60
+ return getValidIssnSubfields(field).length > 1;
61
+ }
62
+ function getRelevantFields(fields) {
63
+ return fields.filter(f => isRelevantField(f));
64
+ }
65
+ async function fix490x(recordType, fields, reallyFix, message = []) {
66
+ if (recordType === NEITHER_OR_UNKNOWN) {
67
+ return message;
68
+ }
69
+ const [currField, ...remainingFields] = fields;
70
+ if (!currField) {
71
+ return message;
72
+ }
73
+ const validXs = getValidIssnSubfields(currField);
74
+ const deletableXs = await getRemovableSubfields(validXs, recordType);
75
+ if (deletableXs.length === 0 || deletableXs.length === validXs.length) {
76
+ return fix490x(recordType, remainingFields, reallyFix, message);
77
+ }
78
+ const deletableStrings = deletableXs.map(sf => (0, _utils.subfieldToString)(sf));
79
+ (0, _utils.nvdebug)(`Field has removable ISSNS: '${deletableStrings.join(', ')}`, debug);
80
+
81
+ // fixer:
82
+ if (reallyFix) {
83
+ currField.subfields = currField.subfields.filter(sf => !deletableStrings.includes((0, _utils.subfieldToString)(sf))); // eslint-disable-line functional/immutable-data
84
+ (0, _punctuation.fieldFixPunctuation)(currField);
85
+ return fix490x(recordType, remainingFields, reallyFix, message);
86
+ }
87
+ // validators:
88
+ const clonedField = (0, _clone.default)(currField);
89
+ const originalString = (0, _utils.fieldToString)(clonedField);
90
+ clonedField.subfields = clonedField.subfields.filter(sf => !deletableStrings.includes((0, _utils.subfieldToString)(sf))); // eslint-disable-line functional/immutable-data
91
+
92
+ const newMessage = `Replace '${originalString}' with '${(0, _utils.fieldToString)(clonedField)}'`;
93
+ return fix490x(recordType, remainingFields, reallyFix, [...message, newMessage]);
94
+ }
95
+ async function getRemovableSubfields(validXs, recordType, removables = []) {
96
+ const [currSubfield, ...remainingXs] = validXs;
97
+ if (!currSubfield) {
98
+ return removables;
99
+ }
100
+ const isRemoveable = await isRemovableSubfield(currSubfield, recordType);
101
+ if (isRemoveable) {
102
+ return getRemovableSubfields(remainingXs, recordType, [...removables, currSubfield]);
103
+ }
104
+ return getRemovableSubfields(remainingXs, recordType, removables);
105
+ }
106
+ async function isRemovableSubfield(subfield, recordType) {
107
+ //console.info(` isRemovableField() in...`); // eslint-disable-line no-console
108
+ const issn = subfield.value.substring(0, 9); // Strip punctuation (ISSN consists of nine letter, eg. "1234-5678")
109
+
110
+ //console.info(` got ISSN ${issn}`); // eslint-disable-line no-console
111
+ const issnRecords = await issnToRecords(issn);
112
+ //console.info(` ISSN returned ${issnRecords.length} record(s)`); // eslint-disable-line no-console
113
+
114
+ // !isMismatchingRecord !== isMatchingRecord as NEITHER_OR_UNKNOWN record type is neutral. Thus double negative "not mismatch". Sorry about that.
115
+ if (issnRecords.some(r => !isMismatchingRecord(r))) {
116
+ return false;
117
+ }
118
+ return true;
119
+ function isMismatchingRecord(r) {
120
+ const issnRecordType = getRecordType(r);
121
+ if (issnRecordType === NEITHER_OR_UNKNOWN) {
122
+ return false;
123
+ }
124
+ return issnRecordType !== recordType;
125
+ }
126
+ }
127
+ async function issnToRecords(issn) {
128
+ //console.log('issnToRecords() in...'); // eslint-disable-line no-console
129
+ const records = await search(sruClient, `bath.issn=${issn}`);
130
+ //console.log(`ISSN2RECORDS got ${records.length} record(s)!`); // eslint-disable-line no-console
131
+ return records;
132
+ }
133
+ function getRecordType(record) {
134
+ const f337 = record.get('337');
135
+ if (f337.length !== 1) {
136
+ return NEITHER_OR_UNKNOWN;
137
+ }
138
+ const b = f337[0].subfields.filter(sf => sf.code === 'b');
139
+ if (b.length !== 1) {
140
+ return NEITHER_OR_UNKNOWN;
141
+ }
142
+ if (b[0].value === 'c') {
143
+ return ELECTRONIC;
144
+ }
145
+ if (b[0].value === 'n') {
146
+ return PRINTED;
147
+ }
148
+ return NEITHER_OR_UNKNOWN;
149
+ }
150
+ }
151
+
152
+ // All the code below is copypasted from melinda-ui-artikkelit project file src/services/sruServices/sruClient.js
153
+
154
+ function createSruClient(sruApiUrl) {
155
+ const sruClientOptions = {
156
+ url: sruApiUrl,
157
+ recordSchema: 'marcxml',
158
+ retrieveAll: false,
159
+ maxRecordsPerRequest: 100
160
+ };
161
+ return (0, _sruClient.default)(sruClientOptions);
162
+ }
163
+
164
+ /*******************************************************************************/
165
+ /* Search and retrieve (copypaste from melinda-ui-artikkelit) */
166
+
167
+ function search(sruClient, query, one = false) {
168
+ return new Promise((resolve, reject) => {
169
+ const promises = [];
170
+ const noValidation = {
171
+ fields: false,
172
+ subfields: false,
173
+ subfieldValues: false
174
+ };
175
+
176
+ // console.info(`SRU query: $${searchUrl}`);
177
+
178
+ sruClient.searchRetrieve(query).on('record', xmlString => {
179
+ promises.push(_marcRecordSerializers.MARCXML.from(xmlString, noValidation)); // eslint-disable-line functional/immutable-data
180
+ }).on('end', async () => {
181
+ try {
182
+ if (promises.length > 0) {
183
+ if (one) {
184
+ const [firstPromise] = promises;
185
+ const firstRecord = await firstPromise;
186
+ return resolve(firstRecord);
187
+ }
188
+ const records = await Promise.all(promises);
189
+ return resolve(records);
190
+ }
191
+ reject(new _melindaCommons.Error(404, 'No records found with search and retrieve'));
192
+ } catch (error) {
193
+ reject(error);
194
+ }
195
+ }).on('error', error => {
196
+ reject(error);
197
+ });
198
+ });
199
+ }
200
+ //# sourceMappingURL=disambiguateSeriesStatements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disambiguateSeriesStatements.js","names":["_debug","_interopRequireDefault","require","_utils","_marcRecordSerializers","_melindaCommons","_clone","_sruClient","_punctuation","e","__esModule","default","debug","createDebugLogger","ELECTRONIC","PRINTED","NEITHER_OR_UNKNOWN","SRU_API_URL","_default","sruClient","createSruClient","description","validate","fix","record","recordType","getRecordType","relevantFields","getRelevantFields","fields","message","fix490x","valid","length","getValidIssnSubfields","field","subfields","filter","sf","code","value","match","isRelevantField","tag","f","reallyFix","currField","remainingFields","validXs","deletableXs","getRemovableSubfields","deletableStrings","map","subfieldToString","nvdebug","join","includes","fieldFixPunctuation","clonedField","clone","originalString","fieldToString","newMessage","removables","currSubfield","remainingXs","isRemoveable","isRemovableSubfield","subfield","issn","substring","issnRecords","issnToRecords","some","r","isMismatchingRecord","issnRecordType","records","search","f337","get","b","sruApiUrl","sruClientOptions","url","recordSchema","retrieveAll","maxRecordsPerRequest","createNatlibfiSruClient","query","one","Promise","resolve","reject","promises","noValidation","subfieldValues","searchRetrieve","on","xmlString","push","MARCXML","from","firstPromise","firstRecord","all","Error","error"],"sources":["../src/disambiguateSeriesStatements.js"],"sourcesContent":["import createDebugLogger from 'debug';\nimport {fieldToString, nvdebug, subfieldToString} from './utils';\nimport {MARCXML} from '@natlibfi/marc-record-serializers';\nimport {Error} from '@natlibfi/melinda-commons';\nimport clone from 'clone';\nimport {default as createNatlibfiSruClient} from '@natlibfi/sru-client';\nimport {fieldFixPunctuation} from './punctuation2';\n\n//const {default: createNatlibfiSruClient} = natlibfiSruClient;\n\nconst debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:disambiguateSeriesStatements');\n\nconst ELECTRONIC = 1;\nconst PRINTED = 2;\nconst NEITHER_OR_UNKNOWN = 0;\nconst SRU_API_URL = 'https://sru.api.melinda.kansalliskirjasto.fi/bib';\n\n// Author(s): Nicholas Volk\nexport default function () {\n const sruClient = createSruClient(SRU_API_URL);\n\n return {\n description: 'Disambiguate between printed and electonic series statements (490 with multiple $xs)',\n validate, fix\n };\n\n async function fix(record) {\n const recordType = getRecordType(record);\n\n const relevantFields = getRelevantFields(record.fields);\n const message = await fix490x(recordType, relevantFields, true);\n\n return {message, fix: [], valid: true};\n }\n\n async function validate(record) {\n const recordType = getRecordType(record);\n\n const relevantFields = getRelevantFields(record.fields);\n const message = await fix490x(recordType, relevantFields, false);\n\n return {message, valid: message.length === 0};\n }\n\n\n function getValidIssnSubfields(field) {\n const subfields = field.subfields?.filter(sf => sf.code === 'x' && sf.value.match(/^[0-9]{4}-[0-9][0-9][0-9][0-9Xx][^0-9Xx]*$/u));\n return subfields;\n }\n\n function isRelevantField(field) {\n if (field.tag !== '490') {\n return false;\n }\n return getValidIssnSubfields(field).length > 1;\n }\n\n function getRelevantFields(fields) {\n return fields.filter(f => isRelevantField(f));\n }\n\n async function fix490x(recordType, fields, reallyFix, message = []) {\n\n if (recordType === NEITHER_OR_UNKNOWN) {\n return message;\n }\n const [currField, ...remainingFields] = fields;\n\n if (!currField) {\n return message;\n }\n\n const validXs = getValidIssnSubfields(currField);\n\n const deletableXs = await getRemovableSubfields(validXs, recordType);\n\n if (deletableXs.length === 0 || deletableXs.length === validXs.length) {\n return fix490x(recordType, remainingFields, reallyFix, message);\n }\n\n const deletableStrings = deletableXs.map(sf => subfieldToString(sf));\n nvdebug(`Field has removable ISSNS: '${deletableStrings.join(', ')}`, debug);\n\n // fixer:\n if (reallyFix) {\n currField.subfields = currField.subfields.filter(sf => !deletableStrings.includes(subfieldToString(sf))); // eslint-disable-line functional/immutable-data\n fieldFixPunctuation(currField);\n return fix490x(recordType, remainingFields, reallyFix, message);\n }\n // validators:\n const clonedField = clone(currField);\n const originalString = fieldToString(clonedField);\n clonedField.subfields = clonedField.subfields.filter(sf => !deletableStrings.includes(subfieldToString(sf))); // eslint-disable-line functional/immutable-data\n\n const newMessage = `Replace '${originalString}' with '${fieldToString(clonedField)}'`;\n\n return fix490x(recordType, remainingFields, reallyFix, [...message, newMessage]);\n }\n\n async function getRemovableSubfields(validXs, recordType, removables = []) {\n const [currSubfield, ...remainingXs] = validXs;\n\n if (!currSubfield) {\n return removables;\n }\n\n const isRemoveable = await isRemovableSubfield(currSubfield, recordType);\n if (isRemoveable) {\n return getRemovableSubfields(remainingXs, recordType, [...removables, currSubfield]);\n }\n return getRemovableSubfields(remainingXs, recordType, removables);\n }\n\n async function isRemovableSubfield(subfield, recordType) {\n //console.info(` isRemovableField() in...`); // eslint-disable-line no-console\n const issn = subfield.value.substring(0, 9); // Strip punctuation (ISSN consists of nine letter, eg. \"1234-5678\")\n\n //console.info(` got ISSN ${issn}`); // eslint-disable-line no-console\n const issnRecords = await issnToRecords(issn);\n //console.info(` ISSN returned ${issnRecords.length} record(s)`); // eslint-disable-line no-console\n\n // !isMismatchingRecord !== isMatchingRecord as NEITHER_OR_UNKNOWN record type is neutral. Thus double negative \"not mismatch\". Sorry about that.\n if (issnRecords.some(r => !isMismatchingRecord(r))) {\n return false;\n }\n return true;\n\n function isMismatchingRecord(r) {\n const issnRecordType = getRecordType(r);\n if (issnRecordType === NEITHER_OR_UNKNOWN) {\n return false;\n }\n return issnRecordType !== recordType;\n }\n }\n\n async function issnToRecords(issn) {\n //console.log('issnToRecords() in...'); // eslint-disable-line no-console\n const records = await search(sruClient, `bath.issn=${issn}`);\n //console.log(`ISSN2RECORDS got ${records.length} record(s)!`); // eslint-disable-line no-console\n return records;\n }\n\n function getRecordType(record) {\n const f337 = record.get('337');\n if (f337.length !== 1) {\n return NEITHER_OR_UNKNOWN;\n }\n\n const b = f337[0].subfields.filter(sf => sf.code === 'b');\n if (b.length !== 1) {\n return NEITHER_OR_UNKNOWN;\n }\n\n if (b[0].value === 'c') {\n return ELECTRONIC;\n }\n\n if (b[0].value === 'n') {\n return PRINTED;\n }\n\n return NEITHER_OR_UNKNOWN;\n }\n\n}\n\n// All the code below is copypasted from melinda-ui-artikkelit project file src/services/sruServices/sruClient.js\n\nexport function createSruClient(sruApiUrl) {\n\n const sruClientOptions = {\n url: sruApiUrl,\n recordSchema: 'marcxml',\n retrieveAll: false,\n maxRecordsPerRequest: 100\n };\n\n return createNatlibfiSruClient(sruClientOptions);\n}\n\n\n/*******************************************************************************/\n/* Search and retrieve (copypaste from melinda-ui-artikkelit) */\n\nexport function search(sruClient, query, one = false) {\n\n return new Promise((resolve, reject) => {\n const promises = [];\n\n const noValidation = {\n fields: false,\n subfields: false,\n subfieldValues: false\n };\n\n // console.info(`SRU query: $${searchUrl}`);\n\n sruClient.searchRetrieve(query)\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, noValidation)); // eslint-disable-line functional/immutable-data\n })\n .on('end', async () => {\n try {\n\n if (promises.length > 0) {\n\n if (one) {\n const [firstPromise] = promises;\n const firstRecord = await firstPromise;\n return resolve(firstRecord);\n }\n\n const records = await Promise.all(promises);\n return resolve(records);\n }\n reject(new Error(404, 'No records found with search and retrieve'));\n\n } catch (error) {\n reject(error);\n }\n })\n .on('error', error => {\n reject(error);\n });\n });\n}\n\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAAmD,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnD;;AAEA,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,uEAAuE,CAAC;AAExG,MAAMC,UAAU,GAAG,CAAC;AACpB,MAAMC,OAAO,GAAG,CAAC;AACjB,MAAMC,kBAAkB,GAAG,CAAC;AAC5B,MAAMC,WAAW,GAAG,kDAAkD;;AAEtE;AACe,SAAAC,SAAA,EAAY;EACzB,MAAMC,SAAS,GAAGC,eAAe,CAACH,WAAW,CAAC;EAE9C,OAAO;IACLI,WAAW,EAAE,sFAAsF;IACnGC,QAAQ;IAAEC;EACZ,CAAC;EAED,eAAeA,GAAGA,CAACC,MAAM,EAAE;IACzB,MAAMC,UAAU,GAAGC,aAAa,CAACF,MAAM,CAAC;IAExC,MAAMG,cAAc,GAAGC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,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtC,MAAMC,QAAQ,GAAG,EAAE;IAEnB,MAAMC,YAAY,GAAG;MACnBlE,MAAM,EAAE,KAAK;MACbO,SAAS,EAAE,KAAK;MAChB4D,cAAc,EAAE;IAClB,CAAC;;IAED;;IAEA7E,SAAS,CAAC8E,cAAc,CAACR,KAAK,CAAC,CAC5BS,EAAE,CAAC,QAAQ,EAAEC,SAAS,IAAI;MACzBL,QAAQ,CAACM,IAAI,CAACC,8BAAO,CAACC,IAAI,CAACH,SAAS,EAAEJ,YAAY,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CACDG,EAAE,CAAC,KAAK,EAAE,YAAY;MACrB,IAAI;QAEF,IAAIJ,QAAQ,CAAC7D,MAAM,GAAG,CAAC,EAAE;UAEvB,IAAIyD,GAAG,EAAE;YACP,MAAM,CAACa,YAAY,CAAC,GAAGT,QAAQ;YAC/B,MAAMU,WAAW,GAAG,MAAMD,YAAY;YACtC,OAAOX,OAAO,CAACY,WAAW,CAAC;UAC7B;UAEA,MAAM3B,OAAO,GAAG,MAAMc,OAAO,CAACc,GAAG,CAACX,QAAQ,CAAC;UAC3C,OAAOF,OAAO,CAACf,OAAO,CAAC;QACzB;QACAgB,MAAM,CAAC,IAAIa,qBAAK,CAAC,GAAG,EAAE,2CAA2C,CAAC,CAAC;MAErE,CAAC,CAAC,OAAOC,KAAK,EAAE;QACdd,MAAM,CAACc,KAAK,CAAC;MACf;IACF,CAAC,CAAC,CACDT,EAAE,CAAC,OAAO,EAAES,KAAK,IAAI;MACpBd,MAAM,CAACc,KAAK,CAAC;IACf,CAAC,CAAC;EACN,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _chai = require("chai");
4
+ var _marcRecord = require("@natlibfi/marc-record");
5
+ var _disambiguateSeriesStatements = _interopRequireDefault(require("./disambiguateSeriesStatements"));
6
+ var _fixura = require("@natlibfi/fixura");
7
+ var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
8
+ var _debug = _interopRequireDefault(require("debug"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ (0, _fixugen.default)({
11
+ callback,
12
+ path: [__dirname, '..', 'test-fixtures', 'disambiguate-series-statements'],
13
+ useMetadataFile: true,
14
+ recurse: false,
15
+ fixura: {
16
+ reader: _fixura.READERS.JSON
17
+ },
18
+ mocha: {
19
+ before: () => testValidatorFactory()
20
+ }
21
+ });
22
+ const debug = (0, _debug.default)('@natlibfi/marc-record-validators-melinda/disambiguateSeriesStatements:test');
23
+ async function testValidatorFactory() {
24
+ const validator = await (0, _disambiguateSeriesStatements.default)();
25
+ (0, _chai.expect)(validator).to.be.an('object').that.has.any.keys('description', 'validate');
26
+ (0, _chai.expect)(validator.description).to.be.a('string');
27
+ (0, _chai.expect)(validator.validate).to.be.a('function');
28
+ }
29
+ async function callback({
30
+ getFixture,
31
+ enabled = true,
32
+ fix = false
33
+ }) {
34
+ if (enabled === false) {
35
+ debug('TEST SKIPPED!');
36
+ return;
37
+ }
38
+ const validator = await (0, _disambiguateSeriesStatements.default)();
39
+ const record = new _marcRecord.MarcRecord(getFixture('record.json'));
40
+ const expectedResult = getFixture('expectedResult.json');
41
+ // console.log(expectedResult); // eslint-disable-line
42
+
43
+ if (!fix) {
44
+ const result = await validator.validate(record);
45
+ (0, _chai.expect)(result).to.eql(expectedResult);
46
+ return;
47
+ }
48
+ await validator.fix(record);
49
+ (0, _chai.expect)(record).to.eql(expectedResult);
50
+ }
51
+ //# sourceMappingURL=disambiguateSeriesStatements.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disambiguateSeriesStatements.spec.js","names":["_chai","require","_marcRecord","_disambiguateSeriesStatements","_interopRequireDefault","_fixura","_fixugen","_debug","e","__esModule","default","generateTests","callback","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","mocha","before","testValidatorFactory","debug","createDebugLogger","validator","validatorFactory","expect","to","be","an","that","has","any","keys","description","a","validate","getFixture","enabled","fix","record","MarcRecord","expectedResult","result","eql"],"sources":["../src/disambiguateSeriesStatements.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport validatorFactory from './disambiguateSeriesStatements';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\nimport createDebugLogger from 'debug';\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'disambiguate-series-statements'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON\n },\n mocha: {\n before: () => testValidatorFactory()\n }\n});\nconst debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/disambiguateSeriesStatements:test');\n\nasync function testValidatorFactory() {\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\nasync function callback({getFixture, enabled = true, fix = false}) {\n if (enabled === false) {\n debug('TEST SKIPPED!');\n return;\n }\n\n const validator = await validatorFactory();\n const record = new MarcRecord(getFixture('record.json'));\n const expectedResult = getFixture('expectedResult.json');\n // console.log(expectedResult); // eslint-disable-line\n\n if (!fix) {\n const result = await validator.validate(record);\n expect(result).to.eql(expectedResult);\n return;\n }\n\n await validator.fix(record);\n expect(record).to.eql(expectedResult);\n}\n"],"mappings":";;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,MAAA,GAAAH,sBAAA,CAAAH,OAAA;AAAsC,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EA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AAqB,CAAC;EACxD;;EAEA,IAAI,CAACE,GAAG,EAAE;IACR,MAAMI,MAAM,GAAG,MAAMnB,SAAS,CAACY,QAAQ,CAACI,MAAM,CAAC;IAC/C,IAAAd,YAAM,EAACiB,MAAM,CAAC,CAAChB,EAAE,CAACiB,GAAG,CAACF,cAAc,CAAC;IACrC;EACF;EAEA,MAAMlB,SAAS,CAACe,GAAG,CAACC,MAAM,CAAC;EAC3B,IAAAd,YAAM,EAACc,MAAM,CAAC,CAACb,EAAE,CAACiB,GAAG,CAACF,cAAc,CAAC;AACvC","ignoreList":[]}
@@ -19,7 +19,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
19
19
  before: () => testValidatorFactory()
20
20
  }
21
21
  });
22
- const debug = (0, _debug.default)('@natlibfi/marc-record-validators-melinda/fix-country-codestest');
22
+ const debug = (0, _debug.default)('@natlibfi/marc-record-validators-melinda/fix-country-codes:test');
23
23
  async function testValidatorFactory() {
24
24
  const validator = await (0, _fixCountryCodes.default)();
25
25
  (0, _chai.expect)(validator).to.be.an('object').that.has.any.keys('description', 'validate');
@@ -1 +1 @@
1
- {"version":3,"file":"fix-country-codes.spec.js","names":["_chai","require","_marcRecord","_fixCountryCodes","_interopRequireDefault","_fixura","_fixugen","_debug","e","__esModule","default","generateTests","callback","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","mocha","before","testValidatorFactory","debug","createDebugLogger","validator","validatorFactory","expect","to","be","an","that","has","any","keys","description","a","validate","getFixture","enabled","fix","record","MarcRecord","expectedResult","result","eql"],"sources":["../src/fix-country-codes.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport validatorFactory from './fix-country-codes';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\nimport createDebugLogger from 'debug';\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'fix-country-codes'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON\n },\n mocha: {\n before: () => testValidatorFactory()\n }\n});\nconst debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fix-country-codestest');\n\nasync function testValidatorFactory() {\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\nasync function callback({getFixture, enabled = true, fix = false}) {\n if (enabled === false) {\n debug('TEST SKIPPED!');\n return;\n }\n\n const validator = await validatorFactory();\n const record = new MarcRecord(getFixture('record.json'));\n const expectedResult = getFixture('expectedResult.json');\n // console.log(expectedResult); // eslint-disable-line\n\n if (!fix) {\n const result = await validator.validate(record);\n expect(result).to.eql(expectedResult);\n return;\n }\n\n await validator.fix(record);\n expect(record).to.eql(expectedResult);\n}\n"],"mappings":";;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,MAAA,GAAAH,sBAAA,CAAAH,OAAA;AAAsC,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtC,IAAAG,gBAAa,EAAC;EACZC,QAAQ;EACRC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,mBAAmB,CAAC;EAC7DC,eAAe,EAAE,IAAI;EACrBC,OAAO,EAAE,KAAK;EACdC,MAAM,EAAE;IACNC,MAAM,EAAEC,eAAO,CAACC;EAClB,CAAC;EACDC,KAAK,EAAE;IACLC,MAAM,EAAEA,CAAA,KAAMC,oBAAoB,CAAC;EACrC;AACF,CAAC,CAAC;AACF,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAA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{"version":3,"file":"fix-country-codes.spec.js","names":["_chai","require","_marcRecord","_fixCountryCodes","_interopRequireDefault","_fixura","_fixugen","_debug","e","__esModule","default","generateTests","callback","path","__dirname","useMetadataFile","recurse","fixura","reader","READERS","JSON","mocha","before","testValidatorFactory","debug","createDebugLogger","validator","validatorFactory","expect","to","be","an","that","has","any","keys","description","a","validate","getFixture","enabled","fix","record","MarcRecord","expectedResult","result","eql"],"sources":["../src/fix-country-codes.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport validatorFactory from './fix-country-codes';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\nimport createDebugLogger from 'debug';\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'fix-country-codes'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON\n },\n mocha: {\n before: () => testValidatorFactory()\n }\n});\nconst debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fix-country-codes:test');\n\nasync function testValidatorFactory() {\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\nasync function callback({getFixture, enabled = true, fix = false}) {\n if (enabled === false) {\n debug('TEST SKIPPED!');\n return;\n }\n\n const validator = await validatorFactory();\n const record = new MarcRecord(getFixture('record.json'));\n const expectedResult = getFixture('expectedResult.json');\n // console.log(expectedResult); // eslint-disable-line\n\n if (!fix) {\n const result = await validator.validate(record);\n expect(result).to.eql(expectedResult);\n return;\n }\n\n await validator.fix(record);\n expect(record).to.eql(expectedResult);\n}\n"],"mappings":";;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAF,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AS,GAAG,MAAM,IAAAC,wBAAgB,EAAC,CAAC;EAC1C,MAAMe,MAAM,GAAG,IAAIC,sBAAU,CAACJ,UAAU,CAAC,aAAa,CAAC,CAAC;EACxD,MAAMK,cAAc,GAAGL,UAAU,CAAC,qBAAqB,CAAC;EACxD;;EAEA,IAAI,CAACE,GAAG,EAAE;IACR,MAAMI,MAAM,GAAG,MAAMnB,SAAS,CAACY,QAAQ,CAACI,MAAM,CAAC;IAC/C,IAAAd,YAAM,EAACiB,MAAM,CAAC,CAAChB,EAAE,CAACiB,GAAG,CAACF,cAAc,CAAC;IACrC;EACF;EAEA,MAAMlB,SAAS,CAACe,GAAG,CAACC,MAAM,CAAC;EAC3B,IAAAd,YAAM,EAACc,MAAM,CAAC,CAACb,EAAE,CAACiB,GAAG,CAACF,cAAc,CAAC;AACvC","ignoreList":[]}
package/dist/index.js CHANGED
@@ -45,6 +45,12 @@ Object.defineProperty(exports, "CyrilluxUsemarconReplacement", {
45
45
  return _cyrilluxUsemarconReplacement.default;
46
46
  }
47
47
  });
48
+ Object.defineProperty(exports, "DisambiguateSeriesStatements", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _disambiguateSeriesStatements.default;
52
+ }
53
+ });
48
54
  Object.defineProperty(exports, "DoubleCommas", {
49
55
  enumerable: true,
50
56
  get: function () {
@@ -346,6 +352,7 @@ var _addMissingField3 = _interopRequireDefault(require("./addMissingField337"));
346
352
  var _addMissingField4 = _interopRequireDefault(require("./addMissingField338"));
347
353
  var _cyrillux = _interopRequireDefault(require("./cyrillux"));
348
354
  var _cyrilluxUsemarconReplacement = _interopRequireDefault(require("./cyrillux-usemarcon-replacement"));
355
+ var _disambiguateSeriesStatements = _interopRequireDefault(require("./disambiguateSeriesStatements"));
349
356
  var _doubleCommas = _interopRequireDefault(require("./double-commas"));
350
357
  var _duplicatesInd = _interopRequireDefault(require("./duplicates-ind1"));
351
358
  var _emptyFields = _interopRequireDefault(require("./empty-fields"));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_accessRights","_interopRequireDefault","require","_addMissingField","_addMissingField2","_addMissingField3","_addMissingField4","_cyrillux","_cyrilluxUsemarconReplacement","_doubleCommas","_duplicatesInd","_emptyFields","_endingPunctuation","_endingWhitespace","_field0081834CharacterGroups","_field505Separators","_field521Fix","_fieldExclusion","_fieldStructure","_fieldsPresent","_fix33X","_fixCountryCodes","_fixLanguageCodes","_fixRelatorTerms","_fixedFields","_identicalFields","_indicatorFixes","_isbnIssn","_itemLanguage","_mergeField500Lisapainokset","_mergeFields","_mergeRelatorTermFields","_multipleSubfield","_nonBreakingSpace","_normalizeDashes","_normalizeIdentifiers","_normalizeQualifyingInformation","_normalizeUtf8Diacritics","_punctuation","_punctuation2","_reindexSubfield6OccurenceNumbers","_removeDuplicateDataFields","_removeInferiorDataFields","_resolvableExtReferencesMelinda","_resolveOrphanedSubfield6s","_sanitizeVocabularySourceCodes","_sortFields","_sortRelatorTerms","_sortSubfields","_sortTags","_subfieldValueNormalizations","_subfieldExclusion","_sync007And","_translateTerms","_typeOfDate","_unicodeDecomposition","_updateField","_urn","e","__esModule","default"],"sources":["../src/index.js"],"sourcesContent":["import AccessRights from './access-rights';\nimport AddMissingField041 from './addMissingField041';\nimport AddMissingField336 from './addMissingField336';\nimport AddMissingField337 from './addMissingField337';\nimport AddMissingField338 from './addMissingField338';\nimport Cyrillux from './cyrillux';\nimport CyrilluxUsemarconReplacement from './cyrillux-usemarcon-replacement';\nimport DoubleCommas from './double-commas';\nimport DuplicatesInd1 from './duplicates-ind1';\nimport EmptyFields from './empty-fields';\nimport EndingPunctuation from './ending-punctuation';\nimport EndingWhitespace from './ending-whitespace';\nimport Field008CharacterGroups from './field-008-18-34-character-groups';\nimport Field505Separators from './field-505-separators';\nimport Field521Fix from './field-521-fix';\nimport FieldExclusion from './field-exclusion';\nimport FieldStructure from './field-structure';\nimport FieldsPresent from './fields-present';\nimport Fix33X from './fix-33X';\nimport FixCountryCodes from './fix-country-codes';\nimport FixLanguageCodes from './fix-language-codes';\nimport FixRelatorTerms from './fixRelatorTerms';\nimport FixedFields from './fixed-fields';\nimport IdenticalFields from './identical-fields';\nimport IndicatorFixes from './indicator-fixes';\nimport IsbnIssn from './isbn-issn';\nimport ItemLanguage from './item-language';\nimport MergeField500Lisapainokset from './mergeField500Lisapainokset';\nimport MergeFields from './merge-fields/';\nimport MergeRelatorTermFields from './mergeRelatorTermFields';\nimport MultipleSubfield0s from './multiple-subfield-0';\nimport NonBreakingSpace from './non-breaking-space';\nimport NormalizeDashes from './normalize-dashes';\nimport NormalizeIdentifiers from './normalize-identifiers';\nimport NormalizeQualifyingInformation from './normalize-qualifying-information';\nimport NormalizeUTF8Diacritics from './normalize-utf8-diacritics';\nimport Punctuation from './punctuation/';\nimport Punctuation2 from './punctuation2';\nimport ReindexSubfield6OccurenceNumbers from './reindexSubfield6OccurenceNumbers';\nimport RemoveDuplicateDataFields from './removeDuplicateDataFields';\nimport RemoveInferiorDataFields from './removeInferiorDataFields';\nimport ResolvableExtReferences from './resolvable-ext-references-melinda';\nimport ResolveOrphanedSubfield6s from './resolveOrphanedSubfield6s';\nimport SanitizeVocabularySourceCodes from './sanitize-vocabulary-source-codes';\nimport SortFields from './sortFields';\nimport SortRelatorTerms from './sortRelatorTerms';\nimport SortSubfields from './sortSubfields';\nimport SortTags from './sort-tags';\n// import StripPunctuation from './stripPunctuation'; // Can we add this here? Should be used very cautiosly!\nimport SubfieldValueNormalizations from './subfieldValueNormalizations';\nimport SubfieldExclusion from './subfield-exclusion';\nimport Sync007And300 from './sync-007-and-300';\nimport TranslateTerms from './translate-terms';\nimport TypeOfDateF008 from './typeOfDate-008';\nimport UnicodeDecomposition from './unicode-decomposition';\nimport UpdateField540 from './update-field-540';\nimport Urn from './urn';\n\nexport {\n AccessRights,\n AddMissingField041,\n AddMissingField336,\n AddMissingField337,\n AddMissingField338,\n Cyrillux,\n CyrilluxUsemarconReplacement,\n DoubleCommas,\n DuplicatesInd1,\n EmptyFields,\n EndingPunctuation,\n EndingWhitespace,\n Field008CharacterGroups,\n Field505Separators,\n Field521Fix,\n FieldExclusion,\n FieldsPresent,\n FieldStructure,\n Fix33X,\n FixCountryCodes,\n FixLanguageCodes,\n FixRelatorTerms,\n FixedFields,\n IdenticalFields,\n IndicatorFixes,\n IsbnIssn,\n ItemLanguage,\n MergeField500Lisapainokset,\n MergeRelatorTermFields,\n MultipleSubfield0s,\n NonBreakingSpace,\n NormalizeDashes,\n NormalizeIdentifiers,\n NormalizeQualifyingInformation,\n NormalizeUTF8Diacritics,\n Punctuation,\n Punctuation2,\n ResolveOrphanedSubfield6s, // Do this before reindexing! (thus I'm not sticking with alphabetical order here)\n ReindexSubfield6OccurenceNumbers,\n RemoveDuplicateDataFields,\n RemoveInferiorDataFields,\n ResolvableExtReferences,\n SanitizeVocabularySourceCodes,\n SortRelatorTerms,\n SortSubfields,\n SortTags,\n SubfieldExclusion,\n SubfieldValueNormalizations,\n Sync007And300,\n TypeOfDateF008,\n TranslateTerms,\n UnicodeDecomposition,\n UpdateField540,\n Urn,\n SortFields, // Keep this penultimate\n MergeFields // Run this last *iff* you want to use this at all\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,O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IAAAqD,qBAAA,GAAAtD,sBAAA,CAAAC,OAAA;AACA,IAAAsD,YAAA,GAAAvD,sBAAA,CAAAC,OAAA;AACA,IAAAuD,IAAA,GAAAxD,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAyD,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_accessRights","_interopRequireDefault","require","_addMissingField","_addMissingField2","_addMissingField3","_addMissingField4","_cyrillux","_cyrilluxUsemarconReplacement","_disambiguateSeriesStatements","_doubleCommas","_duplicatesInd","_emptyFields","_endingPunctuation","_endingWhitespace","_field0081834CharacterGroups","_field505Separators","_field521Fix","_fieldExclusion","_fieldStructure","_fieldsPresent","_fix33X","_fixCountryCodes","_fixLanguageCodes","_fixRelatorTerms","_fixedFields","_identicalFields","_indicatorFixes","_isbnIssn","_itemLanguage","_mergeField500Lisapainokset","_mergeFields","_mergeRelatorTermFields","_multipleSubfield","_nonBreakingSpace","_normalizeDashes","_normalizeIdentifiers","_normalizeQualifyingInformation","_normalizeUtf8Diacritics","_punctuation","_punctuation2","_reindexSubfield6OccurenceNumbers","_removeDuplicateDataFields","_removeInferiorDataFields","_resolvableExtReferencesMelinda","_resolveOrphanedSubfield6s","_sanitizeVocabularySourceCodes","_sortFields","_sortRelatorTerms","_sortSubfields","_sortTags","_subfieldValueNormalizations","_subfieldExclusion","_sync007And","_translateTerms","_typeOfDate","_unicodeDecomposition","_updateField","_urn","e","__esModule","default"],"sources":["../src/index.js"],"sourcesContent":["import AccessRights from './access-rights';\nimport AddMissingField041 from './addMissingField041';\nimport AddMissingField336 from './addMissingField336';\nimport AddMissingField337 from './addMissingField337';\nimport AddMissingField338 from './addMissingField338';\nimport Cyrillux from './cyrillux';\nimport CyrilluxUsemarconReplacement from './cyrillux-usemarcon-replacement';\nimport DisambiguateSeriesStatements from './disambiguateSeriesStatements';\nimport DoubleCommas from './double-commas';\nimport DuplicatesInd1 from './duplicates-ind1';\nimport EmptyFields from './empty-fields';\nimport EndingPunctuation from './ending-punctuation';\nimport EndingWhitespace from './ending-whitespace';\nimport Field008CharacterGroups from './field-008-18-34-character-groups';\nimport Field505Separators from './field-505-separators';\nimport Field521Fix from './field-521-fix';\nimport FieldExclusion from './field-exclusion';\nimport FieldStructure from './field-structure';\nimport FieldsPresent from './fields-present';\nimport Fix33X from './fix-33X';\nimport FixCountryCodes from './fix-country-codes';\nimport FixLanguageCodes from './fix-language-codes';\nimport FixRelatorTerms from './fixRelatorTerms';\nimport FixedFields from './fixed-fields';\nimport IdenticalFields from './identical-fields';\nimport IndicatorFixes from './indicator-fixes';\nimport IsbnIssn from './isbn-issn';\nimport ItemLanguage from './item-language';\nimport MergeField500Lisapainokset from './mergeField500Lisapainokset';\nimport MergeFields from './merge-fields/';\nimport MergeRelatorTermFields from './mergeRelatorTermFields';\nimport MultipleSubfield0s from './multiple-subfield-0';\nimport NonBreakingSpace from './non-breaking-space';\nimport NormalizeDashes from './normalize-dashes';\nimport NormalizeIdentifiers from './normalize-identifiers';\nimport NormalizeQualifyingInformation from './normalize-qualifying-information';\nimport NormalizeUTF8Diacritics from './normalize-utf8-diacritics';\nimport Punctuation from './punctuation/';\nimport Punctuation2 from './punctuation2';\nimport ReindexSubfield6OccurenceNumbers from './reindexSubfield6OccurenceNumbers';\nimport RemoveDuplicateDataFields from './removeDuplicateDataFields';\nimport RemoveInferiorDataFields from './removeInferiorDataFields';\nimport ResolvableExtReferences from './resolvable-ext-references-melinda';\nimport ResolveOrphanedSubfield6s from './resolveOrphanedSubfield6s';\nimport SanitizeVocabularySourceCodes from './sanitize-vocabulary-source-codes';\nimport SortFields from './sortFields';\nimport SortRelatorTerms from './sortRelatorTerms';\nimport SortSubfields from './sortSubfields';\nimport SortTags from './sort-tags';\n// import StripPunctuation from './stripPunctuation'; // Can we add this here? Should be used very cautiosly!\nimport SubfieldValueNormalizations from './subfieldValueNormalizations';\nimport SubfieldExclusion from './subfield-exclusion';\nimport Sync007And300 from './sync-007-and-300';\nimport TranslateTerms from './translate-terms';\nimport TypeOfDateF008 from './typeOfDate-008';\nimport UnicodeDecomposition from './unicode-decomposition';\nimport UpdateField540 from './update-field-540';\nimport Urn from './urn';\n\nexport {\n AccessRights,\n AddMissingField041,\n AddMissingField336,\n AddMissingField337,\n AddMissingField338,\n Cyrillux,\n CyrilluxUsemarconReplacement,\n DisambiguateSeriesStatements,\n DoubleCommas,\n DuplicatesInd1,\n EmptyFields,\n EndingPunctuation,\n EndingWhitespace,\n Field008CharacterGroups,\n Field505Separators,\n Field521Fix,\n FieldExclusion,\n FieldsPresent,\n FieldStructure,\n Fix33X,\n FixCountryCodes,\n FixLanguageCodes,\n FixRelatorTerms,\n FixedFields,\n IdenticalFields,\n IndicatorFixes,\n IsbnIssn,\n ItemLanguage,\n MergeField500Lisapainokset,\n MergeRelatorTermFields,\n MultipleSubfield0s,\n NonBreakingSpace,\n NormalizeDashes,\n NormalizeIdentifiers,\n NormalizeQualifyingInformation,\n NormalizeUTF8Diacritics,\n Punctuation,\n Punctuation2,\n ResolveOrphanedSubfield6s, // Do this before reindexing! (thus I'm not sticking with alphabetical order here)\n ReindexSubfield6OccurenceNumbers,\n RemoveDuplicateDataFields,\n RemoveInferiorDataFields,\n ResolvableExtReferences,\n SanitizeVocabularySourceCodes,\n SortRelatorTerms,\n SortSubfields,\n SortTags,\n SubfieldExclusion,\n SubfieldValueNormalizations,\n Sync007And300,\n TypeOfDateF008,\n TranslateTerms,\n UnicodeDecomposition,\n UpdateField540,\n Urn,\n SortFields, // Keep this penultimate\n MergeFields // Run this last *iff* you want to use this at all\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,iBAAA,GAAA/C,sBAAA,CAAAC,OAAA;AACA,IAAA+C,cAAA,GAAAhD,sBAAA,CAAAC,OAAA;AACA,IAAAgD,SAAA,GAAAjD,sBAAA,CAAAC,OAAA;AAEA,IAAAiD,4BAAA,GAAAlD,sBAAA,CAAAC,OAAA;AACA,IAAAkD,kBAAA,GAAAnD,sBAAA,CAAAC,OAAA;AACA,IAAAmD,WAAA,GAAApD,sBAAA,CAAAC,OAAA;AACA,IAAAoD,eAAA,GAAArD,sBAAA,CAAAC,OAAA;AACA,IAAAqD,WAAA,GAAAtD,sBAAA,CAAAC,OAAA;AACA,IAAAsD,qBAAA,GAAAvD,sBAAA,CAAAC,OAAA;AACA,IAAAuD,YAAA,GAAAxD,sBAAA,CAAAC,OAAA;AACA,IAAAwD,IAAA,GAAAzD,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAA0D,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -32,7 +32,7 @@ const debugDev = debug.extend('dev');
32
32
 
33
33
  // NB! Can be do this via config.json?
34
34
  function removeEnnakkotieto(field) {
35
- const tmp = field.subfields.filter(subfield => subfield.code !== 'g' || subfield.value !== 'ENNAKKOTIETO.');
35
+ const tmp = field.subfields.filter(subfield => !(0, _normalizeFieldForComparison.isEnnakkotietoSubfieldG)(subfield));
36
36
  // remove only iff some other subfield remains
37
37
  if (tmp.length > 0) {
38
38
  // eslint-disable-line functional/no-conditional-statements
@@ -73,7 +73,7 @@ function mergeField2(baseRecord, baseField, sourceField, config, candFieldPairs8
73
73
  // If a base ennakkotieto is merged with real data, remove ennakkotieto subfield:
74
74
  // (If our prepub normalizations are ok, this should not be needed.
75
75
  // However, it's simple and works well enough, so let's keep it here.)
76
- if ((0, _utils.fieldHasSubfield)(baseField, 'g', 'ENNAKKOTIETO.') && !(0, _utils.fieldHasSubfield)(sourceField, 'g', 'ENNAKKOTIETO.')) {
76
+ if (baseField.subfields?.find(sf => (0, _normalizeFieldForComparison.isEnnakkotietoSubfieldG)(sf)) && !sourceField.subfields?.find(sf => (0, _normalizeFieldForComparison.isEnnakkotietoSubfieldG)(sf))) {
77
77
  // eslint-disable-line functional/no-conditional-statements
78
78
  removeEnnakkotieto(baseField);
79
79
  baseField.merged = 1; // eslint-disable-line functional/immutable-data
@@ -1 +1 @@
1
- {"version":3,"file":"mergeField.js","names":["_debug","_interopRequireDefault","require","_utils","_subfield6Utils","_normalizeFieldForComparison","_mergeOrAddSubfield","_mergeIndicator","_mergableTag","_counterpartField","e","__esModule","default","debug","createDebugLogger","debugDev","extend","removeEnnakkotieto","field","tmp","subfields","filter","subfield","code","value","length","copyrightYearHack","baseRecord","baseField","sourceField","tag","relevantSubfields","sf","hasCopyright","forEach","replace","insertField","removeCopyright","mergeField2","config","candFieldPairs880","fieldToString","fieldHasSubfield","merged","mergeIndicators","normalizedSourceField","cloneAndNormalizeFieldForComparison","strippedSourceField","cloneAndRemovePunctuation","nvdebug","originalSubfield","index","normalizedSubfield","punctlessSubfield","originalBaseValue","subfieldToString","subfieldData","mergeOrAddSubfield","newValue","skipMergeField","mergableTag","fields","some","mergeCandidate","fieldsAreIdentical","deleted","sourceRecordIsBetter","isAsteriField","match","swapDataBetweenFields","field1","field2","swapNamedData","name","data","mergeField","sourceRecord","counterpartField","getCounterpart","undefined","fieldGetOccurrenceNumberPairs","fieldsToString"],"sources":["../../src/merge-fields/mergeField.js"],"sourcesContent":["//import {MarcRecord} from '@natlibfi/marc-record';\nimport createDebugLogger from 'debug';\nimport {fieldHasSubfield, fieldToString, fieldsToString, fieldsAreIdentical, nvdebug, hasCopyright, removeCopyright, subfieldToString} from '../utils';\nimport {fieldGetOccurrenceNumberPairs} from '../subfield6Utils.js';\nimport {cloneAndNormalizeFieldForComparison, cloneAndRemovePunctuation} from '../normalizeFieldForComparison';\nimport {mergeOrAddSubfield} from './mergeOrAddSubfield';\nimport {mergeIndicators} from './mergeIndicator';\nimport {mergableTag} from './mergableTag';\nimport {getCounterpart} from './counterpartField';\n//import {default as normalizeEncoding} from '@natlibfi/marc-record-validators-melinda/dist/normalize-utf8-diacritics';\n//import {postprocessRecords} from './mergeOrAddPostprocess.js';\n//import {preprocessBeforeAdd} from './processFilter.js';\n\n//import fs from 'fs';\n//import path from 'path';\n\n\n//const defaultConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'reducers', 'config.json'), 'utf8'));\n\n// Specs: https://workgroups.helsinki.fi/x/K1ohCw (though we occasionally differ from them)...\n\nconst debug = createDebugLogger('@natlibfi/melinda-marc-record-merge-reducers:mergeField');\n//const debugData = debug.extend('data');\nconst debugDev = debug.extend('dev');\n\n// NB! Can be do this via config.json?\nfunction removeEnnakkotieto(field) {\n const tmp = field.subfields.filter(subfield => subfield.code !== 'g' || subfield.value !== 'ENNAKKOTIETO.');\n // remove only iff some other subfield remains\n if (tmp.length > 0) { // eslint-disable-line functional/no-conditional-statements\n field.subfields = tmp; // eslint-disable-line functional/immutable-data\n }\n}\n\n\nfunction copyrightYearHack(baseRecord, baseField, sourceField) {\n if (baseField.tag !== '264' || sourceField.tag !== '260') {\n return;\n }\n const relevantSubfields = sourceField.subfields.filter(sf => sf.code === 'c' && hasCopyright(sf.value));\n\n relevantSubfields.forEach(sf => {\n // Add new:\n const value = sf.value.replace(/\\.$/u, '');\n baseRecord.insertField({'tag': '264', 'ind1': ' ', 'ind2': '4', 'subfields': [{'code': 'c', value}]});\n // Modify original subfield:\n sf.value = removeCopyright(sf.value); // eslint-disable-line functional/immutable-data\n });\n}\n\n// eslint-disable-next-line max-params\nfunction mergeField2(baseRecord, baseField, sourceField, config, candFieldPairs880 = []) {\n //// Identical fields\n // No need to check every subfield separately.\n // Also no need to postprocess the resulting field.\n if (fieldToString(baseField) === fieldToString(sourceField)) {\n return baseRecord;\n }\n\n // If a base ennakkotieto is merged with real data, remove ennakkotieto subfield:\n // (If our prepub normalizations are ok, this should not be needed.\n // However, it's simple and works well enough, so let's keep it here.)\n if (fieldHasSubfield(baseField, 'g', 'ENNAKKOTIETO.') && !fieldHasSubfield(sourceField, 'g', 'ENNAKKOTIETO.')) { // eslint-disable-line functional/no-conditional-statements\n removeEnnakkotieto(baseField);\n baseField.merged = 1; // eslint-disable-line functional/immutable-data\n }\n\n copyrightYearHack(baseRecord, baseField, sourceField);\n\n mergeIndicators(baseField, sourceField, config);\n\n\n // We want to add the incoming subfields without punctuation, and add puctuation later on.\n // (Cloning is harmless, but probably not needed.)\n // NEW: we also drag the normalized version along. It is needed for the merge-or-add decision\n const normalizedSourceField = cloneAndNormalizeFieldForComparison(sourceField); // This is for comparison\n const strippedSourceField = cloneAndRemovePunctuation(sourceField); // This is for adding subfields\n\n //nvdebug(` MERGING SUBFIELDS OF '${fieldToString(sourceField)}' (original)`, debugDev);\n //nvdebug(` MERGING SUBFIELDS OF '${fieldToString(normalizedSourceField)}' (comparison)`, debugDev);\n nvdebug(` MERGING SUBFIELDS OF '${fieldToString(strippedSourceField)}' (merge/add)`, debugDev);\n\n sourceField.subfields.forEach((originalSubfield, index) => {\n //strippedSourceField.subfields.forEach((subfieldForMergeOrAdd, index) => {\n const normalizedSubfield = normalizedSourceField.subfields[index];\n const punctlessSubfield = strippedSourceField.subfields[index];\n const originalBaseValue = fieldToString(baseField);\n nvdebug(` TRYING TO MERGE SUBFIELD '${subfieldToString(originalSubfield)}' TO '${originalBaseValue}'`, debugDev);\n\n const subfieldData = {'tag': sourceField.tag, 'code': originalSubfield.code, 'originalValue': originalSubfield.value, 'normalizedValue': normalizedSubfield.value, 'punctuationlessValue': punctlessSubfield.value};\n\n mergeOrAddSubfield(baseField, subfieldData, candFieldPairs880); // candSubfield);\n const newValue = fieldToString(baseField);\n if (originalBaseValue !== newValue) { // eslint-disable-line functional/no-conditional-statements\n nvdebug(` SUBFIELD MERGE RESULT: '${newValue}'`, debugDev);\n //debug(` TODO: sort subfields, handle punctuation...`);\n }\n //else { debugDev(` mergeOrAddSubfield() did not add '‡${fieldToString(subfieldForMergeOrAdd)}' to '${originalValue}'`); }\n\n });\n}\n\n\nfunction skipMergeField(baseRecord, sourceField, config) {\n if (!mergableTag(sourceField.tag, config)) {\n nvdebug(`skipMergeField(): field '${fieldToString(sourceField)}' listed as skippable!`, debugDev);\n return true;\n }\n\n // Skip duplicate field:\n if (baseRecord.fields.some(baseField => !baseField.mergeCandidate && fieldsAreIdentical(sourceField, baseField))) {\n nvdebug(`skipMergeField(): field '${fieldToString(sourceField)}' already exists! No merge required!`, debugDev);\n sourceField.deleted = 1; // eslint-disable-line functional/immutable-data\n return true;\n }\n\n return false;\n}\n\nfunction sourceRecordIsBetter(baseField, sourceField) {\n if (!baseField.subfields) {\n return;\n }\n // MELINDA-8978: prefer Asteri version\n if (isAsteriField(sourceField) && !isAsteriField(baseField)) {\n return 1;\n }\n\n function isAsteriField(field) {\n if (field.subfields.some(sf => sf.code === '0' && sf.value.match(/^\\((?:FI-ASTERI-[NW]|FIN1[13])\\)[0-9]{9}$/u))) {\n return true;\n }\n }\n return false;\n}\n\nfunction swapDataBetweenFields(field1, field2) {\n // NB! Does not support controlfields yet! Add support if the need arises.\n if (field1.subfields) { // If field1 has subfields, then also field2 has them. No need to check the other field here.\n swapNamedData('ind1');\n swapNamedData('ind2');\n swapNamedData('subfields');\n return;\n }\n return;\n\n function swapNamedData(name) {\n const data = field1[name]; // eslint-disable-line functional/immutable-data\n field1[name] = field2[name]; // eslint-disable-line functional/immutable-data\n field2[name] = data; // eslint-disable-line functional/immutable-data\n }\n\n}\n\nexport function mergeField(baseRecord, sourceRecord, sourceField, config) {\n nvdebug(`SELF: ${fieldToString(sourceField)}`, debugDev);\n\n sourceField.mergeCandidate = true; // eslint-disable-line functional/immutable-data\n // skip duplicates and special cases:\n if (skipMergeField(baseRecord, sourceField, config)) {\n nvdebug(`mergeField(): don't merge '${fieldToString(sourceField)}'`, debugDev);\n delete sourceField.mergeCandidate; // eslint-disable-line functional/immutable-data\n return false;\n }\n\n nvdebug(`mergeField(): Try to merge '${fieldToString(sourceField)}'.`, debugDev);\n const counterpartField = getCounterpart(baseRecord, sourceRecord, sourceField, config);\n\n if (counterpartField) {\n if (sourceRecordIsBetter(counterpartField, sourceField)) { // eslint-disable-line functional/no-conditional-statements\n swapDataBetweenFields(counterpartField, sourceField);\n }\n\n const candFieldPairs880 = sourceField.tag === '880' ? undefined : fieldGetOccurrenceNumberPairs(sourceField, sourceRecord.fields);\n nvdebug(`mergeField(): Got counterpart: '${fieldToString(counterpartField)}'. Thus try merge...`, debugDev);\n nvdebug(`PAIR: ${candFieldPairs880 ? fieldsToString(candFieldPairs880) : 'NADA'}`, debugDev);\n mergeField2(baseRecord, counterpartField, sourceField, config, candFieldPairs880);\n sourceField.deleted = 1; // eslint-disable-line functional/immutable-data\n delete sourceField.mergeCandidate; // eslint-disable-line functional/immutable-data\n return true;\n }\n // NB! Counterpartless field is inserted to 7XX even if field.tag says 1XX:\n debugDev(`mergeField(): No mergable counterpart found for '${fieldToString(sourceField)}'.`);\n delete sourceField.mergeCandidate; // eslint-disable-line functional/immutable-data\n return false;\n}\n\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,4BAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAAkD,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AARlD;;AASA;AACA;AACA;;AAEA;AACA;;AAGA;;AAEA;;AAEA,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,yDAAyD,CAAC;AAC1F;AACA,MAAMC,QAAQ,GAAG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["_debug","_interopRequireDefault","require","_utils","_subfield6Utils","_normalizeFieldForComparison","_mergeOrAddSubfield","_mergeIndicator","_mergableTag","_counterpartField","e","__esModule","default","debug","createDebugLogger","debugDev","extend","removeEnnakkotieto","field","tmp","subfields","filter","subfield","isEnnakkotietoSubfieldG","length","copyrightYearHack","baseRecord","baseField","sourceField","tag","relevantSubfields","sf","code","hasCopyright","value","forEach","replace","insertField","removeCopyright","mergeField2","config","candFieldPairs880","fieldToString","find","merged","mergeIndicators","normalizedSourceField","cloneAndNormalizeFieldForComparison","strippedSourceField","cloneAndRemovePunctuation","nvdebug","originalSubfield","index","normalizedSubfield","punctlessSubfield","originalBaseValue","subfieldToString","subfieldData","mergeOrAddSubfield","newValue","skipMergeField","mergableTag","fields","some","mergeCandidate","fieldsAreIdentical","deleted","sourceRecordIsBetter","isAsteriField","match","swapDataBetweenFields","field1","field2","swapNamedData","name","data","mergeField","sourceRecord","counterpartField","getCounterpart","undefined","fieldGetOccurrenceNumberPairs","fieldsToString"],"sources":["../../src/merge-fields/mergeField.js"],"sourcesContent":["//import {MarcRecord} from '@natlibfi/marc-record';\nimport createDebugLogger from 'debug';\nimport {fieldToString, fieldsToString, fieldsAreIdentical, nvdebug, hasCopyright, removeCopyright, subfieldToString} from '../utils';\nimport {fieldGetOccurrenceNumberPairs} from '../subfield6Utils.js';\nimport {cloneAndNormalizeFieldForComparison, cloneAndRemovePunctuation, isEnnakkotietoSubfieldG} from '../normalizeFieldForComparison';\nimport {mergeOrAddSubfield} from './mergeOrAddSubfield';\nimport {mergeIndicators} from './mergeIndicator';\nimport {mergableTag} from './mergableTag';\nimport {getCounterpart} from './counterpartField';\n//import {default as normalizeEncoding} from '@natlibfi/marc-record-validators-melinda/dist/normalize-utf8-diacritics';\n//import {postprocessRecords} from './mergeOrAddPostprocess.js';\n//import {preprocessBeforeAdd} from './processFilter.js';\n\n//import fs from 'fs';\n//import path from 'path';\n\n\n//const defaultConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'src', 'reducers', 'config.json'), 'utf8'));\n\n// Specs: https://workgroups.helsinki.fi/x/K1ohCw (though we occasionally differ from them)...\n\nconst debug = createDebugLogger('@natlibfi/melinda-marc-record-merge-reducers:mergeField');\n//const debugData = debug.extend('data');\nconst debugDev = debug.extend('dev');\n\n// NB! Can be do this via config.json?\nfunction removeEnnakkotieto(field) {\n const tmp = field.subfields.filter(subfield => !isEnnakkotietoSubfieldG(subfield));\n // remove only iff some other subfield remains\n if (tmp.length > 0) { // eslint-disable-line functional/no-conditional-statements\n field.subfields = tmp; // eslint-disable-line functional/immutable-data\n }\n}\n\n\nfunction copyrightYearHack(baseRecord, baseField, sourceField) {\n if (baseField.tag !== '264' || sourceField.tag !== '260') {\n return;\n }\n const relevantSubfields = sourceField.subfields.filter(sf => sf.code === 'c' && hasCopyright(sf.value));\n\n relevantSubfields.forEach(sf => {\n // Add new:\n const value = sf.value.replace(/\\.$/u, '');\n baseRecord.insertField({'tag': '264', 'ind1': ' ', 'ind2': '4', 'subfields': [{'code': 'c', value}]});\n // Modify original subfield:\n sf.value = removeCopyright(sf.value); // eslint-disable-line functional/immutable-data\n });\n}\n\n// eslint-disable-next-line max-params\nfunction mergeField2(baseRecord, baseField, sourceField, config, candFieldPairs880 = []) {\n //// Identical fields\n // No need to check every subfield separately.\n // Also no need to postprocess the resulting field.\n if (fieldToString(baseField) === fieldToString(sourceField)) {\n return baseRecord;\n }\n\n // If a base ennakkotieto is merged with real data, remove ennakkotieto subfield:\n // (If our prepub normalizations are ok, this should not be needed.\n // However, it's simple and works well enough, so let's keep it here.)\n if (baseField.subfields?.find(sf => isEnnakkotietoSubfieldG(sf)) && !sourceField.subfields?.find(sf => isEnnakkotietoSubfieldG(sf))) { // eslint-disable-line functional/no-conditional-statements\n removeEnnakkotieto(baseField);\n baseField.merged = 1; // eslint-disable-line functional/immutable-data\n }\n\n copyrightYearHack(baseRecord, baseField, sourceField);\n\n mergeIndicators(baseField, sourceField, config);\n\n\n // We want to add the incoming subfields without punctuation, and add puctuation later on.\n // (Cloning is harmless, but probably not needed.)\n // NEW: we also drag the normalized version along. It is needed for the merge-or-add decision\n const normalizedSourceField = cloneAndNormalizeFieldForComparison(sourceField); // This is for comparison\n const strippedSourceField = cloneAndRemovePunctuation(sourceField); // This is for adding subfields\n\n //nvdebug(` MERGING SUBFIELDS OF '${fieldToString(sourceField)}' (original)`, debugDev);\n //nvdebug(` MERGING SUBFIELDS OF '${fieldToString(normalizedSourceField)}' (comparison)`, debugDev);\n nvdebug(` MERGING SUBFIELDS OF '${fieldToString(strippedSourceField)}' (merge/add)`, debugDev);\n\n sourceField.subfields.forEach((originalSubfield, index) => {\n //strippedSourceField.subfields.forEach((subfieldForMergeOrAdd, index) => {\n const normalizedSubfield = normalizedSourceField.subfields[index];\n const punctlessSubfield = strippedSourceField.subfields[index];\n const originalBaseValue = fieldToString(baseField);\n nvdebug(` TRYING TO MERGE SUBFIELD '${subfieldToString(originalSubfield)}' TO '${originalBaseValue}'`, debugDev);\n\n const subfieldData = {'tag': sourceField.tag, 'code': originalSubfield.code, 'originalValue': originalSubfield.value, 'normalizedValue': normalizedSubfield.value, 'punctuationlessValue': punctlessSubfield.value};\n\n mergeOrAddSubfield(baseField, subfieldData, candFieldPairs880); // candSubfield);\n const newValue = fieldToString(baseField);\n if (originalBaseValue !== newValue) { // eslint-disable-line functional/no-conditional-statements\n nvdebug(` SUBFIELD MERGE RESULT: '${newValue}'`, debugDev);\n //debug(` TODO: sort subfields, handle punctuation...`);\n }\n //else { debugDev(` mergeOrAddSubfield() did not add '‡${fieldToString(subfieldForMergeOrAdd)}' to '${originalValue}'`); }\n\n });\n}\n\n\nfunction skipMergeField(baseRecord, sourceField, config) {\n if (!mergableTag(sourceField.tag, config)) {\n nvdebug(`skipMergeField(): field '${fieldToString(sourceField)}' listed as skippable!`, debugDev);\n return true;\n }\n\n // Skip duplicate field:\n if (baseRecord.fields.some(baseField => !baseField.mergeCandidate && fieldsAreIdentical(sourceField, baseField))) {\n nvdebug(`skipMergeField(): field '${fieldToString(sourceField)}' already exists! No merge required!`, debugDev);\n sourceField.deleted = 1; // eslint-disable-line functional/immutable-data\n return true;\n }\n\n return false;\n}\n\nfunction sourceRecordIsBetter(baseField, sourceField) {\n if (!baseField.subfields) {\n return;\n }\n // MELINDA-8978: prefer Asteri version\n if (isAsteriField(sourceField) && !isAsteriField(baseField)) {\n return 1;\n }\n\n function isAsteriField(field) {\n if (field.subfields.some(sf => sf.code === '0' && sf.value.match(/^\\((?:FI-ASTERI-[NW]|FIN1[13])\\)[0-9]{9}$/u))) {\n return true;\n }\n }\n return false;\n}\n\nfunction swapDataBetweenFields(field1, field2) {\n // NB! Does not support controlfields yet! Add support if the need arises.\n if (field1.subfields) { // If field1 has subfields, then also field2 has them. No need to check the other field here.\n swapNamedData('ind1');\n swapNamedData('ind2');\n swapNamedData('subfields');\n return;\n }\n return;\n\n function swapNamedData(name) {\n const data = field1[name]; // eslint-disable-line functional/immutable-data\n field1[name] = field2[name]; // eslint-disable-line functional/immutable-data\n field2[name] = data; // eslint-disable-line functional/immutable-data\n }\n\n}\n\nexport function mergeField(baseRecord, sourceRecord, sourceField, config) {\n nvdebug(`SELF: ${fieldToString(sourceField)}`, debugDev);\n\n sourceField.mergeCandidate = true; // eslint-disable-line functional/immutable-data\n // skip duplicates and special cases:\n if (skipMergeField(baseRecord, sourceField, config)) {\n nvdebug(`mergeField(): don't merge '${fieldToString(sourceField)}'`, debugDev);\n delete sourceField.mergeCandidate; // eslint-disable-line functional/immutable-data\n return false;\n }\n\n nvdebug(`mergeField(): Try to merge '${fieldToString(sourceField)}'.`, debugDev);\n const counterpartField = getCounterpart(baseRecord, sourceRecord, sourceField, config);\n\n if (counterpartField) {\n if (sourceRecordIsBetter(counterpartField, sourceField)) { // eslint-disable-line functional/no-conditional-statements\n swapDataBetweenFields(counterpartField, sourceField);\n }\n\n const candFieldPairs880 = sourceField.tag === '880' ? undefined : fieldGetOccurrenceNumberPairs(sourceField, sourceRecord.fields);\n nvdebug(`mergeField(): Got counterpart: '${fieldToString(counterpartField)}'. Thus try merge...`, debugDev);\n nvdebug(`PAIR: ${candFieldPairs880 ? fieldsToString(candFieldPairs880) : 'NADA'}`, debugDev);\n mergeField2(baseRecord, counterpartField, sourceField, config, candFieldPairs880);\n sourceField.deleted = 1; // eslint-disable-line functional/immutable-data\n delete sourceField.mergeCandidate; // eslint-disable-line functional/immutable-data\n return true;\n }\n // NB! Counterpartless field is inserted to 7XX even if field.tag says 1XX:\n debugDev(`mergeField(): No mergable counterpart found for '${fieldToString(sourceField)}'.`);\n delete sourceField.mergeCandidate; // eslint-disable-line functional/immutable-data\n return false;\n}\n\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,4BAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAAkD,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AARlD;;AASA;AACA;AACA;;AAEA;AACA;;AAGA;;AAEA;;AAEA,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,yDAAyD,CAAC;AAC1F;AACA,MAAMC,QAAQ,GAAGF,KAAK,CAACG,MAAM,CAAC,KAAK,CAAC;;AAEpC;AACA,SAASC,kBAAkBA,CAACC,KAAK,EAAE;EACjC,MAAMC,GAAG,GAAGD,KAAK,CAACE,SAAS,CAACC,MAAM,CAACC,QAAQ,IAAI,CAAC,IAAAC,oDAAuB,EAACD,QAAQ,CAAC,CAAC;EAClF;EACA,IAAIH,GAAG,CAACK,MAAM,GAAG,CAAC,EAAE;IAAE;IACpBN,K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,EAAEmD,YAAY,EAAEjD,WAAW,EAAEY,MAAM,CAAC;EAEtF,IAAIsC,gBAAgB,EAAE;IACpB,IAAIX,oBAAoB,CAACW,gBAAgB,EAAElD,WAAW,CAAC,EAAE;MAAE;MACzD0C,qBAAqB,CAACQ,gBAAgB,EAAElD,WAAW,CAAC;IACtD;IAEA,MAAMa,iBAAiB,GAAGb,WAAW,CAACC,GAAG,KAAK,KAAK,GAAGmD,SAAS,GAAG,IAAAC,6CAA6B,EAACrD,WAAW,EAAEiD,YAAY,CAACf,MAAM,CAAC;IACjI,IAAAZ,cAAO,EAAC,mCAAmC,IAAAR,oBAAa,EAACoC,gBAAgB,CAAC,sBAAsB,EAAE/D,QAAQ,CAAC;IAC3G,IAAAmC,cAAO,EAAC,SAAST,iBAAiB,GAAG,IAAAyC,qBAAc,EAACzC,iBAAiB,CAAC,GAAG,MAAM,EAAE,EAAE1B,QAAQ,CAAC;IAC5FwB,WAAW,CAACb,UAAU,EAAEoD,gBAAgB,EAAElD,WAAW,EAAEY,MAAM,EAAEC,iBAAiB,CAAC;IACjFb,WAAW,CAACsC,OAAO,GAAG,CAAC,CAAC,CAAC;IACzB,OAAOtC,WAAW,CAACoC,cAAc,CAAC,CAAC;IACnC,OAAO,IAAI;EACb;EACA;EACAjD,QAAQ,CAAC,oDAAoD,IAAA2B,oBAAa,EAACd,WAAW,CAAC,IAAI,CAAC;EAC5F,OAAOA,WAAW,CAACoC,cAAc,CAAC,CAAC;EACnC,OAAO,KAAK;AACd","ignoreList":[]}
@@ -31,10 +31,13 @@ function catalogingSourceModifyingAgencyCandIsOriginalCatalogingSourceAgencyInTa
31
31
  return false;
32
32
  }
33
33
  function ennakkotietoInSubfieldG(candSubfieldData) {
34
- if (candSubfieldData.code === 'g' && ['ENNAKKOTIETO.', 'ENNAKKOTIETO'].includes(candSubfieldData.originalValue)) {
34
+ if ((0, _normalizeFieldForComparison.isEnnakkotietoSubfieldG)({
35
+ 'code': candSubfieldData.code,
36
+ 'value': candSubfieldData.originalValue
37
+ })) {
35
38
  // Skip just ‡g subfield or the whole field?
36
39
  // We decided to skip just this subfield. We want at least $0 and maybe even more from ennakkotieto.
37
- debugDev('Skip ‡g ENNAKKOTIETO.');
40
+ debugDev(`Skip '‡g ${candSubfieldData.originalValue}'`);
38
41
  return true;
39
42
  }
40
43
  return false;