@natlibfi/melinda-rest-api-commons 2.3.2-alpha.1 → 2.3.2-alpha.10

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.
Files changed (42) hide show
  1. package/dist/amqp.health.spec.js +69 -0
  2. package/dist/amqp.health.spec.js.map +1 -0
  3. package/dist/amqp.js +135 -92
  4. package/dist/amqp.js.map +1 -1
  5. package/dist/amqp.tests.spec.js +338 -0
  6. package/dist/amqp.tests.spec.js.map +1 -0
  7. package/dist/constants.js +5 -3
  8. package/dist/constants.js.map +1 -1
  9. package/dist/helpers/conversion.js +5 -25
  10. package/dist/helpers/conversion.js.map +1 -1
  11. package/dist/helpers/conversion.spec.js +1 -7
  12. package/dist/helpers/conversion.spec.js.map +1 -1
  13. package/dist/helpers/fix-constants.js +98 -0
  14. package/dist/helpers/fix-constants.js.map +1 -0
  15. package/dist/helpers/fix-handle-tempurns.js +153 -0
  16. package/dist/helpers/fix-handle-tempurns.js.map +1 -0
  17. package/dist/helpers/fix-strip-f884s.js +87 -0
  18. package/dist/helpers/fix-strip-f884s.js.map +1 -0
  19. package/dist/helpers/fix-utils.js +82 -0
  20. package/dist/helpers/fix-utils.js.map +1 -0
  21. package/dist/helpers/fix.js +178 -0
  22. package/dist/helpers/fix.js.map +1 -0
  23. package/dist/helpers/fix.spec.js +46 -0
  24. package/dist/helpers/fix.spec.js.map +1 -0
  25. package/dist/helpers/validation.js +0 -6
  26. package/dist/helpers/validation.js.map +1 -1
  27. package/dist/helpers/validation.spec.js +1 -7
  28. package/dist/helpers/validation.spec.js.map +1 -1
  29. package/dist/index.js +12 -18
  30. package/dist/index.js.map +1 -1
  31. package/dist/mongo.js +50 -89
  32. package/dist/mongo.js.map +1 -1
  33. package/dist/mongo.spec.js.draft +54 -0
  34. package/dist/mongoLog.js +16 -35
  35. package/dist/mongoLog.js.map +1 -1
  36. package/dist/utils.js +33 -35
  37. package/dist/utils.js.map +1 -1
  38. package/package.json +122 -116
  39. package/dist/helpers/format.js +0 -305
  40. package/dist/helpers/format.js.map +0 -1
  41. package/dist/helpers/format.spec.js +0 -224
  42. package/dist/helpers/format.spec.js.map +0 -1
package/dist/utils.js CHANGED
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.addRecordResponseItem = addRecordResponseItem;
7
+ exports.addRecordResponseItems = addRecordResponseItems;
7
8
  exports.createImportJobState = createImportJobState;
8
9
  exports.createRecordResponseItem = createRecordResponseItem;
9
10
  exports.logError = logError;
10
-
11
11
  var _melindaBackendCommons = require("@natlibfi/melinda-backend-commons");
12
-
13
12
  var _melindaCommons = require("@natlibfi/melinda-commons");
14
-
15
13
  var _constants = require("./constants");
16
-
17
14
  var _httpStatus = _interopRequireDefault(require("http-status"));
18
-
19
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
16
  /**
22
17
  *
23
18
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -45,31 +40,26 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
45
40
  * for the JavaScript code in this file.
46
41
  *
47
42
  */
48
- const logger = (0, _melindaBackendCommons.createLogger)();
49
43
 
44
+ const logger = (0, _melindaBackendCommons.createLogger)();
50
45
  function logError(err) {
51
46
  if (err instanceof _melindaCommons.Error) {
52
47
  logger.error(JSON.stringify(err));
53
48
  return;
54
49
  }
55
-
56
50
  if (err === 'SIGINT') {
57
51
  logger.error(err);
58
52
  return;
59
53
  }
60
-
61
54
  logger.error(err.stack === undefined ? err : err.stack);
62
55
  }
63
-
64
56
  function createImportJobState(operation, state, queryImportJobState = false) {
65
57
  if (!(state in _constants.IMPORT_JOB_STATE)) {
66
58
  throw new Error('Invalid IMPORT_JOB_STATE');
67
59
  }
68
-
69
60
  if (!(operation in _constants.OPERATIONS)) {
70
61
  throw new Error('Invalid operation');
71
62
  }
72
-
73
63
  if (queryImportJobState) {
74
64
  const importJobStateWithOperation = `importJobState.${operation}`;
75
65
  const importJobStateForQuery = {
@@ -77,12 +67,10 @@ function createImportJobState(operation, state, queryImportJobState = false) {
77
67
  };
78
68
  return importJobStateForQuery;
79
69
  }
80
-
81
70
  return {
82
71
  [operation]: state
83
72
  };
84
73
  }
85
-
86
74
  function createRecordResponseItem({
87
75
  responsePayload,
88
76
  responseStatus,
@@ -96,19 +84,22 @@ function createRecordResponseItem({
96
84
  ...recordResponseStatusAndMessage
97
85
  };
98
86
  return recordResponseItem;
99
- } // eslint-disable-next-line max-statements
100
-
87
+ }
101
88
 
89
+ // eslint-disable-next-line max-statements
102
90
  function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id) {
103
- logger.debug(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`); //const responseStatusName = httpStatus[`${responseStatus}_NAME`];
91
+ logger.debug(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`);
92
+ //const responseStatusName = httpStatus[`${responseStatus}_NAME`];
104
93
  //logger.debug(`Response status name: ${responseStatusName}`);
105
94
 
106
95
  const message = getMessageFromResponsePayload(responsePayload);
107
96
  const ids = responsePayload.ids || [];
108
- logger.debug(`Response message: ${message}`); // We map responseStatus here for a wider recordStatus and more detailed detailedRecordStatus
97
+ logger.debug(`Response message: ${message}`);
98
+
99
+ // We map responseStatus here for a wider recordStatus and more detailed detailedRecordStatus
109
100
  // recordStatus corresponds to RECORD_IMPORT_STATEs used in https://github.com/NatLibFi/melinda-record-import-commons-js
110
- // Non-http statuses
111
101
 
102
+ // Non-http statuses
112
103
  if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'SKIPPED'].includes(responseStatus)) {
113
104
  return {
114
105
  recordStatus: responseStatus,
@@ -116,7 +107,6 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
116
107
  message
117
108
  };
118
109
  }
119
-
120
110
  if (['UNKNOWN'].includes(responseStatus)) {
121
111
  return {
122
112
  recordStatus: 'ERROR',
@@ -124,9 +114,9 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
124
114
  message,
125
115
  ids
126
116
  };
127
- } // Duplicates and other CONFLICT statuses
128
-
117
+ }
129
118
 
119
+ // Duplicates and other CONFLICT statuses
130
120
  if ([_httpStatus.default.CONFLICT, 'CONFLICT'].includes(responseStatus)) {
131
121
  if (/^Duplicates in database/u.test(message)) {
132
122
  return {
@@ -136,7 +126,6 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
136
126
  ids
137
127
  };
138
128
  }
139
-
140
129
  if (/^MatchValidation for all/u.test(message)) {
141
130
  return {
142
131
  recordStatus: 'ERROR',
@@ -144,9 +133,9 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
144
133
  message,
145
134
  ids
146
135
  };
147
- } // Use ids only if there are more than one id or the id in payload does not match databaseId
148
-
136
+ }
149
137
 
138
+ // Use ids only if there are more than one id or the id in payload does not match databaseId
150
139
  if (ids.length > 1 || ids[0] !== id) {
151
140
  return {
152
141
  recordStatus: 'ERROR',
@@ -155,14 +144,12 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
155
144
  ids
156
145
  };
157
146
  }
158
-
159
147
  return {
160
148
  recordStatus: 'ERROR',
161
149
  detailedRecordStatus: 'CONFLICT',
162
150
  message
163
151
  };
164
152
  }
165
-
166
153
  if ([_httpStatus.default.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {
167
154
  if (ids.length > 1 || ids[0] !== id) {
168
155
  return {
@@ -172,42 +159,36 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
172
159
  ids
173
160
  };
174
161
  }
175
-
176
162
  return {
177
163
  recordStatus: 'INVALID',
178
164
  detailedRecordStatus: 'UNPROCESSABLE_ENTITY',
179
165
  message
180
166
  };
181
167
  }
182
-
183
168
  if ([_httpStatus.default.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {
184
169
  return {
185
170
  recordStatus: 'ERROR',
186
171
  detailedRecordStatus: 'NOT_FOUND',
187
172
  message
188
173
  };
189
- } // Otherwise
190
-
174
+ }
191
175
 
176
+ // Otherwise
192
177
  return {
193
178
  recordStatus: 'ERROR',
194
179
  detailedRecordStatus: responseStatus,
195
180
  message
196
181
  };
197
182
  }
198
-
199
183
  function getMessageFromResponsePayload(responsePayload) {
200
184
  if (responsePayload.message) {
201
185
  return responsePayload.message;
202
186
  }
203
-
204
187
  if (typeof responsePayload === 'string' || responsePayload instanceof String) {
205
188
  return responsePayload;
206
189
  }
207
-
208
190
  return '';
209
191
  }
210
-
211
192
  async function addRecordResponseItem({
212
193
  recordResponseItem,
213
194
  correlationId,
@@ -220,4 +201,21 @@ async function addRecordResponseItem({
220
201
  });
221
202
  return true;
222
203
  }
204
+
205
+ // Use addRecordResponseItems to add several recordResponseItems in one mongo operation to avoid writeconflicts
206
+ async function addRecordResponseItems({
207
+ recordResponseItems,
208
+ correlationId,
209
+ mongoOperator
210
+ }) {
211
+ if (!Array.isArray(recordResponseItems)) {
212
+ throw new Error('RecordResponseItems is not an array!');
213
+ }
214
+ await mongoOperator.pushMessages({
215
+ correlationId,
216
+ messages: recordResponseItems,
217
+ messageField: 'records'
218
+ });
219
+ return true;
220
+ }
223
221
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["logger","createLogger","logError","err","ApiError","error","JSON","stringify","stack","undefined","createImportJobState","operation","state","queryImportJobState","IMPORT_JOB_STATE","Error","OPERATIONS","importJobStateWithOperation","importJobStateForQuery","createRecordResponseItem","responsePayload","responseStatus","recordMetadata","id","recordResponseStatusAndMessage","getRecordResponseStatusAndMessage","recordResponseItem","databaseId","debug","message","getMessageFromResponsePayload","ids","includes","recordStatus","detailedRecordStatus","httpStatus","CONFLICT","test","length","UNPROCESSABLE_ENTITY","NOT_FOUND","String","addRecordResponseItem","correlationId","mongoOperator","pushMessages","messages","messageField"],"sources":["../src/utils.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 {createLogger} from '@natlibfi/melinda-backend-commons';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {IMPORT_JOB_STATE, OPERATIONS} from './constants';\nimport httpStatus from 'http-status';\n\nconst logger = createLogger();\n\nexport function logError(err) {\n if (err instanceof ApiError) {\n logger.error(JSON.stringify(err));\n return;\n }\n\n if (err === 'SIGINT') {\n logger.error(err);\n return;\n }\n\n logger.error(err.stack === undefined ? err : err.stack);\n}\n\nexport function createImportJobState(operation, state, queryImportJobState = false) {\n if (!(state in IMPORT_JOB_STATE)) {\n throw new Error('Invalid IMPORT_JOB_STATE');\n }\n\n if (!(operation in OPERATIONS)) {\n throw new Error('Invalid operation');\n }\n\n if (queryImportJobState) {\n const importJobStateWithOperation = `importJobState.${operation}`;\n const importJobStateForQuery = {[importJobStateWithOperation]: state};\n\n return importJobStateForQuery;\n }\n\n return {[operation]: state};\n}\n\nexport function createRecordResponseItem({responsePayload, responseStatus, recordMetadata, id}) {\n const recordResponseStatusAndMessage = getRecordResponseStatusAndMessage(responseStatus, responsePayload, id);\n const recordResponseItem = {\n databaseId: id || '000000000',\n recordMetadata: responsePayload.recordMetadata || recordMetadata || undefined,\n ...recordResponseStatusAndMessage\n };\n return recordResponseItem;\n}\n\n// eslint-disable-next-line max-statements\nfunction getRecordResponseStatusAndMessage(responseStatus, responsePayload, id) {\n\n logger.debug(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`);\n //const responseStatusName = httpStatus[`${responseStatus}_NAME`];\n //logger.debug(`Response status name: ${responseStatusName}`);\n\n const message = getMessageFromResponsePayload(responsePayload);\n const ids = responsePayload.ids || [];\n\n logger.debug(`Response message: ${message}`);\n\n // We map responseStatus here for a wider recordStatus and more detailed detailedRecordStatus\n // recordStatus corresponds to RECORD_IMPORT_STATEs used in https://github.com/NatLibFi/melinda-record-import-commons-js\n\n // Non-http statuses\n if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'SKIPPED'].includes(responseStatus)) {\n return {recordStatus: responseStatus, detailedRecordStatus: responseStatus, message};\n }\n\n if (['UNKNOWN'].includes(responseStatus)) {\n return {recordStatus: 'ERROR', detailedRecordStatus: responseStatus, message, ids};\n }\n\n // Duplicates and other CONFLICT statuses\n if ([httpStatus.CONFLICT, 'CONFLICT'].includes(responseStatus)) {\n if ((/^Duplicates in database/u).test(message)) {\n return {recordStatus: 'DUPLICATE', detailedRecordStatus: 'DUPLICATE', message, ids};\n }\n if ((/^MatchValidation for all/u).test(message)) {\n return {recordStatus: 'ERROR', detailedRecordStatus: 'CONFLICT', message, ids};\n }\n\n // Use ids only if there are more than one id or the id in payload does not match databaseId\n if (ids.length > 1 || ids[0] !== id) {\n return {recordStatus: 'ERROR', detailedRecordStatus: 'CONFLICT', message, ids};\n }\n return {recordStatus: 'ERROR', detailedRecordStatus: 'CONFLICT', message};\n }\n\n if ([httpStatus.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {\n if (ids.length > 1 || ids[0] !== id) {\n return {recordStatus: 'INVALID', detailedRecordStatus: 'UNPROCESSABLE_ENTITY', message, ids};\n }\n return {recordStatus: 'INVALID', detailedRecordStatus: 'UNPROCESSABLE_ENTITY', message};\n }\n\n if ([httpStatus.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {\n return {recordStatus: 'ERROR', detailedRecordStatus: 'NOT_FOUND', message};\n }\n\n // Otherwise\n return {recordStatus: 'ERROR', detailedRecordStatus: responseStatus, message};\n}\n\nfunction getMessageFromResponsePayload(responsePayload) {\n if (responsePayload.message) {\n return responsePayload.message;\n }\n if (typeof responsePayload === 'string' || responsePayload instanceof String) {\n return responsePayload;\n }\n return '';\n}\n\nexport async function addRecordResponseItem({recordResponseItem, correlationId, mongoOperator}) {\n await mongoOperator.pushMessages({correlationId, messages: [recordResponseItem], messageField: 'records'});\n return true;\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;AAOA,MAAMA,MAAM,GAAG,IAAAC,mCAAA,GAAf;;AAEO,SAASC,QAAT,CAAkBC,GAAlB,EAAuB;EAC5B,IAAIA,GAAG,YAAYC,qBAAnB,EAA6B;IAC3BJ,MAAM,CAACK,KAAP,CAAaC,IAAI,CAACC,SAAL,CAAeJ,GAAf,CAAb;IACA;EACD;;EAED,IAAIA,GAAG,KAAK,QAAZ,EAAsB;IACpBH,MAAM,CAACK,KAAP,CAAaF,GAAb;IACA;EACD;;EAEDH,MAAM,CAACK,KAAP,CAAaF,GAAG,CAACK,KAAJ,KAAcC,SAAd,GAA0BN,GAA1B,GAAgCA,GAAG,CAACK,KAAjD;AACD;;AAEM,SAASE,oBAAT,CAA8BC,SAA9B,EAAyCC,KAAzC,EAAgDC,mBAAmB,GAAG,KAAtE,EAA6E;EAClF,IAAI,EAAED,KAAK,IAAIE,2BAAX,CAAJ,EAAkC;IAChC,MAAM,IAAIC,KAAJ,CAAU,0BAAV,CAAN;EAC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,GAAG,CAAC,CAAD,CAAH,KAAWR,EAAjC,EAAqC;MACnC,OAAO;QAACU,YAAY,EAAE,SAAf;QAA0BC,oBAAoB,EAAE,sBAAhD;QAAwEL,OAAxE;QAAiFE;MAAjF,CAAP;IACD;;IACD,OAAO;MAACE,YAAY,EAAE,SAAf;MAA0BC,oBAAoB,EAAE,sBAAhD;MAAwEL;IAAxE,CAAP;EACD;;EAED,IAAI,CAACM,mBAAA,CAAWK,SAAZ,EAAuB,WAAvB,EAAoCR,QAApC,CAA6CX,cAA7C,CAAJ,EAAkE;IAChE,OAAO;MAACY,YAAY,EAAE,OAAf;MAAwBC,oBAAoB,EAAE,WAA9C;MAA2DL;IAA3D,CAAP;EACD,CAhD6E,CAkD9E;;;EACA,OAAO;IAACI,YAAY,EAAE,OAAf;IAAwBC,oBAAoB,EAAEb,cAA9C;IAA8DQ;EAA9D,CAAP;AACD;;AAED,SAASC,6BAAT,CAAuCV,eAAvC,EAAwD;EACtD,IAAIA,eAAe,CAACS,OAApB,EAA6B;IAC3B,OAAOT,eAAe,CAACS,OAAvB;EACD;;EACD,IAAI,OAAOT,eAAP,KAA2B,QAA3B,IAAuCA,eAAe,YAAYqB,MAAtE,EAA8E;IAC5E,OAAOrB,eAAP;EACD;;EACD,OAAO,EAAP;AACD;;AAEM,eAAesB,qBAAf,CAAqC;EAAChB,kBAAD;EAAqBiB,aAArB;EAAoCC;AAApC,CAArC,EAAyF;EAC9F,MAAMA,aAAa,CAACC,YAAd,CAA2B;IAACF,aAAD;IAAgBG,QAAQ,EAAE,CAACpB,kBAAD,CAA1B;IAAgDqB,YAAY,EAAE;EAA9D,CAA3B,CAAN;EACA,OAAO,IAAP;AACD"}
1
+ {"version":3,"file":"utils.js","names":["logger","createLogger","logError","err","ApiError","error","JSON","stringify","stack","undefined","createImportJobState","operation","state","queryImportJobState","IMPORT_JOB_STATE","Error","OPERATIONS","importJobStateWithOperation","importJobStateForQuery","createRecordResponseItem","responsePayload","responseStatus","recordMetadata","id","recordResponseStatusAndMessage","getRecordResponseStatusAndMessage","recordResponseItem","databaseId","debug","message","getMessageFromResponsePayload","ids","includes","recordStatus","detailedRecordStatus","httpStatus","CONFLICT","test","length","UNPROCESSABLE_ENTITY","NOT_FOUND","String","addRecordResponseItem","correlationId","mongoOperator","pushMessages","messages","messageField","addRecordResponseItems","recordResponseItems","Array","isArray"],"sources":["../src/utils.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 {createLogger} from '@natlibfi/melinda-backend-commons';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {IMPORT_JOB_STATE, OPERATIONS} from './constants';\nimport httpStatus from 'http-status';\n\nconst logger = createLogger();\n\nexport function logError(err) {\n if (err instanceof ApiError) {\n logger.error(JSON.stringify(err));\n return;\n }\n\n if (err === 'SIGINT') {\n logger.error(err);\n return;\n }\n\n logger.error(err.stack === undefined ? err : err.stack);\n}\n\nexport function createImportJobState(operation, state, queryImportJobState = false) {\n if (!(state in IMPORT_JOB_STATE)) {\n throw new Error('Invalid IMPORT_JOB_STATE');\n }\n\n if (!(operation in OPERATIONS)) {\n throw new Error('Invalid operation');\n }\n\n if (queryImportJobState) {\n const importJobStateWithOperation = `importJobState.${operation}`;\n const importJobStateForQuery = {[importJobStateWithOperation]: state};\n\n return importJobStateForQuery;\n }\n\n return {[operation]: state};\n}\n\nexport function createRecordResponseItem({responsePayload, responseStatus, recordMetadata, id}) {\n const recordResponseStatusAndMessage = getRecordResponseStatusAndMessage(responseStatus, responsePayload, id);\n const recordResponseItem = {\n databaseId: id || '000000000',\n recordMetadata: responsePayload.recordMetadata || recordMetadata || undefined,\n ...recordResponseStatusAndMessage\n };\n return recordResponseItem;\n}\n\n// eslint-disable-next-line max-statements\nfunction getRecordResponseStatusAndMessage(responseStatus, responsePayload, id) {\n\n logger.debug(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`);\n //const responseStatusName = httpStatus[`${responseStatus}_NAME`];\n //logger.debug(`Response status name: ${responseStatusName}`);\n\n const message = getMessageFromResponsePayload(responsePayload);\n const ids = responsePayload.ids || [];\n\n logger.debug(`Response message: ${message}`);\n\n // We map responseStatus here for a wider recordStatus and more detailed detailedRecordStatus\n // recordStatus corresponds to RECORD_IMPORT_STATEs used in https://github.com/NatLibFi/melinda-record-import-commons-js\n\n // Non-http statuses\n if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'SKIPPED'].includes(responseStatus)) {\n return {recordStatus: responseStatus, detailedRecordStatus: responseStatus, message};\n }\n\n if (['UNKNOWN'].includes(responseStatus)) {\n return {recordStatus: 'ERROR', detailedRecordStatus: responseStatus, message, ids};\n }\n\n // Duplicates and other CONFLICT statuses\n if ([httpStatus.CONFLICT, 'CONFLICT'].includes(responseStatus)) {\n if ((/^Duplicates in database/u).test(message)) {\n return {recordStatus: 'DUPLICATE', detailedRecordStatus: 'DUPLICATE', message, ids};\n }\n if ((/^MatchValidation for all/u).test(message)) {\n return {recordStatus: 'ERROR', detailedRecordStatus: 'CONFLICT', message, ids};\n }\n\n // Use ids only if there are more than one id or the id in payload does not match databaseId\n if (ids.length > 1 || ids[0] !== id) {\n return {recordStatus: 'ERROR', detailedRecordStatus: 'CONFLICT', message, ids};\n }\n return {recordStatus: 'ERROR', detailedRecordStatus: 'CONFLICT', message};\n }\n\n if ([httpStatus.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {\n if (ids.length > 1 || ids[0] !== id) {\n return {recordStatus: 'INVALID', detailedRecordStatus: 'UNPROCESSABLE_ENTITY', message, ids};\n }\n return {recordStatus: 'INVALID', detailedRecordStatus: 'UNPROCESSABLE_ENTITY', message};\n }\n\n if ([httpStatus.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {\n return {recordStatus: 'ERROR', detailedRecordStatus: 'NOT_FOUND', message};\n }\n\n // Otherwise\n return {recordStatus: 'ERROR', detailedRecordStatus: responseStatus, message};\n}\n\nfunction getMessageFromResponsePayload(responsePayload) {\n if (responsePayload.message) {\n return responsePayload.message;\n }\n if (typeof responsePayload === 'string' || responsePayload instanceof String) {\n return responsePayload;\n }\n return '';\n}\n\nexport async function addRecordResponseItem({recordResponseItem, correlationId, mongoOperator}) {\n await mongoOperator.pushMessages({correlationId, messages: [recordResponseItem], messageField: 'records'});\n return true;\n}\n\n// Use addRecordResponseItems to add several recordResponseItems in one mongo operation to avoid writeconflicts\nexport async function addRecordResponseItems({recordResponseItems, correlationId, mongoOperator}) {\n if (!Array.isArray(recordResponseItems)) {\n throw new Error('RecordResponseItems is not an array!');\n }\n await mongoOperator.pushMessages({correlationId, messages: recordResponseItems, messageField: 'records'});\n return true;\n}\n\n"],"mappings":";;;;;;;;;;AA4BA;AACA;AACA;AACA;AAAqC;AA/BrC;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;;AAOA,MAAMA,MAAM,GAAG,IAAAC,mCAAY,GAAE;AAEtB,SAASC,QAAQ,CAACC,GAAG,EAAE;EAC5B,IAAIA,GAAG,YAAYC,qBAAQ,EAAE;IAC3BJ,MAAM,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E,CAACpB,kBAAkB,CAAC;IAAEqB,YAAY,EAAE;EAAS,CAAC,CAAC;EAC1G,OAAO,IAAI;AACb;;AAEA;AACO,eAAeC,sBAAsB,CAAC;EAACC,mBAAmB;EAAEN,aAAa;EAAEC;AAAa,CAAC,EAAE;EAChG,IAAI,CAACM,KAAK,CAACC,OAAO,CAACF,mBAAmB,CAAC,EAAE;IACvC,MAAM,IAAIlC,KAAK,CAAC,sCAAsC,CAAC;EACzD;EACA,MAAM6B,aAAa,CAACC,YAAY,CAAC;IAACF,aAAa;IAAEG,QAAQ,EAAEG,mBAAmB;IAAEF,YAAY,EAAE;EAAS,CAAC,CAAC;EACzG,OAAO,IAAI;AACb"}
package/package.json CHANGED
@@ -1,118 +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.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",
32
- "dev": "NODE_ENV=development cross-env DEBUG=1 nodemon",
33
- "build": "babel src --source-maps --copy-files --delete-dir-on-start --out-dir=dist"
34
- },
35
- "dependencies": {
36
- "@natlibfi/marc-record": "^7.2.0-alpha.1",
37
- "@natlibfi/marc-record-serializers": "^8.1.0",
38
- "@natlibfi/marc-record-validate": "^7.0.1",
39
- "@natlibfi/marc-record-validators-melinda": "^9.0.9",
40
- "@natlibfi/melinda-backend-commons": "^2.0.5",
41
- "@natlibfi/melinda-commons": "^12.0.3",
42
- "amqplib": ">=0.8.0 <1.0.0",
43
- "debug": "^4.3.4",
44
- "http-status": "^1.5.2",
45
- "moment": "^2.29.3",
46
- "mongo-sanitize": "^1.1.0",
47
- "mongodb": "^4.6.0"
48
- },
49
- "devDependencies": {
50
- "@babel/cli": "^7.18.10",
51
- "@babel/core": "^7.18.13",
52
- "@babel/eslint-parser": "^7.18.9",
53
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
54
- "@babel/preset-env": "^7.18.10",
55
- "@natlibfi/eslint-config-melinda-backend": "^2.0.0",
56
- "@natlibfi/fixura": "^2.2.1",
57
- "babel-plugin-dynamic-import-node": "^2.3.3",
58
- "babel-plugin-istanbul": "^6.1.1",
59
- "babel-plugin-rewire": "^1.2.0",
60
- "chai": "^4.3.6",
61
- "cross-env": "^7.0.3",
62
- "eslint": "^8.23.0",
63
- "mocha": "^10.0.0",
64
- "nodemon": "^2.0.19",
65
- "nyc": "^15.1.0"
66
- },
67
- "eslintConfig": {
68
- "extends": "@natlibfi/melinda-backend"
69
- },
70
- "babel": {
71
- "presets": [
72
- [
73
- "@babel/preset-env",
74
- {
75
- "targets": "maintained node versions"
76
- }
77
- ]
78
- ],
79
- "plugins": [
80
- "@babel/plugin-syntax-dynamic-import",
81
- "dynamic-import-node"
82
- ],
83
- "env": {
84
- "test": {
85
- "plugins": [
86
- "istanbul",
87
- "rewire"
88
- ]
89
- }
90
- }
91
- },
92
- "nyc": {
93
- "exclude": [
94
- "**/*.spec.js"
95
- ],
96
- "reporter": [
97
- "lcov",
98
- "html"
99
- ],
100
- "require": [
101
- "@babel/register"
102
- ],
103
- "sourceMap": false,
104
- "instrument": false,
105
- "lines": 80,
106
- "statements": 80,
107
- "functions": 80,
108
- "branches": 80
109
- },
110
- "nodemonConfig": {
111
- "exec": "npm run test:dev",
112
- "watch": [
113
- "src/*"
114
- ],
115
- "ext": "js",
116
- "delay": 2.5
117
- }
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.10",
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.1",
44
+ "@natlibfi/marc-record-validate": "^7.0.2",
45
+ "@natlibfi/marc-record-validators-melinda": "^9.0.13",
46
+ "@natlibfi/melinda-backend-commons": "^2.1.0",
47
+ "@natlibfi/melinda-commons": "^12.0.5",
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.19.6",
58
+ "@babel/eslint-parser": "^7.19.1",
59
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
60
+ "@babel/preset-env": "^7.19.4",
61
+ "@natlibfi/eslint-config-melinda-backend": "^2.0.1",
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.6",
67
+ "cross-env": "^7.0.3",
68
+ "eslint": "^8.25.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
+ }
118
124
  }