@natlibfi/melinda-commons 12.0.4-alpha.4 → 12.0.4
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/.github/workflows/melinda-node-tests.yml +1 -1
- package/LICENSE.txt +21 -165
- package/README.md +1 -1
- package/dist/subRecordPicker.js +5 -5
- package/dist/subRecordPicker.js.map +1 -1
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/dist/utils.spec.js +5 -5
- package/dist/utils.spec.js.map +1 -1
- package/package.json +17 -17
package/LICENSE.txt
CHANGED
|
@@ -1,165 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
An "Application" is any work that makes use of an interface provided
|
|
23
|
-
by the Library, but which is not otherwise based on the Library.
|
|
24
|
-
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
-
of using an interface provided by the Library.
|
|
26
|
-
|
|
27
|
-
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
-
Application with the Library. The particular version of the Library
|
|
29
|
-
with which the Combined Work was made is also called the "Linked
|
|
30
|
-
Version".
|
|
31
|
-
|
|
32
|
-
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
-
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
-
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
-
based on the Application, and not on the Linked Version.
|
|
36
|
-
|
|
37
|
-
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
-
object code and/or source code for the Application, including any data
|
|
39
|
-
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
-
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
-
|
|
42
|
-
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
-
|
|
44
|
-
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
-
without being bound by section 3 of the GNU GPL.
|
|
46
|
-
|
|
47
|
-
2. Conveying Modified Versions.
|
|
48
|
-
|
|
49
|
-
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
-
facility refers to a function or data to be supplied by an Application
|
|
51
|
-
that uses the facility (other than as an argument passed when the
|
|
52
|
-
facility is invoked), then you may convey a copy of the modified
|
|
53
|
-
version:
|
|
54
|
-
|
|
55
|
-
a) under this License, provided that you make a good faith effort to
|
|
56
|
-
ensure that, in the event an Application does not supply the
|
|
57
|
-
function or data, the facility still operates, and performs
|
|
58
|
-
whatever part of its purpose remains meaningful, or
|
|
59
|
-
|
|
60
|
-
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
-
this License applicable to that copy.
|
|
62
|
-
|
|
63
|
-
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
-
|
|
65
|
-
The object code form of an Application may incorporate material from
|
|
66
|
-
a header file that is part of the Library. You may convey such object
|
|
67
|
-
code under terms of your choice, provided that, if the incorporated
|
|
68
|
-
material is not limited to numerical parameters, data structure
|
|
69
|
-
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
-
(ten or fewer lines in length), you do both of the following:
|
|
71
|
-
|
|
72
|
-
a) Give prominent notice with each copy of the object code that the
|
|
73
|
-
Library is used in it and that the Library and its use are
|
|
74
|
-
covered by this License.
|
|
75
|
-
|
|
76
|
-
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
-
document.
|
|
78
|
-
|
|
79
|
-
4. Combined Works.
|
|
80
|
-
|
|
81
|
-
You may convey a Combined Work under terms of your choice that,
|
|
82
|
-
taken together, effectively do not restrict modification of the
|
|
83
|
-
portions of the Library contained in the Combined Work and reverse
|
|
84
|
-
engineering for debugging such modifications, if you also do each of
|
|
85
|
-
the following:
|
|
86
|
-
|
|
87
|
-
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
-
the Library is used in it and that the Library and its use are
|
|
89
|
-
covered by this License.
|
|
90
|
-
|
|
91
|
-
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
-
document.
|
|
93
|
-
|
|
94
|
-
c) For a Combined Work that displays copyright notices during
|
|
95
|
-
execution, include the copyright notice for the Library among
|
|
96
|
-
these notices, as well as a reference directing the user to the
|
|
97
|
-
copies of the GNU GPL and this license document.
|
|
98
|
-
|
|
99
|
-
d) Do one of the following:
|
|
100
|
-
|
|
101
|
-
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
-
License, and the Corresponding Application Code in a form
|
|
103
|
-
suitable for, and under terms that permit, the user to
|
|
104
|
-
recombine or relink the Application with a modified version of
|
|
105
|
-
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
-
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
-
Corresponding Source.
|
|
108
|
-
|
|
109
|
-
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
-
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
-
a copy of the Library already present on the user's computer
|
|
112
|
-
system, and (b) will operate properly with a modified version
|
|
113
|
-
of the Library that is interface-compatible with the Linked
|
|
114
|
-
Version.
|
|
115
|
-
|
|
116
|
-
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
-
be required to provide such information under section 6 of the
|
|
118
|
-
GNU GPL, and only to the extent that such information is
|
|
119
|
-
necessary to install and execute a modified version of the
|
|
120
|
-
Combined Work produced by recombining or relinking the
|
|
121
|
-
Application with a modified version of the Linked Version. (If
|
|
122
|
-
you use option 4d0, the Installation Information must accompany
|
|
123
|
-
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
-
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
-
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
-
for conveying Corresponding Source.)
|
|
127
|
-
|
|
128
|
-
5. Combined Libraries.
|
|
129
|
-
|
|
130
|
-
You may place library facilities that are a work based on the
|
|
131
|
-
Library side by side in a single library together with other library
|
|
132
|
-
facilities that are not Applications and are not covered by this
|
|
133
|
-
License, and convey such a combined library under terms of your
|
|
134
|
-
choice, if you do both of the following:
|
|
135
|
-
|
|
136
|
-
a) Accompany the combined library with a copy of the same work based
|
|
137
|
-
on the Library, uncombined with any other library facilities,
|
|
138
|
-
conveyed under the terms of this License.
|
|
139
|
-
|
|
140
|
-
b) Give prominent notice with the combined library that part of it
|
|
141
|
-
is a work based on the Library, and explaining where to find the
|
|
142
|
-
accompanying uncombined form of the same work.
|
|
143
|
-
|
|
144
|
-
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
-
|
|
146
|
-
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
-
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
-
versions will be similar in spirit to the present version, but may
|
|
149
|
-
differ in detail to address new problems or concerns.
|
|
150
|
-
|
|
151
|
-
Each version is given a distinguishing version number. If the
|
|
152
|
-
Library as you received it specifies that a certain numbered version
|
|
153
|
-
of the GNU Lesser General Public License "or any later version"
|
|
154
|
-
applies to it, you have the option of following the terms and
|
|
155
|
-
conditions either of that published version or of any later version
|
|
156
|
-
published by the Free Software Foundation. If the Library as you
|
|
157
|
-
received it does not specify a version number of the GNU Lesser
|
|
158
|
-
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
-
General Public License ever published by the Free Software Foundation.
|
|
160
|
-
|
|
161
|
-
If the Library as you received it specifies that a proxy can decide
|
|
162
|
-
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
-
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
-
permanent authorization for you to choose that version for the
|
|
165
|
-
Library.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-present University Of Helsinki (The National Library Of Finland)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -7,4 +7,4 @@ Shared modules for Melinda's software
|
|
|
7
7
|
|
|
8
8
|
Copyright (c) 2018-2022 **University Of Helsinki (The National Library Of Finland)**
|
|
9
9
|
|
|
10
|
-
This project's source code is licensed under the terms of **
|
|
10
|
+
This project's source code is licensed under the terms of **MIT** or any later version.
|
package/dist/subRecordPicker.js
CHANGED
|
@@ -51,7 +51,7 @@ function createSubrecordPicker(sruUrl) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const debug = (0, _debug.default)('@natlibfi/melinda-commons:subRecordPicker');
|
|
54
|
-
debug(
|
|
54
|
+
debug(`SRU client url: ${sruUrl}`);
|
|
55
55
|
const sruClient = (0, _sruClient.default)({
|
|
56
56
|
url: sruUrl,
|
|
57
57
|
recordSchema: 'marcxml',
|
|
@@ -64,10 +64,10 @@ function createSubrecordPicker(sruUrl) {
|
|
|
64
64
|
|
|
65
65
|
function readSomeSubrecords(recordId) {
|
|
66
66
|
let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
67
|
-
debug(
|
|
67
|
+
debug(`Picking subrecords for ${recordId}`);
|
|
68
68
|
return new Promise((resolve, reject) => {
|
|
69
69
|
const promises = [];
|
|
70
|
-
sruClient.searchRetrieve(
|
|
70
|
+
sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`, {
|
|
71
71
|
startRecord: offset
|
|
72
72
|
}).on('record', xmlString => {
|
|
73
73
|
promises.push(_marcRecordSerializers.MARCXML.from(xmlString, {
|
|
@@ -88,10 +88,10 @@ function createSubrecordPicker(sruUrl) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function readAllSubrecords(recordId) {
|
|
91
|
-
debug(
|
|
91
|
+
debug(`Picking subrecords for ${recordId}`);
|
|
92
92
|
return new Promise((resolve, reject) => {
|
|
93
93
|
const promises = [];
|
|
94
|
-
sruClient.searchRetrieve(
|
|
94
|
+
sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`).on('record', xmlString => {
|
|
95
95
|
promises.push(_marcRecordSerializers.MARCXML.from(xmlString, {
|
|
96
96
|
subfieldValues: false
|
|
97
97
|
})); // eslint-disable-line functional/immutable-data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subRecordPicker.js","names":["createSubrecordPicker","sruUrl","retrieveAll","undefined","ApiError","debug","createDebugLogger","sruClient","createSruClient","url","recordSchema","readSomeSubrecords","readAllSubrecords","recordId","offset","Promise","resolve","reject","promises","searchRetrieve","startRecord","on","xmlString","push","MARCXML","from","subfieldValues","nextRecordOffset","records","all","error","err"],"sources":["../src/subRecordPicker.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-commons-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createSruClient from '@natlibfi/sru-client';\nimport {MARCXML} from '@natlibfi/marc-record-serializers';\nimport createDebugLogger from 'debug';\nimport {Error as ApiError} from './error';\n\nexport function createSubrecordPicker(sruUrl, retrieveAll = false) {\n if (sruUrl === undefined) { // eslint-disable-line functional/no-conditional-statement\n throw new ApiError(400, 'Invalid sru url');\n }\n\n const debug = createDebugLogger('@natlibfi/melinda-commons:subRecordPicker');\n debug(`SRU client url: ${sruUrl}`);\n const sruClient = createSruClient({url: sruUrl, recordSchema: 'marcxml', retrieveAll});\n\n return {readSomeSubrecords, readAllSubrecords};\n\n function readSomeSubrecords(recordId, offset = 1) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`, {startRecord: offset})\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async nextRecordOffset => {\n try {\n const records = await Promise.all(promises);\n resolve({nextRecordOffset, records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n\n function readAllSubrecords(recordId) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`)\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async () => {\n try {\n const records = await Promise.all(promises);\n resolve({records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n}\n"],"mappings":";;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;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,SAASA,qBAAT,CAA+BC,MAA/B,EAA4D;EAAA,IAArBC,WAAqB,uEAAP,KAAO;;EACjE,IAAID,MAAM,KAAKE,SAAf,EAA0B;IAAE;IAC1B,MAAM,IAAIC,YAAJ,CAAa,GAAb,EAAkB,iBAAlB,CAAN;EACD;;EAED,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAkB,2CAAlB,CAAd;EACAD,KAAK,
|
|
1
|
+
{"version":3,"file":"subRecordPicker.js","names":["createSubrecordPicker","sruUrl","retrieveAll","undefined","ApiError","debug","createDebugLogger","sruClient","createSruClient","url","recordSchema","readSomeSubrecords","readAllSubrecords","recordId","offset","Promise","resolve","reject","promises","searchRetrieve","startRecord","on","xmlString","push","MARCXML","from","subfieldValues","nextRecordOffset","records","all","error","err"],"sources":["../src/subRecordPicker.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for Melinda's software\n*\n* Copyright (C) 2018-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-commons-js\n*\n* melinda-commons-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-commons-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Lesser General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createSruClient from '@natlibfi/sru-client';\nimport {MARCXML} from '@natlibfi/marc-record-serializers';\nimport createDebugLogger from 'debug';\nimport {Error as ApiError} from './error';\n\nexport function createSubrecordPicker(sruUrl, retrieveAll = false) {\n if (sruUrl === undefined) { // eslint-disable-line functional/no-conditional-statement\n throw new ApiError(400, 'Invalid sru url');\n }\n\n const debug = createDebugLogger('@natlibfi/melinda-commons:subRecordPicker');\n debug(`SRU client url: ${sruUrl}`);\n const sruClient = createSruClient({url: sruUrl, recordSchema: 'marcxml', retrieveAll});\n\n return {readSomeSubrecords, readAllSubrecords};\n\n function readSomeSubrecords(recordId, offset = 1) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`, {startRecord: offset})\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async nextRecordOffset => {\n try {\n const records = await Promise.all(promises);\n resolve({nextRecordOffset, records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n\n function readAllSubrecords(recordId) {\n debug(`Picking subrecords for ${recordId}`);\n return new Promise((resolve, reject) => {\n const promises = [];\n sruClient.searchRetrieve(`melinda.partsofhost=${recordId}`)\n .on('record', xmlString => {\n promises.push(MARCXML.from(xmlString, {subfieldValues: false})); // eslint-disable-line functional/immutable-data\n })\n .on('end', async () => {\n try {\n const records = await Promise.all(promises);\n resolve({records});\n } catch (error) {\n reject(error);\n }\n })\n .on('error', err => reject(err));\n });\n }\n}\n"],"mappings":";;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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c;UACdb,MAAM,CAACa,KAAD,CAAN;QACD;MACF,CAXH,EAYGT,EAZH,CAYM,OAZN,EAYeU,GAAG,IAAId,MAAM,CAACc,GAAD,CAZ5B;IAaD,CAfM,CAAP;EAgBD;;EAED,SAASnB,iBAAT,CAA2BC,QAA3B,EAAqC;IACnCR,KAAK,CAAE,0BAAyBQ,QAAS,EAApC,CAAL;IACA,OAAO,IAAIE,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;MACtC,MAAMC,QAAQ,GAAG,EAAjB;MACAX,SAAS,CAACY,cAAV,CAA0B,uBAAsBN,QAAS,EAAzD,EACGQ,EADH,CACM,QADN,EACgBC,SAAS,IAAI;QACzBJ,QAAQ,CAACK,IAAT,CAAcC,8BAAA,CAAQC,IAAR,CAAaH,SAAb,EAAwB;UAACI,cAAc,EAAE;QAAjB,CAAxB,CAAd,EADyB,CACwC;MAClE,CAHH,EAIGL,EAJH,CAIM,KAJN,EAIa,YAAY;QACrB,IAAI;UACF,MAAMO,OAAO,GAAG,MAAMb,OAAO,CAACc,GAAR,CAAYX,QAAZ,CAAtB;UACAF,OAAO,CAAC;YAACY;UAAD,CAAD,CAAP;QACD,CAHD,CAGE,OAAOE,KAAP,EAAc;UACdb,MAAM,CAACa,KAAD,CAAN;QACD;MACF,CAXH,EAYGT,EAZH,CAYM,OAZN,EAYeU,GAAG,IAAId,MAAM,CAACc,GAAD,CAZ5B;IAaD,CAfM,CAAP;EAgBD;AACF"}
|
package/dist/utils.js
CHANGED
|
@@ -41,8 +41,8 @@ exports.toAlephId = toAlephId;
|
|
|
41
41
|
*/
|
|
42
42
|
function generateAuthorizationHeader(username) {
|
|
43
43
|
let password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
44
|
-
const encoded = Buffer.from(
|
|
45
|
-
return
|
|
44
|
+
const encoded = Buffer.from(`${username}:${password}`).toString('base64');
|
|
45
|
+
return `Basic ${encoded}`;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function isDeletedRecord(record) {
|
|
@@ -105,7 +105,7 @@ function getRecordTitle(record) {
|
|
|
105
105
|
const field = record.get(/^245$/u).find(f => f.subfields.some(sf => sf.code === 'a'));
|
|
106
106
|
|
|
107
107
|
if (field) {
|
|
108
|
-
return field.subfields.find(sf => sf.code === 'a').value.replace(new RegExp(
|
|
108
|
+
return field.subfields.find(sf => sf.code === 'a').value.replace(new RegExp(`^${TRIM_PATTERN}`, 'u'), '').replace(new RegExp(`${TRIM_PATTERN}$`, 'u'), '');
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
return '';
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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","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,2BAAT,CAAqCC,QAArC,EAA8D;EAAA,IAAfC,QAAe,uEAAJ,EAAI;EACnE,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAP,
|
|
1
|
+
{"version":3,"file":"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","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,2BAAT,CAAqCC,QAArC,EAA8D;EAAA,IAAfC,QAAe,uEAAJ,EAAI;EACnE,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAP,CAAa,GAAEJ,QAAS,IAAGC,QAAS,EAApC,EAAuCI,QAAvC,CAAgD,QAAhD,CAAhB;EACA,OAAQ,SAAQH,OAAQ,EAAxB;AACD;;AAEM,SAASI,eAAT,CAAyBC,MAAzB,EAAiC;EACtC,IAAI,CAAC,GAA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,OAAOC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,SAAL,CAAeH,CAAf,CAAX,CAAP;AACD;;AAEM,SAASI,SAAT,CAAmBC,EAAnB,EAAuB;EAC5B,OAAOA,EAAE,CAACC,QAAH,CAAY,CAAZ,EAAe,GAAf,CAAP;AACD;;AAEM,SAASC,WAAT,CAAqBF,EAArB,EAAyB;EAC9B,OAAOA,EAAE,CAACZ,OAAH,CAAW,MAAX,EAAmB,EAAnB,CAAP;AACD"}
|
package/dist/utils.spec.js
CHANGED
|
@@ -131,9 +131,9 @@ describe('utils', () => {
|
|
|
131
131
|
describe('getRecordTitle', () => {
|
|
132
132
|
['Should find a title', 'Should not find a title'].forEach((descr, index) => {
|
|
133
133
|
it(descr, () => {
|
|
134
|
-
const title = _fs.default.readFileSync(_path.default.join(FIXTURES_PATH,
|
|
134
|
+
const title = _fs.default.readFileSync(_path.default.join(FIXTURES_PATH, `getRecordTitle/title${index}.txt`), 'utf8');
|
|
135
135
|
|
|
136
|
-
const recordData = _fs.default.readFileSync(_path.default.join(FIXTURES_PATH,
|
|
136
|
+
const recordData = _fs.default.readFileSync(_path.default.join(FIXTURES_PATH, `getRecordTitle/record${index}.json`), 'utf8');
|
|
137
137
|
|
|
138
138
|
const record = new _marcRecord.MarcRecord(JSON.parse(recordData));
|
|
139
139
|
(0, _chai.expect)((0, _utils.getRecordTitle)(record)).to.equal(title);
|
|
@@ -143,9 +143,9 @@ describe('utils', () => {
|
|
|
143
143
|
describe('getRecordStandardIdentifiers', () => {
|
|
144
144
|
['Should find identifiers', 'Should not find an identifier'].forEach((descr, index) => {
|
|
145
145
|
it(descr, () => {
|
|
146
|
-
const identifiers = JSON.parse(_fs.default.readFileSync(_path.default.join(FIXTURES_PATH,
|
|
146
|
+
const identifiers = JSON.parse(_fs.default.readFileSync(_path.default.join(FIXTURES_PATH, `getRecordStandardIdentifiers/identifiers${index}.json`), 'utf8'));
|
|
147
147
|
|
|
148
|
-
const recordData = _fs.default.readFileSync(_path.default.join(FIXTURES_PATH,
|
|
148
|
+
const recordData = _fs.default.readFileSync(_path.default.join(FIXTURES_PATH, `getRecordStandardIdentifiers/record${index}.json`), 'utf8');
|
|
149
149
|
|
|
150
150
|
const record = new _marcRecord.MarcRecord(JSON.parse(recordData));
|
|
151
151
|
(0, _chai.expect)((0, _utils.getRecordStandardIdentifiers)(record)).to.eql(identifiers);
|
|
@@ -155,7 +155,7 @@ describe('utils', () => {
|
|
|
155
155
|
describe('clone', () => {
|
|
156
156
|
it('Should clone an object', function () {
|
|
157
157
|
let index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '1';
|
|
158
|
-
const obj = JSON.parse(_fs.default.readFileSync(_path.default.join(FIXTURES_PATH,
|
|
158
|
+
const obj = JSON.parse(_fs.default.readFileSync(_path.default.join(FIXTURES_PATH, `clone/${index}/obj.json`), 'utf8'));
|
|
159
159
|
const cloned = (0, _utils.clone)(obj);
|
|
160
160
|
(0, _chai.expect)(obj).to.not.equal(cloned);
|
|
161
161
|
(0, _chai.expect)(cloned).to.eql(obj);
|
package/dist/utils.spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.spec.js","names":["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","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;;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,sBAAA,CAAWC,oBAAX,CAAgC;EAACC,cAAc,EAAE;AAAjB,CAAhC;;AAEA,MAAMC,aAAa,GAAGC,aAAA,CAAKC,IAAL,CAAUC,SAAV,EAAqB,wBAArB,CAAtB;;AAEAC,QAAQ,CAAC,OAAD,EAAU,MAAM;EACtBA,QAAQ,CAAC,6BAAD,EAAgC,MAAM;IAC5CC,EAAE,CAAC,6CAAD,EAAgD,MAAM;MACtD,MAAMC,KAAK,GAAG,IAAAC,kCAAA,EAA4B,KAA5B,EAAmC,KAAnC,CAAd;MACA,IAAAC,YAAA,EAAOF,KAAP,EAAcG,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AgBZ,aAAA,CAAKC,IAAL,CAAUF,aAAV,kBAAkCsB,KAAlC,eAAhB,EAAqE,MAArE,CAAX,CAAZ;MACA,MAAMQ,MAAM,GAAG,IAAAC,YAAA,EAAMF,GAAN,CAAf;MAEA,IAAArB,YAAA,EAAOqB,GAAP,EAAYpB,EAAZ,CAAeuB,GAAf,CAAmBtB,KAAnB,CAAyBoB,MAAzB;MACA,IAAAtB,YAAA,EAAOsB,MAAP,EAAerB,EAAf,CAAkBmB,GAAlB,CAAsBC,GAAtB;IACD,CANC,CAAF;EAOD,CARO,CAAR;AASD,CApIO,CAAR"}
|
|
1
|
+
{"version":3,"file":"utils.spec.js","names":["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","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;;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,sBAAA,CAAWC,oBAAX,CAAgC;EAACC,cAAc,EAAE;AAAjB,CAAhC;;AAEA,MAAMC,aAAa,GAAGC,aAAA,CAAKC,IAAL,CAAUC,SAAV,EAAqB,wBAArB,CAAtB;;AAEAC,QAAQ,CAAC,OAAD,EAAU,MAAM;EACtBA,QAAQ,CAAC,6BAAD,EAAgC,MAAM;IAC5CC,EAAE,CAAC,6CAAD,EAAgD,MAAM;MACtD,MAAMC,KAAK,GAAG,IAAAC,kCAAA,EAA4B,KAA5B,EAAmC,KAAnC,CAAd;MACA,IAAAC,YAAA,EAAOF,KAAP,EAAcG,EAAd,CAAiBC,KAAjB,CAAuB,oBAAvB;IACD,CAHC,CAAF;EAID,CALO,CAAR;EAOAN,QAAQ,CAAC,iBAAD,EAAoB,MAAM;IAChCC,EAAE,CAAC,yCAAD,EAA4C,MAAM;MAClD,MAAMM,IAAI,GAAGC,WAAA,CAAGC,YAAH,CAAgBZ,aAAA,CAAKC,IAAL,CAAUF,aAAV,EAAyB,8BAAzB,CAAhB,EAA0E,MAA1E,CAAb;;MACA,MAAMc,MAAM,GAAG,IAAIjB,sBAAJ,CAAekB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EAAOsB,MAAP,EAAerB,EAAf,CAAkBmB,GAAlB,CAAsBC,GAAtB;IACD,CANC,CAAF;EAOD,CARO,CAAR;AASD,CApIO,CAAR"}
|
package/package.json
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git@github.com:natlibfi/melinda-commons-js.git"
|
|
15
15
|
},
|
|
16
|
-
"license": "
|
|
17
|
-
"version": "12.0.4
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"version": "12.0.4",
|
|
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": "^7.2.
|
|
38
|
-
"@natlibfi/marc-record-serializers": "^9.0.0
|
|
39
|
-
"@natlibfi/sru-client": "^5.0.
|
|
37
|
+
"@natlibfi/marc-record": "^7.2.1",
|
|
38
|
+
"@natlibfi/marc-record-serializers": "^9.0.0",
|
|
39
|
+
"@natlibfi/sru-client": "^5.0.3",
|
|
40
40
|
"debug": "^4.3.4",
|
|
41
|
-
"deep-eql": "^4.1.
|
|
42
|
-
"http-status": "^1.5.
|
|
41
|
+
"deep-eql": "^4.1.1",
|
|
42
|
+
"http-status": "^1.5.3",
|
|
43
43
|
"moment": "^2.29.4",
|
|
44
44
|
"nock": "^13.2.9",
|
|
45
45
|
"node-fetch": "^2.6.7"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@babel/cli": "^7.
|
|
49
|
-
"@babel/core": "^7.
|
|
50
|
-
"@babel/eslint-parser": "^7.
|
|
51
|
-
"@babel/node": "^7.
|
|
52
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
53
|
-
"@babel/preset-env": "^7.
|
|
48
|
+
"@babel/cli": "^7.19.3",
|
|
49
|
+
"@babel/core": "^7.19.3",
|
|
50
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
51
|
+
"@babel/node": "^7.19.1",
|
|
52
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
53
|
+
"@babel/preset-env": "^7.19.3",
|
|
54
54
|
"@babel/register": "^7.18.9",
|
|
55
55
|
"@natlibfi/eslint-config-melinda-backend": "^2.0.1",
|
|
56
56
|
"@natlibfi/fixugen-http-client": "^2.0.1",
|
|
57
|
-
"@natlibfi/fixura": "^2.2.
|
|
57
|
+
"@natlibfi/fixura": "^2.2.5",
|
|
58
58
|
"babel-plugin-istanbul": "^6.1.1",
|
|
59
59
|
"babel-plugin-rewire": "^1.2.0",
|
|
60
60
|
"chai": "^4.3.6",
|
|
61
61
|
"cross-env": "^7.0.3",
|
|
62
|
-
"eslint": "^8.
|
|
63
|
-
"mocha": "^
|
|
64
|
-
"nodemon": "^2.0.
|
|
62
|
+
"eslint": "^8.24.0",
|
|
63
|
+
"mocha": "^10.0.0",
|
|
64
|
+
"nodemon": "^2.0.20",
|
|
65
65
|
"nyc": "^15.1.0"
|
|
66
66
|
},
|
|
67
67
|
"eslintConfig": {
|