@natlibfi/melinda-rest-api-commons 2.2.0-alpha.9 → 2.3.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +14 -0
- package/.github/dependabot.yml +40 -0
- package/.github/workflows/melinda-node-tests.yml +71 -0
- package/dist/amqp.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/helpers/conversion.js.map +1 -1
- package/dist/helpers/conversion.spec.js.map +1 -1
- package/dist/helpers/format.js.map +1 -1
- package/dist/helpers/format.spec.js.map +1 -1
- package/dist/helpers/validation.js.map +1 -1
- package/dist/helpers/validation.spec.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/mongo.js +109 -23
- package/dist/mongo.js.map +1 -1
- package/dist/mongoLog.js +126 -0
- package/dist/mongoLog.js.map +1 -0
- package/dist/utils.js +71 -21
- package/dist/utils.js.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# With this line @NatLibFi/melinda-js-lead owns any files in the /.github/
|
|
2
|
+
# directory at the root of the repository and any of its
|
|
3
|
+
# subdirectories.
|
|
4
|
+
/.github/ @NatLibFi/melinda-js-lead
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# With this line @NatLibFi/melinda-js-lead owns any files in the /src/
|
|
8
|
+
# directory at the root of the repository and any of its
|
|
9
|
+
# subdirectories.
|
|
10
|
+
/src/ @NatLibFi/melinda-js-lead
|
|
11
|
+
|
|
12
|
+
# With this line @NatLibFi/melinda-js-lead owns package.json file
|
|
13
|
+
# at the root of the repository
|
|
14
|
+
/package.json @NatLibFi/melinda-js-lead
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# NatLibFi/Melinda maintenance strategy
|
|
2
|
+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
|
|
3
|
+
|
|
4
|
+
version: 2
|
|
5
|
+
updates:
|
|
6
|
+
# Maintain dependencies for GitHub Actions
|
|
7
|
+
- package-ecosystem: "github-actions"
|
|
8
|
+
directory: "/"
|
|
9
|
+
schedule:
|
|
10
|
+
interval: "daily"
|
|
11
|
+
time: "06:30"
|
|
12
|
+
timezone: "Europe/Helsinki"
|
|
13
|
+
|
|
14
|
+
# Minor updates to npm production dependencies daily
|
|
15
|
+
- package-ecosystem: "npm"
|
|
16
|
+
directory: "/"
|
|
17
|
+
schedule:
|
|
18
|
+
interval: "daily"
|
|
19
|
+
time: "06:45"
|
|
20
|
+
timezone: "Europe/Helsinki"
|
|
21
|
+
versioning-strategy: lockfile-only
|
|
22
|
+
labels:
|
|
23
|
+
- "npm minor dependencies"
|
|
24
|
+
allow:
|
|
25
|
+
- dependency-type: "production"
|
|
26
|
+
|
|
27
|
+
# Major updates to npm dependencies weekly @tuesday
|
|
28
|
+
# Not possible yet https://github.com/dependabot/dependabot-core/issues/1778
|
|
29
|
+
# - package-ecosystem: "npm"
|
|
30
|
+
# directory: "/"
|
|
31
|
+
# schedule:
|
|
32
|
+
# interval: "weekly"
|
|
33
|
+
# day: "tuesday"
|
|
34
|
+
# time: "07:00"
|
|
35
|
+
# timezone: "Europe/Helsinki"
|
|
36
|
+
# versioning-strategy: increase-if-necessary
|
|
37
|
+
# labels:
|
|
38
|
+
# - "npm major dependencies"
|
|
39
|
+
# reviewers:
|
|
40
|
+
# - "natlibfi/melinda-js-lead"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Melinda node tests
|
|
2
|
+
|
|
3
|
+
name: Melinda node tests
|
|
4
|
+
|
|
5
|
+
on: push
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build-node-versions:
|
|
9
|
+
name: Node version matrix
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [12.x, 14.x, 16.x, 18.x]
|
|
15
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout the code
|
|
19
|
+
uses: actions/checkout@v3
|
|
20
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
+
uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
cache: 'npm'
|
|
25
|
+
env:
|
|
26
|
+
NPM_CONFIG_IGNORE_SCRIPTS: true
|
|
27
|
+
- run: npm update
|
|
28
|
+
- run: npm audit --package-lock-only --production --audit-level=high
|
|
29
|
+
- run: npm ci
|
|
30
|
+
- run: npm test
|
|
31
|
+
- run: npm run build --if-present
|
|
32
|
+
|
|
33
|
+
license-scan:
|
|
34
|
+
name: License compliance check
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v3
|
|
39
|
+
- uses: mikaelvesavuori/license-compliance-action@v1.0.1
|
|
40
|
+
with:
|
|
41
|
+
exclude_pattern: /^@natlibfi/
|
|
42
|
+
|
|
43
|
+
njsscan:
|
|
44
|
+
name: Njsscan check
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
|
|
47
|
+
steps:
|
|
48
|
+
- name: Checkout the code
|
|
49
|
+
uses: actions/checkout@v3
|
|
50
|
+
- name: nodejsscan scan
|
|
51
|
+
id: njsscan
|
|
52
|
+
uses: ajinabraham/njsscan-action@master
|
|
53
|
+
with:
|
|
54
|
+
args: '.'
|
|
55
|
+
|
|
56
|
+
publish:
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
needs: [build-node-versions, njsscan]
|
|
59
|
+
if: contains(github.ref, 'refs/tags/')
|
|
60
|
+
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v3
|
|
63
|
+
# Setup .npmrc file to publish to npm
|
|
64
|
+
- uses: actions/setup-node@v3
|
|
65
|
+
with:
|
|
66
|
+
node-version: '14.x'
|
|
67
|
+
registry-url: 'https://registry.npmjs.org'
|
|
68
|
+
- run: npm ci
|
|
69
|
+
- run: npm publish
|
|
70
|
+
env:
|
|
71
|
+
NODE_AUTH_TOKEN: ${{ secrets.MELINDA_REST_API_COMMONS_NPM_TOKEN }}
|
package/dist/amqp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/amqp.js"],"names":["AMQP_URL","connection","amqplib","connect","channel","createChannel","logger","checkQueue","consumeChunk","consumeOne","ackMessages","nackMessages","sendToQueue","removeQueue","messagesToRecords","queue","style","toRecord","purge","silly","errorUndefinedQueue","channelInfo","assertQueue","durable","purgeQueue","verbose","messageCount","ApiError","httpStatus","UNPROCESSABLE_ENTITY","error","messages","getData","headers","getHeaderInfo","debug","length","records","message","get","colors","maxArrayLength","depth","forEach","properties","correlationId","ack","nack","data","JSON","stringify","Buffer","from","persistent","tempChannel","deleteQueue","close","map","content","parse","toString","MarcRecord","messagesToGet","CHUNK_SIZE","pump","count","results","identifiers","identifier","deliveryTag","fields","includes","concat","undefined","INTERNAL_SERVER_ERROR"],"mappings":";;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWe,wBAAgBA,QAAhB,EAA0B;AACvC,QAAMC,UAAU,GAAG,MAAMC,iBAAQC,OAAR,CAAgBH,QAAhB,CAAzB;AACA,QAAMI,OAAO,GAAG,MAAMH,UAAU,CAACI,aAAX,EAAtB;AACA,QAAMC,MAAM,GAAG,0CAAf;AAEA,SAAO;AAACC,IAAAA,UAAD;AAAaC,IAAAA,YAAb;AAA2BC,IAAAA,UAA3B;AAAuCC,IAAAA,WAAvC;AAAoDC,IAAAA,YAApD;AAAkEC,IAAAA,WAAlE;AAA+EC,IA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CAACK,MAAO,kBAA1C;AAEA,aAAOL,QAAP;AACD,KAXD,CAWE,OAAOD,KAAP,EAAc;AACd,2BAASA,KAAT;AACD;;AAED,mBAAekC,IAAf,CAAoBC,KAApB,EAA2BC,OAAO,GAAG,EAArC,EAAyCC,WAAW,GAAG,EAAvD,EAA2D;AACzD,UAAIF,KAAK,KAAK,CAAd,EAAiB;AACf,eAAOC,OAAP;AACD;;AAED,YAAM5B,OAAO,GAAG,MAAMlC,OAAO,CAACmC,GAAR,CAAYxB,KAAZ,CAAtB;AACA,YAAMqD,UAAU,GAAG;AACjBvB,QAAAA,aAAa,EAAEP,OAAO,CAACM,UAAR,CAAmBC,aADjB;AAEjBwB,QAAAA,WAAW,EAAE/B,OAAO,CAACgC,MAAR,CAAeD;AAFX,OAAnB,CANyD,CAUzD;;AACA,UAAIF,WAAW,CAACI,QAAZ,CAAqBH,UAArB,CAAJ,EAAsC;AACpC,eAAOJ,IAAI,CAACC,KAAK,GAAG,CAAT,EAAYC,OAAZ,EAAqBC,WAArB,CAAX;AACD;;AAED,aAAOH,IAAI,CAACC,KAAK,GAAG,CAAT,EAAYC,OAAO,CAACM,MAAR,CAAelC,OAAf,CAAZ,EAAqC6B,WAAW,CAACK,MAAZ,CAAmBJ,UAAnB,CAArC,CAAX;AACD;AACF;;AAED,WAASlC,aAAT,CAAuBc,IAAvB,EAA6B;AAC3B,WAAOA,IAAI,CAACJ,UAAL,CAAgBX,OAAvB;AACD;;AAED,WAASb,mBAAT,CAA6BL,KAA7B,EAAoC;AAClC,QAAIA,KAAK,KAAK0D,SAAV,IAAuB1D,KAAK,KAAK,EAAjC,IAAuCA,KAAK,KAAK,IAArD,EAA2D;AACzD,YAAM,IAAIY,qBAAJ,CAAaC,oBAAW8C,qBAAxB,EAAgD,kBAAhD,CAAN;AACD;AACF;AACF","sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport 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 {CHUNK_SIZE} from './constants';\nimport {logError} from './utils';\nimport {inspect} from 'util';\nimport httpStatus from 'http-status';\n\nexport default async function (AMQP_URL) {\n const connection = await amqplib.connect(AMQP_URL);\n const channel = await connection.createChannel();\n const logger = createLogger();\n\n return {checkQueue, consumeChunk, consumeOne, ackMessages, nackMessages, sendToQueue, removeQueue, messagesToRecords};\n\n // eslint-disable-next-line max-statements\n async function checkQueue({queue, style = 'basic', toRecord = true, purge = false}) {\n logger.silly(`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 return checkQueue({queue, style});\n }\n\n if (channelInfo.messageCount < 1) {\n logger.silly(`checkQueue: ${channelInfo.messageCount} - ${queue} is empty`);\n return false;\n }\n logger.silly(`Queue ${queue} has ${channelInfo.messageCount} messages`);\n\n if (style === 'messages') {\n return channelInfo.messageCount;\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 return consumeOne(queue, toRecord);\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 return consumeChunk(queue, toRecord);\n }\n\n // Defaults:\n throw new ApiError(httpStatus.UNPROCESSABLE_ENTITY);\n } catch (error) {\n logError(error);\n }\n\n function purgeQueue(purge) {\n if (purge) {\n return channel.purgeQueue(queue);\n }\n }\n }\n\n async function consumeChunk(queue, toRecord) {\n logger.silly(`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 const headers = getHeaderInfo(messages[0]);\n logger.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 logError(error);\n }\n }\n\n async function consumeOne(queue, toRecord) {\n logger.silly(`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 logger.silly(`Message: ${inspect(message, {colors: true, maxArrayLength: 3, depth: 3})}`);\n // Do not spam the logs\n logger.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 logError(error);\n }\n }\n\n function ackMessages(messages) {\n messages.forEach(message => {\n logger.silly(`Ack message ${message.properties.correlationId}`);\n channel.ack(message);\n });\n }\n\n function nackMessages(messages) {\n messages.forEach(message => {\n logger.silly(`Nack message ${message.properties.correlationId}`);\n channel.nack(message);\n });\n }\n\n async function sendToQueue({queue, correlationId, headers, data}) {\n try {\n logger.silly(`Queue ${queue}`);\n logger.silly(`CorrelationId ${correlationId}`);\n logger.silly(`Data ${JSON.stringify(data)}`);\n logger.silly(`Headers ${JSON.stringify(headers)}`);\n\n errorUndefinedQueue(queue);\n await channel.assertQueue(queue, {durable: true});\n\n channel.sendToQueue(\n queue,\n Buffer.from(JSON.stringify({data})),\n {\n correlationId,\n persistent: true,\n headers\n }\n );\n logger.silly(`Send message for ${correlationId} to queue: ${queue}`);\n } catch (error) {\n logError(error);\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 await tempChannel.deleteQueue(queue);\n if (tempChannel) { // eslint-disable-line functional/no-conditional-statement\n await tempChannel.close();\n }\n }\n\n // ----------------\n // Helper functions\n // ----------------\n\n function messagesToRecords(messages) {\n logger.debug(`Parsing messages (${messages.length}) to records`);\n\n return messages.map(message => {\n const content = JSON.parse(message.content.toString());\n return new MarcRecord(content.data);\n });\n }\n\n async function getData(queue) {\n logger.debug(`Getting queue data from ${queue}`);\n try {\n const {messageCount} = await channel.checkQueue(queue);\n logger.silly(`There is ${messageCount} messages in queue ${queue}`);\n const messagesToGet = messageCount >= CHUNK_SIZE ? CHUNK_SIZE : messageCount;\n logger.silly(`Getting ${messagesToGet} messages from queue ${queue}`);\n\n const messages = await pump(messagesToGet);\n\n logger.debug(`Returning ${messages.length} unique messages`);\n\n return messages;\n } catch (error) {\n logError(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\n\n"],"file":"amqp.js"}
|
|
1
|
+
{"version":3,"file":"amqp.js","names":["AMQP_URL","connection","amqplib","connect","channel","createChannel","logger","createLogger","checkQueue","consumeChunk","consumeOne","ackMessages","nackMessages","sendToQueue","removeQueue","messagesToRecords","queue","style","toRecord","purge","silly","errorUndefinedQueue","channelInfo","assertQueue","durable","purgeQueue","verbose","messageCount","ApiError","httpStatus","UNPROCESSABLE_ENTITY","error","logError","messages","getData","headers","getHeaderInfo","debug","length","records","message","get","inspect","colors","maxArrayLength","depth","forEach","properties","correlationId","ack","nack","data","JSON","stringify","Buffer","from","persistent","tempChannel","deleteQueue","close","map","content","parse","toString","MarcRecord","messagesToGet","CHUNK_SIZE","pump","count","results","identifiers","identifier","deliveryTag","fields","includes","concat","undefined","INTERNAL_SERVER_ERROR"],"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-2021 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport 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 {CHUNK_SIZE} from './constants';\nimport {logError} from './utils';\nimport {inspect} from 'util';\nimport httpStatus from 'http-status';\n\nexport default async function (AMQP_URL) {\n const connection = await amqplib.connect(AMQP_URL);\n const channel = await connection.createChannel();\n const logger = createLogger();\n\n return {checkQueue, consumeChunk, consumeOne, ackMessages, nackMessages, sendToQueue, removeQueue, messagesToRecords};\n\n // eslint-disable-next-line max-statements\n async function checkQueue({queue, style = 'basic', toRecord = true, purge = false}) {\n logger.silly(`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 return checkQueue({queue, style});\n }\n\n if (channelInfo.messageCount < 1) {\n logger.silly(`checkQueue: ${channelInfo.messageCount} - ${queue} is empty`);\n return false;\n }\n logger.silly(`Queue ${queue} has ${channelInfo.messageCount} messages`);\n\n if (style === 'messages') {\n return channelInfo.messageCount;\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 return consumeOne(queue, toRecord);\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 return consumeChunk(queue, toRecord);\n }\n\n // Defaults:\n throw new ApiError(httpStatus.UNPROCESSABLE_ENTITY);\n } catch (error) {\n logError(error);\n }\n\n function purgeQueue(purge) {\n if (purge) {\n return channel.purgeQueue(queue);\n }\n }\n }\n\n async function consumeChunk(queue, toRecord) {\n logger.silly(`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 const headers = getHeaderInfo(messages[0]);\n logger.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 logError(error);\n }\n }\n\n async function consumeOne(queue, toRecord) {\n logger.silly(`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 logger.silly(`Message: ${inspect(message, {colors: true, maxArrayLength: 3, depth: 3})}`);\n // Do not spam the logs\n logger.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 logError(error);\n }\n }\n\n function ackMessages(messages) {\n messages.forEach(message => {\n logger.silly(`Ack message ${message.properties.correlationId}`);\n channel.ack(message);\n });\n }\n\n function nackMessages(messages) {\n messages.forEach(message => {\n logger.silly(`Nack message ${message.properties.correlationId}`);\n channel.nack(message);\n });\n }\n\n async function sendToQueue({queue, correlationId, headers, data}) {\n try {\n logger.silly(`Queue ${queue}`);\n logger.silly(`CorrelationId ${correlationId}`);\n logger.silly(`Data ${JSON.stringify(data)}`);\n logger.silly(`Headers ${JSON.stringify(headers)}`);\n\n errorUndefinedQueue(queue);\n await channel.assertQueue(queue, {durable: true});\n\n channel.sendToQueue(\n queue,\n Buffer.from(JSON.stringify({data})),\n {\n correlationId,\n persistent: true,\n headers\n }\n );\n logger.silly(`Send message for ${correlationId} to queue: ${queue}`);\n } catch (error) {\n logError(error);\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 await tempChannel.deleteQueue(queue);\n if (tempChannel) { // eslint-disable-line functional/no-conditional-statement\n await tempChannel.close();\n }\n }\n\n // ----------------\n // Helper functions\n // ----------------\n\n function messagesToRecords(messages) {\n logger.debug(`Parsing messages (${messages.length}) to records`);\n\n return messages.map(message => {\n const content = JSON.parse(message.content.toString());\n return new MarcRecord(content.data);\n });\n }\n\n async function getData(queue) {\n logger.debug(`Getting queue data from ${queue}`);\n try {\n const {messageCount} = await channel.checkQueue(queue);\n logger.silly(`There is ${messageCount} messages in queue ${queue}`);\n const messagesToGet = messageCount >= CHUNK_SIZE ? CHUNK_SIZE : messageCount;\n logger.silly(`Getting ${messagesToGet} messages from queue ${queue}`);\n\n const messages = await pump(messagesToGet);\n\n logger.debug(`Returning ${messages.length} unique messages`);\n\n return messages;\n } catch (error) {\n logError(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\n\n"],"mappings":";;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWe,wBAAgBA,QAAhB,E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ASD,KAAT;IACD;;IAED,eAAeoC,IAAf,CAAoBC,KAApB,EAA2BC,OAAO,GAAG,EAArC,EAAyCC,WAAW,GAAG,EAAvD,EAA2D;MACzD,IAAIF,KAAK,KAAK,CAAd,EAAiB;QACf,OAAOC,OAAP;MACD;;MAED,MAAM7B,OAAO,GAAG,MAAMpC,OAAO,CAACqC,GAAR,CAAYzB,KAAZ,CAAtB;MACA,MAAMuD,UAAU,GAAG;QACjBvB,aAAa,EAAER,OAAO,CAACO,UAAR,CAAmBC,aADjB;QAEjBwB,WAAW,EAAEhC,OAAO,CAACiC,MAAR,CAAeD;MAFX,CAAnB,CANyD,CAUzD;;MACA,IAAIF,WAAW,CAACI,QAAZ,CAAqBH,UAArB,CAAJ,EAAsC;QACpC,OAAOJ,IAAI,CAACC,KAAK,GAAG,CAAT,EAAYC,OAAZ,EAAqBC,WAArB,CAAX;MACD;;MAED,OAAOH,IAAI,CAACC,KAAK,GAAG,CAAT,EAAYC,OAAO,CAACM,MAAR,CAAenC,OAAf,CAAZ,EAAqC8B,WAAW,CAACK,MAAZ,CAAmBJ,UAAnB,CAArC,CAAX;IACD;EACF;;EAED,SAASnC,aAAT,CAAuBe,IAAvB,EAA6B;IAC3B,OAAOA,IAAI,CAACJ,UAAL,CAAgBZ,OAAvB;EACD;;EAED,SAASd,mBAAT,CAA6BL,KAA7B,EAAoC;IAClC,IAAIA,KAAK,KAAK4D,SAAV,IAAuB5D,KAAK,KAAK,EAAjC,IAAuCA,KAAK,KAAK,IAArD,EAA2D;MACzD,MAAM,IAAIY,qBAAJ,CAAaC,mBAAA,CAAWgD,qBAAxB,EAAgD,kBAAhD,CAAN;IACD;EACF;AACF"}
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"constants.js","names":["QUEUE_ITEM_STATE","VALIDATOR","PENDING_QUEUING","PENDING_VALIDATION","QUEUING_IN_PROGRESS","UPLOADING","VALIDATING","WAITING_FOR_RECORDS","IMPORTER","IMPORTING","IN_PROCESS","IN_QUEUE","DONE","ERROR","ABORT","IMPORT_JOB_STATE","EMPTY","QUEUING","PROCESSING","OPERATIONS","CREATE","UPDATE","CHUNK_SIZE","CONVERSION_FORMATS","MARCXML","ISO2709","JSON","ALEPHSEQ"],"sources":["../src/constants.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\n// QueueItemState flows: see README.md\n\nexport const QUEUE_ITEM_STATE = {\n VALIDATOR: {\n PENDING_QUEUING: 'PENDING_QUEUING',\n PENDING_VALIDATION: 'PENDING_VALIDATION',\n QUEUING_IN_PROGRESS: 'QUEUING_IN_PROGRESS',\n UPLOADING: 'UPLOADING',\n VALIDATING: 'VALIDATING',\n WAITING_FOR_RECORDS: 'WAITING_FOR_RECORDS'\n },\n IMPORTER: {\n IMPORTING: 'IMPORTING',\n IN_PROCESS: 'IN_PROCESS',\n IN_QUEUE: 'IN_QUEUE'\n },\n DONE: 'DONE',\n ERROR: 'ERROR',\n ABORT: 'ABORT'\n};\n\nexport const IMPORT_JOB_STATE = {\n EMPTY: 'EMPTY',\n QUEUING: 'QUEUING',\n IN_QUEUE: 'IN_QUEUE',\n IMPORTING: 'IMPORTING',\n PROCESSING: 'PROCESSING',\n DONE: 'DONE',\n ERROR: 'ERROR',\n ABORT: 'ABORT'\n};\n\nexport const OPERATIONS = {\n CREATE: 'CREATE',\n UPDATE: 'UPDATE'\n};\n\nexport const CHUNK_SIZE = 100;\n\nexport const CONVERSION_FORMATS = {\n MARCXML: 'MARCXML',\n ISO2709: 'ISO2709',\n JSON: 'JSON',\n ALEPHSEQ: 'ALEPHSEQ'\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEO,MAAMA,gBAAgB,GAAG;EAC9BC,SAAS,EAAE;IACTC,eAAe,EAAE,iBADR;IAETC,kBAAkB,EAAE,oBAFX;IAGTC,mBAAmB,EAAE,qBAHZ;IAITC,SAAS,EAAE,WAJF;IAKTC,UAAU,EAAE,YALH;IAMTC,mBAAmB,EAAE;EANZ,CADmB;EAS9BC,QAAQ,EAAE;IACRC,SAAS,EAAE,WADH;IAERC,UAAU,EAAE,YAFJ;IAGRC,QAAQ,EAAE;EAHF,CAToB;EAc9BC,IAAI,EAAE,MAdwB;EAe9BC,KAAK,EAAE,OAfuB;EAgB9BC,KAAK,EAAE;AAhBuB,CAAzB;;AAmBA,MAAMC,gBAAgB,GAAG;EAC9BC,KAAK,EAAE,OADuB;EAE9BC,OAAO,EAAE,SAFqB;EAG9BN,QAAQ,EAAE,UAHoB;EAI9BF,SAAS,EAAE,WAJmB;EAK9BS,UAAU,EAAE,YALkB;EAM9BN,IAAI,EAAE,MANwB;EAO9BC,KAAK,EAAE,OAPuB;EAQ9BC,KAAK,EAAE;AARuB,CAAzB;;AAWA,MAAMK,UAAU,GAAG;EACxBC,MAAM,EAAE,QADgB;EAExBC,MAAM,EAAE;AAFgB,CAAnB;;AAKA,MAAMC,UAAU,GAAG,GAAnB;;AAEA,MAAMC,kBAAkB,GAAG;EAChCC,OAAO,EAAE,SADuB;EAEhCC,OAAO,EAAE,SAFuB;EAGhCC,IAAI,EAAE,MAH0B;EAIhCC,QAAQ,EAAE;AAJsB,CAA3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"conversion.js","names":["logger","createLogger","serialize","unserialize","record","format","verbose","CONVERSION_FORMATS","MARCXML","to","ISO2709","JSON","Json","ALEPHSEQ","AlephSequential","ConversionError","httpStatus","UNSUPPORTED_MEDIA_TYPE","err","logError","BAD_REQUEST","data","validationOptions","subfieldValues","silly","debug","stringify","from"],"sources":["../../src/helpers/conversion.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport 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 if (err instanceof ConversionError) { // eslint-disable-line functional/no-conditional-statement\n throw err;\n }\n throw new ConversionError(httpStatus.BAD_REQUEST, 'Error while serializing record');\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 if (err instanceof ConversionError) { // eslint-disable-line functional/no-conditional-statement\n throw err;\n }\n throw new ConversionError(httpStatus.BAD_REQUEST, 'Error while unserializing record');\n }\n }\n}\n"],"mappings":";;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AAN;IACD;EACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"conversion.spec.js","names":["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*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {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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oCa,EAApC,CAAuCU,KAAvC,CAA6C,IAA7C;IACD,CAHC,CAAF;IAMAb,EAAE,CAAC,2DAAD,EAA8D,MAAM;MACpE,IAAAE,YAAA,EAAO,MAAM;QACXd,iBAAiB,CAAC4B,WAAlB,CAA8B,EAA9B,EAAkCL,6BAAA,CAAmBnB,IAArD;MACD,CAFD,EAEGW,EAFH,CAEMM,KAFN,CAEYU,qBAFZ;IAGD,CAJC,CAAF;EAKD,CA/BO,CAAR;AAgCD,CArFO,CAAR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"format.js","names":["formatRecord","record","settings","logger","createLogger","verbose","newRecord","MarcRecord","clone","subfieldValues","generateMissingSIDs","forEach","options","replacePrefixes","toObject","oldPrefix","newPrefix","prefixReplaceCodes","pattern","replacement","getDatafields","field","subfields","filter","code","includes","subfield","value","replace","f035Filters","fSIDFilters","f035s","f035ToSidInfo","get","fSIDs","sidsToSidInfo","sidsToBeAdded","genNewSids","length","f035SidInfo","some","fSIDInfo","SID","sidField","insertField","map","sidInfo","tag","ind1","ind2","SIDs","flatMap","sub","undefined","wantedSub","regexp","test","findIndex","slice","indexOf","BIB_FORMAT_SETTINGS"],"sources":["../../src/helpers/format.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\n\nexport function formatRecord(record, settings = []) {\n const logger = createLogger();\n\n logger.verbose('Applying formating');\n const newRecord = MarcRecord.clone(record, {subfieldValues: false});\n\n generateMissingSIDs();\n\n settings.forEach(options => {\n replacePrefixes(options);\n });\n\n return newRecord.toObject();\n\n // Replace prefix in all specified subfields\n function replacePrefixes(options) {\n const {oldPrefix, newPrefix, prefixReplaceCodes} = options;\n const pattern = `(${oldPrefix})`;\n const replacement = `(${newPrefix})`;\n newRecord.getDatafields()\n .forEach(field => {\n field.subfields\n .filter(({code}) => prefixReplaceCodes.includes(code))\n .forEach(subfield => {\n subfield.value = subfield.value.replace(pattern, replacement); // eslint-disable-line functional/immutable-data\n });\n });\n }\n\n\n function generateMissingSIDs() {\n const f035Filters = [/^\\(FI-BTJ\\)/u, /^\\(FI-TATI\\)/u];\n const fSIDFilters = ['FI-BTJ', 'tati'];\n const f035s = f035ToSidInfo(newRecord.get(/^035$/u));\n const fSIDs = sidsToSidInfo(newRecord.get(/^SID$/u));\n\n const sidsToBeAdded = genNewSids(fSIDs.length === 0\n ? f035s\n // test that SIDs are not there yet\n : f035s.filter(f035SidInfo => fSIDs.some(fSIDInfo => f035SidInfo.SID !== fSIDInfo.SID && f035SidInfo.value !== fSIDInfo.value)));\n\n // Add new SIDs\n return sidsToBeAdded.forEach(sidField => newRecord.insertField(sidField));\n\n function genNewSids(sidsToBeAdded) {\n return sidsToBeAdded.map(sidInfo => ({tag: 'SID', ind1: ' ', ind2: ' ', subfields: [{code: 'c', value: sidInfo.value}, {code: 'b', value: sidInfo.SID}]}));\n }\n\n function sidsToSidInfo(SIDs) {\n return SIDs.flatMap(({subfields}) => {\n const [SID] = subfields.filter(sub => sub.code === 'b' && fSIDFilters.includes(sub.value)).map(sub => sub.value);\n const [value] = subfields.filter(sub => sub.code === 'c' && sub.value !== undefined).map(sub => sub.value);\n\n if (SID && value) {\n return {\n SID,\n value\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n\n function f035ToSidInfo(f035s) {\n return f035s.flatMap(({subfields}) => {\n const [wantedSub] = subfields.filter(sub => sub.code === 'a' && f035Filters.some(regexp => regexp.test(sub.value)));\n\n if (wantedSub) {\n return {\n SID: fSIDFilters[f035Filters.findIndex(regexp => regexp.test(wantedSub.value))],\n value: wantedSub.value.slice(wantedSub.value.indexOf(')') + 1)\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n }\n}\n\n// If placed in config.js testing needs envs\nexport const BIB_FORMAT_SETTINGS = [\n {\n oldPrefix: 'FI-MELINDA',\n newPrefix: 'FIN01',\n prefixReplaceCodes: ['w']\n },\n {\n oldPrefix: 'FI-ASTERI-S',\n newPrefix: 'FIN10',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-N',\n newPrefix: 'FIN11',\n prefixReplaceCodes: ['0']\n }\n];\n"],"mappings":";;;;;;;;AA4BA;;AACA;;AA7BA;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;AAKO,SAASA,YAAT,CAAsBC,MAAtB,EAA8BC,QAAQ,GAAG,EAAzC,EAA6C;EAClD,MAAMC,MAAM,GAAG,IAAAC,mCAAA,GAAf;EAEAD,MAAM,CAACE,OAAP,CAAe,oBAAf;;EACA,MAAMC,SAAS,GAAGC,sBAAA,CAAWC,KAAX,CAAiBP,MAAjB,EAAyB;IAACQ,cAAc,EAAE;EAAjB,CAAzB,CAAlB;;EAEAC,mBAAmB;EAEnBR,QAAQ,CAACS,OAAT,CAAiBC,OAAO,IAAI;IAC1BC,eAAe,CAACD,OAAD,CAAf;EACD,CAFD;EAIA,OAAON,SAAS,CAACQ,QAAV,EAA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ory","root","reader","READERS","JSON","it","record","MarcRecord","components","result","formatRecord","toObject","BIB_FORMAT_SETTINGS","expected","expect","to","eql"],"sources":["../../src/helpers/format.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {expect} from 'chai';\nimport fixtureFactory, {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {formatRecord, BIB_FORMAT_SETTINGS} from './format';\n\ndescribe('services/format', () => {\n const FIXTURES_PATH = [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'format'\n ];\n const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});\n\n describe('fiAsteriN0Fin11', () => {\n it('Should succeed', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'fiAsteriN0Fin11.json'\n ]\n }));\n const result = formatRecord(record.toObject(), BIB_FORMAT_SETTINGS);\n const expected = getFixture({\n components: [\n 'out',\n 'fiAsteriN0Fin11.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('fiAsteriS0Fin10', () => {\n it('Should succeed', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'fiAsteriS0Fin10.json'\n ]\n }));\n const result = formatRecord(record.toObject(), BIB_FORMAT_SETTINGS);\n const expected = getFixture({\n components: [\n 'out',\n 'fiAsteriS0Fin10.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('fiMelindaWFin01', () => {\n it('Should succeed', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'fiMelindaWFin01.json'\n ]\n }));\n const result = formatRecord(record.toObject(), BIB_FORMAT_SETTINGS);\n const expected = getFixture({\n components: [\n 'out',\n 'fiMelindaWFin01.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('f035fibtj', () => {\n it('Should add FI-BTJ SID', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f035fibtj.json'\n ]\n }));\n const result = formatRecord(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f035fibtj.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('f035tati', () => {\n it('Should add tati SID', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f035tati.json'\n ]\n }));\n const result = formatRecord(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f035tati.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('f035fibtjAndTati', () => {\n it('Should add tati SID and skip FI-BTJ SID', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f035fibtjAndTati.json'\n ]\n }));\n const result = formatRecord(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f035fibtjAndTati.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n});\n"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;;;;;AA/BA;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;AAOAA,QAAQ,CAAC,iBAAD,EAAoB,MAAM;EAChC,MAAMC,aAAa,GAAG,CACpBC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CAAzB,CAAf;MAMA,MAAMC,MAAM,GAAG,IAAAC,oBAAA,EAAaJ,MAAM,CAACK,QAAP,EAAb,CAAf;MACA,MAAME,QAAQ,GAAGd,UAAU,CAAC;QAC1BS,UAAU,EAAE,CACV,KADU,EAEV,eAFU;MADc,CAAD,CAA3B;MAOA,IAAAM,YAAA,EAAOL,MAAP,EAAeM,EAAf,CAAkBC,GAAlB,CAAsBH,QAAtB;IACD,CAhBC,CAAF;EAiBD,CAlBO,CAAR;EAoBAjB,QAAQ,CAAC,kBAAD,EAAqB,MAAM;IACjCS,EAAE,CAAC,yCAAD,EAA4C,MAAM;MAClD,MAAMC,MAAM,GAAG,IAAIC,sBAAJ,CAAeR,UAAU,CAAC;QACvCS,UAAU,EAAE,CACV,IADU,EAEV,uBAFU;MAD2B,CAAD,CAAzB,CAAf;MAMA,MAAMC,MAAM,GAAG,IAAAC,oBAAA,EAAaJ,MAAM,CAACK,QAAP,EAAb,CAAf;MACA,MAAME,QAAQ,GAAGd,UAAU,CAAC;QAC1BS,UAAU,EAAE,CACV,KADU,EAEV,uBAFU;MADc,CAAD,CAA3B;MAOA,IAAAM,YAAA,EAAOL,MAAP,EAAeM,EAAf,CAAkBC,GAAlB,CAAsBH,QAAtB;IACD,CAhBC,CAAF;EAiBD,CAlBO,CAAR;AAmBD,CAjIO,CAAR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"validation.js","names":["logger","createLogger","verbose","validate","validateFactory","fieldStructure","tag","valuePattern","unvalidRecord","record","valid","report","fix","validateFixes","subfieldValues","failed","messages"],"sources":["../../src/helpers/validation.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport validateFactory from '@natlibfi/marc-record-validate';\nimport {\n FieldStructure as fieldStructure\n} from '@natlibfi/marc-record-validators-melinda';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\n\nexport default async () => {\n const logger = createLogger();\n\n logger.verbose('Running inbuilt record validations');\n const validate = validateFactory([await fieldStructure([{tag: /^003$/u, valuePattern: /^FI-MELINDA$/u}])]);\n\n return async unvalidRecord => {\n const {record, valid, report} = await validate(unvalidRecord, {fix: false, validateFixes: false}, {subfieldValues: false});\n\n return {\n record,\n failed: valid === false,\n messages: report\n };\n };\n};\n"],"mappings":";;;;;;;AA4BA;;AACA;;AAGA;;;;AAhCA;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;eAQe,YAAY;EACzB,MAAMA,MAAM,GAAG,IAAAC,mCAAA,GAAf;EAEAD,MAAM,CAACE,OAAP,CAAe,oCAAf;EACA,MAAMC,QAAQ,GAAG,IAAAC,2BAAA,EAAgB,CAAC,MAAM,IAAAC,2CAAA,EAAe,CAAC;IAACC,GAAG,EAAE,QAAN;IAAgBC,YAAY,EAAE;EAA9B,CAAD,CAAf,CAAP,CAAhB,CAAjB;EAEA,OAAO,MAAMC,aAAN,IAAuB;IAC5B,MAAM;MAACC,MAAD;MAASC,KAAT;MAAgBC;IAAhB,IAA0B,MAAMR,QAAQ,CAACK,aAAD,EAAgB;MAACI,GAAG,EAAE,KAAN;MAAaC,aAAa,EAAE;IAA5B,CAAhB,EAAoD;MAACC,cAAc,EAAE;IAAjB,CAApD,CAA9C;IAEA,OAAO;MACLL,MADK;MAELM,MAAM,EAAEL,KAAK,KAAK,KAFb;MAGLM,QAAQ,EAAEL;IAHL,CAAP;EAKD,CARD;AASD,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"validation.spec.js","names":["describe","FIXTURES_PATH","__dirname","getFixture","fixtureFactory","root","reader","READERS","JSON","it","validator","createValidator","record","MarcRecord","components","result","toObject","expected","expect","to","eql","failed","equal"],"sources":["../../src/helpers/validation.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {expect} from 'chai';\nimport fixtureFactory, {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createValidator from './validation';\n\ndescribe('services/validate', () => {\n const FIXTURES_PATH = [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'validation'\n ];\n const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});\n\n describe('f003-fi-melinda', () => {\n it('Should have failed: false', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(false);\n });\n });\n\n describe('f003-not-fi-melinda', () => {\n it('Should have failed: true', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-not-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-not-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(true);\n });\n });\n});\n\n"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;;;;;;;AA/BA;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;AAOAA,QAAQ,CAAC,mBAAD,EAAsB,MAAM;EAClC,MAAMC,aAAa,GAAG,CACpBC,SADoB,EAEpB,IAFoB,EAGpB,IAHoB,EAIpB,eAJoB,EAKpB,YALoB,CAAtB;EAOA,MAAM;IAACC;EAAD,IAAe,IAAAC,eAAA,EAAe;IAACC,IAAI,EAAEJ,aAAP;IAAsBK,MAAM,EAAEC,eAAA,CAAQC;EAAtC,CAAf,CAArB;EAEAR,QAAQ,CAAC,iBAAD,EAAoB,MAAM;IAChCS,EAAE,CAAC,2BAAD,EAA8B,YAAY;MAC1C,MAAMC,SAAS,GAAG,MAAM,IAAAC,mBAAA,GAAxB;MACA,MAAMC,MAAM,GAAG,IAAIC,sBAAJ,CAAeV,UAAU,CAAC;QACvCW,UAAU,EAAE,CACV,IADU,EAEV,sBAFU;MAD2B,CAAD,CAAzB,CAAf;MAMA,MAAMC,MAAM,GAAG,MAAML,SAAS,CAACE,MAAM,CAACI,QAAP,EAAD,CAA9B;MACA,MAAMC,QAAQ,GAAGd,UAAU,CAAC;QAC1BW,UAAU,EAAE,CACV,KADU,EAEV,sBAFU;MADc,CAAD,CAA3B;MAMA,IAAAI,YAAA,EAAOH,MAAP,EAAeI,EAAf,CAAkBC,GAAlB,CAAsBH,QAAtB;MACA,IAAAC,YAAA,EAAOH,MAAM,CAACM,MAAd,EAAsBF,EAAtB,CAAyBG,KAAzB,CAA+B,KAA/B;IACD,CAjBC,CAAF;EAkBD,CAnBO,CAAR;EAqBAtB,QAAQ,CAAC,qBAAD,EAAwB,MAAM;IACpCS,EAAE,CAAC,0BAAD,EAA6B,YAAY;MACzC,MAAMC,SAAS,GAAG,MAAM,IAAAC,mBAAA,GAAxB;MACA,MAAMC,MAAM,GAAG,IAAIC,sBAAJ,CAAeV,UAAU,CAAC;QACvCW,UAAU,EAAE,CACV,IADU,EAEV,0BAFU;MAD2B,CAAD,CAAzB,CAAf;MAMA,MAAMC,MAAM,GAAG,MAAML,SAAS,CAACE,MAAM,CAACI,QAAP,EAAD,CAA9B;MACA,MAAMC,QAAQ,GAAGd,UAAU,CAAC;QAC1BW,UAAU,EAAE,CACV,KADU,EAEV,0BAFU;MADc,CAAD,CAA3B;MAMA,IAAAI,YAAA,EAAOH,MAAP,EAAeI,EAAf,CAAkBC,GAAlB,CAAsBH,QAAtB;MACA,IAAAC,YAAA,EAAOH,MAAM,CAACM,MAAd,EAAsBF,EAAtB,CAAyBG,KAAzB,CAA+B,IAA/B;IACD,CAjBC,CAAF;EAkBD,CAnBO,CAAR;AAoBD,CAnDO,CAAR"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
mongoFactory: true,
|
|
8
|
+
mongoLogFactory: true,
|
|
8
9
|
amqpFactory: true,
|
|
9
10
|
conversions: true,
|
|
10
11
|
validations: true,
|
|
@@ -64,6 +65,12 @@ Object.defineProperty(exports, "mongoFactory", {
|
|
|
64
65
|
return _mongo.default;
|
|
65
66
|
}
|
|
66
67
|
});
|
|
68
|
+
Object.defineProperty(exports, "mongoLogFactory", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () {
|
|
71
|
+
return _mongoLog.default;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
67
74
|
Object.defineProperty(exports, "validations", {
|
|
68
75
|
enumerable: true,
|
|
69
76
|
get: function () {
|
|
@@ -73,6 +80,8 @@ Object.defineProperty(exports, "validations", {
|
|
|
73
80
|
|
|
74
81
|
var _mongo = _interopRequireDefault(require("./mongo"));
|
|
75
82
|
|
|
83
|
+
var _mongoLog = _interopRequireDefault(require("./mongoLog"));
|
|
84
|
+
|
|
76
85
|
var _amqp = _interopRequireDefault(require("./amqp"));
|
|
77
86
|
|
|
78
87
|
var _conversion = _interopRequireDefault(require("./helpers/conversion"));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020-2021 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport mongoFactory from './mongo';\nimport mongoLogFactory from './mongoLog';\nimport amqpFactory from './amqp';\nimport conversions from './helpers/conversion';\nimport validations from './helpers/validation';\nimport * as format from './helpers/format';\nimport {logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem} from './utils';\n\nexport {mongoFactory, mongoLogFactory, amqpFactory, conversions, validations, format, logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem};\nexport * from './constants';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AACA;;AAGA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|