@natlibfi/melinda-rest-api-commons 4.1.2 → 4.1.3-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.
Files changed (38) hide show
  1. package/.github/CODEOWNERS +2 -14
  2. package/.github/workflows/melinda-node-tests.yml +1 -1
  3. package/LICENSE.txt +21 -661
  4. package/README.md +1 -1
  5. package/dist/amqp.health.spec.js +0 -28
  6. package/dist/amqp.health.spec.js.map +1 -1
  7. package/dist/amqp.js +0 -28
  8. package/dist/amqp.js.map +1 -1
  9. package/dist/amqp.tests.spec.js +0 -28
  10. package/dist/amqp.tests.spec.js.map +1 -1
  11. package/dist/constants.js +0 -28
  12. package/dist/constants.js.map +1 -1
  13. package/dist/helpers/conversion.js +0 -28
  14. package/dist/helpers/conversion.js.map +1 -1
  15. package/dist/helpers/conversion.spec.js +0 -28
  16. package/dist/helpers/conversion.spec.js.map +1 -1
  17. package/dist/helpers/fix-constants.js +0 -28
  18. package/dist/helpers/fix-constants.js.map +1 -1
  19. package/dist/helpers/fix-handle-tempurns.js +0 -28
  20. package/dist/helpers/fix-handle-tempurns.js.map +1 -1
  21. package/dist/helpers/fix-strip-f884s.js +0 -28
  22. package/dist/helpers/fix-strip-f884s.js.map +1 -1
  23. package/dist/helpers/fix-utils.js +0 -28
  24. package/dist/helpers/fix-utils.js.map +1 -1
  25. package/dist/helpers/fix.js +0 -28
  26. package/dist/helpers/fix.js.map +1 -1
  27. package/dist/helpers/validation.js +0 -27
  28. package/dist/helpers/validation.js.map +1 -1
  29. package/dist/helpers/validation.spec.js +0 -28
  30. package/dist/helpers/validation.spec.js.map +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/mongo.js +0 -27
  33. package/dist/mongo.js.map +1 -1
  34. package/dist/mongoLog.js +0 -28
  35. package/dist/mongoLog.js.map +1 -1
  36. package/dist/utils.js +0 -28
  37. package/dist/utils.js.map +1 -1
  38. package/package.json +2 -2
@@ -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","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,GA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;AAEM,MAAMM,wBAAwB,GAAAnB,OAAA,CAAAmB,wBAAA,GAAG;EACtCJ,UAAU,EAAE;AACd,CAAC"}
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":["// 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;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"}
@@ -6,34 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.handleTempUrns = handleTempUrns;
8
8
  var _debug = _interopRequireDefault(require("debug"));
9
- /**
10
- *
11
- * @licstart The following is the entire license notice for the JavaScript code in this file.
12
- *
13
- * Shared modules for microservices of Melinda rest api batch import system
14
- *
15
- * Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
16
- *
17
- * This file is part of melinda-rest-api-commons
18
- *
19
- * melinda-rest-api-commons program is free software: you can redistribute it and/or modify
20
- * it under the terms of the GNU Affero General Public License as
21
- * published by the Free Software Foundation, either version 3 of the
22
- * License, or (at your option) any later version.
23
- *
24
- * melinda-rest-api-commons is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU Affero General Public License for more details.
28
- *
29
- * You should have received a copy of the GNU Affero General Public License
30
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
31
- *
32
- * @licend The above is the entire license notice
33
- * for the JavaScript code in this file.
34
- *
35
- */
36
-
37
9
  //import {MarcRecord} from '@natlibfi/marc-record';
38
10
 
39
11
  const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:fixRecord:handleTempUrns');
@@ -1 +1 @@
1
- {"version":3,"file":"fix-handle-tempurns.js","names":["_debug","_interopRequireDefault","require","debug","createDebugLogger","debugData","extend","handleTempUrns","newRecord","options","JSON","stringify","f856sUrnsWithTempSubfields","f856sUrnsWithNoTempSubfields","getf856sUrns","length","existingLegalDepositURN","validateLD","removeFields","fixedFields","map","removeTempSubfield","filter","field","insertFields","hasURN","f","tag","subfields","some","code","value","test","hasTempSubfield","hasNoTempSubfield","f856sUrn","fields","LD_SUBFIELDS","f856sUrnWithLdSubfields","fieldHasLDSubfields","ldSubfields","every","ldsf","sf","isNaN","parseInt","filteredSubfields","ind1","ind2"],"sources":["../../src/helpers/fix-handle-tempurns.js"],"sourcesContent":["\n/**\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//import {MarcRecord} from '@natlibfi/marc-record';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fixRecord:handleTempUrns');\nconst debugData = debug.extend('data');\n\n// eslint-disable-next-line max-statements\nexport function handleTempUrns(newRecord, options) {\n\n if (options !== true) {\n debug(`NOT running handleTempUrns fixer, no options`);\n return newRecord;\n }\n\n debug(`Running handleTempUrns fixer`);\n debugData(`Options for handleTempUrns: ${JSON.stringify(options)}`);\n\n const {f856sUrnsWithTempSubfields, f856sUrnsWithNoTempSubfields} = getf856sUrns(newRecord);\n\n // None of the URNs has temp subfields, we don't need to do anything\n if (f856sUrnsWithTempSubfields.length < 1) {\n debug(`No Urns with temp subfield`);\n return newRecord;\n }\n\n // Do we have an existing URN with legal deposit subfields, if we have, we can remove the temp URN field(s)\n const existingLegalDepositURN = validateLD(f856sUrnsWithNoTempSubfields);\n debug(`existingLegalDepositURN: ${existingLegalDepositURN}`);\n\n if (existingLegalDepositURN) {\n debug(`We have an existing LD URN, we can delete temp fields (${f856sUrnsWithTempSubfields.length})`);\n newRecord.removeFields(f856sUrnsWithTempSubfields);\n return newRecord;\n }\n\n // We do not have an existing legalDepositURN, we should use the tempURN and remove the temp subfields from it\n if (!existingLegalDepositURN && f856sUrnsWithTempSubfields.length > 0) {\n //debug(`All Urns (${f856sUrn.length}) have a temp subfield`);\n debugData(`Original temp URNs: (${JSON.stringify(f856sUrnsWithTempSubfields)})`);\n const fixedFields = f856sUrnsWithTempSubfields.map(removeTempSubfield).filter(field => field);\n debug(`We removed temp subfields: (${JSON.stringify(fixedFields)})`);\n newRecord.removeFields(f856sUrnsWithTempSubfields);\n newRecord.insertFields(fixedFields);\n return newRecord;\n }\n // Should we check that the non-temp URN has 2nd ind '0' - meaning that the URN handles the actual resource itself?\n}\n\nfunction getf856sUrns(newRecord) {\n const hasURN = f => f.tag === '856' && f.subfields.some(({code, value}) => code === 'u' && (/urn.fi/u).test(value));\n\n const hasTempSubfield = f => f.subfields.some(({code, value}) => code === '9' && (/^MELINDA<TEMP>$/u).test(value));\n const hasNoTempSubfield = f => !f.subfields.some(({code, value}) => code === '9' && (/^MELINDA<TEMP>$/u).test(value));\n\n const f856sUrn = newRecord.fields.filter(hasURN);\n const f856sUrnsWithTempSubfields = f856sUrn.filter(hasTempSubfield);\n const f856sUrnsWithNoTempSubfields = f856sUrn.filter(hasNoTempSubfield);\n\n debugData(`URN f856s: ${JSON.stringify(f856sUrn)}`);\n debugData(`URN f856s with temp subfield: ${JSON.stringify(f856sUrnsWithTempSubfields)}`);\n return {f856sUrn, f856sUrnsWithTempSubfields, f856sUrnsWithNoTempSubfields};\n}\n\n\n// ---- LD-functions below are same as in https://github.com/NatLibFi/marc-record-validators-melinda/blob/feature-updates-to-urn/src/urn.js\n// we propably should develop the urn/legaldeposit -validator to use also here\n\nfunction validateLD(f856sUrn) {\n debug(`Validating the existence of legal deposit subfields`);\n\n const LD_SUBFIELDS = [\n {code: 'z', value: 'Käytettävissä vapaakappalekirjastoissa'},\n {code: '5', value: 'FI-Vapaa'}\n ];\n\n const f856sUrnWithLdSubfields = f856sUrn.filter(field => fieldHasLDSubfields(field, LD_SUBFIELDS));\n if (f856sUrnWithLdSubfields.length > 0) {\n debug(`Record has ${f856sUrnWithLdSubfields.length} URN fields with all necessary legal deposit subfields`);\n debugData(`f856sUrnWithLdSubfields: ${JSON.stringify(f856sUrnWithLdSubfields)}`);\n return true;\n }\n return false;\n}\n\nfunction fieldHasLDSubfields(field, ldSubfields) {\n if (ldSubfields.every(ldsf => field.subfields.some(sf => sf.code === ldsf.code && sf.value === ldsf.value))) {\n return true;\n }\n}\n\nfunction removeTempSubfield(field) {\n\n // Handle non-numeric fields, and fields with a numeric tag of 010 and greater\n // Aleph's FMT as a controlfield might be a problem\n if (!isNaN(field.tag) && parseInt(field.tag, 10) >= 10) {\n\n const filteredSubfields = field.subfields.filter(sf => sf.code !== '9' && !(/^MELINDA<TEMP>$/u).test(sf.value));\n\n // Remove whole field if there are no subfields left\n if (filteredSubfields.length < 1) {\n return false;\n }\n\n return {\n tag: field.tag,\n ind1: field.ind1,\n ind2: field.ind2,\n subfields: filteredSubfields\n };\n }\n // return controlFields as is\n return field;\n}\n\n\n"],"mappings":";;;;;;;AA8BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AA7BA;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;;AAGA,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,6DAA6D,CAAC;AAC9F,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;;AAEtC;AACO,SAASC,cAAcA,CAACC,SAAS,EAAEC,OAAO,EAAE;EAEjD,IAAIA,OAAO,KAAK,IAAI,EAAE;IACpBN,KAAK,CAAE,8CAA6C,CAAC;IACrD,OAAOK,SAAS;EAClB;EAEAL,KAAK,CAAE,8BAA6B,CAAC;EACrCE,SAAS,CAAE,+BAA8BK,IAAI,CAACC,SAAS,CAACF,OAAO,CAAE,EAAC,CAAC;EAEnE,MAAM;IAACG,0BAA0B;IAAEC;EAA4B,CAAC,GAAGC,YAAY,CAACN,SAAS,CAAC;;EAE1F;EACA,IAAII,0BAA0B,CAACG,MAAM,GAAG,CAAC,EAAE;IACzCZ,KAAK,CAAE,4BAA2B,CAAC;IACnC,OAAOK,SAAS;EAClB;;EAEA;EACA,MAAMQ,uBAAuB,GAAGC,UAAU,CAACJ,4BAA4B,CAAC;EACxEV,KAAK,CAAE,4BAA2Ba,uBAAwB,EAAC,CAAC;EAE5D,IAAIA,uBAAuB,EAAE;IAC3Bb,KAAK,CAAE,0DAAyDS,0BAA0B,CAACG,MAAO,GAAE,CAAC;IACrGP,SAAS,CAACU,YAAY,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,KAAKW,IAAI,CAACX,KAAK,CAAC,CAAC,EAAE;IAC3G,OAAO,IAAI;EACb;AACF;AAEA,SAASV,kBAAkBA,CAACE,KAAK,EAAE;EAEjC;EACA;EACA,IAAI,CAACqB,KAAK,CAACrB,KAAK,CAACI,GAAG,CAAC,IAAIkB,QAAQ,CAACtB,KAAK,CAACI,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;IAEtD,MAAMmB,iBAAiB,GAAGvB,KAAK,CAACK,SAAS,CAACN,MAAM,CAACqB,EAAE,IAAIA,EAAE,CAACb,IAAI,KAAK,GAAG,IAAI,CAAE,kBAAkB,CAAEE,IAAI,CAACW,EAAE,CAACZ,KAAK,CAAC,CAAC;;IAE/G;IACA,IAAIe,iBAAiB,CAAC/B,MAAM,GAAG,CAAC,EAAE;MAChC,OAAO,KAAK;IACd;IAEA,OAAO;MACLY,GAAG,EAAEJ,KAAK,CAACI,GAAG;MACdoB,IAAI,EAAExB,KAAK,CAACwB,IAAI;MAChBC,IAAI,EAAEzB,KAAK,CAACyB,IAAI;MAChBpB,SAAS,EAAEkB;IACb,CAAC;EACH;EACA;EACA,OAAOvB,KAAK;AACd"}
1
+ {"version":3,"file":"fix-handle-tempurns.js","names":["_debug","_interopRequireDefault","require","debug","createDebugLogger","debugData","extend","handleTempUrns","newRecord","options","JSON","stringify","f856sUrnsWithTempSubfields","f856sUrnsWithNoTempSubfields","getf856sUrns","length","existingLegalDepositURN","validateLD","removeFields","fixedFields","map","removeTempSubfield","filter","field","insertFields","hasURN","f","tag","subfields","some","code","value","test","hasTempSubfield","hasNoTempSubfield","f856sUrn","fields","LD_SUBFIELDS","f856sUrnWithLdSubfields","fieldHasLDSubfields","ldSubfields","every","ldsf","sf","isNaN","parseInt","filteredSubfields","ind1","ind2"],"sources":["../../src/helpers/fix-handle-tempurns.js"],"sourcesContent":["\n\n//import {MarcRecord} from '@natlibfi/marc-record';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fixRecord:handleTempUrns');\nconst debugData = debug.extend('data');\n\n// eslint-disable-next-line max-statements\nexport function handleTempUrns(newRecord, options) {\n\n if (options !== true) {\n debug(`NOT running handleTempUrns fixer, no options`);\n return newRecord;\n }\n\n debug(`Running handleTempUrns fixer`);\n debugData(`Options for handleTempUrns: ${JSON.stringify(options)}`);\n\n const {f856sUrnsWithTempSubfields, f856sUrnsWithNoTempSubfields} = getf856sUrns(newRecord);\n\n // None of the URNs has temp subfields, we don't need to do anything\n if (f856sUrnsWithTempSubfields.length < 1) {\n debug(`No Urns with temp subfield`);\n return newRecord;\n }\n\n // Do we have an existing URN with legal deposit subfields, if we have, we can remove the temp URN field(s)\n const existingLegalDepositURN = validateLD(f856sUrnsWithNoTempSubfields);\n debug(`existingLegalDepositURN: ${existingLegalDepositURN}`);\n\n if (existingLegalDepositURN) {\n debug(`We have an existing LD URN, we can delete temp fields (${f856sUrnsWithTempSubfields.length})`);\n newRecord.removeFields(f856sUrnsWithTempSubfields);\n return newRecord;\n }\n\n // We do not have an existing legalDepositURN, we should use the tempURN and remove the temp subfields from it\n if (!existingLegalDepositURN && f856sUrnsWithTempSubfields.length > 0) {\n //debug(`All Urns (${f856sUrn.length}) have a temp subfield`);\n debugData(`Original temp URNs: (${JSON.stringify(f856sUrnsWithTempSubfields)})`);\n const fixedFields = f856sUrnsWithTempSubfields.map(removeTempSubfield).filter(field => field);\n debug(`We removed temp subfields: (${JSON.stringify(fixedFields)})`);\n newRecord.removeFields(f856sUrnsWithTempSubfields);\n newRecord.insertFields(fixedFields);\n return newRecord;\n }\n // Should we check that the non-temp URN has 2nd ind '0' - meaning that the URN handles the actual resource itself?\n}\n\nfunction getf856sUrns(newRecord) {\n const hasURN = f => f.tag === '856' && f.subfields.some(({code, value}) => code === 'u' && (/urn.fi/u).test(value));\n\n const hasTempSubfield = f => f.subfields.some(({code, value}) => code === '9' && (/^MELINDA<TEMP>$/u).test(value));\n const hasNoTempSubfield = f => !f.subfields.some(({code, value}) => code === '9' && (/^MELINDA<TEMP>$/u).test(value));\n\n const f856sUrn = newRecord.fields.filter(hasURN);\n const f856sUrnsWithTempSubfields = f856sUrn.filter(hasTempSubfield);\n const f856sUrnsWithNoTempSubfields = f856sUrn.filter(hasNoTempSubfield);\n\n debugData(`URN f856s: ${JSON.stringify(f856sUrn)}`);\n debugData(`URN f856s with temp subfield: ${JSON.stringify(f856sUrnsWithTempSubfields)}`);\n return {f856sUrn, f856sUrnsWithTempSubfields, f856sUrnsWithNoTempSubfields};\n}\n\n\n// ---- LD-functions below are same as in https://github.com/NatLibFi/marc-record-validators-melinda/blob/feature-updates-to-urn/src/urn.js\n// we propably should develop the urn/legaldeposit -validator to use also here\n\nfunction validateLD(f856sUrn) {\n debug(`Validating the existence of legal deposit subfields`);\n\n const LD_SUBFIELDS = [\n {code: 'z', value: 'Käytettävissä vapaakappalekirjastoissa'},\n {code: '5', value: 'FI-Vapaa'}\n ];\n\n const f856sUrnWithLdSubfields = f856sUrn.filter(field => fieldHasLDSubfields(field, LD_SUBFIELDS));\n if (f856sUrnWithLdSubfields.length > 0) {\n debug(`Record has ${f856sUrnWithLdSubfields.length} URN fields with all necessary legal deposit subfields`);\n debugData(`f856sUrnWithLdSubfields: ${JSON.stringify(f856sUrnWithLdSubfields)}`);\n return true;\n }\n return false;\n}\n\nfunction fieldHasLDSubfields(field, ldSubfields) {\n if (ldSubfields.every(ldsf => field.subfields.some(sf => sf.code === ldsf.code && sf.value === ldsf.value))) {\n return true;\n }\n}\n\nfunction removeTempSubfield(field) {\n\n // Handle non-numeric fields, and fields with a numeric tag of 010 and greater\n // Aleph's FMT as a controlfield might be a problem\n if (!isNaN(field.tag) && parseInt(field.tag, 10) >= 10) {\n\n const filteredSubfields = field.subfields.filter(sf => sf.code !== '9' && !(/^MELINDA<TEMP>$/u).test(sf.value));\n\n // Remove whole field if there are no subfields left\n if (filteredSubfields.length < 1) {\n return false;\n }\n\n return {\n tag: field.tag,\n ind1: field.ind1,\n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B,GAAGvB,KAAK,CAACK,SAAS,CAACN,MAAM,CAACqB,EAAE,IAAIA,EAAE,CAACb,IAAI,KAAK,GAAG,IAAI,CAAE,kBAAkB,CAAEE,IAAI,CAACW,EAAE,CAACZ,KAAK,CAAC,CAAC;;IAE/G;IACA,IAAIe,iBAAiB,CAAC/B,MAAM,GAAG,CAAC,EAAE;MAChC,OAAO,KAAK;IACd;IAEA,OAAO;MACLY,GAAG,EAAEJ,KAAK,CAACI,GAAG;MACdoB,IAAI,EAAExB,KAAK,CAACwB,IAAI;MAChBC,IAAI,EAAEzB,KAAK,CAACyB,IAAI;MAChBpB,SAAS,EAAEkB;IACb,CAAC;EACH;EACA;EACA,OAAOvB,KAAK;AACd"}
@@ -8,34 +8,6 @@ exports.stripF884s = stripF884s;
8
8
  var _marcRecord = require("@natlibfi/marc-record");
9
9
  var _debug = _interopRequireDefault(require("debug"));
10
10
  var _util = require("util");
11
- /**
12
- *
13
- * @licstart The following is the entire license notice for the JavaScript code in this file.
14
- *
15
- * Shared modules for microservices of Melinda rest api batch import system
16
- *
17
- * Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
18
- *
19
- * This file is part of melinda-rest-api-commons
20
- *
21
- * melinda-rest-api-commons program is free software: you can redistribute it and/or modify
22
- * it under the terms of the GNU Affero General Public License as
23
- * published by the Free Software Foundation, either version 3 of the
24
- * License, or (at your option) any later version.
25
- *
26
- * melinda-rest-api-commons is distributed in the hope that it will be useful,
27
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
- * GNU Affero General Public License for more details.
30
- *
31
- * You should have received a copy of the GNU Affero General Public License
32
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
33
- *
34
- * @licend The above is the entire license notice
35
- * for the JavaScript code in this file.
36
- *
37
- */
38
-
39
11
  //import {sortFieldsBySubfieldValue, removeSubfield} from './fix-utils';
40
12
 
41
13
  function stripF884s(newRecord, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"fix-strip-f884s.js","names":["_marcRecord","require","_debug","_interopRequireDefault","_util","stripF884s","newRecord","options","debug","createDebugLogger","debugData","extend","JSON","stringify","isMelindaf884","f","tag","subfields","some","code","value","f884Melindas","fields","filter","length","results","reduce","allResults","f884","index","conversion","findConversion","source","findSource","convSource","firstDate","lastDate","findDates","hash","findHash","currResult","newResult","updatedResult","editedf884s","editFields","editedFields","map","field","sfGAll","sfKAll","sfG","replace","sfK","subfield","uniq884s","uniqFields","inspect","depth","uniq","MarcRecord","isEqual","push","removeFields","insertFields","sfA","emptySource","emptyHash","test","padStart"],"sources":["../../src/helpers/fix-strip-f884s.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 createDebugLogger from 'debug';\n//import {sortFieldsBySubfieldValue, removeSubfield} from './fix-utils';\nimport {inspect} from 'util';\n\nexport function stripF884s(newRecord, options) {\n const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fixRecord:stripF884s');\n const debugData = debug.extend('data');\n\n if (options !== true) {\n debug(`NOT running stripF884s fixer, no options`);\n return newRecord;\n }\n\n debug(`Running stripF884s fixer`);\n debugData(`Options for stripF884s: ${JSON.stringify(options)}`);\n\n // Handle only f884 with $5 MELINDA - let's no remove random f884s\n const isMelindaf884 = f => f.tag === '884' && f.subfields.some(({code, value}) => code === '5' && value === 'MELINDA');\n\n const f884Melindas = newRecord.fields.filter(isMelindaf884);\n debugData(`Melinda's f884s (${f884Melindas.length}) \\n ${JSON.stringify(f884Melindas)}`);\n //debugData(`Melinda's f884s (${f884Melindas.length}) \\n ${inspect(f884Melindas, {depth: 3})}`);\n\n if (f884Melindas.length < 2) {\n debug(`Not enough Melinda's f884s to filter (${f884Melindas.length})`);\n return newRecord;\n }\n\n // Pick data (firstDate, lastDate, hash with latest date) for all conversion : source combinations\n const results = f884Melindas.reduce((allResults, f884, index) => {\n debugData(`All results: ${JSON.stringify(allResults)}`);\n //debugData(`Handling field (${index}): ${inspect(f884, {depth: 3})}`);\n debugData(`Handling field *(${index})*: ${JSON.stringify(f884)}`);\n\n const conversion = findConversion(f884);\n const source = findSource(f884);\n const convSource = `${conversion}:${source}`;\n const {firstDate, lastDate} = findDates(f884);\n const hash = findHash(f884);\n\n // Find currently existing data for conversion : source combination\n const currResult = allResults[convSource];\n debugData(JSON.stringify(currResult));\n\n // If we do not have any current data, add data from field\n if (!currResult) {\n debug(`Add a new convSource ${convSource} to results`);\n const newResult = {\n conversion,\n source,\n firstDate,\n lastDate,\n hash\n };\n debugData(`- New result: ${JSON.stringify(newResult)}`);\n return {\n ...allResults,\n [convSource]: newResult\n };\n }\n // If we have current data, update it from the data from field, if needed\n debug(`Update result for ${convSource}`);\n debugData(`- Current result: ${JSON.stringify(currResult)}`);\n\n const updatedResult = {\n ...currResult,\n firstDate: currResult.firstDate > firstDate && firstDate !== '00000000' ? firstDate : currResult.firstDate,\n lastDate: currResult.lastDate < lastDate ? lastDate : currResult.lastDate,\n hash: currResult.lastDate < lastDate && lastDate !== '00000000' && hash !== '0000000000000000000000000000000000000000000000000000000000000000' ? hash : currResult.hash\n };\n debugData(`- Updated result: ${JSON.stringify(updatedResult)}`);\n return {\n ...allResults,\n [convSource]: updatedResult\n };\n }, {});\n\n debugData(`RESULTS: ${JSON.stringify(results)}`);\n const editedf884s = editFields(f884Melindas, results);\n\n debug(`Edited fields (${editedf884s.length})`);\n //debugData(inspect(editedf884s, {depth: 3}));\n debugData(`${JSON.stringify(editedf884s)}`);\n\n // We update each field based on the results we got from fields\n // Note: we do not add $g:s or $k:s if the field doesn't have them\n function editFields(fields, results) {\n debug(`EDITING FIELDS (${fields.length})`);\n const editedFields = fields.map((field) => {\n const convSource = `${findConversion(field)}:${findSource(field)}`;\n debug(`Looking for: ${convSource}`);\n\n if (convSource && results[convSource]) {\n debugData(`Found: ${JSON.stringify(results[convSource])}`);\n const firstDate = results[convSource].firstDate && results[convSource].firstDate !== '00000000' ? results[convSource].firstDate : '';\n const lastDate = results[convSource].lastDate && results[convSource].lastDate !== '00000000' ? results[convSource].lastDate : '';\n\n const source = results[convSource].source && results[convSource].source !== 'NO_SOURCE' ? results[convSource].source : '';\n const hash = results[convSource].hash && results[convSource].hash !== '0000000000000000000000000000000000000000000000000000000000000000' ? results[convSource].hash : '';\n\n const sfGAll = firstDate === lastDate ? `${firstDate}` : `${firstDate} - ${lastDate}`;\n debugData(`EditedDates: ${sfGAll}`);\n const sfKAll = `${source}:${hash}`;\n\n const sfG = sfGAll.replace(/^ - /u, '').replace(/ - $/u, '');\n const sfK = sfKAll.replace(/^:/u, '').replace(/:$/u, '');\n\n return {\n ...field,\n subfields: field.subfields.map(subfield => {\n\n // we don't get $g or $k if the original field doesn't have them\n if (subfield.code === 'g') {\n return {\n code: subfield.code,\n value: sfG\n };\n }\n\n if (subfield.code === 'k') {\n return {\n code: subfield.code,\n value: sfK\n };\n }\n\n return subfield;\n })\n\n };\n }\n debug(`Not found: ${convSource}`);\n return field;\n });\n return editedFields;\n }\n\n // we'll need to uniq these too\n\n const uniq884s = uniqFields(editedf884s);\n debug(`UniqFields (${uniq884s.length})`);\n debugData(inspect(uniq884s, {depth: 3}));\n\n\n function uniqFields(fields) {\n return fields.reduce((uniq, field) => {\n if (!uniq.some(f => MarcRecord.isEqual(f, field))) { // eslint-disable-line functional/no-conditional-statements\n uniq.push(field); // eslint-disable-line functional/immutable-data\n }\n\n return uniq;\n }, []);\n }\n // Replace original Melinda-f884s with remaining Melinda-f884s\n // NOTE: this sorts MELINDA-f884s after possible other f884s\n newRecord.removeFields(f884Melindas);\n newRecord.insertFields(uniq884s);\n\n return newRecord;\n\n\n // Find conversion:source pairs\n // Find first date\n // Find last date and last hash\n\n\n function findConversion(f884) {\n const [sfA] = f884.subfields.filter((subfield) => subfield.code === 'a').map(subfield => subfield.value);\n const conversion = sfA;\n debugData(`Conversion: \"${conversion}\"`);\n return conversion;\n }\n\n function findSource(f884) {\n const [sfK] = f884.subfields.filter((subfield) => subfield.code === 'k').map(subfield => subfield.value);\n const source = sfK.replace(/:.*$/u, '');\n if (source && source.length !== 64) {\n debugData(`Source: \"${source}\"`);\n return source;\n }\n const emptySource = 'NO_SOURCE';\n debugData(`Source: \"${emptySource}\"`);\n return emptySource;\n }\n\n function findHash(f884) {\n const [sfK] = f884.subfields.filter((subfield) => subfield.code === 'k').map(subfield => subfield.value);\n const hash = sfK.replace(/^.*:/u, '');\n if (hash && hash.length === 64) {\n debugData(`Hash: \"${hash}\"`);\n return hash;\n }\n const emptyHash = '0000000000000000000000000000000000000000000000000000000000000000';\n debugData(`Hash: \"${emptyHash}\"`);\n return emptyHash;\n }\n\n function findDates(f884) {\n const [sfG] = f884.subfields.filter((subfield) => subfield.code === 'g').map(subfield => subfield.value);\n if (sfG && (/ - /u).test(sfG)) {\n const firstDate = sfG.replace(/ - .*$/u, '').padStart(8, '0');\n const lastDate = sfG.replace(/^.* - /u, '').padStart(8, '0');\n debugData(`FirstDate: \"${firstDate}\", LastDate: \"${lastDate}\"`);\n return {firstDate, lastDate};\n }\n const firstDate = sfG ? sfG.padStart(8, '0') : '00000000';\n const lastDate = sfG ? sfG.padStart(8, '0') : '00000000';\n\n debugData(`FirstDate: \"${firstDate}\", LastDate: \"${lastDate}\"`);\n return {firstDate, lastDate};\n }\n\n}\n"],"mappings":";;;;;;;AA4BA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AA/BA;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;;AAIA;;AAGO,SAASI,UAAUA,CAACC,SAAS,EAAEC,OAAO,EAAE;EAC7C,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,yDAAyD,CAAC;EAC1F,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;EAEtC,IAAIJ,OAAO,KAAK,IAAI,EAAE;IACpBC,KAAK,CAAE,0CAAyC,CAAC;IACjD,OAAOF,SAAS;EAClB;EAEAE,KAAK,CAAE,0BAAyB,CAAC;EACjCE,SAAS,CAAE,2BAA0BE,IAAI,CAACC,SAAS,CAACN,OAAO,CAAE,EAAC,CAAC;;EAE/D;EACA,MAAMO,aAAa,GAAGC,CAAC,IAAIA,CAAC,CAACC,GAAG,KAAK,KAAK,IAAID,CAAC,CAACE,SAAS,CAACC,IAAI,CAAC,CAAC;IAACC,IAAI;IAAEC;EAAK,CAAC,KAAKD,IAAI,KAAK,GAAG,IAAIC,KAAK,KAAK,SAAS,CAAC;EAEtH,MAAMC,YAAY,GAAGf,SAAS,CAACgB,MAAM,CAACC,MAAM,CAACT,aAAa,CAAC;EAC3DJ,SAAS,CAAE,oBAAmBW,YAAY,CAACG,MAAO,QAAOZ,IAAI,CAACC,SAAS,CAACQ,YAAY,CAAE,EAAC,CAAC;EACxF;;EAEA,IAAIA,YAAY,CAACG,MAAM,GAAG,CAAC,EAAE;IAC3BhB,KAAK,CAAE,yCAAwCa,YAAY,CAACG,MA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CAAC;EAC9B;AAEF"}
1
+ {"version":3,"file":"fix-strip-f884s.js","names":["_marcRecord","require","_debug","_interopRequireDefault","_util","stripF884s","newRecord","options","debug","createDebugLogger","debugData","extend","JSON","stringify","isMelindaf884","f","tag","subfields","some","code","value","f884Melindas","fields","filter","length","results","reduce","allResults","f884","index","conversion","findConversion","source","findSource","convSource","firstDate","lastDate","findDates","hash","findHash","currResult","newResult","updatedResult","editedf884s","editFields","editedFields","map","field","sfGAll","sfKAll","sfG","replace","sfK","subfield","uniq884s","uniqFields","inspect","depth","uniq","MarcRecord","isEqual","push","removeFields","insertFields","sfA","emptySource","emptyHash","test","padStart"],"sources":["../../src/helpers/fix-strip-f884s.js"],"sourcesContent":["import {MarcRecord} from '@natlibfi/marc-record';\nimport createDebugLogger from 'debug';\n//import {sortFieldsBySubfieldValue, removeSubfield} from './fix-utils';\nimport {inspect} from 'util';\n\nexport function stripF884s(newRecord, options) {\n const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fixRecord:stripF884s');\n const debugData = debug.extend('data');\n\n if (options !== true) {\n debug(`NOT running stripF884s fixer, no options`);\n return newRecord;\n }\n\n debug(`Running stripF884s fixer`);\n debugData(`Options for stripF884s: ${JSON.stringify(options)}`);\n\n // Handle only f884 with $5 MELINDA - let's no remove random f884s\n const isMelindaf884 = f => f.tag === '884' && f.subfields.some(({code, value}) => code === '5' && value === 'MELINDA');\n\n const f884Melindas = newRecord.fields.filter(isMelindaf884);\n debugData(`Melinda's f884s (${f884Melindas.length}) \\n ${JSON.stringify(f884Melindas)}`);\n //debugData(`Melinda's f884s (${f884Melindas.length}) \\n ${inspect(f884Melindas, {depth: 3})}`);\n\n if (f884Melindas.length < 2) {\n debug(`Not enough Melinda's f884s to filter (${f884Melindas.length})`);\n return newRecord;\n }\n\n // Pick data (firstDate, lastDate, hash with latest date) for all conversion : source combinations\n const results = f884Melindas.reduce((allResults, f884, index) => {\n debugData(`All results: ${JSON.stringify(allResults)}`);\n //debugData(`Handling field (${index}): ${inspect(f884, {depth: 3})}`);\n debugData(`Handling field *(${index})*: ${JSON.stringify(f884)}`);\n\n const conversion = findConversion(f884);\n const source = findSource(f884);\n const convSource = `${conversion}:${source}`;\n const {firstDate, lastDate} = findDates(f884);\n const hash = findHash(f884);\n\n // Find currently existing data for conversion : source combination\n const currResult = allResults[convSource];\n debugData(JSON.stringify(currResult));\n\n // If we do not have any current data, add data from field\n if (!currResult) {\n debug(`Add a new convSource ${convSource} to results`);\n const newResult = {\n conversion,\n source,\n firstDate,\n lastDate,\n hash\n };\n debugData(`- New result: ${JSON.stringify(newResult)}`);\n return {\n ...allResults,\n [convSource]: newResult\n };\n }\n // If we have current data, update it from the data from field, if needed\n debug(`Update result for ${convSource}`);\n debugData(`- Current result: ${JSON.stringify(currResult)}`);\n\n const updatedResult = {\n ...currResult,\n firstDate: currResult.firstDate > firstDate && firstDate !== '00000000' ? firstDate : currResult.firstDate,\n lastDate: currResult.lastDate < lastDate ? lastDate : currResult.lastDate,\n hash: currResult.lastDate < lastDate && lastDate !== '00000000' && hash !== '0000000000000000000000000000000000000000000000000000000000000000' ? hash : currResult.hash\n };\n debugData(`- Updated result: ${JSON.stringify(updatedResult)}`);\n return {\n ...allResults,\n [convSource]: updatedResult\n };\n }, {});\n\n debugData(`RESULTS: ${JSON.stringify(results)}`);\n const editedf884s = editFields(f884Melindas, results);\n\n debug(`Edited fields (${editedf884s.length})`);\n //debugData(inspect(editedf884s, {depth: 3}));\n debugData(`${JSON.stringify(editedf884s)}`);\n\n // We update each field based on the results we got from fields\n // Note: we do not add $g:s or $k:s if the field doesn't have them\n function editFields(fields, results) {\n debug(`EDITING FIELDS (${fields.length})`);\n const editedFields = fields.map((field) => {\n const convSource = `${findConversion(field)}:${findSource(field)}`;\n debug(`Looking for: ${convSource}`);\n\n if (convSource && results[convSource]) {\n debugData(`Found: ${JSON.stringify(results[convSource])}`);\n const firstDate = results[convSource].firstDate && results[convSource].firstDate !== '00000000' ? results[convSource].firstDate : '';\n const lastDate = results[convSource].lastDate && results[convSource].lastDate !== '00000000' ? results[convSource].lastDate : '';\n\n const source = results[convSource].source && results[convSource].source !== 'NO_SOURCE' ? results[convSource].source : '';\n const hash = results[convSource].hash && results[convSource].hash !== '0000000000000000000000000000000000000000000000000000000000000000' ? results[convSource].hash : '';\n\n const sfGAll = firstDate === lastDate ? `${firstDate}` : `${firstDate} - ${lastDate}`;\n debugData(`EditedDates: ${sfGAll}`);\n const sfKAll = `${source}:${hash}`;\n\n const sfG = sfGAll.replace(/^ - /u, '').replace(/ - $/u, '');\n const sfK = sfKAll.replace(/^:/u, '').replace(/:$/u, '');\n\n return {\n ...field,\n subfields: field.subfields.map(subfield => {\n\n // we don't get $g or $k if the original field doesn't have them\n if (subfield.code === 'g') {\n return {\n code: subfield.code,\n value: sfG\n };\n }\n\n if (subfield.code === 'k') {\n return {\n code: subfield.code,\n value: sfK\n };\n }\n\n return subfield;\n })\n\n };\n }\n debug(`Not found: ${convSource}`);\n return field;\n });\n return editedFields;\n }\n\n // we'll need to uniq these too\n\n const uniq884s = uniqFields(editedf884s);\n debug(`UniqFields (${uniq884s.length})`);\n debugData(inspect(uniq884s, {depth: 3}));\n\n\n function uniqFields(fields) {\n return fields.reduce((uniq, field) => {\n if (!uniq.some(f => MarcRecord.isEqual(f, field))) { // eslint-disable-line functional/no-conditional-statements\n uniq.push(field); // eslint-disable-line functional/immutable-data\n }\n\n return uniq;\n }, []);\n }\n // Replace original Melinda-f884s with remaining Melinda-f884s\n // NOTE: this sorts MELINDA-f884s after possible other f884s\n newRecord.removeFields(f884Melindas);\n newRecord.insertFields(uniq884s);\n\n return newRecord;\n\n\n // Find conversion:source pairs\n // Find first date\n // Find last date and last hash\n\n\n function findConversion(f884) {\n const [sfA] = f884.subfields.filter((subfield) => subfield.code === 'a').map(subfield => subfield.value);\n const conversion = sfA;\n debugData(`Conversion: \"${conversion}\"`);\n return conversion;\n }\n\n function findSource(f884) {\n const [sfK] = f884.subfields.filter((subfield) => subfield.code === 'k').map(subfield => subfield.value);\n const source = sfK.replace(/:.*$/u, '');\n if (source && source.length !== 64) {\n debugData(`Source: \"${source}\"`);\n return source;\n }\n const emptySource = 'NO_SOURCE';\n debugData(`Source: \"${emptySource}\"`);\n return emptySource;\n }\n\n function findHash(f884) {\n const [sfK] = f884.subfields.filter((subfield) => subfield.code === 'k').map(subfield => subfield.value);\n const hash = sfK.replace(/^.*:/u, '');\n if (hash && hash.length === 64) {\n debugData(`Hash: \"${hash}\"`);\n return hash;\n }\n const emptyHash = '0000000000000000000000000000000000000000000000000000000000000000';\n debugData(`Hash: \"${emptyHash}\"`);\n return emptyHash;\n }\n\n function findDates(f884) {\n const [sfG] = f884.subfields.filter((subfield) => subfield.code === 'g').map(subfield => subfield.value);\n if (sfG && (/ - /u).test(sfG)) {\n const firstDate = sfG.replace(/ - .*$/u, '').padStart(8, '0');\n const lastDate = sfG.replace(/^.* - /u, '').padStart(8, '0');\n debugData(`FirstDate: \"${firstDate}\", LastDate: \"${lastDate}\"`);\n return {firstDate, lastDate};\n }\n const firstDate = sfG ? sfG.padStart(8, '0') : '00000000';\n const lastDate = sfG ? sfG.padStart(8, '0') : '00000000';\n\n debugData(`FirstDate: \"${firstDate}\", LastDate: \"${lastDate}\"`);\n return {firstDate, lastDate};\n }\n\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AADA;;AAGO,SAASI,UAAUA,CAACC,SAAS,EAAEC,OAAO,EAAE;EAC7C,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,yDAAyD,CAAC;EAC1F,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;EAEtC,IAAIJ,OAAO,KAAK,IAAI,EAAE;IACpBC,KAAK,CAAE,0CAAyC,CAAC;IACjD,OAAOF,SAAS;EAClB;EAEAE,KAAK,CAAE,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AACiB,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;MAC7D,MAAMhC,QAAQ,GAAGc,GAAG,CAACC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAACiB,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;MAC5D1D,SAAS,CAAE,eAAcyB,SAAU,iBAAgBC,QAAS,GAAE,CAAC;MAC/D,OAAO;QAACD,SAAS;QAAEC;MAAQ,CAAC;IAC9B;IACA,MAAMD,SAAS,GAAGe,GAAG,GAAGA,GAAG,CAACkB,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,UAAU;IACzD,MAAMhC,QAAQ,GAAGc,GAAG,GAAGA,GAAG,CAACkB,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,UAAU;IAExD1D,SAAS,CAAE,eAAcyB,SAAU,iBAAgBC,QAAS,GAAE,CAAC;IAC/D,OAAO;MAACD,SAAS;MAAEC;IAAQ,CAAC;EAC9B;AAEF"}
@@ -5,34 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.removeSubfield = removeSubfield;
7
7
  exports.sortFieldsBySubfieldValue = sortFieldsBySubfieldValue;
8
- /**
9
- *
10
- * @licstart The following is the entire license notice for the JavaScript code in this file.
11
- *
12
- * Shared modules for microservices of Melinda rest api batch import system
13
- *
14
- * Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
15
- *
16
- * This file is part of melinda-rest-api-commons
17
- *
18
- * melinda-rest-api-commons program is free software: you can redistribute it and/or modify
19
- * it under the terms of the GNU Affero General Public License as
20
- * published by the Free Software Foundation, either version 3 of the
21
- * License, or (at your option) any later version.
22
- *
23
- * melinda-rest-api-commons is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU Affero General Public License for more details.
27
- *
28
- * You should have received a copy of the GNU Affero General Public License
29
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
30
- *
31
- * @licend The above is the entire license notice
32
- * for the JavaScript code in this file.
33
- *
34
- */
35
-
36
8
  function removeSubfield(field, code) {
37
9
  // Handle non-numeric fields, and fields with a numeric tag of 010 and greater
38
10
  // Aleph's FMT as a controlfield might be a problem
@@ -1 +1 @@
1
- {"version":3,"file":"fix-utils.js","names":["removeSubfield","field","code","isNaN","tag","parseInt","filteredSubfields","subfields","filter","sf","length","ind1","ind2","sortFieldsBySubfieldValue","fields","subfieldCode","sort","a","b","a1value","getFirstSubfieldValue","b1value","subs","subf","value"],"sources":["../../src/helpers/fix-utils.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\nexport function removeSubfield(field, code) {\n\n // Handle non-numeric fields, and fields with a numeric tag of 010 and greater\n // Aleph's FMT as a controlfield might be a problem\n if (!isNaN(field.tag) && parseInt(field.tag, 10) >= 10) {\n\n const filteredSubfields = field.subfields.filter(sf => sf.code !== code);\n\n // Remove whole field if there are no subfields left\n if (filteredSubfields.length < 1) {\n return false;\n }\n\n return {\n tag: field.tag,\n ind1: field.ind1,\n ind2: field.ind2,\n subfields: filteredSubfields\n };\n }\n // return controlFields as is\n return field;\n}\n\n\n// sort fields by value of each fields first subfield with subfielCode\nexport function sortFieldsBySubfieldValue(fields, subfieldCode) {\n return [...fields].sort((a, b) => {\n const a1value = getFirstSubfieldValue(a, subfieldCode);\n const b1value = getFirstSubfieldValue(b, subfieldCode);\n if (a1value && !b1value) {\n return -1;\n }\n if (!a1value && b1value) {\n return 1;\n }\n if (a1value > b1value) {\n return 1;\n }\n if (b1value > a1value) {\n return -1;\n }\n return 0;\n });\n // get value for the for instance of subfield with subfieldCode\n function getFirstSubfieldValue(field, subfieldCode) {\n const subs = field.subfields ? field.subfields.filter(subf => subf.code === subfieldCode) : [];\n return subs.length > 0 ? subs[0].value : '';\n }\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;;AAEO,SAASA,cAAcA,CAACC,KAAK,EAAEC,IAAI,EAAE;EAE1C;EACA;EACA,IAAI,CAACC,KAAK,CAACF,KAAK,CAACG,GAAG,CAAC,IAAIC,QAAQ,CAACJ,KAAK,CAACG,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;IAEtD,MAAME,iBAAiB,GAAGL,KAAK,CAACM,SAAS,CAACC,MAAM,CAACC,EAAE,IAAIA,EAAE,CAACP,IAAI,KAAKA,IAAI,CAAC;;IAExE;IACA,IAAII,iBAAiB,CAACI,MAAM,GAAG,CAAC,EAAE;MAChC,OAAO,KAAK;IACd;IAEA,OAAO;MACLN,GAAG,EAAEH,KAAK,CAACG,GAAG;MACdO,IAAI,EAAEV,KAAK,CAACU,IAAI;MAChBC,IAAI,EAAEX,KAAK,CAACW,IAAI;MAChBL,SAAS,EAAED;IACb,CAAC;EACH;EACA;EACA,OAAOL,KAAK;AACd;;AAGA;AACO,SAASY,yBAAyBA,CAACC,MAAM,EAAEC,YAAY,EAAE;EAC9D,OAAO,CAAC,GAAGD,MAAM,CAAC,CAACE,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IAChC,MAAMC,OAAO,GAAGC,qBAAqB,CAACH,CAAC,EAAEF,YAAY,CAAC;IACtD,MAAMM,OAAO,GAAGD,qBAAqB,CAACF,CAAC,EAAEH,YAAY,CAAC;IACtD,IAAII,OAAO,IAAI,CAACE,OAAO,EAAE;MACvB,OAAO,CAAC,CAAC;IACX;IACA,IAAI,CAACF,OAAO,IAAIE,OAAO,EAAE;MACvB,OAAO,CAAC;IACV;IACA,IAAIF,OAAO,GAAGE,OAAO,EAAE;MACrB,OAAO,CAAC;IACV;IACA,IAAIA,OAAO,GAAGF,OAAO,EAAE;MACrB,OAAO,CAAC,CAAC;IACX;IACA,OAAO,CAAC;EACV,CAAC,CAAC;EACF;EACA,SAASC,qBAAqBA,CAACnB,KAAK,EAAEc,YAAY,EAAE;IAClD,MAAMO,IAAI,GAAGrB,KAAK,CAACM,SAAS,GAAGN,KAAK,CAACM,SAAS,CAACC,MAAM,CAACe,IAAI,IAAIA,IAAI,CAACrB,IAAI,KAAKa,YAAY,CAAC,GAAG,EAAE;IAC9F,OAAOO,IAAI,CAACZ,MAAM,GAAG,CAAC,GAAGY,IAAI,CAAC,CAAC,CAAC,CAACE,KAAK,GAAG,EAAE;EAC7C;AACF"}
1
+ {"version":3,"file":"fix-utils.js","names":["removeSubfield","field","code","isNaN","tag","parseInt","filteredSubfields","subfields","filter","sf","length","ind1","ind2","sortFieldsBySubfieldValue","fields","subfieldCode","sort","a","b","a1value","getFirstSubfieldValue","b1value","subs","subf","value"],"sources":["../../src/helpers/fix-utils.js"],"sourcesContent":["\n\nexport function removeSubfield(field, code) {\n\n // Handle non-numeric fields, and fields with a numeric tag of 010 and greater\n // Aleph's FMT as a controlfield might be a problem\n if (!isNaN(field.tag) && parseInt(field.tag, 10) >= 10) {\n\n const filteredSubfields = field.subfields.filter(sf => sf.code !== code);\n\n // Remove whole field if there are no subfields left\n if (filteredSubfields.length < 1) {\n return false;\n }\n\n return {\n tag: field.tag,\n ind1: field.ind1,\n ind2: field.ind2,\n subfields: filteredSubfields\n };\n }\n // return controlFields as is\n return field;\n}\n\n\n// sort fields by value of each fields first subfield with subfielCode\nexport function sortFieldsBySubfieldValue(fields, subfieldCode) {\n return [...fields].sort((a, b) => {\n const a1value = getFirstSubfieldValue(a, subfieldCode);\n const b1value = getFirstSubfieldValue(b, subfieldCode);\n if (a1value && !b1value) {\n return -1;\n }\n if (!a1value && b1value) {\n return 1;\n }\n if (a1value > b1value) {\n return 1;\n }\n if (b1value > a1value) {\n return -1;\n }\n return 0;\n });\n // get value for the for instance of subfield with subfieldCode\n function getFirstSubfieldValue(field, subfieldCode) {\n const subs = field.subfields ? field.subfields.filter(subf => subf.code === subfieldCode) : [];\n return subs.length > 0 ? subs[0].value : '';\n }\n}\n"],"mappings":";;;;;;;AAEO,SAASA,cAAcA,CAACC,KAAK,EAAEC,IAAI,EAAE;EAE1C;EACA;EACA,IAAI,CAACC,KAAK,CAACF,KAAK,CAACG,GAAG,CAAC,IAAIC,QAAQ,CAACJ,KAAK,CAACG,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;IAEtD,MAAME,iBAAiB,GAAGL,KAAK,CAACM,SAAS,CAACC,MAAM,CAACC,EAAE,IAAIA,EAAE,CAACP,IAAI,KAAKA,IAAI,CAAC;;IAExE;IACA,IAAII,iBAAiB,CAACI,MAAM,GAAG,CAAC,EAAE;MAChC,OAAO,KAAK;IACd;IAEA,OAAO;MACLN,GAAG,EAAEH,KAAK,CAACG,GAAG;MACdO,IAAI,EAAEV,KAAK,CAACU,IAAI;MAChBC,IAAI,EAAEX,KAAK,CAACW,IAAI;MAChBL,SAAS,EAAED;IACb,CAAC;EACH;EACA;EACA,OAAOL,KAAK;AACd;;AAGA;AACO,SAASY,yBAAyBA,CAACC,MAAM,EAAEC,YAAY,EAAE;EAC9D,OAAO,CAAC,GAAGD,MAAM,CAAC,CAACE,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IAChC,MAAMC,OAAO,GAAGC,qBAAqB,CAACH,CAAC,EAAEF,YAAY,CAAC;IACtD,MAAMM,OAAO,GAAGD,qBAAqB,CAACF,CAAC,EAAEH,YAAY,CAAC;IACtD,IAAII,OAAO,IAAI,CAACE,OAAO,EAAE;MACvB,OAAO,CAAC,CAAC;IACX;IACA,IAAI,CAACF,OAAO,IAAIE,OAAO,EAAE;MACvB,OAAO,CAAC;IACV;IACA,IAAIF,OAAO,GAAGE,OAAO,EAAE;MACrB,OAAO,CAAC;IACV;IACA,IAAIA,OAAO,GAAGF,OAAO,EAAE;MACrB,OAAO,CAAC,CAAC;IACX;IACA,OAAO,CAAC;EACV,CAAC,CAAC;EACF;EACA,SAASC,qBAAqBA,CAACnB,KAAK,EAAEc,YAAY,EAAE;IAClD,MAAMO,IAAI,GAAGrB,KAAK,CAACM,SAAS,GAAGN,KAAK,CAACM,SAAS,CAACC,MAAM,CAACe,IAAI,IAAIA,IAAI,CAACrB,IAAI,KAAKa,YAAY,CAAC,GAAG,EAAE;IAC9F,OAAOO,IAAI,CAACZ,MAAM,GAAG,CAAC,GAAGY,IAAI,CAAC,CAAC,CAAC,CAACE,KAAK,GAAG,EAAE;EAC7C;AACF"}
@@ -26,34 +26,6 @@ Object.keys(_fixConstants).forEach(function (key) {
26
26
  }
27
27
  });
28
28
  });
29
- /**
30
- *
31
- * @licstart The following is the entire license notice for the JavaScript code in this file.
32
- *
33
- * Shared modules for microservices of Melinda rest api batch import system
34
- *
35
- * Copyright (C) 2020-2024 University Of Helsinki (The National Library Of Finland)
36
- *
37
- * This file is part of melinda-rest-api-commons
38
- *
39
- * melinda-rest-api-commons program is free software: you can redistribute it and/or modify
40
- * it under the terms of the GNU Affero General Public License as
41
- * published by the Free Software Foundation, either version 3 of the
42
- * License, or (at your option) any later version.
43
- *
44
- * melinda-rest-api-commons is distributed in the hope that it will be useful,
45
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47
- * GNU Affero General Public License for more details.
48
- *
49
- * You should have received a copy of the GNU Affero General Public License
50
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
51
- *
52
- * @licend The above is the entire license notice
53
- * for the JavaScript code in this file.
54
- *
55
- */
56
-
57
29
  const logger = (0, _melindaBackendCommons.createLogger)();
58
30
  const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:fixRecord');
59
31
  const debugData = debug.extend('data');
@@ -1 +1 @@
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","config","toString","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-2024 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 984s\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 const config = [\n {\n tag: /^984$/u,\n subfields: [\n {\n code: /a/u,\n value: F984A_PATTERN\n }\n ]\n }\n ];\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 // 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;AAEA,IAAAI,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kB,EAAE;EAC9C,MAAMC,aAAa,GAAG,qCAAqC;EAC3D,MAAMC,MAAM,GAAG,CACb;IACEd,GAAG,EAAE,QAAQ;IACbvB,SAAS,EAAE,CACT;MACEE,IAAI,EAAE,IAAI;MACVG,KAAK,EAAE+B;IACT,CAAC;EAEL,CAAC,CACF;EAED3E,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,CAACE,QAAQ,CAAC,CAAE,EAAC,CAAC;EAC5F;EACA,MAAMC,SAAS,GAAG,IAAAC,2CAAc,EAACH,MAAM,CAAC;EACxCE,SAAS,CAACE,GAAG,CAAC3E,MAAM,CAAC;EACrB,OAAOA,MAAM;AAEf"}
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","config","toString","validator","FieldExclusion","fix"],"sources":["../../src/helpers/fix.js"],"sourcesContent":["import {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 984s\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 const config = [\n {\n tag: /^984$/u,\n subfields: [\n {\n code: /a/u,\n value: F984A_PATTERN\n }\n ]\n }\n ];\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 // eslint-disable-next-line new-cap\n const validator = FieldExclusion(config);\n validator.fix(record);\n return record;\n\n}\n\n"],"mappings":";;;;;;;;;;AAAA,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,4BAAA,GAAAN,OAAA;AAEA,IAAAO,aAAA,GAAAP,OAAA;AAAAQ,MAAA,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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,CAACE,QAAQ,CAAC,CAAE,EAAC,CAAC;EAC5F;EACA,MAAMC,SAAS,GAAG,IAAAC,2CAAc,EAACH,MAAM,CAAC;EACxCE,SAAS,CAACE,GAAG,CAAC3E,MAAM,CAAC;EACrB,OAAOA,MAAM;AAEf"}
@@ -8,33 +8,6 @@ exports.default = void 0;
8
8
  var _marcRecordValidate = _interopRequireDefault(require("@natlibfi/marc-record-validate"));
9
9
  var _marcRecordValidatorsMelinda = require("@natlibfi/marc-record-validators-melinda");
10
10
  var _melindaBackendCommons = require("@natlibfi/melinda-backend-commons");
11
- /**
12
- *
13
- * @licstart The following is the entire license notice for the JavaScript code in this file.
14
- *
15
- * Shared modules for microservices of Melinda rest api batch import system
16
- *
17
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
18
- *
19
- * This file is part of melinda-rest-api-commons
20
- *
21
- * melinda-rest-api-commons program is free software: you can redistribute it and/or modify
22
- * it under the terms of the GNU Affero General Public License as
23
- * published by the Free Software Foundation, either version 3 of the
24
- * License, or (at your option) any later version.
25
- *
26
- * melinda-rest-api-commons is distributed in the hope that it will be useful,
27
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
- * GNU Affero General Public License for more details.
30
- *
31
- * You should have received a copy of the GNU Affero General Public License
32
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
33
- *
34
- * @licend The above is the entire license notice
35
- * for the JavaScript code in this file.
36
- *
37
- */
38
11
  var _default = async () => {
39
12
  const logger = (0, _melindaBackendCommons.createLogger)();
40
13
  logger.verbose('Running inbuilt record validations');
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","names":["_marcRecordValidate","_interopRequireDefault","require","_marcRecordValidatorsMelinda","_melindaBackendCommons","_default","logger","createLogger","verbose","validate","validateFactory","fieldStructure","tag","valuePattern","unvalidRecord","record","valid","report","fix","validateFixes","subfieldValues","failed","messages","exports","default"],"sources":["../../src/helpers/validation.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 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 validateFactory from '@natlibfi/marc-record-validate';\nimport {\n FieldStructure as fieldStructure\n} from '@natlibfi/marc-record-validators-melinda';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\n\nexport default async () => {\n const logger = createLogger();\n\n logger.verbose('Running inbuilt record validations');\n const validate = validateFactory([await fieldStructure([{tag: /^003$/u, valuePattern: /^FI-MELINDA$/u}])]);\n\n return async unvalidRecord => {\n const {record, valid, report} = await validate(unvalidRecord, {fix: false, validateFixes: false}, {subfieldValues: false});\n\n return {\n record,\n failed: valid === false,\n messages: report\n };\n };\n};\n"],"mappings":";;;;;;;AA4BA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,4BAAA,GAAAD,OAAA;AAGA,IAAAE,sBAAA,GAAAF,OAAA;AAhCA;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;AA1BA,IAAAG,QAAA,GAkCe,MAAAA,CAAA,KAAY;EACzB,MAAMC,MAAM,GAAG,IAAAC,mCAAY,EAAC,CAAC;EAE7BD,MAAM,CAACE,OAAO,CAAC,oCAAoC,CAAC;EACpD,MAAMC,QAAQ,GAAG,IAAAC,2BAAe,EAAC,CAAC,MAAM,IAAAC,2CAAc,EAAC,CAAC;IAACC,GAAG,EAAE,QAAQ;IAAEC,YAAY,EAAE;EAAe,CAAC,CAAC,CAAC,CAAC,CAAC;EAE1G,OAAO,MAAMC,aAAa,IAAI;IAC5B,MAAM;MAACC,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAG,MAAMR,QAAQ,CAACK,aAAa,EAAE;MAACI,GAAG,EAAE,KAAK;MAAEC,aAAa,EAAE;IAAK,CAAC,EAAE;MAACC,cAAc,EAAE;IAAK,CAAC,CAAC;IAE1H,OAAO;MACLL,MAAM;MACNM,MAAM,EAAEL,KAAK,KAAK,KAAK;MACvBM,QAAQ,EAAEL;IACZ,CAAC;EACH,CAAC;AACH,CAAC;AAAAM,OAAA,CAAAC,OAAA,GAAAnB,QAAA"}
1
+ {"version":3,"file":"validation.js","names":["_marcRecordValidate","_interopRequireDefault","require","_marcRecordValidatorsMelinda","_melindaBackendCommons","_default","logger","createLogger","verbose","validate","validateFactory","fieldStructure","tag","valuePattern","unvalidRecord","record","valid","report","fix","validateFixes","subfieldValues","failed","messages","exports","default"],"sources":["../../src/helpers/validation.js"],"sourcesContent":["import validateFactory from '@natlibfi/marc-record-validate';\nimport {\n FieldStructure as fieldStructure\n} from '@natlibfi/marc-record-validators-melinda';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\n\nexport default async () => {\n const logger = createLogger();\n\n logger.verbose('Running inbuilt record validations');\n const validate = validateFactory([await fieldStructure([{tag: /^003$/u, valuePattern: /^FI-MELINDA$/u}])]);\n\n return async unvalidRecord => {\n const {record, valid, report} = await validate(unvalidRecord, {fix: false, validateFixes: false}, {subfieldValues: false});\n\n return {\n record,\n failed: valid === false,\n messages: report\n };\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,4BAAA,GAAAD,OAAA;AAGA,IAAAE,sBAAA,GAAAF,OAAA;AAA+D,IAAAG,QAAA,GAEhD,MAAAA,CAAA,KAAY;EACzB,MAAMC,MAAM,GAAG,IAAAC,mCAAY,EAAC,CAAC;EAE7BD,MAAM,CAACE,OAAO,CAAC,oCAAoC,CAAC;EACpD,MAAMC,QAAQ,GAAG,IAAAC,2BAAe,EAAC,CAAC,MAAM,IAAAC,2CAAc,EAAC,CAAC;IAACC,GAAG,EAAE,QAAQ;IAAEC,YAAY,EAAE;EAAe,CAAC,CAAC,CAAC,CAAC,CAAC;EAE1G,OAAO,MAAMC,aAAa,IAAI;IAC5B,MAAM;MAACC,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAG,MAAMR,QAAQ,CAACK,aAAa,EAAE;MAACI,GAAG,EAAE,KAAK;MAAEC,aAAa,EAAE;IAAK,CAAC,EAAE;MAACC,cAAc,EAAE;IAAK,CAAC,CAAC;IAE1H,OAAO;MACLL,MAAM;MACNM,MAAM,EAAEL,KAAK,KAAK,KAAK;MACvBM,QAAQ,EAAEL;IACZ,CAAC;EACH,CAAC;AACH,CAAC;AAAAM,OAAA,CAAAC,OAAA,GAAAnB,QAAA"}
@@ -7,34 +7,6 @@ var _marcRecord = require("@natlibfi/marc-record");
7
7
  var _validation = _interopRequireDefault(require("./validation"));
8
8
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
9
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
- /**
11
- *
12
- * @licstart The following is the entire license notice for the JavaScript code in this file.
13
- *
14
- * Shared modules for microservices of Melinda rest api batch import system
15
- *
16
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
17
- *
18
- * This file is part of melinda-rest-api-commons
19
- *
20
- * melinda-rest-api-commons program is free software: you can redistribute it and/or modify
21
- * it under the terms of the GNU Affero General Public License as
22
- * published by the Free Software Foundation, either version 3 of the
23
- * License, or (at your option) any later version.
24
- *
25
- * melinda-rest-api-commons is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU Affero General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU Affero General Public License
31
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
- *
33
- * @licend The above is the entire license notice
34
- * for the JavaScript code in this file.
35
- *
36
- */
37
-
38
10
  describe('services/validate', () => {
39
11
  const FIXTURES_PATH = [__dirname, '..', '..', 'test-fixtures', 'validation'];
40
12
  const {
@@ -1 +1 @@
1
- {"version":3,"file":"validation.spec.js","names":["_chai","require","_fixura","_interopRequireWildcard","_marcRecord","_validation","_interopRequireDefault","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","describe","FIXTURES_PATH","__dirname","getFixture","fixtureFactory","root","reader","READERS","JSON","it","validator","createValidator","record","MarcRecord","components","result","toObject","expected","expect","to","eql","failed","equal"],"sources":["../../src/helpers/validation.spec.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 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 {expect} from 'chai';\nimport fixtureFactory, {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createValidator from './validation';\n\ndescribe('services/validate', () => {\n const FIXTURES_PATH = [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'validation'\n ];\n const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});\n\n describe('f003-fi-melinda', () => {\n it('Should have failed: false', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(false);\n });\n });\n\n describe('f003-not-fi-melinda', () => {\n it('Should have failed: true', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-not-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-not-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(true);\n });\n });\n});\n\n"],"mappings":";;;AA4BA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA2C,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CA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AAC,qBAAqB,EAAE,MAAM;IACpCS,EAAE,CAAC,0BAA0B,EAAE,YAAY;MACzC,MAAMC,SAAS,GAAG,MAAM,IAAAC,mBAAe,EAAC,CAAC;MACzC,MAAMC,MAAM,GAAG,IAAIC,sBAAU,CAACV,UAAU,CAAC;QACvCW,UAAU,EAAE,CACV,IAAI,EACJ,0BAA0B;MAE9B,CAAC,CAAC,CAAC;MACH,MAAMC,MAAM,GAAG,MAAML,SAAS,CAACE,MAAM,CAACI,QAAQ,CAAC,CAAC,CAAC;MACjD,MAAMC,QAAQ,GAAGd,UAAU,CAAC;QAC1BW,UAAU,EAAE,CACV,KAAK,EACL,0BAA0B;MAE9B,CAAC,CAAC;MACF,IAAAI,YAAM,EAACH,MAAM,CAAC,CAACI,EAAE,CAACC,GAAG,CAACH,QAAQ,CAAC;MAC/B,IAAAC,YAAM,EAACH,MAAM,CAACM,MAAM,CAAC,CAACF,EAAE,CAACG,KAAK,CAAC,IAAI,CAAC;IACtC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"validation.spec.js","names":["_chai","require","_fixura","_interopRequireWildcard","_marcRecord","_validation","_interopRequireDefault","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","describe","FIXTURES_PATH","__dirname","getFixture","fixtureFactory","root","reader","READERS","JSON","it","validator","createValidator","record","MarcRecord","components","result","toObject","expected","expect","to","eql","failed","equal"],"sources":["../../src/helpers/validation.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport fixtureFactory, {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createValidator from './validation';\n\ndescribe('services/validate', () => {\n const FIXTURES_PATH = [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'validation'\n ];\n const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});\n\n describe('f003-fi-melinda', () => {\n it('Should have failed: false', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(false);\n });\n });\n\n describe('f003-not-fi-melinda', () => {\n it('Should have failed: true', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-not-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-not-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(true);\n });\n });\n});\n\n"],"mappings":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA2C,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAA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AC,CAAC;MACF,IAAAI,YAAM,EAACH,MAAM,CAAC,CAACI,EAAE,CAACC,GAAG,CAACH,QAAQ,CAAC;MAC/B,IAAAC,YAAM,EAACH,MAAM,CAACM,MAAM,CAAC,CAACF,EAAE,CAACG,KAAK,CAAC,KAAK,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFtB,QAAQ,CAAC,qBAAqB,EAAE,MAAM;IACpCS,EAAE,CAAC,0BAA0B,EAAE,YAAY;MACzC,MAAMC,SAAS,GAAG,MAAM,IAAAC,mBAAe,EAAC,CAAC;MACzC,MAAMC,MAAM,GAAG,IAAIC,sBAAU,CAACV,UAAU,CAAC;QACvCW,UAAU,EAAE,CACV,IAAI,EACJ,0BAA0B;MAE9B,CAAC,CAAC,CAAC;MACH,MAAMC,MAAM,GAAG,MAAML,SAAS,CAACE,MAAM,CAACI,QAAQ,CAAC,CAAC,CAAC;MACjD,MAAMC,QAAQ,GAAGd,UAAU,CAAC;QAC1BW,UAAU,EAAE,CACV,KAAK,EACL,0BAA0B;MAE9B,CAAC,CAAC;MACF,IAAAI,YAAM,EAACH,MAAM,CAAC,CAACI,EAAE,CAACC,GAAG,CAACH,QAAQ,CAAC;MAC/B,IAAAC,YAAM,EAACH,MAAM,CAACM,MAAM,CAAC,CAACF,EAAE,CAACG,KAAK,CAAC,IAAI,CAAC;IACtC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_mongo","_interopRequireDefault","require","_mongoLog","_amqp","_conversion","_validation","fixes","_interopRequireWildcard","exports","_utils","_constants","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set"],"sources":["../src/index.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-2021 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 mongoFactory from './mongo';\nimport mongoLogFactory from './mongoLog';\nimport amqpFactory from './amqp';\nimport conversions from './helpers/conversion';\nimport validations from './helpers/validation';\nimport * as fixes from './helpers/fix';\nimport {logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem, addRecordResponseItems} from './utils';\n\nexport {mongoFactory, mongoLogFactory, amqpFactory, conversions, validations, fixes, logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem, addRecordResponseItems};\nexport * from './constants';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,KAAA,GAAAC,uBAAA,CAAAN,OAAA;AAAuCO,OAAA,CAAAF,KAAA,GAAAA,KAAA;AACvC,I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,CAAAsB,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAd,GAAA,IAAAc,CAAA,CAAAC,GAAA,IAAAzB,MAAA,CAAAQ,cAAA,CAAAW,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA"}
1
+ {"version":3,"file":"index.js","names":["_mongo","_interopRequireDefault","require","_mongoLog","_amqp","_conversion","_validation","fixes","_interopRequireWildcard","exports","_utils","_constants","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set"],"sources":["../src/index.js"],"sourcesContent":["\n\nimport mongoFactory from './mongo';\nimport mongoLogFactory from './mongoLog';\nimport amqpFactory from './amqp';\nimport conversions from './helpers/conversion';\nimport validations from './helpers/validation';\nimport * as fixes from './helpers/fix';\nimport {logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem, addRecordResponseItems} from './utils';\n\nexport {mongoFactory, mongoLogFactory, amqpFactory, conversions, validations, fixes, logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem, addRecordResponseItems};\nexport * from './constants';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,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AAAX,CAAA,oBAAAW,CAAA,IAAAvB,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAW,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAArB,MAAA,CAAAsB,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAd,GAAA,IAAAc,CAAA,CAAAC,GAAA,IAAAzB,MAAA,CAAAQ,cAAA,CAAAW,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA"}
package/dist/mongo.js CHANGED
@@ -14,33 +14,6 @@ var _moment = _interopRequireDefault(require("moment"));
14
14
  var _httpStatus = _interopRequireDefault(require("http-status"));
15
15
  var _mongoSanitize = _interopRequireDefault(require("mongo-sanitize"));
16
16
  /* eslint-disable max-lines */
17
- /**
18
- *
19
- * @licstart The following is the entire license notice for the JavaScript code in this file.
20
- *
21
- * Shared modules for microservices of Melinda rest api batch import system
22
- *
23
- * Copyright (C) 2020-2023 University Of Helsinki (The National Library Of Finland)
24
- *
25
- * This file is part of melinda-rest-api-commons
26
- *
27
- * melinda-rest-api-commons program is free software: you can redistribute it and/or modify
28
- * it under the terms of the GNU Affero General Public License as
29
- * published by the Free Software Foundation, either version 3 of the
30
- * License, or (at your option) any later version.
31
- *
32
- * melinda-rest-api-commons is distributed in the hope that it will be useful,
33
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
34
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35
- * GNU Affero General Public License for more details.
36
- *
37
- * You should have received a copy of the GNU Affero General Public License
38
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
39
- *
40
- * @licend The above is the entire license notice
41
- * for the JavaScript code in this file.
42
- *
43
- */
44
17
 
45
18
  //import isDeepStrictEqual from 'util';
46
19