@natlibfi/melinda-rest-api-commons 3.0.4 → 3.0.6-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ updates:
10
10
  interval: "daily"
11
11
  time: "06:30"
12
12
  timezone: "Europe/Helsinki"
13
+ target-branch: "dependencies"
13
14
 
14
15
  # Minor updates to npm production dependencies daily
15
16
  - package-ecosystem: "npm"
@@ -19,10 +20,9 @@ updates:
19
20
  time: "06:45"
20
21
  timezone: "Europe/Helsinki"
21
22
  versioning-strategy: lockfile-only
22
- labels:
23
- - "npm minor dependencies"
24
23
  allow:
25
24
  - dependency-type: "production"
25
+ target-branch: "dependencies"
26
26
 
27
27
  # Major updates to npm dependencies weekly @tuesday
28
28
  # Not possible yet https://github.com/dependabot/dependabot-core/issues/1778
package/dist/mongoLog.js CHANGED
@@ -204,8 +204,8 @@ async function _default(MONGO_URI) {
204
204
  const result = await db.collection(collection).updateMany(filter, [{
205
205
  $set: {
206
206
  modificationTime: (0, _moment.default)().toDate(),
207
- protect: {
208
- $not: '$protect'
207
+ protected: {
208
+ $not: '$protected'
209
209
  }
210
210
  }
211
211
  }]);
@@ -1 +1 @@
1
- {"version":3,"file":"mongoLog.js","names":["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 const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .find(rest)\n .sort({blobSequence: 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 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 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 getExpandedListOfLogs(logItemType = 'MERGE_LOG') {\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 // We don't currently have cataloger in logs, this will always be null\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 protect: {$not: '$protect'}\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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAA0C;AAnC1C;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,wBAAgBA,SAAS,EAAE;EACxC,MAAMC,MAAM,GAAG,IAAAC,mCAAY,GAAE;;EAE7B;EACA,MAAMC,MAAM,GAAG,MAAMC,oBAAW,CAACC,OAAO,CAACL,SAAS,EAAE;IAACM,eAAe,EAAE,IAAI;IAAEC,kBAAkB,EAAE;EAAI,CAAC,CAAC;EACtG,MAAMC,EAAE,GAAGL,MAAM,CAACK,EAAE,CAAC,UAAU,CAAC;EAChC,MAAMC,UAAU,GAAG,MAAM;EACzB,OAAO;IAACC,UAAU;IAAEC,KAAK;IAAEC,SAAS;IAAEC,aAAa;IAAEC,qBAAqB;IAAEC,OAAO;IAAEC,MAAM;IAAEC;EAAiB,CAAC;EAE/G,eAAeP,UAAU,CAACQ,OAAO,EAAE;IACjC,MAAMC,IAAI,GAAG,IAAAC,eAAM,GAAE,CAACC,MAAM,EAAE;IAC9B,MAAMC,UAAU,GAAG;MACjB,GAAGJ,OAAO;MACVK,YAAY,EAAEJ,IAAI;MAClBK,SAAS,EAAE;IACb,CAAC;IACD,IAAI;MACFC,gBAAgB,CAACP,OAAO,CAACQ,WAAW,EAAE,KAAK,CAAC;MAC5C,MAAMC,MAAM,GAAG,MAAMnB,EAAE,CAACC,UAAU,CAACA,UAAU,CAAC,CAACmB,SAAS,CA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Y,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":["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 const result = await db.collection(collection) // eslint-disable-line functional/immutable-data\n .find(rest)\n .sort({blobSequence: 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 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 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 getExpandedListOfLogs(logItemType = 'MERGE_LOG') {\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 // We don't currently have cataloger in logs, this will always be null\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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAA0C;AAnC1C;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,wBAAgBA,SAAS,EAAE;EACxC,MAAMC,MAAM,GAAG,IAAAC,mCAAY,GAAE;;EAE7B;EACA,MAAMC,MA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AO,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,gBAAgB,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"}
package/package.json CHANGED
@@ -14,10 +14,10 @@
14
14
  "url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
15
15
  },
16
16
  "license": "AGPL-3.0+",
17
- "version": "3.0.4",
17
+ "version": "3.0.6-alpha.1",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
- "node": ">=14"
20
+ "node": ">=18"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"
@@ -41,20 +41,20 @@
41
41
  "@natlibfi/fixugen": "^1.1.0",
42
42
  "@natlibfi/marc-record": "^7.2.2",
43
43
  "@natlibfi/marc-record-serializers": "^9.0.4",
44
- "@natlibfi/marc-record-validate": "^7.0.2",
44
+ "@natlibfi/marc-record-validate": "^7.0.3",
45
45
  "@natlibfi/marc-record-validators-melinda": "^9.1.1",
46
46
  "@natlibfi/melinda-backend-commons": "^2.1.0",
47
47
  "@natlibfi/melinda-commons": "^12.0.7",
48
- "amqplib": ">=0.8.0 <1.0.0",
48
+ "amqplib": ">=0.10.3 <1.0.0",
49
49
  "debug": "^4.3.4",
50
- "http-status": "^1.5.3",
50
+ "http-status": "^1.6.2",
51
51
  "moment": "^2.29.4",
52
52
  "mongo-sanitize": "^1.1.0",
53
- "mongodb": "^4.12.1"
53
+ "mongodb": "^4.13.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/cli": "^7.19.3",
57
- "@babel/core": "^7.20.5",
56
+ "@babel/cli": "^7.20.7",
57
+ "@babel/core": "^7.20.12",
58
58
  "@babel/eslint-parser": "^7.19.1",
59
59
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
60
60
  "@babel/preset-env": "^7.20.2",
@@ -65,8 +65,8 @@
65
65
  "babel-plugin-rewire": "^1.2.0",
66
66
  "chai": "^4.3.7",
67
67
  "cross-env": "^7.0.3",
68
- "eslint": "^8.29.0",
69
- "mocha": "^10.1.0",
68
+ "eslint": "^8.32.0",
69
+ "mocha": "^10.2.0",
70
70
  "nodemon": "^2.0.20",
71
71
  "nyc": "^15.1.0"
72
72
  },