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

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
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addRecordResponseItem = addRecordResponseItem;
7
7
  exports.createImportJobState = createImportJobState;
8
8
  exports.createRecordResponseItem = createRecordResponseItem;
9
- exports.getRecordResponseStatus = getRecordResponseStatus;
10
9
  exports.logError = logError;
11
10
 
12
11
  var _melindaBackendCommons = require("@natlibfi/melinda-backend-commons");
@@ -90,63 +89,114 @@ function createRecordResponseItem({
90
89
  recordMetadata,
91
90
  id
92
91
  }) {
93
- const recordResponseStatus = getRecordResponseStatus(responseStatus, responsePayload);
92
+ const recordResponseStatusAndMessage = getRecordResponseStatusAndMessage(responseStatus, responsePayload);
94
93
  const recordResponseItem = {
95
- melindaId: id || '000000000',
96
- recordMetadata: recordMetadata || undefined,
97
- ...recordResponseStatus
94
+ databaseId: id || '000000000',
95
+ recordMetadata: responsePayload.recordMetadata || recordMetadata || undefined,
96
+ ...recordResponseStatusAndMessage
98
97
  };
99
98
  return recordResponseItem;
100
- }
99
+ } // eslint-disable-next-line max-statements
100
+
101
101
 
102
- function getRecordResponseStatus(responseStatus, responsePayload) {
103
- logger.verbose(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`);
102
+ function getRecordResponseStatusAndMessage(responseStatus, responsePayload) {
103
+ logger.debug(`Response status: ${responseStatus} responsePayload: ${JSON.stringify(responsePayload)}`);
104
104
  const responseStatusName = _httpStatus.default[`${responseStatus}_NAME`];
105
- logger.verbose(`Response status name: ${responseStatusName}`); // Non-http statuses
105
+ logger.debug(`Response status name: ${responseStatusName}`);
106
+ const message = getMessageFromResponsePayload(responsePayload);
107
+ logger.debug(`Response message: ${message}`); // Non-http statuses
108
+
109
+ if (['UPDATED', 'CREATED', 'INVALID', 'ERROR'].includes(responseStatus)) {
110
+ return {
111
+ status: responseStatus,
112
+ message
113
+ };
114
+ }
106
115
 
107
- if (['UPDATED', 'CREATED', 'INVALID', 'ERROR', 'UNKNOWN'].includes(responseStatus)) {
116
+ if (['UNKNOWN'].includes(responseStatus)) {
117
+ const possibleIds = responsePayload.ids || [];
108
118
  return {
109
119
  status: responseStatus,
110
- message: responsePayload
120
+ message,
121
+ possibleIds
111
122
  };
112
- } // Duplicates and other conflicts
123
+ } // Duplicates and other CONFLICT statuses
113
124
 
114
125
 
115
126
  if ([_httpStatus.default.CONFLICT, 'CONFLICT'].includes(responseStatus)) {
116
- if (/^Duplicates in database/u.test(responsePayload.message)) {
127
+ if (/^Duplicates in database/u.test(message)) {
128
+ const duplicateIds = responsePayload.ids || [];
117
129
  return {
118
130
  status: 'DUPLICATE',
119
- message: responsePayload.message,
120
- duplicateIds: responsePayload.ids
131
+ message,
132
+ duplicateIds
133
+ };
134
+ }
135
+
136
+ if (/^MatchValidation for all/u.test(message)) {
137
+ const duplicateIds = responsePayload.ids || [];
138
+ return {
139
+ status: 'CONFLICT',
140
+ message,
141
+ duplicateIds
142
+ };
143
+ }
144
+
145
+ const conflictIds = responsePayload.ids || [];
146
+
147
+ if (conflictIds.length > 0) {
148
+ return {
149
+ status: 'CONFLICT',
150
+ message,
151
+ conflictIds
121
152
  };
122
153
  }
123
154
 
124
155
  return {
125
156
  status: 'CONFLICT',
126
- message: responsePayload.message
157
+ message
127
158
  };
128
159
  }
129
160
 
130
161
  if ([_httpStatus.default.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {
131
- return {
162
+ const unprocessableIds = responsePayload.ids || [];
163
+ const response = unprocessableIds.length > 0 ? {
132
164
  status: 'UNPROCESSABLE_ENTITY',
133
- message: responsePayload
165
+ message,
166
+ unprocessableIds
167
+ } : {
168
+ status: 'UNPROCESSABLE_ENTITY',
169
+ message
134
170
  };
171
+ return response;
135
172
  }
136
173
 
137
174
  if ([_httpStatus.default.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {
138
175
  return {
139
176
  status: 'NOT_FOUND',
140
- message: responsePayload
177
+ message
141
178
  };
142
- }
179
+ } // Otherwise
180
+
143
181
 
144
182
  return {
145
183
  status: 'ERROR',
146
- message: responsePayload
184
+ message
147
185
  };
148
186
  }
149
187
 
188
+ function getMessageFromResponsePayload(responsePayload) {
189
+ if (responsePayload.message) {
190
+ return responsePayload.message;
191
+ }
192
+
193
+ if (typeof responsePayload === 'string' || responsePayload instanceof String) {
194
+ return responsePayload;
195
+ }
196
+
197
+ return '';
198
+ }
199
+
150
200
  async function addRecordResponseItem({
151
201
  recordResponseItem,
152
202
  correlationId,
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","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":";;;;;;;;;;;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,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,GA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AO;AAACY,IAAAA,MAAM,EAAE,OAAT;AAAkBC,IAAAA,OAAO,EAAEb;AAA3B,GAAP;AACD;;AAEM,eAAeoB,qBAAf,CAAqC;AAACd,EAAAA,kBAAD;AAAqBe,EAAAA,aAArB;AAAoCC,EAAAA;AAApC,CAArC,EAAyF;AAC9F,QAAMA,aAAa,CAACC,YAAd,CAA2B;AAACF,IAAAA,aAAD;AAAgBG,IAAAA,QAAQ,EAAE,CAAClB,kBAAD,CAA1B;AAAgDmB,IAAAA,YAAY,EAAE;AAA9D,GAA3B,CAAN;AACA,SAAO,IAAP;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';\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"}
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","includes","status","possibleIds","ids","CONFLICT","test","duplicateIds","conflictIds","length","UNPROCESSABLE_ENTITY","unprocessableIds","response","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);\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) {\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\n logger.debug(`Response message: ${message}`);\n\n // Non-http statuses\n if (['UPDATED', 'CREATED', 'INVALID', 'ERROR'].includes(responseStatus)) {\n return {status: responseStatus, message};\n }\n\n if (['UNKNOWN'].includes(responseStatus)) {\n const possibleIds = responsePayload.ids || [];\n return {status: responseStatus, message, possibleIds};\n }\n\n // Duplicates and other CONFLICT statuses\n if ([httpStatus.CONFLICT, 'CONFLICT'].includes(responseStatus)) {\n if ((/^Duplicates in database/u).test(message)) {\n const duplicateIds = responsePayload.ids || [];\n return {status: 'DUPLICATE', message, duplicateIds};\n }\n if ((/^MatchValidation for all/u).test(message)) {\n const duplicateIds = responsePayload.ids || [];\n return {status: 'CONFLICT', message, duplicateIds};\n }\n const conflictIds = responsePayload.ids || [];\n if (conflictIds.length > 0) {\n return {status: 'CONFLICT', message, conflictIds};\n }\n return {status: 'CONFLICT', message};\n }\n\n if ([httpStatus.UNPROCESSABLE_ENTITY, 'UNPROCESSABLE_ENTITY'].includes(responseStatus)) {\n const unprocessableIds = responsePayload.ids || [];\n const response = unprocessableIds.length > 0 ? {status: 'UNPROCESSABLE_ENTITY', message, unprocessableIds} : {status: 'UNPROCESSABLE_ENTITY', message};\n return response;\n }\n\n if ([httpStatus.NOT_FOUND, 'NOT_FOUND'].includes(responseStatus)) {\n return {status: 'NOT_FOUND', message};\n }\n\n // Otherwise\n return {status: '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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lC,EAA0DT,QAA1D,CAAmEZ,cAAnE,CAAJ,EAAwF;IACtF,MAAMsB,gBAAgB,GAAGvB,eAAe,CAACgB,GAAhB,IAAuB,EAAhD;IACA,MAAMQ,QAAQ,GAAGD,gBAAgB,CAACF,MAAjB,GAA0B,CAA1B,GAA8B;MAACP,MAAM,EAAE,sBAAT;MAAiCH,OAAjC;MAA0CY;IAA1C,CAA9B,GAA4F;MAACT,MAAM,EAAE,sBAAT;MAAiCH;IAAjC,CAA7G;IACA,OAAOa,QAAP;EACD;;EAED,IAAI,CAACd,mBAAA,CAAWe,SAAZ,EAAuB,WAAvB,EAAoCZ,QAApC,CAA6CZ,cAA7C,CAAJ,EAAkE;IAChE,OAAO;MAACa,MAAM,EAAE,WAAT;MAAsBH;IAAtB,CAAP;EACD,CA7CyE,CA+C1E;;;EACA,OAAO;IAACG,MAAM,EAAE,OAAT;IAAkBH;EAAlB,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,YAAY0B,MAAtE,EAA8E;IAC5E,OAAO1B,eAAP;EACD;;EACD,OAAO,EAAP;AACD;;AAEM,eAAe2B,qBAAf,CAAqC;EAACrB,kBAAD;EAAqBsB,aAArB;EAAoCC;AAApC,CAArC,EAAyF;EAC9F,MAAMA,aAAa,CAACC,YAAd,CAA2B;IAACF,aAAD;IAAgBG,QAAQ,EAAE,CAACzB,kBAAD,CAA1B;IAAgD0B,YAAY,EAAE;EAA9D,CAA3B,CAAN;EACA,OAAO,IAAP;AACD"}
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.8",
17
+ "version": "2.3.0-alpha.2",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=14"
@@ -36,21 +36,21 @@
36
36
  "@natlibfi/marc-record": "^7.0.0",
37
37
  "@natlibfi/marc-record-serializers": "^8.1.0",
38
38
  "@natlibfi/marc-record-validate": "^7.0.1",
39
- "@natlibfi/marc-record-validators-melinda": "^9.0.4",
39
+ "@natlibfi/marc-record-validators-melinda": "^9.0.9",
40
40
  "@natlibfi/melinda-backend-commons": "^2.0.5",
41
41
  "@natlibfi/melinda-commons": "^12.0.3",
42
42
  "amqplib": ">=0.8.0 <1.0.0",
43
- "http-status": "^1.5.0",
44
- "moment": "^2.29.1",
43
+ "http-status": "^1.5.2",
44
+ "moment": "^2.29.3",
45
45
  "mongo-sanitize": "^1.1.0",
46
- "mongodb": "^4.1.3"
46
+ "mongodb": "^4.6.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/cli": "^7.17.6",
50
- "@babel/core": "^7.17.5",
49
+ "@babel/cli": "^7.17.10",
50
+ "@babel/core": "^7.17.12",
51
51
  "@babel/eslint-parser": "^7.17.0",
52
52
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
53
- "@babel/preset-env": "^7.16.11",
53
+ "@babel/preset-env": "^7.17.12",
54
54
  "@natlibfi/eslint-config-melinda-backend": "^2.0.0",
55
55
  "@natlibfi/fixura": "^2.2.1",
56
56
  "babel-plugin-dynamic-import-node": "^2.3.3",
@@ -58,9 +58,9 @@
58
58
  "babel-plugin-rewire": "^1.2.0",
59
59
  "chai": "^4.3.6",
60
60
  "cross-env": "^7.0.3",
61
- "eslint": "^8.10.0",
62
- "mocha": "^9.2.1",
63
- "nodemon": "^2.0.15",
61
+ "eslint": "^8.15.0",
62
+ "mocha": "^10.0.0",
63
+ "nodemon": "^2.0.16",
64
64
  "nyc": "^15.1.0"
65
65
  },
66
66
  "eslintConfig": {