@natlibfi/melinda-rest-api-commons 2.3.1-alpha.2 → 2.3.1-alpha.4

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/dist/utils.js CHANGED
@@ -104,21 +104,23 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
104
104
  const responseStatusName = _httpStatus.default[`${responseStatus}_NAME`];
105
105
  logger.debug(`Response status name: ${responseStatusName}`);
106
106
  const message = getMessageFromResponsePayload(responsePayload);
107
- const {
108
- ids
109
- } = responsePayload || [];
110
- logger.debug(`Response message: ${message}`); // Non-http statuses
107
+ const ids = responsePayload.ids || [];
108
+ logger.debug(`Response message: ${message}`); // We map responseStatus here for a wider recordStatus and more detailed detailedRecordStatus
109
+ // recordStatus corresponds to RECORD_IMPORT_STATEs used in https://github.com/NatLibFi/melinda-record-import-commons-js
110
+ // Non-http statuses
111
111
 
112
112
  if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'SKIPPED'].includes(responseStatus)) {
113
113
  return {
114
114
  recordStatus: responseStatus,
115
+ detailedRecordStatus: responseStatus,
115
116
  message
116
117
  };
117
118
  }
118
119
 
119
120
  if (['UNKNOWN'].includes(responseStatus)) {
120
121
  return {
121
- recordStatus: responseStatus,
122
+ recordStatus: 'ERROR',
123
+ detailedRecordStatus: responseStatus,
122
124
  message,
123
125
  ids
124
126
  };
@@ -129,6 +131,7 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
129
131
  if (/^Duplicates in database/u.test(message)) {
130
132
  return {
131
133
  recordStatus: 'DUPLICATE',
134
+ detailedRecordStatus: 'DUPLICATE',
132
135
  message,
133
136
  ids
134
137
  };
@@ -136,7 +139,8 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
136
139
 
137
140
  if (/^MatchValidation for all/u.test(message)) {
138
141
  return {
139
- recordStatus: 'CONFLICT',
142
+ recordStatus: 'ERROR',
143
+ detailedRecordStatus: 'CONFLICT',
140
144
  message,
141
145
  ids
142
146
  };
@@ -145,14 +149,16 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
145
149
 
146
150
  if (ids.length > 1 || ids[0] !== id) {
147
151
  return {
148
- recordStatus: 'CONFLICT',
152
+ recordStatus: 'ERROR',
153
+ detailedRecordStatus: 'CONFLICT',
149
154
  message,
150
155
  ids
151
156
  };
152
157
  }
153
158
 
154
159
  return {
155
- recordStatus: 'CONFLICT',
160
+ recordStatus: 'ERROR',
161
+ detailedRecordStatus: 'CONFLICT',
156
162
  message
157
163
  };
158
164
  }
@@ -160,21 +166,24 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
160
166
  if ([_httpStatus.default.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {
161
167
  if (ids.length > 1 || ids[0] !== id) {
162
168
  return {
163
- recordStatus: 'UNPROCESSABLE_ENTITY',
169
+ recordStatus: 'INVALID',
170
+ detailedRecordStatus: 'UNPROCESSABLE_ENTITY',
164
171
  message,
165
172
  ids
166
173
  };
167
174
  }
168
175
 
169
176
  return {
170
- recordStatus: 'UNPROCESSABLE_ENTITY',
177
+ recordStatus: 'INVALID',
178
+ detailedRecordStatus: 'UNPROCESSABLE_ENTITY',
171
179
  message
172
180
  };
173
181
  }
174
182
 
175
183
  if ([_httpStatus.default.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {
176
184
  return {
177
- recordStatus: 'NOT_FOUND',
185
+ recordStatus: 'ERROR',
186
+ detailedRecordStatus: 'NOT_FOUND',
178
187
  message
179
188
  };
180
189
  } // Otherwise
@@ -182,6 +191,7 @@ function getRecordResponseStatusAndMessage(responseStatus, responsePayload, id)
182
191
 
183
192
  return {
184
193
  recordStatus: 'ERROR',
194
+ detailedRecordStatus: responseStatus,
185
195
  message
186
196
  };
187
197
  }
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","responseStatusName","httpStatus","message","getMessageFromResponsePayload","ids","includes","recordStatus","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 || [];\n\n logger.debug(`Response message: ${message}`);\n\n // Non-http statuses\n if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'SKIPPED'].includes(responseStatus)) {\n return {recordStatus: responseStatus, message};\n }\n\n if (['UNKNOWN'].includes(responseStatus)) {\n return {recordStatus: 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', message, ids};\n }\n if ((/^MatchValidation for all/u).test(message)) {\n return {recordStatus: '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: 'CONFLICT', message, ids};\n }\n return {recordStatus: 'CONFLICT', message};\n }\n\n if ([httpStatus.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {\n if (ids.length > 1 || ids[0] !== id) {\n return {recordStatus: 'UNPROCESSABLE_ENTITY', message, ids};\n }\n return {recordStatus: 'UNPROCESSABLE_ENTITY', message};\n }\n\n if ([httpStatus.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {\n return {recordStatus: 'NOT_FOUND', message};\n }\n\n // Otherwise\n return {recordStatus: 'ERROR', 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,IAAI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AY,EAAE,sBAAf;QAAuCJ,OAAvC;QAAgDE;MAAhD,CAAP;IACD;;IACD,OAAO;MAACE,YAAY,EAAE,sBAAf;MAAuCJ;IAAvC,CAAP;EACD;;EAED,IAAI,CAACD,mBAAA,CAAWU,SAAZ,EAAuB,WAAvB,EAAoCN,QAApC,CAA6Cb,cAA7C,CAAJ,EAAkE;IAChE,OAAO;MAACc,YAAY,EAAE,WAAf;MAA4BJ;IAA5B,CAAP;EACD,CA7C6E,CA+C9E;;;EACA,OAAO;IAACI,YAAY,EAAE,OAAf;IAAwBJ;EAAxB,CAAP;AACD;;AAED,SAASC,6BAAT,CAAuCZ,eAAvC,EAAwD;EACtD,IAAIA,eAAe,CAACW,OAApB,EAA6B;IAC3B,OAAOX,eAAe,CAACW,OAAvB;EACD;;EACD,IAAI,OAAOX,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","responseStatusName","httpStatus","message","getMessageFromResponsePayload","ids","includes","recordStatus","detailedRecordStatus","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,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url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
15
15
  },
16
16
  "license": "AGPL-3.0+",
17
- "version": "2.3.1-alpha.2",
18
- "main": "dist/index.js",
17
+ "version": "2.3.1-alpha.4",
18
+ "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=14"
21
21
  },