@natlibfi/melinda-rest-api-commons 2.2.0-alpha.7 → 2.2.0-alpha.8

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/index.js CHANGED
@@ -11,8 +11,16 @@ var _exportNames = {
11
11
  format: true,
12
12
  logError: true,
13
13
  createImportJobState: true,
14
- createImportJobStateForQuery: true
14
+ createImportJobStateForQuery: true,
15
+ createRecordResponseItem: true,
16
+ addRecordResponseItem: true
15
17
  };
18
+ Object.defineProperty(exports, "addRecordResponseItem", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _utils.addRecordResponseItem;
22
+ }
23
+ });
16
24
  Object.defineProperty(exports, "amqpFactory", {
17
25
  enumerable: true,
18
26
  get: function () {
@@ -37,6 +45,12 @@ Object.defineProperty(exports, "createImportJobStateForQuery", {
37
45
  return _utils.createImportJobStateForQuery;
38
46
  }
39
47
  });
48
+ Object.defineProperty(exports, "createRecordResponseItem", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _utils.createRecordResponseItem;
52
+ }
53
+ });
40
54
  exports.format = void 0;
41
55
  Object.defineProperty(exports, "logError", {
42
56
  enumerable: true,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;;;AACA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","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 amqpFactory from './amqp';\nimport conversions from './helpers/conversion';\nimport validations from './helpers/validation';\nimport * as format from './helpers/format';\nimport {logError, createImportJobState, createImportJobStateForQuery} from './utils';\n\nexport {mongoFactory, amqpFactory, conversions, validations, format, logError, createImportJobState, createImportJobStateForQuery};\nexport * from './constants';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;;;AACA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","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 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, amqpFactory, conversions, validations, format, logError, createImportJobState, createImportJobStateForQuery, createRecordResponseItem, addRecordResponseItem};\nexport * from './constants';\n"],"file":"index.js"}
package/dist/utils.js CHANGED
@@ -3,7 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.addRecordResponseItem = addRecordResponseItem;
6
7
  exports.createImportJobState = createImportJobState;
8
+ exports.createRecordResponseItem = createRecordResponseItem;
9
+ exports.getRecordResponseStatus = getRecordResponseStatus;
7
10
  exports.logError = logError;
8
11
 
9
12
  var _melindaBackendCommons = require("@natlibfi/melinda-backend-commons");
@@ -12,6 +15,10 @@ var _melindaCommons = require("@natlibfi/melinda-commons");
12
15
 
13
16
  var _constants = require("./constants");
14
17
 
18
+ var _httpStatus = _interopRequireDefault(require("http-status"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
15
22
  /**
16
23
  *
17
24
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -76,4 +83,80 @@ function createImportJobState(operation, state, queryImportJobState = false) {
76
83
  [operation]: state
77
84
  };
78
85
  }
86
+
87
+ function createRecordResponseItem({
88
+ responsePayload,
89
+ responseStatus,
90
+ recordMetadata,
91
+ id
92
+ }) {
93
+ const recordResponseStatus = getRecordResponseStatus(responseStatus, responsePayload);
94
+ const recordResponseItem = {
95
+ melindaId: id || '000000000',
96
+ recordMetadata: recordMetadata || undefined,
97
+ ...recordResponseStatus
98
+ };
99
+ return recordResponseItem;
100
+ }
101
+
102
+ function getRecordResponseStatus(responseStatus, responsePayload) {
103
+ logger.verbose(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`);
104
+ const responseStatusName = _httpStatus.default[`${responseStatus}_NAME`];
105
+ logger.verbose(`Response status name: ${responseStatusName}`); // Non-http statuses
106
+
107
+ if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'UNKNOWN'].includes(responseStatus)) {
108
+ return {
109
+ status: responseStatus,
110
+ message: responsePayload
111
+ };
112
+ } // Duplicates and other conflicts
113
+
114
+
115
+ if ([_httpStatus.default.CONFLICT, 'CONFLICT'].includes(responseStatus)) {
116
+ if (/^Duplicates in database/u.test(responsePayload.message)) {
117
+ return {
118
+ status: 'DUPLICATE',
119
+ message: responsePayload.message,
120
+ duplicateIds: responsePayload.ids
121
+ };
122
+ }
123
+
124
+ return {
125
+ status: 'CONFLICT',
126
+ message: responsePayload.message
127
+ };
128
+ }
129
+
130
+ if ([_httpStatus.default.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {
131
+ return {
132
+ status: 'UNPROCESSABLE_ENTITY',
133
+ message: responsePayload
134
+ };
135
+ }
136
+
137
+ if ([_httpStatus.default.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {
138
+ return {
139
+ status: 'NOT_FOUND',
140
+ message: responsePayload
141
+ };
142
+ }
143
+
144
+ return {
145
+ status: 'ERROR',
146
+ message: responsePayload
147
+ };
148
+ }
149
+
150
+ async function addRecordResponseItem({
151
+ recordResponseItem,
152
+ correlationId,
153
+ mongoOperator
154
+ }) {
155
+ await mongoOperator.pushMessages({
156
+ correlationId,
157
+ messages: [recordResponseItem],
158
+ messageField: 'records'
159
+ });
160
+ return true;
161
+ }
79
162
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["logger","logError","err","ApiError","error","JSON","stringify","stack","undefined","createImportJobState","operation","state","queryImportJobState","IMPORT_JOB_STATE","Error","OPERATIONS","importJobStateWithOperation","importJobStateForQuery"],"mappings":";;;;;;;;AA4BA;;AACA;;AACA;;AA9BA;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;AAMA,MAAMA,MAAM,GAAG,0CAAf;;AAEO,SAASC,QAAT,CAAkBC,GAAlB,EAAuB;AAC5B,MAAIA,GAAG,YAAYC,qBAAnB,EAA6B;AAC3BH,IAAAA,MAAM,CAACI,KAAP,CAAaC,IAAI,CAACC,SAAL,CAAeJ,GAAf,CAAb;AACA;AACD;;AAED,MAAIA,GAAG,KAAK,QAAZ,EAAsB;AACpBF,IAAAA,MAAM,CAACI,KAAP,CAAaF,GAAb;AACA;AACD;;AAEDF,EAAAA,MAAM,CAACI,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;AAClF,MAAI,EAAED,KAAK,IAAIE,2BAAX,CAAJ,EAAkC;AAChC,UAAM,IAAIC,KAAJ,CAAU,0BAAV,CAAN;AACD;;AAED,MAAI,EAAEJ,SAAS,IAAIK,qBAAf,CAAJ,EAAgC;AAC9B,UAAM,IAAID,KAAJ,CAAU,mBAAV,CAAN;AACD;;AAED,MAAIF,mBAAJ,EAAyB;AACvB,UAAMI,2BAA2B,GAAI,kBAAiBN,SAAU,EAAhE;AACA,UAAMO,sBAAsB,GAAG;AAAC,OAACD,2BAAD,GAA+BL;AAAhC,KAA/B;AAEA,WAAOM,sBAAP;AACD;;AAED,SAAO;AAAC,KAACP,SAAD,GAAaC;AAAd,GAAP;AACD","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';\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"],"file":"utils.js"}
1
+ {"version":3,"sources":["../src/utils.js"],"names":["logger","logError","err","ApiError","error","JSON","stringify","stack","undefined","createImportJobState","operation","state","queryImportJobState","IMPORT_JOB_STATE","Error","OPERATIONS","importJobStateWithOperation","importJobStateForQuery","createRecordResponseItem","responsePayload","responseStatus","recordMetadata","id","recordResponseStatus","getRecordResponseStatus","recordResponseItem","melindaId","verbose","responseStatusName","httpStatus","includes","status","message","CONFLICT","test","duplicateIds","ids","UNPROCESSABLE_ENTITY","NOT_FOUND","addRecordResponseItem","correlationId","mongoOperator","pushMessages","messages","messageField"],"mappings":"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","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 recordResponseStatus = getRecordResponseStatus(responseStatus, responsePayload);\n const recordResponseItem = {\n melindaId: id || '000000000',\n recordMetadata: recordMetadata || undefined,\n ...recordResponseStatus\n };\n return recordResponseItem;\n}\n\nexport function getRecordResponseStatus(responseStatus, responsePayload) {\n\n logger.verbose(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`);\n const responseStatusName = httpStatus[`${responseStatus}_NAME`];\n logger.verbose(`Response status name: ${responseStatusName}`);\n\n // Non-http statuses\n if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'UNKNOWN'].includes(responseStatus)) {\n return {status: responseStatus, message: responsePayload};\n }\n\n // Duplicates and other conflicts\n if ([httpStatus.CONFLICT, 'CONFLICT'].includes(responseStatus)) {\n if ((/^Duplicates in database/u).test(responsePayload.message)) {\n return {status: 'DUPLICATE', message: responsePayload.message, duplicateIds: responsePayload.ids};\n }\n return {status: 'CONFLICT', message: responsePayload.message};\n }\n\n if ([httpStatus.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {\n return {status: 'UNPROCESSABLE_ENTITY', message: responsePayload};\n }\n\n if ([httpStatus.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {\n return {status: 'NOT_FOUND', message: responsePayload};\n }\n\n return {status: 'ERROR', message: responsePayload};\n}\n\nexport async function addRecordResponseItem({recordResponseItem, correlationId, mongoOperator}) {\n await mongoOperator.pushMessages({correlationId, messages: [recordResponseItem], messageField: 'records'});\n return true;\n}\n\n"],"file":"utils.js"}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
15
15
  },
16
16
  "license": "AGPL-3.0+",
17
- "version": "2.2.0-alpha.7",
17
+ "version": "2.2.0-alpha.8",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=14"