@natlibfi/melinda-rest-api-commons 4.0.18-alpha.3 → 4.0.18-alpha.8

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/mongoLog.js CHANGED
@@ -13,6 +13,7 @@ var _moment = _interopRequireDefault(require("moment"));
13
13
  var _httpStatus = _interopRequireDefault(require("http-status"));
14
14
  var _mongoSanitize = _interopRequireDefault(require("mongo-sanitize"));
15
15
  var _constants = require("./constants");
16
+ var _luxon = require("luxon");
16
17
  /**
17
18
  *
18
19
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -124,17 +125,14 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
124
125
 
125
126
  // getListOfLogs returns list of correlationIds that have logs of given logItemType
126
127
  // if logItemType is not given, getListOfLogs returns list of correlationIds that have MERGE_LOG
127
- async function getListOfLogs(logItemType = 'MERGE_LOG') {
128
- checkLogItemType(logItemType, false, false);
128
+ async function getListOfLogs(logItemType = _constants.LOG_ITEM_TYPE.MERGE_LOG) {
129
+ // checkLogItemType(logItemType, false, false);
129
130
  const result = await db.collection(collection) // eslint-disable-line functional/immutable-data
130
131
  .distinct('correlationId', {
131
132
  logItemType
132
133
  });
133
134
  logger.debug(`Query result: ${result.length > 0 ? `Found ${result.length} log items!` : 'Not found!'}`);
134
- return {
135
- status: result.length > 0 ? _httpStatus.default.OK : _httpStatus.default.NOT_FOUND,
136
- payload: result.length > 0 ? result : 'No logs found'
137
- };
135
+ return result;
138
136
  }
139
137
  async function getListOfCatalogers() {
140
138
  logger.debug(`Getting list of Catalogers`);
@@ -148,7 +146,8 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
148
146
  logItemTypes = [_constants.LOG_ITEM_TYPE.MERGE_LOG, _constants.LOG_ITEM_TYPE.MATCH_LOG],
149
147
  catalogers = [],
150
148
  dateBefore = new Date(),
151
- dateAfter = new Date('2000-01-01')
149
+ dateAfter = '2000-01-01',
150
+ test = false
152
151
  }) {
153
152
  logger.debug(`commons: logItemTypes: ${JSON.stringify(logItemTypes)}, dateAfter: ${dateAfter}, dateBefore: ${dateBefore}}, catalogers: ${JSON.stringify(catalogers)}`);
154
153
  logger.debug(JSON.stringify(generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter))); // eslint-disable-line
@@ -156,7 +155,7 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
156
155
  logger.debug(`Getting expanded list of logs`);
157
156
  const pipeline = [
158
157
  // currently return only MERGE_LOG and MATCH_LOG
159
- generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter), {
158
+ generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter, test), {
160
159
  '$sort': {
161
160
  'correlationId': 1,
162
161
  'logItemType': 1,
@@ -208,13 +207,8 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
208
207
  logger.silly(`Query result: ${JSON.stringify(result)}`);
209
208
  logger.silly(`Query result: ${JSON.stringify(fixedResult)}`);
210
209
  logger.debug(`Query result: ${fixedResult.length > 0 ? `Found ${fixedResult.length} log items!` : 'Not found!'}`);
211
- return {
212
- status: fixedResult.length > 0 ? _httpStatus.default.OK : _httpStatus.default.NOT_FOUND,
213
- payload: fixedResult.length > 0 ? fixedResult : 'No logs found'
214
- };
215
- function generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter) {
216
- const dateBeforeIso = new Date(dateBefore).toISOString();
217
- const dateAfterIso = new Date(dateAfter).toISOString();
210
+ return fixedResult;
211
+ function generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter, test = false) {
218
212
  const matchOptions = {
219
213
  '$match': {
220
214
  'logItemType': logItemTypes.length > 0 ? {
@@ -224,8 +218,8 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
224
218
  '$in': catalogers
225
219
  } : /.*/ui,
226
220
  'creationTime': {
227
- '$gte': dateAfterIso,
228
- '$lte': dateBeforeIso
221
+ '$gte': test ? _luxon.DateTime.fromJSDate(new Date(dateAfter)).startOf('day').toISODate() : new Date(dateAfter),
222
+ '$lte': test ? _luxon.DateTime.fromJSDate(new Date(dateBefore)).endOf('day').toISODate() : new Date(dateBefore)
229
223
  }
230
224
  }
231
225
  };
@@ -251,10 +245,7 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
251
245
  }
252
246
  }
253
247
  }]);
254
- return {
255
- status: result.modifiedCount > 0 ? _httpStatus.default.OK : _httpStatus.default.NOT_FOUND,
256
- payload: result.modifiedCount > 0 ? result : 'No logs found'
257
- };
248
+ return result;
258
249
  } catch (error) {
259
250
  const errorMessage = error.payload || error.message || '';
260
251
  (0, _utils.logError)(error);
@@ -274,10 +265,7 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
274
265
  };
275
266
  try {
276
267
  const result = await db.collection(collection).deleteMany(filter);
277
- return {
278
- status: result.deletedCount > 0 ? _httpStatus.default.OK : _httpStatus.default.NOT_FOUND,
279
- payload: result.deletedCount > 0 ? result : 'No logs found'
280
- };
268
+ return result;
281
269
  } catch (error) {
282
270
  const errorMessage = error.payload || error.message || '';
283
271
  (0, _utils.logError)(error);
@@ -309,10 +297,7 @@ async function _default(MONGO_URI, dbName = 'rest-api') {
309
297
  };
310
298
  try {
311
299
  const result = await db.collection(collection).deleteMany(filter);
312
- return {
313
- status: result.deletedCount > 0 ? _httpStatus.default.OK : _httpStatus.default.NOT_FOUND,
314
- payload: result.deletedCount > 0 ? result : 'No logs found'
315
- };
300
+ return result;
316
301
  } catch (error) {
317
302
  const errorMessage = error.payload || error.message || '';
318
303
  (0, _utils.logError)(error);
@@ -1 +1 @@
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;I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,CAACG,OAAO,IAAI,EAAE;MACzD,IAAAC,eAAQ,EAACJ,KAAK,CAAC;MACf,MAAM,IAAIH,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,kBAAiBE,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"}
1
+ {"version":3,"file":"mongoLog.js","names":["_mongodb","require","_melindaBackendCommons","_melindaCommons","_utils","_moment","_interopRequireDefault","_httpStatus","_mongoSanitize","_constants","_luxon","_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","LOG_ITEM_TYPE","MERGE_LOG","distinct","logItemTypes","MATCH_LOG","catalogers","dateBefore","Date","dateAfter","test","generateMatchObject","pipeline","aggregate","fixedResult","map","logListing","_id","cataloger","logCount","silly","matchOptions","DateTime","fromJSDate","startOf","toISODate","endOf","cleanCorrelationId","sanitize","cleanBlobSequence","filter","updateMany","$set","modificationTime","$not","force","clean","$ne","deleteMany","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';\nimport {DateTime} from 'luxon';\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 = LOG_ITEM_TYPE.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 result;\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 = '2000-01-01', test = false}) {\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, test),\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 fixedResult;\n\n function generateMatchObject(logItemTypes, catalogers, dateBefore, dateAfter, test = false) {\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': test ? DateTime.fromJSDate(new Date(dateAfter)).startOf('day').toISODate() : new Date(dateAfter),\n '$lte': test ? DateTime.fromJSDate(new Date(dateBefore)).endOf('day').toISODate() : new Date(dateBefore)\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 result;\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 result;\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 result;\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 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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jE,OAAO3D,MAAM;IACf,CAAC,CAAC,OAAOY,KAAK,EAAE;MACd,MAAMC,YAAY,GAAGD,KAAK,CAACE,OAAO,IAAIF,KAAK,CAACG,OAAO,IAAI,EAAE;MACzD,IAAAC,eAAQ,EAACJ,KAAK,CAAC;MACf,MAAM,IAAIH,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,kBAAiBE,YAAa,EAAC,CAAC;IACxF;EACF;EAEA,SAASf,gBAAgBA,CAACC,WAAW,EAAE2E,YAAY,GAAG,KAAK,EAAEC,gBAAgB,GAAG,KAAK,EAAE;IACrF,IAAI5E,WAAW,EAAE;MACf,MAAM6E,kBAAkB,GAAGC,MAAM,CAACC,MAAM,CAAChD,wBAAa,CAAC,CAACiD,OAAO,CAAChF,WAAW,CAAC,GAAG,CAAC,CAAC;MACjF,IAAI6E,kBAAkB,EAAE;QACtB,OAAOvG,MAAM,CAAC6C,KAAK,CAAE,sBAAqBnB,WAAY,EAAC,CAAC;MAC1D;MACA,IAAI2E,YAAY,EAAE;QAChB,MAAM,IAAIjE,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,wBAAuBZ,WAAY,EAAC,CAAC;MAC7F;MACA,OAAO1B,MAAM,CAAC6C,KAAK,CAAE,kCAAiCnB,WAAY,EAAC,CAAC;IACtE;IAEA,IAAI4E,gBAAgB,EAAE;MACpB,MAAM,IAAIlE,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,mBAAkBZ,WAAY,EAAC,CAAC;IACxF;IACA,OAAO1B,MAAM,CAAC6C,KAAK,CAAE,mBAAkBnB,WAAY,EAAC,CAAC;EACvD;AACF"}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
15
15
  },
16
16
  "license": "AGPL-3.0+",
17
- "version": "4.0.18-alpha.3",
17
+ "version": "4.0.18-alpha.8",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=18"
@@ -47,6 +47,7 @@
47
47
  "amqplib": "^0.10.3",
48
48
  "debug": "^4.3.4",
49
49
  "http-status": "^1.7.0",
50
+ "luxon": "^3.4.3",
50
51
  "moment": "^2.29.4",
51
52
  "mongo-sanitize": "^1.1.0",
52
53
  "mongodb": "^4.17.1"