@natlibfi/melinda-commons 13.0.19-alpha.2 → 13.0.19

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.
@@ -11,7 +11,7 @@ jobs:
11
11
 
12
12
  strategy:
13
13
  matrix:
14
- node-version: [18.x, 20.x, 22.x]
14
+ node-version: [18.x, 20.x, 22.x, 23.x]
15
15
  # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
16
16
 
17
17
  steps:
package/README.md CHANGED
@@ -5,6 +5,6 @@ Shared modules for Melinda's software
5
5
 
6
6
  ## License and copyright
7
7
 
8
- Copyright (c) 2018-2024 **University Of Helsinki (The National Library Of Finland)**
8
+ Copyright (c) 2018-2025 **University Of Helsinki (The National Library Of Finland)**
9
9
 
10
10
  This project's source code is licensed under the terms of **MIT** or any later version.
package/dist/error.js CHANGED
@@ -4,34 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- /**
8
- *
9
- * @licstart The following is the entire license notice for the JavaScript code in this file.
10
- *
11
- * Shared modules for Melinda's software
12
- *
13
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
14
- *
15
- * This file is part of melinda-commons-js
16
- *
17
- * melinda-commons-js program is free software: you can redistribute it and/or modify
18
- * it under the terms of the GNU Lesser General Public License as
19
- * published by the Free Software Foundation, either version 3 of the
20
- * License, or (at your option) any later version.
21
- *
22
- * melinda-commons-js is distributed in the hope that it will be useful,
23
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- * GNU Lesser General Public License for more details.
26
- *
27
- * You should have received a copy of the GNU Lesser General Public License
28
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
29
- *
30
- * @licend The above is the entire license notice
31
- * for the JavaScript code in this file.
32
- *
33
- */
34
-
35
7
  class _default extends Error {
36
8
  constructor(status, payload) {
37
9
  for (var _len = arguments.length, params = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
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-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","ignoreList":[]}
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":["export 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":";;;;;;AAAe,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","ignoreList":[]}
@@ -3,34 +3,6 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  var _chai = require("chai");
5
5
  var _error = _interopRequireDefault(require("./error"));
6
- /**
7
- *
8
- * @licstart The following is the entire license notice for the JavaScript code in this file.
9
- *
10
- * Shared modules for Melinda's software
11
- *
12
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
13
- *
14
- * This file is part of melinda-commons-js
15
- *
16
- * melinda-commons-js program is free software: you can redistribute it and/or modify
17
- * it under the terms of the GNU Lesser General Public License as
18
- * published by the Free Software Foundation, either version 3 of the
19
- * License, or (at your option) any later version.
20
- *
21
- * melinda-commons-js is distributed in the hope that it will be useful,
22
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- * GNU Lesser General Public License for more details.
25
- *
26
- * You should have received a copy of the GNU Lesser General Public License
27
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
- *
29
- * @licend The above is the entire license notice
30
- * for the JavaScript code in this file.
31
- *
32
- */
33
-
34
6
  describe('error', () => {
35
7
  it('Should construct the expected instance', () => {
36
8
  const error = new _error.default(200, 'foobar');
@@ -1 +1 @@
1
- {"version":3,"file":"error.spec.js","names":["_chai","require","_error","_interopRequireDefault","describe","it","error","CommonsError","expect","to","be","an","instanceOf","Error","status","equal","payload"],"sources":["../src/error.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 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"],"mappings":";;;AA4BA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKAG,QAAQ,CAAC,OAAO,EAAE,MAAM;EACtBC,EAAE,CAAC,wCAAwC,EAAE,MAAM;IACjD,MAAMC,KAAK,GAAG,IAAIC,cAAY,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE7C,IAAAC,YAAM,EAACF,KAAK,CAAC,CAACG,EAAE,CAACC,EAAE,CAACC,EAAE,CAACC,UAAU,CAACC,KAAK,CAAC;IACxC,IAAAL,YAAM,EAACF,KAAK,CAACQ,MAAM,CAAC,CAACL,EAAE,CAACM,KAAK,CAAC,GAAG,CAAC;IAClC,IAAAP,YAAM,EAACF,KAAK,CAACU,OAAO,CAAC,CAACP,EAAE,CAACM,KAAK,CAAC,QAAQ,CAAC;EAC1C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"error.spec.js","names":["_chai","require","_error","_interopRequireDefault","describe","it","error","CommonsError","expect","to","be","an","instanceOf","Error","status","equal","payload"],"sources":["../src/error.spec.js"],"sourcesContent":["import {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"],"mappings":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEAG,QAAQ,CAAC,OAAO,EAAE,MAAM;EACtBC,EAAE,CAAC,wCAAwC,EAAE,MAAM;IACjD,MAAMC,KAAK,GAAG,IAAIC,cAAY,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE7C,IAAAC,YAAM,EAACF,KAAK,CAAC,CAACG,EAAE,CAACC,EAAE,CAACC,EAAE,CAACC,UAAU,CAACC,KAAK,CAAC;IACxC,IAAAL,YAAM,EAACF,KAAK,CAACQ,MAAM,CAAC,CAACL,EAAE,CAACM,KAAK,CAAC,GAAG,CAAC;IAClC,IAAAP,YAAM,EAACF,KAAK,CAACU,OAAO,CAAC,CAACP,EAAE,CAACM,KAAK,CAAC,QAAQ,CAAC;EAC1C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
package/dist/index.js CHANGED
@@ -35,34 +35,6 @@ Object.keys(_utils).forEach(function (key) {
35
35
  });
36
36
  });
37
37
  var _error = _interopRequireDefault(require("./error"));
38
- /**
39
- *
40
- * @licstart The following is the entire license notice for the JavaScript code in this file.
41
- *
42
- * Shared modules for Melinda's software
43
- *
44
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
45
- *
46
- * This file is part of melinda-commons-js
47
- *
48
- * melinda-commons-js program is free software: you can redistribute it and/or modify
49
- * it under the terms of the GNU Lesser General Public License as
50
- * published by the Free Software Foundation, either version 3 of the
51
- * License, or (at your option) any later version.
52
- *
53
- * melinda-commons-js is distributed in the hope that it will be useful,
54
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
55
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56
- * GNU Lesser General Public License for more details.
57
- *
58
- * You should have received a copy of the GNU Lesser General Public License
59
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
60
- *
61
- * @licend The above is the entire license notice
62
- * for the JavaScript code in this file.
63
- *
64
- */
65
-
66
38
  // Aleph creates partial subfields...
67
39
  _marcRecord.MarcRecord.setValidationOptions({
68
40
  subfieldValues: false
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_marcRecord","require","_subRecordPicker","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_error","_interopRequireDefault","MarcRecord","setValidationOptions","subfieldValues"],"sources":["../src/index.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for 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 {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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAEA,IAAAS,MAAA,GAAAC,sBAAA,CAAAhB,OAAA;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;AACAiB,sBAAU,CAACC,oBAAoB,CAAC;EAACC,cAAc,EAAE;AAAK,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_marcRecord","require","_subRecordPicker","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_error","_interopRequireDefault","MarcRecord","setValidationOptions","subfieldValues"],"sources":["../src/index.js"],"sourcesContent":["import {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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAEA,IAAAS,MAAA,GAAAC,sBAAA,CAAAhB,OAAA;AAPA;AACAiB,sBAAU,CAACC,oBAAoB,CAAC;EAACC,cAAc,EAAE;AAAK,CAAC,CAAC","ignoreList":[]}
@@ -9,34 +9,6 @@ var _sruClient = _interopRequireDefault(require("@natlibfi/sru-client"));
9
9
  var _marcRecordSerializers = require("@natlibfi/marc-record-serializers");
10
10
  var _debug = _interopRequireDefault(require("debug"));
11
11
  var _error = require("./error");
12
- /**
13
- *
14
- * @licstart The following is the entire license notice for the JavaScript code in this file.
15
- *
16
- * Shared modules for Melinda's software
17
- *
18
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
19
- *
20
- * This file is part of melinda-commons-js
21
- *
22
- * melinda-commons-js program is free software: you can redistribute it and/or modify
23
- * it under the terms of the GNU Lesser General Public License as
24
- * published by the Free Software Foundation, either version 3 of the
25
- * License, or (at your option) any later version.
26
- *
27
- * melinda-commons-js is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- * GNU Lesser General Public License for more details.
31
- *
32
- * You should have received a copy of the GNU Lesser General Public License
33
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
- *
35
- * @licend The above is the entire license notice
36
- * for the JavaScript code in this file.
37
- *
38
- */
39
-
40
12
  function createSubrecordPicker(sruUrl) {
41
13
  let retrieveAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
42
14
  if (sruUrl === undefined) {
@@ -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-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;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,CAAC,mBAAmBN,MAAM,EAAE,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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,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","ignoreList":[]}
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":["import 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":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,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,CAAC,mBAAmBN,MAAM,EAAE,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,SAAS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AAI;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","ignoreList":[]}
@@ -5,34 +5,6 @@ var _chai = require("chai");
5
5
  var _subRecordPicker = require("./subRecordPicker");
6
6
  var _fixura = require("@natlibfi/fixura");
7
7
  var _fixugenHttpClient = _interopRequireDefault(require("@natlibfi/fixugen-http-client"));
8
- /**
9
- *
10
- * @licstart The following is the entire license notice for the JavaScript code in this file.
11
- *
12
- * Shared modules for Melinda's software
13
- *
14
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
15
- *
16
- * This file is part of melinda-commons-js
17
- *
18
- * melinda-commons-js program is free software: you can redistribute it and/or modify
19
- * it under the terms of the GNU Lesser General Public License as
20
- * published by the Free Software Foundation, either version 3 of the
21
- * License, or (at your option) any later version.
22
- *
23
- * melinda-commons-js is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU Lesser General Public License for more details.
27
- *
28
- * You should have received a copy of the GNU Lesser General Public License
29
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
30
- *
31
- * @licend The above is the entire license notice
32
- * for the JavaScript code in this file.
33
- *
34
- */
35
-
36
8
  describe('subRecordPicker', () => {
37
9
  const sruUrl = 'https://sru';
38
10
  const retrieveAll = false;
@@ -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,CAAC,CAAC;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,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","ignoreList":[]}
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":["import {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":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEAK,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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C,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","ignoreList":[]}
package/dist/utils.js CHANGED
@@ -11,34 +11,6 @@ exports.getRecordTitle = getRecordTitle;
11
11
  exports.isDeletedRecord = isDeletedRecord;
12
12
  exports.parseBoolean = parseBoolean;
13
13
  exports.toAlephId = toAlephId;
14
- /**
15
- *
16
- * @licstart The following is the entire license notice for the JavaScript code in this file.
17
- *
18
- * Shared modules for Melinda's software
19
- *
20
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
21
- *
22
- * This file is part of melinda-commons-js
23
- *
24
- * melinda-commons-js program is free software: you can redistribute it and/or modify
25
- * it under the terms of the GNU Lesser General Public License as
26
- * published by the Free Software Foundation, either version 3 of the
27
- * License, or (at your option) any later version.
28
- *
29
- * melinda-commons-js is distributed in the hope that it will be useful,
30
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
- * GNU Lesser General Public License for more details.
33
- *
34
- * You should have received a copy of the GNU Lesser General Public License
35
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
36
- *
37
- * @licend The above is the entire license notice
38
- * for the JavaScript code in this file.
39
- *
40
- */
41
-
42
14
  function generateAuthorizationHeader(username) {
43
15
  let password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
44
16
  const encoded = Buffer.from(`${username}:${password}`).toString('base64');
@@ -92,6 +64,7 @@ function parseBoolean(value) {
92
64
  }
93
65
  function getRecordTitle(record) {
94
66
  const TRIM_PATTERN = '[?!.,(){}:;/ ]*';
67
+ // DEVELOP: get mainHeadings for aut records
95
68
  const field = record.get(/^245$/u).find(f => f.subfields.some(sf => sf.code === 'a'));
96
69
  if (field) {
97
70
  return field.subfields.find(sf => sf.code === 'a').value.replace(new RegExp(`^${TRIM_PATTERN}`, 'u'), '').replace(new RegExp(`${TRIM_PATTERN}$`, 'u'), '');
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}\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,CAAC,GAAGP,QAAQ,IAAIC,QAAQ,EAAE,CAAC,CAACO,QAAQ,CA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E,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","ignoreList":[]}
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":["export 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 // DEVELOP: get mainHeadings for aut records\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":";;;;;;;;;;;;;AAAO,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,CAAC,GAAGP,QAAQ,IAAIC,QAAQ,EAAE,CAAC,CAACO,QAAQ,CAAC,QAAQ,CAAC;EACzE,OAAO,SAASH,OAAO,EAAE;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,OAAO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AAS,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","ignoreList":[]}
@@ -6,34 +6,6 @@ var _path = _interopRequireDefault(require("path"));
6
6
  var _chai = require("chai");
7
7
  var _marcRecord = require("@natlibfi/marc-record");
8
8
  var _utils = require("./utils");
9
- /**
10
- *
11
- * @licstart The following is the entire license notice for the JavaScript code in this file.
12
- *
13
- * Shared modules for Melinda's software
14
- *
15
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
16
- *
17
- * This file is part of melinda-commons-js
18
- *
19
- * melinda-commons-js program is free software: you can redistribute it and/or modify
20
- * it under the terms of the GNU Lesser General Public License as
21
- * published by the Free Software Foundation, either version 3 of the
22
- * License, or (at your option) any later version.
23
- *
24
- * melinda-commons-js is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU Lesser General Public License for more details.
28
- *
29
- * You should have received a copy of the GNU Lesser General Public License
30
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
31
- *
32
- * @licend The above is the entire license notice
33
- * for the JavaScript code in this file.
34
- *
35
- */
36
-
37
9
  _marcRecord.MarcRecord.setValidationOptions({
38
10
  subfieldValues: false
39
11
  });
@@ -1 +1 @@
1
- {"version":3,"file":"utils.spec.js","names":["_fs","_interopRequireDefault","require","_path","_chai","_marcRecord","_utils","MarcRecord","setValidationOptions","subfieldValues","FIXTURES_PATH","path","join","__dirname","describe","it","value","generateAuthorizationHeader","expect","to","equal","data","fs","readFileSync","record","JSON","parse","isDeletedRecord","parseBoolean","undefined","forEach","descr","index","title","recordData","getRecordTitle","identifiers","getRecordStandardIdentifiers","eql","arguments","length","obj","cloned","clone","not"],"sources":["../src/utils.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 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 it('Should parse literal \\'FALSE\\' value as false', () => {\n expect(parseBoolean('FALSE')).to.equal(false);\n });\n\n it('Should parse literal \\'FAlsE\\' value as false', () => {\n expect(parseBoolean('FAlsE')).to.equal(false);\n });\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"],"mappings":";;;AA4BA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAhCA;AACA;AAC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AAsCsB,KAAK,OAAO,CAAC,EAAE,MAAM,CAAC;QACxH,MAAMR,MAAM,GAAG,IAAIjB,sBAAU,CAACkB,IAAI,CAACC,KAAK,CAACQ,UAAU,CAAC,CAAC;QAErD,IAAAhB,YAAM,EAAC,IAAAmB,mCAA4B,EAACb,MAAM,CAAC,CAAC,CAACL,EAAE,CAACmB,GAAG,CAACF,WAAW,CAAC;MAClE,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFtB,QAAQ,CAAC,OAAO,EAAE,MAAM;IACtBC,EAAE,CAAC,wBAAwB,EAAE,YAAiB;MAAA,IAAhBiB,KAAK,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAV,SAAA,GAAAU,SAAA,MAAG,GAAG;MACvC,MAAME,GAAG,GAAGhB,IAAI,CAACC,KAAK,CAACJ,WAAE,CAACC,YAAY,CAACZ,aAAI,CAACC,IAAI,CAACF,aAAa,EAAE,SAASsB,KAAK,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;MACpG,MAAMU,MAAM,GAAG,IAAAC,YAAK,EAACF,GAAG,CAAC;MAEzB,IAAAvB,YAAM,EAACuB,GAAG,CAAC,CAACtB,EAAE,CAACyB,GAAG,CAACxB,KAAK,CAACsB,MAAM,CAAC;MAChC,IAAAxB,YAAM,EAACwB,MAAM,CAAC,CAACvB,EAAE,CAACmB,GAAG,CAACG,GAAG,CAAC;IAC5B,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils.spec.js","names":["_fs","_interopRequireDefault","require","_path","_chai","_marcRecord","_utils","MarcRecord","setValidationOptions","subfieldValues","FIXTURES_PATH","path","join","__dirname","describe","it","value","generateAuthorizationHeader","expect","to","equal","data","fs","readFileSync","record","JSON","parse","isDeletedRecord","parseBoolean","undefined","forEach","descr","index","title","recordData","getRecordTitle","identifiers","getRecordStandardIdentifiers","eql","arguments","length","obj","cloned","clone","not"],"sources":["../src/utils.spec.js"],"sourcesContent":["import 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 it('Should parse literal \\'FALSE\\' value as false', () => {\n expect(parseBoolean('FALSE')).to.equal(false);\n });\n\n it('Should parse literal \\'FAlsE\\' value as false', () => {\n expect(parseBoolean('FAlsE')).to.equal(false);\n });\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"],"mappings":";;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAKAK,sBAAU,CAACC,oBAAoB,CAAC;EAACC,cAAc,EAAE;AAAK,CAAC,CAAC;AAExD,MAAMC,aAAa,GAAGC,aAAI,CAACC,IAAI,CAACC,SAAS,EAAE,wBAAwB,CAAC;AAEpEC,QAAQ,CAAC,OAAO,EAAE,MAAM;EACtBA,QAAQ,CAAC,6BAA6B,EAAE,MAAM;IAC5CC,EAAE,CAAC,6CAA6C,EAAE,MAAM;MACtD,MAAMC,KAAK,GAAG,IAAAC,kCAA2B,EAAC,KAAK,EAAE,KAAK,CAAC;MACvD,IAAAC,YAAM,EAACF,KAAK,CAAC,CAACG,EAAE,CAACC,KAAK,CAAC,oBAAoB,CAAC;IAC9C,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFN,QAAQ,CAAC,iBAAiB,EAAE,MAAM;IAChCC,EAAE,CAAC,yCAAyC,EAAE,MAAM;MAClD,MAAMM,IAAI,GAAGC,WAAE,CAAC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AAC;MAEzB,IAAAvB,YAAM,EAACuB,GAAG,CAAC,CAACtB,EAAE,CAACyB,GAAG,CAACxB,KAAK,CAACsB,MAAM,CAAC;MAChC,IAAAxB,YAAM,EAACwB,MAAM,CAAC,CAACvB,EAAE,CAACmB,GAAG,CAACG,GAAG,CAAC;IAC5B,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
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.19-alpha.2",
17
+ "version": "13.0.19",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=18"
@@ -36,32 +36,28 @@
36
36
  "dev:debug": "cross-env LOG_LEVEL=debug DEBUG=@natlibfi/* NODE_ENV=test nodemon"
37
37
  },
38
38
  "dependencies": {
39
- "@natlibfi/marc-record": "^9.1.0-alpha.3",
40
- "@natlibfi/marc-record-serializers": "^10.1.3-alpha.2",
41
- "@natlibfi/sru-client": "^6.0.15",
42
- "debug": "^4.3.7",
43
- "deep-eql": "^5.0.2",
44
- "http-status": "^1.8.1",
45
- "moment": "^2.30.1",
46
- "nock": "^13.5.5"
39
+ "@natlibfi/marc-record": "^9.1.2",
40
+ "@natlibfi/marc-record-serializers": "^10.1.5",
41
+ "@natlibfi/sru-client": "^6.0.17",
42
+ "debug": "^4.4.0"
47
43
  },
48
44
  "devDependencies": {
49
- "@babel/cli": "^7.25.7",
50
- "@babel/core": "^7.25.8",
51
- "@babel/node": "^7.25.7",
52
- "@babel/plugin-transform-runtime": "^7.25.7",
53
- "@babel/preset-env": "^7.25.8",
54
- "@babel/register": "^7.25.7",
45
+ "@babel/cli": "^7.26.4",
46
+ "@babel/core": "^7.26.0",
47
+ "@babel/node": "^7.26.0",
48
+ "@babel/plugin-transform-runtime": "^7.25.9",
49
+ "@babel/preset-env": "^7.26.0",
50
+ "@babel/register": "^7.25.9",
55
51
  "@natlibfi/eslint-config-melinda-backend": "^3.0.5",
56
52
  "@natlibfi/fixugen-http-client": "^3.0.10",
57
- "@natlibfi/fixura": "^3.0.10",
53
+ "@natlibfi/fixura": "^3.0.11",
58
54
  "babel-plugin-istanbul": "^7.0.0",
59
55
  "babel-plugin-rewire": "^1.2.0",
60
56
  "chai": "^4.5.0",
61
57
  "cross-env": "^7.0.3",
62
58
  "eslint": "^8.57.1",
63
- "mocha": "^10.7.3",
64
- "nodemon": "^3.1.7",
59
+ "mocha": "^11.0.1",
60
+ "nodemon": "^3.1.9",
65
61
  "nyc": "^17.1.0"
66
62
  },
67
63
  "eslintConfig": {
package/src/error.js CHANGED
@@ -1,31 +1,3 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Shared modules for Melinda's software
6
- *
7
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of melinda-commons-js
10
- *
11
- * melinda-commons-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * melinda-commons-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
1
  export default class extends Error {
30
2
  constructor(status, payload, ...params) {
31
3
  super(params);
package/src/error.spec.js CHANGED
@@ -1,31 +1,3 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Shared modules for Melinda's software
6
- *
7
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of melinda-commons-js
10
- *
11
- * melinda-commons-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * melinda-commons-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
1
  import {expect} from 'chai';
30
2
  import CommonsError from './error';
31
3
 
package/src/index.js CHANGED
@@ -1,31 +1,3 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Shared modules for Melinda's software
6
- *
7
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of melinda-commons-js
10
- *
11
- * melinda-commons-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * melinda-commons-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
1
  import {MarcRecord} from '@natlibfi/marc-record';
30
2
 
31
3
  // Aleph creates partial subfields...
@@ -1,31 +1,3 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Shared modules for Melinda's software
6
- *
7
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of melinda-commons-js
10
- *
11
- * melinda-commons-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * melinda-commons-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
1
  import createSruClient from '@natlibfi/sru-client';
30
2
  import {MARCXML} from '@natlibfi/marc-record-serializers';
31
3
  import createDebugLogger from 'debug';
@@ -1,31 +1,3 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Shared modules for Melinda's software
6
- *
7
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of melinda-commons-js
10
- *
11
- * melinda-commons-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * melinda-commons-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
1
  import {expect} from 'chai';
30
2
  import {createSubrecordPicker} from './subRecordPicker';
31
3
  import {READERS} from '@natlibfi/fixura';
package/src/utils.js CHANGED
@@ -1,31 +1,3 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Shared modules for Melinda's software
6
- *
7
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of melinda-commons-js
10
- *
11
- * melinda-commons-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * melinda-commons-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
1
  export function generateAuthorizationHeader(username, password = '') {
30
2
  const encoded = Buffer.from(`${username}:${password}`).toString('base64');
31
3
  return `Basic ${encoded}`;
@@ -70,6 +42,7 @@ export function parseBoolean(value) {
70
42
 
71
43
  export function getRecordTitle(record) {
72
44
  const TRIM_PATTERN = '[?!.,(){}:;/ ]*';
45
+ // DEVELOP: get mainHeadings for aut records
73
46
  const field = record
74
47
  .get(/^245$/u)
75
48
  .find(f => f.subfields.some(sf => sf.code === 'a'));
package/src/utils.spec.js CHANGED
@@ -1,31 +1,3 @@
1
- /**
2
- *
3
- * @licstart The following is the entire license notice for the JavaScript code in this file.
4
- *
5
- * Shared modules for Melinda's software
6
- *
7
- * Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)
8
- *
9
- * This file is part of melinda-commons-js
10
- *
11
- * melinda-commons-js program is free software: you can redistribute it and/or modify
12
- * it under the terms of the GNU Lesser General Public License as
13
- * published by the Free Software Foundation, either version 3 of the
14
- * License, or (at your option) any later version.
15
- *
16
- * melinda-commons-js is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU Lesser General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU Lesser General Public License
22
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
- *
24
- * @licend The above is the entire license notice
25
- * for the JavaScript code in this file.
26
- *
27
- */
28
-
29
1
  import fs from 'fs';
30
2
  import path from 'path';
31
3
  import {expect} from 'chai';