@natlibfi/melinda-record-matching 2.2.0-alpha.4 → 2.2.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.github/CODEOWNERS +10 -0
  2. package/.github/dependabot.yml +40 -0
  3. package/.github/workflows/melinda-node-tests.yml +70 -0
  4. package/package.json +1 -1
  5. package/dist/candidate-search/candidate-search-utils.js +0 -58
  6. package/dist/candidate-search/candidate-search-utils.js.map +0 -1
  7. package/dist/candidate-search/index.js +0 -273
  8. package/dist/candidate-search/index.js.map +0 -1
  9. package/dist/candidate-search/index.spec.js +0 -161
  10. package/dist/candidate-search/index.spec.js.map +0 -1
  11. package/dist/candidate-search/query-list/bib.js +0 -252
  12. package/dist/candidate-search/query-list/bib.js.map +0 -1
  13. package/dist/candidate-search/query-list/bib.spec.js +0 -72
  14. package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
  15. package/dist/candidate-search/query-list/index.js +0 -67
  16. package/dist/candidate-search/query-list/index.js.map +0 -1
  17. package/dist/index.js +0 -578
  18. package/dist/index.js.map +0 -1
  19. package/dist/index.spec.js +0 -133
  20. package/dist/index.spec.js.map +0 -1
  21. package/dist/match-detection/features/bib/all-source-ids.js +0 -122
  22. package/dist/match-detection/features/bib/all-source-ids.js.map +0 -1
  23. package/dist/match-detection/features/bib/authors.js +0 -117
  24. package/dist/match-detection/features/bib/authors.js.map +0 -1
  25. package/dist/match-detection/features/bib/bibliographic-level.js +0 -42
  26. package/dist/match-detection/features/bib/bibliographic-level.js.map +0 -1
  27. package/dist/match-detection/features/bib/host-component.js +0 -42
  28. package/dist/match-detection/features/bib/host-component.js.map +0 -1
  29. package/dist/match-detection/features/bib/index.js +0 -104
  30. package/dist/match-detection/features/bib/index.js.map +0 -1
  31. package/dist/match-detection/features/bib/index.spec.js +0 -97
  32. package/dist/match-detection/features/bib/index.spec.js.map +0 -1
  33. package/dist/match-detection/features/bib/isbn.js +0 -55
  34. package/dist/match-detection/features/bib/isbn.js.map +0 -1
  35. package/dist/match-detection/features/bib/issn.js +0 -55
  36. package/dist/match-detection/features/bib/issn.js.map +0 -1
  37. package/dist/match-detection/features/bib/language.js +0 -113
  38. package/dist/match-detection/features/bib/language.js.map +0 -1
  39. package/dist/match-detection/features/bib/melinda-id.js +0 -52
  40. package/dist/match-detection/features/bib/melinda-id.js.map +0 -1
  41. package/dist/match-detection/features/bib/melinda-identifier-factory.js +0 -100
  42. package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +0 -1
  43. package/dist/match-detection/features/bib/other-standard-identifier.js +0 -55
  44. package/dist/match-detection/features/bib/other-standard-identifier.js.map +0 -1
  45. package/dist/match-detection/features/bib/publication-time.js +0 -47
  46. package/dist/match-detection/features/bib/publication-time.js.map +0 -1
  47. package/dist/match-detection/features/bib/record-type.js +0 -42
  48. package/dist/match-detection/features/bib/record-type.js.map +0 -1
  49. package/dist/match-detection/features/bib/standard-identifier-factory.js +0 -126
  50. package/dist/match-detection/features/bib/standard-identifier-factory.js.map +0 -1
  51. package/dist/match-detection/features/bib/title.js +0 -91
  52. package/dist/match-detection/features/bib/title.js.map +0 -1
  53. package/dist/match-detection/features/index.js +0 -15
  54. package/dist/match-detection/features/index.js.map +0 -1
  55. package/dist/match-detection/index.js +0 -184
  56. package/dist/match-detection/index.js.map +0 -1
  57. package/dist/match-detection/index.spec.js +0 -99
  58. package/dist/match-detection/index.spec.js.map +0 -1
  59. package/dist/matching-utils.js +0 -95
  60. package/dist/matching-utils.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.spec.js","names":["debug","createDebugLogger","describe","generateTests","callback","path","__dirname","recurse","fixura","reader","READERS","JSON","getFixture","factoryOptions","searchOptions","expectedFactoryError","expectedSearchError","enabled","url","isCandidateSearchError","expect","createSearchInterface","formatFactoryOptions","to","throw","CandidateSearchError","RegExp","search","iterate","stringify","maxRecordsPerRequest","maxServerResults","undefined","record","MarcRecord","subfieldValues","expectedErrorStatus","count","expectedResults","Error","err","be","an","errorMessage","MatchingError","payload","message","errorStatus","status","match","results","formatResults","eql","records","map","id","toObject"],"sources":["../../src/candidate-search/index.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-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-record-matching-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 Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {expect} from 'chai';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen-http-client';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {Error as MatchingError} from '@natlibfi/melinda-commons';\nimport createSearchInterface, {CandidateSearchError} from '.';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:test');\n\ndescribe('candidate-search', () => {\n generateTests({\n callback,\n path: [__dirname, '..', '..', 'test-fixtures', 'candidate-search', 'index'],\n recurse: false,\n fixura: {\n reader: READERS.JSON\n }\n });\n\n // eslint-disable-next-line max-statements\n async function callback({getFixture, factoryOptions, searchOptions, expectedFactoryError = false, expectedSearchError = false, enabled = true}) {\n const url = 'http://foo.bar';\n\n if (!enabled) {\n return;\n }\n\n if (expectedFactoryError) {\n if (expectedFactoryError.isCandidateSearchError) {\n expect(() => createSearchInterface({...formatFactoryOptions(), url})).to.throw(CandidateSearchError, new RegExp(expectedFactoryError, 'u'));\n return;\n }\n\n expect(() => createSearchInterface({...formatFactoryOptions(), url})).to.throw(new RegExp(expectedFactoryError, 'u'));\n return;\n }\n\n const search = createSearchInterface({...formatFactoryOptions(), url});\n await iterate({searchOptions, expectedSearchError});\n\n function formatFactoryOptions() {\n debug(`Using factoryOptions: ${JSON.stringify(factoryOptions)}`);\n return {\n ...factoryOptions,\n maxRecordsPerRequest: factoryOptions.maxRecordsPerRequest || 1,\n maxServerResults: factoryOptions.maxServerResults || undefined,\n record: new MarcRecord(factoryOptions.record, {subfieldValues: false})\n };\n }\n\n // eslint-disable-next-line max-statements\n async function iterate({searchOptions, expectedSearchError, expectedErrorStatus, count = 1}) {\n const expectedResults = getFixture(`expectedResults${count}.json`);\n\n if (expectedSearchError) { // eslint-disable-line functional/no-conditional-statement\n try {\n await search(searchOptions);\n throw new Error('Expected an error');\n } catch (err) {\n debug(`Got an error: ${err}`);\n expect(err).to.be.an('error');\n const errorMessage = err instanceof MatchingError ? err.payload.message : err.message;\n const errorStatus = err instanceof MatchingError ? err.status : undefined;\n debug(`errorMessage: ${errorMessage}, errorStatus: ${errorStatus}`);\n expect(errorMessage).to.match(new RegExp(expectedSearchError, 'u'));\n\n if (expectedErrorStatus) {\n expect(errorStatus).to.be(expectedErrorStatus);\n return;\n }\n return;\n }\n }\n\n // eslint-disable-next-line functional/no-conditional-statement\n if (!expectedSearchError) {\n const results = await search(searchOptions);\n expect(formatResults(results)).to.eql(expectedResults);\n }\n\n function formatResults(results) {\n debug(results); //eslint-disable-line\n return {\n ...results,\n records: results.records.map(({record, id}) => ({id, record: record.toObject()}))\n };\n }\n\n }\n }\n});\n"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAlCA;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;AAUA,MAAMA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EAAqBpB,EAArB,CAAwB0B,KAAxB,CAA8B,IAAIvB,MAAJ,CAAWV,mBAAX,EAAgC,GAAhC,CAA9B;;UAEA,IAAIoB,mBAAJ,EAAyB;YACvB,IAAAhB,YAAA,EAAO2B,WAAP,EAAoBxB,EAApB,CAAuBkB,EAAvB,CAA0BL,mBAA1B;YACA;UACD;;UACD;QACD;MACF,CArB0F,CAuB3F;;;MACA,IAAI,CAACpB,mBAAL,EAA0B;QACxB,MAAMkC,OAAO,GAAG,MAAMvB,MAAM,CAACb,aAAD,CAA5B;QACA,IAAAM,YAAA,EAAO+B,aAAa,CAACD,OAAD,CAApB,EAA+B3B,EAA/B,CAAkC6B,GAAlC,CAAsCd,eAAtC;MACD;;MAED,SAASa,aAAT,CAAuBD,OAAvB,EAAgC;QAC9BlD,KAAK,CAACkD,OAAD,CAAL,CAD8B,CACd;;QAChB,OAAO,EACL,GAAGA,OADE;UAELG,OAAO,EAAEH,OAAO,CAACG,OAAR,CAAgBC,GAAhB,CAAoB,CAAC;YAACrB,MAAD;YAASsB;UAAT,CAAD,MAAmB;YAACA,EAAD;YAAKtB,MAAM,EAAEA,MAAM,CAACuB,QAAP;UAAb,CAAnB,CAApB;QAFJ,CAAP;MAID;IAEF;EACF;AACF,CAjFO,CAAR"}
@@ -1,252 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.bibHostComponents = bibHostComponents;
7
- exports.bibMelindaIds = bibMelindaIds;
8
- exports.bibSourceIds = bibSourceIds;
9
- exports.bibStandardIdentifiers = bibStandardIdentifiers;
10
- exports.bibTitle = bibTitle;
11
-
12
- var _debug = _interopRequireDefault(require("debug"));
13
-
14
- var _candidateSearchUtils = require("../candidate-search-utils");
15
-
16
- var _matchingUtils = require("../../matching-utils");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- /**
21
- *
22
- * @licstart The following is the entire license notice for the JavaScript code in this file.
23
- *
24
- * Melinda record matching modules for Javascript
25
- *
26
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
27
- *
28
- * This file is part of melinda-record-matching-js
29
- *
30
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
31
- * it under the terms of the GNU Lesser General Public License as
32
- * published by the Free Software Foundation, either version 3 of the
33
- * License, or (at your option) any later version.
34
- *
35
- * melinda-record-matching-js is distributed in the hope that it will be useful,
36
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
37
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38
- * GNU Lesser General Public License for more details.
39
- *
40
- * You should have received a copy of the GNU Affero General Public License
41
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
42
- *
43
- * @licend The above is the entire license notice
44
- * for the JavaScript code in this file.
45
- *
46
- */
47
- function bibSourceIds(record) {
48
- /* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records
49
- SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:
50
- SID__ $c 123457 $b helka
51
- SID__ $c (ANDL100020)1077305 $b sata
52
- SID__ $c VER999999 $ FI-KV
53
- SID__ $c /10024/508126 $ REPO_THESEUS
54
- In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:
55
- Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted
56
- 1234567helka
57
- 1077305sata
58
- VER999999FIKV
59
- /10024/508126REPO_THESEUS
60
- Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,
61
- existence of a SID field depends on how the record has been added to Melinda and how it has been handled
62
- afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db
63
- after the matching record is removed from the local db.
64
- */
65
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');
66
- const debugData = debug.extend('data'); //const debugInfo = debug.extend('info');
67
-
68
- debug(`Creating queries for sourceid's`);
69
- const fSids = record.get('SID');
70
- debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);
71
- return fSids.length > 0 ? toSidQueries(fSids) : [];
72
-
73
- function toSidQueries(fSids) {
74
- debug(`Creating actual queries for sourceid's`);
75
- const sidStrings = getSidStrings(fSids);
76
-
77
- if (sidStrings.length < 1) {
78
- debug(`No identifiers found, no queries created.`);
79
- return [];
80
- }
81
-
82
- const sidQueries = (0, _candidateSearchUtils.toQueries)(sidStrings, 'melinda.sourceid');
83
- return sidQueries;
84
-
85
- function getSidStrings(fSids) {
86
- debug(`Getting Sid strings from SID fields`); // Map SID fields to valid sidStrings, filter out empty strings
87
-
88
- const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);
89
- return sidStrings;
90
-
91
- function toSidString(field) {
92
- debug(`Getting string from a field`);
93
- return (0, _matchingUtils.validateSidFieldSubfieldCounts)(field) ? createSidString(field) : '';
94
-
95
- function createSidString(field) {
96
- debug(`Creating string from a field`);
97
- const [sfC] = (0, _matchingUtils.getSubfieldValues)(field, 'c');
98
- const [sfB] = (0, _matchingUtils.getSubfieldValues)(field, 'b');
99
- const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));
100
- const cleanedSfB = normalizeSidSubfieldValue(sfB);
101
- debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);
102
- return cleanedSfC.concat(cleanedSfB);
103
- }
104
-
105
- function removeSourcePrefix(subfieldValue) {
106
- const sourcePrefixRegex = /^(?<sourcePrefix>\([A-Za-z0-9-]+\))(?<id>.+)$/u;
107
- const normalizedValue = subfieldValue ? subfieldValue.replace(sourcePrefixRegex, '$<id>') : '';
108
- debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);
109
- return normalizedValue;
110
- }
111
-
112
- function normalizeSidSubfieldValue(subfieldValue) {
113
- debugData(`Normalizing ${subfieldValue}`);
114
- const normalizeAwayRegex = /[- ]/u;
115
- return subfieldValue ? subfieldValue.replace(normalizeAwayRegex, '') : '';
116
- }
117
- }
118
- }
119
- }
120
- }
121
-
122
- function bibMelindaIds(record) {
123
- // Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records
124
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');
125
- const debugData = debug.extend('data');
126
- debug(`Creating queries for MelindaIds`); // Note: Melinda-ID's for search queries are created just from records f035a's and f035z's
127
- // Both (FI-MELINDA)- and FCC-prefixed forms are found
128
- // f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA
129
-
130
- const melindaIds = (0, _matchingUtils.getMelindaIdsF035)(record);
131
- debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);
132
-
133
- if (melindaIds.length < 1) {
134
- debug(`No identifiers found, no queries created.`);
135
- return [];
136
- }
137
-
138
- return (0, _candidateSearchUtils.toQueries)(melindaIds, 'melinda.melindaid');
139
- } // bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05
140
- // bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?
141
-
142
-
143
- function bibHostComponents(record) {
144
- const id = getHostId();
145
- return id ? [`melinda.partsofhost=${id}`] : [];
146
-
147
- function getHostId() {
148
- const [field] = record.get(/^773$/u);
149
-
150
- if (field) {
151
- const {
152
- value
153
- } = field.subfields.find(({
154
- code
155
- }) => code === 'w') || {};
156
-
157
- if (value && /^\(FI-MELINDA\)/u.test(value)) {
158
- return value.replace(/^\(FI-MELINDA\)/u, '');
159
- }
160
-
161
- if (value && /^\(FIN01\)/u.test(value)) {
162
- return value.replace(/^\(FIN01\)/u, '');
163
- }
164
-
165
- return false;
166
- }
167
-
168
- return false;
169
- }
170
- } // SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to
171
- // (probably) to *headings* index TIT
172
- // - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search
173
- // Headings index TIT drops articles etc. from the start of the title according to the filing indicator
174
- // Currently filing indicator is not implemented - if the title starts with an article and the Melinda
175
- // record is correctly catalogued using a filing indicator -> dc.title search won't match
176
-
177
-
178
- function bibTitle(record) {
179
- const title = getTitle();
180
- const booleanStartWords = ['and', 'or', 'nor', 'not'];
181
-
182
- if (title) {
183
- const formatted = title.replace(/[^\w\s\p{Alphabetic}]/gu, '') // Clean up concurrent spaces from fe. subfield changes
184
- .replace(/ +/gu, ' ').trim().slice(0, 30).trim(); // use word search for titles starting with a boolean
185
-
186
- const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word)); // Prevent too many matches by having a minimum length requirement
187
-
188
- return formatted.length >= 5 ? [`dc.title="${useWordSearch ? '' : '^'}${formatted}*"`] : [];
189
- }
190
-
191
- return [];
192
-
193
- function getTitle() {
194
- const [field] = record.get(/^245$/u);
195
-
196
- if (field) {
197
- return field.subfields.filter(({
198
- code
199
- }) => ['a', 'b'].includes(code)).map(({
200
- value
201
- }) => value) // In Melinda's index subfield separators are indexed as ' '
202
- .join(' ');
203
- }
204
-
205
- return false;
206
- }
207
- } // eslint-disable-next-line max-statements
208
-
209
-
210
- function bibStandardIdentifiers(record) {
211
- const debug = (0, _debug.default)('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');
212
- const debugData = debug.extend('data');
213
- debug(`Creating queries for standard identifiers`);
214
- const fields = record.get(/^(?<def>020|022|024)$/u);
215
- const identifiers = [].concat(...fields.map(toIdentifiers));
216
- const uniqueIdentifiers = [...new Set(identifiers)];
217
- debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);
218
- debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);
219
- debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);
220
-
221
- if (uniqueIdentifiers.length < 1) {
222
- debug(`No identifiers found, no queries created.`);
223
- return [];
224
- }
225
-
226
- return (0, _candidateSearchUtils.toQueries)(uniqueIdentifiers, 'dc.identifier');
227
-
228
- function toIdentifiers({
229
- tag,
230
- subfields
231
- }) {
232
- const issnIsbnReqExp = /^[A-Za-z0-9-]+$/u;
233
- const otherIdReqExp = /^[A-Za-z0-9-:]+$/u;
234
-
235
- if (tag === '022') {
236
- return subfields.filter(sub => ['a', 'z', 'y'].includes(sub.code) && issnIsbnReqExp.test(sub.value) && sub.value !== undefined).map(({
237
- value
238
- }) => value);
239
- }
240
-
241
- if (tag === '020') {
242
- return subfields.filter(sub => ['a', 'z'].includes(sub.code) && issnIsbnReqExp.test(sub.value) && sub.value !== undefined).map(({
243
- value
244
- }) => value);
245
- }
246
-
247
- return subfields.filter(sub => ['a', 'z'].includes(sub.code) && otherIdReqExp.test(sub.value) && sub.value !== undefined).map(({
248
- value
249
- }) => value);
250
- }
251
- }
252
- //# sourceMappingURL=bib.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bib.js","names":["bibSourceIds","record","debug","createDebugLogger","debugData","extend","fSids","get","length","JSON","stringify","toSidQueries","sidStrings","getSidStrings","sidQueries","toQueries","map","toSidString","filter","nonEmptySid","field","validateSidFieldSubfieldCounts","createSidString","sfC","getSubfieldValues","sfB","cleanedSfC","removeSourcePrefix","normalizeSidSubfieldValue","cleanedSfB","concat","subfieldValue","sourcePrefixRegex","normalizedValue","replace","normalizeAwayRegex","bibMelindaIds","melindaIds","getMelindaIdsF035","bibHostComponents","id","getHostId","value","subfields","find","code","test","bibTitle","title","getTitle","booleanStartWords","formatted","trim","slice","useWordSearch","some","word","toLowerCase","startsWith","includes","join","bibStandardIdentifiers","fields","identifiers","toIdentifiers","uniqueIdentifiers","Set","tag","issnIsbnReqExp","otherIdReqExp","sub","undefined"],"sources":["../../../src/candidate-search/query-list/bib.js"],"sourcesContent":["\n/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-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-record-matching-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 Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\nimport createDebugLogger from 'debug';\nimport {toQueries} from '../candidate-search-utils';\nimport {getMelindaIdsF035, validateSidFieldSubfieldCounts, getSubfieldValues} from '../../matching-utils';\n\n\nexport function bibSourceIds(record) {\n\n /* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records\n SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:\n\n SID__ $c 123457 $b helka\n SID__ $c (ANDL100020)1077305 $b sata\n SID__ $c VER999999 $ FI-KV\n SID__ $c /10024/508126 $ REPO_THESEUS\n\n In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:\n Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted\n\n 1234567helka\n 1077305sata\n VER999999FIKV\n /10024/508126REPO_THESEUS\n\n Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,\n existence of a SID field depends on how the record has been added to Melinda and how it has been handled\n afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db\n after the matching record is removed from the local db.\n\n */\n\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');\n const debugData = debug.extend('data');\n //const debugInfo = debug.extend('info');\n\n debug(`Creating queries for sourceid's`);\n\n const fSids = record.get('SID');\n debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);\n\n return fSids.length > 0 ? toSidQueries(fSids) : [];\n\n function toSidQueries(fSids) {\n debug(`Creating actual queries for sourceid's`);\n\n const sidStrings = getSidStrings(fSids);\n\n if (sidStrings.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n const sidQueries = toQueries(sidStrings, 'melinda.sourceid');\n\n return sidQueries;\n\n function getSidStrings(fSids) {\n debug(`Getting Sid strings from SID fields`);\n\n // Map SID fields to valid sidStrings, filter out empty strings\n const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);\n return sidStrings;\n\n function toSidString(field) {\n debug(`Getting string from a field`);\n\n return validateSidFieldSubfieldCounts(field) ? createSidString(field) : '';\n\n function createSidString(field) {\n debug(`Creating string from a field`);\n const [sfC] = getSubfieldValues(field, 'c');\n const [sfB] = getSubfieldValues(field, 'b');\n\n const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));\n const cleanedSfB = normalizeSidSubfieldValue(sfB);\n\n debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);\n return cleanedSfC.concat(cleanedSfB);\n }\n\n function removeSourcePrefix(subfieldValue) {\n const sourcePrefixRegex = (/^(?<sourcePrefix>\\([A-Za-z0-9-]+\\))(?<id>.+)$/u);\n const normalizedValue = subfieldValue ? subfieldValue.replace(sourcePrefixRegex, '$<id>') : '';\n debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);\n return normalizedValue;\n }\n\n function normalizeSidSubfieldValue(subfieldValue) {\n debugData(`Normalizing ${subfieldValue}`);\n const normalizeAwayRegex = (/[- ]/u);\n return subfieldValue ? subfieldValue.replace(normalizeAwayRegex, '') : '';\n }\n\n }\n }\n }\n}\n\nexport function bibMelindaIds(record) {\n // Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');\n const debugData = debug.extend('data');\n debug(`Creating queries for MelindaIds`);\n\n // Note: Melinda-ID's for search queries are created just from records f035a's and f035z's\n // Both (FI-MELINDA)- and FCC-prefixed forms are found\n // f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA\n const melindaIds = getMelindaIdsF035(record);\n\n debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);\n\n if (melindaIds.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(melindaIds, 'melinda.melindaid');\n}\n\n\n// bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05\n// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?\nexport function bibHostComponents(record) {\n const id = getHostId();\n return id ? [`melinda.partsofhost=${id}`] : [];\n\n function getHostId() {\n const [field] = record.get(/^773$/u);\n\n if (field) {\n const {value} = field.subfields.find(({code}) => code === 'w') || {};\n\n if (value && (/^\\(FI-MELINDA\\)/u).test(value)) {\n return value.replace(/^\\(FI-MELINDA\\)/u, '');\n }\n\n if (value && (/^\\(FIN01\\)/u).test(value)) {\n return value.replace(/^\\(FIN01\\)/u, '');\n }\n\n return false;\n }\n return false;\n }\n}\n\n// SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to\n// (probably) to *headings* index TIT\n// - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search\n\n// Headings index TIT drops articles etc. from the start of the title according to the filing indicator\n// Currently filing indicator is not implemented - if the title starts with an article and the Melinda\n// record is correctly catalogued using a filing indicator -> dc.title search won't match\n\nexport function bibTitle(record) {\n const title = getTitle();\n const booleanStartWords = ['and', 'or', 'nor', 'not'];\n\n if (title) {\n const formatted = title\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n // use word search for titles starting with a boolean\n const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\n // Prevent too many matches by having a minimum length requirement\n return formatted.length >= 5 ? [`dc.title=\"${useWordSearch ? '' : '^'}${formatted}*\"`] : [];\n }\n\n return [];\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n return field.subfields\n .filter(({code}) => ['a', 'b'].includes(code))\n .map(({value}) => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n }\n return false;\n }\n}\n\n// eslint-disable-next-line max-statements\nexport function bibStandardIdentifiers(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');\n const debugData = debug.extend('data');\n debug(`Creating queries for standard identifiers`);\n\n const fields = record.get(/^(?<def>020|022|024)$/u);\n const identifiers = [].concat(...fields.map(toIdentifiers));\n const uniqueIdentifiers = [...new Set(identifiers)];\n\n debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);\n debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);\n debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);\n\n if (uniqueIdentifiers.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(uniqueIdentifiers, 'dc.identifier');\n\n function toIdentifiers({tag, subfields}) {\n const issnIsbnReqExp = (/^[A-Za-z0-9-]+$/u);\n const otherIdReqExp = (/^[A-Za-z0-9-:]+$/u);\n\n if (tag === '022') {\n return subfields\n .filter(sub => ['a', 'z', 'y'].includes(sub.code) && issnIsbnReqExp.test(sub.value) && sub.value !== undefined)\n .map(({value}) => value);\n }\n\n if (tag === '020') {\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && issnIsbnReqExp.test(sub.value) && sub.value !== undefined)\n .map(({value}) => value);\n }\n\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && otherIdReqExp.test(sub.value) && sub.value !== undefined)\n .map(({value}) => value);\n }\n}\n"],"mappings":";;;;;;;;;;;AA4BA;;AACA;;AACA;;;;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMO,SAASA,YAAT,CAAsBC,MAAtB,EAA8B;EAEnC;AACF;AACA;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C;QAAC0B;MAAD,CAAD,KAAaA,KAFb,CAAP;IAGD;;IAED,IAAIyB,GAAG,KAAK,KAAZ,EAAmB;MACjB,OAAOxB,SAAS,CACbzB,MADI,CACGoD,GAAG,IAAI,CAAC,GAAD,EAAM,GAAN,EAAWX,QAAX,CAAoBW,GAAG,CAACzB,IAAxB,KAAiCuB,cAAc,CAACtB,IAAf,CAAoBwB,GAAG,CAAC5B,KAAxB,CAAjC,IAAmE4B,GAAG,CAAC5B,KAAJ,KAAc6B,SAD3F,EAEJvD,GAFI,CAEA,CAAC;QAAC0B;MAAD,CAAD,KAAaA,KAFb,CAAP;IAGD;;IAED,OAAOC,SAAS,CACbzB,MADI,CACGoD,GAAG,IAAI,CAAC,GAAD,EAAM,GAAN,EAAWX,QAAX,CAAoBW,GAAG,CAACzB,IAAxB,KAAiCwB,aAAa,CAACvB,IAAd,CAAmBwB,GAAG,CAAC5B,KAAvB,CAAjC,IAAkE4B,GAAG,CAAC5B,KAAJ,KAAc6B,SAD1F,EAEJvD,GAFI,CAEA,CAAC;MAAC0B;IAAD,CAAD,KAAaA,KAFb,CAAP;EAGD;AACF"}
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
4
-
5
- var _fixura = require("@natlibfi/fixura");
6
-
7
- var _chai = require("chai");
8
-
9
- var _marcRecord = require("@natlibfi/marc-record");
10
-
11
- var generators = _interopRequireWildcard(require("./bib"));
12
-
13
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
-
15
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
- /**
20
- *
21
- * @licstart The following is the entire license notice for the JavaScript code in this file.
22
- *
23
- * Melinda record matching modules for Javascript
24
- *
25
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
26
- *
27
- * This file is part of melinda-record-matching-js
28
- *
29
- * melinda-record-matching-js program is free software: you can redistribute it and/or modify
30
- * it under the terms of the GNU Lesser General Public License as
31
- * published by the Free Software Foundation, either version 3 of the
32
- * License, or (at your option) any later version.
33
- *
34
- * melinda-record-matching-js is distributed in the hope that it will be useful,
35
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
- * GNU Lesser General Public License for more details.
38
- *
39
- * You should have received a copy of the GNU Affero General Public License
40
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
41
- *
42
- * @licend The above is the entire license notice
43
- * for the JavaScript code in this file.
44
- *
45
- */
46
- describe('candidate-search/query-list/bib/', () => {
47
- (0, _fixugen.default)({
48
- path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],
49
- useMetadataFile: true,
50
- fixura: {
51
- reader: _fixura.READERS.JSON
52
- },
53
- callback: ({
54
- type,
55
- inputRecord,
56
- expectedQuery,
57
- enabled = true
58
- }) => {
59
- const generate = generators[type];
60
- const record = new _marcRecord.MarcRecord(inputRecord, {
61
- subfieldValues: false
62
- });
63
-
64
- if (!enabled) {
65
- return;
66
- }
67
-
68
- (0, _chai.expect)(generate(record)).to.eql(expectedQuery);
69
- }
70
- });
71
- });
72
- //# sourceMappingURL=bib.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bib.spec.js","names":["describe","generateTests","path","__dirname","useMetadataFile","fixura","reader","READERS","JSON","callback","type","inputRecord","expectedQuery","enabled","generate","generators","record","MarcRecord","subfieldValues","expect","to","eql"],"sources":["../../../src/candidate-search/query-list/bib.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-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-record-matching-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 Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as generators from './bib';\n\ndescribe('candidate-search/query-list/bib/', () => {\n generateTests({\n path: [__dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({type, inputRecord, expectedQuery, enabled = true}) => {\n const generate = generators[type];\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n\n if (!enabled) {\n return;\n }\n\n expect(generate(record)).to.eql(expectedQuery);\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;AAQAA,QAAQ,CAAC,kCAAD,EAAqC,MAAM;EACjD,IAAAC,gBAAA,EAAc;IACZC,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,IAAlB,EAAwB,IAAxB,EAA8B,eAA9B,EAA+C,kBAA/C,EAAmE,YAAnE,EAAiF,KAAjF,CADM;IAEZC,eAAe,EAAE,IAFL;IAGZC,MAAM,EAAE;MACNC,MAAM,EAAEC,eAAA,CAAQC;IADV,CAHI;IAMZC,QAAQ,EAAE,CAAC;MAACC,IAAD;MAAOC,WAAP;MAAoBC,aAApB;MAAmCC,OAAO,GAAG;IAA7C,CAAD,KAAwD;MAChE,MAAMC,QAAQ,GAAGC,UAAU,CAACL,IAAD,CAA3B;MACA,MAAMM,MAAM,GAAG,IAAIC,sBAAJ,CAAeN,WAAf,EAA4B;QAACO,cAAc,EAAE;MAAjB,CAA5B,CAAf;;MAEA,IAAI,CAACL,OAAL,EAAc;QACZ;MACD;;MAED,IAAAM,YAAA,EAAOL,QAAQ,CAACE,MAAD,CAAf,EAAyBI,EAAzB,CAA4BC,GAA5B,CAAgCT,aAAhC;IACD;EAfW,CAAd;AAiBD,CAlBO,CAAR"}
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.searchTypes = exports.default = void 0;
7
-
8
- var bib = _interopRequireWildcard(require("./bib"));
9
-
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
-
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
-
14
- /**
15
- *
16
- * @licstart The following is the entire license notice for the JavaScript code in this file.
17
- *
18
- * Melinda record matching modules for Javascript
19
- *
20
- * Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
21
- *
22
- * This file is part of melinda-record-matching-js
23
- *
24
- * melinda-record-matching-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-record-matching-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 Affero 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
- const searchTypes = {
42
- bib: {
43
- standardIdentifiers: 'bibStandardIdentifiers',
44
- hostComponents: 'bibHostComponents',
45
- title: 'bibTitle',
46
- melindaId: 'bibMelindaIds',
47
- sourceIds: 'bibSourceIds'
48
- }
49
- };
50
- exports.searchTypes = searchTypes;
51
-
52
- var _default = (record, searchSpec) => {
53
- const extractors = { ...bib
54
- };
55
- return searchSpec.map(generateQueryExtractor).map(cb => cb(record)).flat();
56
-
57
- function generateQueryExtractor(type) {
58
- if (extractors[type]) {
59
- return extractors[type];
60
- }
61
-
62
- throw new Error(`Unknown search type: ${type}`);
63
- }
64
- };
65
-
66
- exports.default = _default;
67
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["searchTypes","bib","standardIdentifiers","hostComponents","title","melindaId","sourceIds","record","searchSpec","extractors","map","generateQueryExtractor","cb","flat","type","Error"],"sources":["../../../src/candidate-search/query-list/index.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-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-record-matching-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 Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport * as bib from './bib';\n\nexport const searchTypes = {\n bib: {\n standardIdentifiers: 'bibStandardIdentifiers',\n hostComponents: 'bibHostComponents',\n title: 'bibTitle',\n melindaId: 'bibMelindaIds',\n sourceIds: 'bibSourceIds'\n }\n};\n\nexport default (record, searchSpec) => {\n const extractors = {...bib};\n\n return searchSpec\n .map(generateQueryExtractor)\n .map(cb => cb(record))\n .flat();\n\n function generateQueryExtractor(type) {\n if (extractors[type]) {\n return extractors[type];\n }\n\n throw new Error(`Unknown search type: ${type}`);\n }\n};\n"],"mappings":";;;;;;;AA4BA;;;;;;AA5BA;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;AAIO,MAAMA,WAAW,GAAG;EACzBC,GAAG,EAAE;IACHC,mBAAmB,EAAE,wBADlB;IAEHC,cAAc,EAAE,mBAFb;IAGHC,KAAK,EAAE,UAHJ;IAIHC,SAAS,EAAE,eAJR;IAKHC,SAAS,EAAE;EALR;AADoB,CAApB;;;eAUQ,CAACC,MAAD,EAASC,UAAT,KAAwB;EACrC,MAAMC,UAAU,GAAG,EAAC,GAAGR;EAAJ,CAAnB;EAEA,OAAOO,UAAU,CACdE,GADI,CACAC,sBADA,EAEJD,GAFI,CAEAE,EAAE,IAAIA,EAAE,CAACL,MAAD,CAFR,EAGJM,IAHI,EAAP;;EAKA,SAASF,sBAAT,CAAgCG,IAAhC,EAAsC;IACpC,IAAIL,UAAU,CAACK,IAAD,CAAd,EAAsB;MACpB,OAAOL,UAAU,CAACK,IAAD,CAAjB;IACD;;IAED,MAAM,IAAIC,KAAJ,CAAW,wBAAuBD,IAAK,EAAvC,CAAN;EACD;AACF,C"}