@carbonorm/carbonnode 3.0.3 → 3.0.5
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/convertForRequestBody.d.ts +7 -3
- package/dist/api/executors/Executor.d.ts +3 -4
- package/dist/api/executors/HttpExecutor.d.ts +4 -5
- package/dist/api/restOrm.d.ts +4 -32
- package/dist/api/restRequest.d.ts +2 -3
- package/dist/api/types/ormInterfaces.d.ts +161 -161
- package/dist/index.cjs.js +549 -97
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +551 -98
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/scripts/assets/handlebars/C6.ts.handlebars +32 -24
- package/scripts/generateRestBindings.cjs +4 -0
- package/scripts/generateRestBindings.ts +4 -0
- package/src/api/convertForRequestBody.ts +62 -90
- package/src/api/executors/Executor.ts +8 -4
- package/src/api/executors/HttpExecutor.ts +81 -68
- package/src/api/restRequest.ts +7 -4
- package/src/api/types/ormInterfaces.ts +200 -321
- package/src/api/rest/C6.test.ts +0 -88
- package/src/api/rest/C6.ts +0 -5338
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import Qs from 'qs';
|
|
3
|
-
import { __assign, __awaiter,
|
|
3
|
+
import { __assign, __awaiter, __generator, __extends, __spreadArray } from 'tslib';
|
|
4
4
|
import { toast } from 'react-toastify';
|
|
5
5
|
|
|
6
6
|
var C6Constants = {
|
|
@@ -236,65 +236,70 @@ function convertForRequestBody (restfulObject, tableName, C6, regexErrorHandler)
|
|
|
236
236
|
if (regexErrorHandler === void 0) { regexErrorHandler = alert; }
|
|
237
237
|
var payload = {};
|
|
238
238
|
var tableNames = Array.isArray(tableName) ? tableName : [tableName];
|
|
239
|
-
var tableDefinitions =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
throw new Error("Table name (".concat(tableName, ") is not found in the C6.TABLES object."));
|
|
239
|
+
var tableDefinitions = tableNames.map(function (name) {
|
|
240
|
+
var tableDefinition = Object.values(C6.TABLES).find(function (t) { return t.TABLE_NAME === name; });
|
|
241
|
+
if (!tableDefinition) {
|
|
242
|
+
console.error("Table name (".concat(name, ") is not found in the C6.TABLES object."), C6.TABLES);
|
|
243
|
+
throw new Error("Table name (".concat(name, ") is not found in the C6.TABLES object."));
|
|
245
244
|
}
|
|
246
|
-
|
|
245
|
+
return tableDefinition;
|
|
247
246
|
});
|
|
248
|
-
tableDefinitions.
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
for (var _i = 0, tableDefinitions_1 = tableDefinitions; _i < tableDefinitions_1.length; _i++) {
|
|
248
|
+
var tableDefinition = tableDefinitions_1[_i];
|
|
249
|
+
var _loop_1 = function (value) {
|
|
251
250
|
var shortReference = value.toUpperCase();
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
251
|
+
if ([
|
|
252
|
+
C6Constants.GET,
|
|
253
|
+
C6Constants.POST,
|
|
254
|
+
C6Constants.UPDATE,
|
|
255
|
+
C6Constants.REPLACE,
|
|
256
|
+
C6Constants.DELETE,
|
|
257
|
+
C6Constants.WHERE,
|
|
258
|
+
C6Constants.JOIN,
|
|
259
|
+
C6Constants.PAGINATION
|
|
260
|
+
].includes(value)) {
|
|
261
|
+
var val_1 = restfulObject[value];
|
|
262
|
+
if (Array.isArray(val_1)) {
|
|
263
|
+
payload[value] = val_1.sort();
|
|
264
|
+
}
|
|
265
|
+
else if (typeof val_1 === 'object' && val_1 !== null) {
|
|
266
|
+
payload[value] = Object.keys(val_1)
|
|
267
|
+
.sort()
|
|
268
|
+
.reduce(function (acc, key) {
|
|
269
|
+
var _a;
|
|
270
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[key] = val_1[key], _a)));
|
|
271
|
+
}, {});
|
|
272
|
+
}
|
|
273
|
+
return "continue";
|
|
273
274
|
}
|
|
274
275
|
if (shortReference in tableDefinition) {
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
276
|
+
var longName = tableDefinition[shortReference];
|
|
277
|
+
var columnValue = restfulObject[value];
|
|
278
|
+
payload[longName] = columnValue;
|
|
279
|
+
var regexValidations = tableDefinition.REGEX_VALIDATION[longName];
|
|
280
|
+
if (regexValidations instanceof RegExp) {
|
|
281
|
+
if (!regexValidations.test(columnValue)) {
|
|
282
|
+
regexErrorHandler("Failed to match regex (".concat(regexValidations, ") for column (").concat(longName, ")"));
|
|
283
|
+
throw new Error("Failed to match regex (".concat(regexValidations, ") for column (").concat(longName, ")"));
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
|
-
else if (typeof
|
|
285
|
-
|
|
286
|
-
var regex =
|
|
287
|
-
if (
|
|
288
|
-
var devErrorMessage =
|
|
289
|
-
regexErrorHandler(errorMessage
|
|
290
|
-
throw Error(devErrorMessage);
|
|
286
|
+
else if (typeof regexValidations === 'object' && regexValidations !== null) {
|
|
287
|
+
for (var errorMessage in regexValidations) {
|
|
288
|
+
var regex = regexValidations[errorMessage];
|
|
289
|
+
if (!regex.test(columnValue)) {
|
|
290
|
+
var devErrorMessage = "Failed to match regex (".concat(regex, ") for column (").concat(longName, ")");
|
|
291
|
+
regexErrorHandler(errorMessage || devErrorMessage);
|
|
292
|
+
throw new Error(devErrorMessage);
|
|
291
293
|
}
|
|
292
|
-
}
|
|
294
|
+
}
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
297
|
+
};
|
|
298
|
+
for (var _a = 0, _b = Object.keys(restfulObject); _a < _b.length; _a++) {
|
|
299
|
+
var value = _b[_a];
|
|
300
|
+
_loop_1(value);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
298
303
|
return Object.keys(payload)
|
|
299
304
|
.sort()
|
|
300
305
|
.reduce(function (acc, key) {
|
|
@@ -311,32 +316,25 @@ var isNode = typeof process !== 'undefined' && !!((_a = process.versions) === nu
|
|
|
311
316
|
*/
|
|
312
317
|
function restRequest(config) {
|
|
313
318
|
var _this = this;
|
|
314
|
-
return function () {
|
|
315
|
-
var
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
case 2: return [4 /*yield*/, Promise.resolve().then(function () { return HttpExecutor$1; })];
|
|
332
|
-
case 3:
|
|
333
|
-
HttpExecutor = (_a.sent()).HttpExecutor;
|
|
334
|
-
http = new HttpExecutor(config, request);
|
|
335
|
-
return [2 /*return*/, http.execute()];
|
|
336
|
-
}
|
|
337
|
-
});
|
|
319
|
+
return function (request) { return __awaiter(_this, void 0, void 0, function () {
|
|
320
|
+
var SqlExecutor, executor, HttpExecutor, http;
|
|
321
|
+
return __generator(this, function (_a) {
|
|
322
|
+
switch (_a.label) {
|
|
323
|
+
case 0:
|
|
324
|
+
if (!(isNode && config.mysqlPool)) return [3 /*break*/, 2];
|
|
325
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return SqlExecutor$1; })];
|
|
326
|
+
case 1:
|
|
327
|
+
SqlExecutor = (_a.sent()).SqlExecutor;
|
|
328
|
+
executor = new SqlExecutor(config, request);
|
|
329
|
+
return [2 /*return*/, executor.execute()];
|
|
330
|
+
case 2: return [4 /*yield*/, Promise.resolve().then(function () { return HttpExecutor$1; })];
|
|
331
|
+
case 3:
|
|
332
|
+
HttpExecutor = (_a.sent()).HttpExecutor;
|
|
333
|
+
http = new HttpExecutor(config, request);
|
|
334
|
+
return [2 /*return*/, http.execute()];
|
|
335
|
+
}
|
|
338
336
|
});
|
|
339
|
-
};
|
|
337
|
+
}); };
|
|
340
338
|
}
|
|
341
339
|
|
|
342
340
|
function restOrm(config) {
|
|
@@ -541,7 +539,6 @@ var isVerbose = ['true', '1', 'yes', 'on'].includes(envVerbose.toLowerCase());
|
|
|
541
539
|
|
|
542
540
|
var Executor = /** @class */ (function () {
|
|
543
541
|
function Executor(config, request) {
|
|
544
|
-
if (request === void 0) { request = {}; }
|
|
545
542
|
this.config = config;
|
|
546
543
|
this.request = request;
|
|
547
544
|
}
|
|
@@ -610,23 +607,11 @@ var eFetchDependencies;
|
|
|
610
607
|
eFetchDependencies[eFetchDependencies["RECURSIVE"] = 8] = "RECURSIVE";
|
|
611
608
|
})(eFetchDependencies || (eFetchDependencies = {}));
|
|
612
609
|
|
|
613
|
-
|
|
614
|
-
* the first argument ....
|
|
615
|
-
*
|
|
616
|
-
* Our api returns a zero argument function iff the method is get and the previous request reached the predefined limit.
|
|
617
|
-
* This function can be aliased as GetNextPageOfResults(). If the end is reached undefined will be returned.
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* For POST, PUT, and DELETE requests one can expect the primary key of the new or modified index, or a boolean success
|
|
621
|
-
* indication if no primary key exists.
|
|
622
|
-
**/
|
|
610
|
+
// Refined TypeScript types for CarbonORM
|
|
623
611
|
var POST = 'POST';
|
|
624
612
|
var PUT = 'PUT';
|
|
625
613
|
var GET = 'GET';
|
|
626
614
|
var DELETE = 'DELETE';
|
|
627
|
-
function isPromise(x) {
|
|
628
|
-
return Object(x).constructor === Promise;
|
|
629
|
-
}
|
|
630
615
|
|
|
631
616
|
var toastOptions = {
|
|
632
617
|
position: "bottom-left",
|
|
@@ -788,11 +773,12 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
788
773
|
};
|
|
789
774
|
HttpExecutor.prototype.execute = function () {
|
|
790
775
|
return __awaiter(this, void 0, void 0, function () {
|
|
791
|
-
var _a, C6, restModel, requestMethod, clearCache, tableName, fullTableList, operatingTableFullName, tables;
|
|
776
|
+
var _a, C6, axios, restURL, withCredentials, restModel, reactBootstrap, requestMethod, skipPrimaryCheck, clearCache, tableName, fullTableList, operatingTableFullName, operatingTable, tables, query, apiRequest;
|
|
777
|
+
var _this = this;
|
|
792
778
|
return __generator(this, function (_b) {
|
|
793
779
|
switch (_b.label) {
|
|
794
780
|
case 0:
|
|
795
|
-
_a = this.config, C6 = _a.C6, _a.axios, _a.restURL, _a.withCredentials, restModel = _a.restModel, _a.reactBootstrap, requestMethod = _a.requestMethod, _a.skipPrimaryCheck, clearCache = _a.clearCache;
|
|
781
|
+
_a = this.config, C6 = _a.C6, axios = _a.axios, restURL = _a.restURL, withCredentials = _a.withCredentials, restModel = _a.restModel, reactBootstrap = _a.reactBootstrap, requestMethod = _a.requestMethod, skipPrimaryCheck = _a.skipPrimaryCheck, clearCache = _a.clearCache;
|
|
796
782
|
return [4 /*yield*/, this.runLifecycleHooks("beforeProcessing", {
|
|
797
783
|
config: this.config,
|
|
798
784
|
request: this.request,
|
|
@@ -802,7 +788,7 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
802
788
|
tableName = restModel.TABLE_NAME;
|
|
803
789
|
fullTableList = Array.isArray(tableName) ? tableName : [tableName];
|
|
804
790
|
operatingTableFullName = fullTableList[0];
|
|
805
|
-
removePrefixIfExists(operatingTableFullName, C6.PREFIX);
|
|
791
|
+
operatingTable = removePrefixIfExists(operatingTableFullName, C6.PREFIX);
|
|
806
792
|
tables = fullTableList.join(',');
|
|
807
793
|
switch (requestMethod) {
|
|
808
794
|
case GET:
|
|
@@ -819,16 +805,483 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
819
805
|
console.groupCollapsed('%c API: (' + requestMethod + ') Request for (' + tableName + ')', 'color: #0c0');
|
|
820
806
|
console.log('request', this.request);
|
|
821
807
|
console.groupEnd();
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
console.
|
|
808
|
+
// an undefined query would indicate queryCallback returned undefined,
|
|
809
|
+
// thus the request shouldn't fire as is in custom cache
|
|
810
|
+
if (undefined === this.request || null === this.request) {
|
|
811
|
+
console.groupCollapsed('%c API: (' + requestMethod + ') Request Query for (' + tableName + ') undefined, returning null (will not fire)!', 'color: #c00');
|
|
812
|
+
console.log('request', this.request);
|
|
827
813
|
console.log('%c Returning (undefined|null) for a query would indicate a custom cache hit (outside API.tsx), thus the request should not fire.', 'color: #c00');
|
|
828
814
|
console.trace();
|
|
829
815
|
console.groupEnd();
|
|
830
816
|
return [2 /*return*/, null];
|
|
831
817
|
}
|
|
818
|
+
query = this.request;
|
|
819
|
+
if (C6.GET === requestMethod) {
|
|
820
|
+
if (undefined === query[C6.PAGINATION]) {
|
|
821
|
+
query[C6.PAGINATION] = {};
|
|
822
|
+
}
|
|
823
|
+
query[C6.PAGINATION][C6.PAGE] = query[C6.PAGINATION][C6.PAGE] || 1;
|
|
824
|
+
query[C6.PAGINATION][C6.LIMIT] = query[C6.PAGINATION][C6.LIMIT] || 100;
|
|
825
|
+
}
|
|
826
|
+
apiRequest = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
827
|
+
var _a, debug, _b, cacheResults, dataInsertMultipleRows, success, _c, fetchDependencies, _d, error, querySerialized, cacheResult, cachingConfirmed, cacheCheck, cacheCheck, addBackPK, apiResponse, returnGetNextPageFunction, restRequestUri, needsConditionOrPrimaryCheck, TABLES, primaryKey, removedPkValue_1, axiosActiveRequest;
|
|
828
|
+
var _e;
|
|
829
|
+
var _this = this;
|
|
830
|
+
var _f, _g, _h, _j, _k, _l;
|
|
831
|
+
return __generator(this, function (_m) {
|
|
832
|
+
_a = this.request, debug = _a.debug, _b = _a.cacheResults, cacheResults = _b === void 0 ? (C6.GET === requestMethod) : _b, dataInsertMultipleRows = _a.dataInsertMultipleRows, success = _a.success, _c = _a.fetchDependencies, fetchDependencies = _c === void 0 ? eFetchDependencies.NONE : _c, _d = _a.error, error = _d === void 0 ? "An unexpected API error occurred!" : _d;
|
|
833
|
+
if (C6.GET === requestMethod
|
|
834
|
+
&& undefined !== ((_f = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _f === void 0 ? void 0 : _f[C6.PAGE])
|
|
835
|
+
&& 1 !== query[C6.PAGINATION][C6.PAGE]) {
|
|
836
|
+
console.groupCollapsed('Request on table (' + tableName + ') is firing for page (' + query[C6.PAGINATION][C6.PAGE] + '), please wait!');
|
|
837
|
+
console.log('Request Data (note you may see the success and/or error prompt):', this.request);
|
|
838
|
+
console.trace();
|
|
839
|
+
console.groupEnd();
|
|
840
|
+
}
|
|
841
|
+
querySerialized = sortAndSerializeQueryObject(tables, query !== null && query !== void 0 ? query : {});
|
|
842
|
+
cacheResult = apiRequestCache.find(function (cache) { return cache.requestArgumentsSerialized === querySerialized; });
|
|
843
|
+
cachingConfirmed = false;
|
|
844
|
+
// determine if we need to paginate.
|
|
845
|
+
if (requestMethod === C6.GET) {
|
|
846
|
+
if (undefined === (query === null || query === void 0 ? void 0 : query[C6.PAGINATION])) {
|
|
847
|
+
if (undefined === query || null === query) {
|
|
848
|
+
query = {};
|
|
849
|
+
}
|
|
850
|
+
query[C6.PAGINATION] = {};
|
|
851
|
+
}
|
|
852
|
+
query[C6.PAGINATION][C6.PAGE] = query[C6.PAGINATION][C6.PAGE] || 1;
|
|
853
|
+
query[C6.PAGINATION][C6.LIMIT] = query[C6.PAGINATION][C6.LIMIT] || 100;
|
|
854
|
+
// this will evaluate true most the time
|
|
855
|
+
if (true === cacheResults) {
|
|
856
|
+
// just find the next, non-fetched, page and return a function to request it
|
|
857
|
+
if (undefined !== cacheResult) {
|
|
858
|
+
do {
|
|
859
|
+
cacheCheck = checkCache(cacheResult, requestMethod, tableName, this.request);
|
|
860
|
+
if (false !== cacheCheck) {
|
|
861
|
+
return [2 /*return*/, cacheCheck];
|
|
862
|
+
}
|
|
863
|
+
// this line incrementing page is why we return recursively
|
|
864
|
+
++query[C6.PAGINATION][C6.PAGE];
|
|
865
|
+
// this json stringify is to capture the new page number
|
|
866
|
+
querySerialized = sortAndSerializeQueryObject(tables, query !== null && query !== void 0 ? query : {});
|
|
867
|
+
cacheResult = apiRequestCache.find(function (cache) { return cache.requestArgumentsSerialized === querySerialized; });
|
|
868
|
+
} while (undefined !== cacheResult);
|
|
869
|
+
if (debug && isDevelopment) {
|
|
870
|
+
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);
|
|
871
|
+
}
|
|
872
|
+
// @ts-ignore - this is an incorrect warning on TS, it's well typed
|
|
873
|
+
return [2 /*return*/, apiRequest];
|
|
874
|
+
}
|
|
875
|
+
cachingConfirmed = true;
|
|
876
|
+
}
|
|
877
|
+
else {
|
|
878
|
+
if (debug && isDevelopment) {
|
|
879
|
+
toast.info("DEVS: Ignore cache was set to true.", toastOptionsDevs);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
if (debug && isDevelopment) {
|
|
883
|
+
toast.success("DEVS: Request not in cache." + (requestMethod === C6.GET ? "Page (" + query[C6.PAGINATION][C6.PAGE] + ")." : '') + " Logging cache 2 console.", toastOptionsDevs);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
else if (cacheResults) { // if we are not getting, we are updating, deleting, or inserting
|
|
887
|
+
if (cacheResult) {
|
|
888
|
+
cacheCheck = checkCache(cacheResult, requestMethod, tableName, this.request);
|
|
889
|
+
if (false !== cacheCheck) {
|
|
890
|
+
return [2 /*return*/, cacheCheck];
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
cachingConfirmed = true;
|
|
894
|
+
// push to cache so we do not repeat the request
|
|
895
|
+
}
|
|
896
|
+
returnGetNextPageFunction = false;
|
|
897
|
+
restRequestUri = restURL + operatingTable + '/';
|
|
898
|
+
needsConditionOrPrimaryCheck = (PUT === requestMethod || DELETE === requestMethod)
|
|
899
|
+
&& false === skipPrimaryCheck;
|
|
900
|
+
TABLES = C6.TABLES;
|
|
901
|
+
primaryKey = (_k = (_j = (_h = structuredClone((_g = TABLES[operatingTable]) === null || _g === void 0 ? void 0 : _g.PRIMARY)) === null || _h === void 0 ? void 0 : _h.pop()) === null || _j === void 0 ? void 0 : _j.split('.')) === null || _k === void 0 ? void 0 : _k.pop();
|
|
902
|
+
if (needsConditionOrPrimaryCheck) {
|
|
903
|
+
if (undefined === primaryKey) {
|
|
904
|
+
if (null === query
|
|
905
|
+
|| undefined === query
|
|
906
|
+
|| undefined === (query === null || query === void 0 ? void 0 : query[C6.WHERE])
|
|
907
|
+
|| (true === Array.isArray(query[C6.WHERE])
|
|
908
|
+
|| query[C6.WHERE].length === 0)
|
|
909
|
+
|| (Object.keys(query === null || query === void 0 ? void 0 : query[C6.WHERE]).length === 0)) {
|
|
910
|
+
console.error(query);
|
|
911
|
+
throw Error('Failed to parse primary key information. Query: (' + JSON.stringify(query) + ') Primary Key: (' + JSON.stringify(primaryKey) + ') TABLES[operatingTable]?.PRIMARY: (' + JSON.stringify((_l = TABLES[operatingTable]) === null || _l === void 0 ? void 0 : _l.PRIMARY) + ') for operatingTable (' + operatingTable + ').');
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
if (undefined === query
|
|
916
|
+
|| null === query
|
|
917
|
+
|| false === primaryKey in query) {
|
|
918
|
+
if (true === debug && isDevelopment) {
|
|
919
|
+
toast.error('DEVS: The primary key (' + primaryKey + ') was not provided!!');
|
|
920
|
+
}
|
|
921
|
+
throw Error('You must provide the primary key (' + primaryKey + ') for table (' + operatingTable + '). Request (' + JSON.stringify(this.request, undefined, 4) + ') Query (' + JSON.stringify(query) + ')');
|
|
922
|
+
}
|
|
923
|
+
if (undefined === (query === null || query === void 0 ? void 0 : query[primaryKey])
|
|
924
|
+
|| null === (query === null || query === void 0 ? void 0 : query[primaryKey])) {
|
|
925
|
+
toast.error('The primary key (' + primaryKey + ') provided is undefined or null explicitly!!');
|
|
926
|
+
throw Error('The primary key (' + primaryKey + ') provided in the request was exactly equal to undefined.');
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
// A part of me exists that wants to remove this, but it's a good feature
|
|
931
|
+
// this allows developers the ability to cache requests based on primary key
|
|
932
|
+
// for tables like `photos` this can be a huge performance boost
|
|
933
|
+
if (undefined !== query
|
|
934
|
+
&& null !== query
|
|
935
|
+
&& undefined !== primaryKey
|
|
936
|
+
&& primaryKey in query) {
|
|
937
|
+
restRequestUri += query[primaryKey] + '/';
|
|
938
|
+
removedPkValue_1 = query[primaryKey];
|
|
939
|
+
addBackPK = function () {
|
|
940
|
+
query !== null && query !== void 0 ? query : (query = {});
|
|
941
|
+
query[primaryKey] = removedPkValue_1;
|
|
942
|
+
};
|
|
943
|
+
delete query[primaryKey];
|
|
944
|
+
console.log('query', query, 'primaryKey', primaryKey, 'removedPkValue', removedPkValue_1);
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
console.log('query', query);
|
|
948
|
+
}
|
|
949
|
+
try {
|
|
950
|
+
console.groupCollapsed('%c API: (' + requestMethod + ') Request Query for (' + operatingTable + ') is about to fire, will return with promise!', 'color: #A020F0');
|
|
951
|
+
console.log(this.request);
|
|
952
|
+
console.log('%c If this is the first request for this datatype; thus the value being set is currently undefined, please remember to update the state to null.', 'color: #A020F0');
|
|
953
|
+
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');
|
|
954
|
+
console.trace();
|
|
955
|
+
console.groupEnd();
|
|
956
|
+
this.runLifecycleHooks("beforeExecution", {
|
|
957
|
+
config: this.config,
|
|
958
|
+
request: this.request
|
|
959
|
+
});
|
|
960
|
+
axiosActiveRequest = (_e = axios)[requestMethod.toLowerCase()].apply(_e, __spreadArray([restRequestUri], (function () {
|
|
961
|
+
var convert = function (data) {
|
|
962
|
+
return convertForRequestBody(data, fullTableList, C6, function (message) { return toast.error(message, toastOptions); });
|
|
963
|
+
};
|
|
964
|
+
var baseConfig = {
|
|
965
|
+
withCredentials: withCredentials,
|
|
966
|
+
};
|
|
967
|
+
switch (requestMethod) {
|
|
968
|
+
case GET:
|
|
969
|
+
return [__assign(__assign({}, baseConfig), { params: query })];
|
|
970
|
+
case POST:
|
|
971
|
+
if (dataInsertMultipleRows !== undefined) {
|
|
972
|
+
return [
|
|
973
|
+
dataInsertMultipleRows.map(convert),
|
|
974
|
+
baseConfig
|
|
975
|
+
];
|
|
976
|
+
}
|
|
977
|
+
return [convert(query), baseConfig];
|
|
978
|
+
case PUT:
|
|
979
|
+
return [convert(query), baseConfig];
|
|
980
|
+
case DELETE:
|
|
981
|
+
return [__assign(__assign({}, baseConfig), { data: convert(query) })];
|
|
982
|
+
default:
|
|
983
|
+
throw new Error("The request method (".concat(requestMethod, ") was not recognized."));
|
|
984
|
+
}
|
|
985
|
+
})(), false));
|
|
986
|
+
if (cachingConfirmed) {
|
|
987
|
+
// push to cache so we do not repeat the request
|
|
988
|
+
apiRequestCache.push({
|
|
989
|
+
requestArgumentsSerialized: querySerialized,
|
|
990
|
+
request: axiosActiveRequest
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
// todo - wip verify this works
|
|
994
|
+
// we had removed the value from the request to add to the URI.
|
|
995
|
+
addBackPK === null || addBackPK === void 0 ? void 0 : addBackPK(); // adding back so post-processing methods work
|
|
996
|
+
// returning the promise with this then is important for tests. todo - we could make that optional.
|
|
997
|
+
// https://rapidapi.com/guides/axios-async-await
|
|
998
|
+
return [2 /*return*/, axiosActiveRequest.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
999
|
+
var cacheIndex, callback, responseData_1, dependencies_1, fetchReferences_1, apiRequestPromises, _loop_1, _a, _b, _c, _i, tableToFetch;
|
|
1000
|
+
var _this = this;
|
|
1001
|
+
var _d, _e, _f, _g, _h, _j, _k;
|
|
1002
|
+
return __generator(this, function (_l) {
|
|
1003
|
+
switch (_l.label) {
|
|
1004
|
+
case 0:
|
|
1005
|
+
// noinspection SuspiciousTypeOfGuard
|
|
1006
|
+
if (typeof response.data === 'string') {
|
|
1007
|
+
if (isTest) {
|
|
1008
|
+
console.trace();
|
|
1009
|
+
throw new Error('The response data was a string this typically indicated html was sent. Make sure all cookies (' + JSON.stringify(response.config.headers) + ') needed are present! (' + response.data + ')');
|
|
1010
|
+
}
|
|
1011
|
+
return [2 /*return*/, Promise.reject(response)];
|
|
1012
|
+
}
|
|
1013
|
+
if (cachingConfirmed) {
|
|
1014
|
+
cacheIndex = apiRequestCache.findIndex(function (cache) { return cache.requestArgumentsSerialized === querySerialized; });
|
|
1015
|
+
apiRequestCache[cacheIndex].final = false === returnGetNextPageFunction;
|
|
1016
|
+
// only cache get method requests
|
|
1017
|
+
apiRequestCache[cacheIndex].response = response;
|
|
1018
|
+
}
|
|
1019
|
+
this.runLifecycleHooks("afterExecution", {
|
|
1020
|
+
config: this.config,
|
|
1021
|
+
request: this.request,
|
|
1022
|
+
response: response
|
|
1023
|
+
});
|
|
1024
|
+
// todo - this feels dumb now, but i digress
|
|
1025
|
+
apiResponse = TestRestfulResponse(response, success, error);
|
|
1026
|
+
if (false === apiResponse) {
|
|
1027
|
+
if (debug && isDevelopment) {
|
|
1028
|
+
toast.warning("DEVS: TestRestfulResponse returned false for (" + operatingTable + ").", toastOptionsDevs);
|
|
1029
|
+
}
|
|
1030
|
+
return [2 /*return*/, response];
|
|
1031
|
+
}
|
|
1032
|
+
callback = function () { return _this.runLifecycleHooks("afterCommit", {
|
|
1033
|
+
config: _this.config,
|
|
1034
|
+
request: _this.request,
|
|
1035
|
+
response: response
|
|
1036
|
+
}); };
|
|
1037
|
+
if (undefined !== reactBootstrap && response) {
|
|
1038
|
+
switch (requestMethod) {
|
|
1039
|
+
case GET:
|
|
1040
|
+
reactBootstrap.updateRestfulObjectArrays({
|
|
1041
|
+
dataOrCallback: Array.isArray(response.data.rest) ? response.data.rest : [response.data.rest],
|
|
1042
|
+
stateKey: this.config.restModel.TABLE_NAME,
|
|
1043
|
+
uniqueObjectId: this.config.restModel.PRIMARY_SHORT,
|
|
1044
|
+
callback: callback
|
|
1045
|
+
});
|
|
1046
|
+
break;
|
|
1047
|
+
case POST:
|
|
1048
|
+
this.postState(response, this.request, callback);
|
|
1049
|
+
break;
|
|
1050
|
+
case PUT:
|
|
1051
|
+
this.putState(response, this.request, callback);
|
|
1052
|
+
break;
|
|
1053
|
+
case DELETE:
|
|
1054
|
+
this.deleteState(response, this.request, callback);
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
callback();
|
|
1060
|
+
}
|
|
1061
|
+
if (!(C6.GET === requestMethod)) return [3 /*break*/, 6];
|
|
1062
|
+
responseData_1 = response.data;
|
|
1063
|
+
returnGetNextPageFunction = 1 !== ((_d = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _d === void 0 ? void 0 : _d[C6.LIMIT]) &&
|
|
1064
|
+
((_e = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _e === void 0 ? void 0 : _e[C6.LIMIT]) === responseData_1.rest.length;
|
|
1065
|
+
if (false === isTest || true === isVerbose) {
|
|
1066
|
+
console.groupCollapsed('%c API: Response (' + requestMethod + ' ' + tableName + ') returned length (' + ((_f = responseData_1.rest) === null || _f === void 0 ? void 0 : _f.length) + ') of possible (' + ((_g = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _g === void 0 ? void 0 : _g[C6.LIMIT]) + ') limit!', 'color: #0c0');
|
|
1067
|
+
console.log('%c ' + requestMethod + ' ' + tableName, 'color: #0c0');
|
|
1068
|
+
console.log('%c Request Data (note you may see the success and/or error prompt):', 'color: #0c0', this.request);
|
|
1069
|
+
console.log('%c Response Data:', 'color: #0c0', responseData_1.rest);
|
|
1070
|
+
console.log('%c Will return get next page function:' + (1 !== ((_h = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _h === void 0 ? void 0 : _h[C6.LIMIT]) ? '' : ' (Will not return with explicit limit 1 set)'), 'color: #0c0', true === returnGetNextPageFunction);
|
|
1071
|
+
console.trace();
|
|
1072
|
+
console.groupEnd();
|
|
1073
|
+
}
|
|
1074
|
+
if (false === returnGetNextPageFunction
|
|
1075
|
+
&& true === debug
|
|
1076
|
+
&& isDevelopment) {
|
|
1077
|
+
toast.success("DEVS: Response returned length (" + ((_j = responseData_1.rest) === null || _j === void 0 ? void 0 : _j.length) + ") less than limit (" + ((_k = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _k === void 0 ? void 0 : _k[C6.LIMIT]) + ").", toastOptionsDevs);
|
|
1078
|
+
}
|
|
1079
|
+
if (!(fetchDependencies
|
|
1080
|
+
&& 'number' === typeof fetchDependencies
|
|
1081
|
+
&& responseData_1.rest.length > 0)) return [3 /*break*/, 6];
|
|
1082
|
+
console.groupCollapsed('%c API: Fetch Dependencies segment (' + requestMethod + ' ' + tableName + ')'
|
|
1083
|
+
+ (fetchDependencies & eFetchDependencies.CHILDREN ? ' | (CHILDREN|REFERENCED) ' : '')
|
|
1084
|
+
+ (fetchDependencies & eFetchDependencies.PARENTS ? ' | (PARENTS|REFERENCED_BY)' : '')
|
|
1085
|
+
+ (fetchDependencies & eFetchDependencies.C6ENTITY ? ' | (C6ENTITY)' : '')
|
|
1086
|
+
+ (fetchDependencies & eFetchDependencies.RECURSIVE ? ' | (RECURSIVE)' : ''), 'color: #33ccff');
|
|
1087
|
+
console.groupCollapsed('Collapsed JS Trace');
|
|
1088
|
+
console.trace(); // hidden in collapsed group
|
|
1089
|
+
console.groupEnd();
|
|
1090
|
+
dependencies_1 = {};
|
|
1091
|
+
if (fetchDependencies & eFetchDependencies.C6ENTITY) {
|
|
1092
|
+
dependencies_1 = operatingTable.endsWith("carbon_carbons")
|
|
1093
|
+
? __assign(__assign({}, fetchDependencies & eFetchDependencies.CHILDREN // REFERENCED === CHILDREN
|
|
1094
|
+
? C6.TABLES[operatingTable].TABLE_REFERENCED_BY
|
|
1095
|
+
: {}), fetchDependencies & eFetchDependencies.PARENTS // REFERENCES === PARENTS
|
|
1096
|
+
? C6.TABLES[operatingTable].TABLE_REFERENCES
|
|
1097
|
+
: {}) : __assign(__assign({}, fetchDependencies & eFetchDependencies.CHILDREN // REFERENCED === CHILDREN
|
|
1098
|
+
? __assign(__assign({}, Object.keys(C6.TABLES[operatingTable].TABLE_REFERENCES).reduce(function (accumulator, columnName) {
|
|
1099
|
+
if (!C6.TABLES[operatingTable].PRIMARY_SHORT.includes(columnName)) {
|
|
1100
|
+
accumulator[columnName] = C6.TABLES[operatingTable].TABLE_REFERENCES[columnName];
|
|
1101
|
+
}
|
|
1102
|
+
return accumulator;
|
|
1103
|
+
}, {})), C6.TABLES[operatingTable].TABLE_REFERENCED_BY // it is unlikely that a C6 table will have any TABLE_REFERENCED_BY
|
|
1104
|
+
) : {}), fetchDependencies & eFetchDependencies.PARENTS // REFERENCES === PARENTS
|
|
1105
|
+
? C6.TABLES[operatingTable].PRIMARY_SHORT.reduce(function (accumulator, primaryKey) {
|
|
1106
|
+
if (primaryKey in C6.TABLES[operatingTable].TABLE_REFERENCES) {
|
|
1107
|
+
accumulator[primaryKey] = C6.TABLES[operatingTable].TABLE_REFERENCES[primaryKey];
|
|
1108
|
+
}
|
|
1109
|
+
return accumulator;
|
|
1110
|
+
}, {})
|
|
1111
|
+
: {});
|
|
1112
|
+
}
|
|
1113
|
+
else {
|
|
1114
|
+
// this is the natural mysql context
|
|
1115
|
+
dependencies_1 = __assign(__assign({}, fetchDependencies & eFetchDependencies.REFERENCED // REFERENCED === CHILDREN
|
|
1116
|
+
? C6.TABLES[operatingTable].TABLE_REFERENCED_BY
|
|
1117
|
+
: {}), fetchDependencies & eFetchDependencies.REFERENCES // REFERENCES === PARENTS
|
|
1118
|
+
? C6.TABLES[operatingTable].TABLE_REFERENCES
|
|
1119
|
+
: {});
|
|
1120
|
+
}
|
|
1121
|
+
fetchReferences_1 = {};
|
|
1122
|
+
apiRequestPromises = [];
|
|
1123
|
+
console.log('%c Dependencies', 'color: #005555', dependencies_1);
|
|
1124
|
+
Object.keys(dependencies_1)
|
|
1125
|
+
.forEach(function (column) { return dependencies_1[column]
|
|
1126
|
+
.forEach(function (constraint) {
|
|
1127
|
+
var _a, _b, _c, _d;
|
|
1128
|
+
var _e, _f, _g;
|
|
1129
|
+
var columnValues = (_b = (_a = responseData_1.rest[column]) !== null && _a !== void 0 ? _a : responseData_1.rest.map(function (row) {
|
|
1130
|
+
if (operatingTable.endsWith("carbons")
|
|
1131
|
+
&& 'entity_tag' in row
|
|
1132
|
+
&& !constraint.TABLE.endsWith(row['entity_tag'].split('\\').pop().toLowerCase())) {
|
|
1133
|
+
return false; // map
|
|
1134
|
+
}
|
|
1135
|
+
if (!(column in row)) {
|
|
1136
|
+
return false;
|
|
1137
|
+
}
|
|
1138
|
+
// todo - row[column] is a FK value, we should optionally remove values that are already in state
|
|
1139
|
+
// this could be any column in the table constraint.TABLE, not just the primary key
|
|
1140
|
+
return row[column];
|
|
1141
|
+
}).filter(function (n) { return n; })) !== null && _b !== void 0 ? _b : [];
|
|
1142
|
+
if (columnValues.length === 0) {
|
|
1143
|
+
return; // forEach
|
|
1144
|
+
}
|
|
1145
|
+
(_c = fetchReferences_1[_e = constraint.TABLE]) !== null && _c !== void 0 ? _c : (fetchReferences_1[_e] = {});
|
|
1146
|
+
(_d = (_f = fetchReferences_1[constraint.TABLE])[_g = constraint.COLUMN]) !== null && _d !== void 0 ? _d : (_f[_g] = []);
|
|
1147
|
+
fetchReferences_1[constraint.TABLE][constraint.COLUMN].push(columnValues);
|
|
1148
|
+
}); });
|
|
1149
|
+
console.log('fetchReferences', fetchReferences_1);
|
|
1150
|
+
_loop_1 = function (tableToFetch) {
|
|
1151
|
+
var referencesTables, shouldContinue, fetchTable, RestApi, nextFetchDependencies;
|
|
1152
|
+
var _m;
|
|
1153
|
+
return __generator(this, function (_o) {
|
|
1154
|
+
switch (_o.label) {
|
|
1155
|
+
case 0:
|
|
1156
|
+
if (fetchDependencies & eFetchDependencies.C6ENTITY
|
|
1157
|
+
&& 'string' === typeof tableName
|
|
1158
|
+
&& tableName.endsWith("carbon_carbons")) {
|
|
1159
|
+
referencesTables = responseData_1.rest.reduce(function (accumulator, row) {
|
|
1160
|
+
if ('entity_tag' in row && !accumulator.includes(row['entity_tag'])) {
|
|
1161
|
+
accumulator.push(row['entity_tag']);
|
|
1162
|
+
}
|
|
1163
|
+
return accumulator;
|
|
1164
|
+
}, []).map(function (entityTag) { return entityTag.split('\\').pop().toLowerCase(); });
|
|
1165
|
+
shouldContinue = referencesTables.find(function (referencesTable) { return tableToFetch.endsWith(referencesTable); });
|
|
1166
|
+
if (!shouldContinue) {
|
|
1167
|
+
console.log('%c C6ENTITY: The constraintTableName (' + tableToFetch + ') did not end with any value in referencesTables', 'color: #c00', referencesTables);
|
|
1168
|
+
return [2 /*return*/, "continue"];
|
|
1169
|
+
}
|
|
1170
|
+
console.log('%c C6ENTITY: The constraintTableName (' + tableToFetch + ') will be fetched.', 'color: #0c0');
|
|
1171
|
+
}
|
|
1172
|
+
return [4 /*yield*/, C6.IMPORT(tableToFetch)];
|
|
1173
|
+
case 1:
|
|
1174
|
+
fetchTable = _o.sent();
|
|
1175
|
+
RestApi = fetchTable.default;
|
|
1176
|
+
console.log('%c Fetch Dependencies will select (' + tableToFetch + ') using GET request', 'color: #33ccff');
|
|
1177
|
+
nextFetchDependencies = eFetchDependencies.NONE;
|
|
1178
|
+
if (fetchDependencies & eFetchDependencies.RECURSIVE) {
|
|
1179
|
+
if (fetchDependencies & eFetchDependencies.ALL) {
|
|
1180
|
+
throw Error('Recursive fetch dependencies with both PARENT and CHILD reference will result in an infin1ite loop. As there is not real ending condition, this is not supported.');
|
|
1181
|
+
}
|
|
1182
|
+
nextFetchDependencies = fetchDependencies;
|
|
1183
|
+
}
|
|
1184
|
+
else if (fetchDependencies & eFetchDependencies.C6ENTITY) {
|
|
1185
|
+
if (tableToFetch === "carbon_carbons") {
|
|
1186
|
+
nextFetchDependencies = fetchDependencies;
|
|
1187
|
+
}
|
|
1188
|
+
else {
|
|
1189
|
+
nextFetchDependencies = fetchDependencies ^ eFetchDependencies.C6ENTITY;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
console.log('fetchReferences', fetchReferences_1[tableToFetch], "Current fetchDependencies for (" + operatingTable + "):", fetchDependencies, "New fetchDependencies for (" + tableToFetch + "): ", nextFetchDependencies);
|
|
1193
|
+
// todo - filter out ids that exist in state?!? note - remember that this does not necessarily mean the pk, but only known is its an FK to somewhere
|
|
1194
|
+
// it not certain that they are using carbons' entities either
|
|
1195
|
+
// this is a dynamic call to the rest api, any generated table may resolve with (RestApi)
|
|
1196
|
+
// todo - using value to avoid joins.... but. maybe this should be a parameterizable option -- think race conditions; its safer to join
|
|
1197
|
+
apiRequestPromises.push(RestApi.Get((_m = {},
|
|
1198
|
+
_m[C6.WHERE] = {
|
|
1199
|
+
0: Object.keys(fetchReferences_1[tableToFetch]).reduce(function (sum, column) {
|
|
1200
|
+
fetchReferences_1[tableToFetch][column] = fetchReferences_1[tableToFetch][column].flat(Infinity);
|
|
1201
|
+
if (0 === fetchReferences_1[tableToFetch][column].length) {
|
|
1202
|
+
console.warn('The column (' + column + ') was not found in the response data. We will not fetch.', responseData_1);
|
|
1203
|
+
return false;
|
|
1204
|
+
}
|
|
1205
|
+
sum[column] = fetchReferences_1[tableToFetch][column].length === 1
|
|
1206
|
+
? fetchReferences_1[tableToFetch][column][0]
|
|
1207
|
+
: [
|
|
1208
|
+
C6.IN, fetchReferences_1[tableToFetch][column]
|
|
1209
|
+
];
|
|
1210
|
+
return sum;
|
|
1211
|
+
}, {})
|
|
1212
|
+
},
|
|
1213
|
+
_m.fetchDependencies = nextFetchDependencies,
|
|
1214
|
+
_m)));
|
|
1215
|
+
return [2 /*return*/];
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
};
|
|
1219
|
+
_a = fetchReferences_1;
|
|
1220
|
+
_b = [];
|
|
1221
|
+
for (_c in _a)
|
|
1222
|
+
_b.push(_c);
|
|
1223
|
+
_i = 0;
|
|
1224
|
+
_l.label = 1;
|
|
1225
|
+
case 1:
|
|
1226
|
+
if (!(_i < _b.length)) return [3 /*break*/, 4];
|
|
1227
|
+
_c = _b[_i];
|
|
1228
|
+
if (!(_c in _a)) return [3 /*break*/, 3];
|
|
1229
|
+
tableToFetch = _c;
|
|
1230
|
+
return [5 /*yield**/, _loop_1(tableToFetch)];
|
|
1231
|
+
case 2:
|
|
1232
|
+
_l.sent();
|
|
1233
|
+
_l.label = 3;
|
|
1234
|
+
case 3:
|
|
1235
|
+
_i++;
|
|
1236
|
+
return [3 /*break*/, 1];
|
|
1237
|
+
case 4:
|
|
1238
|
+
console.groupEnd();
|
|
1239
|
+
return [4 /*yield*/, Promise.all(apiRequestPromises)];
|
|
1240
|
+
case 5:
|
|
1241
|
+
_l.sent();
|
|
1242
|
+
apiRequestPromises.map(function (promise) { return __awaiter(_this, void 0, void 0, function () {
|
|
1243
|
+
var _a, _b;
|
|
1244
|
+
return __generator(this, function (_c) {
|
|
1245
|
+
switch (_c.label) {
|
|
1246
|
+
case 0:
|
|
1247
|
+
if (!Array.isArray(this.request.fetchDependencies)) {
|
|
1248
|
+
// to reassign value we must ref the root
|
|
1249
|
+
this.request.fetchDependencies = [];
|
|
1250
|
+
}
|
|
1251
|
+
_b = (_a = this.request.fetchDependencies).push;
|
|
1252
|
+
return [4 /*yield*/, promise];
|
|
1253
|
+
case 1:
|
|
1254
|
+
_b.apply(_a, [_c.sent()]);
|
|
1255
|
+
return [2 /*return*/];
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
}); });
|
|
1259
|
+
_l.label = 6;
|
|
1260
|
+
case 6:
|
|
1261
|
+
if (debug && isDevelopment) {
|
|
1262
|
+
toast.success("DEVS: (" + requestMethod + ") request complete.", toastOptionsDevs);
|
|
1263
|
+
}
|
|
1264
|
+
return [2 /*return*/, response];
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
}); })];
|
|
1268
|
+
}
|
|
1269
|
+
catch (throwableError) {
|
|
1270
|
+
if (isTest) {
|
|
1271
|
+
throw new Error(JSON.stringify(throwableError));
|
|
1272
|
+
}
|
|
1273
|
+
console.groupCollapsed('%c API: An error occurred in the try catch block. returning null!', 'color: #ff0000');
|
|
1274
|
+
console.log('%c ' + requestMethod + ' ' + tableName, 'color: #A020F0');
|
|
1275
|
+
console.warn(throwableError);
|
|
1276
|
+
console.trace();
|
|
1277
|
+
console.groupEnd();
|
|
1278
|
+
TestRestfulResponse(throwableError, success, error);
|
|
1279
|
+
return [2 /*return*/, null];
|
|
1280
|
+
}
|
|
1281
|
+
return [2 /*return*/];
|
|
1282
|
+
});
|
|
1283
|
+
}); };
|
|
1284
|
+
return [4 /*yield*/, apiRequest()];
|
|
832
1285
|
case 2: return [2 /*return*/, _b.sent()];
|
|
833
1286
|
}
|
|
834
1287
|
});
|
|
@@ -1097,5 +1550,5 @@ function onError(message) {
|
|
|
1097
1550
|
toast.error(message, isDevelopment ? toastOptionsDevs : toastOptions);
|
|
1098
1551
|
}
|
|
1099
1552
|
|
|
1100
|
-
export { C6Constants, DELETE, Executor, GET, HttpExecutor, POST, PUT, SqlExecutor, TestRestfulResponse, apiRequestCache, axiosInstance, buildAggregateField, buildBooleanJoinedConditions, buildSelectQuery, checkAllRequestsComplete, checkCache, clearCache, convertForRequestBody, determineRuntimeJsType, eFetchDependencies, error, getEnvVar, getPrimaryKeyTypes, group, info, isDevelopment as isLocal, isNode,
|
|
1553
|
+
export { C6Constants, DELETE, Executor, GET, HttpExecutor, POST, PUT, SqlExecutor, TestRestfulResponse, apiRequestCache, axiosInstance, buildAggregateField, buildBooleanJoinedConditions, buildSelectQuery, checkAllRequestsComplete, checkCache, clearCache, convertForRequestBody, determineRuntimeJsType, eFetchDependencies, error, getEnvVar, getPrimaryKeyTypes, group, info, isDevelopment as isLocal, isNode, isTest, isVerbose, onError, onSuccess, removeInvalidKeys, removePrefixIfExists, restOrm, restRequest, sortAndSerializeQueryObject, timeout, toastOptions, toastOptionsDevs, userCustomClearCache, warn };
|
|
1101
1554
|
//# sourceMappingURL=index.esm.js.map
|