@natlibfi/melinda-commons 12.0.0-alpha.1 → 12.0.3-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/README.md CHANGED
@@ -1,9 +1,10 @@
1
- # Shared modules for Melinda's software [![NPM Version](https://img.shields.io/npm/v/@natlibfi/melinda-commons.svg)](https://npmjs.org/package/@natlibfi/melinda-commons)
1
+ # Shared modules for Melinda's software
2
+ [![NPM Version](https://img.shields.io/npm/v/@natlibfi/melinda-commons.svg)](https://npmjs.org/package/@natlibfi/melinda-commons)
2
3
 
3
4
  Shared modules for Melinda's software
4
5
 
5
6
  ## License and copyright
6
7
 
7
- Copyright (c) 2018-2020 **University Of Helsinki (The National Library Of Finland)**
8
+ Copyright (c) 2018-2021 **University Of Helsinki (The National Library Of Finland)**
8
9
 
9
10
  This project's source code is licensed under the terms of **GNU Lesser General Public License Version 3** or any later version.
package/dist/error.js CHANGED
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+
10
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
13
 
12
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -27,7 +29,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
27
29
  *
28
30
  * Shared modules for Melinda's software
29
31
  *
30
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
32
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
31
33
  *
32
34
  * This file is part of melinda-commons-js
33
35
  *
@@ -70,7 +72,7 @@ var _default = /*#__PURE__*/function (_Error) {
70
72
  return _this;
71
73
  }
72
74
 
73
- return _default;
75
+ return (0, _createClass2.default)(_default);
74
76
  }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
75
77
 
76
78
  exports.default = _default;
package/dist/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/error.js"],"names":["status","payload","params","Error"],"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;;;;;;AAGE,oBAAYA,MAAZ,EAAoBC,OAApB,EAAwC;AAAA;;AAAA;;AAAA,sCAARC,MAAQ;AAARA,MAAAA,MAAQ;AAAA;;AACtC,8BAAMA,MAAN;AACA,UAAKF,MAAL,GAAcA,MAAd,CAFsC,CAEhB;;AACtB,UAAKC,OAAL,GAAeA,OAAf,CAHsC,CAGd;;AAHc;AAIvC;;;+CAL0BE,K","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-2020 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"],"file":"error.js"}
1
+ {"version":3,"sources":["../src/error.js"],"names":["status","payload","params","Error"],"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;;;;;;AAGE,oBAAYA,MAAZ,EAAoBC,OAApB,EAAwC;AAAA;;AAAA;;AAAA,sCAARC,MAAQ;AAARA,MAAAA,MAAQ;AAAA;;AACtC,8BAAMA,MAAN;AACA,UAAKF,MAAL,GAAcA,MAAd,CAFsC,CAEhB;;AACtB,UAAKC,OAAL,GAAeA,OAAf,CAHsC,CAGd;;AAHc;AAIvC;;;+CAL0BE,K","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-2021 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"],"file":"error.js"}
@@ -12,7 +12,7 @@ var _error = _interopRequireDefault(require("./error"));
12
12
  *
13
13
  * Shared modules for Melinda's software
14
14
  *
15
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
15
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
16
16
  *
17
17
  * This file is part of melinda-commons-js
18
18
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/error.spec.js"],"names":["describe","it","error","CommonsError","to","be","an","instanceOf","Error","status","equal","payload"],"mappings":";;;;AA4BA;;AACA;;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;AAKAA,QAAQ,CAAC,OAAD,EAAU,YAAM;AACtBC,EAAAA,EAAE,CAAC,wCAAD,EAA2C,YAAM;AACjD,QAAMC,KAAK,GAAG,IAAIC,cAAJ,CAAiB,GAAjB,EAAsB,QAAtB,CAAd;AAEA,sBAAOD,KAAP,EAAcE,EAAd,CAAiBC,EAAjB,CAAoBC,EAApB,CAAuBC,UAAvB,CAAkCC,KAAlC;AACA,sBAAON,KAAK,CAACO,MAAb,EAAqBL,EAArB,CAAwBM,KAAxB,CAA8B,GAA9B;AACA,sBAAOR,KAAK,CAACS,OAAb,EAAsBP,EAAtB,CAAyBM,KAAzB,CAA+B,QAA/B;AACD,GANC,CAAF;AAOD,CARO,CAAR","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-2020 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 CommonsError from './error';\n\ndescribe('error', () => {\n it('Should construct the expected instance', () => {\n const error = new CommonsError(200, 'foobar');\n\n expect(error).to.be.an.instanceOf(Error);\n expect(error.status).to.equal(200);\n expect(error.payload).to.equal('foobar');\n });\n});\n"],"file":"error.spec.js"}
1
+ {"version":3,"sources":["../src/error.spec.js"],"names":["describe","it","error","CommonsError","to","be","an","instanceOf","Error","status","equal","payload"],"mappings":";;;;AA4BA;;AACA;;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;AAKAA,QAAQ,CAAC,OAAD,EAAU,YAAM;AACtBC,EAAAA,EAAE,CAAC,wCAAD,EAA2C,YAAM;AACjD,QAAMC,KAAK,GAAG,IAAIC,cAAJ,CAAiB,GAAjB,EAAsB,QAAtB,CAAd;AAEA,sBAAOD,KAAP,EAAcE,EAAd,CAAiBC,EAAjB,CAAoBC,EAApB,CAAuBC,UAAvB,CAAkCC,KAAlC;AACA,sBAAON,KAAK,CAACO,MAAb,EAAqBL,EAArB,CAAwBM,KAAxB,CAA8B,GAA9B;AACA,sBAAOR,KAAK,CAACS,OAAb,EAAsBP,EAAtB,CAAyBM,KAAzB,CAA+B,QAA/B;AACD,GANC,CAAF;AAOD,CARO,CAAR","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-2021 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 CommonsError from './error';\n\ndescribe('error', () => {\n it('Should construct the expected instance', () => {\n const error = new CommonsError(200, 'foobar');\n\n expect(error).to.be.an.instanceOf(Error);\n expect(error.status).to.equal(200);\n expect(error.payload).to.equal('foobar');\n });\n});\n"],"file":"error.spec.js"}
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ var _error = _interopRequireDefault(require("./error"));
48
48
  *
49
49
  * Shared modules for Melinda's software
50
50
  *
51
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
51
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
52
52
  *
53
53
  * This file is part of melinda-commons-js
54
54
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["MarcRecord","setValidationOptions","subfieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AAKA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AArCA;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;AACAA,uBAAWC,oBAAX,CAAgC;AAACC,EAAAA,cAAc,EAAE;AAAjB,CAAhC","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-2020 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 {MarcRecord} from '@natlibfi/marc-record';\n\n// Aleph creates partial subfields...\nMarcRecord.setValidationOptions({subfieldValues: false});\n\nimport {createSubrecordPicker} from './subRecordPicker';\n\nexport * from './utils';\n\nexport {default as Error} from './error';\nexport {createSubrecordPicker};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["MarcRecord","setValidationOptions","subfieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AAKA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AArCA;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;AACAA,uBAAWC,oBAAX,CAAgC;AAACC,EAAAA,cAAc,EAAE;AAAjB,CAAhC","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-2021 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 {MarcRecord} from '@natlibfi/marc-record';\n\n// Aleph creates partial subfields...\nMarcRecord.setValidationOptions({subfieldValues: false});\n\nimport {createSubrecordPicker} from './subRecordPicker';\n\nexport * from './utils';\n\nexport {default as Error} from './error';\nexport {createSubrecordPicker};\n"],"file":"index.js"}
@@ -18,13 +18,15 @@ var _fixugenHttpClient = _interopRequireDefault(require("@natlibfi/fixugen-http-
18
18
 
19
19
  var _marcRecord = require("@natlibfi/marc-record");
20
20
 
21
+ var _debug = _interopRequireDefault(require("debug"));
22
+
21
23
  /**
22
24
  *
23
25
  * @licstart The following is the entire license notice for the JavaScript code in this file.
24
26
  *
25
27
  * Shared modules for Melinda's software
26
28
  *
27
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
29
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
28
30
  *
29
31
  * This file is part of melinda-commons-js
30
32
  *
@@ -45,6 +47,7 @@ var _marcRecord = require("@natlibfi/marc-record");
45
47
  * for the JavaScript code in this file.
46
48
  *
47
49
  */
50
+ var debug = (0, _debug.default)('@natlibfi/melinda-commons:subRecordPicker:test');
48
51
  describe('subRecordPicker', function () {
49
52
  var sruUrl = 'https://sru';
50
53
  var retrieveAll = false;
@@ -74,7 +77,7 @@ describe('subRecordPicker', function () {
74
77
 
75
78
  function _callback() {
76
79
  _callback = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
77
- var getFixture, method, sruUrl, retrieveAll, recordId, client, expectedRecords, _yield$client$method, records, _records, record, format;
80
+ var getFixture, method, sruUrl, retrieveAll, recordId, client, expectedRecords, _yield$client$method, records, _records, recordObject, record, format;
78
81
 
79
82
  return _regenerator.default.wrap(function _callee$(_context) {
80
83
  while (1) {
@@ -99,11 +102,14 @@ describe('subRecordPicker', function () {
99
102
  _yield$client$method = _context.sent;
100
103
  records = _yield$client$method.records;
101
104
  // Expect records to be marc records
102
- _records = (0, _slicedToArray2.default)(records, 1), record = _records[0];
105
+ _records = (0, _slicedToArray2.default)(records, 1), recordObject = _records[0];
106
+ debug(recordObject);
107
+ record = new _marcRecord.MarcRecord(recordObject);
108
+ debug(record);
103
109
  (0, _chai.expect)(record).to.be.instanceof(_marcRecord.MarcRecord);
104
110
  (0, _chai.expect)(format()).to.eql(expectedRecords);
105
111
 
106
- case 11:
112
+ case 14:
107
113
  case "end":
108
114
  return _context.stop();
109
115
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/subRecordPicker.spec.js"],"names":["describe","sruUrl","retrieveAll","it","client","to","respondTo","createSubrecordPicker","throw","callback","path","__dirname","format","records","map","r","toObject","getFixture","method","recordId","expectedRecords","components","reader","READERS","JSON","record","be","instanceof","MarcRecord","eql"],"mappings":";;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;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;AAQAA,QAAQ,CAAC,iBAAD,EAAoB,YAAM;AAChC,MAAMC,MAAM,GAAG,aAAf;AACA,MAAMC,WAAW,GAAG,KAApB;AAEAF,EAAAA,QAAQ,CAAC,uBAAD,EAA0B,YAAM;AACtCG,IAAAA,EAAE,CAAC,4BAAD,EAA+B,YAAM;AACrC,UAAMC,MAAM,GAAG,4CAAsBH,MAAtB,EAA8BC,WAA9B,CAAf;AACA,wBAAOE,MAAP,EAAeC,EAAf,CAAkBC,SAAlB,CAA4B,mBAA5B;AACA,wBAAOF,MAAP,EAAeC,EAAf,CAAkBC,SAAlB,CAA4B,oBAA5B;AACD,KAJC,CAAF;AAMAH,IAAAA,EAAE,CAAC,oDAAD,EAAuD,YAAM;AAC7D,UAAMC,MAAM,GAAG,4CAAsBH,MAA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AP,EAAepB,EAAf,CAAkBqB,EAAlB,CAAqBC,UAArB,CAAgCC,sBAAhC;AACA,gCAAOhB,MAAM,EAAb,EAAiBP,EAAjB,CAAoBwB,GAApB,CAAwBT,eAAxB;;AARF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KA3BgC;AAAA;AAAA;AAyCjC,CAzCO,CAAR","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-2020 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';\nimport {MarcRecord} from '@natlibfi/marc-record';\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 records to be marc records\n const [record] = records;\n expect(record).to.be.instanceof(MarcRecord);\n expect(format()).to.eql(expectedRecords);\n\n function format() {\n return records.map(r => r.toObject());\n }\n }\n});\n"],"file":"subRecordPicker.spec.js"}
1
+ {"version":3,"sources":["../src/subRecordPicker.spec.js"],"names":["debug","describe","sruUrl","retrieveAll","it","client","to","respondTo","createSubrecordPicker","throw","callback","path","__dirname","format","records","map","r","toObject","getFixture","method","recordId","expectedRecords","components","reader","READERS","JSON","recordObject","record","MarcRecord","be","instanceof","eql"],"mappings":";;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAjCA;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;AASA,IAAMA,KAAK,GAAG,oBAAkB,gDAAlB,CAAd;AAEAC,QAAQ,CAAC,iBAAD,EAAoB,YAAM;AAChC,MAAMC,MAAM,GAAG,aAAf;AACA,MAAMC,WAAW,GAAG,KAApB;AAEAF,EAAAA,QAAQ,CAAC,uBAAD,EAA0B,YAAM;AACtCG,IAAAA,EAAE,CAAC,4BAAD,EAA+B,YAAM;AACrC,UAAMC,MAAM,GAAG,4CAAsBH,MAAtB,EAA8BC,WAA9B,CAAf;AACA,wBAAOE,MAAP,EAAeC,EAAf,CAAkBC,SAAlB,CAA4B,mBAA5B;AACA,wBAAOF,MAAP,EAAeC,EAAf,CAAkBC,SAAlB,CAA4B,oBAA5B;AACD,KAJC,CAAF;AAMAH,IAAAA,EAAE,CAAC,oDAAD,EAAuD,YAAM;AAC7D,UAAMC,MAAM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YANT;AAOE1B,cAAAA,KAAK,CAAC0B,YAAD,CAAL;AACMC,cAAAA,MARR,GAQiB,IAAIC,sBAAJ,CAAeF,YAAf,CARjB;AASE1B,cAAAA,KAAK,CAAC2B,MAAD,CAAL;AAEA,gCAAOA,MAAP,EAAerB,EAAf,CAAkBuB,EAAlB,CAAqBC,UAArB,CAAgCF,sBAAhC;AACA,gCAAOf,MAAM,EAAb,EAAiBP,EAAjB,CAAoByB,GAApB,CAAwBV,eAAxB;;AAZF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KA3BgC;AAAA;AAAA;AA6CjC,CA7CO,CAAR","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-2021 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';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-commons:subRecordPicker:test');\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 records to be marc records\n const [recordObject] = records;\n debug(recordObject);\n const record = new MarcRecord(recordObject);\n debug(record);\n\n expect(record).to.be.instanceof(MarcRecord);\n expect(format()).to.eql(expectedRecords);\n\n function format() {\n return records.map(r => r.toObject());\n }\n }\n});\n"],"file":"subRecordPicker.spec.js"}
package/dist/utils.js CHANGED
@@ -20,7 +20,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
20
20
 
21
21
  var _setPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/setPrototypeOf"));
22
22
 
23
- function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); _groups.set(_this, groups || _groups.get(re)); return (0, _setPrototypeOf2.default)(_this, BabelRegExp.prototype); } (0, _inherits2.default)(BabelRegExp, RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; if (_typeof(args[args.length - 1]) !== "object") { args = [].slice.call(args); args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
23
+ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), (0, _setPrototypeOf2.default)(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { return groups[name] = result[g[name]], groups; }, Object.create(null)); } return (0, _inherits2.default)(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); return result && (result.groups = buildGroups(result, this)), result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != _typeof(args[args.length - 1]) && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }
24
24
 
25
25
  /**
26
26
  *
@@ -28,7 +28,7 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return
28
28
  *
29
29
  * Shared modules for Melinda's software
30
30
  *
31
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
31
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
32
32
  *
33
33
  * This file is part of melinda-commons-js
34
34
  *
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["generateAuthorizationHeader","username","password","encoded","Buffer","from","toString","isDeletedRecord","record","includes","leader","checkDel","checkSta","get","some","check","subfields","code","value","values","parseBoolean","undefined","Number","isNaN","length","Boolean","getRecordTitle","TRIM_PATTERN","field","find","f","sf","replace","RegExp","getRecordStandardIdentifiers","filter","map","subfield","clone","o","JSON","parse","stringify","toAlephId","id","padStart","fromAlephId"],"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,2BAAT,CAAqCC,QAArC,EAA8D;AAAA,MAAfC,QAAe,uEAAJ,EAAI;AACnE,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAP,WAAeJ,QAAf,cAA2BC,QAA3B,GAAuCI,QAAvC,CAAgD,QAAhD,CAAhB;AACA,yBAAgBH,OAAhB;AACD;;AAEM,SAASI,eAAT,CAAyBC,MAAzB,EAAiC;AACtC,MAAI,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgBC,QAAhB,CAAyBD,MAAM,CAACE,MAAP,CAAc,CAAd,CAAzB,CAAJ,EAAgD;AAC9C,WAAO,IAAP;AACD;;AAED,SAAOC,QAAQ,MAAMC,QAAQ,EAA7B;;AAEA,WAASD,QAAT,GAAoB;AAClB,WAAOH,MAAM,CAACK,GAAP,CAAW,OAAX,EAAqBC,IAArB,CAA0BC,KAA1B,CAAP;;AAEA,aAASA,KAAT,OAA4B;AAAA,UAAZC,SAAY,QAAZA,SAAY;AAC1B,aAAOA,SAAS,CAACF,IAAV,CAAe;AAAA,YAAEG,IAAF,SAAEA,IAAF;AAAA,YAAQC,KAAR,SAAQA,KAAR;AAAA,eAAmBD,IAAI,K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CAAP;AACD","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-2020 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 && value !== 'false';\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"],"file":"utils.js"}
1
+ {"version":3,"sources":["../src/utils.js"],"names":["generateAuthorizationHeader","username","password","encoded","Buffer","from","toString","isDeletedRecord","record","includes","leader","checkDel","checkSta","get","some","check","subfields","code","value","values","parseBoolean","undefined","Number","isNaN","length","Boolean","getRecordTitle","TRIM_PATTERN","field","find","f","sf","replace","RegExp","getRecordStandardIdentifiers","filter","map","subfield","clone","o","JSON","parse","stringify","toAlephId","id","padStart","fromAlephId"],"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,2BAAT,CAAqCC,QAArC,EAA8D;AAAA,MAAfC,QAAe,uEAAJ,EAAI;AACnE,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAP,WAAeJ,QAAf,cAA2BC,QAA3B,GAAuCI,QAAvC,CAAgD,QAAhD,CAAhB;AACA,yBAAgBH,OAAhB;AACD;;AAEM,SAASI,eAAT,CAAyBC,MAAzB,EAAiC;AACtC,MAAI,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgBC,QAAhB,CAAyBD,MAAM,CAACE,MAAP,CAAc,CAAd,CAAzB,CAAJ,EAAgD;AAC9C,WAAO,IAAP;AACD;;AAED,SAAO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T,CAAeC,CAAf,EAAkB;AACvB,SAAOC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,SAAL,CAAeH,CAAf,CAAX,CAAP;AACD;;AAEM,SAASI,SAAT,CAAmBC,EAAnB,EAAuB;AAC5B,SAAOA,EAAE,CAACC,QAAH,CAAY,CAAZ,EAAe,GAAf,CAAP;AACD;;AAEM,SAASC,WAAT,CAAqBF,EAArB,EAAyB;AAC9B,SAAOA,EAAE,CAACZ,OAAH,CAAW,KAAX,EAAmB,EAAnB,CAAP;AACD","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-2021 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 && value !== 'false';\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"],"file":"utils.js"}
@@ -18,7 +18,7 @@ var _utils = require("./utils");
18
18
  *
19
19
  * Shared modules for Melinda's software
20
20
  *
21
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
21
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
22
22
  *
23
23
  * This file is part of melinda-commons-js
24
24
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.spec.js"],"names":["MarcRecord","setValidationOptions","subfieldValues","FIXTURES_PATH","path","join","__dirname","describe","it","value","to","equal","data","fs","readFileSync","record","JSON","parse","undefined","forEach","descr","index","title","recordData","identifiers","eql","obj","cloned","not"],"mappings":";;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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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-2020 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 fs from 'fs';\nimport path from 'path';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {\n generateAuthorizationHeader, isDeletedRecord, parseBoolean, clone,\n getRecordTitle, getRecordStandardIdentifiers\n} from './utils';\n\nMarcRecord.setValidationOptions({subfieldValues: false});\n\nconst FIXTURES_PATH = path.join(__dirname, '../test-fixtures/utils');\n\ndescribe('utils', () => {\n describe('generateAuthorizationHeader', () => {\n it('Should create a proper Authorization header', () => {\n const value = generateAuthorizationHeader('foo', 'bar');\n expect(value).to.equal('Basic Zm9vOmJhcg==');\n });\n });\n\n describe('isDeletedRecord', () => {\n it('Should find the record deleted (Leader)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record1.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (DEL)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record2.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (STA)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record3.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record not deleted', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record4.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(false);\n });\n\n it('Should find the record deleted (Split)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record5.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (Deprecated)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record6.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (Split (Aleph))', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record7.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (Deprecated (Aleph))', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record8.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n });\n\n describe('parseBoolean', () => {\n it('Should parse undefined as false', () => {\n expect(parseBoolean(undefined)).to.equal(false);\n });\n\n it('Should parse zero-length string as false', () => {\n expect(parseBoolean('')).to.equal(false);\n });\n\n it('Should parse numericish value as true', () => {\n expect(parseBoolean('1')).to.equal(true);\n });\n\n it('Should parse numericush value as false', () => {\n expect(parseBoolean('0')).to.equal(false);\n });\n\n it('Should parse literal \\'false\\' value as false', () => {\n expect(parseBoolean('false')).to.equal(false);\n });\n\n it('Should parse non-numericish value as true', () => {\n expect(parseBoolean('foo')).to.equal(true);\n });\n });\n\n describe('getRecordTitle', () => {\n [\n 'Should find a title',\n 'Should not find a title'\n ].forEach((descr, index) => {\n it(descr, () => {\n const title = fs.readFileSync(path.join(FIXTURES_PATH, `getRecordTitle/title${index}.txt`), 'utf8');\n const recordData = fs.readFileSync(path.join(FIXTURES_PATH, `getRecordTitle/record${index}.json`), 'utf8');\n const record = new MarcRecord(JSON.parse(recordData));\n\n expect(getRecordTitle(record)).to.equal(title);\n });\n });\n });\n\n describe('getRecordStandardIdentifiers', () => {\n [\n 'Should find identifiers',\n 'Should not find an identifier'\n ].forEach((descr, index) => {\n it(descr, () => {\n const identifiers = JSON.parse(fs.readFileSync(path.join(FIXTURES_PATH, `getRecordStandardIdentifiers/identifiers${index}.json`), 'utf8'));\n const recordData = fs.readFileSync(path.join(FIXTURES_PATH, `getRecordStandardIdentifiers/record${index}.json`), 'utf8');\n const record = new MarcRecord(JSON.parse(recordData));\n\n expect(getRecordStandardIdentifiers(record)).to.eql(identifiers);\n });\n });\n });\n\n describe('clone', () => {\n it('Should clone an object', (index = '1') => {\n const obj = JSON.parse(fs.readFileSync(path.join(FIXTURES_PATH, `clone/${index}/obj.json`), 'utf8'));\n const cloned = clone(obj);\n\n expect(obj).to.not.equal(cloned);\n expect(cloned).to.eql(obj);\n });\n });\n});\n"],"file":"utils.spec.js"}
1
+ {"version":3,"sources":["../src/utils.spec.js"],"names":["MarcRecord","setValidationOptions","subfieldValues","FIXTURES_PATH","path","join","__dirname","describe","it","value","to","equal","data","fs","readFileSync","record","JSON","parse","undefined","forEach","descr","index","title","recordData","identifiers","eql","obj","cloned","not"],"mappings":";;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;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;AAWAA,uBAAWC,oBAAX,CAAgC;AAACC,EAAAA,cAAc,EAAE;AAAjB,CAAhC;;AAEA,IAAMC,aAAa,GAAG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AR,EAAkB;AAC1Bb,MAAAA,EAAE,CAACY,KAAD,EAAQ,YAAM;AACd,YAAMI,WAAW,GAAGR,IAAI,CAACC,KAAL,CAAWJ,YAAGC,YAAH,CAAgBV,cAAKC,IAAL,CAAUF,aAAV,oDAAoEkB,KAApE,WAAhB,EAAmG,MAAnG,CAAX,CAApB;;AACA,YAAME,UAAU,GAAGV,YAAGC,YAAH,CAAgBV,cAAKC,IAAL,CAAUF,aAAV,+CAA+DkB,KAA/D,WAAhB,EAA8F,MAA9F,CAAnB;;AACA,YAAMN,MAAM,GAAG,IAAIf,sBAAJ,CAAegB,IAAI,CAACC,KAAL,CAAWM,UAAX,CAAf,CAAf;AAEA,0BAAO,yCAA6BR,MAA7B,CAAP,EAA6CL,EAA7C,CAAgDe,GAAhD,CAAoDD,WAApD;AACD,OANC,CAAF;AAOD,KAXD;AAYD,GAbO,CAAR;AAeAjB,EAAAA,QAAQ,CAAC,OAAD,EAAU,YAAM;AACtBC,IAAAA,EAAE,CAAC,wBAAD,EAA2B,YAAiB;AAAA,UAAhBa,KAAgB,uEAAR,GAAQ;AAC5C,UAAMK,GAAG,GAAGV,IAAI,CAACC,KAAL,CAAWJ,YAAGC,YAAH,CAAgBV,cAAKC,IAAL,CAAUF,aAAV,kBAAkCkB,KAAlC,eAAhB,EAAqE,MAArE,CAAX,CAAZ;AACA,UAAMM,MAAM,GAAG,kBAAMD,GAAN,CAAf;AAEA,wBAAOA,GAAP,EAAYhB,EAAZ,CAAekB,GAAf,CAAmBjB,KAAnB,CAAyBgB,MAAzB;AACA,wBAAOA,MAAP,EAAejB,EAAf,CAAkBe,GAAlB,CAAsBC,GAAtB;AACD,KANC,CAAF;AAOD,GARO,CAAR;AASD,CA3HO,CAAR","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-2021 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 fs from 'fs';\nimport path from 'path';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {\n generateAuthorizationHeader, isDeletedRecord, parseBoolean, clone,\n getRecordTitle, getRecordStandardIdentifiers\n} from './utils';\n\nMarcRecord.setValidationOptions({subfieldValues: false});\n\nconst FIXTURES_PATH = path.join(__dirname, '../test-fixtures/utils');\n\ndescribe('utils', () => {\n describe('generateAuthorizationHeader', () => {\n it('Should create a proper Authorization header', () => {\n const value = generateAuthorizationHeader('foo', 'bar');\n expect(value).to.equal('Basic Zm9vOmJhcg==');\n });\n });\n\n describe('isDeletedRecord', () => {\n it('Should find the record deleted (Leader)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record1.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (DEL)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record2.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (STA)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record3.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record not deleted', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record4.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(false);\n });\n\n it('Should find the record deleted (Split)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record5.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (Deprecated)', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record6.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (Split (Aleph))', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record7.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n\n it('Should find the record deleted (Deprecated (Aleph))', () => {\n const data = fs.readFileSync(path.join(FIXTURES_PATH, 'isDeletedRecord/record8.json'), 'utf8');\n const record = new MarcRecord(JSON.parse(data));\n expect(isDeletedRecord(record)).to.equal(true);\n });\n });\n\n describe('parseBoolean', () => {\n it('Should parse undefined as false', () => {\n expect(parseBoolean(undefined)).to.equal(false);\n });\n\n it('Should parse zero-length string as false', () => {\n expect(parseBoolean('')).to.equal(false);\n });\n\n it('Should parse numericish value as true', () => {\n expect(parseBoolean('1')).to.equal(true);\n });\n\n it('Should parse numericush value as false', () => {\n expect(parseBoolean('0')).to.equal(false);\n });\n\n it('Should parse literal \\'false\\' value as false', () => {\n expect(parseBoolean('false')).to.equal(false);\n });\n\n it('Should parse non-numericish value as true', () => {\n expect(parseBoolean('foo')).to.equal(true);\n });\n });\n\n describe('getRecordTitle', () => {\n [\n 'Should find a title',\n 'Should not find a title'\n ].forEach((descr, index) => {\n it(descr, () => {\n const title = fs.readFileSync(path.join(FIXTURES_PATH, `getRecordTitle/title${index}.txt`), 'utf8');\n const recordData = fs.readFileSync(path.join(FIXTURES_PATH, `getRecordTitle/record${index}.json`), 'utf8');\n const record = new MarcRecord(JSON.parse(recordData));\n\n expect(getRecordTitle(record)).to.equal(title);\n });\n });\n });\n\n describe('getRecordStandardIdentifiers', () => {\n [\n 'Should find identifiers',\n 'Should not find an identifier'\n ].forEach((descr, index) => {\n it(descr, () => {\n const identifiers = JSON.parse(fs.readFileSync(path.join(FIXTURES_PATH, `getRecordStandardIdentifiers/identifiers${index}.json`), 'utf8'));\n const recordData = fs.readFileSync(path.join(FIXTURES_PATH, `getRecordStandardIdentifiers/record${index}.json`), 'utf8');\n const record = new MarcRecord(JSON.parse(recordData));\n\n expect(getRecordStandardIdentifiers(record)).to.eql(identifiers);\n });\n });\n });\n\n describe('clone', () => {\n it('Should clone an object', (index = '1') => {\n const obj = JSON.parse(fs.readFileSync(path.join(FIXTURES_PATH, `clone/${index}/obj.json`), 'utf8'));\n const cloned = clone(obj);\n\n expect(obj).to.not.equal(cloned);\n expect(cloned).to.eql(obj);\n });\n });\n});\n"],"file":"utils.spec.js"}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/melinda-commons-js.git"
15
15
  },
16
16
  "license": "LGPL-3.0+",
17
- "version": "12.0.0-alpha.1",
17
+ "version": "12.0.3-alpha.1",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=14"
@@ -34,34 +34,34 @@
34
34
  "watch:test": "cross-env DEBUG=1 NODE_ENV=test nodemon -w src -w test-fixtures --exec 'npm run test:dev'"
35
35
  },
36
36
  "dependencies": {
37
- "@natlibfi/marc-record": "^6.1.2",
38
- "@natlibfi/marc-record-serializers": "^8.0.0-alpha.1",
39
- "@natlibfi/sru-client": "^4.1.0",
40
- "debug": "^4.3.2",
37
+ "@natlibfi/marc-record": "^7.0.0",
38
+ "@natlibfi/marc-record-serializers": "^8.1.0",
39
+ "@natlibfi/sru-client": "^5.0.1",
40
+ "debug": "^4.3.3",
41
41
  "deep-eql": "^4.0.0",
42
42
  "http-status": "^1.5.0",
43
43
  "moment": "^2.29.1",
44
- "nock": "^13.1.4",
45
- "node-fetch": "^2.6.1"
44
+ "nock": "^13.2.2",
45
+ "node-fetch": "^2.6.7"
46
46
  },
47
47
  "devDependencies": {
48
- "@babel/cli": "^7.15.7",
49
- "@babel/core": "^7.15.8",
50
- "@babel/eslint-parser": "^7.15.8",
51
- "@babel/node": "^7.15.8",
52
- "@babel/plugin-transform-runtime": "^7.15.8",
53
- "@babel/preset-env": "^7.15.8",
54
- "@babel/register": "^7.15.3",
55
- "@natlibfi/eslint-config-melinda-backend": "^1.1.1",
48
+ "@babel/cli": "^7.16.8",
49
+ "@babel/core": "^7.16.12",
50
+ "@babel/eslint-parser": "^7.16.5",
51
+ "@babel/node": "^7.16.8",
52
+ "@babel/plugin-transform-runtime": "^7.16.10",
53
+ "@babel/preset-env": "^7.16.11",
54
+ "@babel/register": "^7.16.9",
55
+ "@natlibfi/eslint-config-melinda-backend": "^2.0.0",
56
56
  "@natlibfi/fixugen-http-client": "^1.1.3",
57
57
  "@natlibfi/fixura": "^2.2.1",
58
58
  "babel-plugin-istanbul": "^6.1.1",
59
59
  "babel-plugin-rewire": "^1.2.0",
60
- "chai": "^4.3.4",
60
+ "chai": "^4.3.6",
61
61
  "cross-env": "^7.0.3",
62
- "eslint": "^7.32.0",
63
- "mocha": "^9.1.3",
64
- "nodemon": "^2.0.14",
62
+ "eslint": "^8.8.0",
63
+ "mocha": "^9.2.0",
64
+ "nodemon": "^2.0.15",
65
65
  "nyc": "^15.1.0"
66
66
  },
67
67
  "eslintConfig": {
package/src/error.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Shared modules for Melinda's software
6
6
  *
7
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
7
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
8
8
  *
9
9
  * This file is part of melinda-commons-js
10
10
  *
package/src/error.spec.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Shared modules for Melinda's software
6
6
  *
7
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
7
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
8
8
  *
9
9
  * This file is part of melinda-commons-js
10
10
  *
package/src/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Shared modules for Melinda's software
6
6
  *
7
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
7
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
8
8
  *
9
9
  * This file is part of melinda-commons-js
10
10
  *
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Shared modules for Melinda's software
6
6
  *
7
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
7
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
8
8
  *
9
9
  * This file is part of melinda-commons-js
10
10
  *
@@ -31,6 +31,9 @@ import {createSubrecordPicker} from './subRecordPicker';
31
31
  import {READERS} from '@natlibfi/fixura';
32
32
  import generateTests from '@natlibfi/fixugen-http-client';
33
33
  import {MarcRecord} from '@natlibfi/marc-record';
34
+ import createDebugLogger from 'debug';
35
+
36
+ const debug = createDebugLogger('@natlibfi/melinda-commons:subRecordPicker:test');
34
37
 
35
38
  describe('subRecordPicker', () => {
36
39
  const sruUrl = 'https://sru';
@@ -65,7 +68,11 @@ describe('subRecordPicker', () => {
65
68
  const {records} = await client[method](recordId);
66
69
 
67
70
  // Expect records to be marc records
68
- const [record] = records;
71
+ const [recordObject] = records;
72
+ debug(recordObject);
73
+ const record = new MarcRecord(recordObject);
74
+ debug(record);
75
+
69
76
  expect(record).to.be.instanceof(MarcRecord);
70
77
  expect(format()).to.eql(expectedRecords);
71
78
 
package/src/utils.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Shared modules for Melinda's software
6
6
  *
7
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
7
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
8
8
  *
9
9
  * This file is part of melinda-commons-js
10
10
  *
package/src/utils.spec.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Shared modules for Melinda's software
6
6
  *
7
- * Copyright (C) 2018-2020 University Of Helsinki (The National Library Of Finland)
7
+ * Copyright (C) 2018-2021 University Of Helsinki (The National Library Of Finland)
8
8
  *
9
9
  * This file is part of melinda-commons-js
10
10
  *