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