@natlibfi/melinda-rest-api-commons 4.1.2-alpha.1 → 4.1.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -661
- package/README.md +1 -1
- package/dist/amqp.health.spec.js +0 -28
- package/dist/amqp.health.spec.js.map +1 -1
- package/dist/amqp.js +0 -28
- package/dist/amqp.js.map +1 -1
- package/dist/amqp.tests.spec.js +0 -28
- package/dist/amqp.tests.spec.js.map +1 -1
- package/dist/constants.js +0 -28
- package/dist/constants.js.map +1 -1
- package/dist/helpers/conversion.js +0 -28
- package/dist/helpers/conversion.js.map +1 -1
- package/dist/helpers/conversion.spec.js +0 -28
- package/dist/helpers/conversion.spec.js.map +1 -1
- package/dist/helpers/fix-constants.js +0 -28
- package/dist/helpers/fix-constants.js.map +1 -1
- package/dist/helpers/fix-handle-tempurns.js +0 -28
- package/dist/helpers/fix-handle-tempurns.js.map +1 -1
- package/dist/helpers/fix-strip-f884s.js +0 -28
- package/dist/helpers/fix-strip-f884s.js.map +1 -1
- package/dist/helpers/fix-utils.js +0 -28
- package/dist/helpers/fix-utils.js.map +1 -1
- package/dist/helpers/fix.js +0 -28
- package/dist/helpers/fix.js.map +1 -1
- package/dist/helpers/validation.js +0 -27
- package/dist/helpers/validation.js.map +1 -1
- package/dist/helpers/validation.spec.js +0 -28
- package/dist/helpers/validation.spec.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mongo.js +0 -27
- package/dist/mongo.js.map +1 -1
- package/dist/mongoLog.js +0 -28
- package/dist/mongoLog.js.map +1 -1
- package/dist/utils.js +0 -28
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -67,4 +67,4 @@ Executed on test server using bridge to docker server and back to server
|
|
|
67
67
|
|
|
68
68
|
Copyright (c) 2020-2024 **University Of Helsinki (The National Library Of Finland)**
|
|
69
69
|
|
|
70
|
-
This project's source code is licensed under the terms of
|
|
70
|
+
This project's source code is licensed under the terms of MIT or any later version.
|
package/dist/amqp.health.spec.js
CHANGED
|
@@ -4,34 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
var _debug = _interopRequireDefault(require("debug"));
|
|
5
5
|
var _index = require("./index");
|
|
6
6
|
var _util = require("util");
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
10
|
-
*
|
|
11
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
12
|
-
*
|
|
13
|
-
* Copyright (C) 2022 University Of Helsinki (The National Library Of Finland)
|
|
14
|
-
*
|
|
15
|
-
* This file is part of melinda-rest-api-commons
|
|
16
|
-
*
|
|
17
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
18
|
-
* it under the terms of the GNU Affero General Public License as
|
|
19
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
20
|
-
* License, or (at your option) any later version.
|
|
21
|
-
*
|
|
22
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
23
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
-
* GNU Affero General Public License for more details.
|
|
26
|
-
*
|
|
27
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
28
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
-
*
|
|
30
|
-
* @licend The above is the entire license notice
|
|
31
|
-
* for the JavaScript code in this file.
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
7
|
//import {expect} from 'chai';
|
|
36
8
|
|
|
37
9
|
const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:amqp:test');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqp.health.spec.js","names":["_debug","_interopRequireDefault","require","_index","_util","debug","createDebugLogger","setTimeoutPromise","promisify","setTimeout","describe","it","amqpUrl","amqpOperator","amqpFactory","awaitTime","closeConnection","close","closeChannel"],"sources":["../src/amqp.health.spec.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"amqp.health.spec.js","names":["_debug","_interopRequireDefault","require","_index","_util","debug","createDebugLogger","setTimeoutPromise","promisify","setTimeout","describe","it","amqpUrl","amqpOperator","amqpFactory","awaitTime","closeConnection","close","closeChannel"],"sources":["../src/amqp.health.spec.js"],"sourcesContent":["//import {expect} from 'chai';\nimport createDebugLogger from 'debug';\nimport {amqpFactory} from './index';\n\n\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp:test');\n//const debugData = debug.extend('data');\n\nimport {promisify} from 'util';\nconst setTimeoutPromise = promisify(setTimeout);\n\ndescribe('HealthCheck: amqpOperator should error if channel or connection fails', () => {\n\n it('FIX: test healthCheck - this test does not really test anything, but error can be seen in debug!', async () => {\n debug(`Testing amqp against a local AMQP instance - we'll need some kind of mockup for this`);\n const amqpUrl = 'amqp://127.0.0.1:5672/';\n\n const amqpOperator = await amqpFactory(amqpUrl, true);\n debug(`Connecting to ${amqpUrl}, with healthCheck running`);\n await awaitTime(amqpOperator, false);\n\n debug(`Testing healthCheckLoop for ${amqpOperator}`);\n debug(`Waiting 0.5s and expecting healthCheckLoop to work`);\n await awaitTime(amqpOperator, false);\n debug(`Amqp Operator should have been alive.`);\n\n debug(`Testing healthCheckLoop with closed channel`);\n debug(`Waiting 0.5s and expecting healthCheckLoop to throw error`);\n await awaitTime(amqpOperator, true);\n debug(`Amqp Operator should have been errored.`);\n\n debug(`Closing connection`);\n await amqpOperator.closeConnection();\n\n async function awaitTime(amqpOperator, close) {\n if (close) {\n await amqpOperator.closeChannel();\n await setTimeoutPromise(500);\n return;\n }\n\n await setTimeoutPromise(500);\n return;\n }\n\n });\n});\n\n"],"mappings":";;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GA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|
14
14
|
var _util = require("util");
|
|
15
15
|
var _httpStatus = _interopRequireDefault(require("http-status"));
|
|
16
16
|
var _utils = require("./utils");
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
20
|
-
*
|
|
21
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
22
|
-
*
|
|
23
|
-
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
24
|
-
*
|
|
25
|
-
* This file is part of melinda-rest-api-commons
|
|
26
|
-
*
|
|
27
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
28
|
-
* it under the terms of the GNU Affero General Public License as
|
|
29
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
30
|
-
* License, or (at your option) any later version.
|
|
31
|
-
*
|
|
32
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
33
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
34
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
35
|
-
* GNU Affero General Public License for more details.
|
|
36
|
-
*
|
|
37
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
38
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
39
|
-
*
|
|
40
|
-
* @licend The above is the entire license notice
|
|
41
|
-
* for the JavaScript code in this file.
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
17
|
async function _default(AMQP_URL, runHealthCheck = false) {
|
|
46
18
|
const logger = (0, _melindaBackendCommons.createLogger)();
|
|
47
19
|
const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:amqp');
|
package/dist/amqp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqp.js","names":["_amqplib","_interopRequireDefault","require","_marcRecord","_melindaCommons","_melindaBackendCommons","_debug","_constants","_util","_httpStatus","_utils","_default","AMQP_URL","runHealthCheck","logger","createLogger","debug","createDebugLogger","debugHC","extend","debugData","connection","amqplib","connect","channel","createChannel","healthCheckLoop","healthCheck","checkQueue","consumeChunk","consumeOne","ackMessages","nackMessages","sendToQueue","removeQueue","messagesToRecords","closeChannel","closeConnection","close","wait","setTimeoutPromise","promisify","setTimeout","assertQueue","durable","error","JSON","stringify","handleAmqpErrors","queue","style","toRecord","purge","errorUndefinedQueue","channelInfo","purgeQueue","verbose","messageCount","checkMessageCount","ApiError","httpStatus","INTERNAL_SERVER_ERROR","messages","getData","headers","getHeaderInfo","length","records","message","get","inspect","colors","maxArrayLength","depth","forEach","properties","correlationId","ack","nack","data","Buffer","from","persistent","errorToThrow","tempChannel","deleteQueue","map","content","parse","toString","MarcRecord","subfieldValues","messagesToGet","CHUNK_SIZE","pump","count","results","identifiers","identifier","deliveryTag","fields","includes","concat","undefined","newError","status","payload","logError"],"sources":["../src/amqp.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 amqplib from 'amqplib';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\nimport createDebugLogger from 'debug';\nimport {CHUNK_SIZE} from './constants';\nimport {promisify, inspect} from 'util';\nimport httpStatus from 'http-status';\nimport {logError} from './utils';\n\nexport default async function (AMQP_URL, runHealthCheck = false) {\n const logger = createLogger();\n const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp');\n const debugHC = debug.extend('HC');\n const debugData = debug.extend('data');\n\n debug(`Creating an AMQP operator to ${AMQP_URL}`);\n const connection = await amqplib.connect(AMQP_URL);\n const channel = await connection.createChannel();\n\n const healthCheckLoop = runHealthCheck ? healthCheck() : false;\n\n debug(`Connection: ${connection}`);\n debug(`Channel: ${channel}`);\n debug(`HealthCheckLoop: ${healthCheckLoop ? 'Running health check' : 'Not running health check'}`);\n\n return {checkQueue, consumeChunk, consumeOne, ackMessages, nackMessages, sendToQueue, removeQueue, messagesToRecords, closeChannel, closeConnection};\n\n async function closeChannel() {\n debug(`Closing channel`);\n await channel.close();\n debug(`Channel: ${channel}`);\n }\n\n async function closeConnection() {\n debug(`Closing connection`);\n await connection.close();\n debug(`Connection: ${connection}`);\n }\n\n async function healthCheck(wait = false) {\n const setTimeoutPromise = promisify(setTimeout);\n if (wait) {\n await setTimeoutPromise(wait);\n return healthCheck(false);\n }\n\n try {\n debugHC(`Health checking amqp by asserting a queue`);\n await channel.assertQueue('HEALTHCHECK', {durable: false});\n debugHC(`Waiting 200ms before running healthCheck next`);\n return healthCheck('200');\n } catch (error) {\n debugHC(`HealthCheck error ${JSON.stringify(error)}`);\n handleAmqpErrors(error);\n }\n }\n\n // eslint-disable-next-line max-statements\n async function checkQueue({queue, style = 'basic', toRecord = true, purge = false}) {\n debug(`checkQueue: ${queue}, Style: ${style}, toRecord: ${toRecord}, Purge: ${purge}`);\n\n try {\n\n errorUndefinedQueue(queue);\n const channelInfo = await channel.assertQueue(queue, {durable: true});\n\n if (purge) {\n await purgeQueue(purge);\n logger.verbose(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);\n debug(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);\n return checkQueue({queue, style});\n }\n\n if (style === 'messages') {\n return channelInfo.messageCount;\n }\n\n\n // Note: returns one message (+ record, of toRecord: true)\n // note: if toRecord is false returns just plain message / false\n // note: if toRecord is true returns {headers, records, messages} -object / false\n // should this be more consistent?\n if (style === 'one') {\n if (checkMessageCount(channelInfo)) {\n return consumeOne(queue, toRecord);\n }\n return false;\n }\n\n // Note: returns a chunk of (100) messages (+ records, if toRecord: true)\n // returns {headers, records, messages} object or {headers, messages} object depending on toRecord\n if (style === 'basic') {\n if (checkMessageCount(channelInfo)) {\n return consumeChunk(queue, toRecord);\n }\n return false;\n }\n\n // Defaults:\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `CheckQueue does not recognize style ${style}`);\n } catch (error) {\n handleAmqpErrors(error);\n }\n\n function checkMessageCount(channelInfo) {\n if (channelInfo.messageCount < 1) {\n debug(`checkQueue: ${channelInfo.messageCount} - ${queue} is empty`);\n return false;\n }\n debug(`Queue ${queue} has ${channelInfo.messageCount} messages`);\n return true;\n }\n\n function purgeQueue(purge) {\n debug(`Purging queue: ${queue}, purge: ${purge}`);\n if (purge) {\n return channel.purgeQueue(queue);\n }\n }\n }\n\n async function consumeChunk(queue, toRecord) {\n debug(`Prepared to consumeChunk from queue: ${queue}`);\n try {\n await channel.assertQueue(queue, {durable: true});\n\n // getData: next chunk (100) messages\n const messages = await getData(queue);\n\n // Note: headers are from the first message of the chunk\n const headers = getHeaderInfo(messages[0]);\n debug(`consumeChunk (${messages ? messages.length : '0'} from queue ${queue}) ${toRecord ? 'to records' : 'just messages'}`);\n\n if (toRecord) {\n const records = await messagesToRecords(messages);\n return {headers, records, messages};\n }\n\n return {headers, messages};\n } catch (error) {\n handleAmqpErrors(error);\n }\n }\n\n async function consumeOne(queue, toRecord) {\n debug(`Prepared to consumeOne from queue: ${queue}`);\n try {\n await channel.assertQueue(queue, {durable: true});\n\n // Returns false if 0 items in queue\n const message = await channel.get(queue);\n\n debugData(`Message: ${inspect(message, {colors: true, maxArrayLength: 3, depth: 3})}`);\n // Do not spam the logs\n debug(`consumeOne from queue: ${queue} ${toRecord ? 'to records' : 'just the message'}`);\n\n if (message) {\n if (toRecord) {\n const headers = getHeaderInfo(message);\n const records = messagesToRecords([message]);\n return {headers, records, messages: [message]};\n }\n\n return message;\n }\n\n return false;\n } catch (error) {\n handleAmqpErrors(error);\n }\n }\n\n function ackMessages(messages) {\n messages.forEach(message => {\n debug(`Ack message ${message.properties.correlationId}`);\n channel.ack(message);\n });\n }\n\n function nackMessages(messages) {\n messages.forEach(message => {\n debug(`Nack message ${message.properties.correlationId}`);\n channel.nack(message);\n });\n }\n\n async function sendToQueue({queue, correlationId, headers, data}) {\n debug(`sendToQueue`);\n // eslint-disable-next-line no-useless-catch\n try {\n debug(`Queue ${queue}`);\n debug(`CorrelationId ${correlationId}`);\n debugData(`Data ${JSON.stringify(data)}`);\n debug(`Headers ${JSON.stringify(headers)}`);\n\n errorUndefinedQueue(queue);\n\n debug(`Asserting queue: ${queue}`);\n await channel.assertQueue(queue, {durable: true});\n\n debug(`Actually sendToQueue: ${queue}`);\n await channel.sendToQueue(\n queue,\n Buffer.from(JSON.stringify({data})),\n {\n correlationId,\n persistent: true,\n headers\n }\n );\n debug(`Send message for ${correlationId} to queue: ${queue}`);\n\n\n } catch (error) {\n const errorToThrow = error;\n //if (error instanceof ApiError) {\n // throw error;\n //}\n debug(`SendToQueue errored: ${JSON.stringify(error)}`);\n handleAmqpErrors(errorToThrow);\n }\n }\n\n async function removeQueue(queue) {\n // deleteQueue borks the channel if the queue does not exist\n // -> use throwaway tempChannel to avoid killing actual channel in use\n // this might be doable also with assertQueue before deleteQueue\n const tempChannel = await connection.createChannel();\n logger.verbose(`Removing queue ${queue}.`);\n debug(`Removing queue ${queue}.`);\n await tempChannel.deleteQueue(queue);\n\n if (tempChannel) {\n await tempChannel.close();\n return;\n }\n\n return;\n }\n\n // ----------------\n // Helper functions\n // ----------------\n\n function messagesToRecords(messages) {\n debug(`Parsing messages (${messages.length}) to records`);\n\n return messages.map(message => {\n const content = JSON.parse(message.content.toString());\n // Use subfieldValues: false validationOption here\n return new MarcRecord(content.data, {subfieldValues: false});\n });\n }\n\n async function getData(queue) {\n debug(`Getting queue data from ${queue}`);\n try {\n const {messageCount} = await channel.checkQueue(queue);\n debug(`There is ${messageCount} messages in queue ${queue}`);\n const messagesToGet = messageCount >= CHUNK_SIZE ? CHUNK_SIZE : messageCount;\n debug(`Getting ${messagesToGet} messages from queue ${queue}`);\n\n const messages = await pump(messagesToGet);\n\n debug(`Returning ${messages.length} unique messages`);\n\n return messages;\n } catch (error) {\n handleAmqpErrors(error);\n }\n\n async function pump(count, results = [], identifiers = []) {\n if (count === 0) {\n return results;\n }\n\n const message = await channel.get(queue);\n const identifier = {\n correlationId: message.properties.correlationId,\n deliveryTag: message.fields.deliveryTag\n };\n // Filter not unique messages\n if (identifiers.includes(identifier)) {\n return pump(count - 1, results, identifiers);\n }\n\n return pump(count - 1, results.concat(message), identifiers.concat(identifier));\n }\n }\n\n function getHeaderInfo(data) {\n return data.properties.headers;\n }\n\n function errorUndefinedQueue(queue) {\n if (queue === undefined || queue === '' || queue === null) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Undefined queue!`);\n }\n }\n\n function handleAmqpErrors(error) {\n const newError = error;\n debug(`HandleAmqpErrors got an error: ${JSON.stringify(error)}`);\n if (error instanceof ApiError) {\n debug(`We have an ApiError`);\n throw new ApiError(newError.status, newError.payload);\n }\n debug(`We have a non-ApiError`);\n logError(error);\n throw newError;\n }\n}\n\n\n"],"mappings":";;;;;;;AA4BA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IA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interopRequireDefault","require","_marcRecord","_melindaCommons","_melindaBackendCommons","_debug","_constants","_util","_httpStatus","_utils","_default","AMQP_URL","runHealthCheck","logger","createLogger","debug","createDebugLogger","debugHC","extend","debugData","connection","amqplib","connect","channel","createChannel","healthCheckLoop","healthCheck","checkQueue","consumeChunk","consumeOne","ackMessages","nackMessages","sendToQueue","removeQueue","messagesToRecords","closeChannel","closeConnection","close","wait","setTimeoutPromise","promisify","setTimeout","assertQueue","durable","error","JSON","stringify","handleAmqpErrors","queue","style","toRecord","purge","errorUndefinedQueue","channelInfo","purgeQueue","verbose","messageCount","checkMessageCount","ApiError","httpStatus","INTERNAL_SERVER_ERROR","messages","getData","headers","getHeaderInfo","length","records","message","get","inspect","colors","maxArrayLength","depth","forEach","properties","correlationId","ack","nack","data","Buffer","from","persistent","errorToThrow","tempChannel","deleteQueue","map","content","parse","toString","MarcRecord","subfieldValues","messagesToGet","CHUNK_SIZE","pump","count","results","identifiers","identifier","deliveryTag","fields","includes","concat","undefined","newError","status","payload","logError"],"sources":["../src/amqp.js"],"sourcesContent":["import amqplib from 'amqplib';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\nimport createDebugLogger from 'debug';\nimport {CHUNK_SIZE} from './constants';\nimport {promisify, inspect} from 'util';\nimport httpStatus from 'http-status';\nimport {logError} from './utils';\n\nexport default async function (AMQP_URL, runHealthCheck = false) {\n const logger = createLogger();\n const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp');\n const debugHC = debug.extend('HC');\n const debugData = debug.extend('data');\n\n debug(`Creating an AMQP operator to ${AMQP_URL}`);\n const connection = await amqplib.connect(AMQP_URL);\n const channel = await connection.createChannel();\n\n const healthCheckLoop = runHealthCheck ? healthCheck() : false;\n\n debug(`Connection: ${connection}`);\n debug(`Channel: ${channel}`);\n debug(`HealthCheckLoop: ${healthCheckLoop ? 'Running health check' : 'Not running health check'}`);\n\n return {checkQueue, consumeChunk, consumeOne, ackMessages, nackMessages, sendToQueue, removeQueue, messagesToRecords, closeChannel, closeConnection};\n\n async function closeChannel() {\n debug(`Closing channel`);\n await channel.close();\n debug(`Channel: ${channel}`);\n }\n\n async function closeConnection() {\n debug(`Closing connection`);\n await connection.close();\n debug(`Connection: ${connection}`);\n }\n\n async function healthCheck(wait = false) {\n const setTimeoutPromise = promisify(setTimeout);\n if (wait) {\n await setTimeoutPromise(wait);\n return healthCheck(false);\n }\n\n try {\n debugHC(`Health checking amqp by asserting a queue`);\n await channel.assertQueue('HEALTHCHECK', {durable: false});\n debugHC(`Waiting 200ms before running healthCheck next`);\n return healthCheck('200');\n } catch (error) {\n debugHC(`HealthCheck error ${JSON.stringify(error)}`);\n handleAmqpErrors(error);\n }\n }\n\n // eslint-disable-next-line max-statements\n async function checkQueue({queue, style = 'basic', toRecord = true, purge = false}) {\n debug(`checkQueue: ${queue}, Style: ${style}, toRecord: ${toRecord}, Purge: ${purge}`);\n\n try {\n\n errorUndefinedQueue(queue);\n const channelInfo = await channel.assertQueue(queue, {durable: true});\n\n if (purge) {\n await purgeQueue(purge);\n logger.verbose(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);\n debug(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);\n return checkQueue({queue, style});\n }\n\n if (style === 'messages') {\n return channelInfo.messageCount;\n }\n\n\n // Note: returns one message (+ record, of toRecord: true)\n // note: if toRecord is false returns just plain message / false\n // note: if toRecord is true returns {headers, records, messages} -object / false\n // should this be more consistent?\n if (style === 'one') {\n if (checkMessageCount(channelInfo)) {\n return consumeOne(queue, toRecord);\n }\n return false;\n }\n\n // Note: returns a chunk of (100) messages (+ records, if toRecord: true)\n // returns {headers, records, messages} object or {headers, messages} object depending on toRecord\n if (style === 'basic') {\n if (checkMessageCount(channelInfo)) {\n return consumeChunk(queue, toRecord);\n }\n return false;\n }\n\n // Defaults:\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `CheckQueue does not recognize style ${style}`);\n } catch (error) {\n handleAmqpErrors(error);\n }\n\n function checkMessageCount(channelInfo) {\n if (channelInfo.messageCount < 1) {\n debug(`checkQueue: ${channelInfo.messageCount} - ${queue} is empty`);\n return false;\n }\n debug(`Queue ${queue} has ${channelInfo.messageCount} messages`);\n return true;\n }\n\n function purgeQueue(purge) {\n debug(`Purging queue: ${queue}, purge: ${purge}`);\n if (purge) {\n return channel.purgeQueue(queue);\n }\n }\n }\n\n async function consumeChunk(queue, toRecord) {\n debug(`Prepared to consumeChunk from queue: ${queue}`);\n try {\n await channel.assertQueue(queue, {durable: true});\n\n // getData: next chunk (100) messages\n const messages = await getData(queue);\n\n // Note: headers are from the first message of the chunk\n const headers = getHeaderInfo(messages[0]);\n debug(`consumeChunk (${messages ? messages.length : '0'} from queue ${queue}) ${toRecord ? 'to records' : 'just messages'}`);\n\n if (toRecord) {\n const records = await messagesToRecords(messages);\n return {headers, records, messages};\n }\n\n return {headers, messages};\n } catch (error) {\n handleAmqpErrors(error);\n }\n }\n\n async function consumeOne(queue, toRecord) {\n debug(`Prepared to consumeOne from queue: ${queue}`);\n try {\n await channel.assertQueue(queue, {durable: true});\n\n // Returns false if 0 items in queue\n const message = await channel.get(queue);\n\n debugData(`Message: ${inspect(message, {colors: true, maxArrayLength: 3, depth: 3})}`);\n // Do not spam the logs\n debug(`consumeOne from queue: ${queue} ${toRecord ? 'to records' : 'just the message'}`);\n\n if (message) {\n if (toRecord) {\n const headers = getHeaderInfo(message);\n const records = messagesToRecords([message]);\n return {headers, records, messages: [message]};\n }\n\n return message;\n }\n\n return false;\n } catch (error) {\n handleAmqpErrors(error);\n }\n }\n\n function ackMessages(messages) {\n messages.forEach(message => {\n debug(`Ack message ${message.properties.correlationId}`);\n channel.ack(message);\n });\n }\n\n function nackMessages(messages) {\n messages.forEach(message => {\n debug(`Nack message ${message.properties.correlationId}`);\n channel.nack(message);\n });\n }\n\n async function sendToQueue({queue, correlationId, headers, data}) {\n debug(`sendToQueue`);\n // eslint-disable-next-line no-useless-catch\n try {\n debug(`Queue ${queue}`);\n debug(`CorrelationId ${correlationId}`);\n debugData(`Data ${JSON.stringify(data)}`);\n debug(`Headers ${JSON.stringify(headers)}`);\n\n errorUndefinedQueue(queue);\n\n debug(`Asserting queue: ${queue}`);\n await channel.assertQueue(queue, {durable: true});\n\n debug(`Actually sendToQueue: ${queue}`);\n await channel.sendToQueue(\n queue,\n Buffer.from(JSON.stringify({data})),\n {\n correlationId,\n persistent: true,\n headers\n }\n );\n debug(`Send message for ${correlationId} to queue: ${queue}`);\n\n\n } catch (error) {\n const errorToThrow = error;\n //if (error instanceof ApiError) {\n // throw error;\n //}\n debug(`SendToQueue errored: ${JSON.stringify(error)}`);\n handleAmqpErrors(errorToThrow);\n }\n }\n\n async function removeQueue(queue) {\n // deleteQueue borks the channel if the queue does not exist\n // -> use throwaway tempChannel to avoid killing actual channel in use\n // this might be doable also with assertQueue before deleteQueue\n const tempChannel = await connection.createChannel();\n logger.verbose(`Removing queue ${queue}.`);\n debug(`Removing queue ${queue}.`);\n await tempChannel.deleteQueue(queue);\n\n if (tempChannel) {\n await tempChannel.close();\n return;\n }\n\n return;\n }\n\n // ----------------\n // Helper functions\n // ----------------\n\n function messagesToRecords(messages) {\n debug(`Parsing messages (${messages.length}) to records`);\n\n return messages.map(message => {\n const content = JSON.parse(message.content.toString());\n // Use subfieldValues: false validationOption here\n return new MarcRecord(content.data, {subfieldValues: false});\n });\n }\n\n async function getData(queue) {\n debug(`Getting queue data from ${queue}`);\n try {\n const {messageCount} = await channel.checkQueue(queue);\n debug(`There is ${messageCount} messages in queue ${queue}`);\n const messagesToGet = messageCount >= CHUNK_SIZE ? CHUNK_SIZE : messageCount;\n debug(`Getting ${messagesToGet} messages from queue ${queue}`);\n\n const messages = await pump(messagesToGet);\n\n debug(`Returning ${messages.length} unique messages`);\n\n return messages;\n } catch (error) {\n handleAmqpErrors(error);\n }\n\n async function pump(count, results = [], identifiers = []) {\n if (count === 0) {\n return results;\n }\n\n const message = await channel.get(queue);\n const identifier = {\n correlationId: message.properties.correlationId,\n deliveryTag: message.fields.deliveryTag\n };\n // Filter not unique messages\n if (identifiers.includes(identifier)) {\n return pump(count - 1, results, identifiers);\n }\n\n return pump(count - 1, results.concat(message), identifiers.concat(identifier));\n }\n }\n\n function getHeaderInfo(data) {\n return data.properties.headers;\n }\n\n function errorUndefinedQueue(queue) {\n if (queue === undefined || queue === '' || queue === null) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Undefined queue!`);\n }\n }\n\n function handleAmqpErrors(error) {\n const newError = error;\n debug(`HandleAmqpErrors got an error: ${JSON.stringify(error)}`);\n if (error instanceof ApiError) {\n debug(`We have an ApiError`);\n throw new ApiError(newError.status, newError.payload);\n }\n debug(`We have a non-ApiError`);\n logError(error);\n throw newError;\n }\n}\n\n\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAEe,eAAAS,SAAgBC,QAAQ,EAAEC,cAAc,GAAG,KAAK,EAAE;EAC/D,MAAMC,MAAM,GAAG,IAAAC,mCAAY,EAAC,CAAC;EAC7B,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,yCAAyC,CAAC;EAC1E,MAAMC,OAAO,GAAGF,KAAK,CAACG,MAAM,CAAC,IAAI,CAAC;EAClC,MAAMC,SAAS,GAAGJ,KAAK,CAACG,MAAM,CAAC,MAAM,CAAC;EAEtCH,KAAK,CAAE,gCAA+BJ,QAAS,EAAC,CAAC;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ACJ,KAAK,EAAE;IAClC,IAAIA,KAAK,KAAKsD,SAAS,IAAItD,KAAK,KAAK,EAAE,IAAIA,KAAK,KAAK,IAAI,EAAE;MACzD,MAAM,IAAIU,qBAAQ,CAACC,mBAAU,CAACC,qBAAqB,EAAG,kBAAiB,CAAC;IAC1E;EACF;EAEA,SAASb,gBAAgBA,CAACH,KAAK,EAAE;IAC/B,MAAM2D,QAAQ,GAAG3D,KAAK;IACtB7B,KAAK,CAAE,kCAAiC8B,IAAI,CAACC,SAAS,CAACF,KAAK,CAAE,EAAC,CAAC;IAChE,IAAIA,KAAK,YAAYc,qBAAQ,EAAE;MAC7B3C,KAAK,CAAE,qBAAoB,CAAC;MAC5B,MAAM,IAAI2C,qBAAQ,CAAC6C,QAAQ,CAACC,MAAM,EAAED,QAAQ,CAACE,OAAO,CAAC;IACvD;IACA1F,KAAK,CAAE,wBAAuB,CAAC;IAC/B,IAAA2F,eAAQ,EAAC9D,KAAK,CAAC;IACf,MAAM2D,QAAQ;EAChB;AACF"}
|
package/dist/amqp.tests.spec.js
CHANGED
|
@@ -8,34 +8,6 @@ var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
|
8
8
|
var _index = require("./index");
|
|
9
9
|
var _melindaCommons = require("@natlibfi/melinda-commons");
|
|
10
10
|
var _util = require("util");
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
14
|
-
*
|
|
15
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
16
|
-
*
|
|
17
|
-
* Copyright (C) 2022 University Of Helsinki (The National Library Of Finland)
|
|
18
|
-
*
|
|
19
|
-
* This file is part of melinda-rest-api-commons
|
|
20
|
-
*
|
|
21
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
22
|
-
* it under the terms of the GNU Affero General Public License as
|
|
23
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
24
|
-
* License, or (at your option) any later version.
|
|
25
|
-
*
|
|
26
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
27
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
28
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
29
|
-
* GNU Affero General Public License for more details.
|
|
30
|
-
*
|
|
31
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
32
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
33
|
-
*
|
|
34
|
-
* @licend The above is the entire license notice
|
|
35
|
-
* for the JavaScript code in this file.
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
11
|
const setTimeoutPromise = (0, _util.promisify)(setTimeout);
|
|
40
12
|
const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:amqp:test');
|
|
41
13
|
//const debugData = debug.extend('data');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqp.tests.spec.js","names":["_chai","require","_fixura","_debug","_interopRequireDefault","_fixugen","_index","_melindaCommons","_util","setTimeoutPromise","promisify","setTimeout","debug","createDebugLogger","testData","queue","correlationId","data","amqpUrl","amqpOperator","generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","mocha","before","amqpFactory","beforeEach","checkQueue","toRecord","purge","afterEach","removeQueue","after","closeConnection","getFixture","expectToFail","expectedErrorStatus","ackMessages","nackMessages","checkNextMessage","checkQueueStyle","sentToQueue","expectedMessageCount","expectedErrorMessage","undefined","expectApiError","expectFalseCheckResult","sendMessagesToQueue","ackOrNackMessages","queueRemoval","messageCount","style","expect","to","eql","headers","records","queueCheckNextMessage","nextMessage","expectedNextMessage","error","equal","testErrors","be","instanceOf","ApiError","status","payload","not","constructor","name","consumeOne","result","have","property","length","messages","fields","deliveryTag","redelivered","routingKey","expectedResult","message","promises","map","sendToQueue","Promise","all"],"sources":["../src/amqp.tests.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) 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 {expect} from 'chai';\nimport {READERS} from '@natlibfi/fixura';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {amqpFactory} from './index';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {promisify} from 'util';\n\nconst setTimeoutPromise = promisify(setTimeout);\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp:test');\n//const debugData = debug.extend('data');\n\nconst testData = {\n queue: 'TESTQUEUE',\n correlationId: 'aaaaaaaa-0000-aaaa-0000-000000000000',\n data: {'leader': '02518cam a2200745zi 4500', 'fields': [{'tag': '001', 'value': '000019640'}]}\n};\n\ndebug(`Testing amqp against a local AMQP instance - we'll need some kind of mockup for this`);\nconst amqpUrl = 'amqp://127.0.0.1:5672/';\n// eslint-disable-next-line functional/no-let\nlet amqpOperator;\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'amqp'],\n recurse: false,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: true,\n reader: READERS.JSON\n },\n mocha: {\n before: async () => {\n debug(`Connecting to ${amqpUrl}, with healthCheck running`);\n amqpOperator = await amqpFactory(amqpUrl, true);\n },\n beforeEach: async () => {\n await amqpOperator.checkQueue({queue: testData.queue, toRecord: false, purge: true});\n },\n afterEach: async () => {\n await amqpOperator.removeQueue(testData.queue);\n },\n after: async () => {\n await amqpOperator.closeConnection();\n //await testHeathCheck();\n }\n }\n});\n\n// eslint-disable-next-line max-statements\nasync function callback({\n getFixture,\n expectToFail = false,\n expectedErrorStatus = '',\n ackMessages = false,\n nackMessages = false,\n checkNextMessage = false,\n checkQueueStyle = false,\n queue = testData.queue,\n sentToQueue,\n expectedMessageCount,\n removeQueue = false,\n expectedErrorMessage = undefined,\n expectApiError = false,\n expectFalseCheckResult = false\n}) {\n try {\n await sendMessagesToQueue();\n\n await ackOrNackMessages();\n\n await checkQueue();\n\n await queueRemoval();\n\n const messageCount = await amqpOperator.checkQueue({queue, style: 'messages'});\n debug(`MessageCount: ${messageCount}`);\n expect(messageCount).to.eql(expectedMessageCount);\n\n if (checkNextMessage) {\n const {headers, records} = await queueCheckNextMessage();\n const nextMessage = {headers, records};\n const expectedNextMessage = getFixture('expectedMessage.json');\n expect(nextMessage).to.eql(expectedNextMessage);\n return;\n }\n\n } catch (error) {\n if (!expectToFail) {\n throw error;\n }\n expect(expectToFail, 'This is expected to fail').to.equal(true);\n testErrors(error);\n }\n\n function testErrors(error) {\n\n if (expectApiError) {\n expect(error).to.be.instanceOf(ApiError);\n debug(`We expected and got an ApiError`);\n expect(error.status).to.equal(expectedErrorStatus);\n\n if (expectedErrorMessage) {\n expect(error.payload).to.eql(expectedErrorMessage);\n return;\n }\n\n return;\n }\n expect(error).not.to.be.instanceOf(ApiError);\n debug(`We expected and got an non-ApiError`);\n debug(`Error is a ${error.constructor.name}`);\n }\n\n function queueRemoval() {\n if (removeQueue) {\n return amqpOperator.removeQueue(removeQueue);\n }\n\n return;\n }\n\n function queueCheckNextMessage() {\n if (checkNextMessage) {\n return amqpOperator.consumeOne(testData.queue, true);\n }\n\n return false;\n }\n\n // eslint-disable-next-line max-statements\n async function checkQueue() {\n debug(`checkQueueStyle: ${checkQueueStyle}`);\n\n if (checkQueueStyle === 'oneToRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: true, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('records');\n expect(result).to.have.property('messages');\n expect(result.records.length).to.eql(1);\n expect(result.messages.length).to.eql(1);\n\n return;\n }\n\n if (checkQueueStyle === 'oneNotRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});\n const {fields} = result;\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(fields).to.have.property('deliveryTag');\n expect(fields).to.have.property('exchange');\n expect(fields).to.have.property('messageCount');\n expect(fields).to.have.property('redelivered');\n expect(fields).to.have.property('routingKey');\n expect(typeof fields.deliveryTag).to.be.eql('number');\n expect(typeof fields.messageCount).to.be.eql('number');\n expect(typeof fields.redelivered).to.be.eql('boolean');\n expect(typeof fields.routingKey).to.be.eql('string');\n\n return;\n }\n\n if (checkQueueStyle === 'basicToRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: true, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('records');\n expect(result).to.have.property('messages');\n expect(result.records.length).to.eql(3);\n expect(result.messages.length).to.eql(3);\n const expectedResult = getFixture('expectedResult.json');\n expect(result.records).to.eql(expectedResult);\n\n return;\n }\n\n if (checkQueueStyle === 'basicNotRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: false, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('messages');\n expect(result.messages.length).to.eql(3);\n\n const [{fields}] = result.messages;\n\n expect(fields).to.have.property('deliveryTag');\n expect(fields).to.have.property('exchange');\n expect(fields).to.have.property('messageCount');\n expect(fields).to.have.property('redelivered');\n expect(fields).to.have.property('routingKey');\n\n expect(typeof fields.deliveryTag).to.be.eql('number');\n expect(typeof fields.messageCount).to.be.eql('number');\n expect(typeof fields.redelivered).to.be.eql('boolean');\n expect(typeof fields.routingKey).to.be.eql('string');\n\n return;\n }\n\n if (checkQueueStyle === 'purge') {\n return amqpOperator.checkQueue({queue, style: 'messages', purge: true});\n }\n\n if (checkQueueStyle === 'foobar') {\n return amqpOperator.checkQueue({queue, style: 'foobar', toRecord: false, purge: false});\n }\n\n return false;\n }\n\n async function ackOrNackMessages() {\n if (ackMessages) {\n const message = await amqpOperator.consumeOne(testData.queue, false);\n await amqpOperator.ackMessages([message]);\n\n return setTimeoutPromise(10);\n }\n\n if (nackMessages) {\n const message = await amqpOperator.consumeOne(testData.queue, false);\n await amqpOperator.nackMessages([message]);\n\n return setTimeoutPromise(10);\n }\n\n return;\n }\n\n async function sendMessagesToQueue() {\n if (sentToQueue) {\n const messages = getFixture('input.json');\n // {queue, correlationId, headers, data}\n\n const promises = messages.map(message => amqpOperator.sendToQueue(message));\n await Promise.all(promises);\n\n return setTimeoutPromise(10);\n }\n\n return;\n }\n}\n\n/*\nfunction testHeathCheck() {\n return it('expects healthCheck', async () => {\n\n const amqpOperator2 = await amqpFactory(amqpUrl, true);\n try {\n\n debug(`**********`);\n await testHealthCheckLoopWorking(amqpOperator2);\n\n debug(`**********`);\n await testHealthCheckLoopErroring(amqpOperator2);\n } catch (error) {\n debug(error);\n expect(error).to.eql('');\n } finally {\n amqpOperator2.closeConnection();\n }\n\n async function testHealthCheckLoopWorking(amqpOperator) {\n debug(`Testing healthCheckLoop for ${amqpOperator}`);\n debug(`Waiting 0.5s and expecting healthCheckLoop to work`);\n await setTimeoutPromise('500');\n debug(`Amqp Operator should have been alive.`);\n }\n\n async function testHealthCheckLoopErroring(amqpOperator) {\n debug(`Testing healthCheckLoop with closed channel`);\n amqpOperator.closeChannel();\n debug(`Waiting 0.5s and expecting healthCheckLoop to throw error`);\n await setTimeoutPromise('500');\n deb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E,CAAC;IAC9B;IAEA;EACF;EAEA,eAAe8C,mBAAmBA,CAAA,EAAG;IACnC,IAAIN,WAAW,EAAE;MACf,MAAMmC,QAAQ,GAAG1C,UAAU,CAAC,YAAY,CAAC;MACzC;;MAEA,MAAMiD,QAAQ,GAAGP,QAAQ,CAACQ,GAAG,CAACF,OAAO,IAAIvE,YAAY,CAAC0E,WAAW,CAACH,OAAO,CAAC,CAAC;MAC3E,MAAMI,OAAO,CAACC,GAAG,CAACJ,QAAQ,CAAC;MAE3B,OAAOlF,iBAAiB,CAAC,EAAE,CAAC;IAC9B;IAEA;EACF;AACF;;AAEA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"amqp.tests.spec.js","names":["_chai","require","_fixura","_debug","_interopRequireDefault","_fixugen","_index","_melindaCommons","_util","setTimeoutPromise","promisify","setTimeout","debug","createDebugLogger","testData","queue","correlationId","data","amqpUrl","amqpOperator","generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","mocha","before","amqpFactory","beforeEach","checkQueue","toRecord","purge","afterEach","removeQueue","after","closeConnection","getFixture","expectToFail","expectedErrorStatus","ackMessages","nackMessages","checkNextMessage","checkQueueStyle","sentToQueue","expectedMessageCount","expectedErrorMessage","undefined","expectApiError","expectFalseCheckResult","sendMessagesToQueue","ackOrNackMessages","queueRemoval","messageCount","style","expect","to","eql","headers","records","queueCheckNextMessage","nextMessage","expectedNextMessage","error","equal","testErrors","be","instanceOf","ApiError","status","payload","not","constructor","name","consumeOne","result","have","property","length","messages","fields","deliveryTag","redelivered","routingKey","expectedResult","message","promises","map","sendToQueue","Promise","all"],"sources":["../src/amqp.tests.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {READERS} from '@natlibfi/fixura';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {amqpFactory} from './index';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {promisify} from 'util';\n\nconst setTimeoutPromise = promisify(setTimeout);\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp:test');\n//const debugData = debug.extend('data');\n\nconst testData = {\n queue: 'TESTQUEUE',\n correlationId: 'aaaaaaaa-0000-aaaa-0000-000000000000',\n data: {'leader': '02518cam a2200745zi 4500', 'fields': [{'tag': '001', 'value': '000019640'}]}\n};\n\ndebug(`Testing amqp against a local AMQP instance - we'll need some kind of mockup for this`);\nconst amqpUrl = 'amqp://127.0.0.1:5672/';\n// eslint-disable-next-line functional/no-let\nlet amqpOperator;\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'amqp'],\n recurse: false,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: true,\n reader: READERS.JSON\n },\n mocha: {\n before: async () => {\n debug(`Connecting to ${amqpUrl}, with healthCheck running`);\n amqpOperator = await amqpFactory(amqpUrl, true);\n },\n beforeEach: async () => {\n await amqpOperator.checkQueue({queue: testData.queue, toRecord: false, purge: true});\n },\n afterEach: async () => {\n await amqpOperator.removeQueue(testData.queue);\n },\n after: async () => {\n await amqpOperator.closeConnection();\n //await testHeathCheck();\n }\n }\n});\n\n// eslint-disable-next-line max-statements\nasync function callback({\n getFixture,\n expectToFail = false,\n expectedErrorStatus = '',\n ackMessages = false,\n nackMessages = false,\n checkNextMessage = false,\n checkQueueStyle = false,\n queue = testData.queue,\n sentToQueue,\n expectedMessageCount,\n removeQueue = false,\n expectedErrorMessage = undefined,\n expectApiError = false,\n expectFalseCheckResult = false\n}) {\n try {\n await sendMessagesToQueue();\n\n await ackOrNackMessages();\n\n await checkQueue();\n\n await queueRemoval();\n\n const messageCount = await amqpOperator.checkQueue({queue, style: 'messages'});\n debug(`MessageCount: ${messageCount}`);\n expect(messageCount).to.eql(expectedMessageCount);\n\n if (checkNextMessage) {\n const {headers, records} = await queueCheckNextMessage();\n const nextMessage = {headers, records};\n const expectedNextMessage = getFixture('expectedMessage.json');\n expect(nextMessage).to.eql(expectedNextMessage);\n return;\n }\n\n } catch (error) {\n if (!expectToFail) {\n throw error;\n }\n expect(expectToFail, 'This is expected to fail').to.equal(true);\n testErrors(error);\n }\n\n function testErrors(error) {\n\n if (expectApiError) {\n expect(error).to.be.instanceOf(ApiError);\n debug(`We expected and got an ApiError`);\n expect(error.status).to.equal(expectedErrorStatus);\n\n if (expectedErrorMessage) {\n expect(error.payload).to.eql(expectedErrorMessage);\n return;\n }\n\n return;\n }\n expect(error).not.to.be.instanceOf(ApiError);\n debug(`We expected and got an non-ApiError`);\n debug(`Error is a ${error.constructor.name}`);\n }\n\n function queueRemoval() {\n if (removeQueue) {\n return amqpOperator.removeQueue(removeQueue);\n }\n\n return;\n }\n\n function queueCheckNextMessage() {\n if (checkNextMessage) {\n return amqpOperator.consumeOne(testData.queue, true);\n }\n\n return false;\n }\n\n // eslint-disable-next-line max-statements\n async function checkQueue() {\n debug(`checkQueueStyle: ${checkQueueStyle}`);\n\n if (checkQueueStyle === 'oneToRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: true, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('records');\n expect(result).to.have.property('messages');\n expect(result.records.length).to.eql(1);\n expect(result.messages.length).to.eql(1);\n\n return;\n }\n\n if (checkQueueStyle === 'oneNotRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});\n const {fields} = result;\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(fields).to.have.property('deliveryTag');\n expect(fields).to.have.property('exchange');\n expect(fields).to.have.property('messageCount');\n expect(fields).to.have.property('redelivered');\n expect(fields).to.have.property('routingKey');\n expect(typeof fields.deliveryTag).to.be.eql('number');\n expect(typeof fields.messageCount).to.be.eql('number');\n expect(typeof fields.redelivered).to.be.eql('boolean');\n expect(typeof fields.routingKey).to.be.eql('string');\n\n return;\n }\n\n if (checkQueueStyle === 'basicToRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: true, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('records');\n expect(result).to.have.property('messages');\n expect(result.records.length).to.eql(3);\n expect(result.messages.length).to.eql(3);\n const expectedResult = getFixture('expectedResult.json');\n expect(result.records).to.eql(expectedResult);\n\n return;\n }\n\n if (checkQueueStyle === 'basicNotRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: false, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('messages');\n expect(result.messages.length).to.eql(3);\n\n const [{fields}] = result.messages;\n\n expect(fields).to.have.property('deliveryTag');\n expect(fields).to.have.property('exchange');\n expect(fields).to.have.property('messageCount');\n expect(fields).to.have.property('redelivered');\n expect(fields).to.have.property('routingKey');\n\n expect(typeof fields.deliveryTag).to.be.eql('number');\n expect(typeof fields.messageCount).to.be.eql('number');\n expect(typeof fields.redelivered).to.be.eql('boolean');\n expect(typeof fields.routingKey).to.be.eql('string');\n\n return;\n }\n\n if (checkQueueStyle === 'purge') {\n return amqpOperator.checkQueue({queue, style: 'messages', purge: true});\n }\n\n if (checkQueueStyle === 'foobar') {\n return amqpOperator.checkQueue({queue, style: 'foobar', toRecord: false, purge: false});\n }\n\n return false;\n }\n\n async function ackOrNackMessages() {\n if (ackMessages) {\n const message = await amqpOperator.consumeOne(testData.queue, false);\n await amqpOperator.ackMessages([message]);\n\n return setTimeoutPromise(10);\n }\n\n if (nackMessages) {\n const message = await amqpOperator.consumeOne(testData.queue, false);\n await amqpOperator.nackMessages([message]);\n\n return setTimeoutPromise(10);\n }\n\n return;\n }\n\n async function sendMessagesToQueue() {\n if (sentToQueue) {\n const messages = getFixture('input.json');\n // {queue, correlationId, headers, data}\n\n const promises = messages.map(message => amqpOperator.sendToQueue(message));\n await Promise.all(promises);\n\n return setTimeoutPromise(10);\n }\n\n return;\n }\n}\n\n/*\nfunction testHeathCheck() {\n return it('expects healthCheck', async () => {\n\n const amqpOperator2 = await amqpFactory(amqpUrl, true);\n try {\n\n debug(`**********`);\n await testHealthCheckLoopWorking(amqpOperator2);\n\n debug(`**********`);\n await testHealthCheckLoopErroring(amqpOperator2);\n } catch (error) {\n debug(error);\n expect(error).to.eql('');\n } finally {\n amqpOperator2.closeConnection();\n }\n\n async function testHealthCheckLoopWorking(amqpOperator) {\n debug(`Testing healthCheckLoop for ${amqpOperator}`);\n debug(`Waiting 0.5s and expecting healthCheckLoop to work`);\n await setTimeoutPromise('500');\n debug(`Amqp Operator should have been alive.`);\n }\n\n async function testHealthCheckLoopErroring(amqpOperator) {\n debug(`Testing healthCheckLoop with closed channel`);\n amqpOperator.closeChannel();\n debug(`Waiting 0.5s and expecting healthCheckLoop to throw error`);\n await setTimeoutPromise('500');\n debug(`amqpOperator should have errored`);\n }\n });\n}\n*/\n"],"mappings":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAEA,MAAMQ,iBAAiB,GAAG,IAAAC,eAAS,EAACC,UAAU,CAAC;AAC/C,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,8CAA8C,CAAC;AAC/E;;AAEA,MAAMC,QAAQ,GAAG;EACfC,KAAK,EAAE,WAAW;EAClBC,aAAa,EAAE,sCAAsC;EACrDC,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AAQ,EAAE,KAAK;QAAEC,KAAK,EAAE;MAAK,CAAC,CAAC;IACzF;IAEA,OAAO,KAAK;EACd;EAEA,eAAemB,iBAAiBA,CAAA,EAAG;IACjC,IAAIX,WAAW,EAAE;MACf,MAAM6C,OAAO,GAAG,MAAMvE,YAAY,CAAC4D,UAAU,CAACjE,QAAQ,CAACC,KAAK,EAAE,KAAK,CAAC;MACpE,MAAMI,YAAY,CAAC0B,WAAW,CAAC,CAAC6C,OAAO,CAAC,CAAC;MAEzC,OAAOjF,iBAAiB,CAAC,EAAE,CAAC;IAC9B;IAEA,IAAIqC,YAAY,EAAE;MAChB,MAAM4C,OAAO,GAAG,MAAMvE,YAAY,CAAC4D,UAAU,CAACjE,QAAQ,CAACC,KAAK,EAAE,KAAK,CAAC;MACpE,MAAMI,YAAY,CAAC2B,YAAY,CAAC,CAAC4C,OAAO,CAAC,CAAC;MAE1C,OAAOjF,iBAAiB,CAAC,EAAE,CAAC;IAC9B;IAEA;EACF;EAEA,eAAe8C,mBAAmBA,CAAA,EAAG;IACnC,IAAIN,WAAW,EAAE;MACf,MAAMmC,QAAQ,GAAG1C,UAAU,CAAC,YAAY,CAAC;MACzC;;MAEA,MAAMiD,QAAQ,GAAGP,QAAQ,CAACQ,GAAG,CAACF,OAAO,IAAIvE,YAAY,CAAC0E,WAAW,CAACH,OAAO,CAAC,CAAC;MAC3E,MAAMI,OAAO,CAACC,GAAG,CAACJ,QAAQ,CAAC;MAE3B,OAAOlF,iBAAiB,CAAC,EAAE,CAAC;IAC9B;IAEA;EACF;AACF;;AAEA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
package/dist/constants.js
CHANGED
|
@@ -4,34 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.QUEUE_ITEM_STATE = exports.OPERATIONS = exports.LOG_ITEM_TYPE = exports.IMPORT_JOB_STATE = exports.CONVERSION_FORMATS = exports.CHUNK_SIZE = void 0;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
10
|
-
*
|
|
11
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
12
|
-
*
|
|
13
|
-
* Copyright (C) 2020-2022, 2024 University Of Helsinki (The National Library Of Finland)
|
|
14
|
-
*
|
|
15
|
-
* This file is part of melinda-rest-api-commons
|
|
16
|
-
*
|
|
17
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
18
|
-
* it under the terms of the GNU Affero General Public License as
|
|
19
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
20
|
-
* License, or (at your option) any later version.
|
|
21
|
-
*
|
|
22
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
23
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
-
* GNU Affero General Public License for more details.
|
|
26
|
-
*
|
|
27
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
28
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
-
*
|
|
30
|
-
* @licend The above is the entire license notice
|
|
31
|
-
* for the JavaScript code in this file.
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
7
|
// QueueItemState flows: see README.md
|
|
36
8
|
|
|
37
9
|
const QUEUE_ITEM_STATE = exports.QUEUE_ITEM_STATE = {
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","LOAD_PROCESS_LOG","CONVERSION_FORMATS","MARCXML","ISO2709","JSON","ALEPHSEQ"],"sources":["../src/constants.js"],"sourcesContent":["
|
|
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","LOAD_PROCESS_LOG","CONVERSION_FORMATS","MARCXML","ISO2709","JSON","ALEPHSEQ"],"sources":["../src/constants.js"],"sourcesContent":["// 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 LOAD_PROCESS_LOG: 'LOAD_PROCESS_LOG'\n};\n\nexport const CONVERSION_FORMATS = {\n MARCXML: 'MARCXML',\n ISO2709: 'ISO2709',\n JSON: 'JSON',\n ALEPHSEQ: 'ALEPHSEQ'\n};\n"],"mappings":";;;;;;AAAA;;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,cAAc;EAC5BC,gBAAgB,EAAE;AACpB,CAAC;AAEM,MAAMC,kBAAkB,GAAA9B,OAAA,CAAA8B,kBAAA,GAAG;EAChCC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE;AACZ,CAAC"}
|
|
@@ -11,34 +11,6 @@ var _melindaBackendCommons = require("@natlibfi/melinda-backend-commons");
|
|
|
11
11
|
var _melindaCommons = require("@natlibfi/melinda-commons");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
13
|
var _utils = require("../utils");
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
17
|
-
*
|
|
18
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
19
|
-
*
|
|
20
|
-
* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)
|
|
21
|
-
*
|
|
22
|
-
* This file is part of melinda-rest-api-commons
|
|
23
|
-
*
|
|
24
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
25
|
-
* it under the terms of the GNU Affero General Public License as
|
|
26
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
27
|
-
* License, or (at your option) any later version.
|
|
28
|
-
*
|
|
29
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
30
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
31
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
32
|
-
* GNU Affero General Public License for more details.
|
|
33
|
-
*
|
|
34
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
35
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
36
|
-
*
|
|
37
|
-
* @licend The above is the entire license notice
|
|
38
|
-
* for the JavaScript code in this file.
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
14
|
function _default() {
|
|
43
15
|
const logger = (0, _melindaBackendCommons.createLogger)();
|
|
44
16
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.js","names":["_httpStatus","_interopRequireDefault","require","_marcRecordSerializers","_melindaBackendCommons","_melindaCommons","_constants","_utils","_default","logger","createLogger","serialize","unserialize","record","format","verbose","CONVERSION_FORMATS","MARCXML","to","ISO2709","JSON","Json","ALEPHSEQ","AlephSequential","ConversionError","httpStatus","UNSUPPORTED_MEDIA_TYPE","err","logError","message","payload","debug","BAD_REQUEST","data","validationOptions","subfieldValues","silly","stringify","from"],"sources":["../../src/helpers/conversion.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"conversion.js","names":["_httpStatus","_interopRequireDefault","require","_marcRecordSerializers","_melindaBackendCommons","_melindaCommons","_constants","_utils","_default","logger","createLogger","serialize","unserialize","record","format","verbose","CONVERSION_FORMATS","MARCXML","to","ISO2709","JSON","Json","ALEPHSEQ","AlephSequential","ConversionError","httpStatus","UNSUPPORTED_MEDIA_TYPE","err","logError","message","payload","debug","BAD_REQUEST","data","validationOptions","subfieldValues","silly","stringify","from"],"sources":["../../src/helpers/conversion.js"],"sourcesContent":["\n\nimport httpStatus from 'http-status';\nimport {MARCXML, ISO2709, Json, AlephSequential} from '@natlibfi/marc-record-serializers';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\nimport {Error as ConversionError} from '@natlibfi/melinda-commons';\nimport {CONVERSION_FORMATS} from '../constants';\nimport {logError} from '../utils';\n\nexport default function () {\n const logger = createLogger();\n\n return {serialize, unserialize};\n\n // This uses format as a number form contants CONVERSION_FORMATS\n function serialize(record, format) {\n logger.verbose(`Serializing record to ${format}`);\n try {\n if (format === CONVERSION_FORMATS.MARCXML) {\n return MARCXML.to(record);\n }\n\n if (format === CONVERSION_FORMATS.ISO2709) {\n return ISO2709.to(record);\n }\n\n if (format === CONVERSION_FORMATS.JSON) {\n return Json.to(record);\n }\n\n if (format === CONVERSION_FORMATS.ALEPHSEQ) {\n return AlephSequential.to(record);\n }\n\n throw new ConversionError(httpStatus.UNSUPPORTED_MEDIA_TYPE);\n } catch (err) {\n logError(err);\n const message = err.message || err.payload?.message || err.payload;\n logger.debug(`${message}`);\n if (err instanceof ConversionError) { // eslint-disable-line functional/no-conditional-statements\n throw err;\n }\n throw new ConversionError(httpStatus.BAD_REQUEST, `Error while serializing record. ${message}`);\n }\n }\n\n // eslint-disable-next-line max-statements\n function unserialize(data, format, validationOptions = {subfieldValues: false}) {\n logger.verbose(`Unserializing record from ${format}`);\n logger.silly(`Format: ${format}`);\n logger.debug(`Validation options: ${JSON.stringify(validationOptions)}`);\n logger.silly(`Data: ${JSON.stringify(data)}`);\n try {\n if (format === CONVERSION_FORMATS.MARCXML) {\n logger.silly('Unserialize format marcxml');\n return MARCXML.from(data, validationOptions);\n }\n\n if (format === CONVERSION_FORMATS.ISO2709) {\n logger.silly('Unserialize format iso2709');\n return ISO2709.from(data, validationOptions);\n }\n\n if (format === CONVERSION_FORMATS.JSON) {\n logger.silly('Unserialize format json');\n return Json.from(data, validationOptions);\n }\n\n if (format === CONVERSION_FORMATS.ALEPHSEQ) {\n logger.silly('Unserialize format aleph sequential');\n return AlephSequential.from(data, validationOptions);\n }\n\n throw new ConversionError(httpStatus.UNSUPPORTED_MEDIA_TYPE);\n } catch (err) {\n logError(err);\n const message = err.message || err.payload?.message || err.payload;\n logger.debug(`${message}`);\n if (err instanceof ConversionError) { // eslint-disable-line functional/no-conditional-statements\n throw err;\n }\n throw new ConversionError(httpStatus.BAD_REQUEST, `Error while unserializing record. ${message}`);\n }\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEe,SAAAM,SAAA,EAAY;EACzB,MAAMC,MAAM,GAAG,IAAAC,mCAAY,EAAC,CAAC;EAE7B,OAAO;IAACC,SAAS;IAAEC;EAAW,CAAC;;EAE/B;EACA,SAASD,SAASA,CAACE,MAAM,EAAEC,MAAM,EAAE;IACjCL,MAAM,CAACM,OAAO,CAAE,yBAAwBD,MAAO,EAAC,CAAC;IACjD,IAAI;MACF,IAAIA,MAAM,KAAKE,6BAAkB,CAACC,OAAO,EAAE;QACzC,OAAOA,8BAAO,CAACC,EAAE,CAACL,MAAM,CAAC;MAC3B;MAEA,IAAIC,MAAM,KAAKE,6BAAkB,CAACG,OAAO,EAAE;QACzC,OAAOA,8BAAO,CAACD,EAAE,CAACL,MAAM,CAAC;MAC3B;MAEA,IAAIC,MAAM,KAAKE,6BAAkB,CAACI,IAAI,EAAE;QACtC,OAAOC,2BAAI,CAACH,EAAE,CAACL,MAAM,CAAC;MACxB;MAEA,IAAIC,MAAM,KAAKE,6BAAkB,CAACM,QAAQ,EAAE;QAC1C,OAAOC,sCAAe,CAACL,EAAE,CAACL,MAAM,CAAC;MACnC;MAEA,MAAM,IAAIW,qBAAe,CAACC,mBAAU,CAACC,sBAAsB,CAAC;IAC9D,CAAC,CAAC,OAAOC,GA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MAAM,CAAC2B,KAAK,CAAC,yBAAyB,CAAC;QACvC,OAAOf,2BAAI,CAACiB,IAAI,CAACL,IAAI,EAAEC,iBAAiB,CAAC;MAC3C;MAEA,IAAIpB,MAAM,KAAKE,6BAAkB,CAACM,QAAQ,EAAE;QAC1Cb,MAAM,CAAC2B,KAAK,CAAC,qCAAqC,CAAC;QACnD,OAAOb,sCAAe,CAACe,IAAI,CAACL,IAAI,EAAEC,iBAAiB,CAAC;MACtD;MAEA,MAAM,IAAIV,qBAAe,CAACC,mBAAU,CAACC,sBAAsB,CAAC;IAC9D,CAAC,CAAC,OAAOC,GAAG,EAAE;MACZ,IAAAC,eAAQ,EAACD,GAAG,CAAC;MACb,MAAME,OAAO,GAAGF,GAAG,CAACE,OAAO,IAAIF,GAAG,CAACG,OAAO,EAAED,OAAO,IAAIF,GAAG,CAACG,OAAO;MAClErB,MAAM,CAACsB,KAAK,CAAE,GAAEF,OAAQ,EAAC,CAAC;MAC1B,IAAIF,GAAG,YAAYH,qBAAe,EAAE;QAAE;QACpC,MAAMG,GAAG;MACX;MACA,MAAM,IAAIH,qBAAe,CAACC,mBAAU,CAACO,WAAW,EAAG,qCAAoCH,OAAQ,EAAC,CAAC;IACnG;EACF;AACF"}
|
|
@@ -7,34 +7,6 @@ var _marcRecord = require("@natlibfi/marc-record");
|
|
|
7
7
|
var _melindaCommons = require("@natlibfi/melinda-commons");
|
|
8
8
|
var _conversion = _interopRequireDefault(require("./conversion"));
|
|
9
9
|
var _constants = require("../constants");
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
13
|
-
*
|
|
14
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
15
|
-
*
|
|
16
|
-
* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)
|
|
17
|
-
*
|
|
18
|
-
* This file is part of melinda-rest-api-commons
|
|
19
|
-
*
|
|
20
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU Affero General Public License as
|
|
22
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
23
|
-
* License, or (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU Affero General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*
|
|
33
|
-
* @licend The above is the entire license notice
|
|
34
|
-
* for the JavaScript code in this file.
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
10
|
describe('services/conversion', () => {
|
|
39
11
|
const {
|
|
40
12
|
getFixture
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.spec.js","names":["_chai","require","_fixura","_interopRequireDefault","_marcRecord","_melindaCommons","_conversion","_constants","describe","getFixture","fixtureFactory","root","__dirname","conversionService","createConversionService","marcRecord","MarcRecord","JSON","parse","components","subfieldValues","marcXml","iso2709","json","alephSeq","it","service","expect","to","be","an","and","respondTo","serialize","throw","data","CONVERSION_FORMATS","MARCXML","equal","ISO2709","ALEPHSEQ","unserialize","record","equalsTo","ConversionError"],"sources":["../../src/helpers/conversion.spec.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"conversion.spec.js","names":["_chai","require","_fixura","_interopRequireDefault","_marcRecord","_melindaCommons","_conversion","_constants","describe","getFixture","fixtureFactory","root","__dirname","conversionService","createConversionService","marcRecord","MarcRecord","JSON","parse","components","subfieldValues","marcXml","iso2709","json","alephSeq","it","service","expect","to","be","an","and","respondTo","serialize","throw","data","CONVERSION_FORMATS","MARCXML","equal","ISO2709","ALEPHSEQ","unserialize","record","equalsTo","ConversionError"],"sources":["../../src/helpers/conversion.spec.js"],"sourcesContent":["\n\nimport {expect} from 'chai';\nimport fixtureFactory from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {Error as ConversionError} from '@natlibfi/melinda-commons';\nimport createConversionService from './conversion';\nimport {CONVERSION_FORMATS} from '../constants';\n\ndescribe('services/conversion', () => {\n const {getFixture} = fixtureFactory({root: [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'conversion'\n ]});\n const conversionService = createConversionService();\n\n const marcRecord = new MarcRecord(JSON.parse(getFixture({components: ['json1']})), {subfieldValues: false});\n const marcXml = getFixture({components: ['marcxml1']});\n const iso2709 = getFixture({components: ['iso2709_1']});\n const json = getFixture({components: ['json1']});\n const alephSeq = getFixture({components: ['aleph_sequential']});\n\n\n describe('factory', () => {\n it('Should create the expected object', () => {\n const service = createConversionService();\n expect(service).to.be.an('object').and\n .respondTo('serialize')\n .respondTo('unserialize');\n });\n });\n\n describe('#serialize', () => {\n it('Should throw because of unsupported format', () => {\n expect(conversionService.serialize).to.throw();\n });\n\n it('Should serialize to MARCXML', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.MARCXML);\n expect(data).to.equal(marcXml);\n });\n\n it('Should serialize to ISO2709', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ISO2709);\n expect(data).to.equal(iso2709);\n });\n\n it('Should serialize to JSON', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.JSON);\n expect(data).to.equal(json);\n });\n\n it('Should serialize to aleph sequential', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ALEPHSEQ);\n expect(data).to.equal(alephSeq);\n });\n\n });\n\n describe('#unserialize', () => {\n it('Should throw because of unsupported format', () => {\n expect(conversionService.unserialize).to.throw();\n });\n\n it('Should unserialize from MARCXML', async () => {\n const record = await conversionService.unserialize(marcXml, CONVERSION_FORMATS.MARCXML);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n it('Should unserialize from ISO2709', () => {\n const record = conversionService.unserialize(iso2709, CONVERSION_FORMATS.ISO2709);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n it('Should unserialize from JSON', () => {\n const record = conversionService.unserialize(json, CONVERSION_FORMATS.JSON);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n it('Should unserialize from Aleph sequential', () => {\n const record = conversionService.unserialize(alephSeq, CONVERSION_FORMATS.ALEPHSEQ);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n\n it('Should throw because the record could not be unserialized', () => {\n expect(() => {\n conversionService.unserialize('', CONVERSION_FORMATS.JSON);\n }).to.throw(ConversionError);\n });\n });\n});\n"],"mappings":";;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAEAO,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpC,MAAM;IAACC;EAAU,CAAC,GAAG,IAAAC,eAAc,EAAC;IAACC,IAAI,EAAE,CACzCC,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,YAAY;EACb,CAAC,CAAC;EACH,MAAMC,iBAAiB,GAAG,IAAAC,mBAAuB,EAAC,CAAC;EAEnD,MAAMC,UAAU,GAAG,IAAIC,sBAAU,CAACC,IAAI,CAACC,KAAK,CAACT,UAAU,CAAC;IAACU,UAAU,EAAE,CAAC,OAAO;EAAC,CAAC,CAAC,CAAC,EAAE;IAACC,cAAc,EAAE;EAAK,CAAC,CAAC;EAC3G,MAAMC,OAAO,GAAGZ,UAAU,CAAC;IAACU,UAAU,EAAE,CAAC,UAAU;EAAC,CAAC,CAAC;EACtD,MAAMG,OAAO,GAAGb,UAAU,CAAC;IAACU,UAAU,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E,CAAC,8BAA8B,EAAE,MAAM;MACvC,MAAMiB,MAAM,GAAG7B,iBAAiB,CAAC4B,WAAW,CAAClB,IAAI,EAAEa,6BAAkB,CAACnB,IAAI,CAAC;MAC3E,IAAAU,YAAM,EAACe,MAAM,CAACC,QAAQ,CAAC5B,UAAU,CAAC,CAAC,CAACa,EAAE,CAACU,KAAK,CAAC,IAAI,CAAC;IACpD,CAAC,CAAC;IAEFb,EAAE,CAAC,0CAA0C,EAAE,MAAM;MACnD,MAAMiB,MAAM,GAAG7B,iBAAiB,CAAC4B,WAAW,CAACjB,QAAQ,EAAEY,6BAAkB,CAACI,QAAQ,CAAC;MACnF,IAAAb,YAAM,EAACe,MAAM,CAACC,QAAQ,CAAC5B,UAAU,CAAC,CAAC,CAACa,EAAE,CAACU,KAAK,CAAC,IAAI,CAAC;IACpD,CAAC,CAAC;IAGFb,EAAE,CAAC,2DAA2D,EAAE,MAAM;MACpE,IAAAE,YAAM,EAAC,MAAM;QACXd,iBAAiB,CAAC4B,WAAW,CAAC,EAAE,EAAEL,6BAAkB,CAACnB,IAAI,CAAC;MAC5D,CAAC,CAAC,CAACW,EAAE,CAACM,KAAK,CAACU,qBAAe,CAAC;IAC9B,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -4,34 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.REPLACE_PREFIXES = exports.BIB_STRIP_F984S_SETTINGS = exports.BIB_STRIP_F884S_SETTINGS = exports.BIB_PREVALIDATION_FIX_SETTINGS = exports.BIB_PREIMPORT_FIX_SETTINGS = exports.BIB_POSTMERGE_FIX_SETTINGS = exports.BIB_HANDLE_TEMP_URNS_SETTINGS = exports.BIB_FORMAT_SETTINGS = exports.BIB_F035_TO_SID = exports.AUTNAME_PREIMPORT_FIX_SETTINGS = void 0;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
10
|
-
*
|
|
11
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
12
|
-
*
|
|
13
|
-
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
14
|
-
*
|
|
15
|
-
* This file is part of melinda-rest-api-commons
|
|
16
|
-
*
|
|
17
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
18
|
-
* it under the terms of the GNU Affero General Public License as
|
|
19
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
20
|
-
* License, or (at your option) any later version.
|
|
21
|
-
*
|
|
22
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
23
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
-
* GNU Affero General Public License for more details.
|
|
26
|
-
*
|
|
27
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
28
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
-
*
|
|
30
|
-
* @licend The above is the entire license notice
|
|
31
|
-
* for the JavaScript code in this file.
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
7
|
// This could be formatted so that 035-prefix and SID contents would be better connected than by just an array index
|
|
36
8
|
const BIB_F035_TO_SID = exports.BIB_F035_TO_SID = {
|
|
37
9
|
f035Filters: [/^\(FI-BTJ\)/u, /^\(FI-TATI\)/u],
|