@natlibfi/melinda-commons 13.0.4 → 13.0.5-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/error.js CHANGED
@@ -38,8 +38,8 @@ class _default extends Error {
38
38
  params[_key - 2] = arguments[_key];
39
39
  }
40
40
  super(params);
41
- this.status = status; // eslint-disable-line functional/no-this-expression
42
- this.payload = payload; // eslint-disable-line functional/no-this-expression
41
+ this.status = status; // eslint-disable-line functional/no-this-expressions
42
+ this.payload = payload; // eslint-disable-line functional/no-this-expressions
43
43
  }
44
44
  }
45
45
  exports.default = _default;
package/dist/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","names":["_default","Error","constructor","status","payload","_len","arguments","length","params","Array","_key","exports","default"],"sources":["../src/error.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 default class extends Error {\n constructor(status, payload, ...params) {\n super(params);\n this.status = status; // eslint-disable-line functional/no-this-expression\n this.payload = payload; // eslint-disable-line functional/no-this-expression\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;;AAEe,MAAAA,QAAA,SAAcC,KAAK,CAAC;EACjCC,WAAWA,CAACC,MAAM,EAAEC,OAAO,EAAa;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAARC,MAAM,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAANF,MAAM,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;IAAA;IACpC,KAAK,CAACF,MAAM,CAAC;IACb,IAAI,CAACL,MAAM,GAAGA,MAAM,CAAC,CAAC;IACtB,IAAI,CAACC,OAAO,GAAGA,OAAO,CAAC,CAAC;EAC1B;AACF;AAACO,OAAA,CAAAC,OAAA,GAAAZ,QAAA"}
1
+ {"version":3,"file":"error.js","names":["_default","Error","constructor","status","payload","_len","arguments","length","params","Array","_key","exports","default"],"sources":["../src/error.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 default class extends Error {\n constructor(status, payload, ...params) {\n super(params);\n this.status = status; // eslint-disable-line functional/no-this-expressions\n this.payload = payload; // eslint-disable-line functional/no-this-expressions\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;;AAEe,MAAAA,QAAA,SAAcC,KAAK,CAAC;EACjCC,WAAWA,CAACC,MAAM,EAAEC,OAAO,EAAa;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAARC,MAAM,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAANF,MAAM,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;IAAA;IACpC,KAAK,CAACF,MAAM,CAAC;IACb,IAAI,CAACL,MAAM,GAAGA,MAAM,CAAC,CAAC;IACtB,IAAI,CAACC,OAAO,GAAGA,OAAO,CAAC,CAAC;EAC1B;AACF;AAACO,OAAA,CAAAC,OAAA,GAAAZ,QAAA"}
@@ -40,7 +40,7 @@ var _error = require("./error");
40
40
  function createSubrecordPicker(sruUrl) {
41
41
  let retrieveAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
42
42
  if (sruUrl === undefined) {
43
- // eslint-disable-line functional/no-conditional-statement
43
+ // eslint-disable-line functional/no-conditional-statements
44
44
  throw new _error.Error(400, 'Invalid sru url');
45
45
  }
46
46
  const debug = (0, _debug.default)('@natlibfi/melinda-commons:subRecordPicker');
@@ -1 +1 @@
1
- {"version":3,"file":"subRecordPicker.js","names":["_sruClient","_interopRequireDefault","require","_marcRecordSerializers","_debug","_error","createSubrecordPicker","sruUrl","retrieveAll","arguments","length","undefined","ApiError","debug","createDebugLogger","sruClient","createSruClient","url","recordSchema","readSomeSubrecords","readAllSubrecords","recordId","offset","Promise","resolve","reject","promises","searchRetrieve","startRecord","on","xmlString","push","MARCXML","from","subfieldValues","nextRecordOffset","records","all","error","err"],"sources":["../src/subRecordPicker.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 createSruClient from '@natlibfi/sru-client';\nimport {MARCXML} from '@natlibfi/marc-record-serializers';\nimport createDebugLogger from 'debug';\nimport {Error as ApiError} from './error';\n\nexport function createSubrecordPicker(sruUrl, retrieveAll = false) {\n if (sruUrl === undefined) { // eslint-disable-line functional/no-conditional-statement\n throw new ApiError(400, 'Invalid sru url');\n }\n\n const debug = createDebugLogger('@natlibfi/melinda-commons:subRecordPicker');\n debug(`SRU client url: ${sruUrl}`);\n const sruClient = createSruClient({url: sruUrl, recordSchema: 'marcxml', retrieveAll});\n\n return {readSomeSubrecords, readAllSubrecords};\n\n function readSomeSubrecords(recordId, offset = 1) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`, {startRecord: offset})\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async nextRecordOffset => {\n try {\n const records = await Promise.all(promises);\n resolve({nextRecordOffset, records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n\n function readAllSubrecords(recordId) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`)\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async () => {\n try {\n const records = await Promise.all(promises);\n resolve({records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n}\n"],"mappings":";;;;;;;AA4BA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,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;;AAOO,SAASI,qBAAqBA,CAACC,MAAM,EAAuB;EAAA,IAArBC,WAAW,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAC/D,IAAIF,MAAM,KAAKI,SAAS,EAAE;IAAE;IAC1B,MAAM,IAAIC,YAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;EAC5C;EAEA,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,2CAA2C,CAAC;EAC5ED,KAAK,CAAE,mBAAkBN,MAAO,EAAC,CAAC;EAClC,MAAMQ,SAAS,GAAG,IAAAC,kBAAe,EAAC;IAACC,GAAG,EAAEV,MAAM;IAAEW,YAAY,EAAE,SAAS;IAAEV;EAAW,CAAC,CAAC;EAEtF,OAAO;IAACW,kBAAkB;IAAEC;EAAiB,CAAC;EAE9C,SAASD,kBAAkBA,CAACE,QAAQ,EAAc;IAAA,IAAZC,MAAM,GAAAb,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MA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CAAC;MACnE,CAAC,CAAC,CACDL,EAAE,CAAC,KAAK,EAAE,YAAY;QACrB,IAAI;UACF,MAAMO,OAAO,GAAG,MAAMb,OAAO,CAACc,GAAG,CAACX,QAAQ,CAAC;UAC3CF,OAAO,CAAC;YAACY;UAAO,CAAC,CAAC;QACpB,CAAC,CAAC,OAAOE,KAAK,EAAE;UACdb,MAAM,CAACa,KAAK,CAAC;QACf;MACF,CAAC,CAAC,CACDT,EAAE,CAAC,OAAO,EAAEU,GAAG,IAAId,MAAM,CAACc,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC;EACJ;AACF"}
1
+ {"version":3,"file":"subRecordPicker.js","names":["_sruClient","_interopRequireDefault","require","_marcRecordSerializers","_debug","_error","createSubrecordPicker","sruUrl","retrieveAll","arguments","length","undefined","ApiError","debug","createDebugLogger","sruClient","createSruClient","url","recordSchema","readSomeSubrecords","readAllSubrecords","recordId","offset","Promise","resolve","reject","promises","searchRetrieve","startRecord","on","xmlString","push","MARCXML","from","subfieldValues","nextRecordOffset","records","all","error","err"],"sources":["../src/subRecordPicker.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 createSruClient from '@natlibfi/sru-client';\nimport {MARCXML} from '@natlibfi/marc-record-serializers';\nimport createDebugLogger from 'debug';\nimport {Error as ApiError} from './error';\n\nexport function createSubrecordPicker(sruUrl, retrieveAll = false) {\n if (sruUrl === undefined) { // eslint-disable-line functional/no-conditional-statements\n throw new ApiError(400, 'Invalid sru url');\n }\n\n const debug = createDebugLogger('@natlibfi/melinda-commons:subRecordPicker');\n debug(`SRU client url: ${sruUrl}`);\n const sruClient = createSruClient({url: sruUrl, recordSchema: 'marcxml', retrieveAll});\n\n return {readSomeSubrecords, readAllSubrecords};\n\n function readSomeSubrecords(recordId, offset = 1) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`, {startRecord: offset})\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async nextRecordOffset => {\n try {\n const records = await Promise.all(promises);\n resolve({nextRecordOffset, records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n\n function readAllSubrecords(recordId) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`)\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async () => {\n try {\n const records = await Promise.all(promises);\n resolve({records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n}\n"],"mappings":";;;;;;;AA4BA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,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;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AG,CAACX,QAAQ,CAAC;UAC3CF,OAAO,CAAC;YAACW,gBAAgB;YAAEC;UAAO,CAAC,CAAC;QACtC,CAAC,CAAC,OAAOE,KAAK,EAAE;UACdb,MAAM,CAACa,KAAK,CAAC;QACf;MACF,CAAC,CAAC,CACDT,EAAE,CAAC,OAAO,EAAEU,GAAG,IAAId,MAAM,CAACc,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC;EACJ;EAEA,SAASnB,iBAAiBA,CAACC,QAAQ,EAAE;IACnCR,KAAK,CAAE,0BAAyBQ,QAAS,EAAC,CAAC;IAC3C,OAAO,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAMC,QAAQ,GAAG,EAAE;MACnBX,SAAS,CAACY,cAAc,CAAE,uBAAsBN,QAAS,EAAC,CAAC,CACxDQ,EAAE,CAAC,QAAQ,EAAEC,SAAS,IAAI;QACzBJ,QAAQ,CAACK,IAAI,CAACC,8BAAO,CAACC,IAAI,CAACH,SAAS,EAAE;UAACI,cAAc,EAAE;QAAK,CAAC,CAAC,CAAC,CAAC,CAAC;MACnE,CAAC,CAAC,CACDL,EAAE,CAAC,KAAK,EAAE,YAAY;QACrB,IAAI;UACF,MAAMO,OAAO,GAAG,MAAMb,OAAO,CAACc,GAAG,CAACX,QAAQ,CAAC;UAC3CF,OAAO,CAAC;YAACY;UAAO,CAAC,CAAC;QACpB,CAAC,CAAC,OAAOE,KAAK,EAAE;UACdb,MAAM,CAACa,KAAK,CAAC;QACf;MACF,CAAC,CAAC,CACDT,EAAE,CAAC,OAAO,EAAEU,GAAG,IAAId,MAAM,CAACc,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC;EACJ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"subRecordPicker.spec.js","names":["_chai","require","_subRecordPicker","_fixura","_fixugenHttpClient","_interopRequireDefault","describe","sruUrl","retrieveAll","it","client","createSubrecordPicker","expect","to","respondTo","throw","generateTests","callback","path","__dirname","_ref","getFixture","method","recordId","expectedRecords","components","reader","READERS","JSON","records","format","eql","map","r","toObject"],"sources":["../src/subRecordPicker.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 Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 {createSubrecordPicker} from './subRecordPicker';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen-http-client';\n\ndescribe('subRecordPicker', () => {\n const sruUrl = 'https://sru';\n const retrieveAll = false;\n\n describe('createSubrecordPicker', () => {\n it('Client should have methods', () => {\n const client = createSubrecordPicker(sruUrl, retrieveAll);\n expect(client).to.respondTo('readAllSubrecords');\n expect(client).to.respondTo('readSomeSubrecords');\n });\n\n it('Create client should work with just one parametter', () => {\n const client = createSubrecordPicker(sruUrl);\n expect(client).to.respondTo('readAllSubrecords');\n expect(client).to.respondTo('readSomeSubrecords');\n });\n\n it('Create client should have at least one parametter', () => {\n expect(createSubrecordPicker).to.throw();\n });\n });\n\n generateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'subRecordPicker']\n });\n\n async function callback({getFixture, method, sruUrl, retrieveAll, recordId}) {\n const client = createSubrecordPicker(sruUrl, retrieveAll);\n const expectedRecords = getFixture({components: ['expected-records.json'], reader: READERS.JSON});\n const {records} = await client[method](recordId);\n\n expect(format()).to.eql(expectedRecords);\n\n function format() {\n return records.map(r => r.toObject());\n }\n }\n});\n"],"mappings":";;;AA4BA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,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;;AAOAK,QAAQ,CAAC,iBAAiB,EAAE,MAAM;EAChC,MAAMC,MAAM,GAAG,aAAa;EAC5B,MAAMC,WAAW,GAAG,KAAK;EAEzBF,QAAQ,CAAC,uBAAuB,EAAE,MAAM;IACtCG,EAAE,CAAC,4BAA4B,EAAE,MAAM;MACrC,MAAMC,MAAM,GAAG,IAAAC,sCAAqB,EAACJ,MAAM,EAAEC,WAAW,CAAC;MACzD,IAAAI,YAAM,EAACF,MAAM,CAAC,CAACG,EAAE,CAACC,SAAS,CAAC,mBAAmB,CAAC;MAChD,IAAAF,YAAM,EAACF,MAAM,CAAC,CAACG,EAAE,CAACC,SAAS,CAAC,oBAAoB,CAAC;IACnD,CAAC,CAAC;IAEFL,EAAE,CAAC,oDAAoD,EAAE,MAAM;MAC7D,MAAMC,MAAM,GAAG,IAAAC,sCAAqB,EAACJ,MAAM,CAAC;MAC5C,IAAAK,YAAM,EAACF,MAAM,CAAC,CAACG,EAAE,CAACC,SAAS,CAAC,mBAAmB,CAAC;MAChD,IAAAF,YAAM,EAACF,MAAM,CAAC,CAACG,EAAE,CAACC,SAAS,CAAC,oBAAoB,CAAC;IACnD,CAAC,CAAC;IAEFL,EAAE,CAAC,mDAAmD,EAAE,MAAM;MAC5D,IAAAG,YAAM,EAACD,sCAAqB,CAAC,CAACE,EAAE,CAACE,KAAK,EAAE;IAC1C,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,IAAAC,0BAAa,EAAC;IACZC,QAAQ;IACRC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,iBAAiB;EAC5D,CAAC,CAAC;EAEF,eAAeF,QAAQA,CAAAG,IAAA,EAAsD;IAAA,IAArD;MAACC,UAAU;MAAEC,MAAM;MAAEf,MAAM;MAAEC,WAAW;MAAEe;IAAQ,CAAC,GAAAH,IAAA;IACzE,MAAMV,MAAM,GAAG,IAAAC,sCAAqB,EAACJ,MAAM,EAAEC,WAAW,CAAC;IACzD,MAAMgB,eAAe,GAAGH,UAAU,CAAC;MAACI,UAAU,EAAE,CAAC,uBAAuB,CAAC;MAAEC,MAAM,EAAEC,eAAO,CAACC;IAAI,CAAC,CAAC;IACjG,MAAM;MAACC;IAAO,CAAC,GAAG,MAAMnB,MAAM,CAACY,MAAM,CAAC,CAACC,QAAQ,CAAC;IAEhD,IAAAX,YAAM,EAACkB,MAAM,EAAE,CAAC,CAACjB,EAAE,CAACkB,GAAG,CAACP,eAAe,CAAC;IAExC,SAASM,MAAMA,CAAA,EAAG;MAChB,OAAOD,OAAO,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,EAAE,CAAC;IACvC;EACF;AACF,CAAC,CAAC"}
1
+ {"version":3,"file":"subRecordPicker.spec.js","names":["_chai","require","_subRecordPicker","_fixura","_fixugenHttpClient","_interopRequireDefault","describe","sruUrl","retrieveAll","it","client","createSubrecordPicker","expect","to","respondTo","throw","generateTests","callback","path","__dirname","_ref","getFixture","method","recordId","expectedRecords","components","reader","READERS","JSON","records","format","eql","map","r","toObject"],"sources":["../src/subRecordPicker.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 Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 {createSubrecordPicker} from './subRecordPicker';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen-http-client';\n\ndescribe('subRecordPicker', () => {\n const sruUrl = 'https://sru';\n const retrieveAll = false;\n\n describe('createSubrecordPicker', () => {\n it('Client should have methods', () => {\n const client = createSubrecordPicker(sruUrl, retrieveAll);\n expect(client).to.respondTo('readAllSubrecords');\n expect(client).to.respondTo('readSomeSubrecords');\n });\n\n it('Create client should work with just one parametter', () => {\n const client = createSubrecordPicker(sruUrl);\n expect(client).to.respondTo('readAllSubrecords');\n expect(client).to.respondTo('readSomeSubrecords');\n });\n\n it('Create client should have at least one parametter', () => {\n expect(createSubrecordPicker).to.throw();\n });\n });\n\n generateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'subRecordPicker']\n });\n\n async function callback({getFixture, method, sruUrl, retrieveAll, recordId}) {\n const client = createSubrecordPicker(sruUrl, retrieveAll);\n const expectedRecords = getFixture({components: ['expected-records.json'], reader: READERS.JSON});\n const {records} = await client[method](recordId);\n\n expect(format()).to.eql(expectedRecords);\n\n function format() {\n return records.map(r => r.toObject());\n }\n }\n});\n"],"mappings":";;;AA4BA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AA/BA;AACA;AACA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AEe;IAAQ,CAAC,GAAAH,IAAA;IACzE,MAAMV,MAAM,GAAG,IAAAC,sCAAqB,EAACJ,MAAM,EAAEC,WAAW,CAAC;IACzD,MAAMgB,eAAe,GAAGH,UAAU,CAAC;MAACI,UAAU,EAAE,CAAC,uBAAuB,CAAC;MAAEC,MAAM,EAAEC,eAAO,CAACC;IAAI,CAAC,CAAC;IACjG,MAAM;MAACC;IAAO,CAAC,GAAG,MAAMnB,MAAM,CAACY,MAAM,CAAC,CAACC,QAAQ,CAAC;IAEhD,IAAAX,YAAM,EAACkB,MAAM,CAAC,CAAC,CAAC,CAACjB,EAAE,CAACkB,GAAG,CAACP,eAAe,CAAC;IAExC,SAASM,MAAMA,CAAA,EAAG;MAChB,OAAOD,OAAO,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,CAAC,CAAC;IACvC;EACF;AACF,CAAC,CAAC"}
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["generateAuthorizationHeader","username","password","arguments","length","undefined","encoded","Buffer","from","toString","isDeletedRecord","record","includes","leader","checkDel","checkSta","get","some","check","_ref","subfields","_ref2","code","value","_ref3","values","_ref4","parseBoolean","Number","isNaN","test","Boolean","getRecordTitle","TRIM_PATTERN","field","find","f","sf","replace","RegExp","getRecordStandardIdentifiers","filter","map","subfield","clone","o","JSON","parse","stringify","toAlephId","id","padStart","fromAlephId"],"sources":["../src/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 Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 generateAuthorizationHeader(username, password = '') {\n const encoded = Buffer.from(`${username}:${password}`).toString('base64');\n return `Basic ${encoded}`;\n}\n\nexport function isDeletedRecord(record) {\n if (['d', 's', 'x'].includes(record.leader[5])) {\n return true;\n }\n\n return checkDel() || checkSta();\n\n function checkDel() {\n return record.get(/^DEL$/u).some(check);\n\n function check({subfields}) {\n return subfields.some(({code, value}) => code === 'a' && value === 'Y');\n }\n }\n\n function checkSta() {\n return record.get(/^STA$/u).some(check);\n\n function check({subfields}) {\n const values = ['DELETED', 'DELETED-SPLIT', 'DELETED-DEPRECATED'];\n return subfields.some(({code, value}) => code === 'a' && values.includes(value));\n }\n }\n}\n\nexport function parseBoolean(value) {\n if (value === undefined) {\n return false;\n }\n\n if (Number.isNaN(Number(value))) {\n return value.length > 0 && !(/^(?:false)$/ui).test(value);\n }\n\n return Boolean(Number(value));\n}\n\nexport function getRecordTitle(record) {\n const TRIM_PATTERN = '[?!.,(){}:;/ ]*';\n const field = record\n .get(/^245$/u)\n .find(f => f.subfields.some(sf => sf.code === 'a'));\n\n if (field) {\n return field.subfields.find(sf => sf.code === 'a').value\n .replace(new RegExp(`^${TRIM_PATTERN}`, 'u'), '')\n .replace(new RegExp(`${TRIM_PATTERN}$`, 'u'), '');\n }\n\n return '';\n}\n\nexport function getRecordStandardIdentifiers(record) {\n return record.get(/^(?<def>020|022|024)$/u)\n .filter(f => f.subfields.some(sf => ['a', 'z'].includes(sf.code)))\n .map(field => {\n const subfield = field.subfields.find(sf => ['a', 'z'].includes(sf.code));\n return subfield.value;\n });\n}\n\nexport function clone(o) {\n return JSON.parse(JSON.stringify(o));\n}\n\nexport function toAlephId(id) {\n return id.padStart(9, '0');\n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AEN,YAAa,GAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;EACrD;EAEA,OAAO,EAAE;AACX;AAEO,SAASO,4BAA4BA,CAAC7B,MAAM,EAAE;EACnD,OAAOA,MAAM,CAACK,GAAG,CAAC,wBAAwB,CAAC,CACxCyB,MAAM,CAACL,CAAC,IAAIA,CAAC,CAAChB,SAAS,CAACH,IAAI,CAACoB,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACzB,QAAQ,CAACyB,EAAE,CAACf,IAAI,CAAC,CAAC,CAAC,CACjEoB,GAAG,CAACR,KAAK,IAAI;IACZ,MAAMS,QAAQ,GAAGT,KAAK,CAACd,SAAS,CAACe,IAAI,CAACE,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACzB,QAAQ,CAACyB,EAAE,CAACf,IAAI,CAAC,CAAC;IACzE,OAAOqB,QAAQ,CAACpB,KAAK;EACvB,CAAC,CAAC;AACN;AAEO,SAASqB,KAAKA,CAACC,CAAC,EAAE;EACvB,OAAOC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACH,CAAC,CAAC,CAAC;AACtC;AAEO,SAASI,SAASA,CAACC,EAAE,EAAE;EAC5B,OAAOA,EAAE,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;AAC5B;AAEO,SAASC,WAAWA,CAACF,EAAE,EAAE;EAC9B,OAAOA,EAAE,CAACZ,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;AAC/B"}
1
+ {"version":3,"file":"utils.js","names":["generateAuthorizationHeader","username","password","arguments","length","undefined","encoded","Buffer","from","toString","isDeletedRecord","record","includes","leader","checkDel","checkSta","get","some","check","_ref","subfields","_ref2","code","value","_ref3","values","_ref4","parseBoolean","Number","isNaN","test","Boolean","getRecordTitle","TRIM_PATTERN","field","find","f","sf","replace","RegExp","getRecordStandardIdentifiers","filter","map","subfield","clone","o","JSON","parse","stringify","toAlephId","id","padStart","fromAlephId"],"sources":["../src/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 Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser 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-commons-js 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 Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser 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 generateAuthorizationHeader(username, password = '') {\n const encoded = Buffer.from(`${username}:${password}`).toString('base64');\n return `Basic ${encoded}`;\n}\n\nexport function isDeletedRecord(record) {\n if (['d', 's', 'x'].includes(record.leader[5])) {\n return true;\n }\n\n return checkDel() || checkSta();\n\n function checkDel() {\n return record.get(/^DEL$/u).some(check);\n\n function check({subfields}) {\n return subfields.some(({code, value}) => code === 'a' && value === 'Y');\n }\n }\n\n function checkSta() {\n return record.get(/^STA$/u).some(check);\n\n function check({subfields}) {\n const values = ['DELETED', 'DELETED-SPLIT', 'DELETED-DEPRECATED'];\n return subfields.some(({code, value}) => code === 'a' && values.includes(value));\n }\n }\n}\n\nexport function parseBoolean(value) {\n if (value === undefined) {\n return false;\n }\n\n if (Number.isNaN(Number(value))) {\n return value.length > 0 && !(/^(?:false)$/ui).test(value);\n }\n\n return Boolean(Number(value));\n}\n\nexport function getRecordTitle(record) {\n const TRIM_PATTERN = '[?!.,(){}:;/ ]*';\n const field = record\n .get(/^245$/u)\n .find(f => f.subfields.some(sf => sf.code === 'a'));\n\n if (field) {\n return field.subfields.find(sf => sf.code === 'a').value\n .replace(new RegExp(`^${TRIM_PATTERN}`, 'u'), '')\n .replace(new RegExp(`${TRIM_PATTERN}$`, 'u'), '');\n }\n\n return '';\n}\n\nexport function getRecordStandardIdentifiers(record) {\n return record.get(/^(?<def>020|022|024)$/u)\n .filter(f => f.subfields.some(sf => ['a', 'z'].includes(sf.code)))\n .map(field => {\n const subfield = field.subfields.find(sf => ['a', 'z'].includes(sf.code));\n return subfield.value;\n });\n}\n\nexport function clone(o) {\n return JSON.parse(JSON.stringify(o));\n}\n\nexport function toAlephId(id) {\n return id.padStart(9, '0');\n}\n\nexport function fromAlephId(id) {\n return id.replace(/^0+/u, '');\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,2BAA2BA,CAACC,QAAQ,EAAiB;EAAA,IAAfC,QAAQ,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EACjE,MAAMG,OAAO,GAAGC,MAAM,CAACC,IAAI,CAAE,GAAEP,QAAS,IAAGC,QAAS,EAAC,CAAC,CAACO,QAAQ,CAAC,QAAQ,CAAC;EACzE,OAAQ,SAAQH,OAAQ,EAAC;AAC3B;AAEO,SAASI,eAAeA,CAACC,MAAM,EAAE;EACtC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAACC,QAAQ,CAACD,MAAM,CAACE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IAC9C,OAAO,IAAI;EACb;EAEA,OAAOC,QAAQ,CAAC,CAAC,IAAIC,QAAQ,CAAC,CAAC;EAE/B,SAASD,QAAQA,CAAA,EAAG;IAClB,OAAOH,MAAM,CAACK,GAAG,CAAC,QAAQ,CAAC,CAACC,IAAI,CAACC,KAAK,CAAC;IAEvC,SAASA,KAAKA,CAAAC,IAAA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,CAACZ,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;AAC/B"}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/melinda-commons-js.git"
15
15
  },
16
16
  "license": "MIT",
17
- "version": "13.0.4",
17
+ "version": "13.0.5-alpha.1",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=18"
@@ -35,33 +35,33 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@natlibfi/marc-record": "^7.2.2",
38
- "@natlibfi/marc-record-serializers": "^10.0.4",
39
- "@natlibfi/sru-client": "^6.0.2",
38
+ "@natlibfi/marc-record-serializers": "^10.0.5",
39
+ "@natlibfi/sru-client": "^6.0.3",
40
40
  "debug": "^4.3.4",
41
41
  "deep-eql": "^4.1.3",
42
42
  "http-status": "^1.6.2",
43
43
  "moment": "^2.29.4",
44
- "nock": "^13.3.0",
45
- "node-fetch": "^2.6.8"
44
+ "nock": "^13.3.2",
45
+ "node-fetch": "^2.6.12"
46
46
  },
47
47
  "devDependencies": {
48
- "@babel/cli": "^7.20.7",
49
- "@babel/core": "^7.20.12",
50
- "@babel/eslint-parser": "^7.19.1",
51
- "@babel/node": "^7.20.7",
52
- "@babel/plugin-transform-runtime": "^7.19.6",
53
- "@babel/preset-env": "^7.20.2",
54
- "@babel/register": "^7.18.9",
55
- "@natlibfi/eslint-config-melinda-backend": "^2.0.2",
48
+ "@babel/cli": "^7.22.9",
49
+ "@babel/core": "^7.22.9",
50
+ "@babel/eslint-parser": "^7.22.9",
51
+ "@babel/node": "^7.22.6",
52
+ "@babel/plugin-transform-runtime": "^7.22.9",
53
+ "@babel/preset-env": "^7.22.9",
54
+ "@babel/register": "^7.22.5",
55
+ "@natlibfi/eslint-config-melinda-backend": "^3.0.0",
56
56
  "@natlibfi/fixugen-http-client": "^2.0.1",
57
- "@natlibfi/fixura": "^2.2.5",
57
+ "@natlibfi/fixura": "^3.0.0",
58
58
  "babel-plugin-istanbul": "^6.1.1",
59
59
  "babel-plugin-rewire": "^1.2.0",
60
60
  "chai": "^4.3.7",
61
61
  "cross-env": "^7.0.3",
62
- "eslint": "^8.38.0",
62
+ "eslint": "^8.45.0",
63
63
  "mocha": "^10.2.0",
64
- "nodemon": "^2.0.20",
64
+ "nodemon": "^3.0.1",
65
65
  "nyc": "^15.1.0"
66
66
  },
67
67
  "eslintConfig": {
package/src/error.js CHANGED
@@ -29,7 +29,7 @@
29
29
  export default class extends Error {
30
30
  constructor(status, payload, ...params) {
31
31
  super(params);
32
- this.status = status; // eslint-disable-line functional/no-this-expression
33
- this.payload = payload; // eslint-disable-line functional/no-this-expression
32
+ this.status = status; // eslint-disable-line functional/no-this-expressions
33
+ this.payload = payload; // eslint-disable-line functional/no-this-expressions
34
34
  }
35
35
  }
@@ -32,7 +32,7 @@ import createDebugLogger from 'debug';
32
32
  import {Error as ApiError} from './error';
33
33
 
34
34
  export function createSubrecordPicker(sruUrl, retrieveAll = false) {
35
- if (sruUrl === undefined) { // eslint-disable-line functional/no-conditional-statement
35
+ if (sruUrl === undefined) { // eslint-disable-line functional/no-conditional-statements
36
36
  throw new ApiError(400, 'Invalid sru url');
37
37
  }
38
38