@natlibfi/melinda-rest-api-commons 2.3.2-alpha.9 → 2.3.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/package.json CHANGED
@@ -1,120 +1,124 @@
1
1
  {
2
- "name": "@natlibfi/melinda-rest-api-commons",
3
- "description": "Shared modules for microservices of Melinda rest api import system",
4
- "author": {
5
- "name": "The National Library of Finland"
6
- },
7
- "keywords": [],
8
- "homepage": "https://github.com/natlibfi/melinda-rest-api-commons",
9
- "bugs": {
10
- "url": "https://github.com/natlibfi/melinda-rest-api-commons/issues"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
15
- },
16
- "license": "AGPL-3.0+",
17
- "version": "2.3.2-alpha.9",
18
- "main": "./dist/index.js",
19
- "engines": {
20
- "node": ">=14"
21
- },
22
- "publishConfig": {
23
- "access": "public"
24
- },
25
- "scripts": {
26
- "prepare": "npm run build",
27
- "lint": "eslint ./src",
28
- "lint:dev": "eslint ./src --fix",
29
- "test": "npm run lint && npm run test:base -- src/**/*.spec.js",
30
- "test:dev": "npm run lint:dev && npm run test:base -- src/**/*.spec.js",
31
- "test:base": "cross-env NODE_ENV=test nyc mocha --require @babel/register --exclude src/amqp.spec.js",
32
- "test:local": "cross-env NODE_ENV=test nyc mocha --require @babel/register -- src/amqp.spec.js",
33
- "dev": "NODE_ENV=development cross-env DEBUG=1 nodemon",
34
- "build": "babel src --source-maps --copy-files --delete-dir-on-start --out-dir=dist"
35
- },
36
- "dependencies": {
37
- "@natlibfi/fixugen": "^1.1.0",
38
- "@natlibfi/marc-record": "^7.2.2",
39
- "@natlibfi/marc-record-serializers": "^9.0.1",
40
- "@natlibfi/marc-record-validate": "^7.0.2",
41
- "@natlibfi/marc-record-validators-melinda": "^9.0.13",
42
- "@natlibfi/melinda-backend-commons": "^2.1.0",
43
- "@natlibfi/melinda-commons": "^12.0.5",
44
- "amqplib": ">=0.8.0 <1.0.0",
45
- "debug": "^4.3.4",
46
- "http-status": "^1.5.3",
47
- "moment": "^2.29.4",
48
- "mongo-sanitize": "^1.1.0",
49
- "mongodb": "^4.11.0"
50
- },
51
- "devDependencies": {
52
- "@babel/cli": "^7.19.3",
53
- "@babel/core": "^7.19.6",
54
- "@babel/eslint-parser": "^7.19.1",
55
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
56
- "@babel/preset-env": "^7.19.4",
57
- "@natlibfi/eslint-config-melinda-backend": "^2.0.1",
58
- "@natlibfi/fixura": "^2.2.5",
59
- "babel-plugin-dynamic-import-node": "^2.3.3",
60
- "babel-plugin-istanbul": "^6.1.1",
61
- "babel-plugin-rewire": "^1.2.0",
62
- "chai": "^4.3.6",
63
- "cross-env": "^7.0.3",
64
- "eslint": "^8.25.0",
65
- "mocha": "^10.1.0",
66
- "nodemon": "^2.0.20",
67
- "nyc": "^15.1.0"
68
- },
69
- "eslintConfig": {
70
- "extends": "@natlibfi/melinda-backend"
71
- },
72
- "babel": {
73
- "presets": [
74
- [
75
- "@babel/preset-env",
76
- {
77
- "targets": "maintained node versions"
78
- }
79
- ]
80
- ],
81
- "plugins": [
82
- "@babel/plugin-syntax-dynamic-import",
83
- "dynamic-import-node"
84
- ],
85
- "env": {
86
- "test": {
87
- "plugins": [
88
- "istanbul",
89
- "rewire"
90
- ]
91
- }
92
- }
93
- },
94
- "nyc": {
95
- "exclude": [
96
- "**/*.spec.js"
97
- ],
98
- "reporter": [
99
- "lcov",
100
- "html"
101
- ],
102
- "require": [
103
- "@babel/register"
104
- ],
105
- "sourceMap": false,
106
- "instrument": false,
107
- "lines": 80,
108
- "statements": 80,
109
- "functions": 80,
110
- "branches": 80
111
- },
112
- "nodemonConfig": {
113
- "exec": "npm run test:dev",
114
- "watch": [
115
- "src/*"
116
- ],
117
- "ext": "js",
118
- "delay": 2.5
119
- }
2
+ "name": "@natlibfi/melinda-rest-api-commons",
3
+ "description": "Shared modules for microservices of Melinda rest api import system",
4
+ "author": {
5
+ "name": "The National Library of Finland"
6
+ },
7
+ "keywords": [],
8
+ "homepage": "https://github.com/natlibfi/melinda-rest-api-commons",
9
+ "bugs": {
10
+ "url": "https://github.com/natlibfi/melinda-rest-api-commons/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
15
+ },
16
+ "license": "AGPL-3.0+",
17
+ "version": "2.3.3-alpha.1",
18
+ "main": "./dist/index.js",
19
+ "engines": {
20
+ "node": ">=14"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "scripts": {
26
+ "prepare": "npm run build",
27
+ "lint": "eslint ./src",
28
+ "lint:dev": "eslint ./src --fix",
29
+ "test": "npm run lint && npm run test:base -- src/**/*.spec.js",
30
+ "test:dev": "npm run lint:dev && npm run test:base -- src/**/*.spec.js",
31
+ "test:base": "cross-env NODE_ENV=test nyc mocha --require @babel/register --exclude src/amqp.health.spec.js --exclude src/amqp.tests.spec.js",
32
+ "test:local": "cross-env NODE_ENV=test nyc mocha --require @babel/register -- src/amqp.*.spec.js",
33
+ "test:healthcheck": "cross-env NODE_ENV=test nyc mocha --require @babel/register -- src/amqp.health.spec.js",
34
+ "coverage": "npm run cover:unit && npm run cover:report",
35
+ "cover:unit": "nyc --silent npm run test",
36
+ "cover:report": "nyc report --reporter=lcov --reporter=text",
37
+ "dev": "NODE_ENV=development cross-env DEBUG='@natlibfi/*' nodemon",
38
+ "build": "babel src --source-maps --copy-files --delete-dir-on-start --out-dir=dist"
39
+ },
40
+ "dependencies": {
41
+ "@natlibfi/fixugen": "^1.1.0",
42
+ "@natlibfi/marc-record": "^7.2.2",
43
+ "@natlibfi/marc-record-serializers": "^9.0.3",
44
+ "@natlibfi/marc-record-validate": "^7.0.2",
45
+ "@natlibfi/marc-record-validators-melinda": "^9.0.14",
46
+ "@natlibfi/melinda-backend-commons": "^2.1.0",
47
+ "@natlibfi/melinda-commons": "^12.0.6",
48
+ "amqplib": ">=0.8.0 <1.0.0",
49
+ "debug": "^4.3.4",
50
+ "http-status": "^1.5.3",
51
+ "moment": "^2.29.4",
52
+ "mongo-sanitize": "^1.1.0",
53
+ "mongodb": "^4.11.0"
54
+ },
55
+ "devDependencies": {
56
+ "@babel/cli": "^7.19.3",
57
+ "@babel/core": "^7.20.2",
58
+ "@babel/eslint-parser": "^7.19.1",
59
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
60
+ "@babel/preset-env": "^7.20.2",
61
+ "@natlibfi/eslint-config-melinda-backend": "^2.0.2",
62
+ "@natlibfi/fixura": "^2.2.5",
63
+ "babel-plugin-dynamic-import-node": "^2.3.3",
64
+ "babel-plugin-istanbul": "^6.1.1",
65
+ "babel-plugin-rewire": "^1.2.0",
66
+ "chai": "^4.3.7",
67
+ "cross-env": "^7.0.3",
68
+ "eslint": "^8.27.0",
69
+ "mocha": "^10.1.0",
70
+ "nodemon": "^2.0.20",
71
+ "nyc": "^15.1.0"
72
+ },
73
+ "eslintConfig": {
74
+ "extends": "@natlibfi/melinda-backend"
75
+ },
76
+ "babel": {
77
+ "presets": [
78
+ [
79
+ "@babel/preset-env",
80
+ {
81
+ "targets": "maintained node versions"
82
+ }
83
+ ]
84
+ ],
85
+ "plugins": [
86
+ "@babel/plugin-syntax-dynamic-import",
87
+ "dynamic-import-node"
88
+ ],
89
+ "env": {
90
+ "test": {
91
+ "plugins": [
92
+ "istanbul",
93
+ "rewire"
94
+ ]
95
+ }
96
+ }
97
+ },
98
+ "nyc": {
99
+ "exclude": [
100
+ "**/*.spec.js"
101
+ ],
102
+ "reporter": [
103
+ "lcov",
104
+ "html"
105
+ ],
106
+ "require": [
107
+ "@babel/register"
108
+ ],
109
+ "sourceMap": false,
110
+ "instrument": false,
111
+ "lines": 80,
112
+ "statements": 80,
113
+ "functions": 80,
114
+ "branches": 80
115
+ },
116
+ "nodemonConfig": {
117
+ "exec": "npm run test:dev",
118
+ "watch": [
119
+ "src/*"
120
+ ],
121
+ "ext": "js",
122
+ "delay": 2.5
123
+ }
120
124
  }
package/dist/amqp.spec.js DELETED
@@ -1,252 +0,0 @@
1
- "use strict";
2
-
3
- var _chai = require("chai");
4
- var _fixura = require("@natlibfi/fixura");
5
- var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
6
- var _debug = _interopRequireDefault(require("debug"));
7
- var _index = require("./index");
8
- var _melindaCommons = require("@natlibfi/melinda-commons");
9
- var _util = require("util");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
- //import inspect from 'util';
40
-
41
- const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:amqp:test');
42
- //const debugData = debug.extend('data');
43
-
44
- const setTimeoutPromise = (0, _util.promisify)(setTimeout);
45
- (0, _fixugen.default)({
46
- callback,
47
- path: [__dirname, '..', 'test-fixtures', 'amqp'],
48
- recurse: false,
49
- useMetadataFile: true,
50
- fixura: {
51
- failWhenNotFound: false,
52
- reader: _fixura.READERS.JSON
53
- }
54
- });
55
-
56
- // eslint-disable-next-line max-statements
57
- async function callback() {
58
- const testData = {
59
- queue: 'TESTQUEUE',
60
- correlationId: '5b7be681-0d4d-47ca-b5d7-1531173ec6bf',
61
- data: {
62
- 'leader': '02518cam a2200745zi 4500',
63
- 'fields': [{
64
- 'tag': '001',
65
- 'value': '000019640'
66
- }]
67
- }
68
- };
69
- debug(`Testing amqp against a local AMQP instance - we'll need some kind of mockup for this`);
70
- const amqpUrl = 'amqp://127.0.0.1:5672/';
71
- debug(`Connecting to ${amqpUrl}, with healthCheck running`);
72
- const amqpOperator = await (0, _index.amqpFactory)(amqpUrl, true);
73
- debug(`**********`);
74
- await testHealthCheckLoopWorking(amqpOperator);
75
- debug(`**********`);
76
- await testHealthCheckLoopErroring(amqpOperator);
77
- await amqpOperator.closeConnection();
78
- debug(`--- Create a new amqpOperator2 ----`);
79
- debug(`Connecting to ${amqpUrl}, without healthCheck running`);
80
- const amqpOperator2 = await (0, _index.amqpFactory)(amqpUrl);
81
- debug(`**********`);
82
- debug(`*** Test purging the queue: ${testData.queue} *******`);
83
- const purgeMessage = await amqpOperator2.checkQueue({
84
- queue: testData.queue,
85
- toRecord: false,
86
- purge: true
87
- });
88
- (0, _chai.expect)(purgeMessage).to.eql(false);
89
- await testSendToQueue(amqpOperator2, testData);
90
- debug(`* wait, otherwise queue is not ready *`);
91
- await setTimeoutPromise('100');
92
- debug(`*** Test getting messageCount from theQueue: ${testData.queue} *******`);
93
- const messageCount = await amqpOperator2.checkQueue({
94
- queue: testData.queue,
95
- style: 'messages'
96
- });
97
- debug(messageCount);
98
- (0, _chai.expect)(messageCount).to.eql(1);
99
- debug(`*** Test checking theQueue: ${testData.queue} *******`);
100
- const message = await amqpOperator2.checkQueue({
101
- queue: testData.queue,
102
- style: 'one',
103
- toRecord: false,
104
- purge: false
105
- });
106
- (0, _chai.expect)(message).to.not.equal('goo');
107
- debug(message);
108
- debug(`*** Test nacking the message: ${testData.queue} *******`);
109
- await amqpOperator2.nackMessages([message]);
110
- debug(`* wait, otherwise queue is not ready *`);
111
- await setTimeoutPromise('100');
112
- const messageCountAfterNack = await amqpOperator2.checkQueue({
113
- queue: testData.queue,
114
- style: 'messages'
115
- });
116
- debug(`After nack: ${messageCountAfterNack}`);
117
- (0, _chai.expect)(messageCountAfterNack).to.eql(1);
118
- const message2 = await amqpOperator2.checkQueue({
119
- queue: testData.queue,
120
- style: 'one',
121
- toRecord: false,
122
- purge: false
123
- });
124
- debug(`*** Test acking the message: ${testData.queue} *******`);
125
- await amqpOperator2.ackMessages([message2]);
126
- debug(`* wait, otherwise queue is not ready *`);
127
- await setTimeoutPromise('100');
128
- const messageCountAfterAck = await amqpOperator2.checkQueue({
129
- queue: testData.queue,
130
- style: 'messages'
131
- });
132
- debug(`After ack: ${messageCountAfterAck}`);
133
- (0, _chai.expect)(messageCountAfterAck).to.eql(0);
134
- debug(`*** Test removing the the queue: ${testData.queue} *******`);
135
- const removeResult = await amqpOperator2.removeQueue(testData.queue);
136
- debug(removeResult);
137
- debug(`**********`);
138
- try {
139
- await testUndefinedQueue(amqpOperator2, testData);
140
- } catch (error) {
141
- //expect(error()).to.be.an('apierror');
142
- const errorAsString = JSON.stringify(error);
143
- (0, _chai.expect)(error).to.be.an.instanceof(_melindaCommons.Error);
144
- (0, _chai.expect)(errorAsString).to.eql(`{"status":500,"payload":"Undefined queue!"}`);
145
- }
146
- debug(`**********`);
147
- debug(`--- Closing amqpOperator2 ----`);
148
- await amqpOperator2.closeChannel();
149
- await amqpOperator2.closeConnection();
150
- debug(`**********`);
151
- try {
152
- await testSendToQueue(amqpOperator2, testData);
153
- } catch (error) {
154
- (0, _chai.expect)(error.message).to.eql(`Channel closed`);
155
- debug(`We got an error: ${JSON.stringify(error)}`);
156
- }
157
- debug(`**********`);
158
- debug(`Done`);
159
- //}
160
-
161
- async function testHealthCheckLoopWorking(amqpOperator) {
162
- debug(`Testing healthCheckLoop for ${amqpOperator}`);
163
- debug(`Waiting 0.5s and expecting healthCheckLoop to work`);
164
- await setTimeoutPromise('500');
165
- debug(`Amqp Operator should have been alive.`);
166
- }
167
- async function testHealthCheckLoopErroring(amqpOperator) {
168
- debug(`Testing healthCheckLoop with closed channel`);
169
- amqpOperator.closeChannel();
170
- debug(`Waiting 0.5s and expecting healthCheckLoop to throw error`);
171
- await setTimeoutPromise('500');
172
- debug(`amqpOperator should have errored`);
173
- }
174
- async function testSendToQueue(amqpOperator, testData) {
175
- // Test sendToQueue
176
- debug(`*** Testing sendToQueue ***`);
177
- const {
178
- queue,
179
- correlationId,
180
- data
181
- } = testData;
182
- const headers = {
183
- correlationId
184
- };
185
- await amqpOperator.sendToQueue({
186
- queue,
187
- correlationId,
188
- headers,
189
- data
190
- });
191
- return;
192
- }
193
-
194
- /*
195
- async function testCheckQueue(amqpOperator, testData) {
196
- debug(`Testing checkQueue`);
197
- const {queue} = testData;
198
- const message = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});
199
- debug(message);
200
- return message;
201
- //expect(message).to.be.defined;
202
- }
203
- */
204
-
205
- async function testUndefinedQueue(amqpOperator, testData) {
206
- // Test sendToQueue
207
- debug(`Testing sendToQueue with undefined queue`);
208
- const {
209
- correlationId,
210
- data
211
- } = testData;
212
- const headers = {
213
- correlationId
214
- };
215
- const queue = undefined;
216
- (0, _chai.expect)(await amqpOperator.sendToQueue({
217
- queue,
218
- correlationId,
219
- headers,
220
- data
221
- })).to.throw();
222
- }
223
-
224
- /*
225
- await amqpOperator.sendToQueue({queue, correlationId, headers, data});
226
- await amqpOperator.ackMessages([message]);
227
- const message2 = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});
228
- await amqpOperator.ackMessages([message2]);
229
- expect(message2).to.be(true);
230
- //debug(`FOO: ${JSON.stringify(message)}`);
231
- // http:
232
- // await amqpOperator.sendToQueue({queue: 'REQUESTS', correlationId, headers, data});
233
- // validator:
234
- // const message = await amqpOperator.checkQueue({queue: 'REQUESTS', style: 'one', toRecord: false, purge: false});
235
- // await amqpOperator.ackMessages([message]);
236
- // const message = await amqpOperator.checkQueue({queue: validatorQueue, style: 'one', toRecord: false, purge: false});
237
- // amqpOperator.removeQueue(validatorQueue);
238
- //await amqpOperator.checkQueue({queue: operationQueue, style: 'messages', purge: true});
239
- // await amqpOperator.checkQueue({queue: `${headers.operation}.${correlationId}`, style: 'messages', purge: true});
240
- // importer
241
- /*
242
- const {headers, records, messages} = await amqpOperator.checkQueue({queue: `${operation}.${correlationId}`, style: 'basic', toRecord: true, purge: purgeQueues});
243
- await amqpOperator.nackMessages(messages);
244
- await amqpOperator.sendToQueue({
245
- const {messages} = await amqpOperator.checkQueue({queue, style: 'basic', toRecords: false, purge: false});
246
- await amqpOperator.ackMessages(messages);
247
- const processMessage = await amqpOperator.checkQueue({queue: processQueue, style: 'one', toRecord: false, purge: false});
248
- const {headers: firstMessageHeaders, messages} = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: false, purge: false});
249
- const queueMessagesCount = await amqpOperator.checkQueue({queue, style: 'messages'});
250
- */
251
- }
252
- //# sourceMappingURL=amqp.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amqp.spec.js","names":["debug","createDebugLogger","setTimeoutPromise","promisify","setTimeout","generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","testData","queue","correlationId","data","amqpUrl","amqpOperator","amqpFactory","testHealthCheckLoopWorking","testHealthCheckLoopErroring","closeConnection","amqpOperator2","purgeMessage","checkQueue","toRecord","purge","expect","to","eql","testSendToQueue","messageCount","style","message","not","equal","nackMessages","messageCountAfterNack","message2","ackMessages","messageCountAfterAck","removeResult","removeQueue","testUndefinedQueue","error","errorAsString","stringify","be","an","instanceof","ApiError","closeChannel","headers","sendToQueue","undefined","throw"],"sources":["../src/amqp.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 generateTests from '@natlibfi/fixugen';\nimport createDebugLogger from 'debug';\nimport {amqpFactory} from './index';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\n//import inspect from 'util';\nimport {promisify} from 'util';\n\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp:test');\n//const debugData = debug.extend('data');\n\nconst setTimeoutPromise = promisify(setTimeout);\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'amqp'],\n recurse: false,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: false,\n reader: READERS.JSON\n }\n});\n\n// eslint-disable-next-line max-statements\nasync function callback() {\n\n const testData = {\n queue: 'TESTQUEUE',\n correlationId: '5b7be681-0d4d-47ca-b5d7-1531173ec6bf',\n data: {'leader': '02518cam a2200745zi 4500', 'fields': [{'tag': '001', 'value': '000019640'}]}\n };\n\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 debug(`Connecting to ${amqpUrl}, with healthCheck running`);\n const amqpOperator = await amqpFactory(amqpUrl, true);\n\n debug(`**********`);\n await testHealthCheckLoopWorking(amqpOperator);\n\n debug(`**********`);\n await testHealthCheckLoopErroring(amqpOperator);\n\n await amqpOperator.closeConnection();\n\n debug(`--- Create a new amqpOperator2 ----`);\n debug(`Connecting to ${amqpUrl}, without healthCheck running`);\n const amqpOperator2 = await amqpFactory(amqpUrl);\n\n debug(`**********`);\n debug(`*** Test purging the queue: ${testData.queue} *******`);\n const purgeMessage = await amqpOperator2.checkQueue({queue: testData.queue, toRecord: false, purge: true});\n expect(purgeMessage).to.eql(false);\n await testSendToQueue(amqpOperator2, testData);\n debug(`* wait, otherwise queue is not ready *`);\n await setTimeoutPromise('100');\n\n debug(`*** Test getting messageCount from theQueue: ${testData.queue} *******`);\n const messageCount = await amqpOperator2.checkQueue({queue: testData.queue, style: 'messages'});\n debug(messageCount);\n expect(messageCount).to.eql(1);\n\n debug(`*** Test checking theQueue: ${testData.queue} *******`);\n const message = await amqpOperator2.checkQueue({queue: testData.queue, style: 'one', toRecord: false, purge: false});\n expect(message).to.not.equal('goo');\n debug(message);\n\n debug(`*** Test nacking the message: ${testData.queue} *******`);\n await amqpOperator2.nackMessages([message]);\n debug(`* wait, otherwise queue is not ready *`);\n await setTimeoutPromise('100');\n\n const messageCountAfterNack = await amqpOperator2.checkQueue({queue: testData.queue, style: 'messages'});\n debug(`After nack: ${messageCountAfterNack}`);\n expect(messageCountAfterNack).to.eql(1);\n\n const message2 = await amqpOperator2.checkQueue({queue: testData.queue, style: 'one', toRecord: false, purge: false});\n\n debug(`*** Test acking the message: ${testData.queue} *******`);\n await amqpOperator2.ackMessages([message2]);\n debug(`* wait, otherwise queue is not ready *`);\n await setTimeoutPromise('100');\n\n const messageCountAfterAck = await amqpOperator2.checkQueue({queue: testData.queue, style: 'messages'});\n debug(`After ack: ${messageCountAfterAck}`);\n expect(messageCountAfterAck).to.eql(0);\n\n debug(`*** Test removing the the queue: ${testData.queue} *******`);\n const removeResult = await amqpOperator2.removeQueue(testData.queue);\n debug(removeResult);\n\n\n debug(`**********`);\n try {\n await testUndefinedQueue(amqpOperator2, testData);\n } catch (error) {\n //expect(error()).to.be.an('apierror');\n const errorAsString = JSON.stringify(error);\n expect(error).to.be.an.instanceof(ApiError);\n expect(errorAsString).to.eql(`{\"status\":500,\"payload\":\"Undefined queue!\"}`);\n }\n debug(`**********`);\n\n debug(`--- Closing amqpOperator2 ----`);\n await amqpOperator2.closeChannel();\n await amqpOperator2.closeConnection();\n\n debug(`**********`);\n\n try {\n await testSendToQueue(amqpOperator2, testData);\n } catch (error) {\n expect(error.message).to.eql(`Channel closed`);\n debug(`We got an error: ${JSON.stringify(error)}`);\n }\n debug(`**********`);\n\n debug(`Done`);\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 async function testSendToQueue(amqpOperator, testData) {\n // Test sendToQueue\n debug(`*** Testing sendToQueue ***`);\n\n const {queue, correlationId, data} = testData;\n const headers = {correlationId};\n\n await amqpOperator.sendToQueue({queue, correlationId, headers, data});\n return;\n }\n\n /*\n async function testCheckQueue(amqpOperator, testData) {\n debug(`Testing checkQueue`);\n const {queue} = testData;\n const message = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});\n debug(message);\n return message;\n //expect(message).to.be.defined;\n }\n*/\n\n async function testUndefinedQueue(amqpOperator, testData) {\n // Test sendToQueue\n debug(`Testing sendToQueue with undefined queue`);\n const {correlationId, data} = testData;\n const headers = {correlationId};\n const queue = undefined;\n\n expect(await amqpOperator.sendToQueue({queue, correlationId, headers, data})).to.throw();\n }\n\n\n /*\n\n\n await amqpOperator.sendToQueue({queue, correlationId, headers, data});\n\n\n await amqpOperator.ackMessages([message]);\n const message2 = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});\n await amqpOperator.ackMessages([message2]);\n\n expect(message2).to.be(true);\n\n\n //debug(`FOO: ${JSON.stringify(message)}`);\n\n\n // http:\n // await amqpOperator.sendToQueue({queue: 'REQUESTS', correlationId, headers, data});\n\n // validator:\n // const message = await amqpOperator.checkQueue({queue: 'REQUESTS', style: 'one', toRecord: false, purge: false});\n // await amqpOperator.ackMessages([message]);\n // const message = await amqpOperator.checkQueue({queue: validatorQueue, style: 'one', toRecord: false, purge: false});\n // amqpOperator.removeQueue(validatorQueue);\n //await amqpOperator.checkQueue({queue: operationQueue, style: 'messages', purge: true});\n // await amqpOperator.checkQueue({queue: `${headers.operation}.${correlationId}`, style: 'messages', purge: true});\n\n // importer\n /*\nconst {headers, records, messages} = await amqpOperator.checkQueue({queue: `${operation}.${correlationId}`, style: 'basic', toRecord: true, purge: purgeQueues});\n await amqpOperator.nackMessages(messages);\n await amqpOperator.sendToQueue({\n const {messages} = await amqpOperator.checkQueue({queue, style: 'basic', toRecords: false, purge: false});\n await amqpOperator.ackMessages(messages);\n const processMessage = await amqpOperator.checkQueue({queue: processQueue, style: 'one', toRecord: false, purge: false});\n const {headers: firstMessageHeaders, messages} = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: false, purge: false});\n const queueMessagesCount = await amqpOperator.checkQueue({queue, style: 'messages'});\n\n\n */\n\n}\n\n"],"mappings":";;AA4BA;AACA;AACA;AACA;AACA;AACA;AAEA;AAA+B;AAnC/B;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;;AAQA;;AAGA,MAAMA,KAAK,GAAG,IAAAC,cAAiB,EAAC,8CAA8C,CAAC;AAC/E;;AAEA,MAAMC,iBAAiB,GAAG,IAAAC,eAAS,EAACC,UAAU,CAAC;AAE/C,IAAAC,gBAAa,EAAC;EACZC,QAAQ;EACRC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EA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