@carbonorm/carbonnode 1.0.0 → 1.0.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/api/C6.d.ts +122 -0
- package/dist/api/convertForRequestBody.d.ts +3 -0
- package/dist/api/interfaces/ormInterfaces.d.ts +27 -0
- package/dist/api/restRequest.d.ts +131 -0
- package/dist/carbonnode.cjs.js +117 -73
- package/dist/carbonnode.esm.js +117 -73
- package/dist/carbonnode.umd.js +117 -73
- package/dist/index.cjs.js +649 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.esm.js +630 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +653 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/variables/isLocal.d.ts +2 -0
- package/dist/variables/isTest.d.ts +2 -0
- package/dist/variables/isVerbose.d.ts +2 -0
- package/dist/variables/toastOptions.d.ts +3 -0
- package/package.json +8 -5
- package/src/api/C6.ts +151 -0
- package/src/api/convertForRequestBody.ts +90 -0
- package/src/api/interfaces/ormInterfaces.ts +31 -0
- package/src/api/restRequest.ts +815 -0
- package/src/index.ts +17 -0
- package/src/variables/isLocal.ts +2 -0
- package/src/variables/isTest.ts +4 -0
- package/src/variables/isVerbose.ts +4 -0
- package/src/variables/toastOptions.ts +23 -0
package/dist/carbonnode.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var reactToastify = require('react-toastify');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var C6 = {
|
|
6
6
|
// try to 1=1 match the Rest abstract class
|
|
7
7
|
ADDDATE: 'ADDDATE',
|
|
8
8
|
ADDTIME: 'ADDTIME',
|
|
@@ -128,13 +128,47 @@ const C6 = {
|
|
|
128
128
|
VALIDATE_C6_ENTITY_ID_REGEX: '#^([a-fA-F0-9]{20,35})$#',
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
/******************************************************************************
|
|
132
|
+
Copyright (c) Microsoft Corporation.
|
|
133
|
+
|
|
134
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
135
|
+
purpose with or without fee is hereby granted.
|
|
136
|
+
|
|
137
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
138
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
139
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
140
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
141
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
142
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
143
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
144
|
+
***************************************************************************** */
|
|
145
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
var __assign = function() {
|
|
149
|
+
__assign = Object.assign || function __assign(t) {
|
|
150
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
151
|
+
s = arguments[i];
|
|
152
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
153
|
+
}
|
|
154
|
+
return t;
|
|
155
|
+
};
|
|
156
|
+
return __assign.apply(this, arguments);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
160
|
+
var e = new Error(message);
|
|
161
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
function convertForRequestBody (restfulObject, tableName, regexErrorHandler) {
|
|
165
|
+
if (regexErrorHandler === void 0) { regexErrorHandler = alert; }
|
|
166
|
+
var payload = {};
|
|
167
|
+
var tableNames = Array.isArray(tableName) ? tableName : [tableName];
|
|
168
|
+
tableNames.forEach(function (table) {
|
|
169
|
+
Object.keys(restfulObject).map(function (value) {
|
|
136
170
|
var _a;
|
|
137
|
-
|
|
171
|
+
var shortReference = value.toUpperCase();
|
|
138
172
|
switch (value) {
|
|
139
173
|
case C6.GET:
|
|
140
174
|
case C6.POST:
|
|
@@ -150,25 +184,28 @@ function convertForRequestBody (restfulObject, tableName, regexErrorHandler = al
|
|
|
150
184
|
else if (typeof restfulObject[value] === 'object' && restfulObject[value] !== null) {
|
|
151
185
|
payload[value] = Object.keys(restfulObject[value])
|
|
152
186
|
.sort()
|
|
153
|
-
.reduce(
|
|
187
|
+
.reduce(function (acc, key) {
|
|
188
|
+
var _a;
|
|
189
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[key] = restfulObject[value][key], _a)));
|
|
190
|
+
}, {});
|
|
154
191
|
}
|
|
155
192
|
return;
|
|
156
193
|
}
|
|
157
194
|
if (shortReference in C6[table]) {
|
|
158
|
-
|
|
159
|
-
payload[
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
if (false ===
|
|
163
|
-
regexErrorHandler('Failed to match regex (' +
|
|
164
|
-
throw Error('Failed to match regex (' +
|
|
195
|
+
var longName_1 = C6[table][shortReference];
|
|
196
|
+
payload[longName_1] = restfulObject[value];
|
|
197
|
+
var regexValidations_1 = C6[table].REGEX_VALIDATION[longName_1];
|
|
198
|
+
if (regexValidations_1 instanceof RegExp) {
|
|
199
|
+
if (false === regexValidations_1.test(restfulObject[value])) {
|
|
200
|
+
regexErrorHandler('Failed to match regex (' + regexValidations_1 + ') for column (' + longName_1 + ')');
|
|
201
|
+
throw Error('Failed to match regex (' + regexValidations_1 + ') for column (' + longName_1 + ')');
|
|
165
202
|
}
|
|
166
203
|
}
|
|
167
|
-
else if (typeof
|
|
168
|
-
(_a = Object.keys(
|
|
169
|
-
|
|
204
|
+
else if (typeof regexValidations_1 === 'object' && regexValidations_1 !== null) {
|
|
205
|
+
(_a = Object.keys(regexValidations_1)) === null || _a === void 0 ? void 0 : _a.map(function (errorMessage) {
|
|
206
|
+
var regex = regexValidations_1[errorMessage];
|
|
170
207
|
if (false === regex.test(restfulObject[value])) {
|
|
171
|
-
|
|
208
|
+
var devErrorMessage = 'Failed to match regex (' + regex + ') for column (' + longName_1 + ')';
|
|
172
209
|
regexErrorHandler(errorMessage !== null && errorMessage !== void 0 ? errorMessage : devErrorMessage);
|
|
173
210
|
throw Error(devErrorMessage);
|
|
174
211
|
}
|
|
@@ -180,16 +217,19 @@ function convertForRequestBody (restfulObject, tableName, regexErrorHandler = al
|
|
|
180
217
|
});
|
|
181
218
|
return Object.keys(payload)
|
|
182
219
|
.sort()
|
|
183
|
-
.reduce(
|
|
220
|
+
.reduce(function (acc, key) {
|
|
221
|
+
var _a;
|
|
222
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[key] = payload[key], _a)));
|
|
223
|
+
}, {});
|
|
184
224
|
}
|
|
185
225
|
|
|
186
226
|
var isLocal = process.env.NODE_ENV === 'development';
|
|
187
227
|
|
|
188
|
-
|
|
228
|
+
var isTest = process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === 'test';
|
|
189
229
|
|
|
190
|
-
|
|
230
|
+
var isVerbose = process.env.REACT_APP_VERBOSE === 'true';
|
|
191
231
|
|
|
192
|
-
|
|
232
|
+
var toastOptions = {
|
|
193
233
|
position: "bottom-left",
|
|
194
234
|
autoClose: 10000,
|
|
195
235
|
hideProgressBar: false,
|
|
@@ -198,7 +238,7 @@ const toastOptions = {
|
|
|
198
238
|
draggable: true,
|
|
199
239
|
theme: "dark",
|
|
200
240
|
};
|
|
201
|
-
|
|
241
|
+
var toastOptionsDevs = {
|
|
202
242
|
position: "bottom-right",
|
|
203
243
|
autoClose: 3000,
|
|
204
244
|
hideProgressBar: false,
|
|
@@ -217,28 +257,28 @@ function TestRestfulResponse(response, success, error) {
|
|
|
217
257
|
|| undefined !== ((_c = response.data) === null || _c === void 0 ? void 0 : _c.created)
|
|
218
258
|
|| undefined !== ((_d = response.data) === null || _d === void 0 ? void 0 : _d.updated)
|
|
219
259
|
|| undefined !== ((_e = response.data) === null || _e === void 0 ? void 0 : _e.deleted))) {
|
|
220
|
-
|
|
260
|
+
var successReturn = 'function' === typeof success ? success === null || success === void 0 ? void 0 : success(response) : success;
|
|
221
261
|
if (typeof successReturn === 'string') {
|
|
222
262
|
reactToastify.toast.success(successReturn, toastOptions);
|
|
223
263
|
}
|
|
224
264
|
// this could end up with bad results for deleting id's === 0
|
|
225
265
|
return (_h = (_g = (_f = response.data.created) !== null && _f !== void 0 ? _f : response.data.updated) !== null && _g !== void 0 ? _g : response.data.deleted) !== null && _h !== void 0 ? _h : true;
|
|
226
266
|
}
|
|
227
|
-
|
|
267
|
+
var errorReturn = 'function' === typeof error ? error === null || error === void 0 ? void 0 : error(response) : error;
|
|
228
268
|
if (typeof errorReturn === 'string') {
|
|
229
269
|
reactToastify.toast.error(errorReturn, toastOptions);
|
|
230
270
|
}
|
|
231
271
|
return false;
|
|
232
272
|
}
|
|
233
273
|
function removeInvalidKeys(request, c6Tables) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
c6Tables.forEach(table
|
|
274
|
+
var intersection = {};
|
|
275
|
+
var restfulObjectKeys = [];
|
|
276
|
+
c6Tables.forEach(function (table) { return Object.values(table.COLUMNS).forEach(function (column) {
|
|
237
277
|
if (false === restfulObjectKeys.includes(column)) {
|
|
238
278
|
restfulObjectKeys.push(column);
|
|
239
279
|
}
|
|
240
|
-
}));
|
|
241
|
-
Object.keys(request).forEach(key
|
|
280
|
+
}); });
|
|
281
|
+
Object.keys(request).forEach(function (key) {
|
|
242
282
|
if (restfulObjectKeys.includes(key)) {
|
|
243
283
|
intersection[key] = request[key];
|
|
244
284
|
}
|
|
@@ -248,17 +288,17 @@ function removeInvalidKeys(request, c6Tables) {
|
|
|
248
288
|
}
|
|
249
289
|
// do not remove entries from this array. It is used to track the progress of API requests.
|
|
250
290
|
// position in array is important. Do not sort. To not add to begging.
|
|
251
|
-
|
|
252
|
-
|
|
291
|
+
var apiRequestCache = [];
|
|
292
|
+
var userCustomClearCache = [];
|
|
253
293
|
function checkAllRequestsComplete() {
|
|
254
|
-
|
|
294
|
+
var stillRunning = apiRequestCache.filter(function (cache) { return undefined === cache.response; });
|
|
255
295
|
if (stillRunning.length !== 0) {
|
|
256
296
|
if (document === null || document === undefined) {
|
|
257
297
|
throw new Error('document is undefined while waiting for API requests to complete (' + JSON.stringify(apiRequestCache) + ')');
|
|
258
298
|
}
|
|
259
299
|
// when requests return emtpy sets in full renders, it may not be possible to track their progress.
|
|
260
300
|
console.warn('stillRunning...', stillRunning);
|
|
261
|
-
return stillRunning.map((cache)
|
|
301
|
+
return stillRunning.map(function (cache) { return cache.requestArgumentsSerialized; });
|
|
262
302
|
}
|
|
263
303
|
return true;
|
|
264
304
|
}
|
|
@@ -284,7 +324,7 @@ function checkCache(cacheResult, requestMethod, tableName, request) {
|
|
|
284
324
|
return false;
|
|
285
325
|
}
|
|
286
326
|
function sortAndSerializeQueryObject(tables, query) {
|
|
287
|
-
|
|
327
|
+
var orderedQuery = Object.keys(query).sort().reduce(function (obj, key) {
|
|
288
328
|
obj[key] = query[key];
|
|
289
329
|
return obj;
|
|
290
330
|
}, {});
|
|
@@ -294,7 +334,7 @@ function clearCache(props) {
|
|
|
294
334
|
if (false === (props === null || props === void 0 ? void 0 : props.ignoreWarning)) {
|
|
295
335
|
console.warn('The rest api clearCache should only be used with extreme care! Avoid using this in favor of using `cacheResults : boolean`.');
|
|
296
336
|
}
|
|
297
|
-
userCustomClearCache.map((f)
|
|
337
|
+
userCustomClearCache.map(function (f) { return 'function' === typeof f && f(); });
|
|
298
338
|
userCustomClearCache = apiRequestCache = [];
|
|
299
339
|
}
|
|
300
340
|
/**
|
|
@@ -307,20 +347,21 @@ function clearCache(props) {
|
|
|
307
347
|
* For POST, PUT, and DELETE requests one can expect the primary key of the new or modified index, or a boolean success
|
|
308
348
|
* indication if no primary key exists.
|
|
309
349
|
**/
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
350
|
+
var POST = 'POST';
|
|
351
|
+
var PUT = 'PUT';
|
|
352
|
+
var GET = 'GET';
|
|
353
|
+
var DELETE = 'DELETE';
|
|
314
354
|
function isPromise(x) {
|
|
315
355
|
return Object(x).constructor === Promise;
|
|
316
356
|
}
|
|
317
357
|
function extendedTypeHints() {
|
|
318
|
-
return (argv)
|
|
358
|
+
return function (argv) { return restApi(argv); };
|
|
319
359
|
}
|
|
320
|
-
function restApi(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
360
|
+
function restApi(_a) {
|
|
361
|
+
var C6 = _a.C6, axios = _a.axios, restURL = _a.restURL, tableName = _a.tableName, _b = _a.requestMethod, requestMethod = _b === void 0 ? GET : _b, _c = _a.queryCallback, queryCallback = _c === void 0 ? {} : _c, responseCallback = _a.responseCallback, _d = _a.skipPrimaryCheck, skipPrimaryCheck = _d === void 0 ? false : _d, _e = _a.clearCache, clearCache = _e === void 0 ? undefined : _e;
|
|
362
|
+
var fullTableList = Array.isArray(tableName) ? tableName : [tableName];
|
|
363
|
+
var operatingTable = fullTableList[0];
|
|
364
|
+
var tables = fullTableList.join(',');
|
|
324
365
|
switch (requestMethod) {
|
|
325
366
|
case GET:
|
|
326
367
|
case POST:
|
|
@@ -333,10 +374,11 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
333
374
|
if (null !== clearCache || undefined !== clearCache) {
|
|
334
375
|
userCustomClearCache[tables + requestMethod] = clearCache;
|
|
335
376
|
}
|
|
336
|
-
return (request
|
|
377
|
+
return function (request) {
|
|
378
|
+
if (request === void 0) { request = {}; }
|
|
337
379
|
// an undefined query would indicate queryCallback returned undefined,
|
|
338
380
|
// thus the request shouldn't fire as is in custom cache
|
|
339
|
-
|
|
381
|
+
var query;
|
|
340
382
|
if ('function' === typeof queryCallback) {
|
|
341
383
|
query = queryCallback(request); // obj or obj[]
|
|
342
384
|
}
|
|
@@ -375,9 +417,9 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
375
417
|
// The problem with creating cache keys with a stringified object is the order of keys matters and it's possible for the same query to be stringified differently.
|
|
376
418
|
// Here we ensure the key order will be identical between two of the same requests. https://stackoverflow.com/questions/5467129/sort-javascript-object-by-key
|
|
377
419
|
// literally impossible for query to be undefined or null here but the editor is too busy licking windows to understand that
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
420
|
+
var querySerialized = sortAndSerializeQueryObject(tables, query !== null && query !== void 0 ? query : {});
|
|
421
|
+
var cacheResult = apiRequestCache.find(function (cache) { return cache.requestArgumentsSerialized === querySerialized; });
|
|
422
|
+
var cachingConfirmed = false;
|
|
381
423
|
// determine if we need to paginate.
|
|
382
424
|
if (requestMethod === C6.GET) {
|
|
383
425
|
if (undefined === (query === null || query === void 0 ? void 0 : query[C6.PAGINATION])) {
|
|
@@ -393,7 +435,7 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
393
435
|
// just find the next, non-fetched, page and return a function to request it
|
|
394
436
|
if (undefined !== cacheResult) {
|
|
395
437
|
do {
|
|
396
|
-
|
|
438
|
+
var cacheCheck = checkCache(cacheResult, requestMethod, tableName, request);
|
|
397
439
|
if (false !== cacheCheck) {
|
|
398
440
|
return cacheCheck;
|
|
399
441
|
}
|
|
@@ -401,10 +443,10 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
401
443
|
++query[C6.PAGINATION][C6.PAGE];
|
|
402
444
|
// this json stringify is to capture the new page number
|
|
403
445
|
querySerialized = sortAndSerializeQueryObject(tables, query !== null && query !== void 0 ? query : {});
|
|
404
|
-
cacheResult = apiRequestCache.find(cache
|
|
446
|
+
cacheResult = apiRequestCache.find(function (cache) { return cache.requestArgumentsSerialized === querySerialized; });
|
|
405
447
|
} while (undefined !== cacheResult);
|
|
406
448
|
if (request.debug && isLocal) {
|
|
407
|
-
reactToastify.toast.warning("DEVS: Request in cache. (" + apiRequestCache.findIndex(cache
|
|
449
|
+
reactToastify.toast.warning("DEVS: Request in cache. (" + apiRequestCache.findIndex(function (cache) { return cache.requestArgumentsSerialized === querySerialized; }) + "). Returning function to request page (" + query[C6.PAGINATION][C6.PAGE] + ")", toastOptionsDevs);
|
|
408
450
|
}
|
|
409
451
|
// @ts-ignore - this is an incorrect warning on TS, it's well typed
|
|
410
452
|
return apiRequest;
|
|
@@ -422,7 +464,7 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
422
464
|
}
|
|
423
465
|
else if (request.cacheResults) { // if we are not getting, we are updating, deleting, or inserting
|
|
424
466
|
if (cacheResult) {
|
|
425
|
-
|
|
467
|
+
var cacheCheck = checkCache(cacheResult, requestMethod, tableName, request);
|
|
426
468
|
if (false !== cacheCheck) {
|
|
427
469
|
return cacheCheck;
|
|
428
470
|
}
|
|
@@ -430,16 +472,16 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
430
472
|
cachingConfirmed = true;
|
|
431
473
|
// push to cache so we do not repeat the request
|
|
432
474
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
475
|
+
var addBackPK;
|
|
476
|
+
var apiResponse;
|
|
477
|
+
var returnGetNextPageFunction = false;
|
|
478
|
+
var restRequestUri = restURL + operatingTable + '/';
|
|
479
|
+
var needsConditionOrPrimaryCheck = (PUT === requestMethod || DELETE === requestMethod)
|
|
438
480
|
&& false === skipPrimaryCheck;
|
|
439
|
-
|
|
481
|
+
var TABLES = C6.TABLES;
|
|
440
482
|
// todo - aggregate primary key check with condition check
|
|
441
483
|
// check if PK exists in query, clone so pop does not affect the real data
|
|
442
|
-
|
|
484
|
+
var primaryKey = (_f = (_e = (_d = structuredClone((_c = TABLES[operatingTable]) === null || _c === void 0 ? void 0 : _c.PRIMARY)) === null || _d === void 0 ? void 0 : _d.pop()) === null || _e === void 0 ? void 0 : _e.split('.')) === null || _f === void 0 ? void 0 : _f.pop();
|
|
443
485
|
if (needsConditionOrPrimaryCheck) {
|
|
444
486
|
if (undefined === primaryKey) {
|
|
445
487
|
if (null === query
|
|
@@ -474,10 +516,10 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
474
516
|
&& undefined !== primaryKey
|
|
475
517
|
&& primaryKey in query) {
|
|
476
518
|
restRequestUri += query[primaryKey] + '/';
|
|
477
|
-
|
|
478
|
-
addBackPK = ()
|
|
519
|
+
var removedPkValue_1 = query[primaryKey];
|
|
520
|
+
addBackPK = function () {
|
|
479
521
|
query !== null && query !== void 0 ? query : (query = {});
|
|
480
|
-
query[primaryKey] =
|
|
522
|
+
query[primaryKey] = removedPkValue_1;
|
|
481
523
|
};
|
|
482
524
|
delete query[primaryKey];
|
|
483
525
|
}
|
|
@@ -488,7 +530,7 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
488
530
|
console.log('%c Remember undefined indicated the request has not fired, null indicates the request is firing, an empty array would signal no data was returned for the sql stmt.', 'color: #A020F0');
|
|
489
531
|
console.trace();
|
|
490
532
|
console.groupEnd();
|
|
491
|
-
|
|
533
|
+
var axiosActiveRequest = axios[requestMethod.toLowerCase()](restRequestUri, (function () {
|
|
492
534
|
// we had removed the value from the request to add to the URI.
|
|
493
535
|
addBackPK === null || addBackPK === void 0 ? void 0 : addBackPK(); // adding back so post-processing methods work
|
|
494
536
|
if (requestMethod === GET) {
|
|
@@ -498,16 +540,18 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
498
540
|
}
|
|
499
541
|
else if (requestMethod === POST) {
|
|
500
542
|
if (undefined !== (request === null || request === void 0 ? void 0 : request.dataInsertMultipleRows)) {
|
|
501
|
-
return request.dataInsertMultipleRows.map(
|
|
543
|
+
return request.dataInsertMultipleRows.map(function (data) {
|
|
544
|
+
return convertForRequestBody(data, fullTableList, function (message) { return reactToastify.toast.error(message, toastOptions); });
|
|
545
|
+
});
|
|
502
546
|
}
|
|
503
|
-
return convertForRequestBody(query, fullTableList, (message)
|
|
547
|
+
return convertForRequestBody(query, fullTableList, function (message) { return reactToastify.toast.error(message, toastOptions); });
|
|
504
548
|
}
|
|
505
549
|
else if (requestMethod === PUT) {
|
|
506
|
-
return convertForRequestBody(query, fullTableList, (message)
|
|
550
|
+
return convertForRequestBody(query, fullTableList, function (message) { return reactToastify.toast.error(message, toastOptions); });
|
|
507
551
|
}
|
|
508
552
|
else if (requestMethod === DELETE) {
|
|
509
553
|
return {
|
|
510
|
-
data: convertForRequestBody(query, fullTableList, (message)
|
|
554
|
+
data: convertForRequestBody(query, fullTableList, function (message) { return reactToastify.toast.error(message, toastOptions); })
|
|
511
555
|
};
|
|
512
556
|
}
|
|
513
557
|
else {
|
|
@@ -522,7 +566,7 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
522
566
|
});
|
|
523
567
|
}
|
|
524
568
|
// https://rapidapi.com/guides/axios-async-await
|
|
525
|
-
return axiosActiveRequest.then(response
|
|
569
|
+
return axiosActiveRequest.then(function (response) {
|
|
526
570
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
527
571
|
if (typeof response.data === 'string') {
|
|
528
572
|
if (isTest) {
|
|
@@ -535,7 +579,7 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
535
579
|
if (false !== apiResponse) {
|
|
536
580
|
responseCallback(response, request, apiResponse);
|
|
537
581
|
if (C6.GET === requestMethod) {
|
|
538
|
-
|
|
582
|
+
var responseData = response.data;
|
|
539
583
|
// @ts-ignore
|
|
540
584
|
returnGetNextPageFunction = 1 !== ((_b = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _b === void 0 ? void 0 : _b[C6.LIMIT]) &&
|
|
541
585
|
((_c = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _c === void 0 ? void 0 : _c[C6.LIMIT]) === responseData.rest.length;
|
|
@@ -556,7 +600,7 @@ function restApi({ C6, axios, restURL, tableName, requestMethod = GET, queryCall
|
|
|
556
600
|
}
|
|
557
601
|
}
|
|
558
602
|
if (cachingConfirmed) {
|
|
559
|
-
|
|
603
|
+
var cacheIndex = apiRequestCache.findIndex(function (cache) { return cache.requestArgumentsSerialized === querySerialized; });
|
|
560
604
|
apiRequestCache[cacheIndex].final = false === returnGetNextPageFunction;
|
|
561
605
|
// only cache get method requests
|
|
562
606
|
apiRequestCache[cacheIndex].response = response;
|