Skip to content

Commit a087827

Browse files
authored
Feature handleMatchFailuresAsNew [MRA-841] (#367) (#368)
* Add matchFailuresAsNew query parameter * NOTE: requires validator ^3.8.0 to be usable * Update deps * 3.5.0-alpha.1
1 parent d4151f2 commit a087827

File tree

7 files changed

+70
-39
lines changed

7 files changed

+70
-39
lines changed

package-lock.json

+36-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"url": "[email protected]:natlibfi/melinda-rest-api-http.git"
1515
},
1616
"license": "MIT",
17-
"version": "3.4.1",
17+
"version": "3.5.0-alpha.1",
1818
"main": "dist/index.js",
1919
"engines": {
2020
"node": ">=18"
@@ -44,7 +44,7 @@
4444
"mongo-sanitize": "^1.1.0",
4545
"nodemon": "^3.1.9",
4646
"passport": "^0.7.0",
47-
"uuid": "^11.0.5"
47+
"uuid": "^11.1.0"
4848
},
4949
"devDependencies": {
5050
"@babel/cli": "^7.26.4",

src/api.json

+16
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
"default": false
7171
}
7272
},
73+
{
74+
"name": "matchFailuresAsNew",
75+
"description": "Handle merge jobs where are all matches fail matchValidation as new.",
76+
"in": "query",
77+
"schema": {
78+
"type": "boolean"
79+
}
80+
},
7381
{
7482
"name": "cataloger",
7583
"description": "Cataloger name to use while operating on a record. Note: requires admin rights to use",
@@ -309,6 +317,14 @@
309317
"default": false
310318
}
311319
},
320+
{
321+
"name": "matchFailuresAsNew",
322+
"description": "Handle merge jobs where are all matches fail matchValidation as new.",
323+
"in": "query",
324+
"schema": {
325+
"type": "boolean"
326+
}
327+
},
312328
{
313329
"name": "cataloger",
314330
"description": "Cataloger name to use while operating on a record. Note: requires admin rights to use",

src/api.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ paths:
231231
schema:
232232
type: boolean
233233
default: false
234+
- name: matchFailuresAsNew
235+
description: >-
236+
Handle merge jobs where are all matches fail matchValidation as new
237+
in: query
238+
schema:
239+
type: boolean
234240
- name: cataloger
235241
description: >-
236242
Cataloger name to use while operating on a record. Note: requires admin rights to use
@@ -404,6 +410,12 @@ paths:
404410
schema:
405411
type: boolean
406412
default: false
413+
- name: matchFailuresAsNew
414+
description: >-
415+
Handle merge jobs where are all matches fail matchValidation as new
416+
in: query
417+
schema:
418+
type: boolean
407419
- name: pRejectFile
408420
description: Error log file location
409421
in: query

src/interfaces/bulk.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export default async function ({mongoUri, amqpUrl, allowedLibs}) {
328328
const paramUnique = queryParams.unique ? parseBoolean(queryParams.unique) : undefined;
329329
const paramMerge = queryParams.merge ? parseBoolean(queryParams.merge) : undefined;
330330
const paramSkipLowValidation = queryParams.skipLowValidation ? parseBoolean(queryParams.skipLowValidateLow) : undefined;
331-
331+
const paramMatchFailuresAsNew = queryParams.matchFailuresAsNew ? parseBoolean(queryParams.matchFailuresAsNew) : undefined;
332332

333333
if (paramValidate === false && (paramUnique || paramMerge)) {
334334
logger.debug(`Query parameter validate=0 is not valid with query parameters unique=1 and/or merge=1`);
@@ -354,6 +354,7 @@ export default async function ({mongoUri, amqpUrl, allowedLibs}) {
354354
failOnError: queryParams.failOnError === undefined ? false : parseBoolean(queryParams.failOnError),
355355
// bulk skips changes that won't change the database record as default
356356
skipNoChangeUpdates: queryParams.skipNoChangeUpdates === undefined ? true : parseBoolean(queryParams.skipNoChangeUpdates),
357+
matchFailuresAsNew: paramMatchFailuresAsNew,
357358
prio: false
358359
};
359360

src/routes/prio.js

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export default async ({sruUrl, amqpUrl, mongoUri, pollWaitTime, recordType, requ
116116
failOnError: null,
117117
// Prio forces updates as default, even if the update would not make changes to the database record
118118
skipNoChangeUpdates: req.query.skipNoChangeUpdates === undefined ? false : parseBoolean(req.query.skipNoChangeUpdates),
119+
matchFailuresAsNew: req.query.matchFailuresAsNew === undefined ? undefined : parseBoolean(req.query.matchFailuresAsNew),
119120
prio: true
120121
};
121122

src/routes/queryUtils.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export function checkQueryParams(req, res, next) {
2424
{name: 'skipLowValidation', value: queryParams.skipLowValidation ? (/^(?:1|0|true|false)$/ui).test(queryParams.skipLowValidation) : true},
2525
{name: 'failOnError', value: queryParams.failOnError ? (/^(?:1|0|true|false)$/ui).test(queryParams.failOnError) : true},
2626
{name: 'skipNoChangeUpdates', value: queryParams.skipNoChangeUpdates ? (/^(?:1|0|true|false)$/ui).test(queryParams.skipNoChangeUpdates) : true},
27+
{name: 'maatchFailuresAsNew', value: queryParams.matchFailuresAsNew ? (/^(?:1|0|true|false)$/ui).test(queryParams.matchFailuresAsNew) : true},
2728
{name: 'pRejectFile', value: queryParams.pRejectFile ? (/^[a-z|A-Z|0-9|/|.|_|-]{0,100}$/u).test(queryParams.pRejectFile) : true},
2829
{name: 'pLogFile', value: queryParams.pLogFile ? (/^[a-z|A-Z|0-9|/|.|_|-]{0,100}$/u).test(queryParams.pLogFile) : true},
2930
{name: 'pCatalogerIn', value: queryParams.pCatalogerIn ? (/^(?:0|false|undefined|[A-Z|0-9|_|-]{0,10}$)/u).test(queryParams.pCatalogerIn) : true},

0 commit comments

Comments
 (0)