@natlibfi/melinda-rest-api-commons 4.0.17-alpha.1 → 4.0.17-alpha.3
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/dependabot.yml +9 -4
- package/dist/constants.js +6 -12
- package/dist/constants.js.map +1 -1
- package/dist/helpers/fix-constants.js +10 -18
- package/dist/helpers/fix-constants.js.map +1 -1
- package/dist/helpers/fix.spec.js +2 -2
- package/dist/helpers/fix.spec.js.map +1 -1
- package/dist/helpers/validation.spec.js +2 -2
- package/dist/helpers/validation.spec.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mongoLog.js +45 -10
- package/dist/mongoLog.js.map +1 -1
- package/dist/mongoLog.spec.js +79 -0
- package/dist/mongoLog.spec.js.map +1 -0
- package/package.json +131 -119
package/.github/dependabot.yml
CHANGED
|
@@ -10,7 +10,7 @@ updates:
|
|
|
10
10
|
interval: "daily"
|
|
11
11
|
time: "06:30"
|
|
12
12
|
timezone: "Europe/Helsinki"
|
|
13
|
-
target-branch: "
|
|
13
|
+
target-branch: "next"
|
|
14
14
|
|
|
15
15
|
# Minor updates to npm production dependencies daily
|
|
16
16
|
- package-ecosystem: "npm"
|
|
@@ -20,9 +20,14 @@ updates:
|
|
|
20
20
|
time: "06:45"
|
|
21
21
|
timezone: "Europe/Helsinki"
|
|
22
22
|
versioning-strategy: lockfile-only
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
target-branch: "next"
|
|
24
|
+
pull-request-branch-name:
|
|
25
|
+
separator: "-"
|
|
26
|
+
groups:
|
|
27
|
+
production-dependencies:
|
|
28
|
+
dependency-type: "production"
|
|
29
|
+
development-dependencies:
|
|
30
|
+
dependency-type: "development"
|
|
26
31
|
|
|
27
32
|
# Major updates to npm dependencies weekly @tuesday
|
|
28
33
|
# Not possible yet https://github.com/dependabot/dependabot-core/issues/1778
|
package/dist/constants.js
CHANGED
|
@@ -34,7 +34,7 @@ exports.QUEUE_ITEM_STATE = exports.OPERATIONS = exports.LOG_ITEM_TYPE = exports.
|
|
|
34
34
|
|
|
35
35
|
// QueueItemState flows: see README.md
|
|
36
36
|
|
|
37
|
-
const QUEUE_ITEM_STATE = {
|
|
37
|
+
const QUEUE_ITEM_STATE = exports.QUEUE_ITEM_STATE = {
|
|
38
38
|
VALIDATOR: {
|
|
39
39
|
PENDING_QUEUING: 'PENDING_QUEUING',
|
|
40
40
|
PENDING_VALIDATION: 'PENDING_VALIDATION',
|
|
@@ -52,8 +52,7 @@ const QUEUE_ITEM_STATE = {
|
|
|
52
52
|
ERROR: 'ERROR',
|
|
53
53
|
ABORT: 'ABORT'
|
|
54
54
|
};
|
|
55
|
-
exports.
|
|
56
|
-
const IMPORT_JOB_STATE = {
|
|
55
|
+
const IMPORT_JOB_STATE = exports.IMPORT_JOB_STATE = {
|
|
57
56
|
EMPTY: 'EMPTY',
|
|
58
57
|
QUEUING: 'QUEUING',
|
|
59
58
|
IN_QUEUE: 'IN_QUEUE',
|
|
@@ -63,30 +62,25 @@ const IMPORT_JOB_STATE = {
|
|
|
63
62
|
ERROR: 'ERROR',
|
|
64
63
|
ABORT: 'ABORT'
|
|
65
64
|
};
|
|
66
|
-
exports.
|
|
67
|
-
const OPERATIONS = {
|
|
65
|
+
const OPERATIONS = exports.OPERATIONS = {
|
|
68
66
|
CREATE: 'CREATE',
|
|
69
67
|
UPDATE: 'UPDATE'
|
|
70
68
|
};
|
|
71
|
-
exports.
|
|
72
|
-
const CHUNK_SIZE = 100;
|
|
69
|
+
const CHUNK_SIZE = exports.CHUNK_SIZE = 100;
|
|
73
70
|
|
|
74
71
|
// We could configure here whether a logItemType is for a several records of a single record
|
|
75
72
|
// ie. whether is has bulkSequence or bulkSequenceStart & bulkSequenceEnd
|
|
76
|
-
exports.
|
|
77
|
-
const LOG_ITEM_TYPE = {
|
|
73
|
+
const LOG_ITEM_TYPE = exports.LOG_ITEM_TYPE = {
|
|
78
74
|
INPUT_RECORD_LOG: 'INPUT_RECORD_LOG',
|
|
79
75
|
MERGE_LOG: 'MERGE_LOG',
|
|
80
76
|
MATCH_LOG: 'MATCH_LOG',
|
|
81
77
|
RESULT_RECORD_LOG: 'RESULT_RECORD_LOG',
|
|
82
78
|
SPLITTER_LOG: 'SPLITTER_LOG'
|
|
83
79
|
};
|
|
84
|
-
exports.
|
|
85
|
-
const CONVERSION_FORMATS = {
|
|
80
|
+
const CONVERSION_FORMATS = exports.CONVERSION_FORMATS = {
|
|
86
81
|
MARCXML: 'MARCXML',
|
|
87
82
|
ISO2709: 'ISO2709',
|
|
88
83
|
JSON: 'JSON',
|
|
89
84
|
ALEPHSEQ: 'ALEPHSEQ'
|
|
90
85
|
};
|
|
91
|
-
exports.CONVERSION_FORMATS = CONVERSION_FORMATS;
|
|
92
86
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["QUEUE_ITEM_STATE","VALIDATOR","PENDING_QUEUING","PENDING_VALIDATION","QUEUING_IN_PROGRESS","UPLOADING","VALIDATING","WAITING_FOR_RECORDS","IMPORTER","IMPORTING","IN_PROCESS","IN_QUEUE","DONE","ERROR","ABORT","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["QUEUE_ITEM_STATE","exports","VALIDATOR","PENDING_QUEUING","PENDING_VALIDATION","QUEUING_IN_PROGRESS","UPLOADING","VALIDATING","WAITING_FOR_RECORDS","IMPORTER","IMPORTING","IN_PROCESS","IN_QUEUE","DONE","ERROR","ABORT","IMPORT_JOB_STATE","EMPTY","QUEUING","PROCESSING","OPERATIONS","CREATE","UPDATE","CHUNK_SIZE","LOG_ITEM_TYPE","INPUT_RECORD_LOG","MERGE_LOG","MATCH_LOG","RESULT_RECORD_LOG","SPLITTER_LOG","CONVERSION_FORMATS","MARCXML","ISO2709","JSON","ALEPHSEQ"],"sources":["../src/constants.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero 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-rest-api-commons 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 Affero 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\n// QueueItemState flows: see README.md\n\nexport const QUEUE_ITEM_STATE = {\n VALIDATOR: {\n PENDING_QUEUING: 'PENDING_QUEUING',\n PENDING_VALIDATION: 'PENDING_VALIDATION',\n QUEUING_IN_PROGRESS: 'QUEUING_IN_PROGRESS',\n UPLOADING: 'UPLOADING',\n VALIDATING: 'VALIDATING',\n WAITING_FOR_RECORDS: 'WAITING_FOR_RECORDS'\n },\n IMPORTER: {\n IMPORTING: 'IMPORTING',\n IN_PROCESS: 'IN_PROCESS',\n IN_QUEUE: 'IN_QUEUE'\n },\n DONE: 'DONE',\n ERROR: 'ERROR',\n ABORT: 'ABORT'\n};\n\nexport const IMPORT_JOB_STATE = {\n EMPTY: 'EMPTY',\n QUEUING: 'QUEUING',\n IN_QUEUE: 'IN_QUEUE',\n IMPORTING: 'IMPORTING',\n PROCESSING: 'PROCESSING',\n DONE: 'DONE',\n ERROR: 'ERROR',\n ABORT: 'ABORT'\n};\n\nexport const OPERATIONS = {\n CREATE: 'CREATE',\n UPDATE: 'UPDATE'\n};\n\nexport const CHUNK_SIZE = 100;\n\n// We could configure here whether a logItemType is for a several records of a single record\n// ie. whether is has bulkSequence or bulkSequenceStart & bulkSequenceEnd\nexport const LOG_ITEM_TYPE = {\n INPUT_RECORD_LOG: 'INPUT_RECORD_LOG',\n MERGE_LOG: 'MERGE_LOG',\n MATCH_LOG: 'MATCH_LOG',\n RESULT_RECORD_LOG: 'RESULT_RECORD_LOG',\n SPLITTER_LOG: 'SPLITTER_LOG'\n};\n\nexport const CONVERSION_FORMATS = {\n MARCXML: 'MARCXML',\n ISO2709: 'ISO2709',\n JSON: 'JSON',\n ALEPHSEQ: 'ALEPHSEQ'\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;;AAEA;;AAEO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAC9BE,SAAS,EAAE;IACTC,eAAe,EAAE,iBAAiB;IAClCC,kBAAkB,EAAE,oBAAoB;IACxCC,mBAAmB,EAAE,qBAAqB;IAC1CC,SAAS,EAAE,WAAW;IACtBC,UAAU,EAAE,YAAY;IACxBC,mBAAmB,EAAE;EACvB,CAAC;EACDC,QAAQ,EAAE;IACRC,SAAS,EAAE,WAAW;IACtBC,UAAU,EAAE,YAAY;IACxBC,QAAQ,EAAE;EACZ,CAAC;EACDC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE;AACT,CAAC;AAEM,MAAMC,gBAAgB,GAAAf,OAAA,CAAAe,gBAAA,GAAG;EAC9BC,KAAK,EAAE,OAAO;EACdC,OAAO,EAAE,SAAS;EAClBN,QAAQ,EAAE,UAAU;EACpBF,SAAS,EAAE,WAAW;EACtBS,UAAU,EAAE,YAAY;EACxBN,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE;AACT,CAAC;AAEM,MAAMK,UAAU,GAAAnB,OAAA,CAAAmB,UAAA,GAAG;EACxBC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE;AACV,CAAC;AAEM,MAAMC,UAAU,GAAAtB,OAAA,CAAAsB,UAAA,GAAG,GAAG;;AAE7B;AACA;AACO,MAAMC,aAAa,GAAAvB,OAAA,CAAAuB,aAAA,GAAG;EAC3BC,gBAAgB,EAAE,kBAAkB;EACpCC,SAAS,EAAE,WAAW;EACtBC,SAAS,EAAE,WAAW;EACtBC,iBAAiB,EAAE,mBAAmB;EACtCC,YAAY,EAAE;AAChB,CAAC;AAEM,MAAMC,kBAAkB,GAAA7B,OAAA,CAAA6B,kBAAA,GAAG;EAChCC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE;AACZ,CAAC"}
|
|
@@ -33,14 +33,13 @@ exports.REPLACE_PREFIXES = exports.BIB_STRIP_F884S_SETTINGS = exports.BIB_PREVAL
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
// This could be formatted so that 035-prefix and SID contents would be better connected than by just an array index
|
|
36
|
-
const BIB_F035_TO_SID = {
|
|
36
|
+
const BIB_F035_TO_SID = exports.BIB_F035_TO_SID = {
|
|
37
37
|
f035Filters: [/^\(FI-BTJ\)/u, /^\(FI-TATI\)/u],
|
|
38
38
|
fSIDFilters: ['FI-BTJ', 'tati']
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// There is somewhere other implementations of this same standardPrefixes to alephInternalPrefixes normalization
|
|
42
|
-
exports.
|
|
43
|
-
const REPLACE_PREFIXES = [{
|
|
42
|
+
const REPLACE_PREFIXES = exports.REPLACE_PREFIXES = [{
|
|
44
43
|
oldPrefix: 'FI-MELINDA',
|
|
45
44
|
newPrefix: 'FIN01',
|
|
46
45
|
prefixReplaceCodes: ['w']
|
|
@@ -64,35 +63,28 @@ const REPLACE_PREFIXES = [{
|
|
|
64
63
|
|
|
65
64
|
// If placed in config.js testing needs envs
|
|
66
65
|
// BIB_FORMAT_SETTINGS is outdated, use other settings instead
|
|
67
|
-
|
|
68
|
-
const BIB_FORMAT_SETTINGS = {
|
|
66
|
+
|
|
67
|
+
const BIB_FORMAT_SETTINGS = exports.BIB_FORMAT_SETTINGS = {
|
|
69
68
|
replacePrefixes: REPLACE_PREFIXES,
|
|
70
69
|
generateMissingSIDs: BIB_F035_TO_SID
|
|
71
70
|
};
|
|
72
|
-
exports.
|
|
73
|
-
const BIB_PREVALIDATION_FIX_SETTINGS = {
|
|
71
|
+
const BIB_PREVALIDATION_FIX_SETTINGS = exports.BIB_PREVALIDATION_FIX_SETTINGS = {
|
|
74
72
|
generateMissingSIDs: BIB_F035_TO_SID
|
|
75
73
|
};
|
|
76
|
-
exports.
|
|
77
|
-
const BIB_POSTMERGE_FIX_SETTINGS = {
|
|
74
|
+
const BIB_POSTMERGE_FIX_SETTINGS = exports.BIB_POSTMERGE_FIX_SETTINGS = {
|
|
78
75
|
handleTempUrns: true,
|
|
79
76
|
stripF884s: true
|
|
80
77
|
};
|
|
81
|
-
exports.
|
|
82
|
-
const BIB_PREIMPORT_FIX_SETTINGS = {
|
|
78
|
+
const BIB_PREIMPORT_FIX_SETTINGS = exports.BIB_PREIMPORT_FIX_SETTINGS = {
|
|
83
79
|
replacePrefixes: REPLACE_PREFIXES
|
|
84
80
|
};
|
|
85
|
-
exports.
|
|
86
|
-
const AUTNAME_PREIMPORT_FIX_SETTINGS = {
|
|
81
|
+
const AUTNAME_PREIMPORT_FIX_SETTINGS = exports.AUTNAME_PREIMPORT_FIX_SETTINGS = {
|
|
87
82
|
replacePrefixes: REPLACE_PREFIXES
|
|
88
83
|
};
|
|
89
|
-
exports.
|
|
90
|
-
const BIB_HANDLE_TEMP_URNS_SETTINGS = {
|
|
84
|
+
const BIB_HANDLE_TEMP_URNS_SETTINGS = exports.BIB_HANDLE_TEMP_URNS_SETTINGS = {
|
|
91
85
|
handleTempUrns: true
|
|
92
86
|
};
|
|
93
|
-
exports.
|
|
94
|
-
const BIB_STRIP_F884S_SETTINGS = {
|
|
87
|
+
const BIB_STRIP_F884S_SETTINGS = exports.BIB_STRIP_F884S_SETTINGS = {
|
|
95
88
|
stripF884s: true
|
|
96
89
|
};
|
|
97
|
-
exports.BIB_STRIP_F884S_SETTINGS = BIB_STRIP_F884S_SETTINGS;
|
|
98
90
|
//# sourceMappingURL=fix-constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-constants.js","names":["BIB_F035_TO_SID","
|
|
1
|
+
{"version":3,"file":"fix-constants.js","names":["BIB_F035_TO_SID","exports","f035Filters","fSIDFilters","REPLACE_PREFIXES","oldPrefix","newPrefix","prefixReplaceCodes","BIB_FORMAT_SETTINGS","replacePrefixes","generateMissingSIDs","BIB_PREVALIDATION_FIX_SETTINGS","BIB_POSTMERGE_FIX_SETTINGS","handleTempUrns","stripF884s","BIB_PREIMPORT_FIX_SETTINGS","AUTNAME_PREIMPORT_FIX_SETTINGS","BIB_HANDLE_TEMP_URNS_SETTINGS","BIB_STRIP_F884S_SETTINGS"],"sources":["../../src/helpers/fix-constants.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero 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-rest-api-commons 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 Affero 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\n// This could be formatted so that 035-prefix and SID contents would be better connected than by just an array index\nexport const BIB_F035_TO_SID = {\n f035Filters: [/^\\(FI-BTJ\\)/u, /^\\(FI-TATI\\)/u],\n fSIDFilters: ['FI-BTJ', 'tati']\n};\n\n// There is somewhere other implementations of this same standardPrefixes to alephInternalPrefixes normalization\nexport const REPLACE_PREFIXES = [\n {\n oldPrefix: 'FI-MELINDA',\n newPrefix: 'FIN01',\n prefixReplaceCodes: ['w']\n },\n {\n oldPrefix: 'FI-ASTERI-S',\n newPrefix: 'FIN10',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-N',\n newPrefix: 'FIN11',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-A',\n newPrefix: 'FIN12',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-W',\n newPrefix: 'FIN13',\n prefixReplaceCodes: ['0']\n }\n];\n\n\n// If placed in config.js testing needs envs\n// BIB_FORMAT_SETTINGS is outdated, use other settings instead\n\n\nexport const BIB_FORMAT_SETTINGS = {\n replacePrefixes: REPLACE_PREFIXES,\n generateMissingSIDs: BIB_F035_TO_SID\n};\n\nexport const BIB_PREVALIDATION_FIX_SETTINGS = {\n generateMissingSIDs: BIB_F035_TO_SID\n};\n\nexport const BIB_POSTMERGE_FIX_SETTINGS = {\n handleTempUrns: true,\n stripF884s: true\n};\n\nexport const BIB_PREIMPORT_FIX_SETTINGS = {\n replacePrefixes: REPLACE_PREFIXES\n};\n\nexport const AUTNAME_PREIMPORT_FIX_SETTINGS = {\n replacePrefixes: REPLACE_PREFIXES\n};\n\nexport const BIB_HANDLE_TEMP_URNS_SETTINGS = {\n handleTempUrns: true\n};\n\nexport const BIB_STRIP_F884S_SETTINGS = {\n stripF884s: true\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;;AAEA;AACO,MAAMA,eA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M,MAAMa,6BAA6B,GAAAhB,OAAA,CAAAgB,6BAAA,GAAG;EAC3CJ,cAAc,EAAE;AAClB,CAAC;AAEM,MAAMK,wBAAwB,GAAAjB,OAAA,CAAAiB,wBAAA,GAAG;EACtCJ,UAAU,EAAE;AACd,CAAC"}
|
package/dist/helpers/fix.spec.js
CHANGED
|
@@ -8,8 +8,8 @@ var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
|
8
8
|
var _fix = require("./fix");
|
|
9
9
|
var fixSettings = _interopRequireWildcard(require("./fix-constants"));
|
|
10
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
-
function _getRequireWildcardCache(
|
|
12
|
-
function _interopRequireWildcard(
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
// import inspect from 'util';
|
|
14
14
|
|
|
15
15
|
const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:fix:test');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix.spec.js","names":["_chai","require","_marcRecord","_fixura","_fixugen","_interopRequireDefault","_fix","fixSettings","_interopRequireWildcard","_debug","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"file":"fix.spec.js","names":["_chai","require","_marcRecord","_fixura","_fixugen","_interopRequireDefault","_fix","fixSettings","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","debug","createDebugLogger","debugData","extend","generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","getFixture","settings","undefined","Error","runSettings","record","MarcRecord","subfieldValues","expectedRecord","stringify","resultRecord","fixRecord","expect","to","eql"],"sources":["../../src/helpers/fix.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\nimport {fixRecord} from './fix';\nimport * as fixSettings from './fix-constants';\nimport createDebugLogger from 'debug';\n// import inspect from 'util';\n\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fix:test');\nconst debugData = debug.extend('data');\n\ngenerateTests({\n callback,\n path: [__dirname, '..', '..', 'test-fixtures', 'fix'],\n recurse: true,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: false,\n reader: READERS.JSON\n }\n});\n\nfunction callback({getFixture, settings = undefined}) {\n if (settings !== undefined && fixSettings[settings] === undefined) {\n throw new Error(`There are no settings ${settings} defined!`);\n }\n const runSettings = fixSettings[settings] || settings;\n\n const record = new MarcRecord(getFixture('record.json'), {subfieldValues: false});\n const expectedRecord = getFixture('expectedRecord.json');\n\n debug(`Running fixer with settings ${settings}.`);\n debugData(JSON.stringify(runSettings, null, 2));\n\n const resultRecord = fixRecord(record, runSettings);\n debugData(`Result: ${JSON.stringify(resultRecord)}`);\n debugData(`Expected: ${JSON.stringify(expectedRecord)}`);\n expect(resultRecord).to.eql(expectedRecord);\n\n}\n"],"mappings":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAC,sBAAA,CAAAJ,OAAA;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I,YAAM,EAACF,YAAY,CAAC,CAACG,EAAE,CAACC,GAAG,CAACN,cAAc,CAAC;AAE7C"}
|
|
@@ -5,8 +5,8 @@ var _chai = require("chai");
|
|
|
5
5
|
var _fixura = _interopRequireWildcard(require("@natlibfi/fixura"));
|
|
6
6
|
var _marcRecord = require("@natlibfi/marc-record");
|
|
7
7
|
var _validation = _interopRequireDefault(require("./validation"));
|
|
8
|
-
function _getRequireWildcardCache(
|
|
9
|
-
function _interopRequireWildcard(
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.spec.js","names":["_chai","require","_fixura","_interopRequireWildcard","_marcRecord","_validation","_interopRequireDefault","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"file":"validation.spec.js","names":["_chai","require","_fixura","_interopRequireWildcard","_marcRecord","_validation","_interopRequireDefault","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","describe","FIXTURES_PATH","__dirname","getFixture","fixtureFactory","root","reader","READERS","JSON","it","validator","createValidator","record","MarcRecord","components","result","toObject","expected","expect","to","eql","failed","equal"],"sources":["../../src/helpers/validation.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 microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero 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-rest-api-commons 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 Affero 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 fixtureFactory, {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createValidator from './validation';\n\ndescribe('services/validate', () => {\n const FIXTURES_PATH = [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'validation'\n ];\n const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});\n\n describe('f003-fi-melinda', () => {\n it('Should have failed: false', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(false);\n });\n });\n\n describe('f003-not-fi-melinda', () => {\n it('Should have failed: true', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-not-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003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,0BAA0B,EAAE,YAAY;MACzC,MAAMC,SAAS,GAAG,MAAM,IAAAC,mBAAe,EAAC,CAAC;MACzC,MAAMC,MAAM,GAAG,IAAIC,sBAAU,CAACV,UAAU,CAAC;QACvCW,UAAU,EAAE,CACV,IAAI,EACJ,0BAA0B;MAE9B,CAAC,CAAC,CAAC;MACH,MAAMC,MAAM,GAAG,MAAML,SAAS,CAACE,MAAM,CAACI,QAAQ,CAAC,CAAC,CAAC;MACjD,MAAMC,QAAQ,GAAGd,UAAU,CAAC;QAC1BW,UAAU,EAAE,CACV,KAAK,EACL,0BAA0B;MAE9B,CAAC,CAAC;MACF,IAAAI,YAAM,EAACH,MAAM,CAAC,CAACI,EAAE,CAACC,GAAG,CAACH,QAAQ,CAAC;MAC/B,IAAAC,YAAM,EAACH,MAAM,CAACM,MAAM,CAAC,CAACF,EAAE,CAACG,KAAK,CAAC,IAAI,CAAC;IACtC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -105,6 +105,6 @@ Object.keys(_constants).forEach(function (key) {
|
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
|
-
function _getRequireWildcardCache(
|
|
109
|
-
function _interopRequireWildcard(
|
|
108
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
109
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
110
110
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_mongo","_interopRequireDefault","require","_mongoLog","_amqp","_conversion","_validation","fixes","_interopRequireWildcard","exports","_utils","_constants","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_mongo","_interopRequireDefault","require","_mongoLog","_amqp","_conversion","_validation","fixes","_interopRequireWildcard","exports","_utils","_constants","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set"],"sources":["../src/index.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero 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-rest-api-commons 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 Affero 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 mongoFactory from './mongo';\nimport mongoLogFactory from './mongoLog';\nimport amqpFactory from './amqp';\nimport conversions from './helpers/conversion';\nimport validations from './helpers/validation';\nimport * as fixes from './helpers/fix';\nimport {logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem, addRecordResponseItems} from './utils';\n\nexport {mongoFactory, mongoLogFactory, amqpFactory, conversions, validations, fixes, logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem, addRecordResponseItems};\nexport * from './constants';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,KAAA,GAAAC,uBAAA,CAAAN,OAAA;AAAuCO,OAAA,CAAAF,KAAA,GAAAA,KAAA;AACvC,IAAAG,MAAA,GAAAR,OAAA;AAGA,IAAAS,UAAA,GAAAT,OAAA;AAAAU,MAAA,CAAAC,IAAA,CAAAF,UAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAN,OAAA,IAAAA,OAAA,CAAAM,GAAA,MAAAJ,UAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAQ,cAAA,CAAAX,OAAA,EAAAM,GAAA;IAAAM,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAX,UAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAA4B,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAhB,wBAAAgB,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAL,GAAA,CAAAE,CAAA,OAAAO,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAArB,MAAA,CAAAQ,cAAA,IAAAR,MAAA,CAAAsB,wBAAA,WAAAC,CAAA,IAAAX,CAAA,oBAAAW,CAAA,IAAAvB,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAW,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAArB,MAAA,CAAAsB,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAd,GAAA,IAAAc,CAAA,CAAAC,GAAA,IAAAzB,MAAA,CAAAQ,cAAA,CAAAW,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA"}
|
package/dist/mongoLog.js
CHANGED
|
@@ -41,7 +41,7 @@ var _constants = require("./constants");
|
|
|
41
41
|
*
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
|
-
async function _default(MONGO_URI) {
|
|
44
|
+
async function _default(MONGO_URI, dbName = 'rest-api') {
|
|
45
45
|
const logger = (0, _melindaBackendCommons.createLogger)();
|
|
46
46
|
|
|
47
47
|
// Connect to mongo (MONGO)
|
|
@@ -49,13 +49,14 @@ async function _default(MONGO_URI) {
|
|
|
49
49
|
useNewUrlParser: true,
|
|
50
50
|
useUnifiedTopology: true
|
|
51
51
|
});
|
|
52
|
-
const db = client.db(
|
|
52
|
+
const db = client.db(dbName);
|
|
53
53
|
const collection = 'logs';
|
|
54
54
|
return {
|
|
55
55
|
addLogItem,
|
|
56
56
|
query,
|
|
57
57
|
queryById,
|
|
58
58
|
getListOfLogs,
|
|
59
|
+
getListOfCatalogers,
|
|
59
60
|
getExpandedListOfLogs,
|
|
60
61
|
protect,
|
|
61
62
|
remove,
|
|
@@ -69,6 +70,7 @@ async function _default(MONGO_URI) {
|
|
|
69
70
|
protected: false
|
|
70
71
|
};
|
|
71
72
|
try {
|
|
73
|
+
// console.log(newLogItem); // eslint-disable-line
|
|
72
74
|
checkLogItemType(logItem.logItemType, false);
|
|
73
75
|
const result = await db.collection(collection).insertOne(newLogItem);
|
|
74
76
|
if (result.acknowledged) {
|
|
@@ -79,6 +81,7 @@ async function _default(MONGO_URI) {
|
|
|
79
81
|
} = logItem;
|
|
80
82
|
const itemString = blobSequenceStart && blobSequenceEnd ? `${blobSequenceStart} - ${blobSequenceEnd}` : `${blobSequence}`;
|
|
81
83
|
logger.info(`*** New ${logItem.logItemType} added for ${logItem.correlationId}, blobSequence(s): ${itemString}. ***`);
|
|
84
|
+
// console.log('addLogItem done', result); // eslint-disable-line
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
84
87
|
throw new _melindaCommons.Error(_httpStatus.default.INTERNAL_SERVER_ERROR);
|
|
@@ -133,20 +136,27 @@ async function _default(MONGO_URI) {
|
|
|
133
136
|
payload: result.length > 0 ? result : 'No logs found'
|
|
134
137
|
};
|
|
135
138
|
}
|
|
139
|
+
async function getListOfCatalogers() {
|
|
140
|
+
logger.debug(`Getting list of Catalogers`);
|
|
141
|
+
const result = await db.collection(collection) // eslint-disable-line functional/immutable-data
|
|
142
|
+
.distinct('cataloger');
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
136
145
|
|
|
137
146
|
// getExpandedListOfLogs returns groped MERGE_LOGs and MATCH_LOGs
|
|
138
|
-
async function getExpandedListOfLogs(
|
|
147
|
+
async function getExpandedListOfLogs({
|
|
148
|
+
logItemTypes = [_constants.LOG_ITEM_TYPE.MERGE_LOG, _constants.LOG_ITEM_TYPE.MATCH_LOG],
|
|
149
|
+
catalogers = [],
|
|
150
|
+
dateBefore = new Date(),
|
|
151
|
+
dateAfter = new Date('2000-01-01')
|
|
152
|
+
}) {
|
|
153
|
+
logger.debug(`commons: logItemTypes: ${JSON.stringify(logItemTypes)}, dateAfter: ${dateAfter}, dateBefore: ${dateBefore}}, catalogers: ${JSON.stringify(catalogers)}`);
|
|
154
|
+
logger.debug(JSON.stringify(generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter))); // eslint-disable-line
|
|
139
155
|
//checkLogItemType(logItemType, false, false);
|
|
140
156
|
logger.debug(`Getting expanded list of logs`);
|
|
141
157
|
const pipeline = [
|
|
142
158
|
// currently return only MERGE_LOG and MATCH_LOG
|
|
143
|
-
{
|
|
144
|
-
'$match': {
|
|
145
|
-
'logItemType': {
|
|
146
|
-
'$in': ['MERGE_LOG', 'MATCH_LOG']
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
159
|
+
generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter), {
|
|
150
160
|
'$sort': {
|
|
151
161
|
'correlationId': 1,
|
|
152
162
|
'logItemType': 1,
|
|
@@ -168,6 +178,12 @@ async function _default(MONGO_URI) {
|
|
|
168
178
|
'$sum': 1
|
|
169
179
|
}
|
|
170
180
|
}
|
|
181
|
+
}, {
|
|
182
|
+
'$sort': {
|
|
183
|
+
'correlationId': 1,
|
|
184
|
+
'logItemType': 1,
|
|
185
|
+
'creationTime': 1
|
|
186
|
+
}
|
|
171
187
|
}];
|
|
172
188
|
const result = await db.collection(collection) // eslint-disable-line functional/immutable-data
|
|
173
189
|
.aggregate(pipeline).toArray();
|
|
@@ -196,6 +212,25 @@ async function _default(MONGO_URI) {
|
|
|
196
212
|
status: fixedResult.length > 0 ? _httpStatus.default.OK : _httpStatus.default.NOT_FOUND,
|
|
197
213
|
payload: fixedResult.length > 0 ? fixedResult : 'No logs found'
|
|
198
214
|
};
|
|
215
|
+
function generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter) {
|
|
216
|
+
const dateBeforeIso = new Date(dateBefore).toISOString();
|
|
217
|
+
const dateAfterIso = new Date(dateAfter).toISOString();
|
|
218
|
+
const matchOptions = {
|
|
219
|
+
'$match': {
|
|
220
|
+
'logItemType': logItemTypes.length > 0 ? {
|
|
221
|
+
'$in': logItemTypes
|
|
222
|
+
} : /.*/ui,
|
|
223
|
+
'cataloger': catalogers.length > 0 ? {
|
|
224
|
+
'$in': catalogers
|
|
225
|
+
} : /.*/ui,
|
|
226
|
+
'creationTime': {
|
|
227
|
+
'$gte': dateAfterIso,
|
|
228
|
+
'$lte': dateBeforeIso
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
return matchOptions;
|
|
233
|
+
}
|
|
199
234
|
}
|
|
200
235
|
async function protect(correlationId, blobSequence) {
|
|
201
236
|
logger.info(`Protecting in Mongo (${collection}) correlationId: ${correlationId}, blobSequence: ${blobSequence}`);
|
package/dist/mongoLog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoLog.js","names":["_mongodb","require","_melindaBackendCommons","_melindaCommons","_utils","_moment","_interopRequireDefault","_httpStatus","_mongoSanitize","_constants","_default","MONGO_URI","logger","createLogger","client","MongoClient","connect","useNewUrlParser","useUnifiedTopology","db","collection","addLogItem","query","queryById","getListOfLogs","getExpandedListOfLogs","protect","remove","removeBySequences","logItem","time","moment","toDate","newLogItem","creationTime","protected","checkLogItemType","logItemType","result","insertOne","acknowledged","blobSequence","blobSequenceStart","blobSequenceEnd","itemString","info","correlationId","ApiError","httpStatus","INTERNAL_SERVER_ERROR","error","errorMessage","payload","message","logError","params","debug","JSON","stringify","limit","skip","rest","find","sort","parseInt","toArray","length","correlationIdString","distinct","status","OK","NOT_FOUND","pipeline","aggregate","fixedResult","map","logListing","_id","cataloger","logCount","silly","cleanCorrelationId","sanitize","cleanBlobSequence","filter","updateMany","$set","modificationTime","$not","modifiedCount","force","clean","$ne","deleteMany","deletedCount","sequences","cleanSequences","sequence","Number","isInteger","$in","errorUnknown","errorNotExisting","typeInLogItemTypes","Object","values","LOG_ITEM_TYPE","indexOf"],"sources":["../src/mongoLog.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero 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-rest-api-commons 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 Affero 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 {MongoClient} from 'mongodb';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {logError} from './utils.js';\nimport moment from 'moment';\nimport httpStatus from 'http-status';\nimport sanitize from 'mongo-sanitize';\nimport {LOG_ITEM_TYPE} from './constants';\n\nexport default async function (MONGO_URI) {\n const logger = createLogger();\n\n // Connect to mongo (MONGO)\n const client = await MongoClient.connect(MONGO_URI, {useNewUrlParser: true, useUnifiedTopology: true});\n const db = client.db('rest-api');\n const collection = 'logs';\n return {addLogItem, query, queryById, getListOfLogs, getExpandedListOfLogs, protect, remove, removeBySequences};\n\n async function addLogItem(logItem) {\n const time = moment().toDate();\n const newLogItem = {\n ...logItem,\n creationTime: time,\n protected: false\n };\n try {\n checkLogItemType(logItem.logItemType, false);\n const result = await db.collection(collection).insertOne(newLogItem);\n if (result.acknowledged) {\n const {blobSequence, blobSequenceStart, blobSequenceEnd} = logItem;\n const itemString = blobSequenceStart && blobSequenceEnd ? `${blobSequenceStart} - ${blobSequenceEnd}` : `${blobSequence}`;\n logger.info(`*** New ${logItem.logItemType} added for ${logItem.correlationId}, blobSequence(s): ${itemString}. ***`);\n return;\n }\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR);\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n async function query(params) {\n logger.debug(`Query params: ${JSON.stringify(params)}`);\n checkLogItemType(params.logItemType, false, false);\n const {limit = 5, skip = 0, ...rest} = params;\n logger.debug(`Actual query params: ${JSON.stringify(rest)}`);\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .find(rest)\n .sort({creationTime: 1})\n .skip(parseInt(skip, 10))\n .limit(parseInt(limit, 10))\n .toArray();\n //logger.debug(`Query result: ${result}`);\n logger.debug(`Query result: ${result.length > 0 ? `Found ${result.length} log items! (skip: ${skip} limit: ${limit})` : 'Not found!'}`);\n return result;\n }\n\n // DEVELOP: queryById returns jsut one (randomish) log! is this useful?\n async function queryById(correlationIdString, skip = 0, limit = 1) {\n logger.debug(`QueryById: ${correlationIdString}`);\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .find({correlationId: correlationIdString})\n .sort({blobSequence: 1})\n .skip(parseInt(skip, 10))\n .limit(parseInt(limit, 10))\n .toArray();\n logger.debug(`Query result: ${result.length > 0 ? `Found ${result.length} log items!` : 'Not found!'}`);\n return result;\n }\n\n // getListOfLogs returns list of correlationIds that have logs of given logItemType\n // if logItemType is not given, getListOfLogs returns list of correlationIds that have MERGE_LOG\n async function getListOfLogs(logItemType = 'MERGE_LOG') {\n checkLogItemType(logItemType, false, false);\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .distinct('correlationId', {logItemType});\n logger.debug(`Query result: ${result.length > 0 ? `Found ${result.length} log items!` : 'Not found!'}`);\n return {status: result.length > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.length > 0 ? result : 'No logs found'};\n }\n\n // getExpandedListOfLogs returns groped MERGE_LOGs and MATCH_LOGs\n async function getExpandedListOfLogs() {\n //checkLogItemType(logItemType, false, false);\n logger.debug(`Getting expanded list of logs`);\n const pipeline = [\n // currently return only MERGE_LOG and MATCH_LOG\n {'$match': {'logItemType': {'$in': ['MERGE_LOG', 'MATCH_LOG']}}},\n {'$sort':\n {'correlationId': 1, 'logItemType': 1, 'creationTime': 1}},\n {'$group':\n {'_id': {'correlationId': '$correlationId', 'logItemType': '$logItemType'},\n 'creationTime': {'$first': '$creationTime'},\n 'cataloger': {'$first': '$cataloger'},\n 'logCount': {'$sum': 1}}}\n ];\n\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .aggregate(pipeline)\n .toArray();\n\n const fixedResult = result.map((logListing) => {\n const {correlationId, logItemType} = logListing._id;\n const {cataloger, creationTime, logCount} = logListing;\n return {correlationId, logItemType, cataloger, creationTime, logCount};\n });\n\n logger.silly(`Query result: ${JSON.stringify(result)}`);\n logger.silly(`Query result: ${JSON.stringify(fixedResult)}`);\n\n logger.debug(`Query result: ${fixedResult.length > 0 ? `Found ${fixedResult.length} log items!` : 'Not found!'}`);\n return {status: fixedResult.length > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: fixedResult.length > 0 ? fixedResult : 'No logs found'};\n }\n\n async function protect(correlationId, blobSequence) {\n logger.info(`Protecting in Mongo (${collection}) correlationId: ${correlationId}, blobSequence: ${blobSequence}`);\n const cleanCorrelationId = sanitize(correlationId);\n const cleanBlobSequence = sanitize(blobSequence);\n const filter = blobSequence ? {correlationId: cleanCorrelationId, blobSequence: parseInt(cleanBlobSequence, 10)} : {correlationId: cleanCorrelationId};\n\n try {\n const result = await db.collection(collection).updateMany(\n filter,\n [\n {\n $set: {\n modificationTime: moment().toDate(),\n protected: {$not: '$protected'}\n }\n }\n ]\n );\n return {status: result.modifiedCount > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.modifiedCount > 0 ? result : 'No logs found'};\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n async function remove(correlationId, force = false) {\n logger.info(`Removing from Mongo (${collection}) correlationId: ${correlationId}`);\n const clean = sanitize(correlationId);\n const filter = force ? {correlationId: clean} : {correlationId: clean, protected: {$ne: true}};\n\n try {\n const result = await db.collection(collection).deleteMany(filter);\n return {status: result.deletedCount > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.deletedCount > 0 ? result : 'No logs found'};\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n async function removeBySequences(correlationId, sequences = [], force = false) {\n logger.info(`Removing from Mongo (${collection}) correlationId: ${correlationId}, sequences: ${sequences.length}`);\n const clean = sanitize(correlationId);\n // blobSequences are integers that start from 1\n // we accept also strings that are convertilble to integers greated than 0\n const cleanSequences = sequences.filter(sequence => Number.isInteger(Number(sequence)) && sequence > 0);\n\n if (sequences.length !== cleanSequences.length) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Invalid sequences in removeBySequences. Sequences should be positive integers`);\n }\n\n const filter = force ? {correlationId: clean, blobSequence: {$in: cleanSequences}} : {correlationId: clean, blobSequence: {$in: sequences}, protected: {$ne: true}};\n\n try {\n const result = await db.collection(collection).deleteMany(filter);\n return {status: result.deletedCount > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.deletedCount > 0 ? result : 'No logs found'};\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n function checkLogItemType(logItemType, errorUnknown = false, errorNotExisting = false) {\n\n if (logItemType) {\n const typeInLogItemTypes = Object.values(LOG_ITEM_TYPE).indexOf(logItemType) > -1;\n if (typeInLogItemTypes) {\n return logger.debug(`Valid logItemType: ${logItemType}`);\n }\n if (errorUnknown) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Unknown logItemType: ${logItemType}`);\n }\n return logger.debug(`WARN: We have unknown logType: ${logItemType}`);\n }\n\n if (errorNotExisting) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `No logItemType: ${logItemType}`);\n }\n return logger.debug(`No logItemType: ${logItemType}`);\n }\n}\n"],"mappings":";;;;;;;AA4BA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,WAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,cAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAnCA;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;;AAWe,eAAAS,SAAgBC,SAAS,EAAE;EACxC,MAAMC,MAAM,GAAG,IAAAC,mCAAY,EAAC,CAAC;;EAE7B;EACA,MAAMC,MAAM,GAAG,MAAMC,oBAAW,CAACC,OAAO,CAACL,SAAS,EAAE;IAACM,eAAe,EAAE,IAAI;IAAEC,kBAAkB,EAAE;EAAI,CAAC,CAAC;EACtG,MAAMC,EAA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AQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,kBAAiBE,YAAa,EAAC,CAAC;IACxF;EACF;EAEA,SAASf,gBAAgBA,CAACC,WAAW,EAAEgE,YAAY,GAAG,KAAK,EAAEC,gBAAgB,GAAG,KAAK,EAAE;IAErF,IAAIjE,WAAW,EAAE;MACf,MAAMkE,kBAAkB,GAAGC,MAAM,CAACC,MAAM,CAACC,wBAAa,CAAC,CAACC,OAAO,CAACtE,WAAW,CAAC,GAAG,CAAC,CAAC;MACjF,IAAIkE,kBAAkB,EAAE;QACtB,OAAO3F,MAAM,CAAC4C,KAAK,CAAE,sBAAqBnB,WAAY,EAAC,CAAC;MAC1D;MACA,IAAIgE,YAAY,EAAE;QAChB,MAAM,IAAItD,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,wBAAuBZ,WAAY,EAAC,CAAC;MAC7F;MACA,OAAOzB,MAAM,CAAC4C,KAAK,CAAE,kCAAiCnB,WAAY,EAAC,CAAC;IACtE;IAEA,IAAIiE,gBAAgB,EAAE;MACpB,MAAM,IAAIvD,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,mBAAkBZ,WAAY,EAAC,CAAC;IACxF;IACA,OAAOzB,MAAM,CAAC4C,KAAK,CAAE,mBAAkBnB,WAAY,EAAC,CAAC;EACvD;AACF"}
|
|
1
|
+
{"version":3,"file":"mongoLog.js","names":["_mongodb","require","_melindaBackendCommons","_melindaCommons","_utils","_moment","_interopRequireDefault","_httpStatus","_mongoSanitize","_constants","_default","MONGO_URI","dbName","logger","createLogger","client","MongoClient","connect","useNewUrlParser","useUnifiedTopology","db","collection","addLogItem","query","queryById","getListOfLogs","getListOfCatalogers","getExpandedListOfLogs","protect","remove","removeBySequences","logItem","time","moment","toDate","newLogItem","creationTime","protected","checkLogItemType","logItemType","result","insertOne","acknowledged","blobSequence","blobSequenceStart","blobSequenceEnd","itemString","info","correlationId","ApiError","httpStatus","INTERNAL_SERVER_ERROR","error","errorMessage","payload","message","logError","params","debug","JSON","stringify","limit","skip","rest","find","sort","parseInt","toArray","length","correlationIdString","distinct","status","OK","NOT_FOUND","logItemTypes","LOG_ITEM_TYPE","MERGE_LOG","MATCH_LOG","catalogers","dateBefore","Date","dateAfter","generateMatchObject","pipeline","aggregate","fixedResult","map","logListing","_id","cataloger","logCount","silly","dateBeforeIso","toISOString","dateAfterIso","matchOptions","cleanCorrelationId","sanitize","cleanBlobSequence","filter","updateMany","$set","modificationTime","$not","modifiedCount","force","clean","$ne","deleteMany","deletedCount","sequences","cleanSequences","sequence","Number","isInteger","$in","errorUnknown","errorNotExisting","typeInLogItemTypes","Object","values","indexOf"],"sources":["../src/mongoLog.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero 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-rest-api-commons 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 Affero 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 {MongoClient} from 'mongodb';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {logError} from './utils.js';\nimport moment from 'moment';\nimport httpStatus from 'http-status';\nimport sanitize from 'mongo-sanitize';\nimport {LOG_ITEM_TYPE} from './constants';\n\nexport default async function (MONGO_URI, dbName = 'rest-api') {\n const logger = createLogger();\n\n // Connect to mongo (MONGO)\n const client = await MongoClient.connect(MONGO_URI, {useNewUrlParser: true, useUnifiedTopology: true});\n const db = client.db(dbName);\n const collection = 'logs';\n return {addLogItem, query, queryById, getListOfLogs, getListOfCatalogers, getExpandedListOfLogs, protect, remove, removeBySequences};\n\n async function addLogItem(logItem) {\n const time = moment().toDate();\n const newLogItem = {\n ...logItem,\n creationTime: time,\n protected: false\n };\n try {\n // console.log(newLogItem); // eslint-disable-line\n checkLogItemType(logItem.logItemType, false);\n const result = await db.collection(collection).insertOne(newLogItem);\n if (result.acknowledged) {\n const {blobSequence, blobSequenceStart, blobSequenceEnd} = logItem;\n const itemString = blobSequenceStart && blobSequenceEnd ? `${blobSequenceStart} - ${blobSequenceEnd}` : `${blobSequence}`;\n logger.info(`*** New ${logItem.logItemType} added for ${logItem.correlationId}, blobSequence(s): ${itemString}. ***`);\n // console.log('addLogItem done', result); // eslint-disable-line\n return;\n }\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR);\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n async function query(params) {\n logger.debug(`Query params: ${JSON.stringify(params)}`);\n checkLogItemType(params.logItemType, false, false);\n const {limit = 5, skip = 0, ...rest} = params;\n logger.debug(`Actual query params: ${JSON.stringify(rest)}`);\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .find(rest)\n .sort({creationTime: 1})\n .skip(parseInt(skip, 10))\n .limit(parseInt(limit, 10))\n .toArray();\n //logger.debug(`Query result: ${result}`);\n logger.debug(`Query result: ${result.length > 0 ? `Found ${result.length} log items! (skip: ${skip} limit: ${limit})` : 'Not found!'}`);\n return result;\n }\n\n // DEVELOP: queryById returns jsut one (randomish) log! is this useful?\n async function queryById(correlationIdString, skip = 0, limit = 1) {\n logger.debug(`QueryById: ${correlationIdString}`);\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .find({correlationId: correlationIdString})\n .sort({blobSequence: 1})\n .skip(parseInt(skip, 10))\n .limit(parseInt(limit, 10))\n .toArray();\n logger.debug(`Query result: ${result.length > 0 ? `Found ${result.length} log items!` : 'Not found!'}`);\n return result;\n }\n\n // getListOfLogs returns list of correlationIds that have logs of given logItemType\n // if logItemType is not given, getListOfLogs returns list of correlationIds that have MERGE_LOG\n async function getListOfLogs(logItemType = 'MERGE_LOG') {\n checkLogItemType(logItemType, false, false);\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .distinct('correlationId', {logItemType});\n logger.debug(`Query result: ${result.length > 0 ? `Found ${result.length} log items!` : 'Not found!'}`);\n return {status: result.length > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.length > 0 ? result : 'No logs found'};\n }\n\n async function getListOfCatalogers() {\n logger.debug(`Getting list of Catalogers`);\n\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .distinct('cataloger');\n\n return result;\n }\n\n // getExpandedListOfLogs returns groped MERGE_LOGs and MATCH_LOGs\n async function getExpandedListOfLogs({logItemTypes = [LOG_ITEM_TYPE.MERGE_LOG, LOG_ITEM_TYPE.MATCH_LOG], catalogers = [], dateBefore = new Date(), dateAfter = new Date('2000-01-01')}) {\n logger.debug(`commons: logItemTypes: ${JSON.stringify(logItemTypes)}, dateAfter: ${dateAfter}, dateBefore: ${dateBefore}}, catalogers: ${JSON.stringify(catalogers)}`);\n logger.debug(JSON.stringify(generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter))); // eslint-disable-line\n //checkLogItemType(logItemType, false, false);\n logger.debug(`Getting expanded list of logs`);\n const pipeline = [\n // currently return only MERGE_LOG and MATCH_LOG\n generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter),\n {\n '$sort':\n {'correlationId': 1, 'logItemType': 1, 'creationTime': 1}\n },\n {\n '$group':\n {\n '_id': {'correlationId': '$correlationId', 'logItemType': '$logItemType'},\n 'creationTime': {'$first': '$creationTime'},\n 'cataloger': {'$first': '$cataloger'},\n 'logCount': {'$sum': 1}\n }\n },\n {\n '$sort':\n {'correlationId': 1, 'logItemType': 1, 'creationTime': 1}\n }\n ];\n\n const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .aggregate(pipeline)\n .toArray();\n\n const fixedResult = result.map((logListing) => {\n const {correlationId, logItemType} = logListing._id;\n const {cataloger, creationTime, logCount} = logListing;\n return {correlationId, logItemType, cataloger, creationTime, logCount};\n });\n\n logger.silly(`Query result: ${JSON.stringify(result)}`);\n logger.silly(`Query result: ${JSON.stringify(fixedResult)}`);\n\n logger.debug(`Query result: ${fixedResult.length > 0 ? `Found ${fixedResult.length} log items!` : 'Not found!'}`);\n return {status: fixedResult.length > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: fixedResult.length > 0 ? fixedResult : 'No logs found'};\n\n function generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter) {\n const dateBeforeIso = new Date(dateBefore).toISOString();\n const dateAfterIso = new Date(dateAfter).toISOString();\n const matchOptions = {\n '$match': {\n 'logItemType': logItemTypes.length > 0 ? {'$in': logItemTypes} : /.*/ui,\n 'cataloger': catalogers.length > 0 ? {'$in': catalogers} : /.*/ui,\n 'creationTime': {\n '$gte': dateAfterIso,\n '$lte': dateBeforeIso\n }\n }\n };\n\n return matchOptions;\n }\n }\n\n async function protect(correlationId, blobSequence) {\n logger.info(`Protecting in Mongo (${collection}) correlationId: ${correlationId}, blobSequence: ${blobSequence}`);\n const cleanCorrelationId = sanitize(correlationId);\n const cleanBlobSequence = sanitize(blobSequence);\n const filter = blobSequence ? {correlationId: cleanCorrelationId, blobSequence: parseInt(cleanBlobSequence, 10)} : {correlationId: cleanCorrelationId};\n\n try {\n const result = await db.collection(collection).updateMany(\n filter,\n [\n {\n $set: {\n modificationTime: moment().toDate(),\n protected: {$not: '$protected'}\n }\n }\n ]\n );\n return {status: result.modifiedCount > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.modifiedCount > 0 ? result : 'No logs found'};\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n async function remove(correlationId, force = false) {\n logger.info(`Removing from Mongo (${collection}) correlationId: ${correlationId}`);\n const clean = sanitize(correlationId);\n const filter = force ? {correlationId: clean} : {correlationId: clean, protected: {$ne: true}};\n\n try {\n const result = await db.collection(collection).deleteMany(filter);\n return {status: result.deletedCount > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.deletedCount > 0 ? result : 'No logs found'};\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n async function removeBySequences(correlationId, sequences = [], force = false) {\n logger.info(`Removing from Mongo (${collection}) correlationId: ${correlationId}, sequences: ${sequences.length}`);\n const clean = sanitize(correlationId);\n // blobSequences are integers that start from 1\n // we accept also strings that are convertilble to integers greated than 0\n const cleanSequences = sequences.filter(sequence => Number.isInteger(Number(sequence)) && sequence > 0);\n\n if (sequences.length !== cleanSequences.length) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Invalid sequences in removeBySequences. Sequences should be positive integers`);\n }\n\n const filter = force ? {correlationId: clean, blobSequence: {$in: cleanSequences}} : {correlationId: clean, blobSequence: {$in: sequences}, protected: {$ne: true}};\n\n try {\n const result = await db.collection(collection).deleteMany(filter);\n return {status: result.deletedCount > 0 ? httpStatus.OK : httpStatus.NOT_FOUND, payload: result.deletedCount > 0 ? result : 'No logs found'};\n } catch (error) {\n const errorMessage = error.payload || error.message || '';\n logError(error);\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Mongo errored: ${errorMessage}`);\n }\n }\n\n function checkLogItemType(logItemType, errorUnknown = false, errorNotExisting = false) {\n\n if (logItemType) {\n const typeInLogItemTypes = Object.values(LOG_ITEM_TYPE).indexOf(logItemType) > -1;\n if (typeInLogItemTypes) {\n return logger.debug(`Valid logItemType: ${logItemType}`);\n }\n if (errorUnknown) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Unknown logItemType: ${logItemType}`);\n }\n return logger.debug(`WARN: We have unknown logType: ${logItemType}`);\n }\n\n if (errorNotExisting) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `No logItemType: ${logItemType}`);\n }\n return logger.debug(`No logItemType: ${logItemType}`);\n }\n}\n"],"mappings":";;;;;;;AA4BA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,WAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,cAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAnCA;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;;AAWe,eAAAS,SAAgBC,SAAS,EAAEC,MAAM,GAAG,UAAU,EAAE;EAC7D,MAAMC,MAAM,GAAG,IAAAC,mCAAY,EAAC,CAAC;;EAE7B;EACA,MAAMC,MAAM,GAAG,MAAMC,oBAAW,CAACC,OAAO,CAACN,SAAS,EAAE;IAACO,eAAe,EAAE,IAAI;IAAEC,kBAAkB,EAAE;EAAI,CAAC,CAAC;EACtG,MAAMC,EAAE,GAAGL,MAAM,CAACK,EAAE,CAACR,MAAM,CAAC;EAC5B,MAAMS,UAAU,GAAG,MAAM;EACzB,OAAO;IAACC,UAAU;IAAEC,KAAK;IAAEC,SAAS;IAAEC,aAAa;IAAEC,mBAAmB;IAAEC,qBAAqB;IAAEC,OAAO;IAAEC,MAAM;IAAEC;EAAiB,CAAC;EAEpI,eAAeR,UAAUA,C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BAAiBE,YAAa,EAAC,CAAC;IACxF;EACF;EAEA,SAASf,gBAAgBA,CAACC,WAAW,EAAE6E,YAAY,GAAG,KAAK,EAAEC,gBAAgB,GAAG,KAAK,EAAE;IAErF,IAAI9E,WAAW,EAAE;MACf,MAAM+E,kBAAkB,GAAGC,MAAM,CAACC,MAAM,CAAC7C,wBAAa,CAAC,CAAC8C,OAAO,CAAClF,WAAW,CAAC,GAAG,CAAC,CAAC;MACjF,IAAI+E,kBAAkB,EAAE;QACtB,OAAOzG,MAAM,CAAC6C,KAAK,CAAE,sBAAqBnB,WAAY,EAAC,CAAC;MAC1D;MACA,IAAI6E,YAAY,EAAE;QAChB,MAAM,IAAInE,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,wBAAuBZ,WAAY,EAAC,CAAC;MAC7F;MACA,OAAO1B,MAAM,CAAC6C,KAAK,CAAE,kCAAiCnB,WAAY,EAAC,CAAC;IACtE;IAEA,IAAI8E,gBAAgB,EAAE;MACpB,MAAM,IAAIpE,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,mBAAkBZ,WAAY,EAAC,CAAC;IACxF;IACA,OAAO1B,MAAM,CAAC6C,KAAK,CAAE,mBAAkBnB,WAAY,EAAC,CAAC;EACvD;AACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _fixura = require("@natlibfi/fixura");
|
|
5
|
+
var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
6
|
+
var _fixuraMongo = _interopRequireDefault(require("@natlibfi/fixura-mongo"));
|
|
7
|
+
var _chai = require("chai");
|
|
8
|
+
var _mongoLog = _interopRequireDefault(require("./mongoLog"));
|
|
9
|
+
// import {expect} from 'chai';
|
|
10
|
+
|
|
11
|
+
let mongoFixtures; // eslint-disable-line functional/no-let
|
|
12
|
+
|
|
13
|
+
(0, _fixugen.default)({
|
|
14
|
+
callback,
|
|
15
|
+
path: [__dirname, '..', 'test-fixtures', 'mongoLog'],
|
|
16
|
+
recurse: false,
|
|
17
|
+
useMetadataFile: true,
|
|
18
|
+
fixura: {
|
|
19
|
+
failWhenNotFound: true,
|
|
20
|
+
reader: _fixura.READERS.JSON
|
|
21
|
+
},
|
|
22
|
+
mocha: {
|
|
23
|
+
before: async () => {
|
|
24
|
+
await initMongofixtures();
|
|
25
|
+
},
|
|
26
|
+
beforeEach: () => mongoFixtures.clear(),
|
|
27
|
+
afterEach: () => mongoFixtures.clear(),
|
|
28
|
+
after: async () => {
|
|
29
|
+
await mongoFixtures.close();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
async function initMongofixtures() {
|
|
34
|
+
mongoFixtures = await (0, _fixuraMongo.default)({
|
|
35
|
+
rootPath: [__dirname, '..', 'test-fixtures', 'mongoLog'],
|
|
36
|
+
gridFS: {
|
|
37
|
+
bucketName: 'blobs'
|
|
38
|
+
},
|
|
39
|
+
useObjectId: true,
|
|
40
|
+
format: {
|
|
41
|
+
creationTime: v => new Date(v),
|
|
42
|
+
modificationTime: v => new Date(v)
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async function callback({
|
|
47
|
+
getFixture,
|
|
48
|
+
functionName,
|
|
49
|
+
params,
|
|
50
|
+
preFillDb = false
|
|
51
|
+
}) {
|
|
52
|
+
const mongoUri = await mongoFixtures.getUri();
|
|
53
|
+
const mongoLogOperator = await (0, _mongoLog.default)(mongoUri, '');
|
|
54
|
+
const expectedResult = await getFixture('expectedResult.json');
|
|
55
|
+
// console.log(typeof mongoUri); // eslint-disable-line
|
|
56
|
+
|
|
57
|
+
if (preFillDb) {
|
|
58
|
+
// eslint-disable-line functional/no-conditional-statements
|
|
59
|
+
await mongoFixtures.populate(getFixture('dbContents.json'));
|
|
60
|
+
}
|
|
61
|
+
if (functionName === 'addLogItem') {
|
|
62
|
+
await mongoLogOperator.addLogItem(params);
|
|
63
|
+
const dump = await mongoFixtures.dump();
|
|
64
|
+
return (0, _chai.expect)(dump.logs[0]['0']).to.eql(expectedResult);
|
|
65
|
+
}
|
|
66
|
+
if (functionName === 'getCatalogersListOfLogs') {
|
|
67
|
+
const result = await mongoLogOperator.getCatalogersListOfLogs();
|
|
68
|
+
// console.log(result); // eslint-disable-line
|
|
69
|
+
|
|
70
|
+
return (0, _chai.expect)(result).to.eql(expectedResult);
|
|
71
|
+
}
|
|
72
|
+
if (functionName === 'getExpandedListOfLogs') {
|
|
73
|
+
const result = await mongoLogOperator.getExpandedListOfLogs(params);
|
|
74
|
+
// console.log(result); // eslint-disable-line
|
|
75
|
+
|
|
76
|
+
return (0, _chai.expect)(result).to.eql(expectedResult);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=mongoLog.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoLog.spec.js","names":["_fixura","require","_fixugen","_interopRequireDefault","_fixuraMongo","_chai","_mongoLog","mongoFixtures","generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","mocha","before","initMongofixtures","beforeEach","clear","afterEach","after","close","mongoFixturesFactory","rootPath","gridFS","bucketName","useObjectId","format","creationTime","v","Date","modificationTime","getFixture","functionName","params","preFillDb","mongoUri","getUri","mongoLogOperator","createMongoLogOperator","expectedResult","populate","addLogItem","dump","expect","logs","to","eql","result","getCatalogersListOfLogs","getExpandedListOfLogs"],"sources":["../src/mongoLog.spec.js"],"sourcesContent":["// import {expect} from 'chai';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\nimport mongoFixturesFactory from '@natlibfi/fixura-mongo';\nimport {expect} from 'chai';\nimport createMongoLogOperator from './mongoLog';\n\nlet mongoFixtures; // eslint-disable-line functional/no-let\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'mongoLog'],\n recurse: false,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: true,\n reader: READERS.JSON\n },\n mocha: {\n before: async () => {\n await initMongofixtures();\n },\n beforeEach: () => mongoFixtures.clear(),\n afterEach: () => mongoFixtures.clear(),\n after: async () => {\n await mongoFixtures.close();\n }\n }\n});\n\nasync function initMongofixtures() {\n mongoFixtures = await mongoFixturesFactory({\n rootPath: [__dirname, '..', 'test-fixtures', 'mongoLog'],\n gridFS: {bucketName: 'blobs'},\n useObjectId: true,\n format: {\n creationTime: v => new Date(v),\n modificationTime: v => new Date(v)\n }\n });\n}\n\nasync function callback({\n getFixture,\n functionName,\n params,\n preFillDb = false\n}) {\n const mongoUri = await mongoFixtures.getUri();\n const mongoLogOperator = await createMongoLogOperator(mongoUri, '');\n const expectedResult = await getFixture('expectedResult.json');\n // console.log(typeof mongoUri); // eslint-disable-line\n\n if (preFillDb) { // eslint-disable-line functional/no-conditional-statements\n await mongoFixtures.populate(getFixture('dbContents.json'));\n }\n\n if (functionName === 'addLogItem') {\n await mongoLogOperator.addLogItem(params);\n const dump = await mongoFixtures.dump();\n\n return expect(dump.logs[0]['0']).to.eql(expectedResult);\n }\n\n if (functionName === 'getCatalogersListOfLogs') {\n const result = await mongoLogOperator.getCatalogersListOfLogs();\n // console.log(result); // eslint-disable-line\n\n return expect(result).to.eql(expectedResult);\n }\n\n if (functionName === 'getExpandedListOfLogs') {\n const result = await mongoLogOperator.getExpandedListOfLogs(params);\n // console.log(result); // eslint-disable-line\n\n return expect(result).to.eql(expectedResult);\n }\n\n\n}\n"],"mappings":";;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAH,sBAAA,CAAAF,OAAA;AALA;;AAOA,IAAIM,aAAa,CAAC,CAAC;;AAEnB,IAAAC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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
]
|
|
82
|
-
],
|
|
83
|
-
"plugins": [
|
|
84
|
-
[
|
|
85
|
-
"@babel/transform-runtime"
|
|
86
|
-
]
|
|
87
|
-
],
|
|
88
|
-
"env": {
|
|
89
|
-
"test": {
|
|
90
|
-
"plugins": [
|
|
91
|
-
"istanbul",
|
|
92
|
-
"rewire"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
2
|
+
"name": "@natlibfi/melinda-rest-api-commons",
|
|
3
|
+
"description": "Shared modules for microservices of Melinda rest api import system",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "The National Library of Finland"
|
|
6
|
+
},
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"homepage": "https://github.com/natlibfi/melinda-rest-api-commons",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/natlibfi/melinda-rest-api-commons/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "AGPL-3.0+",
|
|
17
|
+
"version": "4.0.17-alpha.3",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepare": "npm run build",
|
|
27
|
+
"lint": "eslint ./src",
|
|
28
|
+
"lint:dev": "eslint ./src --fix",
|
|
29
|
+
"test": "npm run lint && npm run test:base -- src/**/*.spec.js src/*.spec.js",
|
|
30
|
+
"test:dev": "npm run lint:dev && npm run test:base -- src/**/*.spec.js",
|
|
31
|
+
"test:base": "cross-env NODE_ENV=test nyc mocha --package ./package.json --exclude src/amqp.health.spec.js --exclude src/amqp.tests.spec.js",
|
|
32
|
+
"test:local": "cross-env NODE_ENV=test nyc mocha --package ./package.json -- src/amqp.*.spec.js",
|
|
33
|
+
"test:healthcheck": "cross-env NODE_ENV=test nyc mocha --require @babel/register -- src/amqp.health.spec.js",
|
|
34
|
+
"coverage": "npm run cover:unit && npm run cover:report",
|
|
35
|
+
"cover:unit": "nyc --silent npm run test",
|
|
36
|
+
"cover:report": "nyc report --reporter=lcov --reporter=text",
|
|
37
|
+
"dev": "NODE_ENV=development cross-env DEBUG='@natlibfi/*' nodemon",
|
|
38
|
+
"build": "babel src --source-maps --copy-files --delete-dir-on-start --out-dir=dist"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@natlibfi/marc-record": "^8.0.0",
|
|
42
|
+
"@natlibfi/marc-record-serializers": "^10.1.1",
|
|
43
|
+
"@natlibfi/marc-record-validate": "^8.0.1",
|
|
44
|
+
"@natlibfi/marc-record-validators-melinda": "^10.13.0",
|
|
45
|
+
"@natlibfi/melinda-backend-commons": "^2.2.1",
|
|
46
|
+
"@natlibfi/melinda-commons": "^13.0.6",
|
|
47
|
+
"amqplib": "^0.10.3",
|
|
48
|
+
"debug": "^4.3.4",
|
|
49
|
+
"http-status": "^1.7.0",
|
|
50
|
+
"moment": "^2.29.4",
|
|
51
|
+
"mongo-sanitize": "^1.1.0",
|
|
52
|
+
"mongodb": "^4.17.1"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@babel/cli": "^7.22.15",
|
|
56
|
+
"@babel/core": "^7.22.20",
|
|
57
|
+
"@babel/plugin-transform-runtime": "7.22.15",
|
|
58
|
+
"@babel/preset-env": "^7.22.20",
|
|
59
|
+
"@natlibfi/eslint-config-melinda-backend": "^3.0.2",
|
|
60
|
+
"@natlibfi/fixugen": "^2.0.1",
|
|
61
|
+
"@natlibfi/fixura": "^3.0.1",
|
|
62
|
+
"@natlibfi/fixura-mongo": "^2.0.10-alpha.1",
|
|
63
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
64
|
+
"babel-plugin-rewire": "^1.2.0",
|
|
65
|
+
"chai": "^4.3.8",
|
|
66
|
+
"cross-env": "^7.0.3",
|
|
67
|
+
"eslint": "^8.49.0",
|
|
68
|
+
"mocha": "^10.2.0",
|
|
69
|
+
"nodemon": "^3.0.1",
|
|
70
|
+
"nyc": "^15.1.0"
|
|
71
|
+
},
|
|
72
|
+
"eslintConfig": {
|
|
73
|
+
"extends": "@natlibfi/melinda-backend"
|
|
74
|
+
},
|
|
75
|
+
"babel": {
|
|
76
|
+
"presets": [
|
|
77
|
+
[
|
|
78
|
+
"@babel/preset-env",
|
|
79
|
+
{
|
|
80
|
+
"targets": "maintained node versions"
|
|
95
81
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"lines": 80,
|
|
111
|
-
"statements": 80,
|
|
112
|
-
"functions": 80,
|
|
113
|
-
"branches": 80
|
|
114
|
-
},
|
|
115
|
-
"nodemonConfig": {
|
|
116
|
-
"exec": "npm run test:dev",
|
|
117
|
-
"watch": [
|
|
118
|
-
"src/*"
|
|
119
|
-
],
|
|
120
|
-
"ext": "js",
|
|
121
|
-
"delay": 2.5
|
|
82
|
+
]
|
|
83
|
+
],
|
|
84
|
+
"plugins": [
|
|
85
|
+
[
|
|
86
|
+
"@babel/transform-runtime"
|
|
87
|
+
]
|
|
88
|
+
],
|
|
89
|
+
"env": {
|
|
90
|
+
"test": {
|
|
91
|
+
"plugins": [
|
|
92
|
+
"istanbul",
|
|
93
|
+
"rewire"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
122
96
|
}
|
|
97
|
+
},
|
|
98
|
+
"mocha": {
|
|
99
|
+
"spec": [
|
|
100
|
+
"src/*.spec.js"
|
|
101
|
+
],
|
|
102
|
+
"require": [
|
|
103
|
+
"@babel/register"
|
|
104
|
+
],
|
|
105
|
+
"inline-diffs": true,
|
|
106
|
+
"maxDiffSize": 25000,
|
|
107
|
+
"bail": true,
|
|
108
|
+
"exit": true
|
|
109
|
+
},
|
|
110
|
+
"nyc": {
|
|
111
|
+
"exclude": [
|
|
112
|
+
"**/*.spec.js"
|
|
113
|
+
],
|
|
114
|
+
"reporter": [
|
|
115
|
+
"text"
|
|
116
|
+
],
|
|
117
|
+
"require": [
|
|
118
|
+
"@babel/register"
|
|
119
|
+
],
|
|
120
|
+
"sourceMap": false,
|
|
121
|
+
"instrument": false,
|
|
122
|
+
"lines": 80,
|
|
123
|
+
"statements": 80,
|
|
124
|
+
"functions": 80,
|
|
125
|
+
"branches": 80
|
|
126
|
+
},
|
|
127
|
+
"nodemonConfig": {
|
|
128
|
+
"exec": "npm run test:dev",
|
|
129
|
+
"watch": [
|
|
130
|
+
"src/*"
|
|
131
|
+
],
|
|
132
|
+
"ext": "js",
|
|
133
|
+
"delay": 2.5
|
|
134
|
+
}
|
|
123
135
|
}
|