@natlibfi/melinda-rest-api-commons 4.0.20-alpha.4 → 4.1.0-alpha.2
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.
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.REPLACE_PREFIXES = exports.BIB_STRIP_F884S_SETTINGS = exports.BIB_PREVALIDATION_FIX_SETTINGS = exports.BIB_PREIMPORT_FIX_SETTINGS = exports.BIB_POSTMERGE_FIX_SETTINGS = exports.BIB_HANDLE_TEMP_URNS_SETTINGS = exports.BIB_FORMAT_SETTINGS = exports.BIB_F035_TO_SID = exports.AUTNAME_PREIMPORT_FIX_SETTINGS = void 0;
|
|
6
|
+
exports.REPLACE_PREFIXES = exports.BIB_STRIP_F984S_SETTINGS = exports.BIB_STRIP_F884S_SETTINGS = exports.BIB_PREVALIDATION_FIX_SETTINGS = exports.BIB_PREIMPORT_FIX_SETTINGS = exports.BIB_POSTMERGE_FIX_SETTINGS = exports.BIB_HANDLE_TEMP_URNS_SETTINGS = exports.BIB_FORMAT_SETTINGS = exports.BIB_F035_TO_SID = exports.AUTNAME_PREIMPORT_FIX_SETTINGS = void 0;
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
9
|
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
@@ -76,7 +76,8 @@ const BIB_POSTMERGE_FIX_SETTINGS = exports.BIB_POSTMERGE_FIX_SETTINGS = {
|
|
|
76
76
|
stripF884s: true
|
|
77
77
|
};
|
|
78
78
|
const BIB_PREIMPORT_FIX_SETTINGS = exports.BIB_PREIMPORT_FIX_SETTINGS = {
|
|
79
|
-
replacePrefixes: REPLACE_PREFIXES
|
|
79
|
+
replacePrefixes: REPLACE_PREFIXES,
|
|
80
|
+
stripF984s: true
|
|
80
81
|
};
|
|
81
82
|
const AUTNAME_PREIMPORT_FIX_SETTINGS = exports.AUTNAME_PREIMPORT_FIX_SETTINGS = {
|
|
82
83
|
replacePrefixes: REPLACE_PREFIXES
|
|
@@ -87,4 +88,7 @@ const BIB_HANDLE_TEMP_URNS_SETTINGS = exports.BIB_HANDLE_TEMP_URNS_SETTINGS = {
|
|
|
87
88
|
const BIB_STRIP_F884S_SETTINGS = exports.BIB_STRIP_F884S_SETTINGS = {
|
|
88
89
|
stripF884s: true
|
|
89
90
|
};
|
|
91
|
+
const BIB_STRIP_F984S_SETTINGS = exports.BIB_STRIP_F984S_SETTINGS = {
|
|
92
|
+
stripF984s: true
|
|
93
|
+
};
|
|
90
94
|
//# sourceMappingURL=fix-constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-constants.js","names":["BIB_F035_TO_SID","exports","f035Filters","fSIDFilters","REPLACE_PREFIXES","oldPrefix","newPrefix","prefixReplaceCodes","BIB_FORMAT_SETTINGS","replacePrefixes","generateMissingSIDs","BIB_PREVALIDATION_FIX_SETTINGS","BIB_POSTMERGE_FIX_SETTINGS","handleTempUrns","stripF884s","BIB_PREIMPORT_FIX_SETTINGS","AUTNAME_PREIMPORT_FIX_SETTINGS","BIB_HANDLE_TEMP_URNS_SETTINGS","BIB_STRIP_F884S_SETTINGS"],"sources":["../../src/helpers/fix-constants.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\n// This could be formatted so that 035-prefix and SID contents would be better connected than by just an array index\nexport const BIB_F035_TO_SID = {\n f035Filters: [/^\\(FI-BTJ\\)/u, /^\\(FI-TATI\\)/u],\n fSIDFilters: ['FI-BTJ', 'tati']\n};\n\n// There is somewhere other implementations of this same standardPrefixes to alephInternalPrefixes normalization\nexport const REPLACE_PREFIXES = [\n {\n oldPrefix: 'FI-MELINDA',\n newPrefix: 'FIN01',\n prefixReplaceCodes: ['w']\n },\n {\n oldPrefix: 'FI-ASTERI-S',\n newPrefix: 'FIN10',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-N',\n newPrefix: 'FIN11',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-A',\n newPrefix: 'FIN12',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-W',\n newPrefix: 'FIN13',\n prefixReplaceCodes: ['0']\n }\n];\n\n
|
|
1
|
+
{"version":3,"file":"fix-constants.js","names":["BIB_F035_TO_SID","exports","f035Filters","fSIDFilters","REPLACE_PREFIXES","oldPrefix","newPrefix","prefixReplaceCodes","BIB_FORMAT_SETTINGS","replacePrefixes","generateMissingSIDs","BIB_PREVALIDATION_FIX_SETTINGS","BIB_POSTMERGE_FIX_SETTINGS","handleTempUrns","stripF884s","BIB_PREIMPORT_FIX_SETTINGS","stripF984s","AUTNAME_PREIMPORT_FIX_SETTINGS","BIB_HANDLE_TEMP_URNS_SETTINGS","BIB_STRIP_F884S_SETTINGS","BIB_STRIP_F984S_SETTINGS"],"sources":["../../src/helpers/fix-constants.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\n// This could be formatted so that 035-prefix and SID contents would be better connected than by just an array index\nexport const BIB_F035_TO_SID = {\n f035Filters: [/^\\(FI-BTJ\\)/u, /^\\(FI-TATI\\)/u],\n fSIDFilters: ['FI-BTJ', 'tati']\n};\n\n// There is somewhere other implementations of this same standardPrefixes to alephInternalPrefixes normalization\nexport const REPLACE_PREFIXES = [\n {\n oldPrefix: 'FI-MELINDA',\n newPrefix: 'FIN01',\n prefixReplaceCodes: ['w']\n },\n {\n oldPrefix: 'FI-ASTERI-S',\n newPrefix: 'FIN10',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-N',\n newPrefix: 'FIN11',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-A',\n newPrefix: 'FIN12',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-W',\n newPrefix: 'FIN13',\n prefixReplaceCodes: ['0']\n }\n];\n\n// If placed in config.js testing needs envs\n// BIB_FORMAT_SETTINGS is outdated, use other settings instead\n\n\nexport const BIB_FORMAT_SETTINGS = {\n replacePrefixes: REPLACE_PREFIXES,\n generateMissingSIDs: BIB_F035_TO_SID\n};\n\nexport const BIB_PREVALIDATION_FIX_SETTINGS = {\n generateMissingSIDs: BIB_F035_TO_SID\n};\n\nexport const BIB_POSTMERGE_FIX_SETTINGS = {\n handleTempUrns: true,\n stripF884s: true\n};\n\nexport const BIB_PREIMPORT_FIX_SETTINGS = {\n replacePrefixes: REPLACE_PREFIXES,\n stripF984s: true\n};\n\nexport const AUTNAME_PREIMPORT_FIX_SETTINGS = {\n replacePrefixes: REPLACE_PREFIXES\n};\n\nexport const BIB_HANDLE_TEMP_URNS_SETTINGS = {\n handleTempUrns: true\n};\n\nexport const BIB_STRIP_F884S_SETTINGS = {\n stripF884s: true\n};\n\nexport const BIB_STRIP_F984S_SETTINGS = {\n stripF984s: true\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACO,MAAMA,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG;EAC7BE,WAAW,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;EAC9CC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM;AAChC,CAAC;;AAED;AACO,MAAMC,gBAAgB,GAAAH,OAAA,CAAAG,gBAAA,GAAG,CAC9B;EACEC,SAAS,EAAE,YAAY;EACvBC,SAAS,EAAE,OAAO;EAClBC,kBAAkB,EAAE,CAAC,GAAG;AAC1B,CAAC,EACD;EACEF,SAAS,EAAE,aAAa;EACxBC,SAAS,EAAE,OAAO;EAClBC,kBAAkB,EAAE,CAAC,GAAG;AAC1B,CAAC,EACD;EACEF,SAAS,EAAE,aAAa;EACxBC,SAAS,EAAE,OAAO;EAClBC,kBAAkB,EAAE,CAAC,GAAG;AAC1B,CAAC,EACD;EACEF,SAAS,EAAE,aAAa;EACxBC,SAAS,EAAE,OAAO;EAClBC,kBAAkB,EAAE,CAAC,GAAG;AAC1B,CAAC,EACD;EACEF,SAAS,EAAE,aAAa;EACxBC,SAAS,EAAE,OAAO;EAClBC,kBAAkB,EAAE,CAAC,GAAG;AAC1B,CAAC,CACF;;AAED;AACA;;AAGO,MAAMC,mBAAmB,GAAAP,OAAA,CAAAO,mBAAA,GAAG;EACjCC,eAAe,EAAEL,gBAAgB;EACjCM,mBAAmB,EAAEV;AACvB,CAAC;AAEM,MAAMW,8BAA8B,GAAAV,OAAA,CAAAU,8BAAA,GAAG;EAC5CD,mBAAmB,EAAEV;AACvB,CAAC;AAEM,MAAMY,0BAA0B,GAAAX,OAAA,CAAAW,0BAAA,GAAG;EACxCC,cAAc,EAAE,IAAI;EACpBC,UAAU,EAAE;AACd,CAAC;AAEM,MAAMC,0BAA0B,GAAAd,OAAA,CAAAc,0BAAA,GAAG;EACxCN,eAAe,EAAEL,gBAAgB;EACjCY,UAAU,EAAE;AACd,CAAC;AAEM,MAAMC,8BAA8B,GAAAhB,OAAA,CAAAgB,8BAAA,GAAG;EAC5CR,eAAe,EAAEL;AACnB,CAAC;AAEM,MAAMc,6BAA6B,GAAAjB,OAAA,CAAAiB,6BAAA,GAAG;EAC3CL,cAAc,EAAE;AAClB,CAAC;AAEM,MAAMM,wBAAwB,GAAAlB,OAAA,CAAAkB,wBAAA,GAAG;EACtCL,UAAU,EAAE;AACd,CAAC;AAEM,MAAMM,wBAAwB,GAAAnB,OAAA,CAAAmB,wBAAA,GAAG;EACtCJ,UAAU,EAAE;AACd,CAAC"}
|
package/dist/helpers/fix.js
CHANGED
|
@@ -13,6 +13,7 @@ var _melindaBackendCommons = require("@natlibfi/melinda-backend-commons");
|
|
|
13
13
|
var _debug = _interopRequireDefault(require("debug"));
|
|
14
14
|
var _fixHandleTempurns = require("./fix-handle-tempurns");
|
|
15
15
|
var _fixStripF884s = require("./fix-strip-f884s");
|
|
16
|
+
var _marcRecordValidatorsMelinda = require("@natlibfi/marc-record-validators-melinda");
|
|
16
17
|
var _fixConstants = require("./fix-constants");
|
|
17
18
|
Object.keys(_fixConstants).forEach(function (key) {
|
|
18
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -31,7 +32,7 @@ Object.keys(_fixConstants).forEach(function (key) {
|
|
|
31
32
|
*
|
|
32
33
|
* Shared modules for microservices of Melinda rest api batch import system
|
|
33
34
|
*
|
|
34
|
-
* Copyright (C) 2020-
|
|
35
|
+
* Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
|
|
35
36
|
*
|
|
36
37
|
* This file is part of melinda-rest-api-commons
|
|
37
38
|
*
|
|
@@ -78,7 +79,11 @@ function fixRecord(record, settings = {}) {
|
|
|
78
79
|
|
|
79
80
|
// Fix 4, strip extra field 884s
|
|
80
81
|
const newRecord4 = (0, _fixStripF884s.stripF884s)(newRecord3, settings.stripF884s);
|
|
81
|
-
|
|
82
|
+
|
|
83
|
+
// Fix 5, strip extra field 884s
|
|
84
|
+
const newRecord5 = stripF984s(newRecord4, settings.stripF984s || false);
|
|
85
|
+
debugData(newRecord5);
|
|
86
|
+
return newRecord5.toObject();
|
|
82
87
|
}
|
|
83
88
|
function replaceAllPrefixes(record, replacePrefixesOptions) {
|
|
84
89
|
if (replacePrefixesOptions.length < 1) {
|
|
@@ -175,4 +180,25 @@ function generateMissingSIDs(record, options) {
|
|
|
175
180
|
}).filter(value => value !== undefined);
|
|
176
181
|
}
|
|
177
182
|
}
|
|
183
|
+
function stripF984s(record, stripF984sSettings) {
|
|
184
|
+
const F984A_PATTERN = /^(?:ALWAYS)|(?:NEVER)-PREFER-IN-MERGE$/u;
|
|
185
|
+
debug(`Running removeF984AFields`);
|
|
186
|
+
debugData(`removeF984AFieldsSettings: ${JSON.stringify(stripF984sSettings)}`);
|
|
187
|
+
if (!stripF984sSettings || !F984A_PATTERN || record.get('984').length < 1) {
|
|
188
|
+
debug(`No settings or pattern for removeF984AFields or f984 in record`);
|
|
189
|
+
return record;
|
|
190
|
+
}
|
|
191
|
+
debug(`Removing f984 fields with subfield $a consisting values ${F984A_PATTERN.toString()}`);
|
|
192
|
+
const config = [{
|
|
193
|
+
tag: /^984$/u,
|
|
194
|
+
subfields: [{
|
|
195
|
+
code: /a/u,
|
|
196
|
+
value: F984A_PATTERN
|
|
197
|
+
}]
|
|
198
|
+
}];
|
|
199
|
+
// eslint-disable-next-line new-cap
|
|
200
|
+
const validator = (0, _marcRecordValidatorsMelinda.FieldExclusion)(config);
|
|
201
|
+
validator.fix(record);
|
|
202
|
+
return record;
|
|
203
|
+
}
|
|
178
204
|
//# sourceMappingURL=fix.js.map
|
package/dist/helpers/fix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix.js","names":["_marcRecord","require","_melindaBackendCommons","_debug","_interopRequireDefault","_fixHandleTempurns","_fixStripF884s","_fixConstants","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","logger","createLogger","debug","createDebugLogger","debugData","extend","fixRecord","record","settings","verbose","JSON","stringify","newRecord","MarcRecord","clone","subfieldValues","generateMissingSIDsOptions","generateMissingSIDs","undefined","newRecord1","replacePrefixesOptions","replacePrefixes","newRecord2","replaceAllPrefixes","newRecord3","handleTempUrns","newRecord4","stripF884s","toObject","length","options","replacePrefix","oldPrefix","newPrefix","prefixReplaceCodes","pattern","replacement","getDatafields","field","subfields","filter","code","includes","subfield","value","replace","f035Filters","fSIDFilters","f035s","f035ToSidInfo","fSIDs","sidsToSidInfo","sidsToBeAdded","genNewSids","f035SidInfo","some","fSIDInfo","SID","sidField","insertField","map","sidInfo","tag","ind1","ind2","SIDs","flatMap","sub","wantedSub","regexp","test","findIndex","slice","indexOf"],"sources":["../../src/helpers/fix.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\nimport createDebugLogger from 'debug';\n\nimport {handleTempUrns} from './fix-handle-tempurns';\nimport {stripF884s} from './fix-strip-f884s';\n\nexport * from './fix-constants';\n\nconst logger = createLogger();\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fixRecord');\nconst debugData = debug.extend('data');\n\nexport function fixRecord(record, settings = {}) {\n\n logger.verbose(`We will apply formatting to the record according to settings: ${JSON.stringify(settings)}`);\n const newRecord = MarcRecord.clone(record, {subfieldValues: false});\n debugData(`settings: ${JSON.stringify(settings)}`);\n\n // We should handle these in some prettier way ...\n\n // Fix 1, generate SIDs\n const generateMissingSIDsOptions = settings.generateMissingSIDs || undefined;\n const newRecord1 = generateMissingSIDs(newRecord, generateMissingSIDsOptions);\n\n // Fix 2, replace identifier prefixes\n const replacePrefixesOptions = settings.replacePrefixes || [];\n const newRecord2 = replaceAllPrefixes(newRecord1, replacePrefixesOptions);\n\n // Fix 3, handle temporary URNs from legal deposit record import\n const newRecord3 = handleTempUrns(newRecord2, settings.handleTempUrns);\n\n // Fix 4, strip extra field 884s\n const newRecord4 = stripF884s(newRecord3, settings.stripF884s);\n\n return newRecord4.toObject();\n\n}\n\n\nfunction replaceAllPrefixes(record, replacePrefixesOptions) {\n if (replacePrefixesOptions.length < 1) {\n debug(`NOT running replacePrefixes, no options`);\n return record;\n }\n\n debug(`Running replacePrefixes fixer`);\n debugData(`replacePrefixesOptions: ${JSON.stringify(replacePrefixesOptions)}`);\n\n replacePrefixesOptions.forEach(options => {\n replacePrefix(record, options);\n });\n return record;\n}\n\n\n// Replace prefix in all specified subfields\nfunction replacePrefix(record, options) {\n const {oldPrefix, newPrefix, prefixReplaceCodes} = options;\n debug(`Replacing ${oldPrefix} with ${newPrefix} in subfields ${prefixReplaceCodes}`);\n const pattern = `(${oldPrefix})`;\n const replacement = `(${newPrefix})`;\n record.getDatafields()\n .forEach(field => {\n field.subfields\n .filter(({code}) => prefixReplaceCodes.includes(code))\n .forEach(subfield => {\n subfield.value = subfield.value.replace(pattern, replacement); // eslint-disable-line functional/immutable-data\n });\n });\n return record;\n}\n\n\nfunction generateMissingSIDs(record, options) {\n\n const f035Filters = options && options.f035Filters ? options.f035Filters : [];\n const fSIDFilters = options && options.fSIDFilters ? options.fSIDFilters : [];\n\n if (f035Filters.length !== fSIDFilters.length || f035Filters.length < 1 || fSIDFilters.length < 1) {\n debug(`NOT running generateMissingsSIDs, no options`);\n return record;\n }\n\n debug(`Running generateMissingSIDs fixer`);\n debugData(`generateMissingSIDs options: ${JSON.stringify(options)}`);\n\n const f035s = f035ToSidInfo(record.get(/^035$/u));\n const fSIDs = sidsToSidInfo(record.get(/^SID$/u));\n\n const sidsToBeAdded = genNewSids(fSIDs.length === 0\n ? f035s\n // test that SIDs are not there yet\n : f035s.filter(f035SidInfo => !fSIDs.some(fSIDInfo => f035SidInfo.SID === fSIDInfo.SID && f035SidInfo.value === fSIDInfo.value)));\n\n debugData(`Adding (${sidsToBeAdded.length}) SIDs: ${JSON.stringify(sidsToBeAdded)}`);\n\n // Add new SIDs\n sidsToBeAdded.forEach(sidField => record.insertField(sidField));\n return record;\n\n function genNewSids(sidsToBeAdded) {\n return sidsToBeAdded.map(sidInfo => ({tag: 'SID', ind1: ' ', ind2: ' ', subfields: [{code: 'c', value: sidInfo.value}, {code: 'b', value: sidInfo.SID}]}));\n }\n\n function sidsToSidInfo(SIDs) {\n return SIDs.flatMap(({subfields}) => {\n const [SID] = subfields.filter(sub => sub.code === 'b' && fSIDFilters.includes(sub.value)).map(sub => sub.value);\n const [value] = subfields.filter(sub => sub.code === 'c' && sub.value !== undefined).map(sub => sub.value);\n\n if (SID && value) {\n return {\n SID,\n value\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n\n function f035ToSidInfo(f035s) {\n return f035s.flatMap(({subfields}) => {\n const [wantedSub] = subfields.filter(sub => sub.code === 'a' && f035Filters.some(regexp => regexp.test(sub.value)));\n\n if (wantedSub) {\n return {\n SID: fSIDFilters[f035Filters.findIndex(regexp => regexp.test(wantedSub.value))],\n value: wantedSub.value.slice(wantedSub.value.indexOf(')') + 1)\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n}\n\n\n"],"mappings":";;;;;;;;;;AA4BA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAEA,IAAAM,aAAA,GAAAN,OAAA;AAAAO,MAAA,CAAAC,IAAA,CAAAF,aAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,aAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,aAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,MAAMS,MAAM,GAAG,IAAAC,mCAAY,EAAC,CAAC;AAC7B,MAAMC,KAAK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AM,CAACC,IAAI,CAACF,SAAS,CAACxB,KAAK,CAAC,CAAC,CAAC;UAC/EA,KAAK,EAAEwB,SAAS,CAACxB,KAAK,CAAC4B,KAAK,CAACJ,SAAS,CAACxB,KAAK,CAAC6B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAC/D,CAAC;MACH;MAEA,OAAOvD,SAAS;IAClB,CAAC,CAAC,CAACsB,MAAM,CAACI,KAAK,IAAIA,KAAK,KAAK1B,SAAS,CAAC;EACzC;AACF"}
|
|
1
|
+
{"version":3,"file":"fix.js","names":["_marcRecord","require","_melindaBackendCommons","_debug","_interopRequireDefault","_fixHandleTempurns","_fixStripF884s","_marcRecordValidatorsMelinda","_fixConstants","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","logger","createLogger","debug","createDebugLogger","debugData","extend","fixRecord","record","settings","verbose","JSON","stringify","newRecord","MarcRecord","clone","subfieldValues","generateMissingSIDsOptions","generateMissingSIDs","undefined","newRecord1","replacePrefixesOptions","replacePrefixes","newRecord2","replaceAllPrefixes","newRecord3","handleTempUrns","newRecord4","stripF884s","newRecord5","stripF984s","toObject","length","options","replacePrefix","oldPrefix","newPrefix","prefixReplaceCodes","pattern","replacement","getDatafields","field","subfields","filter","code","includes","subfield","value","replace","f035Filters","fSIDFilters","f035s","f035ToSidInfo","fSIDs","sidsToSidInfo","sidsToBeAdded","genNewSids","f035SidInfo","some","fSIDInfo","SID","sidField","insertField","map","sidInfo","tag","ind1","ind2","SIDs","flatMap","sub","wantedSub","regexp","test","findIndex","slice","indexOf","stripF984sSettings","F984A_PATTERN","toString","config","validator","FieldExclusion","fix"],"sources":["../../src/helpers/fix.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\nimport createDebugLogger from 'debug';\n\nimport {handleTempUrns} from './fix-handle-tempurns';\nimport {stripF884s} from './fix-strip-f884s';\n\nimport {FieldExclusion} from '@natlibfi/marc-record-validators-melinda';\n\nexport * from './fix-constants';\n\nconst logger = createLogger();\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fixRecord');\nconst debugData = debug.extend('data');\n\nexport function fixRecord(record, settings = {}) {\n\n logger.verbose(`We will apply formatting to the record according to settings: ${JSON.stringify(settings)}`);\n const newRecord = MarcRecord.clone(record, {subfieldValues: false});\n debugData(`settings: ${JSON.stringify(settings)}`);\n\n // We should handle these in some prettier way ...\n\n // Fix 1, generate SIDs\n const generateMissingSIDsOptions = settings.generateMissingSIDs || undefined;\n const newRecord1 = generateMissingSIDs(newRecord, generateMissingSIDsOptions);\n\n // Fix 2, replace identifier prefixes\n const replacePrefixesOptions = settings.replacePrefixes || [];\n const newRecord2 = replaceAllPrefixes(newRecord1, replacePrefixesOptions);\n\n // Fix 3, handle temporary URNs from legal deposit record import\n const newRecord3 = handleTempUrns(newRecord2, settings.handleTempUrns);\n\n // Fix 4, strip extra field 884s\n const newRecord4 = stripF884s(newRecord3, settings.stripF884s);\n\n // Fix 5, strip extra field 884s\n const newRecord5 = stripF984s(newRecord4, settings.stripF984s || false);\n debugData(newRecord5);\n\n return newRecord5.toObject();\n\n}\n\n\nfunction replaceAllPrefixes(record, replacePrefixesOptions) {\n if (replacePrefixesOptions.length < 1) {\n debug(`NOT running replacePrefixes, no options`);\n return record;\n }\n\n debug(`Running replacePrefixes fixer`);\n debugData(`replacePrefixesOptions: ${JSON.stringify(replacePrefixesOptions)}`);\n\n replacePrefixesOptions.forEach(options => {\n replacePrefix(record, options);\n });\n return record;\n}\n\n\n// Replace prefix in all specified subfields\nfunction replacePrefix(record, options) {\n const {oldPrefix, newPrefix, prefixReplaceCodes} = options;\n debug(`Replacing ${oldPrefix} with ${newPrefix} in subfields ${prefixReplaceCodes}`);\n const pattern = `(${oldPrefix})`;\n const replacement = `(${newPrefix})`;\n record.getDatafields()\n .forEach(field => {\n field.subfields\n .filter(({code}) => prefixReplaceCodes.includes(code))\n .forEach(subfield => {\n subfield.value = subfield.value.replace(pattern, replacement); // eslint-disable-line functional/immutable-data\n });\n });\n return record;\n}\n\n\nfunction generateMissingSIDs(record, options) {\n\n const f035Filters = options && options.f035Filters ? options.f035Filters : [];\n const fSIDFilters = options && options.fSIDFilters ? options.fSIDFilters : [];\n\n if (f035Filters.length !== fSIDFilters.length || f035Filters.length < 1 || fSIDFilters.length < 1) {\n debug(`NOT running generateMissingsSIDs, no options`);\n return record;\n }\n\n debug(`Running generateMissingSIDs fixer`);\n debugData(`generateMissingSIDs options: ${JSON.stringify(options)}`);\n\n const f035s = f035ToSidInfo(record.get(/^035$/u));\n const fSIDs = sidsToSidInfo(record.get(/^SID$/u));\n\n const sidsToBeAdded = genNewSids(fSIDs.length === 0\n ? f035s\n // test that SIDs are not there yet\n : f035s.filter(f035SidInfo => !fSIDs.some(fSIDInfo => f035SidInfo.SID === fSIDInfo.SID && f035SidInfo.value === fSIDInfo.value)));\n\n debugData(`Adding (${sidsToBeAdded.length}) SIDs: ${JSON.stringify(sidsToBeAdded)}`);\n\n // Add new SIDs\n sidsToBeAdded.forEach(sidField => record.insertField(sidField));\n return record;\n\n function genNewSids(sidsToBeAdded) {\n return sidsToBeAdded.map(sidInfo => ({tag: 'SID', ind1: ' ', ind2: ' ', subfields: [{code: 'c', value: sidInfo.value}, {code: 'b', value: sidInfo.SID}]}));\n }\n\n function sidsToSidInfo(SIDs) {\n return SIDs.flatMap(({subfields}) => {\n const [SID] = subfields.filter(sub => sub.code === 'b' && fSIDFilters.includes(sub.value)).map(sub => sub.value);\n const [value] = subfields.filter(sub => sub.code === 'c' && sub.value !== undefined).map(sub => sub.value);\n\n if (SID && value) {\n return {\n SID,\n value\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n\n function f035ToSidInfo(f035s) {\n return f035s.flatMap(({subfields}) => {\n const [wantedSub] = subfields.filter(sub => sub.code === 'a' && f035Filters.some(regexp => regexp.test(sub.value)));\n\n if (wantedSub) {\n return {\n SID: fSIDFilters[f035Filters.findIndex(regexp => regexp.test(wantedSub.value))],\n value: wantedSub.value.slice(wantedSub.value.indexOf(')') + 1)\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n}\n\n\nfunction stripF984s(record, stripF984sSettings) {\n const F984A_PATTERN = /^(?:ALWAYS)|(?:NEVER)-PREFER-IN-MERGE$/u;\n\n debug(`Running removeF984AFields`);\n debugData(`removeF984AFieldsSettings: ${JSON.stringify(stripF984sSettings)}`);\n\n if (!stripF984sSettings || !F984A_PATTERN || record.get('984').length < 1) {\n debug(`No settings or pattern for removeF984AFields or f984 in record`);\n return record;\n }\n\n debug(`Removing f984 fields with subfield $a consisting values ${F984A_PATTERN.toString()}`);\n const config = [\n {\n tag: /^984$/u,\n subfields: [\n {\n code: /a/u,\n value: F984A_PATTERN\n }\n ]\n }\n ];\n // eslint-disable-next-line new-cap\n const validator = FieldExclusion(config);\n validator.fix(record);\n return record;\n\n}\n\n"],"mappings":";;;;;;;;;;AA4BA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAE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EqE,kBAAkB,EAAE;EAC9C,MAAMC,aAAa,GAAG,yCAAyC;EAE/D3E,KAAK,CAAE,2BAA0B,CAAC;EAClCE,SAAS,CAAE,8BAA6BM,IAAI,CAACC,SAAS,CAACiE,kBAAkB,CAAE,EAAC,CAAC;EAE7E,IAAI,CAACA,kBAAkB,IAAI,CAACC,aAAa,IAAItE,MAAM,CAACR,GAAG,CAAC,KAAK,CAAC,CAACgC,MAAM,GAAG,CAAC,EAAE;IACzE7B,KAAK,CAAE,gEAA+D,CAAC;IACvE,OAAOK,MAAM;EACf;EAEAL,KAAK,CAAE,2DAA0D2E,aAAa,CAACC,QAAQ,CAAC,CAAE,EAAC,CAAC;EAC5F,MAAMC,MAAM,GAAG,CACb;IACEf,GAAG,EAAE,QAAQ;IACbvB,SAAS,EAAE,CACT;MACEE,IAAI,EAAE,IAAI;MACVG,KAAK,EAAE+B;IACT,CAAC;EAEL,CAAC,CACF;EACD;EACA,MAAMG,SAAS,GAAG,IAAAC,2CAAc,EAACF,MAAM,CAAC;EACxCC,SAAS,CAACE,GAAG,CAAC3E,MAAM,CAAC;EACrB,OAAOA,MAAM;AAEf"}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
|
|
15
15
|
},
|
|
16
16
|
"license": "AGPL-3.0+",
|
|
17
|
-
"version": "4.0
|
|
17
|
+
"version": "4.1.0-alpha.2",
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=18"
|
|
@@ -40,30 +40,30 @@
|
|
|
40
40
|
"@natlibfi/marc-record-serializers": "^10.1.2",
|
|
41
41
|
"@natlibfi/marc-record-validate": "^8.0.4",
|
|
42
42
|
"@natlibfi/marc-record-validators-melinda": "^10.15.2",
|
|
43
|
-
"@natlibfi/melinda-backend-commons": "^2.2.
|
|
44
|
-
"@natlibfi/melinda-commons": "^13.0.
|
|
43
|
+
"@natlibfi/melinda-backend-commons": "^2.2.5",
|
|
44
|
+
"@natlibfi/melinda-commons": "^13.0.10",
|
|
45
45
|
"amqplib": "^0.10.3",
|
|
46
46
|
"debug": "^4.3.4",
|
|
47
47
|
"http-status": "^1.7.3",
|
|
48
|
-
"moment": "^2.
|
|
48
|
+
"moment": "^2.30.1",
|
|
49
49
|
"mongo-sanitize": "^1.1.0",
|
|
50
50
|
"mongodb": "^4.17.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@babel/cli": "^7.23.4",
|
|
54
|
-
"@babel/core": "^7.23.
|
|
55
|
-
"@babel/plugin-transform-runtime": "^7.23.
|
|
56
|
-
"@babel/preset-env": "^7.23.
|
|
57
|
-
"@babel/register": "^7.
|
|
54
|
+
"@babel/core": "^7.23.7",
|
|
55
|
+
"@babel/plugin-transform-runtime": "^7.23.7",
|
|
56
|
+
"@babel/preset-env": "^7.23.8",
|
|
57
|
+
"@babel/register": "^7.23.7",
|
|
58
58
|
"@natlibfi/eslint-config-melinda-backend": "^3.0.3",
|
|
59
|
-
"@natlibfi/fixugen": "^2.0.
|
|
60
|
-
"@natlibfi/fixura": "^3.0.
|
|
61
|
-
"@natlibfi/fixura-mongo": "^2.0.
|
|
59
|
+
"@natlibfi/fixugen": "^2.0.4",
|
|
60
|
+
"@natlibfi/fixura": "^3.0.4",
|
|
61
|
+
"@natlibfi/fixura-mongo": "^2.0.11",
|
|
62
62
|
"babel-plugin-istanbul": "^6.1.1",
|
|
63
63
|
"babel-plugin-rewire": "^1.2.0",
|
|
64
|
-
"chai": "^4.
|
|
64
|
+
"chai": "^4.4.0",
|
|
65
65
|
"cross-env": "^7.0.3",
|
|
66
|
-
"eslint": "^8.
|
|
66
|
+
"eslint": "^8.56.0",
|
|
67
67
|
"mocha": "^10.2.0",
|
|
68
68
|
"nodemon": "^3.0.2",
|
|
69
69
|
"nyc": "^15.1.0"
|