@natlibfi/melinda-record-matching 5.1.4 → 5.1.6-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/candidate-search/index.js +2 -0
- package/dist/candidate-search/index.js.map +2 -2
- package/dist/candidate-search/query-list/bib.js +16 -3
- package/dist/candidate-search/query-list/bib.js.map +2 -2
- package/dist/cli.js.map +2 -2
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +7 -0
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +2 -2
- package/dist/match-detection/features/bib/title.js +51 -5
- package/dist/match-detection/features/bib/title.js.map +3 -3
- package/dist/matching-utils.js +39 -0
- package/dist/matching-utils.js.map +2 -2
- package/package.json +9 -11
- package/src/candidate-search/index.js +3 -0
- package/src/candidate-search/query-list/bib.js +24 -4
- package/src/cli.js +1 -0
- package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +14 -0
- package/src/match-detection/features/bib/title.js +62 -7
- package/src/matching-utils.js +50 -0
- package/{src → test}/candidate-search/index.test.js +3 -1
- package/{src → test}/candidate-search/query-list/auth.test.js +1 -1
- package/{src → test}/candidate-search/query-list/bib.test.js +1 -1
- package/{src → test}/index.test.js +10 -5
- package/{src → test}/match-detection/features/auth/index.test.js +1 -1
- package/{src → test}/match-detection/features/bib/index.test.js +1 -1
- package/{src → test}/match-detection/index.test.js +2 -2
- package/dist/candidate-search/index.test.js +0 -89
- package/dist/candidate-search/index.test.js.map +0 -7
- package/dist/candidate-search/query-list/auth.test.js +0 -31
- package/dist/candidate-search/query-list/auth.test.js.map +0 -7
- package/dist/candidate-search/query-list/bib.test.js +0 -31
- package/dist/candidate-search/query-list/bib.test.js.map +0 -7
- package/dist/index.test.js +0 -69
- package/dist/index.test.js.map +0 -7
- package/dist/match-detection/features/auth/index.test.js +0 -37
- package/dist/match-detection/features/auth/index.test.js.map +0 -7
- package/dist/match-detection/features/bib/index.test.js +0 -37
- package/dist/match-detection/features/bib/index.test.js.map +0 -7
- package/dist/match-detection/index.test.js +0 -40
- package/dist/match-detection/index.test.js.map +0 -7
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe } from "node:test";
|
|
3
|
-
import { READERS } from "@natlibfi/fixura";
|
|
4
|
-
import generateTests from "@natlibfi/fixugen-http-client";
|
|
5
|
-
import { MarcRecord } from "@natlibfi/marc-record";
|
|
6
|
-
import { Error as MatchingError } from "@natlibfi/melinda-commons";
|
|
7
|
-
import createSearchInterface, { CandidateSearchError } from "./index.js";
|
|
8
|
-
import createDebugLogger from "debug";
|
|
9
|
-
const debug = createDebugLogger("@natlibfi/melinda-record-matching:candidate-search:test");
|
|
10
|
-
describe("candidate-search", () => {
|
|
11
|
-
generateTests({
|
|
12
|
-
callback,
|
|
13
|
-
path: [import.meta.dirname, "..", "..", "test-fixtures", "candidate-search", "index"],
|
|
14
|
-
recurse: false,
|
|
15
|
-
fixura: {
|
|
16
|
-
reader: READERS.JSON
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
async function callback({ getFixture, factoryOptions, searchOptions, expectedFactoryError = false, expectedSearchError = false }) {
|
|
20
|
-
const url = "http://foo.bar";
|
|
21
|
-
if (expectedFactoryError) {
|
|
22
|
-
debug(`We're expecting an error`);
|
|
23
|
-
if (expectedFactoryError.isCandidateSearchError) {
|
|
24
|
-
try {
|
|
25
|
-
const result = await createSearchInterface({ ...formatFactoryOptions(), url });
|
|
26
|
-
debug(result);
|
|
27
|
-
} catch (err) {
|
|
28
|
-
assert.equal(err instanceof CandidateSearchError, true);
|
|
29
|
-
assert.match(err.message, new RegExp(expectedFactoryError.message));
|
|
30
|
-
} finally {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
const result = await createSearchInterface({ ...formatFactoryOptions(), url });
|
|
36
|
-
debug(result);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
assert.equal(err instanceof Error, true);
|
|
39
|
-
assert.match(err.message, new RegExp(expectedFactoryError.message));
|
|
40
|
-
} finally {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const { search } = await createSearchInterface({ ...formatFactoryOptions(), url });
|
|
45
|
-
await iterate({ searchOptions, expectedSearchError });
|
|
46
|
-
function formatFactoryOptions() {
|
|
47
|
-
debug(`Using factoryOptions: ${JSON.stringify(factoryOptions)}`);
|
|
48
|
-
return {
|
|
49
|
-
...factoryOptions,
|
|
50
|
-
maxRecordsPerRequest: factoryOptions.maxRecordsPerRequest || 1,
|
|
51
|
-
maxServerResults: factoryOptions.maxServerResults || void 0,
|
|
52
|
-
record: new MarcRecord(factoryOptions.record, { subfieldValues: false })
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
async function iterate({ searchOptions: searchOptions2, expectedSearchError: expectedSearchError2, expectedErrorStatus, count = 1 }) {
|
|
56
|
-
const expectedResults = getFixture(`expectedResults${count}.json`);
|
|
57
|
-
if (expectedSearchError2) {
|
|
58
|
-
try {
|
|
59
|
-
await search(searchOptions2);
|
|
60
|
-
throw new Error("Expected an error");
|
|
61
|
-
} catch (err) {
|
|
62
|
-
debug(`Got an error: ${err}`);
|
|
63
|
-
assert(err instanceof Error);
|
|
64
|
-
const errorMessage = err instanceof MatchingError ? err.payload.message : err.message;
|
|
65
|
-
const errorStatus = err instanceof MatchingError ? err.status : void 0;
|
|
66
|
-
debug(`errorMessage: ${errorMessage}, errorStatus: ${errorStatus}`);
|
|
67
|
-
assert.match(errorMessage, new RegExp(expectedSearchError2, "u"));
|
|
68
|
-
if (expectedErrorStatus) {
|
|
69
|
-
assert.equal(errorStatus, expectedErrorStatus);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (!expectedSearchError2) {
|
|
76
|
-
const results = await search(searchOptions2);
|
|
77
|
-
assert.deepStrictEqual(formatResults(results), expectedResults);
|
|
78
|
-
}
|
|
79
|
-
function formatResults(results) {
|
|
80
|
-
debug(results);
|
|
81
|
-
return {
|
|
82
|
-
...results,
|
|
83
|
-
records: results.records.map(({ record, id }) => ({ id, record: record.toObject() }))
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
//# sourceMappingURL=index.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/candidate-search/index.test.js"],
|
|
4
|
-
"sourcesContent": ["import assert from 'node:assert';\nimport {describe} from 'node:test';\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 './index.js';\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: [import.meta.dirname, '..', '..', 'test-fixtures', 'candidate-search', 'index'],\n recurse: false,\n fixura: {\n reader: READERS.JSON\n }\n });\n\n async function callback({getFixture, factoryOptions, searchOptions, expectedFactoryError = false, expectedSearchError = false}) {\n const url = 'http://foo.bar';\n\n if (expectedFactoryError) {\n debug(`We're expecting an error`);\n if (expectedFactoryError.isCandidateSearchError) {\n try {\n const result = await createSearchInterface({...formatFactoryOptions(), url});\n debug(result);\n } catch (err) {\n assert.equal(err instanceof CandidateSearchError, true);\n assert.match(err.message, new RegExp(expectedFactoryError.message));\n } finally {\n return;\n }\n }\n\n try {\n const result = await createSearchInterface({...formatFactoryOptions(), url});\n debug(result);\n } catch (err) {\n assert.equal(err instanceof Error, true);\n assert.match(err.message, new RegExp(expectedFactoryError.message));\n } finally {\n return;\n }\n }\n\n const {search} = await 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 async function iterate({searchOptions, expectedSearchError, expectedErrorStatus, count = 1}) {\n const expectedResults = getFixture(`expectedResults${count}.json`);\n\n if (expectedSearchError) {\n try {\n await search(searchOptions);\n throw new Error('Expected an error');\n } catch (err) {\n debug(`Got an error: ${err}`);\n assert(err instanceof 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 assert.match(errorMessage, new RegExp(expectedSearchError, 'u'));\n\n if (expectedErrorStatus) {\n assert.equal(errorStatus, expectedErrorStatus);\n return;\n }\n return;\n }\n }\n\n if (!expectedSearchError) {\n const results = await search(searchOptions);\n assert.deepStrictEqual(formatResults(results), expectedResults);\n }\n\n function formatResults(results) {\n debug(results);\n return {\n ...results,\n records: results.records.map(({record, id}) => ({id, record: record.toObject()}))\n };\n }\n }\n }\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,SAAQ,eAAc;AACtB,OAAO,mBAAmB;AAC1B,SAAQ,kBAAiB;AACzB,SAAQ,SAAS,qBAAoB;AACrC,OAAO,yBAAwB,4BAA2B;AAC1D,OAAO,uBAAuB;AAE9B,MAAM,QAAQ,kBAAkB,yDAAyD;AAEzF,SAAS,oBAAoB,MAAM;AACjC,gBAAc;AAAA,IACZ;AAAA,IACA,MAAM,CAAC,YAAY,SAAS,MAAM,MAAM,iBAAiB,oBAAoB,OAAO;AAAA,IACpF,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,QAAQ,QAAQ;AAAA,I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AkB,WAAW,kBAAkB,KAAK,OAAO;AAEjE,UAAIA,sBAAqB;AACvB,YAAI;AACF,gBAAM,OAAOD,cAAa;AAC1B,gBAAM,IAAI,MAAM,mBAAmB;AAAA,QACrC,SAAS,KAAK;AACZ,gBAAM,iBAAiB,GAAG,EAAE;AAC5B,iBAAO,eAAe,KAAK;AAC3B,gBAAM,eAAe,eAAe,gBAAgB,IAAI,QAAQ,UAAU,IAAI;AAC9E,gBAAM,cAAc,eAAe,gBAAgB,IAAI,SAAS;AAChE,gBAAM,iBAAiB,YAAY,kBAAkB,WAAW,EAAE;AAClE,iBAAO,MAAM,cAAc,IAAI,OAAOC,sBAAqB,GAAG,CAAC;AAE/D,cAAI,qBAAqB;AACvB,mBAAO,MAAM,aAAa,mBAAmB;AAC7C;AAAA,UACF;AACA;AAAA,QACF;AAAA,MACF;AAEA,UAAI,CAACA,sBAAqB;AACxB,cAAM,UAAU,MAAM,OAAOD,cAAa;AAC1C,eAAO,gBAAgB,cAAc,OAAO,GAAG,eAAe;AAAA,MAChE;AAEA,eAAS,cAAc,SAAS;AAC9B,cAAM,OAAO;AACb,eAAO;AAAA,UACL,GAAG;AAAA,UACH,SAAS,QAAQ,QAAQ,IAAI,CAAC,EAAC,QAAQ,GAAE,OAAO,EAAC,IAAI,QAAQ,OAAO,SAAS,EAAC,EAAE;AAAA,QAClF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;",
|
|
6
|
-
"names": ["searchOptions", "expectedSearchError"]
|
|
7
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe } from "node:test";
|
|
3
|
-
import createDebugLogger from "debug";
|
|
4
|
-
import generateTests from "@natlibfi/fixugen";
|
|
5
|
-
import { READERS } from "@natlibfi/fixura";
|
|
6
|
-
import { MarcRecord } from "@natlibfi/marc-record";
|
|
7
|
-
import * as generators from "./auth.js";
|
|
8
|
-
const debug = createDebugLogger("@natlibfi/melinda-record-matching:candidate-search:query-list:auth-test");
|
|
9
|
-
const debugData = debug.extend("data");
|
|
10
|
-
describe("candidate-search/query-list/auth/", () => {
|
|
11
|
-
generateTests({
|
|
12
|
-
path: [import.meta.dirname, "..", "..", "..", "test-fixtures", "candidate-search", "query-list", "auth"],
|
|
13
|
-
useMetadataFile: true,
|
|
14
|
-
fixura: {
|
|
15
|
-
reader: READERS.JSON
|
|
16
|
-
},
|
|
17
|
-
callback: ({ type, inputRecord, expectedQuery, expectedQueryListType }) => {
|
|
18
|
-
const generate = generators[type];
|
|
19
|
-
const record = new MarcRecord(inputRecord, { subfieldValues: false });
|
|
20
|
-
const result = generate(record);
|
|
21
|
-
debugData(`Result: ${JSON.stringify(result)}`);
|
|
22
|
-
if (result.queryListType) {
|
|
23
|
-
assert.deepStrictEqual(result.queryList, expectedQuery);
|
|
24
|
-
assert.equal(result.queryListType, expectedQueryListType);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
assert.deepStrictEqual(result, expectedQuery);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=auth.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/candidate-search/query-list/auth.test.js"],
|
|
4
|
-
"sourcesContent": ["import assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as generators from './auth.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query-list:auth-test');\nconst debugData = debug.extend('data');\n\ndescribe('candidate-search/query-list/auth/', () => {\n generateTests({\n path: [import.meta.dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'auth'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({type, inputRecord, expectedQuery, expectedQueryListType}) => {\n const generate = generators[type];\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n\n const result = generate(record);\n debugData(`Result: ${JSON.stringify(result)}`);\n\n if (result.queryListType) {\n assert.deepStrictEqual(result.queryList, expectedQuery);\n assert.equal(result.queryListType, expectedQueryListType);\n return;\n }\n assert.deepStrictEqual(result, expectedQuery);\n }\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAC1B,SAAQ,eAAc;AACtB,SAAQ,kBAAiB;AACzB,YAAY,gBAAgB;AAE5B,MAAM,QAAQ,kBAAkB,yEAAyE;AACzG,MAAM,YAAY,MAAM,OAAO,MAAM;AAErC,SAAS,qCAAqC,MAAM;AAClD,gBAAc;AAAA,IACZ,MAAM,CAAC,YAAY,SAAS,MAAM,MAAM,MAAM,iBAAiB,oBAAoB,cAAc,MAAM;AAAA,IACvG,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,QAAQ,QAAQ;AAAA,IAClB;AAAA,IACA,UAAU,CAAC,EAAC,MAAM,aAAa,eAAe,sBAAqB,MAAM;AACvE,YAAM,WAAW,WAAW,IAAI;AAChC,YAAM,SAAS,IAAI,WAAW,aAAa,EAAC,gBAAgB,MAAK,CAAC;AAElE,YAAM,SAAS,SAAS,MAAM;AAC9B,gBAAU,WAAW,KAAK,UAAU,MAAM,CAAC,EAAE;AAE7C,UAAI,OAAO,eAAe;AACxB,eAAO,gBAAgB,OAAO,WAAW,aAAa;AACtD,eAAO,MAAM,OAAO,eAAe,qBAAqB;AACxD;AAAA,MACF;AACA,aAAO,gBAAgB,QAAQ,aAAa;AAAA,IAC9C;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe } from "node:test";
|
|
3
|
-
import createDebugLogger from "debug";
|
|
4
|
-
import generateTests from "@natlibfi/fixugen";
|
|
5
|
-
import { READERS } from "@natlibfi/fixura";
|
|
6
|
-
import { MarcRecord } from "@natlibfi/marc-record";
|
|
7
|
-
import * as generators from "./bib.js";
|
|
8
|
-
const debug = createDebugLogger("@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents:test");
|
|
9
|
-
const debugData = debug.extend("data");
|
|
10
|
-
describe("candidate-search/query-list/bib/", () => {
|
|
11
|
-
generateTests({
|
|
12
|
-
path: [import.meta.dirname, "..", "..", "..", "test-fixtures", "candidate-search", "query-list", "bib"],
|
|
13
|
-
useMetadataFile: true,
|
|
14
|
-
fixura: {
|
|
15
|
-
reader: READERS.JSON
|
|
16
|
-
},
|
|
17
|
-
callback: ({ type, inputRecord, expectedQuery, expectedQueryListType }) => {
|
|
18
|
-
const generate = generators[type];
|
|
19
|
-
const record = new MarcRecord(inputRecord, { subfieldValues: false });
|
|
20
|
-
const result = generate(record);
|
|
21
|
-
debugData(`Result: ${JSON.stringify(result)}`);
|
|
22
|
-
if (result.queryListType) {
|
|
23
|
-
assert.deepStrictEqual(result.queryList, expectedQuery);
|
|
24
|
-
assert.equal(result.queryListType, expectedQueryListType);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
assert.deepStrictEqual(result, expectedQuery);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=bib.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/candidate-search/query-list/bib.test.js"],
|
|
4
|
-
"sourcesContent": ["import assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as generators from './bib.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents:test');\nconst debugData = debug.extend('data');\n\ndescribe('candidate-search/query-list/bib/', () => {\n generateTests({\n path: [import.meta.dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({type, inputRecord, expectedQuery, expectedQueryListType}) => {\n const generate = generators[type];\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n\n const result = generate(record);\n debugData(`Result: ${JSON.stringify(result)}`);\n\n if (result.queryListType) {\n assert.deepStrictEqual(result.queryList, expectedQuery);\n assert.equal(result.queryListType, expectedQueryListType);\n return;\n }\n assert.deepStrictEqual(result, expectedQuery);\n }\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAC1B,SAAQ,eAAc;AACtB,SAAQ,kBAAiB;AACzB,YAAY,gBAAgB;AAE5B,MAAM,QAAQ,kBAAkB,iFAAiF;AACjH,MAAM,YAAY,MAAM,OAAO,MAAM;AAErC,SAAS,oCAAoC,MAAM;AACjD,gBAAc;AAAA,IACZ,MAAM,CAAC,YAAY,SAAS,MAAM,MAAM,MAAM,iBAAiB,oBAAoB,cAAc,KAAK;AAAA,IACtG,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,QAAQ,QAAQ;AAAA,IAClB;AAAA,IACA,UAAU,CAAC,EAAC,MAAM,aAAa,eAAe,sBAAqB,MAAM;AACvE,YAAM,WAAW,WAAW,IAAI;AAChC,YAAM,SAAS,IAAI,WAAW,aAAa,EAAC,gBAAgB,MAAK,CAAC;AAElE,YAAM,SAAS,SAAS,MAAM;AAC9B,gBAAU,WAAW,KAAK,UAAU,MAAM,CAAC,EAAE;AAE7C,UAAI,OAAO,eAAe;AACxB,eAAO,gBAAgB,OAAO,WAAW,aAAa;AACtD,eAAO,MAAM,OAAO,eAAe,qBAAqB;AACxD;AAAA,MACF;AACA,aAAO,gBAAgB,QAAQ,aAAa;AAAA,IAC9C;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/index.test.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe } from "node:test";
|
|
3
|
-
import createDebugLogger from "debug";
|
|
4
|
-
import { READERS } from "@natlibfi/fixura";
|
|
5
|
-
import generateTests from "@natlibfi/fixugen-http-client";
|
|
6
|
-
import { MarcRecord } from "@natlibfi/marc-record";
|
|
7
|
-
import createMatchInterface, { matchDetection } from "./index.js";
|
|
8
|
-
const debug = createDebugLogger("@natlibfi/melinda-record-matching:index:test");
|
|
9
|
-
const debugData = debug.extend("data");
|
|
10
|
-
describe("INDEX", () => {
|
|
11
|
-
generateTests({
|
|
12
|
-
callback,
|
|
13
|
-
path: [import.meta.dirname, "..", "test-fixtures", "index"],
|
|
14
|
-
recurse: false,
|
|
15
|
-
fixura: {
|
|
16
|
-
reader: READERS.JSON
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
async function callback({ getFixture, options, expectedMatchStatus, expectedStopReason, expectedFailures, expectedCandidateCount }) {
|
|
20
|
-
const record = new MarcRecord(getFixture("inputRecord.json"), { subfieldValues: false });
|
|
21
|
-
const expectedMatches = getFixture("expectedMatches.json");
|
|
22
|
-
const expectedNonMatches = getFixture("expectedNonMatches.json") || [];
|
|
23
|
-
const match = createMatchInterface(formatOptions());
|
|
24
|
-
const { matches, matchStatus, nonMatches, conversionFailures, candidateCount } = await match({ record });
|
|
25
|
-
debugData(`Matches: ${matches.length}, Status: ${matchStatus.status}/${matchStatus.stopReason}, NonMatches: ${nonMatches ? nonMatches.length : "not returned"}, ConversionFailures: ${conversionFailures ? conversionFailures.length : "not returned"}`);
|
|
26
|
-
assert.equal(matchStatus.status, expectedMatchStatus);
|
|
27
|
-
assert.equal(matchStatus.stopReason, expectedStopReason);
|
|
28
|
-
assert.equal(candidateCount, expectedCandidateCount);
|
|
29
|
-
const formattedMatchResult = formatRecordResults(matches);
|
|
30
|
-
assert.deepStrictEqual(formattedMatchResult, expectedMatches);
|
|
31
|
-
const formattedNonMatchResult = formatRecordResults(nonMatches);
|
|
32
|
-
assert.deepStrictEqual(formattedNonMatchResult, expectedNonMatches);
|
|
33
|
-
if (expectedFailures) {
|
|
34
|
-
assert.deepStrictEqual(conversionFailures, expectedFailures);
|
|
35
|
-
}
|
|
36
|
-
function formatOptions() {
|
|
37
|
-
const contextFeatures = matchDetection.features[options.detection.strategy.type];
|
|
38
|
-
return {
|
|
39
|
-
...options,
|
|
40
|
-
search: {
|
|
41
|
-
...options.search
|
|
42
|
-
},
|
|
43
|
-
detection: {
|
|
44
|
-
...options.detect,
|
|
45
|
-
strategy: options.detection.strategy.features.map((v) => contextFeatures[v]())
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function formatRecordResults(matches2) {
|
|
50
|
-
if (matches2) {
|
|
51
|
-
debugData(JSON.stringify(matches2));
|
|
52
|
-
return matches2.map((match2) => ({
|
|
53
|
-
...match2,
|
|
54
|
-
candidate: formatCandidate(match2.candidate)
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
function formatCandidate({ id, record: record2 }) {
|
|
60
|
-
const newId = id;
|
|
61
|
-
const newRecord = record2;
|
|
62
|
-
return {
|
|
63
|
-
id: newId,
|
|
64
|
-
record: newRecord.toObject()
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=index.test.js.map
|
package/dist/index.test.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.test.js"],
|
|
4
|
-
"sourcesContent": ["import assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen-http-client';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createMatchInterface, {matchDetection} from './index.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:index:test');\nconst debugData = debug.extend('data');\n\ndescribe('INDEX', () => {\n generateTests({\n callback,\n path: [import.meta.dirname, '..', 'test-fixtures', 'index'],\n recurse: false,\n fixura: {\n reader: READERS.JSON\n }\n });\n\n async function callback({getFixture, options, expectedMatchStatus, expectedStopReason, expectedFailures, expectedCandidateCount}) {\n\n const record = new MarcRecord(getFixture('inputRecord.json'), {subfieldValues: false});\n const expectedMatches = getFixture('expectedMatches.json');\n const expectedNonMatches = getFixture('expectedNonMatches.json') || [];\n\n\n const match = createMatchInterface(formatOptions());\n const {matches, matchStatus, nonMatches, conversionFailures, candidateCount} = await match({record});\n debugData(`Matches: ${matches.length}, Status: ${matchStatus.status}/${matchStatus.stopReason}, NonMatches: ${nonMatches ? nonMatches.length : 'not returned'}, ConversionFailures: ${conversionFailures ? conversionFailures.length : 'not returned'}`);\n\n assert.equal(matchStatus.status, expectedMatchStatus);\n assert.equal(matchStatus.stopReason, expectedStopReason);\n assert.equal(candidateCount, expectedCandidateCount);\n\n const formattedMatchResult = formatRecordResults(matches);\n assert.deepStrictEqual(formattedMatchResult, expectedMatches);\n\n const formattedNonMatchResult = formatRecordResults(nonMatches);\n assert.deepStrictEqual(formattedNonMatchResult, expectedNonMatches);\n\n if (expectedFailures) {\n assert.deepStrictEqual(conversionFailures, expectedFailures);\n }\n\n function formatOptions() {\n const contextFeatures = matchDetection.features[options.detection.strategy.type];\n\n return {\n ...options,\n search: {\n ...options.search\n },\n detection: {\n ...options.detect,\n strategy: options.detection.strategy.features.map(v => contextFeatures[v]())\n }\n };\n }\n\n function formatRecordResults(matches) {\n if (matches) {\n debugData(JSON.stringify(matches));\n return matches.map((match) => ({\n ...match,\n candidate: formatCandidate(match.candidate)\n }));\n }\n return [];\n }\n\n // Format candidate to remove validationOptions from record\n function formatCandidate({id, record}) {\n const newId = id;\n const newRecord = record;\n return {\n id: newId,\n record: newRecord.toObject()\n };\n }\n }\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,OAAO,uBAAuB;AAC9B,SAAQ,eAAc;AACtB,OAAO,mBAAmB;AAC1B,SAAQ,kBAAiB;AACzB,OAAO,wBAAuB,sBAAqB;AAEnD,MAAM,QAAQ,kBAAkB,8CAA8C;AAC9E,MAAM,YAAY,MAAM,OAAO,MAAM;AAErC,SAAS,SAAS,MAAM;AACtB,gBAAc;AAAA,IACZ;AAAA,IACA,MAAM,CAAC,YAAY,SAAS,MAAM,iBAAiB,OAAO;AAAA,IAC1D,SAAS;AAAA,IACT,QAAQ;AAAA,MACN,QAAQ,QAAQ;AAAA,IAClB;AAAA,EACF,CAAC;AAED,iBAAe,SAAS,EAAC,YAAY,SAAS,qBAAqB,oBAAoB,kBAAkB,uBAAsB,GAAG;AAEhI,UAAM,SAAS,IAAI,WAAW,WAAW,kBAAkB,GAAG,EAAC,gBAAgB,MAAK,CAAC;AACrF,UAAM,kBAAkB,WAAW,sBAAsB;AACzD,UAAM,qBAAqB,WAAW,yBAAyB,KAAK,CAAC;AAGrE,UAAM,QAAQ,qBAAqB,cAAc,CAAC;AAClD,UAAM,EAAC,SAAS,aAAa,YAAY,oBAAoB,eAAc,IAAI,MAAM,MAAM,EAAC,OAAM,CAAC;AACnG,cAAU,YAAY,QAAQ,MAAM,aAAa,YAAY,MAAM,IAAI,YAAY,UAAU,iBAAiB,aAAa,WAAW,SAAS,cAAc,yBAAyB,qBAAqB,mBAAmB,SAAS,cAAc,EAAE;AAEvP,WAAO,MAAM,YAAY,QAAQ,mBAAmB;AACpD,WAAO,MAAM,YAAY,YAAY,kBAAkB;AACvD,WAAO,MAAM,gBAAgB,sBAAsB;AAEnD,UAAM,uBAAuB,oBAAoB,OAAO;AACxD,WAAO,gBAAgB,sBAAsB,eAAe;AAE5D,UAAM,0BAA0B,oBAAoB,UAAU;AAC9D,WAAO,gBAAgB,yBAAyB,kBAAkB;AAElE,QAAI,kBAAkB;AACpB,aAAO,gBAAgB,oBAAoB,gBAAgB;AAAA,IAC7D;AAEA,aAAS,gBAAgB;AACvB,YAAM,kBAAkB,eAAe,SAAS,QAAQ,UAAU,SAAS,IAAI;AAE/E,aAAO;AAAA,QACL,GAAG;AAAA,QACH,QAAQ;AAAA,UACN,GAAG,QAAQ;AAAA,QACb;AAAA,QACA,WAAW;AAAA,UACT,GAAG,QAAQ;AAAA,UACX,UAAU,QAAQ,UAAU,SAAS,SAAS,IAAI,OAAK,gBAAgB,CAAC,EAAE,CAAC;AAAA,QAC7E;AAAA,MACF;AAAA,IACF;AAEA,aAAS,oBAAoBA,UAAS;AACpC,UAAIA,UAAS;AACX,kBAAU,KAAK,UAAUA,QAAO,CAAC;AACjC,eAAOA,SAAQ,IAAI,CAACC,YAAW;AAAA,UAC7B,GAAGA;AAAA,UACH,WAAW,gBAAgBA,OAAM,SAAS;AAAA,QAC5C,EAAE;AAAA,MACJ;AACA,aAAO,CAAC;AAAA,IACV;AAGA,aAAS,gBAAgB,EAAC,IAAI,QAAAC,QAAM,GAAG;AACrC,YAAM,QAAQ;AACd,YAAM,YAAYA;AAClB,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ,UAAU,SAAS;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACF,CAAC;",
|
|
6
|
-
"names": ["matches", "match", "record"]
|
|
7
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe } from "node:test";
|
|
3
|
-
import createDebugLogger from "debug";
|
|
4
|
-
import generateTests from "@natlibfi/fixugen";
|
|
5
|
-
import { READERS } from "@natlibfi/fixura";
|
|
6
|
-
import { MarcRecord } from "@natlibfi/marc-record";
|
|
7
|
-
import * as features from "./index.js";
|
|
8
|
-
const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection:features/auth:test");
|
|
9
|
-
const debugData = debug.extend("data");
|
|
10
|
-
describe("match-detection/features/auth/", () => {
|
|
11
|
-
generateTests({
|
|
12
|
-
path: [import.meta.dirname, "..", "..", "..", "..", "test-fixtures", "match-detection", "features", "auth"],
|
|
13
|
-
useMetadataFile: true,
|
|
14
|
-
fixura: {
|
|
15
|
-
reader: READERS.JSON
|
|
16
|
-
},
|
|
17
|
-
callback: ({ feature, options, type, ...expectations }) => {
|
|
18
|
-
debug(`Testing: ${feature} ${type}`);
|
|
19
|
-
if (type === "extract") {
|
|
20
|
-
const { expectedFeatures, inputRecord } = expectations;
|
|
21
|
-
const record = new MarcRecord(inputRecord, { subfieldValues: false });
|
|
22
|
-
debugData(`Record: ${record}`);
|
|
23
|
-
const { extract } = features[feature](options);
|
|
24
|
-
assert.deepStrictEqual(extract({ record }), expectedFeatures);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (type === "compare") {
|
|
28
|
-
const { featuresA, featuresB, expectedPoints } = expectations;
|
|
29
|
-
const { compare } = features[feature](options);
|
|
30
|
-
assert.equal(Math.round(compare(featuresA, featuresB) * 100) / 100, expectedPoints);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
throw new Error(`Invalid type ${type}`);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=index.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/match-detection/features/auth/index.test.js"],
|
|
4
|
-
"sourcesContent": ["\nimport assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as features from './index.js';\n\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/auth:test');\nconst debugData = debug.extend('data');\n\n\ndescribe('match-detection/features/auth/', () => {\n generateTests({\n path: [import.meta.dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'auth'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n\n callback: ({feature, options, type, ...expectations}) => {\n debug(`Testing: ${feature} ${type}`);\n\n if (type === 'extract') {\n const {expectedFeatures, inputRecord} = expectations;\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n debugData(`Record: ${record}`);\n const {extract} = features[feature](options);\n\n assert.deepStrictEqual(extract({record}), expectedFeatures);\n return;\n }\n\n if (type === 'compare') {\n const {featuresA, featuresB, expectedPoints} = expectations;\n const {compare} = features[feature](options);\n\n assert.equal(Math.round(compare(featuresA, featuresB) *100)/100, expectedPoints);\n return;\n }\n\n throw new Error(`Invalid type ${type}`);\n }\n });\n});\n"],
|
|
5
|
-
"mappings": "AACA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAC1B,SAAQ,eAAc;AACtB,SAAQ,kBAAiB;AACzB,YAAY,cAAc;AAG1B,MAAM,QAAQ,kBAAkB,sEAAsE;AACtG,MAAM,YAAY,MAAM,OAAO,MAAM;AAGrC,SAAS,kCAAkC,MAAM;AAC/C,gBAAc;AAAA,IACZ,MAAM,CAAC,YAAY,SAAS,MAAM,MAAM,MAAM,MAAM,iBAAiB,mBAAmB,YAAY,MAAM;AAAA,IAC1G,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,QAAQ,QAAQ;AAAA,IAClB;AAAA,IAEA,UAAU,CAAC,EAAC,SAAS,SAAS,MAAM,GAAG,aAAY,MAAM;AACvD,YAAM,YAAY,OAAO,IAAI,IAAI,EAAE;AAEnC,UAAI,SAAS,WAAW;AACtB,cAAM,EAAC,kBAAkB,YAAW,IAAI;AACxC,cAAM,SAAS,IAAI,WAAW,aAAa,EAAC,gBAAgB,MAAK,CAAC;AAClE,kBAAU,WAAW,MAAM,EAAE;AAC7B,cAAM,EAAC,QAAO,IAAI,SAAS,OAAO,EAAE,OAAO;AAE3C,eAAO,gBAAgB,QAAQ,EAAC,OAAM,CAAC,GAAG,gBAAgB;AAC1D;AAAA,MACF;AAEA,UAAI,SAAS,WAAW;AACtB,cAAM,EAAC,WAAW,WAAW,eAAc,IAAI;AAC/C,cAAM,EAAC,QAAO,IAAI,SAAS,OAAO,EAAE,OAAO;AAE3C,eAAO,MAAM,KAAK,MAAM,QAAQ,WAAW,SAAS,IAAG,GAAG,IAAE,KAAK,cAAc;AAC/E;AAAA,MACF;AAEA,YAAM,IAAI,MAAM,gBAAgB,IAAI,EAAE;AAAA,IACxC;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe } from "node:test";
|
|
3
|
-
import createDebugLogger from "debug";
|
|
4
|
-
import generateTests from "@natlibfi/fixugen";
|
|
5
|
-
import { READERS } from "@natlibfi/fixura";
|
|
6
|
-
import { MarcRecord } from "@natlibfi/marc-record";
|
|
7
|
-
import * as features from "./index.js";
|
|
8
|
-
const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection:features/bib:test");
|
|
9
|
-
const debugData = debug.extend("data");
|
|
10
|
-
describe("match-detection/features/bib/", () => {
|
|
11
|
-
generateTests({
|
|
12
|
-
path: [import.meta.dirname, "..", "..", "..", "..", "test-fixtures", "match-detection", "features", "bib"],
|
|
13
|
-
useMetadataFile: true,
|
|
14
|
-
fixura: {
|
|
15
|
-
reader: READERS.JSON
|
|
16
|
-
},
|
|
17
|
-
callback: ({ feature, options, type, ...expectations }) => {
|
|
18
|
-
debug(`Testing: ${feature} ${type}`);
|
|
19
|
-
if (type === "extract") {
|
|
20
|
-
const { expectedFeatures, inputRecord } = expectations;
|
|
21
|
-
const record = new MarcRecord(inputRecord, { subfieldValues: false });
|
|
22
|
-
debugData(`Record: ${record}`);
|
|
23
|
-
const { extract } = features[feature](options);
|
|
24
|
-
assert.deepStrictEqual(extract({ record }), expectedFeatures);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (type === "compare") {
|
|
28
|
-
const { featuresA, featuresB, expectedPoints } = expectations;
|
|
29
|
-
const { compare } = features[feature](options);
|
|
30
|
-
assert.equal(Math.round(compare(featuresA, featuresB) * 100) / 100, expectedPoints);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
throw new Error(`Invalid type ${type}`);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=index.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/match-detection/features/bib/index.test.js"],
|
|
4
|
-
"sourcesContent": ["\nimport assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as features from './index.js';\n\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:features/bib:test');\nconst debugData = debug.extend('data');\n\n\ndescribe('match-detection/features/bib/', () => {\n generateTests({\n path: [import.meta.dirname, '..', '..', '..', '..', 'test-fixtures', 'match-detection', 'features', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n\n callback: ({feature, options, type, ...expectations}) => {\n debug(`Testing: ${feature} ${type}`);\n\n if (type === 'extract') {\n const {expectedFeatures, inputRecord} = expectations;\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n debugData(`Record: ${record}`);\n const {extract} = features[feature](options);\n\n assert.deepStrictEqual(extract({record}), expectedFeatures);\n return;\n }\n\n if (type === 'compare') {\n const {featuresA, featuresB, expectedPoints} = expectations;\n const {compare} = features[feature](options);\n\n assert.equal(Math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",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe } from "node:test";
|
|
3
|
-
import createDebugLogger from "debug";
|
|
4
|
-
import { inspect } from "util";
|
|
5
|
-
import generateTests from "@natlibfi/fixugen";
|
|
6
|
-
import { READERS } from "@natlibfi/fixura";
|
|
7
|
-
import { MarcRecord } from "@natlibfi/marc-record";
|
|
8
|
-
import createDetectionInterface from "./index.js";
|
|
9
|
-
import * as features from "./features/index.js";
|
|
10
|
-
const debug = createDebugLogger("@natlibfi/melinda-record-matching:match-detection:test");
|
|
11
|
-
const debugData = debug.extend("data");
|
|
12
|
-
describe("match-detection", () => {
|
|
13
|
-
generateTests({
|
|
14
|
-
path: [import.meta.dirname, "..", "..", "test-fixtures", "match-detection", "index"],
|
|
15
|
-
useMetadataFile: true,
|
|
16
|
-
recurse: false,
|
|
17
|
-
fixura: {
|
|
18
|
-
reader: READERS.JSON
|
|
19
|
-
},
|
|
20
|
-
callback: ({ getFixture, options, expectedResults, array }) => {
|
|
21
|
-
const detect = createDetectionInterface(formatOptions());
|
|
22
|
-
const recordA = new MarcRecord(getFixture("recordA.json"), { subfieldValues: false });
|
|
23
|
-
debugData(inspect(recordA));
|
|
24
|
-
debug(`Our recordB is an array of records: ${array}`);
|
|
25
|
-
const recordB = array ? getFixture("recordB.json").map((recordJson) => new MarcRecord(recordJson, { subfieldValues: false })) : new MarcRecord(getFixture("recordB.json"), { subfieldValues: false });
|
|
26
|
-
debugData(inspect(recordB));
|
|
27
|
-
const results = detect({ recordA, recordB });
|
|
28
|
-
debugData(`${JSON.stringify(results)}`);
|
|
29
|
-
assert.deepStrictEqual(results, expectedResults);
|
|
30
|
-
function formatOptions() {
|
|
31
|
-
const contextFeatures = features[options.strategy.type];
|
|
32
|
-
return {
|
|
33
|
-
...options,
|
|
34
|
-
strategy: options.strategy.features.map((v) => contextFeatures[v]())
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
//# sourceMappingURL=index.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/match-detection/index.test.js"],
|
|
4
|
-
"sourcesContent": ["import assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport {inspect} from 'util';\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\n\nimport createDetectionInterface from './index.js';\nimport * as features from './features/index.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:match-detection:test');\nconst debugData = debug.extend('data');\n\ndescribe('match-detection', () => {\n generateTests({\n path: [import.meta.dirname, '..', '..', 'test-fixtures', 'match-detection', 'index'],\n useMetadataFile: true,\n recurse: false,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({getFixture, options, expectedResults, array}) => {\n const detect = createDetectionInterface(formatOptions());\n const recordA = new MarcRecord(getFixture('recordA.json'), {subfieldValues: false});\n debugData(inspect(recordA));\n\n debug(`Our recordB is an array of records: ${array}`);\n const recordB = array\n ? getFixture('recordB.json').map(recordJson => new MarcRecord(recordJson, {subfieldValues: false}))\n : new MarcRecord(getFixture('recordB.json'), {subfieldValues: false});\n debugData(inspect(recordB));\n\n const results = detect({recordA, recordB});\n debugData(`${JSON.stringify(results)}`);\n\n assert.deepStrictEqual(results, expectedResults);\n\n function formatOptions() {\n const contextFeatures = features[options.strategy.type];\n\n return {\n ...options,\n strategy: options.strategy.features.map(v => contextFeatures[v]())\n };\n }\n }\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,OAAO,uBAAuB;AAC9B,SAAQ,eAAc;AACtB,OAAO,mBAAmB;AAC1B,SAAQ,eAAc;AACtB,SAAQ,kBAAiB;AAEzB,OAAO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